From owner-svn-src-all@FreeBSD.ORG Thu Apr 16 22:04:07 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1898106566C; Thu, 16 Apr 2009 22:04:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CFF6B8FC14; Thu, 16 Apr 2009 22:04:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3GM47Sr093173; Thu, 16 Apr 2009 22:04:07 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3GM47sG093171; Thu, 16 Apr 2009 22:04:07 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200904162204.n3GM47sG093171@svn.freebsd.org> From: Kip Macy Date: Thu, 16 Apr 2009 22:04:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r191154 - head/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Apr 2009 22:04:08 -0000 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.