Lines Matching refs:neighbor

13 Neighbor *neighbor_free(Neighbor *neighbor) {  in neighbor_free()  argument
14 if (!neighbor) in neighbor_free()
17 if (neighbor->network) { in neighbor_free()
18 assert(neighbor->section); in neighbor_free()
19 hashmap_remove(neighbor->network->neighbors_by_section, neighbor->section); in neighbor_free()
22 config_section_free(neighbor->section); in neighbor_free()
24 if (neighbor->link) in neighbor_free()
25 set_remove(neighbor->link->neighbors, neighbor); in neighbor_free()
27 return mfree(neighbor); in neighbor_free()
34 _cleanup_(neighbor_freep) Neighbor *neighbor = NULL; in neighbor_new_static()
46 neighbor = hashmap_get(network->neighbors_by_section, n); in neighbor_new_static()
47 if (neighbor) { in neighbor_new_static()
48 *ret = TAKE_PTR(neighbor); in neighbor_new_static()
52 neighbor = new(Neighbor, 1); in neighbor_new_static()
53 if (!neighbor) in neighbor_new_static()
56 *neighbor = (Neighbor) { in neighbor_new_static()
63 …_ensure_put(&network->neighbors_by_section, &config_section_hash_ops, neighbor->section, neighbor); in neighbor_new_static()
67 *ret = TAKE_PTR(neighbor); in neighbor_new_static()
71 static int neighbor_dup(const Neighbor *neighbor, Neighbor **ret) { in neighbor_dup() argument
74 assert(neighbor); in neighbor_dup()
77 dest = newdup(Neighbor, neighbor, 1); in neighbor_dup()
90 static void neighbor_hash_func(const Neighbor *neighbor, struct siphash *state) { in neighbor_hash_func() argument
91 assert(neighbor); in neighbor_hash_func()
93 siphash24_compress(&neighbor->family, sizeof(neighbor->family), state); in neighbor_hash_func()
95 switch (neighbor->family) { in neighbor_hash_func()
99 … siphash24_compress(&neighbor->in_addr, FAMILY_ADDRESS_SIZE(neighbor->family), state); in neighbor_hash_func()
106 hw_addr_hash_func(&neighbor->ll_addr, state); in neighbor_hash_func()
144 static int neighbor_add(Link *link, Neighbor *neighbor) { in neighbor_add() argument
148 assert(neighbor); 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
163 assert(neighbor); in log_neighbor_debug()
169 (void) network_config_state_to_string_alloc(neighbor->state, &state); in log_neighbor_debug()
170 (void) in_addr_to_string(neighbor->family, &neighbor->in_addr, &dst); in log_neighbor_debug()
174 str, strna(network_config_source_to_string(neighbor->source)), strna(state), in log_neighbor_debug()
175 HW_ADDR_TO_STR(&neighbor->ll_addr), strna(dst)); in log_neighbor_debug()
178 static int neighbor_configure_message(Neighbor *neighbor, Link *link, sd_netlink_message *req) { in neighbor_configure_message() argument
185 r = netlink_message_append_hw_addr(req, NDA_LLADDR, &neighbor->ll_addr); in neighbor_configure_message()
189 … r = netlink_message_append_in_addr_union(req, NDA_DST, neighbor->family, &neighbor->in_addr); in neighbor_configure_message()
196 static int neighbor_configure(Neighbor *neighbor, Link *link, Request *req) { in neighbor_configure() argument
200 assert(neighbor); in neighbor_configure()
207 log_neighbor_debug(neighbor, "Configuring", link); in neighbor_configure()
210 link->ifindex, neighbor->family); in neighbor_configure()
214 r = neighbor_configure_message(neighbor, link, m); in neighbor_configure()
221 static int neighbor_process_request(Request *req, Link *link, Neighbor *neighbor) { in neighbor_process_request() argument
226 assert(neighbor); in neighbor_process_request()
231 r = neighbor_configure(neighbor, link, req); in neighbor_process_request()
235 neighbor_enter_configuring(neighbor); in neighbor_process_request()
239 …re_handler(sd_netlink *rtnl, sd_netlink_message *m, Request *req, Link *link, Neighbor *neighbor) { in static_neighbor_configure_handler() argument
261 static int link_request_neighbor(Link *link, const Neighbor *neighbor) { in link_request_neighbor() argument
266 assert(neighbor); in link_request_neighbor()
267 assert(neighbor->source != NETWORK_CONFIG_SOURCE_FOREIGN); in link_request_neighbor()
269 if (neighbor_get(link, neighbor, &existing) < 0) { in link_request_neighbor()
272 r = neighbor_dup(neighbor, &tmp); in link_request_neighbor()
282 existing->source = neighbor->source; in link_request_neighbor()
301 Neighbor *neighbor; in link_request_static_neighbors() local
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()
344 static int neighbor_remove(Neighbor *neighbor) { in neighbor_remove() argument
349 assert(neighbor); in neighbor_remove()
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()
359 link->ifindex, neighbor->family); in neighbor_remove()
363 … r = netlink_message_append_in_addr_union(req, NDA_DST, neighbor->family, &neighbor->in_addr); in neighbor_remove()
374 neighbor_enter_removing(neighbor); in neighbor_remove()
379 Neighbor *neighbor; in link_drop_foreign_neighbors() local
386 SET_FOREACH(neighbor, link->neighbors) { in link_drop_foreign_neighbors()
388 if (neighbor->source != NETWORK_CONFIG_SOURCE_FOREIGN) in link_drop_foreign_neighbors()
392 if (!neighbor_exists(neighbor)) in link_drop_foreign_neighbors()
395 neighbor_mark(neighbor); 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()
407 if (!neighbor_is_marked(neighbor)) in link_drop_foreign_neighbors()
410 k = neighbor_remove(neighbor); in link_drop_foreign_neighbors()
419 Neighbor *neighbor; in link_drop_managed_neighbors() local
424 SET_FOREACH(neighbor, link->neighbors) { in link_drop_managed_neighbors()
426 if (neighbor->source == NETWORK_CONFIG_SOURCE_FOREIGN) in link_drop_managed_neighbors()
430 if (!neighbor_exists(neighbor)) in link_drop_managed_neighbors()
433 k = neighbor_remove(neighbor); in link_drop_managed_neighbors()
442 Neighbor *neighbor; in link_foreignize_neighbors() local
446 SET_FOREACH(neighbor, link->neighbors) in link_foreignize_neighbors()
447 neighbor->source = NETWORK_CONFIG_SOURCE_FOREIGN; in link_foreignize_neighbors()
452 Neighbor *neighbor = NULL; in manager_rtnl_process_neighbor() local
527 (void) neighbor_get(link, tmp, &neighbor); in manager_rtnl_process_neighbor()
531 if (neighbor) { in manager_rtnl_process_neighbor()
532 neighbor_enter_configured(neighbor); in manager_rtnl_process_neighbor()
533 log_neighbor_debug(neighbor, "Received remembered", link); in manager_rtnl_process_neighbor()
548 if (neighbor) { in manager_rtnl_process_neighbor()
549 neighbor_enter_removed(neighbor); in manager_rtnl_process_neighbor()
550 if (neighbor->state == 0) { in manager_rtnl_process_neighbor()
551 log_neighbor_debug(neighbor, "Forgetting", link); in manager_rtnl_process_neighbor()
552 neighbor_free(neighbor); in manager_rtnl_process_neighbor()
554 log_neighbor_debug(neighbor, "Removed", link); in manager_rtnl_process_neighbor()
567 static int neighbor_section_verify(Neighbor *neighbor) { in neighbor_section_verify() argument
568 if (section_is_invalid(neighbor->section)) in neighbor_section_verify()
571 if (neighbor->family == AF_UNSPEC) in neighbor_section_verify()
575 neighbor->section->filename, neighbor->section->line); in neighbor_section_verify()
577 if (neighbor->ll_addr.length == 0) in neighbor_section_verify()
581 neighbor->section->filename, neighbor->section->line); in neighbor_section_verify()
587 Neighbor *neighbor; in network_drop_invalid_neighbors() local
591 HASHMAP_FOREACH(neighbor, network->neighbors_by_section) in network_drop_invalid_neighbors()
592 if (neighbor_section_verify(neighbor) < 0) in network_drop_invalid_neighbors()
593 neighbor_free(neighbor); in network_drop_invalid_neighbors()