Lines Matching refs:link

30 static bool link_lldp_rx_enabled(Link *link) {  in link_lldp_rx_enabled()  argument
31 assert(link); in link_lldp_rx_enabled()
33 if (link->flags & IFF_LOOPBACK) in link_lldp_rx_enabled()
36 if (link->iftype != ARPHRD_ETHER) in link_lldp_rx_enabled()
39 if (!link->network) in link_lldp_rx_enabled()
45 if (link->kind && STR_IN_SET(link->kind, "bridge", "bond")) in link_lldp_rx_enabled()
48 return link->network->lldp_mode != LLDP_MODE_NO; in link_lldp_rx_enabled()
52 Link *link = userdata; in lldp_rx_handler() local
55 assert(link); in lldp_rx_handler()
57 (void) link_lldp_save(link); in lldp_rx_handler()
59 if (link->lldp_tx && event == SD_LLDP_RX_EVENT_ADDED) { in lldp_rx_handler()
62 …log_link_debug(link, "Received LLDP datagram from previously unknown neighbor, restarting 'fast' L… in lldp_rx_handler()
64 (void) sd_lldp_tx_stop(link->lldp_tx); in lldp_rx_handler()
65 r = sd_lldp_tx_start(link->lldp_tx); in lldp_rx_handler()
67 log_link_warning_errno(link, r, "Failed to restart LLDP transmission: %m"); in lldp_rx_handler()
71 int link_lldp_rx_configure(Link *link) { in link_lldp_rx_configure() argument
74 if (!link_lldp_rx_enabled(link)) in link_lldp_rx_configure()
77 if (link->lldp_rx) in link_lldp_rx_configure()
80 r = sd_lldp_rx_new(&link->lldp_rx); in link_lldp_rx_configure()
84 r = sd_lldp_rx_attach_event(link->lldp_rx, link->manager->event, 0); in link_lldp_rx_configure()
88 r = sd_lldp_rx_set_ifindex(link->lldp_rx, link->ifindex); in link_lldp_rx_configure()
92 r = sd_lldp_rx_match_capabilities(link->lldp_rx, in link_lldp_rx_configure()
93 link->network->lldp_mode == LLDP_MODE_ROUTERS_ONLY ? in link_lldp_rx_configure()
99 r = sd_lldp_rx_set_filter_address(link->lldp_rx, &link->hw_addr.ether); in link_lldp_rx_configure()
103 r = sd_lldp_rx_set_callback(link->lldp_rx, lldp_rx_handler, link); in link_lldp_rx_configure()
110 int link_lldp_save(Link *link) { in link_lldp_save() argument
116 assert(link); in link_lldp_save()
118 if (isempty(link->lldp_file)) in link_lldp_save()
121 if (!link->lldp_rx) { in link_lldp_save()
122 (void) unlink(link->lldp_file); in link_lldp_save()
126 r = sd_lldp_rx_get_neighbors(link->lldp_rx, &l); in link_lldp_save()
130 (void) unlink(link->lldp_file); in link_lldp_save()
136 r = fopen_temporary(link->lldp_file, &f, &temp_path); in link_lldp_save()
160 r = conservative_rename(temp_path, link->lldp_file); in link_lldp_save()
166 … log_link_error_errno(link, r, "Failed to save LLDP data to %s: %m", link->lldp_file); in link_lldp_save()