From owner-freebsd-net@FreeBSD.ORG Thu Apr 5 14:02:48 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DF0DC16A401 for ; Thu, 5 Apr 2007 14:02:48 +0000 (UTC) (envelope-from jinmei@isl.rdc.toshiba.co.jp) Received: from shuttle.wide.toshiba.co.jp (shuttle.wide.toshiba.co.jp [202.249.10.124]) by mx1.freebsd.org (Postfix) with ESMTP id B0E0013C448 for ; Thu, 5 Apr 2007 14:02:48 +0000 (UTC) (envelope-from jinmei@isl.rdc.toshiba.co.jp) Received: from jmb.local (t050096.ppp.asahi-net.or.jp [203.189.50.96]) by shuttle.wide.toshiba.co.jp (Postfix) with ESMTP id 95C337301F; Thu, 5 Apr 2007 23:02:47 +0900 (JST) Date: Thu, 05 Apr 2007 23:02:42 +0900 Message-ID: From: JINMEI Tatuya / =?ISO-2022-JP?B?GyRCP0BMQEMjOkgbKEI=?= To: Andrew McDonald In-Reply-To: <20070405081639.GB6798@mcdonald.org.uk> References: <20070404211815.GA6798@mcdonald.org.uk> <20070405081639.GB6798@mcdonald.org.uk> User-Agent: Wanderlust/2.14.0 (Africa) Emacs/22.0 Mule/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: freebsd-net@freebsd.org Subject: Re: IPv6 Router Alert breaks forwarding X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 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, 05 Apr 2007 14:02:49 -0000 At Thu, 5 Apr 2007 09:16:39 +0100, Andrew McDonald wrote: > Thinking about it a bit, there is a simple fix that leaves MLD working > (but currently doesn't provide a way for other applications to use > router alert). The IPv6 Router Alert Option (RAO) has a 16-bit value > field. For MLD this is zero. Other uses would contain different values > (as per RFC2711). > > rtalert contains the contents of this value field, or (u_int32_t)~0 if > there is no router alert option. So, if we change the check to: > /* > * accept the packet if a router alert option with value 0 > * is included and we act as an IPv6 router. > */ > if (rtalert == 0 && ip6_forwarding) > ours = 1; > we'll only pick up packets containing ipv6 router alerts with value 0 > (i.e. MLD router alerted packets). The behavior looks reasonable, but I'd code it more explicitly with some comments so that the intent is clear and others can correctly modify it for future extensions. A possible patch to implement it is pasted below. One thing I'm not really sure is whether someone is using (or has used) other predefined alert values: 1 Datagram contains RSVP message. 2 Datagram contains an Active Networks message. (I guess you're now going to use values 3-35 per RFC3175). If there is a user, we need to be careful not to break compatibility. JINMEI, Tatuya Communication Platform Lab. Corporate R&D Center, Toshiba Corp. jinmei@isl.rdc.toshiba.co.jp Index: ip6_input.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/ip6_input.c,v retrieving revision 1.90 diff -u -r1.90 ip6_input.c --- ip6_input.c 24 Feb 2007 11:38:47 -0000 1.90 +++ ip6_input.c 5 Apr 2007 13:57:21 -0000 @@ -657,11 +657,25 @@ nxt = hbh->ip6h_nxt; /* - * accept the packet if a router alert option is included - * and we act as an IPv6 router. + * If we are acting as a router and the packet contains a + * router alert option, see if we know the option value. + * Currently, we only support the option value for MLD, in which + * case we should pass the packet to the multicast routing + * daemon. */ - if (rtalert != ~0 && ip6_forwarding) - ours = 1; + if (rtalert != ~0 && ip6_forwarding) { + switch (rtalert) { + case IP6OPT_RTALERT_MLD: + ours = 1; + break; + default: + /* + * RFC2711 requires unrecognized values must be + * silently ignored. + */ + break; + } + } } else nxt = ip6->ip6_nxt;