aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/compat/compat.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-11-27 12:18:52 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-12-05 11:51:39 +0100
commit5eb87fb6497e4d25f8d47ef934dbedafdfb8fb81 (patch)
treeff77fa1ecc4b9815d2c571dcdca343fbe72b918b /src/compat/compat.h
parentversion: bump snapshot (diff)
downloadwireguard-monolithic-historical-5eb87fb6497e4d25f8d47ef934dbedafdfb8fb81.tar.xz
wireguard-monolithic-historical-5eb87fb6497e4d25f8d47ef934dbedafdfb8fb81.zip
netlink: prepare for removal of genl_family_attrbuf in 5.5
Diffstat (limited to '')
-rw-r--r--src/compat/compat.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/compat/compat.h b/src/compat/compat.h
index 34d6d9e..ab22fa4 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -843,6 +843,24 @@ static inline void skb_mark_not_on_list(struct sk_buff *skb)
#define cpu_have_named_feature(name) (elf_hwcap & (HWCAP_ ## name))
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
+#include <linux/stddef.h>
+#ifndef offsetofend
+#define offsetofend(TYPE, MEMBER) (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))
+#endif
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)
+#define genl_dumpit_info(cb) ({ \
+ struct { struct nlattr **attrs; } *a = (void *)((u8 *)cb->args + offsetofend(struct dump_ctx, next_allowedip)); \
+ BUILD_BUG_ON(sizeof(cb->args) < offsetofend(struct dump_ctx, next_allowedip) + sizeof(*a)); \
+ a->attrs = genl_family_attrbuf(&genl_family); \
+ if (nlmsg_parse(cb->nlh, GENL_HDRLEN + genl_family.hdrsize, a->attrs, genl_family.maxattr, device_policy, NULL) < 0) \
+ memset(a->attrs, 0, (genl_family.maxattr + 1) * sizeof(struct nlattr *)); \
+ a; \
+})
+#endif
+
#if defined(ISUBUNTU1604)
#include <linux/siphash.h>
#ifndef _WG_LINUX_SIPHASH_H