[NET]: Fix IP_ADD/DROP_MEMBERSHIP to handle only connectionless

Fix IP[V6]_ADD_MEMBERSHIP and IP[V6]_DROP_MEMBERSHIP to
return -EPROTO for connection oriented sockets.

Signed-off-by: Flavio Leitner <fleitner@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Flavio Leitner 2007-08-24 22:16:39 -07:00 committed by David S. Miller
parent 36d98d3edc
commit a96fb49be3
2 changed files with 8 additions and 0 deletions

View File

@ -625,6 +625,10 @@ static int do_ip_setsockopt(struct sock *sk, int level,
{ {
struct ip_mreqn mreq; struct ip_mreqn mreq;
err = -EPROTO;
if (inet_sk(sk)->is_icsk)
break;
if (optlen < sizeof(struct ip_mreq)) if (optlen < sizeof(struct ip_mreq))
goto e_inval; goto e_inval;
err = -EFAULT; err = -EFAULT;

View File

@ -554,6 +554,10 @@ done:
{ {
struct ipv6_mreq mreq; struct ipv6_mreq mreq;
retv = -EPROTO;
if (inet_sk(sk)->is_icsk)
break;
retv = -EFAULT; retv = -EFAULT;
if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq))) if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq)))
break; break;