From owner-freebsd-net@freebsd.org Sun May 29 07:12:13 2016 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 197E3B51BF9 for ; Sun, 29 May 2016 07:12:13 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 06AFD1D63 for ; Sun, 29 May 2016 07:12:13 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: by mailman.ysv.freebsd.org (Postfix) id 06076B51BF8; Sun, 29 May 2016 07:12:13 +0000 (UTC) Delivered-To: net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 037E6B51BF6 for ; Sun, 29 May 2016 07:12:13 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 835741D61 for ; Sun, 29 May 2016 07:12:12 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c110-21-42-169.carlnfd1.nsw.optusnet.com.au [110.21.42.169]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id D1B8ED491C7; Sun, 29 May 2016 17:12:03 +1000 (AEST) Date: Sun, 29 May 2016 17:12:01 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Evans cc: David DeSimone , "net@freebsd.org" Subject: RE: ifconfig creates a bogus(?) route In-Reply-To: <20160529111806.I1012@besplex.bde.org> Message-ID: <20160529163228.I1958@besplex.bde.org> References: <20160528154122.C1843@besplex.bde.org> <20160529111806.I1012@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=kDyANCGC9fy361NNEb9EQQ==:117 a=kDyANCGC9fy361NNEb9EQQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=y-on_t-p6bA_YMW549oA:9 a=pxSoZ1cC2Bej9OTl:21 a=PyjwaoGlHOKfdf3m:21 a=CjuIK1q_8ugA:10 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 May 2016 07:12:13 -0000 On Sun, 29 May 2016, Bruce Evans wrote: > ... > I still haven't figured out how to set up the bogus(?) route using route > add/change, but can now complete the initialization using a "route change" > that appears to be null: > > Test script: > ... > X # Fix up the initialization with a null change: > X route change -iface 192.168.2.8 192.168.2.8 > X netstat -rn Before: >... > Y Destination Gateway Flags Refs Use Netif Expire > Y 127.0.0.1 link#2 UH 0 0 lo0 > Y 192.168.2.0/24 link#1 U 0 0 em0 > Y 192.168.2.8 link#1 UHS 0 0 lo0 > Y route to: 192.168.2.8 > Y destination: 192.168.2.8 > Y interface: lo0 > Y flags: >... After: >... > Y Destination Gateway Flags Refs Use Netif Expire > Y 127.0.0.1 link#2 UH 0 0 lo0 > Y 192.168.2.0/24 link#1 U 0 0 em0 > Y 192.168.2.8 192.168.2.8 UHS 0 0 lo0 > Y route to: 192.168.2.8 > Y destination: 192.168.2.8 > Y interface: lo0 > Y flags: >... > Note that the "null" route change just echos the current setting and it > doesn't change anything according to netstat -rn and route -n, but it > fixes up some internal state so that the ping works. When ping works, > tcpdump shows it going from 127.0.0.1 to 192.168.2.8 and coming back as > expected. When ping hangs, tcpdump shows it going from 0.0.0.0 to > 192.168.2.8 and never coming back. The default route doesn't exist in > either case. Bah, it did change (from link#1 to 192.168.2.8 for Gateway in netstat -rn output only). -iface makes no difference (I thought it prevented this change). The initialization bug has something to do with the magic default route of 0.0.0.0). When lo0 is used uninitialized, it is still initialized to 0 and the 0 gets copied to somewhere not shown properly in the initial route from (or is it to?) 192.168.2.8. netstat -rn translates this 0 together with another address to #link1, but route -n get doesn't show it. I think this configuration is supposed to not occur. I couldn't find a way to get back it using route(8) after fixing it. When lo0 is brought up first, different magic obscures what is happening. E.g., when lo0 is misconfigured with "inet 127.0.0.127", the em0 route is auto-configured with this strange lo0 address instead of completely misconfigured to 0. Neither netstat -rn nor route -n get displays this clearly (they give the same display as in the uninitialized case except for the .127 route). Then if lo0 is ifconfig'ed again to fix this misconfiguration, the all routes related to the old lo0 (bogus or working) are deleted and not restored. But if lo0 is brought up for the first time after em0, the the 0.0.0.0 route related to the old lo0 is not deleted; it keeps breaking things. Bruce