]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
af-packet: fix error handling in bypass case
authorEric Leblond <eric@regit.org>
Sun, 7 Jan 2018 12:15:37 +0000 (13:15 +0100)
committerEric Leblond <eric@regit.org>
Tue, 6 Feb 2018 15:58:19 +0000 (16:58 +0100)
If the key is already in the hash table then the bypass is
succesful.

src/source-af-packet.c

index 6ad15e5ff18f8992927fe12c9460cb6a178ef102..79d0d8cedd5546e06c34b43aaad4337ed036bda6 100644 (file)
@@ -2279,9 +2279,13 @@ static int AFPInsertHalfFlow(int mapd, void *key, uint64_t inittime)
     SCLogDebug("Inserting element in eBPF mapping: %lu", inittime);
     if (bpf_map_update_elem(mapd, key, value, BPF_NOEXIST) != 0) {
         switch (errno) {
+            /* no more place in the hash */
             case E2BIG:
-            case EEXIST:
                 return 0;
+            /* if we already have the key then bypass is a success */
+            case EEXIST:
+                return 1;
+            /* Not supposed to be there so issue a error */
             default:
                 SCLogError(SC_ERR_BPF, "Can't update eBPF map: %s (%d)",
                         strerror(errno),