Reputation: 6484
I'm looking in the ebpf
verifier code, and I can't get my head around the following macros:
#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
#define offsetofend(TYPE, MEMBER) \
(offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))
<...>
#define bpf_ctx_range(TYPE, MEMBER) \
offsetof(TYPE, MEMBER) ... offsetofend(TYPE, MEMBER) - 1
#define bpf_ctx_range_till(TYPE, MEMBER1, MEMBER2) \
offsetof(TYPE, MEMBER1) ... offsetofend(TYPE, MEMBER2) - 1
I understand offsetof
and offsetofend
macros, but what is ...
meaning?
Thanks.
Upvotes: 4
Views: 253
Reputation: 3206
Check out how it's used in filter.c
:
case bpf_ctx_range(struct __sk_buff, data):
This is GCC's case range extension (it's also supported by clang). With it, a single case statement can match on a range of values, like case 0 ... 5:
. There's more information here:
https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html
Upvotes: 5