summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-11-04 03:38:54 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2016-11-04 03:38:54 +0100
commit339b9c47d9aed8244c0cb1365a78b1918e5e69a1 (patch)
tree08b6cbd655668c5203d43d26e15fee9233ef7994
parent4db38d808daaa1a5ba79f87018a4e7240e1a331e (diff)
compat: stub out dst_cache for old kernels
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--src/compat.h14
-rw-r--r--src/peer.h2
-rw-r--r--src/socket.c1
3 files changed, 16 insertions, 1 deletions
diff --git a/src/compat.h b/src/compat.h
index 6663ec6..6d9c0e2 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -126,6 +126,20 @@ __attribute__((unused)) static inline int udp_sock_create_new(struct net *net, s
#define time_is_after_eq_jiffies64(a) time_before_eq64(get_jiffies_64(), a)
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
+struct dst_cache { };
+static inline struct dst_entry *dst_cache_get(struct dst_cache *dst_cache) { return NULL; }
+static inline struct rtable *dst_cache_get_ip4(struct dst_cache *dst_cache, __be32 *saddr) { return NULL; }
+static inline void dst_cache_set_ip4(struct dst_cache *dst_cache, struct dst_entry *dst, __be32 saddr) { }
+#if IS_ENABLED(CONFIG_IPV6)
+static inline void dst_cache_set_ip6(struct dst_cache *dst_cache, struct dst_entry *dst, const struct in6_addr *addr) { }
+static inline struct dst_entry *dst_cache_get_ip6(struct dst_cache *dst_cache, struct in6_addr *saddr) { return NULL; }
+#endif
+static inline void dst_cache_reset(struct dst_cache *dst_cache) { }
+static inline int dst_cache_init(struct dst_cache *dst_cache, gfp_t gfp) { return 0; }
+static inline void dst_cache_destroy(struct dst_cache *dst_cache) { }
+#endif
+
/* https://lkml.org/lkml/2015/6/12/415 */
#include <linux/netdevice.h>
static inline struct net_device *netdev_pub(void *dev)
diff --git a/src/peer.h b/src/peer.h
index c97d934..466946b 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -10,7 +10,9 @@
#include <linux/netfilter.h>
#include <linux/spinlock.h>
#include <linux/kref.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
#include <net/dst_cache.h>
+#endif
struct wireguard_device;
diff --git a/src/socket.c b/src/socket.c
index 265c6dc..4ae767d 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -10,7 +10,6 @@
#include <linux/net.h>
#include <linux/if_vlan.h>
#include <linux/if_ether.h>
-#include <net/dst_cache.h>
#include <net/udp_tunnel.h>
#include <net/ipv6.h>