From: Francis Dupont Date: Mon, 19 Nov 2018 15:55:03 +0000 (+0100) Subject: [65-libyang-simplify-update-models] Implemented authoritative X-Git-Tag: 75-radius-documentation-needs-an-update_base~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a56b32bbc55ff13930aa22d605c6389bd84269b7;p=thirdparty%2Fkea.git [65-libyang-simplify-update-models] Implemented authoritative --- diff --git a/src/lib/yang/adaptor_config.cc b/src/lib/yang/adaptor_config.cc index cca5b7c8be..adca8e27b0 100644 --- a/src/lib/yang/adaptor_config.cc +++ b/src/lib/yang/adaptor_config.cc @@ -522,52 +522,6 @@ AdaptorConfig::sanitizeRelaySuppliedOptions(ConstElementPtr dhcp) { mutable_dhcp->remove("relay-supplied-options"); } -void -AdaptorConfig::removeAuthoritativeSubnets(ConstElementPtr subnets) { - if (!subnets || subnets->empty()) { - // nothing to do here. - return; - } - - for (size_t i = 0; i < subnets->size(); ++i) { - ElementPtr subnet = subnets->getNonConst(i); - ConstElementPtr auth = subnet->get("authoritative"); - if (auth) { - subnet->remove("authoritative"); - } - } -} - -void -AdaptorConfig::removeAuthoritativeSharedNetworks(ConstElementPtr networks) { - if (!networks || networks->empty()) { - // nothing to do here. - return; - } - - for (size_t i = 0; i < networks->size(); ++i) { - ElementPtr network = networks->getNonConst(i); - ConstElementPtr auth = network->get("authoritative"); - if (auth) { - network->remove("authoritative"); - } - removeAuthoritativeSubnets(network->get("subnet4")); - } -} - -void -AdaptorConfig::removeAuthoritative(ConstElementPtr dhcp) { - removeAuthoritativeSubnets(dhcp->get("subnet4")); - removeAuthoritativeSharedNetworks(dhcp->get("shared-networks")); - ConstElementPtr auth = dhcp->get("authoritative"); - if (!auth) { - // Done. - return; - } - ElementPtr mutable_dhcp = boost::const_pointer_cast(dhcp); - mutable_dhcp->remove("authoritative"); -} - void AdaptorConfig::preProcess(ElementPtr dhcp, const string& subsel, const string& space) { @@ -654,9 +608,7 @@ AdaptorConfig::preProcess(ElementPtr dhcp, const string& subsel, sanitizeDatabase(dhcp); - if (space == DHCP4_SPACE) { - removeAuthoritative(dhcp); - } else if (space == DHCP6_SPACE) { + if (space == DHCP6_SPACE) { sanitizeRelaySuppliedOptions(dhcp); } } diff --git a/src/lib/yang/adaptor_config.h b/src/lib/yang/adaptor_config.h index 85f5cff635..22c23f15ad 100644 --- a/src/lib/yang/adaptor_config.h +++ b/src/lib/yang/adaptor_config.h @@ -275,26 +275,6 @@ protected: /// @param dhcp The DHCPv6 server. static void sanitizeRelaySuppliedOptions(isc::data::ConstElementPtr dhcp); - /// @brief Remove authoritative flag from a subnet list. - /// - /// @param subnets The subnet list. - static void removeAuthoritativeSubnets(isc::data::ConstElementPtr subnets); - - /// @brief Remove authoritative flag from a shared network list. - /// - /// Remove authoritative flag in each shared network and its - /// subnet4 children. - /// - /// @param networks The shared network list. - static void removeAuthoritativeSharedNetworks(isc::data::ConstElementPtr networks); - - /// @brief Remove authoritative flags. - /// - /// Remove global, shared network and subnet4 authoritative flags. - /// - /// @param dhcp The DHCPv4 server. - static void removeAuthoritative(isc::data::ConstElementPtr dhcp); - /// @brief Pre process a configuration. /// /// Assign subnet IDs, check and set default in options, etc. diff --git a/src/lib/yang/models/kea-dhcp4-server.yang b/src/lib/yang/models/kea-dhcp4-server.yang index e997dfbede..3ae0a6f743 100644 --- a/src/lib/yang/models/kea-dhcp4-server.yang +++ b/src/lib/yang/models/kea-dhcp4-server.yang @@ -8,12 +8,15 @@ module kea-dhcp4-server { } import kea-types { prefix kea; + revision-date 2018-09-14; } import kea-dhcp-types { prefix dhcp; + revision-date 2018-09-14; } import kea-logging { prefix logging; + revision-date 2018-09-14; } organization "Internet Systems Consortium"; @@ -21,7 +24,7 @@ module kea-dhcp4-server { description "This model defines a YANG data model that can be used to configure and manage a Kea DHCPv4 server."; - revision 2018-09-14 { + revision 2018-11-11 { description "Initial revision"; reference ""; } @@ -88,6 +91,15 @@ module kea-dhcp4-server { } } + grouping authoritative { + description "Authoritative grouping."; + leaf authoritative { + type boolean; + description "NAK requests for unknown clients. If set to false + ignore them."; + } + } + grouping relay { description "Relay grouping."; leaf-list ip-addresses { @@ -201,6 +213,7 @@ module kea-dhcp4-server { type inet:ipv6-prefix; description "Subnet DHCPv4-over-DHCPv6 IPv6 prefix."; } + uses authoritative; uses dhcp:subnet-user-context; } } @@ -312,6 +325,7 @@ module kea-dhcp4-server { description "Optional information about relay agent."; uses relay; } + uses authoritative; uses dhcp:network-reservation-mode; uses dhcp:network-client-class; uses dhcp:network-require-client-classes; @@ -405,6 +419,7 @@ module kea-dhcp4-server { description "Global host reservations."; } } + uses authoritative; } container logging { diff --git a/src/lib/yang/translator_config.cc b/src/lib/yang/translator_config.cc index 1f5c2207ef..a2798e377d 100644 --- a/src/lib/yang/translator_config.cc +++ b/src/lib/yang/translator_config.cc @@ -299,6 +299,7 @@ TranslatorConfig::getServerKeaDhcp4() { getParam(result, xpath, "next-server"); getParam(result, xpath, "server-hostname"); getParam(result, xpath, "boot-file-name"); + getParam(result, xpath, "authoritative"); return (result); } @@ -725,6 +726,10 @@ TranslatorConfig::setServerKeaDhcp4(ConstElementPtr elem) { if (boot) { setItem(xpath + "/boot-file-name", boot, SR_STRING_T); } + ConstElementPtr auth = elem->get("authoritative"); + if (auth) { + setItem(xpath + "/authoritative", auth, SR_BOOL_T); + } } void diff --git a/src/lib/yang/translator_shared_network.cc b/src/lib/yang/translator_shared_network.cc index 0774b8a9ab..e9936f9ecc 100644 --- a/src/lib/yang/translator_shared_network.cc +++ b/src/lib/yang/translator_shared_network.cc @@ -128,6 +128,10 @@ TranslatorSharedNetwork::getSharedNetworkKea(const string& xpath, if (match) { result->set("match-client-id", match); } + ConstElementPtr auth = getItem(xpath + "/authoritative"); + if (auth) { + result->set("authoritative", auth); + } ConstElementPtr next = getItem(xpath + "/next-server"); if (next) { result->set("next-server", next); @@ -244,6 +248,10 @@ TranslatorSharedNetwork::setSharedNetworkKea(const string& xpath, if (match) { setItem(xpath + "/match-client-id", match, SR_BOOL_T); } + ConstElementPtr auth = elem->get("authoritative"); + if (auth) { + setItem(xpath + "/authoritative", auth, SR_BOOL_T); + } ConstElementPtr next = elem->get("next-server"); if (next) { setItem(xpath + "/next-server", next, SR_STRING_T); diff --git a/src/lib/yang/translator_subnet.cc b/src/lib/yang/translator_subnet.cc index c7849edf18..526f1410df 100644 --- a/src/lib/yang/translator_subnet.cc +++ b/src/lib/yang/translator_subnet.cc @@ -179,6 +179,10 @@ TranslatorSubnet::getSubnetKea(const string& xpath) { if (match) { result->set("match-client-id", match); } + ConstElementPtr auth = getItem(xpath + "/authoritative"); + if (auth) { + result->set("authoritative", auth); + } ConstElementPtr next = getItem(xpath + "/next-server"); if (next) { result->set("next-server", next); @@ -349,6 +353,10 @@ TranslatorSubnet::setSubnetKea(const string& xpath, ConstElementPtr elem) { if (match) { setItem(xpath + "/match-client-id", match, SR_BOOL_T); } + ConstElementPtr auth = elem->get("authoritative"); + if (auth) { + setItem(xpath + "/authoritative", auth, SR_BOOL_T); + } ConstElementPtr next = elem->get("next-server"); if (next) { setItem(xpath + "/next-server", next, SR_STRING_T);