Commit 0854fa82 authored by Andrei Vagin's avatar Andrei Vagin Committed by David S. Miller

net: remove the new_ifindex argument from dev_change_net_namespace

Here is only one place where we want to specify new_ifindex. In all
other cases, callers pass 0 as new_ifindex. It looks reasonable to add a
low-level function with new_ifindex and to convert
dev_change_net_namespace to a static inline wrapper.

Fixes: eeb85a14 ("net: Allow to specify ifindex when device is moved to another namespace")
Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarAndrei Vagin <avagin@gmail.com>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7e4a5131
...@@ -2354,7 +2354,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev) ...@@ -2354,7 +2354,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
*/ */
if (!net_eq(dev_net(ndev), dev_net(vf_netdev))) { if (!net_eq(dev_net(ndev), dev_net(vf_netdev))) {
ret = dev_change_net_namespace(vf_netdev, ret = dev_change_net_namespace(vf_netdev,
dev_net(ndev), "eth%d", 0); dev_net(ndev), "eth%d");
if (ret) if (ret)
netdev_err(vf_netdev, netdev_err(vf_netdev,
"could not move to same namespace as %s: %d\n", "could not move to same namespace as %s: %d\n",
......
...@@ -4026,8 +4026,14 @@ void __dev_notify_flags(struct net_device *, unsigned int old_flags, ...@@ -4026,8 +4026,14 @@ void __dev_notify_flags(struct net_device *, unsigned int old_flags,
int dev_change_name(struct net_device *, const char *); int dev_change_name(struct net_device *, const char *);
int dev_set_alias(struct net_device *, const char *, size_t); int dev_set_alias(struct net_device *, const char *, size_t);
int dev_get_alias(const struct net_device *, char *, size_t); int dev_get_alias(const struct net_device *, char *, size_t);
int dev_change_net_namespace(struct net_device *dev, struct net *net, int __dev_change_net_namespace(struct net_device *dev, struct net *net,
const char *pat, int new_ifindex); const char *pat, int new_ifindex);
static inline
int dev_change_net_namespace(struct net_device *dev, struct net *net,
const char *pat)
{
return __dev_change_net_namespace(dev, net, pat, 0);
}
int __dev_set_mtu(struct net_device *, int); int __dev_set_mtu(struct net_device *, int);
int dev_validate_mtu(struct net_device *dev, int mtu, int dev_validate_mtu(struct net_device *dev, int mtu,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
......
...@@ -11062,7 +11062,7 @@ void unregister_netdev(struct net_device *dev) ...@@ -11062,7 +11062,7 @@ void unregister_netdev(struct net_device *dev)
EXPORT_SYMBOL(unregister_netdev); EXPORT_SYMBOL(unregister_netdev);
/** /**
* dev_change_net_namespace - move device to different nethost namespace * __dev_change_net_namespace - move device to different nethost namespace
* @dev: device * @dev: device
* @net: network namespace * @net: network namespace
* @pat: If not NULL name pattern to try if the current device name * @pat: If not NULL name pattern to try if the current device name
...@@ -11077,7 +11077,7 @@ EXPORT_SYMBOL(unregister_netdev); ...@@ -11077,7 +11077,7 @@ EXPORT_SYMBOL(unregister_netdev);
* Callers must hold the rtnl semaphore. * Callers must hold the rtnl semaphore.
*/ */
int dev_change_net_namespace(struct net_device *dev, struct net *net, int __dev_change_net_namespace(struct net_device *dev, struct net *net,
const char *pat, int new_ifindex) const char *pat, int new_ifindex)
{ {
struct net *net_old = dev_net(dev); struct net *net_old = dev_net(dev);
...@@ -11202,7 +11202,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, ...@@ -11202,7 +11202,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net,
out: out:
return err; return err;
} }
EXPORT_SYMBOL_GPL(dev_change_net_namespace); EXPORT_SYMBOL_GPL(__dev_change_net_namespace);
static int dev_cpu_dead(unsigned int oldcpu) static int dev_cpu_dead(unsigned int oldcpu)
{ {
...@@ -11458,7 +11458,7 @@ static void __net_exit default_device_exit(struct net *net) ...@@ -11458,7 +11458,7 @@ static void __net_exit default_device_exit(struct net *net)
snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex); snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
if (__dev_get_by_name(&init_net, fb_name)) if (__dev_get_by_name(&init_net, fb_name))
snprintf(fb_name, IFNAMSIZ, "dev%%d"); snprintf(fb_name, IFNAMSIZ, "dev%%d");
err = dev_change_net_namespace(dev, &init_net, fb_name, 0); err = dev_change_net_namespace(dev, &init_net, fb_name);
if (err) { if (err) {
pr_emerg("%s: failed to move %s to init_net: %d\n", pr_emerg("%s: failed to move %s to init_net: %d\n",
__func__, dev->name, err); __func__, dev->name, err);
......
...@@ -2619,7 +2619,7 @@ static int do_setlink(const struct sk_buff *skb, ...@@ -2619,7 +2619,7 @@ static int do_setlink(const struct sk_buff *skb,
else else
new_ifindex = 0; new_ifindex = 0;
err = dev_change_net_namespace(dev, net, ifname, new_ifindex); err = __dev_change_net_namespace(dev, net, ifname, new_ifindex);
put_net(net); put_net(net);
if (err) if (err)
goto errout; goto errout;
...@@ -3461,7 +3461,7 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -3461,7 +3461,7 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
if (err < 0) if (err < 0)
goto out_unregister; goto out_unregister;
if (link_net) { if (link_net) {
err = dev_change_net_namespace(dev, dest_net, ifname, 0); err = dev_change_net_namespace(dev, dest_net, ifname);
if (err < 0) if (err < 0)
goto out_unregister; goto out_unregister;
} }
......
...@@ -205,7 +205,7 @@ int cfg802154_switch_netns(struct cfg802154_registered_device *rdev, ...@@ -205,7 +205,7 @@ int cfg802154_switch_netns(struct cfg802154_registered_device *rdev,
if (!wpan_dev->netdev) if (!wpan_dev->netdev)
continue; continue;
wpan_dev->netdev->features &= ~NETIF_F_NETNS_LOCAL; wpan_dev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
err = dev_change_net_namespace(wpan_dev->netdev, net, "wpan%d", 0); err = dev_change_net_namespace(wpan_dev->netdev, net, "wpan%d");
if (err) if (err)
break; break;
wpan_dev->netdev->features |= NETIF_F_NETNS_LOCAL; wpan_dev->netdev->features |= NETIF_F_NETNS_LOCAL;
...@@ -222,7 +222,7 @@ int cfg802154_switch_netns(struct cfg802154_registered_device *rdev, ...@@ -222,7 +222,7 @@ int cfg802154_switch_netns(struct cfg802154_registered_device *rdev,
continue; continue;
wpan_dev->netdev->features &= ~NETIF_F_NETNS_LOCAL; wpan_dev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
err = dev_change_net_namespace(wpan_dev->netdev, net, err = dev_change_net_namespace(wpan_dev->netdev, net,
"wpan%d", 0); "wpan%d");
WARN_ON(err); WARN_ON(err);
wpan_dev->netdev->features |= NETIF_F_NETNS_LOCAL; wpan_dev->netdev->features |= NETIF_F_NETNS_LOCAL;
} }
......
...@@ -165,7 +165,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, ...@@ -165,7 +165,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
if (!wdev->netdev) if (!wdev->netdev)
continue; continue;
wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL; wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
err = dev_change_net_namespace(wdev->netdev, net, "wlan%d", 0); err = dev_change_net_namespace(wdev->netdev, net, "wlan%d");
if (err) if (err)
break; break;
wdev->netdev->features |= NETIF_F_NETNS_LOCAL; wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
...@@ -182,7 +182,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, ...@@ -182,7 +182,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
continue; continue;
wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL; wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
err = dev_change_net_namespace(wdev->netdev, net, err = dev_change_net_namespace(wdev->netdev, net,
"wlan%d", 0); "wlan%d");
WARN_ON(err); WARN_ON(err);
wdev->netdev->features |= NETIF_F_NETNS_LOCAL; wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment