From patchwork Tue Jul 5 14:51:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 644813 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rkRg01hMRz9sBf for ; Wed, 6 Jul 2016 00:51:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933167AbcGEOvm (ORCPT ); Tue, 5 Jul 2016 10:51:42 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:42772 "EHLO mail.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933141AbcGEOvj (ORCPT ); Tue, 5 Jul 2016 10:51:39 -0400 Received: from mail.nwl.cc (orbyte.nwl.cc [127.0.0.1]) by mail.nwl.cc (Postfix) with ESMTP id 1485667C47; Tue, 5 Jul 2016 16:51:38 +0200 (CEST) Received: from xsao (localhost [IPv6:::1]) by mail.nwl.cc (Postfix) with ESMTP id E7398637C7; Tue, 5 Jul 2016 16:51:37 +0200 (CEST) From: Phil Sutter To: Stephen Hemminger Cc: "Eric W . Biederman" , netdev@vger.kernel.org Subject: [iproute PATCHv2 1/2] ipnetns: Move NETNS_RUN_DIR into it's own propagation group Date: Tue, 5 Jul 2016 16:51:19 +0200 Message-Id: <1467730280-17493-2-git-send-email-phil@nwl.cc> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1467730280-17493-1-git-send-email-phil@nwl.cc> References: <1467730280-17493-1-git-send-email-phil@nwl.cc> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On systems where the parent mount point is shared, NETNS_RUN_DIR inherits the parent's propagation group. This leads to netns mount points being propagated to the parent and thus showing up twice in the output of 'mount'. By making the newly mounted NETNS_RUN_DIR private first, then shared again, it will move to it's own propagation group which will still allow for netns mounts to propagate between mount namespaces but gets rid of the double netns entry at the same time. Suggested-by: Miklos Szeredi Signed-off-by: Phil Sutter --- ip/ipnetns.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ip/ipnetns.c b/ip/ipnetns.c index b3ee23c23aaa2..1cefe73c68bfc 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -650,6 +650,11 @@ static int netns_add(int argc, char **argv) NETNS_RUN_DIR, NETNS_RUN_DIR, strerror(errno)); return -1; } + if (mount("", NETNS_RUN_DIR, "none", MS_PRIVATE, NULL)) { + fprintf(stderr, "mount --make-private %s failed: %s\n", + NETNS_RUN_DIR, strerror(errno)); + return -1; + } made_netns_run_dir_mount = 1; }