DataDog / datadog-process-agent

Datadog Process Agent
https://datadoghq.com
20 stars 9 forks source link

[network-tracer] Fix underflows #276

Closed sfluor closed 5 years ago

sfluor commented 5 years ago

This removes substractions in isExpired to avoid having a negative uint64 hence wrapping and returning a wrong result.

This resulted in considering some connections as expired while they were not like:

get connections !
active conn [TCP] [PID: 20329] [127.0.0.1:41064 ⇄ 127.0.0.1:45938] (local) 1280101 bytes sent (+0), 573 bytes received (+0), 0 retransmits (+0)
get connections !
active conn [TCP] [PID: 20329] [127.0.0.1:41064 ⇄ 127.0.0.1:45938] (local) 1280101 bytes sent (+0), 573 bytes received (+0), 0 retransmits (+0)
get connections !
active conn [TCP] [PID: 20329] [127.0.0.1:41064 ⇄ 127.0.0.1:45938] (local) 1280101 bytes sent (+0), 573 bytes received (+0), 0 retransmits (+0)
get connections !
active conn [TCP] [PID: 20329] [127.0.0.1:41064 ⇄ 127.0.0.1:45938] (local) 1601310 bytes sent (+0), 622 bytes received (+0), 0 retransmits (+0)
get connections !
active conn [TCP] [PID: 20329] [127.0.0.1:41064 ⇄ 127.0.0.1:45938] (local) 1601310 bytes sent (+0), 622 bytes received (+0), 0 retransmits (+0)
get connections !
expired conn: &{saddr_h:0 saddr_l:16777343 daddr_h:0 daddr_l:16777343 sport:41064 dport:45938 netns:4026531957 pid:20329 metadata:1}

get connections !
active conn [TCP] [PID: 20329] [127.0.0.1:41064 ⇄ 127.0.0.1:45938] (local) 753528 bytes sent (+0), 782 bytes received (+0), 0 retransmits (+0)
Underflow occured ! stats: {totalSent:1601310 totalRecv:622 totalRetransmits:0 lastUpdateEpoch:585516629226535}, conn: [TCP] [PID: 20329] [127.0.0.1:41064 ⇄ 127.0.0.1:45938] (local) 753528 bytes sent (+0), 782 bytes received (+0), 0 retransmits (+0)
sunhay commented 5 years ago

Can we add some tests for this logic?