Change in osmo-ggsn[master]: sgsnemu: Fix build/run against linux < 4.11 (no sysctl addr_gen_mode ...

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/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Apr 19 09:20:13 UTC 2020


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

Change subject: sgsnemu: Fix build/run against linux < 4.11 (no sysctl addr_gen_mode support)
......................................................................

sgsnemu: Fix build/run against linux < 4.11 (no sysctl addr_gen_mode support)

On older systems (like debian 8), the enum is not present in the header
file and build will fail (as saw in osmocom's OBS instance).
Furthermore, the sysctl to change the value was added at a later point
in time, which means compiling can go fine but running may fail due to
the sysctl not being available.

This is a fix-up to Change-Id I1d51f3ca91edbb3b788939982ab63264182ec2ce

Change-Id: I208970d5b16ea7148444d414b0a6f68c8d9a086c
---
M configure.ac
M sgsnemu/sgsnemu.c
2 files changed, 20 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/configure.ac b/configure.ac
index c695958..0e61729 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,6 +131,15 @@
  AC_DEFINE([HAVE_IPHDR])],
  AC_MSG_RESULT(no))
 
+# Address generation modes (enum) implemented in linux 3.17 (bc91b0f07ada5535427373a4e2050877bcc12218)
+# /proc/sys/net/ipv6/conf/${iface}/addr_gen_mode was added in linux 4.11 (d35a00b8e33dab7385f724e713ae71c8be0a49f4)
+AC_MSG_CHECKING(whether enum in6_addr_gen_mode.IN6_ADDR_GEN_MODE_NONE exists)
+AH_TEMPLATE(HAVE_IN6_ADDR_GEN_MODE_NONE)
+AC_EGREP_HEADER(IN6_ADDR_GEN_MODE_NONE, linux/if_link.h,
+[AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_IN6_ADDR_GEN_MODE_NONE])],
+ AC_MSG_RESULT(no))
+
 # Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
 # AC_FUNC_MALLOC
diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
index c28df52..ea52da6 100644
--- a/sgsnemu/sgsnemu.c
+++ b/sgsnemu/sgsnemu.c
@@ -15,6 +15,8 @@
  *
  */
 
+#include "config.h"
+
 #ifdef __linux__
 #define _GNU_SOURCE 1		/* strdup() prototype, broken arpa/inet.h */
 #endif
@@ -47,10 +49,11 @@
 #include <time.h>
 
 #if defined(__linux__)
+#if defined(HAVE_IN6_ADDR_GEN_MODE_NONE)
 #include <linux/if_link.h>
+#endif // HAVE_IN6_ADDR_GEN_MODE_NONE
 #endif
 
-#include "config.h"
 #include "../lib/tun.h"
 #include "../lib/ippool.h"
 #include "../lib/syserr.h"
@@ -1702,13 +1705,16 @@
 			exit(1);
 		}
 
-#if defined(__linux__)
-		/* Avoid tunnel setting its own link-local addr automatically, we don't need it. */
+#if defined(__linux__) && defined(HAVE_IN6_ADDR_GEN_MODE_NONE)
+		/* Avoid tunnel setting its own link-local addr automatically,
+		   we don't need it. Don't exit on error since this sysctl is
+		   only available starting with linux 4.11. */
 		snprintf(buf, sizeof(buf), "%u", IN6_ADDR_GEN_MODE_NONE);
 		if (proc_ipv6_conf_write(options.tun_dev_name, "addr_gen_mode", buf) < 0) {
 			SYS_ERR(DSGSN, LOGL_ERROR, errno,
-				"Failed to disable addr_gen_mode on %s\n", options.tun_dev_name);
-			exit(1);
+				"Failed to disable addr_gen_mode on %s, an extra link-local "
+				"ip address will appear on the tun device.\n",
+				options.tun_dev_name);
 		}
 #endif
 

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

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I208970d5b16ea7148444d414b0a6f68c8d9a086c
Gerrit-Change-Number: 17861
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200419/cb212fea/attachment.htm>


More information about the gerrit-log mailing list