neels has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-upf/+/29210 )

Change subject: Allow running without a GTP dev
......................................................................

Allow running without a GTP dev

Allow running without opening a GTP dev for encapsulation/decapsulation.
Probe and open the mnl socket for talking to the GTP kernel module only
when actual GTP devices exist in the config.

A site that is only doing tunnel proxying via netfilter hence does not
require GTP support in the kernel.

Change-Id: Ibb79b3ce1906136f77a895ff6f691d72a92c9fb9
---
M include/osmocom/upf/upf_gtp.h
M src/osmo-upf/osmo_upf_main.c
M src/osmo-upf/upf_gtp.c
3 files changed, 8 insertions(+), 10 deletions(-)

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



diff --git a/include/osmocom/upf/upf_gtp.h b/include/osmocom/upf/upf_gtp.h
index a67c850..1e0df5e 100644
--- a/include/osmocom/upf/upf_gtp.h
+++ b/include/osmocom/upf/upf_gtp.h
@@ -69,7 +69,7 @@

 int upf_gtp_tun_desc_cmp(const struct upf_gtp_tun_desc *a, const struct 
upf_gtp_tun_desc *b);

-int upf_gtp_genl_open();
+int upf_gtp_genl_ensure_open();
 void upf_gtp_genl_close();

 int upf_gtp_dev_open(const char *name, bool create_gtp_dev, const char 
*local_addr, bool listen_for_gtpv0,
diff --git a/src/osmo-upf/osmo_upf_main.c b/src/osmo-upf/osmo_upf_main.c
index b4888af..65a0e84 100644
--- a/src/osmo-upf/osmo_upf_main.c
+++ b/src/osmo-upf/osmo_upf_main.c
@@ -331,9 +331,6 @@
                }
        }

-       if (upf_gtp_genl_open())
-               return -1;
-
        if (upf_gtp_devs_open())
                return -1;

diff --git a/src/osmo-upf/upf_gtp.c b/src/osmo-upf/upf_gtp.c
index 6280e45..d75e8d7 100644
--- a/src/osmo-upf/upf_gtp.c
+++ b/src/osmo-upf/upf_gtp.c
@@ -183,6 +183,12 @@

        dev->sgsn_mode = sgsn_mode;

+       rc = upf_gtp_genl_ensure_open();
+       if (rc) {
+               LOG_GTP_DEV(dev, LOGL_ERROR, "Cannot set up GTP device, failed 
to open mnl_socket\n");
+               return rc;
+       }
+
        if (listen_for_gtpv0) {
                rc = osmo_sock_init_osa_ofd(&dev->gtpv0.ofd, SOCK_DGRAM, 0, 
&dev->gtpv0.local_addr, &any,
                                            OSMO_SOCK_F_BIND);
@@ -255,13 +261,8 @@
 }

 /* Open an MNL socket which allows to create and remove GTP devices (requires 
CAP_NET_ADMIN). */
-int upf_gtp_genl_open()
+int upf_gtp_genl_ensure_open()
 {
-       if (g_upf->gtp.mockup) {
-               LOGP(DGTP, LOGL_NOTICE, "gtp/mockup active: not opening 
mnl_socket\n");
-               return 0;
-       }
-
        /* Already open? */
        if (g_upf->gtp.nl && g_upf->gtp.genl_id >= 0)
                return 0;

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

Gerrit-Project: osmo-upf
Gerrit-Branch: master
Gerrit-Change-Id: Ibb79b3ce1906136f77a895ff6f691d72a92c9fb9
Gerrit-Change-Number: 29210
Gerrit-PatchSet: 2
Gerrit-Owner: neels <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: neels <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to