No functional changes here, only add test to see if the orig_skb matches the usage of application SO_TIMESTAMPING. And it's good to support two modes in parallel later in this series. Signed-off-by: Jason Xing <kerneljasonxing@xxxxxxxxx> --- net/core/skbuff.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index a441613a1e6c..46530d516909 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5539,18 +5539,37 @@ void skb_complete_tx_timestamp(struct sk_buff *skb, } EXPORT_SYMBOL_GPL(skb_complete_tx_timestamp); +static bool skb_tstamp_tx_report_so_timestamping(struct sk_buff *skb, + int tstype, bool sw) +{ + switch (tstype) { + case SCM_TSTAMP_SCHED: + return skb_shinfo(skb)->tx_flags & SKBTX_SCHED_TSTAMP; + case SCM_TSTAMP_SND: + return skb_shinfo(skb)->tx_flags & (sw ? SKBTX_SW_TSTAMP : + SKBTX_HW_TSTAMP); + case SCM_TSTAMP_ACK: + return TCP_SKB_CB(skb)->txstamp_ack; + } + + return false; +} + void __skb_tstamp_tx(struct sk_buff *orig_skb, const struct sk_buff *ack_skb, struct skb_shared_hwtstamps *hwtstamps, struct sock *sk, int tstype) { + bool tsonly, opt_stats = false, sw = hwtstamps ? false : true; struct sk_buff *skb; - bool tsonly, opt_stats = false; u32 tsflags; if (!sk) return; + if (!skb_tstamp_tx_report_so_timestamping(orig_skb, tstype, sw)) + return; + tsflags = READ_ONCE(sk->sk_tsflags); if (!hwtstamps && !(tsflags & SOF_TIMESTAMPING_OPT_TX_SWHW) && skb_shinfo(orig_skb)->tx_flags & SKBTX_IN_PROGRESS) -- 2.43.5