Skip to content

Commit ec6743a

Browse files
w1ldptrdavem330
authored andcommitted
net: sched: track rtnl lock status when validating extensions
Actions API is already updated to not rely on rtnl lock for synchronization. However, it need to be provided with rtnl status when called from classifiers API in order to be able to correctly release the lock when loading kernel module. Extend extension validation function with 'rtnl_held' flag which is passed to actions API. Add new 'rtnl_held' parameter to tcf_exts_validate() in cls API. No classifier is currently updated to support unlocked execution, so pass hardcoded 'true' flag parameter value. Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 726d061 commit ec6743a

13 files changed

Lines changed: 21 additions & 16 deletions

File tree

‎include/net/pkt_cls.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts,
416416

417417
int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
418418
struct nlattr **tb, struct nlattr *rate_tlv,
419-
struct tcf_exts *exts, bool ovr,
419+
struct tcf_exts *exts, bool ovr, bool rtnl_held,
420420
struct netlink_ext_ack *extack);
421421
void tcf_exts_destroy(struct tcf_exts *exts);
422422
void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src);

‎net/sched/cls_api.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,7 +2841,7 @@ EXPORT_SYMBOL(tcf_exts_destroy);
28412841

28422842
int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
28432843
struct nlattr *rate_tlv, struct tcf_exts *exts, bool ovr,
2844-
struct netlink_ext_ack *extack)
2844+
bool rtnl_held, struct netlink_ext_ack *extack)
28452845
{
28462846
#ifdef CONFIG_NET_CLS_ACT
28472847
{
@@ -2851,7 +2851,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
28512851
if (exts->police && tb[exts->police]) {
28522852
act = tcf_action_init_1(net, tp, tb[exts->police],
28532853
rate_tlv, "police", ovr,
2854-
TCA_ACT_BIND, true, extack);
2854+
TCA_ACT_BIND, rtnl_held,
2855+
extack);
28552856
if (IS_ERR(act))
28562857
return PTR_ERR(act);
28572858

@@ -2863,8 +2864,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
28632864

28642865
err = tcf_action_init(net, tp, tb[exts->action],
28652866
rate_tlv, NULL, ovr, TCA_ACT_BIND,
2866-
exts->actions, &attr_size, true,
2867-
extack);
2867+
exts->actions, &attr_size,
2868+
rtnl_held, extack);
28682869
if (err < 0)
28692870
return err;
28702871
exts->nr_actions = err;

‎net/sched/cls_basic.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int basic_set_parms(struct net *net, struct tcf_proto *tp,
153153
{
154154
int err;
155155

156-
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, extack);
156+
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, true, extack);
157157
if (err < 0)
158158
return err;
159159

‎net/sched/cls_bpf.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp,
417417
if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf))
418418
return -EINVAL;
419419

420-
ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr, extack);
420+
ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr, true,
421+
extack);
421422
if (ret < 0)
422423
return ret;
423424

‎net/sched/cls_cgroup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
110110
goto errout;
111111

112112
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &new->exts, ovr,
113-
extack);
113+
true, extack);
114114
if (err < 0)
115115
goto errout;
116116

‎net/sched/cls_flow.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
445445
goto err2;
446446

447447
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &fnew->exts, ovr,
448-
extack);
448+
true, extack);
449449
if (err < 0)
450450
goto err2;
451451

‎net/sched/cls_flower.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,8 @@ static int fl_set_parms(struct net *net, struct tcf_proto *tp,
12721272
{
12731273
int err;
12741274

1275-
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, extack);
1275+
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, true,
1276+
extack);
12761277
if (err < 0)
12771278
return err;
12781279

‎net/sched/cls_fw.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp,
217217
int err;
218218

219219
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &f->exts, ovr,
220-
extack);
220+
true, extack);
221221
if (err < 0)
222222
return err;
223223

‎net/sched/cls_matchall.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ static int mall_set_parms(struct net *net, struct tcf_proto *tp,
145145
{
146146
int err;
147147

148-
err = tcf_exts_validate(net, tp, tb, est, &head->exts, ovr, extack);
148+
err = tcf_exts_validate(net, tp, tb, est, &head->exts, ovr, true,
149+
extack);
149150
if (err < 0)
150151
return err;
151152

‎net/sched/cls_route.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
393393
struct route4_bucket *b;
394394
int err;
395395

396-
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, extack);
396+
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, true, extack);
397397
if (err < 0)
398398
return err;
399399

0 commit comments

Comments
 (0)