Lines Matching refs:link
32 if (nexthop->link) { in nexthop_free()
33 set_remove(nexthop->link->nexthops, nexthop); in nexthop_free()
35 if (nexthop->link->manager && nexthop->id > 0) in nexthop_free()
36 … hashmap_remove(nexthop->link->manager->nexthops_by_id, UINT32_TO_PTR(nexthop->id)); in nexthop_free()
183 dest->link = NULL; in nexthop_dup()
227 static int nexthop_get(Manager *manager, Link *link, NextHop *in, NextHop **ret) { in nexthop_get() argument
234 if (!link) in nexthop_get()
237 nexthops = link->nexthops; in nexthop_get()
276 static int nexthop_add(Manager *manager, Link *link, NextHop *nexthop) { in nexthop_add() argument
283 assert(link); in nexthop_add()
285 r = set_ensure_put(&link->nexthops, &nexthop_hash_ops, nexthop); in nexthop_add()
291 nexthop->link = link; in nexthop_add()
293 manager = link->manager; in nexthop_add()
348 static void log_nexthop_debug(const NextHop *nexthop, const char *str, const Link *link) { in log_nexthop_debug() argument
367 …log_link_debug(link, "%s %s nexthop (%s): id: %"PRIu32", gw: %s, blackhole: %s, group: %s, flags: … in log_nexthop_debug()
372 static int nexthop_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) { in nexthop_remove_handler() argument
379 if (link && IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)) in nexthop_remove_handler()
384 log_link_message_warning_errno(link, m, r, "Could not drop nexthop, ignoring"); in nexthop_remove_handler()
392 Link *link; in nexthop_remove() local
396 assert(nexthop->manager || (nexthop->link && nexthop->link->manager)); in nexthop_remove()
399 link = nexthop->link; in nexthop_remove()
400 manager = nexthop->manager ?: nexthop->link->manager; in nexthop_remove()
403 log_link_debug(link, "Cannot remove nexthop without valid ID, ignoring."); in nexthop_remove()
407 log_nexthop_debug(nexthop, "Removing", link); in nexthop_remove()
411 return log_link_error_errno(link, r, "Could not create RTM_DELNEXTHOP message: %m"); in nexthop_remove()
415 return log_link_error_errno(link, r, "Could not append NHA_ID attribute: %m"); in nexthop_remove()
418 link ? link_netlink_destroy_callback : NULL, link); in nexthop_remove()
420 return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); in nexthop_remove()
422 link_ref(link); /* link may be NULL, link_ref() is OK with that */ in nexthop_remove()
428 static int nexthop_configure(NextHop *nexthop, Link *link, Request *req) { in nexthop_configure() argument
434 assert(link); in nexthop_configure()
435 assert(link->manager); in nexthop_configure()
436 assert(link->manager->rtnl); in nexthop_configure()
437 assert(link->ifindex > 0); in nexthop_configure()
440 log_nexthop_debug(nexthop, "Configuring", link); in nexthop_configure()
442 …r = sd_rtnl_message_new_nexthop(link->manager->rtnl, &m, RTM_NEWNEXTHOP, nexthop->family, nexthop-… in nexthop_configure()
473 r = sd_netlink_message_append_u32(m, NHA_OIF, link->ifindex); in nexthop_configure()
488 return request_call_netlink_async(link->manager->rtnl, m, req); in nexthop_configure()
491 static int static_nexthop_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link… in static_nexthop_handler() argument
495 assert(link); in static_nexthop_handler()
499 log_link_message_warning_errno(link, m, r, "Could not set nexthop"); in static_nexthop_handler()
500 link_enter_failed(link); in static_nexthop_handler()
504 if (link->static_nexthop_messages == 0) { in static_nexthop_handler()
505 log_link_debug(link, "Nexthops set"); in static_nexthop_handler()
506 link->static_nexthops_configured = true; in static_nexthop_handler()
507 link_check_ready(link); in static_nexthop_handler()
513 static bool nexthop_is_ready_to_configure(Link *link, const NextHop *nexthop) { in nexthop_is_ready_to_configure() argument
516 assert(link); in nexthop_is_ready_to_configure()
519 if (!link_is_ready_to_configure(link, false)) in nexthop_is_ready_to_configure()
526 if (link->set_flags_messages > 0) in nexthop_is_ready_to_configure()
528 if (!FLAGS_SET(link->flags, IFF_UP)) in nexthop_is_ready_to_configure()
536 if (manager_get_nexthop_by_id(link->manager, nhg->id, &g) < 0) in nexthop_is_ready_to_configure()
546 ORDERED_SET_FOREACH(req, link->manager->request_queue) { in nexthop_is_ready_to_configure()
554 …return gateway_is_ready(link, FLAGS_SET(nexthop->flags, RTNH_F_ONLINK), nexthop->family, &nexthop-… in nexthop_is_ready_to_configure()
557 static int nexthop_process_request(Request *req, Link *link, NextHop *nexthop) { in nexthop_process_request() argument
561 assert(link); in nexthop_process_request()
564 if (!nexthop_is_ready_to_configure(link, nexthop)) in nexthop_process_request()
567 r = nexthop_configure(nexthop, link, req); in nexthop_process_request()
569 return log_link_warning_errno(link, r, "Failed to configure nexthop"); in nexthop_process_request()
575 static int link_request_nexthop(Link *link, NextHop *nexthop) { in link_request_nexthop() argument
579 assert(link); in link_request_nexthop()
583 if (nexthop_get(link->manager, link, nexthop, &existing) < 0) { in link_request_nexthop()
590 r = nexthop_acquire_id(link->manager, tmp); in link_request_nexthop()
594 r = nexthop_add(link->manager, link, tmp); in link_request_nexthop()
602 log_nexthop_debug(existing, "Requesting", link); in link_request_nexthop()
603 r = link_queue_request_safe(link, REQUEST_TYPE_NEXTHOP, in link_request_nexthop()
608 &link->static_nexthop_messages, in link_request_nexthop()
618 int link_request_static_nexthops(Link *link, bool only_ipv4) { in link_request_static_nexthops() argument
622 assert(link); in link_request_static_nexthops()
623 assert(link->network); in link_request_static_nexthops()
625 link->static_nexthops_configured = false; in link_request_static_nexthops()
627 HASHMAP_FOREACH(nh, link->network->nexthops_by_section) { in link_request_static_nexthops()
631 r = link_request_nexthop(link, nh); in link_request_static_nexthops()
633 return log_link_warning_errno(link, r, "Could not request nexthop: %m"); in link_request_static_nexthops()
636 if (link->static_nexthop_messages == 0) { in link_request_static_nexthops()
637 link->static_nexthops_configured = true; in link_request_static_nexthops()
638 link_check_ready(link); in link_request_static_nexthops()
640 log_link_debug(link, "Requesting nexthops"); in link_request_static_nexthops()
641 link_set_state(link, LINK_STATE_CONFIGURING); in link_request_static_nexthops()
649 Link *link; in manager_mark_nexthops() local
671 HASHMAP_FOREACH(link, manager->links_by_index) { in manager_mark_nexthops()
672 if (link == except) in manager_mark_nexthops()
675 if (!IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED)) in manager_mark_nexthops()
678 HASHMAP_FOREACH(nexthop, link->network->nexthops_by_section) { in manager_mark_nexthops()
705 int link_drop_foreign_nexthops(Link *link) { in link_drop_foreign_nexthops() argument
709 assert(link); in link_drop_foreign_nexthops()
710 assert(link->manager); in link_drop_foreign_nexthops()
711 assert(link->network); in link_drop_foreign_nexthops()
714 SET_FOREACH(nexthop, link->nexthops) { in link_drop_foreign_nexthops()
731 HASHMAP_FOREACH(nexthop, link->network->nexthops_by_section) { in link_drop_foreign_nexthops()
734 if (nexthop_get(NULL, link, nexthop, &existing) >= 0) in link_drop_foreign_nexthops()
739 SET_FOREACH(nexthop, link->nexthops) { in link_drop_foreign_nexthops()
748 manager_mark_nexthops(link->manager, /* foreign = */ true, NULL); in link_drop_foreign_nexthops()
750 k = manager_drop_marked_nexthops(link->manager); in link_drop_foreign_nexthops()
757 int link_drop_managed_nexthops(Link *link) { in link_drop_managed_nexthops() argument
761 assert(link); in link_drop_managed_nexthops()
762 assert(link->manager); in link_drop_managed_nexthops()
764 SET_FOREACH(nexthop, link->nexthops) { in link_drop_managed_nexthops()
782 manager_mark_nexthops(link->manager, /* foreign = */ false, link); in link_drop_managed_nexthops()
784 k = manager_drop_marked_nexthops(link->manager); in link_drop_managed_nexthops()
791 void link_foreignize_nexthops(Link *link) { in link_foreignize_nexthops() argument
794 assert(link); in link_foreignize_nexthops()
796 SET_FOREACH(nexthop, link->nexthops) in link_foreignize_nexthops()
799 manager_mark_nexthops(link->manager, /* foreign = */ false, link); in link_foreignize_nexthops()
801 SET_FOREACH(nexthop, link->manager->nexthops) { in link_foreignize_nexthops()
816 Link *link = NULL; in manager_rtnl_process_nexthop() local
850 r = link_get_by_index(m, ifindex, &link); in manager_rtnl_process_nexthop()
851 if (r < 0 || !link) { in manager_rtnl_process_nexthop()
864 log_link_warning_errno(link, r, "rtnl: could not get nexthop family, ignoring: %m"); in manager_rtnl_process_nexthop()
867 …log_link_debug(link, "rtnl: received nexthop message with invalid family %d, ignoring.", tmp->fami… in manager_rtnl_process_nexthop()
873 … log_link_warning_errno(link, r, "rtnl: could not get nexthop protocol, ignoring: %m"); in manager_rtnl_process_nexthop()
879 log_link_warning_errno(link, r, "rtnl: could not get nexthop flags, ignoring: %m"); in manager_rtnl_process_nexthop()
885 … log_link_warning_errno(link, r, "rtnl: could not get NHA_GROUP attribute, ignoring: %m"); in manager_rtnl_process_nexthop()
892 …log_link_warning(link, "rtnl: received nexthop message with invalid nexthop group size, ignoring."… in manager_rtnl_process_nexthop()
903 … log_link_warning(link, "rtnl: received nexthop message with invalid ID in group, ignoring."); in manager_rtnl_process_nexthop()
907 … log_link_warning(link, "rtnl: received nexthop message with invalid weight in group, ignoring."); in manager_rtnl_process_nexthop()
919 … log_link_warning_errno(link, r, "Failed to store nexthop group, ignoring: %m"); in manager_rtnl_process_nexthop()
930 … log_link_warning_errno(link, r, "rtnl: could not get NHA_GATEWAY attribute, ignoring: %m"); in manager_rtnl_process_nexthop()
937 … log_link_warning_errno(link, r, "rtnl: could not get NHA_BLACKHOLE attribute, ignoring: %m"); in manager_rtnl_process_nexthop()
944 …log_link_warning_errno(link, r, "rtnl: received nexthop message without NHA_ID attribute, ignoring… in manager_rtnl_process_nexthop()
947 … log_link_warning_errno(link, r, "rtnl: could not get NHA_ID attribute, ignoring: %m"); in manager_rtnl_process_nexthop()
950 … log_link_warning(link, "rtnl: received nexthop message with invalid nexthop ID, ignoring: %m"); in manager_rtnl_process_nexthop()
957 link = NULL; in manager_rtnl_process_nexthop()
959 (void) nexthop_get(m, link, tmp, &nexthop); in manager_rtnl_process_nexthop()
966 log_nexthop_debug(tmp, "Received remembered", link); in manager_rtnl_process_nexthop()
969 log_nexthop_debug(tmp, "Remembering", link); in manager_rtnl_process_nexthop()
971 r = nexthop_add(m, link, tmp); in manager_rtnl_process_nexthop()
973 … log_link_warning_errno(link, r, "Could not remember foreign nexthop, ignoring: %m"); in manager_rtnl_process_nexthop()
985 log_nexthop_debug(nexthop, "Forgetting", link); in manager_rtnl_process_nexthop()
988 log_nexthop_debug(nexthop, "Removed", link); in manager_rtnl_process_nexthop()
990 log_nexthop_debug(tmp, "Kernel removed unknown", link); in manager_rtnl_process_nexthop()