From: Paul Chaignon <paul@isovalent.com>
To: Yonghong Song <yhs@fb.com>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
Martin KaFai Lau <martin.lau@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
Kaixi Fan <fankaixi.li@bytedance.com>,
Nikolay Aleksandrov <razor@blackwall.org>
Subject: Re: [PATCH bpf 4/5] bpf: Set flow flag to allow any source IP in bpf_tunnel_key
Date: Mon, 18 Jul 2022 14:21:59 +0200 [thread overview]
Message-ID: <20220718122159.GA23451@Mem> (raw)
In-Reply-To: <fe77bef0-bbfa-261d-6419-548160c986e5@fb.com>
On Fri, Jul 15, 2022 at 11:21:08AM -0700, Yonghong Song wrote:
> On 7/15/22 8:02 AM, Paul Chaignon wrote:
> > Commit 26101f5ab6bd ("bpf: Add source ip in "struct bpf_tunnel_key"")
> > added support for getting and setting the outer source IP of encapsulated
> > packets via the bpf_skb_{get,set}_tunnel_key BPF helper. This change
> > allows BPF programs to set any IP address as the source, including for
> > example the IP address of a container running on the same host.
> >
> > In that last case, however, the encapsulated packets are dropped when
> > looking up the route because the source IP address isn't assigned to any
> > interface on the host. To avoid this, we need to set the
> > FLOWI_FLAG_ANYSRC flag.
> >
> > Fixes: 26101f5ab6bd ("bpf: Add source ip in "struct bpf_tunnel_key"")
> > Signed-off-by: Paul Chaignon <paul@isovalent.com>
> > ---
> > net/core/filter.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index 5d16d66727fc..6d9c800cdab9 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -4641,6 +4641,7 @@ BPF_CALL_4(bpf_skb_set_tunnel_key, struct sk_buff *, skb,
> > info->key.tun_id = cpu_to_be64(from->tunnel_id);
> > info->key.tos = from->tunnel_tos;
> > info->key.ttl = from->tunnel_ttl;
> > + info->key.flow_flags = FLOWI_FLAG_ANYSRC;
>
> Can we set FLOWI_FLAG_ANYSRC in all conditions?
> In lwt_bpf.c, func bpf_lwt_xmit_reroute(), FLOWI_FLAG_ANYSRC
> is set for ipv4 but not for ipv6. I am wondering whether
> FLOWI_FLAG_ANYSRC needs to be set for ipv6 packet or not
> in bpf_skb_set_tunnel_key().
That's a good point; I didn't know about bpf_lwt_xmit_reroute. I set the
flag for IPv6 as the same check seemed to exist, but didn't test it.
I'll check if it's actually needed.
>
> > if (flags & BPF_F_TUNINFO_IPV6) {
> > info->mode |= IP_TUNNEL_INFO_IPV6;
next prev parent reply other threads:[~2022-07-18 12:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-15 14:59 [PATCH bpf 0/5] bpf: Allow any source IP in bpf_skb_set_tunnel_key Paul Chaignon
2022-07-15 15:01 ` [PATCH bpf 1/5] ip_tunnels: Add new flow flags field to ip_tunnel_key Paul Chaignon
2022-07-15 15:01 ` [PATCH bpf 2/5] vxlan: Use ip_tunnel_key flow flags in route lookups Paul Chaignon
2022-07-15 15:02 ` [PATCH bpf 3/5] geneve: " Paul Chaignon
2022-07-15 15:02 ` [PATCH bpf 4/5] bpf: Set flow flag to allow any source IP in bpf_tunnel_key Paul Chaignon
2022-07-15 18:21 ` Yonghong Song
2022-07-18 12:21 ` Paul Chaignon [this message]
2022-07-18 16:04 ` Paul Chaignon
2022-07-15 15:03 ` [PATCH bpf 5/5] selftests/bpf: Don't assign outer source IP to host Paul Chaignon
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=20220718122159.GA23451@Mem \
--to=paul@isovalent.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=fankaixi.li@bytedance.com \
--cc=john.fastabend@gmail.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=razor@blackwall.org \
--cc=yhs@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).