diff mbox series

[v2,1/6] backports: rename magic functions for netlink parsing

Message ID 20181002193215.399-1-johannes@sipsolutions.net (mailing list archive)
State Accepted
Headers show
Series [v2,1/6] backports: rename magic functions for netlink parsing | expand

Commit Message

Johannes Berg Oct. 2, 2018, 7:32 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Make all the magic variable argument calls inlines and
rename them so we can override them more easily later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 backport/backport-include/net/netlink.h | 100 +++++++++++++++++++++-----------
 1 file changed, 65 insertions(+), 35 deletions(-)

Comments

Johannes Berg Oct. 2, 2018, 7:33 p.m. UTC | #1
I've just tested this whole series on 3.11 (yes!) and 4.11, so I'm
confident it works and will apply it :-)

And yes, it does have a few fixes over the first version that came up
when testing on 3.11.

johannes
--
To unsubscribe from this list: send the line "unsubscribe backports" in
Johannes Berg Oct. 2, 2018, 7:34 p.m. UTC | #2
On Tue, 2018-10-02 at 21:33 +0200, Johannes Berg wrote:
> I've just tested this whole series on 3.11 (yes!) and 4.11, so I'm
> confident it works and will apply it :-)
> 
> And yes, it does have a few fixes over the first version that came up
> when testing on 3.11.

Sorry, that should've been 3.12, specifically 3.12.74.

But it doesn't matter as the big generic netlink changes were in 3.13.

johannes
--
To unsubscribe from this list: send the line "unsubscribe backports" in
diff mbox series

Patch

diff --git a/backport/backport-include/net/netlink.h b/backport/backport-include/net/netlink.h
index 37c899b07b1d..7775bc8295c3 100644
--- a/backport/backport-include/net/netlink.h
+++ b/backport/backport-include/net/netlink.h
@@ -7,70 +7,100 @@ 
 #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)
+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
+static inline int _nla_validate4(const struct nlattr *head,
+				 int len, int maxtype,
+				 const struct nla_policy *policy)
+{
+	return nla_validate(head, len, maxtype, policy);
+}
+#undef nla_validate
 #define nla_validate(...) \
-	macro_dispatcher(nla_validate, __VA_ARGS__)(__VA_ARGS__)
+	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)
+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);
+}
+static inline int _nla_parse5(struct nlattr **tb, int maxtype,
+			      const struct nlattr *head,
+			      int len, const struct nla_policy *policy)
 {
 	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__)
+	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)
+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);
+}
+static inline int _nlmsg_parse5(const struct nlmsghdr *nlh, int hdrlen,
+			        struct nlattr *tb[], int maxtype,
+			        const struct nla_policy *policy)
 {
 	return nlmsg_parse(nlh, hdrlen, tb, maxtype, policy);
 }
-#define nlmsg_parse5 nlmsg_parse
 #define nlmsg_parse(...) \
-	macro_dispatcher(nlmsg_parse, __VA_ARGS__)(__VA_ARGS__)
+	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)
+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);
+}
+static inline int _nlmsg_validate4(const struct nlmsghdr *nlh,
+				   int hdrlen, int maxtype,
+				   const struct nla_policy *policy)
 {
 	return nlmsg_validate(nlh, hdrlen, maxtype, policy);
 }
-#define nlmsg_validate4 nlmsg_validate
 #define nlmsg_validate(...) \
-	macro_dispatcher(nlmsg_validate, __VA_ARGS__)(__VA_ARGS__)
+	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)
+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);
+}
+static inline int _nla_parse_nested4(struct nlattr *tb[], int maxtype,
+				     const struct nlattr *nla,
+				     const struct nla_policy *policy)
 {
 	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__)
+	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)
+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);
+}
+static inline int _nla_validate_nested3(const struct nlattr *start, int maxtype,
+					const struct nla_policy *policy)
 {
 	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__)
+	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)