]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4492] Finished API doc
authorThomas Markwalder <tmark@isc.org>
Wed, 6 May 2026 14:56:57 +0000 (10:56 -0400)
committerThomas Markwalder <tmark@isc.org>
Tue, 12 May 2026 17:17:33 +0000 (17:17 +0000)
/doc/sphinx/api-files.txt
    Added API files

/doc/sphinx/arm/hooks-lease-cmds.rst
    Documented SFLQ commands

/src/hooks/dhcp/lease_cmds/lease_cmds_messages.mes
    Removed command args from get-all messages

/src/hooks/dhcp/lease_cmds/libloadtests/sflq_cmds_unittests.cc
    Udpated UTs

/src/hooks/dhcp/lease_cmds/sflq_cmds.*
    Improved arg handling

/src/share/api/sflq-pool4-del.json
/src/share/api/sflq-pool4-get-all.json
/src/share/api/sflq-pool4-get-by-range.json
/src/share/api/sflq-pool4-get-by-subnet.json
/src/share/api/sflq-pool6-create.json
/src/share/api/sflq-pool6-del.json
    finihsed API files

14 files changed:
changelog_unreleased/4492-shared-flq-allocator-add-command-handlers-to-lease-command-hook-library [new file with mode: 0644]
doc/devel/doc.dox
doc/sphinx/api-files.txt
doc/sphinx/arm/hooks-lease-cmds.rst
src/hooks/dhcp/lease_cmds/lease_cmds_messages.mes
src/hooks/dhcp/lease_cmds/libloadtests/sflq_cmds_unittests.cc
src/hooks/dhcp/lease_cmds/sflq_cmds.cc
src/hooks/dhcp/lease_cmds/sflq_cmds.h
src/share/api/sflq-pool4-del.json
src/share/api/sflq-pool4-get-all.json
src/share/api/sflq-pool4-get-by-range.json
src/share/api/sflq-pool4-get-by-subnet.json
src/share/api/sflq-pool6-create.json
src/share/api/sflq-pool6-del.json

