Fix pfring so that zero-copy mode can work.

Detect when default_packet_size is zero, which enables zero-copy mode for
pfring and in that case, do what AF Packet does and set pkt_ext pointer to
the data and set PKT_ZERO_COPY flag.
pull/717/head
Ken Steele 12 years ago
parent f9705377ae
commit 882d98733f

@ -6536,8 +6536,8 @@ int SigTest24IPV4Keyword(void)
memset(&th_v, 0, sizeof(ThreadVars));
memset(p1, 0, SIZE_OF_PACKET);
memset(p2, 0, SIZE_OF_PACKET);
p1->ip4vars.comp_csum = -1;
p2->ip4vars.comp_csum = -1;
PACKET_RESET_CHECKSUMS(p1);
PACKET_RESET_CHECKSUMS(p2);
p1->ip4h = (IPV4Hdr *)valid_raw_ipv4;
@ -6640,8 +6640,8 @@ int SigTest25NegativeIPV4Keyword(void)
memset(&th_v, 0, sizeof(ThreadVars));
memset(p1, 0, SIZE_OF_PACKET);
memset(p2, 0, SIZE_OF_PACKET);
p1->ip4vars.comp_csum = -1;
p2->ip4vars.comp_csum = -1;
PACKET_RESET_CHECKSUMS(p1);
PACKET_RESET_CHECKSUMS(p2);
p1->ip4h = (IPV4Hdr *)valid_raw_ipv4;
@ -6861,9 +6861,7 @@ static int SigTest26TCPV4AndNegativeIPV4Keyword(void)
memset(&th_v, 0, sizeof(ThreadVars));
memset(p1, 0, SIZE_OF_PACKET);
p1->pkt = (uint8_t *)(p1 + 1);
memset(p2, 0, SIZE_OF_PACKET);
p2->pkt = (uint8_t *)(p2 + 1);
PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4));
PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp));
@ -6989,9 +6987,7 @@ static int SigTest26TCPV4AndIPV4Keyword(void)
memset(&th_v, 0, sizeof(ThreadVars));
memset(p1, 0, SIZE_OF_PACKET);
p1->pkt = (uint8_t *)(p1 + 1);
memset(p2, 0, SIZE_OF_PACKET);
p2->pkt = (uint8_t *)(p2 + 1);
PacketCopyData(p1, raw_ipv4, sizeof(raw_ipv4));
PacketCopyDataOffset(p1, GET_PKT_LEN(p1), valid_raw_tcp, sizeof(valid_raw_tcp));

@ -303,10 +303,17 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
/* Depending on what compile time options are used for pfring we either return 0 or -1 on error and always 1 for success */
#ifdef HAVE_PFRING_RECV_UCHAR
int r = pfring_recv(ptv->pd, (u_char**)&GET_PKT_DIRECT_DATA(p),
(u_int)GET_PKT_DIRECT_MAX_SIZE(p),
u_char *pkt_buffer = GET_PKT_DIRECT_DATA(p);
u_int buffer_size = GET_PKT_DIRECT_MAX_SIZE(p);
int r = pfring_recv(ptv->pd, &pkt_buffer,
buffer_size,
&hdr,
LIBPFRING_WAIT_FOR_INCOMING);
/* Check for Zero-copy if buffer size is zero */
if (buffer_size == 0) {
PacketSetData(p, pkt_buffer, hdr.caplen);
}
#else
int r = pfring_recv(ptv->pd, (char *)GET_PKT_DIRECT_DATA(p),
(u_int)GET_PKT_DIRECT_MAX_SIZE(p),

Loading…
Cancel
Save