From: Francis Dupont Date: Tue, 11 Oct 2022 22:20:24 +0000 (+0200) Subject: [#2587] Addressed comments X-Git-Tag: Kea-2.3.2~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99b957cfbf3d8bb0fa25833265803a2d774d5fff;p=thirdparty%2Fkea.git [#2587] Addressed comments --- diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index 761e3b47d8..339e4c0daa 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -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:: diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 7a2523f865..504d988061 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -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 diff --git a/src/lib/dhcpsrv/lease_mgr.cc b/src/lib/dhcpsrv/lease_mgr.cc index b4715c96db..ed3d87607b 100644 --- a/src/lib/dhcpsrv/lease_mgr.cc +++ b/src/lib/dhcpsrv/lease_mgr.cc @@ -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; diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h index 55a3ab9480..79932603f6 100644 --- a/src/lib/dhcpsrv/lease_mgr.h +++ b/src/lib/dhcpsrv/lease_mgr.h @@ -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);