ethernet_interface: Defer link down for MAC change
We don't want the interface to become unavailable until right before a
reload is triggered. Right now this is okay because reloads happen
instantaneously. A follow up patch will defer reloads for a set amount
of time, and we don't want the NIC to be down for the entire time.
Change-Id: I3ad7ed0deb0a3154535f85e1a26a00add123b518
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index 2e15803..3ab8d81 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -1241,9 +1241,11 @@
MacAddressIntf::macAddress(validMAC);
writeConfigurationFile();
- // The MAC and LLADDRs will only update if the NIC is already down
- EthernetIntfSocket eifSocket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
- setNICAdminState(eifSocket.sock, interface.c_str(), false);
+ manager.addReloadPreHook([interface]() {
+ // The MAC and LLADDRs will only update if the NIC is already down
+ EthernetIntfSocket eifSocket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
+ setNICAdminState(eifSocket.sock, interface.c_str(), false);
+ });
manager.reloadConfigs();
}