Skip to content

Commit

Permalink
add sampling check to align with all other ebpf hooks
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Mahmoud <[email protected]>
  • Loading branch information
msherif1234 committed Jul 31, 2024
1 parent a593b2a commit 2040e9b
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 21 deletions.
13 changes: 7 additions & 6 deletions bpf/ovs_monitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@

#include "utils.h"

struct psample_metadata {
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, unused : 5;
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 int trace_ovs_dp(struct sk_buff *skb, struct psample_metadata *md) {
static inline int trace_ovs_dp(struct sk_buff *skb, struct rh_psample_metadata *md) {
u8 dscp = 0, protocol = 0, md_len = 0;
u16 family = 0, flags = 0;
u8 *user_cookie = NULL;
Expand Down Expand Up @@ -109,10 +110,10 @@ static inline int trace_ovs_dp(struct sk_buff *skb, struct psample_metadata *md)
return ret;
}

SEC("kprobe/psample_sample_packet")
SEC("kprobe/rh_psample_sample_packet")
int BPF_KPROBE(ovs_dp_monitor, void *group, struct sk_buff *skb, u32 sample_rate,
struct psample_metadata *md) {
if (enable_ovs_monitoring == 0) {
struct rh_psample_metadata *md) {
if (enable_ovs_monitoring == 0 || do_sampling == 0) {
return 0;
}
if (skb == NULL || md == NULL) {
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.
2 changes: 1 addition & 1 deletion pkg/ebpf/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
pcaRecordsMap = "packet_record"
tcEgressFilterName = "tc/tc_egress_flow_parse"
tcIngressFilterName = "tc/tc_ingress_flow_parse"
ovsMonitoringHook = "psample_sample_packet"
ovsMonitoringHook = "rh_psample_sample_packet"
)

var log = logrus.WithField("component", "ebpf.FlowFetcher")
Expand Down
25 changes: 18 additions & 7 deletions pkg/pbflow/flow_grpc.pb.go

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

25 changes: 18 additions & 7 deletions pkg/pbpacket/packet_grpc.pb.go

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

0 comments on commit 2040e9b

Please sign in to comment.