]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
netmap: fix enabling promisc mode on FreeBSD
authorVictor Julien <victor@inliniac.net>
Sat, 11 Jun 2016 14:12:26 +0000 (16:12 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 20 Jun 2016 15:57:59 +0000 (17:57 +0200)
In FreeBSD setting the IFF_PROMISC flag has no effect. Instead we
need to set the IFF_PPROMISC flag.

src/source-netmap.c

index b9ce7a843f9474e4e029ca581234da3b6608b75a..738da5af13e302bdc07bf74671349e937e5a8af0 100644 (file)
@@ -133,6 +133,11 @@ TmEcode NoNetmapSupportExit(ThreadVars *tv, void *initdata, void **data)
 
 #if defined(__linux__)
 #define POLL_EVENTS (POLLHUP|POLLRDHUP|POLLERR|POLLNVAL)
+
+#ifndef IFF_PPROMISC
+#define IFF_PPROMISC IFF_PROMISC
+#endif
+
 #else
 #define POLL_EVENTS (POLLHUP|POLLERR|POLLNVAL)
 #endif
@@ -438,8 +443,9 @@ static int NetmapOpen(char *ifname, int promisc, NetmapDevice **pdevice, int ver
         close(if_fd);
         goto error_fd;
     }
-    if (promisc) {
-        if_flags |= IFF_PROMISC;
+    /* if needed, try to set iface in promisc mode */
+    if (promisc && (if_flags & (IFF_PROMISC|IFF_PPROMISC)) == 0) {
+        if_flags |= IFF_PPROMISC;
         NetmapSetIfaceFlags(if_fd, ifname, if_flags);
     }