[Kea-users] vendor specific dhcp4 options from database

Richard Kojedzinszky richard at kojedz.in
Sat Apr 1 14:57:01 UTC 2023


Hi,

A more efficient solution, where encapsulation is done after all data 
has been read from database:

diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc 
b/src/lib/dhcpsrv/pgsql_host_data_source.cc
index a1251be692..5c438aac17 100644
--- a/src/lib/dhcpsrv/pgsql_host_data_source.cc
+++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc
@@ -2530,6 +2530,11 @@ 
PgSqlHostDataSourceImpl::getHostCollection(PgSqlHostContextPtr& ctx,
                        << tagged_statements[stindex].name);
          }
      }
+
+    for (auto& host : result) {
+        
boost::const_pointer_cast<Host>(host)->getCfgOption4()->encapsulate();
+        
boost::const_pointer_cast<Host>(host)->getCfgOption6()->encapsulate();
+    }
  }

  ConstHostPtr

Of course, this is just for postgresql.

Regards,
Richard

2023-04-01 15:26 időpontban Richard Kojedzinszky via Kea-users ezt írta:
> Hi,
> 
> It seems that encapsulation step is missing for records processed from 
> sql. At least, the following little diff solved my case:
> 
> diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc 
> b/src/lib/dhcpsrv/pgsql_host_data_source.cc
> index a1251be692..0cdef61cde 100644
> --- a/src/lib/dhcpsrv/pgsql_host_data_source.cc
> +++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc
> @@ -689,6 +689,7 @@ private:
>              }
> 
>              cfg->add(desc, space);
> +            cfg->encapsulate();
>          }
> 
>          /// @brief Specify column names.
> 
> Of course, this is not really nice, I am still checking for nicer 
> solutions.
> 
> Regards,
> Richard
> 
> 2023-03-31 23:02 időpontban Darren Ankney ezt írta:
>> Hi Richard,
>> 
>> You would need to load the cb_cmds hook to manage the option-def and
>> option-data in the database
>> (https://kea.readthedocs.io/en/kea-2.2.0/arm/hooks.html#cb-cmds-configuration-backend-commands)
>> using the API commands.  You also need to connect to the database for
>> configuration backend
>> (https://kea.readthedocs.io/en/kea-2.2.0/arm/dhcp4-srv.html#configuration-backend-in-dhcpv4)
>> so that it can load the configuration containing the options from the
>> database for use.
>> 
>> I saw neither of these things in your config file.
>> 
>> Thank you,
>> 
>> Darren Ankney
>> 
>> On Fri, Mar 31, 2023 at 2:33 PM Richard Kojedzinszky via Kea-users
>> <kea-users at lists.isc.org> wrote:
>>> 
>>> Dear users,
>>> 
>>> I would like to define vendor specific options in database, howewer I
>>> dont succeed. If I define it in the config file, it works. I am
>>> attaching
>>> kea-dhcp4.static.conf for static and working configuration, and
>>> attaching kea-dhcp4.dyn.conf and database.dump.sql with relevant 
>>> records
>>> only. Non-vendor options appear well in the reply packets, howewer
>>> options in space ipxe dont.
>>> 
>>> Can somebody help me what am I doing wrong?
>>> 
>>> Thanks in advance,
>>> Richard--
>>> ISC funds the development of this software with paid support 
>>> subscriptions. Contact us at https://www.isc.org/contact/ for more 
>>> information.
>>> 
>>> To unsubscribe visit 
>>> https://lists.isc.org/mailman/listinfo/kea-users.
>>> 
>>> Kea-users mailing list
>>> Kea-users at lists.isc.org
>>> https://lists.isc.org/mailman/listinfo/kea-users


More information about the Kea-users mailing list