Skip to content

Commit

Permalink
IPsec userspace to enable ipsec tracker
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Mahmoud <[email protected]>
  • Loading branch information
msherif1234 committed Jan 31, 2025
1 parent 1a6bb3f commit f73f9d5
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 37 deletions.
1 change: 1 addition & 0 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func FlowsAgent(cfg *Config) (*Flows, error) {
EnablePktTranslation: cfg.EnablePktTranslationTracking,
UseEbpfManager: cfg.EbpfProgramManagerMode,
BpfManBpfFSPath: cfg.BpfManBpfFSPath,
EnableIPsecTracker: cfg.EnableIPsecTracking,
FilterConfig: filterRules,
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ type Config struct {
BpfManBpfFSPath string `env:"BPFMAN_BPF_FS_PATH" envDefault:"/run/netobserv/maps"`
// EnableUDNMapping to allow mapping pod's interface to udn label
EnableUDNMapping bool `env:"ENABLE_UDN_MAPPING" envDefault:"false"`
// EnableIPsecTracking enable tracking IPsec flows encryption
EnableIPsecTracking bool `env:"ENABLE_IPSEC_TRACKING" envDefault:"false"`
/* Deprecated configs are listed below this line
* See manageDeprecatedConfigs function for details
*/
Expand Down
3 changes: 3 additions & 0 deletions pkg/decode/decode_protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ func RecordToMap(fr *model.Record) config.GenericMap {
out["XlatSrcAddr"] = model.IP(fr.Metrics.AdditionalMetrics.TranslatedFlow.Saddr).String()
out["XlatDstAddr"] = model.IP(fr.Metrics.AdditionalMetrics.TranslatedFlow.Daddr).String()
}
if fr.Metrics.AdditionalMetrics.FlowEncrypted {
out["EncryptedFlow"] = fr.Metrics.AdditionalMetrics.FlowEncrypted
}
}

if fr.TimeFlowRtt != 0 {
Expand Down
4 changes: 4 additions & 0 deletions pkg/model/flow_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func (p *BpfFlowContent) AccumulateAdditional(other *ebpf.BpfAdditionalMetrics)
if !AllZeroIP(IP(other.TranslatedFlow.Saddr)) && !AllZeroIP(IP(other.TranslatedFlow.Daddr)) {
p.AdditionalMetrics.TranslatedFlow = other.TranslatedFlow
}
// Encryption
if p.AdditionalMetrics.FlowEncrypted != other.FlowEncrypted {
p.AdditionalMetrics.FlowEncrypted = other.FlowEncrypted
}
}

func allZerosMac(s [6]uint8) bool {
Expand Down
81 changes: 46 additions & 35 deletions pkg/pbflow/flow.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/pbflow/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func FlowToPB(fr *model.Record) *Record {
DstPort: uint32(fr.Metrics.AdditionalMetrics.TranslatedFlow.Dport),
ZoneId: uint32(fr.Metrics.AdditionalMetrics.TranslatedFlow.ZoneId),
}
pbflowRecord.FlowEncrypted = fr.Metrics.AdditionalMetrics.FlowEncrypted
}
pbflowRecord.DupList = make([]*DupMapEntry, 0)
for _, intf := range fr.Interfaces {
Expand Down Expand Up @@ -166,6 +167,7 @@ func PBToFlow(pb *Record) *model.Record {
Dport: uint16(pb.Xlat.GetDstPort()),
ZoneId: uint16(pb.Xlat.GetZoneId()),
},
FlowEncrypted: pb.FlowEncrypted,
},
},
TimeFlowStart: pb.TimeFlowStart.AsTime(),
Expand Down
Loading

0 comments on commit f73f9d5

Please sign in to comment.