]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
utils: nfsynproxy: fix error while compiling the BPF filter
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 18 Nov 2013 18:06:06 +0000 (19:06 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 18 Nov 2013 18:34:01 +0000 (19:34 +0100)
Fix the following error while running nfsynproxy here:

 pcap_compile: not-yet-activated pcap_t passed to pcap_compile

According to what I have read, we have to compile the filter
once the pcap_t handle has been activated.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
utils/nfsynproxy.c

index 9b6de93bde364ef86365f5f1aaf9e7957959641f..baedc92c5d9fbb199b2d638b082e217afd9b0cf8 100644 (file)
@@ -109,20 +109,20 @@ static void probe_host(const char *host)
                goto err2;
        }
 
-       if (pcap_compile(ph, &fp, "src host 127.0.0.1 and tcp and src port 80",
-                        1, PCAP_NETMASK_UNKNOWN) == -1) {
-               pcap_perror(ph, "pcap_compile");
-               goto err2;
-       }
-
        if (pcap_setfilter(ph, &fp) == -1) {
                pcap_perror(ph, "pcap_setfilter");
-               goto err3;
+               goto err2;
        }
 
        if (pcap_activate(ph) != 0) {
                pcap_perror(ph, "pcap_activate");
-               goto err3;
+               goto err2;
+       }
+
+       if (pcap_compile(ph, &fp, "src host 127.0.0.1 and tcp and src port 80",
+                        1, PCAP_NETMASK_UNKNOWN) == -1) {
+               pcap_perror(ph, "pcap_compile");
+               goto err2;
        }
 
        fd = socket(AF_INET, SOCK_STREAM, 0);