From: Eric Leblond Date: Sun, 24 Dec 2017 15:17:19 +0000 (+0100) Subject: af-packet: end of map factoring X-Git-Tag: suricata-4.1.0-beta1~211 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eff10fce1054257a46349904bc043edd38bcea72;p=thirdparty%2Fsuricata.git af-packet: end of map factoring --- diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 2fcad22238..80719aa382 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -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++) { diff --git a/src/source-af-packet.h b/src/source-af-packet.h index 2beae12b50..e6db995349 100644 --- a/src/source-af-packet.h +++ b/src/source-af-packet.h @@ -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) /**