[shortcut-fe] correct neighbour fetching function
Kernel before 3.4.1 use destination IP address to get neighbour.
Kernel after 3.4.1 use destination IP address to get neighbour if
it is directly connected host, use gateway if not directly connected
host.
To be compitable with these two versions, we defined a macro to unify
the interface.
Change-Id: Iad20f940f6e2e75b7ba264aba72861a711e66033
Signed-off-by: Xiaoping Fan <xfan@codeaurora.org>
diff --git a/shortcut-fe/sfe_backport.h b/shortcut-fe/sfe_backport.h
index 4bc9253..3b021b4 100644
--- a/shortcut-fe/sfe_backport.h
+++ b/shortcut-fe/sfe_backport.h
@@ -167,3 +167,18 @@
#define sfe_hash_for_each(name, bkt, node, obj, member) \
hash_for_each(name, bkt, node, obj, member)
#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
+#define sfe_dst_get_neighbour(dst, daddr) dst_neigh_lookup(dst, addr)
+#else
+static inline struct neighbour *
+sfe_dst_get_neighbour(struct dst_entry *dst, void *daddr)
+{
+ struct neighbour *neigh = dst_get_neighbour_noref(dst);
+
+ if (neigh)
+ neigh_hold(neigh);
+
+ return neigh;
+}
+#endif