if_llatbl.c (238967) | if_llatbl.c (238989) |
---|---|
1/* 2 * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved. 3 * Copyright (c) 2004-2008 Qing Li. All rights reserved. 4 * Copyright (c) 2008 Kip Macy. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved. 3 * Copyright (c) 2004-2008 Qing Li. All rights reserved. 4 * Copyright (c) 2008 Kip Macy. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/net/if_llatbl.c 238967 2012-08-01 09:00:26Z glebius $"); | 28__FBSDID("$FreeBSD: head/sys/net/if_llatbl.c 238989 2012-08-02 13:20:44Z glebius $"); |
29 30#include "opt_ddb.h" 31#include "opt_inet.h" 32#include "opt_inet6.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/malloc.h> --- 87 unchanged lines hidden (view full) --- 124 125 lle->la_flags &= ~LLE_VALID; 126 LLE_FREE_LOCKED(lle); 127 128 return (pkts_dropped); 129} 130 131/* | 29 30#include "opt_ddb.h" 31#include "opt_inet.h" 32#include "opt_inet6.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/malloc.h> --- 87 unchanged lines hidden (view full) --- 124 125 lle->la_flags &= ~LLE_VALID; 126 LLE_FREE_LOCKED(lle); 127 128 return (pkts_dropped); 129} 130 131/* |
132 * Update an llentry for address dst (equivalent to rtalloc for new-arp) 133 * Caller must pass in a valid struct llentry * (or NULL) | 132 * (al)locate an llentry for address dst (equivalent to rtalloc for new-arp). |
134 * | 133 * |
135 * if found the llentry * is returned referenced and unlocked | 134 * If found the llentry * is returned referenced and unlocked. |
136 */ | 135 */ |
137int 138llentry_update(struct llentry **llep, struct lltable *lt, 139 struct sockaddr_storage *dst, struct ifnet *ifp) | 136struct llentry * 137llentry_alloc(struct ifnet *ifp, struct lltable *lt, 138 struct sockaddr_storage *dst) |
140{ 141 struct llentry *la; 142 143 IF_AFDATA_RLOCK(ifp); | 139{ 140 struct llentry *la; 141 142 IF_AFDATA_RLOCK(ifp); |
144 la = lla_lookup(lt, LLE_EXCLUSIVE, 145 (struct sockaddr *)dst); | 143 la = lla_lookup(lt, LLE_EXCLUSIVE, (struct sockaddr *)dst); |
146 IF_AFDATA_RUNLOCK(ifp); 147 if ((la == NULL) && 148 (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) { 149 IF_AFDATA_WLOCK(ifp); | 144 IF_AFDATA_RUNLOCK(ifp); 145 if ((la == NULL) && 146 (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) == 0) { 147 IF_AFDATA_WLOCK(ifp); |
150 la = lla_lookup(lt, 151 (LLE_CREATE | LLE_EXCLUSIVE), | 148 la = lla_lookup(lt, (LLE_CREATE | LLE_EXCLUSIVE), |
152 (struct sockaddr *)dst); 153 IF_AFDATA_WUNLOCK(ifp); 154 } | 149 (struct sockaddr *)dst); 150 IF_AFDATA_WUNLOCK(ifp); 151 } |
155 if (la != NULL && (*llep != la)) { 156 if (*llep != NULL) 157 LLE_FREE(*llep); | 152 153 if (la != NULL) { |
158 LLE_ADDREF(la); 159 LLE_WUNLOCK(la); | 154 LLE_ADDREF(la); 155 LLE_WUNLOCK(la); |
160 *llep = la; 161 } else if (la != NULL) 162 LLE_WUNLOCK(la); | 156 } |
163 | 157 |
164 if (la == NULL) 165 return (ENOENT); 166 167 return (0); | 158 return (la); |
168} 169 170/* 171 * Free all entries from given table and free itself. 172 */ 173void 174lltable_free(struct lltable *llt) 175{ --- 367 unchanged lines hidden --- | 159} 160 161/* 162 * Free all entries from given table and free itself. 163 */ 164void 165lltable_free(struct lltable *llt) 166{ --- 367 unchanged lines hidden --- |