Skip to contentSkip to conversation

net: orphan frags on stand-alone ptype in dev_queue_xmit_nit

PATCH In review Willem de Bruijn 3 participants 3 messages Sep 22, 2017 – Sep 23, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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 for this.

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.

Changes
v1->v2: handle skb_orphan_frags_rx failure

Fixes 1f8b977ab32d ("sock: enable MSG_ZEROCOPY")
---
 net/core/dev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/core/dev.c +6 -2
index 9a2254f9802f..588b473194a8 100644
@@ -1948,8 +1948,12 @@ void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
 		goto again;
 	}
 out_unlock:
-	if (pt_prev)
-		pt_prev->func(skb2, skb->dev, pt_prev, skb->dev);
+	if (pt_prev) {
+		if (!skb_orphan_frags_rx(skb2, GFP_ATOMIC))
+			pt_prev->func(skb2, skb->dev, pt_prev, skb->dev);
+		else
+			kfree_skb(skb2);
+	}
 	rcu_read_unlock();
 }
 EXPORT_SYMBOL_GPL(dev_queue_xmit_nit);
Signature · 1 line
2.14.1.821.g8fa685d3b7-goog
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 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 for this.

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.

Quoted 8 lines

Changes
v1->v2: handle skb_orphan_frags_rx failure

Fixes 1f8b977ab32d ("sock: enable MSG_ZEROCOPY")
---
 net/core/dev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
maintainer
#2 lore raw
In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>
Date: Fri, 22 Sep 2017 19:42:37 -0400

Quoted 8 lines

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 for this.

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().

Quoted 7 lines

Add the missing skb_orphan_frags_rx.

Changes
v1->v2: handle skb_orphan_frags_rx failure

Fixes 1f8b977ab32d ("sock: enable MSG_ZEROCOPY")

Applied and queued up for -stable, thanks.