Fix issues with IP range drop map.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
#include <xdp/utils/helpers.h>
|
||||
|
||||
#include <xdp/utils/maps.h>
|
||||
|
||||
/**
|
||||
* Checks if an IP is within a specific CIDR range.
|
||||
*
|
||||
@@ -26,11 +24,9 @@ static __always_inline int is_ip_in_range(u32 src_ip, u32 net_ip, u8 cidr)
|
||||
*/
|
||||
static __always_inline int check_ip_range_drop(u32 ip)
|
||||
{
|
||||
LpmTrieKey key =
|
||||
{
|
||||
.prefix_len = 32,
|
||||
.data = ip
|
||||
};
|
||||
lpm_trie_key_t key = {0};
|
||||
key.prefix_len = 32;
|
||||
key.data = ip;
|
||||
|
||||
u64 *lookup = bpf_map_lookup_elem(&map_range_drop, &key);
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <bpf/bpf_helpers.h>
|
||||
#endif
|
||||
|
||||
#include <xdp/utils/maps.h>
|
||||
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
|
||||
|
||||
@@ -30,11 +30,12 @@ struct
|
||||
} map_block6 SEC(".maps");
|
||||
|
||||
#ifdef ENABLE_IP_RANGE_DROP
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
__uint(type, BPF_MAP_TYPE_LPM_TRIE);
|
||||
__uint(max_entries, MAX_IP_RANGES);
|
||||
__uint(map_flags, BPF_F_NO_PREALLOC);
|
||||
__type(key, LpmTrieKey);
|
||||
__type(key, lpm_trie_key_t);
|
||||
__type(value, u64);
|
||||
} map_range_drop SEC(".maps");
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user