laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ggsn/+/22732 )

Change subject: apn_start: avoid segfault if missing tun-device
......................................................................

apn_start: avoid segfault if missing tun-device

Check if tun-device is defined and give the user a hint that it is
missing instead of segfaulting with gtpu-mode kernel-gtp:
  20210205141701206 DGGSN <0002> ggsn.c:186 APN(internet): Starting
  20210205141701206 DGGSN <0002> ggsn.c:204 APN(internet): Opening Kernel GTP 
device (null)
  Segmentation fault

With gtpu-mode tun it didn't segfault, but still tried to open the NULL
device:
  20210205141557598 DGGSN <0002> ggsn.c:186 APN(internet): Starting
  20210205141557599 DGGSN <0002> ggsn.c:189 APN(internet): Opening TUN device 
(null)
  20210205141557599 DTUN <0001> tun.c:195 errno=1/Operation not permitted 
ioctl() failed

Related: OS#3208
Change-Id: I9f71af65cc0eed71728c04b774e5c08352947913
---
M ggsn/ggsn_vty.c
1 file changed, 4 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/ggsn/ggsn_vty.c b/ggsn/ggsn_vty.c
index f76018e..71d8ff6 100644
--- a/ggsn/ggsn_vty.c
+++ b/ggsn/ggsn_vty.c
@@ -699,6 +699,10 @@
        struct apn_ctx *apn = (struct apn_ctx *) vty->index;

        if (apn->cfg.shutdown) {
+               if (!apn->tun.cfg.dev_name) {
+                       vty_out(vty, "%% Failed to start APN, tun-device is not 
configured%s", VTY_NEWLINE);
+                       return CMD_WARNING;
+               }
                if (apn_start(apn) < 0) {
                        vty_out(vty, "%% Failed to start APN, check log for 
details%s", VTY_NEWLINE);
                        return CMD_WARNING;

--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/22732
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I9f71af65cc0eed71728c04b774e5c08352947913
Gerrit-Change-Number: 22732
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to