Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Apr 2009 22:04:07 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r191154 - head/sys/net
Message-ID:  <200904162204.n3GM47sG093171@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904162204.n3GM47sG093171>