--- nfqnl_test.original.c 2009-02-17 20:27:28.000000000 +0100 +++ nfqnl_test.c 2010-11-05 11:24:26.000000000 +0100 @@ -8,6 +8,8 @@ #include +#include + /* returns packet id */ static u_int32_t print_pkt (struct nfq_data *tb) { @@ -115,9 +117,21 @@ fd = nfq_fd(h); - while ((rv = recv(fd, buf, sizeof(buf), 0)) && rv >= 0) { - printf("pkt received\n"); - nfq_handle_packet(h, buf, rv); + for (;;) { + if ((rv = recv(fd, buf, sizeof(buf), 0)) >= 0) { + printf("pkt received\n"); + nfq_handle_packet(h, buf, rv); + continue; + } + /* if the computer is slower than the network the buffer + * may fill up. Depending on the application, this error + * may be ignored */ + if (errno == ENOBUFS) { + printf("pkt lost!!\n"); + continue; + } + printf("recv failed: errno=%d (%s)\n", + errno, strerror(errno)); } printf("unbinding from queue 0\n");