mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
net/packet: ignore timestamp bits when testing tx frame status
Since the commit in Fixes, the tx completion handler writes the frame
status as TP_STATUS_AVAILABLE | ts, where ts can be
TP_STATUS_TS_SOFTWARE or TP_STATUS_TS_RAW_HARDWARE.
Two places compare a tx frame status to TP_STATUS_AVAILABLE for
equality, and so fail to detect such a released frame:
- tpacket_snd(), when packet_xmit() fails: the packet is silently
dropped instead of an error being returned to the caller for retry.
- packet_poll(), on the tx ring head frame: the socket is not reported
as writable.
Mask out the timestamp bits in both. In packet_lookup_frame(), only do
so when testing a tx ring frame for TP_STATUS_AVAILABLE.
Cc: stable+noautosel@kernel.org # LLM report + LLM fix, not seen in real life
Fixes: b9c32fb271 ("packet: if hw/sw ts enabled in rx/tx ring, report which ts we got")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20261004171847.186954-1-willemdebruijn.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
a9c455cd3d
commit
88fb9fad5c
|
|
@ -398,6 +398,10 @@ static inline struct page * __pure pgv_to_page(void *addr)
|
|||
return virt_to_page(addr);
|
||||
}
|
||||
|
||||
/* Timestamp bits that may be set in addition to the frame state */
|
||||
static const u32 tp_status_ts_mask = TP_STATUS_TS_SOFTWARE |
|
||||
TP_STATUS_TS_RAW_HARDWARE;
|
||||
|
||||
static void __packet_set_status(struct packet_sock *po, void *frame, int status)
|
||||
{
|
||||
union tpacket_uhdr h;
|
||||
|
|
@ -519,6 +523,7 @@ static void *packet_lookup_frame(const struct packet_sock *po,
|
|||
{
|
||||
unsigned int pg_vec_pos, frame_offset;
|
||||
union tpacket_uhdr h;
|
||||
u32 mask = 0;
|
||||
|
||||
pg_vec_pos = position / rb->frames_per_block;
|
||||
frame_offset = position % rb->frames_per_block;
|
||||
|
|
@ -526,7 +531,10 @@ static void *packet_lookup_frame(const struct packet_sock *po,
|
|||
h.raw = rb->pg_vec[pg_vec_pos].buffer +
|
||||
(frame_offset * rb->frame_size);
|
||||
|
||||
if (status != __packet_get_status(po, h.raw))
|
||||
if (rb == &po->tx_ring && status == TP_STATUS_AVAILABLE)
|
||||
mask = tp_status_ts_mask;
|
||||
|
||||
if (status != (__packet_get_status(po, h.raw) & ~mask))
|
||||
return NULL;
|
||||
|
||||
return h.raw;
|
||||
|
|
@ -2947,7 +2955,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
|
|||
if (unlikely(err != 0)) {
|
||||
if (err > 0)
|
||||
err = net_xmit_errno(err);
|
||||
if (err && __packet_get_status(po, ph) ==
|
||||
if (err && (__packet_get_status(po, ph) & ~tp_status_ts_mask) ==
|
||||
TP_STATUS_AVAILABLE) {
|
||||
/* skb was destructed already */
|
||||
skb = NULL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user