[iovisor-dev] eBPF prog getting rejected with devmap (and cpumap)

Jesper Dangaard Brouer jbrouer at redhat.com
Thu Sep 21 20:02:50 UTC 2017


Hi Daniel,

My very simple program is getting rejected on bpf loading time.  When
using another map as input for a decision, for map type BPF_MAP_TYPE_DEVMAP.

SEC("xdp_redirect_map_rr")
int xdp_prog_redirect_map_rr(struct xdp_md *ctx)
{
	void *data_end = (void *)(long)ctx->data_end;
	void *data     = (void *)(long)ctx->data;
	struct ethhdr *eth = data;
	int vport = 0;
	u32 key = 0;
	long *value;

	// count packet in global counter
	value = bpf_map_lookup_elem(&rxcnt, &key);
	if (value)
		*value += 1;

	/* Strange, verifier reject this (with LLVM version 3.9.1) */
	vport = *value % 2;

	if (vport >= 10)
		return XDP_ABORTED;

	return bpf_redirect_map(&tx_port, vport, 0);
}

bpf_load_program() err=13
0: (b7) r6 = 0
1: (63) *(u32 *)(r10 -4) = r6
2: (bf) r2 = r10
3: (07) r2 += -4
4: (18) r1 = 0xffff880832682700
6: (85) call bpf_map_lookup_elem#1
7: (79) r2 = *(u64 *)(r0 +0)
R0 invalid mem access 'map_value_or_null'

Are we missing something verifier code for BPF_MAP_TYPE_DEVMAP ?

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


More information about the iovisor-dev mailing list