Adding validation to dhcpd_conf example

Hello,

I’d like to exercise validation with dhcpd_conf as an example.
dhcpd_conf is using cdb_connect and subscription for dhcpd config changes.
I’d like to add validation to this subscription point.

Looking at validation example: examples.confd/validate/c/more_a_than_b.c
it has the following elements:

  1. daemon and daemon context. Something that dhcpd_conf does not have. Do we need to add this? Only daemon context can validate data?
  2. ctrl, single worker and mappi sockets. Do we need all of these to be added to the dhcpd_conf example?
  3. In the poll event loop, do we need to listen to all 3 (out of the 4 opened) sockets? i.e. ctrl, worker and subscription? I can see that maapi socket is not used for the poll event loop.

thank you in advance,
Kobi

Hi,

Yes, the Data Provider API requires a daemon context. See the confd_lib_dp(3) man page confd_init_daemon() function.

You don’t necessarily need a MAAPI socket. If you look at what the Management Agent API (MAAPI) is used for in that example it is for doing a maapi_diff_iterate() and reading the new data that is in the transaction that is being validated. If you use the CDB API, you are reading the data that is currently in CDB, not in the transaction that is about to be committed if validation succeeds.

Yes, the DP API requires a control socket and at least one worker socket. See the ConfD UG chapter “C Example with Operational Data”

1 Like

Thank you for your reply. This is very useful.

If you use the CDB API, you are reading the data that is currently in CDB, not in the transaction that is about to be committed if validation succeeds.

OK. this is an important info. What you are saying is that MAAPI allows me to look at the data before it is committed into the CDB while working with CDB API, I’m getting notifications after the new config was committed into the CDB. Right?

Yes, you get CDB subscriber notifications for the configuration changes after the new config was written to CDB. At that time The MAAPI and CDB API show the same config (that was committed to CDB). In the validation phase, the config has not yet been written to CDB. See ConfD UG chapter “Validating Data in C” and confd_lib_dp(3) man page section “VALIDATION CALLBACKS” for details.

1 Like

Many thanks! this is useful info.