netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make IP_MULTICAST_ALL and IP_MSFILTER work on raw sockets
@ 2014-07-18 16:38 Quentin Armitage
  2014-07-21  4:27 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Quentin Armitage @ 2014-07-18 16:38 UTC (permalink / raw)
  To: Alexey Kuznetsov, James Morris, Hideaki YOSHIFUJI,
	Patrick McHardy, netdev, David S.Miller
  Cc: linux-kernel

Currently, although IP_MULTICAST_ALL and IP_MSFILTER ioctl calls succeed on
raw sockets, there is no code to implement the functionality on received
packets; it is only implemented for UDP sockets. The raw(7) man page states:
"In addition, all ip(7) IPPROTO_IP socket options valid for datagram sockets
are supported", which implies these ioctls should work on raw sockets.

To fix this, add a call to ip_mc_sf_allow on raw sockets.

This should not break any existing code, since the current position of
not calling ip_mc_sf_filter makes it behave as if neither the IP_MULTICAST_ALL
nor the IP_MSFILTER ioctl had been called. Adding the call to ip_mc_sf_allow
will therefore maintain the current behaviour so long as IP_MULTICAST_ALL and
IP_MSFILTER ioctls are not called. Any code that currently is calling
IP_MULTICAST_ALL or IP_MSFILTER ioctls on raw sockets presumably is wanting
the filter to be applied, although no filtering will currently be occurring.

Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
---
 net/ipv4/raw.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 2c65160..2e1628c 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -58,6 +58,7 @@
 #include <linux/in_route.h>
 #include <linux/route.h>
 #include <linux/skbuff.h>
+#include <linux/igmp.h>
 #include <net/net_namespace.h>
 #include <net/dst.h>
 #include <net/sock.h>
