]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
afp: nicer error message in case of fanout failure 4280/head
authorShivani Bhardwaj <shivanib134@gmail.com>
Mon, 7 Oct 2019 18:32:40 +0000 (00:02 +0530)
committerShivani Bhardwaj <shivanib134@gmail.com>
Mon, 7 Oct 2019 18:32:40 +0000 (00:02 +0530)
Use clearer message in case fanout is not supported or cluster_id is
already in use.

Closes redmine ticket #1940.

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

index 4e6400b9f5b283e585b025790a7f3e13744e4d13..05761a7882891d71986a3515df6843ebe3c52766 100644 (file)
@@ -613,7 +613,7 @@ finalize:
     /* if the number of threads is not 1, we need to first check if fanout
      * functions on this system. */
     if (aconf->threads != 1) {
-        if (AFPIsFanoutSupported() == 0) {
+        if (AFPIsFanoutSupported(aconf->cluster_id) == 0) {
             if (aconf->threads != 0) {
                 SCLogNotice("fanout not supported on this system, falling "
                         "back to 1 capture thread");
index e117d36e5c888e7748c2473144e13caad5aa6a58..712fe521eea253a7eebd109241c4da8f5b7a1ee4 100644 (file)
@@ -1995,7 +1995,7 @@ mmap_err:
 /** \brief test if we can use FANOUT. Older kernels like those in
  *         CentOS6 have HAVE_PACKET_FANOUT defined but fail to work
  */
-int AFPIsFanoutSupported(void)
+int AFPIsFanoutSupported(int cluster_id)
 {
 #ifdef HAVE_PACKET_FANOUT
     int fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
@@ -2009,7 +2009,8 @@ int AFPIsFanoutSupported(void)
     close(fd);
 
     if (r < 0) {
-        SCLogPerf("fanout not supported by kernel: %s", strerror(errno));
+        SCLogError(SC_ERR_INVALID_VALUE, "fanout not supported by kernel: "
+                "Kernel too old or cluster-id %d already in use.", cluster_id);
         return 0;
     }
     return 1;
index af3b36b2045229affeb8fc708229be39fe521e16..0468e4b2ffff576b259b4f4d6877aa879102676d 100644 (file)
@@ -186,6 +186,7 @@ TmEcode AFPPeersListCheck(void);
 void AFPPeersListClean(void);
 int AFPGetLinkType(const char *ifname);
 
-int AFPIsFanoutSupported(void);
+int AFPIsFanoutSupported(int cluster_id);
+
 
 #endif /* __SOURCE_AFP_H__ */