Issue #3486 has been updated by sigttou.

File 0003-netinet-Don-t-add-an-interface-route-when-a-p2p-peer.patch added
File 0002-netinet-Treat-a-32-loopback-host-route-as-a-prefix-o.patch added
File 0001-netinet-Don-t-add-an-interface-route-for-a-32-addres.patch added
File 0004-netinet-Remove-the-loopback-route-when-adding-an-add.patch added

Updated patches, replacing the two attached earlier. (0004 is independent of 
the first three)

* 0001: for an address with an all-ones mask on an interface that is neither 
loopback nor point-to-point, @in_addprefix()@ does not add the interface route 
(the loopback host route already routes the address) and sends RTM_NEWADDR 
itself. @in_scrubprefix()@ sends the matching RTM_DELADDR (a flag in the ifaddr 
records that the address message was sent). No RTM_ADD/RTM_DELETE is sent for 
the skipped route. When the prefix route is removed, the move loop keeps the 
loopback route for such a /32, that route is then owned by another address of 
lo0 (usually 127.0.0.1), not by the interface address.
* 0002: @ifconfig lo0 alias A@ after @tap0 inet A/32 A@ works (the duplicate 
scan accepts a /32 with the same host address as owner of the prefix), the 
other order already worked with 0001.
* 0003: a point-to-point address whose peer is the address (@ifconfig tun0 inet 
A A@, any mask) also skips the interface route. That EEXIST also happens with 
9ac2060abb reverted.
* 0004 (drop it if you prefer): when adding an address fails, the loopback host 
route that @in_addprefix()@ added just before stays in the routing table (a 
stale @A UH lo0@ route after the EEXIST), this removes it again if this call 
added it. A route that already existed is left alone.

Limits I know of:
* @SIOCSIFDSTADDR@ on such a point-to-point address installs no route for a new 
peer (ifconfig uses SIOCAIFADDR, which works).
* Removing the lo0 address that owns the moved route (e.g. @ifconfig lo0 inet 
127.0.0.1 -alias@) removes that route and the address loses local delivery, 
like the ordinary loopback routes; the same happens when lo0 has no other IPv4 
address.
* An address on a down interface is not taken over as route owner: if tap0 is 
down when @lo0 -alias A@ runs, A has no local route until the address is set 
again.
* With three addresses with the same A (two taps and an lo0 alias) ping of A 
failed right after the alias was added, and after deleting the alias the last 
tap address had no local route.


----------------------------------------
Bug #3486: IPv4 /32 interface address fails with EEXIST 
http://bugs.dragonflybsd.org/issues/3486#change-14997

* Author: sigttou
* Status: New
* Priority: Normal
* Target version: 6.6
* Start date: 2026-11-29
----------------------------------------
Since 9ac2060abb ("net: Normalize IPv4 /32 route to a host route"), adding an 
IPv4 /32 address to a non-loopback interface fails:

<pre>
# ifconfig tap0 create
# ifconfig tap0 inet 10.9.9.9/32 10.9.9.9
ifconfig: ioctl (SIOCAIFADDR): File exists
</pre>

A /24 address on the same interface works. tailscaled adds exactly such an 
address to its tap device (@ifconfig tailscale0 inet 100.x.y.z/32 100.x.y.z@), 
so the node gets no tailnet address on a kernel with the commit.

@in_addprefix()@ first adds the loopback host route for the address, then 
@rtinit(RTM_ADD)@ reaches @rtrequest1()@, where @rt_hostroute_normalize()@ 
turns the /32 interface route into the same host route key (netmask dropped, 
RTF_HOST); the add collides and returns @EEXIST@. Before the commit both routes 
existed (@A UH lo0@ and @A/32 UC tap0@).

Two patches, either fixes it. 

candidate-N-0001-netinet-Do-not-add-an-interface-route-for-a-32-address.patch 
(my preference): @in_addprefix()@ does not add the interface route for a /32 
address on a non-loopback, non-point-to-point interface, because the loopback 
host route it has just added already routes the address. No /32 network route 
is created, which matches 5a47208162. Costs: the address has no interface route 
(@IFA_ROUTE@ unset), so @route delete x/32@ removes the only route and the 
address becomes unreachable (the loopback route is the host route now, local 
delivery and ARP do not depend on the interface route, ifa lookups use the 
ifaddr list), no @RTM_NEWADDR@/@RTM_DELADDR@ is sent for such an address (those 
come from the @rtinit()@ callback), as for an address that shares the prefix 
route of another one; and a host-route address whose destination equals the /32 
(e.g. @ifconfig lo0 alias A@ after @tap0 A/32@) no longer finds an owner of the 
prefix in the duplicate scan and hits @EEXIST@, which worked before the commit.

rti-ifa-0001-net-Only-normalize-32-routes-without-an-interface-address.patch 
(alternative): @rtrequest1()@ normalizes only requests that do not carry an 
interface address (@rti_ifa == NULL@), so @rtinit()@ keeps the /32 prefix route 
and the route table is exactly the pre-9ac2060abb one. route(8) still gets a 
host route. The /32 network route that 5a47208162 considers pointless stays, 
and routing-socket GET/CHANGE/LOCK/DELETE for x/32 select the loopback host 
route instead of the interface route.

I prefer the first one because it removes the /32 network route instead of 
working around the collision and fits 5a47208162, but the second one restores 
the previous behaviour exactly (routes, address messages, shared-prefix cases), 
so it is the safer one if you do not want to change the interface route 
handling.

---Files--------------------------------
rti-ifa-0001-net-Only-normalize-32-routes-without-an-interface-address.patch 
(1.5 KB)
candidate-N-0001-netinet-Do-not-add-an-interface-route-for-a-32-address.patch 
(1.36 KB)
0003-netinet-Don-t-add-an-interface-route-when-a-p2p-peer.patch (2.1 KB)
0002-netinet-Treat-a-32-loopback-host-route-as-a-prefix-o.patch (1.98 KB)
0001-netinet-Don-t-add-an-interface-route-for-a-32-addres.patch (7.55 KB)
0004-netinet-Remove-the-loopback-route-when-adding-an-add.patch (1.85 KB)


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://bugs.dragonflybsd.org/my/account

Reply via email to