bpf_net_helpers: define some boolean constants

This will make the code more legibble once we switch to using these.

Also moving them out of the .c files so we can share the same
constants across multiple files.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5cc9058cee8d1ea10d2f9e62a38313d0728f07d3
This commit is contained in:
Maciej Żenczykowski
2023-04-19 16:37:11 -07:00
parent 2541a1924e
commit 4c33f5c958
3 changed files with 27 additions and 10 deletions

View File

@@ -86,3 +86,30 @@ static inline __always_inline void try_make_writable(struct __sk_buff* skb, int
if (len > skb->len) len = skb->len;
if (skb->data_end - skb->data < len) bpf_skb_pull_data(skb, len);
}
// constants for passing in to 'bool egress'
static const bool INGRESS = false;
static const bool EGRESS = true;
// constants for passing in to 'bool downstream'
static const bool UPSTREAM = false;
static const bool DOWNSTREAM = true;
// constants for passing in to 'bool is_ethernet'
static const bool RAWIP = false;
static const bool ETHER = true;
// constants for passing in to 'bool updatetime'
static const bool NO_UPDATETIME = false;
static const bool UPDATETIME = true;
// constants for passing in to ignore_on_eng / ignore_on_user / ignore_on_userdebug
// define's instead of static const due to tm-mainline-prod compiler static_assert limitations
#define LOAD_ON_ENG false
#define LOAD_ON_USER false
#define LOAD_ON_USERDEBUG false
#define IGNORE_ON_ENG true
#define IGNORE_ON_USER true
#define IGNORE_ON_USERDEBUG true
#define KVER_4_14 KVER(4, 14, 0)