Revert "net: Re-use and set mono_delivery_time bit for userspace tstamp packets"
authorAbhishek Chauhan <quic_abchauha@quicinc.com>
Thu, 14 Mar 2024 19:24:04 +0000 (12:24 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 Mar 2024 12:29:53 +0000 (12:29 +0000)
This reverts commit 885c36e59f46375c138de18ff1692f18eff67b7f.

The patch currently broke the bpf selftest test_tc_dtime because
uapi field __sk_buff->tstamp_type depends on skb->mono_delivery_time which
does not necessarily mean mono with the original fix as the bit was re-used
for userspace timestamp as well to avoid tstamp reset in the forwarding
path. To solve this we need to keep mono_delivery_time as is and
introduce another bit called user_delivery_time and fall back to the
initial proposal of setting the user_delivery_time bit based on
sk_clockid set from userspace.

Fixes: 885c36e59f46 ("net: Re-use and set mono_delivery_time bit for userspace tstamp packets")
Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/
Signed-off-by: Abhishek Chauhan <quic_abchauha@quicinc.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/ipv4/ip_output.c
net/ipv4/raw.c
net/ipv6/ip6_output.c
net/ipv6/raw.c
net/packet/af_packet.c

index 3023bc2be6a1c126bdbba2a0bc9b1f11d4131735..7d56ce195120aea09d12be05e301d90d94f7a36c 100644 (file)
@@ -822,9 +822,9 @@ typedef unsigned char *sk_buff_data_t;
  *     @decrypted: Decrypted SKB
  *     @slow_gro: state present at GRO time, slower prepare step required
  *     @mono_delivery_time: When set, skb->tstamp has the
- *             delivery_time in mono clock base (i.e., EDT) or a clock base chosen
- *             by SO_TXTIME. If zero, skb->tstamp has the (rcv) timestamp at
- *             ingress.
+ *             delivery_time in mono clock base (i.e. EDT).  Otherwise, the
+ *             skb->tstamp has the (rcv) timestamp at ingress and
+ *             delivery_time at egress.
  *     @napi_id: id of the NAPI struct this skb came from
  *     @sender_cpu: (aka @napi_id) source CPU in XPS
  *     @alloc_cpu: CPU which did the skb allocation.
index 33f93dc730a3359b2a43e3cab447b94bc63597e0..1fe794967211e249016df00dc3c2ae230d71dcff 100644 (file)
@@ -1458,7 +1458,6 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
        skb->priority = (cork->tos != -1) ? cork->priority: READ_ONCE(sk->sk_priority);
        skb->mark = cork->mark;
        skb->tstamp = cork->transmit_time;
-       skb->mono_delivery_time = !!skb->tstamp;
        /*
         * Steal rt from cork.dst to avoid a pair of atomic_inc/atomic_dec
         * on dst refcount
index 42ac434cfcfa677ee58408297f4d3ac05d98b546..12b3740393ba57d14be54dc4ae31d75952002c3b 100644 (file)
@@ -360,7 +360,6 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
        skb->priority = READ_ONCE(sk->sk_priority);
        skb->mark = sockc->mark;
        skb->tstamp = sockc->transmit_time;
-       skb->mono_delivery_time = !!skb->tstamp;
        skb_dst_set(skb, &rt->dst);
        *rtp = NULL;
 
index 02eeca5492cd4d894b4acc8ec89bf004e81c0ccb..b9dd3a66e4236fbf67af75c5f98c921b38c18bf6 100644 (file)
@@ -1925,7 +1925,7 @@ struct sk_buff *__ip6_make_skb(struct sock *sk,
        skb->priority = READ_ONCE(sk->sk_priority);
        skb->mark = cork->base.mark;
        skb->tstamp = cork->base.transmit_time;
-       skb->mono_delivery_time = !!skb->tstamp;
+
        ip6_cork_steal_dst(skb, cork);
        IP6_INC_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUTREQUESTS);
        if (proto == IPPROTO_ICMPV6) {
index ca49e6617afaff3fe6c5f3a174bbe6d96f94ac62..0d896ca7b589122270b9e85815a64ce37d0d932d 100644 (file)
@@ -622,7 +622,7 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
        skb->priority = READ_ONCE(sk->sk_priority);
        skb->mark = sockc->mark;
        skb->tstamp = sockc->transmit_time;
-       skb->mono_delivery_time = !!skb->tstamp;
+
        skb_put(skb, length);
        skb_reset_network_header(skb);
        iph = ipv6_hdr(skb);
index 7cfc7d301508fcead214fbdb4e962b0553a17916..18f616f487eaad0f7b31fb074e194c0479f30d77 100644 (file)
@@ -2057,7 +2057,7 @@ retry:
        skb->priority = READ_ONCE(sk->sk_priority);
        skb->mark = READ_ONCE(sk->sk_mark);
        skb->tstamp = sockc.transmit_time;
-       skb->mono_delivery_time = !!skb->tstamp;
+
        skb_setup_tx_timestamp(skb, sockc.tsflags);
 
        if (unlikely(extra_len == 4))
@@ -2586,7 +2586,6 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
        skb->priority = READ_ONCE(po->sk.sk_priority);
        skb->mark = READ_ONCE(po->sk.sk_mark);
        skb->tstamp = sockc->transmit_time;
-       skb->mono_delivery_time = !!skb->tstamp;
        skb_setup_tx_timestamp(skb, sockc->tsflags);
        skb_zcopy_set_nouarg(skb, ph.raw);
 
@@ -3065,7 +3064,6 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
        skb->priority = READ_ONCE(sk->sk_priority);
        skb->mark = sockc.mark;
        skb->tstamp = sockc.transmit_time;
-       skb->mono_delivery_time = !!skb->tstamp;
 
        if (unlikely(extra_len == 4))
                skb->no_fcs = 1;