[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABAhCOR2v4HQecFvYuocNy3FDLoy9rKc3a0f1gVhg79dy+Ra9Q@mail.gmail.com>
Date: Wed, 23 Oct 2024 12:19:43 +0800
From: Xiao Liang <shaw.leon@...il.com>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: davem@...emloft.net, dsahern@...nel.org, edumazet@...gle.com,
idosch@...dia.com, kuba@...nel.org, netdev@...r.kernel.org, pabeni@...hat.com
Subject: Re: [PATCH net-next 1/5] rtnetlink: Lookup device in target netns
when creating link
On Wed, Oct 23, 2024 at 11:49 AM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
>
> > --- a/net/core/rtnetlink.c
> > +++ b/net/core/rtnetlink.c
> > @@ -3733,20 +3733,24 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
> > {
> > struct nlattr ** const tb = tbs->tb;
> > struct net *net = sock_net(skb->sk);
> > + struct net *device_net;
> > struct net_device *dev;
> > struct ifinfomsg *ifm;
> > bool link_specified;
> >
> > + /* When creating, lookup for existing device in target net namespace */
> > + device_net = nlh->nlmsg_flags & NLM_F_CREATE ? tgt_net : net;
>
> Technically, this changes uAPI behaviour.
>
> Let's say a user wants to
>
> 1) move the device X in the current netns to another if exists, otherwise
> 2) create a new device X in the target netns
>
> This can be achieved by setting NLM_F_CREATE and IFLA_NET_NS_PID,
> IFLA_NET_NS_FD, or IFLA_TARGET_NETNSID.
>
> But with this change, the device X in the current netns will not be moved,
> and a new device X is created in the target netns.
You're right, what about testing for NLM_F_EXCL aslo?
Powered by blists - more mailing lists