mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-upf.git
synced 2025-10-23 08:12:03 +00:00
nft: ensure to assign rule id only once
Make sure an assigned id is not overwritten. So far this function was guaranteed to be called only once. But I would like to allow getting the nftables ruleset string more than once in a future patch. Prepare that. Change-Id: I4e8c48c01fb2f5d4cfd223fe03abbf15b1a55670
This commit is contained in:
@@ -42,6 +42,7 @@ struct upf_nft_tunmap_desc {
|
||||
struct osmo_sockaddr gtp_remote_addr;
|
||||
uint32_t remote_teid;
|
||||
} core;
|
||||
/* id as in ruleset name 'tunmap<id>'. If zero, no id has been assigned yet. */
|
||||
uint32_t id;
|
||||
};
|
||||
|
||||
|
@@ -215,8 +215,12 @@ int upf_nft_tunmap_create(struct upf_nft_tunmap_desc *tunmap)
|
||||
struct upf_nft_args args;
|
||||
|
||||
/* Give this tunnel mapping a new id, returned to the caller so that the tunnel mapping can be deleted later */
|
||||
g_upf->nft.next_id_state++;
|
||||
tunmap->id = g_upf->nft.next_id_state;
|
||||
if (!tunmap->id) {
|
||||
g_upf->nft.next_id_state++;
|
||||
if (!g_upf->nft.next_id_state)
|
||||
g_upf->nft.next_id_state++;
|
||||
tunmap->id = g_upf->nft.next_id_state;
|
||||
}
|
||||
|
||||
upf_nft_args_from_tunmap_desc(&args, tunmap);
|
||||
return upf_nft_run(upf_nft_ruleset_tunmap_create_c(OTC_SELECT, &args));
|
||||
|
Reference in New Issue
Block a user