Confd_str2val on identityref

I’m using confd_str2val to convert a string representation of a identityref, this works fine in our development environment that is linux on pc.

The same code executed on linux om a powerpc platform fails silently, the function return CONFD_OK but no converion has taken place.

Is this a bug in the powerpc dist or is this a general big/little endian problem?

Hi,

Ran this little test below on a couple of our PPC targets. The test passed as described below.
Perhaps you can run this test on your target too and let us know the result?

$ ls
Makefile	check_idref.c	confd.conf	ytypes.yang
$ cat Makefile | grep -B 5 "check_idref -t"
start:  stop 
	$(CONFD) -c ./confd.conf $(CONFD_FLAGS) 
	### * Setting configuration and running identityref test now:
	confd_cmd -d -d -c 'mset /types/idref "des"'
	confd_cmd -d -d -c 'mset /types/idref2 "aes"'
	./check_idref -t
$ cat ytypes.yang 
module ytypes {
  namespace "http://tail-f.com/test/ytypes";
  prefix ytypes;
  
  revision "2010-06-08";

  typedef crypto-id {
    type identityref {
      base crypto-alg;
    }
  }

  identity crypto-alg;
  identity des {
    base crypto-alg;
  }
  identity aes {
    base crypto-alg;
  }

  container types {
    leaf idref {
      type crypto-id;
    }
    leaf idref2 {
      type crypto-id;
    }
  }
}
$ cat check_idref.c 
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include <confd.h>
#include <confd_cdb.h>

#include "ytypes.h"

#define OK(cond) do {                                           \
    int _ret = (cond);						\
    if (_ret != CONFD_OK) {					\
      fprintf(stderr, "retval=%d errno=%d lasterr=%s\n",	\
	      _ret, confd_errno, confd_lasterr());		\
      assert(_ret == CONFD_OK);					\
    } } while (0)

#define ERR(cond, err) (assert((cond) == CONFD_ERR && (err) == confd_errno))

static int debuglevel = CONFD_SILENT;
struct addrinfo *addr = NULL;

static struct {
  u_int32_t ns;
  u_int32_t tag;
  char *typename;
  char *in;
} typeval[] = {
  { ytypes__ns, ytypes_idref, "crypto-id", "des" },
  { ytypes__ns, ytypes_idref2, "crypto-id", "aes" }
};
static int ntypes = sizeof(typeval)/sizeof(typeval[0]);

void check_type()
{
  int i;
  confd_value_t v1, v2;
  char val[BUFSIZ];
  char path[BUFSIZ];
  int len;
  char *p;
  struct confd_type *type;
  int s;
  confd_hkeypath_t kp;
  u_int32_t hashed_types;

  assert((s = socket(PF_INET, SOCK_STREAM, 0)) >= 0);
  OK(cdb_connect(s, CDB_DATA_SOCKET, addr->ai_addr, addr->ai_addrlen));
  OK(cdb_start_session(s, CDB_RUNNING));

  for (i = 0; i < ntypes; i++) {
    kp.len = 2;
    hashed_types = confd_str2hash("types");
    CONFD_SET_XMLTAG(&kp.v[1][0], hashed_types, typeval[i].ns);
    CONFD_SET_XMLTAG(&kp.v[0][0], typeval[i].tag, typeval[i].ns);
    confd_pp_kpath(path, sizeof(path), &kp);
    fprintf(stderr, "cdb_get() -->v1 from path: %s\n", path);
    OK(cdb_get(s, &v1, "%h", &kp));
	
    type = confd_find_ns_type(typeval[i].ns, typeval[i].typename);
    len = confd_val2str(type, &v1, val, sizeof(val));
    fprintf(stderr, "confd_val2str v1: %s\n", &val[0]);

    fprintf(stderr, "confd_str2val -->v2: %s\n", typeval[i].in);
    OK(confd_str2val(type, typeval[i].in, &v2));

    fprintf(stderr, "testing assert(confd_val_eq(&v1, &v2))\n");
    assert(confd_val_eq(&v1, &v2));
    switch (typeval[i].tag) {
    case ytypes_idref:
    case ytypes_idref2:
      /* value is an enum or identityref (or boolean),
	 confd_val2str_ptr() should work */
      p = confd_val2str_ptr(type, &v1);
      fprintf(stderr, "confd_val2str_ptr v2: %s\n", p);
      assert(p != NULL);
      assert(strcmp(p, val) == 0);
      break;
    default:
      break;
    }
    confd_free_value(&v1);
    confd_free_value(&v2);
  }
  cdb_close(s);
}

int main(int argc, char **argv)
{
  int c, i;
  char confd_port[16];
  struct addrinfo hints;

  snprintf(confd_port, sizeof(confd_port), "%d", CONFD_PORT);
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = PF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
    
  while ((c = getopt(argc, argv, "dtp")) != -1) {
    switch (c) {
    case 'd':
      debuglevel = CONFD_DEBUG;
      break;
    case 't':
      debuglevel = CONFD_TRACE;
      break;
    case 'p':
      debuglevel = CONFD_PROTO_TRACE;
      break;
    default:
      fprintf(stderr,
	      "Usage: %s [-dtp]\n",
	      argv[0]);
      exit(1);
    }
  }
  confd_init("iftest", stderr, debuglevel);
    
  if (addr == NULL &&
      (i = getaddrinfo("127.0.0.1", confd_port, &hints, &addr)) != 0)
    /* "Can't happen" */
    confd_fatal("%s: Failed to get address for ConfD: %s\n",
		argv[0], gai_strerror(i));
    
  OK(confd_load_schemas(addr->ai_addr, addr->ai_addrlen));
    
  check_type();
  return 0;
}
$ make all start
/Users/tailf/confd-6.2/bin/confdc --fail-on-warnings  -c -o ytypes.fxs  ytypes.yang
/Users/tailf/confd-6.2/bin/confdc --emit-h ytypes.h ytypes.fxs
cc -c -o check_idref.o check_idref.c -Wall -g -I/Users/tailf/releases/../confd-6.2-orig/include -I/opt/local/include
cc -o check_idref check_idref.o /Users/tailf/confd-6.2/lib/libconfd.a -lpthread -lm -L/opt/local/lib
mkdir -p ./confd-cdb
cp /Users/tailf/confd-6.2/var/confd/cdb/aaa_init.xml ./confd-cdb
ln -s /Users/tailf/confd-6.2/etc/confd/ssh ssh-keydir
Build complete
### Killing any confd daemon and simple_cdb confd agents
/Users/tailf/releases/confd-6.2/bin/confd --stop    || true
killall check_idref || true
No matching processes belonging to you were found
/Users/tailf/releases/confd-6.2/bin/confd -c ./confd.conf --addloadpath /Users/tailf/confd-6.2-orig/etc/confd  
### * Setting configuration and running identityref test now:
confd_cmd -d -d -c 'mset /types/idref "des"'
mset "/types/idref" "des"
CMD_MAAPI is true [mtid = 0]
TRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION  --> CONFD_OK
TRACE MAAPI_START_TRANS  --> CONFD_OK
TRACE MAAPI_SET_ELEM2 /types/idref --> CONFD_OK
TRACE MAAPI_APPLY_TRANS  --> CONFD_OK
TRACE MAAPI_STOP_TRANS  --> CONFD_OK
TRACE MAAPI_END_USER_SESSION  --> CONFD_OK
confd_cmd -d -d -c 'mset /types/idref2 "aes"'
mset "/types/idref2" "aes"
CMD_MAAPI is true [mtid = 0]
TRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION  --> CONFD_OK
TRACE MAAPI_START_TRANS  --> CONFD_OK
TRACE MAAPI_SET_ELEM2 /types/idref2 --> CONFD_OK
TRACE MAAPI_APPLY_TRANS  --> CONFD_OK
TRACE MAAPI_STOP_TRANS  --> CONFD_OK
TRACE MAAPI_END_USER_SESSION  --> CONFD_OK
./check_idref -t
TRACE Connected (maapi) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_HASH_DB
TRACE Connected (cdb) to ConfD
TRACE CDB_NEW_SESSION  --> CONFD_OK
TRACE Established new CDB session to ConfD
cdb_get() -->v1 from path: /types/idref
TRACE CDB_GET /ytypes:types/idref --> CONFD_OK
confd_val2str v1: ytypes:des
confd_str2val -->v2: des
testing assert(confd_val_eq(&v1, &v2))
confd_val2str_ptr v2: ytypes:des
cdb_get() -->v1 from path: /types/idref2
TRACE CDB_GET /ytypes:types/idref2 --> CONFD_OK
confd_val2str v1: ytypes:aes
confd_str2val -->v2: aes
testing assert(confd_val_eq(&v1, &v2))
confd_val2str_ptr v2: ytypes:aes

Hi,

I’m doing things a little different.
In my get_elem callback which gets the idref leaf I do:

csp = confd_find_cs_node(kp, kp->len);
confd_str2val(csp->info.type, “ianaift:opticalChannel”, &v);
confd_val2str(csp->info.type, &v, vv, sizeof(vv));
printf("%s", vv);

The funny thing is that it works on one platform and not the other.

Hi,
Perhaps your keypath is messed up?
Can you pretty print it for us using confd_pp_kpath()?

int confd_pp_kpath(char *buf, int bufsiz, const confd_hkeypath_t *hkey path);

Here is your identityref example running that you can try on your PPC variant if you wish:

$ cat Makefile | grep -B 5 "check_idref -t"

start:  stop 
	$(CONFD) -c ./confd.conf $(CONFD_FLAGS) 
	### * Setting configuration and running identityref test:
	confd_cmd -d -d -c 'mset /myiftype "opticalChannel"'
	./check_idref -t
$ cat myif.yang
module myif {
  namespace "http://tail-f.com/test/myif";
  prefix myif;

  import iana-if-type {
    prefix ianaift;
  }

  leaf myiftype {
    type identityref {
      base ianaift:iana-interface-type;
    }
  }
}
$ cat check_idref.c
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include <confd.h>
#include <confd_cdb.h>

#include "myif.h"

#define OK(cond) do {                                           \
    int _ret = (cond);						\
    if (_ret != CONFD_OK) {					\
      fprintf(stderr, "retval=%d errno=%d lasterr=%s\n",	\
	      _ret, confd_errno, confd_lasterr());		\
      assert(_ret == CONFD_OK);					\
    } } while (0)

#define ERR(cond, err) (assert((cond) == CONFD_ERR && (err) == confd_errno))

static int debuglevel = CONFD_SILENT;
struct addrinfo *addr = NULL;

void check_type()
{
  confd_value_t v;
  char vv[BUFSIZ];
  char path[BUFSIZ];
  struct confd_cs_node *csp, *root;
  int s;
  
  assert((s = socket(PF_INET, SOCK_STREAM, 0)) >= 0);
  OK(cdb_connect(s, CDB_DATA_SOCKET, addr->ai_addr, addr->ai_addrlen));
  OK(cdb_start_session(s, CDB_RUNNING));
  
  strcpy(&path[0], "/myif:myiftype");

  root = confd_find_cs_root(myif__ns);
  csp = confd_cs_node_cd(root, "/myiftype");
  
  confd_str2val(csp->info.type, "ianaift:opticalChannel", &v);
  confd_val2str(csp->info.type, &v, vv, sizeof(vv));
  printf("%s\n", vv);

  confd_free_value(&v);
  
  cdb_close(s);
}

int main(int argc, char **argv)
{
  int c, i;
  char confd_port[16];
  struct addrinfo hints;

  snprintf(confd_port, sizeof(confd_port), "%d", CONFD_PORT);
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = PF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
    
  while ((c = getopt(argc, argv, "dtp")) != -1) {
    switch (c) {
    case 'd':
      debuglevel = CONFD_DEBUG;
      break;
    case 't':
      debuglevel = CONFD_TRACE;
      break;
    case 'p':
      debuglevel = CONFD_PROTO_TRACE;
      break;
    default:
      fprintf(stderr,
	      "Usage: %s [-dtp]\n",
	      argv[0]);
      exit(1);
    }
  }
  confd_init("iftest", stderr, debuglevel);
    
  if (addr == NULL &&
      (i = getaddrinfo("127.0.0.1", confd_port, &hints, &addr)) != 0)
    /* "Can't happen" */
    confd_fatal("%s: Failed to get address for ConfD: %s\n",
		argv[0], gai_strerror(i));
    
  OK(confd_load_schemas(addr->ai_addr, addr->ai_addrlen));
    
  check_type();
  return 0;
}
$ make all start
...
### * Setting configuration and running identityref test:
confd_cmd -d -d -c 'mset /myiftype "opticalChannel"'
mset "/myiftype" "opticalChannel"
CMD_MAAPI is true [mtid = 0]
TRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION  --> CONFD_OK
TRACE MAAPI_START_TRANS  --> CONFD_OK
TRACE MAAPI_SET_ELEM2 /myiftype --> CONFD_OK
TRACE MAAPI_APPLY_TRANS  --> CONFD_OK
TRACE MAAPI_STOP_TRANS  --> CONFD_OK
TRACE MAAPI_END_USER_SESSION  --> CONFD_OK
./check_idref -t
TRACE Connected (maapi) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_HASH_DB
TRACE Connected (cdb) to ConfD
TRACE CDB_NEW_SESSION  --> CONFD_OK
TRACE Established new CDB session to ConfD
ianaift:opticalChannel

Hi,

here are a simplified version of my get_elem

static int get_elem(struct confd_trans_ctx tctx, confd_hkeypath_t kp) {
SomeDataS
sd = (SomeDataS
)tctx->t_opaque;
struct confd_cs_node csp = confd_find_cs_node(kp, kp->len);
char path[255] = “”;
char
value=0;
confd_pp_kpath(path, 100, kp);
printf(“PATH: %s\n”,path);

sd->getValue(path,&value); // fetch the string from somewhere
printf("VALUE: %s\n",value);
if (CONFD_OK == confd_str2val(csp->info.type, value, &v)) {
                confd_data_reply_value(tctx, &v);
            } else {
                confd_data_reply_not_found(tctx);
            }
free(value);
return CONFD_OK;

}

This gives me

PATH: /interfaces/interface{client::if::client:1:2:1-2}/config/type
VALUE: ethernetCsmacd
trace from confd:
(idref<0>) --> CONFD_OK

when run on linux on pc

PATH: /interfaces/interface{client::if::client:1:2:1-2}/config/type
VALUE: ethernetCsmacd
trace from confd:
(ethernetCsmacd) --> CONFD_OK

So it looks like the string “ethernetCsmacd” is translated ok on x86 but not on ppc

Hi,
I cannot reproduce your issue.

What is the type of the v variable that you return in your confd_data_reply_value(tctx, &v); ? Where is it declared? Could there be a race condition in your code?

Can you run the below test / example on your powerpc and let me know what your output is?

$ cat Makefile | grep -B 4 "check_idref -t"
start:  stop 
	$(CONFD) -c ./confd.conf $(CONFD_FLAGS) 
	### * Setting configuration and running identityref test now:
	confd_cmd -d -d -c 'mcreate /interfaces/interface{"client::if::client:1:2:1-2"}; mset /interfaces/interface{"client::if::client:1:2:1-2"}/type "ethernetCsmacd"'
	./check_idref -t
$ cat check_idref.c
#include <netdb.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include <confd.h>
#include <confd_cdb.h>

#include "ietf-interfaces.h"

#define OK(cond) do {                                           \
    int _ret = (cond);						\
    if (_ret != CONFD_OK) {					\
      fprintf(stderr, "retval=%d errno=%d lasterr=%s\n",	\
	      _ret, confd_errno, confd_lasterr());		\
      assert(_ret == CONFD_OK);					\
    } } while (0)

static int debuglevel = CONFD_SILENT;
struct addrinfo *addr = NULL;

void check_type()
{
  confd_value_t v;
  char vv[BUFSIZ];
  struct confd_cs_node *csp, *root;
  int s;
  
  assert((s = socket(PF_INET, SOCK_STREAM, 0)) >= 0);
  OK(cdb_connect(s, CDB_DATA_SOCKET, addr->ai_addr, addr->ai_addrlen));
  OK(cdb_start_session(s, CDB_RUNNING));

  root = confd_find_cs_root(if__ns);
  csp = confd_cs_node_cd(root, "/interfaces/interface{\"client::if::client:1:2:1-2\"}/type");
  
  confd_str2val(csp->info.type, "ianaift:ethernetCsmacd", &v);
  confd_val2str(csp->info.type, &v, vv, sizeof(vv));
  printf("%s\n", vv);

  confd_free_value(&v);
  
  cdb_close(s);
}

int main(int argc, char **argv)
{
  int c, i;
  char confd_port[16];
  struct addrinfo hints;

  snprintf(confd_port, sizeof(confd_port), "%d", CONFD_PORT);
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = PF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
    
  while ((c = getopt(argc, argv, "dtp")) != -1) {
    switch (c) {
    case 'd':
      debuglevel = CONFD_DEBUG;
      break;
    case 't':
      debuglevel = CONFD_TRACE;
      break;
    case 'p':
      debuglevel = CONFD_PROTO_TRACE;
      break;
    default:
      fprintf(stderr,
	      "Usage: %s [-dtp]\n",
	      argv[0]);
      exit(1);
    }
  }
  confd_init("iftest", stderr, debuglevel);
    
  if (addr == NULL &&
      (i = getaddrinfo("127.0.0.1", confd_port, &hints, &addr)) != 0)
    /* "Can't happen" */
    confd_fatal("%s: Failed to get address for ConfD: %s\n",
		argv[0], gai_strerror(i));
    
  OK(confd_load_schemas(addr->ai_addr, addr->ai_addrlen));
    
  check_type();
  return 0;
}
$ make all start
...
### * Setting configuration and running identityref test now:
confd_cmd -d -d -c 'mcreate /interfaces/interface{"client::if::client:1:2:1-2"}; mset /interfaces/interface{"client::if::client:1:2:1-2"}/type "ethernetCsmacd"'
mcreate "/interfaces/interface{"client::if::client:1:2:1-2"}" ; mset "/interfaces/interface{"client::if::client:1:2:1-2"}/type" "ethernetCsmacd"
CMD_MAAPI is true [mtid = 0]
TRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION  --> CONFD_OK
TRACE MAAPI_START_TRANS  --> CONFD_OK
TRACE MAAPI_CREATE /interfaces/interface{"client::if::client:1:2:1-2"} --> CONFD_OK
CMD_MAAPI is true [mtid = 7]
TRACE MAAPI_SET_ELEM2 /interfaces/interface{"client::if::client:1:2:1-2"}/type --> CONFD_OK
TRACE MAAPI_APPLY_TRANS  --> CONFD_OK
TRACE MAAPI_STOP_TRANS  --> CONFD_OK
TRACE MAAPI_END_USER_SESSION  --> CONFD_OK
./check_idref -t
TRACE Connected (maapi) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_HASH_DB
TRACE Connected (cdb) to ConfD
TRACE CDB_NEW_SESSION  --> CONFD_OK
TRACE Established new CDB session to ConfD
ianaift:ethernetCsmacd

