Skip to content

Commit

Permalink
Merge pull request #413 from msherif1234/pca_dbg
Browse files Browse the repository at this point in the history
NETOBSERV-1882 make sure pkt drop hook is disabled for PCA feature
  • Loading branch information
msherif1234 authored Sep 17, 2024
2 parents 6ac7c5c + 4d2781a commit 27cbe69
Showing 1 changed file with 47 additions and 17 deletions.
64 changes: 47 additions & 17 deletions pkg/ebpf/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,22 +1085,6 @@ func NewPacketFetcher(cfg *FlowFetcherConfig) (*PacketFetcher, error) {
if err != nil {
return nil, err
}

// Removing Specs for flow agent
objects.TcEgressFlowParse = nil
objects.TcIngressFlowParse = nil
objects.TcxEgressFlowParse = nil
objects.TcxIngressFlowParse = nil
objects.DirectFlows = nil
objects.AggregatedFlows = nil
delete(spec.Programs, aggregatedFlowsMap)
delete(spec.Programs, constSampling)
delete(spec.Programs, constTraceMessages)
delete(spec.Programs, constEnableDNSTracking)
delete(spec.Programs, constEnableFlowFiltering)
delete(spec.Programs, constEnableNetworkEventsMonitoring)
delete(spec.Programs, constNetworkEventsMonitoringGroupID)

pcaEnable := 0
if cfg.EnablePCA {
pcaEnable = 1
Expand All @@ -1113,7 +1097,32 @@ func NewPacketFetcher(cfg *FlowFetcherConfig) (*PacketFetcher, error) {
return nil, fmt.Errorf("rewriting BPF constants definition: %w", err)
}

if err := spec.LoadAndAssign(&objects, nil); err != nil {
type pcaBpfPrograms struct {
TcEgressPcaParse *ebpf.Program `ebpf:"tc_egress_pca_parse"`
TcIngressPcaParse *ebpf.Program `ebpf:"tc_ingress_pca_parse"`
TcxEgressPcaParse *ebpf.Program `ebpf:"tcx_egress_pca_parse"`
TcxIngressPcaParse *ebpf.Program `ebpf:"tcx_ingress_pca_parse"`
}
type newBpfObjects struct {
pcaBpfPrograms
BpfMaps
}
var newObjects newBpfObjects
delete(spec.Programs, pktDropHook)
delete(spec.Programs, rhNetworkEventsMonitoringHook)
delete(spec.Programs, tcpRcvKprobe)
delete(spec.Programs, tcpFentryHook)
delete(spec.Programs, aggregatedFlowsMap)
delete(spec.Programs, constSampling)
delete(spec.Programs, constTraceMessages)
delete(spec.Programs, constEnableDNSTracking)
delete(spec.Programs, constDNSTrackingPort)
delete(spec.Programs, constEnableRtt)
delete(spec.Programs, constEnableFlowFiltering)
delete(spec.Programs, constEnableNetworkEventsMonitoring)
delete(spec.Programs, constNetworkEventsMonitoringGroupID)

if err := spec.LoadAndAssign(&newObjects, nil); err != nil {
var ve *ebpf.VerifierError
if errors.As(err, &ve) {
// Using %+v will print the whole verifier error, not just the last
Expand All @@ -1123,6 +1132,27 @@ func NewPacketFetcher(cfg *FlowFetcherConfig) (*PacketFetcher, error) {
return nil, fmt.Errorf("loading and assigning BPF objects: %w", err)
}

objects = BpfObjects{
BpfPrograms: BpfPrograms{
TcEgressPcaParse: newObjects.TcEgressPcaParse,
TcIngressPcaParse: newObjects.TcIngressPcaParse,
TcxEgressPcaParse: newObjects.TcxEgressPcaParse,
TcxIngressPcaParse: newObjects.TcxIngressPcaParse,
TcEgressFlowParse: nil,
TcIngressFlowParse: nil,
TcxEgressFlowParse: nil,
TcxIngressFlowParse: nil,
TcpRcvFentry: nil,
TcpRcvKprobe: nil,
KfreeSkb: nil,
RhNetworkEventsMonitoring: nil,
},
BpfMaps: BpfMaps{
PacketRecord: newObjects.PacketRecord,
FilterMap: newObjects.FilterMap,
},
}

f := NewFilter(&objects, cfg.FilterConfig)
if err := f.ProgramFilter(); err != nil {
return nil, fmt.Errorf("programming flow filter: %w", err)
Expand Down

0 comments on commit 27cbe69

Please sign in to comment.