netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IPv6: Fix the return value of ipv6_getsockopt
@ 2007-12-13  5:44 Wei Yongjun
  2007-12-16 21:40 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2007-12-13  5:44 UTC (permalink / raw)
  To: netdev

If CONFIG_NETFILTER if not selected when compile the kernel source code, 
ipv6_getsockopt will returen an EINVAL error if optname is not supported by
the kernel. But if CONFIG_NETFILTER is selected, ENOPROTOOPT error will 
be return.
This patch fix to always return ENOPROTOOPT error if optname argument of 
ipv6_getsockopt is not supported by the kernel.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>

--- a/net/ipv6/ipv6_sockglue.c	2007-12-11 04:33:00.000000000 -0500
+++ b/net/ipv6/ipv6_sockglue.c	2007-12-11 06:40:18.000000000 -0500
@@ -1046,7 +1046,7 @@ static int do_ipv6_getsockopt(struct soc
 		break;
 
 	default:
-		return -EINVAL;
+		return -ENOPROTOOPT;
 	}
 	len = min_t(unsigned int, sizeof(int), len);
 	if(put_user(len, optlen))
@@ -1069,9 +1069,8 @@ int ipv6_getsockopt(struct sock *sk, int
 
 	err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
 #ifdef CONFIG_NETFILTER
-	/* we need to exclude all possible EINVALs except default case */
-	if (err == -EINVAL && optname != IPV6_ADDRFORM &&
-			optname != MCAST_MSFILTER) {
+	/* we need to exclude all possible ENOPROTOOPTs except default case */
+	if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
 		int len;
 
 		if (get_user(len, optlen))
@@ -1108,9 +1107,8 @@ int compat_ipv6_getsockopt(struct sock *
 
 	err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
 #ifdef CONFIG_NETFILTER
-	/* we need to exclude all possible EINVALs except default case */
-	if (err == -EINVAL && optname != IPV6_ADDRFORM &&
-			optname != MCAST_MSFILTER) {
+	/* we need to exclude all possible ENOPROTOOPTs except default case */
+	if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
 		int len;
 
 		if (get_user(len, optlen))




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] IPv6: Fix the return value of ipv6_getsockopt
  2007-12-13  5:44 [PATCH] IPv6: Fix the return value of ipv6_getsockopt Wei Yongjun
@ 2007-12-16 21:40 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-12-16 21:40 UTC (permalink / raw)
  To: yjwei; +Cc: netdev

From: Wei Yongjun <yjwei@cn.fujitsu.com>
Date: Thu, 13 Dec 2007 14:44:00 +0900

> If CONFIG_NETFILTER if not selected when compile the kernel source code, 
> ipv6_getsockopt will returen an EINVAL error if optname is not supported by
> the kernel. But if CONFIG_NETFILTER is selected, ENOPROTOOPT error will 
> be return.
> This patch fix to always return ENOPROTOOPT error if optname argument of 
> ipv6_getsockopt is not supported by the kernel.
> 
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>

Patch applied to net-2.6, thanks for this bug fix.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-16 21:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-13  5:44 [PATCH] IPv6: Fix the return value of ipv6_getsockopt Wei Yongjun
2007-12-16 21:40 ` David Miller

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).