From: Patrick McHardy <kaber@trash.net>
To: netfilter-devel@vger.kernel.org, linux-audit@redhat.com,
Eric Paris <eparis@parisplace.org>,
Al Viro <viro@ZenIV.linux.org.uk>
Subject: Re: [PATCH] netfilter: audit target to record accepted/dropped packets
Date: Fri, 14 Jan 2011 16:46:03 +0100 [thread overview]
Message-ID: <4D306FBB.8020705@trash.net> (raw)
In-Reply-To: <20110114152024.GA9654@canuck.infradead.org>
On 14.01.2011 16:20, Thomas Graf wrote:
> +static unsigned int
> +audit_tg(struct sk_buff *skb, const struct xt_action_param *par)
> +{
> + const struct xt_AUDIT_info *info = par->targinfo;
> + struct audit_buffer *ab;
> +
> + ab = audit_log_start(NULL, GFP_ATOMIC, AUDIT_NETFILTER_PKT);
> + if (ab == NULL)
> + goto errout;
> +
> + audit_log_format(ab, "action=%u hook=%u len=%u inif=%s outif=%s",
> + info->type, par->hooknum, skb->len,
> + par->in ? par->in->name : "?",
> + par->out ? par->out->name : "?");
> +
> + if (skb->mark)
> + audit_log_format(ab, " mark=%#x", skb->mark);
> +
> + switch (skb->dev->type) {
This won't work in the AF_INET/LOCAL_OUT hook, skb->dev is set just
before the packet is handed to the POST_ROUTING hook. The ethernet
header is also only present on incoming packets.
> + case ARPHRD_ETHER:
> + audit_log_format(ab, " smac=%pM dmac=%pM macproto=0x%04x",
> + eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
> + ntohs(eth_hdr(skb)->h_proto));
> +
> + if (par->family == NFPROTO_BRIDGE) {
> + switch (eth_hdr(skb)->h_proto) {
> + case __constant_htons(ETH_P_IP):
> + audit_ip4(ab, skb);
> + break;
> +
> + case __constant_htons(ETH_P_IPV6):
> + audit_ip6(ab, skb);
> + break;
> + }
> + }
> + break;
> + }
> +
> + switch (par->family) {
> + case NFPROTO_IPV4:
> + audit_ip4(ab, skb);
> + break;
> +
> + case NFPROTO_IPV6:
> + audit_ip6(ab, skb);
> + break;
> + }
> +
> + audit_log_end(ab);
> +
> +errout:
> + return XT_CONTINUE;
> +}
> +
next prev parent reply other threads:[~2011-01-14 15:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-14 15:20 [PATCH] netfilter: audit target to record accepted/dropped packets Thomas Graf
2011-01-14 15:26 ` Eric Paris
2011-01-14 15:31 ` Jan Engelhardt
2011-01-14 15:37 ` Thomas Graf
2011-01-14 15:46 ` Patrick McHardy [this message]
2011-01-14 16:19 ` Thomas Graf
2011-01-14 16:49 ` Jan Engelhardt
2011-01-14 16:59 ` [PATCHv2] " Thomas Graf
2011-01-14 17:29 ` Jan Engelhardt
2011-01-14 22:22 ` Thomas Graf
2011-01-14 23:10 ` Michał Mirosław
2011-01-14 23:19 ` Jan Engelhardt
2011-01-14 23:16 ` Jan Engelhardt
2011-01-14 22:24 ` [PATCHv3] " Thomas Graf
2011-01-14 23:48 ` [PATCHv4] " Thomas Graf
2011-01-15 16:07 ` Patrick McHardy
2011-01-16 17:12 ` [PATCHv3] " Patrick McHardy
2011-01-14 18:51 ` [PATCHv2] " Mr Dash Four
2011-01-14 19:18 ` Jan Engelhardt
2011-01-14 19:24 ` Eric Paris
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=4D306FBB.8020705@trash.net \
--to=kaber@trash.net \
--cc=eparis@parisplace.org \
--cc=linux-audit@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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).