mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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 <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
			
			
This commit is contained in:
		
							parent
							
								
									bf3b99e4f9
								
							
						
					
					
						commit
						b50e462bc2
					
				
					 1 changed files with 14 additions and 3 deletions
				
			
		| 
						 | 
					@ -419,7 +419,8 @@ static int tcf_police_search(struct net *net, struct tc_action **a, u32 index)
 | 
				
			||||||
	return tcf_idr_search(tn, a, index);
 | 
						return tcf_idr_search(tn, a, index);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int tcf_police_act_to_flow_act(int tc_act, u32 *extval)
 | 
					static int tcf_police_act_to_flow_act(int tc_act, u32 *extval,
 | 
				
			||||||
 | 
									      struct netlink_ext_ack *extack)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int act_id = -EOPNOTSUPP;
 | 
						int act_id = -EOPNOTSUPP;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -430,12 +431,20 @@ static int tcf_police_act_to_flow_act(int tc_act, u32 *extval)
 | 
				
			||||||
			act_id = FLOW_ACTION_DROP;
 | 
								act_id = FLOW_ACTION_DROP;
 | 
				
			||||||
		else if (tc_act == TC_ACT_PIPE)
 | 
							else if (tc_act == TC_ACT_PIPE)
 | 
				
			||||||
			act_id = FLOW_ACTION_PIPE;
 | 
								act_id = FLOW_ACTION_PIPE;
 | 
				
			||||||
 | 
							else if (tc_act == TC_ACT_RECLASSIFY)
 | 
				
			||||||
 | 
								NL_SET_ERR_MSG_MOD(extack, "Offload not supported when conform/exceed action is \"reclassify\"");
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								NL_SET_ERR_MSG_MOD(extack, "Unsupported conform/exceed action offload");
 | 
				
			||||||
	} else if (TC_ACT_EXT_CMP(tc_act, TC_ACT_GOTO_CHAIN)) {
 | 
						} else if (TC_ACT_EXT_CMP(tc_act, TC_ACT_GOTO_CHAIN)) {
 | 
				
			||||||
		act_id = FLOW_ACTION_GOTO;
 | 
							act_id = FLOW_ACTION_GOTO;
 | 
				
			||||||
		*extval = tc_act & TC_ACT_EXT_VAL_MASK;
 | 
							*extval = tc_act & TC_ACT_EXT_VAL_MASK;
 | 
				
			||||||
	} else if (TC_ACT_EXT_CMP(tc_act, TC_ACT_JUMP)) {
 | 
						} else if (TC_ACT_EXT_CMP(tc_act, TC_ACT_JUMP)) {
 | 
				
			||||||
		act_id = FLOW_ACTION_JUMP;
 | 
							act_id = FLOW_ACTION_JUMP;
 | 
				
			||||||
		*extval = tc_act & TC_ACT_EXT_VAL_MASK;
 | 
							*extval = tc_act & TC_ACT_EXT_VAL_MASK;
 | 
				
			||||||
 | 
						} else if (tc_act == TC_ACT_UNSPEC) {
 | 
				
			||||||
 | 
							NL_SET_ERR_MSG_MOD(extack, "Offload not supported when conform/exceed action is \"continue\"");
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							NL_SET_ERR_MSG_MOD(extack, "Unsupported conform/exceed action offload");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return act_id;
 | 
						return act_id;
 | 
				
			||||||
| 
						 | 
					@ -467,14 +476,16 @@ static int tcf_police_offload_act_setup(struct tc_action *act, void *entry_data,
 | 
				
			||||||
		entry->police.mtu = tcf_police_tcfp_mtu(act);
 | 
							entry->police.mtu = tcf_police_tcfp_mtu(act);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		act_id = tcf_police_act_to_flow_act(police->tcf_action,
 | 
							act_id = tcf_police_act_to_flow_act(police->tcf_action,
 | 
				
			||||||
						    &entry->police.exceed.extval);
 | 
											    &entry->police.exceed.extval,
 | 
				
			||||||
 | 
											    extack);
 | 
				
			||||||
		if (act_id < 0)
 | 
							if (act_id < 0)
 | 
				
			||||||
			return act_id;
 | 
								return act_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		entry->police.exceed.act_id = act_id;
 | 
							entry->police.exceed.act_id = act_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		act_id = tcf_police_act_to_flow_act(p->tcfp_result,
 | 
							act_id = tcf_police_act_to_flow_act(p->tcfp_result,
 | 
				
			||||||
						    &entry->police.notexceed.extval);
 | 
											    &entry->police.notexceed.extval,
 | 
				
			||||||
 | 
											    extack);
 | 
				
			||||||
		if (act_id < 0)
 | 
							if (act_id < 0)
 | 
				
			||||||
			return act_id;
 | 
								return act_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue