mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
Reduce the overhead of locking, use IF_AFDATA_RLOCK() when we are doing
simple lookups. Sponsored by: Yandex LLC MFC after: 1 week
This commit is contained in:
parent
ae7dc19cd1
commit
73cb2f38f2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=243148
@ -2677,9 +2677,9 @@ icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
|
||||
struct nd_opt_hdr *nd_opt;
|
||||
char *lladdr;
|
||||
|
||||
IF_AFDATA_LOCK(ifp);
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
ln = nd6_lookup(router_ll6, 0, ifp);
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
if (ln == NULL)
|
||||
goto nolladdropt;
|
||||
|
||||
|
@ -609,9 +609,9 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
|
||||
|
||||
rt = ron->ro_rt;
|
||||
ifp = rt->rt_ifp;
|
||||
IF_AFDATA_LOCK(ifp);
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
la = lla_lookup(LLTABLE6(ifp), 0, (struct sockaddr *)&sin6_next->sin6_addr);
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
if (la != NULL)
|
||||
LLE_RUNLOCK(la);
|
||||
else {
|
||||
|
@ -686,10 +686,10 @@ ip6_input(struct mbuf *m)
|
||||
dst6.sin6_len = sizeof(struct sockaddr_in6);
|
||||
dst6.sin6_addr = ip6->ip6_dst;
|
||||
ifp = m->m_pkthdr.rcvif;
|
||||
IF_AFDATA_LOCK(ifp);
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
lle = lla_lookup(LLTABLE6(ifp), 0,
|
||||
(struct sockaddr *)&dst6);
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
if ((lle != NULL) && (lle->la_flags & LLE_IFADDR)) {
|
||||
struct ifaddr *ifa;
|
||||
struct in6_ifaddr *ia6;
|
||||
|
@ -975,12 +975,12 @@ nd6_is_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp)
|
||||
* Even if the address matches none of our addresses, it might be
|
||||
* in the neighbor cache.
|
||||
*/
|
||||
IF_AFDATA_LOCK(ifp);
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
if ((lle = nd6_lookup(&addr->sin6_addr, 0, ifp)) != NULL) {
|
||||
LLE_RUNLOCK(lle);
|
||||
rc = 1;
|
||||
}
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
@ -1480,9 +1480,9 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
|
||||
if ((error = in6_setscope(&nb_addr, ifp, NULL)) != 0)
|
||||
return (error);
|
||||
|
||||
IF_AFDATA_LOCK(ifp);
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
ln = nd6_lookup(&nb_addr, 0, ifp);
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
|
||||
if (ln == NULL) {
|
||||
error = EINVAL;
|
||||
@ -2198,9 +2198,9 @@ nd6_storelladdr(struct ifnet *ifp, struct mbuf *m,
|
||||
/*
|
||||
* the entry should have been created in nd6_store_lladdr
|
||||
*/
|
||||
IF_AFDATA_LOCK(ifp);
|
||||
IF_AFDATA_RLOCK(ifp);
|
||||
ln = lla_lookup(LLTABLE6(ifp), 0, dst);
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
IF_AFDATA_RUNLOCK(ifp);
|
||||
if ((ln == NULL) || !(ln->la_flags & LLE_VALID)) {
|
||||
if (ln != NULL)
|
||||
LLE_RUNLOCK(ln);
|
||||
|
@ -637,13 +637,13 @@ defrouter_select(void)
|
||||
* the ordering rule of the list described in defrtrlist_update().
|
||||
*/
|
||||
TAILQ_FOREACH(dr, &V_nd_defrouter, dr_entry) {
|
||||
IF_AFDATA_LOCK(dr->ifp);
|
||||
IF_AFDATA_RLOCK(dr->ifp);
|
||||
if (selected_dr == NULL &&
|
||||
(ln = nd6_lookup(&dr->rtaddr, 0, dr->ifp)) &&
|
||||
ND6_IS_LLINFO_PROBREACH(ln)) {
|
||||
selected_dr = dr;
|
||||
}
|
||||
IF_AFDATA_UNLOCK(dr->ifp);
|
||||
IF_AFDATA_RUNLOCK(dr->ifp);
|
||||
if (ln != NULL) {
|
||||
LLE_RUNLOCK(ln);
|
||||
ln = NULL;
|
||||
@ -671,13 +671,13 @@ defrouter_select(void)
|
||||
else
|
||||
selected_dr = TAILQ_NEXT(installed_dr, dr_entry);
|
||||
} else if (installed_dr) {
|
||||
IF_AFDATA_LOCK(installed_dr->ifp);
|
||||
IF_AFDATA_RLOCK(installed_dr->ifp);
|
||||
if ((ln = nd6_lookup(&installed_dr->rtaddr, 0, installed_dr->ifp)) &&
|
||||
ND6_IS_LLINFO_PROBREACH(ln) &&
|
||||
rtpref(selected_dr) <= rtpref(installed_dr)) {
|
||||
selected_dr = installed_dr;
|
||||
}
|
||||
IF_AFDATA_UNLOCK(installed_dr->ifp);
|
||||
IF_AFDATA_RUNLOCK(installed_dr->ifp);
|
||||
if (ln != NULL)
|
||||
LLE_RUNLOCK(ln);
|
||||
}
|
||||
@ -1301,9 +1301,9 @@ find_pfxlist_reachable_router(struct nd_prefix *pr)
|
||||
int canreach;
|
||||
|
||||
LIST_FOREACH(pfxrtr, &pr->ndpr_advrtrs, pfr_entry) {
|
||||
IF_AFDATA_LOCK(pfxrtr->router->ifp);
|
||||
IF_AFDATA_RLOCK(pfxrtr->router->ifp);
|
||||
ln = nd6_lookup(&pfxrtr->router->rtaddr, 0, pfxrtr->router->ifp);
|
||||
IF_AFDATA_UNLOCK(pfxrtr->router->ifp);
|
||||
IF_AFDATA_RUNLOCK(pfxrtr->router->ifp);
|
||||
if (ln == NULL)
|
||||
continue;
|
||||
canreach = ND6_IS_LLINFO_PROBREACH(ln);
|
||||
|
Loading…
Reference in New Issue
Block a user