* [PATCH iproute2] Allow to configure /var/run/netns directory
@ 2018-05-18 22:44 Pavel Maltsev
2018-05-23 22:30 ` Stephen Hemminger
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Maltsev @ 2018-05-18 22:44 UTC (permalink / raw)
To: netdev, lorenzo, stephen, pavelm; +Cc: lorenzo, stephen, Pavel Maltsev
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
Signed-off-by: Pavel Maltsev <pavelm@google.com>
---
Makefile | 6 +++++-
include/namespace.h | 5 +++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index b526d3b5..651d2a50 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,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
@@ -34,7 +36,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 aed7ce08..e47f9b5d 100644
--- a/include/namespace.h
+++ b/include/namespace.h
@@ -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) */
--
2.17.0.441.gb46fe60e1d-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2] Allow to configure /var/run/netns directory
2018-05-18 22:44 [PATCH iproute2] Allow to configure /var/run/netns directory Pavel Maltsev
@ 2018-05-23 22:30 ` Stephen Hemminger
0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2018-05-23 22:30 UTC (permalink / raw)
To: Pavel Maltsev; +Cc: netdev, lorenzo
On Fri, 18 May 2018 15:44:00 -0700
Pavel Maltsev <pavelm@google.com> wrote:
> 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
>
> Signed-off-by: Pavel Maltsev <pavelm@google.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH iproute2] Allow to configure /var/run/netns directory
@ 2018-05-15 21:49 Pavel Maltsev
2018-05-18 21:53 ` Stephen Hemminger
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Maltsev @ 2018-05-15 21:49 UTC (permalink / raw)
To: netdev, lorenzo, stephen, pavelm; +Cc: lorenzo, stephen, Pavel Maltsev
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
Signed-off-by: Pavel Maltsev <pavelm@google.com>
---
configure | 3 +++
include/namespace.h | 3 +++
2 files changed, 6 insertions(+)
diff --git a/configure b/configure
index 5ef5cd4c..a6a222da 100755
--- a/configure
+++ b/configure
@@ -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
diff --git a/include/namespace.h b/include/namespace.h
index aed7ce08..b8fb14df 100644
--- a/include/namespace.h
+++ b/include/namespace.h
@@ -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
--
2.17.0.441.gb46fe60e1d-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH iproute2] Allow to configure /var/run/netns directory
2018-05-15 21:49 Pavel Maltsev
@ 2018-05-18 21:53 ` Stephen Hemminger
2018-05-18 22:48 ` Pavel Maltsev
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2018-05-18 21:53 UTC (permalink / raw)
To: Pavel Maltsev; +Cc: netdev, lorenzo
On Tue, 15 May 2018 14:49:46 -0700
Pavel Maltsev <pavelm@google.com> wrote:
> 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
>
> Signed-off-by: Pavel Maltsev <pavelm@google.com>
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?
diff --git a/Makefile b/Makefile
index b526d3b5b5c4..ab828669e711 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/include/namespace.h b/include/namespace.h
index aed7ce08507f..e47f9b5d49d1 100644
--- a/include/namespace.h
+++ b/include/namespace.h
@@ -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) */
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH iproute2] Allow to configure /var/run/netns directory
2018-05-18 21:53 ` Stephen Hemminger
@ 2018-05-18 22:48 ` Pavel Maltsev
0 siblings, 0 replies; 5+ messages in thread
From: Pavel Maltsev @ 2018-05-18 22:48 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Lorenzo Colitti
Thanks, Stephen,
I've uploaded new patch as you suggested by putting these
variables in the makefile rather than configure script.
On Fri, May 18, 2018 at 2:53 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Tue, 15 May 2018 14:49:46 -0700
> Pavel Maltsev <pavelm@google.com> wrote:
>
> > 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
> >
> > Signed-off-by: Pavel Maltsev <pavelm@google.com>
>
> 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?
>
> diff --git a/Makefile b/Makefile
> index b526d3b5b5c4..ab828669e711 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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
> diff --git a/include/namespace.h b/include/namespace.h
> index aed7ce08507f..e47f9b5d49d1 100644
> --- a/include/namespace.h
> +++ b/include/namespace.h
> @@ -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) */
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-23 22:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-18 22:44 [PATCH iproute2] Allow to configure /var/run/netns directory Pavel Maltsev
2018-05-23 22:30 ` Stephen Hemminger
-- strict thread matches above, loose matches on Subject: below --
2018-05-15 21:49 Pavel Maltsev
2018-05-18 21:53 ` Stephen Hemminger
2018-05-18 22:48 ` Pavel Maltsev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox