Skip to content

Commit f5220d6

Browse files
pqarmitagedavem330
authored andcommitted
ipv4: Make IP_MULTICAST_ALL and IP_MSFILTER work on raw sockets
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> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 92bab4e commit f5220d6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎net/ipv4/raw.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include <linux/in_route.h>
5959
#include <linux/route.h>
6060
#include <linux/skbuff.h>
61+
#include <linux/igmp.h>
6162
#include <net/net_namespace.h>
6263
#include <net/dst.h>
6364
#include <net/sock.h>
@@ -174,7 +175,9 @@ static int raw_v4_input(struct sk_buff *skb, const struct iphdr *iph, int hash)
174175

175176
while (sk) {
176177
delivered = 1;
177-
if (iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) {
178+
if ((iph->protocol != IPPROTO_ICMP || !icmp_filter(sk, skb)) &&
179+
ip_mc_sf_allow(sk, iph->daddr, iph->saddr,
180+
skb->dev->ifindex)) {
178181
struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC);
179182

180183
/* Not releasing hash table! */

0 commit comments

Comments
 (0)