git: c139b3c19b52 - main - arp/nd: Cope with late calls to iflladdr_event

Kristof Provost kp at FreeBSD.org
Tue Feb 23 13:55:09 UTC 2021


The branch main has been updated by kp:

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

commit c139b3c19b52abe3b5ba23a8175e58e70c7a528d
Author:     Kristof Provost <kp at FreeBSD.org>
AuthorDate: 2021-02-22 07:19:43 +0000
Commit:     Kristof Provost <kp at FreeBSD.org>
CommitDate: 2021-02-23 12:54:07 +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
---
 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 e09ad3d47382..ef50ec9ca964 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -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));
 
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index 497c0bfc10e8..62f0ac733a23 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -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));
 }


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