diff --git a/agent/src/ebpf/user/mount.c b/agent/src/ebpf/user/mount.c index b7b34805a1a..6cc51907770 100644 --- a/agent/src/ebpf/user/mount.c +++ b/agent/src/ebpf/user/mount.c @@ -216,6 +216,9 @@ int mount_info_cache_init(const char *name) struct mount_info *mount_info_cache_lookup(pid_t pid, u64 mntns_id) { + if (!enable_mount_info_cache()) + return MOUNT_INFO_INVAL; + if (mntns_id == 0 && pid > 0) { if (get_mount_ns_id(pid, &mntns_id)) return MOUNT_INFO_INVAL; @@ -552,6 +555,9 @@ static int check_mount_kvp_cb(mount_info_hash_kv * kvp, void *ctx) void collect_mount_info_stats(bool output_log) { + if (!enable_mount_info_cache()) + return; + u64 elems_count = 0; mount_info_hash_t *h = &mount_info_hash; mount_info_hash_foreach_key_value_pair(h, @@ -592,6 +598,9 @@ void check_and_cleanup_mount_info(pid_t pid, u64 mntns_id) // Periodically check whether the host node's mount information has changed. void check_root_mount_info(bool output_log) { + if (!enable_mount_info_cache()) + return; + u32 new_hash = 0; hash_mountinfo_file(1, &new_hash); if (new_hash != 0 && new_hash != host_root_mountinfo_hash) { diff --git a/agent/src/ebpf/user/proc.c b/agent/src/ebpf/user/proc.c index 4648c921a58..da714c742d6 100644 --- a/agent/src/ebpf/user/proc.c +++ b/agent/src/ebpf/user/proc.c @@ -762,7 +762,10 @@ void *get_symbol_cache(pid_t pid, bool new_cache) int create_and_init_proc_info_caches(void) { // Initialize the mount information cache. - mount_info_cache_init("mount-info-cache"); + if (mount_info_cache_init("mount-info-cache")) { + ebpf_warning("mount_info_cache_init() failed.\n"); + return ETR_NOMEM; + } /* * Building a 'proc_event_ring' for handling process events. diff --git a/agent/src/ebpf/user/socket.c b/agent/src/ebpf/user/socket.c index b7010129b96..c40e25d52bf 100644 --- a/agent/src/ebpf/user/socket.c +++ b/agent/src/ebpf/user/socket.c @@ -3094,7 +3094,8 @@ int running_socket_tracer(tracer_callback_t handle, socket_tracer_set_probes(tps); golang_trace_init(); openssl_trace_init(); - create_and_init_proc_info_caches(); + if ((ret = create_and_init_proc_info_caches())) + return ret; struct bpf_tracer *tracer = setup_bpf_tracer(SK_TRACER_NAME, bpf_load_buffer_name,