diff mbox series

[RFC,net-next,09/11] net: ntb_netdev: support VLAN using IFF_NO_VLAN_ROOM

Message ID 20200527212512.17901-10-edwin.peer@broadcom.com
State New
Headers show
Series [RFC,net-next,01/11] net: geneve: enable vlan offloads | expand

Commit Message

Edwin Peer May 27, 2020, 9:25 p.m. UTC
It's not clear how useful VLANs layered over Ethernet emulated over NTB
transport are, but they are presently allowed. The L2 emulation exposed
by NTB does not account for possible VLAN tags in the space allocated
for Ethernet headers when configured for maximal MTU.

Signed-off-by: Edwin Peer <edwin.peer@broadcom.com>
---
 drivers/net/ntb_netdev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
index a5bab614ff84..839414afa175 100644
--- a/drivers/net/ntb_netdev.c
+++ b/drivers/net/ntb_netdev.c
@@ -52,6 +52,7 @@ 
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/ntb.h>
+#include <linux/if_vlan.h>
 #include <linux/ntb_transport.h>
 
 #define NTB_NETDEV_VER	"0.7"
@@ -299,14 +300,16 @@  static int ntb_netdev_close(struct net_device *ndev)
 static int ntb_netdev_change_mtu(struct net_device *ndev, int new_mtu)
 {
 	struct ntb_netdev *dev = netdev_priv(ndev);
+	unsigned int max_mtu = ntb_transport_max_size(dev->qp) - ETH_HLEN;
 	struct sk_buff *skb;
 	int len, rc;
 
-	if (new_mtu > ntb_transport_max_size(dev->qp) - ETH_HLEN)
+	if (new_mtu > max_mtu)
 		return -EINVAL;
 
 	if (!netif_running(ndev)) {
 		ndev->mtu = new_mtu;
+		__vlan_constrain_mtu(ndev, max_mtu);
 		return 0;
 	}
 
@@ -336,6 +339,7 @@  static int ntb_netdev_change_mtu(struct net_device *ndev, int new_mtu)
 	}
 
 	ndev->mtu = new_mtu;
+	__vlan_constrain_mtu(ndev, max_mtu);
 
 	ntb_transport_link_up(dev->qp);
 
@@ -422,7 +426,7 @@  static int ntb_netdev_probe(struct device *client_dev)
 	dev->pdev = pdev;
 	ndev->features = NETIF_F_HIGHDMA;
 
-	ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
+	ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_VLAN_ROOM;
 
 	ndev->hw_features = ndev->features;
 	ndev->watchdog_timeo = msecs_to_jiffies(NTB_TX_TIMEOUT_MS);