Created
July 9, 2020 06:43
-
-
Save stesie/44b727af67a1c3317cdfa4eb17e2a829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: batman-adv-2013.4.0/bridge_loop_avoidance.c | |
=================================================================== | |
--- batman-adv-2013.4.0.orig/bridge_loop_avoidance.c | |
+++ batman-adv-2013.4.0/bridge_loop_avoidance.c | |
@@ -351,7 +351,6 @@ static void batadv_bla_send_claim(struct | |
batadv_inc_counter(bat_priv, BATADV_CNT_RX); | |
batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, | |
skb->len + ETH_HLEN); | |
- soft_iface->last_rx = jiffies; | |
netif_rx(skb); | |
out: | |
Index: batman-adv-2013.4.0/distributed-arp-table.c | |
=================================================================== | |
--- batman-adv-2013.4.0.orig/distributed-arp-table.c | |
+++ batman-adv-2013.4.0/distributed-arp-table.c | |
@@ -858,7 +858,6 @@ bool batadv_dat_snoop_outgoing_arp_reque | |
bat_priv->soft_iface); | |
bat_priv->stats.rx_packets++; | |
bat_priv->stats.rx_bytes += skb->len + ETH_HLEN; | |
- bat_priv->soft_iface->last_rx = jiffies; | |
netif_rx(skb_new); | |
batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n"); | |
Index: batman-adv-2013.4.0/hard-interface.c | |
=================================================================== | |
--- batman-adv-2013.4.0.orig/hard-interface.c | |
+++ batman-adv-2013.4.0/hard-interface.c | |
@@ -61,6 +61,59 @@ out: | |
} | |
/** | |
+ * batadv_getlink_net - return link net namespace (of use fallback) | |
+ * @netdev: net_device to check | |
+ * @fallback_net: return in case get_link_net is not available for @netdev | |
+ * | |
+ * Return: result of rtnl_link_ops->get_link_net or @fallback_net | |
+ */ | |
+static struct net *batadv_getlink_net(const struct net_device *netdev, | |
+ struct net *fallback_net) | |
+{ | |
+ if (!netdev->rtnl_link_ops) | |
+ return fallback_net; | |
+ | |
+ if (!netdev->rtnl_link_ops->get_link_net) | |
+ return fallback_net; | |
+ | |
+ return netdev->rtnl_link_ops->get_link_net(netdev); | |
+} | |
+ | |
+/** | |
+ * batadv_mutual_parents - check if two devices are each others parent | |
+ * @dev1: 1st net dev | |
+ * @net1: 1st devices netns | |
+ * @dev2: 2nd net dev | |
+ * @net2: 2nd devices netns | |
+ * | |
+ * veth devices come in pairs and each is the parent of the other! | |
+ * | |
+ * Return: true if the devices are each others parent, otherwise false | |
+ */ | |
+static bool batadv_mutual_parents(const struct net_device *dev1, | |
+ struct net *net1, | |
+ const struct net_device *dev2, | |
+ struct net *net2) | |
+{ | |
+ int dev1_parent_iflink = dev_get_iflink(dev1); | |
+ int dev2_parent_iflink = dev_get_iflink(dev2); | |
+ const struct net *dev1_parent_net; | |
+ const struct net *dev2_parent_net; | |
+ | |
+ dev1_parent_net = batadv_getlink_net(dev1, net1); | |
+ dev2_parent_net = batadv_getlink_net(dev2, net2); | |
+ | |
+ if (!dev1_parent_iflink || !dev2_parent_iflink) | |
+ return false; | |
+ | |
+ return (dev1_parent_iflink == dev2->ifindex) && | |
+ (dev2_parent_iflink == dev1->ifindex) && | |
+ net_eq(dev1_parent_net, net2) && | |
+ net_eq(dev2_parent_net, net1); | |
+} | |
+ | |
+ | |
+/** | |
* batadv_is_on_batman_iface - check if a device is a batman iface descendant | |
* @net_dev: the device to check | |
* | |
@@ -75,7 +128,9 @@ out: | |
*/ | |
static bool batadv_is_on_batman_iface(const struct net_device *net_dev) | |
{ | |
+ struct net *net = dev_net(net_dev); | |
struct net_device *parent_dev; | |
+ struct net *parent_net; | |
bool ret; | |
/* check if this is a batman-adv mesh interface */ | |
@@ -87,12 +142,18 @@ static bool batadv_is_on_batman_iface(co | |
dev_get_iflink(net_dev) == net_dev->ifindex) | |
return false; | |
- /* recurse over the parent device */ | |
- parent_dev = __dev_get_by_index(&init_net, dev_get_iflink(net_dev)); | |
+ parent_net = batadv_getlink_net(net_dev, net); | |
+ | |
+ /* recurse over the parent device */ | |
+ parent_dev = __dev_get_by_index((struct net *)parent_net, | |
+ dev_get_iflink(net_dev)); | |
/* if we got a NULL parent_dev there is something broken.. */ | |
if (WARN(!parent_dev, "Cannot find parent device")) | |
return false; | |
+ if (batadv_mutual_parents(net_dev, net, parent_dev, parent_net)) | |
+ return false; | |
+ | |
ret = batadv_is_on_batman_iface(parent_dev); | |
return ret; | |
@@ -429,7 +490,7 @@ int batadv_hardif_enable_interface(struc | |
bat_priv = netdev_priv(hard_iface->soft_iface); | |
ret = netdev_master_upper_dev_link(hard_iface->net_dev, | |
- soft_iface, NULL, NULL); | |
+ soft_iface, NULL, NULL, NULL); | |
if (ret) | |
goto err_dev; | |
Index: batman-adv-2013.4.0/soft-interface.c | |
=================================================================== | |
--- batman-adv-2013.4.0.orig/soft-interface.c | |
+++ batman-adv-2013.4.0/soft-interface.c | |
@@ -361,8 +361,6 @@ void batadv_interface_rx(struct net_devi | |
batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, | |
skb->len + ETH_HLEN); | |
- soft_iface->last_rx = jiffies; | |
- | |
/* Let the bridge loop avoidance check the packet. If will | |
* not handle it, we can safely push it up. | |
*/ | |
@@ -528,11 +526,13 @@ free_bat_counters: | |
* batadv_softif_slave_add - Add a slave interface to a batadv_soft_interface | |
* @dev: batadv_soft_interface used as master interface | |
* @slave_dev: net_device which should become the slave interface | |
+ * @extack: extended ACK report struct | |
* | |
* Return 0 if successful or error otherwise. | |
*/ | |
static int batadv_softif_slave_add(struct net_device *dev, | |
- struct net_device *slave_dev) | |
+ struct net_device *slave_dev, | |
+ struct netlink_ext_ack *extack) | |
{ | |
struct batadv_hard_iface *hard_iface; | |
int ret = -EINVAL; | |
@@ -618,7 +618,7 @@ static void batadv_softif_init_early(str | |
ether_setup(dev); | |
dev->netdev_ops = &batadv_netdev_ops; | |
- dev->destructor = batadv_softif_free; | |
+ dev->priv_destructor = batadv_softif_free; | |
dev->tx_queue_len = 0; | |
/* can't call min_mtu, because the needed variables |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment