aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/ipv6_sockglue.c
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-06-11 14:27:26 -0400
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2008-06-11 20:19:09 -0400
commit1717699cd5130009b7cd6756e883d8582c1fe706 (patch)
tree884f77b16c05578522eb4d8ad8d585eb008df60d /net/ipv6/ipv6_sockglue.c
parent28d4488216645cd71402925cffde9528b0cfdb7e (diff)
ipv6: Fail with appropriate error code when setting not-applicable sockopt.
IPV6_MULTICAST_HOPS, for example, is not valid for stream sockets. Since they are virtually unavailable for stream sockets, we should return ENOPROTOOPT instead of EINVAL. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net/ipv6/ipv6_sockglue.c')
-rw-r--r--net/ipv6/ipv6_sockglue.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 9a3697172d5e..c042ce19bd14 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -67,7 +67,7 @@ int ip6_ra_control(struct sock *sk, int sel, void (*destructor)(struct sock *))
67 67
68 /* RA packet may be delivered ONLY to IPPROTO_RAW socket */ 68 /* RA packet may be delivered ONLY to IPPROTO_RAW socket */
69 if (sk->sk_type != SOCK_RAW || inet_sk(sk)->num != IPPROTO_RAW) 69 if (sk->sk_type != SOCK_RAW || inet_sk(sk)->num != IPPROTO_RAW)
70 return -EINVAL; 70 return -ENOPROTOOPT;
71 71
72 new_ra = (sel>=0) ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL; 72 new_ra = (sel>=0) ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL;
73 73
@@ -446,7 +446,7 @@ done:
446 446
447 case IPV6_MULTICAST_HOPS: 447 case IPV6_MULTICAST_HOPS:
448 if (sk->sk_type == SOCK_STREAM) 448 if (sk->sk_type == SOCK_STREAM)
449 goto e_inval; 449 break;
450 if (optlen < sizeof(int)) 450 if (optlen < sizeof(int))
451 goto e_inval; 451 goto e_inval;
452 if (val > 255 || val < -1) 452 if (val > 255 || val < -1)
@@ -466,7 +466,7 @@ done:
466 466
467 case IPV6_MULTICAST_IF: 467 case IPV6_MULTICAST_IF:
468 if (sk->sk_type == SOCK_STREAM) 468 if (sk->sk_type == SOCK_STREAM)
469 goto e_inval; 469 break;
470 if (optlen < sizeof(int)) 470 if (optlen < sizeof(int))
471 goto e_inval; 471 goto e_inval;
472 472
@@ -862,7 +862,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
862 if (sk->sk_protocol != IPPROTO_UDP && 862 if (sk->sk_protocol != IPPROTO_UDP &&
863 sk->sk_protocol != IPPROTO_UDPLITE && 863 sk->sk_protocol != IPPROTO_UDPLITE &&
864 sk->sk_protocol != IPPROTO_TCP) 864 sk->sk_protocol != IPPROTO_TCP)
865 return -EINVAL; 865 return -ENOPROTOOPT;
866 if (sk->sk_state != TCP_ESTABLISHED) 866 if (sk->sk_state != TCP_ESTABLISHED)
867 return -ENOTCONN; 867 return -ENOTCONN;
868 val = sk->sk_family; 868 val = sk->sk_family;