Set MAC address only when it changes
If the MAC address hasn't been set or has changed,
set it. Otherwise, don't set it because it will cause
the link to reset.
Change-Id: I9018df6a3fa4743894bc0f3cd47bdf1be71632e4
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 6b6948a..15f40fb 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -675,6 +675,13 @@
return MacAddressIntf::mACAddress();
}
+ // Check if the MAC changed.
+ auto pmac = MacAddressIntf::mACAddress();
+ if (strcasecmp(pmac.c_str(), value.c_str()) == 0)
+ {
+ return MacAddressIntf::mACAddress();
+ }
+
// Allow the mac to be set if one of the condition is true.
// 1) Incoming Mac is of local admin type.
// or