From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH iproute2] ip: add support for seg6local End.BPF action Date: Mon, 16 Jul 2018 07:48:48 -0700 Message-ID: <20180716074848.07fc6bca@xeon-e3> References: <20180716144741.20478-1-m.xhonneux@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, dsahern@gmail.com, dlebrun@google.com To: Mathieu Xhonneux Return-path: Received: from mail-pg1-f196.google.com ([209.85.215.196]:37809 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727452AbeGPPQg (ORCPT ); Mon, 16 Jul 2018 11:16:36 -0400 Received: by mail-pg1-f196.google.com with SMTP id n7-v6so716636pgq.4 for ; Mon, 16 Jul 2018 07:48:51 -0700 (PDT) In-Reply-To: <20180716144741.20478-1-m.xhonneux@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 16 Jul 2018 14:47:41 +0000 Mathieu Xhonneux 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 > --- > 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.