diff mbox

Natty SRU: ipv6: restore correct ECN handling on TCP xmit

Message ID 20111011093507.8CAB1F88CF@lochsa.rtg.net
State New
Headers show

Commit Message

Tim Gardner Oct. 11, 2011, 9:35 a.m. UTC
From d8130742ea8e3c0f8f4a3fca3db54f16e335b443 Mon Sep 17 00:00:00 2001
From: Steinar H. Gunderson <sgunderson@bigfoot.com>
Date: Fri, 6 May 2011 23:44:46 +0000
Subject: [PATCH] ipv6: restore correct ECN handling on TCP xmit

BugLink: http://bugs.launchpad.net/bugs/872179

Since commit e9df2e8fd8fbc9 (Use appropriate sock tclass setting for
routing lookup) we lost ability to properly add ECN codemarks to ipv6
TCP frames.

It seems like TCP_ECN_send() calls INET_ECN_xmit(), which only sets the
ECN bit in the IPv4 ToS field (inet_sk(sk)->tos), but after the patch,
what's checked is inet6_sk(sk)->tclass, which is a completely different
field.

Close bug https://bugzilla.kernel.org/show_bug.cgi?id=34322

[Eric Dumazet] : added the INET_ECN_dontxmit() fix and replace macros
by inline functions for clarity.

Signed-off-by: Steinar H. Gunderson <sgunderson@bigfoot.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit ca06707022d6ba4744198a8ebbe4994786b0c613)

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 include/net/inet_ecn.h |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

Comments

Stefan Bader Oct. 11, 2011, 10:06 a.m. UTC | #1
On 11.10.2011 10:35, Tim Gardner wrote:
> From d8130742ea8e3c0f8f4a3fca3db54f16e335b443 Mon Sep 17 00:00:00 2001
> From: Steinar H. Gunderson <sgunderson@bigfoot.com>
> Date: Fri, 6 May 2011 23:44:46 +0000
> Subject: [PATCH] ipv6: restore correct ECN handling on TCP xmit
> 
> BugLink: http://bugs.launchpad.net/bugs/872179
> 
> Since commit e9df2e8fd8fbc9 (Use appropriate sock tclass setting for
> routing lookup) we lost ability to properly add ECN codemarks to ipv6
> TCP frames.
> 
> It seems like TCP_ECN_send() calls INET_ECN_xmit(), which only sets the
> ECN bit in the IPv4 ToS field (inet_sk(sk)->tos), but after the patch,
> what's checked is inet6_sk(sk)->tclass, which is a completely different
> field.
> 
> Close bug https://bugzilla.kernel.org/show_bug.cgi?id=34322
> 
> [Eric Dumazet] : added the INET_ECN_dontxmit() fix and replace macros
> by inline functions for clarity.
> 
> Signed-off-by: Steinar H. Gunderson <sgunderson@bigfoot.com>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> (cherry picked from commit ca06707022d6ba4744198a8ebbe4994786b0c613)
> 
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  include/net/inet_ecn.h |   16 +++++++++++++---
>  1 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
> index 88bdd01..2fa8d13 100644
> --- a/include/net/inet_ecn.h
> +++ b/include/net/inet_ecn.h
> @@ -38,9 +38,19 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
>  	return outer;
>  }
>  
> -#define	INET_ECN_xmit(sk) do { inet_sk(sk)->tos |= INET_ECN_ECT_0; } while (0)
> -#define	INET_ECN_dontxmit(sk) \
> -	do { inet_sk(sk)->tos &= ~INET_ECN_MASK; } while (0)
> +static inline void INET_ECN_xmit(struct sock *sk)
> +{
> +	inet_sk(sk)->tos |= INET_ECN_ECT_0;
> +	if (inet6_sk(sk) != NULL)
> +		inet6_sk(sk)->tclass |= INET_ECN_ECT_0;
> +}
> +
> +static inline void INET_ECN_dontxmit(struct sock *sk)
> +{
> +	inet_sk(sk)->tos &= ~INET_ECN_MASK;
> +	if (inet6_sk(sk) != NULL)
> +		inet6_sk(sk)->tclass &= ~INET_ECN_MASK;
> +}
>  
>  #define IP6_ECN_flow_init(label) do {		\
>        (label) &= ~htonl(INET_ECN_MASK << 20);	\

Looks to be in accordance to the description and clean pick.

Acked-by: Stefan Bader <smb@canonical.com>
Leann Ogasawara Oct. 11, 2011, 3:57 p.m. UTC | #2
On Tue, 2011-10-11 at 03:35 -0600, Tim Gardner wrote:
> From d8130742ea8e3c0f8f4a3fca3db54f16e335b443 Mon Sep 17 00:00:00 2001
> From: Steinar H. Gunderson <sgunderson@bigfoot.com>
> Date: Fri, 6 May 2011 23:44:46 +0000
> Subject: [PATCH] ipv6: restore correct ECN handling on TCP xmit
> 
> BugLink: http://bugs.launchpad.net/bugs/872179
> 
> Since commit e9df2e8fd8fbc9 (Use appropriate sock tclass setting for
> routing lookup) we lost ability to properly add ECN codemarks to ipv6
> TCP frames.
> 
> It seems like TCP_ECN_send() calls INET_ECN_xmit(), which only sets the
> ECN bit in the IPv4 ToS field (inet_sk(sk)->tos), but after the patch,
> what's checked is inet6_sk(sk)->tclass, which is a completely different
> field.
> 
> Close bug https://bugzilla.kernel.org/show_bug.cgi?id=34322
> 
> [Eric Dumazet] : added the INET_ECN_dontxmit() fix and replace macros
> by inline functions for clarity.
> 
> Signed-off-by: Steinar H. Gunderson <sgunderson@bigfoot.com>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> (cherry picked from commit ca06707022d6ba4744198a8ebbe4994786b0c613)
> 
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>

Acked-by: Leann Ogasawara <leann.ogasawara@canonical.com>

> ---
>  include/net/inet_ecn.h |   16 +++++++++++++---
>  1 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
> index 88bdd01..2fa8d13 100644
> --- a/include/net/inet_ecn.h
> +++ b/include/net/inet_ecn.h
> @@ -38,9 +38,19 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
>  	return outer;
>  }
>  
> -#define	INET_ECN_xmit(sk) do { inet_sk(sk)->tos |= INET_ECN_ECT_0; } while (0)
> -#define	INET_ECN_dontxmit(sk) \
> -	do { inet_sk(sk)->tos &= ~INET_ECN_MASK; } while (0)
> +static inline void INET_ECN_xmit(struct sock *sk)
> +{
> +	inet_sk(sk)->tos |= INET_ECN_ECT_0;
> +	if (inet6_sk(sk) != NULL)
> +		inet6_sk(sk)->tclass |= INET_ECN_ECT_0;
> +}
> +
> +static inline void INET_ECN_dontxmit(struct sock *sk)
> +{
> +	inet_sk(sk)->tos &= ~INET_ECN_MASK;
> +	if (inet6_sk(sk) != NULL)
> +		inet6_sk(sk)->tclass &= ~INET_ECN_MASK;
> +}
>  
>  #define IP6_ECN_flow_init(label) do {		\
>        (label) &= ~htonl(INET_ECN_MASK << 20);	\
> -- 
> 1.7.0.4
> 
>
Tim Gardner Oct. 11, 2011, 5:18 p.m. UTC | #3
On 10/11/2011 10:35 AM, Tim Gardner wrote:
>  From d8130742ea8e3c0f8f4a3fca3db54f16e335b443 Mon Sep 17 00:00:00 2001
> From: Steinar H. Gunderson<sgunderson@bigfoot.com>
> Date: Fri, 6 May 2011 23:44:46 +0000
> Subject: [PATCH] ipv6: restore correct ECN handling on TCP xmit
>
> BugLink: http://bugs.launchpad.net/bugs/872179
>
> Since commit e9df2e8fd8fbc9 (Use appropriate sock tclass setting for
> routing lookup) we lost ability to properly add ECN codemarks to ipv6
> TCP frames.
>
> It seems like TCP_ECN_send() calls INET_ECN_xmit(), which only sets the
> ECN bit in the IPv4 ToS field (inet_sk(sk)->tos), but after the patch,
> what's checked is inet6_sk(sk)->tclass, which is a completely different
> field.
>
> Close bug https://bugzilla.kernel.org/show_bug.cgi?id=34322
>
> [Eric Dumazet] : added the INET_ECN_dontxmit() fix and replace macros
> by inline functions for clarity.
>
> Signed-off-by: Steinar H. Gunderson<sgunderson@bigfoot.com>
> Signed-off-by: Eric Dumazet<eric.dumazet@gmail.com>
> Cc: YOSHIFUJI Hideaki<yoshfuji@linux-ipv6.org>
> Cc: Andrew Morton<akpm@linux-foundation.org>
> Signed-off-by: David S. Miller<davem@davemloft.net>
> (cherry picked from commit ca06707022d6ba4744198a8ebbe4994786b0c613)
>
> Signed-off-by: Tim Gardner<tim.gardner@canonical.com>
> ---
>   include/net/inet_ecn.h |   16 +++++++++++++---
>   1 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
> index 88bdd01..2fa8d13 100644
> --- a/include/net/inet_ecn.h
> +++ b/include/net/inet_ecn.h
> @@ -38,9 +38,19 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
>   	return outer;
>   }
>
> -#define	INET_ECN_xmit(sk) do { inet_sk(sk)->tos |= INET_ECN_ECT_0; } while (0)
> -#define	INET_ECN_dontxmit(sk) \
> -	do { inet_sk(sk)->tos&= ~INET_ECN_MASK; } while (0)
> +static inline void INET_ECN_xmit(struct sock *sk)
> +{
> +	inet_sk(sk)->tos |= INET_ECN_ECT_0;
> +	if (inet6_sk(sk) != NULL)
> +		inet6_sk(sk)->tclass |= INET_ECN_ECT_0;
> +}
> +
> +static inline void INET_ECN_dontxmit(struct sock *sk)
> +{
> +	inet_sk(sk)->tos&= ~INET_ECN_MASK;
> +	if (inet6_sk(sk) != NULL)
> +		inet6_sk(sk)->tclass&= ~INET_ECN_MASK;
> +}
>
>   #define IP6_ECN_flow_init(label) do {		\
>         (label)&= ~htonl(INET_ECN_MASK<<  20);	\
diff mbox

Patch

diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index 88bdd01..2fa8d13 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -38,9 +38,19 @@  static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
 	return outer;
 }
 
-#define	INET_ECN_xmit(sk) do { inet_sk(sk)->tos |= INET_ECN_ECT_0; } while (0)
-#define	INET_ECN_dontxmit(sk) \
-	do { inet_sk(sk)->tos &= ~INET_ECN_MASK; } while (0)
+static inline void INET_ECN_xmit(struct sock *sk)
+{
+	inet_sk(sk)->tos |= INET_ECN_ECT_0;
+	if (inet6_sk(sk) != NULL)
+		inet6_sk(sk)->tclass |= INET_ECN_ECT_0;
+}
+
+static inline void INET_ECN_dontxmit(struct sock *sk)
+{
+	inet_sk(sk)->tos &= ~INET_ECN_MASK;
+	if (inet6_sk(sk) != NULL)
+		inet6_sk(sk)->tclass &= ~INET_ECN_MASK;
+}
 
 #define IP6_ECN_flow_init(label) do {		\
       (label) &= ~htonl(INET_ECN_MASK << 20);	\