Correct the IPv6 Router Address Configuration command
The IPv6 Router Address Configuration Get/Set LAN command was not
reporting or modifying the correct portion of the networking
system. This command is intended to configure the Routing
Advertisement feature of IPv6. It is not a direct reflection of the
DHCP state.
Systemd-networkd manages the Routing Advertisement via the
IPv6AcceptRA parameter, which according to the networkd documentaion,
enables/disables IPv6 DHCP functionality.
Tested:
Issued "ipmitool raw 12 2 3 64 0 0" and was able to read the current
state of the IPv6AcceptRA variable.
Issued "ipmitool raw 12 1 3 64 2" and saw the configuration file for
the channel change, and the addition of a new IPv6 address to the
network device.
Issued "ipmitool raw 12 1 3 64 0" and saw that configuration file for
the channel change, and the removal of the IPv6 address from the
network device.
Change-Id: Id01441f88ccc9d56449ab8115f4855de74e80cfc
Signed-off-by: Johnathan Mantey <johnathanx.mantey@intel.com>
diff --git a/transporthandler.cpp b/transporthandler.cpp
index cacf2ec..00202c5 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -732,6 +732,35 @@
return setStatus[channel] = SetStatus::Complete;
}
+/** @brief Gets the IPv6 Router Advertisement value
+ *
+ * @param[in] bus - The bus object used for lookups
+ * @param[in] params - The parameters for the channel
+ * @return networkd IPV6AcceptRA value
+ */
+static bool getIPv6AcceptRA(sdbusplus::bus::bus& bus,
+ const ChannelParams& params)
+{
+ auto raEnabled =
+ std::get<bool>(getDbusProperty(bus, params.service, params.logicalPath,
+ INTF_ETHERNET, "IPv6AcceptRA"));
+ return raEnabled;
+}
+
+/** @brief Sets the IPv6AcceptRA flag
+ *
+ * @param[in] bus - The bus object used for lookups
+ * @param[in] params - The parameters for the channel
+ * @param[in] ipv6AcceptRA - boolean to enable/disable IPv6 Routing
+ * Advertisement
+ */
+void setIPv6AcceptRA(sdbusplus::bus::bus& bus, const ChannelParams& params,
+ const bool ipv6AcceptRA)
+{
+ setDbusProperty(bus, params.service, params.logicalPath, INTF_ETHERNET,
+ "IPv6AcceptRA", ipv6AcceptRA);
+}
+
/**
* Define placeholder command handlers for the OEM Extension bytes for the Set
* LAN Configuration Parameters and Get LAN Configuration Parameters
@@ -1097,26 +1126,20 @@
case LanParam::IPv6RouterControl:
{
std::bitset<8> control;
+ constexpr uint8_t reservedRACCBits = 0xfc;
if (req.unpack(control) != 0 || !req.fullyUnpacked())
{
return responseReqDataLenInvalid();
}
- std::bitset<8> expected;
- EthernetInterface::DHCPConf dhcp =
- channelCall<getDHCPProperty>(channel);
- if ((dhcp == EthernetInterface::DHCPConf::both) |
- (dhcp == EthernetInterface::DHCPConf::v6))
+ if (std::bitset<8> expected(control &
+ std::bitset<8>(reservedRACCBits));
+ expected.any())
{
- expected[IPv6RouterControlFlag::Dynamic] = 1;
+ return response(ccParamNotSupported);
}
- else
- {
- expected[IPv6RouterControlFlag::Static] = 1;
- }
- if (expected != control)
- {
- return responseInvalidFieldRequest();
- }
+
+ bool enableRA = control[IPv6RouterControlFlag::Dynamic];
+ channelCall<setIPv6AcceptRA>(channel, enableRA);
return responseSuccess();
}
case LanParam::IPv6StaticRouter1IP:
@@ -1420,17 +1443,9 @@
case LanParam::IPv6RouterControl:
{
std::bitset<8> control;
- EthernetInterface::DHCPConf dhcp =
- channelCall<getDHCPProperty>(channel);
- if ((dhcp == EthernetInterface::DHCPConf::both) ||
- (dhcp == EthernetInterface::DHCPConf::v6))
- {
- control[IPv6RouterControlFlag::Dynamic] = 1;
- }
- else
- {
- control[IPv6RouterControlFlag::Static] = 1;
- }
+ control[IPv6RouterControlFlag::Dynamic] =
+ channelCall<getIPv6AcceptRA>(channel);
+ control[IPv6RouterControlFlag::Static] = 1;
ret.pack(control);
return responseSuccess(std::move(ret));
}