diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index f2a6e71..c1d0956 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -62,6 +62,7 @@ struct pcpu_lstats { unsigned long packets; unsigned long bytes; + int depth; }; /* KISS: just allocate small chunks and copy bits. @@ -158,8 +159,16 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev) lb_stats->bytes += skb->len; lb_stats->packets++; - netif_rx(skb); - + /* + * We can call netif_receive_skb() instead of netif_rx() + * to speedup processing, but not in case of recursion, + * or we risk stack overflow. + */ + if (lb_stats->depth++ == 0) + netif_receive_skb(skb); + else + netif_rx(skb); + lb_stats->depth--; return 0; }