af-packet: end of map factoring

pull/3221/head
Eric Leblond 8 years ago
parent d65f45856c
commit eff10fce10

@ -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++) {

@ -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)
/**

Loading…
Cancel
Save