netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Thomas Graf <tgraf@suug.ch>
Cc: Linux Netdev List <netdev@vger.kernel.org>,
	Netfilter Development Mailinglist
	<netfilter-devel@vger.kernel.org>
Subject: libnl: nfqueue: add nfqueue specific socket allocation function
Date: Thu, 23 Oct 2008 13:47:08 +0200	[thread overview]
Message-ID: <4900643C.6000501@trash.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1957 bytes --]

commit e92539843a0c7e5116254382626cce226bf2135e
Author: Patrick McHardy <kaber@trash.net>
Date:   Thu Oct 23 13:46:16 2008 +0200

    libnl: nfqueue: add nfqueue specific socket allocation function
    
    nfqueue users usually send verdict messages from the receive callback.
    When waiting for ACKs, the receive callback might be called again
    recursively until the stack blows up.
    
    Add a nfqueue specific socket allocation function that automatically
    disables ACKing for the socket.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/netlink/netfilter/queue.h b/include/netlink/netfilter/queue.h
index 491b361..664610d 100644
--- a/include/netlink/netfilter/queue.h
+++ b/include/netlink/netfilter/queue.h
@@ -31,6 +31,8 @@ enum nfnl_queue_copy_mode {
 };
 
 /* General */
+extern struct nl_sock *		nfnl_queue_socket_alloc(void);
+
 extern struct nfnl_queue *	nfnl_queue_alloc(void);
 
 extern void			nfnl_queue_get(struct nfnl_queue *);
diff --git a/lib/netfilter/queue.c b/lib/netfilter/queue.c
index 8d3c7ce..ff1de0e 100644
--- a/lib/netfilter/queue.c
+++ b/lib/netfilter/queue.c
@@ -24,6 +24,16 @@
 #include <netlink/netfilter/nfnl.h>
 #include <netlink/netfilter/queue.h>
 
+struct nl_sock *nfnl_queue_socket_alloc(void)
+{
+	struct nl_sock *nlsk;
+
+	nlsk = nl_socket_alloc();
+	if (nlsk)
+		nl_socket_disable_auto_ack(nlsk);
+	return nlsk;
+}
+
 static int send_queue_request(struct nl_sock *sk, struct nl_msg *msg)
 {
 	int err;
diff --git a/src/nf-queue.c b/src/nf-queue.c
index 4e17f70..0ed9e69 100644
--- a/src/nf-queue.c
+++ b/src/nf-queue.c
@@ -47,7 +47,10 @@ int main(int argc, char *argv[])
 	int err = 1;
 	int family;
 
-	nf_sock = nlt_alloc_socket();
+	nf_sock = nfnl_queue_socket_alloc();
+	if (nf_sock == NULL)
+		fatal(ENOBUFS, "Unable to allocate netlink socket");
+
 	nl_disable_sequence_check(nf_sock);
 	nl_socket_modify_cb(nf_sock, NL_CB_VALID, NL_CB_CUSTOM, event_input, NULL);
 

             reply	other threads:[~2008-10-23 11:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-23 11:47 Patrick McHardy [this message]
2008-10-23 12:01 ` libnl: nfqueue: add nfqueue specific socket allocation function Thomas Graf

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=4900643C.6000501@trash.net \
    --to=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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).