From 45c1d51c395e57e78c3ad16ee48a7bc0d0c3d06b Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Thu, 10 Oct 2019 23:54:37 +0000 Subject: [PATCH] Don't use if_maddr_rlock() in sppp(4), use epoch(9) directly instead. --- sys/net/if_spppsubr.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 9d999701e91e..a96f67270cff 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -4818,6 +4818,7 @@ sppp_keepalive(void *dummy) void sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst, u_long *srcmask) { + struct epoch_tracker et; struct ifnet *ifp = SP2IFP(sp); struct ifaddr *ifa; struct sockaddr_in *si, *sm; @@ -4830,7 +4831,7 @@ sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst, u_long *srcmask) * aliases don't make any sense on a p2p link anyway. */ si = NULL; - if_addr_rlock(ifp); + NET_EPOCH_ENTER(et); CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) if (ifa->ifa_addr->sa_family == AF_INET) { si = (struct sockaddr_in *)ifa->ifa_addr; @@ -4849,7 +4850,7 @@ sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst, u_long *srcmask) if (si && si->sin_addr.s_addr) ddst = si->sin_addr.s_addr; } - if_addr_runlock(ifp); + NET_EPOCH_EXIT(et); if (dst) *dst = ntohl(ddst); if (src) *src = ntohl(ssrc); @@ -4863,6 +4864,7 @@ static void sppp_set_ip_addr(struct sppp *sp, u_long src) { STDDCL; + struct epoch_tracker et; struct ifaddr *ifa; struct sockaddr_in *si; struct in_ifaddr *ia; @@ -4872,7 +4874,7 @@ sppp_set_ip_addr(struct sppp *sp, u_long src) * aliases don't make any sense on a p2p link anyway. */ si = NULL; - if_addr_rlock(ifp); + NET_EPOCH_ENTER(et); CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family == AF_INET) { si = (struct sockaddr_in *)ifa->ifa_addr; @@ -4882,7 +4884,7 @@ sppp_set_ip_addr(struct sppp *sp, u_long src) } } } - if_addr_runlock(ifp); + NET_EPOCH_EXIT(et); if (ifa != NULL) { int error; @@ -4921,6 +4923,7 @@ static void sppp_get_ip6_addrs(struct sppp *sp, struct in6_addr *src, struct in6_addr *dst, struct in6_addr *srcmask) { + struct epoch_tracker et; struct ifnet *ifp = SP2IFP(sp); struct ifaddr *ifa; struct sockaddr_in6 *si, *sm; @@ -4934,7 +4937,7 @@ sppp_get_ip6_addrs(struct sppp *sp, struct in6_addr *src, struct in6_addr *dst, * aliases don't make any sense on a p2p link anyway. */ si = NULL; - if_addr_rlock(ifp); + NET_EPOCH_ENTER(et); CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) if (ifa->ifa_addr->sa_family == AF_INET6) { si = (struct sockaddr_in6 *)ifa->ifa_addr; @@ -4960,7 +4963,7 @@ sppp_get_ip6_addrs(struct sppp *sp, struct in6_addr *src, struct in6_addr *dst, bcopy(&ddst, dst, sizeof(*dst)); if (src) bcopy(&ssrc, src, sizeof(*src)); - if_addr_runlock(ifp); + NET_EPOCH_EXIT(et); } #ifdef IPV6CP_MYIFID_DYN @@ -4980,6 +4983,7 @@ static void sppp_set_ip6_addr(struct sppp *sp, const struct in6_addr *src) { STDDCL; + struct epoch_tracker et; struct ifaddr *ifa; struct sockaddr_in6 *sin6; @@ -4989,7 +4993,7 @@ sppp_set_ip6_addr(struct sppp *sp, const struct in6_addr *src) */ sin6 = NULL; - if_addr_rlock(ifp); + NET_EPOCH_ENTER(et); CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family == AF_INET6) { sin6 = (struct sockaddr_in6 *)ifa->ifa_addr; @@ -4999,7 +5003,7 @@ sppp_set_ip6_addr(struct sppp *sp, const struct in6_addr *src) } } } - if_addr_runlock(ifp); + NET_EPOCH_EXIT(et); if (ifa != NULL) { int error;