From 22c8af6991eab12a87fec4f06559e1d7ea3826f1 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Fri, 14 Dec 2012 12:42:48 +0100 Subject: api: add CTA_LABEL_MASK attribute handling allows to set/clear only a subset of the in-kernel label set, e.g. "set bit 1 and do not change any others". Signed-off-by: Florian Westphal --- src/conntrack/setter.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/conntrack/setter.c') diff --git a/src/conntrack/setter.c b/src/conntrack/setter.c index 8879f02..4dda6c9 100644 --- a/src/conntrack/setter.c +++ b/src/conntrack/setter.c @@ -421,16 +421,26 @@ retry: } static void -set_attr_connlabels(struct nf_conntrack *ct, const void *value, size_t len) +do_set_attr_connlabels(struct nfct_bitmask *current, const void *value) { - if (ct->connlabels == value) - return; + if (current && current != value) + nfct_bitmask_destroy(current); +} - if (ct->connlabels) - nfct_bitmask_destroy(ct->connlabels); +static void +set_attr_connlabels(struct nf_conntrack *ct, const void *value, size_t len) +{ + do_set_attr_connlabels(ct->connlabels, value); ct->connlabels = (void *) value; } +static void +set_attr_connlabels_mask(struct nf_conntrack *ct, const void *value, size_t len) +{ + do_set_attr_connlabels(ct->connlabels_mask, value); + ct->connlabels_mask = (void *) value; +} + static void set_attr_do_nothing(struct nf_conntrack *ct, const void *value, size_t len) {} @@ -502,4 +512,5 @@ const set_attr set_attr_array[ATTR_MAX] = { [ATTR_TIMESTAMP_STOP] = set_attr_do_nothing, [ATTR_HELPER_INFO] = set_attr_helper_info, [ATTR_CONNLABELS] = set_attr_connlabels, + [ATTR_CONNLABELS_MASK] = set_attr_connlabels_mask, }; -- cgit v1.2.3