Skip to content

Commit a198acc

Browse files
committed
[#3587] Updated doc, messages, parsers, and UTs
/doc/sphinx/arm/classify.rst /doc/sphinx/arm/dhcp4-srv.rst /doc/sphinx/arm/dhcp6-srv.rst /doc/sphinx/arm/hooks-class-cmds.rst /doc/sphinx/arm/hooks-limits.rst /src/bin/dhcp4/dhcp4_lexer.ll /src/bin/dhcp4/dhcp4_messages.mes /src/bin/dhcp4/dhcp4_srv.cc /src/bin/dhcp4/tests/classify_unittest.cc /src/bin/dhcp4/tests/config_parser_unittest.cc /src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes /src/bin/dhcp6/dhcp6_srv.cc /src/bin/dhcp6/tests/classify_unittest.cc /src/bin/dhcp6/tests/config_parser_unittest.cc /src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc /src/share/api/class-get.json
1 parent a2b1258 commit a198acc

21 files changed

+310
-209
lines changed

doc/sphinx/arm/classify.rst

+29-25
Original file line numberDiff line numberDiff line change
@@ -736,11 +736,14 @@ A client class definition can contain the following properties:
736736
assigned to members of this class. In the case of a template class, these
737737
options are assigned to the generated spawned class.
738738
- The ``option-def`` list is not mandatory and is used to define custom options.
739-
- The ``only-if-required`` flag is not mandatory; when its value is set to
739+
- The ``only-if-required`` has been replaced with ``only-in-additional-list`` and
740+
is now deprecated. It will still be accepted as input for a time to allow users
741+
to migrate but will eventually be unsupported.
742+
- The ``only-in-additional-list`` flag is not mandatory; when its value is set to
740743
``false`` (the default), membership is determined during classification and is
741744
available for subnet selection, for instance. When the value is set to
742-
``true``, membership is evaluated only when required and is usable only for
743-
option configuration.
745+
``true``, membership is evaluated only if the class appears in an ``evaluate-
746+
additional-classes`` list and is usable only for option configuration.
744747
- The ``user-context`` is not mandatory and represents a map with user-defined data
745748
and possibly configuration options for hook libraries.
746749
- The ``next-server`` parameter is not mandatory and configures the ``siaddr`` field in
@@ -907,18 +910,19 @@ expression for example purposes.
907910
Usually the ``test`` and ``template-test`` expressions are evaluated before
908911
subnet selection, but in some cases it is useful to evaluate it later when the
909912
subnet, shared network, or pools are known but output-option processing has not
910-
yet been done. For this purpose, the ``only-if-required`` flag, which is
913+
yet been done. For this purpose, the ``only-in-additional-list`` flag, which is
911914
``false`` by default, allows the evaluation of the ``test`` expression or the
912-
``template-test`` expression only when it is required, i.e. in a
913-
``require-client-classes`` list of the selected pool, subnet, or shared network.
915+
``template-test`` expression only when it is required by the class's presence
916+
in the ``evaluate-additional-classes`` list of the selected pool, subnet, or
917+
shared network.
914918

915-
The ``require-client-classes`` list, which is valid for pool, subnet,
919+
The ``evaluate-additional-classes`` list, which is valid for pool, subnet,
916920
and shared-network scope, specifies the classes which are evaluated in
917921
the second pass before output-option processing. The list is built in
918-
same precedence order of the option data, i.e. an option data item in
919-
a subnet takes precedence over one in a shared network, and also a
920-
required class in a subnet is added before one in a shared
921-
network. The mechanism is related to the ``only-if-required`` flag but
922+
same precedence order as the option data, i.e. an option data item in
923+
a subnet takes precedence over one in a shared network. An
924+
additional class in a subnet is added before one in a shared
925+
network. The mechanism is related to the ``only-in-additional-list`` flag but
922926
it is not mandatory that the flag be set to ``true``.
923927

924928
.. note ::
@@ -1200,9 +1204,9 @@ value is obtained is determined as explained in the previous paragraphs.
12001204
Option Class-Tagging
12011205
====================
12021206

1203-
Option class-tagging allows an option value to conditionally applied
1204-
to the response based on the client's class membership. The effect is
1205-
similar to using an if-block in ISC DHCP to conditionally include
1207+
Option class-tagging allows an option value to conditionally applied
1208+
to the response based on the client's class membership. The effect is
1209+
similar to using an if-block in ISC DHCP to conditionally include
12061210
options at a given scope. Class-tagging is done by specifying a list of
12071211
one of more class names in the option's ``client-classes`` entry.
12081212

@@ -1252,24 +1256,24 @@ being added to the response which occurs after lease assignment just
12521256
before the response is to be sent to the client.
12531257

12541258

1255-
When ``never-send`` for an option is true at any scope, all
1259+
When ``never-send`` for an option is true at any scope, all
12561260
``client-classes`` entries for that option are ignored. The
12571261
option will not included.
12581262

1259-
When ``always-send`` is true at any scope, the option will be
1260-
included unless, the option determined by scope specifies
1261-
a ``client-classes`` list that does not contain any of the
1263+
When ``always-send`` is true at any scope, the option will be
1264+
included unless, the option determined by scope specifies
1265+
a ``client-classes`` list that does not contain any of the
12621266
client's classes.
12631267

1264-
Otherwise, An option requested by the client will be included in
1268+
Otherwise, An option requested by the client will be included in
12651269
the response if the option either does not specify ``client-classes``
12661270
or the client belongs to at least one of the classes in ``client-classes``.
12671271

1268-
When an option's class-tag does not match, it is as though
1272+
When an option's class-tag does not match, it is as though
12691273
the option was not specified at that scope. In the following
12701274
example the option "foo" is specified for both the subnet and
12711275
the pool. The pool specification includes a class-tag that limits
1272-
the option to members of class "melon":
1276+
the option to members of class "melon":
12731277

12741278
::
12751279

@@ -1289,16 +1293,16 @@ the option to members of class "melon":
12891293
}]
12901294
}]
12911295
}
1292-
1296+
12931297

