Page MenuHomeFreeBSD

routing: fix source address selection rules for IPv4 over IPv6.
ClosedPublic

Authored by melifaro on Mon, Sep 6, 10:28 PM.

Details

Summary

Current logic always selects an IFA of the same family from the
outgoing interfaces. In IPv4 over IPv6 setup there can be just
single non-127.0.0.1 ifa, attach to an loopback address.

Create a separate rt_getifa_family() to handle entire ifa selection
for the IPv4 over IPv6.

Test Plan

Without the change:

22:29 [0] m@devel2 ifconfig
vtnet0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=4c04bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,LRO,VLAN_HWTSO,LINKSTATE,TXCSUM_IPV6>
	ether 52:54:00:14:e3:19
	inet6 fe80::5054:ff:fe14:e319%vtnet0 prefixlen 64 scopeid 0x1
	inet6 2a01:4f8:13a:70c:ffff::8 prefixlen 96
	media: Ethernet autoselect (10Gbase-T <full-duplex>)
	status: active
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

22:30 [0] m@devel2 s route add default -inet6 2a01:4f8:13a:70c:ffff::1

22:30 [0] m@devel2 netstat -4rnW
Routing tables

Internet:
Destination        Gateway            Flags   Nhop#    Mtu      Netif Expire
default            2a01:4f8:13a:70c:ffff::1 UGS      3   1500     vtnet0
10.199.199.190     link#2             UH          2  16384        lo0
127.0.0.1          link#2             UH          1  16384        lo0
22:30 [0] m@devel2 netstat -4onW
Nexthop data

Internet:
Idx   Type         IFA                Gateway             Flags      Use Mtu         Netif     Addrif Refcnt Prepend
1       v4/resolve 127.0.0.1          lo0/resolve        H             0  16384        lo0               2
2       v4/resolve 10.199.199.190     lo0/resolve        H             0  16384        lo0               2
3            v4/gw 2a01:4f8:13a:70c:ffff::8 2a01:4f8:13a:70c:ffff::1 GS        0   1500     vtnet0               2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

After the change:

22:35 [0] m@devel2 netstat -4rnW
Routing tables

Internet:
Destination        Gateway            Flags   Nhop#    Mtu      Netif Expire
default            2a01:4f8:13a:70c:ffff::1 UGS      3   1500     vtnet0
10.199.199.190     link#2             UH          2  16384        lo0
127.0.0.1          link#2             UH          1  16384        lo0
22:35 [0] m@devel2 netstat -4onW
Nexthop data

Internet:
Idx   Type         IFA                Gateway             Flags      Use Mtu         Netif     Addrif Refcnt Prepend
1       v4/resolve 127.0.0.1          lo0/resolve        H             0  16384        lo0               2
2       v4/resolve 10.199.199.190     lo0/resolve        H             0  16384        lo0               2
3            v4/gw 10.199.199.190     2a01:4f8:13a:70c:ffff::1 GS        0   1500     vtnet0               2
22:35 [0] m@devel2

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

melifaro added a reviewer: network.
melifaro added a reviewer: zlei.huang_gmail.com.
This revision was not accepted when it landed; it landed in state Needs Review.Tue, Sep 7, 9:44 PM
This revision was automatically updated to reflect the committed changes.

I'm still investing on this issue. As the following case

  1. IPv4 over IPv6 nexthops
  2. IPv4 over IPv4 linklocal nexthops

we can treat them as Unnumbered, and for routers there's https://datatracker.ietf.org/doc/html/rfc1812#section-2.2.7, claiming router-id should be used.

As for end hosts, I have not found any RFCs specifying it.

Any thoughts ? @melifaro