All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Oskolkov <posk@google.com>
To: David Ahern <dsahern@gmail.com>
Cc: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org,
	posk.devel@gmail.com
Subject: Re: [PATCH bpf-next 1/2] bpf: add BPF_LWT_ENCAP_IP option to bpf_lwt_push_encap
Date: Fri, 30 Nov 2018 15:35:56 -0800	[thread overview]
Message-ID: <CAPNVh5fSVeKhfpovBiV222zP8zA9zNbrva7Ek6fO5nNh6vJz_w@mail.gmail.com> (raw)
In-Reply-To: <50f3135e-5e24-d152-b99c-ca86260fbe12@gmail.com>

Thanks, David! This is for egress only, so I'll add an appropriate
check. I'll also address your other comments/concerns in a v2 version
of this patchset.
On Fri, Nov 30, 2018 at 12:08 PM David Ahern <dsahern@gmail.com> wrote:
>
> On 11/28/18 6:34 PM, Peter Oskolkov wrote:
> > On Wed, Nov 28, 2018 at 4:47 PM David Ahern <dsahern@gmail.com> 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!
> >
>
> Is the encap happening on ingress or egress? Seems like the current code
> does not assume either direction for lwt (BPF_PROG_TYPE_LWT_IN vs
> BPF_PROG_TYPE_LWT_OUT), yet your change does - output only. Basically,
> you should be filling in a flow struct and doing a proper lookup.
>
> When the potentially custom encap header is pushed on, seems to me skb
> marks should still be honored for the route lookup. If not, you should
> handle that in the API.
>
> From there skb->dev at a minimum should be used as either iif (ingress)
> or oif (egress).
>
> The iph is already set so you have quick access to the tos.
>
> Also, this should implement IPv6 as well before going in.

  reply	other threads:[~2018-12-01 10:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29  0:22 [PATCH bpf-next 1/2] bpf: add BPF_LWT_ENCAP_IP option to bpf_lwt_push_encap Peter Oskolkov
2018-11-29  0:22 ` [PATCH bpf-next 2/2] selftests/bpf: add test_lwt_ip_encap selftest Peter Oskolkov
2018-11-29  0:47 ` [PATCH bpf-next 1/2] bpf: add BPF_LWT_ENCAP_IP option to bpf_lwt_push_encap David Ahern
2018-11-29  1:34   ` Peter Oskolkov
2018-11-30 20:08     ` David Ahern
2018-11-30 23:35       ` Peter Oskolkov [this message]
2018-11-30 23:51         ` David Ahern
2018-12-01  0:14           ` Peter Oskolkov
2018-12-03 16:04             ` David Ahern
2018-12-03 16:55               ` Peter Oskolkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPNVh5fSVeKhfpovBiV222zP8zA9zNbrva7Ek6fO5nNh6vJz_w@mail.gmail.com \
    --to=posk@google.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=posk.devel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.