Skip to content

Commit

Permalink
Change SLAAC to IPv6SLAAC as per bios enum (openbmc#67)
Browse files Browse the repository at this point in the history
* Change SLAAC to IPv6SLAAC as per bios enum

The "method" attribute of the bios table had the below
values:
"IPv6Static", "IPv6DHCP", "SLAAC"

There is a recent change that changes "SLAAC" to "IPv6SLAAC".
This commit has changes with respect to the above change.

Tested By:

busctl set-property xyz.openbmc_project.Network.Hypervisor \
/xyz/openbmc_project/network/hypervisor/eth1 \
xyz.openbmc_project.Network.EthernetInterface DHCPEnabled s \
"xyz.openbmc_project.Network.EthernetInterface.DHCPConf.v6stateless"

When the above value is set, the dbus origin is changed to "SLAAC"
and bios table is updated to "IPv6SLAAC"

Change-Id: I619c80b4e25d4a5a8fb7766adcc1191de42b2ffd
Signed-off-by: Asmitha Karunanithi <[email protected]>

* Add dependency on pldm service for hypervisor app

The hypervisor app depends on the bios service currently,
that comes up with the bios table. But it is pldm that
populates the bios table values.

There are cases, where hypervisor app comes up first before
pldm populates the bios table, causing the app to have default values
(0.0.0.0 ip) in the dbus even when vmi ip has been configured.

This commit adds a dependency on pldm service for the
hypervisor app to start.

Tested By:
* Rebooted the bmc - and checked if hypervisor dbus has the vmi ip
  that is configured
* Code updated the bmc to observe the same behaviour as above

Change-Id: I1ba3c54c0eb24ebe7c5fab52ef80a47bd9d57c82
Signed-off-by: Asmitha Karunanithi <[email protected]>

* code-format: fix up downstream clang issues

1050 branch didn't have CI running so some issues got in. Enable CI and
fix issues.

Signed-off-by: Andrew Geissler <[email protected]>

* Fix CI failure for a unit test case

This commit resolves CI failure for dhcpEnabled test case

Change-Id: Ifcb90fc077eba9e44b394f95325e11e22d79322b
Signed-off-by: Asmitha Karunanithi <[email protected]>

---------

Signed-off-by: Asmitha Karunanithi <[email protected]>
Signed-off-by: Andrew Geissler <[email protected]>
Co-authored-by: Andrew Geissler <[email protected]>
  • Loading branch information
asmithakarun and geissonator authored Mar 28, 2023
1 parent d8e6801 commit 8fa2a6d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/ethernet_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ ServerList EthernetInterface::staticNameServers(ServerList value)
void EthernetInterface::loadNTPServers(const config::Parser& config)
{
std::string timeSyncMethod{};
auto method = bus.get().new_method_call("xyz.openbmc_project.Settings",
"/xyz/openbmc_project/time/sync_method",
PROPERTY_INTERFACE, METHOD_GET);
auto method = bus.get().new_method_call(
"xyz.openbmc_project.Settings", "/xyz/openbmc_project/time/sync_method",
PROPERTY_INTERFACE, METHOD_GET);

method.append("xyz.openbmc_project.Time.Synchronization", "TimeSyncMethod");

Expand All @@ -510,7 +510,8 @@ void EthernetInterface::loadNTPServers(const config::Parser& config)
{
EthernetInterfaceIntf::ntpServers(getNTPServerFromTimeSyncd());
}
EthernetInterfaceIntf::staticNTPServers(config.map.getValueStrings("Network", "NTP"));
EthernetInterfaceIntf::staticNTPServers(
config.map.getValueStrings("Network", "NTP"));
}

void EthernetInterface::loadNameServers(const config::Parser& config)
Expand Down
16 changes: 11 additions & 5 deletions src/ibm/hypervisor-network-mgr-src/hyp_ethernet_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ void HypEthInterface::watchBaseBiosTable()
DHCPConf dhcpState = ethObj->dhcpEnabled();
if ((dhcpState == HypEthInterface::DHCPConf::none) &&
((dhcpEnabled == "IPv4DHCP") ||
(dhcpEnabled == "IPv6DHCP") || (dhcpEnabled == "SLAAC")))
(dhcpEnabled == "IPv6DHCP") ||
(dhcpEnabled == "IPv6SLAAC")))
{
// There is a change in bios table method attribute (changed
// to dhcp) but dbus property contains static Change the
Expand All @@ -161,7 +162,7 @@ void HypEthInterface::watchBaseBiosTable()
ethObj->dhcp6(true);
}
}
else if (dhcpEnabled == "SLAAC")
else if (dhcpEnabled == "IPv6SLAAC")
{
if (ethObj->ipv6AcceptRA())
{
Expand Down Expand Up @@ -528,9 +529,10 @@ void HypEthInterface::createIPAddressObjects()
dhcp6(true);
}
}
else if ((ipType.find("SLAAC") != std::string::npos) &&
else if ((ipType.find("IPv6SLAAC") != std::string::npos) &&
(protocol == "ipv6"))
{
ipOrigin = HypIP::AddressOrigin::SLAAC;
ipv6AcceptRA(true);
}
else
Expand Down Expand Up @@ -1014,7 +1016,8 @@ HypEthInterface::DHCPConf HypEthInterface::dhcpEnabled(DHCPConf value)
{
if (slaacEnabled)
{
method = "SLAAC";
method = "IPv6SLAAC";
(itr->second)->origin(HypIP::AddressOrigin::SLAAC);
}
else if (v6Enabled)
{
Expand Down Expand Up @@ -1060,12 +1063,15 @@ HypEthInterface::DHCPConf HypEthInterface::dhcpEnabled(DHCPConf value)
((itr->second)->origin() == HypIP::AddressOrigin::DHCP))
{
method = "IPv4Static";
(itr->second)->origin(HypIP::AddressOrigin::Static);
(itr->second)->resetBaseBiosTableAttrs("IPv4");
}
else if (((itr->second)->type() == HypIP::Protocol::IPv6) &&
((itr->second)->origin() == HypIP::AddressOrigin::DHCP))
(((itr->second)->origin() == HypIP::AddressOrigin::DHCP) ||
((itr->second)->origin() == HypIP::AddressOrigin::SLAAC)))
{
method = "IPv6Static";
(itr->second)->origin(HypIP::AddressOrigin::Static);
(itr->second)->resetBaseBiosTableAttrs("IPv6");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/BIOSConfig/Manager/server.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/Network/EthernetInterface/server.hpp>
#include <xyz/openbmc_project/Network/IP/Create/server.hpp>

Expand Down
30 changes: 29 additions & 1 deletion src/ibm/hypervisor-network-mgr-src/hyp_ip_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ HypIP::AddressOrigin HypIPAddress::origin(HypIP::AddressOrigin origin)
convertAddressOriginToString(HypIP::AddressOrigin::DHCP);
std::string staticStr =
convertAddressOriginToString(HypIP::AddressOrigin::Static);
std::string slaacStr =
convertAddressOriginToString(HypIP::AddressOrigin::SLAAC);

if (originStr != dhcpStr && originStr != staticStr)
if (originStr != dhcpStr && originStr != staticStr && originStr != slaacStr)
{
log<level::ERR>("Not a valid origin");
elog<NotAllowed>(NotAllowedArgument::REASON("Invalid Origin"));
Expand Down Expand Up @@ -423,6 +425,19 @@ HypIP::AddressOrigin HypIPAddress::origin(HypIP::AddressOrigin origin)
originBiosAttr = "IPv6DHCP";
}
}
else if (originStr.substr(originStr.rfind(".") + 1) == "SLAAC")
{
if (HypIP::type() == HypIP::Protocol::IPv4)
{
log<level::ERR>("Not a valid origin for IPv4");
elog<NotAllowed>(
NotAllowedArgument::REASON("Invalid Origin for IPv4"));
}
else if (HypIP::type() == HypIP::Protocol::IPv6)
{
originBiosAttr = "IPv6SLAAC";
}
}

std::string currOriginValue;
if (addrOrigin == HypIP::AddressOrigin::Static)
Expand All @@ -447,6 +462,19 @@ HypIP::AddressOrigin HypIPAddress::origin(HypIP::AddressOrigin origin)
currOriginValue = "IPv6DHCP";
}
}
else if (addrOrigin == HypIP::AddressOrigin::SLAAC)
{
if (HypIP::type() == HypIP::Protocol::IPv4)
{
log<level::ERR>("Not a valid origin for IPv4");
elog<NotAllowed>(
NotAllowedArgument::REASON("Invalid Origin for IPv4"));
}
else if (HypIP::type() == HypIP::Protocol::IPv6)
{
currOriginValue = "IPv6SLAAC";
}
}

origin = HypIP::origin(origin);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[Unit]
Description=Hypervisor Network Manager
Wants=xyz.openbmc_project.biosconfig_manager.service
After=xyz.openbmc_project.biosconfig_manager.service
Wants=pldmd.service
After=pldmd.service

[Service]
ExecStart=/usr/bin/hyp-network-manager
Expand Down
1 change: 0 additions & 1 deletion test/test_ethernet_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ TEST_F(TestEthernetInterface, DHCPEnabled)
EXPECT_EQ(dhcp6, interface.dhcp6());
EXPECT_EQ(ra, interface.ipv6AcceptRA());
};
test(DHCPConf::both, /*dhcp4=*/true, /*dhcp6=*/true, /*ra=*/false);

auto set_test = [&](DHCPConf conf, bool dhcp4, bool dhcp6, bool ra) {
EXPECT_EQ(conf, interface.dhcpEnabled(conf));
Expand Down

0 comments on commit 8fa2a6d

Please sign in to comment.