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: xdp asm volatile fix in relation to reg spill #11152

Merged
merged 3 commits into from
Apr 28, 2020
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
9 changes: 5 additions & 4 deletions bpf/include/bpf/ctx/xdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define META_PIVOT ((int)(field_sizeof(struct __sk_buff, cb) + \
sizeof(__u32) * 2))

/* This must be a mask and all offsets guaranteed to be less than that. */
#define __CTX_OFF_MAX 0xff

static __always_inline __maybe_unused int
Expand All @@ -36,7 +37,7 @@ xdp_load_bytes(struct xdp_md *ctx, __u64 off, void *to, const __u64 len)
*/
asm volatile("r1 = *(u32 *)(%[ctx] +0)\n\t"
"r2 = *(u32 *)(%[ctx] +4)\n\t"
"if %[off] > %[offmax] goto +6\n\t"
"%[off] &= %[offmax]\n\t"
"r1 += %[off]\n\t"
"%[from] = r1\n\t"
"r1 += %[len]\n\t"
Expand All @@ -62,7 +63,7 @@ xdp_store_bytes(struct xdp_md *ctx, __u64 off, const void *from,
/* See xdp_load_bytes(). */
asm volatile("r1 = *(u32 *)(%[ctx] +0)\n\t"
"r2 = *(u32 *)(%[ctx] +4)\n\t"
"if %[off] > %[offmax] goto +6\n\t"
"%[off] &= %[offmax]\n\t"
"r1 += %[off]\n\t"
"%[to] = r1\n\t"
"r1 += %[len]\n\t"
Expand Down Expand Up @@ -149,7 +150,7 @@ l3_csum_replace(struct xdp_md *ctx, __u64 off, const __u32 from, __u32 to,
/* See xdp_load_bytes(). */
asm volatile("r1 = *(u32 *)(%[ctx] +0)\n\t"
"r2 = *(u32 *)(%[ctx] +4)\n\t"
"if %[off] > %[offmax] goto +6\n\t"
"%[off] &= %[offmax]\n\t"
"r1 += %[off]\n\t"
"%[sum] = r1\n\t"
"r1 += 2\n\t"
Expand Down Expand Up @@ -186,7 +187,7 @@ l4_csum_replace(struct xdp_md *ctx, __u64 off, __u32 from, __u32 to,
/* See xdp_load_bytes(). */
asm volatile("r1 = *(u32 *)(%[ctx] +0)\n\t"
"r2 = *(u32 *)(%[ctx] +4)\n\t"
"if %[off] > %[offmax] goto +6\n\t"
"%[off] &= %[offmax]\n\t"
"r1 += %[off]\n\t"
"%[sum] = r1\n\t"
"r1 += 2\n\t"
Expand Down
2 changes: 1 addition & 1 deletion bpf/lib/nodeport.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ static __always_inline int find_dsr_v6(struct __ctx_buff *ctx, __u8 nexthdr,

static __always_inline int handle_dsr_v6(struct __ctx_buff *ctx, bool *dsr)
{
struct dsr_opt_v6 opt __align_stack_8 = {};
void *data, *data_end;
struct ipv6hdr *ip6;
struct dsr_opt_v6 opt = {};
int ret;

if (!revalidate_data(ctx, &data, &data_end, &ip6))
Expand Down
5 changes: 5 additions & 0 deletions daemon/cmd/daemon_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,11 @@ func initKubeProxyReplacementOptions() {

if option.Config.EnableNodePort &&
option.Config.NodePortAcceleration != option.NodePortAccelerationNone {
if option.Config.Tunnel != option.TunnelDisabled {
log.Fatalf("Cannot use NodePort acceleration with tunneling. Either run cilium-agent with --%s=%s or --%s=%s",
option.NodePortAcceleration, option.NodePortAccelerationNone, option.TunnelName, option.TunnelDisabled)
}

if option.Config.XDPDevice != "undefined" &&
option.Config.XDPDevice != option.Config.Device {
log.Fatalf("Cannot set NodePort acceleration device: mismatch between Prefilter device %s and NodePort device %s",
Expand Down