VTY: rename 'gtp' to 'tunend'

So far the config nodes were named after the implementation:
"GTP kernel module" = "gtp" and
"netfilter" = "nft"

We found that this is confusing, since both are related to handling GTP.
Rename "gtp" to "tunend"; a subsequent patch will rename "nft" to
"tunmap".

Keep a hidden "gtp" VTY cmd as backwards compat alias.

In log output, also print "tunend" instead of "endecaps"
(up_gtp_action_to_str_buf()).

Related: SYS#6192
Change-Id: I49ac7b1f8b5b74f586edfed1dfb29f9af55a521b
This commit is contained in:
Neels Janosch Hofmeyr
2022-11-18 13:18:31 +01:00
parent 80aefa42c6
commit 95eb2c6a89
10 changed files with 65 additions and 57 deletions

View File

@@ -21,7 +21,7 @@ ctrl
timer pfcp x24 5000
pfcp
local-addr 127.0.0.11
gtp
tunend
dev create apn11 127.0.0.11
nft
table-name osmo-upf-11

View File

@@ -21,7 +21,7 @@ ctrl
timer pfcp x24 5000
pfcp
local-addr 127.0.0.12
gtp
tunend
dev create apn12 127.0.0.12
nft
table-name osmo-upf-12

View File

@@ -11,5 +11,5 @@ log stderr
timer pfcp x24 5000
pfcp
local-addr 127.0.0.1
gtp
tunend
dev create apn23

View File

@@ -11,7 +11,7 @@ log stderr
timer pfcp x24 5000
pfcp
local-addr 127.0.0.1
gtp
tunend
mockup
nft
mockup

View File

@@ -44,7 +44,7 @@ struct pfcp_vty_cfg {
uint16_t local_port;
};
struct gtp_vty_cfg_dev {
struct tunend_vty_cfg_dev {
struct llist_head entry;
/* If true, osmo-upf creates the GTP device on startup. If false, the GTP device was created by the user, and we
@@ -60,8 +60,8 @@ struct gtp_vty_cfg_dev {
char *local_addr;
};
struct gtp_vty_cfg {
/* list of struct gtp_vty_cfg_dev, GTP devices as in the config file. The actual GTP devices in use are in
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. */
struct llist_head devs;
};
@@ -80,7 +80,7 @@ struct g_upf {
bool mockup;
/* GTP devices as in osmo-upf.cfg */
struct gtp_vty_cfg vty_cfg;
struct tunend_vty_cfg vty_cfg;
/* GTP devices actually in use, list of struct upf_gtp_dev. */
struct llist_head devs;

View File

@@ -84,7 +84,7 @@ static int up_gtp_action_enable_disable(struct up_gtp_action *a, bool enable)
switch (a->kind) {
case UP_GTP_U_ENDECAPS:
if (g_upf->gtp.mockup) {
LOG_UP_GTP_ACTION(a, LOGL_NOTICE, "gtp/mockup active, skipping GTP action %s\n",
LOG_UP_GTP_ACTION(a, LOGL_NOTICE, "tunend/mockup active, skipping GTP action %s\n",
enable ? "enable" : "disable");
return 0;
}
@@ -166,7 +166,7 @@ int up_gtp_action_to_str_buf(char *buf, size_t buflen, const struct up_gtp_actio
struct osmo_strbuf sb = { .buf = buf, .len = buflen };
switch (a->kind) {
case UP_GTP_U_ENDECAPS:
OSMO_STRBUF_PRINTF(sb, "GTP:endecaps GTP-access:");
OSMO_STRBUF_PRINTF(sb, "GTP:tunend GTP-access:");
OSMO_STRBUF_APPEND(sb, osmo_sockaddr_to_str_buf2, &a->endecaps.gtp_remote_addr);
OSMO_STRBUF_PRINTF(sb, " TEID-r:0x%"PRIx32" TEID-l:0x%"PRIx32" IP-core:",
a->endecaps.remote_teid, a->endecaps.local_teid);

View File

@@ -87,8 +87,8 @@ int upf_pfcp_listen()
int upf_gtp_devs_open()
{
struct gtp_vty_cfg *c = &g_upf->gtp.vty_cfg;
struct gtp_vty_cfg_dev *d;
struct tunend_vty_cfg *c = &g_upf->gtp.vty_cfg;
struct tunend_vty_cfg_dev *d;
llist_for_each_entry(d, &c->devs, entry) {
if (upf_gtp_dev_open(d->dev_name, d->create, d->local_addr, false, false))

View File

@@ -173,7 +173,7 @@ int upf_gtp_dev_open(const char *name, bool create_gtp_dev, const char *local_ad
struct upf_gtp_dev *dev;
if (g_upf->gtp.mockup) {
LOGP(DGTP, LOGL_NOTICE, "gtp/mockup active: not opening GTP device '%s'\n", name);
LOGP(DGTP, LOGL_NOTICE, "tunend/mockup active: not opening GTP device '%s'\n", name);
return 0;
}

View File

@@ -40,7 +40,7 @@
enum upf_vty_node {
PFCP_NODE = _LAST_OSMOVTY_NODE + 1,
GTP_NODE,
TUNEND_NODE,
NFT_NODE,
};
@@ -51,7 +51,7 @@ static struct cmd_node cfg_pfcp_node = {
};
#define pfcp_vty (g_upf->pfcp.vty_cfg)
#define gtp_vty (g_upf->gtp.vty_cfg)
#define tunend_vty (g_upf->gtp.vty_cfg)
DEFUN(cfg_pfcp, cfg_pfcp_cmd,
"pfcp",
@@ -78,29 +78,32 @@ DEFUN(cfg_pfcp_local_addr, cfg_pfcp_local_addr_cmd,
return CMD_SUCCESS;
}
static struct cmd_node cfg_gtp_node = {
GTP_NODE,
"%s(config-gtp)# ",
static struct cmd_node cfg_tunend_node = {
TUNEND_NODE,
"%s(config-tunend)# ",
1,
};
DEFUN(cfg_gtp, cfg_gtp_cmd,
"gtp",
"Enter the 'gtp' node to configure Linux GTP kernel module usage\n")
#define TUNEND_NODE_STR "Enter the 'tunend' node to configure Linux GTP kernel module usage\n"
DEFUN(cfg_tunend, cfg_tunend_cmd, "tunend", TUNEND_NODE_STR)
{
vty->node = GTP_NODE;
vty->node = TUNEND_NODE;
return CMD_SUCCESS;
}
static int config_write_gtp(struct vty *vty)
/* legacy compat: "tunend" was originally named "gtp" */
DEFUN_CMD_ELEMENT(cfg_tunend, cfg_gtp_cmd, "gtp", TUNEND_NODE_STR, CMD_ATTR_HIDDEN, 0);
static int config_write_tunend(struct vty *vty)
{
struct gtp_vty_cfg_dev *d;
vty_out(vty, "gtp%s", VTY_NEWLINE);
struct tunend_vty_cfg_dev *d;
vty_out(vty, "tunend%s", VTY_NEWLINE);
if (g_upf->gtp.mockup)
vty_out(vty, " mockup%s", VTY_NEWLINE);
llist_for_each_entry(d, &gtp_vty.devs, entry) {
llist_for_each_entry(d, &tunend_vty.devs, entry) {
if (d->create) {
vty_out(vty, " dev create %s", d->dev_name);
if (d->local_addr)
@@ -115,7 +118,7 @@ static int config_write_gtp(struct vty *vty)
#define DEV_STR "Configure the GTP device to use for encaps/decaps.\n"
DEFUN(cfg_gtp_mockup, cfg_gtp_mockup_cmd,
DEFUN(cfg_tunend_mockup, cfg_tunend_mockup_cmd,
"mockup",
"don't actually send commands to the GTP kernel module, just return success\n")
{
@@ -123,7 +126,7 @@ DEFUN(cfg_gtp_mockup, cfg_gtp_mockup_cmd,
return CMD_SUCCESS;
}
DEFUN(cfg_gtp_no_mockup, cfg_gtp_no_mockup_cmd,
DEFUN(cfg_tunend_no_mockup, cfg_tunend_no_mockup_cmd,
"no mockup",
NO_STR
"operate GTP kernel module normally\n")
@@ -132,7 +135,7 @@ DEFUN(cfg_gtp_no_mockup, cfg_gtp_no_mockup_cmd,
return CMD_SUCCESS;
}
DEFUN(cfg_gtp_dev_create, cfg_gtp_dev_create_cmd,
DEFUN(cfg_tunend_dev_create, cfg_tunend_dev_create_cmd,
"dev create DEVNAME [LISTEN_ADDR]",
DEV_STR
"Add GTP device, creating a new Linux kernel GTP device. Will listen on GTPv1 port "
@@ -142,42 +145,42 @@ DEFUN(cfg_gtp_dev_create, cfg_gtp_dev_create_cmd,
"device name, e.g. 'apn0'\n"
"IPv4 or IPv6 address to listen on, omit for ANY\n")
{
struct gtp_vty_cfg_dev *d = talloc_zero(g_upf, struct gtp_vty_cfg_dev);
struct tunend_vty_cfg_dev *d = talloc_zero(g_upf, struct tunend_vty_cfg_dev);
d->create = true;
d->dev_name = talloc_strdup(d, argv[0]);
if (argc > 1)
d->local_addr = talloc_strdup(d, argv[1]);
llist_add(&d->entry, &gtp_vty.devs);
llist_add(&d->entry, &tunend_vty.devs);
vty_out(vty, "Added GTP device %s (create new)%s", d->dev_name, VTY_NEWLINE);
return CMD_SUCCESS;
}
DEFUN(cfg_gtp_dev_use, cfg_gtp_dev_use_cmd,
DEFUN(cfg_tunend_dev_use, cfg_tunend_dev_use_cmd,
"dev use DEVNAME",
DEV_STR
"Add GTP device, using an existing Linux kernel GTP device, e.g. created by 'gtp-link'\n"
"device name, e.g. 'apn0'\n")
{
struct gtp_vty_cfg_dev *d = talloc_zero(g_upf, struct gtp_vty_cfg_dev);
struct tunend_vty_cfg_dev *d = talloc_zero(g_upf, struct tunend_vty_cfg_dev);
d->create = false;
d->dev_name = talloc_strdup(d, argv[0]);
llist_add(&d->entry, &gtp_vty.devs);
llist_add(&d->entry, &tunend_vty.devs);
vty_out(vty, "Added GTP device %s (use existing)%s", d->dev_name, VTY_NEWLINE);
return CMD_SUCCESS;
}
DEFUN(cfg_gtp_dev_del, cfg_gtp_dev_del_cmd,
DEFUN(cfg_tunend_dev_del, cfg_tunend_dev_del_cmd,
"dev delete DEVNAME",
DEV_STR
"Remove a GTP device from the configuration, and delete the Linux kernel GTP device if it was created here.\n"
"device name, e.g. 'apn0'\n")
{
const char *dev_name = argv[0];
struct gtp_vty_cfg_dev *d;
struct tunend_vty_cfg_dev *d;
struct upf_gtp_dev *dev;
/* remove from VTY cfg */
llist_for_each_entry(d, &gtp_vty.devs, entry) {
llist_for_each_entry(d, &tunend_vty.devs, entry) {
if (strcmp(d->dev_name, dev_name))
continue;
llist_del(&d->entry);
@@ -280,8 +283,8 @@ DEFUN(show_pdr, show_pdr_cmd,
return CMD_SUCCESS;
}
DEFUN(show_gtp, show_gtp_cmd,
"show gtp",
DEFUN(show_tunend, show_tunend_cmd,
"show tunend",
SHOW_STR
"Active GTP tunnels and forwardings\n")
{
@@ -345,7 +348,7 @@ void upf_vty_init()
OSMO_ASSERT(g_upf != NULL);
install_element_ve(&show_pdr_cmd);
install_element_ve(&show_gtp_cmd);
install_element_ve(&show_tunend_cmd);
install_element_ve(&show_session_cmd);
install_node(&cfg_pfcp_node, config_write_pfcp);
@@ -353,14 +356,15 @@ void upf_vty_init()
install_element(PFCP_NODE, &cfg_pfcp_local_addr_cmd);
install_node(&cfg_gtp_node, config_write_gtp);
install_node(&cfg_tunend_node, config_write_tunend);
install_element(CONFIG_NODE, &cfg_tunend_cmd);
install_element(CONFIG_NODE, &cfg_gtp_cmd);
install_element(GTP_NODE, &cfg_gtp_mockup_cmd);
install_element(GTP_NODE, &cfg_gtp_no_mockup_cmd);
install_element(GTP_NODE, &cfg_gtp_dev_create_cmd);
install_element(GTP_NODE, &cfg_gtp_dev_use_cmd);
install_element(GTP_NODE, &cfg_gtp_dev_del_cmd);
install_element(TUNEND_NODE, &cfg_tunend_mockup_cmd);
install_element(TUNEND_NODE, &cfg_tunend_no_mockup_cmd);
install_element(TUNEND_NODE, &cfg_tunend_dev_create_cmd);
install_element(TUNEND_NODE, &cfg_tunend_dev_use_cmd);
install_element(TUNEND_NODE, &cfg_tunend_dev_del_cmd);
install_node(&cfg_nft_node, config_write_nft);
install_element(CONFIG_NODE, &cfg_nft_cmd);

View File

@@ -13,8 +13,9 @@ OsmoUPF(config-pfcp)# local-addr ?
IP_ADDR IP address
OsmoUPF(config-pfcp)# exit
OsmoUPF(config)# # ensure its old name "gtp" enters the tunend node
OsmoUPF(config)# gtp
OsmoUPF(config-gtp)# list
OsmoUPF(config-tunend)# list
...
mockup
no mockup
@@ -22,24 +23,27 @@ OsmoUPF(config-gtp)# list
dev use DEVNAME
dev delete DEVNAME
OsmoUPF(config-gtp)# mockup?
mockup don't actually send commands to the GTP kernel module, just return success
OsmoUPF(config-gtp)# no ?
mockup operate GTP kernel module normally
OsmoUPF(config-tunend)# exit
OsmoUPF(config)# tunend
OsmoUPF(config-tunend)# list
...
dev create DEVNAME [LISTEN_ADDR]
dev use DEVNAME
dev delete DEVNAME
OsmoUPF(config-gtp)# dev?
OsmoUPF(config-tunend)# dev?
dev Configure the GTP device to use for encaps/decaps.
OsmoUPF(config-gtp)# dev ?
OsmoUPF(config-tunend)# dev ?
create Add GTP device, creating a new Linux kernel GTP device. Will listen on GTPv1 port 2152 and GTPv0 port 3386 on the specified interface, or on ANY if LISTEN_ADDR is omitted.
use Add GTP device, using an existing Linux kernel GTP device, e.g. created by 'gtp-link'
delete Remove a GTP device from the configuration, and delete the Linux kernel GTP device if it was created here.
OsmoUPF(config-gtp)# dev create ?
OsmoUPF(config-tunend)# dev create ?
DEVNAME device name, e.g. 'apn0'
OsmoUPF(config-gtp)# dev create foo ?
OsmoUPF(config-tunend)# dev create foo ?
[LISTEN_ADDR] IPv4 or IPv6 address to listen on, omit for ANY
OsmoUPF(config-gtp)# dev delete ?
OsmoUPF(config-tunend)# dev delete ?
DEVNAME device name, e.g. 'apn0'
OsmoUPF(config-gtp)# exit
OsmoUPF(config-tunend)# exit
OsmoUPF(config)# nft
OsmoUPF(config-nft)# list