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)

View File

@@ -52,12 +52,6 @@ struct frag_hdr {
__be32 identification;
};
// constants for passing in to 'bool is_ethernet'
static const bool RAWIP = false;
static const bool ETHER = true;
#define KVER_4_14 KVER(4, 14, 0)
DEFINE_BPF_MAP_GRW(clat_ingress6_map, HASH, ClatIngress6Key, ClatIngress6Value, 16, AID_SYSTEM)
static inline __always_inline int nat64(struct __sk_buff* skb,

View File

@@ -42,10 +42,6 @@ static const int DROP_UNLESS_DNS = 2; // internal to our program
static const int BPF_NOMATCH = 0;
static const int BPF_MATCH = 1;
// Used for 'bool egress'
static const bool INGRESS = false;
static const bool EGRESS = true;
// Used for 'bool enable_tracing'
static const bool TRACE_ON = true;
static const bool TRACE_OFF = false;