Skip to content

Commit c2ccf84

Browse files
idoschdavem330
authored andcommitted
net/sched: act_api: Add extack to offload_act_setup() callback
The callback is used by various actions to populate the flow action structure prior to offload. Pass extack to this callback so that the various actions will be able to report accurate error messages to user space. Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Petr Machata <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 11c9531 commit c2ccf84

18 files changed

+50
-27
lines changed

include/net/act_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ struct tc_action_ops {
134134
(*get_psample_group)(const struct tc_action *a,
135135
tc_action_priv_destructor *destructor);
136136
int (*offload_act_setup)(struct tc_action *act, void *entry_data,
137-
u32 *index_inc, bool bind);
137+
u32 *index_inc, bool bind,
138+
struct netlink_ext_ack *extack);
138139
};
139140

140141
struct tc_action_net {

include/net/pkt_cls.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,12 @@ tcf_match_indev(struct sk_buff *skb, int ifindex)
547547
}
548548

549549
int tc_setup_offload_action(struct flow_action *flow_action,
550-
const struct tcf_exts *exts);
550+
const struct tcf_exts *exts,
551+
struct netlink_ext_ack *extack);
551552
void tc_cleanup_offload_action(struct flow_action *flow_action);
552553
int tc_setup_action(struct flow_action *flow_action,
553-
struct tc_action *actions[]);
554+
struct tc_action *actions[],
555+
struct netlink_ext_ack *extack);
554556

555557
int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,
556558
void *type_data, bool err_stop, bool rtnl_held);

