[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZZ7DLvAwXcQit3Ar@nanopsycho>
Date: Wed, 10 Jan 2024 17:17:50 +0100
From: Jiri Pirko <jiri@...nulli.us>
To: Ido Schimmel <idosch@...sch.org>
Cc: netdev@...r.kernel.org, kuba@...nel.org, pabeni@...hat.com,
davem@...emloft.net, edumazet@...gle.com, jhs@...atatu.com,
xiyou.wangcong@...il.com, victor@...atatu.com,
pctammela@...atatu.com, mleitner@...hat.com, vladbu@...dia.com,
paulb@...dia.com
Subject: Re: [patch net-next] net: sched: move block device tracking into
tcf_block_get/put_ext()
Wed, Jan 10, 2024 at 01:09:55PM CET, idosch@...sch.org wrote:
>On Thu, Jan 04, 2024 at 01:58:44PM +0100, Jiri Pirko wrote:
>> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>> index adf5de1ff773..253b26f2eddd 100644
>> --- a/net/sched/cls_api.c
>> +++ b/net/sched/cls_api.c
>> @@ -1428,6 +1428,7 @@ int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
>> struct tcf_block_ext_info *ei,
>> struct netlink_ext_ack *extack)
>> {
>> + struct net_device *dev = qdisc_dev(q);
>> struct net *net = qdisc_net(q);
>> struct tcf_block *block = NULL;
>> int err;
>> @@ -1461,9 +1462,18 @@ 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)) {
>> + err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL);
>> + if (err) {
>> + NL_SET_ERR_MSG(extack, "block dev insert failed");
>> + goto err_dev_insert;
>> + }
>> + }
>
>While this patch fixes the original issue, it creates another one:
>
># ip link add name swp1 type dummy
># tc qdisc replace dev swp1 root handle 10: prio bands 8 priomap 7 6 5 4 3 2 1
># tc qdisc add dev swp1 parent 10:8 handle 108: red limit 1000000 min 200000 max 200001 probability 1.0 avpkt 8000 burst 38 qevent early_drop block 10
>RED: set bandwidth to 10Mbit
># tc qdisc add dev swp1 parent 10:7 handle 107: red limit 1000000 min 500000 max 500001 probability 1.0 avpkt 8000 burst 63 qevent early_drop block 10
>RED: set bandwidth to 10Mbit
>Error: block dev insert failed.
Feel free to text following patch. Since I believe it is not possible
to send fixes to net-next now, I will send it once net-next merges
into net.
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 913b47d3424e ("net/sched: Introduce tc block netdev
tracking infra") for clsact/ingress only. Commit 94e2557d086a ("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 <idosch@...sch.org>
Closes: https://lore.kernel.org/all/ZZ6JE0odnu1lLPtu@shredder/
Fixes: 94e2557d086a ("net: sched: move block device tracking into tcf_block_get/put_ext()")
Signed-off-by: Jiri Pirko <jiri@...dia.com>
---
net/sched/cls_api.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index e3236a3169c3..92a12e3d0fe6 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -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);
--
2.43.0
Powered by blists - more mailing lists