Skip to content

Commit

Permalink
bpf: Fix usage of tunnel map structs
Browse files Browse the repository at this point in the history
Commit 16e132e ("bpf, maps: Give the tunnel map its own structs") gave
the tunnel map its own structs for key and value. In that commit, I
however forgot to replace the structs in the lookups, on the BPF side.
CI passed nonetheless because the fields used in the former and new
structs are currently identical (because the cluster ID isn't used).

This commit fixes it by actually using the new tunnel_{key,value}
structs.

Fixes: 16e132e ("bpf, maps: Give the tunnel map its own structs")
Signed-off-by: Paul Chaignon <[email protected]>
  • Loading branch information
pchaigno authored and qmonnet committed Jan 31, 2023
1 parent 0abaec5 commit cce7976
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bpf/bpf_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ handle_ipv6(struct __ctx_buff *ctx, __u32 secctx, const bool from_host,
info->key, secctx, info->sec_label,
&trace);
} else {
struct endpoint_key key = {};
struct tunnel_key key = {};

/* IPv6 lookup key: daddr/96 */
dst = (union v6addr *) &ip6->daddr;
Expand Down Expand Up @@ -599,7 +599,7 @@ handle_ipv4(struct __ctx_buff *ctx, __u32 secctx,
&trace);
} else {
/* IPv4 lookup key: daddr & IPV4_MASK */
struct endpoint_key key = {};
struct tunnel_key key = {};

key.ip4 = ip4->daddr & IPV4_MASK;
key.family = ENDPOINT_KEY_IPV4;
Expand Down
4 changes: 2 additions & 2 deletions bpf/bpf_lxc.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ static __always_inline int handle_ipv6_from_lxc(struct __ctx_buff *ctx, __u32 *d
/* The packet goes to a peer not managed by this agent instance */
#ifdef TUNNEL_MODE
{
struct endpoint_key key = {};
struct tunnel_key key = {};
union v6addr *daddr = (union v6addr *)&ip6->daddr;

/* Lookup the destination prefix in the list of known
Expand Down Expand Up @@ -1028,7 +1028,7 @@ static __always_inline int handle_ipv4_from_lxc(struct __ctx_buff *ctx, __u32 *d

#ifdef TUNNEL_MODE
{
struct endpoint_key key = {};
struct tunnel_key key = {};

key.ip4 = ip4->daddr & IPV4_MASK;
key.family = ENDPOINT_KEY_IPV4;
Expand Down
8 changes: 4 additions & 4 deletions bpf/lib/encap.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ __encap_and_redirect_lxc(struct __ctx_buff *ctx, __u32 tunnel_endpoint,
*/
static __always_inline int
encap_and_redirect_lxc(struct __ctx_buff *ctx, __u32 tunnel_endpoint,
__u8 encrypt_key, struct endpoint_key *key, __u32 seclabel,
__u8 encrypt_key, struct tunnel_key *key, __u32 seclabel,
__u32 dstid, const struct trace_ctx *trace)
{
struct endpoint_key *tunnel;
struct tunnel_value *tunnel;

if (tunnel_endpoint)
return __encap_and_redirect_lxc(ctx, tunnel_endpoint,
Expand All @@ -271,10 +271,10 @@ encap_and_redirect_lxc(struct __ctx_buff *ctx, __u32 tunnel_endpoint,
}

static __always_inline int
encap_and_redirect_netdev(struct __ctx_buff *ctx, struct endpoint_key *k,
encap_and_redirect_netdev(struct __ctx_buff *ctx, struct tunnel_key *k,
__u32 seclabel, const struct trace_ctx *trace)
{
struct endpoint_key *tunnel;
struct tunnel_value *tunnel;

tunnel = map_lookup_elem(&TUNNEL_MAP, k);
if (!tunnel)
Expand Down

0 comments on commit cce7976

Please sign in to comment.