When we run this on the target environment the output is:
TRACE Connected (maapi) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_HASH_DB
TRACE Connected (cdb) to ConfD
TRACE CDB_NEW_SESSION --> CONFD_OK
TRACE Established new CDB session to ConfD
DEBUG Invalid value for type

Output from x86 target:
TRACE Connected (maapi) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_HASH_DB
TRACE Connected (cdb) to ConfD
TRACE CDB_NEW_SESSION --> CONFD_OK
TRACE Established new CDB session to ConfD
ianaift:ethernetCsmacd

****** XML- data from cdb (snippet) from target:



client::if::client:1:2:1-2
ianaift:ethernetCsmacd


Could not dump the ‘confd --status’ from target. Tailf forum would not allow me to post the output. “too many links”???

Hi,

You can use for example the formatting button "</>" to indicate that this is just code or raw text.

</> confd --status
vsn: 6.2
SMP support: no
Using epoll: no
available modules: backplane,netconf,cdb,cli,snmp,webui
running modules: backplane,netconf,cdb,cli
status: started
namespaces: urn:ietf:params:xml:ns:yang:iana-crypt-hash prefix:ianach exported to: all
            urn:ietf:params:xml:ns:yang:iana-if-type prefix:ianaift exported to: all
            urn:ietf:params:xml:ns:yang:ietf-inet-types prefix:inet exported to: all
            urn:ietf:params:xml:ns:yang:ietf-interfaces prefix:if exported to: all
            urn:ietf:params:xml:ns:yang:ietf-netconf-acm prefix:nacm exported to: all
            urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring prefix:ncm exported to: all
            urn:ietf:params:xml:ns:yang:ietf-netconf-notifications prefix:ncn exported to: all
            urn:ietf:params:xml:ns:yang:ietf-yang-library prefix:yanglib exported to: netconf,restconf
            urn:ietf:params:xml:ns:yang:ietf-yang-types prefix:yang exported to: all
            http://openconfig.net/yang/interfaces/ethernet prefix:oc-eth exported to: all
            http://openconfig.net/yang/interfaces prefix:oc-if exported to: all
            http://openconfig.net/yang/platform prefix:oc-platform exported to: all
            http://openconfig.net/yang/platform/transceiver prefix:oc-transceiver exported to: all
            http://openconfig.net/yang/platform-types prefix:oc-platform-types exported to: all
            http://openconfig.net/yang/terminal-device prefix:oc-opt-term exported to: all
            http://openconfig.net/yang/transport-types prefix:oc-opt-types exported to: all
            http://openconfig.net/yang/openconfig-types prefix:oc-types exported to: all
            http://tail-f.com/ns/aaa/1.1 prefix:aaa exported to: all
            http://tail-f.com/yang/acm prefix:tacm exported to: all
            http://tail-f.com/yang/common-monitoring prefix:tfcg exported to: all
            http://tail-f.com/yang/confd-monitoring prefix:tfcm exported to: all
            http://tail-f.com/ns/kicker prefix:kicker exported to: all
            http://tail-f.com/yang/netconf-monitoring prefix:tncm exported to: all
            http://tail-f.com/ns/webui prefix:webui exported to: all

