The branch stable/13 has been updated by markj:

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

commit cdb6f3d41686b71dd0e804bdee5f094f9130268d
Author:     Mark Johnston <[email protected]>
AuthorDate: 2021-09-10 13:07:40 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2021-09-17 13:13:09 +0000

    net: Enter a net epoch around protocol if_up/down notifications
    
    When traversing a list of interface addresses, we need to be in a net
    epoch section, and protocol ctlinput routines need a stable reference to
    the address.
    
    Reported by:    [email protected]
    Reviewed by:    kp, melifaro
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit b1e6a792d68e9c59740d5e925405d8d4343d099b)
---
 sys/kern/uipc_domain.c | 2 ++
 sys/net/if.c           | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index 4342f1026783..85a2da76012d 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -510,6 +510,8 @@ pfctlinput(int cmd, struct sockaddr *sa)
        struct domain *dp;
        struct protosw *pr;
 
+       NET_EPOCH_ASSERT();
+
        for (dp = domains; dp; dp = dp->dom_next)
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
                        if (pr->pr_ctlinput)
diff --git a/sys/net/if.c b/sys/net/if.c
index aeb7230fcc9a..7d7206e7596c 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2215,14 +2215,17 @@ static void
 if_unroute(struct ifnet *ifp, int flag, int fam)
 {
        struct ifaddr *ifa;
+       struct epoch_tracker et;
 
        KASSERT(flag == IFF_UP, ("if_unroute: flag != IFF_UP"));
 
        ifp->if_flags &= ~flag;
        getmicrotime(&ifp->if_lastchange);
+       NET_EPOCH_ENTER(et);
        CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
                if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family))
                        pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
+       NET_EPOCH_EXIT(et);
        ifp->if_qflush(ifp);
 
        if (ifp->if_carp)
@@ -2238,14 +2241,17 @@ static void
 if_route(struct ifnet *ifp, int flag, int fam)
 {
        struct ifaddr *ifa;
+       struct epoch_tracker et;
 
        KASSERT(flag == IFF_UP, ("if_route: flag != IFF_UP"));
 
        ifp->if_flags |= flag;
        getmicrotime(&ifp->if_lastchange);
+       NET_EPOCH_ENTER(et);
        CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
                if (fam == PF_UNSPEC || (fam == ifa->ifa_addr->sa_family))
                        pfctlinput(PRC_IFUP, ifa->ifa_addr);
+       NET_EPOCH_EXIT(et);
        if (ifp->if_carp)
                (*carp_linkstate_p)(ifp);
        rt_ifmsg(ifp);
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to