LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: toshiharu-linux@dsn.okisemi.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	qi.wang@intel.com, yong.y.wang@intel.com,
	andrew.chih.howe.khor@intel.com, joel.clark@intel.com,
	kok.howg.ewe@intel.com
Subject: Re: [PATCH] pch_gbe: Fix the issue that the receiving data is not normal.
Date: Tue, 25 Jan 2011 13:32:40 -0800 (PST)	[thread overview]
Message-ID: <20110125.133240.59688304.davem@davemloft.net> (raw)
In-Reply-To: <4D3D0373.30003@dsn.okisemi.com>

From: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>
Date: Mon, 24 Jan 2011 13:43:31 +0900

> This PCH_GBE driver had an issue that the receiving data is not normal.
> This driver had not removed correctly the padding data 
> which the DMA include in receiving data. 
> 
> This patch fixed this issue.
> 
> Signed-off-by: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>

There are bugs in these changes:

>  			if (skb_copy_flag) {	/* recycle  skb */
>  				struct sk_buff *new_skb;
>  				new_skb =
> -				    netdev_alloc_skb(netdev,
> -						     length + NET_IP_ALIGN);
> +				    netdev_alloc_skb(netdev, length);
>  				if (new_skb) {
>  					if (!skb_padding_flag) {
>  						skb_reserve(new_skb,
> -								NET_IP_ALIGN);
> +							PCH_GBE_DMA_PADDING);
>  					}
>  					memcpy(new_skb->data, skb->data,
>  						length);

If "!skb_padding_flag" then you will write past the end of the SKB
data in that memcpy.

You cannot allocate only "length" then proceed to reserve PCH_GBE_DMA_PADDING
and then add "length" worth of data on top of that.  In such a cause you
must allocate at least "length + PCH_GBE_DMA_PADDING".

Furthermore you _MUST_ respect NET_IP_ALIGN.  Some platforms set this value
to "0", because otherwise performance suffers greatly.

There are two seperate issues, removing the padding bytes provided by
the device, and aligning the IP headers as wanted by the cpu
architecutre.  Therefore they should be handled seperately, and we
therefore should still see references to NET_IP_ALIGN in your patch.

  reply	other threads:[~2011-01-25 21:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24  4:43 Toshiharu Okada
2011-01-25 21:32 ` David Miller [this message]
2011-01-27  8:45   ` Toshiharu Okada
2011-02-08  8:24 Toshiharu Okada
2011-02-09  0:35 ` David Miller
2011-02-09  4:58   ` Toshiharu Okada

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=20110125.133240.59688304.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=andrew.chih.howe.khor@intel.com \
    --cc=joel.clark@intel.com \
    --cc=kok.howg.ewe@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=qi.wang@intel.com \
    --cc=toshiharu-linux@dsn.okisemi.com \
    --cc=yong.y.wang@intel.com \
    --subject='Re: [PATCH] pch_gbe: Fix the issue that the receiving data is not normal.' \
    /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

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