Skip to content

Instantly share code, notes, and snippets.

@TCY16
Created October 5, 2020 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TCY16/64fb84de3e0253d3c7a516ee0b3043aa to your computer and use it in GitHub Desktop.
Save TCY16/64fb84de3e0253d3c7a516ee0b3043aa to your computer and use it in GitHub Desktop.
// search for the prefix in the LPM trie
struct {
uint32_t prefixlen;
uint32_t ipv4_addr;
} key4 = {
.prefixlen = 32,
.ipv4_addr = key
};
uint64_t *count = bpf_map_lookup_elem(&exclude_v4_prefixes, &key4);
// if the prefix matches, we exclude it from rate limiting
if (count) {
lock_xadd(count, 1);
return 1; // XDP_PASS
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment