nd6.c (80dbff4e99ba37534b40803a1ddff842f5ebdd58) | nd6.c (137f91e80f3802084bd96586d09961a846b91665) |
---|---|
1/*- 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 678 unchanged lines hidden (view full) --- 687static int 688regen_tmpaddr(struct in6_ifaddr *ia6) 689{ 690 struct ifaddr *ifa; 691 struct ifnet *ifp; 692 struct in6_ifaddr *public_ifa6 = NULL; 693 694 ifp = ia6->ia_ifa.ifa_ifp; | 1/*- 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 678 unchanged lines hidden (view full) --- 687static int 688regen_tmpaddr(struct in6_ifaddr *ia6) 689{ 690 struct ifaddr *ifa; 691 struct ifnet *ifp; 692 struct in6_ifaddr *public_ifa6 = NULL; 693 694 ifp = ia6->ia_ifa.ifa_ifp; |
695 IF_ADDR_LOCK(ifp); | 695 IF_ADDR_RLOCK(ifp); |
696 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 697 struct in6_ifaddr *it6; 698 699 if (ifa->ifa_addr->sa_family != AF_INET6) 700 continue; 701 702 it6 = (struct in6_ifaddr *)ifa; 703 --- 25 unchanged lines hidden (view full) --- 729 * address with the prefix. 730 */ 731 if (!IFA6_IS_DEPRECATED(it6)) 732 public_ifa6 = it6; 733 734 if (public_ifa6 != NULL) 735 ifa_ref(&public_ifa6->ia_ifa); 736 } | 696 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 697 struct in6_ifaddr *it6; 698 699 if (ifa->ifa_addr->sa_family != AF_INET6) 700 continue; 701 702 it6 = (struct in6_ifaddr *)ifa; 703 --- 25 unchanged lines hidden (view full) --- 729 * address with the prefix. 730 */ 731 if (!IFA6_IS_DEPRECATED(it6)) 732 public_ifa6 = it6; 733 734 if (public_ifa6 != NULL) 735 ifa_ref(&public_ifa6->ia_ifa); 736 } |
737 IF_ADDR_UNLOCK(ifp); | 737 IF_ADDR_RUNLOCK(ifp); |
738 739 if (public_ifa6 != NULL) { 740 int e; 741 742 if ((e = in6_tmpifadd(public_ifa6, 0, 0)) != 0) { 743 ifa_free(&public_ifa6->ia_ifa); 744 log(LOG_NOTICE, "regen_tmpaddr: failed to create a new" 745 " tmp addr,errno=%d\n", e); --- 615 unchanged lines hidden (view full) --- 1361 /* 1362 * If the interface is marked as ND6_IFF_IFDISABLED and 1363 * has an link-local address with IN6_IFF_DUPLICATED, 1364 * do not clear ND6_IFF_IFDISABLED. 1365 * See RFC 4862, Section 5.4.5. 1366 */ 1367 int duplicated_linklocal = 0; 1368 | 738 739 if (public_ifa6 != NULL) { 740 int e; 741 742 if ((e = in6_tmpifadd(public_ifa6, 0, 0)) != 0) { 743 ifa_free(&public_ifa6->ia_ifa); 744 log(LOG_NOTICE, "regen_tmpaddr: failed to create a new" 745 " tmp addr,errno=%d\n", e); --- 615 unchanged lines hidden (view full) --- 1361 /* 1362 * If the interface is marked as ND6_IFF_IFDISABLED and 1363 * has an link-local address with IN6_IFF_DUPLICATED, 1364 * do not clear ND6_IFF_IFDISABLED. 1365 * See RFC 4862, Section 5.4.5. 1366 */ 1367 int duplicated_linklocal = 0; 1368 |
1369 IF_ADDR_LOCK(ifp); | 1369 IF_ADDR_RLOCK(ifp); |
1370 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 1371 if (ifa->ifa_addr->sa_family != AF_INET6) 1372 continue; 1373 ia = (struct in6_ifaddr *)ifa; 1374 if ((ia->ia6_flags & IN6_IFF_DUPLICATED) && 1375 IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) { 1376 duplicated_linklocal = 1; 1377 break; 1378 } 1379 } | 1370 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 1371 if (ifa->ifa_addr->sa_family != AF_INET6) 1372 continue; 1373 ia = (struct in6_ifaddr *)ifa; 1374 if ((ia->ia6_flags & IN6_IFF_DUPLICATED) && 1375 IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) { 1376 duplicated_linklocal = 1; 1377 break; 1378 } 1379 } |
1380 IF_ADDR_UNLOCK(ifp); | 1380 IF_ADDR_RUNLOCK(ifp); |
1381 1382 if (duplicated_linklocal) { 1383 ND.flags |= ND6_IFF_IFDISABLED; 1384 log(LOG_ERR, "Cannot enable an interface" 1385 " with a link-local address marked" 1386 " duplicate.\n"); 1387 } else { 1388 ND_IFINFO(ifp)->flags &= ~ND6_IFF_IFDISABLED; 1389 if (ifp->if_flags & IFF_UP) 1390 in6_if_up(ifp); 1391 } 1392 } else if (!(ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) && 1393 (ND.flags & ND6_IFF_IFDISABLED)) { 1394 /* ifdisabled 0->1 transision */ 1395 /* Mark all IPv6 address as tentative. */ 1396 1397 ND_IFINFO(ifp)->flags |= ND6_IFF_IFDISABLED; | 1381 1382 if (duplicated_linklocal) { 1383 ND.flags |= ND6_IFF_IFDISABLED; 1384 log(LOG_ERR, "Cannot enable an interface" 1385 " with a link-local address marked" 1386 " duplicate.\n"); 1387 } else { 1388 ND_IFINFO(ifp)->flags &= ~ND6_IFF_IFDISABLED; 1389 if (ifp->if_flags & IFF_UP) 1390 in6_if_up(ifp); 1391 } 1392 } else if (!(ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) && 1393 (ND.flags & ND6_IFF_IFDISABLED)) { 1394 /* ifdisabled 0->1 transision */ 1395 /* Mark all IPv6 address as tentative. */ 1396 1397 ND_IFINFO(ifp)->flags |= ND6_IFF_IFDISABLED; |
1398 IF_ADDR_LOCK(ifp); | 1398 IF_ADDR_RLOCK(ifp); |
1399 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 1400 if (ifa->ifa_addr->sa_family != AF_INET6) 1401 continue; 1402 ia = (struct in6_ifaddr *)ifa; 1403 ia->ia6_flags |= IN6_IFF_TENTATIVE; 1404 } | 1399 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 1400 if (ifa->ifa_addr->sa_family != AF_INET6) 1401 continue; 1402 ia = (struct in6_ifaddr *)ifa; 1403 ia->ia6_flags |= IN6_IFF_TENTATIVE; 1404 } |
1405 IF_ADDR_UNLOCK(ifp); | 1405 IF_ADDR_RUNLOCK(ifp); |
1406 } 1407 1408 if (ND.flags & ND6_IFF_AUTO_LINKLOCAL) { 1409 if (!(ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL)) { 1410 /* auto_linklocal 0->1 transision */ 1411 1412 /* If no link-local address on ifp, configure */ 1413 ND_IFINFO(ifp)->flags |= ND6_IFF_AUTO_LINKLOCAL; 1414 in6_ifattach(ifp, NULL); 1415 } else if (!(ND.flags & ND6_IFF_IFDISABLED) && 1416 ifp->if_flags & IFF_UP) { 1417 /* 1418 * When the IF already has 1419 * ND6_IFF_AUTO_LINKLOCAL, no link-local 1420 * address is assigned, and IFF_UP, try to 1421 * assign one. 1422 */ 1423 int haslinklocal = 0; 1424 | 1406 } 1407 1408 if (ND.flags & ND6_IFF_AUTO_LINKLOCAL) { 1409 if (!(ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL)) { 1410 /* auto_linklocal 0->1 transision */ 1411 1412 /* If no link-local address on ifp, configure */ 1413 ND_IFINFO(ifp)->flags |= ND6_IFF_AUTO_LINKLOCAL; 1414 in6_ifattach(ifp, NULL); 1415 } else if (!(ND.flags & ND6_IFF_IFDISABLED) && 1416 ifp->if_flags & IFF_UP) { 1417 /* 1418 * When the IF already has 1419 * ND6_IFF_AUTO_LINKLOCAL, no link-local 1420 * address is assigned, and IFF_UP, try to 1421 * assign one. 1422 */ 1423 int haslinklocal = 0; 1424 |
1425 IF_ADDR_LOCK(ifp); | 1425 IF_ADDR_RLOCK(ifp); |
1426 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 1427 if (ifa->ifa_addr->sa_family != AF_INET6) 1428 continue; 1429 ia = (struct in6_ifaddr *)ifa; 1430 if (IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) { 1431 haslinklocal = 1; 1432 break; 1433 } 1434 } | 1426 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 1427 if (ifa->ifa_addr->sa_family != AF_INET6) 1428 continue; 1429 ia = (struct in6_ifaddr *)ifa; 1430 if (IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) { 1431 haslinklocal = 1; 1432 break; 1433 } 1434 } |
1435 IF_ADDR_UNLOCK(ifp); | 1435 IF_ADDR_RUNLOCK(ifp); |
1436 if (!haslinklocal) 1437 in6_ifattach(ifp, NULL); 1438 } 1439 } 1440 } 1441 ND_IFINFO(ifp)->flags = ND.flags; 1442 break; 1443#undef ND --- 947 unchanged lines hidden --- | 1436 if (!haslinklocal) 1437 in6_ifattach(ifp, NULL); 1438 } 1439 } 1440 } 1441 ND_IFINFO(ifp)->flags = ND.flags; 1442 break; 1443#undef ND --- 947 unchanged lines hidden --- |