All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarod Wilson <jarod@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Jarod Wilson <jarod@redhat.com>,
	netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	Maya Erez <qca_merez@qca.qualcomm.com>,
	Simon Kelley <simon@thekelleys.org.uk>,
	Stanislav Yakovlev <stas.yakovlev@gmail.com>
Subject: [PATCH net-next 2/6] net: use core MTU range checking in wireless drivers
Date: Tue, 18 Oct 2016 22:33:29 -0400	[thread overview]
Message-ID: <20161019023333.15760-3-jarod@redhat.com> (raw)
In-Reply-To: <20161019023333.15760-1-jarod@redhat.com>

- set max_mtu in wil6210 driver
- set max_mtu in atmel driver
- set min/max_mtu in cisco airo driver, remove airo_change_mtu
- set min/max_mtu in ipw2100/ipw2200 drivers, remove libipw_change_mtu
- set min/max_mtu in p80211netdev, remove wlan_change_mtu

CC: netdev@vger.kernel.org
CC: linux-wireless@vger.kernel.org
CC: Maya Erez <qca_merez@qca.qualcomm.com>
CC: Simon Kelley <simon@thekelleys.org.uk>
CC: Stanislav Yakovlev <stas.yakovlev@gmail.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 drivers/net/wireless/ath/wil6210/netdev.c          | 17 +----------------
 drivers/net/wireless/atmel/atmel.c                 | 13 ++++---------
 drivers/net/wireless/cisco/airo.c                  | 14 +++-----------
 drivers/net/wireless/intel/ipw2x00/ipw2100.c       |  3 ++-
 drivers/net/wireless/intel/ipw2x00/ipw2200.c       |  8 ++++++--
 drivers/net/wireless/intel/ipw2x00/libipw.h        |  1 -
 drivers/net/wireless/intel/ipw2x00/libipw_module.c |  9 ---------
 drivers/staging/wlan-ng/p80211netdev.c             | 18 +++++-------------
 8 files changed, 21 insertions(+), 62 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/netdev.c b/drivers/net/wireless/ath/wil6210/netdev.c
index 61de5e9..d18372c 100644
--- a/drivers/net/wireless/ath/wil6210/netdev.c
+++ b/drivers/net/wireless/ath/wil6210/netdev.c
@@ -41,21 +41,6 @@ static int wil_stop(struct net_device *ndev)
 	return wil_down(wil);
 }
 
-static int wil_change_mtu(struct net_device *ndev, int new_mtu)
-{
-	struct wil6210_priv *wil = ndev_to_wil(ndev);
-
-	if (new_mtu < 68 || new_mtu > mtu_max) {
-		wil_err(wil, "invalid MTU %d\n", new_mtu);
-		return -EINVAL;
-	}
-
-	wil_dbg_misc(wil, "change MTU %d -> %d\n", ndev->mtu, new_mtu);
-	ndev->mtu = new_mtu;
-
-	return 0;
-}
-
 static int wil_do_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd)
 {
 	struct wil6210_priv *wil = ndev_to_wil(ndev);
@@ -69,7 +54,6 @@ static const struct net_device_ops wil_netdev_ops = {
 	.ndo_start_xmit		= wil_start_xmit,
 	.ndo_set_mac_address	= eth_mac_addr,
 	.ndo_validate_addr	= eth_validate_addr,
-	.ndo_change_mtu		= wil_change_mtu,
 	.ndo_do_ioctl		= wil_do_ioctl,
 };
 
@@ -126,6 +110,7 @@ static int wil6210_netdev_poll_tx(struct napi_struct *napi, int budget)
 static void wil_dev_setup(struct net_device *dev)
 {
 	ether_setup(dev);
+	dev->max_mtu = mtu_max;
 	dev->tx_queue_len = WIL_TX_Q_LEN_DEFAULT;
 }
 
diff --git a/drivers/net/wireless/atmel/atmel.c b/drivers/net/wireless/atmel/atmel.c
index bf2e9a0..eb92d5a 100644
--- a/drivers/net/wireless/atmel/atmel.c
+++ b/drivers/net/wireless/atmel/atmel.c
@@ -1295,14 +1295,6 @@ static struct iw_statistics *atmel_get_wireless_stats(struct net_device *dev)
 	return &priv->wstats;
 }
 
