Permit IPv6 Address Router Advertisement values to be changed
The current IPv6 Address Router Advertisement value written to the
configuration file is always 'false'. This allows DBus to update the
configuration file with either boolean value.
Tested:
Used dbus-send to modify the IPv6AcceptRA property. Confirmed the
/etc/systemd/network/00-bmc-ethx.network file updated.
Change-Id: Ia57ca80122411aabf84afb7334d70b5b7740bd28
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index f4f8d57..b03e761 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -48,6 +48,7 @@
std::replace(intfName.begin(), intfName.end(), '_', '.');
interfaceName(intfName);
EthernetInterfaceIntf::dHCPEnabled(dhcpEnabled);
+ EthernetInterfaceIntf::iPv6AcceptRA(getIPv6AcceptRAFromConf());
MacAddressIntf::mACAddress(getMACAddress(intfName));
EthernetInterfaceIntf::nTPServers(getNTPServersFromConf());
EthernetInterfaceIntf::nameservers(getNameServerFromConf());
@@ -418,6 +419,17 @@
return objectPath.string();
}
+bool EthernetInterface::iPv6AcceptRA(bool value)
+{
+ if (value == EthernetInterfaceIntf::iPv6AcceptRA())
+ {
+ return value;
+ }
+ EthernetInterfaceIntf::iPv6AcceptRA(value);
+ manager.writeToConfigurationFile();
+ return value;
+}
+
bool EthernetInterface::dHCPEnabled(bool value)
{
if (value == EthernetInterfaceIntf::dHCPEnabled())
@@ -532,6 +544,26 @@
return path;
}
+bool EthernetInterface::getIPv6AcceptRAFromConf()
+{
+ fs::path confPath = manager.getConfDir();
+
+ std::string fileName = systemd::config::networkFilePrefix +
+ interfaceName() + systemd::config::networkFileSuffix;
+ confPath /= fileName;
+ config::ValueList values;
+ config::Parser parser(confPath.string());
+ auto rc = config::ReturnCode::SUCCESS;
+ std::tie(rc, values) = parser.getValues("Network", "IPv6AcceptRA");
+ if (rc != config::ReturnCode::SUCCESS)
+ {
+ log<level::DEBUG>("Unable to get the value for Network[IPv6AcceptRA]",
+ entry("rc=%d", rc));
+ return false;
+ }
+ return (values[0] == "true");
+}
+
ServerList EthernetInterface::getNTPServersFromConf()
{
fs::path confPath = manager.getConfDir();
@@ -621,7 +653,8 @@
#else
stream << "LinkLocalAddressing=no\n";
#endif
- stream << "IPv6AcceptRA=false\n";
+ stream << std::boolalpha
+ << "IPv6AcceptRA=" << EthernetInterfaceIntf::iPv6AcceptRA() << "\n";
// Add the VLAN entry
for (const auto& intf : vlanInterfaces)
diff --git a/ethernet_interface.hpp b/ethernet_interface.hpp
index 3935390..e48fddb 100644
--- a/ethernet_interface.hpp
+++ b/ethernet_interface.hpp
@@ -156,6 +156,16 @@
*/
std::string mACAddress(std::string value) override;
+ /** @brief get the IPv6AcceptRA flag from the network configuration file
+ *
+ */
+ bool getIPv6AcceptRAFromConf();
+
+ /** @brief check conf file for Router Advertisements
+ *
+ */
+ bool iPv6AcceptRA(bool value) override;
+
/** @brief sets the NTP servers.
* @param[in] value - vector of NTP servers.
*/