netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@plumgrid.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org
Subject: [PATCH net-next] pktgen: fix packet generation
Date: Mon, 11 May 2015 15:19:48 -0700	[thread overview]
Message-ID: <1431382788-6051-1-git-send-email-ast@plumgrid.com> (raw)

pkt_gen->last_ok was not set properly, so after the first burst
pktgen instead of allocating new packet, will reuse old one, advance
eth_type_trans further, which would mean the stack will be seeing very
short bogus packets.

Fixes: 62f64aed622b ("pktgen: introduce xmit_mode '<start_xmit|netif_receive>'")
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
---
This bug slipped through due to all code refactoring and can be seen
after clean reboot. If taps, rps or tx mode was used at least once,
the bug will be hidden.

Note to users: if you don't see ip_rcv() in your perf profile, it means
you were hitting this.
As commit log of 62f64aed622b is saying, the baseline perf profile
should look like:
   37.69%  kpktgend_0   [kernel.vmlinux]  [k] __netif_receive_skb_core
   25.81%  kpktgend_0   [kernel.vmlinux]  [k] kfree_skb
    7.22%  kpktgend_0   [kernel.vmlinux]  [k] ip_rcv
    5.68%  kpktgend_0   [pktgen]          [k] pktgen_thread_worker

Jesper, that explains why you were seeing hot:
atomic_long_inc(&skb->dev->rx_dropped);

Only my V1 version was correct in this regard. V2 and above had this
latent bug. Sorry about that.

 net/core/pktgen.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8f2687da058e..62f979984a23 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1189,6 +1189,16 @@ static ssize_t pktgen_if_write(struct file *file,
 				return -ENOTSUPP;
 
 			pkt_dev->xmit_mode = M_NETIF_RECEIVE;
+
+			/* make sure new packet is allocated every time
+			 * pktgen_xmit() is called
+			 */
+			pkt_dev->last_ok = 1;
+
+			/* override clone_skb if user passed default value
+			 * at module loading time
+			 */
+			pkt_dev->clone_skb = 0;
 		} else {
 			sprintf(pg_result,
 				"xmit_mode -:%s:- unknown\nAvailable modes: %s",
@@ -3415,7 +3425,6 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
 				/* get out of the loop and wait
 				 * until skb is consumed
 				 */
-				pkt_dev->last_ok = 1;
 				break;
 			}
 			/* skb was 'freed' by stack, so clean few
-- 
1.7.9.5

             reply	other threads:[~2015-05-11 22:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11 22:19 Alexei Starovoitov [this message]
2015-05-12  8:19 ` [PATCH net-next] pktgen: fix packet generation Jesper Dangaard Brouer
2015-05-12 15:49   ` Alexei Starovoitov
2015-05-13  3:10 ` 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=1431382788-6051-1-git-send-email-ast@plumgrid.com \
    --to=ast@plumgrid.com \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.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;
as well as URLs for NNTP newsgroup(s).