forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.h
1487 lines (1343 loc) · 61.4 KB
/
helpers.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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
R"********(
/*
* Copyright (c) 2015 PLUMgrid, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BPF_HELPERS_H
#define __BPF_HELPERS_H
/* In Linux 5.4 asm_inline was introduced, but it's not supported by clang.
* Redefine it to just asm to enable successful compilation.
*/
#ifdef asm_inline
#undef asm_inline
#define asm_inline asm
#endif
/* Before bpf_helpers.h is included, uapi bpf.h has been
* included, which references linux/types.h. This may bring
* in asm_volatile_goto definition if permitted based on
* compiler setup and kernel configs.
*
* clang does not support "asm volatile goto" yet.
* So redefine asm_volatile_goto to some invalid asm code.
* If asm_volatile_goto is actually used by the bpf program,
* a compilation error will appear.
*/
#ifdef asm_volatile_goto
#undef asm_volatile_goto
#endif
#define asm_volatile_goto(x...) asm volatile("invalid use of asm_volatile_goto")
/* In 4.18 and later, when CONFIG_FUNCTION_TRACER is defined, kernel Makefile adds
* -DCC_USING_FENTRY. Let do the same for bpf programs.
*/
#if defined(CONFIG_FUNCTION_TRACER)
#define CC_USING_FENTRY
#endif
#include <uapi/linux/bpf.h>
#include <uapi/linux/if_packet.h>
#include <linux/version.h>
#include <linux/log2.h>
#include <asm/page.h>
#ifndef CONFIG_BPF_SYSCALL
#error "CONFIG_BPF_SYSCALL is undefined, please check your .config or ask your Linux distro to enable this feature"
#endif
#ifdef PERF_MAX_STACK_DEPTH
#define BPF_MAX_STACK_DEPTH PERF_MAX_STACK_DEPTH
#else
#define BPF_MAX_STACK_DEPTH 127
#endif
/* helper macro to place programs, maps, license in
* different sections in elf_bpf file. Section names
* are interpreted by elf_bpf loader
*/
#define BCC_SEC(NAME) __attribute__((section(NAME), used))
#ifdef B_WORKAROUND
#define BCC_SEC_HELPERS BCC_SEC("helpers")
#else
#define BCC_SEC_HELPERS
#endif
// Associate map with its key/value types
#define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) \
struct ____btf_map_##name { \
type_key key; \
type_val value; \
}; \
struct ____btf_map_##name \
__attribute__ ((section(".maps." #name), used)) \
____btf_map_##name = { }
// Associate map with its key/value types for QUEUE/STACK map types
#define BPF_ANNOTATE_KV_PAIR_QUEUESTACK(name, type_val) \
struct ____btf_map_##name { \
type_val value; \
}; \
struct ____btf_map_##name \
__attribute__ ((section(".maps." #name), used)) \
____btf_map_##name = { }
// Changes to the macro require changes in BFrontendAction classes
#define BPF_F_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries, _flags) \
struct _name##_table_t { \
_key_type key; \
_leaf_type leaf; \
_leaf_type * (*lookup) (_key_type *); \
_leaf_type * (*lookup_or_init) (_key_type *, _leaf_type *); \
_leaf_type * (*lookup_or_try_init) (_key_type *, _leaf_type *); \
int (*update) (_key_type *, _leaf_type *); \
int (*insert) (_key_type *, _leaf_type *); \
int (*delete) (_key_type *); \
void (*call) (void *, int index); \
void (*increment) (_key_type, ...); \
void (*atomic_increment) (_key_type, ...); \
int (*get_stackid) (void *, u64); \
void * (*sk_storage_get) (void *, void *, int); \
int (*sk_storage_delete) (void *); \
void * (*inode_storage_get) (void *, void *, int); \
int (*inode_storage_delete) (void *); \
void * (*task_storage_get) (void *, void *, int); \
int (*task_storage_delete) (void *); \
u32 max_entries; \
int flags; \
}; \
__attribute__((section("maps/" _table_type))) \
struct _name##_table_t _name = { .flags = (_flags), .max_entries = (_max_entries) }; \
BPF_ANNOTATE_KV_PAIR(_name, _key_type, _leaf_type)
// Changes to the macro require changes in BFrontendAction classes
#define BPF_QUEUESTACK(_table_type, _name, _leaf_type, _max_entries, _flags) \
struct _name##_table_t { \
_leaf_type leaf; \
int * (*peek) (_leaf_type *); \
int * (*pop) (_leaf_type *); \
int * (*push) (_leaf_type *, u64); \
u32 max_entries; \
int flags; \
}; \
__attribute__((section("maps/" _table_type))) \
struct _name##_table_t _name = { .flags = (_flags), .max_entries = (_max_entries) }; \
BPF_ANNOTATE_KV_PAIR_QUEUESTACK(_name, _leaf_type)
// define queue with 3 parameters (_type=queue/stack automatically) and default flags to 0
#define BPF_QUEUE_STACK3(_type, _name, _leaf_type, _max_entries) \
BPF_QUEUESTACK(_type, _name, _leaf_type, _max_entries, 0)
// define queue with 4 parameters (_type=queue/stack automatically)
#define BPF_QUEUE_STACK4(_type, _name, _leaf_type, _max_entries, _flags) \
BPF_QUEUESTACK(_type, _name, _leaf_type, _max_entries, _flags)
// helper for default-variable macro function
#define BPF_QUEUE_STACKX(_1, _2, _3, _4, NAME, ...) NAME
#define BPF_QUEUE(...) \
BPF_QUEUE_STACKX(__VA_ARGS__, BPF_QUEUE_STACK4, BPF_QUEUE_STACK3)("queue", __VA_ARGS__)
#define BPF_STACK(...) \
BPF_QUEUE_STACKX(__VA_ARGS__, BPF_QUEUE_STACK4, BPF_QUEUE_STACK3)("stack", __VA_ARGS__)
#define BPF_QUEUESTACK_PINNED(_table_type, _name, _leaf_type, _max_entries, _flags, _pinned) \
BPF_QUEUESTACK(_table_type ":" _pinned, _name, _leaf_type, _max_entries, _flags)
#define BPF_QUEUESTACK_PUBLIC(_table_type, _name, _leaf_type, _max_entries, _flags) \
BPF_QUEUESTACK(_table_type, _name, _leaf_type, _max_entries, _flags); \
__attribute__((section("maps/export"))) \
struct _name##_table_t __##_name
#define BPF_QUEUESTACK_SHARED(_table_type, _name, _leaf_type, _max_entries, _flags) \
BPF_QUEUESTACK(_table_type, _name, _leaf_type, _max_entries, _flags); \
__attribute__((section("maps/shared"))) \
struct _name##_table_t __##_name
#define BPF_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries) \
BPF_F_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries, 0)
#define BPF_TABLE_PINNED7(_table_type, _key_type, _leaf_type, _name, _max_entries, _pinned, _flags) \
BPF_F_TABLE(_table_type ":" _pinned, _key_type, _leaf_type, _name, _max_entries, _flags)
#define BPF_TABLE_PINNED6(_table_type, _key_type, _leaf_type, _name, _max_entries, _pinned) \
BPF_F_TABLE(_table_type ":" _pinned, _key_type, _leaf_type, _name, _max_entries, 0)
#define BPF_TABLE_PINNEDX(_1, _2, _3, _4, _5, _6, _7, NAME, ...) NAME
// Define a pinned table with optional flags argument
#define BPF_TABLE_PINNED(...) \
BPF_TABLE_PINNEDX(__VA_ARGS__, BPF_TABLE_PINNED7, BPF_TABLE_PINNED6)(__VA_ARGS__)
// define a table same as above but allow it to be referenced by other modules
#define BPF_TABLE_PUBLIC(_table_type, _key_type, _leaf_type, _name, _max_entries) \
BPF_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries); \
__attribute__((section("maps/export"))) \
struct _name##_table_t __##_name
// define a table that is shared across the programs in the same namespace
#define BPF_TABLE_SHARED(_table_type, _key_type, _leaf_type, _name, _max_entries) \
BPF_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries); \
__attribute__((section("maps/shared"))) \
struct _name##_table_t __##_name
// Identifier for current CPU used in perf_submit and perf_read
// Prefer BPF_F_CURRENT_CPU flag, falls back to call helper for older kernel
// Can be overridden from BCC
#ifndef CUR_CPU_IDENTIFIER
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
#define CUR_CPU_IDENTIFIER BPF_F_CURRENT_CPU
#else
#define CUR_CPU_IDENTIFIER bpf_get_smp_processor_id()
#endif
#endif
// Table for pushing custom events to userspace via perf ring buffer
#define BPF_PERF_OUTPUT(_name) \
struct _name##_table_t { \
int key; \
u32 leaf; \
/* map.perf_submit(ctx, data, data_size) */ \
int (*perf_submit) (void *, void *, u32); \
int (*perf_submit_skb) (void *, u32, void *, u32); \
u32 max_entries; \
}; \
__attribute__((section("maps/perf_output"))) \
struct _name##_table_t _name = { .max_entries = 0 }
// Table for pushing custom events to userspace via ring buffer
#define BPF_RINGBUF_OUTPUT(_name, _num_pages) \
struct _name##_table_t { \
int key; \
u32 leaf; \
/* map.ringbuf_output(data, data_size, flags) */ \
int (*ringbuf_output) (void *, u64, u64); \
/* map.ringbuf_reserve(data_size) */ \
void* (*ringbuf_reserve) (u64); \
/* map.ringbuf_discard(data, flags) */ \
void (*ringbuf_discard) (void *, u64); \
/* map.ringbuf_submit(data, flags) */ \
void (*ringbuf_submit) (void *, u64); \
u32 max_entries; \
}; \
__attribute__((section("maps/ringbuf"))) \
struct _name##_table_t _name = { .max_entries = ((_num_pages) * PAGE_SIZE) }
// Table for reading hw perf cpu counters
#define BPF_PERF_ARRAY(_name, _max_entries) \
struct _name##_table_t { \
int key; \
u32 leaf; \
/* counter = map.perf_read(index) */ \
u64 (*perf_read) (int); \
int (*perf_counter_value) (int, void *, u32); \
u32 max_entries; \
}; \
__attribute__((section("maps/perf_array"))) \
struct _name##_table_t _name = { .max_entries = (_max_entries) }
// Table for cgroup file descriptors
#define BPF_CGROUP_ARRAY(_name, _max_entries) \
struct _name##_table_t { \
int key; \
u32 leaf; \
int (*check_current_task) (int); \
u32 max_entries; \
}; \
__attribute__((section("maps/cgroup_array"))) \
struct _name##_table_t _name = { .max_entries = (_max_entries) }
#define BPF_HASH1(_name) \
BPF_TABLE("hash", u64, u64, _name, 10240)
#define BPF_HASH2(_name, _key_type) \
BPF_TABLE("hash", _key_type, u64, _name, 10240)
#define BPF_HASH3(_name, _key_type, _leaf_type) \
BPF_TABLE("hash", _key_type, _leaf_type, _name, 10240)
#define BPF_HASH4(_name, _key_type, _leaf_type, _size) \
BPF_TABLE("hash", _key_type, _leaf_type, _name, _size)
// helper for default-variable macro function
#define BPF_HASHX(_1, _2, _3, _4, NAME, ...) NAME
// Define a hash function, some arguments optional
// BPF_HASH(name, key_type=u64, leaf_type=u64, size=10240)
#define BPF_HASH(...) \
BPF_HASHX(__VA_ARGS__, BPF_HASH4, BPF_HASH3, BPF_HASH2, BPF_HASH1)(__VA_ARGS__)
#define BPF_PERCPU_HASH1(_name) \
BPF_TABLE("percpu_hash", u64, u64, _name, 10240)
#define BPF_PERCPU_HASH2(_name, _key_type) \
BPF_TABLE("percpu_hash", _key_type, u64, _name, 10240)
#define BPF_PERCPU_HASH3(_name, _key_type, _leaf_type) \
BPF_TABLE("percpu_hash", _key_type, _leaf_type, _name, 10240)
#define BPF_PERCPU_HASH4(_name, _key_type, _leaf_type, _size) \
BPF_TABLE("percpu_hash", _key_type, _leaf_type, _name, _size)
// helper for default-variable macro function
#define BPF_PERCPU_HASHX(_1, _2, _3, _4, NAME, ...) NAME
// Define a hash function, some arguments optional
// BPF_PERCPU_HASH(name, key_type=u64, leaf_type=u64, size=10240)
#define BPF_PERCPU_HASH(...) \
BPF_PERCPU_HASHX( \
__VA_ARGS__, BPF_PERCPU_HASH4, BPF_PERCPU_HASH3, BPF_PERCPU_HASH2, BPF_PERCPU_HASH1) \
(__VA_ARGS__)
#define BPF_ARRAY1(_name) \
BPF_TABLE("array", int, u64, _name, 10240)
#define BPF_ARRAY2(_name, _leaf_type) \
BPF_TABLE("array", int, _leaf_type, _name, 10240)
#define BPF_ARRAY3(_name, _leaf_type, _size) \
BPF_TABLE("array", int, _leaf_type, _name, _size)
// helper for default-variable macro function
#define BPF_ARRAYX(_1, _2, _3, NAME, ...) NAME
// Define an array function, some arguments optional
// BPF_ARRAY(name, leaf_type=u64, size=10240)
#define BPF_ARRAY(...) \
BPF_ARRAYX(__VA_ARGS__, BPF_ARRAY3, BPF_ARRAY2, BPF_ARRAY1)(__VA_ARGS__)
#define BPF_PERCPU_ARRAY1(_name) \
BPF_TABLE("percpu_array", int, u64, _name, 10240)
#define BPF_PERCPU_ARRAY2(_name, _leaf_type) \
BPF_TABLE("percpu_array", int, _leaf_type, _name, 10240)
#define BPF_PERCPU_ARRAY3(_name, _leaf_type, _size) \
BPF_TABLE("percpu_array", int, _leaf_type, _name, _size)
// helper for default-variable macro function
#define BPF_PERCPU_ARRAYX(_1, _2, _3, NAME, ...) NAME
// Define an array function (per CPU), some arguments optional
// BPF_PERCPU_ARRAY(name, leaf_type=u64, size=10240)
#define BPF_PERCPU_ARRAY(...) \
BPF_PERCPU_ARRAYX( \
__VA_ARGS__, BPF_PERCPU_ARRAY3, BPF_PERCPU_ARRAY2, BPF_PERCPU_ARRAY1) \
(__VA_ARGS__)
#define BPF_HIST1(_name) \
BPF_TABLE("histogram", int, u64, _name, 64)
#define BPF_HIST2(_name, _key_type) \
BPF_TABLE("histogram", _key_type, u64, _name, 64)
#define BPF_HIST3(_name, _key_type, _size) \
BPF_TABLE("histogram", _key_type, u64, _name, _size)
#define BPF_HISTX(_1, _2, _3, NAME, ...) NAME
// Define a histogram, some arguments optional
// BPF_HISTOGRAM(name, key_type=int, size=64)
#define BPF_HISTOGRAM(...) \
BPF_HISTX(__VA_ARGS__, BPF_HIST3, BPF_HIST2, BPF_HIST1)(__VA_ARGS__)
#define BPF_LPM_TRIE1(_name) \
BPF_F_TABLE("lpm_trie", u64, u64, _name, 10240, BPF_F_NO_PREALLOC)
#define BPF_LPM_TRIE2(_name, _key_type) \
BPF_F_TABLE("lpm_trie", _key_type, u64, _name, 10240, BPF_F_NO_PREALLOC)
#define BPF_LPM_TRIE3(_name, _key_type, _leaf_type) \
BPF_F_TABLE("lpm_trie", _key_type, _leaf_type, _name, 10240, BPF_F_NO_PREALLOC)
#define BPF_LPM_TRIE4(_name, _key_type, _leaf_type, _size) \
BPF_F_TABLE("lpm_trie", _key_type, _leaf_type, _name, _size, BPF_F_NO_PREALLOC)
#define BPF_LPM_TRIEX(_1, _2, _3, _4, NAME, ...) NAME
// Define a LPM trie function, some arguments optional
// BPF_LPM_TRIE(name, key_type=u64, leaf_type=u64, size=10240)
#define BPF_LPM_TRIE(...) \
BPF_LPM_TRIEX(__VA_ARGS__, BPF_LPM_TRIE4, BPF_LPM_TRIE3, BPF_LPM_TRIE2, BPF_LPM_TRIE1)(__VA_ARGS__)
struct bpf_stacktrace {
u64 ip[BPF_MAX_STACK_DEPTH];
};
struct bpf_stacktrace_buildid {
struct bpf_stack_build_id trace[BPF_MAX_STACK_DEPTH];
};
#define BPF_STACK_TRACE(_name, _max_entries) \
BPF_TABLE("stacktrace", int, struct bpf_stacktrace, _name, roundup_pow_of_two(_max_entries))
#define BPF_STACK_TRACE_BUILDID(_name, _max_entries) \
BPF_F_TABLE("stacktrace", int, struct bpf_stacktrace_buildid, _name, roundup_pow_of_two(_max_entries), BPF_F_STACK_BUILD_ID)
#define BPF_PROG_ARRAY(_name, _max_entries) \
BPF_TABLE("prog", u32, u32, _name, _max_entries)
#define BPF_XDP_REDIRECT_MAP(_table_type, _leaf_type, _name, _max_entries) \
struct _name##_table_t { \
u32 key; \
_leaf_type leaf; \
/* xdp_act = map.redirect_map(index, flag) */ \
u64 (*redirect_map) (int, int); \
u32 max_entries; \
}; \
__attribute__((section("maps/"_table_type))) \
struct _name##_table_t _name = { .max_entries = (_max_entries) }
#define BPF_DEVMAP(_name, _max_entries) \
BPF_XDP_REDIRECT_MAP("devmap", int, _name, _max_entries)
#define BPF_CPUMAP(_name, _max_entries) \
BPF_XDP_REDIRECT_MAP("cpumap", u32, _name, _max_entries)
#define _BPF_XSKMAP(_name, _max_entries, _pinned) \
struct _name##_table_t { \
u32 key; \
int leaf; \
int * (*lookup) (int *); \
/* xdp_act = map.redirect_map(index, flag) */ \
u64 (*redirect_map) (int, int); \
u32 max_entries; \
}; \
__attribute__((section("maps/xskmap" _pinned))) \
struct _name##_table_t _name = { .max_entries = (_max_entries) }
#define BPF_XSKMAP2(_name, _max_entries) _BPF_XSKMAP(_name, _max_entries, "")
#define BPF_XSKMAP3(_name, _max_entries, _pinned) _BPF_XSKMAP(_name, _max_entries, ":" _pinned)
#define BPF_XSKMAPX(_1, _2, _3, NAME, ...) NAME
#define BPF_XSKMAP(...) BPF_XSKMAPX(__VA_ARGS__, BPF_XSKMAP3, BPF_XSKMAP2)(__VA_ARGS__)
#define BPF_ARRAY_OF_MAPS(_name, _inner_map_name, _max_entries) \
BPF_TABLE("array_of_maps$" _inner_map_name, int, int, _name, _max_entries)
#define BPF_HASH_OF_MAPS2(_name, _inner_map_name) \
BPF_TABLE("hash_of_maps$" _inner_map_name, int, int, _name, 10240)
#define BPF_HASH_OF_MAPS3(_name, _key_type, _inner_map_name) \
BPF_TABLE("hash_of_maps$" _inner_map_name, _key_type, int, _name, 10240)
#define BPF_HASH_OF_MAPS4(_name, _key_type, _inner_map_name, _max_entries) \
BPF_TABLE("hash_of_maps$" _inner_map_name, _key_type, int, _name, _max_entries)
#define BPF_HASH_OF_MAPSX(_name, _2, _3, _4, NAME, ...) NAME
#define BPF_HASH_OF_MAPS(...) \
BPF_HASH_OF_MAPSX(__VA_ARGS__, BPF_HASH_OF_MAPS4, BPF_HASH_OF_MAPS3, BPF_HASH_OF_MAPS2)(__VA_ARGS__)
#define BPF_SK_STORAGE(_name, _leaf_type) \
struct _name##_table_t { \
int key; \
_leaf_type leaf; \
void * (*sk_storage_get) (void *, void *, int); \
int (*sk_storage_delete) (void *); \
u32 flags; \
}; \
__attribute__((section("maps/sk_storage"))) \
struct _name##_table_t _name = { .flags = BPF_F_NO_PREALLOC }; \
BPF_ANNOTATE_KV_PAIR(_name, int, _leaf_type)
#define BPF_INODE_STORAGE(_name, _leaf_type) \
struct _name##_table_t { \
int key; \
_leaf_type leaf; \
void * (*inode_storage_get) (void *, void *, int); \
int (*inode_storage_delete) (void *); \
u32 flags; \
}; \
__attribute__((section("maps/inode_storage"))) \
struct _name##_table_t _name = { .flags = BPF_F_NO_PREALLOC }; \
BPF_ANNOTATE_KV_PAIR(_name, int, _leaf_type)
#define BPF_TASK_STORAGE(_name, _leaf_type) \
struct _name##_table_t { \
int key; \
_leaf_type leaf; \
void * (*task_storage_get) (void *, void *, int); \
int (*task_storage_delete) (void *); \
u32 flags; \
}; \
__attribute__((section("maps/task_storage"))) \
struct _name##_table_t _name = { .flags = BPF_F_NO_PREALLOC }; \
BPF_ANNOTATE_KV_PAIR(_name, int, _leaf_type)
#define BPF_SOCKMAP_COMMON(_name, _max_entries, _kind, _helper_name) \
struct _name##_table_t { \
u32 key; \
int leaf; \
int (*update) (u32 *, int *); \
int (*delete) (u32 *); \
/* ret = map.sock_map_update(ctx, key, flag) */ \
int (* _helper_name) (void *, void *, u64); \
u32 max_entries; \
}; \
__attribute__((section("maps/" _kind))) \
struct _name##_table_t _name = { .max_entries = (_max_entries) }; \
BPF_ANNOTATE_KV_PAIR(_name, u32, int)
#define BPF_SOCKMAP(_name, _max_entries) \
BPF_SOCKMAP_COMMON(_name, _max_entries, "sockmap", sock_map_update)
#define BPF_SOCKHASH_COMMON(_name, _key_type, _max_entries) \
struct _name##_table_t {\
_key_type key;\
int leaf; \
int (*update) (_key_type *, int *); \
int (*delete) (_key_type *); \
int (*sock_hash_update) (void *, void *, u64); \
int (*msg_redirect_hash) (void *, void *, u64); \
int (*sk_redirect_hash) (void *, void *, u64); \
u32 max_entries; \
}; \
__attribute__((section("maps/sockhash"))) \
struct _name##_table_t _name = { .max_entries = (_max_entries) }; \
BPF_ANNOTATE_KV_PAIR(_name, _key_type, int)
#define BPF_SOCKHASH1(_name) \
BPF_SOCKHASH_COMMON(_name, u32, 10240)
#define BPF_SOCKHASH2(_name, _key_type) \
BPF_SOCKHASH_COMMON(_name, _key_type, 10240)
#define BPF_SOCKHASH3(_name, _key_type, _max_entries) \
BPF_SOCKHASH_COMMON(_name, _key_type, _max_entries)
#define BPF_SOCKHASHX(_1, _2, _3, NAME, ...) NAME
// We can define a five-tuple as the key, and basically never define the val type.
// BPF_SOCKHASH(name, key_type=u64, size=10240)
#define BPF_SOCKHASH(...) \
BPF_SOCKHASHX(__VA_ARGS__, BPF_SOCKHASH3, BPF_SOCKHASH2, BPF_SOCKHASH1)(__VA_ARGS__)
#define BPF_CGROUP_STORAGE_COMMON(_name, _leaf_type, _kind) \
struct _name##_table_t { \
struct bpf_cgroup_storage_key key; \
_leaf_type leaf; \
_leaf_type * (*lookup) (struct bpf_cgroup_storage_key *); \
int (*update) (struct bpf_cgroup_storage_key *, _leaf_type *); \
int (*get_local_storage) (u64); \
}; \
__attribute__((section("maps/" _kind))) \
struct _name##_table_t _name = { 0 }; \
BPF_ANNOTATE_KV_PAIR(_name, struct bpf_cgroup_storage_key, _leaf_type)
#define BPF_CGROUP_STORAGE(_name, _leaf_type) \
BPF_CGROUP_STORAGE_COMMON(_name, _leaf_type, "cgroup_storage")
#define BPF_PERCPU_CGROUP_STORAGE(_name, _leaf_type) \
BPF_CGROUP_STORAGE_COMMON(_name, _leaf_type, "percpu_cgroup_storage")
// packet parsing state machine helpers
#define cursor_advance(_cursor, _len) \
({ void *_tmp = _cursor; _cursor += _len; _tmp; })
#ifdef LINUX_VERSION_CODE_OVERRIDE
unsigned _version BCC_SEC("version") = LINUX_VERSION_CODE_OVERRIDE;
#else
unsigned _version BCC_SEC("version") = LINUX_VERSION_CODE;
#endif
/* helper functions called from eBPF programs written in C */
static void *(*bpf_map_lookup_elem)(void *map, void *key) =
(void *) BPF_FUNC_map_lookup_elem;
static int (*bpf_map_update_elem)(void *map, void *key, void *value, u64 flags) =
(void *) BPF_FUNC_map_update_elem;
static int (*bpf_map_delete_elem)(void *map, void *key) =
(void *) BPF_FUNC_map_delete_elem;
static int (*bpf_probe_read)(void *dst, u64 size, const void *unsafe_ptr) =
(void *) BPF_FUNC_probe_read;
static u64 (*bpf_ktime_get_ns)(void) =
(void *) BPF_FUNC_ktime_get_ns;
static u32 (*bpf_get_prandom_u32)(void) =
(void *) BPF_FUNC_get_prandom_u32;
static int (*bpf_trace_printk_)(const char *fmt, u64 fmt_size, ...) =
(void *) BPF_FUNC_trace_printk;
static int (*bpf_probe_read_str)(void *dst, u64 size, const void *unsafe_ptr) =
(void *) BPF_FUNC_probe_read_str;
int bpf_trace_printk(const char *fmt, ...) asm("llvm.bpf.extra");
static inline __attribute__((always_inline))
void bpf_tail_call_(u64 map_fd, void *ctx, int index) {
((void (*)(void *, u64, int))BPF_FUNC_tail_call)(ctx, map_fd, index);
}
static int (*bpf_clone_redirect)(void *ctx, int ifindex, u32 flags) =
(void *) BPF_FUNC_clone_redirect;
static u64 (*bpf_get_smp_processor_id)(void) =
(void *) BPF_FUNC_get_smp_processor_id;
static u64 (*bpf_get_current_pid_tgid)(void) =
(void *) BPF_FUNC_get_current_pid_tgid;
static u64 (*bpf_get_current_uid_gid)(void) =
(void *) BPF_FUNC_get_current_uid_gid;
static int (*bpf_get_current_comm)(void *buf, int buf_size) =
(void *) BPF_FUNC_get_current_comm;
static u64 (*bpf_get_cgroup_classid)(void *ctx) =
(void *) BPF_FUNC_get_cgroup_classid;
static u64 (*bpf_skb_vlan_push)(void *ctx, u16 proto, u16 vlan_tci) =
(void *) BPF_FUNC_skb_vlan_push;
static u64 (*bpf_skb_vlan_pop)(void *ctx) =
(void *) BPF_FUNC_skb_vlan_pop;
static int (*bpf_skb_get_tunnel_key)(void *ctx, void *to, u32 size, u64 flags) =
(void *) BPF_FUNC_skb_get_tunnel_key;
static int (*bpf_skb_set_tunnel_key)(void *ctx, void *from, u32 size, u64 flags) =
(void *) BPF_FUNC_skb_set_tunnel_key;
static u64 (*bpf_perf_event_read)(void *map, u64 flags) =
(void *) BPF_FUNC_perf_event_read;
static int (*bpf_redirect)(int ifindex, u32 flags) =
(void *) BPF_FUNC_redirect;
static u32 (*bpf_get_route_realm)(void *ctx) =
(void *) BPF_FUNC_get_route_realm;
static int (*bpf_perf_event_output)(void *ctx, void *map, u64 index, void *data, u32 size) =
(void *) BPF_FUNC_perf_event_output;
static int (*bpf_skb_load_bytes)(void *ctx, int offset, void *to, u32 len) =
(void *) BPF_FUNC_skb_load_bytes;
static int (*bpf_perf_event_read_value)(void *map, u64 flags, void *buf, u32 buf_size) =
(void *) BPF_FUNC_perf_event_read_value;
static int (*bpf_perf_prog_read_value)(void *ctx, void *buf, u32 buf_size) =
(void *) BPF_FUNC_perf_prog_read_value;
static int (*bpf_current_task_under_cgroup)(void *map, int index) =
(void *) BPF_FUNC_current_task_under_cgroup;
static u32 (*bpf_get_socket_cookie)(void *ctx) =
(void *) BPF_FUNC_get_socket_cookie;
static u64 (*bpf_get_socket_uid)(void *ctx) =
(void *) BPF_FUNC_get_socket_uid;
static int (*bpf_getsockopt)(void *ctx, int level, int optname, void *optval, int optlen) =
(void *) BPF_FUNC_getsockopt;
static int (*bpf_redirect_map)(void *map, int key, int flags) =
(void *) BPF_FUNC_redirect_map;
static int (*bpf_set_hash)(void *ctx, u32 hash) =
(void *) BPF_FUNC_set_hash;
static int (*bpf_setsockopt)(void *ctx, int level, int optname, void *optval, int optlen) =
(void *) BPF_FUNC_setsockopt;
static int (*bpf_skb_adjust_room)(void *ctx, int len_diff, u32 mode, u64 flags) =
(void *) BPF_FUNC_skb_adjust_room;
static int (*bpf_skb_under_cgroup)(void *ctx, void *map, int index) =
(void *) BPF_FUNC_skb_under_cgroup;
static struct bpf_sock *(*bpf_skc_lookup_tcp)(void *ctx, struct bpf_sock_tuple *tuple, int size,
unsigned long long netns_id,
unsigned long long flags) =
(void *) BPF_FUNC_skc_lookup_tcp;
static int (*bpf_sk_redirect_map)(void *ctx, void *map, int key, int flags) =
(void *) BPF_FUNC_sk_redirect_map;
static int (*bpf_sock_map_update)(void *map, void *key, void *value, unsigned long long flags) =
(void *) BPF_FUNC_sock_map_update;
static int (*bpf_strtol)(const char *buf, size_t buf_len, u64 flags, long *res) =
(void *) BPF_FUNC_strtol;
static int (*bpf_strtoul)(const char *buf, size_t buf_len, u64 flags, unsigned long *res) =
(void *) BPF_FUNC_strtoul;
static int (*bpf_sysctl_get_current_value)(struct bpf_sysctl *ctx, char *buf, size_t buf_len) =
(void *) BPF_FUNC_sysctl_get_current_value;
static int (*bpf_sysctl_get_name)(struct bpf_sysctl *ctx, char *buf, size_t buf_len, u64 flags) =
(void *) BPF_FUNC_sysctl_get_name;
static int (*bpf_sysctl_get_new_value)(struct bpf_sysctl *ctx, char *buf, size_t buf_len) =
(void *) BPF_FUNC_sysctl_get_new_value;
static int (*bpf_sysctl_set_new_value)(struct bpf_sysctl *ctx, const char *buf, size_t buf_len) =
(void *) BPF_FUNC_sysctl_set_new_value;
static int (*bpf_tcp_check_syncookie)(void *sk, void *ip, int ip_len, void *tcp,
int tcp_len) =
(void *) BPF_FUNC_tcp_check_syncookie;
static int (*bpf_xdp_adjust_meta)(void *ctx, int offset) =
(void *) BPF_FUNC_xdp_adjust_meta;
/* bcc_get_stackid will return a negative value in the case of an error
*
* BPF_STACK_TRACE(_name, _size) will allocate space for _size stack traces.
* -ENOMEM will be returned when this limit is reached.
*
* -EFAULT is typically returned when requesting user-space stack straces (using
* BPF_F_USER_STACK) for kernel threads. However, a valid stackid may be
* returned in some cases; consider a tracepoint or kprobe executing in the
* kernel context. Given this you can typically ignore -EFAULT errors when
* retrieving user-space stack traces.
*/
static int (*bcc_get_stackid_)(void *ctx, void *map, u64 flags) =
(void *) BPF_FUNC_get_stackid;
static inline __attribute__((always_inline))
int bcc_get_stackid(uintptr_t map, void *ctx, u64 flags) {
return bcc_get_stackid_(ctx, (void *)map, flags);
}
static int (*bpf_csum_diff)(void *from, u64 from_size, void *to, u64 to_size, u64 seed) =
(void *) BPF_FUNC_csum_diff;
static int (*bpf_skb_get_tunnel_opt)(void *ctx, void *md, u32 size) =
(void *) BPF_FUNC_skb_get_tunnel_opt;
static int (*bpf_skb_set_tunnel_opt)(void *ctx, void *md, u32 size) =
(void *) BPF_FUNC_skb_set_tunnel_opt;
static int (*bpf_skb_change_proto)(void *ctx, u16 proto, u64 flags) =
(void *) BPF_FUNC_skb_change_proto;
static int (*bpf_skb_change_type)(void *ctx, u32 type) =
(void *) BPF_FUNC_skb_change_type;
static u32 (*bpf_get_hash_recalc)(void *ctx) =
(void *) BPF_FUNC_get_hash_recalc;
static u64 (*bpf_get_current_task)(void) =
(void *) BPF_FUNC_get_current_task;
static int (*bpf_probe_write_user)(void *dst, void *src, u32 size) =
(void *) BPF_FUNC_probe_write_user;
static int (*bpf_skb_change_tail)(void *ctx, u32 new_len, u64 flags) =
(void *) BPF_FUNC_skb_change_tail;
static int (*bpf_skb_pull_data)(void *ctx, u32 len) =
(void *) BPF_FUNC_skb_pull_data;
static int (*bpf_csum_update)(void *ctx, u16 csum) =
(void *) BPF_FUNC_csum_update;
static int (*bpf_set_hash_invalid)(void *ctx) =
(void *) BPF_FUNC_set_hash_invalid;
static int (*bpf_get_numa_node_id)(void) =
(void *) BPF_FUNC_get_numa_node_id;
static int (*bpf_skb_change_head)(void *ctx, u32 len, u64 flags) =
(void *) BPF_FUNC_skb_change_head;
static int (*bpf_xdp_adjust_head)(void *ctx, int offset) =
(void *) BPF_FUNC_xdp_adjust_head;
static int (*bpf_override_return)(void *pt_regs, unsigned long rc) =
(void *) BPF_FUNC_override_return;
static int (*bpf_sock_ops_cb_flags_set)(void *skops, int flags) =
(void *) BPF_FUNC_sock_ops_cb_flags_set;
static int (*bpf_msg_redirect_map)(void *msg, void *map, u32 key, u64 flags) =
(void *) BPF_FUNC_msg_redirect_map;
static int (*bpf_msg_apply_bytes)(void *msg, u32 bytes) =
(void *) BPF_FUNC_msg_apply_bytes;
static int (*bpf_msg_cork_bytes)(void *msg, u32 bytes) =
(void *) BPF_FUNC_msg_cork_bytes;
static int (*bpf_msg_pull_data)(void *msg, u32 start, u32 end, u64 flags) =
(void *) BPF_FUNC_msg_pull_data;
static int (*bpf_bind)(void *ctx, void *addr, int addr_len) =
(void *) BPF_FUNC_bind;
static int (*bpf_xdp_adjust_tail)(void *ctx, int offset) =
(void *) BPF_FUNC_xdp_adjust_tail;
static int (*bpf_skb_get_xfrm_state)(void *ctx, u32 index, void *xfrm_state, u32 size, u64 flags) =
(void *) BPF_FUNC_skb_get_xfrm_state;
static int (*bpf_get_stack)(void *ctx, void *buf, u32 size, u64 flags) =
(void *) BPF_FUNC_get_stack;
static int (*bpf_skb_load_bytes_relative)(void *ctx, u32 offset, void *to, u32 len, u32 start_header) =
(void *) BPF_FUNC_skb_load_bytes_relative;
static int (*bpf_fib_lookup)(void *ctx, void *params, int plen, u32 flags) =
(void *) BPF_FUNC_fib_lookup;
static int (*bpf_sock_hash_update)(void *ctx, void *map, void *key, u64 flags) =
(void *) BPF_FUNC_sock_hash_update;
static int (*bpf_msg_redirect_hash)(void *ctx, void *map, void *key, u64 flags) =
(void *) BPF_FUNC_msg_redirect_hash;
static int (*bpf_sk_redirect_hash)(void *ctx, void *map, void *key, u64 flags) =
(void *) BPF_FUNC_sk_redirect_hash;
static int (*bpf_lwt_push_encap)(void *skb, u32 type, void *hdr, u32 len) =
(void *) BPF_FUNC_lwt_push_encap;
static int (*bpf_lwt_seg6_store_bytes)(void *ctx, u32 offset, const void *from, u32 len) =
(void *) BPF_FUNC_lwt_seg6_store_bytes;
static int (*bpf_lwt_seg6_adjust_srh)(void *ctx, u32 offset, s32 delta) =
(void *) BPF_FUNC_lwt_seg6_adjust_srh;
static int (*bpf_lwt_seg6_action)(void *ctx, u32 action, void *param, u32 param_len) =
(void *) BPF_FUNC_lwt_seg6_action;
static int (*bpf_rc_keydown)(void *ctx, u32 protocol, u64 scancode, u32 toggle) =
(void *) BPF_FUNC_rc_keydown;
static int (*bpf_rc_repeat)(void *ctx) =
(void *) BPF_FUNC_rc_repeat;
static u64 (*bpf_skb_cgroup_id)(void *skb) =
(void *) BPF_FUNC_skb_cgroup_id;
static u64 (*bpf_get_current_cgroup_id)(void) =
(void *) BPF_FUNC_get_current_cgroup_id;
static u64 (*bpf_skb_ancestor_cgroup_id)(void *skb, int ancestor_level) =
(void *) BPF_FUNC_skb_ancestor_cgroup_id;
static void * (*bpf_get_local_storage)(void *map, u64 flags) =
(void *) BPF_FUNC_get_local_storage;
static int (*bpf_sk_select_reuseport)(void *reuse, void *map, void *key, u64 flags) =
(void *) BPF_FUNC_sk_select_reuseport;
static struct bpf_sock *(*bpf_sk_lookup_tcp)(void *ctx,
struct bpf_sock_tuple *tuple,
int size, unsigned int netns_id,
unsigned long long flags) =
(void *) BPF_FUNC_sk_lookup_tcp;
static struct bpf_sock *(*bpf_sk_lookup_udp)(void *ctx,
struct bpf_sock_tuple *tuple,
int size, unsigned int netns_id,
unsigned long long flags) =
(void *) BPF_FUNC_sk_lookup_udp;
static int (*bpf_sk_release)(void *sk) =
(void *) BPF_FUNC_sk_release;
static int (*bpf_map_push_elem)(void *map, const void *value, u64 flags) =
(void *) BPF_FUNC_map_push_elem;
static int (*bpf_map_pop_elem)(void *map, void *value) =
(void *) BPF_FUNC_map_pop_elem;
static int (*bpf_map_peek_elem)(void *map, void *value) =
(void *) BPF_FUNC_map_peek_elem;
static int (*bpf_msg_push_data)(void *skb, u32 start, u32 len, u64 flags) =
(void *) BPF_FUNC_msg_push_data;
static int (*bpf_msg_pop_data)(void *msg, u32 start, u32 pop, u64 flags) =
(void *) BPF_FUNC_msg_pop_data;
static int (*bpf_rc_pointer_rel)(void *ctx, s32 rel_x, s32 rel_y) =
(void *) BPF_FUNC_rc_pointer_rel;
static void (*bpf_spin_lock)(struct bpf_spin_lock *lock) =
(void *) BPF_FUNC_spin_lock;
static void (*bpf_spin_unlock)(struct bpf_spin_lock *lock) =
(void *) BPF_FUNC_spin_unlock;
static struct bpf_sock *(*bpf_sk_fullsock)(struct bpf_sock *sk) =
(void *) BPF_FUNC_sk_fullsock;
static struct bpf_tcp_sock *(*bpf_tcp_sock)(struct bpf_sock *sk) =
(void *) BPF_FUNC_tcp_sock;
static int (*bpf_skb_ecn_set_ce)(void *ctx) =
(void *) BPF_FUNC_skb_ecn_set_ce;
static struct bpf_sock *(*bpf_get_listener_sock)(struct bpf_sock *sk) =
(void *) BPF_FUNC_get_listener_sock;
static void *(*bpf_sk_storage_get)(void *map, void *sk,
void *value, __u64 flags) =
(void *) BPF_FUNC_sk_storage_get;
static int (*bpf_sk_storage_delete)(void *map, void *sk) =
(void *)BPF_FUNC_sk_storage_delete;
static int (*bpf_send_signal)(unsigned sig) = (void *)BPF_FUNC_send_signal;
static long long (*bpf_tcp_gen_syncookie)(void *sk, void *ip,
int ip_len, void *tcp, int tcp_len) =
(void *) BPF_FUNC_tcp_gen_syncookie;
static int (*bpf_skb_output)(void *ctx, void *map, __u64 flags, void *data,
__u64 size) =
(void *)BPF_FUNC_skb_output;
static int (*bpf_probe_read_user)(void *dst, __u32 size,
const void *unsafe_ptr) =
(void *)BPF_FUNC_probe_read_user;
static int (*bpf_probe_read_kernel)(void *dst, __u32 size,
const void *unsafe_ptr) =
(void *)BPF_FUNC_probe_read_kernel;
static int (*bpf_probe_read_user_str)(void *dst, __u32 size,
const void *unsafe_ptr) =
(void *)BPF_FUNC_probe_read_user_str;
static int (*bpf_probe_read_kernel_str)(void *dst, __u32 size,
const void *unsafe_ptr) =
(void *)BPF_FUNC_probe_read_kernel_str;
static int (*bpf_tcp_send_ack)(void *tp, __u32 rcv_nxt) =
(void *)BPF_FUNC_tcp_send_ack;
static int (*bpf_send_signal_thread)(__u32 sig) =
(void *)BPF_FUNC_send_signal_thread;
static __u64 (*bpf_jiffies64)(void) = (void *)BPF_FUNC_jiffies64;
struct bpf_perf_event_data;
static int (*bpf_read_branch_records)(struct bpf_perf_event_data *ctx, void *buf,
__u32 size, __u64 flags) =
(void *)BPF_FUNC_read_branch_records;
static int (*bpf_get_ns_current_pid_tgid)(__u64 dev, __u64 ino,
struct bpf_pidns_info *nsdata,
__u32 size) =
(void *)BPF_FUNC_get_ns_current_pid_tgid;
struct bpf_map;
static int (*bpf_xdp_output)(void *ctx, struct bpf_map *map, __u64 flags,
void *data, __u64 size) =
(void *)BPF_FUNC_xdp_output;
static __u64 (*bpf_get_netns_cookie)(void *ctx) = (void *)BPF_FUNC_get_netns_cookie;
static __u64 (*bpf_get_current_ancestor_cgroup_id)(int ancestor_level) =
(void *)BPF_FUNC_get_current_ancestor_cgroup_id;
struct sk_buff;
static int (*bpf_sk_assign)(void *skb, void *sk, __u64 flags) =
(void *)BPF_FUNC_sk_assign;
static __u64 (*bpf_ktime_get_boot_ns)(void) = (void *)BPF_FUNC_ktime_get_boot_ns;
struct seq_file;
static int (*bpf_seq_printf)(struct seq_file *m, const char *fmt, __u32 fmt_size,
const void *data, __u32 data_len) =
(void *)BPF_FUNC_seq_printf;
static int (*bpf_seq_write)(struct seq_file *m, const void *data, __u32 len) =
(void *)BPF_FUNC_seq_write;
static __u64 (*bpf_sk_cgroup_id)(void *sk) = (void *)BPF_FUNC_sk_cgroup_id;
static __u64 (*bpf_sk_ancestor_cgroup_id)(void *sk, int ancestor_level) =
(void *)BPF_FUNC_sk_ancestor_cgroup_id;
static int (*bpf_ringbuf_output)(void *ringbuf, void *data, __u64 size, __u64 flags) =
(void *)BPF_FUNC_ringbuf_output;
static void *(*bpf_ringbuf_reserve)(void *ringbuf, __u64 size, __u64 flags) =
(void *)BPF_FUNC_ringbuf_reserve;
static void (*bpf_ringbuf_submit)(void *data, __u64 flags) =
(void *)BPF_FUNC_ringbuf_submit;
static void (*bpf_ringbuf_discard)(void *data, __u64 flags) =
(void *)BPF_FUNC_ringbuf_discard;
static __u64 (*bpf_ringbuf_query)(void *ringbuf, __u64 flags) =
(void *)BPF_FUNC_ringbuf_query;
static int (*bpf_csum_level)(struct __sk_buff *skb, __u64 level) =
(void *)BPF_FUNC_csum_level;
struct tcp6_sock;
struct tcp_sock;
struct tcp_timewait_sock;
struct tcp_request_sock;
struct udp6_sock;
static struct tcp6_sock *(*bpf_skc_to_tcp6_sock)(void *sk) =
(void *)BPF_FUNC_skc_to_tcp6_sock;
static struct tcp_sock *(*bpf_skc_to_tcp_sock)(void *sk) =
(void *)BPF_FUNC_skc_to_tcp_sock;
static struct tcp_timewait_sock *(*bpf_skc_to_tcp_timewait_sock)(void *sk) =
(void *)BPF_FUNC_skc_to_tcp_timewait_sock;
static struct tcp_request_sock *(*bpf_skc_to_tcp_request_sock)(void *sk) =
(void *)BPF_FUNC_skc_to_tcp_request_sock;
static struct udp6_sock *(*bpf_skc_to_udp6_sock)(void *sk) =
(void *)BPF_FUNC_skc_to_udp6_sock;
struct task_struct;
static long (*bpf_get_task_stack)(struct task_struct *task, void *buf,
__u32 size, __u64 flags) =
(void *)BPF_FUNC_get_task_stack;
struct bpf_sock_ops;
static long (*bpf_load_hdr_opt)(struct bpf_sock_ops *skops, void *searchby_res,
u32 len, u64 flags) =
(void *)BPF_FUNC_load_hdr_opt;
static long (*bpf_store_hdr_opt)(struct bpf_sock_ops *skops, const void *from,
u32 len, u64 flags) =
(void *)BPF_FUNC_store_hdr_opt;
static long (*bpf_reserve_hdr_opt)(struct bpf_sock_ops *skops, u32 len,
u64 flags) =
(void *)BPF_FUNC_reserve_hdr_opt;
static void *(*bpf_inode_storage_get)(struct bpf_map *map, void *inode,
void *value, u64 flags) =
(void *)BPF_FUNC_inode_storage_get;
static int (*bpf_inode_storage_delete)(struct bpf_map *map, void *inode) =
(void *)BPF_FUNC_inode_storage_delete;
struct path;
static long (*bpf_d_path)(struct path *path, char *buf, u32 sz) =
(void *)BPF_FUNC_d_path;
static long (*bpf_copy_from_user)(void *dst, u32 size, const void *user_ptr) =
(void *)BPF_FUNC_copy_from_user;
static long (*bpf_snprintf_btf)(char *str, u32 str_size, struct btf_ptr *ptr,
u32 btf_ptr_size, u64 flags) =
(void *)BPF_FUNC_snprintf_btf;
static long (*bpf_seq_printf_btf)(struct seq_file *m, struct btf_ptr *ptr,
u32 ptr_size, u64 flags) =
(void *)BPF_FUNC_seq_printf_btf;
static u64 (*bpf_skb_cgroup_classid)(struct sk_buff *skb) =
(void *)BPF_FUNC_skb_cgroup_classid;
static long (*bpf_redirect_neigh)(u32 ifindex, struct bpf_redir_neigh *params,
u64 flags) =
(void *)BPF_FUNC_redirect_neigh;
static void * (*bpf_per_cpu_ptr)(const void *percpu_ptr, u32 cpu) =
(void *)BPF_FUNC_per_cpu_ptr;
static void * (*bpf_this_cpu_ptr)(const void *percpu_ptr) =
(void *)BPF_FUNC_this_cpu_ptr;
static long (*bpf_redirect_peer)(u32 ifindex, u64 flags) = (void *)BPF_FUNC_redirect_peer;
static void *(*bpf_task_storage_get)(void *map, struct task_struct *task,
void *value, __u64 flags) =
(void *)BPF_FUNC_task_storage_get;
static long (*bpf_task_storage_delete)(void *map, struct task_struct *task) =
(void *)BPF_FUNC_task_storage_delete;
static struct task_struct *(*bpf_get_current_task_btf)(void) =
(void *)BPF_FUNC_get_current_task_btf;
struct linux_binprm;
static long (*bpf_bprm_opts_set)(struct linux_binprm *bprm, __u64 flags) =
(void *)BPF_FUNC_bprm_opts_set;
static __u64 (*bpf_ktime_get_coarse_ns)(void) = (void *)BPF_FUNC_ktime_get_coarse_ns;
struct inode;
static long (*bpf_ima_inode_hash)(struct inode *inode, void *dst, __u32 size) =
(void *)BPF_FUNC_ima_inode_hash;
struct file;
static struct socket *(*bpf_sock_from_file)(struct file *file) =
(void *)BPF_FUNC_sock_from_file;
static long (*bpf_check_mtu)(void *ctx, __u32 ifindex, __u32 *mtu_len,
__s32 len_diff, __u64 flags) =
(void *)BPF_FUNC_check_mtu;
static long (*bpf_for_each_map_elem)(void *map, void *callback_fn,
void *callback_ctx, __u64 flags) =
(void *)BPF_FUNC_for_each_map_elem;
static long (*bpf_snprintf)(char *str, __u32 str_size, const char *fmt,
__u64 *data, __u32 data_len) =
(void *)BPF_FUNC_snprintf;
static long (*bpf_sys_bpf)(__u32 cmd, void *attr, __u32 attr_size) =
(void *)BPF_FUNC_sys_bpf;
static long (*bpf_btf_find_by_name_kind)(char *name, int name_sz, __u32 kind, int flags) =
(void *)BPF_FUNC_btf_find_by_name_kind;
static long (*bpf_sys_close)(__u32 fd) = (void *)BPF_FUNC_sys_close;
struct bpf_timer;
static long (*bpf_timer_init)(struct bpf_timer *timer, void *map, __u64 flags) =
(void *)BPF_FUNC_timer_init;
static long (*bpf_timer_set_callback)(struct bpf_timer *timer, void *callback_fn) =
(void *)BPF_FUNC_timer_set_callback;
static long (*bpf_timer_start)(struct bpf_timer *timer, __u64 nsecs, __u64 flags) =
(void *)BPF_FUNC_timer_start;
static long (*bpf_timer_cancel)(struct bpf_timer *timer) = (void *)BPF_FUNC_timer_cancel;
static __u64 (*bpf_get_func_ip)(void *ctx) = (void *)BPF_FUNC_get_func_ip;
static __u64 (*bpf_get_attach_cookie)(void *ctx) = (void *)BPF_FUNC_get_attach_cookie;
static long (*bpf_task_pt_regs)(struct task_struct *task) = (void *)BPF_FUNC_task_pt_regs;
static long (*bpf_get_branch_snapshot)(void *entries, __u32 size, __u64 flags) =
(void *)BPF_FUNC_get_branch_snapshot;
static long (*bpf_trace_vprintk)(const char *fmt, __u32 fmt_size, const void *data,
__u32 data_len) =
(void *)BPF_FUNC_trace_vprintk;
static struct unix_sock *(*bpf_skc_to_unix_sock)(void *sk) =
(void *)BPF_FUNC_skc_to_unix_sock;
static long (*bpf_kallsyms_lookup_name)(const char *name, int name_sz, int flags,
__u64 *res) =
(void *)BPF_FUNC_kallsyms_lookup_name;
static long (*bpf_find_vma)(struct task_struct *task, __u64 addr, void *callback_fn,
void *callback_ctx, __u64 flags) =
(void *)BPF_FUNC_find_vma;
static long (*bpf_loop)(__u32 nr_loops, void *callback_fn, void *callback_ctx, __u64 flags) =
(void *)BPF_FUNC_loop;
static long (*bpf_strncmp)(const char *s1, __u32 s1_sz, const char *s2) =
(void *)BPF_FUNC_strncmp;
static long (*bpf_get_func_arg)(void *ctx, __u32 n, __u64 *value) =
(void *)BPF_FUNC_get_func_arg;
static long (*bpf_get_func_ret)(void *ctx, __u64 *value) = (void *)BPF_FUNC_get_func_ret;
static long (*bpf_get_func_arg_cnt)(void *ctx) = (void *)BPF_FUNC_get_func_arg_cnt;
static int (*bpf_get_retval)(void) = (void *)BPF_FUNC_get_retval;
static int (*bpf_set_retval)(int retval) = (void *)BPF_FUNC_set_retval;
static __u64 (*bpf_xdp_get_buff_len)(struct xdp_md *xdp_md) = (void *)BPF_FUNC_xdp_get_buff_len;
static long (*bpf_xdp_load_bytes)(struct xdp_md *xdp_md, __u32 offset, void *buf, __u32 len) =
(void *)BPF_FUNC_xdp_load_bytes;
static long (*bpf_xdp_store_bytes)(struct xdp_md *xdp_md, __u32 offset, void *buf, __u32 len) =
(void *)BPF_FUNC_xdp_store_bytes;
static long (*bpf_copy_from_user_task)(void *dst, __u32 size, const void *user_ptr,
struct task_struct *tsk, __u64 flags) =
(void *)BPF_FUNC_copy_from_user_task;
static long (*bpf_skb_set_tstamp)(struct __sk_buff *skb, __u64 tstamp, __u32 tstamp_type) =
(void *)BPF_FUNC_skb_set_tstamp;
static long (*bpf_ima_file_hash)(struct file *file, void *dst, __u32 size) =
(void *)BPF_FUNC_ima_file_hash;
static void *(*bpf_kptr_xchg)(void *map_value, void *ptr) = (void *)BPF_FUNC_kptr_xchg;
static void *(*bpf_map_lookup_percpu_elem)(void *map, const void *key, __u32 cpu) =
(void *)BPF_FUNC_map_lookup_percpu_elem;
struct mptcp_sock;
struct bpf_dynptr;
struct iphdr;
struct ipv6hdr;
struct tcphdr;
static struct mptcp_sock *(*bpf_skc_to_mptcp_sock)(void *sk) =
(void *)BPF_FUNC_skc_to_mptcp_sock;
static long (*bpf_dynptr_from_mem)(void *data, __u32 size, __u64 flags,
struct bpf_dynptr *ptr) =