net: bcmgenet: use hardware padding of runt frames
authorDoug Berger <opendmb@gmail.com>
Thu, 25 Jun 2020 01:14:55 +0000 (18:14 -0700)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:37:01 +0000 (15:37 -0400)
commitb78bae5ab399b2e73705dcacc85ef2b613e439b3
tree473332b8818e5220244f71bdf4ac6ec0dd7f73ae
parentae6d80f62c739d1b0a9a3f3cfd17c45293bb3a33
net: bcmgenet: use hardware padding of runt frames

[ Upstream commit 20d1f2d1b024f6be199a3bedf1578a1d21592bc5 ]

When commit 474ea9cafc45 ("net: bcmgenet: correctly pad short
packets") added the call to skb_padto() it should have been
located before the nr_frags parameter was read since that value
could be changed when padding packets with lengths between 55
and 59 bytes (inclusive).

The use of a stale nr_frags value can cause corruption of the
pad data when tx-scatter-gather is enabled. This corruption of
the pad can cause invalid checksum computation when hardware
offload of tx-checksum is also enabled.

Since the original reason for the padding was corrected by
commit 7dd399130efb ("net: bcmgenet: fix skb_len in
bcmgenet_xmit_single()") we can remove the software padding all
together and make use of hardware padding of short frames as
long as the hardware also always appends the FCS value to the
frame.

Fixes: 474ea9cafc45 ("net: bcmgenet: correctly pad short packets")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/genet/bcmgenet.c