Bug 252883 - [net][route][loopback] lo1 IP is not added to routing table of cloned interface via rc.d at startup
Summary: [net][route][loopback] lo1 IP is not added to routing table of cloned interfa...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-net (Nobody)
URL: https://reviews.freebsd.org/D28246
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-21 13:06 UTC by Dave Cottlehuber
Modified: 2021-01-22 10:02 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Cottlehuber freebsd_committer freebsd_triage 2021-01-21 13:06:19 UTC
IP routes for loopback cloned interfaces shouldn't need
to have a static route manually added. Regression is
probably present for several weeks, I think.

# ping 100.64.0.1
PING 100.64.0.1 (100.64.0.1): 56 data bytes
^C

# netstat -4rn

Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            172.16.1.1         UGS        igb0
127.0.0.1          link#3             UHS         lo0
172.16.1.0/24      link#1             U          igb0
172.16.1.4         link#1             UHS         lo0

### the following is missing, then the above now works

# route add 100.64.0.1/28 100.64.0.1

uname 13.0-ALPHA1 main-c256063-g098c902b5202 (~ 2021-01-18)

To reproduce:

default install, add these to /etc/rc.conf, reboot or /etc/netstart. 
Issue is also present with a more typical RFC1918 range, I tested with 192.168.0.1 as well.

# /etc/rc.conf
cloned_interfaces="${cloned_interfaces} lo1"
ifconfig_lo1="inet 100.64.0.1/28"
ifconfig_lo1_aliases="inet 100.64.0.2-15/32"


# ifconfig lo1
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
	inet6 fe80::1%lo1 prefixlen 64 scopeid 0x4
	inet 100.64.0.1  netmask 0xfffffff0
	inet 100.64.0.2  netmask 0xffffffff
...
	inet 100.64.0.15 netmask 0xffffffff
	groups: lo
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

# route -nv get 100.64.0.1
RTA_DST: inet 100.64.0.1; RTA_IFP: link ; RTM_GET: Report Metrics: len 224, pid: 0, seq 1, errno 0, flags:<UP,GATEWAY,HOST,STATIC>
locks:  inits: 
sockaddrs: <DST,IFP>
 100.64.0.1 link#0
   route to: 100.64.0.1
destination: 0.0.0.0
       mask: 0.0.0.0
    gateway: 172.16.1.1
        fib: 0
  interface: igb0
      flags: <UP,GATEWAY,DONE,STATIC>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1500         1         0 

locks:  inits: 
sockaddrs: <DST,GATEWAY,NETMASK,IFP,IFA>
 0.0.0.0 172.16.1.1 0.0.0.0 igb0:ac.1f.6b.67.e1.38 172.16.1.4
Comment 1 Herbert J. Skuhra 2021-01-21 13:10:20 UTC
https://reviews.freebsd.org/D28246  ???
Comment 2 Dave Cottlehuber freebsd_committer freebsd_triage 2021-01-21 15:39:22 UTC
thanks Herbert, this patch does indeed fix this!
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-01-21 21:49:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=130aebbab0d38da85f7d32b6d4227f95a2cd9ec7

commit 130aebbab0d38da85f7d32b6d4227f95a2cd9ec7
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2021-01-19 23:50:34 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2021-01-21 21:48:49 +0000

    Further refactor IPv4 interface route creation.

    * Fix bug with /32 aliases introduced in 81728a538d24.
    * Explicitly document business logic for IPv4 ifa routes.
    * Remove remnants of rtinit()
    * Deduplicate ifa->route prefix code by moving it into ia_getrtprefix()
    * Deduplicate conditional check for ifa_maintain_loopback_route()  by
     moving into ia_need_loopback_route()
    * Remove now-unused flags argument from in_addprefix().

    Reviewed by:            donner
    PR:                     252883
    Differential Revision:  https://reviews.freebsd.org/D28246

 sys/netinet/in.c      | 239 +++++++++++++++++++++++++++-----------------------
 sys/netinet/in_var.h  |   2 +-
 sys/netinet/ip_carp.c |   2 +-
 3 files changed, 130 insertions(+), 113 deletions(-)