]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: end of map factoring
authorEric Leblond <eric@regit.org>
Sun, 24 Dec 2017 15:17:19 +0000 (16:17 +0100)
committerEric Leblond <eric@regit.org>
Tue, 6 Feb 2018 15:58:18 +0000 (16:58 +0100)
src/source-af-packet.c
src/source-af-packet.h

index 2fcad222387c6ac39afed1c19b0d1660b8a74c16..80719aa382d5fd25b334afe85fba4291715f2e63 100644 (file)
@@ -2313,6 +2313,9 @@ static int AFPBypassCallback(Packet *p)
     }
     if (PKT_IS_IPV4(p)) {
         SCLogDebug("add an IPv4");
+        if (p->afp_v.v4_map_fd == -1) {
+            return 0;
+        }
         struct flowv4_keys key = {};
         key.src = htonl(GET_IPV4_SRC_ADDR_U32(p));
         key.dst = htonl(GET_IPV4_DST_ADDR_U32(p));
@@ -2336,6 +2339,9 @@ static int AFPBypassCallback(Packet *p)
     if (PKT_IS_IPV6(p) && 
         ((IPV6_GET_NH(p) == IPPROTO_TCP) || (IPV6_GET_NH(p) == IPPROTO_UDP))) {
         int i;
+        if (p->afp_v.v6_map_fd == -1) {
+            return 0;
+        }
         SCLogDebug("add an IPv6");
         struct flowv6_keys key = {};
         for (i = 0; i < 4; i++) {
@@ -2385,6 +2391,9 @@ static int AFPXDPBypassCallback(Packet *p)
     }
     if (PKT_IS_IPV4(p)) {
         struct flowv4_keys key = {};
+        if (p->afp_v.v4_map_fd == -1) {
+            return 0;
+        }
         key.src = GET_IPV4_SRC_ADDR_U32(p);
         key.dst = GET_IPV4_DST_ADDR_U32(p);
         /* FIXME htons or not depending of XDP and af_packet eBPF */
@@ -2407,6 +2416,9 @@ static int AFPXDPBypassCallback(Packet *p)
     if (PKT_IS_IPV6(p) && 
         ((IPV6_GET_NH(p) == IPPROTO_TCP) || (IPV6_GET_NH(p) == IPPROTO_UDP))) {
         SCLogDebug("add an IPv6");
+        if (p->afp_v.v6_map_fd == -1) {
+            return 0;
+        }
         int i;
         struct flowv6_keys key = {};
         for (i = 0; i < 4; i++) {
index 2beae12b5004511e63d374c3249386340810064a..e6db995349b72754e1ecdbc2295acb451c3defd0 100644 (file)
@@ -144,6 +144,8 @@ typedef struct AFPPacketVars_
     (afpv)->copy_mode = 0;                \
     (afpv)->peer = NULL;                  \
     (afpv)->mpeer = NULL;                 \
+    (afpv)->v4_map_fd = -1;               \
+    (afpv)->v6_map_fd = -1;               \
 } while(0)
 
 /**