Skip to content

Commit 4b25846

Browse files
krkumardavem330
authored andcommitted
net: Optimize non-gso test checks
Avoid checking twice whether skb needs to be linearized, if one skb_linearize was already done. Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5f8cbc1 commit 4b25846

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

net/core/dev.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,21 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
19821982
return rc;
19831983
}
19841984

1985+
/*
1986+
* Returns true if either:
1987+
* 1. skb has frag_list and the device doesn't support FRAGLIST, or
1988+
* 2. skb is fragmented and the device does not support SG, or if
1989+
* at least one of fragments is in highmem and device does not
1990+
* support DMA from it.
1991+
*/
1992+
static inline int skb_needs_linearize(struct sk_buff *skb,
1993+
struct net_device *dev)
1994+
{
1995+
return (skb_has_frags(skb) && !(dev->features & NETIF_F_FRAGLIST)) ||
1996+
(skb_shinfo(skb)->nr_frags && (!(dev->features & NETIF_F_SG) ||
1997+
illegal_highdma(dev, skb)));
1998+
}
1999+
19852000
/**
19862001
* dev_queue_xmit - transmit a buffer
19872002
* @skb: buffer to transmit
@@ -2018,18 +2033,8 @@ int dev_queue_xmit(struct sk_buff *skb)
20182033
if (netif_needs_gso(dev, skb))
20192034
goto gso;
20202035

2021-
if (skb_has_frags(skb) &&
2022-
!(dev->features & NETIF_F_FRAGLIST) &&
2023-
__skb_linearize(skb))
2024-
goto out_kfree_skb;
2025-
2026-
/* Fragmented skb is linearized if device does not support SG,
2027-
* or if at least one of fragments is in highmem and device
2028-
* does not support DMA from it.
2029-
*/
2030-
if (skb_shinfo(skb)->nr_frags &&
2031-
(!(dev->features & NETIF_F_SG) || illegal_highdma(dev, skb)) &&
2032-
__skb_linearize(skb))
2036+
/* Convert a paged skb to linear, if required */
2037+
if (skb_needs_linearize(skb, dev) && __skb_linearize(skb))
20332038
goto out_kfree_skb;
20342039

20352040
/* If packet is not checksummed and device does not support

0 commit comments

Comments
 (0)