Deleted Added
full compact
in.c (286577) in.c (286616)
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 286577 2015-08-10 12:03:59Z melifaro $");
34__FBSDID("$FreeBSD: head/sys/netinet/in.c 286616 2015-08-11 05:51:00Z melifaro $");
35
36#include "opt_mpath.h"
37
38#include <sys/param.h>
39#include <sys/eventhandler.h>
40#include <sys/systm.h>
41#include <sys/sockio.h>
42#include <sys/malloc.h>

--- 1111 unchanged lines hidden (view full) ---

1154static inline struct llentry *
1155in_lltable_find_dst(struct lltable *llt, struct in_addr dst)
1156{
1157 struct llentry *lle;
1158 struct llentries *lleh;
1159 struct sockaddr_in *sin;
1160 u_int hashidx;
1161
35
36#include "opt_mpath.h"
37
38#include <sys/param.h>
39#include <sys/eventhandler.h>
40#include <sys/systm.h>
41#include <sys/sockio.h>
42#include <sys/malloc.h>

--- 1111 unchanged lines hidden (view full) ---

1154static inline struct llentry *
1155in_lltable_find_dst(struct lltable *llt, struct in_addr dst)
1156{
1157 struct llentry *lle;
1158 struct llentries *lleh;
1159 struct sockaddr_in *sin;
1160 u_int hashidx;
1161
1162 hashidx = in_lltable_hash_dst(dst, LLTBL_HASHTBL_SIZE);
1162 hashidx = in_lltable_hash_dst(dst, llt->llt_hsize);
1163 lleh = &llt->lle_head[hashidx];
1164 LIST_FOREACH(lle, lleh, lle_next) {
1165 sin = satosin(L3_ADDR(lle));
1166 if (lle->la_flags & LLE_DELETED)
1167 continue;
1168 if (sin->sin_addr.s_addr == dst.s_addr)
1169 break;
1170 }

--- 166 unchanged lines hidden (view full) ---

1337 if (lle->la_flags & LLE_STATIC)
1338 arpc.rtm.rtm_flags |= RTF_STATIC;
1339 arpc.rtm.rtm_index = ifp->if_index;
1340 error = SYSCTL_OUT(wr, &arpc, sizeof(arpc));
1341
1342 return (error);
1343}
1344
1163 lleh = &llt->lle_head[hashidx];
1164 LIST_FOREACH(lle, lleh, lle_next) {
1165 sin = satosin(L3_ADDR(lle));
1166 if (lle->la_flags & LLE_DELETED)
1167 continue;
1168 if (sin->sin_addr.s_addr == dst.s_addr)
1169 break;
1170 }

--- 166 unchanged lines hidden (view full) ---

1337 if (lle->la_flags & LLE_STATIC)
1338 arpc.rtm.rtm_flags |= RTF_STATIC;
1339 arpc.rtm.rtm_index = ifp->if_index;
1340 error = SYSCTL_OUT(wr, &arpc, sizeof(arpc));
1341
1342 return (error);
1343}
1344
1345static struct lltable *
1346in_lltattach(struct ifnet *ifp)
1347{
1348 struct lltable *llt;
1349
1350 llt = lltable_allocate_htbl(IN_LLTBL_DEFAULT_HSIZE);
1351 llt->llt_af = AF_INET;
1352 llt->llt_ifp = ifp;
1353
1354 llt->llt_lookup = in_lltable_lookup;
1355 llt->llt_create = in_lltable_create;
1356 llt->llt_delete = in_lltable_delete;
1357 llt->llt_dump_entry = in_lltable_dump_entry;
1358 llt->llt_hash = in_lltable_hash;
1359 llt->llt_fill_sa_entry = in_lltable_fill_sa_entry;
1360 llt->llt_free_entry = in_lltable_free_entry;
1361 llt->llt_match_prefix = in_lltable_match_prefix;
1362 lltable_link(llt);
1363
1364 return (llt);
1365}
1366
1345void *
1346in_domifattach(struct ifnet *ifp)
1347{
1348 struct in_ifinfo *ii;
1367void *
1368in_domifattach(struct ifnet *ifp)
1369{
1370 struct in_ifinfo *ii;
1349 struct lltable *llt;
1350
1351 ii = malloc(sizeof(struct in_ifinfo), M_IFADDR, M_WAITOK|M_ZERO);
1352
1371
1372 ii = malloc(sizeof(struct in_ifinfo), M_IFADDR, M_WAITOK|M_ZERO);
1373
1353 llt = lltable_init(ifp, AF_INET);
1354 if (llt != NULL) {
1355 llt->llt_lookup = in_lltable_lookup;
1356 llt->llt_create = in_lltable_create;
1357 llt->llt_delete = in_lltable_delete;
1358 llt->llt_dump_entry = in_lltable_dump_entry;
1359 llt->llt_hash = in_lltable_hash;
1360 llt->llt_fill_sa_entry = in_lltable_fill_sa_entry;
1361 llt->llt_free_entry = in_lltable_free_entry;
1362 llt->llt_match_prefix = in_lltable_match_prefix;
1363 }
1364 ii->ii_llt = llt;
1365
1374 ii->ii_llt = in_lltattach(ifp);
1366 ii->ii_igmp = igmp_domifattach(ifp);
1367
1375 ii->ii_igmp = igmp_domifattach(ifp);
1376
1368 return ii;
1377 return (ii);
1369}
1370
1371void
1372in_domifdetach(struct ifnet *ifp, void *aux)
1373{
1374 struct in_ifinfo *ii = (struct in_ifinfo *)aux;
1375
1376 igmp_domifdetach(ifp);
1377 lltable_free(ii->ii_llt);
1378 free(ii, M_IFADDR);
1379}
1378}
1379
1380void
1381in_domifdetach(struct ifnet *ifp, void *aux)
1382{
1383 struct in_ifinfo *ii = (struct in_ifinfo *)aux;
1384
1385 igmp_domifdetach(ifp);
1386 lltable_free(ii->ii_llt);
1387 free(ii, M_IFADDR);
1388}