Skip to content

Commit 9ee137c

Browse files
committed
[#4014] Core and UT for v6 option class-tags
Changes to be committed: modified: doc/sphinx/arm/hooks-cb-cmds.rst modified: src/hooks/dhcp/mysql/mysql_cb_dhcp6.cc modified: src/hooks/dhcp/mysql/mysql_cb_dhcp6.h modified: src/hooks/dhcp/mysql/mysql_cb_impl.cc modified: src/hooks/dhcp/mysql/tests/mysql_cb_dhcp6_unittest.cc modified: src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.cc modified: src/hooks/dhcp/pgsql/pgsql_cb_dhcp6.h modified: src/hooks/dhcp/pgsql/pgsql_cb_impl.cc modified: src/hooks/dhcp/pgsql/tests/pgsql_cb_dhcp6_unittest.cc modified: src/lib/dhcpsrv/config_backend_dhcp6.h modified: src/lib/dhcpsrv/config_backend_pool_dhcp6.cc modified: src/lib/dhcpsrv/config_backend_pool_dhcp6.h modified: src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.h modified: src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc modified: src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.h modified: src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.cc modified: src/lib/dhcpsrv/testutils/test_config_backend_dhcp4.h modified: src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.cc modified: src/lib/dhcpsrv/testutils/test_config_backend_dhcp6.h modified: src/share/api/remote-option4-global-del.json modified: src/share/api/remote-option4-global-get.json modified: src/share/api/remote-option4-global-set.json modified: src/share/api/remote-option4-network-del.json modified: src/share/api/remote-option4-network-set.json modified: src/share/api/remote-option4-pool-del.json modified: src/share/api/remote-option4-pool-set.json modified: src/share/api/remote-option4-subnet-del.json modified: src/share/api/remote-option4-subnet-set.json modified: src/share/api/remote-option6-global-del.json modified: src/share/api/remote-option6-global-get.json modified: src/share/api/remote-option6-global-set.json modified: src/share/api/remote-option6-network-del.json modified: src/share/api/remote-option6-network-set.json modified: src/share/api/remote-option6-pd-pool-del.json modified: src/share/api/remote-option6-pd-pool-set.json modified: src/share/api/remote-option6-pool-del.json modified: src/share/api/remote-option6-pool-set.json modified: src/share/api/remote-option6-subnet-del.json
1 parent 4c81b19 commit 9ee137c

38 files changed

+1063
-221
lines changed

doc/sphinx/arm/hooks-cb-cmds.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ data content.
170170
In order to support this construct, Kea uses the option's ``client-classes``
171171
list in addition to code and space to uniquely identifiy each option. This
172172
is important to keep in mind when using the Management API to alter your
173-
configuration. As of Kea 3.1 (applies to DHCPv4 commands only), commands which
174-
get, set, or delete an individual option now accept an optional ``client-classes``
175-
parameter in addition to ``code`` and ``space`` parameters.
173+
configuration. As of Kea 3.1.1 commands which get, set, or delete an
174+
individual option now accept an optional ``client-classes`` parameter in
175+
addition to ``code`` and ``space`` parameters.
176176

177177
If the ``client-classes`` parameter is omitted:
178178

@@ -1145,7 +1145,7 @@ The ``remote-option4-global-del``, ``remote-option6-global-del`` Commands
11451145

11461146
These commands are used to delete a global DHCP option from the
11471147
database. The option is identified by an option code and option space.
1148-
As of Kea 3.1, an optional ``client-classes`` parameter may also be
1148+
As of Kea 3.1.1 an optional ``client-classes`` parameter may also be
11491149
specified (see :ref:`cb-cmds-option-class-tags-as-keys`).
11501150

11511151
For example:
@@ -1191,7 +1191,7 @@ These commands are used to fetch a global DHCP option from the database.
11911191
The option is identified by the code and option space. The top-level
11921192
option spaces where DHCP standard options belong are called "dhcp4" and
11931193
"dhcp6" for the DHCPv4 and DHCPv6 servers, respectively.
1194-
As of Kea 3.1, an optional ``client-classes`` parameter may also be
1194+
As of Kea 3.1.1, an optional ``client-classes`` parameter may also be
11951195
specified (see :ref:`cb-cmds-option-class-tags-as-keys`).
11961196

11971197
The following command retrieves the IPv6 "DNS Servers" (code 23) option
@@ -1343,7 +1343,7 @@ The ``remote-option4-network-del``, ``remote-option6-network-del`` Commands
13431343

13441344
These commands are used to delete a shared-network-specific DHCP
13451345
option from the database. The option is identified by an option code
1346-
and option space and as of Kea 3.1, an optional ``client-classes``
1346+
and option space and as of Kea 3.1.1, an optional ``client-classes``
13471347
parameter may also be specified (see :ref:`cb-cmds-option-class-tags-as-keys`).
13481348
These parameters are passed within the ``options`` list.
13491349
Another list, ``shared-networks``, contains a map
@@ -1532,7 +1532,7 @@ The ``remote-option4-pool-del``, ``remote-option6-pool-del`` Commands
15321532

15331533
These commands are used to delete an address-pool-specific DHCP
15341534
option from the database. The option is identified by an option code
1535-
and option space, and as of Kea 3.1, an optional ``client-classes`` parameter
1535+
and option space, and as of Kea 3.1.1, an optional ``client-classes`` parameter
15361536
may also be specified (see :ref:`cb-cmds-option-class-tags-as-keys`).
15371537
These parameters are passed within the ``options`` list.
15381538
Another list, ``pools``, contains a map with the
@@ -1631,7 +1631,7 @@ The ``remote-option4-subnet-del``, ``remote-option6-subnet-del`` Commands
16311631

16321632
These commands are used to delete a subnet-specific DHCP option
16331633
from the database. The option is identified by an option code
1634-
and option space, and, as of Kea 3.1, an optional ``client-casses``
1634+
and option space, and, as of Kea 3.1.1, an optional ``client-casses``
16351635
parameter (see :ref:`cb-cmds-option-class-tags-as-keys`).
16361636
These parameters are passed within the ``options`` list.
16371637
Another list, ``subnets``, contains a map with the

src/hooks/dhcp/mysql/mysql_cb_dhcp6.cc

Lines changed: 86 additions & 47 deletions
Large diffs are not rendered by default.

src/hooks/dhcp/mysql/mysql_cb_dhcp6.h

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,17 @@ class MySqlConfigBackendDHCPv6 : public ConfigBackendDHCPv6 {
146146
/// @brief Retrieves single option by code and space.
147147
///
148148
/// @param server_selector Server selector.
149+
/// @param code code of the option to be deleted.
150+
/// @param space option space of the option to be deleted.
151+
/// @param client_classes Optional client classes list of the option to be deleted.
152+
/// Defaults to an empty pointer.
149153
/// @return Pointer to the retrieved option descriptor or null if
150154
/// no option was found.
151155
/// @throw NotImplemented if server selector is "unassigned".
152156
virtual OptionDescriptorPtr
153157
getOption6(const db::ServerSelector& server_selector, const uint16_t code,
154-
const std::string& space) const;
158+
const std::string& space,
159+
const ClientClassesPtr client_classes = ClientClassesPtr()) const;
155160

156161
/// @brief Retrieves all global options.
157162
///
@@ -479,11 +484,14 @@ class MySqlConfigBackendDHCPv6 : public ConfigBackendDHCPv6 {
479484
/// @param server_selector Server selector.
480485
/// @param code Code of the option to be deleted.
481486
/// @param space Option space of the option to be deleted.
487+
/// @param client_classes Optional client classes list of the option to be deleted.
488+
/// Defaults to an empty pointer.
482489
/// @return Number of deleted options.
483490
/// @throw NotImplemented if server selector is "unassigned".
484491
virtual uint64_t
485492
deleteOption6(const db::ServerSelector& server_selector, const uint16_t code,
486-
const std::string& space);
493+
const std::string& space,
494+
const ClientClassesPtr client_classes = ClientClassesPtr());
487495

488496
/// @brief Deletes shared network level option.
489497
///
@@ -492,12 +500,16 @@ class MySqlConfigBackendDHCPv6 : public ConfigBackendDHCPv6 {
492500
/// option belongs to
493501
/// @param code Code of the deleted option.
494502
/// @param space Option space of the deleted option.
503+
/// @param client_classes Optional client classes list of the option to be deleted.
504+
/// Defaults to an empty pointer.
505+
/// @return Number of deleted options.
495506
/// @throw NotImplemented if server selector is "unassigned".
496507
virtual uint64_t
497508
deleteOption6(const db::ServerSelector& server_selector,
498509
const std::string& shared_network_name,
499510
const uint16_t code,
500-
const std::string& space);
511+
const std::string& space,
512+
const ClientClassesPtr client_classes = ClientClassesPtr());
501513

502514
/// @brief Deletes subnet level option.
503515
///
@@ -506,11 +518,16 @@ class MySqlConfigBackendDHCPv6 : public ConfigBackendDHCPv6 {
506518
/// belongs.
507519
/// @param code Code of the deleted option.
508520
/// @param space Option space of the deleted option.
521+
/// @param client_classes Optional client classes list of the option to be deleted.
522+
/// Defaults to an empty pointer.
509523
/// @return Number of deleted options.
510524
/// @throw NotImplemented if server selector is "unassigned".
511525
virtual uint64_t
512-
deleteOption6(const db::ServerSelector& server_selector, const SubnetID& subnet_id,
513-
const uint16_t code, const std::string& space);
526+
deleteOption6(const db::ServerSelector& server_selector,
527+
const SubnetID& subnet_id,
528+
const uint16_t code,
529+
const std::string& space,
530+
const ClientClassesPtr client_classes = ClientClassesPtr());
514531

515532
/// @brief Deletes pool level option.
516533
///
@@ -521,14 +538,17 @@ class MySqlConfigBackendDHCPv6 : public ConfigBackendDHCPv6 {
521538
/// deleted option belongs.
522539
/// @param code Code of the deleted option.
523540
/// @param space Option space of the deleted option.
541+
/// @param client_classes Optional client classes list of the option to be deleted.
542+
/// Defaults to an empty pointer.
524543
/// @return Number of deleted options.
525544
/// @throw NotImplemented if server selector is "unassigned".
526545
virtual uint64_t
527546
deleteOption6(const db::ServerSelector& server_selector,
528547
const asiolink::IOAddress& pool_start_address,
529548
const asiolink::IOAddress& pool_end_address,
530549
const uint16_t code,
531-
const std::string& space);
550+
const std::string& space,
551+
const ClientClassesPtr client_classes = ClientClassesPtr());
532552

533553
/// @brief Deletes prefix delegation pool level option.
534554
///
@@ -539,14 +559,17 @@ class MySqlConfigBackendDHCPv6 : public ConfigBackendDHCPv6 {
539559
/// delegation pool to which the deleted option belongs.
540560
/// @param code Code of the deleted option.
541561
/// @param space Option space of the deleted option.
562+
/// @param client_classes Optional client classes list of the option to be deleted.
563+
/// Defaults to an empty pointer.
542564
/// @return Number of deleted options.
543565
/// @throw NotImplemented if server selector is "unassigned".
544566
virtual uint64_t
545567
deleteOption6(const db::ServerSelector& server_selector,
546568
const asiolink::IOAddress& pd_pool_prefix,
547569
const uint8_t pd_pool_prefix_length,
548570
const uint16_t code,
549-
const std::string& space);
571+
const std::string& space,
572+
const ClientClassesPtr client_classes = ClientClassesPtr());
550573

551574
/// @brief Deletes global parameter.
552575
///

src/hooks/dhcp/mysql/mysql_cb_impl.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,8 @@ MySqlConfigBackendImpl::getOption(const int index,
580580
in_bindings.push_back(MySqlBinding::createInteger<uint16_t>(code));
581581
}
582582
in_bindings.push_back(MySqlBinding::createString(space));
583+
in_bindings.push_back(createClientClassesForWhereClause(client_classes));
583584

584-
/// @todo TKM Remove the if when v6 is ready.
585-
if (universe == Option::V4) {
586-
in_bindings.push_back(createClientClassesForWhereClause(client_classes));
587-
}
588585
getOptions(index, in_bindings, universe, options);
589586
return (options.empty() ? OptionDescriptorPtr() :
590587
OptionDescriptor::create(*options.begin()));

src/hooks/dhcp/mysql/tests/mysql_cb_dhcp6_unittest.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,14 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getModifiedOptionDefs6Test) {
335335
getModifiedOptionDefs6Test();
336336
}
337337

338+
TEST_F(MySqlConfigBackendDHCPv6Test, globalOption6WithClientClassesTest) {
339+
globalOption6WithClientClassesTest();
340+
}
341+
342+
TEST_F(MySqlConfigBackendDHCPv6Test, getAllOptions6WithClientClassesTest) {
343+
getAllOptions6WithClientClassesTest();
344+
}
345+
338346
TEST_F(MySqlConfigBackendDHCPv6Test, createUpdateDeleteOption6Test) {
339347
createUpdateDeleteOption6Test();
340348
}
@@ -407,6 +415,22 @@ TEST_F(MySqlConfigBackendDHCPv6Test, multipleAuditEntriesTest) {
407415
multipleAuditEntriesTest();
408416
}
409417

418+
TEST_F(MySqlConfigBackendDHCPv6Test, sharedNetworkOption6WithClientClassesTest) {
419+
sharedNetworkOption6WithClientClassesTest();
420+
}
421+
422+
TEST_F(MySqlConfigBackendDHCPv6Test, subnetOption6WithClientClassesTest) {
423+
subnetOption6WithClientClassesTest();
424+
}
425+
426+
TEST_F(MySqlConfigBackendDHCPv6Test, poolOption6WithClientClassesTest) {
427+
poolOption6WithClientClassesTest();
428+
}
429+
430+
TEST_F(MySqlConfigBackendDHCPv6Test, pdPoolOption6WithClientClassesTest) {
431+
pdPoolOption6WithClientClassesTest();
432+
}
433+
410434
/// @brief Test fixture for verifying database connection loss-recovery
411435
/// behavior.
412436
class MySqlConfigBackendDHCPv6DbLostCallbackTest : public GenericConfigBackendDbLostCallbackTest {

0 commit comments

Comments
 (0)