Skip to content

Commit

Permalink
fix packet-length reporting in psample and pcap; handle startup race-…
Browse files Browse the repository at this point in the history
…condition in psample
  • Loading branch information
sflow committed Nov 22, 2019
1 parent 7c2b913 commit 53b02da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Linux/mod_pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extern "C" {
14 /* mac len */,
buf + 14 /* payload */,
hdr->caplen - 14, /* length of captured payload */
hdr->len, /* length of packet (pdu) */
hdr->len - 14, /* length of packet (pdu) */
bpfs->drops, /* droppedSamples */
bpfs->samplingRate);
}
Expand Down
7 changes: 6 additions & 1 deletion src/Linux/mod_psample.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ extern "C" {
// so we can know for sure if this was ingress or egress sampled.
// Assume ingress-sampling for now.
SFLAdaptor *samplerDev = inDev;
if(!samplerDev) {
// handle startup race-condition where interface has not been discovered yet
myDebug(2, "psample: unknown ifindex %u (startup race-condition?)", ifin);
return;
}

// See if the sample_n matches what we think was configured
HSPAdaptorNIO *nio = ADAPTOR_NIO(samplerDev);
Expand Down Expand Up @@ -287,7 +292,7 @@ extern "C" {
14, // mac hdr len
pkt + 14, // payload
pkt_len - 14, // captured payload len
pkt_len, // whole pdu len
pkt_len - 14, // whole pdu len
drops,
this_sample_n);
}
Expand Down

0 comments on commit 53b02da

Please sign in to comment.