From patchwork Tue May 15 21:49:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Maltsev X-Patchwork-Id: 913949 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="mrJ2IUOg"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40lrpG5pchz9s0W for ; Wed, 16 May 2018 07:50:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752222AbeEOVuL (ORCPT ); Tue, 15 May 2018 17:50:11 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:message-id:subject:from:to:cc; bh=coB3UO7IlWyu5KSwYtSCNm9hhskgzPDPRDnIRyzOOgM=; b=mrJ2IUOgvftIsFIuS2D9AgZXRXN/li5IffOHRDU01U4++x/7MOyk6Tx4ghqxfY+MZr SONhnH0OGwtbXMEf9HwvMev67nY7zxg6B1sOflNDULwZiMvV1WHZEboWBtO1IDG0nIYR +ax/yAvHM+GXq9qC0ssm8IfpIVobZ63TeDUSQz975Jfm7ZlHvHCfPK3XVAYXC50HX/OY v1o7a1ZnFAUgTl36w1U+LL/cg1DIr3BCbANIRA0Fm0H4l42xC9x1Bg4K1vIkRfUD3EnL rglVvQ1VQNtyf5Cj2hAr9CGSliKwGi7hfNPruvEx+ILL+WEVVPwikThplSFYPQYR7x5j 6ttA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=coB3UO7IlWyu5KSwYtSCNm9hhskgzPDPRDnIRyzOOgM=; b=g2HpcmZNnvRohDaDgi5DShGsQ4LyfmItmmV3AOOlEvLtTRBnGJl5zmb9Uu1fq/flwv 2AtorVhonmBo6odMbve0Xhx7SPAbThKlA4BjxGTU+72OsI1omWqdnf4z4dDQGdVZubKN K8TNMuPQ0NhOXPCKdtBxuM8BNoDV7566WGyrXX8IZMYc/QSRfmFw01Mg6+eOOiw/Hqqt vEypCSUc5BkWfk/7tnFf4e4cVFuX5hyaikVn8oUPQSmqmqv8//rgqaJpdvMwc4/v3c9r 7PLL6kkfBT1PLdlOoTT8VFbq6DyVcXSynlkrYReo76gKoeLmQ7uGPOjzLKLLG/xLS2zf bnSQ== X-Gm-Message-State: ALKqPwcKDIYUvkmtBRfwDZ/cZ/nl3Mvn3MaKYyVhYp7j2hUJ6moU7HPh JmiDjNvTxjrJV/48tJaTgE+bHQS27YnxEfW7qngoncR9i83CCGPF01n/BWFqrymgIQ2iZ++ErtV UiRWvZRttV1dWZunBAXARZKyRjoZc7vDkAfPvhr/Pj3G3zGWwiU3sRJCFwlrBFg== X-Google-Smtp-Source: AB8JxZoa5MFhj/z7bTDuJhH+X1ma7/cvjxBOuvriW+Us86Scal1arJW9qwYkaO/ugFd3F3FbehXih1r0wcA= MIME-Version: 1.0 X-Received: by 2002:a24:a34b:: with SMTP id p72-v6mr18387076ite.52.1526421007080; Tue, 15 May 2018 14:50:07 -0700 (PDT) Date: Tue, 15 May 2018 14:49:46 -0700 Message-Id: <20180515214946.222797-1-pavelm@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Subject: [PATCH iproute2] Allow to configure /var/run/netns directory From: Pavel Maltsev To: netdev@vger.kernel.org, lorenzo@google.com, stephen@networkplumber.org, pavelm@google.com Cc: lorenzo@google.com, stephen@networkplumber.org, Pavel Maltsev Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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