svn commit: r191154 - head/sys/net

Kip Macy kmacy at FreeBSD.org
Thu Apr 16 22:04:08 UTC 2009


Author: kmacy
Date: Thu Apr 16 22:04:07 2009
New Revision: 191154
URL: http://svn.freebsd.org/changeset/base/191154

Log:
  add utility routine for updating an struct llentry *

Modified:
  head/sys/net/if_llatbl.c
  head/sys/net/if_llatbl.h

Modified: head/sys/net/if_llatbl.c
==============================================================================
--- head/sys/net/if_llatbl.c	Thu Apr 16 21:59:45 2009	(r191153)
+++ head/sys/net/if_llatbl.c	Thu Apr 16 22:04:07 2009	(r191154)
@@ -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,

Modified: head/sys/net/if_llatbl.h
==============================================================================
--- head/sys/net/if_llatbl.h	Thu Apr 16 21:59:45 2009	(r191153)
+++ head/sys/net/if_llatbl.h	Thu Apr 16 22:04:07 2009	(r191154)
@@ -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.


More information about the svn-src-head mailing list