From: Victor Julien Date: Sat, 11 Jun 2016 14:12:26 +0000 (+0200) Subject: netmap: fix enabling promisc mode on FreeBSD X-Git-Tag: suricata-3.1.1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1d191b478bf6d90ae4971fd30fbe14a63dd036a;p=thirdparty%2Fsuricata.git netmap: fix enabling promisc mode on FreeBSD In FreeBSD setting the IFF_PROMISC flag has no effect. Instead we need to set the IFF_PPROMISC flag. --- diff --git a/src/source-netmap.c b/src/source-netmap.c index b9ce7a843f..738da5af13 100644 --- a/src/source-netmap.c +++ b/src/source-netmap.c @@ -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); }