]> git.ipfire.org Git - network.git/commitdiff
networkd: Store any flags
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 13 Feb 2023 15:05:41 +0000 (15:05 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 13 Feb 2023 15:05:41 +0000 (15:05 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/link.c

index 2f95dc3070d310c04bc1008a8626d9bcc1b218e1..78ae106daa0ec5a9791c5682eb47eae4d7ed7992 100644 (file)
@@ -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;
 }