|
@@ -75,6 +75,28 @@ out:
|
|
|
return hard_iface;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * batadv_mutual_parents - check if two devices are each others parent
|
|
|
+ * @dev1: 1st net_device
|
|
|
+ * @dev2: 2nd net_device
|
|
|
+ *
|
|
|
+ * 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,
|
|
|
+ const struct net_device *dev2)
|
|
|
+{
|
|
|
+ int dev1_parent_iflink = dev_get_iflink(dev1);
|
|
|
+ int dev2_parent_iflink = dev_get_iflink(dev2);
|
|
|
+
|
|
|
+ if (!dev1_parent_iflink || !dev2_parent_iflink)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ return (dev1_parent_iflink == dev2->ifindex) &&
|
|
|
+ (dev2_parent_iflink == dev1->ifindex);
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* batadv_is_on_batman_iface - check if a device is a batman iface descendant
|
|
|
* @net_dev: the device to check
|
|
@@ -108,6 +130,9 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev)
|
|
|
if (WARN(!parent_dev, "Cannot find parent device"))
|
|
|
return false;
|
|
|
|
|
|
+ if (batadv_mutual_parents(net_dev, parent_dev))
|
|
|
+ return false;
|
|
|
+
|
|
|
ret = batadv_is_on_batman_iface(parent_dev);
|
|
|
|
|
|
return ret;
|