Bug 187699

Summary: [libc] Nondefault FIBs don't get loopback addresses
Product: Base System Reporter: Alan Somers <asomers>
Component: binAssignee: Alan Somers <asomers>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Alan Somers freebsd_committer freebsd_triage 2014-03-18 15:50:00 UTC
"ping 127.0.0.1" and "ping6 ::1" should always work, regardless of which
FIB is in use.  However, they don't.  ipv4_up() in network.subr ensures
adds the 127.0.0.1 address to lo0 in the default fib, which causes the
kernel to add it to the default fib's routing table.  But nothing adds
that address to alternate fibs.  Nor does anything add ::1 to the inet6
routing tables for alternate FIBs.

IMHO, the best way to solve this bug would be to add 127.0.0.1 and ::1
static routes in /etc/rc.d/routing in the functions static_inet() and
static_inet6().

Fix: 

Working on a patch now ...
How-To-Repeat: In /boot/loader.conf.local:
net.fibs="4"
net.add_addr_allfibs="0"

setfib 1 ping localhost    # This will fail, but it should succeed
setfib 1 ping6 ::1         # This will fail, but it should succeed.
Comment 1 Alan Somers freebsd_committer freebsd_triage 2014-03-18 16:08:15 UTC
Responsible Changed
From-To: freebsd-bugs->asomers

I'll take it
Comment 2 Alan Somers freebsd_committer freebsd_triage 2016-06-01 17:23:48 UTC
Fixed by r300882

  Always create loopback routes on every fib

  Always create loopback routes on every fib, for both IPv4 and IPv6

  etc/rc.d/routing
        Create loopback IPv4 and IPv6 routes on every fib at boot. Revert
        278302; now that all FIBs have IPv6 loopback routes, the
        "route add -reject" commands won't fail.

  tests/etc/rc.d/routing_test.sh
        Greatly simplify static_ipv6_loopback_route_for_each_fib. It was
        written under the assumption that loopback routes would be added to
        a given fib by the kernel as soon as an interface is configured on
        that fib. However, the logic can be much simpler now that we simply
        add loopback routes to all fibs at boot. This also removes the need
        to run the test as root, removes the restriction that
        net.add_addr_allfibs=0, and removes the need to configure fibs in
        kyua.conf.

        Also, add a test case for IPv4 loopback routes

  Sponsored by: Spectra Logic Corp
  Differential Revision:        https://reviews.freebsd.org/D6582