Skip to content

Commit

Permalink
NETOBSERV-2051: Fix eBPF verifier errors with 5.14.0-284.71.1.el9_2
Browse files Browse the repository at this point in the history
Verifier in this version requires initializing the entire additional
materics structure

Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
  • Loading branch information
msherif1234 committed Jan 27, 2025
1 parent a60fefa commit 1df06bb
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
18 changes: 9 additions & 9 deletions bpf/flows.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ static inline int flow_monitor(struct __sk_buff *skb, u8 direction) {
if (extra_metrics != NULL) {
update_dns(extra_metrics, &pkt, dns_errno);
} else {
additional_metrics new_metrics = {
.start_mono_time_ts = pkt.current_ts,
.end_mono_time_ts = pkt.current_ts,
.eth_protocol = eth_protocol,
.dns_record.id = pkt.dns_id,
.dns_record.flags = pkt.dns_flags,
.dns_record.latency = pkt.dns_latency,
.dns_record.errno = dns_errno,
};
additional_metrics new_metrics;
__builtin_memset(&new_metrics, 0, sizeof(new_metrics));
new_metrics.start_mono_time_ts = pkt.current_ts;
new_metrics.end_mono_time_ts = pkt.current_ts;
new_metrics.eth_protocol = eth_protocol;
new_metrics.dns_record.id = pkt.dns_id;
new_metrics.dns_record.flags = pkt.dns_flags;
new_metrics.dns_record.latency = pkt.dns_latency;
new_metrics.dns_record.errno = dns_errno;
long ret =
bpf_map_update_elem(&additional_flow_metrics, &id, &new_metrics, BPF_NOEXIST);
if (ret != 0) {
Expand Down
12 changes: 6 additions & 6 deletions bpf/network_events_monitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ static inline int trace_network_events(struct sk_buff *skb, struct rh_psample_me

// there is no matching flows so lets create new one and add the network event metadata
u64 current_time = bpf_ktime_get_ns();
additional_metrics new_flow = {
.start_mono_time_ts = current_time,
.end_mono_time_ts = current_time,
.eth_protocol = eth_protocol,
.network_events_idx = 0,
};
additional_metrics new_flow;
__builtin_memset(&new_flow, 0, sizeof(new_flow));
new_flow.start_mono_time_ts = current_time;
new_flow.end_mono_time_ts = current_time;
new_flow.eth_protocol = eth_protocol;
new_flow.network_events_idx = 0;
bpf_probe_read(new_flow.network_events[0], md_len, user_cookie);
new_flow.network_events_idx++;
ret = bpf_map_update_elem(&additional_flow_metrics, &id, &new_flow, BPF_NOEXIST);
Expand Down
20 changes: 10 additions & 10 deletions bpf/pkt_drops.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ static inline int trace_pkt_drop(void *ctx, u8 state, struct sk_buff *skb,
}
// there is no matching flows so lets create new one and add the drops
u64 current_time = bpf_ktime_get_ns();
additional_metrics new_flow = {
.start_mono_time_ts = current_time,
.end_mono_time_ts = current_time,
.eth_protocol = eth_protocol,
.pkt_drops.packets = 1,
.pkt_drops.bytes = len,
.pkt_drops.latest_state = state,
.pkt_drops.latest_flags = flags,
.pkt_drops.latest_drop_cause = reason,
};
additional_metrics new_flow;
__builtin_memset(&new_flow, 0, sizeof(new_flow));
new_flow.start_mono_time_ts = current_time;
new_flow.end_mono_time_ts = current_time;
new_flow.eth_protocol = eth_protocol;
new_flow.pkt_drops.packets = 1;
new_flow.pkt_drops.bytes = len;
new_flow.pkt_drops.latest_state = state;
new_flow.pkt_drops.latest_flags = flags;
new_flow.pkt_drops.latest_drop_cause = reason;
ret = bpf_map_update_elem(&additional_flow_metrics, &id, &new_flow, BPF_NOEXIST);
if (ret != 0) {
if (trace_messages && ret != -EEXIST) {
Expand Down
10 changes: 5 additions & 5 deletions bpf/pkt_translation.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ static inline long translate_lookup_and_update_flow(flow_id *id, u16 flags,
}

// there is no matching flows so lets create new one and add the xlation
additional_metrics new_extra_metrics = {
.start_mono_time_ts = current_time,
.end_mono_time_ts = current_time,
.eth_protocol = eth_protocol,
};
additional_metrics new_extra_metrics;
__builtin_memset(&new_extra_metrics, 0, sizeof(new_extra_metrics));
new_extra_metrics.start_mono_time_ts = current_time;
new_extra_metrics.end_mono_time_ts = current_time;
new_extra_metrics.eth_protocol = eth_protocol;
parse_tuple(reply_t, &new_extra_metrics.translated_flow, zone_id, family,
id->transport_protocol, true);
ret = bpf_map_update_elem(&additional_flow_metrics, id, &new_extra_metrics, BPF_NOEXIST);
Expand Down
12 changes: 6 additions & 6 deletions bpf/rtt_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ static inline int calculate_flow_rtt_tcp(struct sock *sk, struct sk_buff *skb) {
}

u64 current_time = bpf_ktime_get_ns();
additional_metrics new_flow = {
.start_mono_time_ts = current_time,
.end_mono_time_ts = current_time,
.eth_protocol = eth_protocol,
.flow_rtt = rtt,
};
additional_metrics new_flow;
__builtin_memset(&new_flow, 0, sizeof(new_flow));
new_flow.start_mono_time_ts = current_time;
new_flow.end_mono_time_ts = current_time;
new_flow.eth_protocol = eth_protocol;
new_flow.flow_rtt = rtt;
ret = bpf_map_update_elem(&additional_flow_metrics, &id, &new_flow, BPF_NOEXIST);
if (ret != 0) {
if (trace_messages && ret != -EEXIST) {
Expand Down
Binary file modified pkg/ebpf/bpf_arm64_bpfel.o
Binary file not shown.
Binary file modified pkg/ebpf/bpf_powerpc_bpfel.o
Binary file not shown.
Binary file modified pkg/ebpf/bpf_s390_bpfeb.o
Binary file not shown.
Binary file modified pkg/ebpf/bpf_x86_bpfel.o
Binary file not shown.

0 comments on commit 1df06bb

Please sign in to comment.