mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	net_sched: reject unknown tcfa_action values
After the commit802bfb1915("net/sched: user-space can't set unknown tcfa_action values"), unknown tcfa_action values are converted to TC_ACT_UNSPEC, but the common agreement is instead rejecting such configurations. This change also introduces a helper to simplify the destruction of a single action, avoiding code duplication. v1 -> v2: - helper is now static and renamed according to act_* convention - updated extack message, according to the new behavior Fixes:802bfb1915("net/sched: user-space can't set unknown tcfa_action values") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									c4053ef322
								
							
						
					
					
						commit
						97763dc0f4
					
				
					 1 changed files with 11 additions and 5 deletions
				
			
		| 
						 | 
					@ -662,6 +662,13 @@ int tcf_action_destroy(struct tc_action *actions[], int bind)
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int tcf_action_destroy_1(struct tc_action *a, int bind)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct tc_action *actions[] = { a, NULL };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return tcf_action_destroy(actions, bind);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int tcf_action_put(struct tc_action *p)
 | 
					static int tcf_action_put(struct tc_action *p)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return __tcf_action_put(p, false);
 | 
						return __tcf_action_put(p, false);
 | 
				
			||||||
| 
						 | 
					@ -881,17 +888,16 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
 | 
				
			||||||
	if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN)) {
 | 
						if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN)) {
 | 
				
			||||||
		err = tcf_action_goto_chain_init(a, tp);
 | 
							err = tcf_action_goto_chain_init(a, tp);
 | 
				
			||||||
		if (err) {
 | 
							if (err) {
 | 
				
			||||||
			struct tc_action *actions[] = { a, NULL };
 | 
								tcf_action_destroy_1(a, bind);
 | 
				
			||||||
 | 
					 | 
				
			||||||
			tcf_action_destroy(actions, bind);
 | 
					 | 
				
			||||||
			NL_SET_ERR_MSG(extack, "Failed to init TC action chain");
 | 
								NL_SET_ERR_MSG(extack, "Failed to init TC action chain");
 | 
				
			||||||
			return ERR_PTR(err);
 | 
								return ERR_PTR(err);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!tcf_action_valid(a->tcfa_action)) {
 | 
						if (!tcf_action_valid(a->tcfa_action)) {
 | 
				
			||||||
		NL_SET_ERR_MSG(extack, "invalid action value, using TC_ACT_UNSPEC instead");
 | 
							tcf_action_destroy_1(a, bind);
 | 
				
			||||||
		a->tcfa_action = TC_ACT_UNSPEC;
 | 
							NL_SET_ERR_MSG(extack, "Invalid control action value");
 | 
				
			||||||
 | 
							return ERR_PTR(-EINVAL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return a;
 | 
						return a;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue