Skip to content

Commit

Permalink
net: sched: cbq: create block for q->link.block
Browse files Browse the repository at this point in the history
q->link.block is not initialized, that leads to EINVAL when one tries to
add filter there. So initialize it properly.

This can be reproduced by:
$ tc qdisc add dev eth0 root handle 1: cbq avpkt 1000 rate 1000Mbit bandwidth 1000Mbit
$ tc filter add dev eth0 parent 1: protocol ip prio 100 u32 match ip protocol 0 0x00 flowid 1:1

Reported-by: Jaroslav Aster <[email protected]>
Reported-by: Ivan Vecera <[email protected]>
Fixes: 6529eab ("net: sched: introduce tcf block infractructure")
Signed-off-by: Jiri Pirko <[email protected]>
Acked-by: Eelco Chaudron <[email protected]>
Reviewed-by: Ivan Vecera <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jpirko authored and davem330 committed Nov 28, 2017
1 parent 0195a21 commit d51aae6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion net/sched/sch_cbq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,9 +1158,13 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
if ((q->link.R_tab = qdisc_get_rtab(r, tb[TCA_CBQ_RTAB])) == NULL)
return -EINVAL;

err = tcf_block_get(&q->link.block, &q->link.filter_list, sch);
if (err)
goto put_rtab;

err = qdisc_class_hash_init(&q->clhash);
if (err < 0)
goto put_rtab;
goto put_block;

q->link.sibling = &q->link;
q->link.common.classid = sch->handle;
Expand Down Expand Up @@ -1194,6 +1198,9 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
cbq_addprio(q, &q->link);
return 0;

put_block:
tcf_block_put(q->link.block);

put_rtab:
qdisc_put_rtab(q->link.R_tab);
return err;
Expand Down

0 comments on commit d51aae6

Please sign in to comment.