12941298
Clients that match class "melon" will have a value of 123 for option "foo",
12951299
while clients that do not match "melon" will have a value of 456 for option
1296-
"foo".
1300+
"foo".
12971301

12981302
.. note::
12991303

1300-
Though examples above are for DHCPv4, class-tagging syntax and
1301-
behavior is the same for DHPCv6.
1304+
Though examples above are for DHCPv4, class-tagging syntax and
1305+
behavior is the same for DHPCv6.
13021306

13031307
Classes and Hooks
13041308
=================

doc/sphinx/arm/dhcp4-srv.rst

+32-25
Original file line numberDiff line numberDiff line change
@@ -3421,26 +3421,26 @@ DNS servers set to 192.0.2.1 and 192.0.2.2.
34213421
...
34223422
}
34233423

3424-
.. _dhcp4-required-class:
3424+
.. _dhcp4-additional-class:
34253425

3426-
Required Classification
3427-
~~~~~~~~~~~~~~~~~~~~~~~
3426+
Additional Classification
3427+
~~~~~~~~~~~~~~~~~~~~~~~~~
34283428

34293429
In some cases it is useful to limit the scope of a class to a pool,
34303430
subnet, or shared network. There are two parameters which are used
34313431
to limit the scope of the class by instructing the server to evaluate test
34323432
expressions when required.
34333433

3434-
The first one is the per-class ``only-if-required`` flag, which is ``false``
3435-
by default. When it is set to ``true``, the test expression of the class
3436-
is not evaluated at the reception of the incoming packet but later, and
3437-
only if the class evaluation is required.
3438-
3439-
The second is ``require-client-classes``, which takes a list of class
3434+
The ``evaluate-additional-classes``, which takes a list of class
34403435
names and is valid in pool, subnet, and shared network scope. Classes in
3441-
these lists are marked as required and evaluated after selection of this
3436+
these lists are marked as additional and evaluated after selection of this
34423437
specific pool/subnet/shared network and before output-option processing.
34433438

3439+
The second one is the per-class ``only-in-additional-list`` flag, which is
3440+
``false`` by default. When it is set to ``true``, the test expression of
3441+
the class is not evaluated at the reception of the incoming packet but later,
3442+
and only if the class is present in an ``evaluate-additional-classes`` list.
3443+
34443444
In this example, a class is assigned to the incoming packet when the
34453445
specified subnet is used:
34463446

@@ -3451,38 +3451,45 @@ specified subnet is used:
34513451
{
34523452
"name": "Client_foo",
34533453
"test": "member('ALL')",
3454-
"only-if-required": true
3454+
"only-in-additional-list": true
34553455
},
34563456
...
34573457
],
34583458
"subnet4": [
34593459
{
34603460
"subnet": "192.0.2.0/24",
34613461
"pools": [ { "pool": "192.0.2.10 - 192.0.2.20" } ],
3462-
"require-client-classes": [ "Client_foo" ],
3462+
"evaluate-additional-classes": [ "Client_foo" ],
34633463
...
34643464
},
34653465
...
34663466
],
34673467
...
34683468
}
34693469

3470-
Required evaluation can be used to express complex dependencies like
3470+
Additional evaluation can be used to express complex dependencies like
34713471
subnet membership. It can also be used to reverse the
34723472
precedence; if ``option-data`` is set in a subnet, it takes precedence
34733473
over ``option-data`` in a class. If ``option-data`` is moved to a
34743474
required class and required in the subnet, a class evaluated earlier
34753475
may take precedence.
34763476

3477-
Required evaluation is also available at the shared network and pool levels.
3478-
The order in which required classes are considered is: pool, subnet,
3477+
Additional evaluation is also available at the shared network and pool levels.
3478+
The order in which additional classes are considered is: pool, subnet,
34793479
and shared network, i.e. in the same order from the way in which
34803480
``option-data`` is processed.
34813481

3482-
Since Kea version 2.7.4 required client classes configured without
3482+
Since Kea version 2.7.4 additional client classes configured without
34833483
a test expression are unconditionally added, i.e. they are considered
34843484
to always be evaluated to ``true``.
34853485

3486+
.. note::
3487+
3488+
As of Kea version 2.7.4, ``only-if-required`` and ``require-client-classes``
3489+
have been renamed to ``only-in-additional-list`` and ``evaluate-additional-classes``
3490+
respectivley. The original names will still be accepted as input to allow
3491+
users to migrate but will eventually be unsupported.
3492+
34863493
.. note::
34873494

34883495
Vendor-Identifying Vendor Options are a special case: for all other
@@ -5366,34 +5373,34 @@ For example:
53665373
{
53675374
"name": "dependent-class",
53685375
"test": "member('KNOWN')",
5369-
"only-if-required": true
5376+
"only-in-additional-list": true
53705377
}
53715378
]
53725379
}
53735380

5374-
The ``only-if-required`` parameter is needed here to force evaluation
5381+
The ``only-in-additional-list`` parameter is needed here to force evaluation
53755382
of the class after the lease has been allocated, and thus the reserved
53765383
class has been also assigned.
53775384

53785385
.. note::
53795386

53805387
The classes specified in non-global host reservations
53815388
are assigned to the processed packet after all classes with the
5382-
``only-if-required`` parameter set to ``false`` have been evaluated.
5389+
``only-in-additional-list`` parameter set to ``false`` have been evaluated.
53835390
This means that these classes must not depend on the
53845391
statically assigned classes from the host reservations. If
5385-
such a dependency is needed, the ``only-if-required`` parameter must
5392+
such a dependency is needed, the ``only-in-additional-list`` parameter must
53865393
be set to ``true`` for the dependent classes. Such classes are
53875394
evaluated after the static classes have been assigned to the packet.
53885395
This, however, imposes additional configuration overhead, because
5389-
all classes marked as ``only-if-required`` must be listed in the
5390-
``require-client-classes`` list for every subnet where they are used.
5396+
all classes marked as ``only-in-additional-list`` must be listed in the
5397+
``evaluate-additional-classes`` list for every subnet where they are used.
53915398

53925399
.. note::
53935400

53945401
Client classes specified within the Kea configuration file may
53955402
depend on the classes specified within the global host reservations.
5396-
In such a case the ``only-if-required`` parameter is not needed.
5403+
In such a case the ``only-in-additional-list`` parameter is not needed.
53975404
Refer to :ref:`pool-selection-with-class-reservations4` and
53985405
:ref:`subnet-selection-with-class-reservations4`
53995406
for specific use cases.
@@ -6806,10 +6813,10 @@ the ``dhcp-server-identifier`` option. This option configuration is only
68066813
supported at the subnet, shared network, client class, and global levels. It
68076814
must not be specified at the host-reservation level.
68086815
When configuring the ``dhcp-server-identifier`` option at client-class level, the
6809-
class must not set the ``only-if-required`` flag, because this class would not
6816+
class must not set the ``only-in-additional-list`` flag, because this class would not
68106817
be evaluated before the server determines if the received DHCP message should
68116818
be accepted for processing. Such classes are evaluated after subnet selection.
6812-
See :ref:`dhcp4-required-class` for details.
6819+
See :ref:`dhcp4-additional-class` for details.
68136820

68146821
The following example demonstrates how to override the server identifier
68156822
for a subnet:

doc/sphinx/arm/dhcp6-srv.rst

+30-23
Original file line numberDiff line numberDiff line change
@@ -3153,26 +3153,26 @@ eRouter1.0 client class are allowed to use that pool.
31533153
...
31543154
}
31553155

3156-
.. _dhcp6-required-class:
3156+
.. _dhcp6-additional-class:
31573157

3158-
Required Classification
3159-
~~~~~~~~~~~~~~~~~~~~~~~
3158+
Additional Classification
3159+
~~~~~~~~~~~~~~~~~~~~~~~~~
31603160

31613161
In some cases it is useful to limit the scope of a class to a pool,
31623162
subnet, or shared network. There are two parameters which are used
31633163
to limit the scope of the class by instructing the server to evaluate test
31643164
expressions when required.
31653165

3166-
The first one is the per-class ``only-if-required`` flag, which is ``false``
3167-
by default. When it is set to ``true``, the test expression of the class
3168-
is not evaluated at the reception of the incoming packet but later, and
3169-
only if the class evaluation is required.
3170-
3171-
The second is ``require-client-classes``, which takes a list of class
3166+
The ``evaluate-additional-classes``, which takes a list of class
31723167
names and is valid in pool, subnet, and shared network scope. Classes in
3173-
these lists are marked as required and evaluated after selection of this
3168+
these lists are marked as additional and evaluated after selection of this
31743169
specific pool/subnet/shared network and before output-option processing.
31753170

3171+
The second one is the per-class ``only-in-additional-list`` flag, which is
3172+
``false`` by default. When it is set to ``true``, the test expression of
3173+
the class is not evaluated at the reception of the incoming packet but later,
3174+
and only if the class is present in an ``evaluate-additional-classes`` list.
3175+
31763176
In this example, a class is assigned to the incoming packet when the
31773177
specified subnet is used:
31783178

@@ -3183,7 +3183,7 @@ specified subnet is used:
31833183
{
31843184
"name": "Client_foo",
31853185
"test": "member('ALL')",
3186-
"only-if-required": true
3186+
"only-in-additional-list": true
31873187
},
31883188
...
31893189
],
@@ -3195,30 +3195,37 @@ specified subnet is used:
31953195
"pool": "2001:db8:1::-2001:db8:1::ffff"
31963196
}
31973197
],
3198-
"require-client-classes": [ "Client_foo" ],
3198+
"evaluate-additional-classes": [ "Client_foo" ],
31993199
...
32003200
},
32013201
...
32023202
],
32033203
...
32043204
}
32053205

3206-
Required evaluation can be used to express complex dependencies like
3206+
Additional evaluation can be used to express complex dependencies like
32073207
subnet membership. It can also be used to reverse the
32083208
precedence; if ``option-data`` is set in a subnet, it takes precedence
32093209
over ``option-data`` in a class. If ``option-data`` is moved to a
32103210
required class and required in the subnet, a class evaluated earlier
32113211
may take precedence.
32123212

3213-
Required evaluation is also available at shared network and pool/pd-pool
3214-
levels. The order in which required classes are considered is:
3213+
Additional evaluation is also available at shared network and pool/pd-pool
3214+
levels. The order in which additional classes are considered is:
32153215
(pd-)pool, subnet, and shared network, i.e. in the same order from the
32163216
way in which ``option-data`` is processed.
32173217

3218-
Since Kea version 2.7.4 required client classes configured without
3218+
Since Kea version 2.7.4 additional classes configured without
32193219
a test expression are unconditionally added, i.e. they are considered
32203220
to always be evaluated to ``true``.
32213221

3222+
.. note::
3223+
3224+
As of Kea version 2.7.4, ``only-if-required`` and ``require-client-classes``
3225+
have been renamed to ``only-in-additional-list`` and ``evaluate-additional-classes``
3226+
respectivley. The original names will still be accepted as input to allow
3227+
users to migrate but will eventually be unsupported.
3228+
32223229
.. _dhcp6-ddns-config:
32233230

32243231
DDNS for DHCPv6
@@ -4656,34 +4663,34 @@ For example:
46564663
{
46574664
"name": "dependent-class",
46584665
"test": "member('KNOWN')",
4659-
"only-if-required": true
4666+
"only-in-additional-list": true
46604667
}
46614668
]
46624669
}
46634670

4664-
The ``only-if-required`` parameter is needed here to force
4671+
The ``only-in-additional-list`` parameter is needed here to force
46654672
evaluation of the class after the lease has been allocated and thus the
46664673
reserved class has been also assigned.
46674674

46684675
.. note::
46694676

46704677
The classes specified in non-global host reservations
46714678
are assigned to the processed packet after all classes with the
4672-
``only-if-required`` parameter set to ``false`` have been evaluated.
4679+
``only-in-additional-list` parameter set to ``false`` have been evaluated.
46734680
This means that these classes must not depend on the
46744681
statically assigned classes from the host reservations. If
4675-
such a dependency is needed, the ``only-if-required`` must
4682+
such a dependency is needed, the ``only-in-addtional-list`` must
46764683
be set to ``true`` for the dependent classes. Such classes are
46774684
evaluated after the static classes have been assigned to the packet.
46784685
This, however, imposes additional configuration overhead, because
4679-
all classes marked as ``only-if-required`` must be listed in the
4680-
``require-client-classes`` list for every subnet where they are used.
4686+
all classes marked as ``only-in-addtional-list`` must be listed in the
4687+
``evaluate-additional-classes`` list for every subnet where they are used.
46814688

46824689
.. note::
46834690

46844691
Client classes specified within the Kea configuration file may
46854692
depend on the classes specified within the global host reservations.
4686-
In such a case the ``only-if-required`` parameter is not needed.
4693+
In such a case the ``only-in-additional-list`` parameter is not needed.
46874694
Refer to the :ref:`pool-selection-with-class-reservations6` and
46884695
:ref:`subnet-selection-with-class-reservations6`
46894696
for specific use cases.

0 commit comments

Comments
 (0)