]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
libnl: nfqueue: add nfqueue specific socket allocation function
authorPatrick McHardy <kaber@trash.net>
Thu, 23 Oct 2008 11:47:08 +0000 (13:47 +0200)
committerThomas Graf <tgr@plip.localdomain>
Thu, 23 Oct 2008 11:59:40 +0000 (13:59 +0200)
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>
include/netlink/netfilter/queue.h
lib/netfilter/queue.c
src/nf-queue.c

index 491b361dfb0f5e786447427badf0a3a87079eb57..664610db8c1d8a98838cc1e4c7818374de8a46dd 100644 (file)
@@ -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 *);
index 8d3c7ce9765de42b9c1811fb4921a6ed1d4f3328..ff1de0e07f24ab57fe9c3c1b73610aedd0eb25bb 100644 (file)
 #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;
index 4e17f70911046941409972bb30a26ad7cde75297..0ed9e69a40c948c69d39156cad74ce94b2479a53 100644 (file)
@@ -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);