-static int atmel_change_mtu(struct net_device *dev, int new_mtu)
-{
-	if ((new_mtu < 68) || (new_mtu > 2312))
-		return -EINVAL;
-	dev->mtu = new_mtu;
-	return 0;
-}
-
 static int atmel_set_mac_address(struct net_device *dev, void *p)
 {
 	struct sockaddr *addr = p;
@@ -1506,7 +1498,6 @@ static const struct file_operations atmel_proc_fops = {
 static const struct net_device_ops atmel_netdev_ops = {
 	.ndo_open 		= atmel_open,
 	.ndo_stop		= atmel_close,
-	.ndo_change_mtu 	= atmel_change_mtu,
 	.ndo_set_mac_address 	= atmel_set_mac_address,
 	.ndo_start_xmit 	= start_tx,
 	.ndo_do_ioctl 		= atmel_ioctl,
@@ -1600,6 +1591,10 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
 	dev->irq = irq;
 	dev->base_addr = port;
 
+	/* MTU range: 68 - 2312 */
+	dev->min_mtu = 68;
+	dev->max_mtu = MAX_WIRELESS_BODY - ETH_FCS_LEN;
+
 	SET_NETDEV_DEV(dev, sys_dev);
 
 	if ((rc = request_irq(dev->irq, service_interrupt, IRQF_SHARED, dev->name, dev))) {
diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c
index 69b826d..4b04045 100644
--- a/drivers/net/wireless/cisco/airo.c
+++ b/drivers/net/wireless/cisco/airo.c
@@ -2329,14 +2329,6 @@ static int airo_set_mac_address(struct net_device *dev, void *p)
 	return 0;
 }
 
-static int airo_change_mtu(struct net_device *dev, int new_mtu)
-{
-	if ((new_mtu < 68) || (new_mtu > 2400))
-		return -EINVAL;
-	dev->mtu = new_mtu;
-	return 0;
-}
-
 static LIST_HEAD(airo_devices);
 
 static void add_airo_dev(struct airo_info *ai)
@@ -2656,7 +2648,6 @@ static const struct net_device_ops airo11_netdev_ops = {
 	.ndo_get_stats 		= airo_get_stats,
 	.ndo_set_mac_address	= airo_set_mac_address,
 	.ndo_do_ioctl		= airo_ioctl,
-	.ndo_change_mtu		= airo_change_mtu,
 };
 
 static void wifi_setup(struct net_device *dev)
@@ -2668,6 +2659,8 @@ static void wifi_setup(struct net_device *dev)
 	dev->type               = ARPHRD_IEEE80211;
 	dev->hard_header_len    = ETH_HLEN;
 	dev->mtu                = AIRO_DEF_MTU;
+	dev->min_mtu            = 68;
+	dev->max_mtu            = MIC_MSGLEN_MAX;
 	dev->addr_len           = ETH_ALEN;
 	dev->tx_queue_len       = 100; 
 
@@ -2754,7 +2747,6 @@ static const struct net_device_ops airo_netdev_ops = {
 	.ndo_set_rx_mode	= airo_set_multicast_list,
 	.ndo_set_mac_address	= airo_set_mac_address,
 	.ndo_do_ioctl		= airo_ioctl,
-	.ndo_change_mtu		= airo_change_mtu,
 	.ndo_validate_addr	= eth_validate_addr,
 };
 
@@ -2766,7 +2758,6 @@ static const struct net_device_ops mpi_netdev_ops = {
 	.ndo_set_rx_mode	= airo_set_multicast_list,
 	.ndo_set_mac_address	= airo_set_mac_address,
 	.ndo_do_ioctl		= airo_ioctl,
-	.ndo_change_mtu		= airo_change_mtu,
 	.ndo_validate_addr	= eth_validate_addr,
 };
 
@@ -2822,6 +2813,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
 	dev->irq = irq;
 	dev->base_addr = port;
 	dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+	dev->max_mtu = MIC_MSGLEN_MAX;
 
 	SET_NETDEV_DEV(dev, dmdev);
 
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
index bfa542c..6417609 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
@@ -6035,7 +6035,6 @@ static const struct net_device_ops ipw2100_netdev_ops = {
 	.ndo_open		= ipw2100_open,
 	.ndo_stop		= ipw2100_close,
 	.ndo_start_xmit		= libipw_xmit,
-	.ndo_change_mtu		= libipw_change_mtu,
 	.ndo_tx_timeout		= ipw2100_tx_timeout,
 	.ndo_set_mac_address	= ipw2100_set_address,
 	.ndo_validate_addr	= eth_validate_addr,
@@ -6071,6 +6070,8 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
 	dev->wireless_data = &priv->wireless_data;
 	dev->watchdog_timeo = 3 * HZ;
 	dev->irq = 0;
+	dev->min_mtu = 68;
+	dev->max_mtu = LIBIPW_DATA_LEN;
 
 	/* NOTE: We don't use the wireless_handlers hook
 	 * in dev as the system will start throwing WX requests
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
index bfd6861..ef9af8a 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
@@ -11561,7 +11561,6 @@ static const struct net_device_ops ipw_prom_netdev_ops = {
 	.ndo_open 		= ipw_prom_open,
 	.ndo_stop		= ipw_prom_stop,
 	.ndo_start_xmit		= ipw_prom_hard_start_xmit,
-	.ndo_change_mtu		= libipw_change_mtu,
 	.ndo_set_mac_address 	= eth_mac_addr,
 	.ndo_validate_addr	= eth_validate_addr,
 };
@@ -11587,6 +11586,9 @@ static int ipw_prom_alloc(struct ipw_priv *priv)
 	priv->prom_net_dev->type = ARPHRD_IEEE80211_RADIOTAP;
 	priv->prom_net_dev->netdev_ops = &ipw_prom_netdev_ops;
 
+	priv->prom_net_dev->min_mtu = 68;
+	priv->prom_net_dev->max_mtu = LIBIPW_DATA_LEN;
+
 	priv->prom_priv->ieee->iw_mode = IW_MODE_MONITOR;
 	SET_NETDEV_DEV(priv->prom_net_dev, &priv->pci_dev->dev);
 
@@ -11619,7 +11621,6 @@ static const struct net_device_ops ipw_netdev_ops = {
 	.ndo_set_rx_mode	= ipw_net_set_multicast_list,
 	.ndo_set_mac_address	= ipw_net_set_mac_address,
 	.ndo_start_xmit		= libipw_xmit,
-	.ndo_change_mtu		= libipw_change_mtu,
 	.ndo_validate_addr	= eth_validate_addr,
 };
 
@@ -11729,6 +11730,9 @@ static int ipw_pci_probe(struct pci_dev *pdev,
 	net_dev->wireless_handlers = &ipw_wx_handler_def;
 	net_dev->ethtool_ops = &ipw_ethtool_ops;
 
+	net_dev->min_mtu = 68;
+	net_dev->max_mtu = LIBIPW_DATA_LEN;
+
 	err = sysfs_create_group(&pdev->dev.kobj, &ipw_attribute_group);
 	if (err) {
 		IPW_ERROR("failed to create sysfs device attributes\n");
diff --git a/drivers/net/wireless/intel/ipw2x00/libipw.h b/drivers/net/wireless/intel/ipw2x00/libipw.h
index b057161..b513551 100644
--- a/drivers/net/wireless/intel/ipw2x00/libipw.h
+++ b/drivers/net/wireless/intel/ipw2x00/libipw.h
@@ -948,7 +948,6 @@ static inline int libipw_is_cck_rate(u8 rate)
 /* libipw.c */
 void free_libipw(struct net_device *dev, int monitor);
 struct net_device *alloc_libipw(int sizeof_priv, int monitor);
-int libipw_change_mtu(struct net_device *dev, int new_mtu);
 
 void libipw_networks_age(struct libipw_device *ieee, unsigned long age_secs);
 
diff --git a/drivers/net/wireless/intel/ipw2x00/libipw_module.c b/drivers/net/wireless/intel/ipw2x00/libipw_module.c
index 60f2874..2332075 100644
--- a/drivers/net/wireless/intel/ipw2x00/libipw_module.c
+++ b/drivers/net/wireless/intel/ipw2x00/libipw_module.c
@@ -118,15 +118,6 @@ static void libipw_networks_initialize(struct libipw_device *ieee)
 			      &ieee->network_free_list);
 }
 
-int libipw_change_mtu(struct net_device *dev, int new_mtu)
-{
-	if ((new_mtu < 68) || (new_mtu > LIBIPW_DATA_LEN))
-		return -EINVAL;
-	dev->mtu = new_mtu;
-	return 0;
-}
-EXPORT_SYMBOL(libipw_change_mtu);
-
 struct net_device *alloc_libipw(int sizeof_priv, int monitor)
 {
 	struct libipw_device *ieee;
diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c
index 825a63a..4762d38 100644
--- a/drivers/staging/wlan-ng/p80211netdev.c
+++ b/drivers/staging/wlan-ng/p80211netdev.c
@@ -669,18 +669,6 @@ static int p80211knetdev_set_mac_address(struct net_device *dev, void *addr)
 	return result;
 }
 
-static int wlan_change_mtu(struct net_device *dev, int new_mtu)
-{
-	/* 2312 is max 802.11 payload, 20 is overhead, (ether + llc +snap)
-	   and another 8 for wep. */
-	if ((new_mtu < 68) || (new_mtu > (2312 - 20 - 8)))
-		return -EINVAL;
-
-	dev->mtu = new_mtu;
-
-	return 0;
-}
-
 static const struct net_device_ops p80211_netdev_ops = {
 	.ndo_init = p80211knetdev_init,
 	.ndo_open = p80211knetdev_open,
@@ -690,7 +678,6 @@ static const struct net_device_ops p80211_netdev_ops = {
 	.ndo_do_ioctl = p80211knetdev_do_ioctl,
 	.ndo_set_mac_address = p80211knetdev_set_mac_address,
 	.ndo_tx_timeout = p80211knetdev_tx_timeout,
-	.ndo_change_mtu = wlan_change_mtu,
 	.ndo_validate_addr = eth_validate_addr,
 };
 
@@ -756,6 +743,11 @@ int wlan_setup(struct wlandevice *wlandev, struct device *physdev)
 		wdev->wiphy = wiphy;
 		wdev->iftype = NL80211_IFTYPE_STATION;
 		netdev->ieee80211_ptr = wdev;
+		netdev->min_mtu = 68;
+		/* 2312 is max 802.11 payload, 20 is overhead,
+		 * (ether + llc + snap) and another 8 for wep.
+		 */
+		netdev->max_mtu = (2312 - 20 - 8);
 
 		netif_stop_queue(netdev);
 		netif_carrier_off(netdev);
-- 
2.10.0

  parent reply	other threads:[~2016-10-19  2:33 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-19  2:33 [PATCH net-next 0/6] net: use core MTU range checking everywhere Jarod Wilson
2016-10-19  2:33 ` [PATCH net-next 1/6] net: use core MTU range checking in USB NIC drivers Jarod Wilson
2016-10-19  2:33 ` Jarod Wilson [this message]
2016-10-19  7:38   ` [PATCH net-next 2/6] net: use core MTU range checking in wireless drivers Johannes Berg
2016-10-19 14:27     ` Jarod Wilson
2016-10-19 14:28       ` Johannes Berg
2016-10-19  2:33 ` [PATCH net-next 3/6] net: use core MTU range checking in WAN drivers Jarod Wilson
2016-10-21 12:04   ` Krzysztof Hałasa
2016-10-19  2:33 ` [PATCH net-next 4/6] net: use core MTU range checking in core net infra Jarod Wilson
2016-10-19 12:17   ` Jiri Benc
2016-10-19 14:51     ` Jarod Wilson
2016-10-19 13:55   ` Sabrina Dubroca
2016-10-19 14:40     ` Jarod Wilson
2016-10-19 15:28       ` Sabrina Dubroca
2016-10-19 15:46         ` Jarod Wilson
2016-10-19  2:33 ` [PATCH net-next 5/6] net: use core MTU range checking in virt drivers Jarod Wilson
2016-10-19 13:06   ` Aaron Conole
2016-10-19 13:06   ` Aaron Conole
2016-10-19 13:59   ` Michael S. Tsirkin
2016-10-19 13:59     ` Michael S. Tsirkin
2016-10-19 14:03     ` Michael S. Tsirkin
2016-10-19 14:03       ` Michael S. Tsirkin
2016-10-19 14:17       ` Jarod Wilson
2016-10-19 14:17       ` Jarod Wilson
2016-10-19 14:15     ` Jarod Wilson
2016-10-19 14:15     ` Jarod Wilson
2016-10-19 14:07   ` Haiyang Zhang via Virtualization
2016-10-19 14:07     ` Haiyang Zhang
2016-10-19 14:23     ` Jarod Wilson
2016-10-19 14:23     ` Jarod Wilson
2016-10-19 22:21   ` Shrikrishna Khare
2016-10-19 22:21   ` Shrikrishna Khare
2016-10-19  2:33 ` Jarod Wilson
2016-10-19  2:33 ` [PATCH net-next 6/6] net: use core MTU range checking in misc drivers Jarod Wilson
2016-10-19 14:37   ` Robin Holt
2016-10-19 16:05   ` Sabrina Dubroca
2016-10-19 22:38     ` Stefan Richter
2016-10-20  3:16       ` Jarod Wilson
     [not found]         ` <20161020031641.GJ18569-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-22  9:36           ` Stefan Richter
2016-10-22  9:36             ` Stefan Richter
2016-10-22 18:51             ` Stefan Richter
2016-10-19 19:10 ` [PATCH net-next 0/6] net: use core MTU range checking everywhere David Miller
2016-10-19 19:29   ` Jarod Wilson
2016-10-20 17:55 ` [PATCH net-next v2 0/9] " Jarod Wilson
2016-10-20 17:55   ` [PATCH net-next v2 1/9] ethernet: use net core MTU range checking in more drivers Jarod Wilson
2016-10-20 17:55     ` Jarod Wilson
2016-10-20 17:55   ` [PATCH net-next v2 2/9] net: use core MTU range checking in USB NIC drivers Jarod Wilson
2016-10-20 17:55   ` [PATCH net-next v2 3/9] net: use core MTU range checking in wireless drivers Jarod Wilson
2016-10-20 18:22     ` Johannes Berg
2016-10-20 18:38       ` David Miller
2016-10-20 17:55   ` [PATCH net-next v2 4/9] net: use core MTU range checking in WAN drivers Jarod Wilson
2016-10-20 17:55   ` [PATCH net-next v2 5/9] net: use core MTU range checking in core net infra Jarod Wilson
2016-10-20 17:55   ` [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers Jarod Wilson
2016-10-20 17:55     ` Jarod Wilson
2016-10-20 18:05     ` Haiyang Zhang via Virtualization
2016-10-20 18:05     ` Haiyang Zhang
2016-10-20 20:12       ` Kershner, David A
2016-10-20 20:23     ` Michael S. Tsirkin
2016-10-21  2:37       ` Jarod Wilson
2016-10-21  2:37         ` Jarod Wilson
2016-10-21  3:36         ` Michael S. Tsirkin
2016-10-21  3:36           ` Michael S. Tsirkin
2016-10-21 13:24           ` Aaron Conole
2016-10-21 13:24             ` Aaron Conole
2016-10-20 20:23     ` Michael S. Tsirkin
2016-10-21 10:09     ` Wei Liu
2016-10-21 10:09     ` Wei Liu
2016-10-20 17:55   ` [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers Jarod Wilson
2016-10-21  6:52     ` Rémi Denis-Courmont
2016-10-21 16:22     ` Sebastian Reichel
     [not found]     ` <20161020175524.6184-8-jarod-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-22  7:17       ` [net-next,v2,7/9] " Sven Eckelmann
2016-10-22  7:17         ` Sven Eckelmann
2016-10-22 19:16     ` [PATCH net-next v2 7/9] " Stefan Richter
2016-10-22 19:27       ` Stefan Richter
2016-10-23  1:18         ` Jarod Wilson
2016-10-23 14:29           ` [PATCH net-next 1/2] firewire: net: fix maximum possible MTU Stefan Richter
2016-10-23 14:30             ` [PATCH net-next 2/2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards Stefan Richter
2016-10-23 14:30               ` Stefan Richter
2016-10-24  1:50               ` Jarod Wilson
2016-10-24 12:26                 ` [PATCH net-next 2/2 v2] " Stefan Richter
2016-10-24 12:26                   ` Stefan Richter
2016-10-25  3:05                   ` Jarod Wilson
2016-10-26 21:29               ` [PATCH net-next 2/2] " David Miller
2016-10-26 21:29                 ` David Miller
2016-10-29 20:16               ` [PATCH net-next] firewire: net: really fix maximum possible MTU Stefan Richter
2016-10-30  3:01                 ` David Miller
2016-10-24  1:50             ` [PATCH net-next 1/2] firewire: net: " Jarod Wilson
2016-10-26 21:29             ` David Miller
2016-10-26 21:29               ` David Miller
2016-10-20 17:55   ` [PATCH net-next v2 8/9] s390/net: use net core MTU range checking Jarod Wilson
2016-10-20 17:55   ` [PATCH net-next v2 9/9] ipv4/6: use core net " Jarod Wilson
2016-10-20 18:53   ` [PATCH net-next v2 0/9] net: use core MTU range checking everywhere David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161019023333.15760-3-jarod@redhat.com \
    --to=jarod@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=qca_merez@qca.qualcomm.com \
    --cc=simon@thekelleys.org.uk \
    --cc=stas.yakovlev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.