arp/nd: Cope with late calls to iflladdr_event

When tearing down vnet jails we can move an if_bridge out (as
part of the normal vnet_if_return()). This can, when it's clearing out
its list of member interfaces, change its link layer address.
That sends an iflladdr_event, but at that point we've already freed the
AF_INET/AF_INET6 if_afdata pointers.

In other words: when the iflladdr_event callbacks fire we can't assume
that ifp->if_afdata[AF_INET] will be set.

Reviewed by:	donner@, melifaro@
MFC after:	1 week
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D28860
This commit is contained in:
Kristof Provost 2021-02-22 08:19:43 +01:00
parent 38c0951386
commit c139b3c19b
2 changed files with 6 additions and 0 deletions

View File

@ -1479,6 +1479,10 @@ arp_handle_ifllchange(struct ifnet *ifp)
static void
arp_iflladdr(void *arg __unused, struct ifnet *ifp)
{
/* if_bridge can update its lladdr during if_vmove(), after we've done
* if_detach_internal()/dom_ifdetach(). */
if (ifp->if_afdata[AF_INET] == NULL)
return;
lltable_update_ifaddr(LLTABLE(ifp));

View File

@ -208,6 +208,8 @@ nd6_lle_event(void *arg __unused, struct llentry *lle, int evt)
static void
nd6_iflladdr(void *arg __unused, struct ifnet *ifp)
{
if (ifp->if_afdata[AF_INET6] == NULL)
return;
lltable_update_ifaddr(LLTABLE6(ifp));
}