[PATCH] osmo-ggsn[master]: gtp_kernel: Change gtp_kernel_init() function signature

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Nov 13 15:00:50 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/4810

to look at the new patch set (#2).

gtp_kernel: Change gtp_kernel_init() function signature

Rather than taking an explicit in_addr, prefix_length and a
string-formatted prefix, let's pass in an in46_prefix and derive
the other representations from it.

Also, don't refer to a no-longer-existing global 'ipup' variable but
add it as a function argument.

Change-Id: Ife87142c86589b4fa4062d62afe3670467548589
---
M ggsn/gtp-kernel.c
M ggsn/gtp-kernel.h
2 files changed, 16 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/10/4810/2

diff --git a/ggsn/gtp-kernel.c b/ggsn/gtp-kernel.c
index 916b92f..a5708fc 100644
--- a/ggsn/gtp-kernel.c
+++ b/ggsn/gtp-kernel.c
@@ -57,9 +57,18 @@
 /* Always forces the kernel to allocate gtp0. If it exists it hits EEXIST */
 #define GTP_DEVNAME	"gtp0"
 
-int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
-		    size_t prefixlen, const char *net_arg)
+int gtp_kernel_init(struct gsn_t *gsn, struct in46_prefix *prefix, const char *ipup)
 {
+	struct in_addr net;
+	const char *net_arg;
+
+	if (prefix->addr.len != 4) {
+		SYS_ERR(DGGSN, LOGL_ERROR, 0,
+			"we only support IPv4 in this path :/");
+		return -1;
+	}
+	net = prefix->addr.v4;
+
 	if (gtp_dev_create(-1, GTP_DEVNAME, gsn->fd0, gsn->fd1u) < 0) {
 		SYS_ERR(DGGSN, LOGL_ERROR, 0,
 			"cannot create GTP tunnel device: %s\n",
@@ -83,10 +92,12 @@
 	SYS_ERR(DGGSN, LOGL_DEBUG, 0,
 		"Using the GTP kernel mode (genl ID is %d)\n", gtp_nl.genl_id);
 
+	net_arg = in46p_ntoa(prefix);
+
 	DEBUGP(DGGSN, "Setting route to reach %s via %s\n",
 	       net_arg, GTP_DEVNAME);
 
-	if (gtp_dev_config(GTP_DEVNAME, net, prefixlen) < 0) {
+	if (gtp_dev_config(GTP_DEVNAME, &net, prefix->prefixlen) < 0) {
 		SYS_ERR(DGGSN, LOGL_ERROR, 0,
 			"Cannot add route to reach network %s\n",
 			net_arg);
diff --git a/ggsn/gtp-kernel.h b/ggsn/gtp-kernel.h
index 34fd7bf..ce57994 100644
--- a/ggsn/gtp-kernel.h
+++ b/ggsn/gtp-kernel.h
@@ -7,8 +7,7 @@
 extern char *ipup;
 
 #ifdef GTP_KERNEL
-int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
-		    size_t prefixlen, const char *net_arg);
+int gtp_kernel_init(struct gsn_t *gsn, struct in46_prefix *prefix, const char *ipup);
 void gtp_kernel_stop(void);
 
 int gtp_kernel_tunnel_add(struct pdp_t *pdp);
@@ -17,8 +16,7 @@
 int gtp_kernel_enabled(void);
 
 #else
-static inline int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
-				  size_t prefixlen, const char *net_arg)
+static inline int gtp_kernel_init(struct gsn_t *gsn, struct in46_prefix *prefix, const char *ipup)
 {
 	SYS_ERR(DGGSN, LOGL_ERROR, 0, "ggsn compiled without GTP kernel support!\n");
 	return -1;

-- 
To view, visit https://gerrit.osmocom.org/4810
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ife87142c86589b4fa4062d62afe3670467548589
Gerrit-PatchSet: 2
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list