Skip to content

Commit 8aea638

Browse files
committed
bpf: declare IP header pointer variables as __maybe_unused
Use __maybe_unused to declare IP header pointer variables instead of relying on ENABLE_IPV{4,6} and conditionally declaring them. This helps readability and is in line with other areas of the code. Signed-off-by: Tobias Klauser <tobias@cilium.io>
1 parent 3642fc4 commit 8aea638

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

bpf/lib/encrypt.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,12 @@ set_ipsec_encrypt(struct __ctx_buff *ctx, struct remote_endpoint_info *info,
113113
static __always_inline int
114114
do_decrypt(struct __ctx_buff *ctx, __u16 proto)
115115
{
116+
struct ipv6hdr __maybe_unused *ip6;
117+
struct iphdr __maybe_unused *ip4;
116118
void *data, *data_end;
117119
__u8 protocol = 0;
118120
__u16 node_id = 0;
119121
bool decrypted;
120-
#ifdef ENABLE_IPV6
121-
struct ipv6hdr *ip6;
122-
#endif
123-
#ifdef ENABLE_IPV4
124-
struct iphdr *ip4;
125-
#endif
126122

127123
decrypted = ((ctx->mark & MARK_MAGIC_HOST_MASK) == MARK_MAGIC_DECRYPT);
128124

bpf/lib/wireguard.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,8 @@ static __always_inline bool
195195
strict_allow(struct __ctx_buff *ctx, __be16 proto) {
196196
struct remote_endpoint_info __maybe_unused *dest_info, __maybe_unused *src_info;
197197
bool __maybe_unused in_strict_cidr = false;
198+
struct iphdr __maybe_unused *ip4;
198199
void *data, *data_end;
199-
#ifdef ENABLE_IPV4
200-
struct iphdr *ip4;
201-
#endif
202200

203201
switch (proto) {
204202
#ifdef ENABLE_IPV4

0 commit comments

Comments
 (0)