diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-10-04 00:37:22 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-10-06 19:50:51 +0200 |
commit | 2ffd6d73f946d3d1619e06301b71482f2c60b078 (patch) | |
tree | d182228a3635f5bfce5c9726d4f6b4c61e673324 /src/network/networkd-lldp-rx.c | |
parent | network: move link_enumerate_ipv6_tentative_addresses() (diff) | |
download | systemd-2ffd6d73f946d3d1619e06301b71482f2c60b078.tar.xz systemd-2ffd6d73f946d3d1619e06301b71482f2c60b078.zip |
network: check feature is enabled in xxx_configure()
Diffstat (limited to 'src/network/networkd-lldp-rx.c')
-rw-r--r-- | src/network/networkd-lldp-rx.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/network/networkd-lldp-rx.c b/src/network/networkd-lldp-rx.c index fe88777977..a97bdeda19 100644 --- a/src/network/networkd-lldp-rx.c +++ b/src/network/networkd-lldp-rx.c @@ -25,7 +25,7 @@ static const char* const lldp_mode_table[_LLDP_MODE_MAX] = { DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(lldp_mode, LLDPMode, LLDP_MODE_YES); -bool link_lldp_rx_enabled(Link *link) { +static bool link_lldp_rx_enabled(Link *link) { assert(link); if (link->flags & IFF_LOOPBACK) @@ -68,9 +68,18 @@ static void lldp_handler(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n int link_lldp_rx_configure(Link *link) { int r; - r = sd_lldp_new(&link->lldp); - if (r < 0) - return r; + if (!link_lldp_rx_enabled(link)) + return 0; + + if (!link->lldp) { + r = sd_lldp_new(&link->lldp); + if (r < 0) + return r; + + r = sd_lldp_attach_event(link->lldp, NULL, 0); + if (r < 0) + return r; + } r = sd_lldp_set_ifindex(link->lldp, link->ifindex); if (r < 0) @@ -87,10 +96,6 @@ int link_lldp_rx_configure(Link *link) { if (r < 0) return r; - r = sd_lldp_attach_event(link->lldp, NULL, 0); - if (r < 0) - return r; - r = sd_lldp_set_callback(link->lldp, lldp_handler, link); if (r < 0) return r; |