[rh7] drivers/bnx2x: Limit setting of the max mtu.

Submitted by Andrey Ryabinin on Dec. 29, 2017, 10:06 a.m.

Details

Message ID 20171229100647.24278-1-aryabinin@virtuozzo.com
State New
Series "drivers/bnx2x: Limit setting of the max mtu."
Headers show

Commit Message

Andrey Ryabinin Dec. 29, 2017, 10:06 a.m.
Limit max mtu so that rx_buf_size fits into single page.
This must save us from allocation failures like this:

kswapd0: page allocation failure: order:2, mode:0x4020
Call Trace:
    dump_stack+0x19/0x1b
    warn_alloc_failed+0x110/0x180
    __alloc_pages_nodemask+0x7bf/0xc60
    alloc_pages_current+0x98/0x110
    kmalloc_order+0x18/0x40
    kmalloc_order_trace+0x26/0xa0
    __kmalloc+0x279/0x290
    bnx2x_frag_alloc.isra.61+0x2a/0x40 [bnx2x]
    bnx2x_rx_int+0x227/0x17c0 [bnx2x]
    bnx2x_poll+0x1dd/0x260 [bnx2x]
    net_rx_action+0x179/0x390
    __do_softirq+0x10f/0x2aa
    call_softirq+0x1c/0x30
    do_softirq+0x65/0xa0
    irq_exit+0x105/0x110
    do_IRQ+0x56/0xe0
    common_interrupt+0x6d/0x6d

https://jira.sw.ru/browse/PSBM-77016
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index f4e939f2ad66..339cfb0180e4 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -4868,6 +4868,15 @@  int bnx2x_change_mtu(struct net_device *dev, int new_mtu)
 		return -EINVAL;
 	}
 
+	if (SKB_DATA_ALIGN(new_mtu + BNX2X_FW_RX_ALIGN_START +
+			IP_HEADER_ALIGNMENT_PADDING + ETH_OVERHEAD +
+			BNX2X_FW_RX_ALIGN_END) + NET_SKB_PAD > PAGE_SIZE) {
+		new_mtu = PAGE_SIZE - NET_SKB_PAD - BNX2X_FW_RX_ALIGN_END -
+			ETH_OVERHEAD - IP_HEADER_ALIGNMENT_PADDING -
+			BNX2X_FW_RX_ALIGN_START;
+	}
+
+
 	/* This does not race with packet allocation
 	 * because the actual alloc size is
 	 * only updated as part of load