conntrack: labels: skip labels with non-alnum characters

Can always lift this restriction later but for now enforce
strict label naming.

This is mainly  to make sure that e.g. using
conntrack ... -o xml,connlabels

will output the expected format, without nasty surprises.

Signed-off-by: Florian Westphal <fw@strlen.de>
src: callback: fix memory leak when ct has dynamically allocated attr

Must free ct and exp using the _destroy functions, else we leak attributes with malloc'd data.

Signed-off-by: Florian Westphal <fw@strlen.de>
conntrack: api: add nfct_snprintf_labels

nfct_snprintf doesn't print connlabels, as they're system specific
and can easily generate lots of output.

This adds a new helper function, nfct_snprintf_labels. It behaves like
nfct_snprintf, except that the label names in the labelmap whose bits are
contained in connlabel attribute bitset are added to the buffer.

output looks like this:
output looks like this:
... mark=0 use=1 labels=eth0-in,eth1-in
or
<labels>
<label>eth0-in</label>
<label>eth1-in</label>
</labels>

Signed-off-by: Florian Westphal <fw@strlen.de>
qa: test_connlabel: don't abort when system-wide config exists

Only dump the contents of the system-wide connlabel.conf if present
instead of expecting same content as the qa config.

Signed-off-by: Florian Westphal <fw@strlen.de>
conntrack: labels: labelmap_new: make sure errno is 0 when no labels are found

nfct_labelmap_new returns NULL on failure, e.g. when file cannot be
opened.  It will also fail if no labels have been parsed, and in this
case, content of errno is random.

Avoid it by making sure that errno is re-set when no labels were found.

While at it, also change ptr test when parsing so reviewers don't
need to triple check that this cannot result in out-of-bounds read.

Reported-by: Afschin Hormozdiary <Afschin.Hormozdiary@sophos.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
build: bump version to 1.0.4

also bump LIBVERSION, we've added new interfaces and retained
backwards compatibility.

Signed-off-by: Florian Westphal <fw@strlen.de>