On Mon, 16 Jul 2018 14:47:41 +0000
Mathieu Xhonneux <m.xhonn...@gmail.com> wrote:

> This patch adds support for the End.BPF action of the seg6local
> lightweight tunnel. Functions from the BPF lightweight tunnel are
> re-used in this patch. Example:
> 
> $ ip -6 route add fc00::18 encap seg6local action End.BPF obj my_bpf.o
> sec my_func dev eth0
> 
> $ ip -6 route show fc00::18
> fc00::18  encap seg6local action End.BPF my_bpf.o:[my_func] dev eth0
> metric 1024 pref medium
> 
> Signed-off-by: Mathieu Xhonneux <m.xhonn...@gmail.com>

> ---
>  ip/iproute_lwtunnel.c | 122 
> +++++++++++++++++++++++++++++---------------------
>  lib/bpf.c             |   5 +++
>  2 files changed, 77 insertions(+), 50 deletions(-)
> 
> diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
> index 46a212c8..71c3d8a4 100644
> --- a/ip/iproute_lwtunnel.c
> +++ b/ip/iproute_lwtunnel.c
> @@ -177,6 +177,7 @@ static const char 
> *seg6_action_names[SEG6_LOCAL_ACTION_MAX + 1] = {
>       [SEG6_LOCAL_ACTION_END_S]               = "End.S",
>       [SEG6_LOCAL_ACTION_END_AS]              = "End.AS",
>       [SEG6_LOCAL_ACTION_END_AM]              = "End.AM",
> +     [SEG6_LOCAL_ACTION_END_BPF]             = "End.BPF",
>  };
>  
>  static const char *format_action_type(int action)
> @@ -250,6 +251,15 @@ static void print_encap_seg6local(FILE *fp, struct 
> rtattr *encap)
>               print_string(PRINT_ANY, "oif",
>                            "oif %s ", ll_index_to_name(oif));
>       }
> +
> +     if (tb[SEG6_LOCAL_BPF]) {
> +             struct rtattr *tb_bpf[LWT_BPF_PROG_MAX+1];
> +
> +             parse_rtattr_nested(tb_bpf, LWT_BPF_PROG_MAX, 
> tb[SEG6_LOCAL_BPF]);
> +
> +             if (tb_bpf[LWT_BPF_PROG_NAME])
> +                     fprintf(fp, "%s ", 
> rta_getattr_str(tb_bpf[LWT_BPF_PROG_NAME]));
> +     }
>  }

Please use print_string to support JSON output.

Reply via email to