From: Francis Dupont Date: Wed, 15 Mar 2023 13:14:40 +0000 (+0100) Subject: [#719] Addressed comments X-Git-Tag: Kea-2.3.6~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3db9b8a0dd710f89077579bce1bb682fd4d04792;p=thirdparty%2Fkea.git [#719] Addressed comments --- diff --git a/ChangeLog b/ChangeLog index 28f43add5f..a318aad0dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2110. [func] fdupont + A new boolean configuration flag called "never-send" has been + added to the option data scope. When enabled, the option is not + sent in a response to the client, even if the client explicitly + requests it. + (Gitlab #719) + 2109. [bug] fdupont Compatibility flags e.g. lenient-option-parsing were not saved by config-get and similar commands. diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index c308fe0eec..83d70841b4 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -1527,6 +1527,17 @@ In the example above, ``domain-name-servers`` option is never added to responses on subnet ``192.0.3.0/24``. ``never-send`` has precedence over ``always-send`` so if both are true the option is not added. +.. note:: + + The ``always-send`` and ``never-send`` flags are sticky, meaning + they do not follow the usual configuration inheritance rules. + Instead, if they are enabled at least once along the configuration + inheritance chain, they get applied regardless of them being + disabled in other places which would usually be more prioritized. + For instance, if one of the flags is enabled in the global scope, + but disabled at the subnet level, it will act as enabled, + disregarding the subnet-level setting. + .. note:: The ``never-send`` is less powerful than the :ref:`hooks-flex-option`, @@ -2620,7 +2631,7 @@ Unfortunately, for many other vendors, such as Genexis (25167, discussed above), Kea does not have such a mechanism, so it cannot send any sub-options on its own. To solve this issue, we devised the concept of persistent options. Kea can be told to always send options, even if the client did not request them. This can -be achieved by adding ``"always-send": true`` to the option definition. Note +be achieved by adding ``"always-send": true`` to the option data entry. Note that in this particular case an option is defined in vendor space 25167. With ``always-send`` enabled, the option is sent every time there is a need to deal with vendor space 25167. diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index a9ec10132b..76c964af86 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -1454,6 +1454,17 @@ In the example above, the ``dns-server`` option is never added to responses on subnet ``2001:db8:1::/64``. ``never-send`` has precedence over ``always-send`` so if both are true the option is not added. +.. note:: + + The ``always-send`` and ``never-send`` flags are sticky, meaning + they do not follow the usual configuration inheritance rules. + Instead, if they are enabled at least once along the configuration + inheritance chain, they get applied regardless of them being + disabled in other places which would usually be more prioritized. + For instance, if one of the flags is enabled in the global scope, + but disabled at the subnet level, it will act as enabled, + disregarding the subnet-level setting. + .. note:: The ``never-send`` is less powerful than the :ref:`hooks-flex-option`, diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index d5010555e6..2f8e0724b3 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -1872,7 +1872,7 @@ Dhcpv4Srv::appendRequestedOptions(Dhcpv4Exchange& ex) { static_cast(cancelled_opts.insert(code)); } } - } + } // For each requested option code get the first instance of the option // to be returned to the client. diff --git a/src/bin/dhcp6/dhcp6_parser.cc b/src/bin/dhcp6/dhcp6_parser.cc index 43f3187495..aad89b24fa 100644 --- a/src/bin/dhcp6/dhcp6_parser.cc +++ b/src/bin/dhcp6/dhcp6_parser.cc @@ -3228,8 +3228,8 @@ namespace isc { namespace dhcp { #line 2013 "dhcp6_parser.yy" { ctx.unique("csv-format", ctx.loc2pos(yystack_[2].location)); - ElementPtr space(new BoolElement(yystack_[0].value.as < bool > (), ctx.loc2pos(yystack_[0].location))); - ctx.stack_.back()->set("csv-format", space); + ElementPtr csv(new BoolElement(yystack_[0].value.as < bool > (), ctx.loc2pos(yystack_[0].location))); + ctx.stack_.back()->set("csv-format", csv); } #line 3235 "dhcp6_parser.cc" break; @@ -3248,8 +3248,8 @@ namespace isc { namespace dhcp { #line 2025 "dhcp6_parser.yy" { ctx.unique("never-send", ctx.loc2pos(yystack_[2].location)); - ElementPtr persist(new BoolElement(yystack_[0].value.as < bool > (), ctx.loc2pos(yystack_[0].location))); - ctx.stack_.back()->set("never-send", persist); + ElementPtr cancel(new BoolElement(yystack_[0].value.as < bool > (), ctx.loc2pos(yystack_[0].location))); + ctx.stack_.back()->set("never-send", cancel); } #line 3255 "dhcp6_parser.cc" break; diff --git a/src/bin/dhcp6/dhcp6_parser.yy b/src/bin/dhcp6/dhcp6_parser.yy index 759f57afe0..2c0b7a9c7e 100644 --- a/src/bin/dhcp6/dhcp6_parser.yy +++ b/src/bin/dhcp6/dhcp6_parser.yy @@ -2012,8 +2012,8 @@ option_data_space: space; option_data_csv_format: CSV_FORMAT COLON BOOLEAN { ctx.unique("csv-format", ctx.loc2pos(@1)); - ElementPtr space(new BoolElement($3, ctx.loc2pos(@3))); - ctx.stack_.back()->set("csv-format", space); + ElementPtr csv(new BoolElement($3, ctx.loc2pos(@3))); + ctx.stack_.back()->set("csv-format", csv); }; option_data_always_send: ALWAYS_SEND COLON BOOLEAN { @@ -2024,8 +2024,8 @@ option_data_always_send: ALWAYS_SEND COLON BOOLEAN { option_data_never_send: NEVER_SEND COLON BOOLEAN { ctx.unique("never-send", ctx.loc2pos(@1)); - ElementPtr persist(new BoolElement($3, ctx.loc2pos(@3))); - ctx.stack_.back()->set("never-send", persist); + ElementPtr cancel(new BoolElement($3, ctx.loc2pos(@3))); + ctx.stack_.back()->set("never-send", cancel); }; // ---- pools ------------------------------------