Commit 0e3cea7b authored by David S. Miller's avatar David S. Miller

fib_rules: 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: default avatarDavid S. Miller <davem@davemloft.net>
parent be51da0f
...@@ -542,7 +542,8 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule, ...@@ -542,7 +542,8 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
frh = nlmsg_data(nlh); frh = nlmsg_data(nlh);
frh->family = ops->family; frh->family = ops->family;
frh->table = rule->table; frh->table = rule->table;
NLA_PUT_U32(skb, FRA_TABLE, rule->table); if (nla_put_u32(skb, FRA_TABLE, rule->table))
goto nla_put_failure;
frh->res1 = 0; frh->res1 = 0;
frh->res2 = 0; frh->res2 = 0;
frh->action = rule->action; frh->action = rule->action;
...@@ -553,31 +554,28 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule, ...@@ -553,31 +554,28 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
frh->flags |= FIB_RULE_UNRESOLVED; frh->flags |= FIB_RULE_UNRESOLVED;
if (rule->iifname[0]) { if (rule->iifname[0]) {
NLA_PUT_STRING(skb, FRA_IIFNAME, rule->iifname); if (nla_put_string(skb, FRA_IIFNAME, rule->iifname))
goto nla_put_failure;
if (rule->iifindex == -1) if (rule->iifindex == -1)
frh->flags |= FIB_RULE_IIF_DETACHED; frh->flags |= FIB_RULE_IIF_DETACHED;
} }
if (rule->oifname[0]) { if (rule->oifname[0]) {
NLA_PUT_STRING(skb, FRA_OIFNAME, rule->oifname); if (nla_put_string(skb, FRA_OIFNAME, rule->oifname))
goto nla_put_failure;
if (rule->oifindex == -1) if (rule->oifindex == -1)
frh->flags |= FIB_RULE_OIF_DETACHED; frh->flags |= FIB_RULE_OIF_DETACHED;
} }
if (rule->pref) if ((rule->pref &&
NLA_PUT_U32(skb, FRA_PRIORITY, rule->pref); nla_put_u32(skb, FRA_PRIORITY, rule->pref)) ||
(rule->mark &&
if (rule->mark) nla_put_u32(skb, FRA_FWMARK, rule->mark)) ||
NLA_PUT_U32(skb, FRA_FWMARK, rule->mark); ((rule->mark_mask || rule->mark) &&
nla_put_u32(skb, FRA_FWMASK, rule->mark_mask)) ||
if (rule->mark_mask || rule->mark) (rule->target &&
NLA_PUT_U32(skb, FRA_FWMASK, rule->mark_mask); nla_put_u32(skb, FRA_GOTO, rule->target)))
goto nla_put_failure;
if (rule->target)
NLA_PUT_U32(skb, FRA_GOTO, rule->target);
if (ops->fill(rule, skb, frh) < 0) if (ops->fill(rule, skb, frh) < 0)
goto nla_put_failure; goto nla_put_failure;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment