net/af_packet: remove timestamp from packet status
authorTudor Cornea <tudor.cornea@gmail.com>
Thu, 23 Sep 2021 18:13:24 +0000 (21:13 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 28 Sep 2021 12:59:28 +0000 (14:59 +0200)
commit84b3e4555a1f3ddbc5bcdc7e1afc752741a0521b
tree14d014b660ff298cd57693508f4059f4d685ca20
parent16b8e92d49b87705fffbedd9c3241204d9a584a6
net/af_packet: remove timestamp from packet status

We should eliminate the timestamp status from the packet
status. This should only matter if timestamping is enabled
on the socket, but we might hit a kernel bug, which is fixed
in newer releases.

For interfaces of type 'veth', the sent skb is forwarded
to the peer and back into the network stack which timestamps
it on the RX path if timestamping is enabled globally
(which happens if any socket enables timestamping).

When the skb is destructed, tpacket_destruct_skb() is called
and it calls __packet_set_timestamp() which doesn't check
the flags on the socket and returns the timestamp if it is
set in the skb (and for veth it is, as mentioned above).

See the following kernel commit for reference [1]:

net: packetmmap: fix only tx timestamp on request

The packetmmap tx ring should only return timestamps if requested
via setsockopt PACKET_TIMESTAMP, as documented. This allows
compatibility with non-timestamp aware user-space code which checks
tp_status == TP_STATUS_AVAILABLE; not expecting additional timestamp
flags to be set in tp_status.

[1] https://www.spinics.net/lists/kernel/msg3959391.html

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Signed-off-by: Tudor Cornea <tudor.cornea@gmail.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/af_packet/rte_eth_af_packet.c