Change tc_fill_qdisc() to return -EMSGSIZE when skb is too small. Change tc_dump_qdisc_root() to propagate tc_fill_qdisc() error to its callers. Signed-off-by: Eric Dumazet --- net/sched/sch_api.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 32ccd4672083aa19340520155aeba6d8b6ff546c..322eab3bd2b1327af323c44333318bdd52c7ee52 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -976,7 +976,7 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid, out_nlmsg_trim: nla_put_failure: nlmsg_trim(skb, b); - return -1; + return -EMSGSIZE; } static bool tc_qdisc_dump_ignore(struct Qdisc *q, bool dump_invisible) @@ -1833,16 +1833,16 @@ static int tc_dump_qdisc_root(struct Qdisc *root, struct sk_buff *skb, return 0; q = root; - if (q_idx < s_q_idx) { - q_idx++; - } else { - if (!tc_qdisc_dump_ignore(q, dump_invisible) && - tc_fill_qdisc(skb, q, q->parent, NETLINK_CB(cb->skb).portid, - cb->nlh->nlmsg_seq, NLM_F_MULTI, - RTM_NEWQDISC, NULL) <= 0) - goto done; - q_idx++; + if (!(q_idx < s_q_idx) && + !tc_qdisc_dump_ignore(q, dump_invisible)) { + ret = tc_fill_qdisc(skb, q, q->parent, + NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, NLM_F_MULTI, + RTM_NEWQDISC, NULL); + if (ret < 0) + goto out; } + q_idx++; /* If dumping singletons, there is no qdisc_dev(root) and the singleton * itself has already been dumped. @@ -1854,24 +1854,21 @@ static int tc_dump_qdisc_root(struct Qdisc *root, struct sk_buff *skb, goto out; hash_for_each(qdisc_dev(root)->qdisc_hash, b, q, hash) { - if (q_idx < s_q_idx) { - q_idx++; - continue; + if (!(q_idx < s_q_idx) && + !tc_qdisc_dump_ignore(q, dump_invisible)) { + ret = tc_fill_qdisc(skb, q, q->parent, + NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, NLM_F_MULTI, + RTM_NEWQDISC, NULL); + if (ret < 0) + goto out; } - if (!tc_qdisc_dump_ignore(q, dump_invisible) && - tc_fill_qdisc(skb, q, q->parent, NETLINK_CB(cb->skb).portid, - cb->nlh->nlmsg_seq, NLM_F_MULTI, - RTM_NEWQDISC, NULL) <= 0) - goto done; q_idx++; } out: *q_idx_p = q_idx; return ret; -done: - ret = -1; - goto out; } static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb) -- 2.54.0.545.g6539524ca2-goog