History

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().

Nicolas Dichtel committed 10 years ago

Commit 66c7a5e1 parent 6ed46d12 files · +17 −12Browse files

Unified · Split

2 files
  1. include/uapi/linux/openvswitch.h +2 −0
  2. net/openvswitch/datapath.c +15 −12
include/uapi/linux/openvswitch.h+2−0
@@ -84,6 +84,7 @@ enum ovs_datapath_attr { · 83 unmodified lines
8484 OVS_DP_ATTR_STATS, /* struct ovs_dp_stats */
8585 OVS_DP_ATTR_MEGAFLOW_STATS, /* struct ovs_dp_megaflow_stats */
8686 OVS_DP_ATTR_USER_FEATURES, /* OVS_DP_F_* */
87+ OVS_DP_ATTR_PAD,
8788 __OVS_DP_ATTR_MAX
8889 };
8990
@@ -253,6 +254,7 @@ enum ovs_vport_attr { · 163 unmodified lines
253254 OVS_VPORT_ATTR_UPCALL_PID, /* array of u32 Netlink socket PIDs for */
254255 /* receiving upcalls */
255256 OVS_VPORT_ATTR_STATS, /* struct ovs_vport_stats */
257+ OVS_VPORT_ATTR_PAD,
256258 __OVS_VPORT_ATTR_MAX
257259 };
258260
net/openvswitch/datapath.c+15−12
@@ -738,9 +738,9 @@ static size_t ovs_flow_cmd_msg_size(const struct sw_flow_actions *acts, · 737 unmodified lines
738738 len += nla_total_size(acts->orig_len);
739739
740740 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 */
742742 + 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 */
744744 }
745745
746746 /* Called with ovs_mutex or RCU read lock. */
@@ -759,7 +759,9 @@ static int ovs_flow_cmd_fill_stats(const struct sw_flow *flow, · 12 unmodified lines
759759 return -EMSGSIZE;
760760
761761 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))
763765 return -EMSGSIZE;
764766
765767 if ((u8)ntohs(tcp_flags) &&
@@ -1435,8 +1437,8 @@ static size_t ovs_dp_cmd_msg_size(void) · 669 unmodified lines
14351437 size_t msgsize = NLMSG_ALIGN(sizeof(struct ovs_header));
14361438
14371439 msgsize += nla_total_size(IFNAMSIZ);
1438− msgsize += nla_total_size(sizeof(struct ovs_dp_stats));
1439− msgsize += nla_total_size(sizeof(struct ovs_dp_megaflow_stats));
1440+ msgsize += nla_total_size_64bit(sizeof(struct ovs_dp_stats));
1441+ msgsize += nla_total_size_64bit(sizeof(struct ovs_dp_megaflow_stats));
14401442 msgsize += nla_total_size(sizeof(u32)); /* OVS_DP_ATTR_USER_FEATURES */
14411443
14421444 return msgsize;
@@ -1463,13 +1465,13 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb, · 20 unmodified lines
14631465 goto nla_put_failure;
14641466
14651467 get_dp_stats(dp, &dp_stats, &dp_megaflow_stats);
1466− if (nla_put(skb, OVS_DP_ATTR_STATS, sizeof(struct ovs_dp_stats),
1467− &dp_stats))
1468+ if (nla_put_64bit(skb, OVS_DP_ATTR_STATS, sizeof(struct ovs_dp_stats),
1469+ &dp_stats, OVS_DP_ATTR_PAD))
14681470 goto nla_put_failure;
14691471
1470− if (nla_put(skb, OVS_DP_ATTR_MEGAFLOW_STATS,
1471− sizeof(struct ovs_dp_megaflow_stats),
1472− &dp_megaflow_stats))
1472+ if (nla_put_64bit(skb, OVS_DP_ATTR_MEGAFLOW_STATS,
1473+ sizeof(struct ovs_dp_megaflow_stats),
1474+ &dp_megaflow_stats, OVS_DP_ATTR_PAD))
14731475 goto nla_put_failure;
14741476
14751477 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, · 362 unmodified lines
18381840 goto nla_put_failure;
18391841
18401842 ovs_vport_get_stats(vport, &vport_stats);
1841− if (nla_put(skb, OVS_VPORT_ATTR_STATS, sizeof(struct ovs_vport_stats),
1842− &vport_stats))
1843+ if (nla_put_64bit(skb, OVS_VPORT_ATTR_STATS,
1844+ sizeof(struct ovs_vport_stats), &vport_stats,
1845+ OVS_VPORT_ATTR_PAD))
18431846 goto nla_put_failure;
18441847
18451848 if (ovs_vport_get_upcall_portids(vport, skb))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t