From: Nicolas Dichtel <[email protected]>

The goal of this patch is to prepare the removal of the iflink field. It
introduces a new ndo function, which will be implemented by virtual interfaces.

There is no functional change into this patch. All readers of iflink field
now call dev_get_iflink().

Signed-off-by: Nicolas Dichtel <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
[[email protected]: added compat code]
Signed-off-by: Sven Eckelmann <[email protected]>
---
This has to be moved to linux/netdevice.h for
https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2015-April/012960.html

v2:
 - Fix the comment in the compat code which still said "3, 19, 0"

 compat.h         | 6 ++++++
 hard-interface.c | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/compat.h b/compat.h
index 45412b0..0332296 100644
--- a/compat.h
+++ b/compat.h
@@ -482,4 +482,10 @@ static inline bool seq_has_overflowed(struct seq_file *m)
 
 #endif /* < KERNEL_VERSION(3, 19, 0) */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
+
+#define dev_get_iflink(_net_dev) ((_net_dev)->iflink)
+
+#endif /* < KERNEL_VERSION(4, 1, 0) */
+
 #endif /* _NET_BATMAN_ADV_COMPAT_H_ */
diff --git a/hard-interface.c b/hard-interface.c
index fbda6b5..baf1f98 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -83,11 +83,12 @@ static bool batadv_is_on_batman_iface(const struct 
net_device *net_dev)
                return true;
 
        /* no more parents..stop recursion */
-       if (net_dev->iflink == 0 || net_dev->iflink == net_dev->ifindex)
+       if (dev_get_iflink(net_dev) == 0 ||
+           dev_get_iflink(net_dev) == net_dev->ifindex)
                return false;
 
        /* recurse over the parent device */
-       parent_dev = __dev_get_by_index(&init_net, net_dev->iflink);
+       parent_dev = __dev_get_by_index(&init_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;
-- 
2.1.4

Reply via email to