[PATCH] osmo-ggsn[master]: gtp-kernel: Avoid global state variable

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
Sun Nov 12 22:13:56 UTC 2017


Review at  https://gerrit.osmocom.org/4818

gtp-kernel: Avoid global state variable

Whether or not GTP kernel support is enabled is the property of a
given APN, and not a global state variable.

Change-Id: Iff3bd8a52bd6c20f9811ee41ff700486d08591f3
---
M ggsn/gtp-kernel.c
M ggsn/gtp-kernel.h
2 files changed, 0 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/18/4818/1

diff --git a/ggsn/gtp-kernel.c b/ggsn/gtp-kernel.c
index 102f0f7..e1553bd 100644
--- a/ggsn/gtp-kernel.c
+++ b/ggsn/gtp-kernel.c
@@ -51,7 +51,6 @@
 static struct {
 	int			genl_id;
 	struct mnl_socket	*nl;
-	bool			enabled;
 } gtp_nl;
 
 int gtp_kernel_init(struct gsn_t *gsn, const char *devname, struct in46_prefix *prefix, const char *ipup)
@@ -72,7 +71,6 @@
 			strerror(errno));
 		return -1;
 	}
-	gtp_nl.enabled = true;
 
 	gtp_nl.nl = genl_socket_open();
 	if (gtp_nl.nl == NULL) {
@@ -126,9 +124,6 @@
 
 void gtp_kernel_stop(const char *devname)
 {
-	if (!gtp_nl.enabled)
-		return;
-
 	gtp_dev_destroy(devname);
 }
 
@@ -137,9 +132,6 @@
 	struct in_addr ms, sgsn;
 	struct gtp_tunnel *t;
 	int ret;
-
-	if (!gtp_nl.enabled)
-		return 0;
 
 	pdp_debug(pdp);
 
@@ -175,9 +167,6 @@
 	struct gtp_tunnel *t;
 	int ret;
 
-	if (!gtp_nl.enabled)
-		return 0;
-
 	pdp_debug(pdp);
 
 	t = gtp_tunnel_alloc();
@@ -197,9 +186,4 @@
 	gtp_tunnel_free(t);
 
 	return ret;
-}
-
-int gtp_kernel_enabled(void)
-{
-	return gtp_nl.enabled;
 }
diff --git a/ggsn/gtp-kernel.h b/ggsn/gtp-kernel.h
index 79cdae7..a34d8e0 100644
--- a/ggsn/gtp-kernel.h
+++ b/ggsn/gtp-kernel.h
@@ -13,8 +13,6 @@
 int gtp_kernel_tunnel_add(struct pdp_t *pdp, const char *devname);
 int gtp_kernel_tunnel_del(struct pdp_t *pdp, const char *devname);
 
-int gtp_kernel_enabled(void);
-
 #else
 static inline int gtp_kernel_init(struct gsn_t *gsn, const char *devname, struct in46_prefix *prefix, const char *ipup)
 {
@@ -30,11 +28,6 @@
 }
 
 static inline int gtp_kernel_tunnel_del(struct pdp_t *pdp, const char *devname);
-{
-	return 0;
-}
-
-static inline int gtp_kernel_enabled(void)
 {
 	return 0;
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff3bd8a52bd6c20f9811ee41ff700486d08591f3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list