neels has submitted this change. (
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(-)
Approvals:
Jenkins Builder: Verified
msuraev: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
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-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: msuraev <msuraev(a)sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: merged