Skip to content
Snippets Groups Projects
Unverified Commit c793936a authored by Joel Takvorian's avatar Joel Takvorian Committed by GitHub
Browse files

Avoid unnecessary call when sampling=1 (#313)

Call to "bpf_get_prandom_u32() % sampling" not necessary when sampling
is 1
parent 69219052
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
static inline int flow_monitor(struct __sk_buff *skb, u8 direction) { static inline int flow_monitor(struct __sk_buff *skb, u8 direction) {
filter_action action = ACCEPT; filter_action action = ACCEPT;
// If sampling is defined, will only parse 1 out of "sampling" flows // If sampling is defined, will only parse 1 out of "sampling" flows
if (sampling != 0 && (bpf_get_prandom_u32() % sampling) != 0) { if (sampling > 1 && (bpf_get_prandom_u32() % sampling) != 0) {
return TC_ACT_OK; return TC_ACT_OK;
} }
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment