pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-ggsn/+/38484?usp=email )
(
2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: ggsn: apply configured APN MTU to tun
......................................................................
ggsn: apply configured APN MTU to tun
Related: OS#6298
Related: SYS#7122
Change-Id: Ifae556169d895860812c9ea5633292d7e3fab338
---
M ggsn/ggsn.c
M ggsn/ggsn.h
M ggsn/ggsn_vty.c
3 files changed, 33 insertions(+), 3 deletions(-)
Approvals:
osmith: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index ad23dd9..c73a46d 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -307,6 +307,16 @@
return -1;
}
+ if (apn->tun.cfg.mtu_apply) {
+ rc = osmo_netdev_set_mtu(apn->tun.tun->netdev, apn->cfg.mtu);
+ if (rc < 0) {
+ LOGPAPN(LOGL_ERROR, apn, "Failed to set tun interface MTU %u: %s\n",
+ apn->cfg.mtu, strerror(errno));
+ apn_stop(apn);
+ return -1;
+ }
+ }
+
if (apn->tun.cfg.ipup_script) {
LOGPAPN(LOGL_INFO, apn, "Running ip-up script %s\n",
apn->tun.cfg.ipup_script);
diff --git a/ggsn/ggsn.h b/ggsn/ggsn.h
index bd953a4..23df05e 100644
--- a/ggsn/ggsn.h
+++ b/ggsn/ggsn.h
@@ -95,6 +95,8 @@
/* ip-up and ip-down script names/paths */
char *ipup_script;
char *ipdown_script;
+ /* Whether to apply the MTU (apn->cfg.mtu) on the tun device: */
+ bool mtu_apply;
} cfg;
struct tun_t *tun;
} tun;
diff --git a/ggsn/ggsn_vty.c b/ggsn/ggsn_vty.c
index eda0096..b0f07fe 100644
--- a/ggsn/ggsn_vty.c
+++ b/ggsn/ggsn_vty.c
@@ -422,16 +422,33 @@
/* MAX_POSSIBLE_APN_MTU = 9000
* MAX_DESIRED_APN_MTU = 1420 */
DEFUN(cfg_apn_mtu, cfg_apn_mtu_cmd,
- "mtu (<0-" OSMO_STRINGIFY_VAL(MAX_POSSIBLE_APN_MTU)
">|default)",
+ "mtu (<0-" OSMO_STRINGIFY_VAL(MAX_POSSIBLE_APN_MTU) ">|default)
[apply]",
"Configure announced MTU\n"
"MTU of the APN, announced to the UE\n"
- "Default value of the MTU of the APN (1420)\n")
+ "Default value of the MTU of the APN (1420)\n"
+ "Apply the MTU on the tun-device of the APN\n")
{
struct apn_ctx *apn = (struct apn_ctx *) vty->index;
+ int rc;
+
if (strcmp(argv[0], "default") == 0)
apn->cfg.mtu = MAX_DESIRED_APN_MTU;
else
apn->cfg.mtu = atoi(argv[0]);
+ apn->tun.cfg.mtu_apply = (argc > 1);
+
+ if (apn->tun.cfg.mtu_apply && apn->tun.tun) {
+ rc = osmo_netdev_set_mtu(apn->tun.tun->netdev, apn->cfg.mtu);
+ if (rc < 0) {
+ char buf_err[128];
+ strerror_r(errno, buf_err, sizeof(buf_err));
+ LOGPAPN(LOGL_ERROR, apn, "Failed to set tun interface MTU %u: %s (%d)\n",
+ apn->cfg.mtu, buf_err, rc);
+ vty_out(vty, "%% Failed to set tun interface MTU %u: %s (%d)%s",
+ apn->cfg.mtu, buf_err, rc, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
return CMD_SUCCESS;
}
@@ -705,7 +722,8 @@
VTY_NEWLINE);
}
- vty_out(vty, " mtu %" PRIu16 "%s", apn->cfg.mtu, VTY_NEWLINE);
+ vty_out(vty, " mtu %" PRIu16 "%s%s", apn->cfg.mtu,
+ apn->tun.cfg.mtu_apply ? " apply" : "", VTY_NEWLINE);
if (!apn->cfg.tx_gpdu_seq)
vty_out(vty, " no g-pdu tx-sequence-numbers%s", VTY_NEWLINE);
--
To view, visit
https://gerrit.osmocom.org/c/osmo-ggsn/+/38484?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: Ifae556169d895860812c9ea5633292d7e3fab338
Gerrit-Change-Number: 38484
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>