Lines Matching refs:link

24         if (neighbor->link)  in neighbor_free()
25 set_remove(neighbor->link->neighbors, neighbor); in neighbor_free()
82 dest->link = NULL; in neighbor_dup()
129 static int neighbor_get(Link *link, const Neighbor *in, Neighbor **ret) { in neighbor_get() argument
132 assert(link); in neighbor_get()
135 existing = set_get(link->neighbors, in); in neighbor_get()
144 static int neighbor_add(Link *link, Neighbor *neighbor) { in neighbor_add() argument
147 assert(link); in neighbor_add()
150 r = set_ensure_put(&link->neighbors, &neighbor_hash_ops, neighbor); in neighbor_add()
156 neighbor->link = link; in neighbor_add()
160 static void log_neighbor_debug(const Neighbor *neighbor, const char *str, const Link *link) { in log_neighbor_debug() argument
172 log_link_debug(link, in log_neighbor_debug()
178 static int neighbor_configure_message(Neighbor *neighbor, Link *link, sd_netlink_message *req) { in neighbor_configure_message() argument
196 static int neighbor_configure(Neighbor *neighbor, Link *link, Request *req) { in neighbor_configure() argument
201 assert(link); in neighbor_configure()
202 assert(link->ifindex > 0); in neighbor_configure()
203 assert(link->manager); in neighbor_configure()
204 assert(link->manager->rtnl); in neighbor_configure()
207 log_neighbor_debug(neighbor, "Configuring", link); in neighbor_configure()
209 r = sd_rtnl_message_new_neigh(link->manager->rtnl, &m, RTM_NEWNEIGH, in neighbor_configure()
210 link->ifindex, neighbor->family); in neighbor_configure()
214 r = neighbor_configure_message(neighbor, link, m); in neighbor_configure()
218 return request_call_netlink_async(link->manager->rtnl, m, req); in neighbor_configure()
221 static int neighbor_process_request(Request *req, Link *link, Neighbor *neighbor) { in neighbor_process_request() argument
225 assert(link); in neighbor_process_request()
228 if (!link_is_ready_to_configure(link, false)) in neighbor_process_request()
231 r = neighbor_configure(neighbor, link, req); in neighbor_process_request()
233 return log_link_warning_errno(link, r, "Failed to configure neighbor: %m"); in neighbor_process_request()
239 …gure_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link, Neighbor *neighbor… in static_neighbor_configure_handler() argument
243 assert(link); in static_neighbor_configure_handler()
247 log_link_message_warning_errno(link, m, r, "Could not set neighbor"); in static_neighbor_configure_handler()
248 link_enter_failed(link); in static_neighbor_configure_handler()
252 if (link->static_neighbor_messages == 0) { in static_neighbor_configure_handler()
253 log_link_debug(link, "Neighbors set"); in static_neighbor_configure_handler()
254 link->static_neighbors_configured = true; in static_neighbor_configure_handler()
255 link_check_ready(link); in static_neighbor_configure_handler()
261 static int link_request_neighbor(Link *link, const Neighbor *neighbor) { in link_request_neighbor() argument
265 assert(link); in link_request_neighbor()
269 if (neighbor_get(link, neighbor, &existing) < 0) { in link_request_neighbor()
276 r = neighbor_add(link, tmp); in link_request_neighbor()
284 log_neighbor_debug(existing, "Requesting", link); in link_request_neighbor()
285 r = link_queue_request_safe(link, REQUEST_TYPE_NEIGHBOR, in link_request_neighbor()
290 &link->static_neighbor_messages, in link_request_neighbor()
300 int link_request_static_neighbors(Link *link) { in link_request_static_neighbors() argument
304 assert(link); in link_request_static_neighbors()
305 assert(link->network); in link_request_static_neighbors()
306 assert(link->state != _LINK_STATE_INVALID); in link_request_static_neighbors()
308 link->static_neighbors_configured = false; in link_request_static_neighbors()
310 HASHMAP_FOREACH(neighbor, link->network->neighbors_by_section) { in link_request_static_neighbors()
311 r = link_request_neighbor(link, neighbor); in link_request_static_neighbors()
313 return log_link_warning_errno(link, r, "Could not request neighbor: %m"); in link_request_static_neighbors()
316 if (link->static_neighbor_messages == 0) { in link_request_static_neighbors()
317 link->static_neighbors_configured = true; in link_request_static_neighbors()
318 link_check_ready(link); in link_request_static_neighbors()
320 log_link_debug(link, "Requesting neighbors"); in link_request_static_neighbors()
321 link_set_state(link, LINK_STATE_CONFIGURING); in link_request_static_neighbors()
327 static int neighbor_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) { in neighbor_remove_handler() argument
331 assert(link); in neighbor_remove_handler()
333 if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER)) in neighbor_remove_handler()
339 log_link_message_warning_errno(link, m, r, "Could not remove neighbor"); in neighbor_remove_handler()
346 Link *link; in neighbor_remove() local
350 assert(neighbor->link); in neighbor_remove()
351 assert(neighbor->link->manager); in neighbor_remove()
352 assert(neighbor->link->manager->rtnl); in neighbor_remove()
354 link = neighbor->link; in neighbor_remove()
356 log_neighbor_debug(neighbor, "Removing", link); in neighbor_remove()
358 r = sd_rtnl_message_new_neigh(link->manager->rtnl, &req, RTM_DELNEIGH, in neighbor_remove()
359 link->ifindex, neighbor->family); in neighbor_remove()
361 return log_link_error_errno(link, r, "Could not allocate RTM_DELNEIGH message: %m"); in neighbor_remove()
365 return log_link_error_errno(link, r, "Could not append NDA_DST attribute: %m"); in neighbor_remove()
367 r = netlink_call_async(link->manager->rtnl, NULL, req, neighbor_remove_handler, in neighbor_remove()
368 link_netlink_destroy_callback, link); in neighbor_remove()
370 return log_link_error_errno(link, r, "Could not send rtnetlink message: %m"); in neighbor_remove()
372 link_ref(link); in neighbor_remove()
378 int link_drop_foreign_neighbors(Link *link) { in link_drop_foreign_neighbors() argument
382 assert(link); in link_drop_foreign_neighbors()
383 assert(link->network); in link_drop_foreign_neighbors()
386 SET_FOREACH(neighbor, link->neighbors) { in link_drop_foreign_neighbors()
399 HASHMAP_FOREACH(neighbor, link->network->neighbors_by_section) { in link_drop_foreign_neighbors()
402 if (neighbor_get(link, neighbor, &existing) >= 0) in link_drop_foreign_neighbors()
406 SET_FOREACH(neighbor, link->neighbors) { in link_drop_foreign_neighbors()
418 int link_drop_managed_neighbors(Link *link) { in link_drop_managed_neighbors() argument
422 assert(link); in link_drop_managed_neighbors()
424 SET_FOREACH(neighbor, link->neighbors) { in link_drop_managed_neighbors()
441 void link_foreignize_neighbors(Link *link) { in link_foreignize_neighbors() argument
444 assert(link); in link_foreignize_neighbors()
446 SET_FOREACH(neighbor, link->neighbors) in link_foreignize_neighbors()
455 Link *link; in manager_rtnl_process_neighbor() local
496 r = link_get_by_index(m, ifindex, &link); in manager_rtnl_process_neighbor()
497 if (r < 0 || !link) { in manager_rtnl_process_neighbor()
508 log_link_warning(link, "rtnl: received neighbor message without family, ignoring."); in manager_rtnl_process_neighbor()
511 …log_link_debug(link, "rtnl: received neighbor message with invalid family '%i', ignoring.", tmp->f… in manager_rtnl_process_neighbor()
517 …log_link_warning_errno(link, r, "rtnl: received neighbor message without valid address, ignoring: … in manager_rtnl_process_neighbor()
523 …log_link_warning_errno(link, r, "rtnl: received neighbor message without valid link layer address,… in manager_rtnl_process_neighbor()
527 (void) neighbor_get(link, tmp, &neighbor); in manager_rtnl_process_neighbor()
533 log_neighbor_debug(neighbor, "Received remembered", link); in manager_rtnl_process_neighbor()
536 log_neighbor_debug(tmp, "Remembering", link); in manager_rtnl_process_neighbor()
537 r = neighbor_add(link, tmp); in manager_rtnl_process_neighbor()
539 … log_link_warning_errno(link, r, "Failed to remember foreign neighbor, ignoring: %m"); in manager_rtnl_process_neighbor()
551 log_neighbor_debug(neighbor, "Forgetting", link); in manager_rtnl_process_neighbor()
554 log_neighbor_debug(neighbor, "Removed", link); in manager_rtnl_process_neighbor()
556 log_neighbor_debug(tmp, "Kernel removed unknown", link); in manager_rtnl_process_neighbor()