ebpf icon indicating copy to clipboard operation
ebpf copied to clipboard

has to have BTF in order to use bpf_spin_lock

Open Okabe-Rintarou-0 opened this issue 1 year ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Version

higher than v1.14.13 and lower than v1.15.0

What happened?

use bpf2go, met verifier error: has to have BTF in order to use bpf_spin_lock

struct cluster_stats_key {
    __u64 netns_cookie;
    __u32 cluster_id;
};

struct {
    __uint(type, BPF_MAP_TYPE_HASH);
    __uint(key_size, sizeof(struct cluster_stats_key));
    __uint(value_size, sizeof(struct cluster_stats));
    __uint(map_flags, BPF_F_NO_PREALLOC);
    __uint(max_entries, MAP_SIZE_OF_CLUSTER);
} map_of_cluster_stats SEC(".maps");

struct cluster_sock_data {
    __u32 cluster_id;
};

struct {
    __uint(type, BPF_MAP_TYPE_SK_STORAGE);
    __uint(map_flags, BPF_F_NO_PREALLOC);
    __type(key, int);
    __type(value, struct cluster_sock_data);
} map_of_cluster_sock SEC(".maps");

  bpf_spin_lock(&stats->lock);
  stats->active_connections += delta;
  bpf_spin_unlock((&stats->lock);

How can we reproduce the issue?

run the code above

Cilium Version

v0.15.0

Kernel Version

6.19

Kubernetes Version

1.23.17

Regression

No response

Sysdump

No response

Relevant log output

No response

Anything else?

No response

Cilium Users Document

  • [X] Are you a user of Cilium? Please add yourself to the Users doc

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Okabe-Rintarou-0 avatar Jul 23 '24 11:07 Okabe-Rintarou-0