forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbpf_alignchecker.c
88 lines (81 loc) · 2.6 KB
/
bpf_alignchecker.c
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) 2018-2020 Authors of Cilium */
/* Ensure declaration of notification event types */
#define DEBUG
#define TRACE_NOTIFY
#define DROP_NOTIFY
#define POLICY_VERDICT_NOTIFY
#undef ENABLE_ARP_RESPONDER
#include <bpf/ctx/unspec.h>
#include <bpf/api.h>
#include "node_config.h"
#include "lib/conntrack.h"
#include "lib/dbg.h"
#include "lib/drop.h"
#include "lib/ipv4.h"
#define SKIP_UNDEF_LPM_LOOKUP_FN
#include "lib/maps.h"
#include "lib/nat.h"
#include "lib/trace.h"
#include "lib/policy_log.h"
#include "sockops/bpf_sockops.h"
/* DECLARE declares a unique usage of the union or struct 'x' on the stack.
*
* To prevent compiler from optimizing away the var, we pass a reference
* to the var to a BPF helper function which accepts a reference as
* an argument.
*/
#define DECLARE(datatype, x, iter) \
{ \
datatype x s ## iter = {}; \
trace_printk("%p", 1, &s ## iter); \
iter++; \
}
/* This function is a placeholder for C struct definitions shared with Go,
* it is never executed.
*/
int main(void)
{
int iter = 0;
DECLARE(struct, ipv4_ct_tuple, iter);
DECLARE(struct, ipv6_ct_tuple, iter);
DECLARE(struct, ct_entry, iter);
DECLARE(struct, ipcache_key, iter);
DECLARE(struct, remote_endpoint_info, iter);
DECLARE(struct, lb4_key, iter);
DECLARE(struct, lb4_service, iter);
DECLARE(struct, lb4_backend, iter);
DECLARE(struct, lb6_key, iter);
DECLARE(struct, lb6_service, iter);
DECLARE(struct, lb6_backend, iter);
DECLARE(struct, endpoint_key, iter);
DECLARE(struct, endpoint_info, iter);
DECLARE(struct, metrics_key, iter);
DECLARE(struct, metrics_value, iter);
DECLARE(struct, sock_key, iter);
DECLARE(struct, policy_key, iter);
DECLARE(struct, policy_entry, iter);
DECLARE(struct, ipv4_nat_entry, iter);
DECLARE(struct, ipv6_nat_entry, iter);
DECLARE(struct, trace_notify, iter);
DECLARE(struct, drop_notify, iter);
DECLARE(struct, policy_verdict_notify, iter);
DECLARE(struct, debug_msg, iter);
DECLARE(struct, debug_capture_msg, iter);
DECLARE(struct, ipv4_revnat_tuple, iter);
DECLARE(struct, ipv4_revnat_entry, iter);
DECLARE(struct, ipv6_revnat_tuple, iter);
DECLARE(struct, ipv6_revnat_entry, iter);
DECLARE(struct, ipv4_frag_id, iter);
DECLARE(struct, ipv4_frag_l4ports, iter);
DECLARE(union, macaddr, iter);
DECLARE(struct, lb4_affinity_key, iter);
DECLARE(struct, lb6_affinity_key, iter);
DECLARE(struct, lb_affinity_val, iter);
DECLARE(struct, lb_affinity_match, iter);
DECLARE(struct, lb4_src_range_key, iter);
DECLARE(struct, lb6_src_range_key, iter);
DECLARE(struct, edt_id, iter);
DECLARE(struct, edt_info, iter);
return 0;
}