diff options
author | David S. Miller <davem@davemloft.net> | 2012-03-29 23:20:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-04-01 18:11:37 -0400 |
commit | 028d6a6767456d6c84a72d3451f19fe7ca7b47db (patch) | |
tree | ee49f2a07439ffcaa2ffd34891faf2f30c7cdfef /net/openvswitch/datapath.c | |
parent | 569a8fc38367dfafd87454f27ac646c8e6b54bca (diff) |
openvswitch: Stop using NLA_PUT*().
These macros contain a hidden goto, and are thus extremely error
prone and make code hard to audit.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/openvswitch/datapath.c')
-rw-r--r-- | net/openvswitch/datapath.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 2c030505b335..f5ca1257debf 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
@@ -779,15 +779,18 @@ static int ovs_flow_cmd_fill_info(struct sw_flow *flow, struct datapath *dp, | |||
779 | tcp_flags = flow->tcp_flags; | 779 | tcp_flags = flow->tcp_flags; |
780 | spin_unlock_bh(&flow->lock); | 780 | spin_unlock_bh(&flow->lock); |
781 | 781 | ||
782 | if (used) | 782 | if (used && |
783 | NLA_PUT_U64(skb, OVS_FLOW_ATTR_USED, ovs_flow_used_time(used)); | 783 | nla_put_u64(skb, OVS_FLOW_ATTR_USED, ovs_flow_used_time(used))) |
784 | goto nla_put_failure; | ||
784 | 785 | ||
785 | if (stats.n_packets) | 786 | if (stats.n_packets && |
786 | NLA_PUT(skb, OVS_FLOW_ATTR_STATS, | 787 | nla_put(skb, OVS_FLOW_ATTR_STATS, |
787 | sizeof(struct ovs_flow_stats), &stats); | 788 | sizeof(struct ovs_flow_stats), &stats)) |
789 | goto nla_put_failure; | ||
788 | 790 | ||
789 | if (tcp_flags) | 791 | if (tcp_flags && |
790 | NLA_PUT_U8(skb, OVS_FLOW_ATTR_TCP_FLAGS, tcp_flags); | 792 | nla_put_u8(skb, OVS_FLOW_ATTR_TCP_FLAGS, tcp_flags)) |
793 | goto nla_put_failure; | ||
791 | 794 | ||
792 | /* If OVS_FLOW_ATTR_ACTIONS doesn't fit, skip dumping the actions if | 795 | /* If OVS_FLOW_ATTR_ACTIONS doesn't fit, skip dumping the actions if |
793 | * this is the first flow to be dumped into 'skb'. This is unusual for | 796 | * this is the first flow to be dumped into 'skb'. This is unusual for |
@@ -1169,7 +1172,8 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb, | |||
1169 | goto nla_put_failure; | 1172 | goto nla_put_failure; |
1170 | 1173 | ||
1171 | get_dp_stats(dp, &dp_stats); | 1174 | get_dp_stats(dp, &dp_stats); |
1172 | NLA_PUT(skb, OVS_DP_ATTR_STATS, sizeof(struct ovs_dp_stats), &dp_stats); | 1175 | if (nla_put(skb, OVS_DP_ATTR_STATS, sizeof(struct ovs_dp_stats), &dp_stats)) |
1176 | goto nla_put_failure; | ||
1173 | 1177 | ||
1174 | return genlmsg_end(skb, ovs_header); | 1178 | return genlmsg_end(skb, ovs_header); |
1175 | 1179 | ||
@@ -1469,14 +1473,16 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb, | |||
1469 | 1473 | ||
1470 | ovs_header->dp_ifindex = get_dpifindex(vport->dp); | 1474 | ovs_header->dp_ifindex = get_dpifindex(vport->dp); |
1471 | 1475 | ||
1472 | NLA_PUT_U32(skb, OVS_VPORT_ATTR_PORT_NO, vport->port_no); | 1476 | if (nla_put_u32(skb, OVS_VPORT_ATTR_PORT_NO, vport->port_no) || |
1473 | NLA_PUT_U32(skb, OVS_VPORT_ATTR_TYPE, vport->ops->type); | 1477 | nla_put_u32(skb, OVS_VPORT_ATTR_TYPE, vport->ops->type) || |
1474 | NLA_PUT_STRING(skb, OVS_VPORT_ATTR_NAME, vport->ops->get_name(vport)); | 1478 | nla_put_string(skb, OVS_VPORT_ATTR_NAME, vport->ops->get_name(vport)) || |
1475 | NLA_PUT_U32(skb, OVS_VPORT_ATTR_UPCALL_PID, vport->upcall_pid); | 1479 | nla_put_u32(skb, OVS_VPORT_ATTR_UPCALL_PID, vport->upcall_pid)) |
1480 | goto nla_put_failure; | ||
1476 | 1481 | ||
1477 | ovs_vport_get_stats(vport, &vport_stats); | 1482 | ovs_vport_get_stats(vport, &vport_stats); |
1478 | NLA_PUT(skb, OVS_VPORT_ATTR_STATS, sizeof(struct ovs_vport_stats), | 1483 | if (nla_put(skb, OVS_VPORT_ATTR_STATS, sizeof(struct ovs_vport_stats), |
1479 | &vport_stats); | 1484 | &vport_stats)) |
1485 | goto nla_put_failure; | ||
1480 | 1486 | ||
1481 | err = ovs_vport_get_options(vport, skb); | 1487 | err = ovs_vport_get_options(vport, skb); |
1482 | if (err == -EMSGSIZE) | 1488 | if (err == -EMSGSIZE) |