2828static LIST_HEAD (mirred_list );
2929static DEFINE_SPINLOCK (mirred_list_lock );
3030
31- #define MIRRED_RECURSION_LIMIT 4
32- static DEFINE_PER_CPU (unsigned int , mirred_rec_level ) ;
31+ #define MIRRED_NEST_LIMIT 4
32+ static DEFINE_PER_CPU (unsigned int , mirred_nest_level ) ;
3333
3434static bool tcf_mirred_is_act_redirect (int action )
3535{
@@ -206,12 +206,19 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
206206 return err ;
207207}
208208
209+ static bool is_mirred_nested (void )
210+ {
211+ return unlikely (__this_cpu_read (mirred_nest_level ) > 1 );
212+ }
213+
209214static int tcf_mirred_forward (bool want_ingress , struct sk_buff * skb )
210215{
211216 int err ;
212217
213218 if (!want_ingress )
214219 err = tcf_dev_queue_xmit (skb , dev_queue_xmit );
220+ else if (is_mirred_nested ())
221+ err = netif_rx (skb );
215222 else
216223 err = netif_receive_skb (skb );
217224
@@ -225,7 +232,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
225232 struct sk_buff * skb2 = skb ;
226233 bool m_mac_header_xmit ;
227234 struct net_device * dev ;
228- unsigned int rec_level ;
235+ unsigned int nest_level ;
229236 int retval , err = 0 ;
230237 bool use_reinsert ;
231238 bool want_ingress ;
@@ -236,11 +243,11 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
236243 int mac_len ;
237244 bool at_nh ;
238245
239- rec_level = __this_cpu_inc_return (mirred_rec_level );
240- if (unlikely (rec_level > MIRRED_RECURSION_LIMIT )) {
246+ nest_level = __this_cpu_inc_return (mirred_nest_level );
247+ if (unlikely (nest_level > MIRRED_NEST_LIMIT )) {
241248 net_warn_ratelimited ("Packet exceeded mirred recursion limit on dev %s\n" ,
242249 netdev_name (skb -> dev ));
243- __this_cpu_dec (mirred_rec_level );
250+ __this_cpu_dec (mirred_nest_level );
244251 return TC_ACT_SHOT ;
245252 }
246253
@@ -310,7 +317,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
310317 err = tcf_mirred_forward (res -> ingress , skb );
311318 if (err )
312319 tcf_action_inc_overlimit_qstats (& m -> common );
313- __this_cpu_dec (mirred_rec_level );
320+ __this_cpu_dec (mirred_nest_level );
314321 return TC_ACT_CONSUMED ;
315322 }
316323 }
@@ -322,7 +329,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
322329 if (tcf_mirred_is_act_redirect (m_eaction ))
323330 retval = TC_ACT_SHOT ;
324331 }
325- __this_cpu_dec (mirred_rec_level );
332+ __this_cpu_dec (mirred_nest_level );
326333
327334 return retval ;
328335}
0 commit comments