[ovs-dev,v2,2/2] datapath: pass extended ACK struct to parsing functions

Submitted by Jarno Rajahalme on April 19, 2017, 11:54 p.m.

Details

Message ID 1492646078-55043-2-git-send-email-jarno@ovn.org
State New
Headers show

Commit Message

Jarno Rajahalme April 19, 2017, 11:54 p.m.
From: Johannes Berg <johannes.berg@intel.com>

Upstream commit:

    commit fceb6435e85298f747fee938415057af837f5a8a
    Author: Johannes Berg <johannes.berg@intel.com>
    Date:   Wed Apr 12 14:34:07 2017 +0200

    netlink: pass extended ACK struct to parsing functions

    Pass the new extended ACK reporting struct to all of the generic
    netlink parsing functions. For now, pass NULL in almost all callers
    (except for some in the core.)

    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
---
v2: Call original functions from replacements if available.

 acinclude.m4                                  |  3 +++
 datapath/datapath.c                           |  2 +-
 datapath/flow_netlink.c                       |  4 ++--
 datapath/linux/compat/include/net/genetlink.h | 18 +++++++++++++-----
 datapath/linux/compat/include/net/netlink.h   | 14 ++++++++++++++
 datapath/vport-vxlan.c                        |  3 ++-
 6 files changed, 35 insertions(+), 9 deletions(-)

Comments

Joe Stringer April 20, 2017, 11:36 p.m.
On 19 April 2017 at 16:54, Jarno Rajahalme <jarno@ovn.org> wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> Upstream commit:
>
>     commit fceb6435e85298f747fee938415057af837f5a8a
>     Author: Johannes Berg <johannes.berg@intel.com>
>     Date:   Wed Apr 12 14:34:07 2017 +0200
>
>     netlink: pass extended ACK struct to parsing functions
>
>     Pass the new extended ACK reporting struct to all of the generic
>     netlink parsing functions. For now, pass NULL in almost all callers
>     (except for some in the core.)
>
>     Signed-off-by: Johannes Berg <johannes.berg@intel.com>
>     Signed-off-by: David S. Miller <davem@davemloft.net>
>
> Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
> ---

Acked-by: Joe Stringer <joe@ovn.org>
Jarno Rajahalme April 21, 2017, 1:17 a.m.
> On Apr 20, 2017, at 4:36 PM, Joe Stringer <joe@ovn.org> wrote:
> 
> On 19 April 2017 at 16:54, Jarno Rajahalme <jarno@ovn.org <mailto:jarno@ovn.org>> wrote:
>> From: Johannes Berg <johannes.berg@intel.com>
>> 
>> Upstream commit:
>> 
>>    commit fceb6435e85298f747fee938415057af837f5a8a
>>    Author: Johannes Berg <johannes.berg@intel.com>
>>    Date:   Wed Apr 12 14:34:07 2017 +0200
>> 
>>    netlink: pass extended ACK struct to parsing functions
>> 
>>    Pass the new extended ACK reporting struct to all of the generic
>>    netlink parsing functions. For now, pass NULL in almost all callers
>>    (except for some in the core.)
>> 
>>    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
>>    Signed-off-by: David S. Miller <davem@davemloft.net>
>> 
>> Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
>> ---
> 
> Acked-by: Joe Stringer <joe@ovn.org <mailto:joe@ovn.org>>

Thanks for the review, pushed to master,

  Jarno

Patch hide | download patch | download mbox

diff --git a/acinclude.m4 b/acinclude.m4
index 6a2b9f1..9f8e30d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -663,6 +663,9 @@  AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
   OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_is_last])
   OVS_GREP_IFELSE([$KSRC/include/linux/netlink.h], [void.*netlink_set_err],
                   [OVS_DEFINE([HAVE_VOID_NETLINK_SET_ERR])])
