Skip to content

Commit ded9813

Browse files
rohangt07kuba-moo
authored andcommitted
net: stmmac: Consider Tx VLAN offload tag length for maxSDU
Queue maxSDU requirement of 802.1 Qbv standard requires mac to drop packets that exceeds maxSDU length and maxSDU doesn't include preamble, destination and source address, or FCS but includes ethernet type and VLAN header. On hardware with Tx VLAN offload enabled, VLAN header length is not included in the skb->len, when Tx VLAN offload is requested. This leads to incorrect length checks and allows transmission of oversized packets. Add the VLAN_HLEN to the skb->len before checking the Qbv maxSDU if Tx VLAN offload is requested for the packet. Fixes: c5c3e1b ("net: stmmac: Offload queueMaxSDU from tc-taprio") Signed-off-by: Rohan G Thomas <[email protected]> Reviewed-by: Matthew Gerlach <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c657f86 commit ded9813

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,6 +4500,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
45004500
bool has_vlan, set_ic;
45014501
int entry, first_tx;
45024502
dma_addr_t des;
4503+
u32 sdu_len;
45034504

45044505
tx_q = &priv->dma_conf.tx_queue[queue];
45054506
txq_stats = &priv->xstats.txq_stats[queue];
@@ -4517,10 +4518,15 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
45174518
}
45184519

45194520
if (priv->est && priv->est->enable &&
4520-
priv->est->max_sdu[queue] &&
4521-
skb->len > priv->est->max_sdu[queue]){
4522-
priv->xstats.max_sdu_txq_drop[queue]++;
4523-
goto max_sdu_err;
4521+
priv->est->max_sdu[queue]) {
4522+
sdu_len = skb->len;
4523+
/* Add VLAN tag length if VLAN tag insertion offload is requested */
4524+
if (priv->dma_cap.vlins && skb_vlan_tag_present(skb))
4525+
sdu_len += VLAN_HLEN;
4526+
if (sdu_len > priv->est->max_sdu[queue]) {
4527+
priv->xstats.max_sdu_txq_drop[queue]++;
4528+
goto max_sdu_err;
4529+
}
45244530
}
45254531

45264532
if (unlikely(stmmac_tx_avail(priv, queue) < nfrags + 1)) {

0 commit comments

Comments
 (0)