[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>

authored by Flavio Leitner and committed by David S. Miller a96fb49b 36d98d3e

+8
+4
net/ipv4/ip_sockglue.c
··· 625 { 626 struct ip_mreqn mreq; 627 628 if (optlen < sizeof(struct ip_mreq)) 629 goto e_inval; 630 err = -EFAULT;
··· 625 { 626 struct ip_mreqn mreq; 627 628 + err = -EPROTO; 629 + if (inet_sk(sk)->is_icsk) 630 + break; 631 + 632 if (optlen < sizeof(struct ip_mreq)) 633 goto e_inval; 634 err = -EFAULT;
+4
net/ipv6/ipv6_sockglue.c
··· 554 { 555 struct ipv6_mreq mreq; 556 557 retv = -EFAULT; 558 if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq))) 559 break;
··· 554 { 555 struct ipv6_mreq mreq; 556 557 + retv = -EPROTO; 558 + if (inet_sk(sk)->is_icsk) 559 + break; 560 + 561 retv = -EFAULT; 562 if (copy_from_user(&mreq, optval, sizeof(struct ipv6_mreq))) 563 break;