Skip to content

Commit 5bd0767

Browse files
annie-lidavem330
authored andcommitted
Xen-netback: Fix issue caused by using gso_type wrongly
Current netback uses gso_type to check whether the skb contains gso offload, and this is wrong. Gso_size is the right one to check gso existence, and gso_type is only used to check gso type. Some skbs contains nonzero gso_type and zero gso_size, current netback would treat these skbs as gso and create wrong response for this. This also causes ssh failure to domu from other server. V2: use skb_is_gso function as Paul Durrant suggested Signed-off-by: Annie Li <annie.li@oracle.com> Acked-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Paul Durrant <paul.durrant@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2818fa0 commit 5bd0767

1 file changed

Lines changed: 18 additions & 21 deletions

File tree

drivers/net/xen-netback/netback.c

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static void xenvif_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb,
240240
struct gnttab_copy *copy_gop;
241241
struct xenvif_rx_meta *meta;
242242
unsigned long bytes;
243-
int gso_type;
243+
int gso_type = XEN_NETIF_GSO_TYPE_NONE;
244244

245245
/* Data must not cross a page boundary. */
246246
BUG_ON(size + offset > PAGE_SIZE<<compound_order(page));
@@ -299,12 +299,12 @@ static void xenvif_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb,
299299
}
300300

301301
/* Leave a gap for the GSO descriptor. */
302-
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
303-
gso_type = XEN_NETIF_GSO_TYPE_TCPV4;
304-
else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
305-
gso_type = XEN_NETIF_GSO_TYPE_TCPV6;
306-
else
307-
gso_type = XEN_NETIF_GSO_TYPE_NONE;
302+
if (skb_is_gso(skb)) {
303+
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
304+
gso_type = XEN_NETIF_GSO_TYPE_TCPV4;
305+
else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
306+
gso_type = XEN_NETIF_GSO_TYPE_TCPV6;
307+
}
308308

309309
if (*head && ((1 << gso_type) & vif->gso_mask))
310310
vif->rx.req_cons++;
@@ -338,27 +338,23 @@ static int xenvif_gop_skb(struct sk_buff *skb,
338338
int head = 1;
339339
int old_meta_prod;
340340
int gso_type;
341-
int gso_size;
342341

343342
old_meta_prod = npo->meta_prod;
344343

345-
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) {
346-
gso_type = XEN_NETIF_GSO_TYPE_TCPV4;
347-
gso_size = skb_shinfo(skb)->gso_size;
348-
} else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) {
349-
gso_type = XEN_NETIF_GSO_TYPE_TCPV6;
350-
gso_size = skb_shinfo(skb)->gso_size;
351-
} else {
352-
gso_type = XEN_NETIF_GSO_TYPE_NONE;
353-
gso_size = 0;
344+
gso_type = XEN_NETIF_GSO_TYPE_NONE;
345+
if (skb_is_gso(skb)) {
346+
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
347+
gso_type = XEN_NETIF_GSO_TYPE_TCPV4;
348+
else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
349+
gso_type = XEN_NETIF_GSO_TYPE_TCPV6;
354350
}
355351

356352
/* Set up a GSO prefix descriptor, if necessary */
357353
if ((1 << gso_type) & vif->gso_prefix_mask) {
358354
req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++);
359355
meta = npo->meta + npo->meta_prod++;
360356
meta->gso_type = gso_type;
361-
meta->gso_size = gso_size;
357+
meta->gso_size = skb_shinfo(skb)->gso_size;
362358
meta->size = 0;
363359
meta->id = req->id;
364360
}
@@ -368,7 +364,7 @@ static int xenvif_gop_skb(struct sk_buff *skb,
368364

369365
if ((1 << gso_type) & vif->gso_mask) {
370366
meta->gso_type = gso_type;
371-
meta->gso_size = gso_size;
367+
meta->gso_size = skb_shinfo(skb)->gso_size;
372368
} else {
373369
meta->gso_type = XEN_NETIF_GSO_TYPE_NONE;
374370
meta->gso_size = 0;
@@ -500,8 +496,9 @@ static void xenvif_rx_action(struct xenvif *vif)
500496
size = skb_frag_size(&skb_shinfo(skb)->frags[i]);
501497
max_slots_needed += DIV_ROUND_UP(size, PAGE_SIZE);
502498
}
503-
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4 ||
504-
skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
499+
if (skb_is_gso(skb) &&
500+
(skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4 ||
501+
skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6))
505502
max_slots_needed++;
506503

507504
/* If the skb may not fit then bail out now */

0 commit comments

Comments
 (0)