Are there any RFCs for address selection for IPv4

Zhenlei Huang zlei.huang at gmail.com
Thu Apr 29 10:36:55 UTC 2021


> On Apr 25, 2021, at 6:20 PM, Zhenlei Huang <zlei.huang at gmail.com> wrote:
> 
> Hello hackers,
> 
> For IPv6 there's RFC 6724 to clarify the default address selection procedure, 
> both for source address selection and destination address selection. Are there
> any RFCs like RFC 6724 that are for IPv4? 
> 
> I'm exploring RFC 3927, consider this situation, a host configured with link-local
> address on NIC and global unicast alias address on loopback interface, and default route to 
> the link-local address of router (some ISPs do this). The current implementation kernel
> will use the link-local address as the source address when initializing a connection to 
> remote host via the default route. It seems wrong, as link-local address are not 
> routable as per RFC 3927.
> 
> So it is important if there's corresponding RFC clarify the source address selection 
> for IPv4.
> 
> Thanks :)

After googling and hunting I found a fairly old RFC 1122. The section 3.3.4.3 `Choosing a 
Source Address` looks what I'm looking for.

I did not find any further RFCs that update the section 3.3.4.3 of RFC 1122. So I think it
still applies to hosts / routers with link-local addresses.

Then the source address selection falls into these three situation:
1. Multi-homed host with strong ES model.
2. Multi-homed host with weak ES model.
3. Router

Suppose the host / router has one interface configured with LL address, and routable
addresses configured on other interfaces,  to respect RFC 3927 section 2.7,  then
for situation 2 and 3, a routable address should be selected if the next-hop interface is
unnumbered, ie. the interface is configured with only LL addresses.
For situation 1, since it is strong ES model, and the interface is unnumbered, no routable
address is available, and the kernel should return a error EADDRNOTAVAIL .

I would like to borrow some rules from RFC 6724, for two addresses SA and SB from the
candidate set , a given destination address D

Rule 1. Prefer same address.
  If SA = D, then prefer SA.  Similarly, if SB = D, then prefer SB.

Rule 2. Prefer appropriate scope.
  If Scope(SA) < Scope(SB): If Scope(SA) < Scope(D), then prefer SB and
   otherwise prefer SA.  Similarly, if Scope(SB) < Scope(SA): If
   Scope(SB) < Scope(D), then prefer SA and otherwise prefer SB.

Rule 3. Prefer outgoing interface.
   If SA is assigned to the interface that will be used to send to D and
   SB is assigned to a different interface, then prefer SA.  Similarly,
   if SB is assigned to the interface that will be used to send to D and
   SA is assigned to a different interface, then prefer SB.

Rule 4. Prefer directly connected.
   If DirectlyConnected(SA, D) and not DirectlyConnected(SB, D) then prefer SA.
   If DirectlyConnected(SB, D) and not DirectlyConnected(SA, D) then prefer SB.


For situation 1, the order of rules should be 1, 3, 2, 4. And that might result in un-routable
packets with LL source address sent to next-hop.

For situation 2 and 3, the order is 1, 2, 3, 4. 


Feedbacks are welcome.

Thanks,
Zhenlei Huang



More information about the freebsd-hackers mailing list