Skip to content

Commit

Permalink
max_entries of flow_directions map sets from configuration (#959)
Browse files Browse the repository at this point in the history
  • Loading branch information
bareckidarek authored Jun 22, 2024
1 parent d7d75a1 commit 3a59841
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion bpf/flows_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct {
// Key: the flow identifier. Value: the flow direction.
struct {
__uint(type, BPF_MAP_TYPE_LRU_HASH);
__uint(max_entries, 1 << 24);
__type(key, flow_id);
__type(value, u8);
} flow_directions SEC(".maps");
Expand Down
Binary file modified pkg/internal/netolly/ebpf/net_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/netolly/ebpf/net_bpfel_x86.o
Binary file not shown.
Binary file modified pkg/internal/netolly/ebpf/netsk_bpfel_arm64.o
Binary file not shown.
Binary file modified pkg/internal/netolly/ebpf/netsk_bpfel_x86.o
Binary file not shown.
3 changes: 2 additions & 1 deletion pkg/internal/netolly/ebpf/sock_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ func NewSockFlowFetcher(
return nil, fmt.Errorf("loading BPF data: %w", err)
}

// Resize aggregated flows map according to user-provided configuration
// Resize aggregated flows and flow directions maps according to user-provided configuration
spec.Maps[aggregatedFlowsMap].MaxEntries = uint32(cacheMaxSize)
spec.Maps[flowDirectionsMap].MaxEntries = uint32(cacheMaxSize)

traceMsgs := 0
if tlog.Enabled(context.TODO(), slog.LevelDebug) {
Expand Down
4 changes: 3 additions & 1 deletion pkg/internal/netolly/ebpf/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
constSampling = "sampling"
constTraceMessages = "trace_messages"
aggregatedFlowsMap = "aggregated_flows"
flowDirectionsMap = "flow_directions"
)

func tlog() *slog.Logger {
Expand Down Expand Up @@ -82,8 +83,9 @@ func NewFlowFetcher(
return nil, fmt.Errorf("loading BPF data: %w", err)
}

// Resize aggregated flows map according to user-provided configuration
// Resize aggregated flows and flow directions maps according to user-provided configuration
spec.Maps[aggregatedFlowsMap].MaxEntries = uint32(cacheMaxSize)
spec.Maps[flowDirectionsMap].MaxEntries = uint32(cacheMaxSize)

traceMsgs := 0
if tlog.Enabled(context.TODO(), slog.LevelDebug) {
Expand Down

0 comments on commit 3a59841

Please sign in to comment.