Skip to content
Snippets Groups Projects
Commit f023c1e8 authored by Neal Cardwell's avatar Neal Cardwell
Browse files

net-test: packetdrill encap support: free unknown sniffed packets

When we sniff an unknown packet, free it and allocate another packet
at the top of the sniffing loop. Previously we were not clearing state
after parsing an unknown packet, so state from the unkbown packet
could linger on, co-mingling with state from the next sniffed packet.


Change-Id: Ia9a330766969b114fd6084a087ff3f0d6b11d9d4
parent d0e56fdd
No related branches found
No related tags found
No related merge requests found
...@@ -380,28 +380,31 @@ int netdev_receive_loop(struct packet_socket *psock, ...@@ -380,28 +380,31 @@ int netdev_receive_loop(struct packet_socket *psock,
char **error) char **error)
{ {
assert(*packet == NULL); /* should be no packet yet */ assert(*packet == NULL); /* should be no packet yet */
*packet = packet_new(PACKET_READ_BYTES);
while (1) { while (1) {
int in_bytes = 0; int in_bytes = 0;
enum packet_parse_result_t result; enum packet_parse_result_t result;
*packet = packet_new(PACKET_READ_BYTES);
/* Sniff the next outbound packet from the kernel under test. */ /* Sniff the next outbound packet from the kernel under test. */
if (packet_socket_receive(psock, DIRECTION_OUTBOUND, if (packet_socket_receive(psock, DIRECTION_OUTBOUND,
*packet, &in_bytes)) *packet, &in_bytes))
continue; continue;
result = parse_packet(*packet, in_bytes, layer, error); result = parse_packet(*packet, in_bytes, layer, error);
if (result == PACKET_OK) {
if (result == PACKET_OK)
return STATUS_OK; return STATUS_OK;
} else if (result == PACKET_BAD) {
packet_free(*packet); packet_free(*packet);
*packet = NULL; *packet = NULL;
if (result == PACKET_BAD)
return STATUS_ERR; return STATUS_ERR;
} else {
DEBUGP("parse_result:%d; error parsing packet: %s\n", DEBUGP("parse_result:%d; error parsing packet: %s\n",
result, *error); result, *error);
}
} }
assert(!"should not be reached"); assert(!"should not be reached");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment