Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Daniel Turull <daniel.turull@gmail.com>
Cc: netdev@vger.kernel.org, Robert Olsson <robert@herjulf.net>,
	Jens Laas <jens.laas@its.uu.se>,
	Voravit Tanyingyong <voravit@kth.se>
Subject: Re: [PATCH] pktgen: fix transmission headers with frags=0
Date: Mon, 14 Mar 2011 14:56:17 +0100	[thread overview]
Message-ID: <1300110977.3423.16.camel@edumazet-laptop> (raw)
In-Reply-To: <4D7E167E.2090807@gmail.com>

Le lundi 14 mars 2011 à 14:22 +0100, Daniel Turull a écrit :
> The headers of pktgen were incorrectly added in a pktgen packet
> without frags (frags=0). There was an offset in the pktgen headers.
> 
> The cause was in reusing the pgh variable as a return variable in skb_put
> when adding the payload to the skb.
> 
> A rename of the variable is done.
> 
> Signed-off-by: Daniel Turull <daniel.turull@gmail.com>
> ---
> The PKTGEN magic (be9b e955) now starts in the correct offset.
> Before the patch, it was starting at the end of the packet (be9b)
> 

not exactly, but offseted  +16 bytes
(sizeof(struct pktgen_hdr))

> Capture from tcpdump:
> 
> before patch:
> 14:57:37.854812 IP 10.0.0.2.discard > 10.254.254.84.discard: UDP, length 18
> 	0x0000:  001b 2157 ed84 001b 215d 01d0 0800 4500
> 	0x0010:  002e 0004 0000 2011 8767 0a00 0002 0afe
> 	0x0020:  fe54 0009 0009 001a 0000 0000 0000 b072
> 	0x0030:  9102 00ea ffff 0010 0000 be9b
> 
> after patch:
> 14:44:32.896048 IP 10.0.0.2.discard > 10.217.234.56.discard: UDP, length 18
> 	0x0000:  001b 2157 ed84 001b 215d 01d0 0800 4500
> 	0x0010:  002e 0000 0000 2011 9bac 0a00 0002 0ad9
> 	0x0020:  ea38 0009 0009 001a 0000 be9b e955 0000
> 	0x0030:  0001 4d7e 1b09 0005 5f23 af00
> 
> ---
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index f0aec6c..5baa9d9 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -2615,13 +2615,14 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
>  {
>  	struct timeval timestamp;
>  	struct pktgen_hdr *pgh;
> +	void *data;
>  
>  	pgh = (struct pktgen_hdr *)skb_put(skb, sizeof(*pgh));
>  	datalen -= sizeof(*pgh);
>  
>  	if (pkt_dev->nfrags <= 0) {
> -		pgh = (struct pktgen_hdr *)skb_put(skb, datalen);
> -		memset(pgh + 1, 0, datalen);
> +		data = skb_put(skb, datalen);
> +		memset(data + 1, 0, datalen);
>  	} else {
>  		int frags = pkt_dev->nfrags;
>  		int i, len;
> --

Good catch !

Hmm this patch is not correct, why memset(data + 1, ...) ?

Also, this patch is needed for net-next-2.6 only
(bug introduced by commit 26ad787962ef84677a48c560
(pktgen: speedup fragmented skbs)

I would avoid the "void *data;" declaration and just use following :

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index f0aec6c..f727c83 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2620,7 +2620,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
 	datalen -= sizeof(*pgh);
 
 	if (pkt_dev->nfrags <= 0) {
-		pgh = (struct pktgen_hdr *)skb_put(skb, datalen);
+		skb_put(skb, datalen);
 		memset(pgh + 1, 0, datalen);
 	} else {
 		int frags = pkt_dev->nfrags;



or even :

		memset(skb_put(skb, datalen), 0, datalen);





  reply	other threads:[~2011-03-14 13:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-14 13:22 [PATCH] pktgen: fix transmission headers with frags=0 Daniel Turull
2011-03-14 13:56 ` Eric Dumazet [this message]
2011-03-14 14:13   ` Daniel Turull
2011-03-14 14:18     ` Eric Dumazet
2011-03-14 14:31       ` [PATCH net-next-2.6] pktgen: bug fix in " Daniel Turull
2011-03-14 14:35         ` Eric Dumazet
2011-03-14 20:47           ` 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=1300110977.3423.16.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=daniel.turull@gmail.com \
    --cc=jens.laas@its.uu.se \
    --cc=netdev@vger.kernel.org \
    --cc=robert@herjulf.net \
    --cc=voravit@kth.se \
    /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