Skip to content

Commit e549360

Browse files
hcodinakuba-moo
authored andcommitted
net: wan: fsl_qmc_hdlc: Discard received CRC
Received frame from QMC contains the CRC. Upper layers don't need this CRC and tcpdump mentioned trailing junk data due to this CRC presence. As some other HDLC driver, simply discard this CRC. Fixes: d0f2258 ("net: wan: Add support for QMC HDLC") Cc: [email protected] Signed-off-by: Herve Codina <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c4d6a34 commit e549360

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

drivers/net/wan/fsl_qmc_hdlc.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ static void qmc_hcld_recv_complete(void *context, size_t length, unsigned int fl
250250
struct qmc_hdlc_desc *desc = context;
251251
struct net_device *netdev;
252252
struct qmc_hdlc *qmc_hdlc;
253+
size_t crc_size;
253254
int ret;
254255

255256
netdev = desc->netdev;
@@ -268,15 +269,26 @@ static void qmc_hcld_recv_complete(void *context, size_t length, unsigned int fl
268269
if (flags & QMC_RX_FLAG_HDLC_CRC) /* CRC error */
269270
netdev->stats.rx_crc_errors++;
270271
kfree_skb(desc->skb);
271-
} else {
272-
netdev->stats.rx_packets++;
273-
netdev->stats.rx_bytes += length;
272+
goto re_queue;
273+
}
274274

275-
skb_put(desc->skb, length);
276-
desc->skb->protocol = hdlc_type_trans(desc->skb, netdev);
277-
netif_rx(desc->skb);
275+
/* Discard the CRC */
276+
crc_size = qmc_hdlc->is_crc32 ? 4 : 2;
277+
if (length < crc_size) {
278+
netdev->stats.rx_length_errors++;
279+
kfree_skb(desc->skb);
280+
goto re_queue;
278281
}
282+
length -= crc_size;
283+
284+
netdev->stats.rx_packets++;
285+
netdev->stats.rx_bytes += length;
286+
287+
skb_put(desc->skb, length);
288+
desc->skb->protocol = hdlc_type_trans(desc->skb, netdev);
289+
netif_rx(desc->skb);
279290

291+
re_queue:
280292
/* Re-queue a transfer using the same descriptor */
281293
ret = qmc_hdlc_recv_queue(qmc_hdlc, desc, desc->dma_size);
282294
if (ret) {

0 commit comments

Comments
 (0)