gerrit-log
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
February 2023
- 1 participants
- 2601 discussions
[M] Change in osmo-upf[master]: cosmetic: rename g_upf->gtp to tunend, ->nft to tunmap
by neels 24 Feb '23
by neels 24 Feb '23
24 Feb '23
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-upf/+/31479 )
Change subject: cosmetic: rename g_upf->gtp to tunend, ->nft to tunmap
......................................................................
cosmetic: rename g_upf->gtp to tunend, ->nft to tunmap
Upcoming patch I8eae5b53c563400ddfded264678d9cfb28b6f737 will introduce
a g_upf->gtp sub struct for more generally GTP related things (local
TEID assignment).
Change-Id: I74df838af50f38604e2ff06cac0af11ccfdab386
---
M include/osmocom/upf/upf.h
M src/osmo-upf/up_gtp_action.c
M src/osmo-upf/upf.c
M src/osmo-upf/upf_gtp.c
M src/osmo-upf/upf_gtpu_echo.c
M src/osmo-upf/upf_nft.c
M src/osmo-upf/upf_vty.c
7 files changed, 76 insertions(+), 63 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-upf refs/changes/79/31479/1
diff --git a/include/osmocom/upf/upf.h b/include/osmocom/upf/upf.h
index 2e80abe..71364d4 100644
--- a/include/osmocom/upf/upf.h
+++ b/include/osmocom/upf/upf.h
@@ -68,7 +68,7 @@
struct tunend_vty_cfg {
/* list of struct tunend_vty_cfg_dev, GTP devices as in the config file. The actual GTP devices in use are in
- * g_upf->gtp.devs. */
+ * g_upf->tunend.devs. */
struct llist_head devs;
};
@@ -101,7 +101,7 @@
int32_t genl_id;
uint8_t recovery_count;
- } gtp;
+ } tunend;
/* Tunnel forwarding via linux netfilter */
struct {
@@ -113,7 +113,7 @@
int priority_pre;
int priority_post;
uint32_t next_chain_id_state;
- } nft;
+ } tunmap;
struct llist_head netinst;
};
diff --git a/src/osmo-upf/up_gtp_action.c b/src/osmo-upf/up_gtp_action.c
index e7616ac..28dd078 100644
--- a/src/osmo-upf/up_gtp_action.c
+++ b/src/osmo-upf/up_gtp_action.c
@@ -84,7 +84,7 @@
switch (a->kind) {
case UP_GTP_U_TUNEND:
- if (g_upf->gtp.mockup) {
+ if (g_upf->tunend.mockup) {
LOG_UP_GTP_ACTION(a, LOGL_NOTICE, "tunend/mockup active, skipping GTP action %s\n",
enable ? "enable" : "disable");
return 0;
@@ -116,7 +116,7 @@
return 0;
case UP_GTP_U_TUNMAP:
- if (g_upf->nft.mockup) {
+ if (g_upf->tunmap.mockup) {
LOG_UP_GTP_ACTION(a, LOGL_NOTICE, "tunmap/mockup active, skipping nftables ruleset %s\n",
enable ? "enable" : "disable");
return 0;
diff --git a/src/osmo-upf/upf.c b/src/osmo-upf/upf.c
index e26d9c7..b28e55d 100644
--- a/src/osmo-upf/upf.c
+++ b/src/osmo-upf/upf.c
@@ -50,18 +50,18 @@
.local_port = OSMO_PFCP_PORT,
},
},
- .nft = {
+ .tunmap = {
.priority_pre = -300,
.priority_post = 400,
},
- .gtp = {
+ .tunend = {
/* TODO: recovery count state file; use lower byte of current time, poor person's random. */
.recovery_count = time(NULL),
},
};
- INIT_LLIST_HEAD(&g_upf->gtp.vty_cfg.devs);
- INIT_LLIST_HEAD(&g_upf->gtp.devs);
+ INIT_LLIST_HEAD(&g_upf->tunend.vty_cfg.devs);
+ INIT_LLIST_HEAD(&g_upf->tunend.devs);
INIT_LLIST_HEAD(&g_upf->netinst);
}
@@ -89,7 +89,7 @@
int upf_gtp_devs_open()
{
- struct tunend_vty_cfg *c = &g_upf->gtp.vty_cfg;
+ struct tunend_vty_cfg *c = &g_upf->tunend.vty_cfg;
struct tunend_vty_cfg_dev *d;
llist_for_each_entry(d, &c->devs, entry) {
diff --git a/src/osmo-upf/upf_gtp.c b/src/osmo-upf/upf_gtp.c
index cbca882..e2c6d07 100644
--- a/src/osmo-upf/upf_gtp.c
+++ b/src/osmo-upf/upf_gtp.c
@@ -66,7 +66,7 @@
struct upf_gtp_dev *upf_gtp_dev_find_by_name(const char *name)
{
struct upf_gtp_dev *dev;
- llist_for_each_entry(dev, &g_upf->gtp.devs, entry) {
+ llist_for_each_entry(dev, &g_upf->tunend.devs, entry) {
if (!strcmp(name, dev->name))
return dev;
}
@@ -79,7 +79,7 @@
struct upf_gtp_dev *dev_any = NULL;
struct osmo_sockaddr needle = *local_addr;
- llist_for_each_entry(dev, &g_upf->gtp.devs, entry) {
+ llist_for_each_entry(dev, &g_upf->tunend.devs, entry) {
/* To leave the port number out of the cmp, set the needle's port to match */
osmo_sockaddr_set_port(&needle.u.sa, osmo_sockaddr_port(&dev->gtpv1.local_addr.u.sa));
@@ -95,7 +95,7 @@
struct upf_gtp_dev *upf_gtp_dev_first()
{
- return llist_first_entry_or_null(&g_upf->gtp.devs, struct upf_gtp_dev, entry);
+ return llist_first_entry_or_null(&g_upf->tunend.devs, struct upf_gtp_dev, entry);
}
/* Tell the kernel to remove the GTP device. Called implicitly by talloc_free() (see upf_gtp_dev_destruct()). */
@@ -116,7 +116,7 @@
static int upf_gtp_dev_destruct(struct upf_gtp_dev *dev);
-/* Allocate state for one GTP device, add to g_upf->gtp.devs and return the created device. If state for the device of
+/* Allocate state for one GTP device, add to g_upf->tunend.devs and return the created device. If state for the device of
* that name already exists, do nothing and return NULL. */
static struct upf_gtp_dev *upf_gtp_dev_alloc(const char *name, const char *local_addr)
{
@@ -144,7 +144,7 @@
/* Need to add to list before setting up the destructor. A talloc_free() does automagically remove from the
* list. */
- llist_add(&dev->entry, &g_upf->gtp.devs);
+ llist_add(&dev->entry, &g_upf->tunend.devs);
talloc_set_destructor(dev, upf_gtp_dev_destruct);
@@ -163,7 +163,7 @@
}
/* Let's try something to see if talking to the device works. */
errno = 0;
- rc = gtp_list_tunnel(g_upf->gtp.genl_id, g_upf->gtp.nl);
+ rc = gtp_list_tunnel(g_upf->tunend.genl_id, g_upf->tunend.nl);
if (errno)
rc = -errno;
else if (rc)
@@ -192,7 +192,7 @@
int rc;
struct upf_gtp_dev *dev;
- if (g_upf->gtp.mockup) {
+ if (g_upf->tunend.mockup) {
LOGP(DGTP, LOGL_NOTICE, "tunend/mockup active: not opening GTP device '%s'\n", name);
return 0;
}
@@ -265,17 +265,17 @@
void upf_gtp_devs_close()
{
struct upf_gtp_dev *dev;
- while ((dev = llist_first_entry_or_null(&g_upf->gtp.devs, struct upf_gtp_dev, entry)))
+ while ((dev = llist_first_entry_or_null(&g_upf->tunend.devs, struct upf_gtp_dev, entry)))
talloc_free(dev);
}
void upf_gtp_genl_close()
{
- if (!g_upf->gtp.nl)
+ if (!g_upf->tunend.nl)
return;
- genl_socket_close(g_upf->gtp.nl);
- g_upf->gtp.nl = NULL;
- g_upf->gtp.genl_id = -1;
+ genl_socket_close(g_upf->tunend.nl);
+ g_upf->tunend.nl = NULL;
+ g_upf->tunend.genl_id = -1;
LOGP(DGTP, LOGL_NOTICE, "Closed mnl_socket\n");
}
@@ -284,21 +284,21 @@
int upf_gtp_genl_ensure_open()
{
/* Already open? */
- if (g_upf->gtp.nl && g_upf->gtp.genl_id >= 0)
+ if (g_upf->tunend.nl && g_upf->tunend.genl_id >= 0)
return 0;
/* sanity / paranoia: if re-opening, make sure the previous socket is closed */
- if (g_upf->gtp.nl)
+ if (g_upf->tunend.nl)
upf_gtp_genl_close();
- g_upf->gtp.nl = genl_socket_open();
- if (!g_upf->gtp.nl) {
+ g_upf->tunend.nl = genl_socket_open();
+ if (!g_upf->tunend.nl) {
LOGP(DGTP, LOGL_ERROR, "Cannot open mnl_socket: %s\n", strerror(errno));
return -EIO;
}
- g_upf->gtp.genl_id = genl_lookup_family(g_upf->gtp.nl, "gtp");
- if (g_upf->gtp.genl_id < 0) {
+ g_upf->tunend.genl_id = genl_lookup_family(g_upf->tunend.nl, "gtp");
+ if (g_upf->tunend.genl_id < 0) {
LOGP(DGTP, LOGL_ERROR, "genl family 'gtp' not found\n");
return -ENOTSUP;
}
@@ -398,7 +398,7 @@
return -ENOTSUP;
errno = 0;
- rc = gtp_add_tunnel(g_upf->gtp.genl_id, g_upf->gtp.nl, t);
+ rc = gtp_add_tunnel(g_upf->tunend.genl_id, g_upf->tunend.nl, t);
if (errno) {
rc = -errno;
} else if (rc) {
@@ -466,7 +466,7 @@
if (!t)
return -EINVAL;
- rc = gtp_del_tunnel(g_upf->gtp.genl_id, g_upf->gtp.nl, t);
+ rc = gtp_del_tunnel(g_upf->tunend.genl_id, g_upf->tunend.nl, t);
if (rc)
LOG_GTP_TUN(tun, LOGL_ERROR, "Failed to delete tunnel\n");
else
diff --git a/src/osmo-upf/upf_gtpu_echo.c b/src/osmo-upf/upf_gtpu_echo.c
index bc59695..b251a94 100644
--- a/src/osmo-upf/upf_gtpu_echo.c
+++ b/src/osmo-upf/upf_gtpu_echo.c
@@ -84,7 +84,7 @@
/* ECHO RESPONSE shall contain a recovery counter */
msgb_put_u8(msg, GTP1U_IEI_RECOVERY);
- msgb_put_u8(msg, g_upf->gtp.recovery_count);
+ msgb_put_u8(msg, g_upf->tunend.recovery_count);
osmo_store16be(msg->tail - tx_h->data1, &tx_h->length);
diff --git a/src/osmo-upf/upf_nft.c b/src/osmo-upf/upf_nft.c
index 4b5cb43..ed3b921 100644
--- a/src/osmo-upf/upf_nft.c
+++ b/src/osmo-upf/upf_nft.c
@@ -63,18 +63,18 @@
{
int rc;
- if (g_upf->nft.mockup) {
+ if (g_upf->tunmap.mockup) {
LOGP(DNFT, LOGL_NOTICE, "tunmap/mockup active: not running nft ruleset: '%s'\n", ruleset);
return 0;
}
- if (!g_upf->nft.nft_ctx) {
+ if (!g_upf->tunmap.nft_ctx) {
rc = upf_nft_init();
if (rc)
return rc;
}
- rc = nft_run_cmd_from_buffer(g_upf->nft.nft_ctx, ruleset);
+ rc = nft_run_cmd_from_buffer(g_upf->tunmap.nft_ctx, ruleset);
if (rc < 0) {
LOGP(DNFT, LOGL_ERROR, "error running nft ruleset: rc=%d ruleset=%s\n",
rc, osmo_quote_str_c(OTC_SELECT, ruleset, -1));
@@ -90,18 +90,18 @@
int rc;
/* Always set up the default settings, also in mockup mode, so that the VTY reflects sane values */
- if (!g_upf->nft.table_name)
- g_upf->nft.table_name = talloc_strdup(g_upf, "osmo-upf");
+ if (!g_upf->tunmap.table_name)
+ g_upf->tunmap.table_name = talloc_strdup(g_upf, "osmo-upf");
/* When in mockup mode, do not set up nft_ctx and netfilter table */
- if (g_upf->nft.mockup) {
+ if (g_upf->tunmap.mockup) {
LOGP(DNFT, LOGL_NOTICE,
"tunmap/mockup active: not allocating libnftables nft_ctx. FOR TESTING PURPOSES ONLY.\n");
return 0;
}
- g_upf->nft.nft_ctx = nft_ctx_new(NFT_CTX_DEFAULT);
- if (!g_upf->nft.nft_ctx) {
+ g_upf->tunmap.nft_ctx = nft_ctx_new(NFT_CTX_DEFAULT);
+ if (!g_upf->tunmap.nft_ctx) {
LOGP(DNFT, LOGL_ERROR, "cannot allocate libnftables nft_ctx\n");
return -EIO;
}
@@ -109,14 +109,14 @@
rc = upf_nft_run(upf_nft_tunmap_get_table_init_str(OTC_SELECT));
if (rc) {
LOGP(DNFT, LOGL_ERROR, "Failed to create nft table %s\n",
- osmo_quote_str_c(OTC_SELECT, g_upf->nft.table_name, -1));
+ osmo_quote_str_c(OTC_SELECT, g_upf->tunmap.table_name, -1));
return rc;
}
- LOGP(DNFT, LOGL_NOTICE, "Created nft table %s\n", osmo_quote_str_c(OTC_SELECT, g_upf->nft.table_name, -1));
+ LOGP(DNFT, LOGL_NOTICE, "Created nft table %s\n", osmo_quote_str_c(OTC_SELECT, g_upf->tunmap.table_name, -1));
rc = upf_nft_run(upf_nft_tunmap_get_vmap_init_str(OTC_SELECT));
if (rc) {
- LOGP(DNFT, LOGL_ERROR, "Failed to initialize nft verdict map in table %s\n", g_upf->nft.table_name);
+ LOGP(DNFT, LOGL_ERROR, "Failed to initialize nft verdict map in table %s\n", g_upf->tunmap.table_name);
return rc;
}
return 0;
@@ -124,10 +124,10 @@
int upf_nft_free()
{
- if (!g_upf->nft.nft_ctx)
+ if (!g_upf->tunmap.nft_ctx)
return 0;
- nft_ctx_free(g_upf->nft.nft_ctx);
- g_upf->nft.nft_ctx = NULL;
+ nft_ctx_free(g_upf->tunmap.nft_ctx);
+ g_upf->tunmap.nft_ctx = NULL;
return 0;
}
@@ -314,7 +314,7 @@
OSMO_ASSERT(osmo_sockaddr_port(&tunmap->core.tun.local.addr.u.sa) == 0);
*args = (struct upf_nft_args){
- .table_name = g_upf->nft.table_name,
+ .table_name = g_upf->tunmap.table_name,
.peer_a = {
.addr_remote = &tunmap->access.tun.remote.addr,
.teid_remote = tunmap->access.tun.remote.teid,
@@ -334,21 +334,21 @@
char *upf_nft_tunmap_get_table_init_str(void *ctx)
{
- return upf_nft_ruleset_table_create(ctx, g_upf->nft.table_name);
+ return upf_nft_ruleset_table_create(ctx, g_upf->tunmap.table_name);
}
char *upf_nft_tunmap_get_vmap_init_str(void *ctx)
{
- return upf_nft_ruleset_vmap_init(ctx, g_upf->nft.table_name, g_upf->nft.priority_pre,
- g_upf->nft.priority_post);
+ return upf_nft_ruleset_vmap_init(ctx, g_upf->tunmap.table_name, g_upf->tunmap.priority_pre,
+ g_upf->tunmap.priority_post);
}
static uint32_t chain_id_next(void)
{
- g_upf->nft.next_chain_id_state++;
- if (!g_upf->nft.next_chain_id_state)
- g_upf->nft.next_chain_id_state++;
- return g_upf->nft.next_chain_id_state;
+ g_upf->tunmap.next_chain_id_state++;
+ if (!g_upf->tunmap.next_chain_id_state)
+ g_upf->tunmap.next_chain_id_state++;
+ return g_upf->tunmap.next_chain_id_state;
}
char *upf_nft_tunmap_get_ruleset_str(void *ctx, struct upf_tunmap *tunmap)
diff --git a/src/osmo-upf/upf_vty.c b/src/osmo-upf/upf_vty.c
index 51bf002..4a76439 100644
--- a/src/osmo-upf/upf_vty.c
+++ b/src/osmo-upf/upf_vty.c
@@ -53,7 +53,7 @@
};
#define pfcp_vty (g_upf->pfcp.vty_cfg)
-#define tunend_vty (g_upf->gtp.vty_cfg)
+#define tunend_vty (g_upf->tunend.vty_cfg)
DEFUN(cfg_pfcp, cfg_pfcp_cmd,
"pfcp",
@@ -102,7 +102,7 @@
struct tunend_vty_cfg_dev *d;
vty_out(vty, "tunend%s", VTY_NEWLINE);
- if (g_upf->gtp.mockup)
+ if (g_upf->tunend.mockup)
vty_out(vty, " mockup%s", VTY_NEWLINE);
llist_for_each_entry(d, &tunend_vty.devs, entry) {
@@ -124,7 +124,7 @@
"mockup",
"don't actually send commands to the GTP kernel module, just return success\n")
{
- g_upf->gtp.mockup = true;
+ g_upf->tunend.mockup = true;
return CMD_SUCCESS;
}
@@ -133,7 +133,7 @@
NO_STR
"operate GTP kernel module normally\n")
{
- g_upf->gtp.mockup = false;
+ g_upf->tunend.mockup = false;
return CMD_SUCCESS;
}
@@ -224,11 +224,11 @@
{
vty_out(vty, "tunmap%s", VTY_NEWLINE);
- if (g_upf->nft.mockup)
+ if (g_upf->tunmap.mockup)
vty_out(vty, " mockup%s", VTY_NEWLINE);
- if (g_upf->nft.table_name && strcmp(g_upf->nft.table_name, "osmo-upf"))
- vty_out(vty, " table-name %s%s", g_upf->nft.table_name, VTY_NEWLINE);
+ if (g_upf->tunmap.table_name && strcmp(g_upf->tunmap.table_name, "osmo-upf"))
+ vty_out(vty, " table-name %s%s", g_upf->tunmap.table_name, VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -237,7 +237,7 @@
"mockup",
"don't actually send rulesets to nftables, just return success\n")
{
- g_upf->nft.mockup = true;
+ g_upf->tunmap.mockup = true;
return CMD_SUCCESS;
}
@@ -246,7 +246,7 @@
NO_STR
"operate nftables rulesets normally\n")
{
- g_upf->nft.mockup = false;
+ g_upf->tunmap.mockup = false;
return CMD_SUCCESS;
}
@@ -258,7 +258,7 @@
" The default table name is \"osmo-upf\".\n"
"nft inet table name\n")
{
- osmo_talloc_replace_string(g_upf, &g_upf->nft.table_name, argv[0]);
+ osmo_talloc_replace_string(g_upf, &g_upf->tunmap.table_name, argv[0]);
return CMD_SUCCESS;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-upf/+/31479
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-upf
Gerrit-Branch: master
Gerrit-Change-Id: I74df838af50f38604e2ff06cac0af11ccfdab386
Gerrit-Change-Number: 31479
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange
1
0
24 Feb '23
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-upf/+/31483 )
Change subject: tunmap: ensure assigned chain_id is unused
......................................................................
tunmap: ensure assigned chain_id is unused
When handing out a chain_id, make sure it is not in use yet.
So far picking a chain_id was of PoC grade quality. As osmo-upf is
approaching production grade, make this waterproof.
So far with inefficient iteration of all sessions; faster lookup follows
in I36a75ec4698cd83558185c1f202400eb53ae8ff6.
Related: OS#5900
Change-Id: I139b46de0bd15185a7a06109d55f7c759755ec81
---
M include/osmocom/upf/upf.h
M src/osmo-upf/upf.c
M src/osmo-upf/upf_nft.c
M tests/unique_ids/unique_ids_test.c
M tests/unique_ids/unique_ids_test.err
5 files changed, 141 insertions(+), 71 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-upf refs/changes/83/31483/1
diff --git a/include/osmocom/upf/upf.h b/include/osmocom/upf/upf.h
index c1dc39a..db73c1f 100644
--- a/include/osmocom/upf/upf.h
+++ b/include/osmocom/upf/upf.h
@@ -141,3 +141,4 @@
void upf_gtp_devs_close();
uint32_t upf_next_local_teid(void);
+uint32_t upf_next_chain_id(void);
diff --git a/src/osmo-upf/upf.c b/src/osmo-upf/upf.c
index b0de925..5dccce9 100644
--- a/src/osmo-upf/upf.c
+++ b/src/osmo-upf/upf.c
@@ -31,6 +31,7 @@
#include <osmocom/upf/up_endpoint.h>
#include <osmocom/upf/up_peer.h>
#include <osmocom/upf/up_session.h>
+#include <osmocom/upf/up_gtp_action.h>
#include <osmocom/upf/upf_gtp.h>
struct g_upf *g_upf = NULL;
@@ -149,3 +150,54 @@
}
return 0;
}
+
+static uint32_t upf_next_chain_id_inc(void)
+{
+ g_upf->tunmap.next_chain_id_state++;
+ if (!g_upf->tunmap.next_chain_id_state)
+ g_upf->tunmap.next_chain_id_state++;
+ return g_upf->tunmap.next_chain_id_state;
+}
+
+/* Return an unused chain_id, or 0 if none is found with sane effort. */
+uint32_t upf_next_chain_id(void)
+{
+ uint32_t sanity;
+
+ /* Make sure the new chain_id is not used anywhere */
+ for (sanity = 2342; sanity; sanity--) {
+ struct up_peer *peer;
+ uint32_t chain_id = upf_next_chain_id_inc();
+ bool taken = false;
+
+ if (!g_upf->pfcp.ep)
+ return chain_id;
+
+ llist_for_each_entry(peer, &g_upf->pfcp.ep->peers, entry) {
+ struct up_session *session;
+ int bkt;
+ hash_for_each(peer->sessions_by_up_seid, bkt, session, node_by_up_seid) {
+ struct up_gtp_action *a;
+ llist_for_each_entry(a, &session->active_gtp_actions, entry) {
+ if (a->kind != UP_GTP_U_TUNMAP)
+ continue;
+ if (a->tunmap.access.chain_id == chain_id
+ || a->tunmap.core.chain_id == chain_id) {
+ taken = true;
+ break;
+ }
+ }
+ if (taken)
+ break;
+ }
+ if (taken)
+ break;
+ }
+
+ if (!taken)
+ return chain_id;
+ }
+
+ /* finding a chain_id became insane, return invalid = 0 */
+ return 0;
+}
diff --git a/src/osmo-upf/upf_nft.c b/src/osmo-upf/upf_nft.c
index e91443b..4401f1e 100644
--- a/src/osmo-upf/upf_nft.c
+++ b/src/osmo-upf/upf_nft.c
@@ -343,23 +343,9 @@
g_upf->tunmap.priority_post);
}
-static uint32_t chain_id_next(void)
-{
- g_upf->tunmap.next_chain_id_state++;
- if (!g_upf->tunmap.next_chain_id_state)
- g_upf->tunmap.next_chain_id_state++;
- return g_upf->tunmap.next_chain_id_state;
-}
-
char *upf_nft_tunmap_get_ruleset_str(void *ctx, struct upf_tunmap *tunmap)
{
struct upf_nft_args args;
-
- if (!tunmap->access.chain_id)
- tunmap->access.chain_id = chain_id_next();
- if (!tunmap->core.chain_id)
- tunmap->core.chain_id = chain_id_next();
-
upf_nft_args_from_tunmap(&args, tunmap);
return upf_nft_ruleset_tunmap_create_c(ctx, &args);
}
@@ -371,8 +357,21 @@
return upf_nft_ruleset_tunmap_delete_c(ctx, &args);
}
+static int upf_nft_tunmap_ensure_chain_id(struct upf_nft_tun *tun)
+{
+ if (tun->chain_id)
+ return 0;
+ tun->chain_id = upf_next_chain_id();
+ if (!tun->chain_id)
+ return -ENOSPC;
+ return 0;
+}
+
int upf_nft_tunmap_create(struct upf_tunmap *tunmap)
{
+ if (upf_nft_tunmap_ensure_chain_id(&tunmap->access)
+ || upf_nft_tunmap_ensure_chain_id(&tunmap->core))
+ return -ENOSPC;
return upf_nft_run(upf_nft_tunmap_get_ruleset_str(OTC_SELECT, tunmap));
}
diff --git a/tests/unique_ids/unique_ids_test.c b/tests/unique_ids/unique_ids_test.c
index c86e8f2..b51f281 100644
--- a/tests/unique_ids/unique_ids_test.c
+++ b/tests/unique_ids/unique_ids_test.c
@@ -346,8 +346,8 @@
log_assert(a->kind == UP_GTP_U_TUNMAP);
log_assert(a->tunmap.core.tun.local.teid == 3);
log_assert(a->tunmap.access.tun.local.teid == 4);
- log_assert_expect_failure(a->tunmap.access.chain_id == 3);
- log_assert_expect_failure(a->tunmap.core.chain_id == 4);
+ log_assert(a->tunmap.access.chain_id == 3);
+ log_assert(a->tunmap.core.chain_id == 4);
log("\n");
log("drop first tunmap (%s)\n", s1->fi->name);
@@ -384,8 +384,8 @@
log_assert(a->kind == UP_GTP_U_TUNMAP);
log_assert(a->tunmap.core.tun.local.teid == 5);
log_assert(a->tunmap.access.tun.local.teid == 6);
- log_assert_expect_failure(a->tunmap.access.chain_id == 5);
- log_assert_expect_failure(a->tunmap.core.chain_id == 6);
+ log_assert(a->tunmap.access.chain_id == 5);
+ log_assert(a->tunmap.core.chain_id == 6);
log("\n");
cleanup();
diff --git a/tests/unique_ids/unique_ids_test.err b/tests/unique_ids/unique_ids_test.err
index dfd57ef..f9ea23a 100644
--- a/tests/unique_ids/unique_ids_test.err
+++ b/tests/unique_ids/unique_ids_test.err
@@ -125,21 +125,21 @@
DSESSION DEBUG up_session(1-2-3-4-0x2){INIT}: enabling: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1
[test override] nft_run_cmd_from_buffer():
-add chain inet osmo-upf tunmap-pre-1;
-add rule inet osmo-upf tunmap-pre-1 ip daddr set 13.14.15.16 meta mark set 1 counter accept;
-add chain inet osmo-upf tunmap-post-1;
-add rule inet osmo-upf tunmap-post-1 ip saddr set 1.1.1.1 @ih,32,32 set 0x103 counter accept;
-add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 : jump tunmap-pre-1 };
-add element inet osmo-upf tunmap-post { 1 : jump tunmap-post-1 };
-add chain inet osmo-upf tunmap-pre-2;
-add rule inet osmo-upf tunmap-pre-2 ip daddr set 5.6.7.8 meta mark set 2 counter accept;
-add chain inet osmo-upf tunmap-post-2;
-add rule inet osmo-upf tunmap-post-2 ip saddr set 1.1.1.1 @ih,32,32 set 0x102 counter accept;
-add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 : jump tunmap-pre-2 };
-add element inet osmo-upf tunmap-post { 2 : jump tunmap-post-2 };
+add chain inet osmo-upf tunmap-pre-3;
+add rule inet osmo-upf tunmap-pre-3 ip daddr set 13.14.15.16 meta mark set 3 counter accept;
+add chain inet osmo-upf tunmap-post-3;
+add rule inet osmo-upf tunmap-post-3 ip saddr set 1.1.1.1 @ih,32,32 set 0x103 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 : jump tunmap-pre-3 };
+add element inet osmo-upf tunmap-post { 3 : jump tunmap-post-3 };
+add chain inet osmo-upf tunmap-pre-4;
+add rule inet osmo-upf tunmap-pre-4 ip daddr set 5.6.7.8 meta mark set 4 counter accept;
+add chain inet osmo-upf tunmap-post-4;
+add rule inet osmo-upf tunmap-post-4 ip saddr set 1.1.1.1 @ih,32,32 set 0x102 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 : jump tunmap-pre-4 };
+add element inet osmo-upf tunmap-post { 4 : jump tunmap-post-4 };
-DNFT DEBUG run nft ruleset: "add chain inet osmo-upf tunmap-pre-1;\nadd rule inet osmo-upf tunmap-pre-1 ip daddr set 13.14.15.16 meta mark set 1 counter accept;\nadd chain inet osmo-upf tunmap-post-1;\nadd rule inet osmo-upf tunmap-post-1 ip saddr set 1.1.1.1 @ih,32,32 set 0x103 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 : jump tunmap-pre-1 };\nadd element inet osmo-upf tunmap-post { 1 : jump tunmap-post-1 };\nadd chain inet osmo-upf tunmap-pre-2;\nadd rule inet osmo-upf tunmap-pre-2 ip daddr set 5.6.7.8 meta mark set 2 counter accept;\nadd chain inet osmo-upf tunmap-post-2;\nadd rule inet osmo-upf tunmap-post-2 ip saddr set 1.1.1.1 @ih,32,32 set 0x102 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 : jump tunmap-pre-2 };\nadd element inet osmo-upf tunmap-post { 2 : jump tunmap-post-2 };\n"
-DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1: Enabled tunmap, nft chain IDs: access--1-> <-2--core
+DNFT DEBUG run nft ruleset: "add chain inet osmo-upf tunmap-pre-3;\nadd rule inet osmo-upf tunmap-pre-3 ip daddr set 13.14.15.16 meta mark set 3 counter accept;\nadd chain inet osmo-upf tunmap-post-3;\nadd rule inet osmo-upf tunmap-post-3 ip saddr set 1.1.1.1 @ih,32,32 set 0x103 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 : jump tunmap-pre-3 };\nadd element inet osmo-upf tunmap-post { 3 : jump tunmap-post-3 };\nadd chain inet osmo-upf tunmap-pre-4;\nadd rule inet osmo-upf tunmap-pre-4 ip daddr set 5.6.7.8 meta mark set 4 counter accept;\nadd chain inet osmo-upf tunmap-post-4;\nadd rule inet osmo-upf tunmap-post-4 ip saddr set 1.1.1.1 @ih,32,32 set 0x102 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 : jump tunmap-pre-4 };\nadd element inet osmo-upf tunmap-post { 4 : jump tunmap-post-4 };\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1: Enabled tunmap, nft chain IDs: access--3-> <-4--core
[test override] PFCP tx:
PFCPv1 SESSION_EST_RESP hdr={seq=0 SEID=0x101} ies={ 'Node ID'=v4:unsupported family 0 'Cause'=Request accepted (success) 'F-SEID'=0x2,v4:1.1.1.1 'Created PDR'={ { 'PDR ID'=1 'F-TEID'=TEID-0x3,v4:1.1.1.1 }, { 'PDR ID'=2 'F-TEID'=TEID-0x4,v4:1.1.1.1 } } }
@@ -158,15 +158,15 @@
state:
| peer up_peer(1-2-3-4) ASSOCIATED
| session[ESTABLISHED]: UP-SEID 0x1; chain_id access=1 core=2; local TEID access=0x2 core=0x1
- | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=1 core=2; local TEID access=0x4 core=0x3
+ | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=3 core=4; local TEID access=0x4 core=0x3
assert(s2->up_seid == 2)
assert(a = llist_first_entry_or_null(&s2->active_gtp_actions, struct up_gtp_action, entry))
assert(a->kind == UP_GTP_U_TUNMAP)
assert(a->tunmap.core.tun.local.teid == 3)
assert(a->tunmap.access.tun.local.teid == 4)
-assert(a->tunmap.access.chain_id == 3) <-- EXPECTED TO FAIL (known error)
-assert(a->tunmap.core.chain_id == 4) <-- EXPECTED TO FAIL (known error)
+assert(a->tunmap.access.chain_id == 3)
+assert(a->tunmap.core.chain_id == 4)
drop first tunmap (up_session(1-2-3-4-0x1))
assert(session)
@@ -206,7 +206,7 @@
state:
| peer up_peer(1-2-3-4) ASSOCIATED
- | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=1 core=2; local TEID access=0x4 core=0x3
+ | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=3 core=4; local TEID access=0x4 core=0x3
assert(up_session_find_by_up_seid(peer, s1_up_seid) == NULL)
@@ -266,7 +266,7 @@
state:
| peer up_peer(1-2-3-4) ASSOCIATED
| session[ESTABLISHED]: UP-SEID 0x1; chain_id access=1 core=2; local TEID access=0x2 core=0x1
- | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=1 core=2; local TEID access=0x4 core=0x3
+ | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=3 core=4; local TEID access=0x4 core=0x3
assert(s3->up_seid == 1)
assert(a = llist_first_entry_or_null(&s3->active_gtp_actions, struct up_gtp_action, entry))
@@ -298,21 +298,21 @@
DSESSION DEBUG up_session(1-2-3-4-0x3){INIT}: enabling: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1
[test override] nft_run_cmd_from_buffer():
-add chain inet osmo-upf tunmap-pre-3;
-add rule inet osmo-upf tunmap-pre-3 ip daddr set 13.14.15.16 meta mark set 3 counter accept;
-add chain inet osmo-upf tunmap-post-3;
-add rule inet osmo-upf tunmap-post-3 ip saddr set 1.1.1.1 @ih,32,32 set 0x107 counter accept;
-add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 : jump tunmap-pre-3 };
-add element inet osmo-upf tunmap-post { 3 : jump tunmap-post-3 };
-add chain inet osmo-upf tunmap-pre-4;
-add rule inet osmo-upf tunmap-pre-4 ip daddr set 5.6.7.8 meta mark set 4 counter accept;
-add chain inet osmo-upf tunmap-post-4;
-add rule inet osmo-upf tunmap-post-4 ip saddr set 1.1.1.1 @ih,32,32 set 0x106 counter accept;
-add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 : jump tunmap-pre-4 };
-add element inet osmo-upf tunmap-post { 4 : jump tunmap-post-4 };
+add chain inet osmo-upf tunmap-pre-5;
+add rule inet osmo-upf tunmap-pre-5 ip daddr set 13.14.15.16 meta mark set 5 counter accept;
+add chain inet osmo-upf tunmap-post-5;
+add rule inet osmo-upf tunmap-post-5 ip saddr set 1.1.1.1 @ih,32,32 set 0x107 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 : jump tunmap-pre-5 };
+add element inet osmo-upf tunmap-post { 5 : jump tunmap-post-5 };
+add chain inet osmo-upf tunmap-pre-6;
+add rule inet osmo-upf tunmap-pre-6 ip daddr set 5.6.7.8 meta mark set 6 counter accept;
+add chain inet osmo-upf tunmap-post-6;
+add rule inet osmo-upf tunmap-post-6 ip saddr set 1.1.1.1 @ih,32,32 set 0x106 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 : jump tunmap-pre-6 };
+add element inet osmo-upf tunmap-post { 6 : jump tunmap-post-6 };
-DNFT DEBUG run nft ruleset: "add chain inet osmo-upf tunmap-pre-3;\nadd rule inet osmo-upf tunmap-pre-3 ip daddr set 13.14.15.16 meta mark set 3 counter accept;\nadd chain inet osmo-upf tunmap-post-3;\nadd rule inet osmo-upf tunmap-post-3 ip saddr set 1.1.1.1 @ih,32,32 set 0x107 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 : jump tunmap-pre-3 };\nadd element inet osmo-upf tunmap-post { 3 : jump tunmap-post-3 };\nadd chain inet osmo-upf tunmap-pre-4;\nadd rule inet osmo-upf tunmap-pre-4 ip daddr set 5.6.7.8 meta mark set 4 counter accept;\nadd chain inet osmo-upf tunmap-post-4;\nadd rule inet osmo-upf tunmap-post-4 ip saddr set 1.1.1.1 @ih,32,32 set 0x106 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 : jump tunmap-pre-4 };\nadd element inet osmo-upf tunmap-post { 4 : jump tunmap-post-4 };\n"
-DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1: Enabled tunmap, nft chain IDs: access--3-> <-4--core
+DNFT DEBUG run nft ruleset: "add chain inet osmo-upf tunmap-pre-5;\nadd rule inet osmo-upf tunmap-pre-5 ip daddr set 13.14.15.16 meta mark set 5 counter accept;\nadd chain inet osmo-upf tunmap-post-5;\nadd rule inet osmo-upf tunmap-post-5 ip saddr set 1.1.1.1 @ih,32,32 set 0x107 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 : jump tunmap-pre-5 };\nadd element inet osmo-upf tunmap-post { 5 : jump tunmap-post-5 };\nadd chain inet osmo-upf tunmap-pre-6;\nadd rule inet osmo-upf tunmap-pre-6 ip daddr set 5.6.7.8 meta mark set 6 counter accept;\nadd chain inet osmo-upf tunmap-post-6;\nadd rule inet osmo-upf tunmap-post-6 ip saddr set 1.1.1.1 @ih,32,32 set 0x106 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 : jump tunmap-pre-6 };\nadd element inet osmo-upf tunmap-post { 6 : jump tunmap-post-6 };\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1: Enabled tunmap, nft chain IDs: access--5-> <-6--core
[test override] PFCP tx:
PFCPv1 SESSION_EST_RESP hdr={seq=0 SEID=0x103} ies={ 'Node ID'=v4:unsupported family 0 'Cause'=Request accepted (success) 'F-SEID'=0x3,v4:1.1.1.1 'Created PDR'={ { 'PDR ID'=1 'F-TEID'=TEID-0x5,v4:1.1.1.1 }, { 'PDR ID'=2 'F-TEID'=TEID-0x6,v4:1.1.1.1 } } }
@@ -330,17 +330,17 @@
state:
| peer up_peer(1-2-3-4) ASSOCIATED
- | session[ESTABLISHED]: UP-SEID 0x3; chain_id access=3 core=4; local TEID access=0x6 core=0x5
+ | session[ESTABLISHED]: UP-SEID 0x3; chain_id access=5 core=6; local TEID access=0x6 core=0x5
| session[ESTABLISHED]: UP-SEID 0x1; chain_id access=1 core=2; local TEID access=0x2 core=0x1
- | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=1 core=2; local TEID access=0x4 core=0x3
+ | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=3 core=4; local TEID access=0x4 core=0x3
assert(s4->up_seid == 3)
assert(a = llist_first_entry_or_null(&s4->active_gtp_actions, struct up_gtp_action, entry))
assert(a->kind == UP_GTP_U_TUNMAP)
assert(a->tunmap.core.tun.local.teid == 5)
assert(a->tunmap.access.tun.local.teid == 6)
-assert(a->tunmap.access.chain_id == 5) <-- EXPECTED TO FAIL (known error)
-assert(a->tunmap.core.chain_id == 6) <-- EXPECTED TO FAIL (known error)
+assert(a->tunmap.access.chain_id == 5)
+assert(a->tunmap.core.chain_id == 6)
DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Terminating (cause = OSMO_FSM_TERM_REGULAR)
DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: Terminating (cause = OSMO_FSM_TERM_PARENT)
@@ -351,16 +351,16 @@
[test override] nft_run_cmd_from_buffer():
delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 };
-delete element inet osmo-upf tunmap-post { 3 };
-delete chain inet osmo-upf tunmap-pre-3;
-delete chain inet osmo-upf tunmap-post-3;
+delete element inet osmo-upf tunmap-post { 5 };
+delete chain inet osmo-upf tunmap-pre-5;
+delete chain inet osmo-upf tunmap-post-5;
delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 };
-delete element inet osmo-upf tunmap-post { 4 };
-delete chain inet osmo-upf tunmap-pre-4;
-delete chain inet osmo-upf tunmap-post-4;
+delete element inet osmo-upf tunmap-post { 6 };
+delete chain inet osmo-upf tunmap-pre-6;
+delete chain inet osmo-upf tunmap-post-6;
-DNFT DEBUG run nft ruleset: "delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 };\ndelete element inet osmo-upf tunmap-post { 3 };\ndelete chain inet osmo-upf tunmap-pre-3;\ndelete chain inet osmo-upf tunmap-post-3;\ndelete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 };\ndelete element inet osmo-upf tunmap-post { 4 };\ndelete chain inet osmo-upf tunmap-pre-4;\ndelete chain inet osmo-upf tunmap-post-4;\n"
-DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1: Disabled tunmap, nft chain IDs: access--3-> <-4--core
+DNFT DEBUG run nft ruleset: "delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 };\ndelete element inet osmo-upf tunmap-post { 5 };\ndelete chain inet osmo-upf tunmap-pre-5;\ndelete chain inet osmo-upf tunmap-post-5;\ndelete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 };\ndelete element inet osmo-upf tunmap-post { 6 };\ndelete chain inet osmo-upf tunmap-pre-6;\ndelete chain inet osmo-upf tunmap-post-6;\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1: Disabled tunmap, nft chain IDs: access--5-> <-6--core
DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: Freeing instance
DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: Deallocated
DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: Terminating (cause = OSMO_FSM_TERM_PARENT)
@@ -391,16 +391,16 @@
[test override] nft_run_cmd_from_buffer():
delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 };
-delete element inet osmo-upf tunmap-post { 1 };
-delete chain inet osmo-upf tunmap-pre-1;
-delete chain inet osmo-upf tunmap-post-1;
+delete element inet osmo-upf tunmap-post { 3 };
+delete chain inet osmo-upf tunmap-pre-3;
+delete chain inet osmo-upf tunmap-post-3;
delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 };
-delete element inet osmo-upf tunmap-post { 2 };
-delete chain inet osmo-upf tunmap-pre-2;
-delete chain inet osmo-upf tunmap-post-2;
+delete element inet osmo-upf tunmap-post { 4 };
+delete chain inet osmo-upf tunmap-pre-4;
+delete chain inet osmo-upf tunmap-post-4;
-DNFT DEBUG run nft ruleset: "delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 };\ndelete element inet osmo-upf tunmap-post { 1 };\ndelete chain inet osmo-upf tunmap-pre-1;\ndelete chain inet osmo-upf tunmap-post-1;\ndelete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 };\ndelete element inet osmo-upf tunmap-post { 2 };\ndelete chain inet osmo-upf tunmap-pre-2;\ndelete chain inet osmo-upf tunmap-post-2;\n"
-DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1: Disabled tunmap, nft chain IDs: access--1-> <-2--core
+DNFT DEBUG run nft ruleset: "delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 };\ndelete element inet osmo-upf tunmap-post { 3 };\ndelete chain inet osmo-upf tunmap-pre-3;\ndelete chain inet osmo-upf tunmap-post-3;\ndelete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 };\ndelete element inet osmo-upf tunmap-post { 4 };\ndelete chain inet osmo-upf tunmap-pre-4;\ndelete chain inet osmo-upf tunmap-post-4;\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1: Disabled tunmap, nft chain IDs: access--3-> <-4--core
DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: Freeing instance
DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: Deallocated
DPEER NOTICE up_peer(1-2-3-4){ASSOCIATED}: Peer removed
--
To view, visit https://gerrit.osmocom.org/c/osmo-upf/+/31483
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-upf
Gerrit-Branch: master
Gerrit-Change-Id: I139b46de0bd15185a7a06109d55f7c759755ec81
Gerrit-Change-Number: 31483
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange
1
0
[M] Change in osmo-upf[master]: scale: tunmap: faster lookup of used nft chain_id
by neels 24 Feb '23
by neels 24 Feb '23
24 Feb '23
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-upf/+/31484 )
Change subject: scale: tunmap: faster lookup of used nft chain_id
......................................................................
scale: tunmap: faster lookup of used nft chain_id
To ensure that an nft chain id for the tunmap nft ruleset is not used,
we so far iterate *all* sessions of *all* peers for every new tunmap
being set up, twice.
Instead, record all up_nft_tun in a hash table. This allows much faster
lookup whether a given chain_id is already in use.
chain_id_test.c shows that the lookup works and functional behavior
remains identical.
Scoping: an nft chain_id must be unique within the nft table. So no
matter which local GTP IP address it belongs to, a chain_id must be
unique within the entire osmo-upf process.
Related: OS#5900
Change-Id: I36a75ec4698cd83558185c1f202400eb53ae8ff6
---
M include/osmocom/upf/up_gtp_action.h
M include/osmocom/upf/upf.h
M include/osmocom/upf/upf_nft.h
M src/osmo-upf/upf.c
M src/osmo-upf/upf_nft.c
5 files changed, 65 insertions(+), 33 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-upf refs/changes/84/31484/1
diff --git a/include/osmocom/upf/up_gtp_action.h b/include/osmocom/upf/up_gtp_action.h
index c47c35c..29d8f68 100644
--- a/include/osmocom/upf/up_gtp_action.h
+++ b/include/osmocom/upf/up_gtp_action.h
@@ -48,6 +48,9 @@
struct llist_head entry;
struct up_session *session;
+ /* entry in hash table up_endpoint->gtp_actions_by_chain_id */
+ struct hlist_node node_by_chain_id;
+
uint16_t pdr_access;
uint16_t pdr_core;
diff --git a/include/osmocom/upf/upf.h b/include/osmocom/upf/upf.h
index db73c1f..0d43785 100644
--- a/include/osmocom/upf/upf.h
+++ b/include/osmocom/upf/upf.h
@@ -28,6 +28,7 @@
#include <osmocom/core/socket.h>
#include <osmocom/core/select.h>
#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/hashtable.h>
struct osmo_tdef;
struct ctrl_handle;
@@ -112,7 +113,10 @@
char *table_name;
int priority_pre;
int priority_post;
+
uint32_t next_chain_id_state;
+ /* fast look up of used nft chain ids */
+ DECLARE_HASHTABLE(nft_tun_by_chain_id, 6);
} tunmap;
struct {
@@ -141,4 +145,4 @@
void upf_gtp_devs_close();
uint32_t upf_next_local_teid(void);
-uint32_t upf_next_chain_id(void);
+uint32_t upf_next_chain_id(struct hlist_node *for_node);
diff --git a/include/osmocom/upf/upf_nft.h b/include/osmocom/upf/upf_nft.h
index be2ec0d..534107c 100644
--- a/include/osmocom/upf/upf_nft.h
+++ b/include/osmocom/upf/upf_nft.h
@@ -25,11 +25,17 @@
#include <stdint.h>
+#include <osmocom/core/hashtable.h>
+
#include <osmocom/upf/upf_tun.h>
struct upf_nft_tun {
struct upf_tun tun;
+
+ /* assigned id for nft ruleset, or 0 if none is assigned. */
uint32_t chain_id;
+ /* hashtable entry for g_upf->tunmap.nft_tun_by_chain_id */
+ struct hlist_node node_by_chain_id;
};
struct upf_tunmap {
diff --git a/src/osmo-upf/upf.c b/src/osmo-upf/upf.c
index 5dccce9..1e5e549 100644
--- a/src/osmo-upf/upf.c
+++ b/src/osmo-upf/upf.c
@@ -66,6 +66,8 @@
INIT_LLIST_HEAD(&g_upf->tunend.vty_cfg.devs);
INIT_LLIST_HEAD(&g_upf->tunend.devs);
INIT_LLIST_HEAD(&g_upf->netinst);
+
+ hash_init(g_upf->tunmap.nft_tun_by_chain_id);
}
int upf_pfcp_init(void)
@@ -160,42 +162,26 @@
}
/* Return an unused chain_id, or 0 if none is found with sane effort. */
-uint32_t upf_next_chain_id(void)
+uint32_t upf_next_chain_id(struct hlist_node *for_node)
{
uint32_t sanity;
/* Make sure the new chain_id is not used anywhere */
for (sanity = 2342; sanity; sanity--) {
- struct up_peer *peer;
uint32_t chain_id = upf_next_chain_id_inc();
bool taken = false;
- if (!g_upf->pfcp.ep)
- return chain_id;
-
- llist_for_each_entry(peer, &g_upf->pfcp.ep->peers, entry) {
- struct up_session *session;
- int bkt;
- hash_for_each(peer->sessions_by_up_seid, bkt, session, node_by_up_seid) {
- struct up_gtp_action *a;
- llist_for_each_entry(a, &session->active_gtp_actions, entry) {
- if (a->kind != UP_GTP_U_TUNMAP)
- continue;
- if (a->tunmap.access.chain_id == chain_id
- || a->tunmap.core.chain_id == chain_id) {
- taken = true;
- break;
- }
- }
- if (taken)
- break;
- }
- if (taken)
- break;
+ struct upf_nft_tun *nft_tun;
+ hash_for_each_possible(g_upf->tunmap.nft_tun_by_chain_id, nft_tun, node_by_chain_id, chain_id) {
+ if (chain_id == nft_tun->chain_id)
+ taken = true;
}
- if (!taken)
+ if (!taken) {
+ /* add entry to hash table for fast lookup of used chain_ids */
+ hash_add(g_upf->tunmap.nft_tun_by_chain_id, for_node, chain_id);
return chain_id;
+ }
}
/* finding a chain_id became insane, return invalid = 0 */
diff --git a/src/osmo-upf/upf_nft.c b/src/osmo-upf/upf_nft.c
index 4401f1e..7ff7421 100644
--- a/src/osmo-upf/upf_nft.c
+++ b/src/osmo-upf/upf_nft.c
@@ -357,25 +357,34 @@
return upf_nft_ruleset_tunmap_delete_c(ctx, &args);
}
-static int upf_nft_tunmap_ensure_chain_id(struct upf_nft_tun *tun)
+static int upf_nft_tunmap_chain_id_get(struct upf_nft_tun *tun)
{
- if (tun->chain_id)
- return 0;
- tun->chain_id = upf_next_chain_id();
+ tun->chain_id = upf_next_chain_id(&tun->node_by_chain_id);
if (!tun->chain_id)
return -ENOSPC;
return 0;
}
+static void upf_nft_tunmap_chain_id_put(struct upf_nft_tun *tun)
+{
+ if (!tun->chain_id)
+ return;
+ hlist_del(&tun->node_by_chain_id);
+}
+
int upf_nft_tunmap_create(struct upf_tunmap *tunmap)
{
- if (upf_nft_tunmap_ensure_chain_id(&tunmap->access)
- || upf_nft_tunmap_ensure_chain_id(&tunmap->core))
+ if (upf_nft_tunmap_chain_id_get(&tunmap->access)
+ || upf_nft_tunmap_chain_id_get(&tunmap->core))
return -ENOSPC;
return upf_nft_run(upf_nft_tunmap_get_ruleset_str(OTC_SELECT, tunmap));
}
int upf_nft_tunmap_delete(struct upf_tunmap *tunmap)
{
- return upf_nft_run(upf_nft_tunmap_get_ruleset_del_str(OTC_SELECT, tunmap));
+ if (upf_nft_run(upf_nft_tunmap_get_ruleset_del_str(OTC_SELECT, tunmap)))
+ return -EIO;
+ upf_nft_tunmap_chain_id_put(&tunmap->access);
+ upf_nft_tunmap_chain_id_put(&tunmap->core);
+ return 0;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-upf/+/31484
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-upf
Gerrit-Branch: master
Gerrit-Change-Id: I36a75ec4698cd83558185c1f202400eb53ae8ff6
Gerrit-Change-Number: 31484
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange
1
0
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-upf/+/31482 )
Change subject: add unique_ids_test.c
......................................................................
add unique_ids_test.c
Verify that skipping used IDs works for:
- PFCP UP-SEID
- GTP local TEID
- chain_id for nft rulesets -- so far expected to fail,
fix follows in I139b46de0bd15185a7a06109d55f7c759755ec81.
Related: OS#5900
Change-Id: I36acff15f22d23ade4d281c2af3eb117dfc10359
---
M configure.ac
M include/osmocom/upf/up_endpoint.h
M include/osmocom/upf/up_session.h
M include/osmocom/upf/upf.h
M src/osmo-upf/up_endpoint.c
M src/osmo-upf/up_peer.c
M src/osmo-upf/up_session.c
M src/osmo-upf/upf.c
M src/osmo-upf/upf_nft.c
M tests/Makefile.am
M tests/testsuite.at
A tests/unique_ids/Makefile.am
A tests/unique_ids/unique_ids_test.c
A tests/unique_ids/unique_ids_test.err
A tests/unique_ids/unique_ids_test.ok
15 files changed, 1,050 insertions(+), 24 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-upf refs/changes/82/31482/1
diff --git a/configure.ac b/configure.ac
index 0108f92..5181131 100644
--- a/configure.ac
+++ b/configure.ac
@@ -203,6 +203,7 @@
src/osmo-pfcp-tool/Makefile
tests/Makefile
tests/atlocal
+ tests/unique_ids/Makefile
doc/Makefile
doc/examples/Makefile
doc/manuals/Makefile
diff --git a/include/osmocom/upf/up_endpoint.h b/include/osmocom/upf/up_endpoint.h
index 58fe01c..ac240cd 100644
--- a/include/osmocom/upf/up_endpoint.h
+++ b/include/osmocom/upf/up_endpoint.h
@@ -41,7 +41,8 @@
uint64_t next_up_seid_state;
};
-struct up_endpoint *up_endpoint_init(void *ctx, const struct osmo_sockaddr *local_addr);
+struct up_endpoint *up_endpoint_alloc(void *ctx, const struct osmo_sockaddr *local_addr);
+int up_endpoint_bind(struct up_endpoint *up_ep);
void up_endpoint_free(struct up_endpoint **ep);
uint64_t up_endpoint_next_up_seid(struct up_endpoint *ep);
diff --git a/include/osmocom/upf/up_session.h b/include/osmocom/upf/up_session.h
index 215a414..c424df9 100644
--- a/include/osmocom/upf/up_session.h
+++ b/include/osmocom/upf/up_session.h
@@ -66,8 +66,7 @@
struct llist_head active_gtp_actions;
};
-struct up_session *up_session_find_or_add(struct up_peer *peer, const struct osmo_pfcp_ie_f_seid *cp_f_seid,
- const struct osmo_pfcp_ie_f_seid *up_f_seid);
+struct up_session *up_session_find_or_add(struct up_peer *peer, const struct osmo_pfcp_ie_f_seid *cp_f_seid);
struct up_session *up_session_find_by_up_seid(struct up_peer *peer, uint64_t up_seid);
struct up_session *up_session_find_by_cp_f_seid(struct up_peer *peer, const struct osmo_pfcp_ie_f_seid *cp_f_seid);
struct up_session *up_session_find_by_local_teid(struct up_peer *peer, uint32_t teid);
diff --git a/include/osmocom/upf/upf.h b/include/osmocom/upf/upf.h
index 041edea..c1dc39a 100644
--- a/include/osmocom/upf/upf.h
+++ b/include/osmocom/upf/upf.h
@@ -134,7 +134,8 @@
void g_upf_alloc(void *ctx);
void upf_vty_init();
-int upf_pfcp_listen();
+int upf_pfcp_init(void);
+int upf_pfcp_listen(void);
int upf_gtp_devs_open();
void upf_gtp_devs_close();
diff --git a/src/osmo-upf/up_endpoint.c b/src/osmo-upf/up_endpoint.c
index 7a2628a..34351a6 100644
--- a/src/osmo-upf/up_endpoint.c
+++ b/src/osmo-upf/up_endpoint.c
@@ -233,9 +233,8 @@
}
}
-struct up_endpoint *up_endpoint_init(void *ctx, const struct osmo_sockaddr *local_addr)
+struct up_endpoint *up_endpoint_alloc(void *ctx, const struct osmo_sockaddr *local_addr)
{
- int rc;
struct osmo_pfcp_endpoint_cfg cfg;
struct up_endpoint *up_ep;
up_ep = talloc_zero(ctx, struct up_endpoint);
@@ -252,14 +251,16 @@
up_ep->pfcp_ep = osmo_pfcp_endpoint_create(up_ep, &cfg);
OSMO_ASSERT(up_ep->pfcp_ep);
- rc = osmo_pfcp_endpoint_bind(up_ep->pfcp_ep);
- if (rc) {
- talloc_free(up_ep);
- return NULL;
- }
return up_ep;
}
+int up_endpoint_bind(struct up_endpoint *up_ep)
+{
+ OSMO_ASSERT(up_ep);
+ OSMO_ASSERT(up_ep->pfcp_ep);
+ return osmo_pfcp_endpoint_bind(up_ep->pfcp_ep);
+}
+
static struct up_session *up_endpoint_find_session(struct up_endpoint *ep, uint64_t up_seid)
{
struct up_peer *peer;
diff --git a/src/osmo-upf/up_peer.c b/src/osmo-upf/up_peer.c
index c0e43e4..08f7d12 100644
--- a/src/osmo-upf/up_peer.c
+++ b/src/osmo-upf/up_peer.c
@@ -299,7 +299,7 @@
{
enum osmo_pfcp_cause cause = OSMO_PFCP_CAUSE_REQUEST_ACCEPTED;
struct osmo_pfcp_msg *resp;
- struct up_session *session = up_session_find_or_add(peer, &m->ies.session_est_req.cp_f_seid, NULL);
+ struct up_session *session = up_session_find_or_add(peer, &m->ies.session_est_req.cp_f_seid);
if (!session) {
cause = OSMO_PFCP_CAUSE_NO_RESOURCES_AVAILABLE;
diff --git a/src/osmo-upf/up_session.c b/src/osmo-upf/up_session.c
index 5874f3c..593f131 100644
--- a/src/osmo-upf/up_session.c
+++ b/src/osmo-upf/up_session.c
@@ -1021,16 +1021,11 @@
return session;
}
-struct up_session *up_session_find_or_add(struct up_peer *peer, const struct osmo_pfcp_ie_f_seid *cp_f_seid,
- const struct osmo_pfcp_ie_f_seid *up_f_seid)
+struct up_session *up_session_find_or_add(struct up_peer *peer, const struct osmo_pfcp_ie_f_seid *cp_f_seid)
{
struct up_session *session;
- if (cp_f_seid)
- session = up_session_find_by_cp_f_seid(peer, cp_f_seid);
- else if (up_f_seid)
- session = up_session_find_by_up_seid(peer, up_f_seid->seid);
- else
- return NULL;
+ OSMO_ASSERT(cp_f_seid);
+ session = up_session_find_by_cp_f_seid(peer, cp_f_seid);
if (session)
return session;
diff --git a/src/osmo-upf/upf.c b/src/osmo-upf/upf.c
index 047a6ff..b0de925 100644
--- a/src/osmo-upf/upf.c
+++ b/src/osmo-upf/upf.c
@@ -67,7 +67,7 @@
INIT_LLIST_HEAD(&g_upf->netinst);
}
-int upf_pfcp_listen()
+int upf_pfcp_init(void)
{
struct osmo_sockaddr_str local_addr_str;
struct osmo_sockaddr local_addr;
@@ -79,9 +79,8 @@
* osmo_sockaddr. */
osmo_sockaddr_str_from_str(&local_addr_str, g_upf->pfcp.vty_cfg.local_addr, g_upf->pfcp.vty_cfg.local_port);
osmo_sockaddr_str_to_sockaddr(&local_addr_str, &local_addr.u.sas);
- LOGP(DLPFCP, LOGL_NOTICE, "PFCP: Listening on %s\n", osmo_sockaddr_to_str_c(OTC_SELECT, &local_addr));
- g_upf->pfcp.ep = up_endpoint_init(g_upf, &local_addr);
+ g_upf->pfcp.ep = up_endpoint_alloc(g_upf, &local_addr);
if (!g_upf->pfcp.ep) {
fprintf(stderr, "Failed to allocate PFCP endpoint.\n");
return -1;
@@ -89,6 +88,25 @@
return 0;
}
+int upf_pfcp_listen(void) {
+ int rc;
+ if (!g_upf->pfcp.ep) {
+ rc = upf_pfcp_init();
+ if (rc)
+ return rc;
+ }
+
+ rc = up_endpoint_bind(g_upf->pfcp.ep);
+ if (rc) {
+ LOGP(DLPFCP, LOGL_ERROR, "PFCP: failed to listen on %s\n",
+ osmo_sockaddr_to_str_c(OTC_SELECT, osmo_pfcp_endpoint_get_local_addr(g_upf->pfcp.ep->pfcp_ep)));
+ return rc;
+ }
+ LOGP(DLPFCP, LOGL_NOTICE, "PFCP: Listening on %s\n",
+ osmo_sockaddr_to_str_c(OTC_SELECT, osmo_pfcp_endpoint_get_local_addr(g_upf->pfcp.ep->pfcp_ep)));
+ return 0;
+}
+
int upf_gtp_devs_open()
{
struct tunend_vty_cfg *c = &g_upf->tunend.vty_cfg;
diff --git a/src/osmo-upf/upf_nft.c b/src/osmo-upf/upf_nft.c
index ed3b921..e91443b 100644
--- a/src/osmo-upf/upf_nft.c
+++ b/src/osmo-upf/upf_nft.c
@@ -81,7 +81,7 @@
return -EIO;
}
- LOGP(DNFT, LOGL_DEBUG, "set up nft ruleset: %s\n", osmo_quote_str_c(OTC_SELECT, ruleset, -1));
+ LOGP(DNFT, LOGL_DEBUG, "run nft ruleset: %s\n", osmo_quote_str_c(OTC_SELECT, ruleset, -1));
return 0;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dbdb5f2..5e1d517 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,7 @@
+SUBDIRS = \
+ unique_ids \
+ $(NULL)
+
# The `:;' works around a Bash 3.2 bug when the output is not writeable.
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
:;{ \
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 09a77c3..45a5145 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -1,2 +1,9 @@
AT_INIT
AT_BANNER([Regression tests.])
+
+AT_SETUP([unique_ids_test])
+AT_KEYWORDS([unique_ids_test])
+cat $abs_srcdir/unique_ids/unique_ids_test.ok > expout
+cat $abs_srcdir/unique_ids/unique_ids_test.err > experr
+AT_CHECK([$abs_top_builddir/tests/unique_ids/unique_ids_test], [], [expout], [experr])
+AT_CLEANUP
diff --git a/tests/unique_ids/Makefile.am b/tests/unique_ids/Makefile.am
new file mode 100644
index 0000000..080d328
--- /dev/null
+++ b/tests/unique_ids/Makefile.am
@@ -0,0 +1,52 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ -I$(top_builddir) \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOVTY_CFLAGS) \
+ $(LIBOSMOCTRL_CFLAGS) \
+ $(LIBOSMOGTLV_CFLAGS) \
+ $(LIBOSMOPFCP_CFLAGS) \
+ $(LIBGTPNL_CFLAGS) \
+ $(LIBNFTNL_CFLAGS) \
+ $(LIBNFTABLES_CFLAGS) \
+ $(COVERAGE_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(LIBOSMOCTRL_LIBS) \
+ $(LIBOSMOGTLV_LIBS) \
+ $(LIBOSMOPFCP_LIBS) \
+ $(LIBGTPNL_LIBS) \
+ $(LIBNFTNL_LIBS) \
+ $(LIBNFTABLES_LIBS) \
+ $(COVERAGE_LDFLAGS) \
+ $(NULL)
+
+bin_PROGRAMS = \
+ unique_ids_test \
+ $(NULL)
+
+unique_ids_test_SOURCES = \
+ unique_ids_test.c \
+ $(top_srcdir)/src/osmo-upf/netinst.c \
+ $(top_srcdir)/src/osmo-upf/up_endpoint.c \
+ $(top_srcdir)/src/osmo-upf/up_gtp_action.c \
+ $(top_srcdir)/src/osmo-upf/up_peer.c \
+ $(top_srcdir)/src/osmo-upf/up_session.c \
+ $(top_srcdir)/src/osmo-upf/upf.c \
+ $(top_srcdir)/src/osmo-upf/upf_gtp.c \
+ $(top_srcdir)/src/osmo-upf/upf_gtpu_echo.c \
+ $(top_srcdir)/src/osmo-upf/upf_nft.c \
+ $(NULL)
+
+.PHONY: update_exp
+update_exp:
+ $(builddir)/unique_ids_test >$(srcdir)/unique_ids_test.ok 2>$(srcdir)/unique_ids_test.err
diff --git a/tests/unique_ids/unique_ids_test.c b/tests/unique_ids/unique_ids_test.c
new file mode 100644
index 0000000..c86e8f2
--- /dev/null
+++ b/tests/unique_ids/unique_ids_test.c
@@ -0,0 +1,519 @@
+/* OsmoUPF: Verify that skipping used ids works for: UP-SEID, GTP local TEID, nft ruleset chain_id. */
+
+/* (C) 2023 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * Author: Neels Hofmeyr <nhofmeyr(a)sysmocom.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <nftables/libnftables.h>
+
+#include <osmocom/core/sockaddr_str.h>
+#include <osmocom/core/application.h>
+
+#include <osmocom/pfcp/pfcp_endpoint.h>
+
+#include <osmocom/upf/upf.h>
+#include <osmocom/upf/netinst.h>
+#include <osmocom/upf/up_endpoint.h>
+#include <osmocom/upf/up_peer.h>
+#include <osmocom/upf/up_session.h>
+#include <osmocom/upf/up_gtp_action.h>
+
+#define log(FMT, ARGS...) fprintf(stderr, FMT, ##ARGS)
+#define log_assert(COND) do { \
+ log("assert(" #COND ")\n"); \
+ OSMO_ASSERT(COND); \
+ } while (0)
+
+#define log_assert_expect_failure(COND) do { \
+ log("assert(" #COND ") <-- EXPECTED TO FAIL (known error)\n"); \
+ OSMO_ASSERT(!(COND)); \
+ } while (0)
+
+
+void *main_ctx;
+void *ctx;
+
+/* The override of osmo_pfcp_endpoint_tx() stores any Session Establishment Response's UP-SEID here, so that this test
+ * can reference specific sessions later.
+ */
+uint64_t last_up_seid = 0;
+
+void select_poll(void) {
+ while (osmo_select_main_ctx(1));
+}
+
+static void setup(const char *name)
+{
+ log("\n===== START of %s\n", name);
+ ctx = talloc_named_const(main_ctx, 0, name);
+ g_upf_alloc(ctx);
+ osmo_talloc_replace_string(g_upf, &g_upf->pfcp.vty_cfg.local_addr, "1.1.1.1");
+
+ OSMO_ASSERT(netinst_add(g_upf, &g_upf->netinst, "default", "1.1.1.1", NULL));
+
+ /* PFCP endpoint recovery timestamp overridden by time() below */
+ upf_pfcp_init();
+ /* but do not upf_pfcp_listen() */
+
+ upf_nft_init();
+
+ select_poll();
+ log("\n");
+}
+
+static void cleanup(void)
+{
+ up_endpoint_free(&g_upf->pfcp.ep);
+ upf_gtp_devs_close();
+
+ upf_gtp_genl_close();
+
+ upf_nft_free();
+
+ log("\n===== END of %s\n", talloc_get_name(ctx));
+ talloc_free(ctx);
+}
+
+static struct osmo_sockaddr *str2addr(const char *addr, uint16_t port)
+{
+ static struct osmo_sockaddr osa;
+ struct osmo_sockaddr_str str;
+ osmo_sockaddr_str_from_str(&str, addr, port);
+ osmo_sockaddr_str_to_sockaddr(&str, &osa.u.sas);
+ return &osa;
+}
+
+static struct up_peer *have_peer(const char *remote_addr, uint16_t port)
+{
+ return up_peer_find_or_add(g_upf->pfcp.ep, str2addr(remote_addr, port));
+}
+
+static struct osmo_pfcp_msg *new_pfcp_msg_for_osmo_upf_rx(struct up_peer *from_peer, enum osmo_pfcp_message_type msg_type)
+{
+ /* pfcp_endpoint discards received messages immediately after dispatching; in this test, allocate them in
+ * OTC_SELECT so they get discarded on the next select_poll().
+ * osmo_pfcp_msg_alloc_rx() is not useful here, it creates a blank struct to be decoded from raw data; instead,
+ * use osmo_pfcp_msg_alloc_tx_req() which properly sets up the internal structures to match the given msg_type,
+ * and when that is done set m->rx = true to indicate it is a message received by osmo-upf. */
+ struct osmo_pfcp_msg *m = osmo_pfcp_msg_alloc_tx_req(OTC_SELECT, &from_peer->remote_addr, msg_type);
+ m->rx = true;
+ return m;
+}
+
+static void peer_assoc(struct up_peer *peer)
+{
+ struct osmo_pfcp_msg *m = new_pfcp_msg_for_osmo_upf_rx(peer, OSMO_PFCP_MSGT_ASSOC_SETUP_REQ);
+ m->ies.assoc_setup_req.recovery_time_stamp = 1234;
+ osmo_fsm_inst_dispatch(peer->fi, UP_PEER_EV_RX_ASSOC_SETUP_REQ, m);
+ select_poll();
+}
+
+static int next_teid = 0x100;
+static int next_cp_seid = 0x100;
+
+/* Send a PFCP Session Establishment Request, and return the created session */
+static struct up_session *session_est_tunmap(struct up_peer *peer)
+{
+ struct osmo_pfcp_msg *m;
+
+ struct osmo_pfcp_ie_f_seid cp_f_seid;
+
+ struct osmo_pfcp_ie_f_teid f_teid_access_local;
+ struct osmo_pfcp_ie_outer_header_creation ohc_access;
+
+ struct osmo_pfcp_ie_f_teid f_teid_core_local;
+ struct osmo_pfcp_ie_outer_header_creation ohc_core;
+
+ struct osmo_pfcp_ie_apply_action aa = {};
+
+ osmo_pfcp_bits_set(aa.bits, OSMO_PFCP_APPLY_ACTION_FORW, true);
+
+ f_teid_access_local = (struct osmo_pfcp_ie_f_teid){
+ .choose_flag = true,
+ .choose = {
+ .ipv4_addr = true,
+ },
+ };
+
+ ohc_access = (struct osmo_pfcp_ie_outer_header_creation){
+ .teid_present = true,
+ .teid = next_teid++,
+ .ip_addr = {
+ .v4_present = true,
+ .v4 = *str2addr("5.6.7.8", 0),
+ },
+ };
+ osmo_pfcp_bits_set(ohc_access.desc_bits, OSMO_PFCP_OUTER_HEADER_CREATION_GTP_U_UDP_IPV4, true);
+
+ f_teid_core_local = (struct osmo_pfcp_ie_f_teid){
+ .choose_flag = true,
+ .choose = {
+ .ipv4_addr = true,
+ },
+ };
+
+ ohc_core = (struct osmo_pfcp_ie_outer_header_creation){
+ .teid_present = true,
+ .teid = next_teid++,
+ .ip_addr = {
+ .v4_present = true,
+ .v4 = *str2addr("13.14.15.16", 0),
+ },
+ };
+ osmo_pfcp_bits_set(ohc_core.desc_bits, OSMO_PFCP_OUTER_HEADER_CREATION_GTP_U_UDP_IPV4, true);
+
+ cp_f_seid = (struct osmo_pfcp_ie_f_seid){
+ .seid = next_cp_seid++,
+ };
+ osmo_pfcp_ip_addrs_set(&cp_f_seid.ip_addr, osmo_pfcp_endpoint_get_local_addr(g_upf->pfcp.ep->pfcp_ep));
+
+ m = new_pfcp_msg_for_osmo_upf_rx(peer, OSMO_PFCP_MSGT_SESSION_EST_REQ);
+ m->h.seid_present = true;
+ m->h.seid = 0;
+ /* GTP tunmap: remove header from both directions, and add header in both directions */
+ m->ies.session_est_req = (struct osmo_pfcp_msg_session_est_req){
+ .node_id = m->ies.session_est_req.node_id,
+ .cp_f_seid_present = true,
+ .cp_f_seid = cp_f_seid,
+ .create_pdr_count = 2,
+ .create_pdr = {
+ {
+ .pdr_id = 1,
+ .precedence = 255,
+ .pdi = {
+ .source_iface = OSMO_PFCP_SOURCE_IFACE_CORE,
+ .local_f_teid_present = true,
+ .local_f_teid = f_teid_core_local,
+ },
+ .outer_header_removal_present = true,
+ .outer_header_removal = {
+ .desc = OSMO_PFCP_OUTER_HEADER_REMOVAL_GTP_U_UDP_IPV4,
+ },
+ .far_id_present = true,
+ .far_id = 1,
+ },
+ {
+ .pdr_id = 2,
+ .precedence = 255,
+ .pdi = {
+ .source_iface = OSMO_PFCP_SOURCE_IFACE_ACCESS,
+ .local_f_teid_present = true,
+ .local_f_teid = f_teid_access_local,
+ },
+ .outer_header_removal_present = true,
+ .outer_header_removal = {
+ .desc = OSMO_PFCP_OUTER_HEADER_REMOVAL_GTP_U_UDP_IPV4,
+ },
+ .far_id_present = true,
+ .far_id = 2,
+ },
+ },
+ .create_far_count = 2,
+ .create_far = {
+ {
+ .far_id = 1,
+ .forw_params_present = true,
+ .forw_params = {
+ .destination_iface = OSMO_PFCP_DEST_IFACE_ACCESS,
+ .outer_header_creation_present = true,
+ .outer_header_creation = ohc_access,
+ },
+ .apply_action = aa,
+ },
+ {
+ .far_id = 2,
+ .forw_params_present = true,
+ .forw_params = {
+ .destination_iface = OSMO_PFCP_DEST_IFACE_CORE,
+ .outer_header_creation_present = true,
+ .outer_header_creation = ohc_core,
+ },
+ .apply_action = aa,
+ },
+ },
+ };
+
+ osmo_fsm_inst_dispatch(peer->fi, UP_PEER_EV_RX_SESSION_EST_REQ, m);
+ select_poll();
+
+ return up_session_find_by_up_seid(peer, last_up_seid);
+}
+
+static void session_del(struct up_session *session)
+{
+ struct osmo_pfcp_msg *m;
+
+ log_assert(session);
+
+ m = new_pfcp_msg_for_osmo_upf_rx(session->up_peer, OSMO_PFCP_MSGT_SESSION_DEL_REQ);
+ m->h.seid_present = true;
+ m->h.seid = session->up_seid;
+
+ osmo_fsm_inst_dispatch(session->fi, UP_SESSION_EV_RX_SESSION_DEL_REQ, m);
+ select_poll();
+}
+
+static void dump_state(void)
+{
+ struct up_peer *peer;
+ log("\n state:\n");
+ llist_for_each_entry(peer, &g_upf->pfcp.ep->peers, entry) {
+ struct up_session *session;
+ int bkt;
+ log(" | peer %s %s\n", peer->fi->name, osmo_fsm_inst_state_name(peer->fi));
+ hash_for_each(peer->sessions_by_up_seid, bkt, session, node_by_up_seid) {
+ struct up_gtp_action *a;
+ llist_for_each_entry(a, &session->active_gtp_actions, entry) {
+ if (a->kind != UP_GTP_U_TUNMAP)
+ continue;
+ log(" | session[%s]: UP-SEID 0x%"PRIx64"; chain_id access=%u core=%u;"
+ " local TEID access=0x%x core=0x%x\n",
+ osmo_fsm_inst_state_name(session->fi),
+ session->up_seid,
+ a->tunmap.access.chain_id, a->tunmap.core.chain_id,
+ a->tunmap.access.tun.local.teid, a->tunmap.core.tun.local.teid);
+ }
+ }
+ }
+ log("\n");
+}
+
+static void test_skip_used_id(void)
+{
+ struct up_peer *peer;
+ struct up_session *s1;
+ uint64_t s1_up_seid;
+ struct up_session *s2;
+ struct up_session *s3;
+ struct up_session *s4;
+ struct up_gtp_action *a;
+
+ setup(__func__);
+
+ log("PFCP Associate peer\n");
+ peer = have_peer("1.2.3.4", 1234);
+ peer_assoc(peer);
+ dump_state();
+
+ /* Make sure to start out all IDs with 1 */
+ g_upf->pfcp.ep->next_up_seid_state = 0;
+ g_upf->gtp.next_local_teid_state = 0;
+ g_upf->tunmap.next_chain_id_state = 0;
+
+ log("set up tunmap, which assigns first UP-SEID 0x1, local-TEID 0x1 and 0x2, chain_ids 1 and 2\n");
+ s1 = session_est_tunmap(peer);
+ dump_state();
+
+ log_assert(s1->up_seid == 1);
+ log_assert(a = llist_first_entry_or_null(&s1->active_gtp_actions, struct up_gtp_action, entry));
+ log_assert(a->kind == UP_GTP_U_TUNMAP);
+ log_assert(a->tunmap.core.tun.local.teid == 1);
+ log_assert(a->tunmap.access.tun.local.teid == 2);
+ log_assert(a->tunmap.access.chain_id == 1);
+ log_assert(a->tunmap.core.chain_id == 2);
+ log("\n");
+
+ log("simulate wrapping of IDs back to 1\n");
+ g_upf->pfcp.ep->next_up_seid_state = 0;
+ g_upf->gtp.next_local_teid_state = 0;
+ g_upf->tunmap.next_chain_id_state = 0;
+
+ log("set up second tunmap, should use distinct IDs\n");
+ s2 = session_est_tunmap(peer);
+ dump_state();
+
+ log_assert(s2->up_seid == 2);
+ log_assert(a = llist_first_entry_or_null(&s2->active_gtp_actions, struct up_gtp_action, entry));
+ log_assert(a->kind == UP_GTP_U_TUNMAP);
+ log_assert(a->tunmap.core.tun.local.teid == 3);
+ log_assert(a->tunmap.access.tun.local.teid == 4);
+ log_assert_expect_failure(a->tunmap.access.chain_id == 3);
+ log_assert_expect_failure(a->tunmap.core.chain_id == 4);
+ log("\n");
+
+ log("drop first tunmap (%s)\n", s1->fi->name);
+ s1_up_seid = s1->up_seid;
+ session_del(s1);
+ dump_state();
+ log_assert(up_session_find_by_up_seid(peer, s1_up_seid) == NULL);
+ log("\n");
+
+ log("again wrap all ID state back to 1\n");
+ g_upf->pfcp.ep->next_up_seid_state = 0;
+ g_upf->gtp.next_local_teid_state = 0;
+ g_upf->tunmap.next_chain_id_state = 0;
+
+ log("set up third tunmap, should now re-use same IDs as the first session\n");
+ s3 = session_est_tunmap(peer);
+ dump_state();
+
+ log_assert(s3->up_seid == 1);
+ log_assert(a = llist_first_entry_or_null(&s3->active_gtp_actions, struct up_gtp_action, entry));
+ log_assert(a->kind == UP_GTP_U_TUNMAP);
+ log_assert(a->tunmap.core.tun.local.teid == 1);
+ log_assert(a->tunmap.access.tun.local.teid == 2);
+ log_assert(a->tunmap.access.chain_id == 1);
+ log_assert(a->tunmap.core.chain_id == 2);
+ log("\n");
+
+ log("set up 4th tunmap; chain_id state would use 3 and 4, but they are in use, so should assign 5 and 6\n");
+ s4 = session_est_tunmap(peer);
+ dump_state();
+
+ log_assert(s4->up_seid == 3);
+ log_assert(a = llist_first_entry_or_null(&s4->active_gtp_actions, struct up_gtp_action, entry));
+ log_assert(a->kind == UP_GTP_U_TUNMAP);
+ log_assert(a->tunmap.core.tun.local.teid == 5);
+ log_assert(a->tunmap.access.tun.local.teid == 6);
+ log_assert_expect_failure(a->tunmap.access.chain_id == 5);
+ log_assert_expect_failure(a->tunmap.core.chain_id == 6);
+ log("\n");
+
+ cleanup();
+}
+
+static const struct log_info_cat test_default_categories[] = {
+ [DREF] = {
+ .name = "DREF",
+ .description = "Reference Counting",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ .color = OSMO_LOGCOLOR_DARKGREY,
+ },
+ [DPEER] = {
+ .name = "DPEER",
+ .description = "PFCP peer association",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ .color = OSMO_LOGCOLOR_YELLOW,
+ },
+ [DSESSION] = {
+ .name = "DSESSION",
+ .description = "PFCP sessions",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ .color = OSMO_LOGCOLOR_BLUE,
+ },
+ [DGTP] = {
+ .name = "DGTP",
+ .description = "GTP tunneling",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ .color = OSMO_LOGCOLOR_PURPLE,
+ },
+ [DNFT] = {
+ .name = "DNFT",
+ .description = "GTP forwarding rules via linux netfilter",
+ .enabled = 1, .loglevel = LOGL_DEBUG,
+ .color = OSMO_LOGCOLOR_PURPLE,
+ },
+};
+
+const struct log_info log_info = {
+ .cat = test_default_categories,
+ .num_cat = ARRAY_SIZE(test_default_categories),
+};
+
+int main(void)
+{
+ main_ctx = talloc_named_const(NULL, 0, "main");
+
+ msgb_talloc_ctx_init(main_ctx, 0);
+
+ osmo_fsm_set_dealloc_ctx(OTC_SELECT);
+
+ osmo_init_logging2(main_ctx, &log_info);
+ log_set_print_category_hex(osmo_stderr_target, 0);
+ log_set_print_category(osmo_stderr_target, 1);
+ log_set_print_level(osmo_stderr_target, 1);
+ log_set_print_timestamp(osmo_stderr_target, 0);
+ log_set_print_extended_timestamp(osmo_stderr_target, 0);
+ log_set_all_filter(osmo_stderr_target, 1);
+
+ /* debugging: set this to '#if 0' to see the source file for all logging */
+#if 1
+ log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE);
+ log_set_use_color(osmo_stderr_target, 0);
+#else
+ log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_BASENAME);
+ log_set_print_filename_pos(osmo_stderr_target, LOG_FILENAME_POS_LINE_END);
+ log_set_use_color(osmo_stderr_target, 1);
+#endif
+
+ osmo_fsm_log_timeouts(true);
+ osmo_fsm_log_addr(false);
+
+ /* actual tests */
+ test_skip_used_id();
+
+ log_fini();
+ talloc_free(main_ctx);
+ return 0;
+}
+
+/* overrides */
+
+int osmo_pfcp_endpoint_tx(struct osmo_pfcp_endpoint *ep, struct osmo_pfcp_msg *m)
+{
+ enum osmo_pfcp_cause *cause;
+
+ log("\n[test override] PFCP tx:\n%s\n\n", osmo_pfcp_msg_to_str_c(OTC_SELECT, m));
+
+ last_up_seid = 0;
+
+ cause = osmo_pfcp_msg_cause(m);
+ switch (m->h.message_type) {
+ case OSMO_PFCP_MSGT_SESSION_EST_RESP:
+ if (*cause == OSMO_PFCP_CAUSE_REQUEST_ACCEPTED) {
+ last_up_seid = m->ies.session_est_resp.up_f_seid.seid;
+ log("osmo-upf created session 0x%"PRIx64"\n\n", last_up_seid);
+ }
+ break;
+ default:
+ break;
+ };
+ osmo_pfcp_msg_free(m);
+ return 0;
+}
+
+static void *fake_nft_ctx = (void*)0x1;
+
+struct nft_ctx *nft_ctx_new(uint32_t flags)
+{
+ log("[test override] %s()\n", __func__);
+ return fake_nft_ctx;
+}
+
+void nft_ctx_free(struct nft_ctx *ctx)
+{
+ log("[test override] %s()\n", __func__);
+ log_assert(ctx == fake_nft_ctx);
+}
+
+int nft_run_cmd_from_buffer(struct nft_ctx *nft, const char *buf)
+{
+ log("\n[test override] %s():\n%s\n", __func__, buf);
+ return 0;
+}
+
+/* for deterministic recovery_time_stamp */
+time_t time(time_t *tloc)
+{
+ log("[test override] %s()\n", __func__);
+ return 0;
+}
diff --git a/tests/unique_ids/unique_ids_test.err b/tests/unique_ids/unique_ids_test.err
new file mode 100644
index 0000000..dfd57ef
--- /dev/null
+++ b/tests/unique_ids/unique_ids_test.err
@@ -0,0 +1,412 @@
+
+===== START of test_skip_used_id
+[test override] time()
+[test override] time()
+DLPFCP NOTICE PFCP endpoint: recovery timestamp = 0x83aa7e80 (0 seconds since UNIX epoch, which is 2208988800 seconds since NTP era 0; IETF RFC 5905)
+[test override] nft_ctx_new()
+
+[test override] nft_run_cmd_from_buffer():
+add table inet osmo-upf { flags owner; };
+
+DNFT DEBUG run nft ruleset: "add table inet osmo-upf { flags owner; };\n"
+DNFT NOTICE Created nft table "osmo-upf"
+
+[test override] nft_run_cmd_from_buffer():
+add chain inet osmo-upf pre { type filter hook prerouting priority -300; policy accept; };
+add chain inet osmo-upf post { type filter hook postrouting priority 400; policy accept; };
+add map inet osmo-upf tunmap-pre { typeof ip daddr . @ih,32,32 : verdict; };
+add map inet osmo-upf tunmap-post { typeof meta mark : verdict; };
+add rule inet osmo-upf pre udp dport 2152 ip daddr . @ih,32,32 vmap @tunmap-pre;
+add rule inet osmo-upf post meta mark vmap @tunmap-post;
+
+DNFT DEBUG run nft ruleset: "add chain inet osmo-upf pre { type filter hook prerouting priority -300; policy accept; };\nadd chain inet osmo-upf post { type filter hook postrouting priority 400; policy accept; };\nadd map inet osmo-upf tunmap-pre { typeof ip daddr . @ih,32,32 : verdict; };\nadd map inet osmo-upf tunmap-post { typeof meta mark : verdict; };\nadd rule inet osmo-upf pre udp dport 2152 ip daddr . @ih,32,32 vmap @tunmap-pre;\nadd rule inet osmo-upf post meta mark vmap @tunmap-post;\n"
+
+PFCP Associate peer
+DPEER DEBUG up_peer{NOT_ASSOCIATED}: Allocated
+DPEER DEBUG up_peer(1-2-3-4){NOT_ASSOCIATED}: Updated id
+DPEER DEBUG up_peer(1-2-3-4){NOT_ASSOCIATED}: Received Event UP_PEER_EV_RX_ASSOC_SETUP_REQ
+DPEER DEBUG up_peer(1-2-3-4){NOT_ASSOCIATED}: State change to ASSOCIATED (no timeout)
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: + msg-tx: now used by 1 (msg-tx)
+
+[test override] PFCP tx:
+PFCPv1 ASSOC_SETUP_RESP hdr={seq=0} ies={ 'Node ID'=v4:unsupported family 0 'Cause'=Request accepted (success) 'Recovery Time Stamp'=2208988800 'UP Function Features'=FTUP+BUNDL+RTTL }
+
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: - msg-tx: now used by 0 (-)
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_USE_COUNT_ZERO
+DPEER NOTICE up_peer(1-2-3-4){ASSOCIATED}: Peer associated, Node-Id=v4:unsupported family 0. Local UP features: [FTUP+BUNDL+RTTL]; Peer CP features: [-]
+
+ state:
+ | peer up_peer(1-2-3-4) ASSOCIATED
+
+set up tunmap, which assigns first UP-SEID 0x1, local-TEID 0x1 and 0x2, chain_ids 1 and 2
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_RX_SESSION_EST_REQ
+DSESSION DEBUG up_session(1-2-3-4){INIT}: Allocated
+DSESSION DEBUG up_session(1-2-3-4){INIT}: is child of up_peer(1-2-3-4)
+DSESSION INFO up_session(1-2-3-4){INIT}: Allocated new UP-SEID: 0x1
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: Updated id
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: + msg-rx: now used by 1 (msg-rx)
+DREF INFO up_session(1-2-3-4-0x1){INIT}: + msg-rx: now used by 1 (msg-rx)
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: Received Event UP_SESSION_EV_RX_SESSION_EST_REQ
+DREF DEBUG up_peer(1-2-3-4){ASSOCIATED}: + msg-tx: now used by 2 (msg-rx,msg-tx)
+DREF DEBUG up_session(1-2-3-4-0x1){INIT}: + msg-tx: now used by 2 (msg-rx,msg-tx)
+DSESSION INFO up_session(1-2-3-4-0x1){INIT}: Allocated new local F-TEID TEID-0x1,v4:1.1.1.1
+DSESSION INFO up_session(1-2-3-4-0x1){INIT}: New PDR-1{src:Core TEID-0x1,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-1{FORW dst:Access,GTP_U_UDP_IPV4,TEID:0x100,v4:5.6.7.8}
+DSESSION INFO up_session(1-2-3-4-0x1){INIT}: Allocated new local F-TEID TEID-0x2,v4:1.1.1.1
+DSESSION INFO up_session(1-2-3-4-0x1){INIT}: New PDR-2{src:Access TEID-0x2,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-2{FORW dst:Core,GTP_U_UDP_IPV4,TEID:0x101,v4:13.14.15.16}
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: Active PDR set: PDR-2{src:Access TEID-0x2,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-2{FORW dst:Core,GTP_U_UDP_IPV4,TEID:0x101,v4:13.14.15.16}
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: Active PDR set: + PDR-1{src:Core TEID-0x1,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-1{FORW dst:Access,GTP_U_UDP_IPV4,TEID:0x100,v4:5.6.7.8}
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: GTP actions: 0 previously active; want active: 1
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: want: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x100 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x101 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: enabling: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x100 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x101 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1
+
+[test override] nft_run_cmd_from_buffer():
+add chain inet osmo-upf tunmap-pre-1;
+add rule inet osmo-upf tunmap-pre-1 ip daddr set 13.14.15.16 meta mark set 1 counter accept;
+add chain inet osmo-upf tunmap-post-1;
+add rule inet osmo-upf tunmap-post-1 ip saddr set 1.1.1.1 @ih,32,32 set 0x101 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x2 : jump tunmap-pre-1 };
+add element inet osmo-upf tunmap-post { 1 : jump tunmap-post-1 };
+add chain inet osmo-upf tunmap-pre-2;
+add rule inet osmo-upf tunmap-pre-2 ip daddr set 5.6.7.8 meta mark set 2 counter accept;
+add chain inet osmo-upf tunmap-post-2;
+add rule inet osmo-upf tunmap-post-2 ip saddr set 1.1.1.1 @ih,32,32 set 0x100 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x1 : jump tunmap-pre-2 };
+add element inet osmo-upf tunmap-post { 2 : jump tunmap-post-2 };
+
+DNFT DEBUG run nft ruleset: "add chain inet osmo-upf tunmap-pre-1;\nadd rule inet osmo-upf tunmap-pre-1 ip daddr set 13.14.15.16 meta mark set 1 counter accept;\nadd chain inet osmo-upf tunmap-post-1;\nadd rule inet osmo-upf tunmap-post-1 ip saddr set 1.1.1.1 @ih,32,32 set 0x101 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x2 : jump tunmap-pre-1 };\nadd element inet osmo-upf tunmap-post { 1 : jump tunmap-post-1 };\nadd chain inet osmo-upf tunmap-pre-2;\nadd rule inet osmo-upf tunmap-pre-2 ip daddr set 5.6.7.8 meta mark set 2 counter accept;\nadd chain inet osmo-upf tunmap-post-2;\nadd rule inet osmo-upf tunmap-post-2 ip saddr set 1.1.1.1 @ih,32,32 set 0x100 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x1 : jump tunmap-pre-2 };\nadd element inet osmo-upf tunmap-post { 2 : jump tunmap-post-2 };\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x100 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x101 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1: Enabled tunmap, nft chain IDs: access--1-> <-2--core
+
+[test override] PFCP tx:
+PFCPv1 SESSION_EST_RESP hdr={seq=0 SEID=0x100} ies={ 'Node ID'=v4:unsupported family 0 'Cause'=Request accepted (success) 'F-SEID'=0x1,v4:1.1.1.1 'Created PDR'={ { 'PDR ID'=1 'F-TEID'=TEID-0x1,v4:1.1.1.1 }, { 'PDR ID'=2 'F-TEID'=TEID-0x2,v4:1.1.1.1 } } }
+
+osmo-upf created session 0x1
+
+DREF DEBUG up_session(1-2-3-4-0x1){INIT}: - msg-tx: now used by 1 (msg-rx)
+DREF DEBUG up_peer(1-2-3-4){ASSOCIATED}: - msg-tx: now used by 1 (msg-rx)
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: State change to ESTABLISHED (no timeout)
+DSESSION NOTICE up_session(1-2-3-4-0x1){ESTABLISHED}: Session established: peer:1.2.3.4 SEID-r:0x100 SEID-l:0x1 state:ESTABLISHED PDR-active:2/2 FAR-active:2/2 GTP-active:1
+DREF INFO up_session(1-2-3-4-0x1){ESTABLISHED}: - msg-rx: now used by 0 (-)
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: Received Event UP_SESSION_EV_USE_COUNT_ZERO
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: - msg-rx: now used by 0 (-)
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_USE_COUNT_ZERO
+
+ state:
+ | peer up_peer(1-2-3-4) ASSOCIATED
+ | session[ESTABLISHED]: UP-SEID 0x1; chain_id access=1 core=2; local TEID access=0x2 core=0x1
+
+assert(s1->up_seid == 1)
+assert(a = llist_first_entry_or_null(&s1->active_gtp_actions, struct up_gtp_action, entry))
+assert(a->kind == UP_GTP_U_TUNMAP)
+assert(a->tunmap.core.tun.local.teid == 1)
+assert(a->tunmap.access.tun.local.teid == 2)
+assert(a->tunmap.access.chain_id == 1)
+assert(a->tunmap.core.chain_id == 2)
+
+simulate wrapping of IDs back to 1
+set up second tunmap, should use distinct IDs
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_RX_SESSION_EST_REQ
+DSESSION DEBUG up_session(1-2-3-4){INIT}: Allocated
+DSESSION DEBUG up_session(1-2-3-4){INIT}: is child of up_peer(1-2-3-4)
+DSESSION INFO up_session(1-2-3-4){INIT}: Allocated new UP-SEID: 0x2
+DSESSION DEBUG up_session(1-2-3-4-0x2){INIT}: Updated id
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: + msg-rx: now used by 1 (msg-rx)
+DREF INFO up_session(1-2-3-4-0x2){INIT}: + msg-rx: now used by 1 (msg-rx)
+DSESSION DEBUG up_session(1-2-3-4-0x2){INIT}: Received Event UP_SESSION_EV_RX_SESSION_EST_REQ
+DREF DEBUG up_peer(1-2-3-4){ASSOCIATED}: + msg-tx: now used by 2 (msg-rx,msg-tx)
+DREF DEBUG up_session(1-2-3-4-0x2){INIT}: + msg-tx: now used by 2 (msg-rx,msg-tx)
+DSESSION INFO up_session(1-2-3-4-0x2){INIT}: Allocated new local F-TEID TEID-0x3,v4:1.1.1.1
+DSESSION INFO up_session(1-2-3-4-0x2){INIT}: New PDR-1{src:Core TEID-0x3,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-1{FORW dst:Access,GTP_U_UDP_IPV4,TEID:0x102,v4:5.6.7.8}
+DSESSION INFO up_session(1-2-3-4-0x2){INIT}: Allocated new local F-TEID TEID-0x4,v4:1.1.1.1
+DSESSION INFO up_session(1-2-3-4-0x2){INIT}: New PDR-2{src:Access TEID-0x4,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-2{FORW dst:Core,GTP_U_UDP_IPV4,TEID:0x103,v4:13.14.15.16}
+DSESSION DEBUG up_session(1-2-3-4-0x2){INIT}: Active PDR set: PDR-2{src:Access TEID-0x4,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-2{FORW dst:Core,GTP_U_UDP_IPV4,TEID:0x103,v4:13.14.15.16}
+DSESSION DEBUG up_session(1-2-3-4-0x2){INIT}: Active PDR set: + PDR-1{src:Core TEID-0x3,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-1{FORW dst:Access,GTP_U_UDP_IPV4,TEID:0x102,v4:5.6.7.8}
+DSESSION DEBUG up_session(1-2-3-4-0x2){INIT}: GTP actions: 0 previously active; want active: 1
+DSESSION DEBUG up_session(1-2-3-4-0x2){INIT}: want: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1
+DSESSION DEBUG up_session(1-2-3-4-0x2){INIT}: enabling: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1
+
+[test override] nft_run_cmd_from_buffer():
+add chain inet osmo-upf tunmap-pre-1;
+add rule inet osmo-upf tunmap-pre-1 ip daddr set 13.14.15.16 meta mark set 1 counter accept;
+add chain inet osmo-upf tunmap-post-1;
+add rule inet osmo-upf tunmap-post-1 ip saddr set 1.1.1.1 @ih,32,32 set 0x103 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 : jump tunmap-pre-1 };
+add element inet osmo-upf tunmap-post { 1 : jump tunmap-post-1 };
+add chain inet osmo-upf tunmap-pre-2;
+add rule inet osmo-upf tunmap-pre-2 ip daddr set 5.6.7.8 meta mark set 2 counter accept;
+add chain inet osmo-upf tunmap-post-2;
+add rule inet osmo-upf tunmap-post-2 ip saddr set 1.1.1.1 @ih,32,32 set 0x102 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 : jump tunmap-pre-2 };
+add element inet osmo-upf tunmap-post { 2 : jump tunmap-post-2 };
+
+DNFT DEBUG run nft ruleset: "add chain inet osmo-upf tunmap-pre-1;\nadd rule inet osmo-upf tunmap-pre-1 ip daddr set 13.14.15.16 meta mark set 1 counter accept;\nadd chain inet osmo-upf tunmap-post-1;\nadd rule inet osmo-upf tunmap-post-1 ip saddr set 1.1.1.1 @ih,32,32 set 0x103 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 : jump tunmap-pre-1 };\nadd element inet osmo-upf tunmap-post { 1 : jump tunmap-post-1 };\nadd chain inet osmo-upf tunmap-pre-2;\nadd rule inet osmo-upf tunmap-pre-2 ip daddr set 5.6.7.8 meta mark set 2 counter accept;\nadd chain inet osmo-upf tunmap-post-2;\nadd rule inet osmo-upf tunmap-post-2 ip saddr set 1.1.1.1 @ih,32,32 set 0x102 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 : jump tunmap-pre-2 };\nadd element inet osmo-upf tunmap-post { 2 : jump tunmap-post-2 };\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1: Enabled tunmap, nft chain IDs: access--1-> <-2--core
+
+[test override] PFCP tx:
+PFCPv1 SESSION_EST_RESP hdr={seq=0 SEID=0x101} ies={ 'Node ID'=v4:unsupported family 0 'Cause'=Request accepted (success) 'F-SEID'=0x2,v4:1.1.1.1 'Created PDR'={ { 'PDR ID'=1 'F-TEID'=TEID-0x3,v4:1.1.1.1 }, { 'PDR ID'=2 'F-TEID'=TEID-0x4,v4:1.1.1.1 } } }
+
+osmo-upf created session 0x2
+
+DREF DEBUG up_session(1-2-3-4-0x2){INIT}: - msg-tx: now used by 1 (msg-rx)
+DREF DEBUG up_peer(1-2-3-4){ASSOCIATED}: - msg-tx: now used by 1 (msg-rx)
+DSESSION DEBUG up_session(1-2-3-4-0x2){INIT}: State change to ESTABLISHED (no timeout)
+DSESSION NOTICE up_session(1-2-3-4-0x2){ESTABLISHED}: Session established: peer:1.2.3.4 SEID-r:0x101 SEID-l:0x2 state:ESTABLISHED PDR-active:2/2 FAR-active:2/2 GTP-active:1
+DREF INFO up_session(1-2-3-4-0x2){ESTABLISHED}: - msg-rx: now used by 0 (-)
+DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: Received Event UP_SESSION_EV_USE_COUNT_ZERO
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: - msg-rx: now used by 0 (-)
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_USE_COUNT_ZERO
+
+ state:
+ | peer up_peer(1-2-3-4) ASSOCIATED
+ | session[ESTABLISHED]: UP-SEID 0x1; chain_id access=1 core=2; local TEID access=0x2 core=0x1
+ | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=1 core=2; local TEID access=0x4 core=0x3
+
+assert(s2->up_seid == 2)
+assert(a = llist_first_entry_or_null(&s2->active_gtp_actions, struct up_gtp_action, entry))
+assert(a->kind == UP_GTP_U_TUNMAP)
+assert(a->tunmap.core.tun.local.teid == 3)
+assert(a->tunmap.access.tun.local.teid == 4)
+assert(a->tunmap.access.chain_id == 3) <-- EXPECTED TO FAIL (known error)
+assert(a->tunmap.core.chain_id == 4) <-- EXPECTED TO FAIL (known error)
+
+drop first tunmap (up_session(1-2-3-4-0x1))
+assert(session)
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: Received Event UP_SESSION_EV_RX_SESSION_DEL_REQ
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: + msg-tx: now used by 1 (msg-tx)
+DREF INFO up_session(1-2-3-4-0x1){ESTABLISHED}: + msg-tx: now used by 1 (msg-tx)
+
+[test override] PFCP tx:
+PFCPv1 SESSION_DEL_RESP hdr={seq=0 SEID=0x100} ies={ 'Cause'=Request accepted (success) }
+
+DREF INFO up_session(1-2-3-4-0x1){ESTABLISHED}: - msg-tx: now used by 0 (-)
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: Received Event UP_SESSION_EV_USE_COUNT_ZERO
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: - msg-tx: now used by 0 (-)
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_USE_COUNT_ZERO
+DSESSION NOTICE up_session(1-2-3-4-0x1){ESTABLISHED}: Session releasing: peer:1.2.3.4 SEID-r:0x100 SEID-l:0x1 state:ESTABLISHED PDR-active:2/2 FAR-active:2/2 GTP-active:1
+
+[test override] nft_run_cmd_from_buffer():
+delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x2 };
+delete element inet osmo-upf tunmap-post { 1 };
+delete chain inet osmo-upf tunmap-pre-1;
+delete chain inet osmo-upf tunmap-post-1;
+delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x1 };
+delete element inet osmo-upf tunmap-post { 2 };
+delete chain inet osmo-upf tunmap-pre-2;
+delete chain inet osmo-upf tunmap-post-2;
+
+DNFT DEBUG run nft ruleset: "delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x2 };\ndelete element inet osmo-upf tunmap-post { 1 };\ndelete chain inet osmo-upf tunmap-pre-1;\ndelete chain inet osmo-upf tunmap-post-1;\ndelete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x1 };\ndelete element inet osmo-upf tunmap-post { 2 };\ndelete chain inet osmo-upf tunmap-pre-2;\ndelete chain inet osmo-upf tunmap-post-2;\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x100 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x101 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1: Disabled tunmap, nft chain IDs: access--1-> <-2--core
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: State change to WAIT_USE_COUNT (no timeout)
+DSESSION DEBUG up_session(1-2-3-4-0x1){WAIT_USE_COUNT}: GTP actions: 0 previously active; want active: 0
+DSESSION DEBUG up_session(1-2-3-4-0x1){WAIT_USE_COUNT}: Terminating (cause = OSMO_FSM_TERM_REGULAR)
+DSESSION DEBUG up_session(1-2-3-4-0x1){WAIT_USE_COUNT}: Removing from parent up_peer(1-2-3-4)
+DSESSION DEBUG up_session(1-2-3-4-0x1){WAIT_USE_COUNT}: GTP actions: 0 previously active; want active: 0
+DSESSION DEBUG up_session(1-2-3-4-0x1){WAIT_USE_COUNT}: Freeing instance
+DSESSION DEBUG up_session(1-2-3-4-0x1){WAIT_USE_COUNT}: Deallocated
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_SESSION_TERM
+
+ state:
+ | peer up_peer(1-2-3-4) ASSOCIATED
+ | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=1 core=2; local TEID access=0x4 core=0x3
+
+assert(up_session_find_by_up_seid(peer, s1_up_seid) == NULL)
+
+again wrap all ID state back to 1
+set up third tunmap, should now re-use same IDs as the first session
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_RX_SESSION_EST_REQ
+DSESSION DEBUG up_session(1-2-3-4){INIT}: Allocated
+DSESSION DEBUG up_session(1-2-3-4){INIT}: is child of up_peer(1-2-3-4)
+DSESSION INFO up_session(1-2-3-4){INIT}: Allocated new UP-SEID: 0x1
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: Updated id
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: + msg-rx: now used by 1 (msg-rx)
+DREF INFO up_session(1-2-3-4-0x1){INIT}: + msg-rx: now used by 1 (msg-rx)
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: Received Event UP_SESSION_EV_RX_SESSION_EST_REQ
+DREF DEBUG up_peer(1-2-3-4){ASSOCIATED}: + msg-tx: now used by 2 (msg-rx,msg-tx)
+DREF DEBUG up_session(1-2-3-4-0x1){INIT}: + msg-tx: now used by 2 (msg-rx,msg-tx)
+DSESSION INFO up_session(1-2-3-4-0x1){INIT}: Allocated new local F-TEID TEID-0x1,v4:1.1.1.1
+DSESSION INFO up_session(1-2-3-4-0x1){INIT}: New PDR-1{src:Core TEID-0x1,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-1{FORW dst:Access,GTP_U_UDP_IPV4,TEID:0x104,v4:5.6.7.8}
+DSESSION INFO up_session(1-2-3-4-0x1){INIT}: Allocated new local F-TEID TEID-0x2,v4:1.1.1.1
+DSESSION INFO up_session(1-2-3-4-0x1){INIT}: New PDR-2{src:Access TEID-0x2,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-2{FORW dst:Core,GTP_U_UDP_IPV4,TEID:0x105,v4:13.14.15.16}
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: Active PDR set: PDR-2{src:Access TEID-0x2,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-2{FORW dst:Core,GTP_U_UDP_IPV4,TEID:0x105,v4:13.14.15.16}
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: Active PDR set: + PDR-1{src:Core TEID-0x1,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-1{FORW dst:Access,GTP_U_UDP_IPV4,TEID:0x104,v4:5.6.7.8}
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: GTP actions: 0 previously active; want active: 1
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: want: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x104 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x105 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: enabling: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x104 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x105 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1
+
+[test override] nft_run_cmd_from_buffer():
+add chain inet osmo-upf tunmap-pre-1;
+add rule inet osmo-upf tunmap-pre-1 ip daddr set 13.14.15.16 meta mark set 1 counter accept;
+add chain inet osmo-upf tunmap-post-1;
+add rule inet osmo-upf tunmap-post-1 ip saddr set 1.1.1.1 @ih,32,32 set 0x105 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x2 : jump tunmap-pre-1 };
+add element inet osmo-upf tunmap-post { 1 : jump tunmap-post-1 };
+add chain inet osmo-upf tunmap-pre-2;
+add rule inet osmo-upf tunmap-pre-2 ip daddr set 5.6.7.8 meta mark set 2 counter accept;
+add chain inet osmo-upf tunmap-post-2;
+add rule inet osmo-upf tunmap-post-2 ip saddr set 1.1.1.1 @ih,32,32 set 0x104 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x1 : jump tunmap-pre-2 };
+add element inet osmo-upf tunmap-post { 2 : jump tunmap-post-2 };
+
+DNFT DEBUG run nft ruleset: "add chain inet osmo-upf tunmap-pre-1;\nadd rule inet osmo-upf tunmap-pre-1 ip daddr set 13.14.15.16 meta mark set 1 counter accept;\nadd chain inet osmo-upf tunmap-post-1;\nadd rule inet osmo-upf tunmap-post-1 ip saddr set 1.1.1.1 @ih,32,32 set 0x105 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x2 : jump tunmap-pre-1 };\nadd element inet osmo-upf tunmap-post { 1 : jump tunmap-post-1 };\nadd chain inet osmo-upf tunmap-pre-2;\nadd rule inet osmo-upf tunmap-pre-2 ip daddr set 5.6.7.8 meta mark set 2 counter accept;\nadd chain inet osmo-upf tunmap-post-2;\nadd rule inet osmo-upf tunmap-post-2 ip saddr set 1.1.1.1 @ih,32,32 set 0x104 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x1 : jump tunmap-pre-2 };\nadd element inet osmo-upf tunmap-post { 2 : jump tunmap-post-2 };\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x104 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x105 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1: Enabled tunmap, nft chain IDs: access--1-> <-2--core
+
+[test override] PFCP tx:
+PFCPv1 SESSION_EST_RESP hdr={seq=0 SEID=0x102} ies={ 'Node ID'=v4:unsupported family 0 'Cause'=Request accepted (success) 'F-SEID'=0x1,v4:1.1.1.1 'Created PDR'={ { 'PDR ID'=1 'F-TEID'=TEID-0x1,v4:1.1.1.1 }, { 'PDR ID'=2 'F-TEID'=TEID-0x2,v4:1.1.1.1 } } }
+
+osmo-upf created session 0x1
+
+DREF DEBUG up_session(1-2-3-4-0x1){INIT}: - msg-tx: now used by 1 (msg-rx)
+DREF DEBUG up_peer(1-2-3-4){ASSOCIATED}: - msg-tx: now used by 1 (msg-rx)
+DSESSION DEBUG up_session(1-2-3-4-0x1){INIT}: State change to ESTABLISHED (no timeout)
+DSESSION NOTICE up_session(1-2-3-4-0x1){ESTABLISHED}: Session established: peer:1.2.3.4 SEID-r:0x102 SEID-l:0x1 state:ESTABLISHED PDR-active:2/2 FAR-active:2/2 GTP-active:1
+DREF INFO up_session(1-2-3-4-0x1){ESTABLISHED}: - msg-rx: now used by 0 (-)
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: Received Event UP_SESSION_EV_USE_COUNT_ZERO
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: - msg-rx: now used by 0 (-)
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_USE_COUNT_ZERO
+
+ state:
+ | peer up_peer(1-2-3-4) ASSOCIATED
+ | session[ESTABLISHED]: UP-SEID 0x1; chain_id access=1 core=2; local TEID access=0x2 core=0x1
+ | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=1 core=2; local TEID access=0x4 core=0x3
+
+assert(s3->up_seid == 1)
+assert(a = llist_first_entry_or_null(&s3->active_gtp_actions, struct up_gtp_action, entry))
+assert(a->kind == UP_GTP_U_TUNMAP)
+assert(a->tunmap.core.tun.local.teid == 1)
+assert(a->tunmap.access.tun.local.teid == 2)
+assert(a->tunmap.access.chain_id == 1)
+assert(a->tunmap.core.chain_id == 2)
+
+set up 4th tunmap; chain_id state would use 3 and 4, but they are in use, so should assign 5 and 6
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_RX_SESSION_EST_REQ
+DSESSION DEBUG up_session(1-2-3-4){INIT}: Allocated
+DSESSION DEBUG up_session(1-2-3-4){INIT}: is child of up_peer(1-2-3-4)
+DSESSION INFO up_session(1-2-3-4){INIT}: Allocated new UP-SEID: 0x3
+DSESSION DEBUG up_session(1-2-3-4-0x3){INIT}: Updated id
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: + msg-rx: now used by 1 (msg-rx)
+DREF INFO up_session(1-2-3-4-0x3){INIT}: + msg-rx: now used by 1 (msg-rx)
+DSESSION DEBUG up_session(1-2-3-4-0x3){INIT}: Received Event UP_SESSION_EV_RX_SESSION_EST_REQ
+DREF DEBUG up_peer(1-2-3-4){ASSOCIATED}: + msg-tx: now used by 2 (msg-rx,msg-tx)
+DREF DEBUG up_session(1-2-3-4-0x3){INIT}: + msg-tx: now used by 2 (msg-rx,msg-tx)
+DSESSION INFO up_session(1-2-3-4-0x3){INIT}: Allocated new local F-TEID TEID-0x5,v4:1.1.1.1
+DSESSION INFO up_session(1-2-3-4-0x3){INIT}: New PDR-1{src:Core TEID-0x5,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-1{FORW dst:Access,GTP_U_UDP_IPV4,TEID:0x106,v4:5.6.7.8}
+DSESSION INFO up_session(1-2-3-4-0x3){INIT}: Allocated new local F-TEID TEID-0x6,v4:1.1.1.1
+DSESSION INFO up_session(1-2-3-4-0x3){INIT}: New PDR-2{src:Access TEID-0x6,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-2{FORW dst:Core,GTP_U_UDP_IPV4,TEID:0x107,v4:13.14.15.16}
+DSESSION DEBUG up_session(1-2-3-4-0x3){INIT}: Active PDR set: PDR-2{src:Access TEID-0x6,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-2{FORW dst:Core,GTP_U_UDP_IPV4,TEID:0x107,v4:13.14.15.16}
+DSESSION DEBUG up_session(1-2-3-4-0x3){INIT}: Active PDR set: + PDR-1{src:Core TEID-0x5,v4:1.1.1.1 decaps-GTP_U_UDP_IPV4} --> FAR-1{FORW dst:Access,GTP_U_UDP_IPV4,TEID:0x106,v4:5.6.7.8}
+DSESSION DEBUG up_session(1-2-3-4-0x3){INIT}: GTP actions: 0 previously active; want active: 1
+DSESSION DEBUG up_session(1-2-3-4-0x3){INIT}: want: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1
+DSESSION DEBUG up_session(1-2-3-4-0x3){INIT}: enabling: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1
+
+[test override] nft_run_cmd_from_buffer():
+add chain inet osmo-upf tunmap-pre-3;
+add rule inet osmo-upf tunmap-pre-3 ip daddr set 13.14.15.16 meta mark set 3 counter accept;
+add chain inet osmo-upf tunmap-post-3;
+add rule inet osmo-upf tunmap-post-3 ip saddr set 1.1.1.1 @ih,32,32 set 0x107 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 : jump tunmap-pre-3 };
+add element inet osmo-upf tunmap-post { 3 : jump tunmap-post-3 };
+add chain inet osmo-upf tunmap-pre-4;
+add rule inet osmo-upf tunmap-pre-4 ip daddr set 5.6.7.8 meta mark set 4 counter accept;
+add chain inet osmo-upf tunmap-post-4;
+add rule inet osmo-upf tunmap-post-4 ip saddr set 1.1.1.1 @ih,32,32 set 0x106 counter accept;
+add element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 : jump tunmap-pre-4 };
+add element inet osmo-upf tunmap-post { 4 : jump tunmap-post-4 };
+
+DNFT DEBUG run nft ruleset: "add chain inet osmo-upf tunmap-pre-3;\nadd rule inet osmo-upf tunmap-pre-3 ip daddr set 13.14.15.16 meta mark set 3 counter accept;\nadd chain inet osmo-upf tunmap-post-3;\nadd rule inet osmo-upf tunmap-post-3 ip saddr set 1.1.1.1 @ih,32,32 set 0x107 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 : jump tunmap-pre-3 };\nadd element inet osmo-upf tunmap-post { 3 : jump tunmap-post-3 };\nadd chain inet osmo-upf tunmap-pre-4;\nadd rule inet osmo-upf tunmap-pre-4 ip daddr set 5.6.7.8 meta mark set 4 counter accept;\nadd chain inet osmo-upf tunmap-post-4;\nadd rule inet osmo-upf tunmap-post-4 ip saddr set 1.1.1.1 @ih,32,32 set 0x106 counter accept;\nadd element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 : jump tunmap-pre-4 };\nadd element inet osmo-upf tunmap-post { 4 : jump tunmap-post-4 };\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1: Enabled tunmap, nft chain IDs: access--3-> <-4--core
+
+[test override] PFCP tx:
+PFCPv1 SESSION_EST_RESP hdr={seq=0 SEID=0x103} ies={ 'Node ID'=v4:unsupported family 0 'Cause'=Request accepted (success) 'F-SEID'=0x3,v4:1.1.1.1 'Created PDR'={ { 'PDR ID'=1 'F-TEID'=TEID-0x5,v4:1.1.1.1 }, { 'PDR ID'=2 'F-TEID'=TEID-0x6,v4:1.1.1.1 } } }
+
+osmo-upf created session 0x3
+
+DREF DEBUG up_session(1-2-3-4-0x3){INIT}: - msg-tx: now used by 1 (msg-rx)
+DREF DEBUG up_peer(1-2-3-4){ASSOCIATED}: - msg-tx: now used by 1 (msg-rx)
+DSESSION DEBUG up_session(1-2-3-4-0x3){INIT}: State change to ESTABLISHED (no timeout)
+DSESSION NOTICE up_session(1-2-3-4-0x3){ESTABLISHED}: Session established: peer:1.2.3.4 SEID-r:0x103 SEID-l:0x3 state:ESTABLISHED PDR-active:2/2 FAR-active:2/2 GTP-active:1
+DREF INFO up_session(1-2-3-4-0x3){ESTABLISHED}: - msg-rx: now used by 0 (-)
+DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: Received Event UP_SESSION_EV_USE_COUNT_ZERO
+DREF INFO up_peer(1-2-3-4){ASSOCIATED}: - msg-rx: now used by 0 (-)
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Received Event UP_PEER_EV_USE_COUNT_ZERO
+
+ state:
+ | peer up_peer(1-2-3-4) ASSOCIATED
+ | session[ESTABLISHED]: UP-SEID 0x3; chain_id access=3 core=4; local TEID access=0x6 core=0x5
+ | session[ESTABLISHED]: UP-SEID 0x1; chain_id access=1 core=2; local TEID access=0x2 core=0x1
+ | session[ESTABLISHED]: UP-SEID 0x2; chain_id access=1 core=2; local TEID access=0x4 core=0x3
+
+assert(s4->up_seid == 3)
+assert(a = llist_first_entry_or_null(&s4->active_gtp_actions, struct up_gtp_action, entry))
+assert(a->kind == UP_GTP_U_TUNMAP)
+assert(a->tunmap.core.tun.local.teid == 5)
+assert(a->tunmap.access.tun.local.teid == 6)
+assert(a->tunmap.access.chain_id == 5) <-- EXPECTED TO FAIL (known error)
+assert(a->tunmap.core.chain_id == 6) <-- EXPECTED TO FAIL (known error)
+
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Terminating (cause = OSMO_FSM_TERM_REGULAR)
+DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: Terminating (cause = OSMO_FSM_TERM_PARENT)
+DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: Removing from parent up_peer(1-2-3-4)
+DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: GTP actions: 1 previously active; want active: 0
+DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: active: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1
+DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: disabling: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1
+
+[test override] nft_run_cmd_from_buffer():
+delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 };
+delete element inet osmo-upf tunmap-post { 3 };
+delete chain inet osmo-upf tunmap-pre-3;
+delete chain inet osmo-upf tunmap-post-3;
+delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 };
+delete element inet osmo-upf tunmap-post { 4 };
+delete chain inet osmo-upf tunmap-pre-4;
+delete chain inet osmo-upf tunmap-post-4;
+
+DNFT DEBUG run nft ruleset: "delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x6 };\ndelete element inet osmo-upf tunmap-post { 3 };\ndelete chain inet osmo-upf tunmap-pre-3;\ndelete chain inet osmo-upf tunmap-post-3;\ndelete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x5 };\ndelete element inet osmo-upf tunmap-post { 4 };\ndelete chain inet osmo-upf tunmap-pre-4;\ndelete chain inet osmo-upf tunmap-post-4;\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x106 GTP-access-l:1.1.1.1 TEID-access-l:0x6 GTP-core-r:13.14.15.16 TEID-core-r:0x107 GTP-core-l:1.1.1.1 TEID-core-l:0x5 PFCP-peer:1.2.3.4 SEID-l:0x3 PDR-access:2 PDR-core:1: Disabled tunmap, nft chain IDs: access--3-> <-4--core
+DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: Freeing instance
+DSESSION DEBUG up_session(1-2-3-4-0x3){ESTABLISHED}: Deallocated
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: Terminating (cause = OSMO_FSM_TERM_PARENT)
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: Removing from parent up_peer(1-2-3-4)
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: GTP actions: 1 previously active; want active: 0
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: active: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x104 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x105 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: disabling: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x104 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x105 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1
+
+[test override] nft_run_cmd_from_buffer():
+delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x2 };
+delete element inet osmo-upf tunmap-post { 1 };
+delete chain inet osmo-upf tunmap-pre-1;
+delete chain inet osmo-upf tunmap-post-1;
+delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x1 };
+delete element inet osmo-upf tunmap-post { 2 };
+delete chain inet osmo-upf tunmap-pre-2;
+delete chain inet osmo-upf tunmap-post-2;
+
+DNFT DEBUG run nft ruleset: "delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x2 };\ndelete element inet osmo-upf tunmap-post { 1 };\ndelete chain inet osmo-upf tunmap-pre-1;\ndelete chain inet osmo-upf tunmap-post-1;\ndelete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x1 };\ndelete element inet osmo-upf tunmap-post { 2 };\ndelete chain inet osmo-upf tunmap-pre-2;\ndelete chain inet osmo-upf tunmap-post-2;\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x104 GTP-access-l:1.1.1.1 TEID-access-l:0x2 GTP-core-r:13.14.15.16 TEID-core-r:0x105 GTP-core-l:1.1.1.1 TEID-core-l:0x1 PFCP-peer:1.2.3.4 SEID-l:0x1 PDR-access:2 PDR-core:1: Disabled tunmap, nft chain IDs: access--1-> <-2--core
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: Freeing instance
+DSESSION DEBUG up_session(1-2-3-4-0x1){ESTABLISHED}: Deallocated
+DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: Terminating (cause = OSMO_FSM_TERM_PARENT)
+DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: Removing from parent up_peer(1-2-3-4)
+DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: GTP actions: 1 previously active; want active: 0
+DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: active: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1
+DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: disabling: GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1
+
+[test override] nft_run_cmd_from_buffer():
+delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 };
+delete element inet osmo-upf tunmap-post { 1 };
+delete chain inet osmo-upf tunmap-pre-1;
+delete chain inet osmo-upf tunmap-post-1;
+delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 };
+delete element inet osmo-upf tunmap-post { 2 };
+delete chain inet osmo-upf tunmap-pre-2;
+delete chain inet osmo-upf tunmap-post-2;
+
+DNFT DEBUG run nft ruleset: "delete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x4 };\ndelete element inet osmo-upf tunmap-post { 1 };\ndelete chain inet osmo-upf tunmap-pre-1;\ndelete chain inet osmo-upf tunmap-post-1;\ndelete element inet osmo-upf tunmap-pre { 1.1.1.1 . 0x3 };\ndelete element inet osmo-upf tunmap-post { 2 };\ndelete chain inet osmo-upf tunmap-pre-2;\ndelete chain inet osmo-upf tunmap-post-2;\n"
+DGTP NOTICE GTP:tunmap GTP-access-r:5.6.7.8 TEID-access-r:0x102 GTP-access-l:1.1.1.1 TEID-access-l:0x4 GTP-core-r:13.14.15.16 TEID-core-r:0x103 GTP-core-l:1.1.1.1 TEID-core-l:0x3 PFCP-peer:1.2.3.4 SEID-l:0x2 PDR-access:2 PDR-core:1: Disabled tunmap, nft chain IDs: access--1-> <-2--core
+DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: Freeing instance
+DSESSION DEBUG up_session(1-2-3-4-0x2){ESTABLISHED}: Deallocated
+DPEER NOTICE up_peer(1-2-3-4){ASSOCIATED}: Peer removed
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Freeing instance
+DPEER DEBUG up_peer(1-2-3-4){ASSOCIATED}: Deallocated
+[test override] nft_ctx_free()
+assert(ctx == fake_nft_ctx)
+
+===== END of test_skip_used_id
diff --git a/tests/unique_ids/unique_ids_test.ok b/tests/unique_ids/unique_ids_test.ok
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/unique_ids/unique_ids_test.ok
--
To view, visit https://gerrit.osmocom.org/c/osmo-upf/+/31482
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-upf
Gerrit-Branch: master
Gerrit-Change-Id: I36acff15f22d23ade4d281c2af3eb117dfc10359
Gerrit-Change-Number: 31482
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: newchange
1
0
[S] Change in libosmo-sccp[master]: fixup for: add osmo_scu_prim_name_c() / _buf()
by neels 24 Feb '23
by neels 24 Feb '23
24 Feb '23
neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/31434 )
Change subject: fixup for: add osmo_scu_prim_name_c() / _buf()
......................................................................
fixup for: add osmo_scu_prim_name_c() / _buf()
I would like to tweak the names for the recently added functions, so
that they are more clear -- quickly before we release it or anyone uses
these.
Depends: libosmocore I9f43428af654a5674ac3035fe4db1394aac7a7af
Related: I4c1998fd7fee7282d107846dae2cff4b5ceb3a7b
Change-Id: If381f537ab91af1feef7f0e51921217f27e18e6a
---
M TODO-RELEASE
M include/osmocom/sigtran/sccp_sap.h
M src/sccp_sap.c
3 files changed, 31 insertions(+), 9 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
neels: Looks good to me, approved
diff --git a/TODO-RELEASE b/TODO-RELEASE
index d0852fc..05e12a6 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
+libosmocore >1.8.0 uses new osmo_prim_operation_name()
diff --git a/include/osmocom/sigtran/sccp_sap.h b/include/osmocom/sigtran/sccp_sap.h
index 3930111..607c358 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -273,9 +273,15 @@
#define msgb_scu_prim(msg) ((struct osmo_scu_prim *)(msg)->l1h)
+extern const struct value_string osmo_scu_prim_type_names[];
+static inline const char *osmo_scu_prim_type_name(enum osmo_scu_prim_type val)
+{
+ return get_value_string(osmo_scu_prim_type_names, val);
+}
+
+int osmo_scu_prim_hdr_name_buf(char *buf, size_t buflen, const struct osmo_prim_hdr *oph);
+char *osmo_scu_prim_hdr_name_c(void *ctx, const struct osmo_prim_hdr *oph);
char *osmo_scu_prim_name(const struct osmo_prim_hdr *oph);
-int osmo_scu_prim_name_buf(char *buf, size_t buflen, const struct osmo_prim_hdr *oph);
-char *osmo_scu_prim_name_c(void *ctx, const struct osmo_prim_hdr *oph);
struct osmo_ss7_instance;
struct osmo_sccp_instance;
diff --git a/src/sccp_sap.c b/src/sccp_sap.c
index c0a42c6..51237ad 100644
--- a/src/sccp_sap.c
+++ b/src/sccp_sap.c
@@ -25,7 +25,7 @@
#include <osmocom/sigtran/sccp_sap.h>
-const struct value_string osmo_scu_prim_names[] = {
+const struct value_string osmo_scu_prim_type_names[] = {
{ OSMO_SCU_PRIM_N_CONNECT, "N-CONNECT" },
{ OSMO_SCU_PRIM_N_DATA, "N-DATA" },
{ OSMO_SCU_PRIM_N_EXPEDITED_DATA, "N-EXPEDITED-DATA" },
@@ -45,11 +45,11 @@
char *osmo_scu_prim_name(const struct osmo_prim_hdr *oph)
{
- osmo_scu_prim_name_buf(prim_name_buf, sizeof(prim_name_buf), oph);
+ osmo_scu_prim_hdr_name_buf(prim_name_buf, sizeof(prim_name_buf), oph);
return prim_name_buf;
}
-int osmo_scu_prim_name_buf(char *buf, size_t buflen, const struct osmo_prim_hdr *oph)
+int osmo_scu_prim_hdr_name_buf(char *buf, size_t buflen, const struct osmo_prim_hdr *oph)
{
struct osmo_strbuf sb = { .buf = buf, .len = buflen };
@@ -59,14 +59,14 @@
}
OSMO_STRBUF_PRINTF(sb, "%s.%s",
- get_value_string(osmo_scu_prim_names, oph->primitive),
- get_value_string(osmo_prim_op_names, oph->operation));
+ osmo_scu_prim_type_name(oph->primitive),
+ osmo_prim_operation_name(oph->operation));
return sb.chars_needed;
}
-char *osmo_scu_prim_name_c(void *ctx, const struct osmo_prim_hdr *oph)
+char *osmo_scu_prim_hdr_name_c(void *ctx, const struct osmo_prim_hdr *oph)
{
- OSMO_NAME_C_IMPL(ctx, 32, "ERROR", osmo_scu_prim_name_buf, oph)
+ OSMO_NAME_C_IMPL(ctx, 32, "ERROR", osmo_scu_prim_hdr_name_buf, oph)
}
#include <osmocom/sigtran/sigtran_sap.h>
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/31434
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: If381f537ab91af1feef7f0e51921217f27e18e6a
Gerrit-Change-Number: 31434
Gerrit-PatchSet: 4
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: merged
1
0
[S] Change in libosmo-sccp[master]: fixup for: add osmo_scu_prim_name_c() / _buf()
by neels 24 Feb '23
by neels 24 Feb '23
24 Feb '23
neels has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/31434 )
Change subject: fixup for: add osmo_scu_prim_name_c() / _buf()
......................................................................
Patch Set 4: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/31434
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: If381f537ab91af1feef7f0e51921217f27e18e6a
Gerrit-Change-Number: 31434
Gerrit-PatchSet: 4
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 24 Feb 2023 00:34:30 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
1
0
[XL] Change in osmo-hnbgw[master]: context map: introduce RUA and SCCP FSMs to fix leaks
by neels 24 Feb '23
by neels 24 Feb '23
24 Feb '23
Attention is currently required from: laforge, pespin.
neels has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/31431 )
Change subject: context map: introduce RUA and SCCP FSMs to fix leaks
......................................................................
Patch Set 6:
(3 comments)
Patchset:
PS5:
> Maybe I can spend yet another hour to see if I can split off very simple things. […]
hope it's easier to review now
File include/osmocom/hnbgw/context_map.h:
https://gerrit.osmocom.org/c/osmo-hnbgw/+/31431/comment/ce0c1433_7de81119
PS5, Line 22: enum map_rua_fsm_event {
> (hold on, the PLEASE_DISCONNECT should not be there anymore. […]
i tweaked the naming to include 'REQUEST' and 'INDICATION', hope that's good
File src/osmo-hnbgw/hnbgw_rua.c:
https://gerrit.osmocom.org/c/osmo-hnbgw/+/31431/comment/47c67382_58c2a19f
PS5, Line 183: { RUA_ProcedureCode_id_Connect, "id-Connect" },
> ah ok, was not aware of that!
Done
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/31431
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I6ff7e36532ff57c6f2d3e7e419dd22ef27dafd19
Gerrit-Change-Number: 31431
Gerrit-PatchSet: 6
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 24 Feb 2023 00:33:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de>
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment
1
0
neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/31428 )
Change subject: log tweak
......................................................................
log tweak
Change-Id: Ib6f8c46355d4748089e59c80fc1c8c736c887a26
---
M src/osmo-hnbgw/hnbgw_rua.c
1 file changed, 12 insertions(+), 3 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/src/osmo-hnbgw/hnbgw_rua.c b/src/osmo-hnbgw/hnbgw_rua.c
index 2160694..5581148 100644
--- a/src/osmo-hnbgw/hnbgw_rua.c
+++ b/src/osmo-hnbgw/hnbgw_rua.c
@@ -128,7 +128,7 @@
&out);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RUA_DirectTransfer, &out);
- LOGHNB(hnb, DRUA, LOGL_DEBUG, "transmitting RUA (cn=%s) payload of %u bytes\n",
+ LOGHNB(hnb, DRUA, LOGL_DEBUG, "transmitting RUA DirectTransfer (cn=%s) payload of %u bytes\n",
is_ps ? "ps" : "cs", msgb_length(msg));
return hnbgw_rua_tx(hnb, msg);
@@ -167,9 +167,9 @@
&out);
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RUA_Disconnect, &out);
- LOGHNB(hnb, DRUA, LOGL_DEBUG, "transmitting RUA (cn=%s) payload of %u bytes\n",
- is_ps ? "ps" : "cs", msgb_length(msg));
+ LOGHNB(hnb, DRUA, LOGL_DEBUG, "transmitting RUA Disconnect (cn=%s) payload of %u bytes\n",
+ is_ps ? "ps" : "cs", msgb_length(msg));
return hnbgw_rua_tx(hnb, msg);
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/31428
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Ib6f8c46355d4748089e59c80fc1c8c736c887a26
Gerrit-Change-Number: 31428
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: merged
1
0
23 Feb '23
Attention is currently required from: osmith.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/31473 )
Change subject: Bump version: 1.5.0.2-b7d85 → 1.5.1
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/31473
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hlr
Gerrit-Branch: osmith/1.5.1
Gerrit-Change-Id: I48caf0329140d6e5ff90d42d6c7c01deb05d35d0
Gerrit-Change-Number: 31473
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 23 Feb 2023 21:28:19 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
1
0
[S] Change in osmo-hlr[osmith/1.5.1]: tests: adjust to XOR-3G rename in libosmocore
by fixeria 23 Feb '23
by fixeria 23 Feb '23
23 Feb '23
Attention is currently required from: osmith.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/31472 )
Change subject: tests: adjust to XOR-3G rename in libosmocore
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/31472
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hlr
Gerrit-Branch: osmith/1.5.1
Gerrit-Change-Id: I391b1a9b52e1969172aba9d4a1cc5792fc077fe1
Gerrit-Change-Number: 31472
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 23 Feb 2023 21:28:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
1
0