summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--network_manager.cpp29
-rw-r--r--network_manager.hpp3
2 files changed, 28 insertions, 4 deletions
diff --git a/network_manager.cpp b/network_manager.cpp
index 011e978..e9a62ed 100644
--- a/network_manager.cpp
+++ b/network_manager.cpp
@@ -170,13 +170,13 @@ void Manager::writeToConfigurationFile()
// DHCP
if (intf.second->dHCPEnabled() == true)
{
- stream << "DHCP=true\n";
- // write the dhcp section
- stream << "[DHCP]\n";
- stream << "ClientIdentifier=mac\n";
+ // write the dhcp section if interface is
+ // configured as dhcp.
+ writeDHCPSection(stream);
stream.close();
continue;
}
+
// Static
for (const auto& addr : addrs)
{
@@ -225,6 +225,27 @@ void Manager::writeToConfigurationFile()
restartSystemdUnit("systemd-networkd.service");
}
+void Manager::writeDHCPSection(std::fstream& stream)
+{
+ using namespace std::string_literals;
+ stream << "DHCP=true\n";
+ // write the dhcp section
+ stream << "[DHCP]\n";
+
+ // Hardcoding the client identifier to mac, to address below issue
+ // https://github.com/openbmc/openbmc/issues/1280
+ stream << "ClientIdentifier=mac\n";
+
+ auto value = dhcpConf->dNSEnabled() ? "true"s : "false"s;
+ stream << "UseDNS="s + value + "\n";
+
+ value = dhcpConf->nTPEnabled() ? "true"s : "false"s;
+ stream << "UseNTP="s + value + "\n";
+
+ value = dhcpConf->hostNameEnabled() ? "true"s : "false"s;
+ stream << "UseHostname="s + value + "\n";
+}
+
bool Manager::getDHCPValue(const std::string& intf)
{
bool dhcp = false;
diff --git a/network_manager.hpp b/network_manager.hpp
index 762b3e1..e5ca96b 100644
--- a/network_manager.hpp
+++ b/network_manager.hpp
@@ -75,6 +75,9 @@ class Manager : public details::VLANCreateIface
private:
+ /** @brief write the dhcp section **/
+ void writeDHCPSection(std::fstream& stream);
+
/** @brief Persistent sdbusplus DBus bus connection. */
sdbusplus::bus::bus& bus;
OpenPOWER on IntegriCloud