From: Nicolas Dichtel <hidden> Date: 2025-02-06 16:51:39
This series adds a way to see if an interface cannot be moved to another netns.
I target this series to 'net' because this was possible until commit
05c1280a2bcf ("netdev_features: convert NETIF_F_NETNS_LOCAL to dev->netns_local").
include/uapi/linux/if_link.h | 1 +
net/core/rtnetlink.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
Comments are welcome.
Regards,
Nicolas
From: Nicolas Dichtel <hidden> Date: 2025-02-06 16:51:39
Since the below commit, there is no way to see if the netns_local property
is set on a device. Let's add a netlink attribute to advertise it.
CC: stable@vger.kernel.org
Fixes: 05c1280a2bcf ("netdev_features: convert NETIF_F_NETNS_LOCAL to dev->netns_local")
Signed-off-by: Nicolas Dichtel <redacted>
---
include/uapi/linux/if_link.h | 1 +
net/core/rtnetlink.c | 3 +++
2 files changed, 4 insertions(+)
From: Nicolas Dichtel <hidden> Date: 2025-02-06 16:51:39
The current message is "Invalid argument". Let's help the user by
explaining the error.
Signed-off-by: Nicolas Dichtel <redacted>
---
net/core/rtnetlink.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
From: Andrew Lunn <andrew@lunn.ch> Date: 2025-02-06 23:02:42
On Thu, Feb 06, 2025 at 05:50:27PM +0100, Nicolas Dichtel wrote:
quoted hunk
The current message is "Invalid argument". Let's help the user by
explaining the error.
Signed-off-by: Nicolas Dichtel <redacted>
---
net/core/rtnetlink.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
@@ -3024,8 +3024,12 @@ static int do_setlink(const struct sk_buff *skb, struct net_device *dev,new_ifindex=nla_get_s32_default(tb[IFLA_NEW_IFINDEX],0);err=__dev_change_net_namespace(dev,tgt_net,pat,new_ifindex);-if(err)+if(err){+if(dev->netns_local)+NL_SET_ERR_MSG(extack,+"The interface has the 'netns local' property");
This seems to have the wrong order. Why even try calling
__dev_change_net_namespace() if you know it is going to fail?
Maybe this NL_SET_ERR_MSG() should be pushed into
__dev_change_net_namespace()? You could then return useful messages if
the altnames conflict, the ifindex is already in use, etc.
Andrew
From: Jakub Kicinski <kuba@kernel.org> Date: 2025-02-06 23:39:52
On Thu, 6 Feb 2025 17:50:26 +0100 Nicolas Dichtel wrote:
Since the below commit, there is no way to see if the netns_local property
is set on a device. Let's add a netlink attribute to advertise it.
I think the motivation for the change may be worth elaborating on.
It's a bit unclear to me what user space would care about this
information, a bit of a "story" on how you hit the issue could
be useful perhaps? The uAPI is new but the stable tag indicates
regression..
From: Nicolas Dichtel <hidden> Date: 2025-02-07 09:08:12
Le 07/02/2025 à 00:02, Andrew Lunn a écrit :
On Thu, Feb 06, 2025 at 05:50:27PM +0100, Nicolas Dichtel wrote:
quoted
The current message is "Invalid argument". Let's help the user by
explaining the error.
Signed-off-by: Nicolas Dichtel <redacted>
---
net/core/rtnetlink.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
@@ -3024,8 +3024,12 @@ static int do_setlink(const struct sk_buff *skb, struct net_device *dev,new_ifindex=nla_get_s32_default(tb[IFLA_NEW_IFINDEX],0);err=__dev_change_net_namespace(dev,tgt_net,pat,new_ifindex);-if(err)+if(err){+if(dev->netns_local)+NL_SET_ERR_MSG(extack,+"The interface has the 'netns local' property");
This seems to have the wrong order. Why even try calling
__dev_change_net_namespace() if you know it is going to fail?
Maybe this NL_SET_ERR_MSG() should be pushed into
__dev_change_net_namespace()? You could then return useful messages if
the altnames conflict, the ifindex is already in use, etc.
Users of dev_change_net_namespace() are not netlink users, so I kept the same
API. I will plumb the extack into __dev_change_net_namespace().
Thanks,
Nicolas
From: Nicolas Dichtel <hidden> Date: 2025-02-07 09:10:52
Le 07/02/2025 à 00:39, Jakub Kicinski a écrit :
On Thu, 6 Feb 2025 17:50:26 +0100 Nicolas Dichtel wrote:
quoted
Since the below commit, there is no way to see if the netns_local property
is set on a device. Let's add a netlink attribute to advertise it.
I think the motivation for the change may be worth elaborating on.
It's a bit unclear to me what user space would care about this
information, a bit of a "story" on how you hit the issue could
be useful perhaps? The uAPI is new but the stable tag indicates
regression..
To make it short: we were trying a new NIC with a custom distro provided by a
vendor (with out of tree drivers). We were unable to move the interface in
another netns. Thanks to ethtool we were able to confirm that the 'netns-local'
flag was set. Having this information helps debugging.
Maybe nla_put_flag() ? Or do you really care about false being there?
It depends if the commit is backported or not. If it won't be backported, having
the false value helps to know that the kernel support this attribute (and so
that the property is not set).
FWIW, I will be off for one week, I will come back to this later.
The 3 bytes wasted on padding always makes me question when people pick
NLA_u8.
From: Jakub Kicinski <kuba@kernel.org> Date: 2025-02-07 19:35:36
On Fri, 7 Feb 2025 10:10:49 +0100 Nicolas Dichtel wrote:
Le 07/02/2025 à 00:39, Jakub Kicinski a écrit :
quoted
On Thu, 6 Feb 2025 17:50:26 +0100 Nicolas Dichtel wrote:
quoted
Since the below commit, there is no way to see if the netns_local property
is set on a device. Let's add a netlink attribute to advertise it.
I think the motivation for the change may be worth elaborating on.
It's a bit unclear to me what user space would care about this
information, a bit of a "story" on how you hit the issue could
be useful perhaps? The uAPI is new but the stable tag indicates
regression..
To make it short: we were trying a new NIC with a custom distro provided by a
vendor (with out of tree drivers). We were unable to move the interface in
another netns. Thanks to ethtool we were able to confirm that the 'netns-local'
flag was set. Having this information helps debugging.
Thanks, makes sense. Still a bit unsure if this is a stable candidate,
if you don't mind net-next that'd be my preference. If you do mind,
I'll live with it :)
Maybe nla_put_flag() ? Or do you really care about false being there?
It depends if the commit is backported or not. If it won't be backported, having
the false value helps to know that the kernel support this attribute (and so
that the property is not set).
Wish we had a good solution for this, it's always the argument against
flags :(