| .. | .. |
|---|
| 12 | 12 | #include <linux/if_vlan.h> |
|---|
| 13 | 13 | #include <linux/ip.h> |
|---|
| 14 | 14 | #include <linux/ipv6.h> |
|---|
| 15 | | -#include "bpf_helpers.h" |
|---|
| 15 | +#include <bpf/bpf_helpers.h> |
|---|
| 16 | 16 | #include <linux/slab.h> |
|---|
| 17 | 17 | #include <net/ip_fib.h> |
|---|
| 18 | 18 | |
|---|
| .. | .. |
|---|
| 42 | 42 | }; |
|---|
| 43 | 43 | |
|---|
| 44 | 44 | /* Map for trie implementation*/ |
|---|
| 45 | | -struct bpf_map_def SEC("maps") lpm_map = { |
|---|
| 46 | | - .type = BPF_MAP_TYPE_LPM_TRIE, |
|---|
| 47 | | - .key_size = 8, |
|---|
| 48 | | - .value_size = sizeof(struct trie_value), |
|---|
| 49 | | - .max_entries = 50, |
|---|
| 50 | | - .map_flags = BPF_F_NO_PREALLOC, |
|---|
| 51 | | -}; |
|---|
| 45 | +struct { |
|---|
| 46 | + __uint(type, BPF_MAP_TYPE_LPM_TRIE); |
|---|
| 47 | + __uint(key_size, 8); |
|---|
| 48 | + __uint(value_size, sizeof(struct trie_value)); |
|---|
| 49 | + __uint(max_entries, 50); |
|---|
| 50 | + __uint(map_flags, BPF_F_NO_PREALLOC); |
|---|
| 51 | +} lpm_map SEC(".maps"); |
|---|
| 52 | 52 | |
|---|
| 53 | 53 | /* Map for counter*/ |
|---|
| 54 | | -struct bpf_map_def SEC("maps") rxcnt = { |
|---|
| 55 | | - .type = BPF_MAP_TYPE_PERCPU_ARRAY, |
|---|
| 56 | | - .key_size = sizeof(u32), |
|---|
| 57 | | - .value_size = sizeof(u64), |
|---|
| 58 | | - .max_entries = 256, |
|---|
| 59 | | -}; |
|---|
| 54 | +struct { |
|---|
| 55 | + __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); |
|---|
| 56 | + __type(key, u32); |
|---|
| 57 | + __type(value, u64); |
|---|
| 58 | + __uint(max_entries, 256); |
|---|
| 59 | +} rxcnt SEC(".maps"); |
|---|
| 60 | 60 | |
|---|
| 61 | 61 | /* Map for ARP table*/ |
|---|
| 62 | | -struct bpf_map_def SEC("maps") arp_table = { |
|---|
| 63 | | - .type = BPF_MAP_TYPE_HASH, |
|---|
| 64 | | - .key_size = sizeof(__be32), |
|---|
| 65 | | - .value_size = sizeof(__be64), |
|---|
| 66 | | - .max_entries = 50, |
|---|
| 67 | | -}; |
|---|
| 62 | +struct { |
|---|
| 63 | + __uint(type, BPF_MAP_TYPE_HASH); |
|---|
| 64 | + __type(key, __be32); |
|---|
| 65 | + __type(value, __be64); |
|---|
| 66 | + __uint(max_entries, 50); |
|---|
| 67 | +} arp_table SEC(".maps"); |
|---|
| 68 | 68 | |
|---|
| 69 | 69 | /* Map to keep the exact match entries in the route table*/ |
|---|
| 70 | | -struct bpf_map_def SEC("maps") exact_match = { |
|---|
| 71 | | - .type = BPF_MAP_TYPE_HASH, |
|---|
| 72 | | - .key_size = sizeof(__be32), |
|---|
| 73 | | - .value_size = sizeof(struct direct_map), |
|---|
| 74 | | - .max_entries = 50, |
|---|
| 75 | | -}; |
|---|
| 70 | +struct { |
|---|
| 71 | + __uint(type, BPF_MAP_TYPE_HASH); |
|---|
| 72 | + __type(key, __be32); |
|---|
| 73 | + __type(value, struct direct_map); |
|---|
| 74 | + __uint(max_entries, 50); |
|---|
| 75 | +} exact_match SEC(".maps"); |
|---|
| 76 | 76 | |
|---|
| 77 | | -struct bpf_map_def SEC("maps") tx_port = { |
|---|
| 78 | | - .type = BPF_MAP_TYPE_DEVMAP, |
|---|
| 79 | | - .key_size = sizeof(int), |
|---|
| 80 | | - .value_size = sizeof(int), |
|---|
| 81 | | - .max_entries = 100, |
|---|
| 82 | | -}; |
|---|
| 77 | +struct { |
|---|
| 78 | + __uint(type, BPF_MAP_TYPE_DEVMAP); |
|---|
| 79 | + __uint(key_size, sizeof(int)); |
|---|
| 80 | + __uint(value_size, sizeof(int)); |
|---|
| 81 | + __uint(max_entries, 100); |
|---|
| 82 | +} tx_port SEC(".maps"); |
|---|
| 83 | 83 | |
|---|
| 84 | 84 | /* Function to set source and destination mac of the packet */ |
|---|
| 85 | 85 | static inline void set_src_dst_mac(void *data, void *src, void *dst) |
|---|