From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Romain Francoise <romain@orebokech.com>
Cc: Patrick McHardy <kaber@trash.net>,
netfilter-devel@vger.kernel.org, netfilter@vger.kernel.org,
coreteam@netfilter.org, Joe Perches <joe@perches.com>,
Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
eric.dumazet@gmail.com
Subject: Re: [PATCH] netfilter: xt_LOG: avoid using old-style "<.>" printk prefix
Date: Wed, 12 Sep 2012 14:48:26 +0200 [thread overview]
Message-ID: <20120912124826.GA12726@1984> (raw)
In-Reply-To: <874nn5dbx9.fsf@silenus.orebokech.com>
Hi,
CC'ing Joe Perches and Eric Dumazet, they are discussing a similar
patch.
Would you be OK with the prink_emit variant to solve this? (Once
several issues are resolved).
On Mon, Sep 10, 2012 at 07:29:06PM +0200, Romain Francoise wrote:
> Since commit 04d2c8c83d ("printk: convert the format for KERN_<LEVEL> to
> a 2 byte pattern"), printk no longer uses a "<.>" string prefix
> internally, so the call in xt_LOG ends up emitting the prefix as part of
> the log itself (and possibly not at the configured level).
>
> To avoid having to worry about printk's internal formatting, switch to
> printk_emit(), specifying the desired level directly.
ebt_log chunk is missing.
> Signed-off-by: Romain Francoise <romain@orebokech.com>
> ---
> include/net/netfilter/xt_log.h | 7 +++++--
> net/netfilter/xt_LOG.c | 6 +++++-
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/netfilter/xt_log.h b/include/net/netfilter/xt_log.h
> index 9d9756c..343f5bb 100644
> --- a/include/net/netfilter/xt_log.h
> +++ b/include/net/netfilter/xt_log.h
> @@ -39,11 +39,14 @@ static struct sbuff *sb_open(void)
> return m;
> }
>
> -static void sb_close(struct sbuff *m)
> +static void sb_emit(struct sbuff *m, int level)
> {
> m->buf[m->count] = 0;
> - printk("%s\n", m->buf);
> + printk_emit(0, level, NULL, 0, "%s\n", m->buf);
I think it should be printk_emit(-1, ... Note facility is -1.
Thus, we skip the syslog prefix stripping (we can skip it and save
some cycles).
> +}
>
> +static void sb_close(struct sbuff *m)
> +{
> if (likely(m != &emergency))
> kfree(m);
> else {
> diff --git a/net/netfilter/xt_LOG.c b/net/netfilter/xt_LOG.c
> index ff5f75f..d33ff9f 100644
> --- a/net/netfilter/xt_LOG.c
> +++ b/net/netfilter/xt_LOG.c
> @@ -436,7 +436,7 @@ log_packet_common(struct sbuff *m,
> const struct nf_loginfo *loginfo,
> const char *prefix)
> {
> - sb_add(m, "<%d>%sIN=%s OUT=%s ", loginfo->u.log.level,
> + sb_add(m, "%sIN=%s OUT=%s ",
> prefix,
> in ? in->name : "",
> out ? out->name : "");
> @@ -477,6 +477,8 @@ ipt_log_packet(u_int8_t pf,
>
> dump_ipv4_packet(m, loginfo, skb, 0);
>
> + sb_emit(m, loginfo->u.log.level);
> +
> sb_close(m);
> }
>
> @@ -807,6 +809,8 @@ ip6t_log_packet(u_int8_t pf,
>
> dump_ipv6_packet(m, loginfo, skb, skb_network_offset(skb), 1);
>
> + sb_emit(m, loginfo->u.log.level);
> +
> sb_close(m);
> }
> #endif
> --
> 1.7.10.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-09-12 12:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-10 17:29 [PATCH] netfilter: xt_LOG: avoid using old-style "<.>" printk prefix Romain Francoise
2012-09-12 12:48 ` Pablo Neira Ayuso [this message]
2012-09-12 13:29 ` Romain Francoise
2012-09-12 15: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=20120912124826.GA12726@1984 \
--to=pablo@netfilter.org \
--cc=akpm@linux-foundation.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=joe@perches.com \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=netfilter@vger.kernel.org \
--cc=romain@orebokech.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.