discover/network: Mark interfaces configured once configured
diff mbox

Message ID 20160616053127.22983-1-sam@mendozajonas.com
State Accepted
Headers show

Commit Message

Samuel Mendoza-Jonas June 16, 2016, 5:31 a.m. UTC
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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch
diff mbox

diff --git a/discover/network.c b/discover/network.c
index c072eec..4b79015 100644
--- a/discover/network.c
+++ b/discover/network.c
@@ -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)