Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 09 Sep 2009 21:11:29 -0000
From:      Stef Walter <stef-list@memberwebs.com>
To:        "freebsd-net@FreeBSD.org" <freebsd-net@freebsd.org>
Subject:   [patch] Multicast: uninited memory used in filter at IP_DROP_MEMBERSHIP + IP_ADD_MEMBERSHIP
Resent-Message-ID: <none>

| raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------090905060408000505030902
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

If a multicast caller does an IP_DROP_MEMBERSHIP followed by a
IP_ADD_MEMBERSHIP, often an uninitialized filter is used for the
in_mfilter passed to in_joingroup_locked() in netinet/in_mcast.c.

The IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP have simple in_mreq input,
and are not using SSM or any of the new IGMPv3 features.

This results in the following behavior shown by ifmcstat. Before the
drop + add you can see the following groups for the northstar1
interface. Note that 224.0.0.5 (ie: OSPF-ALL.MCAST.NET) is subscribed
with an empty exclude filter as you would expect from simple ASM mode:

> # ifmcstat -i northstar1
> northstar1:
> 	inet 172.28.1.66
> 	igmpv3 flags=0<> rv 2 qi 125 qri 10 uri 3
> 		group 224.0.0.5 mode exclude
> 		group 224.0.0.1 mode exclude

After the drop + add, it looks like the following. Note that now
224.0.0.5 is subscribed with an empty *include* filter which results in
no packets received.

> # ifmcstat -i northstar1
> northstar1:
> 	inet 172.28.1.66
> 	igmpv3 flags=0<> rv 2 qi 125 qri 10 uri 3
> 		group 224.0.0.1 mode exclude
> 		group 224.0.0.5 mode include

uname: FreeBSD portillo-gate.ws.local 8.0-BETA3 FreeBSD 8.0-BETA3 #24:
Wed Sep  9 15:01:39 UTC 2009
root@portillo-gate.ws.local:/usr/src/sys/i386/compile/PORTILLO  i386

Patch is attached which fixes the problem. Is this the right approach?
If not, I hope it helps highlight the problem area.

Cheers,

Stef


--------------090905060408000505030902
Content-Type: text/x-diff;
 name="freebsd-mcast-uninited.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="freebsd-mcast-uninited.patch"

--- sys/netinet/in_mcast.c.orig	2009-08-03 08:13:06.000000000 +0000
+++ sys/netinet/in_mcast.c	2009-09-09 15:01:24.000000000 +0000
@@ -2024,6 +2050,9 @@
 			error = ENOMEM;
 			goto out_imo_free;
 		}
+	} else if (is_new) {
+		/* Old style ASM filter mode is always exclude */
+		imf_init(imf, MCAST_UNDEFINED, MCAST_EXCLUDE);
 	}
 
 	/*


--------------090905060408000505030902--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?>