git: a285c84d517f - stable/12 - arp/nd: Cope with late calls to iflladdr_event

Kristof Provost kp at FreeBSD.org
Tue Mar 2 15:17:56 UTC 2021


The branch stable/12 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=a285c84d517f4b987dfbbcec876d1fd812065a27

commit a285c84d517f4b987dfbbcec876d1fd812065a27
Author:     Kristof Provost <kp at FreeBSD.org>
AuthorDate: 2021-02-22 07:19:43 +0000
Commit:     Kristof Provost <kp at FreeBSD.org>
CommitDate: 2021-03-02 08:31:13 +0000

    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
    
    (cherry picked from commit c139b3c19b52abe3b5ba23a8175e58e70c7a528d)
---
 sys/netinet/if_ether.c | 4 ++++
 sys/netinet6/nd6.c     | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index a05001999ca4..538f6abb9855 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1461,6 +1461,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));
 
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 50fcc3226f97..d1d4b7c7fa88 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -206,6 +206,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));
 }


More information about the dev-commits-src-all mailing list