backports: fully add netlink extack for generic netlink
PATCH v3 1/1 backports: fully add netlink extack for generic netlink
From: Johannes Berg <[email protected]>
The previous backport just made the code compatible, but removed the extack functionality entirely.
By ignoring the setsockopt() and just assuming that userspace does in fact support extack (which is true for all of wifi and in fact all users of libnl), we can support full extack functionality even on kernels that don't support it.
Signed-off-by Johannes Berg <[email protected]>
--- backport/backport-include/linux/netlink.h | 3 + backport/backport-include/net/genetlink.h | 27 +++- backport/compat/Makefile | 1 + backport/compat/backport-4.12.c | 243 ++++++++++++++++++++++++++++++ patches/0078-genl-extack.cocci | 6 + 5 files changed, 279 insertions(+), 1 deletion(-) create mode 100644 backport/compat/backport-4.12.c
backport/backport-include/linux/netlink.h +3 -0
@@ -11,6 +11,9 @@ struct netlink_ext_ack {const struct nlattr *bad_attr;u8 cookie[NETLINK_MAX_COOKIE_LEN ];u8 cookie_len; + +/* backport only field */ +const void *__bp_genl_real_ops; };#define NL_SET_ERR_MSG (extack, msg) do { \
backport/backport-include/net/genetlink.h +26 -1
@@ -23,10 +23,16 @@ static inline struct netlink_ext_ack *genl_info_extack(struct genl_info *info)#if LINUX_VERSION_IS_GEQ (4 ,12 ,0 )return info->extack;#else -return NULL ; +return info->userhdr;#endif } +/* this gets put in place of info->userhdr, since we use that above */ +static inline void *genl_info_userhdr (struct genl_info *info) +{ +return (u8 *)info->genlhdr +GENL_HDRLEN ; +} +/* this is for patches we apply */ #if LINUX_VERSION_IS_LESS (3 ,7 ,0 )#define genl_info_snd_portid (__genl_info) (__genl_info->snd_pid)
@@ -202,4 +208,23 @@ static inline struct nlattr **genl_family_attrbuf(struct genl_family *family)#define __genl_ro_after_init __ro_after_init#endif +#if LINUX_VERSION_IS_LESS (4 ,12 ,0 ) +static inline int +__real_bp_extack_genl_register_family (struct genl_family *family) +{ +return genl_register_family (family); +} +static inline int +__real_bp_extack_genl_unregister_family (struct genl_family *family) +{ +return genl_unregister_family (family); +} +int bp_extack_genl_register_family (struct genl_family *family); +int bp_extack_genl_unregister_family (struct genl_family *family); +#undef genl_register_family +#define genl_register_family bp_extack_genl_register_family +#undef genl_unregister_family +#define genl_unregister_family bp_extack_genl_unregister_family +#endif +#endif /* __BACKPORT_NET_GENETLINK_H */
backport/compat/Makefile +1 -0
@@ -36,6 +36,7 @@ compat-$(CPTCFG_KERNEL_4_6) += backport-4.6.o compat-$(CPTCFG_KERNEL_4_7) += backport-4.7.o compat-$(CPTCFG_KERNEL_4_8) += backport-4.8.o compat-$(CPTCFG_KERNEL_4_10) += backport-4.10.o +compat-$(CPTCFG_KERNEL_4_12) += backport-4.12.o compat-$(CPTCFG_BPAUTO_CRYPTO_SKCIPHER) += crypto-skcipher.o
backport/compat/backport-4.12.c new file +243 -0
243 lines not on this page · raw message
patches/0078-genl-extack.cocci +6 -0
@@ -3,3 +3,9 @@ struct genl_info *info; @@ -info->extack +genl_info_extack(info) + +@@ +struct genl_info *info; +@@ +-info->userhdr ++genl_info_userhdr(info)
Signature · 4 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe backports" in