Commit e18405d0 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

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 913b47d3 ("net/sched: Introduce tc block netdev
tracking infra") for clsact/ingress only. Commit 94e2557d ("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: default avatarIdo Schimmel <idosch@idosch.org>
Closes: https://lore.kernel.org/all/ZZ6JE0odnu1lLPtu@shredder/


Fixes: 94e2557d ("net: sched: move block device tracking into tcf_block_get/put_ext()")
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Tested-by: default avatarIdo Schimmel <idosch@nvidia.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Tested-by: default avatarVictor Nogueira <victor@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 482521d8
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1424,6 +1424,14 @@ static void tcf_block_owner_del(struct tcf_block *block,
	WARN_ON(1);
}

static bool tcf_block_tracks_dev(struct tcf_block *block,
				 struct tcf_block_ext_info *ei)
{
	return tcf_block_shared(block) &&
	       (ei->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS ||
		ei->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS);
}

int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
		      struct tcf_block_ext_info *ei,
		      struct netlink_ext_ack *extack)
@@ -1462,7 +1470,7 @@ int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
	if (err)
		goto err_block_offload_bind;

	if (tcf_block_shared(block)) {
	if (tcf_block_tracks_dev(block, ei)) {
		err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL);
		if (err) {
			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,

	if (!block)
		return;
	if (tcf_block_shared(block))
	if (tcf_block_tracks_dev(block, ei))
		xa_erase(&block->ports, dev->ifindex);
	tcf_chain0_head_change_cb_del(block, ei);
	tcf_block_owner_del(block, q, ei->binder_type);