ConfD User Community

Confd_load_schemas() API failing


#1

Hi ,

confd_load_schemas() is failing continuously… after i restart yang servmon.

[15-11-2017 14:54:46] CONFD:Failed to confd_load_schemas in confd_schema_setup with error -1
[15-11-2017 14:54:46] CONFD:Failed to get schemas
[15-11-2017 14:54:46] ASMD:Failed to initialize confd
[15-11-2017 14:54:46] CONFD:Failed to confd_load_schemas in confd_schema_setup with error -1
[15-11-2017 14:54:46] CONFD:Failed to get schemas
[15-11-2017 14:54:46] ASMD:Failed to initialize confd
[15-11-2017 14:54:46] CONFD:Failed to confd_load_schemas in confd_schema_setup with error -1
[15-11-2017 14:54:46] CONFD:Failed to get schemas
[15-11-2017 14:54:46] ASMD:Failed to initialize confd
[15-11-2017 14:54:46] CONFD:Failed to confd_load_schemas in confd_schema_setup with error -1
[15-11-2017 14:54:46] CONFD:Failed to get schemas
[15-11-2017 14:54:46] ASMD:Failed to initialize confd
[15-11-2017 14:54:46] CONFD:Failed to confd_load_schemas in confd_schema_setup with error -1

Can you suggest any help for this issue?

Regards,
Bibin


#2

servmon is your application? In this case you haven’t restarted ConfD, just your application?

What is the value in confd_errno?


#3

Hi,

Servmon is not our process it is yang servmon … i mean confd process.

errono is -1

Regards,
Bibin


#4

What is “errono”? Greg asked for confd_errno, which will most certainly not be -1 - probably that’s the return value of confd_load_schemas(), i.e. CONFD_ERR, which just tells you that something went wrong, not what. Please read the ERRORS section of the confd_lib_lib(3) manual page, which explains how to obtain error information from the library, and what the different confd_errno values mean. Then update your logging code to print confd_errno and confd_lasterr(), and not just the function return value.


#5

Hi,

Please find the log below -

[20-11-2017 14:56:24] ASMD:Failed to initialize confd
[20-11-2017 14:56:24] CONFD:Failed to confd_load_schemas with error 24 and error is Failed to connect to ConfD: Invalid argument
[20-11-2017 14:56:24] ASMD:Failed to initialize confd
[20-11-2017 14:56:24] CONFD:Failed to confd_load_schemas with error 24 and error is Failed to connect to ConfD: Invalid argument
[20-11-2017 14:56:24] ASMD:Failed to initialize confd
[20-11-2017 14:56:24] CONFD:Failed to confd_load_schemas with error 24 and error is Failed to connect to ConfD: Invalid argument
[20-11-2017 14:56:24] ASMD:Failed to initialize confd

Regards,
Bibin


#6

Code snipet:

if(confd_load_schemas((struct sockaddr *)&eb_addr, sizeof(struct sockaddr_in) != CONFD_OK))
{
DBG_WTF(“CONFD:Failed to confd_load_schemas with error %d and error is %s \n”, confd_errno, confd_lasterr());
return FAILURE_VAL;
}


#7

Check your parenthesis

 -if(confd_load_schemas((struct sockaddr *)&eb_addr, sizeof(struct sockaddr_in) != CONFD_OK))
 +if(confd_load_schemas((struct sockaddr *)&eb_addr, sizeof(struct sockaddr_in)) != CONFD_OK)

#8

In addition to the syntax problem just pointed out, also take a look at how you populate the fields needed in eb_addr. Take a look at $CONFD_DIR/examples.confd/intro/5-c_stats/arpstat.c and how it calls confd_load_schemas.

The confd_errno is saying you have an OS error, and that your application did not connect to ConfD because of an Invalid argument. Also check that ConfD is running by issuing the ‘confd --status’ command.


#9

Well, the error pointed out by Conny (I’d call it semantics rather than syntax:-) completely explains the failure, since the call passes the value of sizeof(struct sockaddr_in) != CONFD_OK, i.e. 1, as the second argument (which becomes the third argument for connect(2)), and this is obviously not a valid size. The Linux connect(2) man page I looked at doesn’t document EINVAL for errno, but the man page for another OS has

 [EINVAL]           The namelen argument is not a valid length for the
                    address family.

I guess it’s just an omission in the Linux man page.


#10

Thank you for the inputs …

But when i tried to test my application again then i facing the below errors…

[21-11-2017 4:57:10] ASMD:Failed to initialize confd
[21-11-2017 4:57:10] CONFD:Failed to confd_load_schemas with error 24 and error is Failed to connect to ConfD: Connection refused
[21-11-2017 4:57:10] ASMD:Failed to initialize confd
[21-11-2017 4:57:10] CONFD:Failed to confd_load_schemas with error 24 and error is Failed to connect to ConfD: Connection refused
[21-11-2017 4:57:10] ASMD:Failed to initialize confd
[21-11-2017 4:57:10] CONFD:Failed to confd_load_schemas with error 24 and error is Failed to connect to ConfD: Connection refused
[21-11-2017 4:57:10] ASMD:Failed to initialize confd
[21-11-2017 4:57:10] CONFD:Failed to confd_load_schemas with error 24 and error is Failed to connect to ConfD: Connection refused
[21-11-2017 4:57:10] ASMD:Failed to initialize confd

In this case it is saying Connection refused, So after some time it is getting connected.

can you please help me

Regards,
Bibin


#11

This is the typical result if you are calling the function before ConfD has started (and then it works when ConfD has started). And the Linux connect(2) man page does document ECONNREFUSED:

   ECONNREFUSED
          No-one listening on the remote address.

So, as Greg wrote, check that ConfD is running by issuing the ‘confd --status’ command. For a general solution, make sure to start up ConfD and your applications in an ordered manner - i.e. don’t try to start your applications until the ‘confd …’ command that you use to start ConfD has completed.


#12

You can make sure ConfD is up and running before making your phone calls to ConfD by doing something like this:

    confd_init("my_daemon_name", stderr, CONFD_TRACE);

    /* Retry until ConfD has started enough to open the IPC port */
    while (1) {
        /* Establish a MAAPI socket */
        if ((maapisock = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
            confd_fatal("Failed to open socket\n");
        }
        /* (Re)Try connecting */
        if (maapi_connect(maapisock, (struct sockaddr*) &addr, sizeof(struct sockaddr_in)) == CONFD_OK) {
            break;
        }
        fprintf(stderr, "Close socket and retry maapi_connect() to confd in 1s\n");
        maapi_close(maapisock);
        sleep(1);
    }
    /* Make sure we are up and running, start-phase 2, before calling confd_load_schemas (equal to maapi_load_schemas) */
    maapi_wait_start(maapisock, 2);
    /* Close if we don't need MAAPI anymore */
    maapi_close(maapisock);
    /* Now let's go ahead and get that schema */
    if(confd_load_schemas((struct sockaddr *)&addr, sizeof(struct sockaddr_in)) != CONFD_OK) {
        fprintf(stderr, "CONFD:Failed to confd_load_schemas with error %d and error is %s \n", confd_errno, confd_lasterr());
    }