Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Jamie Gloudon <jamie.gloudon@gmail.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next] net: more accurate network taps in transmit path
Date: Wed, 19 Sep 2012 08:44:49 +0200	[thread overview]
Message-ID: <1348037089.26523.397.camel@edumazet-glaptop> (raw)
In-Reply-To: <1348034050.26523.325.camel@edumazet-glaptop>

From: Eric Dumazet <edumazet@google.com>

dev_queue_xmit_nit() should be called right before ndo_start_xmit()
calls or we might give wrong packet contents to taps users :

Packet checksum can be changed, or packet can be linearized or
segmented, and segments partially sent for the later case.

Also a memory allocation can fail and packet never really hit the
driver entry point.

Reported-by: Jamie Gloudon <jamie.gloudon@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/dev.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index dcc673d..52cd1d7 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2213,9 +2213,6 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
 		if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
 			skb_dst_drop(skb);
 
-		if (!list_empty(&ptype_all))
-			dev_queue_xmit_nit(skb, dev);
-
 		features = netif_skb_features(skb);
 
 		if (vlan_tx_tag_present(skb) &&
@@ -2250,6 +2247,9 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
 			}
 		}
 
+		if (!list_empty(&ptype_all))
+			dev_queue_xmit_nit(skb, dev);
+
 		skb_len = skb->len;
 		rc = ops->ndo_start_xmit(skb, dev);
 		trace_net_dev_xmit(skb, rc, dev, skb_len);
@@ -2272,6 +2272,9 @@ gso:
 		if (dev->priv_flags & IFF_XMIT_DST_RELEASE)
 			skb_dst_drop(nskb);
 
+		if (!list_empty(&ptype_all))
+			dev_queue_xmit_nit(nskb, dev);
+
 		skb_len = nskb->len;
 		rc = ops->ndo_start_xmit(nskb, dev);
 		trace_net_dev_xmit(nskb, rc, dev, skb_len);

  reply	other threads:[~2012-09-19  6:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20120918193208.GA19030@darkstar>
     [not found] ` <1347998905.2685.29.camel@bwh-desktop.uk.solarflarecom.com>
2012-09-18 21:14   ` BUG: TCPDUMP invalid cksum persists after disabling TCP cksum offload Jamie Gloudon
2012-09-18 21:46     ` Vijay Subramanian
2012-09-18 21:54       ` Rick Jones
2012-09-18 22:20         ` Jamie Gloudon
2012-09-19  5:54     ` Eric Dumazet
2012-09-19  6:44       ` Eric Dumazet [this message]
2012-09-19 15:58         ` [PATCH net-next] net: more accurate network taps in transmit path Jamie Gloudon
2012-09-19 18:16         ` David Miller
2012-09-19 18:21           ` Eric Dumazet
2012-09-19 19:33             ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348037089.26523.397.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=jamie.gloudon@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox