[Midnightbsd-cvs] src [8042] trunk/sys/net: The llentry_update() is used only by flowtable and the latter

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Thu Sep 15 16:51:01 EDT 2016


Revision: 8042
          http://svnweb.midnightbsd.org/src/?rev=8042
Author:   laffer1
Date:     2016-09-15 16:51:01 -0400 (Thu, 15 Sep 2016)
Log Message:
-----------
 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().

Modified Paths:
--------------
    trunk/sys/net/flowtable.c
    trunk/sys/net/if_llatbl.c
    trunk/sys/net/if_llatbl.h

Modified: trunk/sys/net/flowtable.c
===================================================================
--- trunk/sys/net/flowtable.c	2016-09-15 20:50:03 UTC (rev 8041)
+++ trunk/sys/net/flowtable.c	2016-09-15 20:51:01 UTC (rev 8042)
@@ -1257,7 +1257,7 @@
 			
 			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
@@ -1266,7 +1266,7 @@
 				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

Modified: trunk/sys/net/if_llatbl.c
===================================================================
--- trunk/sys/net/if_llatbl.c	2016-09-15 20:50:03 UTC (rev 8041)
+++ trunk/sys/net/if_llatbl.c	2016-09-15 20:51:01 UTC (rev 8042)
@@ -132,42 +132,33 @@
 }
 
 /*
- * 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);
 }
 
 /*

Modified: trunk/sys/net/if_llatbl.h
===================================================================
--- trunk/sys/net/if_llatbl.h	2016-09-15 20:50:03 UTC (rev 8041)
+++ trunk/sys/net/if_llatbl.h	2016-09-15 20:51:01 UTC (rev 8042)
@@ -189,8 +189,8 @@
 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.



More information about the Midnightbsd-cvs mailing list