Commit 8812304c authored by Raimonds Cicans's avatar Raimonds Cicans Committed by David S. Miller

r8169: Fix receive buffer length when MTU is between 1515 and 1536

In r8169 driver MTU is used to calculate receive buffer size.
Receive buffer size is used to configure hardware incoming packet filter.

For jumbo frames:
Receive buffer size = Max frame size = MTU + 14 (ethernet header) + 4
(vlan header) + 4 (ethernet checksum) = MTU + 22

Bug:
driver for all MTU up to 1536 use receive buffer size 1536

As you can see from formula, this mean all IP packets > 1536 - 22
(for vlan tagged, 1536 - 18 for not tagged) are dropped by hardware
filter.

Example:

host_good>  ifconfig eth0 mtu 1536
host_r8169> ifconfig eth0 mtu 1536
host_good>  ping host_r8169
Ok
host_good>  ping -s 1500 host_r8169
Fail
host_good>  ifconfig eth0 mtu 7000
host_r8169> ifconfig eth0 mtu 7000
host_good>  ping -s 1500 host_r8169
Ok

Bonus: got rid of magic number 8
Signed-off-by: default avatarRaimonds Cicans <ray@apollo.lv>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 55369c0a
...@@ -3243,9 +3243,9 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) ...@@ -3243,9 +3243,9 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, static void rtl8169_set_rxbufsize(struct rtl8169_private *tp,
struct net_device *dev) struct net_device *dev)
{ {
unsigned int mtu = dev->mtu; unsigned int max_frame = dev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
tp->rx_buf_sz = (mtu > RX_BUF_SIZE) ? mtu + ETH_HLEN + 8 : RX_BUF_SIZE; tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE;
} }
static int rtl8169_open(struct net_device *dev) static int rtl8169_open(struct net_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment