Skip to content

Commit

Permalink
bpf: icmp6: wire up ext_err for icmp6_handle_ns()
Browse files Browse the repository at this point in the history
Allow tail_call_internal() to return the index of a missed tail-call.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
  • Loading branch information
julianwiedmann committed Jan 10, 2024
1 parent a5c091c commit 7b5195e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bpf/bpf_lxc.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ static __always_inline int __tail_handle_ipv6(struct __ctx_buff *ctx,
* are subjected to forwarding into the container.
*/
if (unlikely(is_icmp6_ndp(ctx, ip6, ETH_HLEN)))
return icmp6_ndp_handle(ctx, ETH_HLEN, METRIC_EGRESS);
return icmp6_ndp_handle(ctx, ETH_HLEN, METRIC_EGRESS, ext_err);

if (unlikely(!is_valid_lxc_src_ip(ip6)))
return DROP_INVALID_SIP;
Expand Down
11 changes: 7 additions & 4 deletions bpf/lib/icmp6.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,18 +346,20 @@ int tail_icmp6_handle_ns(struct __ctx_buff *ctx)
* @ctx: socket buffer
* @nh_off: offset to the IPv6 header
* @direction: direction of packet(ingress or egress)
* @ext_err: extended error value
*
* Respond to ICMPv6 Neighbour Solicitation
*
* NOTE: This is terminal function and will cause the BPF program to exit
*/
static __always_inline int icmp6_handle_ns(struct __ctx_buff *ctx, int nh_off,
enum metric_dir direction)
enum metric_dir direction,
__s8 *ext_err)
{
ctx_store_meta(ctx, 0, nh_off);
ctx_store_meta(ctx, 1, direction);

return tail_call_internal(ctx, CILIUM_CALL_HANDLE_ICMP6_NS, NULL);
return tail_call_internal(ctx, CILIUM_CALL_HANDLE_ICMP6_NS, ext_err);
}

static __always_inline bool
Expand All @@ -373,7 +375,8 @@ is_icmp6_ndp(struct __ctx_buff *ctx, const struct ipv6hdr *ip6, int nh_off)
}

static __always_inline int icmp6_ndp_handle(struct __ctx_buff *ctx, int nh_off,
enum metric_dir direction)
enum metric_dir direction,
__s8 *ext_err)
{
__u8 type;

Expand All @@ -382,7 +385,7 @@ static __always_inline int icmp6_ndp_handle(struct __ctx_buff *ctx, int nh_off,

cilium_dbg(ctx, DBG_ICMP6_HANDLE, type, 0);
if (type == ICMP6_NS_MSG_TYPE)
return icmp6_handle_ns(ctx, nh_off, direction);
return icmp6_handle_ns(ctx, nh_off, direction, ext_err);

/* All branching above will have issued a tail call, all
* remaining traffic is subject to forwarding to containers.
Expand Down

0 comments on commit 7b5195e

Please sign in to comment.