Skip to content

NETOBSERV-2194: OCP4.19 uses rhel9.6 which doesn't have rh_psample_sample_packet anymore #621

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

Merged
merged 1 commit into from
Mar 27, 2025
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
2 changes: 1 addition & 1 deletion .mk/bc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ define PROGRAMS
"tcp_rcv_fentry":"fentry",
"tcp_rcv_kprobe":"kprobe",
"kfree_skb":"tracepoint",
"rh_network_events_monitoring":"kprobe",
"network_events_monitoring":"kprobe",
"track_nat_manip_pkt":"kprobe"
}
endef
Expand Down
13 changes: 13 additions & 0 deletions bpf/headers/vmlinux_amd64.h
Original file line number Diff line number Diff line change
Expand Up @@ -79761,6 +79761,19 @@ struct psample_group {
struct callback_head rcu;
};

struct psample_metadata {
u32 trunc_size;
int in_ifindex;
int out_ifindex;
u16 out_tc;
u64 out_tc_occ; /* bytes */
u64 latency; /* nanoseconds */
u8 out_tc_valid : 1, out_tc_occ_valid : 1, latency_valid : 1, rate_as_probability : 1,
unused : 4;
const u8 *user_cookie;
u32 user_cookie_len;
};

struct action_gate_entry {
u8 gate_state;
u32 interval;
Expand Down
13 changes: 13 additions & 0 deletions bpf/headers/vmlinux_arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -89448,6 +89448,19 @@ struct psample_group {
struct callback_head rcu;
};

struct psample_metadata {
u32 trunc_size;
int in_ifindex;
int out_ifindex;
u16 out_tc;
u64 out_tc_occ; /* bytes */
u64 latency; /* nanoseconds */
u8 out_tc_valid : 1, out_tc_occ_valid : 1, latency_valid : 1, rate_as_probability : 1,
unused : 4;
const u8 *user_cookie;
u32 user_cookie_len;
};

struct action_gate_entry {
u8 gate_state;
u32 interval;
Expand Down
13 changes: 13 additions & 0 deletions bpf/headers/vmlinux_ppc64le.h
Original file line number Diff line number Diff line change
Expand Up @@ -139483,6 +139483,19 @@ struct psample_group {
struct callback_head rcu;
};

struct psample_metadata {
u32 trunc_size;
int in_ifindex;
int out_ifindex;
u16 out_tc;
u64 out_tc_occ; /* bytes */
u64 latency; /* nanoseconds */
u8 out_tc_valid : 1, out_tc_occ_valid : 1, latency_valid : 1, rate_as_probability : 1,
unused : 4;
const u8 *user_cookie;
u32 user_cookie_len;
};

struct action_gate_entry {
u8 gate_state;
u32 interval;
Expand Down
13 changes: 13 additions & 0 deletions bpf/headers/vmlinux_s390.h
Original file line number Diff line number Diff line change
Expand Up @@ -64738,6 +64738,19 @@ struct psample_group {
struct callback_head rcu;
};

struct psample_metadata {
u32 trunc_size;
int in_ifindex;
int out_ifindex;
u16 out_tc;
u64 out_tc_occ; /* bytes */
u64 latency; /* nanoseconds */
u8 out_tc_valid : 1, out_tc_occ_valid : 1, latency_valid : 1, rate_as_probability : 1,
unused : 4;
const u8 *user_cookie;
u32 user_cookie_len;
};

struct action_gate_entry {
u8 gate_state;
u32 interval;
Expand Down
48 changes: 4 additions & 44 deletions bpf/network_events_monitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@

#include "utils.h"

struct rh_psample_metadata {
u32 trunc_size;
int in_ifindex;
int out_ifindex;
u16 out_tc;
u64 out_tc_occ; /* bytes */
u64 latency; /* nanoseconds */
u8 out_tc_valid : 1, out_tc_occ_valid : 1, latency_valid : 1, rate_as_probability : 1,
unused : 4;
const u8 *user_cookie;
u32 user_cookie_len;
};

static inline bool md_already_exists(u8 network_events[MAX_NETWORK_EVENTS][MAX_EVENT_MD], u8 *md) {
for (u8 i = 0; i < MAX_NETWORK_EVENTS; i++) {
if (__builtin_memcmp(network_events[i], md, MAX_EVENT_MD) == 0) {
Expand Down Expand Up @@ -51,7 +38,7 @@ static inline int lookup_and_update_existing_flow_network_events(flow_id *id, u8
return -1;
}

static inline int trace_network_events(struct sk_buff *skb, struct rh_psample_metadata *md) {
static inline int trace_network_events(struct sk_buff *skb, struct psample_metadata *md) {
u8 dscp = 0, protocol = 0, md_len = 0;
u16 family = 0, flags = 0, eth_protocol = 0;
u8 *user_cookie = NULL;
Expand Down Expand Up @@ -129,35 +116,9 @@ static inline int trace_network_events(struct sk_buff *skb, struct rh_psample_me
return ret;
}

// for older kernel will use `rh_psample_sample_packet` to avoid kapis issues
SEC("kprobe/rh_psample_sample_packet")
int BPF_KPROBE(rh_network_events_monitoring, struct psample_group *group, struct sk_buff *skb,
u32 sample_rate, struct rh_psample_metadata *md) {
if (enable_network_events_monitoring == 0 || do_sampling == 0) {
return 0;
}
if (skb == NULL || md == NULL || group == NULL) {
increase_counter(NETWORK_EVENTS_ERR);
return 0;
}
// filter out none matching samples with different groupid
int group_id = BPF_CORE_READ(group, group_num);
if (group_id != network_events_monitoring_groupid) {
increase_counter(NETWORK_EVENTS_ERR_GROUPID_MISMATCH);
return 0;
}
long ret = 0;
if ((ret = trace_network_events(skb, md)) != 0) {
increase_counter(NETWORK_EVENTS_ERR_UPDATE_MAP_FLOWS);
return 0;
}
increase_counter(NETWORK_EVENTS_GOOD);
return 0;
}
/*
SEC("kprobe/psample_sample_packet")
int BPF_KPROBE(network_events_monitoring, struct psample_group *group, struct sk_buff *skb, u32 sample_rate,
struct psample_metadata *md) {
int BPF_KPROBE(network_events_monitoring, struct psample_group *group, struct sk_buff *skb,
u32 sample_rate, struct psample_metadata *md) {
if (enable_network_events_monitoring == 0 || do_sampling == 0) {
return 0;
}
Expand All @@ -171,7 +132,6 @@ int BPF_KPROBE(network_events_monitoring, struct psample_group *group, struct sk
increase_counter(NETWORK_EVENTS_ERR_GROUPID_MISMATCH);
return 0;
}

long ret = 0;
if ((ret = trace_network_events(skb, md)) != 0) {
increase_counter(NETWORK_EVENTS_ERR_UPDATE_MAP_FLOWS);
Expand All @@ -180,5 +140,5 @@ int BPF_KPROBE(network_events_monitoring, struct psample_group *group, struct sk
increase_counter(NETWORK_EVENTS_GOOD);
return 0;
}
*/

#endif /* __NETWORK_EVENTS_MONITORING_H__ */
54 changes: 27 additions & 27 deletions pkg/ebpf/bpf_arm64_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified pkg/ebpf/bpf_arm64_bpfel.o
Binary file not shown.
54 changes: 27 additions & 27 deletions pkg/ebpf/bpf_powerpc_bpfel.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified pkg/ebpf/bpf_powerpc_bpfel.o
Binary file not shown.
54 changes: 27 additions & 27 deletions pkg/ebpf/bpf_s390_bpfeb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified pkg/ebpf/bpf_s390_bpfeb.o
Binary file not shown.
Loading