From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Martin KaFai Lau <kafai@fb.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
kernel-team@fb.com
Subject: Re: [RFC PATCH v3 net-next 0/4] Preserve mono delivery time (EDT) in skb->tstamp
Date: Sat, 22 Jan 2022 10:43:57 -0500 [thread overview]
Message-ID: <CA+FuTSe83TdzkvYLdfbZDZrW3BGq74_KmmksrCjDKKua7pE1jA@mail.gmail.com> (raw)
In-Reply-To: <20220121073026.4173996-1-kafai@fb.com>
On Fri, Jan 21, 2022 at 2:30 AM Martin KaFai Lau <kafai@fb.com> wrote:
>
> skb->tstamp was first used as the (rcv) timestamp in real time clock base.
> The major usage is to report it to the user (e.g. SO_TIMESTAMP).
>
> Later, skb->tstamp is also set as the (future) delivery_time (e.g. EDT in TCP)
> during egress and used by the qdisc (e.g. sch_fq) to make decision on when
> the skb can be passed to the dev.
>
> Currently, there is no way to tell skb->tstamp having the (rcv) timestamp
> or the delivery_time, so it is always reset to 0 whenever forwarded
> between egress and ingress.
>
> While it makes sense to always clear the (rcv) timestamp in skb->tstamp
> to avoid confusing sch_fq that expects the delivery_time, it is a
> performance issue [0] to clear the delivery_time if the skb finally
> egress to a fq@phy-dev.
>
> v3:
> - Feedback from v2 is using shinfo(skb)->tx_flags could be racy.
> - Considered to reuse a few bits in skb->tstamp to represent
> different semantics, other than more code churns, it will break
> the bpf usecase which currently can write and then read back
> the skb->tstamp.
> - Went back to v1 idea on adding a bit to skb and address the
> feedbacks on v1:
> - Added one bit skb->mono_delivery_time to flag that
> the skb->tstamp has the mono delivery_time (EDT), instead
> of adding a bit to flag if the skb->tstamp has been forwarded or not.
> - Instead of resetting the delivery_time back to the (rcv) timestamp
> during recvmsg syscall which may be too late and not useful,
> the delivery_time reset in v3 happens earlier once the stack
> knows that the skb will be delivered locally.
> - Handled the tapping@ingress case by af_packet
> - No need to change the (rcv) timestamp to mono clock base as in v1.
> The added one bit to flag skb->mono_delivery_time is enough
> to keep the EDT delivery_time during forward.
> - Added logic to the bpf side to make the existing bpf
> running at ingress can still get the (rcv) timestamp
> when reading the __sk_buff->tstamp. New __sk_buff->mono_delivery_time
> is also added. Test is still needed to test this piece.
>
> Martin KaFai Lau (4):
> net: Add skb->mono_delivery_time to distinguish mono delivery_time
> from (rcv) timestamp
> net: Add skb_clear_tstamp() to keep the mono delivery_time
> net: Set skb->mono_delivery_time and clear it when delivering locally
> bpf: Add __sk_buff->mono_delivery_time and handle __sk_buff->tstamp
> based on tc_at_ingress
>
> drivers/net/loopback.c | 2 +-
> include/linux/filter.h | 31 ++++-
> include/linux/skbuff.h | 64 ++++++++--
> include/uapi/linux/bpf.h | 1 +
> net/bridge/br_forward.c | 2 +-
> net/bridge/netfilter/nf_conntrack_bridge.c | 5 +-
> net/core/dev.c | 4 +-
> net/core/filter.c | 140 +++++++++++++++++++--
> net/core/skbuff.c | 8 +-
> net/ipv4/ip_forward.c | 2 +-
> net/ipv4/ip_input.c | 1 +
> net/ipv4/ip_output.c | 5 +-
> net/ipv4/tcp_output.c | 16 +--
> net/ipv6/ip6_input.c | 1 +
> net/ipv6/ip6_output.c | 7 +-
> net/ipv6/netfilter.c | 5 +-
> net/netfilter/ipvs/ip_vs_xmit.c | 6 +-
> net/netfilter/nf_dup_netdev.c | 2 +-
> net/netfilter/nf_flow_table_ip.c | 4 +-
> net/netfilter/nft_fwd_netdev.c | 2 +-
> net/openvswitch/vport.c | 2 +-
> net/packet/af_packet.c | 4 +-
> net/sched/act_bpf.c | 5 +-
> net/sched/cls_bpf.c | 6 +-
> net/xfrm/xfrm_interface.c | 2 +-
> tools/include/uapi/linux/bpf.h | 1 +
> 26 files changed, 265 insertions(+), 63 deletions(-)
>
> --
This overall looks great to me.
The only effect on timestamping is slightly delayed receive timestamp
for packets arriving over a virtual loop (loopback, veth, ..)
interface, as the timestamp is now captured at the network protocol
input.
Actually, while writing that: timestamping is a socket level option,
not specific to IP. Might this break receive timestamping over such
interfaces for other protocols?
next prev parent reply other threads:[~2022-01-22 15:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 7:30 [RFC PATCH v3 net-next 0/4] Preserve mono delivery time (EDT) in skb->tstamp Martin KaFai Lau
2022-01-21 7:30 ` [RFC PATCH v3 net-next 1/4] net: Add skb->mono_delivery_time to distinguish mono delivery_time from (rcv) timestamp Martin KaFai Lau
2022-01-22 15:32 ` Willem de Bruijn
2022-01-22 19:52 ` Martin KaFai Lau
2022-01-22 20:03 ` Martin KaFai Lau
2022-01-21 7:30 ` [RFC PATCH v3 net-next 2/4] net: Add skb_clear_tstamp() to keep the mono delivery_time Martin KaFai Lau
2022-01-21 7:30 ` [RFC PATCH v3 net-next 3/4] net: Set skb->mono_delivery_time and clear it when delivering locally Martin KaFai Lau
2022-01-21 12:02 ` Julian Anastasov
2022-01-22 3:28 ` Martin KaFai Lau
2022-01-21 7:30 ` [RFC PATCH v3 net-next 4/4] bpf: Add __sk_buff->mono_delivery_time and handle __sk_buff->tstamp based on tc_at_ingress Martin KaFai Lau
2022-01-21 18:50 ` sdf
2022-01-21 20:56 ` Martin KaFai Lau
2022-01-21 22:33 ` sdf
2022-01-22 15:43 ` Willem de Bruijn [this message]
2022-01-22 21:05 ` [RFC PATCH v3 net-next 0/4] Preserve mono delivery time (EDT) in skb->tstamp Martin KaFai Lau
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=CA+FuTSe83TdzkvYLdfbZDZrW3BGq74_KmmksrCjDKKua7pE1jA@mail.gmail.com \
--to=willemdebruijn.kernel@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kafai@fb.com \
--cc=kernel-team@fb.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/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).