netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Liping Zhang <zlpnobody@gmail.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Liping Zhang <zlpnobody@163.com>,
	netfilter-devel@vger.kernel.org,
	Liping Zhang <liping.zhang@spreadtrum.com>
Subject: Re: [PATCH nf-next 3/3] netfilter: nft_log: fix snaplen does not truncate packets
Date: Wed, 20 Jul 2016 17:00:45 +0800	[thread overview]
Message-ID: <CAML_gOd8bYutiMoqAD74vpUh5vGYLWPNN-7Hoz3aAFL7-K6rXw@mail.gmail.com> (raw)
In-Reply-To: <20160720082521.GA1336@salvia>

Hi Pablo,

2016-07-20 16:25 GMT+08:00 Pablo Neira Ayuso <pablo@netfilter.org>:
> On Wed, Jul 20, 2016 at 07:00:13AM +0800, Liping Zhang wrote:
>> I find that nftables already support this feature, the following command mean to truncate packets
>> to 100 bytes before logging to the userspace:
>>   #nft add rule filter input log group 0 snaplen 100
>>
>> Before my patch, it does not work.
>> And after apply my patch, it works as expected.
>
> If I git grep NF_LOG_F_COPY_LEN from the nftables.git tree, I don't
> see any reference to this flag being set.
>

I use this NF_LOG_F_COPY_LEN flag as internal, and when the user specify
the NFTA_LOG_SNAPLEN attrribute, it will be enabled automatically.
See my codes:

               if (tb[NFTA_LOG_SNAPLEN] != NULL) {
+                       li->u.ulog.flags |= NF_LOG_F_COPY_LEN;

-               if (li->u.ulog.copy_len) {
+               if (li->u.ulog.flags & NF_LOG_F_COPY_LEN) {
                         if (nla_put_be32(skb, NFTA_LOG_SNAPLEN,
                                         htonl(li->u.ulog.copy_len)))

So this flag will not be setted from userspace explicitly and will not
be dumped to the userspace.

> Then, nft_log kernel has been actually working fine since the
> beginning. It would be good anyway if we set this flag on from
> userspace to leave things in consistent state.

Do you mean this is something similar to "nflog-size" and
"nflog-range" in xt_NFLOG?
"nft log snaplen 100" cannot work since the beginning, so we should
keep it unchanged? And
maybe we should introduce a new option like "nft log snapsize 100"?

  reply	other threads:[~2016-07-20  9:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 12:44 [PATCH nf-next 0/3] netfilter: fix some small bugs related to nft_log Liping Zhang
2016-07-18 12:44 ` [PATCH nf-next 1/3] netfilter: nft_log: fix possible memory leak if log expr init fail Liping Zhang
2016-07-19 18:13   ` Pablo Neira Ayuso
2016-07-18 12:44 ` [PATCH nf-next 2/3] netfilter: nft_log: check the validity of log level Liping Zhang
2016-07-19 18:14   ` Pablo Neira Ayuso
2016-07-18 12:44 ` [PATCH nf-next 3/3] netfilter: nft_log: fix snaplen does not truncate packets Liping Zhang
2016-07-19 18:16   ` Pablo Neira Ayuso
2016-07-19 23:00     ` Liping Zhang
2016-07-20  8:25       ` Pablo Neira Ayuso
2016-07-20  9:00         ` Liping Zhang [this message]
2016-07-20  9:07           ` 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=CAML_gOd8bYutiMoqAD74vpUh5vGYLWPNN-7Hoz3aAFL7-K6rXw@mail.gmail.com \
    --to=zlpnobody@gmail.com \
    --cc=liping.zhang@spreadtrum.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=zlpnobody@163.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 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).