Lines Matching refs:link
54 bool link_radv_enabled(Link *link) { in link_radv_enabled() argument
55 assert(link); in link_radv_enabled()
57 if (!link_may_have_ipv6ll(link)) in link_radv_enabled()
60 if (link->hw_addr.length != ETH_ALEN) in link_radv_enabled()
63 return link->network->router_prefix_delegation; in link_radv_enabled()
180 int link_request_radv_addresses(Link *link) { in link_request_radv_addresses() argument
184 assert(link); in link_request_radv_addresses()
186 if (!link_radv_enabled(link)) in link_request_radv_addresses()
189 HASHMAP_FOREACH(p, link->network->prefixes_by_section) { in link_request_radv_addresses()
200 r = radv_generate_addresses(link, p->tokens, &p->prefix, p->prefixlen, &addresses); in link_request_radv_addresses()
217 r = link_request_static_address(link, TAKE_PTR(address), true); in link_request_radv_addresses()
239 static int radv_set_prefix(Link *link, Prefix *prefix) { in radv_set_prefix() argument
243 assert(link); in radv_set_prefix()
244 assert(link->radv); in radv_set_prefix()
271 return sd_radv_add_prefix(link->radv, p); in radv_set_prefix()
274 static int radv_set_route_prefix(Link *link, RoutePrefix *prefix) { in radv_set_route_prefix() argument
278 assert(link); in radv_set_route_prefix()
279 assert(link->radv); in radv_set_route_prefix()
294 return sd_radv_add_route_prefix(link->radv, p); in radv_set_route_prefix()
330 static int radv_set_dns(Link *link, Link *uplink) { in radv_set_dns() argument
335 if (!link->network->router_emit_dns) in radv_set_dns()
338 if (link->network->router_dns) { in radv_set_dns()
341 dns = new(struct in6_addr, link->network->n_router_dns); in radv_set_dns()
346 for (size_t i = 0; i < link->network->n_router_dns; i++) in radv_set_dns()
347 if (in6_addr_is_null(&link->network->router_dns[i])) { in radv_set_dns()
348 if (in6_addr_is_set(&link->ipv6ll_address)) in radv_set_dns()
349 *(p++) = link->ipv6ll_address; in radv_set_dns()
351 *(p++) = link->network->router_dns[i]; in radv_set_dns()
358 r = network_get_ipv6_dns(link->network, &dns, &n_dns); in radv_set_dns()
373 return sd_radv_set_rdnss(link->radv, in radv_set_dns()
374 usec_to_lifetime(link->network->router_dns_lifetime_usec), in radv_set_dns()
378 static int radv_set_domains(Link *link, Link *uplink) { in radv_set_domains() argument
382 if (!link->network->router_emit_domains) in radv_set_domains()
385 search_domains = link->network->router_search_domains; in radv_set_domains()
390 search_domains = link->network->search_domains; in radv_set_domains()
409 return sd_radv_set_dnssl(link->radv, in radv_set_domains()
410 usec_to_lifetime(link->network->router_dns_lifetime_usec), in radv_set_domains()
415 static int radv_find_uplink(Link *link, Link **ret) { in radv_find_uplink() argument
418 assert(link); in radv_find_uplink()
420 if (link->network->router_uplink_name) in radv_find_uplink()
421 return link_get_by_name(link->manager, link->network->router_uplink_name, ret); in radv_find_uplink()
423 if (link->network->router_uplink_index > 0) in radv_find_uplink()
424 return link_get_by_index(link->manager, link->network->router_uplink_index, ret); in radv_find_uplink()
426 if (link->network->router_uplink_index == UPLINK_INDEX_AUTO) { in radv_find_uplink()
427 if (link_dhcp_pd_is_enabled(link)) in radv_find_uplink()
428 … r = dhcp_pd_find_uplink(link, ret); /* When DHCP-PD is enabled, use its uplink. */ in radv_find_uplink()
430 r = manager_find_uplink(link->manager, AF_INET6, link, ret); in radv_find_uplink()
441 static int radv_configure(Link *link) { in radv_configure() argument
447 assert(link); in radv_configure()
448 assert(link->network); in radv_configure()
450 if (link->radv) in radv_configure()
453 r = sd_radv_new(&link->radv); in radv_configure()
457 r = sd_radv_attach_event(link->radv, link->manager->event, 0); in radv_configure()
461 r = sd_radv_set_mac(link->radv, &link->hw_addr.ether); in radv_configure()
465 r = sd_radv_set_ifindex(link->radv, link->ifindex); in radv_configure()
469 r = sd_radv_set_managed_information(link->radv, link->network->router_managed); in radv_configure()
473 r = sd_radv_set_other_information(link->radv, link->network->router_other_information); in radv_configure()
477 r = sd_radv_set_router_lifetime(link->radv, link->network->router_lifetime_usec); in radv_configure()
481 if (link->network->router_lifetime_usec > 0) { in radv_configure()
482 r = sd_radv_set_preference(link->radv, link->network->router_preference); in radv_configure()
487 HASHMAP_FOREACH(p, link->network->prefixes_by_section) { in radv_configure()
488 r = radv_set_prefix(link, p); in radv_configure()
493 HASHMAP_FOREACH(q, link->network->route_prefixes_by_section) { in radv_configure()
494 r = radv_set_route_prefix(link, q); in radv_configure()
499 (void) radv_find_uplink(link, &uplink); in radv_configure()
501 r = radv_set_dns(link, uplink); in radv_configure()
503 return log_link_debug_errno(link, r, "Could not set RA DNS: %m"); in radv_configure()
505 r = radv_set_domains(link, uplink); in radv_configure()
507 return log_link_debug_errno(link, r, "Could not set RA Domains: %m"); in radv_configure()
512 int radv_update_mac(Link *link) { in radv_update_mac() argument
516 assert(link); in radv_update_mac()
518 if (!link->radv) in radv_update_mac()
521 restart = sd_radv_is_running(link->radv); in radv_update_mac()
523 r = sd_radv_stop(link->radv); in radv_update_mac()
527 r = sd_radv_set_mac(link->radv, &link->hw_addr.ether); in radv_update_mac()
532 r = sd_radv_start(link->radv); in radv_update_mac()
540 static int radv_is_ready_to_configure(Link *link) { in radv_is_ready_to_configure() argument
544 assert(link); in radv_is_ready_to_configure()
545 assert(link->network); in radv_is_ready_to_configure()
547 if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED)) in radv_is_ready_to_configure()
550 if (in6_addr_is_null(&link->ipv6ll_address)) in radv_is_ready_to_configure()
553 if (link->hw_addr.length != ETH_ALEN || hw_addr_is_null(&link->hw_addr)) in radv_is_ready_to_configure()
556 if (link->network->router_emit_dns && !link->network->router_dns) { in radv_is_ready_to_configure()
560 r = network_get_ipv6_dns(link->network, &dns, &n_dns); in radv_is_ready_to_configure()
567 if (link->network->router_emit_domains && in radv_is_ready_to_configure()
568 !link->network->router_search_domains && in radv_is_ready_to_configure()
569 !link->network->search_domains) in radv_is_ready_to_configure()
575 if (radv_find_uplink(link, &uplink) < 0) in radv_is_ready_to_configure()
585 static int radv_process_request(Request *req, Link *link, void *userdata) { in radv_process_request() argument
588 assert(link); in radv_process_request()
590 r = radv_is_ready_to_configure(link); in radv_process_request()
594 r = radv_configure(link); in radv_process_request()
596 …return log_link_warning_errno(link, r, "Failed to configure IPv6 Router Advertisement engine: %m"); in radv_process_request()
598 if (link_has_carrier(link)) { in radv_process_request()
599 r = radv_start(link); in radv_process_request()
601 … return log_link_warning_errno(link, r, "Failed to start IPv6 Router Advertisement engine: %m"); in radv_process_request()
604 log_link_debug(link, "IPv6 Router Advertisement engine is configured%s.", in radv_process_request()
605 link_has_carrier(link) ? " and started." : ""); in radv_process_request()
609 int link_request_radv(Link *link) { in link_request_radv() argument
612 assert(link); in link_request_radv()
614 if (!link_radv_enabled(link)) in link_request_radv()
617 if (link->radv) in link_request_radv()
620 r = link_queue_request(link, REQUEST_TYPE_RADV, radv_process_request, NULL); in link_request_radv()
622 …return log_link_warning_errno(link, r, "Failed to request configuring of the IPv6 Router Advertise… in link_request_radv()
624 log_link_debug(link, "Requested configuring of the IPv6 Router Advertisement engine."); in link_request_radv()
628 int radv_start(Link *link) { in radv_start() argument
631 assert(link); in radv_start()
632 assert(link->network); in radv_start()
634 if (!link->radv) in radv_start()
637 if (!link_has_carrier(link)) in radv_start()
640 if (in6_addr_is_null(&link->ipv6ll_address)) in radv_start()
643 if (sd_radv_is_running(link->radv)) in radv_start()
646 if (link->network->dhcp_pd_announce) { in radv_start()
647 r = dhcp_request_prefix_delegation(link); in radv_start()
649 … return log_link_debug_errno(link, r, "Failed to request DHCP delegated subnet prefix: %m"); in radv_start()
652 log_link_debug(link, "Starting IPv6 Router Advertisements"); in radv_start()
653 return sd_radv_start(link->radv); in radv_start()
657 Link *link, in radv_add_prefix() argument
666 assert(link); in radv_add_prefix()
668 if (!link->radv) in radv_add_prefix()
687 r = sd_radv_add_prefix(link->radv, p); in radv_add_prefix()