discover/network: Mark interfaces configured once configured
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 16 Jun 2016 05:18:30 +0000 (15:18 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 14 Jul 2016 03:49:34 +0000 (13:49 +1000)
In some cases additional netlink messages can be received for an
already-configured interface without any relevant changes. This can
result in multiple DHCP requests for the same interface.
Once an interface has been configured mark it as IFSTATE_CONFIGURED
to avoid configuring it again.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/network.c

index c072eece9627408ac7bbebab2d227d968a8f9fbf..4b79015c24a2ec52dc83db86a5e2b633729ca449 100644 (file)
@@ -398,8 +398,11 @@ static void configure_interface(struct network *network,
                        interface->state = IFSTATE_NEW;
                else if (!link)
                        interface->state = IFSTATE_UP_WAITING_LINK;
-               else
+               else {
+                       pb_debug("network: skipping configured interface %s\n",
+                                       interface->name);
                        return;
+               }
        }
 
        /* always up the lookback, no other handling required */
@@ -451,6 +454,8 @@ static void configure_interface(struct network *network,
        } else if (config->method == CONFIG_METHOD_STATIC) {
                configure_interface_static(network, interface, config);
        }
+
+       interface->state = IFSTATE_CONFIGURED;
 }
 
 static int network_handle_nlmsg(struct network *network, struct nlmsghdr *nlmsg)