From: Razvan Becheriu Date: Mon, 11 May 2026 14:12:46 +0000 (+0300) Subject: [#3144] addressed review comments X-Git-Tag: Kea-3.1.9~57 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=97ef75cce274b641277f52c987bbca83005bb876;p=thirdparty%2Fkea.git [#3144] addressed review comments --- diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 2f4678702a..59131d78e2 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -680,17 +680,20 @@ ConstElementPtr ControlledDhcpv4Srv::commandInterfaceListHandler(const std::string&, ConstElementPtr) { ElementPtr ifaces = Element::createMap(); + bool error = false; std::string message; try { ifaces->set("interfaces", IfaceMgr::instance().ifacesToElement()); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { + error = true; message = ex.what(); } catch (...) { + error = true; message = "unknown error"; } ostringstream msg; - if (message.empty()) { + if (!error) { msg << IfaceMgr::instance().getIfaces().size() << " interfaces detected."; return (isc::config::createAnswer(CONTROL_RESULT_SUCCESS, msg.str(), ifaces)); @@ -703,17 +706,20 @@ ControlledDhcpv4Srv::commandInterfaceListHandler(const std::string&, ConstElementPtr ControlledDhcpv4Srv::commandInterfaceRedetectHandler(const std::string&, ConstElementPtr args) { + bool error = false; std::string message; try { IfaceMgr::instance().detectIfaces(true); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { + error = true; message = ex.what(); } catch (...) { + error = true; message = "unknown error"; } ostringstream msg; - if (message.empty()) { + if (!error) { return (ControlledDhcpv4Srv::commandInterfaceListHandler("", args)); } else { msg << "Unexpected error while retrieving the list of detected interfaces: " << message; @@ -724,6 +730,7 @@ ControlledDhcpv4Srv::commandInterfaceRedetectHandler(const std::string&, ConstElementPtr ControlledDhcpv4Srv::commandInterfaceUseHandler(const std::string&, ConstElementPtr args) { + bool error = false; string message; ConstElementPtr ifaces_config; if (!args) { @@ -750,23 +757,24 @@ ControlledDhcpv4Srv::commandInterfaceUseHandler(const std::string&, return (isc::config::createAnswer(CONTROL_RESULT_ERROR, message)); } try { - ElementPtr mutable_cfg = boost::const_pointer_cast(args); - mutable_cfg->set("re-detect", Element::create(false)); + CfgIfacePtr running_cfg_iface = CfgMgr::instance().getCurrentCfg()->getCfgIface(); + ElementPtr mutable_running_cfg = running_cfg_iface->toElement(); + merge(mutable_running_cfg, args); IfacesConfigParser parser(AF_INET, true); CfgIfacePtr cfg_iface(new CfgIface()); - parser.parse(cfg_iface, args); - CfgIfacePtr running_cfg_iface = CfgMgr::instance().getCurrentCfg()->getCfgIface(); - if (running_cfg_iface->merge(*cfg_iface, AF_INET)) { - running_cfg_iface->triggerOpenSocketsWithRetry(AF_INET, getServerPort(), useBroadcast()); - } - } catch (std::exception& ex) { + parser.parseInterfacesList(cfg_iface, mutable_running_cfg->get("interfaces")); + CfgMgr::instance().getCurrentCfg()->getCfgIface()->update(*cfg_iface); + running_cfg_iface->triggerOpenSocketsWithRetry(AF_INET, getServerPort(), useBroadcast()); + } catch (const std::exception& ex) { + error = true; message = ex.what(); } catch (...) { + error = true; message = "unknown error"; } ostringstream msg; - if (message.empty()) { + if (!error) { return (isc::config::createAnswer(CONTROL_RESULT_SUCCESS, "Configuration successful.")); } else { msg << "Unexpected error while updating used interfaces: " << message; diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index f4ee1317a6..7d2abbfbed 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -2447,6 +2448,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, interfaceList) { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createUnixChannelServer(); + PktFilterPtr filter(new PktFilterTestStub()); + IfaceMgr::instance().setPacketFilter(filter); SKIP_IF(skipped_); std::string response; @@ -2490,6 +2493,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, interfaceRedetect) { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createUnixChannelServer(); + PktFilterPtr filter(new PktFilterTestStub()); + IfaceMgr::instance().setPacketFilter(filter); SKIP_IF(skipped_); std::string response; @@ -2569,6 +2574,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, interfaceUse) { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createUnixChannelServer(); + PktFilterPtr filter(new PktFilterTestStub()); + IfaceMgr::instance().setPacketFilter(filter); SKIP_IF(skipped_); std::string response; diff --git a/src/bin/dhcp4/tests/http_control_socket_unittest.cc b/src/bin/dhcp4/tests/http_control_socket_unittest.cc index 186c9789b6..c01a478e83 100644 --- a/src/bin/dhcp4/tests/http_control_socket_unittest.cc +++ b/src/bin/dhcp4/tests/http_control_socket_unittest.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -3657,6 +3658,8 @@ BaseCtrlChannelDhcpv4Test::testInterfaceList() { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createHttpChannelServer(); + PktFilterPtr filter(new PktFilterTestStub()); + IfaceMgr::instance().setPacketFilter(filter); std::string response; std::string command = "{ \"command\": \"interface-list\" }"; @@ -3708,6 +3711,8 @@ BaseCtrlChannelDhcpv4Test::testInterfaceRedetect() { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createHttpChannelServer(); + PktFilterPtr filter(new PktFilterTestStub()); + IfaceMgr::instance().setPacketFilter(filter); std::string response; IfacePtr eth1 = IfaceMgrTestConfig::createIface("eth1", ETH1_INDEX, @@ -3795,6 +3800,8 @@ BaseCtrlChannelDhcpv4Test::testInterfaceUse() { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createHttpChannelServer(); + PktFilterPtr filter(new PktFilterTestStub()); + IfaceMgr::instance().setPacketFilter(filter); std::string response; std::string command = "{ \"command\": \"interface-use\", \"arguments\": { \"interfaces\": [ \"eth0\" ] } }"; diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index d373392e58..830f0c9144 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -683,17 +683,20 @@ ConstElementPtr ControlledDhcpv6Srv::commandInterfaceListHandler(const std::string&, ConstElementPtr) { ElementPtr ifaces = Element::createMap(); + bool error = false; std::string message; try { ifaces->set("interfaces", IfaceMgr::instance().ifacesToElement()); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { + error = true; message = ex.what(); } catch (...) { + error = true; message = "unknown error"; } ostringstream msg; - if (message.empty()) { + if (!error) { msg << IfaceMgr::instance().getIfaces().size() << " interfaces detected."; return (isc::config::createAnswer(CONTROL_RESULT_SUCCESS, msg.str(), ifaces)); @@ -706,17 +709,20 @@ ControlledDhcpv6Srv::commandInterfaceListHandler(const std::string&, ConstElementPtr ControlledDhcpv6Srv::commandInterfaceRedetectHandler(const std::string&, ConstElementPtr args) { + bool error = false; std::string message; try { IfaceMgr::instance().detectIfaces(true); - } catch (std::exception& ex) { + } catch (const std::exception& ex) { + error = true; message = ex.what(); } catch (...) { + error = true; message = "unknown error"; } ostringstream msg; - if (message.empty()) { + if (!error) { return (ControlledDhcpv6Srv::commandInterfaceListHandler("", args)); } else { msg << "Unexpected error while retrieving the list of detected interfaces: " << message; @@ -727,6 +733,7 @@ ControlledDhcpv6Srv::commandInterfaceRedetectHandler(const std::string&, ConstElementPtr ControlledDhcpv6Srv::commandInterfaceUseHandler(const std::string&, ConstElementPtr args) { + bool error = false; string message; ConstElementPtr ifaces_config; if (!args) { @@ -753,23 +760,24 @@ ControlledDhcpv6Srv::commandInterfaceUseHandler(const std::string&, return (isc::config::createAnswer(CONTROL_RESULT_ERROR, message)); } try { - ElementPtr mutable_cfg = boost::const_pointer_cast(args); - mutable_cfg->set("re-detect", Element::create(false)); + CfgIfacePtr running_cfg_iface = CfgMgr::instance().getCurrentCfg()->getCfgIface(); + ElementPtr mutable_running_cfg = running_cfg_iface->toElement(); + merge(mutable_running_cfg, args); IfacesConfigParser parser(AF_INET6, true); CfgIfacePtr cfg_iface(new CfgIface()); - parser.parse(cfg_iface, args); - CfgIfacePtr running_cfg_iface = CfgMgr::instance().getCurrentCfg()->getCfgIface(); - if (running_cfg_iface->merge(*cfg_iface, AF_INET6)) { - running_cfg_iface->triggerOpenSocketsWithRetry(AF_INET6, getServerPort()); - } - } catch (std::exception& ex) { + parser.parseInterfacesList(cfg_iface, mutable_running_cfg->get("interfaces")); + CfgMgr::instance().getCurrentCfg()->getCfgIface()->update(*cfg_iface); + running_cfg_iface->triggerOpenSocketsWithRetry(AF_INET6, getServerPort()); + } catch (const std::exception& ex) { + error = true; message = ex.what(); } catch (...) { + error = true; message = "unknown error"; } ostringstream msg; - if (message.empty()) { + if (!error) { return (isc::config::createAnswer(CONTROL_RESULT_SUCCESS, "Configuration successful.")); } else { msg << "Unexpected error while updating used interfaces: " << message; diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index 662a8947f0..2a6995c713 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -2441,6 +2442,8 @@ TEST_F(CtrlChannelDhcpv6SrvTest, interfaceList) { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createUnixChannelServer(); + PktFilter6Ptr filter(new PktFilter6TestStub()); + IfaceMgr::instance().setPacketFilter(filter); SKIP_IF(skipped_); std::string response; @@ -2484,6 +2487,8 @@ TEST_F(CtrlChannelDhcpv6SrvTest, interfaceRedetect) { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createUnixChannelServer(); + PktFilter6Ptr filter(new PktFilter6TestStub()); + IfaceMgr::instance().setPacketFilter(filter); SKIP_IF(skipped_); std::string response; @@ -2563,6 +2568,8 @@ TEST_F(CtrlChannelDhcpv6SrvTest, interfaceUse) { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createUnixChannelServer(); + PktFilter6Ptr filter(new PktFilter6TestStub()); + IfaceMgr::instance().setPacketFilter(filter); SKIP_IF(skipped_); std::string response; diff --git a/src/bin/dhcp6/tests/http_control_socket_unittest.cc b/src/bin/dhcp6/tests/http_control_socket_unittest.cc index 6b54f16109..5d66fa0f2d 100644 --- a/src/bin/dhcp6/tests/http_control_socket_unittest.cc +++ b/src/bin/dhcp6/tests/http_control_socket_unittest.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -3649,6 +3650,8 @@ BaseCtrlChannelDhcpv6Test::testInterfaceList() { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createHttpChannelServer(); + PktFilter6Ptr filter(new PktFilter6TestStub()); + IfaceMgr::instance().setPacketFilter(filter); std::string response; std::string command = "{ \"command\": \"interface-list\" }"; @@ -3700,6 +3703,8 @@ BaseCtrlChannelDhcpv6Test::testInterfaceRedetect() { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createHttpChannelServer(); + PktFilter6Ptr filter(new PktFilter6TestStub()); + IfaceMgr::instance().setPacketFilter(filter); std::string response; IfacePtr eth1 = IfaceMgrTestConfig::createIface("eth1", ETH1_INDEX, @@ -3787,6 +3792,8 @@ BaseCtrlChannelDhcpv6Test::testInterfaceUse() { IfaceMgr::instance().closeSockets(); IfaceMgr::instance().detectIfaces(); createHttpChannelServer(); + PktFilter6Ptr filter(new PktFilter6TestStub()); + IfaceMgr::instance().setPacketFilter(filter); std::string response; std::string command = "{ \"command\": \"interface-use\", \"arguments\": { \"interfaces\": [ \"eth0\" ] } }"; diff --git a/src/lib/dhcpsrv/cfg_iface.cc b/src/lib/dhcpsrv/cfg_iface.cc index 4bdad61615..c07ef0c4ff 100644 --- a/src/lib/dhcpsrv/cfg_iface.cc +++ b/src/lib/dhcpsrv/cfg_iface.cc @@ -544,72 +544,11 @@ CfgIface::use(const uint16_t family, const std::string& iface_name) { << "' has already been specified"); } - // Log that we're listening on the specific interface and that the - // address is not explicitly specified. LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_ADD_IFACE).arg(name); iface_set_.insert(name); } } -bool -CfgIface::merge(const CfgIface& other, const uint16_t family) { - bool updated = false; - if (other.wildcard_used_) { - wildcard_used_ = true; - updated = true; - } else { - // Use a copy of the containers so that no change is applied until everything is checked. - auto address_map = address_map_; - auto iface_set = iface_set_; - for (auto const& addr_key : other.address_map_) { - // For the IPv4, if the interface name was specified (instead of the interface- - // address tuple) all addresses are already activated. Adding an explicit address - // for the interface should result in error. - if ((family == AF_INET) && (iface_set.find(addr_key.first) != iface_set.end())) { - isc_throw(DuplicateIfaceName, "interface '" << addr_key.first - << "' has already been selected"); - } - // Check if the address hasn't been selected already. - std::pair iface_address_tuple(addr_key.first, addr_key.second); - if (std::find(address_map.begin(), address_map.end(), - iface_address_tuple) != address_map.end()) { - isc_throw(DuplicateAddress, "must not select address '" - << addr_key.second << "' for interface '" << addr_key.first << "' " - "because this address is already selected"); - } - address_map.insert(addr_key); - } - for (auto const& name : other.iface_set_) { - if ((name != ALL_IFACES_KEYWORD)) { - // An interface has been selected or an IPv4 address on this interface - // has been selected it is not allowed to select the whole interface. - if ((iface_set.find(name) != iface_set.end()) || - ((family == AF_INET) && address_map.count(name) > 0)) { - isc_throw(DuplicateIfaceName, "interface '" << name - << "' has already been specified"); - } - iface_set.insert(name); - } - } - // Ready to apply the changes. - for (auto const& addr_key : other.address_map_) { - address_map_.insert(addr_key); - updated = true; - } - for (auto const& name : other.iface_set_) { - if ((name != ALL_IFACES_KEYWORD)) { - // Log that we're listening on the specific interface and that the - // address is not explicitly specified. - LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_ADD_IFACE_ON_MERGE).arg(name); - iface_set_.insert(name); - updated = true; - } - } - } - - return (updated); -} - void CfgIface::useSocketType(const uint16_t family, const SocketType& socket_type) { @@ -676,5 +615,12 @@ CfgIface::toElement() const { return (result); } +void +CfgIface::update(CfgIface& other) { + iface_set_ = other.iface_set_; + address_map_ = other.address_map_; + wildcard_used_ = other.wildcard_used_; +} + } // end of isc::dhcp namespace } // end of isc namespace diff --git a/src/lib/dhcpsrv/cfg_iface.h b/src/lib/dhcpsrv/cfg_iface.h index c94aa1e38d..0b342c1aeb 100644 --- a/src/lib/dhcpsrv/cfg_iface.h +++ b/src/lib/dhcpsrv/cfg_iface.h @@ -207,13 +207,13 @@ public: /// @c CfgIface::use has been already called for this interface. void use(const uint16_t family, const std::string& iface_name); - /// @brief Merge the interface list and address list. + /// @brief Update runtime mutable members. /// - /// @param other The object from which the lists are updated. - /// @param family Address family (AF_INET or AF_INET6). + /// @note Currently supported members are @ref iface_set_, + /// @ref address_map_ and @ref wildcard_used_. /// - /// @return true if any change has been done, false otherwise. - bool merge(const CfgIface& other, const uint16_t family); + /// @param other The other object to update members from. + void update(CfgIface& other); /// @brief Sets the specified socket type to be used by the server. /// diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.cc b/src/lib/dhcpsrv/dhcpsrv_messages.cc index d29e526c7f..30fc1bf0b1 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.cc +++ b/src/lib/dhcpsrv/dhcpsrv_messages.cc @@ -8,7 +8,6 @@ namespace isc { namespace dhcp { extern const isc::log::MessageID DHCPSRV_CFGMGR_ADD_IFACE = "DHCPSRV_CFGMGR_ADD_IFACE"; -extern const isc::log::MessageID DHCPSRV_CFGMGR_ADD_IFACE_ON_MERGE = "DHCPSRV_CFGMGR_ADD_IFACE_ON_MERGE"; extern const isc::log::MessageID DHCPSRV_CFGMGR_ADD_SUBNET4 = "DHCPSRV_CFGMGR_ADD_SUBNET4"; extern const isc::log::MessageID DHCPSRV_CFGMGR_ADD_SUBNET6 = "DHCPSRV_CFGMGR_ADD_SUBNET6"; extern const isc::log::MessageID DHCPSRV_CFGMGR_ALL_IFACES_ACTIVE = "DHCPSRV_CFGMGR_ALL_IFACES_ACTIVE"; @@ -192,7 +191,6 @@ namespace { const char* values[] = { "DHCPSRV_CFGMGR_ADD_IFACE", "listening on interface %1", - "DHCPSRV_CFGMGR_ADD_IFACE_ON_MERGE", "listening on interface %1", "DHCPSRV_CFGMGR_ADD_SUBNET4", "adding subnet %1", "DHCPSRV_CFGMGR_ADD_SUBNET6", "adding subnet %1", "DHCPSRV_CFGMGR_ALL_IFACES_ACTIVE", "enabling listening on all interfaces", diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.h b/src/lib/dhcpsrv/dhcpsrv_messages.h index 05d6b102df..1e88bdaa10 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.h +++ b/src/lib/dhcpsrv/dhcpsrv_messages.h @@ -9,7 +9,6 @@ namespace isc { namespace dhcp { extern const isc::log::MessageID DHCPSRV_CFGMGR_ADD_IFACE; -extern const isc::log::MessageID DHCPSRV_CFGMGR_ADD_IFACE_ON_MERGE; extern const isc::log::MessageID DHCPSRV_CFGMGR_ADD_SUBNET4; extern const isc::log::MessageID DHCPSRV_CFGMGR_ADD_SUBNET6; extern const isc::log::MessageID DHCPSRV_CFGMGR_ALL_IFACES_ACTIVE; diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes index 0c4f0be105..b653f27aa8 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@ -10,10 +10,6 @@ $NAMESPACE isc::dhcp An info message issued when a new interface is being added to the collection of interfaces on which the server listens to DHCP messages. -% DHCPSRV_CFGMGR_ADD_IFACE_ON_MERGE listening on interface %1 -An info message issued when a new interface is being added to the collection of -interfaces on which the server listens to DHCP messages. - % DHCPSRV_CFGMGR_ADD_SUBNET4 adding subnet %1 Logged at debug log level 40. A debug message reported when the DHCP configuration manager is adding the diff --git a/src/lib/dhcpsrv/parsers/ifaces_config_parser.h b/src/lib/dhcpsrv/parsers/ifaces_config_parser.h index 9eb25cb0fa..bb044fc545 100644 --- a/src/lib/dhcpsrv/parsers/ifaces_config_parser.h +++ b/src/lib/dhcpsrv/parsers/ifaces_config_parser.h @@ -44,7 +44,6 @@ public: /// are invalid. void parse(const CfgIfacePtr& config, const isc::data::ConstElementPtr& values); -private: /// @brief parses interfaces-list structure /// /// This method goes through all the interfaces-specified in @@ -57,6 +56,8 @@ private: void parseInterfacesList(const CfgIfacePtr& cfg_iface, isc::data::ConstElementPtr ifaces_list); +private: + /// @brief AF_INET for DHCPv4 and AF_INET6 for DHCPv6. int protocol_; diff --git a/src/lib/dhcpsrv/tests/cfg_iface_unittest.cc b/src/lib/dhcpsrv/tests/cfg_iface_unittest.cc index 8fc0d70c7c..c935664165 100644 --- a/src/lib/dhcpsrv/tests/cfg_iface_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_iface_unittest.cc @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -1738,44 +1737,6 @@ TEST_F(CfgIfaceTest, retryDoubleOpenServiceSockets6) { EXPECT_EQ(second_port_calls, 2); } -// Test that merge CfgIface works properly. -TEST_F(CfgIfaceTest, mergeV4CfgIface) { - CfgIfacePtr left(new CfgIface()); - CfgIfacePtr right(new CfgIface()); - std::string left_txt("{ \"interfaces\": [\"eth0\", \"eth1/192.0.2.3\"], \"re-detect\": false }"); - std::string right_txt("{ \"interfaces\": [\"eth0/10.0.0.1\", \"eth1961\"], \"re-detect\": false }"); - ConstElementPtr left_cfg = Element::fromJSON(left_txt); - ConstElementPtr right_cfg = Element::fromJSON(right_txt); - IfacesConfigParser parser(AF_INET, true); - EXPECT_NO_THROW(parser.parse(left, left_cfg)); - auto lift_before = left->toElement()->str(); - EXPECT_NO_THROW(parser.parse(right, right_cfg)); - auto right_before = right->toElement()->str(); - EXPECT_THROW(left->merge(*right, AF_INET), DuplicateIfaceName); - EXPECT_EQ(lift_before, left->toElement()->str()); - EXPECT_THROW(right->merge(*left, AF_INET), DuplicateIfaceName); - EXPECT_EQ(right_before, right->toElement()->str()); -} - -// Test that merge CfgIface works properly. -TEST_F(CfgIfaceTest, mergeV6CfgIface) { - CfgIfacePtr left(new CfgIface()); - CfgIfacePtr right(new CfgIface()); - std::string left_txt("{ \"interfaces\": [\"eth0/2001:db8:1::1\", \"eth1\"], \"re-detect\": false }"); - std::string right_txt("{ \"interfaces\": [\"eth0/2001:db8:1::1\", \"eth1961\"], \"re-detect\": false }"); - ConstElementPtr left_cfg = Element::fromJSON(left_txt); - ConstElementPtr right_cfg = Element::fromJSON(right_txt); - IfacesConfigParser parser(AF_INET6, true); - EXPECT_NO_THROW(parser.parse(left, left_cfg)); - auto lift_before = left->toElement()->str(); - EXPECT_NO_THROW(parser.parse(right, right_cfg)); - auto right_before = right->toElement()->str(); - EXPECT_THROW(left->merge(*right, AF_INET6), DuplicateAddress); - EXPECT_EQ(lift_before, left->toElement()->str()); - EXPECT_THROW(right->merge(*left, AF_INET6), DuplicateAddress); - EXPECT_EQ(right_before, right->toElement()->str()); -} - // This test verifies that it is possible to specify the socket // type to be used by the DHCPv4 server. // This test is enabled on LINUX and BSD only, because the diff --git a/src/share/api/interface-list.json b/src/share/api/interface-list.json index 7f9ebfda5e..7f2abdf791 100644 --- a/src/share/api/interface-list.json +++ b/src/share/api/interface-list.json @@ -1,6 +1,6 @@ { "access": "read", - "avail": "3.1.8", + "avail": "3.1.9", "brief": [ "This command retrieves the list of detected interfaces.", "This command does not take any parameters." diff --git a/src/share/api/interface-redetect.json b/src/share/api/interface-redetect.json index 5f9e71cdfa..d08a0c744f 100644 --- a/src/share/api/interface-redetect.json +++ b/src/share/api/interface-redetect.json @@ -1,6 +1,6 @@ { "access": "write", - "avail": "3.1.8", + "avail": "3.1.9", "brief": [ "This command retrieves the list of detected interfaces after performing", "a re-detect procedure.", diff --git a/src/share/api/interface-use.json b/src/share/api/interface-use.json index 163d5a70e9..126f5932ee 100644 --- a/src/share/api/interface-use.json +++ b/src/share/api/interface-use.json @@ -1,6 +1,6 @@ { "access": "write", - "avail": "3.1.8", + "avail": "3.1.9", "brief": [ "This command updates the list of interfaces used to process DHCP traffic.", "This command takes as parameter the list of interfaces with respective",