diff options
author | Ravi Teja <raviteja28031990@gmail.com> | 2022-05-24 17:04:12 +0300 |
---|---|---|
committer | Ed Tanous <edtanous@google.com> | 2023-07-20 01:56:03 +0300 |
commit | b10d8db03f31b4aee15bdcb10d17975677f01625 (patch) | |
tree | 6041d6854cb5e244c44a78bc9da6360651ed391f | |
parent | 62598e31d0988d589506d5091bd38f72d61faf5e (diff) | |
download | bmcweb-b10d8db03f31b4aee15bdcb10d17975677f01625.tar.xz |
Add IPv6 StatelessAddressAutoConfiguration
This commit has following changes
1.Adds "StatelessAddressAutoConfig"
support as per latest EthernetInterface schema.
2.Remove support for deprecated Stateful and Stateless enums of DHCPv6
"OperatingMode"
Tested by:
```
GET PATCH -d '{"StatelessAddressAutoConfig": {"IPv6AutoConfigEnabled": true}}'
PATCH -d '{"StatelessAddressAutoConfig": { "IPv6AutoConfigEnabled": false}}'
PATCH -d '{"DHCPv6" : {"OperatingMode":"Enabled"}}' PATCH -d '{"DHCPv6"
: {"OperatingMode":"Disabled"}}'
```
Redfish Validator passed
Change-Id: I29d471750ef513074bc5e49c31a16fa15d3d760c
Signed-off-by: Ravi Teja <raviteja28031990@gmail.com>
-rw-r--r-- | Redfish.md | 1 | ||||
-rw-r--r-- | redfish-core/lib/ethernet.hpp | 73 |
2 files changed, 62 insertions, 12 deletions
diff --git a/Redfish.md b/Redfish.md index 3b5b7f8473..0772b8e44d 100644 --- a/Redfish.md +++ b/Redfish.md @@ -535,6 +535,7 @@ Fields common to all schemas - MACAddress - NameServers - SpeedMbps +- StatelessAddressAutoConfig - StaticNameServers - Status - VLAN/VLANEnable diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp index 218affef39..7783e7cfa4 100644 --- a/redfish-core/lib/ethernet.hpp +++ b/redfish-core/lib/ethernet.hpp @@ -86,6 +86,7 @@ struct EthernetInterfaceData bool hostNameEnabled; bool linkUp; bool nicEnabled; + bool ipv6AcceptRa; std::string dhcpEnabled; std::string operatingMode; std::string hostName; @@ -277,6 +278,15 @@ inline bool extractEthernetInterfaceData( ethData.nicEnabled = *nicEnabled; } } + else if (propertyPair.first == "IPv6AcceptRA") + { + const bool* ipv6AcceptRa = + std::get_if<bool>(&propertyPair.second); + if (ipv6AcceptRa != nullptr) + { + ethData.ipv6AcceptRa = *ipv6AcceptRa; + } + } else if (propertyPair.first == "Nameservers") { const std::vector<std::string>* nameservers = @@ -1091,6 +1101,27 @@ inline void setDHCPv4Config(const std::string& propertyName, const bool& value, }); } +inline void handleSLAACAutoConfigPatch( + const std::string& ifaceId, bool ipv6AutoConfigEnabled, + const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) +{ + sdbusplus::message::object_path path("/xyz/openbmc_project/network"); + path /= ifaceId; + sdbusplus::asio::setProperty( + *crow::connections::systemBus, "xyz.openbmc_project.Network", path, + "xyz.openbmc_project.Network.EthernetInterface", "IPv6AcceptRA", + ipv6AutoConfigEnabled, + [asyncResp](const boost::system::error_code& ec) { + if (ec) + { + BMCWEB_LOG_ERROR("D-Bus responses error: {}", ec); + messages::internalError(asyncResp->res); + return; + } + messages::success(asyncResp->res); + }); +} + inline void handleDHCPPatch(const std::string& ifaceId, const EthernetInterfaceData& ethData, const DHCPParameters& v4dhcpParms, @@ -1106,8 +1137,7 @@ inline void handleDHCPPatch(const std::string& ifaceId, bool nextv6DHCPState{}; if (v6dhcpParms.dhcpv6OperatingMode) { - if ((*v6dhcpParms.dhcpv6OperatingMode != "Stateful") && - (*v6dhcpParms.dhcpv6OperatingMode != "Stateless") && + if ((*v6dhcpParms.dhcpv6OperatingMode != "Enabled") && (*v6dhcpParms.dhcpv6OperatingMode != "Disabled")) { messages::propertyValueFormatError(asyncResp->res, @@ -1115,7 +1145,7 @@ inline void handleDHCPPatch(const std::string& ifaceId, "OperatingMode"); return; } - nextv6DHCPState = (*v6dhcpParms.dhcpv6OperatingMode == "Stateful"); + nextv6DHCPState = (*v6dhcpParms.dhcpv6OperatingMode == "Enabled"); } else { @@ -1590,11 +1620,13 @@ inline void jsonResponse["DHCPv4"]["UseDomainName"] = ethData.hostNameEnabled; jsonResponse["DHCPv6"]["OperatingMode"] = - translateDhcpEnabledToBool(ethData.dhcpEnabled, false) ? "Stateful" + translateDhcpEnabledToBool(ethData.dhcpEnabled, false) ? "Enabled" : "Disabled"; jsonResponse["DHCPv6"]["UseNTPServers"] = ethData.ntpEnabled; jsonResponse["DHCPv6"]["UseDNSServers"] = ethData.dnsEnabled; jsonResponse["DHCPv6"]["UseDomainName"] = ethData.hostNameEnabled; + jsonResponse["StatelessAddressAutoConfig"]["IPv6AutoConfigEnabled"] = + ethData.ipv6AcceptRa; if (!ethData.hostName.empty()) { @@ -1956,21 +1988,32 @@ inline void requestEthernetInterfacesRoutes(App& app) std::optional<std::vector<std::string>> staticNameServers; std::optional<nlohmann::json> dhcpv4; std::optional<nlohmann::json> dhcpv6; + std::optional<bool> ipv6AutoConfigEnabled; std::optional<bool> interfaceEnabled; std::optional<size_t> mtuSize; DHCPParameters v4dhcpParms; DHCPParameters v6dhcpParms; - + // clang-format off if (!json_util::readJsonPatch( - req, asyncResp->res, "HostName", hostname, "FQDN", fqdn, - "IPv4StaticAddresses", ipv4StaticAddresses, "MACAddress", - macAddress, "StaticNameServers", staticNameServers, - "IPv6DefaultGateway", ipv6DefaultGateway, "IPv6StaticAddresses", - ipv6StaticAddresses, "DHCPv4", dhcpv4, "DHCPv6", dhcpv6, - "MTUSize", mtuSize, "InterfaceEnabled", interfaceEnabled)) + req, asyncResp->res, + "DHCPv4", dhcpv4, + "DHCPv6", dhcpv6, + "FQDN", fqdn, + "HostName", hostname, + "IPv4StaticAddresses", ipv4StaticAddresses, + "IPv6DefaultGateway", ipv6DefaultGateway, + "IPv6StaticAddresses", ipv6StaticAddresses, + "InterfaceEnabled", interfaceEnabled, + "MACAddress", macAddress, + "MTUSize", mtuSize, + "StatelessAddressAutoConfig/IPv6AutoConfigEnabled", ipv6AutoConfigEnabled, + "StaticNameServers", staticNameServers + ) + ) { return; } + //clang-format on if (dhcpv4) { if (!json_util::readJson(*dhcpv4, asyncResp->res, "DHCPEnabled", @@ -2007,7 +2050,7 @@ inline void requestEthernetInterfacesRoutes(App& app) ipv6StaticAddresses = std::move(ipv6StaticAddresses), staticNameServers = std::move(staticNameServers), dhcpv4 = std::move(dhcpv4), dhcpv6 = std::move(dhcpv6), mtuSize, - v4dhcpParms = std::move(v4dhcpParms), + ipv6AutoConfigEnabled, v4dhcpParms = std::move(v4dhcpParms), v6dhcpParms = std::move(v6dhcpParms), interfaceEnabled]( const bool& success, const EthernetInterfaceData& ethData, const std::vector<IPv4AddressData>& ipv4Data, @@ -2033,6 +2076,12 @@ inline void requestEthernetInterfacesRoutes(App& app) handleHostnamePatch(*hostname, asyncResp); } + if (ipv6AutoConfigEnabled) + { + handleSLAACAutoConfigPatch(ifaceId, *ipv6AutoConfigEnabled, + asyncResp); + } + if (fqdn) { handleFqdnPatch(ifaceId, *fqdn, asyncResp); |