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

cilium: fix encryption flow labels in ip6 case #12015

Merged
merged 1 commit into from
Jun 12, 2020
Merged
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
29 changes: 15 additions & 14 deletions bpf/bpf_lxc.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static __always_inline int ipv6_l3_from_lxc(struct __ctx_buff *ctx,
*/
ret = encap_and_redirect_lxc(ctx, tunnel_endpoint, encrypt_key, &key, SECLABEL, monitor);
if (ret == IPSEC_ENDPOINT)
goto pass_to_stack;
goto encrypt_to_stack;
else if (ret != DROP_NO_TUNNEL_ENDPOINT)
return ret;
}
Expand Down Expand Up @@ -346,10 +346,6 @@ static __always_inline int ipv6_l3_from_lxc(struct __ctx_buff *ctx,
if (ipv6_store_flowlabel(ctx, l3_off, SECLABEL_NB) < 0)
return DROP_WRITE_ERROR;

send_trace_notify(ctx, TRACE_TO_STACK, SECLABEL, *dstID, 0, 0,
reason, monitor);

cilium_dbg_capture(ctx, DBG_CAPTURE_DELIVERY, 0);
#ifndef ENCAP_IFINDEX
#ifdef ENABLE_IPSEC
if (encrypt_key && tunnel_endpoint) {
Expand All @@ -369,6 +365,14 @@ static __always_inline int ipv6_l3_from_lxc(struct __ctx_buff *ctx,
set_identity_mark(ctx, SECLABEL);
}

#ifdef ENCAP_IFINDEX
encrypt_to_stack:
#endif
send_trace_notify(ctx, TRACE_TO_STACK, SECLABEL, *dstID, 0, 0,
reason, monitor);

cilium_dbg_capture(ctx, DBG_CAPTURE_DELIVERY, 0);

return CTX_ACT_OK;
}

Expand Down Expand Up @@ -663,7 +667,7 @@ static __always_inline int handle_ipv4_from_lxc(struct __ctx_buff *ctx,
* for further processing.
*/
else if (ret == IPSEC_ENDPOINT)
goto pass_to_stack;
goto encrypt_to_stack;
/* This is either redirect by encap code or an error has occured
* either way return and stack will consume ctx.
*/
Expand Down Expand Up @@ -697,14 +701,6 @@ static __always_inline int handle_ipv4_from_lxc(struct __ctx_buff *ctx,
if (unlikely(ret != CTX_ACT_OK))
return ret;
#endif

/* FIXME: We can't store the security context anywhere here so all
* packets to other nodes will look like they come from an outside
* network.
*/

send_trace_notify(ctx, TRACE_TO_STACK, SECLABEL, *dstID, 0, 0,
reason, monitor);
#ifndef ENCAP_IFINDEX
#ifdef ENABLE_IPSEC
if (encrypt_key && tunnel_endpoint) {
Expand All @@ -724,6 +720,11 @@ static __always_inline int handle_ipv4_from_lxc(struct __ctx_buff *ctx,
set_identity_mark(ctx, SECLABEL);
}

#ifdef ENCAP_IFINDEX
encrypt_to_stack:
#endif
send_trace_notify(ctx, TRACE_TO_STACK, SECLABEL, *dstID, 0, 0,
reason, monitor);
cilium_dbg_capture(ctx, DBG_CAPTURE_DELIVERY, 0);
return CTX_ACT_OK;
}
Expand Down