@@ -174,7 +175,9 @@ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
 
 	while (sk) {
 		delivered = 1;
-		if (iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) {
+		if ((iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) &&
+		    ip_mc_sf_allow(sk, iph->daddr, iph->saddr,
+				   skb->dev->ifindex)) {
 			struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC);
 
 			/* Not releasing hash table! */
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make IP_MULTICAST_ALL and IP_MSFILTER work on raw sockets
  2014-07-18 16:38 [PATCH] Make IP_MULTICAST_ALL and IP_MSFILTER work on raw sockets Quentin Armitage
@ 2014-07-21  4:27 ` David Miller
  2014-07-21  8:42   ` [PATCH] ipv4: " Quentin Armitage
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2014-07-21  4:27 UTC (permalink / raw)
  To: quentin; +Cc: kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel

From: Quentin Armitage <quentin@armitage.org.uk>
Date: Fri, 18 Jul 2014 17:38:23 +0100

> Currently, although IP_MULTICAST_ALL and IP_MSFILTER ioctl calls succeed on
> raw sockets, there is no code to implement the functionality on received
> packets; it is only implemented for UDP sockets. The raw(7) man page states:
> "In addition, all ip(7) IPPROTO_IP socket options valid for datagram sockets
> are supported", which implies these ioctls should work on raw sockets.
> 
> To fix this, add a call to ip_mc_sf_allow on raw sockets.
> 
> This should not break any existing code, since the current position of
> not calling ip_mc_sf_filter makes it behave as if neither the IP_MULTICAST_ALL
> nor the IP_MSFILTER ioctl had been called. Adding the call to ip_mc_sf_allow
> will therefore maintain the current behaviour so long as IP_MULTICAST_ALL and
> IP_MSFILTER ioctls are not called. Any code that currently is calling
> IP_MULTICAST_ALL or IP_MSFILTER ioctls on raw sockets presumably is wanting
> the filter to be applied, although no filtering will currently be occurring.
> 
> Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>

Please form your subject line properly, the text should be of the form:

[PATCH] ${SUBSYSTEM}: Description.

Your's is missing the subsystem prefix, which should probable be "ipv4: "
in this case.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ipv4: Make IP_MULTICAST_ALL and IP_MSFILTER work on raw sockets
  2014-07-21  4:27 ` David Miller
@ 2014-07-21  8:42   ` Quentin Armitage
  2014-07-21 20:49     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Quentin Armitage @ 2014-07-21  8:42 UTC (permalink / raw)
  To: David Miller, kuznet, jmorris, yoshfuji, kaber, netdev; +Cc: linux-kernel

On Sun, 2014-07-20 at 21:27 -0700, David Miller wrote:
> From: Quentin Armitage <quentin@armitage.org.uk>
> Date: Fri, 18 Jul 2014 17:38:23 +0100
> 
> Currently, although IP_MULTICAST_ALL and IP_MSFILTER ioctl calls succeed on
> raw sockets, there is no code to implement the functionality on received
> packets; it is only implemented for UDP sockets. The raw(7) man page states:
> "In addition, all ip(7) IPPROTO_IP socket options valid for datagram sockets
> are supported", which implies these ioctls should work on raw sockets.
> 
> To fix this, add a call to ip_mc_sf_allow on raw sockets.
> 
> This should not break any existing code, since the current position of
> not calling ip_mc_sf_filter makes it behave as if neither the IP_MULTICAST_ALL
> nor the IP_MSFILTER ioctl had been called. Adding the call to ip_mc_sf_allow
> will therefore maintain the current behaviour so long as IP_MULTICAST_ALL and
> IP_MSFILTER ioctls are not called. Any code that currently is calling
> IP_MULTICAST_ALL or IP_MSFILTER ioctls on raw sockets presumably is wanting
> the filter to be applied, although no filtering will currently be occurring.
> 
> Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
> ---
>  net/ipv4/raw.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
> index 2c65160..2e1628c 100644
> --- a/net/ipv4/raw.c
> +++ b/net/ipv4/raw.c
> @@ -58,6 +58,7 @@
>  #include <linux/in_route.h>
>  #include <linux/route.h>
>  #include <linux/skbuff.h>
> +#include <linux/igmp.h>
>  #include <net/net_namespace.h>
>  #include <net/dst.h>
>  #include <net/sock.h>
> @@ -174,7 +175,9 @@ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
>  
>         while (sk) {
>                 delivered = 1;
> -               if (iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) {
> +               if ((iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) &&
> +                   ip_mc_sf_allow(sk, iph->daddr, iph->saddr,
> +                                  skb->dev->ifindex)) {
>                         struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC);
>  
>                         /* Not releasing hash table! */
> -- 
> 1.7.7.6
> 
> 
> 
> Please form your subject line properly, the text should be of the form:
> 
> [PATCH] ${SUBSYSTEM}: Description.
> 
> Your's is missing the subsystem prefix, which should probable be "ipv4: "
> in this case.

Subsystem ipv4: added to subject.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ipv4: Make IP_MULTICAST_ALL and IP_MSFILTER work on raw sockets
  2014-07-21  8:42   ` [PATCH] ipv4: " Quentin Armitage
@ 2014-07-21 20:49     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-07-21 20:49 UTC (permalink / raw)
  To: quentin; +Cc: kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel

From: Quentin Armitage <quentin@armitage.org.uk>
Date: Mon, 21 Jul 2014 09:42:58 +0100

> Subsystem ipv4: added to subject.

Sorry, that's not going to work.

When you are asked to make changes to any apsect of a change,
you must make a new, fresh, patch posting, with the change
integrated.

If the patch is part of a series, you must also resend the
entire series, not just the patch which has changed.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-21 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-18 16:38 [PATCH] Make IP_MULTICAST_ALL and IP_MSFILTER work on raw sockets Quentin Armitage
2014-07-21  4:27 ` David Miller
2014-07-21  8:42   ` [PATCH] ipv4: " Quentin Armitage
2014-07-21 20:49     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).