Subject: [PATCH] IPv6: Fail with appropriate error code when sending RH0

From: Shan Wei <[email-masked]>
Date: Fri, 27 Jun 2008 12:28:52 +0800

When sending IPv6 packet with RH0(Type 0 Routing Header),
return EINVAL instead of EPERM.

Signed-off-by: Shan Wei<[email-masked]>
---
 net/ipv6/ipv6_sockglue.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 86e28a7..0101d4f 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -377,12 +377,15 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 				break;
 #endif
 			default:
+				retv = -EINVAL;
 				goto sticky_done;
 			}
 
 			if ((rthdr->hdrlen & 1) ||
-			    (rthdr->hdrlen >> 1) != rthdr->segments_left)
+			    (rthdr->hdrlen >> 1) != rthdr->segments_left) {
+				retv = -EINVAL;
 				goto sticky_done;
+			}
 		}
 
 		retv = 0;
-- 
1.5.4.4