Skip to content

Commit f6581c7

Browse files
committed
Merge branch 'net-sched-act-add-extack-support'
Alexander Aring says: ==================== net: sched: act: add extack support this patch series adds extack support for the TC action subsystem. As example I for the extack support in a TC action I choosed mirred action. - Alex Cc: David Ahern <dsahern@gmail.com> changes since v3: - adapt recommended changes from Davide Caratti, please check if I catch everything. Thanks. changes since v2: - remove newline in extack of generic walker handling Thanks to Davide Caratti - add kernel@mojatatu.com in cc ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 66dede2 + 10defbd commit f6581c7

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed

include/net/act_api.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ struct tc_action_ops {
8787
struct tcf_result *);
8888
int (*dump)(struct sk_buff *, struct tc_action *, int, int);
8989
void (*cleanup)(struct tc_action *);
90-
int (*lookup)(struct net *, struct tc_action **, u32);
90+
int (*lookup)(struct net *net, struct tc_action **a, u32 index);
9191
int (*init)(struct net *net, struct nlattr *nla,
9292
struct nlattr *est, struct tc_action **act, int ovr,
9393
int bind);
9494
int (*walk)(struct net *, struct sk_buff *,
95-
struct netlink_callback *, int, const struct tc_action_ops *);
95+
struct netlink_callback *, int,
96+
const struct tc_action_ops *);
9697
void (*stats_update)(struct tc_action *, u64, u32, u64);
9798
struct net_device *(*get_dev)(const struct tc_action *a);
9899
};
@@ -162,10 +163,11 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
162163
int nr_actions, struct tcf_result *res);
163164
int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
164165
struct nlattr *est, char *name, int ovr, int bind,
165-
struct list_head *actions);
166+
struct list_head *actions, struct netlink_ext_ack *extack);
166167
struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
167168
struct nlattr *nla, struct nlattr *est,
168-
char *name, int ovr, int bind);
169+
char *name, int ovr, int bind,
170+
struct netlink_ext_ack *extack);
169171
int tcf_action_dump(struct sk_buff *skb, struct list_head *, int, int);
170172
int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
171173
int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);

net/sched/act_api.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,8 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb)
605605

606606
struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
607607
struct nlattr *nla, struct nlattr *est,
608-
char *name, int ovr, int bind)
608+
char *name, int ovr, int bind,
609+
struct netlink_ext_ack *extack)
609610
{
610611
struct tc_action *a;
611612
struct tc_action_ops *a_o;
@@ -621,7 +622,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
621622
goto err_out;
622623
err = -EINVAL;
623624
kind = tb[TCA_ACT_KIND];
624-
if (kind == NULL)
625+
if (!kind)
625626
goto err_out;
626627
if (nla_strlcpy(act_name, kind, IFNAMSIZ) >= IFNAMSIZ)
627628
goto err_out;
@@ -726,7 +727,7 @@ static void cleanup_a(struct list_head *actions, int ovr)
726727

727728
int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
728729
struct nlattr *est, char *name, int ovr, int bind,
729-
struct list_head *actions)
730+
struct list_head *actions, struct netlink_ext_ack *extack)
730731
{
731732
struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
732733
struct tc_action *act;
@@ -738,7 +739,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,
738739
return err;
739740

740741
for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
741-
act = tcf_action_init_1(net, tp, tb[i], est, name, ovr, bind);
742+
act = tcf_action_init_1(net, tp, tb[i], est, name, ovr, bind,
743+
extack);
742744
if (IS_ERR(act)) {
743745
err = PTR_ERR(act);
744746
goto err;
@@ -822,7 +824,7 @@ static int tca_get_fill(struct sk_buff *skb, struct list_head *actions,
822824
t->tca__pad2 = 0;
823825

824826
nest = nla_nest_start(skb, TCA_ACT_TAB);
825-
if (nest == NULL)
827+
if (!nest)
826828
goto out_nlmsg_trim;
827829

828830
if (tcf_action_dump(skb, actions, bind, ref) < 0)
@@ -934,7 +936,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
934936
t->tca__pad2 = 0;
935937

936938
nest = nla_nest_start(skb, TCA_ACT_TAB);
937-
if (nest == NULL)
939+
if (!nest)
938940
goto out_module_put;
939941

940942
err = ops->walk(net, skb, &dcb, RTM_DELACTION, ops);
@@ -1007,10 +1009,10 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
10071009
return ret;
10081010

10091011
if (event == RTM_DELACTION && n->nlmsg_flags & NLM_F_ROOT) {
1010-
if (tb[1] != NULL)
1012+
if (tb[1])
10111013
return tca_action_flush(net, tb[1], n, portid);
1012-
else
1013-
return -EINVAL;
1014+
1015+
return -EINVAL;
10141016
}
10151017

10161018
for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) {
@@ -1062,12 +1064,14 @@ tcf_add_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
10621064
}
10631065

10641066
static int tcf_action_add(struct net *net, struct nlattr *nla,
1065-
struct nlmsghdr *n, u32 portid, int ovr)
1067+
struct nlmsghdr *n, u32 portid, int ovr,
1068+
struct netlink_ext_ack *extack)
10661069
{
10671070
int ret = 0;
10681071
LIST_HEAD(actions);
10691072

1070-
ret = tcf_action_init(net, NULL, nla, NULL, NULL, ovr, 0, &actions);
1073+
ret = tcf_action_init(net, NULL, nla, NULL, NULL, ovr, 0, &actions,
1074+
extack);
10711075
if (ret)
10721076
return ret;
10731077

@@ -1115,7 +1119,8 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n,
11151119
if (n->nlmsg_flags & NLM_F_REPLACE)
11161120
ovr = 1;
11171121
replay:
1118-
ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, portid, ovr);
1122+
ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, portid, ovr,
1123+
extack);
11191124
if (ret == -EAGAIN)
11201125
goto replay;
11211126
break;

net/sched/act_mirred.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
8080
bool exists = false;
8181
int ret;
8282

83-
if (nla == NULL)
83+
if (!nla)
8484
return -EINVAL;
8585
ret = nla_parse_nested(tb, TCA_MIRRED_MAX, nla, mirred_policy, NULL);
8686
if (ret < 0)
8787
return ret;
88-
if (tb[TCA_MIRRED_PARMS] == NULL)
88+
if (!tb[TCA_MIRRED_PARMS])
8989
return -EINVAL;
9090
parm = nla_data(tb[TCA_MIRRED_PARMS]);
9191

@@ -117,7 +117,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
117117
}
118118

119119
if (!exists) {
120-
if (dev == NULL)
120+
if (!dev)
121121
return -EINVAL;
122122
ret = tcf_idr_create(tn, parm->index, est, a,
123123
&act_mirred_ops, bind, true);

net/sched/cls_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
14341434
if (exts->police && tb[exts->police]) {
14351435
act = tcf_action_init_1(net, tp, tb[exts->police],
14361436
rate_tlv, "police", ovr,
1437-
TCA_ACT_BIND);
1437+
TCA_ACT_BIND, extack);
14381438
if (IS_ERR(act))
14391439
return PTR_ERR(act);
14401440

@@ -1447,7 +1447,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
14471447

14481448
err = tcf_action_init(net, tp, tb[exts->action],
14491449
rate_tlv, NULL, ovr, TCA_ACT_BIND,
1450-
&actions);
1450+
&actions, extack);
14511451
if (err)
14521452
return err;
14531453
list_for_each_entry(act, &actions, list)

0 commit comments

Comments
 (0)