From: Martin KaFai Lau <kafai@fb.com>
Date: Wed, 2 Mar 2022 11:55:50 -0800
Subject: net: Set skb->mono_delivery_time and clear it after
sch_handle_ingress()
Patch-mainline: v5.18-rc1
Git-commit: d98d58a002619b5c165f1eedcd731e2fe2c19088
References: jsc#PED-1377
The previous patches handled the delivery_time before sch_handle_ingress().
This patch can now set the skb->mono_delivery_time to flag the skb->tstamp
is used as the mono delivery_time (EDT) instead of the (rcv) timestamp
and also clear it with skb_clear_delivery_time() after
sch_handle_ingress(). This will make the bpf_redirect_*()
to keep the mono delivery_time and used by a qdisc (fq) of
the egress-ing interface.
A latter patch will postpone the skb_clear_delivery_time() until the
stack learns that the skb is being delivered locally and that will
make other kernel forwarding paths (ip[6]_forward) able to keep
the delivery_time also. Thus, like the previous patches on using
the skb->mono_delivery_time bit, calling skb_clear_delivery_time()
is not limited within the CONFIG_NET_INGRESS to avoid too many code
churns among this set.
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
include/linux/skbuff.h | 3 +--
net/core/dev.c | 8 ++++++--
net/ipv4/ip_output.c | 3 +--
3 files changed, 8 insertions(+), 6 deletions(-)
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3848,8 +3848,7 @@ static inline void skb_set_delivery_time
bool mono)
{
skb->tstamp = kt;
- /* Setting mono_delivery_time will be enabled later */
- skb->mono_delivery_time = 0;
+ skb->mono_delivery_time = kt && mono;
}
DECLARE_STATIC_KEY_FALSE(netstamp_needed_key);
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5172,8 +5172,10 @@ another_round:
goto out;
}
- if (skb_skip_tc_classify(skb))
+ if (skb_skip_tc_classify(skb)) {
+ skb_clear_delivery_time(skb);
goto skip_classify;
+ }
if (pfmemalloc)
goto skip_taps;
@@ -5201,11 +5203,13 @@ skip_taps:
goto another_round;
if (!skb)
goto out;
+ skb_clear_delivery_time(skb);
if (nf_ingress(skb, &pt_prev, &ret, orig_dev) < 0)
goto out;
- }
+ } else
#endif
+ skb_clear_delivery_time(skb);
skb_reset_redirect(skb);
skip_classify:
if (pfmemalloc && !skb_pfmemalloc_protocol(skb))
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1738,8 +1738,7 @@ void ip_send_unicast_reply(struct sock *
arg->csumoffset) = csum_fold(csum_add(nskb->csum,
arg->csum));
nskb->ip_summed = CHECKSUM_NONE;
- /* Setting mono_delivery_time will be enabled later */
- nskb->mono_delivery_time = 0;
+ nskb->mono_delivery_time = !!transmit_time;
ip_push_pending_frames(sk, &fl4);
}
out: