diff --git a/pkg/network/ebpf/c/protocols/classification/protocol-classification.h b/pkg/network/ebpf/c/protocols/classification/protocol-classification.h index a235138a5c718..67169936daf69 100644 --- a/pkg/network/ebpf/c/protocols/classification/protocol-classification.h +++ b/pkg/network/ebpf/c/protocols/classification/protocol-classification.h @@ -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); diff --git a/pkg/network/ebpf/c/protocols/classification/shared-tracer-maps.h b/pkg/network/ebpf/c/protocols/classification/shared-tracer-maps.h index ebc1881c1f3c2..1300f2a5f999d 100644 --- a/pkg/network/ebpf/c/protocols/classification/shared-tracer-maps.h +++ b/pkg/network/ebpf/c/protocols/classification/shared-tracer-maps.h @@ -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) { diff --git a/pkg/network/ebpf/c/tracer/stats.h b/pkg/network/ebpf/c/tracer/stats.h index cb768fa71e3e4..6a20ae65f041b 100644 --- a/pkg/network/ebpf/c/tracer/stats.h +++ b/pkg/network/ebpf/c/tracer/stats.h @@ -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);