nd6_rtr.c (1d54aa3ba94f4d9883b0746ce45123d5b5be773b) | nd6_rtr.c (1272577e22d8f1c1c5b5e88f2624836e93aecb17) |
---|---|
1/* $FreeBSD$ */ 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 --- 100 unchanged lines hidden (view full) --- 109/* 110 * Receive Router Solicitation Message - just for routers. 111 * Router solicitation/advertisement is mostly managed by userland program 112 * (rtadvd) so here we have no function like nd6_ra_output(). 113 * 114 * Based on RFC 2461 115 */ 116void | 1/* $FreeBSD$ */ 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 --- 100 unchanged lines hidden (view full) --- 109/* 110 * Receive Router Solicitation Message - just for routers. 111 * Router solicitation/advertisement is mostly managed by userland program 112 * (rtadvd) so here we have no function like nd6_ra_output(). 113 * 114 * Based on RFC 2461 115 */ 116void |
117nd6_rs_input(m, off, icmp6len) 118 struct mbuf *m; 119 int off, icmp6len; | 117nd6_rs_input(struct mbuf *m, int off, int icmp6len) |
120{ 121 struct ifnet *ifp = m->m_pkthdr.rcvif; 122 struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); 123 struct nd_router_solicit *nd_rs; 124 struct in6_addr saddr6 = ip6->ip6_src; 125 char *lladdr = NULL; 126 int lladdrlen = 0; 127 union nd_opts ndopts; --- 67 unchanged lines hidden (view full) --- 195/* 196 * Receive Router Advertisement Message. 197 * 198 * Based on RFC 2461 199 * TODO: on-link bit on prefix information 200 * TODO: ND_RA_FLAG_{OTHER,MANAGED} processing 201 */ 202void | 118{ 119 struct ifnet *ifp = m->m_pkthdr.rcvif; 120 struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); 121 struct nd_router_solicit *nd_rs; 122 struct in6_addr saddr6 = ip6->ip6_src; 123 char *lladdr = NULL; 124 int lladdrlen = 0; 125 union nd_opts ndopts; --- 67 unchanged lines hidden (view full) --- 193/* 194 * Receive Router Advertisement Message. 195 * 196 * Based on RFC 2461 197 * TODO: on-link bit on prefix information 198 * TODO: ND_RA_FLAG_{OTHER,MANAGED} processing 199 */ 200void |
203nd6_ra_input(m, off, icmp6len) 204 struct mbuf *m; 205 int off, icmp6len; | 201nd6_ra_input(struct mbuf *m, int off, int icmp6len) |
206{ 207 struct ifnet *ifp = m->m_pkthdr.rcvif; 208 struct nd_ifinfo *ndi = ND_IFINFO(ifp); 209 struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); 210 struct nd_router_advert *nd_ra; 211 struct in6_addr saddr6 = ip6->ip6_src; 212 int mcast = 0; 213 union nd_opts ndopts; --- 212 unchanged lines hidden (view full) --- 426} 427 428/* 429 * default router list proccessing sub routines 430 */ 431 432/* tell the change to user processes watching the routing socket. */ 433static void | 202{ 203 struct ifnet *ifp = m->m_pkthdr.rcvif; 204 struct nd_ifinfo *ndi = ND_IFINFO(ifp); 205 struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); 206 struct nd_router_advert *nd_ra; 207 struct in6_addr saddr6 = ip6->ip6_src; 208 int mcast = 0; 209 union nd_opts ndopts; --- 212 unchanged lines hidden (view full) --- 422} 423 424/* 425 * default router list proccessing sub routines 426 */ 427 428/* tell the change to user processes watching the routing socket. */ 429static void |
434nd6_rtmsg(cmd, rt) 435 int cmd; 436 struct rtentry *rt; | 430nd6_rtmsg(int cmd, struct rtentry *rt) |
437{ 438 struct rt_addrinfo info; 439 440 bzero((caddr_t)&info, sizeof(info)); 441 info.rti_info[RTAX_DST] = rt_key(rt); 442 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; 443 info.rti_info[RTAX_NETMASK] = rt_mask(rt); 444 if (rt->rt_ifp) { 445 info.rti_info[RTAX_IFP] = 446 TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr; 447 info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; 448 } 449 450 rt_missmsg(cmd, &info, rt->rt_flags, 0); 451} 452 453void | 431{ 432 struct rt_addrinfo info; 433 434 bzero((caddr_t)&info, sizeof(info)); 435 info.rti_info[RTAX_DST] = rt_key(rt); 436 info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; 437 info.rti_info[RTAX_NETMASK] = rt_mask(rt); 438 if (rt->rt_ifp) { 439 info.rti_info[RTAX_IFP] = 440 TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr; 441 info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; 442 } 443 444 rt_missmsg(cmd, &info, rt->rt_flags, 0); 445} 446 447void |
454defrouter_addreq(new) 455 struct nd_defrouter *new; | 448defrouter_addreq(struct nd_defrouter *new) |
456{ 457 struct sockaddr_in6 def, mask, gate; 458 struct rtentry *newrt = NULL; 459 int s; 460 int error; 461 462 bzero(&def, sizeof(def)); 463 bzero(&mask, sizeof(mask)); --- 16 unchanged lines hidden (view full) --- 480 } 481 if (error == 0) 482 new->installed = 1; 483 splx(s); 484 return; 485} 486 487struct nd_defrouter * | 449{ 450 struct sockaddr_in6 def, mask, gate; 451 struct rtentry *newrt = NULL; 452 int s; 453 int error; 454 455 bzero(&def, sizeof(def)); 456 bzero(&mask, sizeof(mask)); --- 16 unchanged lines hidden (view full) --- 473 } 474 if (error == 0) 475 new->installed = 1; 476 splx(s); 477 return; 478} 479 480struct nd_defrouter * |
488defrouter_lookup(addr, ifp) 489 struct in6_addr *addr; 490 struct ifnet *ifp; | 481defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp) |
491{ 492 struct nd_defrouter *dr; 493 494 for (dr = TAILQ_FIRST(&nd_defrouter); dr; 495 dr = TAILQ_NEXT(dr, dr_entry)) { 496 if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr)) 497 return (dr); 498 } 499 500 return (NULL); /* search failed */ 501} 502 503/* 504 * Remove the default route for a given router. 505 * This is just a subroutine function for defrouter_select(), and should 506 * not be called from anywhere else. 507 */ 508static void | 482{ 483 struct nd_defrouter *dr; 484 485 for (dr = TAILQ_FIRST(&nd_defrouter); dr; 486 dr = TAILQ_NEXT(dr, dr_entry)) { 487 if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr)) 488 return (dr); 489 } 490 491 return (NULL); /* search failed */ 492} 493 494/* 495 * Remove the default route for a given router. 496 * This is just a subroutine function for defrouter_select(), and should 497 * not be called from anywhere else. 498 */ 499static void |
509defrouter_delreq(dr) 510 struct nd_defrouter *dr; | 500defrouter_delreq(struct nd_defrouter *dr) |
511{ 512 struct sockaddr_in6 def, mask, gate; 513 struct rtentry *oldrt = NULL; 514 515 bzero(&def, sizeof(def)); 516 bzero(&mask, sizeof(mask)); 517 bzero(&gate, sizeof(gate)); 518 --- 12 unchanged lines hidden (view full) --- 531 532 dr->installed = 0; 533} 534 535/* 536 * remove all default routes from default router list 537 */ 538void | 501{ 502 struct sockaddr_in6 def, mask, gate; 503 struct rtentry *oldrt = NULL; 504 505 bzero(&def, sizeof(def)); 506 bzero(&mask, sizeof(mask)); 507 bzero(&gate, sizeof(gate)); 508 --- 12 unchanged lines hidden (view full) --- 521 522 dr->installed = 0; 523} 524 525/* 526 * remove all default routes from default router list 527 */ 528void |
539defrouter_reset() | 529defrouter_reset(void) |
540{ 541 struct nd_defrouter *dr; 542 543 for (dr = TAILQ_FIRST(&nd_defrouter); dr; 544 dr = TAILQ_NEXT(dr, dr_entry)) 545 defrouter_delreq(dr); 546 547 /* 548 * XXX should we also nuke any default routers in the kernel, by 549 * going through them by rtalloc1()? 550 */ 551} 552 553void | 530{ 531 struct nd_defrouter *dr; 532 533 for (dr = TAILQ_FIRST(&nd_defrouter); dr; 534 dr = TAILQ_NEXT(dr, dr_entry)) 535 defrouter_delreq(dr); 536 537 /* 538 * XXX should we also nuke any default routers in the kernel, by 539 * going through them by rtalloc1()? 540 */ 541} 542 543void |
554defrtrlist_del(dr) 555 struct nd_defrouter *dr; | 544defrtrlist_del(struct nd_defrouter *dr) |
556{ 557 struct nd_defrouter *deldr = NULL; 558 struct nd_prefix *pr; 559 560 /* 561 * Flush all the routing table entries that use the router 562 * as a next hop. 563 */ --- 44 unchanged lines hidden (view full) --- 608 * we do not need to classify the cases by ifdef. 609 * 610 * At this moment, we do not try to install more than one default router, 611 * even when the multipath routing is available, because we're not sure about 612 * the benefits for stub hosts comparing to the risk of making the code 613 * complicated and the possibility of introducing bugs. 614 */ 615void | 545{ 546 struct nd_defrouter *deldr = NULL; 547 struct nd_prefix *pr; 548 549 /* 550 * Flush all the routing table entries that use the router 551 * as a next hop. 552 */ --- 44 unchanged lines hidden (view full) --- 597 * we do not need to classify the cases by ifdef. 598 * 599 * At this moment, we do not try to install more than one default router, 600 * even when the multipath routing is available, because we're not sure about 601 * the benefits for stub hosts comparing to the risk of making the code 602 * complicated and the possibility of introducing bugs. 603 */ 604void |
616defrouter_select() | 605defrouter_select(void) |
617{ 618 int s = splnet(); 619 struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL; 620 struct rtentry *rt = NULL; 621 struct llinfo_nd6 *ln = NULL; 622 623 /* 624 * This function should be called only when acting as an autoconfigured --- 99 unchanged lines hidden (view full) --- 724 */ 725 log(LOG_ERR, "rtpref: impossible RA flag %x\n", dr->flags); 726 return (RTPREF_INVALID); 727 } 728 /* NOTREACHED */ 729} 730 731static struct nd_defrouter * | 606{ 607 int s = splnet(); 608 struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL; 609 struct rtentry *rt = NULL; 610 struct llinfo_nd6 *ln = NULL; 611 612 /* 613 * This function should be called only when acting as an autoconfigured --- 99 unchanged lines hidden (view full) --- 713 */ 714 log(LOG_ERR, "rtpref: impossible RA flag %x\n", dr->flags); 715 return (RTPREF_INVALID); 716 } 717 /* NOTREACHED */ 718} 719 720static struct nd_defrouter * |
732defrtrlist_update(new) 733 struct nd_defrouter *new; | 721defrtrlist_update(struct nd_defrouter *new) |
734{ 735 struct nd_defrouter *dr, *n; 736 int s = splnet(); 737 738 if ((dr = defrouter_lookup(&new->rtaddr, new->ifp)) != NULL) { 739 /* entry exists */ 740 if (new->rtlifetime == 0) { 741 defrtrlist_del(dr); --- 68 unchanged lines hidden (view full) --- 810 defrouter_select(); 811 812 splx(s); 813 814 return (n); 815} 816 817static struct nd_pfxrouter * | 722{ 723 struct nd_defrouter *dr, *n; 724 int s = splnet(); 725 726 if ((dr = defrouter_lookup(&new->rtaddr, new->ifp)) != NULL) { 727 /* entry exists */ 728 if (new->rtlifetime == 0) { 729 defrtrlist_del(dr); --- 68 unchanged lines hidden (view full) --- 798 defrouter_select(); 799 800 splx(s); 801 802 return (n); 803} 804 805static struct nd_pfxrouter * |
818pfxrtr_lookup(pr, dr) 819 struct nd_prefix *pr; 820 struct nd_defrouter *dr; | 806pfxrtr_lookup(struct nd_prefix *pr, struct nd_defrouter *dr) |
821{ 822 struct nd_pfxrouter *search; 823 824 for (search = pr->ndpr_advrtrs.lh_first; search; search = search->pfr_next) { 825 if (search->router == dr) 826 break; 827 } 828 829 return (search); 830} 831 832static void | 807{ 808 struct nd_pfxrouter *search; 809 810 for (search = pr->ndpr_advrtrs.lh_first; search; search = search->pfr_next) { 811 if (search->router == dr) 812 break; 813 } 814 815 return (search); 816} 817 818static void |
833pfxrtr_add(pr, dr) 834 struct nd_prefix *pr; 835 struct nd_defrouter *dr; | 819pfxrtr_add(struct nd_prefix *pr, struct nd_defrouter *dr) |
836{ 837 struct nd_pfxrouter *new; 838 839 new = (struct nd_pfxrouter *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT); 840 if (new == NULL) 841 return; 842 bzero(new, sizeof(*new)); 843 new->router = dr; 844 845 LIST_INSERT_HEAD(&pr->ndpr_advrtrs, new, pfr_entry); 846 847 pfxlist_onlink_check(); 848} 849 850static void | 820{ 821 struct nd_pfxrouter *new; 822 823 new = (struct nd_pfxrouter *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT); 824 if (new == NULL) 825 return; 826 bzero(new, sizeof(*new)); 827 new->router = dr; 828 829 LIST_INSERT_HEAD(&pr->ndpr_advrtrs, new, pfr_entry); 830 831 pfxlist_onlink_check(); 832} 833 834static void |
851pfxrtr_del(pfr) 852 struct nd_pfxrouter *pfr; | 835pfxrtr_del(struct nd_pfxrouter *pfr) |
853{ 854 LIST_REMOVE(pfr, pfr_entry); 855 free(pfr, M_IP6NDP); 856} 857 858struct nd_prefix * | 836{ 837 LIST_REMOVE(pfr, pfr_entry); 838 free(pfr, M_IP6NDP); 839} 840 841struct nd_prefix * |
859nd6_prefix_lookup(key) 860 struct nd_prefixctl *key; | 842nd6_prefix_lookup(struct nd_prefixctl *key) |
861{ 862 struct nd_prefix *search; 863 864 for (search = nd_prefix.lh_first; search; search = search->ndpr_next) { 865 if (key->ndpr_ifp == search->ndpr_ifp && 866 key->ndpr_plen == search->ndpr_plen && 867 in6_are_prefix_equal(&key->ndpr_prefix.sin6_addr, 868 &search->ndpr_prefix.sin6_addr, key->ndpr_plen)) { 869 break; 870 } 871 } 872 873 return (search); 874} 875 876int | 843{ 844 struct nd_prefix *search; 845 846 for (search = nd_prefix.lh_first; search; search = search->ndpr_next) { 847 if (key->ndpr_ifp == search->ndpr_ifp && 848 key->ndpr_plen == search->ndpr_plen && 849 in6_are_prefix_equal(&key->ndpr_prefix.sin6_addr, 850 &search->ndpr_prefix.sin6_addr, key->ndpr_plen)) { 851 break; 852 } 853 } 854 855 return (search); 856} 857 858int |
877nd6_prelist_add(pr, dr, newp) 878 struct nd_prefixctl *pr; 879 struct nd_prefix **newp; 880 struct nd_defrouter *dr; | 859nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr, 860 struct nd_prefix **newp) |
881{ 882 struct nd_prefix *new = NULL; 883 int error = 0; 884 int i, s; 885 char ip6buf[INET6_ADDRSTRLEN]; 886 887 new = (struct nd_prefix *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT); 888 if (new == NULL) --- 41 unchanged lines hidden (view full) --- 930 931 if (dr) 932 pfxrtr_add(new, dr); 933 934 return 0; 935} 936 937void | 861{ 862 struct nd_prefix *new = NULL; 863 int error = 0; 864 int i, s; 865 char ip6buf[INET6_ADDRSTRLEN]; 866 867 new = (struct nd_prefix *)malloc(sizeof(*new), M_IP6NDP, M_NOWAIT); 868 if (new == NULL) --- 41 unchanged lines hidden (view full) --- 910 911 if (dr) 912 pfxrtr_add(new, dr); 913 914 return 0; 915} 916 917void |
938prelist_remove(pr) 939 struct nd_prefix *pr; | 918prelist_remove(struct nd_prefix *pr) |
940{ 941 struct nd_pfxrouter *pfr, *next; 942 int e, s; 943 char ip6buf[INET6_ADDRSTRLEN]; 944 945 /* make sure to invalidate the prefix until it is really freed. */ 946 pr->ndpr_vltime = 0; 947 pr->ndpr_pltime = 0; --- 29 unchanged lines hidden (view full) --- 977 } 978 splx(s); 979 980 free(pr, M_IP6NDP); 981 982 pfxlist_onlink_check(); 983} 984 | 919{ 920 struct nd_pfxrouter *pfr, *next; 921 int e, s; 922 char ip6buf[INET6_ADDRSTRLEN]; 923 924 /* make sure to invalidate the prefix until it is really freed. */ 925 pr->ndpr_vltime = 0; 926 pr->ndpr_pltime = 0; --- 29 unchanged lines hidden (view full) --- 956 } 957 splx(s); 958 959 free(pr, M_IP6NDP); 960 961 pfxlist_onlink_check(); 962} 963 |
964/* 965 * dr - may be NULL 966 */ 967 |
|
985static int | 968static int |
986prelist_update(new, dr, m, mcast) 987 struct nd_prefixctl *new; 988 struct nd_defrouter *dr; /* may be NULL */ 989 struct mbuf *m; 990 int mcast; | 969prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr, 970 struct mbuf *m, int mcast) |
991{ 992 struct in6_ifaddr *ia6 = NULL, *ia6_match = NULL; 993 struct ifaddr *ifa; 994 struct ifnet *ifp = new->ndpr_ifp; 995 struct nd_prefix *pr; 996 int s = splnet(); 997 int error = 0; 998 int newprefix = 0; --- 321 unchanged lines hidden (view full) --- 1320} 1321 1322/* 1323 * A supplement function used in the on-link detection below; 1324 * detect if a given prefix has a (probably) reachable advertising router. 1325 * XXX: lengthy function name... 1326 */ 1327static struct nd_pfxrouter * | 971{ 972 struct in6_ifaddr *ia6 = NULL, *ia6_match = NULL; 973 struct ifaddr *ifa; 974 struct ifnet *ifp = new->ndpr_ifp; 975 struct nd_prefix *pr; 976 int s = splnet(); 977 int error = 0; 978 int newprefix = 0; --- 321 unchanged lines hidden (view full) --- 1300} 1301 1302/* 1303 * A supplement function used in the on-link detection below; 1304 * detect if a given prefix has a (probably) reachable advertising router. 1305 * XXX: lengthy function name... 1306 */ 1307static struct nd_pfxrouter * |
1328find_pfxlist_reachable_router(pr) 1329 struct nd_prefix *pr; | 1308find_pfxlist_reachable_router(struct nd_prefix *pr) |
1330{ 1331 struct nd_pfxrouter *pfxrtr; 1332 struct rtentry *rt; 1333 struct llinfo_nd6 *ln; 1334 1335 for (pfxrtr = LIST_FIRST(&pr->ndpr_advrtrs); pfxrtr; 1336 pfxrtr = LIST_NEXT(pfxrtr, pfr_entry)) { 1337 if ((rt = nd6_lookup(&pfxrtr->router->rtaddr, 0, --- 194 unchanged lines hidden (view full) --- 1532 /* Do we need a delay in this case? */ 1533 nd6_dad_start((struct ifaddr *)ifa, 0); 1534 } 1535 } 1536 } 1537} 1538 1539int | 1309{ 1310 struct nd_pfxrouter *pfxrtr; 1311 struct rtentry *rt; 1312 struct llinfo_nd6 *ln; 1313 1314 for (pfxrtr = LIST_FIRST(&pr->ndpr_advrtrs); pfxrtr; 1315 pfxrtr = LIST_NEXT(pfxrtr, pfr_entry)) { 1316 if ((rt = nd6_lookup(&pfxrtr->router->rtaddr, 0, --- 194 unchanged lines hidden (view full) --- 1511 /* Do we need a delay in this case? */ 1512 nd6_dad_start((struct ifaddr *)ifa, 0); 1513 } 1514 } 1515 } 1516} 1517 1518int |
1540nd6_prefix_onlink(pr) 1541 struct nd_prefix *pr; | 1519nd6_prefix_onlink(struct nd_prefix *pr) |
1542{ 1543 struct ifaddr *ifa; 1544 struct ifnet *ifp = pr->ndpr_ifp; 1545 struct sockaddr_in6 mask6; 1546 struct nd_prefix *opr; 1547 u_long rtflags; 1548 int error = 0; 1549 struct rtentry *rt = NULL; --- 96 unchanged lines hidden (view full) --- 1646 RT_REMREF(rt); 1647 RT_UNLOCK(rt); 1648 } 1649 1650 return (error); 1651} 1652 1653int | 1520{ 1521 struct ifaddr *ifa; 1522 struct ifnet *ifp = pr->ndpr_ifp; 1523 struct sockaddr_in6 mask6; 1524 struct nd_prefix *opr; 1525 u_long rtflags; 1526 int error = 0; 1527 struct rtentry *rt = NULL; --- 96 unchanged lines hidden (view full) --- 1624 RT_REMREF(rt); 1625 RT_UNLOCK(rt); 1626 } 1627 1628 return (error); 1629} 1630 1631int |
1654nd6_prefix_offlink(pr) 1655 struct nd_prefix *pr; | 1632nd6_prefix_offlink(struct nd_prefix *pr) |
1656{ 1657 int error = 0; 1658 struct ifnet *ifp = pr->ndpr_ifp; 1659 struct nd_prefix *opr; 1660 struct sockaddr_in6 sa6, mask6; 1661 struct rtentry *rt = NULL; 1662 char ip6buf[INET6_ADDRSTRLEN]; 1663 --- 74 unchanged lines hidden (view full) --- 1738 if (rt != NULL) { 1739 RTFREE(rt); 1740 } 1741 1742 return (error); 1743} 1744 1745static struct in6_ifaddr * | 1633{ 1634 int error = 0; 1635 struct ifnet *ifp = pr->ndpr_ifp; 1636 struct nd_prefix *opr; 1637 struct sockaddr_in6 sa6, mask6; 1638 struct rtentry *rt = NULL; 1639 char ip6buf[INET6_ADDRSTRLEN]; 1640 --- 74 unchanged lines hidden (view full) --- 1715 if (rt != NULL) { 1716 RTFREE(rt); 1717 } 1718 1719 return (error); 1720} 1721 1722static struct in6_ifaddr * |
1746in6_ifadd(pr, mcast) 1747 struct nd_prefixctl *pr; 1748 int mcast; | 1723in6_ifadd(struct nd_prefixctl *pr, int mcast) |
1749{ 1750 struct ifnet *ifp = pr->ndpr_ifp; 1751 struct ifaddr *ifa; 1752 struct in6_aliasreq ifra; 1753 struct in6_ifaddr *ia, *ib; 1754 int error, plen0; 1755 struct in6_addr mask; 1756 int prefixlen = pr->ndpr_plen; --- 107 unchanged lines hidden (view full) --- 1864 return (NULL); /* ifaddr must not have been allocated. */ 1865 } 1866 1867 ia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr); 1868 1869 return (ia); /* this is always non-NULL */ 1870} 1871 | 1724{ 1725 struct ifnet *ifp = pr->ndpr_ifp; 1726 struct ifaddr *ifa; 1727 struct in6_aliasreq ifra; 1728 struct in6_ifaddr *ia, *ib; 1729 int error, plen0; 1730 struct in6_addr mask; 1731 int prefixlen = pr->ndpr_plen; --- 107 unchanged lines hidden (view full) --- 1839 return (NULL); /* ifaddr must not have been allocated. */ 1840 } 1841 1842 ia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr); 1843 1844 return (ia); /* this is always non-NULL */ 1845} 1846 |
1847/* 1848 * ia0 - corresponding public address 1849 */ |
|
1872int | 1850int |
1873in6_tmpifadd(ia0, forcegen, delay) 1874 const struct in6_ifaddr *ia0; /* corresponding public address */ 1875 int forcegen, delay; | 1851in6_tmpifadd(const struct in6_ifaddr *ia0, int forcegen, int delay) |
1876{ 1877 struct ifnet *ifp = ia0->ia_ifa.ifa_ifp; 1878 struct in6_ifaddr *newia, *ia; 1879 struct in6_aliasreq ifra; 1880 int i, error; 1881 int trylimit = 3; /* XXX: adhoc value */ 1882 int updateflags; 1883 u_int32_t randid[2]; --- 150 unchanged lines hidden (view full) --- 2034} 2035 2036/* 2037 * Delete all the routing table entries that use the specified gateway. 2038 * XXX: this function causes search through all entries of routing table, so 2039 * it shouldn't be called when acting as a router. 2040 */ 2041void | 1852{ 1853 struct ifnet *ifp = ia0->ia_ifa.ifa_ifp; 1854 struct in6_ifaddr *newia, *ia; 1855 struct in6_aliasreq ifra; 1856 int i, error; 1857 int trylimit = 3; /* XXX: adhoc value */ 1858 int updateflags; 1859 u_int32_t randid[2]; --- 150 unchanged lines hidden (view full) --- 2010} 2011 2012/* 2013 * Delete all the routing table entries that use the specified gateway. 2014 * XXX: this function causes search through all entries of routing table, so 2015 * it shouldn't be called when acting as a router. 2016 */ 2017void |
2042rt6_flush(gateway, ifp) 2043 struct in6_addr *gateway; 2044 struct ifnet *ifp; | 2018rt6_flush(struct in6_addr *gateway, struct ifnet *ifp) |
2045{ 2046 struct radix_node_head *rnh = rt_tables[AF_INET6]; 2047 int s = splnet(); 2048 2049 /* We'll care only link-local addresses */ 2050 if (!IN6_IS_ADDR_LINKLOCAL(gateway)) { 2051 splx(s); 2052 return; 2053 } 2054 2055 RADIX_NODE_HEAD_LOCK(rnh); 2056 rnh->rnh_walktree(rnh, rt6_deleteroute, (void *)gateway); 2057 RADIX_NODE_HEAD_UNLOCK(rnh); 2058 splx(s); 2059} 2060 2061static int | 2019{ 2020 struct radix_node_head *rnh = rt_tables[AF_INET6]; 2021 int s = splnet(); 2022 2023 /* We'll care only link-local addresses */ 2024 if (!IN6_IS_ADDR_LINKLOCAL(gateway)) { 2025 splx(s); 2026 return; 2027 } 2028 2029 RADIX_NODE_HEAD_LOCK(rnh); 2030 rnh->rnh_walktree(rnh, rt6_deleteroute, (void *)gateway); 2031 RADIX_NODE_HEAD_UNLOCK(rnh); 2032 splx(s); 2033} 2034 2035static int |
2062rt6_deleteroute(rn, arg) 2063 struct radix_node *rn; 2064 void *arg; | 2036rt6_deleteroute(struct radix_node *rn, void *arg) |
2065{ 2066#define SIN6(s) ((struct sockaddr_in6 *)s) 2067 struct rtentry *rt = (struct rtentry *)rn; 2068 struct in6_addr *gate = (struct in6_addr *)arg; 2069 2070 if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6) 2071 return (0); 2072 --- 17 unchanged lines hidden (view full) --- 2090 return (0); 2091 2092 return (rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, 2093 rt_mask(rt), rt->rt_flags, 0)); 2094#undef SIN6 2095} 2096 2097int | 2037{ 2038#define SIN6(s) ((struct sockaddr_in6 *)s) 2039 struct rtentry *rt = (struct rtentry *)rn; 2040 struct in6_addr *gate = (struct in6_addr *)arg; 2041 2042 if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6) 2043 return (0); 2044 --- 17 unchanged lines hidden (view full) --- 2062 return (0); 2063 2064 return (rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, 2065 rt_mask(rt), rt->rt_flags, 0)); 2066#undef SIN6 2067} 2068 2069int |
2098nd6_setdefaultiface(ifindex) 2099 int ifindex; | 2070nd6_setdefaultiface(int ifindex) |
2100{ 2101 int error = 0; 2102 2103 if (ifindex < 0 || if_index < ifindex) 2104 return (EINVAL); 2105 if (ifindex != 0 && !ifnet_byindex(ifindex)) 2106 return (EINVAL); 2107 --- 17 unchanged lines hidden --- | 2071{ 2072 int error = 0; 2073 2074 if (ifindex < 0 || if_index < ifindex) 2075 return (EINVAL); 2076 if (ifindex != 0 && !ifnet_byindex(ifindex)) 2077 return (EINVAL); 2078 --- 17 unchanged lines hidden --- |