From d0dd9ebfea593948352a1a7ac438ff417e4323e0 Mon Sep 17 00:00:00 2001 From: Afschin Hormozdiary Date: Fri, 17 May 2013 09:38:26 +0200 Subject: libnetfilter_conntrack: don't ignore ATTR_CONNLABELS The libnfnetlink based backend 'build.c' currently ignores ATTR_CONNLABELS and ATTR_CONNLABELS_MASK. The libmnl based backend 'build_mnl.c' instead handles both attributes correct. Add function to set CTA_LABELS and CTA_LABELS_MASK if required. Signed-off-by: Afschin Hormozdiary Signed-off-by: Florian Westphal --- src/conntrack/parse.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/conntrack/parse.c') diff --git a/src/conntrack/parse.c b/src/conntrack/parse.c index 6096e8d..cb185d0 100644 --- a/src/conntrack/parse.c +++ b/src/conntrack/parse.c @@ -8,6 +8,7 @@ */ #include "internal/internal.h" +#include #include static void __parse_ip(const struct nfattr *attr, @@ -476,6 +477,26 @@ __parse_timestamp(const struct nfattr *attr, struct nf_conntrack *ct) } } +static void +__parse_labels(const struct nfattr *attr, struct nf_conntrack *ct) +{ + struct nfattr *tb[CTA_LABELS]; + struct nfct_bitmask *mask; + uint16_t len = NFA_PAYLOAD(tb[CTA_LABELS-1]); + + nfnl_parse_nested(tb, CTA_LABELS, attr); + if (tb[CTA_LABELS-1]) { + mask = nfct_bitmask_new((len * CHAR_BIT) - 1); + if (!mask) + return; + + if (len) + memcpy(mask->bits, NFA_DATA(tb[CTA_LABELS-1]), len); + + set_bit(ATTR_CONNLABELS, ct->head.set); + } +} + void __parse_conntrack(const struct nlmsghdr *nlh, struct nfattr *cda[], struct nf_conntrack *ct) @@ -564,4 +585,7 @@ void __parse_conntrack(const struct nlmsghdr *nlh, if (cda[CTA_TIMESTAMP-1]) __parse_timestamp(cda[CTA_TIMESTAMP-1], ct); + + if (cda[CTA_LABELS-1]) + __parse_labels(cda[CTA_LABELS-1], ct); } -- cgit v1.2.3