nd6_rtr.c (120727) | nd6_rtr.c (120856) |
---|---|
1/* $FreeBSD: head/sys/netinet6/nd6_rtr.c 120727 2003-10-04 03:44:50Z sam $ */ | 1/* $FreeBSD: head/sys/netinet6/nd6_rtr.c 120856 2003-10-06 14:02:09Z ume $ */ |
2/* $KAME: nd6_rtr.c,v 1.111 2001/04/27 01:37:15 jinmei Exp $ */ 3 4/* 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 535 unchanged lines hidden (view full) --- 545 struct in6_addr *addr; 546 struct ifnet *ifp; 547{ 548 struct nd_defrouter *dr; 549 550 for (dr = TAILQ_FIRST(&nd_defrouter); dr; 551 dr = TAILQ_NEXT(dr, dr_entry)) { 552 if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr)) | 2/* $KAME: nd6_rtr.c,v 1.111 2001/04/27 01:37:15 jinmei Exp $ */ 3 4/* 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 535 unchanged lines hidden (view full) --- 545 struct in6_addr *addr; 546 struct ifnet *ifp; 547{ 548 struct nd_defrouter *dr; 549 550 for (dr = TAILQ_FIRST(&nd_defrouter); dr; 551 dr = TAILQ_NEXT(dr, dr_entry)) { 552 if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr)) |
553 return(dr); | 553 return (dr); |
554 } 555 | 554 } 555 |
556 return(NULL); /* search failed */ | 556 return (NULL); /* search failed */ |
557} 558 559void 560defrouter_delreq(dr, dofree) 561 struct nd_defrouter *dr; 562 int dofree; 563{ 564 struct sockaddr_in6 def, mask, gate; --- 159 unchanged lines hidden (view full) --- 724 dr = NULL; 725 } else { 726 /* override */ 727 dr->flags = new->flags; /* xxx flag check */ 728 dr->rtlifetime = new->rtlifetime; 729 dr->expire = new->expire; 730 } 731 splx(s); | 557} 558 559void 560defrouter_delreq(dr, dofree) 561 struct nd_defrouter *dr; 562 int dofree; 563{ 564 struct sockaddr_in6 def, mask, gate; --- 159 unchanged lines hidden (view full) --- 724 dr = NULL; 725 } else { 726 /* override */ 727 dr->flags = new->flags; /* xxx flag check */ 728 dr->rtlifetime = new->rtlifetime; 729 dr->expire = new->expire; 730 } 731 splx(s); |
732 return(dr); | 732 return (dr); |
733 } 734 735 /* entry does not exist */ 736 if (new->rtlifetime == 0) { 737 splx(s); | 733 } 734 735 /* entry does not exist */ 736 if (new->rtlifetime == 0) { 737 splx(s); |
738 return(NULL); | 738 return (NULL); |
739 } 740 741 n = (struct nd_defrouter *)malloc(sizeof(*n), M_IP6NDP, M_NOWAIT); 742 if (n == NULL) { 743 splx(s); | 739 } 740 741 n = (struct nd_defrouter *)malloc(sizeof(*n), M_IP6NDP, M_NOWAIT); 742 if (n == NULL) { 743 splx(s); |
744 return(NULL); | 744 return (NULL); |
745 } 746 bzero(n, sizeof(*n)); 747 *n = *new; 748 749 /* 750 * Insert the new router at the end of the Default Router List. 751 * If there is no other router, install it anyway. Otherwise, 752 * just continue to use the current default router. 753 */ 754 TAILQ_INSERT_TAIL(&nd_defrouter, n, dr_entry); 755 if (TAILQ_FIRST(&nd_defrouter) == n) 756 defrouter_select(); 757 splx(s); 758 | 745 } 746 bzero(n, sizeof(*n)); 747 *n = *new; 748 749 /* 750 * Insert the new router at the end of the Default Router List. 751 * If there is no other router, install it anyway. Otherwise, 752 * just continue to use the current default router. 753 */ 754 TAILQ_INSERT_TAIL(&nd_defrouter, n, dr_entry); 755 if (TAILQ_FIRST(&nd_defrouter) == n) 756 defrouter_select(); 757 splx(s); 758 |
759 return(n); | 759 return (n); |
760} 761 762static struct nd_pfxrouter * 763pfxrtr_lookup(pr, dr) 764 struct nd_prefix *pr; 765 struct nd_defrouter *dr; 766{ 767 struct nd_pfxrouter *search; 768 769 for (search = pr->ndpr_advrtrs.lh_first; search; search = search->pfr_next) { 770 if (search->router == dr) 771 break; 772 } 773 | 760} 761 762static struct nd_pfxrouter * 763pfxrtr_lookup(pr, dr) 764 struct nd_prefix *pr; 765 struct nd_defrouter *dr; 766{ 767 struct nd_pfxrouter *search; 768 769 for (search = pr->ndpr_advrtrs.lh_first; search; search = search->pfr_next) { 770 if (search->router == dr) 771 break; 772 } 773 |
774 return(search); | 774 return (search); |
775} 776 777static void 778pfxrtr_add(pr, dr) 779 struct nd_prefix *pr; 780 struct nd_defrouter *dr; 781{ 782 struct nd_pfxrouter *new; --- 29 unchanged lines hidden (view full) --- 812 in6_are_prefix_equal(&pr->ndpr_prefix.sin6_addr, 813 &search->ndpr_prefix.sin6_addr, 814 pr->ndpr_plen) 815 ) { 816 break; 817 } 818 } 819 | 775} 776 777static void 778pfxrtr_add(pr, dr) 779 struct nd_prefix *pr; 780 struct nd_defrouter *dr; 781{ 782 struct nd_pfxrouter *new; --- 29 unchanged lines hidden (view full) --- 812 in6_are_prefix_equal(&pr->ndpr_prefix.sin6_addr, 813 &search->ndpr_prefix.sin6_addr, 814 pr->ndpr_plen) 815 ) { 816 break; 817 } 818 } 819 |
820 return(search); | 820 return (search); |
821} 822 823int 824nd6_prelist_add(pr, dr, newp) 825 struct nd_prefix *pr, **newp; 826 struct nd_defrouter *dr; 827{ 828 struct nd_prefix *new = NULL; --- 398 unchanged lines hidden (view full) --- 1227 pfxrtr = LIST_NEXT(pfxrtr, pfr_entry)) { 1228 if ((rt = nd6_lookup(&pfxrtr->router->rtaddr, 0, 1229 pfxrtr->router->ifp)) && 1230 (ln = (struct llinfo_nd6 *)rt->rt_llinfo) && 1231 ND6_IS_LLINFO_PROBREACH(ln)) 1232 break; /* found */ 1233 } 1234 | 821} 822 823int 824nd6_prelist_add(pr, dr, newp) 825 struct nd_prefix *pr, **newp; 826 struct nd_defrouter *dr; 827{ 828 struct nd_prefix *new = NULL; --- 398 unchanged lines hidden (view full) --- 1227 pfxrtr = LIST_NEXT(pfxrtr, pfr_entry)) { 1228 if ((rt = nd6_lookup(&pfxrtr->router->rtaddr, 0, 1229 pfxrtr->router->ifp)) && 1230 (ln = (struct llinfo_nd6 *)rt->rt_llinfo) && 1231 ND6_IS_LLINFO_PROBREACH(ln)) 1232 break; /* found */ 1233 } 1234 |
1235 return(pfxrtr); | 1235 return (pfxrtr); |
1236 1237} 1238 1239/* 1240 * Check if each prefix in the prefix list has at least one available router 1241 * that advertised the prefix (a router is "available" if its neighbor cache 1242 * entry is reachable or probably reachable). 1243 * If the check fails, the prefix may be off-link, because, for example, --- 159 unchanged lines hidden (view full) --- 1403 int error = 0; 1404 struct rtentry *rt = NULL; 1405 1406 /* sanity check */ 1407 if ((pr->ndpr_stateflags & NDPRF_ONLINK) != 0) { 1408 nd6log((LOG_ERR, 1409 "nd6_prefix_onlink: %s/%d is already on-link\n", 1410 ip6_sprintf(&pr->ndpr_prefix.sin6_addr), pr->ndpr_plen); | 1236 1237} 1238 1239/* 1240 * Check if each prefix in the prefix list has at least one available router 1241 * that advertised the prefix (a router is "available" if its neighbor cache 1242 * entry is reachable or probably reachable). 1243 * If the check fails, the prefix may be off-link, because, for example, --- 159 unchanged lines hidden (view full) --- 1403 int error = 0; 1404 struct rtentry *rt = NULL; 1405 1406 /* sanity check */ 1407 if ((pr->ndpr_stateflags & NDPRF_ONLINK) != 0) { 1408 nd6log((LOG_ERR, 1409 "nd6_prefix_onlink: %s/%d is already on-link\n", 1410 ip6_sprintf(&pr->ndpr_prefix.sin6_addr), pr->ndpr_plen); |
1411 return(EEXIST)); | 1411 return (EEXIST)); |
1412 } 1413 1414 /* 1415 * Add the interface route associated with the prefix. Before 1416 * installing the route, check if there's the same prefix on another 1417 * interface, and the prefix has already installed the interface route. 1418 * Although such a configuration is expected to be rare, we explicitly 1419 * allow it. --- 4 unchanged lines hidden (view full) --- 1424 1425 if ((opr->ndpr_stateflags & NDPRF_ONLINK) == 0) 1426 continue; 1427 1428 if (opr->ndpr_plen == pr->ndpr_plen && 1429 in6_are_prefix_equal(&pr->ndpr_prefix.sin6_addr, 1430 &opr->ndpr_prefix.sin6_addr, 1431 pr->ndpr_plen)) | 1412 } 1413 1414 /* 1415 * Add the interface route associated with the prefix. Before 1416 * installing the route, check if there's the same prefix on another 1417 * interface, and the prefix has already installed the interface route. 1418 * Although such a configuration is expected to be rare, we explicitly 1419 * allow it. --- 4 unchanged lines hidden (view full) --- 1424 1425 if ((opr->ndpr_stateflags & NDPRF_ONLINK) == 0) 1426 continue; 1427 1428 if (opr->ndpr_plen == pr->ndpr_plen && 1429 in6_are_prefix_equal(&pr->ndpr_prefix.sin6_addr, 1430 &opr->ndpr_prefix.sin6_addr, 1431 pr->ndpr_plen)) |
1432 return(0); | 1432 return (0); |
1433 } 1434 1435 /* 1436 * We prefer link-local addresses as the associated interface address. 1437 */ 1438 /* search for a link-local addr */ 1439 ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, 1440 IN6_IFF_NOTREADY| --- 14 unchanged lines hidden (view full) --- 1455 * after removing all IPv6 addresses on the receiving 1456 * interface. This should, of course, be rare though. 1457 */ 1458 nd6log((LOG_NOTICE, 1459 "nd6_prefix_onlink: failed to find any ifaddr" 1460 " to add route for a prefix(%s/%d) on %s\n", 1461 ip6_sprintf(&pr->ndpr_prefix.sin6_addr), 1462 pr->ndpr_plen, if_name(ifp))); | 1433 } 1434 1435 /* 1436 * We prefer link-local addresses as the associated interface address. 1437 */ 1438 /* search for a link-local addr */ 1439 ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, 1440 IN6_IFF_NOTREADY| --- 14 unchanged lines hidden (view full) --- 1455 * after removing all IPv6 addresses on the receiving 1456 * interface. This should, of course, be rare though. 1457 */ 1458 nd6log((LOG_NOTICE, 1459 "nd6_prefix_onlink: failed to find any ifaddr" 1460 " to add route for a prefix(%s/%d) on %s\n", 1461 ip6_sprintf(&pr->ndpr_prefix.sin6_addr), 1462 pr->ndpr_plen, if_name(ifp))); |
1463 return(0); | 1463 return (0); |
1464 } 1465 1466 /* 1467 * in6_ifinit() sets nd6_rtrequest to ifa_rtrequest for all ifaddrs. 1468 * ifa->ifa_rtrequest = nd6_rtrequest; 1469 */ 1470 bzero(&mask6, sizeof(mask6)); 1471 mask6.sin6_len = sizeof(mask6); --- 27 unchanged lines hidden (view full) --- 1499 } 1500 1501 if (rt != NULL) { 1502 RT_LOCK(rt); 1503 rt->rt_refcnt--; 1504 RT_UNLOCK(rt); 1505 } 1506 | 1464 } 1465 1466 /* 1467 * in6_ifinit() sets nd6_rtrequest to ifa_rtrequest for all ifaddrs. 1468 * ifa->ifa_rtrequest = nd6_rtrequest; 1469 */ 1470 bzero(&mask6, sizeof(mask6)); 1471 mask6.sin6_len = sizeof(mask6); --- 27 unchanged lines hidden (view full) --- 1499 } 1500 1501 if (rt != NULL) { 1502 RT_LOCK(rt); 1503 rt->rt_refcnt--; 1504 RT_UNLOCK(rt); 1505 } 1506 |
1507 return(error); | 1507 return (error); |
1508} 1509 1510int 1511nd6_prefix_offlink(pr) 1512 struct nd_prefix *pr; 1513{ 1514 int error = 0; 1515 struct ifnet *ifp = pr->ndpr_ifp; 1516 struct nd_prefix *opr; 1517 struct sockaddr_in6 sa6, mask6; 1518 struct rtentry *rt = NULL; 1519 1520 /* sanity check */ 1521 if ((pr->ndpr_stateflags & NDPRF_ONLINK) == 0) { 1522 nd6log((LOG_ERR, 1523 "nd6_prefix_offlink: %s/%d is already off-link\n", 1524 ip6_sprintf(&pr->ndpr_prefix.sin6_addr), pr->ndpr_plen)); | 1508} 1509 1510int 1511nd6_prefix_offlink(pr) 1512 struct nd_prefix *pr; 1513{ 1514 int error = 0; 1515 struct ifnet *ifp = pr->ndpr_ifp; 1516 struct nd_prefix *opr; 1517 struct sockaddr_in6 sa6, mask6; 1518 struct rtentry *rt = NULL; 1519 1520 /* sanity check */ 1521 if ((pr->ndpr_stateflags & NDPRF_ONLINK) == 0) { 1522 nd6log((LOG_ERR, 1523 "nd6_prefix_offlink: %s/%d is already off-link\n", 1524 ip6_sprintf(&pr->ndpr_prefix.sin6_addr), pr->ndpr_plen)); |
1525 return(EEXIST); | 1525 return (EEXIST); |
1526 } 1527 1528 bzero(&sa6, sizeof(sa6)); 1529 sa6.sin6_family = AF_INET6; 1530 sa6.sin6_len = sizeof(sa6); 1531 bcopy(&pr->ndpr_prefix.sin6_addr, &sa6.sin6_addr, 1532 sizeof(struct in6_addr)); 1533 bzero(&mask6, sizeof(mask6)); --- 55 unchanged lines hidden (view full) --- 1589 "%s/%d on %s (errno = %d)\n", 1590 ip6_sprintf(&sa6.sin6_addr), pr->ndpr_plen, if_name(ifp), 1591 error)); 1592 } 1593 1594 if (rt != NULL) 1595 RTFREE(rt); 1596 | 1526 } 1527 1528 bzero(&sa6, sizeof(sa6)); 1529 sa6.sin6_family = AF_INET6; 1530 sa6.sin6_len = sizeof(sa6); 1531 bcopy(&pr->ndpr_prefix.sin6_addr, &sa6.sin6_addr, 1532 sizeof(struct in6_addr)); 1533 bzero(&mask6, sizeof(mask6)); --- 55 unchanged lines hidden (view full) --- 1589 "%s/%d on %s (errno = %d)\n", 1590 ip6_sprintf(&sa6.sin6_addr), pr->ndpr_plen, if_name(ifp), 1591 error)); 1592 } 1593 1594 if (rt != NULL) 1595 RTFREE(rt); 1596 |
1597 return(error); | 1597 return (error); |
1598} 1599 1600static struct in6_ifaddr * 1601in6_ifadd(pr, ifid) 1602 struct nd_prefix *pr; 1603 struct in6_addr *ifid; /* Mobile IPv6 addition */ 1604{ 1605 struct ifnet *ifp = pr->ndpr_ifp; --- 115 unchanged lines hidden (view full) --- 1721 pr->ndpr_addr = ifra.ifra_addr.sin6_addr; 1722 1723 /* allocate ifaddr structure, link into chain, etc. */ 1724 if ((error = in6_update_ifa(ifp, &ifra, NULL)) != 0) { 1725 nd6log((LOG_ERR, 1726 "in6_ifadd: failed to make ifaddr %s on %s (errno=%d)\n", 1727 ip6_sprintf(&ifra.ifra_addr.sin6_addr), if_name(ifp), 1728 error)); | 1598} 1599 1600static struct in6_ifaddr * 1601in6_ifadd(pr, ifid) 1602 struct nd_prefix *pr; 1603 struct in6_addr *ifid; /* Mobile IPv6 addition */ 1604{ 1605 struct ifnet *ifp = pr->ndpr_ifp; --- 115 unchanged lines hidden (view full) --- 1721 pr->ndpr_addr = ifra.ifra_addr.sin6_addr; 1722 1723 /* allocate ifaddr structure, link into chain, etc. */ 1724 if ((error = in6_update_ifa(ifp, &ifra, NULL)) != 0) { 1725 nd6log((LOG_ERR, 1726 "in6_ifadd: failed to make ifaddr %s on %s (errno=%d)\n", 1727 ip6_sprintf(&ifra.ifra_addr.sin6_addr), if_name(ifp), 1728 error)); |
1729 return(NULL); /* ifaddr must not have been allocated. */ | 1729 return (NULL); /* ifaddr must not have been allocated. */ |
1730 } 1731 1732 ia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr); 1733 | 1730 } 1731 1732 ia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr); 1733 |
1734 return(ia); /* this must NOT be NULL. */ | 1734 return (ia); /* this must NOT be NULL. */ |
1735} 1736 1737int 1738in6_tmpifadd(ia0, forcegen) 1739 const struct in6_ifaddr *ia0; /* corresponding public address */ 1740 int forcegen; 1741{ 1742 struct ifnet *ifp = ia0->ia_ifa.ifa_ifp; --- 29 unchanged lines hidden (view full) --- 1772 * already assigned to the interface, generate a new randomized 1773 * interface identifier and repeat this step. 1774 * RFC 3041 3.3 (4). 1775 */ 1776 if (in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr) != NULL) { 1777 if (trylimit-- == 0) { 1778 nd6log((LOG_NOTICE, "in6_tmpifadd: failed to find " 1779 "a unique random IFID\n")); | 1735} 1736 1737int 1738in6_tmpifadd(ia0, forcegen) 1739 const struct in6_ifaddr *ia0; /* corresponding public address */ 1740 int forcegen; 1741{ 1742 struct ifnet *ifp = ia0->ia_ifa.ifa_ifp; --- 29 unchanged lines hidden (view full) --- 1772 * already assigned to the interface, generate a new randomized 1773 * interface identifier and repeat this step. 1774 * RFC 3041 3.3 (4). 1775 */ 1776 if (in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr) != NULL) { 1777 if (trylimit-- == 0) { 1778 nd6log((LOG_NOTICE, "in6_tmpifadd: failed to find " 1779 "a unique random IFID\n")); |
1780 return(EEXIST); | 1780 return (EEXIST); |
1781 } 1782 forcegen = 1; 1783 goto again; 1784 } 1785 1786 /* 1787 * The Valid Lifetime is the lower of the Valid Lifetime of the 1788 * public address or TEMP_VALID_LIFETIME. --- 20 unchanged lines hidden (view full) --- 1809 ifra.ifra_lifetime.ia6t_vltime = vltime0; 1810 ifra.ifra_lifetime.ia6t_pltime = pltime0; 1811 1812 /* 1813 * A temporary address is created only if this calculated Preferred 1814 * Lifetime is greater than REGEN_ADVANCE time units. 1815 */ 1816 if (ifra.ifra_lifetime.ia6t_pltime <= ip6_temp_regen_advance) | 1781 } 1782 forcegen = 1; 1783 goto again; 1784 } 1785 1786 /* 1787 * The Valid Lifetime is the lower of the Valid Lifetime of the 1788 * public address or TEMP_VALID_LIFETIME. --- 20 unchanged lines hidden (view full) --- 1809 ifra.ifra_lifetime.ia6t_vltime = vltime0; 1810 ifra.ifra_lifetime.ia6t_pltime = pltime0; 1811 1812 /* 1813 * A temporary address is created only if this calculated Preferred 1814 * Lifetime is greater than REGEN_ADVANCE time units. 1815 */ 1816 if (ifra.ifra_lifetime.ia6t_pltime <= ip6_temp_regen_advance) |
1817 return(0); | 1817 return (0); |
1818 1819 /* XXX: scope zone ID? */ 1820 1821 ifra.ifra_flags |= (IN6_IFF_AUTOCONF|IN6_IFF_TEMPORARY); 1822 1823 /* allocate ifaddr structure, link into chain, etc. */ 1824 if ((error = in6_update_ifa(ifp, &ifra, NULL)) != 0) | 1818 1819 /* XXX: scope zone ID? */ 1820 1821 ifra.ifra_flags |= (IN6_IFF_AUTOCONF|IN6_IFF_TEMPORARY); 1822 1823 /* allocate ifaddr structure, link into chain, etc. */ 1824 if ((error = in6_update_ifa(ifp, &ifra, NULL)) != 0) |
1825 return(error); | 1825 return (error); |
1826 1827 newia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr); 1828 if (newia == NULL) { /* XXX: can it happen? */ 1829 nd6log((LOG_ERR, 1830 "in6_tmpifadd: ifa update succeeded, but we got " 1831 "no ifaddr\n")); | 1826 1827 newia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr); 1828 if (newia == NULL) { /* XXX: can it happen? */ 1829 nd6log((LOG_ERR, 1830 "in6_tmpifadd: ifa update succeeded, but we got " 1831 "no ifaddr\n")); |
1832 return(EINVAL); /* XXX */ | 1832 return (EINVAL); /* XXX */ |
1833 } 1834 newia->ia6_ndpr = ia0->ia6_ndpr; 1835 newia->ia6_ndpr->ndpr_refcnt++; 1836 1837 /* 1838 * A newly added address might affect the status of other addresses. 1839 * XXX: when the temporary address is generated with a new public 1840 * address, the onlink check is redundant. However, it would be safe 1841 * to do the check explicitly everywhere a new address is generated, 1842 * and, in fact, we surely need the check when we create a new 1843 * temporary address due to deprecation of an old temporary address. 1844 */ 1845 pfxlist_onlink_check(); 1846 | 1833 } 1834 newia->ia6_ndpr = ia0->ia6_ndpr; 1835 newia->ia6_ndpr->ndpr_refcnt++; 1836 1837 /* 1838 * A newly added address might affect the status of other addresses. 1839 * XXX: when the temporary address is generated with a new public 1840 * address, the onlink check is redundant. However, it would be safe 1841 * to do the check explicitly everywhere a new address is generated, 1842 * and, in fact, we surely need the check when we create a new 1843 * temporary address due to deprecation of an old temporary address. 1844 */ 1845 pfxlist_onlink_check(); 1846 |
1847 return(0); | 1847 return (0); |
1848} 1849 1850int 1851in6_init_prefix_ltimes(struct nd_prefix *ndpr) 1852{ 1853 /* check if preferred lifetime > valid lifetime. RFC2462 5.5.3 (c) */ 1854 if (ndpr->ndpr_pltime > ndpr->ndpr_vltime) { 1855 nd6log((LOG_INFO, "in6_init_prefix_ltimes: preferred lifetime" --- 65 unchanged lines hidden (view full) --- 1921 struct radix_node *rn; 1922 void *arg; 1923{ 1924#define SIN6(s) ((struct sockaddr_in6 *)s) 1925 struct rtentry *rt = (struct rtentry *)rn; 1926 struct in6_addr *gate = (struct in6_addr *)arg; 1927 1928 if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6) | 1848} 1849 1850int 1851in6_init_prefix_ltimes(struct nd_prefix *ndpr) 1852{ 1853 /* check if preferred lifetime > valid lifetime. RFC2462 5.5.3 (c) */ 1854 if (ndpr->ndpr_pltime > ndpr->ndpr_vltime) { 1855 nd6log((LOG_INFO, "in6_init_prefix_ltimes: preferred lifetime" --- 65 unchanged lines hidden (view full) --- 1921 struct radix_node *rn; 1922 void *arg; 1923{ 1924#define SIN6(s) ((struct sockaddr_in6 *)s) 1925 struct rtentry *rt = (struct rtentry *)rn; 1926 struct in6_addr *gate = (struct in6_addr *)arg; 1927 1928 if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6) |
1929 return(0); | 1929 return (0); |
1930 1931 if (!IN6_ARE_ADDR_EQUAL(gate, &SIN6(rt->rt_gateway)->sin6_addr)) | 1930 1931 if (!IN6_ARE_ADDR_EQUAL(gate, &SIN6(rt->rt_gateway)->sin6_addr)) |
1932 return(0); | 1932 return (0); |
1933 1934 /* 1935 * Do not delete a static route. 1936 * XXX: this seems to be a bit ad-hoc. Should we consider the 1937 * 'cloned' bit instead? 1938 */ 1939 if ((rt->rt_flags & RTF_STATIC) != 0) | 1933 1934 /* 1935 * Do not delete a static route. 1936 * XXX: this seems to be a bit ad-hoc. Should we consider the 1937 * 'cloned' bit instead? 1938 */ 1939 if ((rt->rt_flags & RTF_STATIC) != 0) |
1940 return(0); | 1940 return (0); |
1941 1942 /* 1943 * We delete only host route. This means, in particular, we don't 1944 * delete default route. 1945 */ 1946 if ((rt->rt_flags & RTF_HOST) == 0) | 1941 1942 /* 1943 * We delete only host route. This means, in particular, we don't 1944 * delete default route. 1945 */ 1946 if ((rt->rt_flags & RTF_HOST) == 0) |
1947 return(0); | 1947 return (0); |
1948 | 1948 |
1949 return(rtrequest(RTM_DELETE, rt_key(rt), | 1949 return (rtrequest(RTM_DELETE, rt_key(rt), |
1950 rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0)); 1951#undef SIN6 1952} 1953 1954int 1955nd6_setdefaultiface(ifindex) 1956 int ifindex; 1957{ 1958 int error = 0; 1959 1960 if (ifindex < 0 || if_index < ifindex) | 1950 rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0)); 1951#undef SIN6 1952} 1953 1954int 1955nd6_setdefaultiface(ifindex) 1956 int ifindex; 1957{ 1958 int error = 0; 1959 1960 if (ifindex < 0 || if_index < ifindex) |
1961 return(EINVAL); | 1961 return (EINVAL); |
1962 1963 if (nd6_defifindex != ifindex) { 1964 nd6_defifindex = ifindex; 1965 if (nd6_defifindex > 0) 1966 nd6_defifp = ifnet_byindex(nd6_defifindex); 1967 else 1968 nd6_defifp = NULL; 1969 --- 11 unchanged lines hidden (view full) --- 1981 /* 1982 * Our current implementation assumes one-to-one maping between 1983 * interfaces and links, so it would be natural to use the 1984 * default interface as the default link. 1985 */ 1986 scope6_setdefault(nd6_defifp); 1987 } 1988 | 1962 1963 if (nd6_defifindex != ifindex) { 1964 nd6_defifindex = ifindex; 1965 if (nd6_defifindex > 0) 1966 nd6_defifp = ifnet_byindex(nd6_defifindex); 1967 else 1968 nd6_defifp = NULL; 1969 --- 11 unchanged lines hidden (view full) --- 1981 /* 1982 * Our current implementation assumes one-to-one maping between 1983 * interfaces and links, so it would be natural to use the 1984 * default interface as the default link. 1985 */ 1986 scope6_setdefault(nd6_defifp); 1987 } 1988 |
1989 return(error); | 1989 return (error); |
1990} | 1990} |