-
Notifications
You must be signed in to change notification settings - Fork 21
/
xdpfwd.h
58 lines (44 loc) · 1008 Bytes
/
xdpfwd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include <inttypes.h>
#define MAXRULES 256
#define MAXCONNECTIONS 1000000
// These represent the min and max port ranges that can be used as source ports. By default, we use 20 ports due to low BPF limitations. I am able to get this working at 1 - 65534 with a custom kernel built.
#define MINPORT 500
#define MAXPORT 520
struct connection
{
uint32_t clientaddr;
uint16_t clientport;
uint16_t bindport;
uint16_t port;
uint64_t firstseen;
uint64_t lastseen;
uint64_t count;
};
struct forward_key
{
uint32_t bindaddr;
uint8_t protocol;
uint16_t bindport;
};
struct forward_info
{
uint32_t destaddr;
uint16_t destport;
};
struct port_key
{
uint32_t bindaddr;
uint32_t destaddr;
uint16_t port;
};
struct conn_key
{
uint32_t clientaddr;
uint16_t clientport;
uint32_t bindaddr;
uint16_t bindport;
uint8_t protocol;
};
#define FORWARD_MAP "/sys/fs/bpf/xdpfwd/forward_map"
#define PIN_DIR "/sys/fs/bpf/xdpfwd"