]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/networkd/link.c
networkd: Store operstate, too
[people/ms/network.git] / src / networkd / link.c
index 78ae106daa0ec5a9791c5682eb47eae4d7ed7992..6392a90a3b90c33024119df990d9245739e8f5b9 100644 (file)
@@ -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;
 }