From owner-freebsd-net@FreeBSD.ORG Mon Aug 31 17:01:39 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 875C51065694 for ; Mon, 31 Aug 2009 17:01:39 +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 770588FC21 for ; Mon, 31 Aug 2009 17:01:39 +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="------------020109080001040507040400" X-Virus-Scanned: ClamAV using ClamSMTP Resent-Date: Mon, 31 Aug 2009 17:01:39 +0000 (UTC) Resent-From: stef-list@memberwebs.com Subject: [patch] Unbreak setfib + routing daemons 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: Mon, 31 Aug 2009 17:01:39 -0000 X-List-Received-Date: Mon, 31 Aug 2009 17:01:39 -0000 This is a multi-part message in MIME format. --------------020109080001040507040400 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Currently route messages are sent to all listeners of PF_ROUTE, regardless or which FIB the listener socket was started on. The upshot of this is that one can't really use routing daemons together with multiple FIBs. The routing daemon sees the messages from the alternate FIBs and rapidly gets confused. In the future, someone might decide to expose FIB numbers in the route messages themselves. This could allow routing daemons to filter them out. Such a solution might be appropriate for FreeBSD 9.x and later, as it would likely break API and ABI. In any case, I'm not really qualified to argue the merits/problems of such an approach, and coding it is beyond my abilities... Attached is a patch which fixes this problem in a simple way. It limits route messages to listening PF_ROUTE sockets on the same FIB that the route message was for. It compiles and works on 7.1+ and 8.0 and CURRENT. FreeBSD PR: http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/134931 How can I help this get into FreeBSD? It would be awesome if this fix or one like it made it in before the 8.0 release. Cheers, Stef --------------020109080001040507040400 Content-Type: text/x-diff; name="freebsd-route-messages-respect-fib.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="freebsd-route-messages-respect-fib.patch" --- sys/net/rtsock.c.orig 2009-08-31 15:26:03.000000000 +0000 +++ sys/net/rtsock.c 2009-08-31 16:07:06.000000000 +0000 @@ -777,4 +777,5 @@ } if (m) { + M_SETFIB(m, so->so_fibnum); if (rp) { /* --- sys/net/raw_usrreq.c.orig 2009-08-31 16:04:58.000000000 +0000 +++ sys/net/raw_usrreq.c 2009-08-31 16:05:11.000000000 +0000 @@ -84,4 +84,7 @@ rp->rcb_proto.sp_protocol != proto->sp_protocol) continue; + if (proto->sp_family == PF_ROUTE && rp->rcb_socket && + M_GETFIB (m) != rp->rcb_socket->so_fibnum) + continue; if (last) { struct mbuf *n; --------------020109080001040507040400--