netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vishwanath Pai <vpai@akamai.com>
To: pablo@netfilter.org, kaber@trash.net, kadlec@blackhole.kfki.hu,
	netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org, johunt@akamai.com,
	netdev@vger.kernel.org, pai.vishwain@gmail.com
Subject: [PATCH] netfilter/nflog: nflog-range does not truncate packets
Date: Wed, 1 Jun 2016 20:23:54 -0400	[thread overview]
Message-ID: <20160602002354.GG1644@akamai.com> (raw)

netfilter/nflog: nflog-range does not truncate packets

The --nflog-range parameter from userspace is ignored in the kernel and
the entire packet is sent to the userspace. The per-instance parameter
copy_range still works, with this change --nflog-range will have
preference over copy_range.

Signed-off-by: Vishwanath Pai <vpai@akamai.com>
Reviewed-by: Joshua Hunt <johunt@akamai.com>

diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 4ef1fae..f40ddba 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -680,7 +680,6 @@ nfulnl_log_packet(struct net *net,
 		if (qthreshold > li->u.ulog.qthreshold)
 			qthreshold = li->u.ulog.qthreshold;
 
-
 	switch (inst->copy_mode) {
 	case NFULNL_COPY_META:
 	case NFULNL_COPY_NONE:
@@ -688,10 +687,12 @@ nfulnl_log_packet(struct net *net,
 		break;
 
 	case NFULNL_COPY_PACKET:
-		if (inst->copy_range > skb->len)
+		data_len = inst->copy_range;
+		if (li->u.ulog.copy_len < data_len)
+			data_len = li->u.ulog.copy_len;
+
+		if (data_len > skb->len)
 			data_len = skb->len;
-		else
-			data_len = inst->copy_range;
 
 		size += nla_total_size(data_len);
 		break;

             reply	other threads:[~2016-06-02  0:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02  0:23 Vishwanath Pai [this message]
2016-06-06 22:31 ` [PATCH] netfilter/nflog: nflog-range does not truncate packets Pablo Neira Ayuso
2016-06-07 23:06   ` Vishwanath Pai
2016-06-08 12:16     ` Pablo Neira Ayuso
2016-06-09 17:57       ` Vishwanath Pai
2016-06-13  3:40         ` Vishwanath Pai
2016-06-15 12:39           ` Pablo Neira Ayuso
2016-06-15 14:55             ` Vishwanath Pai
2016-06-15 15:13               ` Lubashev, Igor
2016-06-17 11:22                 ` Pablo Neira Ayuso
2016-06-17 15:43                   ` Vishwanath Pai

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=20160602002354.GG1644@akamai.com \
    --to=vpai@akamai.com \
    --cc=coreteam@netfilter.org \
    --cc=johunt@akamai.com \
    --cc=kaber@trash.net \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=pai.vishwain@gmail.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).