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

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


On Thu, 21 Sep 2017 22:06:27 +0200
Daniel Borkmann <daniel at iogearbox.net> wrote:

> On 09/21/2017 10:02 PM, Jesper Dangaard Brouer via iovisor-dev wrote:
> > 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;  
> 
> Here it's dereferenced where above it could have been NULL
> from the lookup, so verifier is correct. You'd need to place
> it into the if clause above or just do 'if (!value) return XDP_ABORTED'
> or the like.

Ah, I see!  Thanks for the quick answer and solution :-)

-- 
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