mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 16:01:14 +07:00
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>
This commit is contained in:
parent
28d4488216
commit
1717699cd5
@ -67,7 +67,7 @@ int ip6_ra_control(struct sock *sk, int sel, void (*destructor)(struct sock *))
|
||||
|
||||
/* RA packet may be delivered ONLY to IPPROTO_RAW socket */
|
||||
if (sk->sk_type != SOCK_RAW || inet_sk(sk)->num != IPPROTO_RAW)
|
||||
return -EINVAL;
|
||||
return -ENOPROTOOPT;
|
||||
|
||||
new_ra = (sel>=0) ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL;
|
||||
|
||||
@ -446,7 +446,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
|
||||
|
||||
case IPV6_MULTICAST_HOPS:
|
||||
if (sk->sk_type == SOCK_STREAM)
|
||||
goto e_inval;
|
||||
break;
|
||||
if (optlen < sizeof(int))
|
||||
goto e_inval;
|
||||
if (val > 255 || val < -1)
|
||||
@ -466,7 +466,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
|
||||
|
||||
case IPV6_MULTICAST_IF:
|
||||
if (sk->sk_type == SOCK_STREAM)
|
||||
goto e_inval;
|
||||
break;
|
||||
if (optlen < sizeof(int))
|
||||
goto e_inval;
|
||||
|
||||
@ -862,7 +862,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
|
||||
if (sk->sk_protocol != IPPROTO_UDP &&
|
||||
sk->sk_protocol != IPPROTO_UDPLITE &&
|
||||
sk->sk_protocol != IPPROTO_TCP)
|
||||
return -EINVAL;
|
||||
return -ENOPROTOOPT;
|
||||
if (sk->sk_state != TCP_ESTABLISHED)
|
||||
return -ENOTCONN;
|
||||
val = sk->sk_family;
|
||||
|
Loading…
Reference in New Issue
Block a user