From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Maltsev Subject: [PATCH iproute2] Allow to configure /var/run/netns directory Date: Fri, 18 May 2018 15:44:00 -0700 Message-ID: <20180518224400.201511-1-pavelm@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: lorenzo@google.com, stephen@networkplumber.org, Pavel Maltsev To: netdev@vger.kernel.org, lorenzo@google.com, stephen@networkplumber.org, pavelm@google.com Return-path: Received: from mail-yw0-f202.google.com ([209.85.161.202]:40088 "EHLO mail-yw0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751924AbeERWoM (ORCPT ); Fri, 18 May 2018 18:44:12 -0400 Received: by mail-yw0-f202.google.com with SMTP id g126-v6so4259112ywb.7 for ; Fri, 18 May 2018 15:44:12 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: 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 --- 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 #include +#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