diff --git a/changelog_unreleased/4492-shared-flq-allocator-add-command-handlers-to-lease-command-hook-library b/changelog_unreleased/4492-shared-flq-allocator-add-command-handlers-to-lease-command-hook-library
new file mode 100644 (file)
index 0000000..c139b2f
--- /dev/null
@@ -0,0 +1,4 @@
+[func]         tmark
+       Added API commands for managing SFLQ Allocator
+       pools to lease-cmds hook library.
+       (Gitlab #4492)
index f59655078a98868227d01ad2f737ff2b292c0725..433d5850ca1e9a7834329b909317f66fc47fa248 100644 (file)
@@ -70,7 +70,7 @@ There are several steps needed to document a new API command:
  1. Set up the build with "meson setup build".
  2. Copy src/share/api/_template.json to appropriate name.
  3. Remove comments from it and fill in the actual content.
- 4. Update api_files.mk file in src/share/api.
+ 4. Run "meson setup --reconfigure build" to rebuild the list of API files.
  5. "meson compile -C build doc" will generate both multi-page and single-page
     HTML sites.
 
index f083fe8a6492ca976a034adf5886455b7bcf6150..5662788d1ceceafe3e249daab82788040900b05f 100644 (file)
@@ -171,6 +171,16 @@ src/share/api/reservation-get-by-id.json
 src/share/api/reservation-get-page.json
 src/share/api/reservation-update.json
 src/share/api/server-tag-get.json
+src/share/api/sflq-pool4-create.json
+src/share/api/sflq-pool4-del.json
+src/share/api/sflq-pool4-get-all.json
+src/share/api/sflq-pool4-get-by-range.json
+src/share/api/sflq-pool4-get-by-subnet.json
+src/share/api/sflq-pool6-create.json
+src/share/api/sflq-pool6-del.json
+src/share/api/sflq-pool6-get-all.json
+src/share/api/sflq-pool6-get-by-range.json
+src/share/api/sflq-pool6-get-by-subnet.json
 src/share/api/shutdown.json
 src/share/api/statistic-get.json
 src/share/api/statistic-get-all.json
index 0e6741a1ea7b2de69c629e0cd27e132a2b318926..a3e878f72f90e9fbed514bbf7fbdc1d4e28bdf5b 100644 (file)
@@ -113,6 +113,32 @@ This library provides the following commands:
 
 -  :isccmd:`lease6-write` - writes the IPv6 memfile lease database into a file.
 
+-  :isccmd::`sflq-pool4-create` - creates an IPv4 SFLQ pool in the lease back end.
+
+-  :isccmd::`sflq-pool6-create` - creates an IPv6 SFLQ pool in the lease back end.
+
+-  :isccmd::`sflq-pool4-get-all` - fetches all IPv4 SFLQ pools from the lease back end.
+
+-  :isccmd::`sflq-pool6-get-all` - fetches all IPv6 SFLQ pools from the lease back end.
+
+-  :isccmd::`sflq-pool4-get-by-subnet` - fetches all IPv4 SFLQ pools that belong to
+   a subnet from the lease back end.
+
+-  :isccmd::`sflq-pool6-get-by-subnet` - fetches all IPv6 SFLQ pools that belong to
+   a subnet from the lease back end.
+
+-  :isccmd::`sflq-pool4-get-by-range` - fetches all IPv4 SFLQ pools that overlap an
+   address range from the lease back end.
+
+-  :isccmd::`sflq-pool6-get-by-range` - fetches all IPv6 SFLQ pools that overlap an
+   address range from the lease back end.
+
+-  :isccmd::`sflq-pool4-del` - deletes an IPv4 SFLQ pool that matches an address
+   range from the lease back end.
+
+-  :isccmd::`sflq-pool6-del` - deletes an IPv6 SFLQ pool that matches an address
+   range from the lease back end.
+
 All commands use JSON syntax and can be issued either using the control
 channel (see :ref:`ctrl-channel`).
 
@@ -1126,6 +1152,533 @@ to the previous filename: for example, ``.bak14326``.
    only in exceptional circumstances, such as when recovering after
    running out of disk space.
 
+
+Commands for Managing SFLQ Pools
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The following commands can be used to manage the SFLQ data (e.g. pools and
+free leases) that exists in the lease back end for subnets that use
+the Shared FLQ Allocator. Under normal circumstances this information
+is created and maintained automatically by the SFLQ Allocator mechanisms.
+With these API commands it is possible view, (re)create, and delete
+SFLQ pools.
+
+First, it is important to understand that SFLQ pools are uniquely identified
+by their start and end address. For any valid IPv4 or IPv6 range, there can
+only be one pool. Pools can however, have overlapping ranges.
+
+Commands that fetch pools, return the following values for each pool:
+
+- ``start-address`` - start address of the pool
+- ``end-address`` - end address of the pool
+- ``subnet-id`` - subnet ID to which the pool was created
+- ``lease-type`` - for IPv4 it is always "V4", for IPv6 is is either "IA_NA" or "IA_PD"
+- ``delegated-len`` - for "V4" and "IA_NA" pools it is always 128.  For "IA_PD" pools
+  it is the delegated prefix length.
+- ``created-ts``  - time the pool was created.
+- ``modified-ts`` - time the pool was last updated. It is initially set when the
+  pool creation completes. Thereafter it is updated each time SFLQ allocation
+  picks a free lease from the pool.
+- ``free-leases`` the number of currently free addresses in the pool.
+
+There at least three cases where these commands are likely to prove most
+useful. First, as a means to look for and remove obsolete pools. Because
+the pools can be be shared by an arbitrary number of servers, none of whom
+can know for certain when a pool is no longer needed, the SFLQ data for a pool
+cannot be automatically removed when its allocation scheme is changed to
+something other than SFLQ Allocator. While inactive pools should not cause
+servers to malfunction they do consume data and index space within the lease
+back end.
+
+The second case is that of mixed allocation schemes. In order for SFLQ
+Allocation to work properly, all servers allocating from a given pool (i.e.
+address or prefix range), must use SFLQ. If some servers do while others
+do not, the SFLQ data can quickly become inaccurate. This can be remedied
+by stopping any servers that are not using SFLQ for the pool(s) in question
+and recreating the pool(s) using the sflq-pool*-create commands, changing
+those servers to use SFLQ for the pool(s) and then restarting them.
+
+The third use case is that of overlapping pools, (i.e. pools whose
+address/prefix ranges overlap each other). Kea supports this as deliberate
+configuration choice but it may also occur inadvertently when configuration
+changes are not made consistently across multiple servers. Fetching the SFLQ
+pools by an address range will fetch all SFLQ pools that overlap the input
+range.
+
+.. note::
+
+    Creating or deleting SFLQ pools while servers are actively allocating
+    from their address ranges could lead to inconsistent results and is generally
+    not recommended.  Commands that fetch SFLQ pools may be safely used at anytime.
+
+.. isccmd:: sflq-pool4-create
+.. _command-sflq-pool4-create:
+
+.. isccmd:: sflq-pool6-create
+.. _command-sflq-pool6-create:
+
+The ``sflq-pool4-create``, ``sflq-pool6-create`` Commands
+---------------------------------------------------------
+
+:isccmd:`sflq-pool4-create` and :isccmd:`sflq-pool6-create` can be used to
+(re)create SFLQ pools and their free lease data.  This is useful in cases
+where one or more servers have been using other allocator schemes for
+the address ranges that include SFLQ pools. If the pool already exists,
+the call will simply return. The option ``recreate`` parameter, which
+defaults to false, can be used to force the pool to recreated.
+
+An example :isccmd:`sflq-pool4-create` command for recreating an IPv4 SFLQ
+Pool is shown below:
+
+::
+
+    {
+        "command": "sflq-pool4-create",
+        "arguments": {
+            "start-address": "192.0.2.0",
+            "end-address": "192.0.2.255",
+            "subnet-id" : 100,
+            "recreate": true
+        }
+    }
+
+Of the parameters shown above, only ``recreate`` is optional.
+
+For IPv6 pools the parameter ``lease-type`` with a value of either "IA_NA"
+or "IA_PD" is required.  An example :isccmd:`sflq-pool6-create` command for
+recreating an IPv6 SFLQ pool for an address pool is shown below:
+
+::
+
+    {
+        "command": "sflq-pool6-create",
+        "arguments": {
+            "start-address": "2001:db8:1::",
+            "end-address": "2001:db8:1::FFFF",
+            "subnet-id" : 100,
+            "lease-type": "IA_NA",
+            "recreate": true
+        }
+    }
+
+For IPv6 prefix delegation pools, the delegated prefix length must be
+specified as ``delegated-len`` which must be greater than 0 and less
+or equal to 128.  An example :isccmd:`sflq-pool6-create` command for
+recreating an IPv6 SFLQ pool for a prefix delegation pool is shown below:
+
+::
+
+    {
+        "command": "sflq-pool6-create",
+        "arguments": {
+            "start-address": "3001:20::",
+            "end-address": "3001:20:0:ff:ffff:ffff:ffff:ffff",
+            "subnet-id" : 100,
+            "lease-type": "IA_PD",
+            "delegated-len": 64,
+            "recreate": true
+        }
+    }
+
+.. note::
+
+    For large pools (e.g. >= 1 million address/prefixes), this command can take
+    twenty seconds or more. During this time the server will not process
+    client queries. Make sure the tool with which you send the commands
+    is confgured for long time outs. Once submitted to the lease back
+    end the query will continue to run, even if the API client disconnects.
+
+The command returns a status that indicates either success (result 0)
+or failure (result 1). A failed command always includes a text
+parameter that explains the cause of failure. For example:
+
+::
+
+   { "result": 0, "text": "SFLQ pool created." }
+
+Example failure:
+
+::
+
+   { "result": 1, "text": "missing 'lease-type' parameter" }
+
+.. isccmd:: sflq-pool4-get-all
+.. _command-sflq-pool4-get-all:
+
+.. isccmd:: sflq-pool6-get-all
+.. _command-sflq-pool6-get-all:
+
+The ``sflq-pool4-get-all``, ``sflq-pool6-get-all`` Commands
+-----------------------------------------------------------
+
+:isccmd:`sflq-pool4-get-all` and :isccmd:`sflq-pool6-get-all` can be used
+to fetch a list of all IPv4 or IPv6 SFLQ pools.  It takes no arguments.
+
+An example :isccmd:`sflq-pool4-get-all` command for fetching IPv4 SFLQ
+pools:
+
+::
+
+    {
+        "command": "sflq-pool4-get-all"
+    }
+
+The returned response contains a detailed list of all IPv4 SLFQ pools. In the
+following format:
+
+::
+
+       {
+           "arguments": {
+               "pools": [
+                   {
+                       "created-ts": "2026-05-05 11:16:36.000000",
+                       "delegated-len": 128,
+                       "end-address": "178.0.255.255",
+                       "free-leases": 65535,
+                       "lease-type": "V4",
+                       "modified-ts": "2026-05-05 11:16:36.000000",
+                       "start-address": "178.0.0.1",
+                       "subnet-id": 1
+                   },
+                {
+                    "created-ts": "2026-05-05 11:18:02.000000",
+                    "delegated-len": 128,
+                    "end-address": "192.0.2.255",
+                    "free-leases": 256,
+                    "lease-type": "V4",
+                    "modified-ts": "2026-05-05 11:18:02.000000",
+                    "start-address": "192.0.2.0",
+                    "subnet-id": 2
+                }
+               ]
+           },
+           "result": 0,
+           "text": "1 pool(s) found."
+       }
+
+An example :isccmd:`sflq-pool6-get-all` command for fetching IPv6 SFLQ
+pools:
+
+::
+
+    {
+        "command": "sflq-pool6-get-all"
+    }
+
+The returned response contains a detailed list of all IPv6 SLFQ pools. In the
+following format:
+
+::
+
+       {
+           "arguments": {
+               "pools": [
+                   {
+                       "created-ts": "2026-05-05 13:21:10.000000",
+                       "delegated-len": 120,
+                       "end-address": "2001:db8:1::ffff",
+                       "free-leases": 256,
+                       "lease-type": "IA_PD",
+                       "modified-ts": "2026-05-05 13:21:10.000000",
+                       "start-address": "2001:db8:1::",
+                       "subnet-id": 1
+                   },
+                   {
+                       "created-ts": "2026-05-05 08:40:40.000000",
+                       "delegated-len": 128,
+                       "end-address": "3001::ffff",
+                       "free-leases": 65520,
+                       "lease-type": "IA_NA",
+                       "modified-ts": "2026-05-05 08:40:41.000000",
+                       "start-address": "3001::10",
+                       "subnet-id": 2
+                   }
+               ]
+           },
+           "result": 0,
+           "text": "2 pool(s) found."
+       }
+
+
+.. isccmd:: sflq-pool4-get-by-subnet
+.. _command-sflq-pool4-get-by-subnet:
+
+.. isccmd:: sflq-pool6-get-by-subnet
+.. _command-sflq-pool6-get-by-subnet:
+
+The ``sflq-pool4-get-by-subnet``, ``sflq-pool6-get-by-subnet`` Commands
+-----------------------------------------------------------------------
+
+:isccmd:`sflq-pool4-get-by-subnet` and :isccmd:`sflq-pool6-get-by-subnet`
+can be used to fetch a list of all IPv4 or IPv6 SFLQ pools that were
+created for a subnet.
+
+An example :isccmd:`sflq-pool4-get-by-subnet` command for fetching IPv4 SFLQ
+pools is shown below:
+
+::
+
+       {
+           "command": "sflq-pool4-get-by-subnet",
+           "arguments": {
+               "subnet-id" : 1
+           }
+       }
+
+The returned response contains a detailed list of IPv4 SLFQ pools in
+following format:
+
+::
+
+       {
+           "arguments": {
+               "pools": [
+                   {
+                       "created-ts": "2026-05-05 11:18:02.000000",
+                       "delegated-len": 128,
+                       "end-address": "192.0.2.255",
+                       "free-leases": 256,
+                       "lease-type": "V4",
+                       "modified-ts": "2026-05-05 11:18:02.000000",
+                       "start-address": "192.0.2.0",
+                       "subnet-id": 1
+                   }
+               ]
+           },
+           "result": 0,
+           "text": "1 pool(s) found."
+       }
+
+An example :isccmd:`sflq-pool6-get-by-subnet` command for fetching IPv6 SFLQ
+pools is shown below:
+
+::
+
+       {
+           "command": "sflq-pool6-get-by-subnet",
+           "arguments": {
+               "subnet-id" : 100
+           }
+       }
+
+The returned response contains a detailed list of IPv6 SLFQ pools in
+following format:
+
+::
+
+       {
+           "arguments": {
+               "pools": [
+                   {
+                       "created-ts": "2026-05-05 13:21:10.000000",
+                       "delegated-len": 120,
+                       "end-address": "2001:db8:1::ffff",
+                       "free-leases": 256,
+                       "lease-type": "IA_PD",
+                       "modified-ts": "2026-05-05 13:21:10.000000",
+                       "start-address": "2001:db8:1::",
+                       "subnet-id": 100
+                   }
+               ]
+           },
+           "result": 0,
+           "text": "1 pool(s) found."
+       }
+
+.. isccmd:: sflq-pool4-get-by-range
+.. _command-sflq-pool4-get-by-range:
+
+.. isccmd:: sflq-pool6-get-by-range
+.. _command-sflq-pool6-get-by-range:
+
+The ``sflq-pool4-get-by-range``, ``sflq-pool6-get-by-range`` Commands
+---------------------------------------------------------------------
+
+:isccmd:`sflq-pool4-get-by-range` and :isccmd:`sflq-pool6-get-by-range`
+can be used to fetch a list of all IPv4 or IPv6 SFLQ pools that were
+created for a subnet.
+
+An example :isccmd:`sflq-pool4-get-by-range` command for fetching IPv4 SFLQ
+pools is shown below:
+
+::
+
+       {
+           "command": "sflq-pool4-get-by-range",
+           "arguments": {
+               "start-address": "178.0.0.0",
+               "end-address": "178.255.255.255"
+           }
+       }
+
+The returned response contains a detailed list of IPv4 SLFQ pools in
+following format:
+
+::
+
+       {
+           "arguments": {
+               "pools": [
+                   {
+                       "created-ts": "2026-05-05 11:16:36.000000",
+                       "delegated-len": 128,
+                       "end-address": "178.0.255.255",
+                       "free-leases": 65535,
+                       "lease-type": "V4",
+                       "modified-ts": "2026-05-05 11:16:36.000000",
+                       "start-address": "178.0.0.1",
+                       "subnet-id": 1
+                   }
+               ]
+           },
+           "result": 0,
+           "text": "1 pool(s) found."
+       }
+
+An example :isccmd:`sflq-pool6-get-by-range` command for fetching IPv6 SFLQ
+pools is shown below:
+
+::
+
+       {
+           "command": "sflq-pool6-get-by-range",
+           "arguments": {
+               "start-address": "3001::",
+               "end-address": "3002::"
+           }
+       }
+
+The returned response contains a detailed list of IPv6 SLFQ pools in
+following format:
+
+::
+
+       {
+           "arguments": {
+               "pools": [
+                   {
+                       "created-ts": "2026-05-05 08:40:40.000000",
+                       "delegated-len": 128,
+                       "end-address": "3001::ffff",
+                       "free-leases": 65520,
+                       "lease-type": "IA_NA",
+                       "modified-ts": "2026-05-05 08:40:41.000000",
+                       "start-address": "3001::10",
+                       "subnet-id": 3001
+                   },
+                   {
+                       "created-ts": "2026-05-05 08:40:41.000000",
+                       "delegated-len": 64,
+                       "end-address": "3001:20:0:ff:ffff:ffff:ffff:ffff",
+                       "free-leases": 256,
+                       "lease-type": "IA_PD",
+                       "modified-ts": "2026-05-05 08:40:41.000000",
+                       "start-address": "3001:20::",
+                       "subnet-id": 3001
+                   }
+               ]
+           },
+           "result": 0,
+           "text": "2 pool(s) found."
+       }
+
+
+.. isccmd:: sflq-pool4-del
+.. _command-sflq-pool4-del:
+
+.. isccmd:: sflq-pool6-del
+.. _command-sflq-pool6-del:
+
+The ``sflq-pool4-del``, ``sflq-pool6-del`` Commands
+---------------------------------------------------
+
+:isccmd:`sflq-pool4-del` and :isccmd:`sflq-pool6-del` can be used to delete
+an IPv4 or IPv6 SFLQ pool. It requires two arguments, ``start-address`` and
+and ``end-address``.  Only a pool whose range matches these values will be
+deleted and only if no other SFLQ pools overlap the range described by these
+values.  If any overlapping pools are detected the delete will fail with an
+error message stating this to be the case. There is an optional ``force``
+parameter can be used too override this safeguard.  When set to ``true`` the
+matching pool will be deleted without checking for overlapping pools.
+
+Deleting a pool when there are overlapping pools can produce holes in the
+free lease data where the overlaps occur. If the overlapping pools are to
+remain in use, the ``sflq-poolX-create`` commands should be used to rebuild the
+free lease data for the remaining pools.
+
+Alternatively, all of the overlapping pools can be deleted and the next
+Kea server (re)start or (re)configure will recreate any needed pools
+automatically.
+
+An example :isccmd:`sflq-pool4-del` command for deleting an IPv4 SFLQ
+pool is shown below:
+
+::
+
+    {
+        "command": "sflq-pool4-del",
+        "arguments": {
+            "start-address": "192.0.2.10",
+            "end-address": "192.0.2.20",
+            "force": false
+        }
+    }
+
+The returned response, if there were overlapping pools might look as
+follows:
+
+::
+
+    {
+        "result": 1,
+        "text": "Delete would affect 2 overlapping pools"
+    }
+
+And if there were no overlapping pools or ``force`` were set true, and
+the matching pool exists, the result would be similar to that shown below:
+
+::
+
+    {
+        "result": 0,
+        "text": "SFLQ pool deleted"
+    }
+
+An example :isccmd:`sflq-pool6-del` command for deleting an IPv6 SFLQ
+pool is shown below:
+
+::
+
+    {
+        "command": "sflq-pool6-del",
+        "arguments": {
+            "start-address": "3001::",
+            "end-address": "3001::10:FFFF",
+            "force": false
+        }
+    }
+
+The returned response, if there were overlapping pools might look as
+follows:
+
+::
+
+    {
+        "result": 1,
+        "text": "Delete would affect 3 overlapping pools"
+    }
+
+And if there were no overlapping pools or ``force`` were set true, and
+the matching pool exists, the result would be similar to that shown below:
+
+::
+
+    {
+        "result": 0,
+        "text": "SFLQ pool deleted"
+    }
+
 .. _binding-variables:
 
 Binding Variables
index 7b2469360358ffacd8f263a2c4038686a808823d..4c7b5df88964a6b09af687ef9bedcc4ea0f651a9 100644 (file)
@@ -182,7 +182,7 @@ The sflq-pool4-create command was successful.
 The sflq-pool4-create command has failed. Both the reason as well as the
 parameters passed are logged.
 
-% SFLQ_POOL4_GET_ALL sflq-pool4-get-all command succeeded, (parameters: %1) pools found: %2
+% SFLQ_POOL4_GET_ALL sflq-pool4-get-all command succeeded, pools found: %1
 Logged at debug log level 20.
 The sflq-pool4-get-all command was successful.
 
@@ -222,7 +222,7 @@ The sflq-pool6-create command was successful.
 The sflq-pool6-create command has failed. Both the reason as well as the
 parameters passed are logged.
 
-% SFLQ_POOL6_GET_ALL sflq-pool6-get-all command succeeded, (parameters: %1) pools found: %2
+% SFLQ_POOL6_GET_ALL sflq-pool6-get-all command succeeded, pools found: %1
 Logged at debug log level 20.
 The sflq-pool6-create command was successful.
 
index e40dee08d1fa8c6dec4b9562e035a45cce261fe9..a4e1e2c66cb1310ca2d7a84124f63e9a9bf824d8 100644 (file)
@@ -381,7 +381,7 @@ void SflqCmds4Test::sflqPool4GetAllBadParams() {
         R"(
             "bogus" : "fluff"
         )",
-        "spurious 'bogus' parameter"
+        "command does not take any arguments"
     }};
 
     for ( auto const& scenario : scenarios) {
@@ -918,7 +918,29 @@ void SflqCmds6Test::sflqPool6CreateBadParams() {
             "bogus" : "fluff"
         )",
         "spurious 'bogus' parameter"
-    }};
+    },
+    {
+        __LINE__,
+        R"(
+            "start-address" : "3001::10",
+            "end-address" : "3001::20",
+            "subnet-id" : 100,
+            "lease-type": "IA_NA",
+            "delegated-len": 56
+        )",
+        "'delegated-len' must only be 128 for IA_NA pools"
+    },
+    {
+        __LINE__,
+        R"(
+            "start-address" : "3001::10",
+            "end-address" : "3001::20",
+            "subnet-id" : 100,
+            "lease-type": "IA_PD"
+        )",
+        "'delegated-len' is required for IA_PD pools"
+    }
+    };
 
     for ( auto const& scenario : scenarios) {
         std::ostringstream oss;
@@ -939,7 +961,7 @@ void SflqCmds6Test::sflqPool6GetAllBadParams() {
         R"(
             "bogus" : "fluff"
         )",
-        "spurious 'bogus' parameter"
+        "command does not take any arguments"
     }};
 
     for ( auto const& scenario : scenarios) {
index 44e465b9055fce02ba6a616af582fc874830b581..77dbad12b5636eb32b0a917a811540914915a09a 100644 (file)
@@ -158,7 +158,7 @@ SflqCmdsImpl::sflqPool6CreateHandler(CalloutHandle& handle) {
         }
 
         auto lease_type = extractLeaseType(cmd_args_, AF_INET6);
-        uint8_t delegated_len = extractDelegatedLen(cmd_args_);
+        uint8_t delegated_len = extractDelegatedLen(cmd_args_, lease_type);
         bool recreate = extractBool(cmd_args_, "recreate", false);
 
         // Invoke the pool create function inside a CriticalSection.
@@ -208,13 +208,11 @@ SflqCmdsImpl::sflqPoolGetAll(CalloutHandle& handle, uint16_t family) {
     static const data::SimpleKeywords keywords;
     try {
         extractCommand(handle);
-        if (!cmd_args_ || cmd_args_->getType() != Element::map) {
-            isc_throw(isc::BadValue, "no parameters specified for the command");
+        if (cmd_args_ && ((cmd_args_->getType() != Element::map) ||
+            (cmd_args_->mapValue().size()) > 0)) {
+            isc_throw(BadValue, "command does not take any arguments");
         }
 
-        // Command has no arguments, this will catch any supplied.
-        SimpleParser::checkKeywords(keywords, cmd_args_);
-
         // Invoke the pool get function.
         auto pools = (family == AF_INET ? LeaseMgrFactory::instance().sflqPool4GetAll()
                                        : LeaseMgrFactory::instance().sflqPool6GetAll());
@@ -223,7 +221,6 @@ SflqCmdsImpl::sflqPoolGetAll(CalloutHandle& handle, uint16_t family) {
         setResponse(handle, resp);
         LOG_DEBUG(lease_cmds_logger, LEASE_CMDS_DBG_COMMAND_DATA,
                   (family == AF_INET ? SFLQ_POOL4_GET_ALL : SFLQ_POOL6_GET_ALL))
-                  .arg(cmd_args_->str())
                   .arg(pools->size());
     } catch (const std::exception& ex) {
         LOG_ERROR(lease_cmds_logger, (family == AF_INET ? SFLQ_POOL4_GET_ALL_FAILED
@@ -465,9 +462,14 @@ SflqCmdsImpl::extractLeaseType(ConstElementPtr& params, uint16_t family) {
 }
 
 uint8_t
-SflqCmdsImpl::extractDelegatedLen(ConstElementPtr& params) {
+SflqCmdsImpl::extractDelegatedLen(ConstElementPtr& params,
+                                  Lease::Type lease_type) {
     auto tmp = params->get("delegated-len");
     if (!tmp) {
+        if (lease_type == Lease::TYPE_PD) {
+            isc_throw(BadValue, "'delegated-len' is required for IA_PD pools");
+        }
+
         return (128);
     }
 
@@ -481,6 +483,10 @@ SflqCmdsImpl::extractDelegatedLen(ConstElementPtr& params) {
                   << ", it must be >= 1 and =< 128");
     }
 
+    if (lease_type == Lease::TYPE_NA) {
+        isc_throw(BadValue, "'delegated-len' must only be 128 for IA_NA pools");
+    }
+
     return (val);
 }
 
index 5d5d45c925210daad122f3acb0ff19eaa5903848..46cc28094e706153d08bbb3f4b7a74b9b83f993a 100644 (file)
@@ -370,10 +370,13 @@ public:
     /// it returns a value of 128.
     ///
     /// @param params Element map containging the command arguments.
+    /// @param lease_type Lease::Type supplied with the arguments (IA_NA
+    /// or IA_PD)
     ///
     /// @throw BadValue if the parameter is specified as anything other
     /// than an integer value >= 1 and <= 128.
-    static uint8_t extractDelegatedLen(data::ConstElementPtr& params);
+    static uint8_t extractDelegatedLen(data::ConstElementPtr& params,
+                                       dhcp::Lease::Type lease_type);
 
     /// @brief Extracts 'delegated-len' from given parameters map
     ///
index e6e24a8dca01f8580be99dadde690a9ac244c354..9e01fd35620ab8203849c5a9d1db1aed045199c1 100644 (file)
@@ -6,7 +6,7 @@
     ],
     "cmd-syntax": [
         "{",
-        "   \"command\": \"sflq-pool4-get-get-by-range\"",
+        "   \"command\": \"sflq-pool4-del\"",
         "   \"arguments\": {",
         "       \"end-address\": \"192.0.2.255\",",
         "       \"start-address\": \"192.0.2.0\",",
@@ -19,8 +19,8 @@
     "name": "sflq-pool4-del",
     "resp-syntax": [
         "{",
-        \"result\": 0,",
-        \"text\": \"1 pool(s) deleted.\"",
+        "\"result\": 0,",
+        "\"text\": \"1 pool(s) deleted.\"",
         "}"
     ],
     "support": [
index d16e986e60dab6ae0ce6adfc09d6009ec635601d..98d97d0b82a88164aa3695c1f451925049155a0d 100644 (file)
@@ -27,8 +27,8 @@
         "            \"subnet-id\": 6",
         "       }",
         "]]",
-        \"result\": 0,",
-        \"text\": \"1 pool(s) found.\"",
+        "\"result\": 0,",
+        "\"text\": \"1 pool(s) found.\"",
         "}"
     ],
     "support": [
index 93c8e67a71dec8c66b04370673f8a1952f5c496a..03cb64e54a1523e9ca5afdf4c229f735a4d4ba73 100644 (file)
@@ -31,8 +31,8 @@
         "            \"subnet-id\": 123",
         "       }",
         "]]",
-        \"result\": 0,",
-        \"text\": \"1 pool(s) found.\"",
+        "\"result\": 0,",
+        "\"text\": \"1 pool(s) found.\"",
         "}"
     ],
     "support": [
index 4fea3781a0e123207460df1f3bed14378a874313..9c9054277fcb8b94a778e47114d61f05ac956fd7 100644 (file)
@@ -30,8 +30,8 @@
         "            \"subnet-id\": 123",
         "       }",
         "]]",
-        \"result\": 0,",
-        \"text\": \"1 pool(s) found.\"",
+        "\"result\": 0,",
+        "\"text\": \"1 pool(s) found.\"",
         "}"
     ],
     "support": [
index 72595e0c0b385a67f340c0b97603a8e3f42fec4e..3371415253e411a7f0831daf787223398258eadc 100644 (file)
@@ -8,10 +8,10 @@
         "{",
         "    \"command\": \"sflq-pool6-create\",",
         "    \"arguments\": {",
-        "       \"start-address\": \"1.2.3.4\",",  
-        "       \"end-address\": \"1.2.3.4\",",  
+        "       \"start-address\": \"2001:db8:1::\",",  
+        "       \"end-address\": \"2001:db8:1::FFFF\",",  
         "       \"lease-type\": \"IA_PD\"," ,
-        "       \"delegated-len\": 64",
+        "       \"delegated-len\": 120,",
         "       \"recreate\" : false",
         "        } ]",
         "    }",
index 4f16a27ccd4ece5545cb38a4cc55b73723a2e945..c329aee496df66d5b893d1dc6d2cabe9477f277e 100644 (file)
@@ -19,8 +19,8 @@
     "name": "sflq-pool6-del",
     "resp-syntax": [
         "{",
-        \"result\": 0,",
-        \"text\": \"1 pool(s) deleted.\"",
+        "\"result\": 0,",
+        "\"text\": \"1 pool(s) deleted.\"",
         "}"
     ],
     "support": [