summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-06-20 10:21:00 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-06-24 11:19:18 +0200
commit7d47894395a7311975a5ce50ea204e70f481a27c (patch)
tree564a8355320250a027bb2dc7df2a7970da2d504a
parentcompat: some kernels weirdly backport prandom_u32_max (diff)
downloadwireguard-monolithic-historical-7d47894395a7311975a5ce50ea204e70f481a27c.tar.xz
wireguard-monolithic-historical-7d47894395a7311975a5ce50ea204e70f481a27c.zip
compat: unify custom function prefix/suffix
-rw-r--r--src/compat/compat.h62
-rw-r--r--src/compat/udp_tunnel/udp_tunnel.c14
-rw-r--r--src/compat/udp_tunnel/udp_tunnel_partial_compat.h20
3 files changed, 48 insertions, 48 deletions
diff --git a/src/compat/compat.h b/src/compat/compat.h
index 5b28928..acf18e7 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -126,7 +126,7 @@ static inline void skb_reset_tc(struct sk_buff *skb)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
#include <linux/random.h>
#include <linux/siphash.h>
-static inline u32 __wgcompat_get_random_u32(void)
+static inline u32 __compat_get_random_u32(void)
{
static siphash_key_t key;
static u32 counter = 0;
@@ -141,7 +141,7 @@ static inline u32 __wgcompat_get_random_u32(void)
#endif
return siphash_2u32(counter++, get_random_int(), &key);
}
-#define get_random_u32 __wgcompat_get_random_u32
+#define get_random_u32 __compat_get_random_u32
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) && !defined(ISRHEL7)
@@ -181,7 +181,7 @@ static inline void netif_keep_dst(struct net_device *dev)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) && !defined(ISRHEL7)
#include "checksum/checksum_partial_compat.h"
-static inline void *our_pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len)
+static inline void *__compat_pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len)
{
if (tail != skb) {
skb->data_len += len;
@@ -189,7 +189,7 @@ static inline void *our_pskb_put(struct sk_buff *skb, struct sk_buff *tail, int
}
return skb_put(tail, len);
}
-#define pskb_put our_pskb_put
+#define pskb_put __compat_pskb_put
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) && !defined(ISRHEL7)
@@ -216,11 +216,11 @@ static inline void skb_scrub_packet(struct sk_buff *skb, bool xnet)
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) || defined(ISUBUNTU1404)) && !defined(ISRHEL7)
#include <linux/random.h>
-static inline u32 __wgcompat_prandom_u32_max(u32 ep_ro)
+static inline u32 __compat_prandom_u32_max(u32 ep_ro)
{
return (u32)(((u64)prandom_u32() * ep_ro) >> 32);
}
-#define prandom_u32_max __wgcompat_prandom_u32_max
+#define prandom_u32_max __compat_prandom_u32_max
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 75) && !defined(ISRHEL7)
@@ -273,8 +273,8 @@ static inline void memzero_explicit(void *s, size_t count)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) && !defined(ISRHEL7)
-static const struct in6_addr our_in6addr_any = IN6ADDR_ANY_INIT;
-#define in6addr_any our_in6addr_any
+static const struct in6_addr __compat_in6addr_any = IN6ADDR_ANY_INIT;
+#define in6addr_any __compat_in6addr_any
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) && !defined(ISOPENSUSE15)
@@ -402,16 +402,16 @@ static inline u64 ktime_get_boot_ns(void)
#else
#include <linux/timekeeping.h>
#endif
-static inline u64 __wgcompat_ktime_get_boot_fast_ns(void)
+static inline u64 __compat_ktime_get_boot_fast_ns(void)
{
return ktime_get_boot_ns();
}
-#define ktime_get_boot_fast_ns __wgcompat_ktime_get_boot_fast_ns
+#define ktime_get_boot_fast_ns __compat_ktime_get_boot_fast_ns
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
#include <linux/inetdevice.h>
-static inline __be32 our_confirm_addr_indev(struct in_device *in_dev, __be32 dst, __be32 local, int scope)
+static inline __be32 __compat_confirm_addr_indev(struct in_device *in_dev, __be32 dst, __be32 local, int scope)
{
int same = 0;
__be32 addr = 0;
@@ -438,17 +438,17 @@ static inline __be32 our_confirm_addr_indev(struct in_device *in_dev, __be32 dst
} endfor_ifa(in_dev);
return same ? addr : 0;
}
-static inline __be32 our_inet_confirm_addr(struct net *net, struct in_device *in_dev, __be32 dst, __be32 local, int scope)
+static inline __be32 __compat_inet_confirm_addr(struct net *net, struct in_device *in_dev, __be32 dst, __be32 local, int scope)
{
__be32 addr = 0;
struct net_device *dev;
if (in_dev)
- return our_confirm_addr_indev(in_dev, dst, local, scope);
+ return __compat_confirm_addr_indev(in_dev, dst, local, scope);
rcu_read_lock();
for_each_netdev_rcu(net, dev) {
in_dev = __in_dev_get_rcu(dev);
if (in_dev) {
- addr = our_confirm_addr_indev(in_dev, dst, local, scope);
+ addr = __compat_confirm_addr_indev(in_dev, dst, local, scope);
if (addr)
break;
}
@@ -456,14 +456,14 @@ static inline __be32 our_inet_confirm_addr(struct net *net, struct in_device *in
rcu_read_unlock();
return addr;
}
-#define inet_confirm_addr our_inet_confirm_addr
+#define inet_confirm_addr __compat_inet_confirm_addr
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include <linux/slab.h>
-static inline void *kvmalloc_ours(size_t size, gfp_t flags)
+static inline void *__compat_kvmalloc(size_t size, gfp_t flags)
{
gfp_t kmalloc_flags = flags;
void *ret;
@@ -477,25 +477,25 @@ static inline void *kvmalloc_ours(size_t size, gfp_t flags)
return ret;
return __vmalloc(size, flags, PAGE_KERNEL);
}
-static inline void *kvzalloc_ours(size_t size, gfp_t flags)
+static inline void *__compat_kvzalloc(size_t size, gfp_t flags)
{
- return kvmalloc_ours(size, flags | __GFP_ZERO);
+ return __compat_kvmalloc(size, flags | __GFP_ZERO);
}
-#define kvmalloc kvmalloc_ours
-#define kvzalloc kvzalloc_ours
+#define kvmalloc __compat_kvmalloc
+#define kvzalloc __compat_kvzalloc
#endif
#if ((LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 41)) && !defined(ISUBUNTU1404)
#include <linux/vmalloc.h>
#include <linux/mm.h>
-static inline void kvfree_ours(const void *addr)
+static inline void __compat_kvfree(const void *addr)
{
if (is_vmalloc_addr(addr))
vfree(addr);
else
kfree(addr);
}
-#define kvfree kvfree_ours
+#define kvfree __compat_kvfree
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 9)
@@ -549,16 +549,16 @@ static inline struct nlattr **genl_family_attrbuf(const struct genl_family *fami
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 2) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 16) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 65) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 101) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 84)
-#define ___COMPAT_NETLINK_DUMP_BLOCK { \
+#define __COMPAT_NETLINK_DUMP_BLOCK { \
int ret; \
skb->end -= nlmsg_total_size(sizeof(int)); \
ret = wg_get_device_dump_real(skb, cb); \
skb->end += nlmsg_total_size(sizeof(int)); \
return ret; \
}
-#define ___COMPAT_NETLINK_DUMP_OVERRIDE
+#define __COMPAT_NETLINK_DUMP_OVERRIDE
#else
-#define ___COMPAT_NETLINK_DUMP_BLOCK return wg_get_device_dump_real(skb, cb);
+#define __COMPAT_NETLINK_DUMP_BLOCK return wg_get_device_dump_real(skb, cb);
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 8) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)) || (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 25) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) || LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 87)
#define wg_get_device_dump(a, b) wg_get_device_dump_real(a, b); \
@@ -569,14 +569,14 @@ static int wg_get_device_dump(a, b) { \
if (ret) \
return ret; \
} \
- ___COMPAT_NETLINK_DUMP_BLOCK \
+ __COMPAT_NETLINK_DUMP_BLOCK \
} \
static int wg_get_device_dump_real(a, b)
#define COMPAT_CANNOT_USE_NETLINK_START
-#elif defined(___COMPAT_NETLINK_DUMP_OVERRIDE)
+#elif defined(__COMPAT_NETLINK_DUMP_OVERRIDE)
#define wg_get_device_dump(a, b) wg_get_device_dump_real(a, b); \
static int wg_get_device_dump(a, b) { \
- ___COMPAT_NETLINK_DUMP_BLOCK \
+ __COMPAT_NETLINK_DUMP_BLOCK \
} \
static int wg_get_device_dump_real(a, b)
#endif
@@ -633,8 +633,8 @@ static inline int cpu_has_xfeatures(u64 xfeatures_needed, const char **feature_n
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
-struct _____dummy_container { char dev; };
-#define netdev_notifier_info net_device *)data); __attribute((unused)) char _____dummy = ((struct _____dummy_container
+struct __compat_dummy_container { char dev; };
+#define netdev_notifier_info net_device *)data); __attribute((unused)) char __compat_dummy_variable = ((struct __compat_dummy_container
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
@@ -681,7 +681,7 @@ static inline void *skb_put_data(struct sk_buff *skb, const void *data, unsigned
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
#include <linux/atomic.h>
#ifndef atomic_read_acquire
-#define atomic_read_acquire(v) ({ int ___p1 = atomic_read(v); smp_rmb(); ___p1; })
+#define atomic_read_acquire(v) ({ int __compat_p1 = atomic_read(v); smp_rmb(); __compat_p1; })
#endif
#ifndef atomic_set_release
#define atomic_set_release(v, i) ({ smp_wmb(); atomic_set(v, i); })
diff --git a/src/compat/udp_tunnel/udp_tunnel.c b/src/compat/udp_tunnel/udp_tunnel.c
index dc47d61..ae43566 100644
--- a/src/compat/udp_tunnel/udp_tunnel.c
+++ b/src/compat/udp_tunnel/udp_tunnel.c
@@ -17,7 +17,7 @@
/* This is global so, uh, only one real call site... This is the kind of horrific hack you'd expect to see in compat code. */
static udp_tunnel_encap_rcv_t encap_rcv = NULL;
-static void our_sk_data_ready(struct sock *sk
+static void __compat_sk_data_ready(struct sock *sk
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
,int unused_vulnerable_length_param
#endif
@@ -86,7 +86,7 @@ void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
rcu_assign_sk_user_data(sock->sk, cfg->sk_user_data);
/* We force the cast in this awful way, due to various Android kernels
* backporting things stupidly. */
- *(void **)&sock->sk->sk_data_ready = (void *)our_sk_data_ready;
+ *(void **)&sock->sk->sk_data_ready = (void *)__compat_sk_data_ready;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
@@ -131,12 +131,12 @@ static void udp_set_csum(bool nocheck, struct sk_buff *skb,
#endif
-static void fake_destructor(struct sk_buff *skb)
+static void __compat_fake_destructor(struct sk_buff *skb)
{
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
-static void our_iptunnel_xmit(struct rtable *rt, struct sk_buff *skb,
+static void __compat_iptunnel_xmit(struct rtable *rt, struct sk_buff *skb,
__be32 src, __be32 dst, __u8 proto,
__u8 tos, __u8 ttl, __be16 df, bool xnet)
{
@@ -174,7 +174,7 @@ static void our_iptunnel_xmit(struct rtable *rt, struct sk_buff *skb,
tstats->tx_bytes -= 8;
u64_stats_update_end(&tstats->syncp);
}
-#define iptunnel_xmit our_iptunnel_xmit
+#define iptunnel_xmit __compat_iptunnel_xmit
#endif
void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb,
@@ -203,7 +203,7 @@ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb
if (!skb->sk)
skb->sk = sk;
if (!skb->destructor)
- skb->destructor = fake_destructor;
+ skb->destructor = __compat_fake_destructor;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
ret =
#endif
@@ -379,7 +379,7 @@ int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
if (!skb->sk)
skb->sk = sk;
if (!skb->destructor)
- skb->destructor = fake_destructor;
+ skb->destructor = __compat_fake_destructor;
ip6tunnel_xmit(skb, dev);
return 0;
diff --git a/src/compat/udp_tunnel/udp_tunnel_partial_compat.h b/src/compat/udp_tunnel/udp_tunnel_partial_compat.h
index a4b5a14..0605896 100644
--- a/src/compat/udp_tunnel/udp_tunnel_partial_compat.h
+++ b/src/compat/udp_tunnel/udp_tunnel_partial_compat.h
@@ -19,7 +19,7 @@
#include <net/ip6_checksum.h>
#include <net/ip6_tunnel.h>
#endif
-static inline void fake_destructor(struct sk_buff *skb)
+static inline void __compat_fake_destructor(struct sk_buff *skb)
{
}
typedef int (*udp_tunnel_encap_rcv_t)(struct sock *sk, struct sk_buff *skb);
@@ -30,7 +30,7 @@ struct udp_tunnel_sock_cfg {
};
/* This is global so, uh, only one real call site... This is the kind of horrific hack you'd expect to see in compat code. */
static udp_tunnel_encap_rcv_t encap_rcv = NULL;
-static void our_sk_data_ready(struct sock *sk)
+static void __compat_sk_data_ready(struct sock *sk)
{
struct sk_buff *skb;
while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
@@ -46,7 +46,7 @@ static inline void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
inet_sk(sk)->mc_loop = 0;
encap_rcv = cfg->encap_rcv;
rcu_assign_sk_user_data(sk, cfg->sk_user_data);
- sk->sk_data_ready = our_sk_data_ready;
+ sk->sk_data_ready = __compat_sk_data_ready;
}
static inline void udp_tunnel_sock_release(struct socket *sock)
{
@@ -122,13 +122,13 @@ static inline int udp_tunnel6_xmit_skb(struct socket *sock, struct dst_entry *ds
#include <linux/if.h>
#include <net/udp_tunnel.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
-static inline void fake_destructor(struct sk_buff *skb)
+static inline void __compat_fake_destructor(struct sk_buff *skb)
{
}
#endif
-#define udp_tunnel_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) do { struct net_device *dev__ = (c)->dev; int ret__; if (!(c)->destructor) (c)->destructor = fake_destructor; if (!(c)->sk) (c)->sk = (b); ret__ = udp_tunnel_xmit_skb(a, c, d, e, f, g, h, i, j, k, l); if (ret__) iptunnel_xmit_stats(ret__ - 8, &dev__->stats, dev__->tstats); } while (0)
+#define udp_tunnel_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) do { struct net_device *dev__ = (c)->dev; int ret__; if (!(c)->destructor) (c)->destructor = __compat_fake_destructor; if (!(c)->sk) (c)->sk = (b); ret__ = udp_tunnel_xmit_skb(a, c, d, e, f, g, h, i, j, k, l); if (ret__) iptunnel_xmit_stats(ret__ - 8, &dev__->stats, dev__->tstats); } while (0)
#if IS_ENABLED(CONFIG_IPV6)
-#define udp_tunnel6_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) do { if (!(c)->destructor) (c)->destructor = fake_destructor; if (!(c)->sk) (c)->sk = (b); udp_tunnel6_xmit_skb(a, c, d, e, f, g, h, j, k, l); } while(0)
+#define udp_tunnel6_xmit_skb(a, b, c, d, e, f, g, h, i, j, k, l) do { if (!(c)->destructor) (c)->destructor = __compat_fake_destructor; if (!(c)->sk) (c)->sk = (b); udp_tunnel6_xmit_skb(a, c, d, e, f, g, h, j, k, l); } while(0)
#endif
#else
@@ -156,7 +156,7 @@ static inline void fake_destructor(struct sk_buff *skb)
#include <linux/skbuff.h>
#include <linux/if.h>
#include <net/udp_tunnel.h>
-struct udp_port_cfg_new {
+struct __compat_udp_port_cfg {
u8 family;
union {
struct in_addr local_ip;
@@ -174,7 +174,7 @@ struct udp_port_cfg_new {
__be16 peer_udp_port;
unsigned int use_udp_checksums:1, use_udp6_tx_checksums:1, use_udp6_rx_checksums:1, ipv6_v6only:1;
};
-static inline int __maybe_unused udp_sock_create_new(struct net *net, struct udp_port_cfg_new *cfg, struct socket **sockp)
+static inline int __maybe_unused __compat_udp_sock_create(struct net *net, struct __compat_udp_port_cfg *cfg, struct socket **sockp)
{
struct udp_port_cfg old_cfg = {
.family = cfg->family,
@@ -221,6 +221,6 @@ static inline int __maybe_unused udp_sock_create_new(struct net *net, struct udp
#endif
return -EPFNOSUPPORT;
}
-#define udp_port_cfg udp_port_cfg_new
-#define udp_sock_create(a, b, c) udp_sock_create_new(a, b, c)
+#define udp_port_cfg __compat_udp_port_cfg
+#define udp_sock_create(a, b, c) __compat_udp_sock_create(a, b, c)
#endif