Don't crash when adding second interface to default namespace.

Namespace members used to be char[], now they are vectors. Using
strlen on a default value for these vectors results in a segmentation
fault.

Use vec_cmp instead. While at it, fix the output format to be %v.
This commit is contained in:
Paul Komkoff
2021-10-08 01:24:47 +04:00
committed by Paul Komkoff
parent 92e3835cbe
commit b72707d560

View File

@ -407,11 +407,10 @@ lcp_nl_pair_add_cb (lcp_itf_pair_t *lip)
nm->nl_ns.clib_file_lcp_refcnt); nm->nl_ns.clib_file_lcp_refcnt);
if ((nm->nl_ns.clib_file_lcp_refcnt > 0) && if ((nm->nl_ns.clib_file_lcp_refcnt > 0) &&
clib_memcmp ((char *) nm->nl_ns.netns_name, (char *) lip->lip_namespace, vec_cmp(nm->nl_ns.netns_name, lip->lip_namespace))
strlen ((char *) lip->lip_namespace)))
{ {
NL_WARN ("pair_add_cb: Existing netlink listener for netns %s -- this " NL_WARN ("pair_add_cb: Existing netlink listener for netns %v -- this "
"itf-pair is in netns %s, will not be listened!", "itf-pair is in netns %v, will not be listened!",
nm->nl_ns.netns_name, lip->lip_namespace); nm->nl_ns.netns_name, lip->lip_namespace);
return; return;
} }