From: Eric Leblond Date: Wed, 9 Mar 2016 13:29:19 +0000 (+0100) Subject: af-packet: don't check GRO LRO on non ethernet X-Git-Tag: suricata-3.0.1RC1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7bf299e3bc285e751fa3c396292d35cd37c0cc1;p=thirdparty%2Fsuricata.git af-packet: don't check GRO LRO on non ethernet This way we avoid an error message when sniffing on a non Ethernet device. --- diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index 3d3b6cdeca..e561559a93 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -370,9 +370,17 @@ void *ParseAFPConfig(const char *iface) } } - if (GetIfaceOffloading(iface) == 1) { - SCLogWarning(SC_ERR_AFP_CREATE, - "Using AF_PACKET with GRO or LRO activated can lead to capture problems"); + + int ltype = AFPGetLinkType(iface); + switch (ltype) { + case LINKTYPE_ETHERNET: + if (GetIfaceOffloading(iface) == 1) { + SCLogWarning(SC_ERR_AFP_CREATE, + "Using AF_PACKET with GRO or LRO activated can lead to capture problems"); + } + case -1: + default: + break; } char *active_runmode = RunmodeGetActive(); diff --git a/src/source-af-packet.c b/src/source-af-packet.c index f5b0ea399b..2beb17037c 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -1314,6 +1314,22 @@ static int AFPGetDevLinktype(int fd, const char *ifname) } } +int AFPGetLinkType(const char *ifname) +{ + int ltype; + + int fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + if (fd == -1) { + SCLogError(SC_ERR_AFP_CREATE, "Couldn't create a AF_PACKET socket, error %s", strerror(errno)); + return LINKTYPE_RAW; + } + + ltype = AFPGetDevLinktype(fd, ifname); + close(fd); + + return ltype; +} + static int AFPComputeRingParams(AFPThreadVars *ptv, int order) { /* Compute structure: diff --git a/src/source-af-packet.h b/src/source-af-packet.h index 61f4e69ea0..86ad97bba6 100644 --- a/src/source-af-packet.h +++ b/src/source-af-packet.h @@ -132,6 +132,6 @@ void TmModuleDecodeAFPRegister (void); TmEcode AFPPeersListInit(); TmEcode AFPPeersListCheck(); void AFPPeersListClean(); - +int AFPGetLinkType(const char *ifname); #endif /* __SOURCE_AFP_H__ */