+  OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netlink.h],
+                        [nla_parse], [netlink_ext_ack],
+                        [OVS_DEFINE([HAVE_NETLINK_EXT_ACK])])
 
   OVS_GREP_IFELSE([$KSRC/include/net/sctp/checksum.h], [sctp_compute_cksum])
 
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 8cf0381..c85029c 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -1365,7 +1365,7 @@  static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
 	int err;
 
 	err = genlmsg_parse(cb->nlh, &dp_flow_genl_family, a,
-			    OVS_FLOW_ATTR_MAX, flow_policy);
+			    OVS_FLOW_ATTR_MAX, flow_policy, NULL);
 	if (err)
 		return err;
 	ufid_flags = ovs_nla_get_ufid_flags(a[OVS_FLOW_ATTR_UFID_FLAGS]);
diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c
index 0762f6c..07ab8e9 100644
--- a/datapath/flow_netlink.c
+++ b/datapath/flow_netlink.c
@@ -2431,8 +2431,8 @@  static int validate_userspace(const struct nlattr *attr)
 	struct nlattr *a[OVS_USERSPACE_ATTR_MAX + 1];
 	int error;
 
-	error = nla_parse_nested(a, OVS_USERSPACE_ATTR_MAX,
-				 attr, userspace_policy);
+	error = nla_parse_nested(a, OVS_USERSPACE_ATTR_MAX, attr,
+				 userspace_policy, NULL);
 	if (error)
 		return error;
 
diff --git a/datapath/linux/compat/include/net/genetlink.h b/datapath/linux/compat/include/net/genetlink.h
index 4b42cf7..b05eae5 100644
--- a/datapath/linux/compat/include/net/genetlink.h
+++ b/datapath/linux/compat/include/net/genetlink.h
@@ -125,15 +125,23 @@  static inline int rpl_genl_has_listeners(struct genl_family *family,
 
 #endif /* HAVE_GENL_HAS_LISTENERS */
 
-#ifndef HAVE_GENLMSG_PARSE
-static inline int genlmsg_parse(const struct nlmsghdr *nlh,
-				const struct genl_family *family,
-				struct nlattr *tb[], int maxtype,
-				const struct nla_policy *policy)
+#ifndef HAVE_NETLINK_EXT_ACK
+struct netlink_ext_ack;
+
+static inline int rpl_genlmsg_parse(const struct nlmsghdr *nlh,
+				    const struct genl_family *family,
+				    struct nlattr *tb[], int maxtype,
+				    const struct nla_policy *policy,
+				    struct netlink_ext_ack *extack)
 {
+#ifdef HAVE_GENLMSG_PARSE
+	return genlmsg_parse(nlh, family, tb, maxtype, policy);
+#else
 	return nlmsg_parse(nlh, family->hdrsize + GENL_HDRLEN, tb, maxtype,
 			   policy);
+#endif
 }
+#define genlmsg_parse rpl_genlmsg_parse
 #endif
 
 #endif /* genetlink.h */
diff --git a/datapath/linux/compat/include/net/netlink.h b/datapath/linux/compat/include/net/netlink.h
index 082afac..4325b9b 100644
--- a/datapath/linux/compat/include/net/netlink.h
+++ b/datapath/linux/compat/include/net/netlink.h
@@ -157,4 +157,18 @@  static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value,
 }
 
 #endif
+
+#ifndef HAVE_NETLINK_EXT_ACK
+struct netlink_ext_ack;
+
+static inline int rpl_nla_parse_nested(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_nested rpl_nla_parse_nested
+#endif
+
 #endif /* net/netlink.h */
diff --git a/datapath/vport-vxlan.c b/datapath/vport-vxlan.c
index 11965c0..7beaf6e 100644
--- a/datapath/vport-vxlan.c
+++ b/datapath/vport-vxlan.c
@@ -70,7 +70,8 @@  static int vxlan_configure_exts(struct vport *vport, struct nlattr *attr,
 	if (nla_len(attr) < sizeof(struct nlattr))
 		return -EINVAL;
 
-	err = nla_parse_nested(exts, OVS_VXLAN_EXT_MAX, attr, exts_policy);
+	err = nla_parse_nested(exts, OVS_VXLAN_EXT_MAX, attr, exts_policy,
+			       NULL);
 	if (err < 0)
 		return err;