osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libgtpnl/+/35987?usp=email )


Change subject: gtp: provide interface to set family
......................................................................

gtp: provide interface to set family

Kernel now supports for TID/I_TEI to be used in both IPv4 and IPv6 GTP
tunnels. This improves dualstack support for MS/UE so GTP traffic can
be identified with the same tunnel identifier.

Update gtp-tunnel to specify the family, since a tunnel is now
identified by the following tuple [ version, identifier, family ].

Change-Id: I584d3997ffb89cd430dfda9615a4ce0ce517ab2a
---
M include/libgtpnl/gtp.h
M src/gtp.c
M src/libgtpnl.map
M tools/gtp-link.c
M tools/gtp-tunnel.c
5 files changed, 40 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libgtpnl refs/changes/87/35987/1

diff --git a/include/libgtpnl/gtp.h b/include/libgtpnl/gtp.h
index 9b0bcf4..796932b 100644
--- a/include/libgtpnl/gtp.h
+++ b/include/libgtpnl/gtp.h
@@ -11,6 +11,7 @@

 void gtp_tunnel_set_ifns(struct gtp_tunnel *t, int ifns);
 void gtp_tunnel_set_ifidx(struct gtp_tunnel *t, uint32_t ifidx);
+void gtp_tunnel_set_family(struct gtp_tunnel *t, uint16_t family);
 void gtp_tunnel_set_ms_ip4(struct gtp_tunnel *t, struct in_addr *ms_addr);
 void gtp_tunnel_set_sgsn_ip4(struct gtp_tunnel *t, struct in_addr *sgsn_addr);
 void gtp_tunnel_set_ms_ip6(struct gtp_tunnel *t, const struct in6_addr 
*ms_addr);
diff --git a/src/gtp.c b/src/gtp.c
index 657eb7a..0c378c4 100644
--- a/src/gtp.c
+++ b/src/gtp.c
@@ -58,6 +58,12 @@
 }
 EXPORT_SYMBOL(gtp_tunnel_set_ifidx);

+void gtp_tunnel_set_family(struct gtp_tunnel *t, uint16_t family)
+{
+       t->ms_addr.family = family;
+}
+EXPORT_SYMBOL(gtp_tunnel_set_family);
+
 void gtp_tunnel_set_ms_ip4(struct gtp_tunnel *t, struct in_addr *ms_addr)
 {
        t->ms_addr.family = AF_INET;
diff --git a/src/libgtpnl.map b/src/libgtpnl.map
index 1237e69..41b7dd7 100644
--- a/src/libgtpnl.map
+++ b/src/libgtpnl.map
@@ -43,3 +43,7 @@
   gtp_tunnel_set_ms_ip6;
   gtp_tunnel_set_sgsn_ip6;
 } LIBGTPNL_1.0;
+
+LIBGTPNL_1.2 {
+  gtp_tunnel_set_family;
+} LIBGTPNL_1.1;
diff --git a/tools/gtp-link.c b/tools/gtp-link.c
index 6979459..325a45f 100644
--- a/tools/gtp-link.c
+++ b/tools/gtp-link.c
@@ -75,6 +75,7 @@
 {
        int fd1 = socket(family, SOCK_DGRAM, 0);
        int fd2 = socket(family, SOCK_DGRAM, 0);
+       int one = 1;

        if (fd1 < 0 || fd2 < 0)
                return -1;
diff --git a/tools/gtp-tunnel.c b/tools/gtp-tunnel.c
index 1fcdee7..1b8a7a0 100644
--- a/tools/gtp-tunnel.c
+++ b/tools/gtp-tunnel.c
@@ -131,8 +131,8 @@
        struct gtp_tunnel *t;
        uint32_t gtp_ifidx;

-       if (argc != 5) {
-               printf("%s del <gtp device> <version> <tid>\n",
+       if (argc != 6) {
+               printf("%s del <gtp device> <version> <tid> <family>\n",
                        argv[0]);
                return EXIT_FAILURE;
        }
@@ -160,6 +160,16 @@
                return EXIT_FAILURE;
        }

+       if (strcmp(argv[5], "ip") == 0) {
+               gtp_tunnel_set_family(t, AF_INET);
+       } else if (strcmp(argv[5], "ip6") == 0) {
+               gtp_tunnel_set_family(t, AF_INET6);
+       } else {
+               fprintf(stderr, "wrong family %s, use ip or ip6\n", argv[5]);
+               gtp_tunnel_free(t);
+               return EXIT_FAILURE;
+       }
+
        gtp_del_tunnel(genl_id, nl, t);

        gtp_tunnel_free(t);

--
To view, visit https://gerrit.osmocom.org/c/libgtpnl/+/35987?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libgtpnl
Gerrit-Branch: master
Gerrit-Change-Id: I584d3997ffb89cd430dfda9615a4ce0ce517ab2a
Gerrit-Change-Number: 35987
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>
Gerrit-MessageType: newchange

Reply via email to