88 "github.com/sirupsen/logrus"
99
1010 "github.com/netobserv/netobserv-ebpf-agent/pkg/ebpf"
11- "github.com/netobserv/netobserv-ebpf-agent/pkg/utils"
1211)
1312
1413var dlog = logrus .WithField ("component" , "flow/Deduper" )
@@ -40,7 +39,7 @@ type entry struct {
4039// (no activity for it during the expiration time)
4140// The justMark argument tells that the deduper should not drop the duplicate flows but
4241// set their Duplicate field.
43- func Dedupe (expireTime time.Duration , justMark , mergeDup bool ) func (in <- chan []* Record , out chan <- []* Record ) {
42+ func Dedupe (expireTime time.Duration , justMark , mergeDup bool , ifaceNamer InterfaceNamer ) func (in <- chan []* Record , out chan <- []* Record ) {
4443 cache := & deduperCache {
4544 expire : expireTime ,
4645 entries : list .New (),
@@ -51,7 +50,7 @@ func Dedupe(expireTime time.Duration, justMark, mergeDup bool) func(in <-chan []
5150 cache .removeExpired ()
5251 fwd := make ([]* Record , 0 , len (records ))
5352 for _ , record := range records {
54- cache .checkDupe (record , justMark , mergeDup , & fwd )
53+ cache .checkDupe (record , justMark , mergeDup , & fwd , ifaceNamer )
5554 }
5655 if len (fwd ) > 0 {
5756 out <- fwd
@@ -61,7 +60,7 @@ func Dedupe(expireTime time.Duration, justMark, mergeDup bool) func(in <-chan []
6160}
6261
6362// checkDupe check current record if its already available nad if not added to fwd records list
64- func (c * deduperCache ) checkDupe (r * Record , justMark , mergeDup bool , fwd * []* Record ) {
63+ func (c * deduperCache ) checkDupe (r * Record , justMark , mergeDup bool , fwd * []* Record , ifaceNamer InterfaceNamer ) {
6564 mergeEntry := make (map [string ]uint8 )
6665 rk := r .Id
6766 // zeroes fields from key that should be ignored from the flow comparison
@@ -95,7 +94,7 @@ func (c *deduperCache) checkDupe(r *Record, justMark, mergeDup bool, fwd *[]*Rec
9594 * fwd = append (* fwd , r )
9695 }
9796 if mergeDup {
98- ifName := utils . GetInterfaceName ( r .Id .IfIndex )
97+ ifName := ifaceNamer ( int ( r .Id .IfIndex ) )
9998 mergeEntry [ifName ] = r .Id .Direction
10099 if dupEntryNew (* fEntry .dupList , mergeEntry ) {
101100 * fEntry .dupList = append (* fEntry .dupList , mergeEntry )
@@ -122,7 +121,7 @@ func (c *deduperCache) checkDupe(r *Record, justMark, mergeDup bool, fwd *[]*Rec
122121 expiryTime : timeNow ().Add (c .expire ),
123122 }
124123 if mergeDup {
125- ifName := utils . GetInterfaceName ( r .Id .IfIndex )
124+ ifName := ifaceNamer ( int ( r .Id .IfIndex ) )
126125 mergeEntry [ifName ] = r .Id .Direction
127126 r .DupList = append (r .DupList , mergeEntry )
128127 e .dupList = & r .DupList
0 commit comments