From owner-freebsd-net@freebsd.org  Mon May 30 00:50:34 2016
Return-Path: <owner-freebsd-net@freebsd.org>
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 52CC7B4F87C
 for <freebsd-net@mailman.ysv.freebsd.org>;
 Mon, 30 May 2016 00:50:34 +0000 (UTC)
 (envelope-from kob6558@gmail.com)
Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3])
 by mx1.freebsd.org (Postfix) with ESMTP id 2F1AB1CE7
 for <freebsd-net@freebsd.org>; Mon, 30 May 2016 00:50:34 +0000 (UTC)
 (envelope-from kob6558@gmail.com)
Received: by mailman.ysv.freebsd.org (Postfix)
 id 2E5FFB4F87B; Mon, 30 May 2016 00:50:34 +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 2DFD9B4F87A
 for <net@mailman.ysv.freebsd.org>; Mon, 30 May 2016 00:50:34 +0000 (UTC)
 (envelope-from kob6558@gmail.com)
Received: from mail-ig0-x229.google.com (mail-ig0-x229.google.com
 [IPv6:2607:f8b0:4001:c05::229])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client CN "smtp.gmail.com",
 Issuer "Google Internet Authority G2" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 07AF11CE6
 for <net@freebsd.org>; Mon, 30 May 2016 00:50:33 +0000 (UTC)
 (envelope-from kob6558@gmail.com)
Received: by mail-ig0-x229.google.com with SMTP id ct2so22742450igb.0
 for <net@freebsd.org>; Sun, 29 May 2016 17:50:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:sender:in-reply-to:references:date:message-id:subject
 :from:to:cc; bh=McjFoUGKPb6USpD0E7ZxGfY5+cwPId9MduNtjaH+ZWk=;
 b=sKa4Od5DwH3V2YGUSWmBZ70l2RisS4rVwwd2De6flbXuxSznSyrCDZlT1tJPIVuBFx
 IF07vjYfAI/Yd4r7bDIXetvq6zgquh8/rslD8S8CTBlSuBtqDJq6NXjGPbIBzMMxNttA
 ZL3Z4vluQ7ZOJBw3MGVETlcQlNNiRS1H1ArNG7bci9Ei0uQbFYXoMptJBpMderOR5tXt
 ju35UBikVhuLujlueGjphE82aUy5MT2V/JzlnEJB4YdNx/YjTNEtauWIk8vtPvKsZGj6
 w4p/t+tBOYNkgPI7OsWBB+yXpHvigJ4/0ugIutFiuvv3se9/nLMq1yiON8wnwy9fdJlt
 27BQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:sender:in-reply-to:references:date
 :message-id:subject:from:to:cc;
 bh=McjFoUGKPb6USpD0E7ZxGfY5+cwPId9MduNtjaH+ZWk=;
 b=G5YfsMn9xw4YBqXpDn05Amh+t+Q09Xus1PE3H5zq5SXuYZVo1tpOsVWCXO4nUAhrDC
 BIbMrMUXEpbMrRZrjqG8YafOe4MKycZy1d5ceg383j1WnJLXMQAHub6+Nw/KewRPr3rd
 Wy/3kd1Wmfhq3J3xFE+leAXqZuDnp7Y/bTkODnDMQ9excivMH5o8rhKVIWbeU3OFsk+V
 g/ngNQV/Ik/SundD8Jz8kCp7+88ALfkPPLRnN7w24sGseZG8AQD958IGQuLjUw40xxhI
 yOND/9PBCNfQkvssHNZtvCvRKTLZ+s35LYkKkAzIF1U9Fk29la30MUNqz1VDi0mjPsbI
 HXaQ==
X-Gm-Message-State: ALyK8tLinkdbNN5C0xQ3zOfcDrlcorW14w70dpyjGNJhJuiQoZXEeIgetsr6cMr8MfBB+cIqs2EK8BvO9wN74g==
MIME-Version: 1.0
X-Received: by 10.50.131.201 with SMTP id oo9mr6217856igb.15.1464569433171;
 Sun, 29 May 2016 17:50:33 -0700 (PDT)
Sender: kob6558@gmail.com
Received: by 10.79.20.70 with HTTP; Sun, 29 May 2016 17:50:33 -0700 (PDT)
In-Reply-To: <20160529163228.I1958@besplex.bde.org>
References: <20160528154122.C1843@besplex.bde.org>
 <SN1PR08MB1821D18DE13FB882ED3BA327BA430@SN1PR08MB1821.namprd08.prod.outlook.com>
 <20160529111806.I1012@besplex.bde.org>
 <20160529163228.I1958@besplex.bde.org>
Date: Sun, 29 May 2016 17:50:33 -0700
X-Google-Sender-Auth: FSIxf4P2UAywrxfWysv_bAVswOg
Message-ID: <CAN6yY1v8DdcHUt6aRBaMs1gsTY2d5296Zr0b8L=sqPoHSdq9Lw@mail.gmail.com>
Subject: Re: ifconfig creates a bogus(?) route
From: Kevin Oberman <rkoberman@gmail.com>
To: Bruce Evans <brde@optusnet.com.au>
Cc: David DeSimone <ddesimone@verio.net>, "net@freebsd.org" <net@freebsd.org>
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.22
X-BeenThere: freebsd-net@freebsd.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Networking and TCP/IP with FreeBSD <freebsd-net.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-net>,
 <mailto:freebsd-net-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-net/>
List-Post: <mailto:freebsd-net@freebsd.org>
List-Help: <mailto:freebsd-net-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-net>,
 <mailto:freebsd-net-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 30 May 2016 00:50:34 -0000

On Sun, May 29, 2016 at 12:12 AM, Bruce Evans <brde@optusnet.com.au> wrote:

> 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: <UP,HOST,DONE,STATIC>
>> ...
>>
>
> 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: <UP,HOST,DONE,STATIC>
>> ...
>> 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
>

Bruce,

When it is in the "broken" condition,  what is the output of "route -n get
0"?

So you have a default route? None appears in any of your messages. Normally
0 should route to default. In fact 0/0 is a definition of default. (Well, I
suppose anything/0 is default, but 0/0 is the normal representation.) Since
most systems have a default gateway defined, this may relate to the issue
you are seeing. I'm very unclear what happens with 0/0 if default is not
defined.

FWIW, here is what I see on this system (10.3-STABLE r299096):
Routing tables

Internet:
Destination        Gateway            Flags      Netif Expire
default            192.168.1.1        UGS         re0
127.0.0.1          link#2             UH          lo0
192.168.1.0/24     link#1             U           re0
192.168.1.16       link#1             UHS         lo0
--
Kevin Oberman, Part time kid herder and retired Network Engineer
E-mail: rkoberman@gmail.com
PGP Fingerprint: D03FB98AFA78E3B78C1694B318AB39EF1B055683