* [PATCH net-next] net: fix skb_add_data_nocache() to calc csum correctly
@ 2011-04-07 4:40 Wei Yongjun
2011-04-07 4:50 ` Tom Herbert
0 siblings, 1 reply; 4+ messages in thread
From: Wei Yongjun @ 2011-04-07 4:40 UTC (permalink / raw)
To: David Miller, Tom Herbert, netdev@vger.kernel.org
commit c6e1a0d12ca7b4f22c58e55a16beacfb7d3d8462 broken the calc
(net: Allow no-cache copy from user on transmit)
of checksum, which may cause some tcp packets be dropped because
incorrect checksum. ssh does not work under today's net-next-2.6
tree.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
include/net/sock.h | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 43bd515..9cbf23c 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1392,14 +1392,14 @@ static inline void sk_nocaps_add(struct sock *sk, int flags)
static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
char __user *from, char *to,
- int copy)
+ int copy, int offset)
{
if (skb->ip_summed == CHECKSUM_NONE) {
int err = 0;
__wsum csum = csum_and_copy_from_user(from, to, copy, 0, &err);
if (err)
return err;
- skb->csum = csum_block_add(skb->csum, csum, skb->len);
+ skb->csum = csum_block_add(skb->csum, csum, offset);
} else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) {
if (!access_ok(VERIFY_READ, from, copy) ||
__copy_from_user_nocache(to, from, copy))
@@ -1413,11 +1413,12 @@ static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
static inline int skb_add_data_nocache(struct sock *sk, struct sk_buff *skb,
char __user *from, int copy)
{
- int err;
+ int err, offset = skb->len;
- err = skb_do_copy_data_nocache(sk, skb, from, skb_put(skb, copy), copy);
+ err = skb_do_copy_data_nocache(sk, skb, from, skb_put(skb, copy),
+ copy, offset);
if (err)
- __skb_trim(skb, skb->len);
+ __skb_trim(skb, offset);
return err;
}
@@ -1429,8 +1430,8 @@ static inline int skb_copy_to_page_nocache(struct sock *sk, char __user *from,
{
int err;
- err = skb_do_copy_data_nocache(sk, skb, from,
- page_address(page) + off, copy);
+ err = skb_do_copy_data_nocache(sk, skb, from, page_address(page) + off,
+ copy, skb->len);
if (err)
return err;
--
1.6.5.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: fix skb_add_data_nocache() to calc csum correctly
2011-04-07 4:40 [PATCH net-next] net: fix skb_add_data_nocache() to calc csum correctly Wei Yongjun
@ 2011-04-07 4:50 ` Tom Herbert
2011-04-07 6:05 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Tom Herbert @ 2011-04-07 4:50 UTC (permalink / raw)
To: Wei Yongjun; +Cc: David Miller, netdev@vger.kernel.org
Nice catch.
Acked-by: Tom Herbert <therbert@google.com>
On Wed, Apr 6, 2011 at 9:40 PM, Wei Yongjun <yjwei@cn.fujitsu.com> wrote:
> commit c6e1a0d12ca7b4f22c58e55a16beacfb7d3d8462 broken the calc
> (net: Allow no-cache copy from user on transmit)
> of checksum, which may cause some tcp packets be dropped because
> incorrect checksum. ssh does not work under today's net-next-2.6
> tree.
>
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> ---
> include/net/sock.h | 15 ++++++++-------
> 1 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 43bd515..9cbf23c 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -1392,14 +1392,14 @@ static inline void sk_nocaps_add(struct sock *sk, int flags)
>
> static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
> char __user *from, char *to,
> - int copy)
> + int copy, int offset)
> {
> if (skb->ip_summed == CHECKSUM_NONE) {
> int err = 0;
> __wsum csum = csum_and_copy_from_user(from, to, copy, 0, &err);
> if (err)
> return err;
> - skb->csum = csum_block_add(skb->csum, csum, skb->len);
> + skb->csum = csum_block_add(skb->csum, csum, offset);
> } else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) {
> if (!access_ok(VERIFY_READ, from, copy) ||
> __copy_from_user_nocache(to, from, copy))
> @@ -1413,11 +1413,12 @@ static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
> static inline int skb_add_data_nocache(struct sock *sk, struct sk_buff *skb,
> char __user *from, int copy)
> {
> - int err;
> + int err, offset = skb->len;
>
> - err = skb_do_copy_data_nocache(sk, skb, from, skb_put(skb, copy), copy);
> + err = skb_do_copy_data_nocache(sk, skb, from, skb_put(skb, copy),
> + copy, offset);
> if (err)
> - __skb_trim(skb, skb->len);
> + __skb_trim(skb, offset);
>
> return err;
> }
> @@ -1429,8 +1430,8 @@ static inline int skb_copy_to_page_nocache(struct sock *sk, char __user *from,
> {
> int err;
>
> - err = skb_do_copy_data_nocache(sk, skb, from,
> - page_address(page) + off, copy);
> + err = skb_do_copy_data_nocache(sk, skb, from, page_address(page) + off,
> + copy, skb->len);
> if (err)
> return err;
>
> --
> 1.6.5.2
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: fix skb_add_data_nocache() to calc csum correctly
2011-04-07 4:50 ` Tom Herbert
@ 2011-04-07 6:05 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-04-07 6:05 UTC (permalink / raw)
To: therbert; +Cc: yjwei, netdev
From: Tom Herbert <therbert@google.com>
Date: Wed, 6 Apr 2011 21:50:55 -0700
> Nice catch.
>
> Acked-by: Tom Herbert <therbert@google.com>
>
> On Wed, Apr 6, 2011 at 9:40 PM, Wei Yongjun <yjwei@cn.fujitsu.com> wrote:
>> commit c6e1a0d12ca7b4f22c58e55a16beacfb7d3d8462 broken the calc
>> (net: Allow no-cache copy from user on transmit)
>> of checksum, which may cause some tcp packets be dropped because
>> incorrect checksum. ssh does not work under today's net-next-2.6
>> tree.
>>
>> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Applied, thanks everyone.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: fix skb_add_data_nocache() to calc csum correctly
@ 2011-04-07 12:05 Sedat Dilek
0 siblings, 0 replies; 4+ messages in thread
From: Sedat Dilek @ 2011-04-07 12:05 UTC (permalink / raw)
To: Wei Yongjun; +Cc: David Miller, netdev, Tom Herbert
[QUOTE]
From: Tom Herbert <therbert@google.com>
Date: Wed, 6 Apr 2011 21:50:55 -0700
> Nice catch.
>
> Acked-by: Tom Herbert <therbert@google.com>
>
> On Wed, Apr 6, 2011 at 9:40 PM, Wei Yongjun <yjwei@cn.fujitsu.com> wrote:
>> commit c6e1a0d12ca7b4f22c58e55a16beacfb7d3d8462 broken the calc
>> (net: Allow no-cache copy from user on transmit)
>> of checksum, which may cause some tcp packets be dropped because
>> incorrect checksum. ssh does not work under today's net-next-2.6
>> tree.
>>
>> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Applied, thanks everyone.
[/QUOTE]
With reference to my asking in [1] feel free to add:
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
- Sedat -
[1] http://marc.info/?l=linux-netdev&m=130217337305798&w=2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-04-07 12:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-07 4:40 [PATCH net-next] net: fix skb_add_data_nocache() to calc csum correctly Wei Yongjun
2011-04-07 4:50 ` Tom Herbert
2011-04-07 6:05 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2011-04-07 12:05 Sedat Dilek
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).