diff mbox

[ovs-dev,16/24] datapath: backport: libnl: nla_put_be64(): align on a 64-bit area

Message ID 1468387602-61955-7-git-send-email-pshelar@ovn.org
State Accepted
Headers show

Commit Message

Pravin Shelar July 13, 2016, 5:26 a.m. UTC
Upstream commit:
    commit b46f6ded906ef0be52a4881ba50a084aeca64d7e
    Author: Nicolas Dichtel <nicolas.dichtel@6wind.com>

    libnl: nla_put_be64(): align on a 64-bit area

    nla_data() is now aligned on a 64-bit area.

    A temporary version (nla_put_be64_32bit()) is added for nla_put_net64().
    This function is removed in the next patch.

    Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
---
 datapath/flow_netlink.c                           | 5 +++--
 datapath/linux/compat/include/linux/openvswitch.h | 1 +
 datapath/linux/compat/include/net/netlink.h       | 7 +++++++
 lib/odp-util.c                                    | 2 ++
 4 files changed, 13 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/datapath/flow_netlink.c b/datapath/flow_netlink.c
index b8e8799..c1287f8 100644
--- a/datapath/flow_netlink.c
+++ b/datapath/flow_netlink.c
@@ -263,7 +263,7 @@  size_t ovs_tun_key_attr_size(void)
 	/* Whenever adding new OVS_TUNNEL_KEY_ FIELDS, we should consider
 	 * updating this function.
 	 */
-	return    nla_total_size(8) /* OVS_TUNNEL_KEY_ATTR_ID */
+	return    nla_total_size_64bit(8) /* OVS_TUNNEL_KEY_ATTR_ID */
 		+ nla_total_size(16)   /* OVS_TUNNEL_KEY_ATTR_IPV[46]_SRC */
 		+ nla_total_size(16)   /* OVS_TUNNEL_KEY_ATTR_IPV[46]_DST */
 		+ nla_total_size(1)    /* OVS_TUNNEL_KEY_ATTR_TOS */
@@ -722,7 +722,8 @@  static int __ip_tun_to_nlattr(struct sk_buff *skb,
 			      unsigned short tun_proto)
 {
 	if (output->tun_flags & TUNNEL_KEY &&
-	    nla_put_be64(skb, OVS_TUNNEL_KEY_ATTR_ID, output->tun_id))
+	    nla_put_be64(skb, OVS_TUNNEL_KEY_ATTR_ID, output->tun_id,
+			 OVS_TUNNEL_KEY_ATTR_PAD))
 		return -EMSGSIZE;
 	switch (tun_proto) {
 	case AF_INET:
diff --git a/datapath/linux/compat/include/linux/openvswitch.h b/datapath/linux/compat/include/linux/openvswitch.h
index d8789c9..12260d8 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -381,6 +381,7 @@  enum ovs_tunnel_key_attr {
 	OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS,		/* Nested OVS_VXLAN_EXT_* */
 	OVS_TUNNEL_KEY_ATTR_IPV6_SRC,		/* struct in6_addr src IPv6 address. */
 	OVS_TUNNEL_KEY_ATTR_IPV6_DST,		/* struct in6_addr dst IPv6 address. */
+	OVS_TUNNEL_KEY_ATTR_PAD,
 	__OVS_TUNNEL_KEY_ATTR_MAX
 };
 
diff --git a/datapath/linux/compat/include/net/netlink.h b/datapath/linux/compat/include/net/netlink.h
index 07bd873..082afac 100644
--- a/datapath/linux/compat/include/net/netlink.h
+++ b/datapath/linux/compat/include/net/netlink.h
@@ -149,5 +149,12 @@  static inline int nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
         return nla_put_64bit(skb, attrtype, sizeof(u64), &value, padattr);
 }
 
+#define nla_put_be64 rpl_nla_put_be64
+static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value,
+                               int padattr)
+{
+        return nla_put_64bit(skb, attrtype, sizeof(__be64), &value, padattr);
+}
+
 #endif
 #endif /* net/netlink.h */
diff --git a/lib/odp-util.c b/lib/odp-util.c
index fd1ca9b..c43afad 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -2593,6 +2593,8 @@  format_odp_tun_attr(const struct nlattr *attr, const struct nlattr *mask_attr,
             format_odp_tun_geneve(a, ma, ds, verbose);
             ds_put_cstr(ds, "),");
             break;
+        case OVS_TUNNEL_KEY_ATTR_PAD:
+            break;
         case __OVS_TUNNEL_KEY_ATTR_MAX:
         default:
             format_unknown_key(ds, a, ma);