From owner-freebsd-net@FreeBSD.ORG Thu May 20 06:01:02 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5344D16A4CE; Thu, 20 May 2004 06:01:02 -0700 (PDT) Received: from grosbein.pp.ru (grgw.svzserv.kemerovo.su [213.184.64.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id 345F643D46; Thu, 20 May 2004 06:00:56 -0700 (PDT) (envelope-from eugen@grosbein.pp.ru) Received: from grosbein.pp.ru (eugen@localhost [127.0.0.1]) by grosbein.pp.ru (8.12.11/8.12.11) with ESMTP id i4KD0rY1000579; Thu, 20 May 2004 21:00:53 +0800 (KRAST) (envelope-from eugen@grosbein.pp.ru) Received: (from eugen@localhost) by grosbein.pp.ru (8.12.11/8.12.11/Submit) id i4KD0qCY000578; Thu, 20 May 2004 21:00:52 +0800 (KRAST) (envelope-from eugen) Date: Thu, 20 May 2004 21:00:52 +0800 From: Eugene Grosbein To: Ruslan Ermilov Message-ID: <20040520130052.GA442@grosbein.pp.ru> References: <40A9CF72.85E2EC9D@kuzbass.ru> <20040518105134.GC70919@ip.net.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040518105134.GC70919@ip.net.ua> User-Agent: Mutt/1.4.1i cc: net@freebsd.org Subject: [ANALISYS] Re: multicast arp entry X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2004 13:01:02 -0000 On Tue, May 18, 2004 at 01:51:34PM +0300, Ruslan Ermilov wrote: > > got message of size 236 on Tue May 18 16:42:26 2004 > > RTM_ADD: Add Route: len 236, pid: 0, seq 0, errno 0, > > flags: > > locks: inits: > > sockaddrs: > > 224.0.0.9 1.0.5e.0.0.9 em3:0.7.e9.1f.f1.de 172.20.2.75 > > > > After that arp -an shows: > > (224.0.0.9) at 01:00:5e:00:00:09 on em3 permanent [ethernet] > > > > Then tcpdump shows that multicast packets with source IP of interface em1 > > (those must be directed via em1) go out through em3. I run quagga/ripd > > (same effect for zebra) on FreeBSD 4.9-STABLE. > > > > How do I find who installs this route? > > > The short answer is: the kernel adds it for you, automatically, > just as it does this for you for normal unicast destinations. > > The long answer could be: you could join to a single multicast > group on multiple interfaces, and you will be able to receive > multicast on all of them, but if you don't have multicast > forwarding enabled, only one interface will be used for sending. > Which one gets used will be determined by a normal routing > lookup, i.e., ``route -vn get -host 224.0.0.9'' where no entry > yet exists. Then, when the actual packet gets delivered, the > kernel will insert the corresponding ARP entry, mapping the > multicast group address to a MAC address. I've found that divert machanics is guilty in broken multicasts. Here is the scenario. 1. ripd assignes an outgoing interface for the mulicast socket using setsockopt (sock, IPPROTO_IP, IP_MULTICAST_IF, (void *)&m, sizeof(m)); 2. ripd runs: memset (&mreq, 0, sizeof(mreq)); mreq.imr_multiaddr.s_addr = mcast_addr; mreq.imr_interface = if_addr; /* (1) */ setsockopt (sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq)); This leads to igmp_joingroup(inm) and igmp_sendpkt(inm, inm->inm_rti->rti_type, 0), here inm->inm_ifp is filled with the contents of imo.imo_multicast_ifp, that is if_addr from (1). Still good. 3. Now we enter ip_output() keeping imo as one of arguments. There we run the following code: else if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) && imo != NULL && imo->imo_multicast_ifp != NULL) { /* * Bypass the normal routing lookup for multicast * packets if the interface is specified. */ ifp = imo->imo_multicast_ifp; IFP_TO_IA(ifp, ia); isbroadcast = 0; /* fool gcc */ } It's allright still. 4. When ipfw diverts our packet, we call /* Deliver packet to divert input routine */ divert_packet(m, 0, off & 0xffff, args.divert_rule); Ops, imo is not passed by! So our imo->imo_multicast_ifp is lost and diverted packet will not be sent through it but routing lookup will be performed. Should I fill the PR? Eugene Grosbein