aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Maltsev <pavelm@google.com>2018-05-29 14:25:44 -0700
committerPavel Maltsev <pavelm@google.com>2018-06-06 18:02:11 -0700
commit78ad0e50ade39ce6ae6167b264f26af1524e4089 (patch)
tree20362e52acef6745cf54b78dc7e02c52c60bc2d8
parent2392dac63f04e7a575c8618d2187280aeba742c4 (diff)
downloadplatform_external_iproute2-78ad0e50ade39ce6ae6167b264f26af1524e4089.tar.gz
platform_external_iproute2-78ad0e50ade39ce6ae6167b264f26af1524e4089.tar.bz2
platform_external_iproute2-78ad0e50ade39ce6ae6167b264f26af1524e4089.zip
Allow to configure /var/run/netns directory
Currently NETNS_RUN_DIR is hardcoded and refers to /var/run/netns. However, some systems (e.g. Android) doesn't have /var which results in error attempts to create network namespaces on these systems. This change makes NETNS_RUN_DIR configurable at build time by allowing to pass environment variable to make command. Also, this change makes /etc/netns directory configurable through NETNS_ETC_DIR environment variable. For example: ./configure && NETNS_RUN_DIR=/mnt/vendor/netns make Tested: verified that iproute2 with configuration mentioned above creates namespaces in /mnt/vendor/netns (Cherry-picked without modifications) Signed-off-by: Pavel Maltsev <pavelm@google.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Test: m Bug: 73334854 Change-Id: I150ade94de7fbf99b894072d2f69baff273349a5
-rw-r--r--Makefile6
-rw-r--r--include/namespace.h5
2 files changed, 10 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 6ad96104..b890758d 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,8 @@ PREFIX?=/usr
LIBDIR?=$(PREFIX)/lib
SBINDIR?=/sbin
CONFDIR?=/etc/iproute2
+NETNS_RUN_DIR?=/var/run/netns
+NETNS_ETC_DIR?=/etc/netns
DATADIR?=$(PREFIX)/share
HDRDIR?=$(PREFIX)/include/iproute2
DOCDIR?=$(DATADIR)/doc/iproute2
@@ -26,7 +28,9 @@ ifneq ($(SHARED_LIBS),y)
DEFINES+= -DNO_SHARED_LIBS
endif
-DEFINES+=-DCONFDIR=\"$(CONFDIR)\"
+DEFINES+=-DCONFDIR=\"$(CONFDIR)\" \
+ -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" \
+ -DNETNS_ETC_DIR=\"$(NETNS_ETC_DIR)\"
#options for decnet
ADDLIB+=dnet_ntop.o dnet_pton.o
diff --git a/include/namespace.h b/include/namespace.h
index 51324b21..183f4612 100644
--- a/include/namespace.h
+++ b/include/namespace.h
@@ -7,8 +7,13 @@
#include <sys/syscall.h>
#include <errno.h>
+#ifndef NETNS_RUN_DIR
#define NETNS_RUN_DIR "/var/run/netns"
+#endif
+
+#ifndef NETNS_ETC_DIR
#define NETNS_ETC_DIR "/etc/netns"
+#endif
#ifndef CLONE_NEWNET
#define CLONE_NEWNET 0x40000000 /* New network namespace (lo, device, names sockets, etc) */