Lines Matching refs:router
17 * This code adds border router support to 3rd party HomeKit Routers as part of Appleās commitment to the CHIP project.
19 * This file contains an implementation of Thread Border Router routing.
87 #if STUB_ROUTER // Stub Router is true if we're building a Thread Border router or an RA tester.
336 // If we have been beaconing, and router mode has been disabled, and we don't have
402 // We can reschedule a beacon for sooner if we get a router solicit; in this case, we
420 INFO("Starting router discovery on " PUB_S_SRP, interface->name);
422 // Immediately when an interface shows up, start doing router solicits.
434 // In 20 seconds, check the results of router discovery and update policy as needed.
446 icmp_message_t *router, **p_router;
450 router = *p_router;
451 if (now == 0 || now - router->received_time > MAX_ROUTER_RECEIVED_TIME_GAP_BEFORE_STALE) {
452 *p_router = router->next;
453 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, __router_src_addr_buf);
454 INFO("flushing stale router - ifname: " PUB_S_SRP
455 ", router src: " PRI_SEGMENTED_IPv6_ADDR_SRP, interface->name,
456 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, __router_src_addr_buf));
457 icmp_message_free(router);
476 INFO("stopping vicarious router discovery on " PUB_S_SRP, interface->name);
486 INFO("router discovery not yet started.");
490 INFO("stopping router discovery on " PUB_S_SRP, interface->name);
511 icmp_message_t *router;
516 INFO("No router information available for the interface - "
520 INFO("No router information available for the interface - "
527 for (router = interface->routers; router != NULL; router = router->next) {
528 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, __router_src_addr_buf);
530 if (router->received_time_already_adjusted) {
532 "router src: " PRI_SEGMENTED_IPv6_ADDR_SRP, (now - router->received_time) / MSEC_PER_SEC,
533 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, __router_src_addr_buf));
541 router->received_time = now + time_adjusted;
542 router->received_time_already_adjusted = true; // Only adjust the icmp message received time once.
543 INFO("router received time is adjusted - router src: " PRI_SEGMENTED_IPv6_ADDR_SRP
545 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, __router_src_addr_buf), time_adjusted);
555 // Make every router go stale in 19.999 seconds. This means that if we don't get a response
557 // routers on the interface that aren't stale, which will trigger router discovery.
565 INFO("Vicarious router discovery finished on " PUB_S_SRP ".", interface->name);
568 // discovery as stale, so policy_evaluate will start router discovery if we didn't get any
603 prefix_usable(interface_t *interface, route_state_t *route_state, icmp_message_t *router, prefix_information_t *prefix)
605 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, router_src_addr_buf);
611 (route_state->config_enable_dhcpv6_prefixes && (router->flags & ND_RA_FLAG_MANAGED))) &&
614 INFO("Router " PRI_SEGMENTED_IPv6_ADDR_SRP
616 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, router_src_addr_buf),
620 bool_str(route_state->config_enable_dhcpv6_prefixes && (router->flags & ND_RA_FLAG_MANAGED)),
627 INFO("Router " PRI_SEGMENTED_IPv6_ADDR_SRP
629 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, router_src_addr_buf),
635 // If this is a stub router, and we are advertising our own prefix, and the PIO it is advertising is greater than
637 if (interface->our_prefix_advertised && router->stub_router && cmp > 0) {
638 INFO("Router " PRI_SEGMENTED_IPv6_ADDR_SRP
639 " is a stub router advertising prefix " PRI_SEGMENTED_IPv6_ADDR_SRP ", which loses the election and is not usable",
640 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, router_src_addr_buf),
644 INFO("Router " PRI_SEGMENTED_IPv6_ADDR_SRP
646 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, router_src_addr_buf),
647 router->stub_router ? "a stub router " : "",
655 icmp_message_t *router;
674 // Look at all the router advertisements we've seen to see if any contain a usable prefix which is not the
676 // one router to advertise a prefix, so we will also advertise it for redundancy.
677 for (router = interface->routers; router; router = router->next) {
678 icmp_option_t *option = router->options;
681 for (i = 0; i < router->num_options; i++, option++) {
687 if (prefix_usable(interface, route_state, router, prefix)) {
689 // advertised by another router, because that router is also a Thread BR, and we don't want
707 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, router_src_addr_buf);
709 INFO("router " PRI_SEGMENTED_IPv6_ADDR_SRP " advertising " PRI_SEGMENTED_IPv6_ADDR_SRP
711 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, router_src_addr_buf),
724 if (router->received_time + preferred_lifetime_offset < now) {
725 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, router_src_addr_buf);
727 INFO("router " PRI_SEGMENTED_IPv6_ADDR_SRP " advertising " PRI_SEGMENTED_IPv6_ADDR_SRP
729 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, router_src_addr_buf),
731 (int)((now - router->received_time) / 1000), preferred_lifetime);
740 // router->reachable will be true immediately after receiving a router advertisement until we do a
743 if (!router->reachable) {
744 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, router_src_addr_buf);
746 INFO("router %p " PRI_SEGMENTED_IPv6_ADDR_SRP " advertising %d %p " PRI_SEGMENTED_IPv6_ADDR_SRP
748 router,
749 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, router_src_addr_buf),
752 (int)((now - router->latest_na) / 1000));
756 // Otherwise, if this router's on-link prefix will expire later than any other we've seen
757 if (stale_refresh_time < router->received_time + preferred_lifetime_offset) {
758 stale_refresh_time = router->received_time + preferred_lifetime_offset;
762 if (router->new_router) {
764 router->new_router = false; // clear the bit since srp-mdns-proxy already processed it.
767 // This router has a usable prefix.
772 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, __router_src_add_buf);
774 INFO("router has usable PIO - ifname: " PUB_S_SRP ", router src: " PRI_SEGMENTED_IPv6_ADDR_SRP
777 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, __router_src_add_buf),
780 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, router_src_addr_buf);
781 INFO("Router " PRI_SEGMENTED_IPv6_ADDR_SRP
783 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, router_src_addr_buf));
786 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, __router_src_add_buf);
788 INFO("router has unusable PIO - ifname: " PUB_S_SRP ", router src: " PRI_SEGMENTED_IPv6_ADDR_SRP
791 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, __router_src_add_buf),
796 // Remember whether or not this router has a usable prefix.
797 router->usable = usable;
815 // If there are stale routers, start doing router discovery again to see if we can get them to respond.
816 // Note that doing router discover just because we haven't seen an RA is actually not allowed in RFC 4861,
818 // Also, if we have not yet done router discovery, do it now.
825 // Start router discovery.
826 INFO("starting router discovery");
829 INFO("router discovery in progress");
903 // If we've been looking to see if there's an on-link prefix, and we got one from the new router advertisement,
928 // At this point we have not yet sent a router advertisement with the prefix, so even though it has a preferred
938 // If we have an on-link prefix, schedule a policy re-evaluation at the stale router interval.
949 ERROR("No memory for stale router evaluation wakeup on " PUB_S_SRP ".", interface->name);
960 // Once router discovery is complete, start doing aliveness checks on whatever we discovered (if anything).
989 // In order for vicarious router discovery to be useful, we need all of the routers
991 // on vicarious discovery. If we got any router advertisements, these will not be
994 INFO("Starting vicarious router discovery on " PUB_S_SRP,
1026 // we get a router solicit, to ensure that the solicit gets a quick response, and also gets called once every
1027 // minute so that we quickly notice when a router becomes unreachable.
1038 for (icmp_message_t *router = interface->routers; router != NULL; router = router->next) {
1039 SEGMENTED_IPv6_ADDR_GEN_SRP(router->source.s6_addr, router_src_addr_buf);
1040 INFO("router (%p) " PRI_SEGMENTED_IPv6_ADDR_SRP " was " PUB_S_SRP "reached during probing.", router,
1041 SEGMENTED_IPv6_ADDR_PARAM_SRP(router->source.s6_addr, router_src_addr_buf),
1042 router->reached ? "" : "not ");
1043 router->reachable = router->reached;
1052 router = interface->routers; router != NULL; router = router->next) {
1053 // Don't probe routers that aren't usable, and don't re-probe a router that's already responded in this probe cycle.
1054 if (!router->usable || router->reached) {
1057 neighbor_solicit_send(router->interface, &router->source);
1076 for (icmp_message_t *router = interface->routers; router != NULL; router = router->next) {
1077 router->reached = false;
1091 INFO("scheduling router probe in 60 seconds.");
1107 ERROR("Invalid router solicitation, hop limit = %d, code = %d", message->hop_limit, message->code);
1115 ERROR("source link layer address in router solicitation from unspecified IP address");
1124 INFO("dropping router solicitation sent from this host.");
1178 INFO("not sending a router advertisement.");
1182 // When we receive a router solicit, it means that a host is looking for a router. We should
1184 // no on-link prefix. In this case, we restart our own router discovery process. There is no
1198 icmp_message_t *router, **rp;
1200 ERROR("Invalid router advertisement, hop limit = %d, code = %d", message->hop_limit, message->code);
1206 INFO("dropping router advertisement sent from this host.");
1212 // See if we've had a previous advertisement from this router. Note that routers can send more than one
1222 // (Restructure handling of incoming router advertisements so as to marshal the data in case we get more than one RA
1223 // from the same router with different data.)
1225 router = *rp;
1226 // The new RA is from the same router as this previous RA.
1227 if (!in6addr_compare(&router->source, &message->source)) {
1228 message->next = router->next;
1230 icmp_message_free(router);
1240 // When we receive an RA, we can assume that the router is reachable, and skip immediately probing with a
1246 // Check for the stub router flag here so that we have it when scanning PIOs for usability.
1267 // If this NA matches a router that has advertised a usable prefix, mark the router as alive by setting the
1270 for (icmp_message_t *router = message->interface->routers; router != NULL; router = router->next) {
1271 if (!in6addr_compare(&message->source, &router->source)) {
1274 if (router->usable) {
1279 router->latest_na = ioloop_timenow();
1280 router->reached = true;
1281 router->reachable = true;
1480 INFO("Done waiting for router discovery to finish on " PUB_S_SRP, interface->name);
1591 INFO("discontinuing router solicitations on thread interface " PUB_S_SRP, interface->name);
1595 INFO("Done sending router solicitations on " PUB_S_SRP ".", interface->name);
1598 INFO("sending router solicitation on " PUB_S_SRP , interface->name);
1613 ERROR("No memory for router solicit wakeup on " PUB_S_SRP ".", interface->name);
1658 icmp_message_t *router, *next;
1681 for (router = interface->routers; router; router = next) {
1682 next = router->next;
1683 icmp_message_free(router);
1715 router_is_advertising(icmp_message_t *router, const struct in6_addr *prefix, int preflen)
1717 for (int i = 0; i < router->num_options; i++) {
1718 icmp_option_t *option = &router->options[i];
1729 SEGMENTED_IPv6_ADDR_GEN_SRP(&router->source, router_buf);
1730 INFO("router at " PRI_SEGMENTED_IPv6_ADDR_SRP " advertised prefix " PRI_SEGMENTED_IPv6_ADDR_SRP "/%d",
1731 SEGMENTED_IPv6_ADDR_PARAM_SRP(&router->source, router_buf),
1750 icmp_message_t *router = *rp;
1751 if (router_is_advertising(router, prefix, preflen)) {
1752 *rp = router->next;
1753 router->next = NULL;
1754 icmp_message_free(router);
1756 rp = &router->next;
1894 // When new IP address is removed, it is possible that the existing router information, such as
1896 // flush the stale router information as soon as possible, we mark all the router as stale immediately,
1897 // by setting the router received time to a value which is 601s ago (router will be stale if the router
1898 // information is received for more than 600s). And then do router discovery for 20s, so we can ensure
1899 // that all the stale router information will be updated during the discovery, or flushed away. If all
1908 INFO("clearing router discovery complete flag because address deleted.");
1910 INFO("making all routers stale and start router discovery due to removed address");
1915 // the router discovery immediately.
1918 // Set need_reconfigure_prefix to true to let routing_policy_evaluate know that the router discovery
1919 // is caused by interface removal event, so when the router discovery finished and nothing changes,
2163 INFO("role is: " PUB_S_SRP " (%d)\n ", am_thread_router ? "router" : "not router", role);