YANG data models: 
  module: iana-crypt-hash revision: 2014-04-04
    namespace: urn:ietf:params:xml:ns:yang:iana-crypt-hash
    prefix: ianach
    exported to: all
  module: iana-if-type revision: 2014-05-08
    namespace: urn:ietf:params:xml:ns:yang:iana-if-type
    prefix: ianaift
    exported to: all
  module: ietf-inet-types revision: 2013-07-15
    namespace: urn:ietf:params:xml:ns:yang:ietf-inet-types
    prefix: inet
    exported to: all
  module: ietf-interfaces revision: 2014-05-08
    namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces
    prefix: if
    exported to: all
  module: ietf-netconf-acm revision: 2012-02-22
    namespace: urn:ietf:params:xml:ns:yang:ietf-netconf-acm
    prefix: nacm
    exported to: all
  module: ietf-netconf-monitoring revision: 2010-10-04
    namespace: urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring
    prefix: ncm
    exported to: all
  module: ietf-netconf-notifications revision: 2012-02-06
    namespace: urn:ietf:params:xml:ns:yang:ietf-netconf-notifications
    prefix: ncn
    exported to: all
  module: ietf-yang-library revision: 2016-04-09
    namespace: urn:ietf:params:xml:ns:yang:ietf-yang-library
    prefix: yanglib
    exported to: netconf,restconf
  module: ietf-yang-types revision: 2013-07-15
    namespace: urn:ietf:params:xml:ns:yang:ietf-yang-types
    prefix: yang
    exported to: all
  module: openconfig-if-ethernet revision: 2016-05-26
    namespace: http://openconfig.net/yang/interfaces/ethernet
    prefix: oc-eth
    exported to: all
  module: openconfig-interfaces revision: 2016-05-26
    namespace: http://openconfig.net/yang/interfaces
    prefix: oc-if
    exported to: all
  module: openconfig-platform revision: 2016-06-06
    namespace: http://openconfig.net/yang/platform
    prefix: oc-platform
    exported to: all
  module: openconfig-platform-transceiver revision: 2016-05-24
    namespace: http://openconfig.net/yang/platform/transceiver
    prefix: oc-transceiver
    exported to: all
  module: openconfig-platform-types revision: 2016-06-06
    namespace: http://openconfig.net/yang/platform-types
    prefix: oc-platform-types
    exported to: all
  module: openconfig-terminal-device revision: 2016-05-31
    namespace: http://openconfig.net/yang/terminal-device
    prefix: oc-opt-term
    exported to: all
  module: openconfig-transport-types revision: 2016-05-31
    namespace: http://openconfig.net/yang/transport-types
    prefix: oc-opt-types
    exported to: all
  module: openconfig-types revision: 2016-05-31
    namespace: http://openconfig.net/yang/openconfig-types
    prefix: oc-types
    exported to: all
  module: tailf-aaa revision: 2015-06-16
    namespace: http://tail-f.com/ns/aaa/1.1
    prefix: aaa
    exported to: all
  module: tailf-acm revision: 2013-03-07
    namespace: http://tail-f.com/yang/acm
    prefix: tacm
    exported to: all
  module: tailf-common-monitoring revision: 2013-06-14
    namespace: http://tail-f.com/yang/common-monitoring
    prefix: tfcg
    exported to: all
  module: tailf-confd-monitoring revision: 2013-06-14
    namespace: http://tail-f.com/yang/confd-monitoring
    prefix: tfcm
    exported to: all
  module: tailf-kicker revision: 2016-05-03
    namespace: http://tail-f.com/ns/kicker
    prefix: kicker
    exported to: all
  module: tailf-netconf-monitoring revision: 2014-11-13
    namespace: http://tail-f.com/yang/netconf-monitoring
    prefix: tncm
    exported to: all
  module: tailf-webui revision: 2013-03-07
    namespace: http://tail-f.com/ns/webui
    prefix: webui
    exported to: all

user sessions:
  
callpoints:

validation points:

actionpoints:

typepoints:

notification stream replay support:

SNMP inform delivery callbacks:

SNMP notification subscriptions:

authentication callback:
  not enabled

authorization callbacks:
  not enabled

error formatting callbacks:

partial running locks: 

partial candidate locks: 

partial startup locks: 

