Skip to content

Commit c174cd0

Browse files
pvVudentz
authored andcommitted
Bluetooth: increment TX timestamping tskey always for stream sockets
Documentation/networking/timestamping.rst implies TX timestamping OPT_ID tskey increments for each sendmsg. In practice: TCP socket increments it for all sendmsg, timestamping on or off, but UDP only when timestamping is on. The user-visible counter resets when OPT_ID is turned on, so difference can be seen only if timestamping is enabled for some packets only (eg. via SO_TIMESTAMPING CMSG). Fix BT sockets to work in the same way: stream sockets increment tskey for all sendmsg (seqpacket already increment for timestamped only). Fixes: 134f4b3 ("Bluetooth: add support for skb TX SND/COMPLETION timestamping") Signed-off-by: Pauli Virtanen <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent e92900c commit c174cd0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/bluetooth/hci_conn.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,6 +3072,7 @@ void hci_setup_tx_timestamp(struct sk_buff *skb, size_t key_offset,
30723072
const struct sockcm_cookie *sockc)
30733073
{
30743074
struct sock *sk = skb ? skb->sk : NULL;
3075+
int key;
30753076

30763077
/* This shall be called on a single skb of those generated by user
30773078
* sendmsg(), and only when the sendmsg() does not return error to
@@ -3087,13 +3088,16 @@ void hci_setup_tx_timestamp(struct sk_buff *skb, size_t key_offset,
30873088

30883089
sock_tx_timestamp(sk, sockc, &skb_shinfo(skb)->tx_flags);
30893090

3091+
if (sk->sk_type == SOCK_STREAM)
3092+
key = atomic_add_return(key_offset, &sk->sk_tskey);
3093+
30903094
if (sockc->tsflags & SOF_TIMESTAMPING_OPT_ID &&
30913095
sockc->tsflags & SOF_TIMESTAMPING_TX_RECORD_MASK) {
30923096
if (sockc->tsflags & SOCKCM_FLAG_TS_OPT_ID) {
30933097
skb_shinfo(skb)->tskey = sockc->ts_opt_id;
30943098
} else {
3095-
int key = atomic_add_return(key_offset, &sk->sk_tskey);
3096-
3099+
if (sk->sk_type != SOCK_STREAM)
3100+
key = atomic_inc_return(&sk->sk_tskey);
30973101
skb_shinfo(skb)->tskey = key - 1;
30983102
}
30993103
}

0 commit comments

Comments
 (0)