ConfD User Community

Not able to connect to confd server

ConfD is up and running and try to run the application hello manually .
hello.fxs is present in /etc/confd

Getting an error

DEBUG Library MAXDEPTH/MAXKEYLEN 20/9 for confd_hkeypath_t are too small, ConfD needs 23/5

[vm-root@bin]$ ./hello
Before loading
DEBUG Library MAXDEPTH/MAXKEYLEN 20/9 for confd_hkeypath_t are too small, ConfD needs 23/5
val of error = -1 errval = 2

int main(int argc, char **argv)
{
struct sockaddr_in addr;
int debuglevel = CONFD_DEBUG;
struct confd_action_cbs acb;
struct pollfd set[3];
int ret;

/* Init library */
confd_init("hello_daemon",stderr, debuglevel);

addr.sin_addr.s_addr = inet_addr("127.0.0.1");
addr.sin_family = AF_INET;
addr.sin_port = htons(CONFD_PORT);

//confd_fatal("Before loading \n");
printf("Before loading \n");

int i = confd_load_schemas((struct sockaddr*)&addr,
sizeof (struct sockaddr_in));

if ( i != 0) { printf("val of error = %d  errval = %d", i,errno); }
if ((dctx = confd_init_daemon("hello_daemon")) == NULL)
    confd_fatal("Failed to initialize ConfD\n");

if ((ctlsock = socket(PF_INET, SOCK_STREAM, 0)) < 0 )
    confd_fatal("Failed to open ctlsocket\n");

see ConfD user guide, chapter “Tuning the size of confd_hkeypath_t” - according to debug message - your model seems to have “too complex” structure.
You will need to recompile ConfD library with modified keypath size as described in the chapter mentioned above.
Then you can use this updated library to compile your application to support bigger model keypaths…

hi @josephm
thanks for the response.
Yes we have tried the same by below command for application .

[rmedpurvasanthareddy@buildbng2 rpcmgmt]$ make all  EXTRA_CFLAGS="-DMAXDEPTH=23 -DMAXKEYLEN=5"
/mnt/data0/tools/3rd-party/cisco-tailf/cisco-tailf-latest/bin/confdc --fail-on-warnings   -c -o hello.fxs hello.yang
/mnt/data0/tools/3rd-party/cisco-tailf/cisco-tailf-latest/bin/confdc --emit-h hello.h hello.fxs
cc -c -o hello.o hello.c -Wall -g -I/mnt/data0/tools/3rd-party/cisco-tailf/cisco-tailf-latest/include
cc -Wall -g -I/mnt/data0/tools/3rd-party/cisco-tailf/cisco-tailf-latest/include -o hello hello.o -L/mnt/data0/tools/3rd-party/cisco-tailf/cisco-tailf-latest/lib -lconfd -lpthread
Build complete
[rmedpurvasanthareddy@buildbng2 rpcmgmt]$

After which we tried to move the hello app to device and try to connect to confd server .

but we are getting same error

Which means that the change didn’t probably get into the hello application throughout the whole build pipeline… You have multiple options and it depends on your project architecture.

E.g. for development purposes, i usually directly edit source code of my confd-lib in $CONFD_DIR/src/confd/libconfd and then rebuild the library.
(by changing the #defines of MAXKEYLEN etc. in header files, but you can skip this, and just use -D EXTRA_CFLAGS to rebuild it…)

(edit - one next step below is maybe unnecessary, and is my legacy from very old confd-lib times - i will need to check confd-lib sources makefile to see if it is needed or done automatically already by make process)

Afterwards, i copy appropriate updated/built files from libconfd built directory to a few levels up - to $CONFD_DIR/lib and $CONFD_DIR/include.
This need to be done only once, and then any application that uses this “hacked” confd instance has the updated keypaths without any needed edits into app sources/makefiles…
(when it uses the hacked confd directory to build - using its confd-lib that i hacked/rebuilt before…)

Text that you pasted above seems like you use the updated values for the hello application build - but the description recommends rebuilding the ConfD library with the -D make parameters - located in the $CONFD_DIR/src/confd/libconfd. Then the updated library can be used to build the compatible hello app…

Thanks for the inputs , will check on this.