cdb:
  current transaction id: 1473-671510-187545
  running:
      filename: /opt/appl/cuappl03a-r28a-160912ag1/var/lib/lumentis/cuappl03a-r28a-160912ag1/confd/cdb/A.cdb
      disk size: 1.3 kB
      ram size: 5.0 kB
      read locks: 0
      write lock: unset
  operational:
      filename: /opt/appl/cuappl03a-r28a-160912ag1/var/lib/lumentis/cuappl03a-r28a-160912ag1/confd/cdb/O.cdb
      disk size: 4 bytes
      ram size: 72 bytes
      subscription lock: unset
  no pending subscription notifications
  no registered cdb clients

tts alloc:
  11539 20:6:4 36:160:0 40:10:10 64:5:1 96:11:12
</>
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
  <interface>
    <name>client::if::client:1:2:1-2</name>
    <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>
  </interface>
</interfaces>

So the error occurs in libconfd, i.e. the C-API library that is linked with your application, not in the ConfD daemon.
You have the full source code for libconfd.
If you rebuilt the libconfd c-library check your build.
See libconfd/src/confd_lib.c “confd_val2str()” and libconfd/src/confd_type.c “confd_idref_val_to_str()”

Can you add a printf() after confd_str2val() in the test application? I.e.:

$ diff -u ../idreftest_old/check_idref.c ./check_idref.c
--- ../idreftest_old/check_idref.c	2016-09-08 15:39:36.000000000 +0200
+++ ./check_idref.c	2016-09-14 13:06:58.000000000 +0200
@@ -34,6 +34,7 @@
   csp = confd_cs_node_cd(root, "/interfaces/interface{\"client::if::client:1:2:1-2\"}/type");
   
   confd_str2val(csp->info.type, "ianaift:ethernetCsmacd", &v);
+  printf("v.type = %d v.val.idref.ns %d v.val.idref.id %d\n",v.type, v.val.idref.ns, v.val.idref.id);
   confd_val2str(csp->info.type, &v, vv, sizeof(vv));
   printf("%s\n", vv);

This is the result on my PPC target, what is the result on your PPC?:

### * Setting configuration and running identityref test now:
confd_cmd -d -d -c 'mcreate /interfaces/interface{"client::if::client:1:2:1-2"}; mset /interfaces/interface{"client::if::client:1:2:1-2"}/type "ethernetCsmacd"'
mcreate "/interfaces/interface{"client::if::client:1:2:1-2"}" ; mset "/interfaces/interface{"client::if::client:1:2:1-2"}/type" "ethernetCsmacd"
CMD_MAAPI is true [mtid = 0]
TRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION --> CONFD_OK
TRACE MAAPI_START_TRANS --> CONFD_OK
TRACE MAAPI_CREATE /interfaces/interface{"client::if::client:1:2:1-2"} --> CONFD_OK
CMD_MAAPI is true [mtid = 7]
TRACE MAAPI_SET_ELEM2 /interfaces/interface{"client::if::client:1:2:1-2"}/type --> CONFD_OK
TRACE MAAPI_APPLY_TRANS --> CONFD_OK
TRACE MAAPI_STOP_TRANS --> CONFD_OK
TRACE MAAPI_END_USER_SESSION --> CONFD_OK
./check_idref -t
TRACE Connected (maapi) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_HASH_DB
TRACE Connected (cdb) to ConfD
TRACE CDB_NEW_SESSION --> CONFD_OK
TRACE Established new CDB session to ConfD
v.type = 44 v.val.idref.ns 366334446 v.val.idref.id 748937053
ianaift:ethernetCsmacd

After rebuilding the libconfd lib with the softfloat compiler for our powerpc target it seems to work.

How do I free struct confd_cs_node *csp ;
I don’t see any free api for the same… above examples will lead to memory leak…

“csp” is a pointer to the schema that was previously loaded using confd_load_schemas().
You can do a confd_free_schemas() but you probably want to keep the schema loaded while running your application.
See also the confd_types(3) man page under
“USING SCHEMA INFORMATION” and the ConfD UG under “Advanced Topics” --> “Using shared memory for schema information”