Deleted Added
full compact
in.c (192262) in.c (192476)
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 192262 2009-05-17 20:53:10Z bz $");
34__FBSDID("$FreeBSD: head/sys/netinet/in.c 192476 2009-05-20 21:07:15Z qingli $");
35
36#include "opt_carp.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>

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

1008static int
1009in_scrubprefix(struct in_ifaddr *target)
1010{
1011 INIT_VNET_NET(curvnet);
1012 INIT_VNET_INET(curvnet);
1013 struct in_ifaddr *ia;
1014 struct in_addr prefix, mask, p;
1015 int error;
35
36#include "opt_carp.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>

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

1008static int
1009in_scrubprefix(struct in_ifaddr *target)
1010{
1011 INIT_VNET_NET(curvnet);
1012 INIT_VNET_INET(curvnet);
1013 struct in_ifaddr *ia;
1014 struct in_addr prefix, mask, p;
1015 int error;
1016 struct sockaddr_in prefix0, mask0;
1016 struct rt_addrinfo info;
1017 struct sockaddr_dl null_sdl;
1018
1019 if ((target->ia_flags & IFA_ROUTE) == 0)
1020 return (0);
1021
1022 if ((target->ia_addr.sin_addr.s_addr != INADDR_ANY) &&
1023 !(target->ia_ifp->if_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) {

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

1077 rtinitflags(ia) | RTF_UP);
1078 if (error == 0)
1079 ia->ia_flags |= IFA_ROUTE;
1080 return (error);
1081 }
1082 }
1083
1084 /*
1017 struct rt_addrinfo info;
1018 struct sockaddr_dl null_sdl;
1019
1020 if ((target->ia_flags & IFA_ROUTE) == 0)
1021 return (0);
1022
1023 if ((target->ia_addr.sin_addr.s_addr != INADDR_ANY) &&
1024 !(target->ia_ifp->if_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) {

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

1078 rtinitflags(ia) | RTF_UP);
1079 if (error == 0)
1080 ia->ia_flags |= IFA_ROUTE;
1081 return (error);
1082 }
1083 }
1084
1085 /*
1086 * remove all L2 entries on the given prefix
1087 */
1088 bzero(&prefix0, sizeof(prefix0));
1089 prefix0.sin_len = sizeof(prefix0);
1090 prefix0.sin_family = AF_INET;
1091 prefix0.sin_addr.s_addr = target->ia_subnet;
1092 bzero(&mask0, sizeof(mask0));
1093 mask0.sin_len = sizeof(mask0);
1094 mask0.sin_family = AF_INET;
1095 mask0.sin_addr.s_addr = target->ia_subnetmask;
1096 lltable_prefix_free(AF_INET, (struct sockaddr *)&prefix0,
1097 (struct sockaddr *)&mask0);
1098
1099 /*
1085 * As no-one seem to have this prefix, we can remove the route.
1086 */
1087 rtinit(&(target->ia_ifa), (int)RTM_DELETE, rtinitflags(target));
1088 target->ia_flags &= ~IFA_ROUTE;
1089 return (0);
1090}
1091
1092#undef rtinitflags

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

1227static void
1228in_lltable_free(struct lltable *llt, struct llentry *lle)
1229{
1230 LLE_WUNLOCK(lle);
1231 LLE_LOCK_DESTROY(lle);
1232 free(lle, M_LLTABLE);
1233}
1234
1100 * As no-one seem to have this prefix, we can remove the route.
1101 */
1102 rtinit(&(target->ia_ifa), (int)RTM_DELETE, rtinitflags(target));
1103 target->ia_flags &= ~IFA_ROUTE;
1104 return (0);
1105}
1106
1107#undef rtinitflags

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

1242static void
1243in_lltable_free(struct lltable *llt, struct llentry *lle)
1244{
1245 LLE_WUNLOCK(lle);
1246 LLE_LOCK_DESTROY(lle);
1247 free(lle, M_LLTABLE);
1248}
1249
1250
1251#define IN_ARE_MASKED_ADDR_EQUAL(d, a, m) ( \
1252 (((ntohl((d)->sin_addr.s_addr) ^ (a)->sin_addr.s_addr) & (m)->sin_addr.s_addr)) == 0 )
1253
1254static void
1255in_lltable_prefix_free(struct lltable *llt,
1256 const struct sockaddr *prefix,
1257 const struct sockaddr *mask)
1258{
1259 const struct sockaddr_in *pfx = (const struct sockaddr_in *)prefix;
1260 const struct sockaddr_in *msk = (const struct sockaddr_in *)mask;
1261 struct llentry *lle, *next;
1262 register int i;
1263
1264 for (i=0; i < LLTBL_HASHTBL_SIZE; i++) {
1265 LIST_FOREACH_SAFE(lle, &llt->lle_head[i], lle_next, next) {
1266
1267 if (IN_ARE_MASKED_ADDR_EQUAL((struct sockaddr_in *)L3_ADDR(lle),
1268 pfx, msk)) {
1269 callout_drain(&lle->la_timer);
1270 LLE_WLOCK(lle);
1271 llentry_free(lle);
1272 }
1273 }
1274 }
1275}
1276
1277
1235static int
1236in_lltable_rtcheck(struct ifnet *ifp, const struct sockaddr *l3addr)
1237{
1238 struct rtentry *rt;
1239
1240 KASSERT(l3addr->sa_family == AF_INET,
1241 ("sin_family %d", l3addr->sa_family));
1242

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

1417 struct lltable *llt;
1418
1419 ii = malloc(sizeof(struct in_ifinfo), M_IFADDR, M_WAITOK|M_ZERO);
1420
1421 llt = lltable_init(ifp, AF_INET);
1422 if (llt != NULL) {
1423 llt->llt_new = in_lltable_new;
1424 llt->llt_free = in_lltable_free;
1278static int
1279in_lltable_rtcheck(struct ifnet *ifp, const struct sockaddr *l3addr)
1280{
1281 struct rtentry *rt;
1282
1283 KASSERT(l3addr->sa_family == AF_INET,
1284 ("sin_family %d", l3addr->sa_family));
1285

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

1460 struct lltable *llt;
1461
1462 ii = malloc(sizeof(struct in_ifinfo), M_IFADDR, M_WAITOK|M_ZERO);
1463
1464 llt = lltable_init(ifp, AF_INET);
1465 if (llt != NULL) {
1466 llt->llt_new = in_lltable_new;
1467 llt->llt_free = in_lltable_free;
1468 llt->llt_prefix_free = in_lltable_prefix_free;
1425 llt->llt_rtcheck = in_lltable_rtcheck;
1426 llt->llt_lookup = in_lltable_lookup;
1427 llt->llt_dump = in_lltable_dump;
1428 }
1429 ii->ii_llt = llt;
1430
1431 ii->ii_igmp = igmp_domifattach(ifp);
1432

--- 12 unchanged lines hidden ---
1469 llt->llt_rtcheck = in_lltable_rtcheck;
1470 llt->llt_lookup = in_lltable_lookup;
1471 llt->llt_dump = in_lltable_dump;
1472 }
1473 ii->ii_llt = llt;
1474
1475 ii->ii_igmp = igmp_domifattach(ifp);
1476

--- 12 unchanged lines hidden ---