]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: update wlan information when IFF_LOWER_UP flag is gained 19913/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Jun 2021 20:11:33 +0000 (05:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Jun 2021 20:14:22 +0000 (05:14 +0900)
Fixes the issue mentioned at
https://github.com/systemd/systemd/issues/19832#issuecomment-860269320.

src/network/networkd-link.c

index 3376a2f3e113b61a02feb1cbc9bcf764871c3811..c3729ce681b862958960e770bbdbac059d19cf02 100644 (file)
@@ -1497,17 +1497,6 @@ static int link_carrier_gained(Link *link) {
                 /* let's shortcut things for CAN which doesn't need most of what's done below. */
                 return 0;
 
-        r = wifi_get_info(link);
-        if (r < 0)
-                return r;
-        if (r > 0) {
-                /* All link information is up-to-date. So, it is not necessary to call RTM_GETLINK
-                 * netlink method again. */
-                r = link_reconfigure_impl(link, /* force = */ false);
-                if (r != 0)
-                        return r;
-        }
-
         if (IN_SET(link->state, LINK_STATE_CONFIGURING, LINK_STATE_CONFIGURED)) {
                 r = link_acquire_dynamic_conf(link);
                 if (r < 0)
@@ -1832,7 +1821,7 @@ void link_update_operstate(Link *link, bool also_update_master) {
          : "")
 
 static int link_update_flags(Link *link, sd_netlink_message *message) {
-        bool link_was_admin_up, had_carrier;
+        bool link_was_lower_up, link_was_admin_up, had_carrier;
         uint8_t operstate;
         unsigned flags;
         int r;
@@ -1894,6 +1883,7 @@ static int link_update_flags(Link *link, sd_netlink_message *message) {
                         log_link_debug(link, "Unknown link flags lost, ignoring: %#.5x", unknown_flags_removed);
         }
 
+        link_was_lower_up = link->flags & IFF_LOWER_UP;
         link_was_admin_up = link->flags & IFF_UP;
         had_carrier = link_has_carrier(link);
 
@@ -1902,6 +1892,19 @@ static int link_update_flags(Link *link, sd_netlink_message *message) {
 
         link_update_operstate(link, true);
 
+        if (!link_was_lower_up && (link->flags & IFF_LOWER_UP)) {
+                r = wifi_get_info(link);
+                if (r < 0)
+                        return r;
+                if (r > 0) {
+                        /* All link information is up-to-date. So, it is not necessary to call
+                         * RTM_GETLINK netlink method again. */
+                        r = link_reconfigure_impl(link, /* force = */ false);
+                        if (r < 0)
+                                return r;
+                }
+        }
+
         if (!link_was_admin_up && (link->flags & IFF_UP)) {
                 log_link_info(link, "Link UP");