github.com/cilium/cilium@v1.16.2/bpf/include/bpf/helpers_skb.h (about)

     1  /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
     2  /* Copyright Authors of Cilium */
     3  
     4  #pragma once
     5  
     6  #include <linux/bpf.h>
     7  
     8  #include "compiler.h"
     9  #include "helpers.h"
    10  #include "features_skb.h"
    11  
    12  /* Only used helpers in Cilium go below. */
    13  
    14  /* Packet redirection */
    15  static int BPF_FUNC(redirect, int ifindex, __u32 flags);
    16  static int BPF_FUNC(redirect_neigh, int ifindex, struct bpf_redir_neigh *params,
    17  		    int plen, __u32 flags);
    18  static int BPF_FUNC(redirect_peer, int ifindex, __u32 flags);
    19  static int BPF_FUNC(clone_redirect, struct __sk_buff *skb, __u32 ifindex, __u64 flags);
    20  
    21  /* Packet manipulation */
    22  static int BPF_FUNC(skb_load_bytes, struct __sk_buff *skb, __u32 off,
    23  		    void *to, __u32 len);
    24  static int BPF_FUNC(skb_store_bytes, struct __sk_buff *skb, __u32 off,
    25  		    const void *from, __u32 len, __u32 flags);
    26  
    27  static int BPF_FUNC(l3_csum_replace, struct __sk_buff *skb, __u32 off,
    28  		    __u32 from, __u32 to, __u32 flags);
    29  static int BPF_FUNC(l4_csum_replace, struct __sk_buff *skb, __u32 off,
    30  		    __u32 from, __u32 to, __u32 flags);
    31  
    32  static int BPF_FUNC(skb_adjust_room, struct __sk_buff *skb, __s32 len_diff,
    33  		    __u32 mode, __u64 flags);
    34  
    35  static int BPF_FUNC(skb_change_type, struct __sk_buff *skb, __u32 type);
    36  static int BPF_FUNC(skb_change_proto, struct __sk_buff *skb, __u32 proto,
    37  		    __u32 flags);
    38  static int BPF_FUNC(skb_change_tail, struct __sk_buff *skb, __u32 nlen,
    39  		    __u32 flags);
    40  static int BPF_FUNC(skb_change_head, struct __sk_buff *skb, __u32 head_room,
    41  		    __u64 flags);
    42  
    43  static int BPF_FUNC(skb_pull_data, struct __sk_buff *skb, __u32 len);
    44  
    45  /* Packet tunnel encap/decap */
    46  static int BPF_FUNC(skb_get_tunnel_key, struct __sk_buff *skb,
    47  		    struct bpf_tunnel_key *to, __u32 size, __u32 flags);
    48  static int BPF_FUNC(skb_set_tunnel_key, struct __sk_buff *skb,
    49  		    const struct bpf_tunnel_key *from, __u32 size,
    50  		    __u32 flags);
    51  static int BPF_FUNC(skb_get_tunnel_opt, struct __sk_buff *skb,
    52  		    void *opt, __u32 size);
    53  static int BPF_FUNC(skb_set_tunnel_opt, struct __sk_buff *skb,
    54  		    void *opt, __u32 size);
    55  
    56  /* Events for user space */
    57  static int BPF_FUNC_REMAP(skb_event_output, struct __sk_buff *skb, void *map,
    58  			  __u64 index, const void *data, __u32 size) =
    59  			 (void *)BPF_FUNC_perf_event_output;
    60  
    61  /* Socket lookup, assign, release */
    62  static struct bpf_sock *BPF_FUNC(skc_lookup_tcp, struct __sk_buff *skb,
    63  				 struct bpf_sock_tuple *tuple, __u32 tuple_size,
    64  				 __u64 netns, __u64 flags);
    65  static int BPF_FUNC(sk_release, struct bpf_sock *sk);
    66  static int BPF_FUNC(sk_assign, struct __sk_buff *skb, struct bpf_sock *sk,
    67  		    __u64 flags);