Commit ec6743a1 authored by Vlad Buslov's avatar Vlad Buslov Committed by David S. Miller

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: default avatarVlad Buslov <vladbu@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 726d0612
...@@ -416,7 +416,7 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts, ...@@ -416,7 +416,7 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts,
int tcf_exts_validate(struct net *net, struct tcf_proto *tp, int tcf_exts_validate(struct net *net, struct tcf_proto *tp,
struct nlattr **tb, struct nlattr *rate_tlv, struct nlattr **tb, struct nlattr *rate_tlv,
struct tcf_exts *exts, bool ovr, struct tcf_exts *exts, bool ovr, bool rtnl_held,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
void tcf_exts_destroy(struct tcf_exts *exts); void tcf_exts_destroy(struct tcf_exts *exts);
void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src); void tcf_exts_change(struct tcf_exts *dst, struct tcf_exts *src);
......
...@@ -2841,7 +2841,7 @@ EXPORT_SYMBOL(tcf_exts_destroy); ...@@ -2841,7 +2841,7 @@ EXPORT_SYMBOL(tcf_exts_destroy);
int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
struct nlattr *rate_tlv, struct tcf_exts *exts, bool ovr, struct nlattr *rate_tlv, struct tcf_exts *exts, bool ovr,
struct netlink_ext_ack *extack) bool rtnl_held, struct netlink_ext_ack *extack)
{ {
#ifdef CONFIG_NET_CLS_ACT #ifdef CONFIG_NET_CLS_ACT
{ {
...@@ -2851,7 +2851,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, ...@@ -2851,7 +2851,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
if (exts->police && tb[exts->police]) { if (exts->police && tb[exts->police]) {
act = tcf_action_init_1(net, tp, tb[exts->police], act = tcf_action_init_1(net, tp, tb[exts->police],
rate_tlv, "police", ovr, rate_tlv, "police", ovr,
TCA_ACT_BIND, true, extack); TCA_ACT_BIND, rtnl_held,
extack);
if (IS_ERR(act)) if (IS_ERR(act))
return PTR_ERR(act); return PTR_ERR(act);
...@@ -2863,8 +2864,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, ...@@ -2863,8 +2864,8 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
err = tcf_action_init(net, tp, tb[exts->action], err = tcf_action_init(net, tp, tb[exts->action],
rate_tlv, NULL, ovr, TCA_ACT_BIND, rate_tlv, NULL, ovr, TCA_ACT_BIND,
exts->actions, &attr_size, true, exts->actions, &attr_size,
extack); rtnl_held, extack);
if (err < 0) if (err < 0)
return err; return err;
exts->nr_actions = err; exts->nr_actions = err;
......
...@@ -153,7 +153,7 @@ static int basic_set_parms(struct net *net, struct tcf_proto *tp, ...@@ -153,7 +153,7 @@ static int basic_set_parms(struct net *net, struct tcf_proto *tp,
{ {
int err; int err;
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, extack); err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, true, extack);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -417,7 +417,8 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp, ...@@ -417,7 +417,8 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp,
if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf)) if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf))
return -EINVAL; return -EINVAL;
ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr, extack); ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr, true,
extack);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
...@@ -110,7 +110,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, ...@@ -110,7 +110,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
goto errout; goto errout;
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &new->exts, ovr, err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &new->exts, ovr,
extack); true, extack);
if (err < 0) if (err < 0)
goto errout; goto errout;
......
...@@ -445,7 +445,7 @@ static int flow_change(struct net *net, struct sk_buff *in_skb, ...@@ -445,7 +445,7 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
goto err2; goto err2;
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &fnew->exts, ovr, err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &fnew->exts, ovr,
extack); true, extack);
if (err < 0) if (err < 0)
goto err2; goto err2;
......
...@@ -1272,7 +1272,8 @@ static int fl_set_parms(struct net *net, struct tcf_proto *tp, ...@@ -1272,7 +1272,8 @@ static int fl_set_parms(struct net *net, struct tcf_proto *tp,
{ {
int err; int err;
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, extack); err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, true,
extack);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -217,7 +217,7 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp, ...@@ -217,7 +217,7 @@ static int fw_set_parms(struct net *net, struct tcf_proto *tp,
int err; int err;
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &f->exts, ovr, err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &f->exts, ovr,
extack); true, extack);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -145,7 +145,8 @@ static int mall_set_parms(struct net *net, struct tcf_proto *tp, ...@@ -145,7 +145,8 @@ static int mall_set_parms(struct net *net, struct tcf_proto *tp,
{ {
int err; int err;
err = tcf_exts_validate(net, tp, tb, est, &head->exts, ovr, extack); err = tcf_exts_validate(net, tp, tb, est, &head->exts, ovr, true,
extack);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -393,7 +393,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, ...@@ -393,7 +393,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
struct route4_bucket *b; struct route4_bucket *b;
int err; int err;
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, extack); err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr, true, extack);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -502,7 +502,8 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb, ...@@ -502,7 +502,8 @@ static int rsvp_change(struct net *net, struct sk_buff *in_skb,
err = tcf_exts_init(&e, TCA_RSVP_ACT, TCA_RSVP_POLICE); err = tcf_exts_init(&e, TCA_RSVP_ACT, TCA_RSVP_POLICE);
if (err < 0) if (err < 0)
return err; return err;
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, ovr, extack); err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, ovr, true,
extack);
if (err < 0) if (err < 0)
goto errout2; goto errout2;
......
...@@ -314,7 +314,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, ...@@ -314,7 +314,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
err = tcf_exts_init(&e, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE); err = tcf_exts_init(&e, TCA_TCINDEX_ACT, TCA_TCINDEX_POLICE);
if (err < 0) if (err < 0)
return err; return err;
err = tcf_exts_validate(net, tp, tb, est, &e, ovr, extack); err = tcf_exts_validate(net, tp, tb, est, &e, ovr, true, extack);
if (err < 0) if (err < 0)
goto errout; goto errout;
......
...@@ -726,7 +726,7 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, ...@@ -726,7 +726,7 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp,
{ {
int err; int err;
err = tcf_exts_validate(net, tp, tb, est, &n->exts, ovr, extack); err = tcf_exts_validate(net, tp, tb, est, &n->exts, ovr, true, extack);
if (err < 0) if (err < 0)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment