diff mbox

ipv6:remove useless check

Message ID 49E3EC04.5000105@cn.fujitsu.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Yang Hongyang April 14, 2009, 1:51 a.m. UTC
After switch (rthdr->type) {...},the check below is completely useless.Because:
if the type is 2,then hdrlen must be 2 and segments_left must be 1,clearly the
check is redundant;if the type is not 2,then goto sticky_done,the check is useless
too.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>

---
 net/ipv6/ipv6_sockglue.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

Comments

Shan Wei April 14, 2009, 3:31 a.m. UTC | #1
Yang Hongyang said:
> After switch (rthdr->type) {...},the check below is completely useless.Because:
> if the type is 2,then hdrlen must be 2 and segments_left must be 1,clearly the
> check is redundant;if the type is not 2,then goto sticky_done,the check is useless
> too.
> 

Add CC  Brian Haley.

The check is defined only for Type 0 Routing header in section 4.4 of RFC2460: 

   Hdr Ext Len          8-bit unsigned integer.  Length of the Routing
                        header in 8-octet units, not including the first
                        8 octets.  For the Type 0 Routing header, Hdr
                        Ext Len is equal to two times the number of
                        addresses in the header.

Now, Type 0 Routing header has been removed, the check is redundant.

Reviewed-by: Shan Wei <shanwei@cn.fujitsu.com>

> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
> 
> ---
>  net/ipv6/ipv6_sockglue.c |    4 ----
>  1 files changed, 0 insertions(+), 4 deletions(-)
> 
> diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
> index d31df0f..a7fdf9a 100644
> --- a/net/ipv6/ipv6_sockglue.c
> +++ b/net/ipv6/ipv6_sockglue.c
> @@ -380,10 +380,6 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
>  			default:
>  				goto sticky_done;
>  			}
> -
> -			if ((rthdr->hdrlen & 1) ||
> -			    (rthdr->hdrlen >> 1) != rthdr->segments_left)
> -				goto sticky_done;
>  		}
>  
>  		retv = 0;
David Miller April 14, 2009, 9:22 a.m. UTC | #2
From: Shan Wei <shanwei@cn.fujitsu.com>
Date: Tue, 14 Apr 2009 11:31:40 +0800

> Yang Hongyang said:
>> After switch (rthdr->type) {...},the check below is completely useless.Because:
>> if the type is 2,then hdrlen must be 2 and segments_left must be 1,clearly the
>> check is redundant;if the type is not 2,then goto sticky_done,the check is useless
>> too.
>> 
> 
> Add CC  Brian Haley.
> 
> The check is defined only for Type 0 Routing header in section 4.4 of RFC2460: 
> 
>    Hdr Ext Len          8-bit unsigned integer.  Length of the Routing
>                         header in 8-octet units, not including the first
>                         8 octets.  For the Type 0 Routing header, Hdr
>                         Ext Len is equal to two times the number of
>                         addresses in the header.
> 
> Now, Type 0 Routing header has been removed, the check is redundant.
> 
> Reviewed-by: Shan Wei <shanwei@cn.fujitsu.com>
> 
>> Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>

Applied, thanks everyone.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index d31df0f..a7fdf9a 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -380,10 +380,6 @@  static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 			default:
 				goto sticky_done;
 			}
-
-			if ((rthdr->hdrlen & 1) ||
-			    (rthdr->hdrlen >> 1) != rthdr->segments_left)
-				goto sticky_done;
 		}
 
 		retv = 0;