From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Oskolkov Subject: Re: [PATCH bpf-next 1/2] bpf: add BPF_LWT_ENCAP_IP option to bpf_lwt_push_encap Date: Wed, 28 Nov 2018 17:34:10 -0800 Message-ID: References: <20181129002248.241080-1-posk@google.com> <7c92e102-3e1f-04e3-5387-1616baaa6430@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, posk.devel@gmail.com To: David Ahern Return-path: Received: from mail-lf1-f65.google.com ([209.85.167.65]:38943 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726688AbeK2MiA (ORCPT ); Thu, 29 Nov 2018 07:38:00 -0500 Received: by mail-lf1-f65.google.com with SMTP id n18so193822lfh.6 for ; Wed, 28 Nov 2018 17:34:23 -0800 (PST) In-Reply-To: <7c92e102-3e1f-04e3-5387-1616baaa6430@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, Nov 28, 2018 at 4:47 PM David Ahern wrote: > > On 11/28/18 5:22 PM, Peter Oskolkov wrote: > > diff --git a/net/core/filter.c b/net/core/filter.c > > index bd0df75dc7b6..17f3c37218e5 100644 > > --- a/net/core/filter.c > > +++ b/net/core/filter.c > > @@ -4793,6 +4793,60 @@ static int bpf_push_seg6_encap(struct sk_buff *skb, u32 type, void *hdr, u32 len > > } > > #endif /* CONFIG_IPV6_SEG6_BPF */ > > > > +static int bpf_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len) > > +{ > > + struct dst_entry *dst; > > + struct rtable *rt; > > + struct iphdr *iph; > > + struct net *net; > > + int err; > > + > > + if (skb->protocol != htons(ETH_P_IP)) > > + return -EINVAL; /* ETH_P_IPV6 not yet supported */ > > + > > + iph = (struct iphdr *)hdr; > > + > > + if (unlikely(len < sizeof(struct iphdr) || len > LWTUNNEL_MAX_ENCAP_HSIZE)) > > + return -EINVAL; > > + if (unlikely(iph->version != 4 || iph->ihl * 4 > len)) > > + return -EINVAL; > > + > > + if (skb->sk) > > + net = sock_net(skb->sk); > > + else { > > + net = dev_net(skb_dst(skb)->dev); > > + } > > + rt = ip_route_output(net, iph->daddr, 0, 0, 0); > > That is a very limited use case. e.g., oif = 0 means you are not > considering any kind of policy routing (e.g., VRF). Hi David! Could you be a bit more specific re: what you would like to see here? Thanks!