From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Maltsev Subject: [PATCH iproute2] Allow to configure /var/run/netns directory Date: Tue, 15 May 2018 14:49:46 -0700 Message-ID: <20180515214946.222797-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-it0-f73.google.com ([209.85.214.73]:52473 "EHLO mail-it0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751309AbeEOVuI (ORCPT ); Tue, 15 May 2018 17:50:08 -0400 Received: by mail-it0-f73.google.com with SMTP id n83-v6so4797079itg.2 for ; Tue, 15 May 2018 14:50:07 -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 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 --- 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 #include +#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