[IPV6]: Fix the return value of ipv6_getsockopt
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> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
3ae412544c
commit
cf6fc4a924
@@ -1046,7 +1046,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -ENOPROTOOPT;
|
||||||
}
|
}
|
||||||
len = min_t(unsigned int, sizeof(int), len);
|
len = min_t(unsigned int, sizeof(int), len);
|
||||||
if(put_user(len, optlen))
|
if(put_user(len, optlen))
|
||||||
@@ -1069,9 +1069,8 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
|
|||||||
|
|
||||||
err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
|
err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
|
||||||
#ifdef CONFIG_NETFILTER
|
#ifdef CONFIG_NETFILTER
|
||||||
/* we need to exclude all possible EINVALs except default case */
|
/* we need to exclude all possible ENOPROTOOPTs except default case */
|
||||||
if (err == -EINVAL && optname != IPV6_ADDRFORM &&
|
if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
|
||||||
optname != MCAST_MSFILTER) {
|
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (get_user(len, optlen))
|
if (get_user(len, optlen))
|
||||||
@@ -1108,9 +1107,8 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
|
|||||||
|
|
||||||
err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
|
err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
|
||||||
#ifdef CONFIG_NETFILTER
|
#ifdef CONFIG_NETFILTER
|
||||||
/* we need to exclude all possible EINVALs except default case */
|
/* we need to exclude all possible ENOPROTOOPTs except default case */
|
||||||
if (err == -EINVAL && optname != IPV6_ADDRFORM &&
|
if (err == -ENOPROTOOPT && optname != IPV6_2292PKTOPTIONS) {
|
||||||
optname != MCAST_MSFILTER) {
|
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (get_user(len, optlen))
|
if (get_user(len, optlen))
|
||||||
|
Reference in New Issue
Block a user