From: Sergei Antonov <saproj@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, Sergei Antonov <saproj@gmail.com>
Subject: [PATCH v2 net] net: ftmac100: do not reject packets bigger than 1514
Date: Wed, 12 Oct 2022 18:37:37 +0300 [thread overview]
Message-ID: <20221012153737.128424-1-saproj@gmail.com> (raw)
Despite the datasheet [1] saying the controller should allow incoming
packets of length >=1518, it only allows packets of length <=1514.
Since 1518 is a standard Ethernet maximum frame size, and it can
easily be encountered (in SSH for example), fix this behavior:
* Set FTMAC100_MACCR_RX_FTL in the MAC Control Register.
* Check for packet size > 1518 in ftmac100_rx_packet_error().
[1]
https://bitbucket.org/Kasreyn/mkrom-uc7112lx/src/master/documents/FIC8120_DS_v1.2.pdf
Fixes: 8d77c036b57c ("net: add Faraday FTMAC100 10/100 Ethernet driver")
Signed-off-by: Sergei Antonov <saproj@gmail.com>
---
v1 -> v2:
* Typos in description fixed.
drivers/net/ethernet/faraday/ftmac100.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
index d95d78230828..34d0284079ff 100644
--- a/drivers/net/ethernet/faraday/ftmac100.c
+++ b/drivers/net/ethernet/faraday/ftmac100.c
@@ -154,6 +154,7 @@ static void ftmac100_set_mac(struct ftmac100 *priv, const unsigned char *mac)
FTMAC100_MACCR_CRC_APD | \
FTMAC100_MACCR_FULLDUP | \
FTMAC100_MACCR_RX_RUNT | \
+ FTMAC100_MACCR_RX_FTL | \
FTMAC100_MACCR_RX_BROADPKT)
static int ftmac100_start_hw(struct ftmac100 *priv)
@@ -320,6 +321,7 @@ static bool ftmac100_rx_packet_error(struct ftmac100 *priv,
{
struct net_device *netdev = priv->netdev;
bool error = false;
+ const unsigned int length = ftmac100_rxdes_frame_length(rxdes);
if (unlikely(ftmac100_rxdes_rx_error(rxdes))) {
if (net_ratelimit())
@@ -337,9 +339,16 @@ static bool ftmac100_rx_packet_error(struct ftmac100 *priv,
error = true;
}
- if (unlikely(ftmac100_rxdes_frame_too_long(rxdes))) {
+ /* The frame-too-long flag 'FTMAC100_RXDES0_FTL' is described in the
+ * datasheet as: "When set, it indicates that the received packet
+ * length exceeds 1518 bytes." But testing shows that it is also set
+ * when packet length is equal to 1518.
+ * Since 1518 is a standard Ethernet maximum frame size, let it pass
+ * and only trigger an error when packet length really exceeds it.
+ */
+ if (unlikely(ftmac100_rxdes_frame_too_long(rxdes) && length > 1518)) {
if (net_ratelimit())
- netdev_info(netdev, "rx frame too long\n");
+ netdev_info(netdev, "rx frame too long (%u)\n", length);
netdev->stats.rx_length_errors++;
error = true;
--
2.34.1
next reply other threads:[~2022-10-12 15:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-12 15:37 Sergei Antonov [this message]
2022-10-12 16:13 ` [PATCH v2 net] net: ftmac100: do not reject packets bigger than 1514 David Laight
2022-10-12 16:42 ` Sergei Antonov
2022-10-12 21:37 ` Andrew Lunn
2022-10-12 21:41 ` David Laight
2022-10-13 10:29 ` Sergei Antonov
2022-10-13 14:10 ` Andrew Lunn
2022-10-13 15:53 ` Sergei Antonov
2022-10-13 14:48 ` Vladimir Oltean
2022-10-13 4:24 ` David Laight
2022-10-13 15:47 ` Sergei Antonov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221012153737.128424-1-saproj@gmail.com \
--to=saproj@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).