Skip to content

Commit 85b15c2

Browse files
committed
Merge branch 'net-sched-offload-failure-error-reporting'
Ido Schimmel says: ==================== net/sched: Better error reporting for offload failures This patchset improves error reporting to user space when offload fails during the flow action setup phase. That is, when failures occur in the actions themselves, even before calling device drivers. Requested / reported in [1]. This is done by passing extack to the offload_act_setup() callback and making use of it in the various actions. Patches #1-#2 change matchall and flower to log error messages to user space in accordance with the verbose flag. Patch #3 passes extack to the offload_act_setup() callback from the various call sites, including matchall and flower. Patches #4-#11 make use of extack in the various actions to report offload failures. Patch #12 adds an error message when the action does not support offload at all. Patches #13-#14 change matchall and flower to stop overwriting more specific error messages. [1] https://lore.kernel.org/netdev/20220317185249.5mff5u2x624pjewv@skbuf/ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 4a778f3 + fd23e0e commit 85b15c2

20 files changed

+128
-48
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);

include/net/tc_act/tc_gact.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,19 @@ static inline u32 tcf_gact_goto_chain_index(const struct tc_action *a)
5959
return READ_ONCE(a->tcfa_action) & TC_ACT_EXT_VAL_MASK;
6060
}
6161

62+
static inline bool is_tcf_gact_continue(const struct tc_action *a)
63+
{
64+
return __is_tcf_gact_act(a, TC_ACT_UNSPEC, false);
65+
}
66+
67+
static inline bool is_tcf_gact_reclassify(const struct tc_action *a)
68+
{
69+
return __is_tcf_gact_act(a, TC_ACT_RECLASSIFY, false);
70+
}
71+
72+
static inline bool is_tcf_gact_pipe(const struct tc_action *a)
73+
{
74+
return __is_tcf_gact_act(a, TC_ACT_PIPE, false);
75+
}
76+
6277
#endif /* __NET_TC_GACT_H */

include/net/tc_act/tc_skbedit.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,16 @@ static inline u32 tcf_skbedit_priority(const struct tc_action *a)
9494
return priority;
9595
}
9696

97+
/* Return true iff action is queue_mapping */
98+
static inline bool is_tcf_skbedit_queue_mapping(const struct tc_action *a)
99+
{
100+
return is_tcf_skbedit_with_flag(a, SKBEDIT_F_QUEUE_MAPPING);
101+
}
102+
103+
/* Return true iff action is inheritdsfield */
104+
static inline bool is_tcf_skbedit_inheritdsfield(const struct tc_action *a)
105+
{
106+
return is_tcf_skbedit_with_flag(a, SKBEDIT_F_INHERITDSFIELD);
107+
}
108+
97109
#endif /* __NET_TC_SKBEDIT_H */

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: 12 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;
@@ -267,7 +268,17 @@ static int tcf_gact_offload_act_setup(struct tc_action *act, void *entry_data,
267268
} else if (is_tcf_gact_goto_chain(act)) {
268269
entry->id = FLOW_ACTION_GOTO;
269270
entry->chain_index = tcf_gact_goto_chain_index(act);
271+
} else if (is_tcf_gact_continue(act)) {
272+
NL_SET_ERR_MSG_MOD(extack, "Offload of \"continue\" action is not supported");
273+
return -EOPNOTSUPP;
274+
} else if (is_tcf_gact_reclassify(act)) {
275+
NL_SET_ERR_MSG_MOD(extack, "Offload of \"reclassify\" action is not supported");
276+
return -EOPNOTSUPP;
277+
} else if (is_tcf_gact_pipe(act)) {
278+
NL_SET_ERR_MSG_MOD(extack, "Offload of \"pipe\" action is not supported");
279+
return -EOPNOTSUPP;
270280
} else {
281+
NL_SET_ERR_MSG_MOD(extack, "Unsupported generic action offload");
271282
return -EOPNOTSUPP;
272283
}
273284
*index_inc = 1;

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: 3 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;
@@ -478,6 +479,7 @@ static int tcf_mirred_offload_act_setup(struct tc_action *act, void *entry_data,
478479
entry->id = FLOW_ACTION_MIRRED_INGRESS;
479480
tcf_offload_mirred_get_dev(entry, act);
480481
} else {
482+
NL_SET_ERR_MSG_MOD(extack, "Unsupported mirred offload");
481483
return -EOPNOTSUPP;
482484
}
483485
*index_inc = 1;

0 commit comments

Comments
 (0)