Skip to content

Commit b50e462

Browse files
idoschdavem330
authored andcommitted
net/sched: act_police: Add extack messages for offload failure
For better error reporting to user space, add extack messages when police action offload fails. Example: # echo 1 > /sys/kernel/tracing/events/netlink/netlink_extack/enable # tc filter add dev dummy0 ingress pref 1 proto all matchall skip_sw action police rate 100Mbit burst 10000 Error: cls_matchall: Failed to setup flow action. We have an error talking to the kernel # cat /sys/kernel/tracing/trace_pipe tc-182 [000] b..1. 21.592969: netlink_extack: msg=act_police: Offload not supported when conform/exceed action is "reclassify" tc-182 [000] ..... 21.592982: netlink_extack: msg=cls_matchall: Failed to setup flow action # tc filter add dev dummy0 ingress pref 1 proto all matchall skip_sw action police rate 100Mbit burst 10000 conform-exceed drop/continue Error: cls_matchall: Failed to setup flow action. We have an error talking to the kernel # cat /sys/kernel/tracing/trace_pipe tc-184 [000] b..1. 38.882579: netlink_extack: msg=act_police: Offload not supported when conform/exceed action is "continue" tc-184 [000] ..... 38.882593: netlink_extack: msg=cls_matchall: Failed to setup flow action Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Petr Machata <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bf3b99e commit b50e462

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

net/sched/act_police.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ static int tcf_police_search(struct net *net, struct tc_action **a, u32 index)
419419
return tcf_idr_search(tn, a, index);
420420
}
421421

422-
static int tcf_police_act_to_flow_act(int tc_act, u32 *extval)
422+
static int tcf_police_act_to_flow_act(int tc_act, u32 *extval,
423+
struct netlink_ext_ack *extack)
423424
{
424425
int act_id = -EOPNOTSUPP;
425426

@@ -430,12 +431,20 @@ static int tcf_police_act_to_flow_act(int tc_act, u32 *extval)
430431
act_id = FLOW_ACTION_DROP;
431432
else if (tc_act == TC_ACT_PIPE)
432433
act_id = FLOW_ACTION_PIPE;
434+
else if (tc_act == TC_ACT_RECLASSIFY)
435+
NL_SET_ERR_MSG_MOD(extack, "Offload not supported when conform/exceed action is \"reclassify\"");
436+
else
437+
NL_SET_ERR_MSG_MOD(extack, "Unsupported conform/exceed action offload");
433438
} else if (TC_ACT_EXT_CMP(tc_act, TC_ACT_GOTO_CHAIN)) {
434439
act_id = FLOW_ACTION_GOTO;
435440
*extval = tc_act & TC_ACT_EXT_VAL_MASK;
436441
} else if (TC_ACT_EXT_CMP(tc_act, TC_ACT_JUMP)) {
437442
act_id = FLOW_ACTION_JUMP;
438443
*extval = tc_act & TC_ACT_EXT_VAL_MASK;
444+
} else if (tc_act == TC_ACT_UNSPEC) {
445+
NL_SET_ERR_MSG_MOD(extack, "Offload not supported when conform/exceed action is \"continue\"");
446+
} else {
447+
NL_SET_ERR_MSG_MOD(extack, "Unsupported conform/exceed action offload");
439448
}
440449

441450
return act_id;
@@ -467,14 +476,16 @@ static int tcf_police_offload_act_setup(struct tc_action *act, void *entry_data,
467476
entry->police.mtu = tcf_police_tcfp_mtu(act);
468477

469478
act_id = tcf_police_act_to_flow_act(police->tcf_action,
470-
&entry->police.exceed.extval);
479+
&entry->police.exceed.extval,
480+
extack);
471481
if (act_id < 0)
472482
return act_id;
473483

474484
entry->police.exceed.act_id = act_id;
475485

476486
act_id = tcf_police_act_to_flow_act(p->tcfp_result,
477-
&entry->police.notexceed.extval);
487+
&entry->police.notexceed.extval,
488+
extack);
478489
if (act_id < 0)
479490
return act_id;
480491

0 commit comments

Comments
 (0)