From owner-freebsd-net@FreeBSD.ORG Wed Sep 9 21:11:29 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1BA70106566B for ; Wed, 9 Sep 2009 21:11:29 +0000 (UTC) (envelope-from stef-list@memberwebs.com) Received: from mail.npubs.com (mail.npubs.com [74.82.45.72]) by mx1.freebsd.org (Postfix) with ESMTP id 0B92B8FC16 for ; Wed, 9 Sep 2009 21:11:28 +0000 (UTC) Resent-Message-Id: From: Stef Walter User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: "freebsd-net@FreeBSD.org" Content-Type: multipart/mixed; boundary="------------090905060408000505030902" X-Virus-Scanned: ClamAV using ClamSMTP Resent-Date: Wed, 9 Sep 2009 21:11:29 +0000 (UTC) Resent-From: stef-list@memberwebs.com Subject: [patch] Multicast: uninited memory used in filter at IP_DROP_MEMBERSHIP + IP_ADD_MEMBERSHIP X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: stef@memberwebs.com List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Wed, 09 Sep 2009 21:11:29 -0000 X-List-Received-Date: Wed, 09 Sep 2009 21:11:29 -0000 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--