Re: [PATCH/RFC] packet: fix sock_tx_timestamp() in packet_snd() via sendto syscall
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2016-07-15 15:31:49
On Thu, Jul 14, 2016 at 10:49 PM, Yoshihiro Shimoda [off-list ref] wrote:
Since the sendto syscall doesn't have msg_control buffer, the sock_tx_timestamp() in packet_snd() cannot work correctly because the socks.fsflags is set to 0.
You're right. __sock_tx_timestamp used to take sk->sk_tsflags as input, now it relies solely on this parameter tsflags. All callsites must either pass sk->sk_tsflags directly or initialize sockc.tsflags to this value.
quoted hunk ↗ jump to hunk
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 9f0983f..d76fd41 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c@@ -2887,6 +2887,11 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) err = sock_cmsg_send(sk, msg, &sockc); if (unlikely(err)) goto out_unlock; + } else { + /* Set tsflags from sk because a syscall (e.g. sendto) doesn't + * have msg_control buffer. + */ + sockc.tsflags = sk->sk_tsflags; }
Better to follow the example of other protocols. In all three packet variants, make the following initialization change: - sockc.tsflags = 0; + sockc.tsflags = sk->sk_tsflags; (I had to remove some recipients, because my reply was marked as spam and dropped otherwise..)