linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: thunderx: don't allow jumbo frames with XDP
@ 2019-04-02 23:11 Matteo Croce
  2019-04-03  7:18 ` Jesper Dangaard Brouer
  2019-04-05  0:20 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Matteo Croce @ 2019-04-02 23:11 UTC (permalink / raw)
  To: netdev; +Cc: Sunil Goutham, Robert Richter, linux-arm-kernel

The thunderx driver forbids to load an eBPF program if the MTU is higher
than 1500 bytes, but this can be circumvented by first loading the eBPF,
and then raising the MTU.

XDP assumes that SKBs are linear and fit in a single page, this can lead
to undefined behaviours.
Fix this by limiting the MTU to 1500 bytes if an eBPF program is loaded.

Fixes: 05c773f52b96e ("net: thunderx: Add basic XDP support")
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 drivers/net/ethernet/cavium/thunder/nicvf_main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index aa2be4807191..fe1d7513f01d 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -1578,6 +1578,13 @@ static int nicvf_change_mtu(struct net_device *netdev, int new_mtu)
 	struct nicvf *nic = netdev_priv(netdev);
 	int orig_mtu = netdev->mtu;
 
+	/* For now just support only the usual MTU sized frames */
+	if (nic->xdp_prog && new_mtu > 1500) {
+		netdev_warn(netdev, "Jumbo frames not yet supported with XDP, current MTU %d.\n",
+			    netdev->mtu);
+		return -EOPNOTSUPP;
+	}
+
 	netdev->mtu = new_mtu;
 
 	if (!netif_running(netdev))
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-06 16:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-02 23:11 [PATCH net] net: thunderx: don't allow jumbo frames with XDP Matteo Croce
2019-04-03  7:18 ` Jesper Dangaard Brouer
2019-04-05  0:20 ` David Miller
2019-04-05  0:51   ` Matteo Croce
2019-04-05 15:45     ` Matteo Croce
2019-04-06 16:19       ` Jesper Dangaard Brouer

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).