Skip to contentSkip to conversation

ipv6:remove useless check

PATCH Applied Yang Hongyang 3 participants 3 messages Apr 14, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6:remove useless check

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.

---
 net/ipv6/ipv6_sockglue.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
net/ipv6/ipv6_sockglue.c +0 -4
index d31df0f..a7fdf9a 100644
@@ -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;
Signature · 5 lines
1.6.0.3

-- 
Regards
Yang Hongyang
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Yang Hongyang

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.

Quoted 21 lines
---
 net/ipv6/ipv6_sockglue.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
net/ipv6/ipv6_sockglue.c +0 -4
index d31df0f..a7fdf9a 100644
@@ -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;
Signature · 2 lines
Best Regards
Shan Wei
maintainer Applied
#2 lore raw

From: Shan Wei <[email protected]>
Date: Tue, 14 Apr 2009 11:31:40 +0800

Quoted 17 lines
Quoted 5 lines · Yang Hongyang

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.

Quoted 5 lines

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

Quoted 1 line

Applied, thanks everyone.