diff --git a/pkg/flow/deduper.go b/pkg/flow/deduper.go index a80c6255c85f655767e9558b22973ead1f810a4b..de505c1f4d8a2cc8ad1f1d2a44c9b9c10516a91d 100644 --- a/pkg/flow/deduper.go +++ b/pkg/flow/deduper.go @@ -67,6 +67,7 @@ func (c *deduperCache) isDupe(key *RecordKey) bool { // zeroes fields from key that should be ignored from the flow comparison rk.IFIndex = 0 rk.DataLink = DataLink{} + rk.Direction = 0 // If a flow has been accounted previously, whatever its interface was, // it updates the expiry time for that flow if ele, ok := c.ifaces[rk]; ok { diff --git a/pkg/flow/deduper_test.go b/pkg/flow/deduper_test.go index f2dff9825266d2dd1ffd063d448ecf67f3aa15f3..7f3176ffc3b5d913ae39dd8d2617aa20b6e1f953 100644 --- a/pkg/flow/deduper_test.go +++ b/pkg/flow/deduper_test.go @@ -21,7 +21,7 @@ var ( }, RecordMetrics: RecordMetrics{ Packets: 2, Bytes: 456, }}, Interface: "123456789"} - // another fow from 2 different interfaces + // another fow from 2 different interfaces and directions twoIf1 = &Record{RawRecord: RawRecord{RecordKey: RecordKey{ EthProtocol: 1, Direction: 1, Transport: Transport{SrcPort: 333, DstPort: 456}, DataLink: DataLink{DstMac: MacAddr{0x1}, SrcMac: MacAddr{0x1}}, IFIndex: 1, @@ -29,7 +29,7 @@ var ( Packets: 2, Bytes: 456, }}, Interface: "eth0"} twoIf2 = &Record{RawRecord: RawRecord{RecordKey: RecordKey{ - EthProtocol: 1, Direction: 1, Transport: Transport{SrcPort: 333, DstPort: 456}, + EthProtocol: 1, Direction: 0, Transport: Transport{SrcPort: 333, DstPort: 456}, DataLink: DataLink{DstMac: MacAddr{0x2}, SrcMac: MacAddr{0x2}}, IFIndex: 2, }, RecordMetrics: RecordMetrics{ Packets: 2, Bytes: 456,