Commit ea97ab98 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge tag 'batadv-net-pullrequest-20220302' of git://git.open-mesh.org/linux-merge

Simon Wunderlich says:

====================
Here are some batman-adv bugfixes:

 - Remove redundant iflink requests, by Sven Eckelmann (2 patches)

 - Don't expect inter-netns unique iflink indices, by Sven Eckelmann

* tag 'batadv-net-pullrequest-20220302' of git://git.open-mesh.org/linux-merge:
  batman-adv: Don't expect inter-netns unique iflink indices
  batman-adv: Request iflink once in batadv_get_real_netdevice
  batman-adv: Request iflink once in batadv-on-batadv check
====================

Link: https://lore.kernel.org/r/20220302163049.101957-1-sw@simonwunderlich.deSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 95749c10 6c1f41af
...@@ -149,22 +149,25 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev) ...@@ -149,22 +149,25 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev)
struct net *net = dev_net(net_dev); struct net *net = dev_net(net_dev);
struct net_device *parent_dev; struct net_device *parent_dev;
struct net *parent_net; struct net *parent_net;
int iflink;
bool ret; bool ret;
/* check if this is a batman-adv mesh interface */ /* check if this is a batman-adv mesh interface */
if (batadv_softif_is_valid(net_dev)) if (batadv_softif_is_valid(net_dev))
return true; return true;
/* no more parents..stop recursion */ iflink = dev_get_iflink(net_dev);
if (dev_get_iflink(net_dev) == 0 || if (iflink == 0)
dev_get_iflink(net_dev) == net_dev->ifindex)
return false; return false;
parent_net = batadv_getlink_net(net_dev, net); parent_net = batadv_getlink_net(net_dev, net);
/* iflink to itself, most likely physical device */
if (net == parent_net && iflink == net_dev->ifindex)
return false;
/* recurse over the parent device */ /* recurse over the parent device */
parent_dev = __dev_get_by_index((struct net *)parent_net, parent_dev = __dev_get_by_index((struct net *)parent_net, iflink);
dev_get_iflink(net_dev));
/* if we got a NULL parent_dev there is something broken.. */ /* if we got a NULL parent_dev there is something broken.. */
if (!parent_dev) { if (!parent_dev) {
pr_err("Cannot find parent device\n"); pr_err("Cannot find parent device\n");
...@@ -214,14 +217,15 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev) ...@@ -214,14 +217,15 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev)
struct net_device *real_netdev = NULL; struct net_device *real_netdev = NULL;
struct net *real_net; struct net *real_net;
struct net *net; struct net *net;
int ifindex; int iflink;
ASSERT_RTNL(); ASSERT_RTNL();
if (!netdev) if (!netdev)
return NULL; return NULL;
if (netdev->ifindex == dev_get_iflink(netdev)) { iflink = dev_get_iflink(netdev);
if (iflink == 0) {
dev_hold(netdev); dev_hold(netdev);
return netdev; return netdev;
} }
...@@ -231,9 +235,16 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev) ...@@ -231,9 +235,16 @@ static struct net_device *batadv_get_real_netdevice(struct net_device *netdev)
goto out; goto out;
net = dev_net(hard_iface->soft_iface); net = dev_net(hard_iface->soft_iface);
ifindex = dev_get_iflink(netdev);
real_net = batadv_getlink_net(netdev, net); real_net = batadv_getlink_net(netdev, net);
real_netdev = dev_get_by_index(real_net, ifindex);
/* iflink to itself, most likely physical device */
if (net == real_net && netdev->ifindex == iflink) {
real_netdev = netdev;
dev_hold(real_netdev);
goto out;
}
real_netdev = dev_get_by_index(real_net, iflink);
out: out:
batadv_hardif_put(hard_iface); batadv_hardif_put(hard_iface);
......
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