From: Michael Tremer Date: Mon, 13 Feb 2023 15:10:01 +0000 (+0000) Subject: networkd: Store operstate, too X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=69ef50c7403a5e09fcdf6ee4b53f94665920277a;p=network.git networkd: Store operstate, too Signed-off-by: Michael Tremer --- diff --git a/src/networkd/link.c b/src/networkd/link.c index 78ae106d..6392a90a 100644 --- a/src/networkd/link.c +++ b/src/networkd/link.c @@ -48,6 +48,7 @@ struct nw_link { // Flags unsigned int flags; + uint8_t operstate; }; int nw_link_create(nw_link** link, nw_daemon* daemon, int ifindex) { @@ -173,6 +174,7 @@ static int nw_link_update_mtu(nw_link* link, sd_netlink_message* message) { static int nw_link_update_flags(nw_link* link, sd_netlink_message* message) { unsigned int flags = 0; + uint8_t operstate = 0; int r; // Fetch flags @@ -182,14 +184,23 @@ static int nw_link_update_flags(nw_link* link, sd_netlink_message* message) { return 1; } + // Fetch operstate + r = sd_netlink_message_read_u8(message, IFLA_OPERSTATE, &operstate); + if (r < 1) { + ERROR("Could not read operstate: %m\n"); + return 1; + } + // End here if there have been no changes - if (link->flags == flags) + if (link->flags == flags && link->operstate == operstate) return 0; // XXX We should log any changes here - // Store the new flags + // Store the new flags & operstate link->flags = flags; + link->operstate = operstate; + return 0; }