Skip to contentSkip to conversation

net: orphan frags on stand-alone ptype in dev_queue_xmit_nit

PATCH Superseded Willem de Bruijn 3 participants 3 messages Sep 22, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: orphan frags on stand-alone ptype in dev_queue_xmit_nit

Zerocopy skbs frags are copied when the skb is looped to a local sock. Commit 1080e512d44d ("net: orphan frags on receive") introduced calls to skb_orphan_frags to deliver_skb and __netif_receive_skb.

With msg_zerocopy, these skbs can also exist in the tx path and thus loop from dev_queue_xmit_nit. This already calls deliver_skb in its loop. But it does not orphan before a separate pt_prev->func().

Add the missing skb_orphan_frags_rx.

Fixes 1f8b977ab32d ("sock: enable MSG_ZEROCOPY")
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index 9a2254f9802f..3f5b26ff4f74 100644
@@ -1948,7 +1948,7 @@ void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
 		goto again;
 	}
 out_unlock:
-	if (pt_prev)
+	if (pt_prev && !skb_orphan_frags_rx(skb2, GFP_ATOMIC))
 		pt_prev->func(skb2, skb->dev, pt_prev, skb->dev);
 	rcu_read_unlock();
 }
Signature · 1 line
2.14.1.821.g8fa685d3b7-goog
#1 lore raw
Quoted 21 lines · Willem de Bruijn

Zerocopy skbs frags are copied when the skb is looped to a local sock. Commit 1080e512d44d ("net: orphan frags on receive") introduced calls to skb_orphan_frags to deliver_skb and __netif_receive_skb.

With msg_zerocopy, these skbs can also exist in the tx path and thus loop from dev_queue_xmit_nit. This already calls deliver_skb in its loop. But it does not orphan before a separate pt_prev->func().

Add the missing skb_orphan_frags_rx.

Fixes 1f8b977ab32d ("sock: enable MSG_ZEROCOPY")
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +0 -0
index 9a2254f9802f..3f5b26ff4f74 100644

net/core/dev.c void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) · line 1952

Quoted 6 lines
net/core/dev.c +1 -1
@@ -1948,7 +1948,7 @@ void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
 		goto again;
 	}
 out_unlock:
-	if (pt_prev)
+	if (pt_prev && !skb_orphan_frags_rx(skb2, GFP_ATOMIC))
 		pt_prev->func(skb2, skb->dev, pt_prev, skb->dev);

Don't you need to kfree_skb(skb2) in case of failure ?

Quoted 2 lines
net/core/dev.c +0 -0
 	rcu_read_unlock();
 }
#2 lore raw
Quoted 17 lines · Eric Dumazet
Quoted 16 lines · Willem de Bruijn

Zerocopy skbs frags are copied when the skb is looped to a local sock. Commit 1080e512d44d ("net: orphan frags on receive") introduced calls to skb_orphan_frags to deliver_skb and __netif_receive_skb.

With msg_zerocopy, these skbs can also exist in the tx path and thus loop from dev_queue_xmit_nit. This already calls deliver_skb in its loop. But it does not orphan before a separate pt_prev->func().

Add the missing skb_orphan_frags_rx.

Fixes 1f8b977ab32d ("sock: enable MSG_ZEROCOPY")
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

net/core/dev.c void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) · line 1952

Quoted 11 lines
net/core/dev.c +1 -1
index 9a2254f9802f..3f5b26ff4f74 100644
@@ -1948,7 +1948,7 @@ void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
              goto again;
      }
 out_unlock:
-     if (pt_prev)
+     if (pt_prev && !skb_orphan_frags_rx(skb2, GFP_ATOMIC))
              pt_prev->func(skb2, skb->dev, pt_prev, skb->dev);

Don't you need to kfree_skb(skb2) in case of failure ?

Oh, yes, of course! :/ Will fix right away.