netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: bring UP 'lo' by default after creating new netns
@ 2017-06-29 23:57 Mahesh Bandewar (महेश बंडेवार)
  2017-06-30  1:08 ` Eric W. Biederman
  0 siblings, 1 reply; 3+ messages in thread
From: Mahesh Bandewar (महेश बंडेवार) @ 2017-06-29 23:57 UTC (permalink / raw)
  To: Eric Dumazet, ebiederm, adobriyan, David Miller, xiyou.wangcong
  Cc: linux-netdev

Creation of new network namespace is almost always followed up by
bringing up the loopback device.

        ip netns add foo
        ip -netns foo link set lo up

I'm not sure if there are any consequences of bringing the device UP
at the creation of network-namespace.

thanks,
--mahesh..

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 2178db8e47cd..ac0e86c9a17f 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -428,6 +428,11 @@ struct net *copy_net_ns(unsigned long flags,
                net_drop_ns(net);
                return ERR_PTR(rv);
        }
+       /* Set the loopback device UP */
+       rtnl_lock();
+       dev_open(net->loopback_dev);
+       rtnl_unlock();
+
        return net;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: RFC: bring UP 'lo' by default after creating new netns
  2017-06-29 23:57 RFC: bring UP 'lo' by default after creating new netns Mahesh Bandewar (महेश बंडेवार)
@ 2017-06-30  1:08 ` Eric W. Biederman
  2017-06-30  6:26   ` Mahesh Bandewar (महेश बंडेवार)
  0 siblings, 1 reply; 3+ messages in thread
From: Eric W. Biederman @ 2017-06-30  1:08 UTC (permalink / raw)
  To: Mahesh Bandewar (महेश
	बंडेवार)
  Cc: Eric Dumazet, adobriyan, David Miller, xiyou.wangcong, linux-netdev

"Mahesh Bandewar (महेश बंडेवार)" <maheshb@google.com> writes:

> Creation of new network namespace is almost always followed up by
> bringing up the loopback device.
>
>         ip netns add foo
>         ip -netns foo link set lo up
>
> I'm not sure if there are any consequences of bringing the device UP
> at the creation of network-namespace.

Hard coded in net/core/net_namespace.c:copy_net_ns is definitely the
wrong place in the code for something like this.  If this lives anywhere
it should live in driver/net/loopback.c, or possibly in
net/core/dev.c:net_dev_init.

If we want this we want to match what we do when we the primary network
namespace.  Just so that there are no unneeded surprises with network
namespaces.

Eric

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC: bring UP 'lo' by default after creating new netns
  2017-06-30  1:08 ` Eric W. Biederman
@ 2017-06-30  6:26   ` Mahesh Bandewar (महेश बंडेवार)
  0 siblings, 0 replies; 3+ messages in thread
From: Mahesh Bandewar (महेश बंडेवार) @ 2017-06-30  6:26 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Eric Dumazet, adobriyan, David Miller, xiyou.wangcong, linux-netdev

On Thu, Jun 29, 2017 at 6:08 PM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
> "Mahesh Bandewar (महेश बंडेवार)" <maheshb@google.com> writes:
>
>> Creation of new network namespace is almost always followed up by
>> bringing up the loopback device.
>>
>>         ip netns add foo
>>         ip -netns foo link set lo up
>>
>> I'm not sure if there are any consequences of bringing the device UP
>> at the creation of network-namespace.jjh
>
> Hard coded in net/core/net_namespace.c:copy_net_ns is definitely the
> wrong place in the code for something like this.  If this lives anywhere
> it should live in driver/net/loopback.c, or possibly in
> net/core/dev.c:net_dev_init.
>
interestingly dev_open() needs RTNL while it's not recommended at
net_dev_init() time.
Also net_dev_init() is called at the sub-system registration, do you
mean loopback_net_init() time?

> If we want this we want to match what we do when we the primary network
> namespace.  Just so that there are no unneeded surprises with network
> namespaces.
>
Yes, correct, it should be same whether it's init-net or some other. I
can add the IFF_UP flag during
loopback_setup() but then it will not perform anything that is done
during dev_open() phase. I'll try
moving the code to loopback_net_init() to achieve the same result so
that I can avoid that hard-coding too.

Thanks for comments Eric.

--mahesh..

> Eric

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-30  6:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 23:57 RFC: bring UP 'lo' by default after creating new netns Mahesh Bandewar (महेश बंडेवार)
2017-06-30  1:08 ` Eric W. Biederman
2017-06-30  6:26   ` Mahesh Bandewar (महेश बंडेवार)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).