From: Jesper Dangaard Brouer <brouer@redhat.com>
To: John Fastabend <john.fastabend@gmail.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
Daniel Borkmann <borkmann@iogearbox.net>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>,
maze@google.com, lmb@cloudflare.com, shaun@tigera.io,
Lorenzo Bianconi <lorenzo@kernel.org>,
marek@cloudflare.com, Jakub Kicinski <kuba@kernel.org>,
eyal.birger@gmail.com, brouer@redhat.com
Subject: Re: [PATCH bpf-next V5 2/5] bpf: bpf_fib_lookup return MTU value as output when looked up
Date: Mon, 2 Nov 2020 10:28:50 +0100 [thread overview]
Message-ID: <20201102102850.1dc3124a@carbon> (raw)
In-Reply-To: <5f9c6c259dfe5_16d420817@john-XPS-13-9370.notmuch>
On Fri, 30 Oct 2020 12:40:21 -0700
John Fastabend <john.fastabend@gmail.com> wrote:
> Jesper Dangaard Brouer wrote:
> > The BPF-helpers for FIB lookup (bpf_xdp_fib_lookup and bpf_skb_fib_lookup)
> > can perform MTU check and return BPF_FIB_LKUP_RET_FRAG_NEEDED. The BPF-prog
> > don't know the MTU value that caused this rejection.
> >
> > If the BPF-prog wants to implement PMTU (Path MTU Discovery) (rfc1191) it
> > need to know this MTU value for the ICMP packet.
> >
> > Patch change lookup and result struct bpf_fib_lookup, to contain this MTU
> > value as output via a union with 'tot_len' as this is the value used for
> > the MTU lookup.
> >
> > V5:
> > - Fixed uninit value spotted by Dan Carpenter.
> > - Name struct output member mtu_result
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> > ---
> > include/uapi/linux/bpf.h | 11 +++++++++--
> > net/core/filter.c | 22 +++++++++++++++-------
> > tools/include/uapi/linux/bpf.h | 11 +++++++++--
> > 3 files changed, 33 insertions(+), 11 deletions(-)
> >
> > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> > index e6ceac3f7d62..01b2b17c645a 100644
> > --- a/include/uapi/linux/bpf.h
> > +++ b/include/uapi/linux/bpf.h
> > @@ -2219,6 +2219,9 @@ union bpf_attr {
> > * * > 0 one of **BPF_FIB_LKUP_RET_** codes explaining why the
> > * packet is not forwarded or needs assist from full stack
> > *
> > + * If lookup fails with BPF_FIB_LKUP_RET_FRAG_NEEDED, then the MTU
> > + * was exceeded and result params->mtu contains the MTU.
> > + *
>
> Do we need to hide this behind a flag? It seems otherwise you might confuse
> users. I imagine on error we could reuse the params arg, but now we changed
> the tot_len value underneath them?
The principle behind this bpf_fib_lookup helper, is that params (struct
bpf_fib_lookup) is used for both input and output (results). Almost
every field is change after the lookup. (For performance reasons this
is kept at 64 bytes (cache-line)) Thus, users of this helper already
expect/knows the contents of params have changed.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
struct bpf_fib_lookup {
/* input: network family for lookup (AF_INET, AF_INET6)
* output: network family of egress nexthop
*/
__u8 family;
/* set if lookup is to consider L4 data - e.g., FIB rules */
__u8 l4_protocol;
__be16 sport;
__be16 dport;
union { /* used for MTU check */
/* input to lookup */
__u16 tot_len; /* total length of packet from network hdr */
/* output: MTU value (if requested check_mtu) */
__u16 mtu_result;
};
/* input: L3 device index for lookup
* output: device index from FIB lookup
*/
__u32 ifindex;
union {
/* inputs to lookup */
__u8 tos; /* AF_INET */
__be32 flowinfo; /* AF_INET6, flow_label + priority */
/* output: metric of fib result (IPv4/IPv6 only) */
__u32 rt_metric;
};
union {
__be32 ipv4_src;
__u32 ipv6_src[4]; /* in6_addr; network order */
};
/* input to bpf_fib_lookup, ipv{4,6}_dst is destination address in
* network header. output: bpf_fib_lookup sets to gateway address
* if FIB lookup returns gateway route
*/
union {
__be32 ipv4_dst;
__u32 ipv6_dst[4]; /* in6_addr; network order */
};
/* output */
__be16 h_vlan_proto;
__be16 h_vlan_TCI;
__u8 smac[6]; /* ETH_ALEN */
__u8 dmac[6]; /* ETH_ALEN */
};
next prev parent reply other threads:[~2020-11-02 9:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 16:50 [PATCH bpf-next V5 0/5] Subj: bpf: New approach for BPF MTU handling Jesper Dangaard Brouer
2020-10-30 16:50 ` [PATCH bpf-next V5 1/5] bpf: Remove MTU check in __bpf_skb_max_len Jesper Dangaard Brouer
2020-10-30 16:50 ` [PATCH bpf-next V5 2/5] bpf: bpf_fib_lookup return MTU value as output when looked up Jesper Dangaard Brouer
2020-10-30 19:40 ` John Fastabend
2020-11-02 9:28 ` Jesper Dangaard Brouer [this message]
2020-11-02 15:59 ` David Ahern
2020-11-02 16:18 ` John Fastabend
2020-10-31 15:52 ` David Ahern
2020-10-30 16:51 ` [PATCH bpf-next V5 3/5] bpf: add BPF-helper for MTU checking Jesper Dangaard Brouer
2020-10-30 20:23 ` John Fastabend
2020-11-02 11:15 ` Jesper Dangaard Brouer
2020-11-02 18:04 ` John Fastabend
2020-11-02 20:10 ` Jesper Dangaard Brouer
2020-11-12 12:58 ` Jesper Dangaard Brouer
2020-10-30 16:51 ` [PATCH bpf-next V5 4/5] bpf: drop MTU check when doing TC-BPF redirect to ingress Jesper Dangaard Brouer
2020-10-30 20:36 ` John Fastabend
2020-11-02 12:46 ` Jesper Dangaard Brouer
2020-11-02 16:23 ` John Fastabend
2020-10-30 16:51 ` [PATCH bpf-next V5 5/5] bpf: make it possible to identify BPF redirected SKBs Jesper Dangaard Brouer
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=20201102102850.1dc3124a@carbon \
--to=brouer@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=borkmann@iogearbox.net \
--cc=bpf@vger.kernel.org \
--cc=eyal.birger@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=lmb@cloudflare.com \
--cc=lorenzo@kernel.org \
--cc=marek@cloudflare.com \
--cc=maze@google.com \
--cc=netdev@vger.kernel.org \
--cc=shaun@tigera.io \
/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).