summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2012-08-02 13:20:44 +0000
committerglebius <glebius@FreeBSD.org>2012-08-02 13:20:44 +0000
commit34fe3f296a23dcd2b2315ab9b7cbe217a7e36c17 (patch)
tree51861ac00bbe53eb774230ad7cd58bb5b39aa9ff
parent55897c521e10c657445e8cc5242b180b8557ffb0 (diff)
downloadFreeBSD-src-34fe3f296a23dcd2b2315ab9b7cbe217a7e36c17.zip
FreeBSD-src-34fe3f296a23dcd2b2315ab9b7cbe217a7e36c17.tar.gz
The llentry_update() is used only by flowtable and the latter
always passes NULL pointer to it. Thus, code can be simplified and function renamed to llentry_alloc() to match rtalloc().
-rw-r--r--sys/net/flowtable.c4
-rw-r--r--sys/net/if_llatbl.c31
-rw-r--r--sys/net/if_llatbl.h4
3 files changed, 15 insertions, 24 deletions
diff --git a/sys/net/flowtable.c b/sys/net/flowtable.c
index 0e50377..2e209ef 100644
--- a/sys/net/flowtable.c
+++ b/sys/net/flowtable.c
@@ -1258,7 +1258,7 @@ uncached:
else
l3addr = (struct sockaddr_storage *)&ro->ro_dst;
- llentry_update(&lle, LLTABLE6(ifp), l3addr, ifp);
+ lle = llentry_alloc(ifp, LLTABLE6(ifp), l3addr);
}
#endif
#ifdef INET
@@ -1267,7 +1267,7 @@ uncached:
l3addr = (struct sockaddr_storage *)rt->rt_gateway;
else
l3addr = (struct sockaddr_storage *)&ro->ro_dst;
- llentry_update(&lle, LLTABLE(ifp), l3addr, ifp);
+ lle = llentry_alloc(ifp, LLTABLE(ifp), l3addr);
}
#endif
diff --git a/sys/net/if_llatbl.c b/sys/net/if_llatbl.c
index a9c4199..2fc75ef 100644
--- a/sys/net/if_llatbl.c
+++ b/sys/net/if_llatbl.c
@@ -129,42 +129,33 @@ llentry_free(struct llentry *lle)
}
/*
- * Update an llentry for address dst (equivalent to rtalloc for new-arp)
- * Caller must pass in a valid struct llentry * (or NULL)
+ * (al)locate an llentry for address dst (equivalent to rtalloc for new-arp).
*
- * if found the llentry * is returned referenced and unlocked
+ * If found the llentry * is returned referenced and unlocked.
*/
-int
-llentry_update(struct llentry **llep, struct lltable *lt,
- struct sockaddr_storage *dst, struct ifnet *ifp)
+struct llentry *
+llentry_alloc(struct ifnet *ifp, struct lltable *lt,
+ struct sockaddr_storage *dst)
{
struct llentry *la;
IF_AFDATA_RLOCK(ifp);
- la = lla_lookup(lt, LLE_EXCLUSIVE,
- (struct sockaddr *)dst);
+ 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),
+ 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);
+
+ if (la != NULL) {
LLE_ADDREF(la);
LLE_WUNLOCK(la);
- *llep = la;
- } else if (la != NULL)
- LLE_WUNLOCK(la);
-
- if (la == NULL)
- return (ENOENT);
+ }
- return (0);
+ return (la);
}
/*
diff --git a/sys/net/if_llatbl.h b/sys/net/if_llatbl.h
index c1146d9..63bed22 100644
--- a/sys/net/if_llatbl.h
+++ b/sys/net/if_llatbl.h
@@ -189,8 +189,8 @@ void lltable_drain(int);
int lltable_sysctl_dumparp(int, struct sysctl_req *);
size_t llentry_free(struct llentry *);
-int llentry_update(struct llentry **, struct lltable *,
- struct sockaddr_storage *, struct ifnet *);
+struct llentry *llentry_alloc(struct ifnet *, struct lltable *,
+ struct sockaddr_storage *);
/*
* Generic link layer address lookup function.
OpenPOWER on IntegriCloud