aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_semantics.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-04-01 20:39:02 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-02 04:33:43 -0400
commitf3756b79e8f76cb92830383c215deba146fe0a26 (patch)
tree107c0e99681a0b26b2e750b3fc7a0b01ba1404aa /net/ipv4/fib_semantics.c
parente549a6b3a5acff66f0427091e44f814943a26a86 (diff)
ipv4: 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/ipv4/fib_semantics.c')
-rw-r--r--net/ipv4/fib_semantics.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index a8c5c1d6715b..63aa48acc98a 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -932,33 +932,36 @@ int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
932 rtm->rtm_table = tb_id; 932 rtm->rtm_table = tb_id;
933 else 933 else
934 rtm->rtm_table = RT_TABLE_COMPAT; 934 rtm->rtm_table = RT_TABLE_COMPAT;
935 NLA_PUT_U32(skb, RTA_TABLE, tb_id); 935 if (nla_put_u32(skb, RTA_TABLE, tb_id))
936 goto nla_put_failure;
936 rtm->rtm_type = type; 937 rtm->rtm_type = type;
937 rtm->rtm_flags = fi->fib_flags; 938 rtm->rtm_flags = fi->fib_flags;
938 rtm->rtm_scope = fi->fib_scope; 939 rtm->rtm_scope = fi->fib_scope;
939 rtm->rtm_protocol = fi->fib_protocol; 940 rtm->rtm_protocol = fi->fib_protocol;
940 941
941 if (rtm->rtm_dst_len) 942 if (rtm->rtm_dst_len &&
942 NLA_PUT_BE32(skb, RTA_DST, dst); 943 nla_put_be32(skb, RTA_DST, dst))
943 944 goto nla_put_failure;
944 if (fi->fib_priority) 945 if (fi->fib_priority &&
945 NLA_PUT_U32(skb, RTA_PRIORITY, fi->fib_priority); 946 nla_put_u32(skb, RTA_PRIORITY, fi->fib_priority))
946 947 goto nla_put_failure;
947 if (rtnetlink_put_metrics(skb, fi->fib_metrics) < 0) 948 if (rtnetlink_put_metrics(skb, fi->fib_metrics) < 0)
948 goto nla_put_failure; 949 goto nla_put_failure;
949 950
950 if (fi->fib_prefsrc) 951 if (fi->fib_prefsrc &&
951 NLA_PUT_BE32(skb, RTA_PREFSRC, fi->fib_prefsrc); 952 nla_put_be32(skb, RTA_PREFSRC, fi->fib_prefsrc))
952 953 goto nla_put_failure;
953 if (fi->fib_nhs == 1) { 954 if (fi->fib_nhs == 1) {
954 if (fi->fib_nh->nh_gw) 955 if (fi->fib_nh->nh_gw &&
955 NLA_PUT_BE32(skb, RTA_GATEWAY, fi->fib_nh->nh_gw); 956 nla_put_be32(skb, RTA_GATEWAY, fi->fib_nh->nh_gw))
956 957 goto nla_put_failure;
957 if (fi->fib_nh->nh_oif) 958 if (fi->fib_nh->nh_oif &&
958 NLA_PUT_U32(skb, RTA_OIF, fi->fib_nh->nh_oif); 959 nla_put_u32(skb, RTA_OIF, fi->fib_nh->nh_oif))
960 goto nla_put_failure;
959#ifdef CONFIG_IP_ROUTE_CLASSID 961#ifdef CONFIG_IP_ROUTE_CLASSID
960 if (fi->fib_nh[0].nh_tclassid) 962 if (fi->fib_nh[0].nh_tclassid &&
961 NLA_PUT_U32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid); 963 nla_put_u32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid))
964 goto nla_put_failure;
962#endif 965#endif
963 } 966 }
964#ifdef CONFIG_IP_ROUTE_MULTIPATH 967#ifdef CONFIG_IP_ROUTE_MULTIPATH
@@ -979,11 +982,13 @@ int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
979 rtnh->rtnh_hops = nh->nh_weight - 1; 982 rtnh->rtnh_hops = nh->nh_weight - 1;
980 rtnh->rtnh_ifindex = nh->nh_oif; 983 rtnh->rtnh_ifindex = nh->nh_oif;
981 984
982 if (nh->nh_gw) 985 if (nh->nh_gw &&
983 NLA_PUT_BE32(skb, RTA_GATEWAY, nh->nh_gw); 986 nla_put_be32(skb, RTA_GATEWAY, nh->nh_gw))
987 goto nla_put_failure;
984#ifdef CONFIG_IP_ROUTE_CLASSID 988#ifdef CONFIG_IP_ROUTE_CLASSID
985 if (nh->nh_tclassid) 989 if (nh->nh_tclassid &&
986 NLA_PUT_U32(skb, RTA_FLOW, nh->nh_tclassid); 990 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid))
991 goto nla_put_failure;
987#endif 992#endif
988 /* length of rtnetlink header + attributes */ 993 /* length of rtnetlink header + attributes */
989 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh; 994 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh;