Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Mar 2021 15:17:50 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 05ac80ac0f3a - stable/13 - arp/nd: Cope with late calls to iflladdr_event
Message-ID:  <202103021517.122FHoSR039607@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kp:

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

commit 05ac80ac0f3a41092a07e947fea1ed2e5f047d15
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2021-02-22 07:19:43 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-03-02 14:50:21 +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 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));
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103021517.122FHoSR039607>