Configure DHCP4 and DHCP6 parameters independently
At present, DHCP parameters like DNSEnabled, NTPEnabled etc. are
shared between DHCPv4 and DHCPv6 in the network configuration.
Hence any update on the ipv4 parameters impacts the ipv6 and get
applied to both the interfaces.
This change is to enable the possibility to configure DHCP attributes
independently, by having different dbus objects for dhcp4 and dhcp6
and moving the dhcp configuration from network level to ethernet
interface.
tested by:
Used the busctl command to set and get the parameter values
individually for both DHCPv4 and DHCPv6.
Verified the network configuration file is updated accordingly
Tree Structure:
busctl tree xyz.openbmc_project.Network
`-/xyz
`-/xyz/openbmc_project
`-/xyz/openbmc_project/network
|-/xyz/openbmc_project/network/config
|-/xyz/openbmc_project/network/eth0
| |-/xyz/openbmc_project/network/eth0/dhcp4
| `-/xyz/openbmc_project/network/eth0/dhcp6
`-/xyz/openbmc_project/network/eth1
|-/xyz/openbmc_project/network/eth1/dhcp4
`-/xyz/openbmc_project/network/eth1/dhcp6
Change-Id: If7dbbf596bdaf866ea459d631e716153f54302ec
Signed-off-by: Jishnu CM <jishnunambiarcm@duck.com>
diff --git a/src/dhcp_configuration.cpp b/src/dhcp_configuration.cpp
index c649568..04a56a0 100644
--- a/src/dhcp_configuration.cpp
+++ b/src/dhcp_configuration.cpp
@@ -2,7 +2,6 @@
#include "config_parser.hpp"
#include "network_manager.hpp"
-#include "util.hpp"
#include <sys/stat.h>
@@ -24,15 +23,16 @@
Configuration::Configuration(sdbusplus::bus_t& bus,
stdplus::const_zstring objPath,
- stdplus::PinnedRef<Manager> parent) :
+ stdplus::PinnedRef<EthernetInterface> parent,
+ DHCPType type) :
Iface(bus, objPath.c_str(), Iface::action::defer_emit),
- manager(parent)
+ parent(parent), type(type)
{
config::Parser conf;
std::filesystem::directory_entry newest_file;
time_t newest_time = 0;
- for (const auto& dirent :
- std::filesystem::directory_iterator(manager.get().getConfDir()))
+ for (const auto& dirent : std::filesystem::directory_iterator(
+ parent.get().manager.get().getConfDir()))
{
struct stat st = {};
stat(dirent.path().native().c_str(), &st);
@@ -49,10 +49,15 @@
conf.setFile(newest_file.path());
}
- ConfigIntf::dnsEnabled(getDHCPProp(conf, "UseDNS"), true);
- ConfigIntf::ntpEnabled(getDHCPProp(conf, "UseNTP"), true);
- ConfigIntf::hostNameEnabled(getDHCPProp(conf, "UseHostname"), true);
- ConfigIntf::sendHostNameEnabled(getDHCPProp(conf, "SendHostname"), true);
+ ConfigIntf::dnsEnabled(getDHCPProp(conf, type, "UseDNS"), true);
+ ConfigIntf::ntpEnabled(getDHCPProp(conf, type, "UseNTP"), true);
+ ConfigIntf::hostNameEnabled(getDHCPProp(conf, type, "UseHostname"), true);
+ if (type == DHCPType::v4)
+ {
+ ConfigIntf::sendHostNameEnabled(getDHCPProp(conf, type, "SendHostname"),
+ true);
+ }
+
emit_object_added();
}
@@ -64,10 +69,8 @@
}
auto name = ConfigIntf::sendHostNameEnabled(value);
-
- manager.get().writeToConfigurationFile();
- manager.get().reloadConfigs();
-
+ parent.get().writeConfigurationFile();
+ parent.get().reloadConfigs();
return name;
}
@@ -79,8 +82,8 @@
}
auto name = ConfigIntf::hostNameEnabled(value);
- manager.get().writeToConfigurationFile();
- manager.get().reloadConfigs();
+ parent.get().writeConfigurationFile();
+ parent.get().reloadConfigs();
return name;
}
@@ -93,8 +96,8 @@
}
auto ntp = ConfigIntf::ntpEnabled(value);
- manager.get().writeToConfigurationFile();
- manager.get().reloadConfigs();
+ parent.get().writeConfigurationFile();
+ parent.get().reloadConfigs();
return ntp;
}
@@ -107,8 +110,8 @@
}
auto dns = ConfigIntf::dnsEnabled(value);
- manager.get().writeToConfigurationFile();
- manager.get().reloadConfigs();
+ parent.get().writeConfigurationFile();
+ parent.get().reloadConfigs();
return dns;
}