Re: [PATCH net-next v5 3/3] net: plumb extack in __dev_change_net_namespace()
From: Kuniyuki Iwashima <hidden>
Date: 2025-02-26 22:41:31
From: Nicolas Dichtel <redacted> Date: Wed, 26 Feb 2025 10:31:58 +0100
It could be hard to understand why the netlink command fails. For example, if dev->netns_immutable is set, the error is "Invalid argument". Signed-off-by: Nicolas Dichtel <redacted> Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <redacted> I left two small comments but am not sure if it's worth respin.
quoted hunk ↗ jump to hunk
@@ -12041,30 +12047,48 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net, err = -EEXIST; if (netdev_name_in_use(net, dev->name)) { /* We get here if we can't use the current device name */ - if (!pat) + if (!pat) { + NL_SET_ERR_MSG(extack, + "An interface with the same name exists in the target netns"); goto out; + } err = dev_prep_valid_name(net, dev, pat, new_name, EEXIST); - if (err < 0) + if (err < 0) { + NL_SET_ERR_MSG_FMT(extack, + "Unable to use '%s' for the new interface name",
Only this message does not have "in the target netns".
+ pat); goto out; + } } /* Check that none of the altnames conflicts. */ err = -EEXIST; netdev_for_each_altname(dev, name_node)
I'd add { here
- if (netdev_name_in_use(net, name_node->name))
+ if (netdev_name_in_use(net, name_node->name)) {
+ NL_SET_ERR_MSG_FMT(extack,
+ "An interface with the altname %s exists in the target netns",
+ name_node->name);
goto out;
+ }and } here.