From: Florian Westphal <fw@strlen.de>
To: netfilter-devel <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH RFC v2] netfilter: add connlabel conntrack extension
Date: Wed, 7 Nov 2012 21:04:28 +0100 [thread overview]
Message-ID: <20121107200427.GB12876@breakpoint.cc> (raw)
In-Reply-To: <1351860231-5434-1-git-send-email-fw@strlen.de>
Florian Westphal <fw@strlen.de> wrote:
> Further plans:
> - extend ctnetlink to send a label bit-vector to userspace, or
> remove/attach labels from/to connections.
I've implemented this via CTA_LABELS attribute, which
is a unsigned long[] blob; each bit set indicates that the
connlabel is set on the given connection.
CTA_LABELS is sent to userspace via ctnetlink, it may also be
used to replace the labels currently assigned to a connection
by sending request with CTA_LABELS attribute set to the kernel.
> This would also require extending libnetfilter_conntrack to provide
> some meaningful abstraction; I'll send a separate email with an API
> proposal before working on this, though.
I propose to add following API calls:
int nfct_label_set(struct nf_conntrack *ct, const char *label);
sets the label 'label' on the ct object.
void nfct_label_unset(struct nf_conntrack *ct, const char *label);
opposite, label is cleared if it was set.
int nfct_label_get_max(const struct nf_conntrack *ct);
returns the highest label-bit currently set on the connection,
or -1 if none is set.
int nfct_label_get(const struct nf_conntrack *ct, int bit, char *buf,
size_t len);
fills buf (up to size len) with the name of the label identified
by 'bit', if it is currently set on the conntrack.
returns -1 on error (i.e., label was not set), else length of the name.
Can be used together with nfct_label_get_max() to iterate over all the
labels set on the object, e.g. something like
for i = 0; i < nfct_label_get_max(ct); i++
if (nfct_label_get(ct, i, buf, len) > 0)
printf("label: %s (bit %d)\n", buf, i);
open question is how the library should do the mapping, i.e.
should it hard-code a path to the mapping file (currently
its /etc/xtables/connlabel.conf in my iptables-patch).
I think exposing it makes no sense since noone could know
where the file would be located on a given system.
Also, should we add calls to iterate of the entire set of
configured labels, e.g. something like
void *nfct_label_open(void);
void nfct_label_close(void *);
int nfct_label_iterate(void *fp, char *buf, size_t buflen);
so you could do
void *h = nfct_label_open();
int bit;
while ((bit = nfct_label_iterate(h, bufm sizeof(buf))) > 0)
printf("bit %d: %s\n", bit, buf);
?
If there are no objections/suggestions i'll have a stab at adding
this to libnetfilter_conntrack.
Thanks,
Florian
next prev parent reply other threads:[~2012-11-07 20:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-02 12:43 [PATCH RFC v2] netfilter: add connlabel conntrack extension Florian Westphal
2012-11-07 20:04 ` Florian Westphal [this message]
2012-11-12 6:44 ` Pablo Neira Ayuso
2012-11-12 12:30 ` Florian Westphal
2012-11-12 16:24 ` Pablo Neira Ayuso
2012-11-12 16:32 ` Florian Westphal
2012-11-12 19:02 ` Pablo Neira Ayuso
2012-11-12 6:50 ` Pablo Neira Ayuso
2012-11-12 12:47 ` Florian Westphal
2012-11-15 12:13 ` Pablo Neira Ayuso
2012-11-15 12:50 ` Florian Westphal
2012-11-15 13:09 ` Pablo Neira Ayuso
2012-11-15 12:52 ` Stephen Clark
2012-11-15 13:06 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121107200427.GB12876@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).