aboutsummaryrefslogtreecommitdiffstatshomepage
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
commitc62e2b8f94734246b5381d67186d80b1d7d82e64 (patch)
tree516cd07c35b3a278f11e6a71f22c88c03b21cf80
parentsocket: use dst_cache instead of handrolled cache (diff)
downloadwireguard-monolithic-historical-c62e2b8f94734246b5381d67186d80b1d7d82e64.tar.xz
wireguard-monolithic-historical-c62e2b8f94734246b5381d67186d80b1d7d82e64.zip
compat: stub out dst_cache for old kernels
-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>