From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Pierre Chifflier <chifflier@edenwall.com>
Cc: netfilter-devel@vger.kernel.org, eleblond@edenwall.com
Subject: Re: [PATCH 1/2] Add new input plugin UNIXSOCK
Date: Sun, 28 Feb 2010 17:28:38 +0100 [thread overview]
Message-ID: <4B8A99B6.5080708@netfilter.org> (raw)
In-Reply-To: <20100228140655.GC16135@piche.inl.fr>
Hi Pierre,
Pierre Chifflier wrote:
> Thanks for the review. I have fixed almost every points you have
> mentioned, there are only a few points to discuss.
Thanks.
>> BTW, how does the "big picture" of this look like? I guess that your
>> nufw daemon is listening to packets via libnetfilter_queue and then it
>> sends unixsock messages that include the packet + extra authentication
>> information to ulogd2 to log them, right?
>
> Yes. We use ulogd as a central point for logging information, since
> packets (and decision) can come either from iptables (for non-user
> rules) or from the nufw+nuauth chain (for user filtering rules).
> When logging from nufw, we use the unixsock message to include the
> original packet (so the standard code from ulogd2 will be used) and add
> our additional information (user, application, etc).
>
> nflog + (drop|accept)
> / \
> netfilter ulogd2
> \ /
> (nfq) nufw --> nuauth
Interesting, I have a feeling that it was similar to this ;-).
> Yet this code has nothing specific to nufw, it can be used by any
> application to inject data with extra information.
I think so, but they would need to add new input keys to store that new
extra information or use the _NUFW_ keys. We can add a comment after the
_NUFW_ telling something that "add your new keys here".
>> could this be extended in the future to support flow-based information?
>> I mean, does this really fit into the "packet" directory of ulogd2?
>
> Well, I don't have any fixed opinion on this. If you want I can move
> this plugin to the flow directory (in some way it is similar to IPFIX).
My question is if this plugin is specific for packet-logging. If so, the
packet/ directory is fine.
>>> + [UNIXSOCK_KEY_NUFW_USER_NAME] = {
>>> + .type = ULOGD_RET_STRING,
>>> + .flags = ULOGD_RETF_NONE,
>>> + .name = "nufw.user.name",
>>> + },
>> Could we define some more generic instead of NUFW? I know it's your
>> thing but others may benefit from these fields I guess, right?
>>
>> Well, this is not important anyway, I don't mind too much.
>
> Sure. Should I use something like 'EXTRA' instead of NUFW in the constants
> names ?
I don't mind too much, I leave it up to you.
> [...]
>>> +
>>> +#define unixpath_ce(x) ((x)->ces[0])
>>> +#define bufsize_ce(x) ((x)->ces[1])
>>> +#define perms_ce(x) ((x)->ces[2])
>>> +#define owner_ce(x) ((x)->ces[3])
>>> +#define group_ce(x) ((x)->ces[4])
>> I know that this is xyz_ce() macros are the "standard way" in ulogd2 but
>> it's ugly. I would do the following:
>>
>> enum {
>> UNIXSOCK_OPT_UNIXPATH = 0,
>> UNIXSOCK_OPT_BUFSIZE,
>> UNIXSOCK_OPT_PERM,
>> UNIXSOCK_OPT_OWNER,
>> UNIXSOCK_OPT_GROUP,
>> };
>>
>> Then, we can do the transition easily to several functions like:
>>
>> ulogd_option_get_str(UNIXSOCK_OPT_UNIXPATH, upi->config_kset);
>> ulogd_option_get_u32(UNIXSOCK_OPT_PERM, upi->config_kset);
>>
>> and so on... this is something that I had in my head. I'm not asking you
>> to do so but to tell you about my intentions. If we start defining the
>> enums now, we can do the transition in the near future.
>
> I'd like that too ! I've defined the enum (and kept the xyz_ce macros
> for now). If you want, I can add these functions in another patch ?
Sure, go ahead if you want :-).
[...]
>>> +
>>> +struct ulogd_unixsock_option_t {
>>> + uint16_t option_id;
>>> + uint16_t option_length;
>>> + char option_value[0];
>>> +} __attribute__((packed));
>>> +
>>> +#define ALIGN_SIZE 8
>> Minor question: why align this to 64 bits?
>
> I originally used an alignment to 32 bits, but Jan noticed it would
> break if using options/values on 64 bits (and a test confirmed that). I
> took 64 bits as the biggest allowed value for integers.
I would need to look into this in more detail, not sure where the
problem is. I think that you can use something like `struct nlattr' (see
include/linux/netlink.h) and then nla_put() to add attributes in the TLV
format (see lib/nlattr.c). Those are align-safe. I'm using something
similar for conntrackd for the synchronization messages (src/build.c and
src/parse.c).
> [...]
>>> +/* callback called from ulogd core when fd is readable */
>>> +static int unixsock_instance_read_cb(int fd, unsigned int what, void *param)
>>> +{
>>> + struct ulogd_pluginstance *upi = param;
>>> + struct unixsock_input *ui = (struct unixsock_input*)upi->private;
>>> + int len;
>>> + u_int16_t needed_len;
>>> + u_int32_t packet_sig;
>>> + struct ulogd_unixsock_packet_t *unixsock_packet;
>>> +
>>> + char buf[4096];
>>> +
>>> + if (!(what & ULOGD_FD_READ))
>>> + return 0;
>>> +
>>> + len = read(fd, buf, sizeof(buf));
>> Ah, looking at this, I think that it would be a good idea to ignore
>> SIGPIPE to avoid crashing ulogd2 if the other peer has gone.
> Yes, I didn't want to do that in the plugin itself. Can I put that in
> src/ulogd.c ?
Yes, you can add a comment in ulogd.c telling that at least UNIXSOCK
needs this so we don't forget ;).
next prev parent reply other threads:[~2010-02-28 16:28 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-26 20:54 [ULOGD2] UNIXSOCK plugin (v5) Pierre Chifflier
2010-02-26 20:54 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2010-02-27 13:55 ` Pablo Neira Ayuso
2010-02-28 14:06 ` Pierre Chifflier
2010-02-28 16:28 ` Pablo Neira Ayuso [this message]
2010-02-28 17:29 ` Jan Engelhardt
2010-02-28 18:05 ` Pierre Chifflier
2010-03-01 19:33 ` Pablo Neira Ayuso
2010-03-01 22:16 ` [ULOGD2] UNIXSOCK plugin (v6) Pierre Chifflier
2010-03-01 22:16 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2010-03-01 22:16 ` [PATCH 2/2] Add helper script pcap2ulog Pierre Chifflier
2010-03-03 17:42 ` [PATCH 1/2] Add new input plugin UNIXSOCK Jan Engelhardt
2010-03-03 18:14 ` Jan Engelhardt
2010-03-05 10:25 ` libnetfilter_conntrack alignment issue [was Re: [PATCH 1/2] Add new input plugin UNIXSOCK] Pablo Neira Ayuso
2010-03-07 19:30 ` Jan Engelhardt
2010-03-05 11:15 ` [PATCH 1/2] Add new input plugin UNIXSOCK Patrick McHardy
2010-03-05 17:10 ` Pablo Neira Ayuso
2010-03-08 11:13 ` Patrick McHardy
2010-02-26 20:54 ` [PATCH 2/2] Add helper script pcap2ulog Pierre Chifflier
2010-02-27 10:46 ` [ULOGD2] UNIXSOCK plugin (v5) Eric Leblond
-- strict thread matches above, loose matches on Subject: below --
2010-10-20 11:44 [ULOGD2] UNIXSOCK plugin (v5b) Pierre Chifflier
2010-10-20 11:44 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2010-01-14 19:41 [ULOGD2] UNIXSOCK plugin (v4) Pierre Chifflier
2010-01-14 19:41 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2009-11-01 10:53 [ULOGD2] UNIXSOCK plugin (v3) Pierre Chifflier
2009-11-01 10:53 ` [PATCH 1/2] Add new input plugin UNIXSOCK Pierre Chifflier
2009-11-01 12:45 ` Jan Engelhardt
2009-11-01 13:07 ` Pierre Chifflier
2009-11-01 13:41 ` Jan Engelhardt
2009-11-01 17:01 ` Pierre Chifflier
2009-11-02 6:22 ` David Miller
2009-11-03 17:01 ` Jan Engelhardt
2009-11-06 20:09 ` Pierre Chifflier
2009-11-09 13:09 ` Patrick McHardy
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=4B8A99B6.5080708@netfilter.org \
--to=pablo@netfilter.org \
--cc=chifflier@edenwall.com \
--cc=eleblond@edenwall.com \
--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).