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
84 OVS_DP_ATTR_STATS, /* struct ovs_dp_stats */84 OVS_DP_ATTR_STATS, /* struct ovs_dp_stats */
85 OVS_DP_ATTR_MEGAFLOW_STATS, /* struct ovs_dp_megaflow_stats */85 OVS_DP_ATTR_MEGAFLOW_STATS, /* struct ovs_dp_megaflow_stats */
86 OVS_DP_ATTR_USER_FEATURES, /* OVS_DP_F_* */86 OVS_DP_ATTR_USER_FEATURES, /* OVS_DP_F_* */
87 OVS_DP_ATTR_PAD,
87 __OVS_DP_ATTR_MAX88 __OVS_DP_ATTR_MAX
88};89};
89 90
@@ -253,6 +254,7 @@ enum ovs_vport_attr { · 163 unmodified lines
253 OVS_VPORT_ATTR_UPCALL_PID, /* array of u32 Netlink socket PIDs for */254 OVS_VPORT_ATTR_UPCALL_PID, /* array of u32 Netlink socket PIDs for */
254 /* receiving upcalls */255 /* receiving upcalls */
255 OVS_VPORT_ATTR_STATS, /* struct ovs_vport_stats */256 OVS_VPORT_ATTR_STATS, /* struct ovs_vport_stats */
257 OVS_VPORT_ATTR_PAD,
256 __OVS_VPORT_ATTR_MAX258 __OVS_VPORT_ATTR_MAX
257};259};
258 260
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
738 len += nla_total_size(acts->orig_len);738 len += nla_total_size(acts->orig_len);
739 739
740 return len740 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, · 12 unmodified lines
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) · 669 unmodified lines
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, · 20 unmodified lines
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, · 362 unmodified lines
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))

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