Skip to contentSkip to conversation

Why RTM_NEWADDR is sent before FIB update?

DISCUSSION Timo Teräs 1 participant 1 message Oct 20, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

I'm wonder why does devinet.c:__inet_insert_ifa() (and other places) send first the RTM_NEWADDR notification and only after that calls inetaddr_chain notifiers?

The reason I'm asking that this gives a race condition to user land:
1. process A changes IP address
2. kernel sends RTM_NEWADDR
3. process B gets notification
4. process B tries to bind() to new IP but that fails with
EADDRNOTAVAIL because FIB is not yet updated and inet_addr_type() in inet_bind() does not recognize the IP as local
5. kernel calls inetaddr_chain notifiers which updates FIB

My understanding was that RTM_NEWADDR was notification about new address being usable. But it's currently a notification about "new address will be usable soon".

So should we:
a) call first notifiers and after that send RTM_NEWADDR?
b) synchronise inet_bind() with address changes somehow?
c) live with the bad semantics of the notification in userland
d) ??

- Timo