Treat link-local addresses as static when link
local autoconfig is disabled.
Although a link-local IP can be set via ipmitool (e.g.,
`ipmitool lan set 1 ipaddr 169.254.x.x`), it cannot be read back:
`ipmitool lan print 1` reports "IP Address : 0.0.0.0". That's because
phosphor-host-ipmid only considers static and DHCP addresses:
https://github.com/openbmc/phosphor-host-ipmid/blob/master/transporthandler.cpp#L52
Treating a link-local IP as static when autoconfiguration is disabled
allows it to be reported back by "ipmitool lan print".
TESTED: Built with `default-link-local-autoconf=false`. Set a link-local
ip via `ipmitool lan set 1 ipaddr` and verified it is correctly reported
back via `ipmitool lan print 1`.
Signed-off-by: Ali El-Haj-Mahmoud <aaelhaj@google.com>
Change-Id: I4f9871095b8b99dd7e7957babda39d89c5856be2
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index 529bb2a..632518c 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -229,10 +229,12 @@
{
origin = IP::AddressOrigin::DHCP;
}
+#ifdef LINK_LOCAL_AUTOCONFIGURATION
if (addr.scope == RT_SCOPE_LINK)
{
origin = IP::AddressOrigin::LinkLocal;
}
+#endif
auto ipAddressObjectPath =
generateObjectPath(addressType, address, addr.prefix, origin);