]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: don't check GRO LRO on non ethernet 1917/head
authorEric Leblond <eric@regit.org>
Wed, 9 Mar 2016 13:29:19 +0000 (14:29 +0100)
committerEric Leblond <eric@regit.org>
Wed, 9 Mar 2016 15:58:52 +0000 (16:58 +0100)
This way we avoid an error message when sniffing on a non Ethernet
device.

src/runmode-af-packet.c
src/source-af-packet.c
src/source-af-packet.h

index 3d3b6cdeca0ae4cda1bacea9abd06077e2e05eed..e561559a93ba856193058e31712671fb392e7c0c 100644 (file)
@@ -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();
index f5b0ea399b315e529465ee59aa2665d4f2a23d77..2beb17037c72d29e3e0f4c13336802b207a44e2e 100644 (file)
@@ -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:
index 61f4e69ea0bc4dd926eaf4d59c0bc4ea30892f7a..86ad97bba6a7df9e43155eba16dc62938968e3f5 100644 (file)
@@ -132,6 +132,6 @@ void TmModuleDecodeAFPRegister (void);
 TmEcode AFPPeersListInit();
 TmEcode AFPPeersListCheck();
 void AFPPeersListClean();
-
+int AFPGetLinkType(const char *ifname);
 
 #endif /* __SOURCE_AFP_H__ */