Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@TCY16
Created October 5, 2020 13:48
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/d72b1fbad14dca8136632ae9db5b91a5 to your computer and use it in GitHub Desktop.
Save TCY16/d72b1fbad14dca8136632ae9db5b91a5 to your computer and use it in GitHub Desktop.
// search for the prefix in the LPM trie
struct {
uint32_t prefixlen;
struct in6_addr ipv6_addr;
} key6 = {
.prefixlen = 64,
.ipv6_addr = *key
};
uint64_t *count = bpf_map_lookup_elem(&exclude_v6_prefixes, &key6);
// if the prefix is 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