diff --git a/gtests/net/packetdrill/packet.c b/gtests/net/packetdrill/packet.c index c52bb14392420bb92cce00bf91595676ab23fe6d..b1810ff1a9b5f3c290977800cde316b6e457689a 100644 --- a/gtests/net/packetdrill/packet.c +++ b/gtests/net/packetdrill/packet.c @@ -102,6 +102,7 @@ struct header *packet_append_header(struct packet *packet, { struct header *header = NULL; int num_headers = packet_header_count(packet); + int packet_bytes; assert(num_headers <= PACKET_MAX_HEADERS); if (num_headers == PACKET_MAX_HEADERS) @@ -111,7 +112,8 @@ struct header *packet_append_header(struct packet *packet, if (packet->ip_bytes + header_bytes > packet->buffer_bytes) return NULL; - header->h.ptr = packet->buffer + packet->ip_bytes; + packet_bytes = packet->l2_header_bytes + packet->ip_bytes; + header->h.ptr = packet->buffer + packet_bytes; packet->ip_bytes += header_bytes; header->type = header_type; diff --git a/gtests/net/packetdrill/packet.h b/gtests/net/packetdrill/packet.h index 4ca1059ad703af646c7fe4e1c3dc42425db4e938..83869bcfae03f205ec5876f41bf208768f8ff642 100644 --- a/gtests/net/packetdrill/packet.h +++ b/gtests/net/packetdrill/packet.h @@ -69,7 +69,8 @@ static const int PACKET_READ_BYTES = 64 * 1024; struct packet { u8 *buffer; /* data buffer: full contents of packet */ u32 buffer_bytes; /* bytes of space in data buffer */ - u32 ip_bytes; /* bytes on wire: outermost IP hdrs/payload */ + u32 l2_header_bytes; /* bytes in outer hardware/layer-2 header */ + u32 ip_bytes; /* bytes in outermost IP hdrs/payload */ enum direction_t direction; /* direction packet is traveling */ /* Metadata about all the headers in the packet, including all diff --git a/gtests/net/packetdrill/packet_parser.c b/gtests/net/packetdrill/packet_parser.c index ff64dedb7fd000afdb0cc9f737b4749fb21eea31..1b4d631d368d2efff3e8f153c0a904322e52a6ce 100644 --- a/gtests/net/packetdrill/packet_parser.c +++ b/gtests/net/packetdrill/packet_parser.c @@ -71,6 +71,7 @@ static int parse_layer2_packet(struct packet *packet, } ether = (struct ether_header *)p; p += sizeof(*ether); + packet->l2_header_bytes = sizeof(*ether); return parse_layer3_packet_by_proto(packet, ntohs(ether->ether_type), p, packet_end, error);