Commit 737ea802 authored by Wilson Kok's avatar Wilson Kok Committed by Jiri Slaby

fib_rules: fix fib rule dumps across multiple skbs

[ Upstream commit 41fc0143 ]

dump_rules returns skb length and not error.
But when family == AF_UNSPEC, the caller of dump_rules
assumes that it returns an error. Hence, when family == AF_UNSPEC,
we continue trying to dump on -EMSGSIZE errors resulting in
incorrect dump idx carried between skbs belonging to the same dump.
This results in fib rule dump always only dumping rules that fit
into the first skb.

This patch fixes dump_rules to return error so that we exit correctly
and idx is correctly maintained between skbs that are part of the
same dump.

[rd] fix for <= 3.19: fib_nl_fill_rule() returns skb->len, make the
     check 'err < 0'
Signed-off-by: default avatarWilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent 3b27550c
...@@ -621,15 +621,17 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb, ...@@ -621,15 +621,17 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
{ {
int idx = 0; int idx = 0;
struct fib_rule *rule; struct fib_rule *rule;
int err = 0;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(rule, &ops->rules_list, list) { list_for_each_entry_rcu(rule, &ops->rules_list, list) {
if (idx < cb->args[1]) if (idx < cb->args[1])
goto skip; goto skip;
if (fib_nl_fill_rule(skb, rule, NETLINK_CB(cb->skb).portid, err = fib_nl_fill_rule(skb, rule, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, RTM_NEWRULE, cb->nlh->nlmsg_seq, RTM_NEWRULE,
NLM_F_MULTI, ops) < 0) NLM_F_MULTI, ops);
if (err < 0)
break; break;
skip: skip:
idx++; idx++;
...@@ -638,7 +640,7 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb, ...@@ -638,7 +640,7 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
cb->args[1] = idx; cb->args[1] = idx;
rules_ops_put(ops); rules_ops_put(ops);
return skb->len; return err;
} }
static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb) static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb)
...@@ -654,7 +656,9 @@ static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -654,7 +656,9 @@ static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb)
if (ops == NULL) if (ops == NULL)
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
return dump_rules(skb, cb, ops); dump_rules(skb, cb, ops);
return skb->len;
} }
rcu_read_lock(); rcu_read_lock();
......
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