diff options
author | kmacy <kmacy@FreeBSD.org> | 2009-04-16 22:04:07 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2009-04-16 22:04:07 +0000 |
commit | b371e11fe6e7db4d29c16837d494efca4897ff9c (patch) | |
tree | 4ccd3f7370cfdf8eca6a8f6d9cb14ff9327af3c9 /sys/net/if_llatbl.c | |
parent | 24b38efdce5f73d92ac948039ef4966d9502b484 (diff) | |
download | FreeBSD-src-b371e11fe6e7db4d29c16837d494efca4897ff9c.zip FreeBSD-src-b371e11fe6e7db4d29c16837d494efca4897ff9c.tar.gz |
add utility routine for updating an struct llentry *
Diffstat (limited to 'sys/net/if_llatbl.c')
-rw-r--r-- | sys/net/if_llatbl.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sys/net/if_llatbl.c b/sys/net/if_llatbl.c index 2287f92..d7fb37a 100644 --- a/sys/net/if_llatbl.c +++ b/sys/net/if_llatbl.c @@ -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, |