net/sched/act_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static int offload_action_init(struct flow_offload_action *fl_action,
195195
if (act->ops->offload_act_setup) {
196196
spin_lock_bh(&act->tcfa_lock);
197197
err = act->ops->offload_act_setup(act, fl_action, NULL,
198-
false);
198+
false, extack);
199199
spin_unlock_bh(&act->tcfa_lock);
200200
return err;
201201
}
@@ -271,7 +271,7 @@ static int tcf_action_offload_add_ex(struct tc_action *action,
271271
if (err)
272272
goto fl_err;
273273

274-
err = tc_setup_action(&fl_action->action, actions);
274+
err = tc_setup_action(&fl_action->action, actions, extack);
275275
if (err) {
276276
NL_SET_ERR_MSG_MOD(extack,
277277
"Failed to setup tc actions for offload");

net/sched/act_csum.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ static size_t tcf_csum_get_fill_size(const struct tc_action *act)
696696
}
697697

698698
static int tcf_csum_offload_act_setup(struct tc_action *act, void *entry_data,
699-
u32 *index_inc, bool bind)
699+
u32 *index_inc, bool bind,
700+
struct netlink_ext_ack *extack)
700701
{
701702
if (bind) {
702703
struct flow_action_entry *entry = entry_data;

net/sched/act_ct.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,8 @@ static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets,
15841584
}
15851585

15861586
static int tcf_ct_offload_act_setup(struct tc_action *act, void *entry_data,
1587-
u32 *index_inc, bool bind)
1587+
u32 *index_inc, bool bind,
1588+
struct netlink_ext_ack *extack)
15881589
{
15891590
if (bind) {
15901591
struct flow_action_entry *entry = entry_data;

net/sched/act_gact.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ static size_t tcf_gact_get_fill_size(const struct tc_action *act)
253253
}
254254

255255
static int tcf_gact_offload_act_setup(struct tc_action *act, void *entry_data,
256-
u32 *index_inc, bool bind)
256+
u32 *index_inc, bool bind,
257+
struct netlink_ext_ack *extack)
257258
{
258259
if (bind) {
259260
struct flow_action_entry *entry = entry_data;

net/sched/act_gate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ static int tcf_gate_get_entries(struct flow_action_entry *entry,
619619
}
620620

621621
static int tcf_gate_offload_act_setup(struct tc_action *act, void *entry_data,
622-
u32 *index_inc, bool bind)
622+
u32 *index_inc, bool bind,
623+
struct netlink_ext_ack *extack)
623624
{
624625
int err;
625626

net/sched/act_mirred.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ static void tcf_offload_mirred_get_dev(struct flow_action_entry *entry,
460460
}
461461

462462
static int tcf_mirred_offload_act_setup(struct tc_action *act, void *entry_data,
463-
u32 *index_inc, bool bind)
463+
u32 *index_inc, bool bind,
464+
struct netlink_ext_ack *extack)
464465
{
465466
if (bind) {
466467
struct flow_action_entry *entry = entry_data;

net/sched/act_mpls.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ static int tcf_mpls_search(struct net *net, struct tc_action **a, u32 index)
385385
}
386386

387387
static int tcf_mpls_offload_act_setup(struct tc_action *act, void *entry_data,
388-
u32 *index_inc, bool bind)
388+
u32 *index_inc, bool bind,
389+
struct netlink_ext_ack *extack)
389390
{
390391
if (bind) {
391392
struct flow_action_entry *entry = entry_data;

net/sched/act_pedit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ static int tcf_pedit_search(struct net *net, struct tc_action **a, u32 index)
488488
}
489489

490490
static int tcf_pedit_offload_act_setup(struct tc_action *act, void *entry_data,
491-
u32 *index_inc, bool bind)
491+
u32 *index_inc, bool bind,
492+
struct netlink_ext_ack *extack)
492493
{
493494
if (bind) {
494495
struct flow_action_entry *entry = entry_data;

net/sched/act_police.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ static int tcf_police_act_to_flow_act(int tc_act, u32 *extval)
442442
}
443443

444444
static int tcf_police_offload_act_setup(struct tc_action *act, void *entry_data,
445-
u32 *index_inc, bool bind)
445+
u32 *index_inc, bool bind,
446+
struct netlink_ext_ack *extack)
446447
{
447448
if (bind) {
448449
struct flow_action_entry *entry = entry_data;

net/sched/act_sample.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ static void tcf_offload_sample_get_group(struct flow_action_entry *entry,
291291
}
292292

293293
static int tcf_sample_offload_act_setup(struct tc_action *act, void *entry_data,
294-
u32 *index_inc, bool bind)
294+
u32 *index_inc, bool bind,
295+
struct netlink_ext_ack *extack)
295296
{
296297
if (bind) {
297298
struct flow_action_entry *entry = entry_data;

net/sched/act_skbedit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ static size_t tcf_skbedit_get_fill_size(const struct tc_action *act)
328328
}
329329

330330
static int tcf_skbedit_offload_act_setup(struct tc_action *act, void *entry_data,
331-
u32 *index_inc, bool bind)
331+
u32 *index_inc, bool bind,
332+
struct netlink_ext_ack *extack)
332333
{
333334
if (bind) {
334335
struct flow_action_entry *entry = entry_data;

net/sched/act_tunnel_key.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,8 @@ static int tcf_tunnel_encap_get_tunnel(struct flow_action_entry *entry,
808808
static int tcf_tunnel_key_offload_act_setup(struct tc_action *act,
809809
void *entry_data,
810810
u32 *index_inc,
811-
bool bind)
811+
bool bind,
812+
struct netlink_ext_ack *extack)
812813
{
813814
int err;
814815

net/sched/act_vlan.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ static size_t tcf_vlan_get_fill_size(const struct tc_action *act)
369369
}
370370

371371
static int tcf_vlan_offload_act_setup(struct tc_action *act, void *entry_data,
372-
u32 *index_inc, bool bind)
372+
u32 *index_inc, bool bind,
373+
struct netlink_ext_ack *extack)
373374
{
374375
if (bind) {
375376
struct flow_action_entry *entry = entry_data;

net/sched/cls_api.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3513,11 +3513,13 @@ EXPORT_SYMBOL(tc_cleanup_offload_action);
35133513

35143514
static int tc_setup_offload_act(struct tc_action *act,
35153515
struct flow_action_entry *entry,
3516-
u32 *index_inc)
3516+
u32 *index_inc,
3517+
struct netlink_ext_ack *extack)
35173518
{
35183519
#ifdef CONFIG_NET_CLS_ACT
35193520
if (act->ops->offload_act_setup)
3520-
return act->ops->offload_act_setup(act, entry, index_inc, true);
3521+
return act->ops->offload_act_setup(act, entry, index_inc, true,
3522+
extack);
35213523
else
35223524
return -EOPNOTSUPP;
35233525
#else
@@ -3526,7 +3528,8 @@ static int tc_setup_offload_act(struct tc_action *act,
35263528
}
35273529

35283530
int tc_setup_action(struct flow_action *flow_action,
3529-
struct tc_action *actions[])
3531+
struct tc_action *actions[],
3532+
struct netlink_ext_ack *extack)
35303533
{
35313534
int i, j, index, err = 0;
35323535
struct tc_action *act;
@@ -3551,7 +3554,7 @@ int tc_setup_action(struct flow_action *flow_action,
35513554
entry->hw_stats = tc_act_hw_stats(act->hw_stats);
35523555
entry->hw_index = act->tcfa_index;
35533556
index = 0;
3554-
err = tc_setup_offload_act(act, entry, &index);
3557+
err = tc_setup_offload_act(act, entry, &index, extack);
35553558
if (!err)
35563559
j += index;
35573560
else
@@ -3570,13 +3573,14 @@ int tc_setup_action(struct flow_action *flow_action,
35703573
}
35713574

35723575
int tc_setup_offload_action(struct flow_action *flow_action,
3573-
const struct tcf_exts *exts)
3576+
const struct tcf_exts *exts,
3577+
struct netlink_ext_ack *extack)
35743578
{
35753579
#ifdef CONFIG_NET_CLS_ACT
35763580
if (!exts)
35773581
return 0;
35783582

3579-
return tc_setup_action(flow_action, exts->actions);
3583+
return tc_setup_action(flow_action, exts->actions, extack);
35803584
#else
35813585
return 0;
35823586
#endif

net/sched/cls_flower.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,
464464
cls_flower.rule->match.key = &f->mkey;
465465
cls_flower.classid = f->res.classid;
466466

467-
err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts);
467+
err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts,
468+
cls_flower.common.extack);
468469
if (err) {
469470
kfree(cls_flower.rule);
470471
NL_SET_ERR_MSG_MOD(cls_flower.common.extack,
@@ -2353,7 +2354,8 @@ static int fl_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb,
23532354
cls_flower.rule->match.mask = &f->mask->key;
23542355
cls_flower.rule->match.key = &f->mkey;
23552356

2356-
err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts);
2357+
err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts,
2358+
cls_flower.common.extack);
23572359
if (err) {
23582360
kfree(cls_flower.rule);
23592361
NL_SET_ERR_MSG_MOD(cls_flower.common.extack,

net/sched/cls_matchall.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ static int mall_replace_hw_filter(struct tcf_proto *tp,
9797
cls_mall.command = TC_CLSMATCHALL_REPLACE;
9898
cls_mall.cookie = cookie;
9999

100-
err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts);
100+
err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts,
101+
cls_mall.common.extack);
101102
if (err) {
102103
kfree(cls_mall.rule);
103104
mall_destroy_hw_filter(tp, head, cookie, NULL);
@@ -300,7 +301,8 @@ static int mall_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb,
300301
TC_CLSMATCHALL_REPLACE : TC_CLSMATCHALL_DESTROY;
301302
cls_mall.cookie = (unsigned long)head;
302303

303-
err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts);
304+
err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts,
305+
cls_mall.common.extack);
304306
if (err) {
305307
kfree(cls_mall.rule);
306308
NL_SET_ERR_MSG_MOD(cls_mall.common.extack,

0 commit comments

Comments
 (0)