in.c (231852) | in.c (232054) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (C) 2001 WIDE Project. 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: --- 17 unchanged lines hidden (view full) --- 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * @(#)in.c 8.4 (Berkeley) 1/9/95 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (C) 2001 WIDE Project. 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: --- 17 unchanged lines hidden (view full) --- 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * @(#)in.c 8.4 (Berkeley) 1/9/95 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/in.c 231852 2012-02-17 02:39:58Z bz $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/in.c 232054 2012-02-23 18:21:37Z kmacy $"); |
35 36#include "opt_mpath.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/sockio.h> 41#include <sys/malloc.h> 42#include <sys/priv.h> --- 1212 unchanged lines hidden (view full) --- 1255 IN_MULTI_UNLOCK(); 1256} 1257 1258struct in_llentry { 1259 struct llentry base; 1260 struct sockaddr_in l3_addr4; 1261}; 1262 | 35 36#include "opt_mpath.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/sockio.h> 41#include <sys/malloc.h> 42#include <sys/priv.h> --- 1212 unchanged lines hidden (view full) --- 1255 IN_MULTI_UNLOCK(); 1256} 1257 1258struct in_llentry { 1259 struct llentry base; 1260 struct sockaddr_in l3_addr4; 1261}; 1262 |
1263/* 1264 * Deletes an address from the address table. 1265 * This function is called by the timer functions 1266 * such as arptimer() and nd6_llinfo_timer(), and 1267 * the caller does the locking. 1268 */ 1269static void 1270in_lltable_free(struct lltable *llt, struct llentry *lle) 1271{ 1272 LLE_WUNLOCK(lle); 1273 LLE_LOCK_DESTROY(lle); 1274 free(lle, M_LLTABLE); 1275} 1276 |
|
1263static struct llentry * 1264in_lltable_new(const struct sockaddr *l3addr, u_int flags) 1265{ 1266 struct in_llentry *lle; 1267 1268 lle = malloc(sizeof(struct in_llentry), M_LLTABLE, M_DONTWAIT | M_ZERO); 1269 if (lle == NULL) /* NB: caller generates msg */ 1270 return NULL; 1271 1272 callout_init(&lle->base.la_timer, CALLOUT_MPSAFE); 1273 /* 1274 * For IPv4 this will trigger "arpresolve" to generate 1275 * an ARP request. 1276 */ 1277 lle->base.la_expire = time_uptime; /* mark expired */ 1278 lle->l3_addr4 = *(const struct sockaddr_in *)l3addr; 1279 lle->base.lle_refcnt = 1; | 1277static struct llentry * 1278in_lltable_new(const struct sockaddr *l3addr, u_int flags) 1279{ 1280 struct in_llentry *lle; 1281 1282 lle = malloc(sizeof(struct in_llentry), M_LLTABLE, M_DONTWAIT | M_ZERO); 1283 if (lle == NULL) /* NB: caller generates msg */ 1284 return NULL; 1285 1286 callout_init(&lle->base.la_timer, CALLOUT_MPSAFE); 1287 /* 1288 * For IPv4 this will trigger "arpresolve" to generate 1289 * an ARP request. 1290 */ 1291 lle->base.la_expire = time_uptime; /* mark expired */ 1292 lle->l3_addr4 = *(const struct sockaddr_in *)l3addr; 1293 lle->base.lle_refcnt = 1; |
1294 lle->base.lle_free = in_lltable_free; |
|
1280 LLE_LOCK_INIT(&lle->base); 1281 return &lle->base; 1282} 1283 | 1295 LLE_LOCK_INIT(&lle->base); 1296 return &lle->base; 1297} 1298 |
1284/* 1285 * Deletes an address from the address table. 1286 * This function is called by the timer functions 1287 * such as arptimer() and nd6_llinfo_timer(), and 1288 * the caller does the locking. 1289 */ 1290static void 1291in_lltable_free(struct lltable *llt, struct llentry *lle) 1292{ 1293 LLE_WUNLOCK(lle); 1294 LLE_LOCK_DESTROY(lle); 1295 free(lle, M_LLTABLE); 1296} 1297 1298 | |
1299#define IN_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ 1300 (((ntohl((d)->sin_addr.s_addr) ^ (a)->sin_addr.s_addr) & (m)->sin_addr.s_addr)) == 0 ) 1301 1302static void 1303in_lltable_prefix_free(struct lltable *llt, 1304 const struct sockaddr *prefix, 1305 const struct sockaddr *mask, 1306 u_int flags) --- 265 unchanged lines hidden (view full) --- 1572{ 1573 struct in_ifinfo *ii; 1574 struct lltable *llt; 1575 1576 ii = malloc(sizeof(struct in_ifinfo), M_IFADDR, M_WAITOK|M_ZERO); 1577 1578 llt = lltable_init(ifp, AF_INET); 1579 if (llt != NULL) { | 1299#define IN_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \ 1300 (((ntohl((d)->sin_addr.s_addr) ^ (a)->sin_addr.s_addr) & (m)->sin_addr.s_addr)) == 0 ) 1301 1302static void 1303in_lltable_prefix_free(struct lltable *llt, 1304 const struct sockaddr *prefix, 1305 const struct sockaddr *mask, 1306 u_int flags) --- 265 unchanged lines hidden (view full) --- 1572{ 1573 struct in_ifinfo *ii; 1574 struct lltable *llt; 1575 1576 ii = malloc(sizeof(struct in_ifinfo), M_IFADDR, M_WAITOK|M_ZERO); 1577 1578 llt = lltable_init(ifp, AF_INET); 1579 if (llt != NULL) { |
1580 llt->llt_free = in_lltable_free; | |
1581 llt->llt_prefix_free = in_lltable_prefix_free; 1582 llt->llt_lookup = in_lltable_lookup; 1583 llt->llt_dump = in_lltable_dump; 1584 } 1585 ii->ii_llt = llt; 1586 1587 ii->ii_igmp = igmp_domifattach(ifp); 1588 --- 12 unchanged lines hidden --- | 1580 llt->llt_prefix_free = in_lltable_prefix_free; 1581 llt->llt_lookup = in_lltable_lookup; 1582 llt->llt_dump = in_lltable_dump; 1583 } 1584 ii->ii_llt = llt; 1585 1586 ii->ii_igmp = igmp_domifattach(ifp); 1587 --- 12 unchanged lines hidden --- |