add utility routine for updating an struct llentry *

This commit is contained in:
Kip Macy 2009-04-16 22:04:07 +00:00
parent 279aa3d419
commit c8da95ace9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=191154
2 changed files with 35 additions and 0 deletions

View file

@ -103,6 +103,39 @@ llentry_free(struct llentry *lle)
LLE_FREE_LOCKED(lle);
}
int
llentry_update(struct llentry **llep, struct lltable *lt,
struct sockaddr *dst, struct ifnet *ifp)
{
struct llentry *la;
IF_AFDATA_RLOCK(ifp);
la = lla_lookup(lt, LLE_EXCLUSIVE,
(struct sockaddr *)dst);
IF_AFDATA_RUNLOCK(ifp);
if ((la == NULL) &&
(ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) {
IF_AFDATA_WLOCK(ifp);
la = lla_lookup(lt,
(LLE_CREATE | LLE_EXCLUSIVE),
(struct sockaddr *)dst);
IF_AFDATA_WUNLOCK(ifp);
}
if (la != NULL && (*llep != la)) {
if (*llep != NULL)
LLE_FREE(*llep);
LLE_ADDREF(la);
LLE_WUNLOCK(la);
*llep = la;
} else if (la != NULL)
LLE_WUNLOCK(la);
if (la == NULL)
return (ENOENT);
return (0);
}
/*
* Free all entries from given table and free itself.
* Since lltables collects from all of the intefaces,

View file

@ -178,6 +178,8 @@ void lltable_drain(int);
int lltable_sysctl_dumparp(int, struct sysctl_req *);
void llentry_free(struct llentry *);
int llentry_update(struct llentry **, struct lltable *,
struct sockaddr *, struct ifnet *);
/*
* Generic link layer address lookup function.