Skip to content

Commit e18405d

Browse files
Jiri Pirkodavem330
authored andcommitted
net: sched: track device in tcf_block_get/put_ext() only for clsact binder types
Clsact/ingress qdisc is not the only one using shared block, red is also using it. The device tracking was originally introduced by commit 913b47d ("net/sched: Introduce tc block netdev tracking infra") for clsact/ingress only. Commit 94e2557 ("net: sched: move block device tracking into tcf_block_get/put_ext()") mistakenly enabled that for red as well. Fix that by adding a check for the binder type being clsact when adding device to the block->ports xarray. Reported-by: Ido Schimmel <[email protected]> Closes: https://lore.kernel.org/all/ZZ6JE0odnu1lLPtu@shredder/ Fixes: 94e2557 ("net: sched: move block device tracking into tcf_block_get/put_ext()") Signed-off-by: Jiri Pirko <[email protected]> Tested-by: Ido Schimmel <[email protected]> Acked-by: Jamal Hadi Salim <[email protected]> Tested-by: Victor Nogueira <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 482521d commit e18405d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

net/sched/cls_api.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,14 @@ static void tcf_block_owner_del(struct tcf_block *block,
14241424
WARN_ON(1);
14251425
}
14261426

1427+
static bool tcf_block_tracks_dev(struct tcf_block *block,
1428+
struct tcf_block_ext_info *ei)
1429+
{
1430+
return tcf_block_shared(block) &&
1431+
(ei->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ||
1432+
ei->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS);
1433+
}
1434+
14271435
int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
14281436
struct tcf_block_ext_info *ei,
14291437
struct netlink_ext_ack *extack)
@@ -1462,7 +1470,7 @@ int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
14621470
if (err)
14631471
goto err_block_offload_bind;
14641472

1465-
if (tcf_block_shared(block)) {
1473+
if (tcf_block_tracks_dev(block, ei)) {
14661474
err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL);
14671475
if (err) {
14681476
NL_SET_ERR_MSG(extack, "block dev insert failed");
@@ -1516,7 +1524,7 @@ void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
15161524

15171525
if (!block)
15181526
return;
1519-
if (tcf_block_shared(block))
1527+
if (tcf_block_tracks_dev(block, ei))
15201528
xa_erase(&block->ports, dev->ifindex);
15211529
tcf_chain0_head_change_cb_del(block, ei);
15221530
tcf_block_owner_del(block, q, ei->binder_type);

0 commit comments

Comments
 (0)