R6 invalid mem access 'inv'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am newbie to BPF and I have a consistent "R6 invalid mem access 'inv'" 
error in issue https://github.com/cilium/cilium/issues/16517 when 
attempting to rewrite the skb destination MAC address. I am guessing I 
could be missing something basic and not nessarily related to Cilium. 
This is xdp newbie list, but by any chance, anyone could point out where I 
did wrong, I have tried three variant of patches there and I get same "R6 
invalid mem access 'inv'" error at bpf load and verifier time.

one of the patch is simply to hard code the MAC as below, but still got 
the invalid mem access error

diff --git a/bpf/lib/common.h b/bpf/lib/common.h
index 3e1b11a5f..c6e980776 100644
--- a/bpf/lib/common.h
+++ b/bpf/lib/common.h
@@ -23,6 +23,7 @@
  * #endif
  */
 #define NEEDS_TIMEOUT 1
+#define VTEP_MAC  { .addr = { 0xce, 0x72, 0xa7, 0x03, 0x88, 0x58 } }
 
 #ifndef AF_INET
 #define AF_INET 2
diff --git a/bpf/lib/encap.h b/bpf/lib/encap.h
index dfd87bd82..044579b00 100644
--- a/bpf/lib/encap.h
+++ b/bpf/lib/encap.h
@@ -119,6 +119,7 @@ __encap_with_nodeid(struct __ctx_buff *ctx, __u32 
tunnel_endpoint,
        struct bpf_tunnel_key key = {};
        __u32 node_id;
        int ret;
+       union macaddr vtep_mac = VTEP_MAC;
 
        /* When encapsulating, a packet originating from the local host is
         * being considered as a packet from a remote node as it is being
@@ -137,6 +138,8 @@ __encap_with_nodeid(struct __ctx_buff *ctx, __u32 
tunnel_endpoint,
        ret = ctx_set_tunnel_key(ctx, &key, sizeof(key), 
BPF_F_ZERO_CSUM_TX);
        if (unlikely(ret < 0))
                return DROP_WRITE_ERROR;
+       if (eth_store_daddr(ctx, (__u8 *) &vtep_mac.addr, 0) < 0)
+                return DROP_WRITE_ERROR;
 
        send_trace_notify(ctx, TRACE_TO_OVERLAY, seclabel, 0, 0, 
ENCAP_IFINDEX,
                          0, monitor);
 



[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux