Update network state tables if state is older than given packet

This commit is contained in:
Daniel
2023-08-18 16:52:15 +02:00
parent f3e7abf908
commit 6f9fce39bb
5 changed files with 27 additions and 5 deletions

View File

@@ -35,6 +35,11 @@ func Exists(pktInfo *packet.Info, now time.Time) (exists bool) {
}
func (table *tcpTable) exists(pktInfo *packet.Info) (exists bool) {
// Update tables if older than the connection that is checked.
if table.lastUpdateAt.Load() < pktInfo.SeenAt.UnixNano() {
table.updateTables(table.updateIter.Load())
}
table.lock.RLock()
defer table.lock.RUnlock()
@@ -57,6 +62,11 @@ func (table *tcpTable) exists(pktInfo *packet.Info) (exists bool) {
}
func (table *udpTable) exists(pktInfo *packet.Info, now time.Time) (exists bool) {
// Update tables if older than the connection that is checked.
if table.lastUpdateAt.Load() < pktInfo.SeenAt.UnixNano() {
table.updateTables(table.updateIter.Load())
}
table.lock.RLock()
defer table.lock.RUnlock()