diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2016-04-26 04:06:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-26 12:00:48 -0400 |
commit | 66c7a5ee1a6b7c69d41dfd68d207fdd54efba56a (patch) | |
tree | 0a343edc63d58939863c764ba553bcc34e93f9c5 /net/openvswitch/datapath.c | |
parent | 6ed46d1247a595c58b6c04481fa77cf532f45de0 (diff) |
ovs: align nlattr properly when needed
I also fix commit 8b32ab9e6ef1: use nla_total_size_64bit() for
OVS_FLOW_ATTR_USED in ovs_flow_cmd_msg_size().
Fixes: 8b32ab9e6ef1 ("ovs: use nla_put_u64_64bit()")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/openvswitch/datapath.c')
-rw-r--r-- | net/openvswitch/datapath.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 22d9a5316304..856bd8dba676 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
@@ -738,9 +738,9 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts, | |||
738 | len += nla_total_size(acts->orig_len); | 738 | len += nla_total_size(acts->orig_len); |
739 | 739 | ||
740 | return len | 740 | return len |
741 | + nla_total_size(sizeof(struct ovs_flow_stats)) /* OVS_FLOW_ATTR_STATS */ | 741 | + nla_total_size_64bit(sizeof(struct ovs_flow_stats)) /* OVS_FLOW_ATTR_STATS */ |
742 | + nla_total_size(1) /* OVS_FLOW_ATTR_TCP_FLAGS */ | 742 | + nla_total_size(1) /* OVS_FLOW_ATTR_TCP_FLAGS */ |
743 | + nla_total_size(8); /* OVS_FLOW_ATTR_USED */ | 743 | + nla_total_size_64bit(8); /* OVS_FLOW_ATTR_USED */ |
744 | } | 744 | } |
745 | 745 | ||
746 | /* Called with ovs_mutex or RCU read lock. */ | 746 | /* Called with ovs_mutex or RCU read lock. */ |
@@ -759,7 +759,9 @@ static int ovs_flow_cmd_fill_stats(const struct sw_flow *flow, | |||
759 | return -EMSGSIZE; | 759 | return -EMSGSIZE; |
760 | 760 | ||
761 | if (stats.n_packets && | 761 | if (stats.n_packets && |
762 | nla_put(skb, OVS_FLOW_ATTR_STATS, sizeof(struct ovs_flow_stats), &stats)) | 762 | nla_put_64bit(skb, OVS_FLOW_ATTR_STATS, |
763 | sizeof(struct ovs_flow_stats), &stats, | ||
764 | OVS_FLOW_ATTR_PAD)) | ||
763 | return -EMSGSIZE; | 765 | return -EMSGSIZE; |
764 | 766 | ||
765 | if ((u8)ntohs(tcp_flags) && | 767 | if ((u8)ntohs(tcp_flags) && |
@@ -1435,8 +1437,8 @@ static size_t ovs_dp_cmd_msg_size(void) | |||
1435 | size_t msgsize = NLMSG_ALIGN(sizeof(struct ovs_header)); | 1437 | size_t msgsize = NLMSG_ALIGN(sizeof(struct ovs_header)); |
1436 | 1438 | ||
1437 | msgsize += nla_total_size(IFNAMSIZ); | 1439 | msgsize += nla_total_size(IFNAMSIZ); |
1438 | msgsize += nla_total_size(sizeof(struct ovs_dp_stats)); | 1440 | msgsize += nla_total_size_64bit(sizeof(struct ovs_dp_stats)); |
1439 | msgsize += nla_total_size(sizeof(struct ovs_dp_megaflow_stats)); | 1441 | msgsize += nla_total_size_64bit(sizeof(struct ovs_dp_megaflow_stats)); |
1440 | msgsize += nla_total_size(sizeof(u32)); /* OVS_DP_ATTR_USER_FEATURES */ | 1442 | msgsize += nla_total_size(sizeof(u32)); /* OVS_DP_ATTR_USER_FEATURES */ |
1441 | 1443 | ||
1442 | return msgsize; | 1444 | return msgsize; |
@@ -1463,13 +1465,13 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb, | |||
1463 | goto nla_put_failure; | 1465 | goto nla_put_failure; |
1464 | 1466 | ||
1465 | get_dp_stats(dp, &dp_stats, &dp_megaflow_stats); | 1467 | get_dp_stats(dp, &dp_stats, &dp_megaflow_stats); |
1466 | if (nla_put(skb, OVS_DP_ATTR_STATS, sizeof(struct ovs_dp_stats), | 1468 | if (nla_put_64bit(skb, OVS_DP_ATTR_STATS, sizeof(struct ovs_dp_stats), |
1467 | &dp_stats)) | 1469 | &dp_stats, OVS_DP_ATTR_PAD)) |
1468 | goto nla_put_failure; | 1470 | goto nla_put_failure; |
1469 | 1471 | ||
1470 | if (nla_put(skb, OVS_DP_ATTR_MEGAFLOW_STATS, | 1472 | if (nla_put_64bit(skb, OVS_DP_ATTR_MEGAFLOW_STATS, |
1471 | sizeof(struct ovs_dp_megaflow_stats), | 1473 | sizeof(struct ovs_dp_megaflow_stats), |
1472 | &dp_megaflow_stats)) | 1474 | &dp_megaflow_stats, OVS_DP_ATTR_PAD)) |
1473 | goto nla_put_failure; | 1475 | goto nla_put_failure; |
1474 | 1476 | ||
1475 | if (nla_put_u32(skb, OVS_DP_ATTR_USER_FEATURES, dp->user_features)) | 1477 | if (nla_put_u32(skb, OVS_DP_ATTR_USER_FEATURES, dp->user_features)) |
@@ -1838,8 +1840,9 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb, | |||
1838 | goto nla_put_failure; | 1840 | goto nla_put_failure; |
1839 | 1841 | ||
1840 | ovs_vport_get_stats(vport, &vport_stats); | 1842 | ovs_vport_get_stats(vport, &vport_stats); |
1841 | if (nla_put(skb, OVS_VPORT_ATTR_STATS, sizeof(struct ovs_vport_stats), | 1843 | if (nla_put_64bit(skb, OVS_VPORT_ATTR_STATS, |
1842 | &vport_stats)) | 1844 | sizeof(struct ovs_vport_stats), &vport_stats, |
1845 | OVS_VPORT_ATTR_PAD)) | ||
1843 | goto nla_put_failure; | 1846 | goto nla_put_failure; |
1844 | 1847 | ||
1845 | if (ovs_vport_get_upcall_portids(vport, skb)) | 1848 | if (ovs_vport_get_upcall_portids(vport, skb)) |