From: Michael Tremer Date: Mon, 13 Feb 2023 15:05:41 +0000 (+0000) Subject: networkd: Store any flags X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Fnetwork.git;a=commitdiff_plain;h=c65300b47197145ac899bd2e80597b4c6b44ca6d networkd: Store any flags Signed-off-by: Michael Tremer --- diff --git a/src/networkd/link.c b/src/networkd/link.c index 2f95dc30..78ae106d 100644 --- a/src/networkd/link.c +++ b/src/networkd/link.c @@ -45,6 +45,9 @@ struct nw_link { uint32_t mtu; uint32_t min_mtu; uint32_t max_mtu; + + // Flags + unsigned int flags; }; int nw_link_create(nw_link** link, nw_daemon* daemon, int ifindex) { @@ -168,6 +171,29 @@ static int nw_link_update_mtu(nw_link* link, sd_netlink_message* message) { return 0; } +static int nw_link_update_flags(nw_link* link, sd_netlink_message* message) { + unsigned int flags = 0; + int r; + + // Fetch flags + r = sd_rtnl_message_link_get_flags(message, &flags); + if (r < 0) { + return DEBUG("Could not read link flags: %m\n"); + return 1; + } + + // End here if there have been no changes + if (link->flags == flags) + return 0; + + // XXX We should log any changes here + + // Store the new flags + link->flags = flags; + + return 0; +} + /* This function is called whenever anything changes, so that we can update our internal link object. @@ -185,6 +211,11 @@ static int nw_link_update(nw_link* link, sd_netlink_message* message) { if (r) return r; + // Update flags + r = nw_link_update_flags(link, message); + if (r) + return r; + return 0; }