From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Yigal Reiss (yreiss)" <yreiss@cisco.com>
Cc: "'netdev@vger.kernel.org'" <netdev@vger.kernel.org>,
"netfilter-devel@vger.kernel.org"
<netfilter-devel@vger.kernel.org>,
"Florian Westphal (fw@strlen.de)" <fw@strlen.de>
Subject: Re: [PATCH net-next] change nfqueue failopen to apply also to receive message buffer in addition to queue size
Date: Mon, 21 Mar 2016 22:35:32 +0100 [thread overview]
Message-ID: <20160321213532.GA1818@salvia> (raw)
In-Reply-To: <2ba8dceec36a41149598e43f09af048e@XCH-RTP-014.cisco.com>
[-- Attachment #1: Type: text/plain, Size: 1493 bytes --]
On Mon, Mar 21, 2016 at 11:23:43AM +0000, Yigal Reiss (yreiss) wrote:
> @@ -582,10 +585,17 @@ __nfqnl_enqueue_packet(struct net *net, struct nfqnl_instance *queue,
> *packet_id_ptr = htonl(entry->id);
>
> /* nfnetlink_unicast will either free the nskb or add it to a socket */
> - err = nfnetlink_unicast(nskb, net, queue->peer_portid, MSG_DONTWAIT);
> + err = nfnetlink_unicast_nofree(nskb, net, queue->peer_portid, MSG_DONTWAIT);
This keeps nskb around, this skbuff contains the netlink message, not
the network packet itself that is located in entry->skb.
> if (err < 0) {
> - queue->queue_user_dropped++;
> - goto err_out_unlock;
> + if (queue->flags & NFQA_CFG_F_FAIL_OPEN) {
> + queue->nobuf_failopened++;
> + failopen = 1;
> + err = 0;
In case we couldn't deliver due to socket buffer overrun, if the
NFQA_CFG_F_FAIL_OPEN flag is set, you set failopen to 1.
> + }
> + else {
> + queue->queue_user_dropped++;
> + }
> + goto err_out_free_nskb;
And finally, jump to err_out_free_nskb.
> }
>
> __enqueue_entry(queue, entry);
> @@ -595,7 +605,6 @@ __nfqnl_enqueue_packet(struct net *net, struct nfqnl_instance *queue,
>
> err_out_free_nskb:
> kfree_skb(nskb);
Which just releases the netlink skbuff.
> -err_out_unlock:
> spin_unlock_bh(&queue->lock);
> if (failopen)
> nf_reinject(entry, NF_ACCEPT);
And reinjects the packet.
So isn't the more simple patch that I'm attaching achieving what you need?
Let me know, thanks.
[-- Attachment #2: x.patch --]
[-- Type: text/x-diff, Size: 628 bytes --]
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 7542999..cb5b630 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -582,7 +582,12 @@ __nfqnl_enqueue_packet(struct net *net, struct nfqnl_instance *queue,
/* nfnetlink_unicast will either free the nskb or add it to a socket */
err = nfnetlink_unicast(nskb, net, queue->peer_portid, MSG_DONTWAIT);
if (err < 0) {
- queue->queue_user_dropped++;
+ if (queue->flags & NFQA_CFG_F_FAIL_OPEN) {
+ failopen = 1;
+ err = 0;
+ } else {
+ queue->queue_user_dropped++;
+ }
goto err_out_unlock;
}
next prev parent reply other threads:[~2016-03-21 21:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-21 11:23 [PATCH net-next] change nfqueue failopen to apply also to receive message buffer in addition to queue size Yigal Reiss (yreiss)
2016-03-21 12:22 ` Florian Westphal
2016-03-23 12:04 ` Yigal Reiss (yreiss)
2016-03-23 12:28 ` enhancing nfnetlink stats [was Re: [PATCH net-next] change nfqueue failopen to apply also to receive message buffer in addition to queue size] Pablo Neira Ayuso
2016-03-21 21:35 ` Pablo Neira Ayuso [this message]
2016-03-23 11:40 ` [PATCH net-next] change nfqueue failopen to apply also to receive message buffer in addition to queue size Yigal Reiss (yreiss)
2016-03-23 11:58 ` 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=20160321213532.GA1818@salvia \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=yreiss@cisco.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).