Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Apr 2021 18:36:44 +0800
From:      Zhenlei Huang <zlei.huang@gmail.com>
To:        Zhenlei Huang <zlei.huang@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Are there any RFCs for address selection for IPv4
Message-ID:  <CAD53C43-EAFD-4BD3-B153-A8B7CC51A45B@gmail.com>
In-Reply-To: <D66C20B9-24FA-4557-96F0-90E56B982150@gmail.com>
References:  <D66C20B9-24FA-4557-96F0-90E56B982150@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

> On Apr 25, 2021, at 6:20 PM, Zhenlei Huang <zlei.huang@gmail.com> =
wrote:
>=20
> Hello hackers,
>=20
> For IPv6 there's RFC 6724 to clarify the default address selection =
procedure,=20
> both for source address selection and destination address selection. =
Are there
> any RFCs like RFC 6724 that are for IPv4?=20
>=20
> 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=20
> 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=20
> remote host via the default route. It seems wrong, as link-local =
address are not=20
> routable as per RFC 3927.
>=20
> So it is important if there's corresponding RFC clarify the source =
address selection=20
> for IPv4.
>=20
> Thanks :)

After googling and hunting I found a fairly old RFC 1122. The section =
3.3.4.3 `Choosing a=20
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 =3D D, then prefer SA.  Similarly, if SB =3D 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.=20


Feedbacks are welcome.

Thanks,
Zhenlei Huang




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAD53C43-EAFD-4BD3-B153-A8B7CC51A45B>