Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpf: Consistent usage of MARK_MAGIC_ constants #23125

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions bpf/lib/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,10 @@ enum metric_dir {
#define MARK_MAGIC_ENCRYPT 0x0E00
#define MARK_MAGIC_IDENTITY 0x0F00 /* mark carries identity */
#define MARK_MAGIC_TO_PROXY 0x0200
#define MARK_MAGIC_SNAT_DONE 0x0300

#define MARK_MAGIC_KEY_ID 0xF000
#define MARK_MAGIC_KEY_MASK 0xFF00

/* IPSec cannot be configured with NodePort BPF today, hence non-conflicting
* overlap with MARK_MAGIC_KEY_ID.
*/
#define MARK_MAGIC_SNAT_DONE 0x1500

/* MARK_MAGIC_HEALTH_IPIP_DONE can overlap with MARK_MAGIC_SNAT_DONE with both
* being mutual exclusive given former is only under DSR. Used to push health
Expand Down
3 changes: 2 additions & 1 deletion bpf/lib/overloadable_skb.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ ctx_change_head(struct __sk_buff *ctx, __u32 head_room, __u64 flags)

static __always_inline void ctx_snat_done_set(struct __sk_buff *ctx)
{
ctx->mark &= ~MARK_MAGIC_HOST_MASK;
ctx->mark |= MARK_MAGIC_SNAT_DONE;
}

static __always_inline bool ctx_snat_done(struct __sk_buff *ctx)
{
return (ctx->mark & MARK_MAGIC_SNAT_DONE) == MARK_MAGIC_SNAT_DONE;
return (ctx->mark & MARK_MAGIC_HOST_MASK) == MARK_MAGIC_SNAT_DONE;
}

#ifdef HAVE_ENCAP
Expand Down