* [PATCH 1/2] backports: extend magic to 6 possible arguments
@ 2017-04-21 10:47 Johannes Berg
2017-04-21 10:47 ` [PATCH 2/2] backports: add the necessary backports for netlink extack Johannes Berg
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2017-04-21 10:47 UTC (permalink / raw)
To: backports; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
backport/backport-include/backport/magic.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/backport/backport-include/backport/magic.h b/backport/backport-include/backport/magic.h
index 222e02513ef2..d7e7cc961bbf 100644
--- a/backport/backport-include/backport/magic.h
+++ b/backport/backport-include/backport/magic.h
@@ -5,8 +5,8 @@
* http://efesx.com/2010/08/31/overloading-macros/
*/
-#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 5,4,3,2,1)
-#define VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...) N
+#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 6,5,4,3,2,1)
+#define VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(func, ...) \
macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
--
2.11.0
--
To unsubscribe from this list: send the line "unsubscribe backports" in
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] backports: add the necessary backports for netlink extack
2017-04-21 10:47 [PATCH 1/2] backports: extend magic to 6 possible arguments Johannes Berg
@ 2017-04-21 10:47 ` Johannes Berg
2017-04-21 18:50 ` Arend Van Spriel
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2017-04-21 10:47 UTC (permalink / raw)
To: backports; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
backport/backport-include/linux/netlink.h | 17 ++++++++
backport/backport-include/net/genetlink.h | 24 +++++++++++
backport/backport-include/net/netlink.h | 69 +++++++++++++++++++++++++++++++
patches/0078-genl-extack.cocci | 5 +++
4 files changed, 115 insertions(+)
create mode 100644 patches/0078-genl-extack.cocci
diff --git a/backport/backport-include/linux/netlink.h b/backport/backport-include/linux/netlink.h
index a40cc0f7f58f..58fad589039f 100644
--- a/backport/backport-include/linux/netlink.h
+++ b/backport/backport-include/linux/netlink.h
@@ -3,6 +3,23 @@
#include_next <linux/netlink.h>
#include <linux/version.h>
+#if LINUX_VERSION_IS_LESS(4,12,0)
+#define NETLINK_MAX_COOKIE_LEN 20
+
+struct netlink_ext_ack {
+ const char *_msg;
+ const struct nlattr *bad_attr;
+ u8 cookie[NETLINK_MAX_COOKIE_LEN];
+ u8 cookie_len;
+};
+
+#define NL_SET_ERR_MSG(extack, msg) do { \
+ static const char _msg[] = (msg); \
+ \
+ (extack)->_msg = _msg; \
+} while (0)
+#endif
+
/* this is for patches we apply */
#if LINUX_VERSION_IS_LESS(3,7,0)
#define netlink_notify_portid(__notify) (__notify->pid)
diff --git a/backport/backport-include/net/genetlink.h b/backport/backport-include/net/genetlink.h
index 4b31d73f8072..b655d243621b 100644
--- a/backport/backport-include/net/genetlink.h
+++ b/backport/backport-include/net/genetlink.h
@@ -3,6 +3,30 @@
#include_next <net/genetlink.h>
#include <linux/version.h>
+#if LINUX_VERSION_IS_LESS(4,12,0)
+#define GENL_SET_ERR_MSG(info, msg) do { } while (0)
+
+static inline int genl_err_attr(struct genl_info *info, int err,
+ struct nlattr *attr)
+{
+#if LINUX_VERSION_IS_GEQ(4,12,0)
+ info->extack->bad_attr = attr;
+#endif
+
+ return err;
+}
+#endif
+
+/* this is for patches we apply */
+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;
+#endif
+}
+
/* 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)
diff --git a/backport/backport-include/net/netlink.h b/backport/backport-include/net/netlink.h
index 9a3def77edb9..37c899b07b1d 100644
--- a/backport/backport-include/net/netlink.h
+++ b/backport/backport-include/net/netlink.h
@@ -4,6 +4,75 @@
#include <linux/version.h>
#include <linux/in6.h>
+#if LINUX_VERSION_IS_LESS(4,12,0)
+#include <backport/magic.h>
+
+static inline int nla_validate5(const struct nlattr *head,
+ int len, int maxtype,
+ const struct nla_policy *policy,
+ struct netlink_ext_ack *extack)
+{
+ return nla_validate(head, len, maxtype, policy);
+}
+#define nla_validate4 nla_validate
+#define nla_validate(...) \
+ macro_dispatcher(nla_validate, __VA_ARGS__)(__VA_ARGS__)
+
+static inline int nla_parse6(struct nlattr **tb, int maxtype,
+ const struct nlattr *head,
+ int len, const struct nla_policy *policy,
+ struct netlink_ext_ack *extack)
+{
+ return nla_parse(tb, maxtype, head, len, policy);
+}
+#define nla_parse5(...) nla_parse(__VA_ARGS__)
+#define nla_parse(...) \
+ macro_dispatcher(nla_parse, __VA_ARGS__)(__VA_ARGS__)
+
+static inline int nlmsg_parse6(const struct nlmsghdr *nlh, int hdrlen,
+ struct nlattr *tb[], int maxtype,
+ const struct nla_policy *policy,
+ struct netlink_ext_ack *extack)
+{
+ return nlmsg_parse(nlh, hdrlen, tb, maxtype, policy);
+}
+#define nlmsg_parse5 nlmsg_parse
+#define nlmsg_parse(...) \
+ macro_dispatcher(nlmsg_parse, __VA_ARGS__)(__VA_ARGS__)
+
+static inline int nlmsg_validate5(const struct nlmsghdr *nlh,
+ int hdrlen, int maxtype,
+ const struct nla_policy *policy,
+ struct netlink_ext_ack *extack)
+{
+ return nlmsg_validate(nlh, hdrlen, maxtype, policy);
+}
+#define nlmsg_validate4 nlmsg_validate
+#define nlmsg_validate(...) \
+ macro_dispatcher(nlmsg_validate, __VA_ARGS__)(__VA_ARGS__)
+
+static inline int nla_parse_nested5(struct nlattr *tb[], int maxtype,
+ const struct nlattr *nla,
+ const struct nla_policy *policy,
+ struct netlink_ext_ack *extack)
+{
+ return nla_parse_nested(tb, maxtype, nla, policy);
+}
+#define nla_parse_nested4 nla_parse_nested
+#define nla_parse_nested(...) \
+ macro_dispatcher(nla_parse_nested, __VA_ARGS__)(__VA_ARGS__)
+
+static inline int nla_validate_nested4(const struct nlattr *start, int maxtype,
+ const struct nla_policy *policy,
+ struct netlink_ext_ack *extack)
+{
+ return nla_validate_nested(start, maxtype, policy);
+}
+#define nla_validate_nested3 nla_validate_nested
+#define nla_validate_nested(...) \
+ macro_dispatcher(nla_validate_nested, __VA_ARGS__)(__VA_ARGS__)
+#endif /* LINUX_VERSION_IS_LESS(4,12,0) */
+
#if LINUX_VERSION_IS_LESS(3,7,0)
/**
* nla_put_s8 - Add a s8 netlink attribute to a socket buffer
diff --git a/patches/0078-genl-extack.cocci b/patches/0078-genl-extack.cocci
new file mode 100644
index 000000000000..b25061743554
--- /dev/null
+++ b/patches/0078-genl-extack.cocci
@@ -0,0 +1,5 @@
+@@
+struct genl_info *info;
+@@
+-info->extack
++genl_info_extack(info)
--
2.11.0
--
To unsubscribe from this list: send the line "unsubscribe backports" in
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] backports: add the necessary backports for netlink extack
2017-04-21 10:47 ` [PATCH 2/2] backports: add the necessary backports for netlink extack Johannes Berg
@ 2017-04-21 18:50 ` Arend Van Spriel
2017-04-21 18:54 ` Johannes Berg
0 siblings, 1 reply; 4+ messages in thread
From: Arend Van Spriel @ 2017-04-21 18:50 UTC (permalink / raw)
To: Johannes Berg, backports; +Cc: Johannes Berg
On 21-4-2017 12:47, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
I did not follow everything about this extack thing, but does it impose
a version requirement on the libnl used in user-space?
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
> backport/backport-include/linux/netlink.h | 17 ++++++++
> backport/backport-include/net/genetlink.h | 24 +++++++++++
> backport/backport-include/net/netlink.h | 69 +++++++++++++++++++++++++++++++
> patches/0078-genl-extack.cocci | 5 +++
> 4 files changed, 115 insertions(+)
> create mode 100644 patches/0078-genl-extack.cocci
[...]
> +/* this is for patches we apply */
Guess the comment is inspired by the one below ;-) but would it not be a
bit more clear to say:
/* this is for files patched using 0078-genl-extack.cocci */
> +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;
> +#endif
> +}
> +
> /* 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)
Regards,
Arend
--
To unsubscribe from this list: send the line "unsubscribe backports" in
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] backports: add the necessary backports for netlink extack
2017-04-21 18:50 ` Arend Van Spriel
@ 2017-04-21 18:54 ` Johannes Berg
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2017-04-21 18:54 UTC (permalink / raw)
To: Arend Van Spriel, backports
On Fri, 2017-04-21 at 20:50 +0200, Arend Van Spriel wrote:
> On 21-4-2017 12:47, Johannes Berg wrote:
> > From: Johannes Berg <johannes.berg@intel.com>
>
> I did not follow everything about this extack thing, but does it
> impose a version requirement on the libnl used in user-space?
No. It turns out that libnl doesn't care at all about the ack message
contents, so you can use any version.
Here's a sample iw patch:
https://git.kernel.org/pub/scm/linux/kernel/git/jberg/iw.git/commit/?h=bpf&id=7105f7614c13680306cf3b91ad8711eccfa70df3
> > +/* this is for patches we apply */
>
> Guess the comment is inspired by the one below ;-) but would it not
> be a bit more clear to say:
>
> /* this is for files patched using 0078-genl-extack.cocci */
Yeah I guess that'd make some sense :)
Though realistically none of it is really all that necessary since one
can always grep ;-)
johannes
--
To unsubscribe from this list: send the line "unsubscribe backports" in
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-21 18:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21 10:47 [PATCH 1/2] backports: extend magic to 6 possible arguments Johannes Berg
2017-04-21 10:47 ` [PATCH 2/2] backports: add the necessary backports for netlink extack Johannes Berg
2017-04-21 18:50 ` Arend Van Spriel
2017-04-21 18:54 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).