Skip to contentSkip to conversation

ipvlan: use netif_receive_skb() in ipvlan_process_multicast()

PATCH Superseded Eric Dumazet 1 participant 3 messages Apr 27 – Apr 28

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipvlan: use netif_receive_skb() in ipvlan_process_multicast()

ipvlan_process_multicast() runs from process context, there is no risk of stack overflow if we call netif_receive_skb() instead of netif_rx().

This avoids some overhead adding/removing skbs to/from a per-cpu backlog and raising/processing NET_RX softirqs.

---
 drivers/net/ipvlan/ipvlan_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipvlan/ipvlan_core.c +1 -1
index 1be8620ad3971d281fb36fd0770efd67b566ae60..7ad12dc7845c836bdd04395f153b2b4b397797d6 100644
@@ -286,7 +286,7 @@ void ipvlan_process_multicast(struct work_struct *work)
 				if (tx_pkt)
 					ret = dev_forward_skb(ipvlan->dev, nskb);
 				else
-					ret = netif_rx(nskb);
+					ret = netif_receive_skb(nskb);
 			}
 			ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true);
 			local_bh_enable();
Signature · 1 line
2.54.0.545.g6539524ca2-goog
#1 lore raw
Quoted 18 lines · Eric Dumazet

ipvlan_process_multicast() runs from process context, there is no risk of stack overflow if we call netif_receive_skb() instead of netif_rx().

This avoids some overhead adding/removing skbs to/from a per-cpu backlog and raising/processing NET_RX softirqs.

---
 drivers/net/ipvlan/ipvlan_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipvlan/ipvlan_core.c +0 -0
index 1be8620ad3971d281fb36fd0770efd67b566ae60..7ad12dc7845c836bdd04395f153b2b4b397797d6 100644

drivers/net/ipvlan/ipvlan_core.c void ipvlan_process_multicast(struct work_struct *work) · line 292

Quoted 8 lines
drivers/net/ipvlan/ipvlan_core.c +1 -1
@@ -286,7 +286,7 @@ void ipvlan_process_multicast(struct work_struct *work)
                                if (tx_pkt)
                                        ret = dev_forward_skb(ipvlan->dev, nskb);
                                else
-                                       ret = netif_rx(nskb);
+                                       ret = netif_receive_skb(nskb);
                        }
                        ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true);
                        local_bh_enable();

I will send a V2, to limit the number of netif_receive_skb() in presence of large number of ipvlans.

pw-bot: cr

#2 lore raw
Quoted 15 lines · Eric Dumazet
Quoted 13 lines · Eric Dumazet

ipvlan_process_multicast() runs from process context, there is no risk of stack overflow if we call netif_receive_skb() instead of netif_rx().

This avoids some overhead adding/removing skbs to/from a per-cpu backlog and raising/processing NET_RX softirqs.

---
 drivers/net/ipvlan/ipvlan_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

drivers/net/ipvlan/ipvlan_core.c void ipvlan_process_multicast(struct work_struct *work) · line 292

Quoted 13 lines
drivers/net/ipvlan/ipvlan_core.c +1 -1
index 1be8620ad3971d281fb36fd0770efd67b566ae60..7ad12dc7845c836bdd04395f153b2b4b397797d6 100644
@@ -286,7 +286,7 @@ void ipvlan_process_multicast(struct work_struct *work)
                                if (tx_pkt)
                                        ret = dev_forward_skb(ipvlan->dev, nskb);
                                else
-                                       ret = netif_rx(nskb);
+                                       ret = netif_receive_skb(nskb);
                        }
                        ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true);
                        local_bh_enable();

I will send a V2, to limit the number of netif_receive_skb() in presence of large number of ipvlans.

Well, this was caused this sashiko report:

Because netif_receive_skb() traverses the networking stack synchronously, it bypasses the backlog and softirq processing budgets. In environments with many IPVLAN sub-interfaces, delivering a broadcast or multicast packet could monopolize the CPU for an unbounded amount of time before reaching rcu_read_unlock().

But using netif_rx(nskb) had the same problem.
Each packet was immediately processed at the local_bh_enable() time.

So I do not think a V2 is needed.