Allow to configure /var/run/netns directory
Subsystems (3)
PATCH 1/1 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 configre script.
For example: NETNS_RUN_DIR=/mnt/vendor/netns ./configure && make
Tested: verified that iproute2 with configuration mentioned above creates namespaces in /mnt/vendor/netns
--- configure | 3 +++ include/namespace.h | 3 +++ 2 files changed, 6 insertions(+)
configure +3 -0
@@ -213,6 +213,9 @@ EOF echo "IP_CONFIG_SETNS:=y" >>$CONFIG echo "yes" echo "CFLAGS += -DHAVE_SETNS" >>$CONFIG + if [ -n "$NETNS_RUN_DIR" ]; then + echo "CFLAGS += -DNETNS_RUN_DIR=\\\"$NETNS_RUN_DIR\\\"" >>$CONFIG + fi else echo "no" fi
include/namespace.h +3 -0
@@ -8,7 +8,10 @@#include <sys/syscall.h> #include <errno.h> +#ifndef NETNS_RUN_DIR #define NETNS_RUN_DIR "/var/run/netns" +#endif /* NETNS_RUN_DIR */ +#define NETNS_ETC_DIR "/etc/netns"#ifndef CLONE_NEWNET
Signature · 1 line
2.17.0.441.gb46fe60e1d-goog
Quoted 6 lines · On Tue, 15 May 2018 14:49:46 -0700 Pavel Maltsev <[email protected]> wrote:
Currently
NETNS_RUN_DIRis 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 makesNETNS_RUN_DIRconfigurable at build time by allowing to pass environment variable to configre script.
Quoted 6 lines
For example: NETNS_RUN_DIR=/mnt/vendor/netns ./configure && make
Tested: verified that iproute2 with configuration mentioned above creates namespaces in
/mnt/vendor/netnsSigned-off-by Pavel Maltsev <[email protected]>
The directory path should definitely be overrideable on the build. The configure script is already messy enough, lets do it instead like the other runtime directories are already done ARPDDIR and CONFDIR.
Something like?
Makefile +2 -1
@@ -16,6 +16,7 @@ PREFIX?=/usr LIBDIR?=$(PREFIX)/lib SBINDIR?=/sbin CONFDIR?=/etc/iproute2 +NETNS_RUN_DIR?=/var/run/netns DATADIR?=$(PREFIX)/share HDRDIR?=$(PREFIX)/include/iproute2 DOCDIR?=$(DATADIR)/doc/iproute2
@@ -34,7 +35,7 @@ ifneq ($(SHARED_LIBS),y) DEFINES+= -DNO_SHARED_LIBS endif -DEFINES+=-DCONFDIR=\"$(CONFDIR)\" +DEFINES+=-DCONFDIR=\"$(CONFDIR)\" -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" #options for decnet ADDLIB+=dnet_ntop.o dnet_pton.o
include/namespace.h +5 -0
@@ -8,8 +8,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) */
Thanks, Stephen,
I've uploaded new patch as you suggested by putting these variables in the makefile rather than configure script.
Quoted 63 lines · Stephen Hemminger
Quoted 6 lines · On Tue, 15 May 2018 14:49:46 -0700 Pavel Maltsev <[email protected]> wrote:
Currently
NETNS_RUN_DIRis 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 makesNETNS_RUN_DIRconfigurable at build time by allowing to pass environment variable to configre script.Quoted 6 lines
For example: NETNS_RUN_DIR=/mnt/vendor/netns ./configure && make
Tested: verified that iproute2 with configuration mentioned above creates namespaces in
/mnt/vendor/netnsSigned-off-by Pavel Maltsev <[email protected]>The directory path should definitely be overrideable on the build. The configure script is already messy enough, lets do it instead like the other runtime directories are already done ARPDDIR and CONFDIR.
Something like?
Makefile +2
-1@@ -16,6 +16,7 @@ PREFIX?=/usr LIBDIR?=$(PREFIX)/lib SBINDIR?=/sbin CONFDIR?=/etc/iproute2 +NETNS_RUN_DIR?=/var/run/netns DATADIR?=$(PREFIX)/share HDRDIR?=$(PREFIX)/include/iproute2 DOCDIR?=$(DATADIR)/doc/iproute2@@ -34,7 +35,7 @@ ifneq ($(SHARED_LIBS),y) DEFINES+= -DNO_SHARED_LIBS endif -DEFINES+=-DCONFDIR=\"$(CONFDIR)\" +DEFINES+=-DCONFDIR=\"$(CONFDIR)\" -DNETNS_RUN_DIR=\"$(NETNS_RUN_DIR)\" #options for decnet ADDLIB+=dnet_ntop.o dnet_pton.oinclude/namespace.h +5
-0@@ -8,8 +8,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) */