Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usm, npm, classification: Fix a leak in connection_protocol #31153

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@
// file. If, for example, application-layer is known, calling this helper multiple
// times will result in traversing only the api and encryption-layer programs

static __always_inline bool is_protocol_classification_supported() {
__u64 val = 0;
LOAD_CONSTANT("protocol_classification_enabled", val);
return val > 0;
}

// updates the the protocol stack and adds the current layer to the routing skip list
static __always_inline void update_protocol_information(usm_context_t *usm_ctx, protocol_stack_t *stack, protocol_t proto) {
set_protocol(stack, proto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
// classification procedures on the same connection
BPF_HASH_MAP(connection_protocol, conn_tuple_t, protocol_stack_wrapper_t, 0)

static __always_inline bool is_protocol_classification_supported() {
__u64 val = 0;
LOAD_CONSTANT("protocol_classification_enabled", val);
return val > 0;
}

static __always_inline protocol_stack_t* __get_protocol_stack(conn_tuple_t* tuple) {
protocol_stack_wrapper_t *wrapper = bpf_map_lookup_elem(&connection_protocol, tuple);
if (!wrapper) {
Expand Down
4 changes: 3 additions & 1 deletion pkg/network/ebpf/c/tracer/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ static __always_inline void update_conn_stats(conn_tuple_t *t, size_t sent_bytes
return;
}

update_protocol_classification_information(t, val);
if (is_protocol_classification_supported()) {
update_protocol_classification_information(t, val);
}

// If already in our map, increment size in-place
update_conn_state(t, val, sent_bytes, recv_bytes);
Expand Down
Loading