Skip to content

Commit 3ce9345

Browse files
shailend-gkuba-moo
authored andcommitted
gve: Secure enough bytes in the first TX desc for all TCP pkts
Non-GSO TCP packets whose SKBs' linear portion did not include the entire TCP header were not populating the first Tx descriptor with as many bytes as the vNIC expected. This change ensures that all TCP packets populate the first descriptor with the correct number of bytes. Fixes: 893ce44 ("gve: Add basic driver framework for Compute Engine Virtual NIC") Signed-off-by: Shailend Chand <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a1865f2 commit 3ce9345

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

drivers/net/ethernet/google/gve/gve.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747

4848
#define GVE_RX_BUFFER_SIZE_DQO 2048
4949

50+
#define GVE_GQ_TX_MIN_PKT_DESC_BYTES 182
51+
5052
/* Each slot in the desc ring has a 1:1 mapping to a slot in the data ring */
5153
struct gve_rx_desc_queue {
5254
struct gve_rx_desc *desc_ring; /* the descriptor ring */

drivers/net/ethernet/google/gve/gve_tx.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ static inline int gve_skb_fifo_bytes_required(struct gve_tx_ring *tx,
284284
int bytes;
285285
int hlen;
286286

287-
hlen = skb_is_gso(skb) ? skb_checksum_start_offset(skb) +
288-
tcp_hdrlen(skb) : skb_headlen(skb);
287+
hlen = skb_is_gso(skb) ? skb_checksum_start_offset(skb) + tcp_hdrlen(skb) :
288+
min_t(int, GVE_GQ_TX_MIN_PKT_DESC_BYTES, skb->len);
289289

290290
pad_bytes = gve_tx_fifo_pad_alloc_one_frag(&tx->tx_fifo,
291291
hlen);
@@ -454,13 +454,11 @@ static int gve_tx_add_skb_copy(struct gve_priv *priv, struct gve_tx_ring *tx, st
454454
pkt_desc = &tx->desc[idx];
455455

456456
l4_hdr_offset = skb_checksum_start_offset(skb);
457-
/* If the skb is gso, then we want the tcp header in the first segment
458-
* otherwise we want the linear portion of the skb (which will contain
459-
* the checksum because skb->csum_start and skb->csum_offset are given
460-
* relative to skb->head) in the first segment.
457+
/* If the skb is gso, then we want the tcp header alone in the first segment
458+
* otherwise we want the minimum required by the gVNIC spec.
461459
*/
462460
hlen = is_gso ? l4_hdr_offset + tcp_hdrlen(skb) :
463-
skb_headlen(skb);
461+
min_t(int, GVE_GQ_TX_MIN_PKT_DESC_BYTES, skb->len);
464462

465463
info->skb = skb;
466464
/* We don't want to split the header, so if necessary, pad to the end

0 commit comments

Comments
 (0)