mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
add utility routine for updating an struct llentry *
This commit is contained in:
parent
279aa3d419
commit
c8da95ace9
@ -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,
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user