]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2587] Addressed comments
authorFrancis Dupont <fdupont@isc.org>
Tue, 11 Oct 2022 22:20:24 +0000 (00:20 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sat, 15 Oct 2022 18:39:56 +0000 (20:39 +0200)
doc/sphinx/arm/dhcp4-srv.rst
doc/sphinx/arm/dhcp6-srv.rst
src/lib/dhcpsrv/lease_mgr.cc
src/lib/dhcpsrv/lease_mgr.h

index 761e3b47d8be08d8d4216b768eb4687680e572a1..339e4c0daa6ef6274f0fbb3d8e5b66ad8eeaf523 100644 (file)
@@ -4012,15 +4012,27 @@ subnet levels.
    }
 
 When set to ``true``, information relevant to the DHCPREQUEST asking for the lease is
-added into the lease's user-context as a map element labeled "ISC". Currently,
-the map contains a single value, the ``relay-agent-info`` option (DHCP Option 82),
-when the DHCPREQUEST received contains it. Since DHCPREQUESTs sent as renewals will likely not contain this
+added into the lease's user-context as a map element labeled "ISC". Since
+Kea version 2.3.2,  when the DHCPREQUEST received contains the option
+(DHCP Option 82) the map contains the ``relay-agent-info`` map
+with the content option (DHCP Option 82) in the ``sub-options`` entry and
+when present the ``remote-id`` and ``relay-id`` options.
+Since DHCPREQUESTs sent as renewals will likely not contain this
 information, the values taken from the last DHCPREQUEST that did contain it are
 retained on the lease. The lease's user-context looks something like this:
 
 ::
 
-  { "ISC": { "relay-agent-info": "0x52050104AABBCCDD" } }
+  { "ISC": { "relay-agent-info": { "sub-options": "0x0104AABBCCDD" } } }
+
+Or with remote and relay suboptions:
+
+::
+   { "ISC": { "relay-agent-info": {
+       "sub-options": "0x02030102030C03AABBCC",
+       "remote-id": "03010203",
+       "relay-id": "AABBCC"
+   } } }
 
 .. note::
 
index 7a2523f865685eb98cb73aa96d692fba12fd4a2e..504d9880619a88772345cc2072fd994f62ae818e 100644 (file)
@@ -3477,21 +3477,33 @@ pretty-printed for clarity):
 
     {
         "ISC": {
-            "relays": [
+            "relay-info": [
             {
-                "hop": 2,
+                "hop": 3,
                 "link": "2001:db8::1",
                 "peer": "2001:db8::2"
             },
             {
-                "hop": 1,
+                "hop": 2,
                 "link": "2001:db8::3",
                 "options": "0x00C800080102030405060708",
                 "peer": "2001:db8::4"
+            },
+            {
+                "hop": 1",
+                "link": "2001:db8::5",
+                "options": "0x00250006010203040506003500086464646464646464",
+                "remote-id": "010203040506",
+                "relay-id": "6464646464646464"
             }]
         }
     }
 
+.. note::
+
+   Before Kea version 2.3.2 the entry was named ``relays``, remote and relay
+   identifier options were not decoded.
+
 .. note::
 
     It is possible that other hook libraries are already using
index b4715c96dbc6c1c5e62c6bf8a6fb45933d3ad2a7..ed3d87607b8865910e3d825840c98e497278bea9 100644 (file)
@@ -391,12 +391,9 @@ LeaseMgr::upgradeLease4ExtendedInfo(const Lease4Ptr& lease) {
     }
 
     if (!rai_def) {
-        // Should never be used...
-        rai_def.reset(new OptionDefinition("dhcp-agent-options",
-                                           DHO_DHCP_AGENT_OPTIONS,
-                                           DHCP4_OPTION_SPACE,
-                                           OPT_EMPTY_TYPE,
-                                           DHCP_AGENT_OPTION_SPACE));
+        // The definition is set when libdhcp++ is loaded so it is impossible
+        // to not be able to get it... so should not happen!
+        isc_throw(Unexpected, "can't find RAI option definition?!");
     }
 
     changed = true;
index 55a3ab9480304ca32f74298153f4240ff1a838fc..79932603f638ed462e8d23fe226ccc509e6239c7 100644 (file)
@@ -819,12 +819,26 @@ public:
 
     /// @brief Upgrade a V4 lease user context to the new extended info entry.
     ///
+    /// In details:
+    ///  - change the "ISC" / "relay-agent-info" to a map.
+    ///  - move the "relay-agent-info" string to the "sub-options" entry of
+    ///    the map.
+    ///  - decode remote-id and relay-id from the RAI option content and
+    ///    add the raw value in hexadecimal in "remote-id" and/or "relay-id"
+    ///    entries of the map.
+    ///
     /// @param lease Pointer to the lease to be updated.
     /// @return True if the lease user context was updated, false otherwise.
     static bool upgradeLease4ExtendedInfo(const Lease4Ptr& lease);
 
     /// @brief Upgrade a V6 lease user context to the new extended info entry.
     ///
+    /// In details:
+    ///  - change the "ISC" / "relays" list entry to "relay-info".
+    ///  - decode remote-id and relay-id from each relay options and
+    ///    add the raw value in hexadecimal in "remote-id" and/or "relay-id"
+    ///    in the relay item of the list.
+    ///
     /// @param lease Pointer to the lease to be updated.
     /// @return True if the lease user context was updated, false otherwise.
     static bool upgradeLease6ExtendedInfo(const Lease6Ptr& lease);