Skip to content

Commit

Permalink
bugfix in VXLAN decode
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Sep 18, 2023
1 parent 6c3a17c commit 391de23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Linux/mod_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ extern "C" {
UTArray *samples; // HSPPendingSample
SFLAddress src;
SFLAddress dst;
uint16_t sport;
uint16_t dport;
bool flipped:1;
bool udp:1;
struct inet_diag_req_v2 conn_req;
Expand Down Expand Up @@ -182,9 +184,11 @@ extern "C" {
static char *tcpSamplePrint(HSPTCPSample *ts) {
static char buf[128];
char ip1[51],ip2[51];
snprintf(buf, 128, "TCPSample: %s - %s samples:%u %s",
snprintf(buf, 128, "TCPSample: %s:%u - %s:%u samples:%u %s",
SFLAddress_print(&ts->src, ip1, 50),
ts->sport,
SFLAddress_print(&ts->dst, ip2, 50),
ts->dport,
UTArrayN(ts->samples),
ts->flipped ? "FLIPPED": "");
return buf;
Expand Down Expand Up @@ -664,6 +668,8 @@ extern "C" {
}
}
// L4 ports
tcpSample->sport = sport;
tcpSample->dport = dport;
if(localSrc) {
sockid->idiag_sport = htons(sport);
sockid->idiag_dport = htons(dport);
Expand Down
2 changes: 1 addition & 1 deletion src/Linux/readPackets.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ extern "C" {
}

static void decodePendingSample_vxlan(HSPPendingSample *ps) {
int ip_offset_1 = ps->l4_offset + 8 /* udp */ + 8 /* vxlan */ + 12 /* inner MAC */;
int ip_offset_1 = ps->l4_offset + 8 /* udp */ + 8 /* vxlan */ + 14 /* inner MAC */;
if(ps->ipproto == IPPROTO_UDP
&& ps->hdr_len >= ip_offset_1) {
// Check for VXLAN(4789|8472) header at l4_offset,
Expand Down

0 comments on commit 391de23

Please sign in to comment.