Skip to content

Commit 741c469

Browse files
committed
ring: and int: now correctly recognise gretap interfaces
Previously, libtrace was trying to interpret these as raw IP but gretap actually delivers bridged Ethernet frames so the initial header is Ethernet, not IP.
1 parent 4dd5b86 commit 741c469

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

lib/format_linux_int.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,13 @@ linuxnative_get_link_type(const struct libtrace_packet_t *packet)
393393
uint16_t linktype =
394394
(((struct libtrace_linuxnative_header *)(packet->buffer))
395395
->hdr.sll_hatype);
396+
uint16_t proto =
397+
(((struct libtrace_linuxnative_header *)(packet->buffer))
398+
->hdr.sll_protocol);
399+
if (proto == htons(ETH_P_TEB)) {
400+
/* bridged Ethernet frame, regardless of the hatype */
401+
return TRACE_TYPE_ETH;
402+
}
396403
return linuxcommon_get_link_type(linktype);
397404
}
398405

lib/format_linux_ring.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ static libtrace_linktype_t
511511
linuxring_get_link_type(const struct libtrace_packet_t *packet)
512512
{
513513
uint16_t linktype = GET_SOCKADDR_HDR(packet->buffer)->sll_hatype;
514+
515+
if (GET_SOCKADDR_HDR(packet->buffer)->sll_protocol == htons(ETH_P_TEB)) {
516+
/* this is a GRE tunnel with a transparent Ethernet header */
517+
return TRACE_TYPE_ETH;
518+
}
514519
return linuxcommon_get_link_type(linktype);
515520
}
516521

0 commit comments

Comments
 (0)