net: use core MTU range checking everywhere
Subsystems (64)
cover net: use core MTU range checking everywhere
This stack of patches should get absolutely everything in the kernel converted from doing their own MTU range checking to the core MTU range checking.
Jarod Wilson (6):
net: use core MTU range checking in USB NIC drivers
net: use core MTU range checking in wireless drivers
net: use core MTU range checking in WAN drivers
net: use core MTU range checking in core net infra
net: use core MTU range checking in virt drivers
net: use core MTU range checking in misc drivers
drivers/char/pcmcia/synclink_cs.c | 1 - drivers/firewire/net.c | 12 +---- drivers/infiniband/hw/nes/nes.c | 1 - drivers/infiniband/hw/nes/nes.h | 4 +- drivers/infiniband/hw/nes/nes_nic.c | 10 ++-- drivers/misc/sgi-xp/xpnet.c | 21 ++------ drivers/net/geneve.c | 48 +++++++---------- drivers/net/hippi/rrunner.c | 1 - drivers/net/hyperv/hyperv_net.h | 4 +- drivers/net/hyperv/netvsc_drv.c | 14 ++--- drivers/net/macvlan.c | 6 ++- drivers/net/rionet.c | 15 ++---- drivers/net/slip/slip.c | 11 ++-- drivers/net/tun.c | 20 +++---- drivers/net/usb/lan78xx.c | 8 ++- drivers/net/usb/r8152.c | 15 ++++-- drivers/net/usb/usbnet.c | 2 - drivers/net/virtio_net.c | 23 ++++---- drivers/net/vmxnet3/vmxnet3_drv.c | 7 +-- drivers/net/vxlan.c | 62 +++++++++++----------- drivers/net/wan/c101.c | 1 - drivers/net/wan/cosa.c | 1 - drivers/net/wan/dscc4.c | 1 - drivers/net/wan/farsync.c | 1 - drivers/net/wan/fsl_ucc_hdlc.c | 1 - drivers/net/wan/hdlc.c | 11 +--- drivers/net/wan/hdlc_fr.c | 3 +- drivers/net/wan/hostess_sv11.c | 1 - drivers/net/wan/ixp4xx_hss.c | 1 - drivers/net/wan/lmc/lmc_main.c | 1 - drivers/net/wan/n2.c | 1 - drivers/net/wan/pc300too.c | 1 - drivers/net/wan/pci200syn.c | 1 - drivers/net/wan/sealevel.c | 1 - drivers/net/wan/wanxl.c | 1 - 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 ++----- drivers/tty/synclink.c | 1 - drivers/tty/synclink_gt.c | 1 - drivers/tty/synclinkmp.c | 1 - include/linux/hdlc.h | 2 - include/linux/hippidevice.h | 1 - net/802/hippi.c | 14 +---- net/atm/lec.c | 11 +--- net/batman-adv/soft-interface.c | 13 +---- net/bridge/br_device.c | 9 ++-- net/openvswitch/vport-internal_dev.c | 10 ---- net/sched/sch_teql.c | 5 +- 54 files changed, 153 insertions(+), 310 deletions(-)
Signature · 1 line
2.10.0
PATCH 1/6 net: use core MTU range checking in USB NIC drivers
- Remove stale new_mtu <= 0 check in usbnet.c
- Set appropriate max_mtu for different r8152 driven variants
- Set max_mtu in lan78xx driver
--- drivers/net/usb/lan78xx.c | 8 +++----- drivers/net/usb/r8152.c | 15 ++++++++++++--- drivers/net/usb/usbnet.c | 2 -- 3 files changed, 15 insertions(+), 10 deletions(-)
drivers/net/usb/lan78xx.c +3 -5
@@ -1980,11 +1980,6 @@ static int lan78xx_change_mtu(struct net_device *netdev, int new_mtu)int old_rx_urb_size = dev->rx_urb_size;int ret; -if (new_mtu >MAX_SINGLE_PACKET_SIZE ) -return -EINVAL ; - -if (new_mtu <=0 ) -return -EINVAL ;/* no second zero-length packet read wanted after mtu-sized packets */ if ((ll_mtu % dev->maxpacket) ==0 )return -EDOM ;
@@ -3388,6 +3383,9 @@ static int lan78xx_probe(struct usb_interface *intf,if (netdev->mtu > (dev->hard_mtu - netdev->hard_header_len)) netdev->mtu = dev->hard_mtu - netdev->hard_header_len; +/* MTU range: 68 - 9000 */ + netdev->max_mtu =MAX_SINGLE_PACKET_SIZE ; + dev->ep_blkin = (intf->cur_altsetting)->endpoint +0 ; dev->ep_blkout = (intf->cur_altsetting)->endpoint +1 ; dev->ep_intr = (intf->cur_altsetting)->endpoint +2 ;
drivers/net/usb/r8152.c +12 -3
@@ -4119,9 +4119,6 @@ static int rtl8152_change_mtu(struct net_device *dev, int new_mtu)break ; } -if (new_mtu <68 || new_mtu >RTL8153_MAX_MTU ) -return -EINVAL ; - ret =usb_autopm_get_interface (tp->intf);if (ret <0 )return ret;
@@ -4311,6 +4308,18 @@ static int rtl8152_probe(struct usb_interface *intf, netdev->ethtool_ops = &ops;netif_set_gso_max_size (netdev,RTL_LIMITED_TSO_SIZE ); +/* MTU range: 68 - 1500 or 9194 */ + netdev->min_mtu =ETH_MIN_MTU ; +switch (tp->version) { +case RTL_VER_01 : +case RTL_VER_02 : + netdev->max_mtu =ETH_DATA_LEN ; +break ; +default : + netdev->max_mtu =RTL8153_MAX_MTU ; +break ; + } + tp->mii.dev = netdev; tp->mii.mdio_read = read_mii_word; tp->mii.mdio_write = write_mii_word;
drivers/net/usb/usbnet.c +0 -2
@@ -384,8 +384,6 @@ int usbnet_change_mtu (struct net_device *net, int new_mtu)int old_hard_mtu = dev->hard_mtu;int old_rx_urb_size = dev->rx_urb_size; -if (new_mtu <=0 ) -return -EINVAL ;// no second zero-length packet read wanted after mtu-sized packets if ((ll_mtu % dev->maxpacket) ==0 )return -EDOM ;
Signature · 1 line
2.10.0
PATCH 2/6 net: use core MTU range checking in wireless drivers
In reply to Jarod Wilson- 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
--- 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(-)
drivers/net/wireless/ath/wil6210/netdev.c +1 -16
@@ -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 ; }
drivers/net/wireless/atmel/atmel.c +4 -9
@@ -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))) {
drivers/net/wireless/cisco/airo.c +3 -11
@@ -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);
drivers/net/wireless/intel/ipw2x00/ipw2100.c +2 -1
@@ -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
drivers/net/wireless/intel/ipw2x00/ipw2200.c +6 -2
@@ -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" );
drivers/net/wireless/intel/ipw2x00/libipw.h +0 -1
@@ -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);
drivers/net/wireless/intel/ipw2x00/libipw_module.c +0 -9
@@ -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;
drivers/staging/wlan-ng/p80211netdev.c +5 -13
@@ -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);
Signature · 1 line
2.10.0
Johannes Berg
maintainerRe: [PATCH net-next 2/6] net: use core MTU range checking in wireless drivers
Quoted 6 lines · Jarod Wilson
- set
max_mtuin wil6210 driver
- setmax_mtuin atmel driver
- set min/max_mtu in cisco airo driver, removeairo_change_mtu
- set min/max_mtu in ipw2100/ipw2200 drivers, removelibipw_change_mtu
- set min/max_mtu in p80211netdev, removewlan_change_mtu
I guess we should do the same in net/mac80211/iface.c?
johannes
Re: [PATCH net-next 2/6] net: use core MTU range checking in wireless drivers
Quoted 9 lines · Johannes Berg
Quoted 6 lines · Jarod Wilson
- set
max_mtuin wil6210 driver
- setmax_mtuin atmel driver
- set min/max_mtu in cisco airo driver, removeairo_change_mtu
- set min/max_mtu in ipw2100/ipw2200 drivers, removelibipw_change_mtu
- set min/max_mtu in p80211netdev, removewlan_change_mtuI guess we should do the same in
net/mac80211/iface.c?
Yeah. I thought I'd located all places this needed to happen, but obviously not. I'll get this added and do another sweep for others I might have missed.
Signature · 2 lines
Jarod Wilson [email protected]
Johannes Berg
maintainerRe: [PATCH net-next 2/6] net: use core MTU range checking in wireless drivers
Quoted 6 lines
Quoted 2 lines
I guess we should do the same in
net/mac80211/iface.c?Yeah. I thought I'd located all places this needed to happen, but obviously not. I'll get this added and do another sweep for others I might have missed.
No worries. I can also do it if you prefer, just wanted to ask :)
johannes
PATCH 3/6 net: use core MTU range checking in WAN drivers
In reply to Jarod Wilson- set min/max_mtu in all hdlc drivers, remove hdlc_change_mtu
- sent max_mtu in lec driver, remove lec_change_mtu
--- drivers/char/pcmcia/synclink_cs.c | 1 - drivers/net/wan/c101.c | 1 - drivers/net/wan/cosa.c | 1 - drivers/net/wan/dscc4.c | 1 - drivers/net/wan/farsync.c | 1 - drivers/net/wan/fsl_ucc_hdlc.c | 1 - drivers/net/wan/hdlc.c | 11 ++--------- drivers/net/wan/hdlc_fr.c | 3 ++- drivers/net/wan/hostess_sv11.c | 1 - drivers/net/wan/ixp4xx_hss.c | 1 - drivers/net/wan/lmc/lmc_main.c | 1 - drivers/net/wan/n2.c | 1 - drivers/net/wan/pc300too.c | 1 - drivers/net/wan/pci200syn.c | 1 - drivers/net/wan/sealevel.c | 1 - drivers/net/wan/wanxl.c | 1 - drivers/tty/synclink.c | 1 - drivers/tty/synclink_gt.c | 1 - drivers/tty/synclinkmp.c | 1 - include/linux/hdlc.h | 2 -- net/atm/lec.c | 11 +---------- 21 files changed, 5 insertions(+), 39 deletions(-)
drivers/char/pcmcia/synclink_cs.c +0 -1
@@ -4248,7 +4248,6 @@ static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size)static const struct net_device_ops hdlcdev_ops = { .ndo_open = hdlcdev_open, .ndo_stop = hdlcdev_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hdlcdev_ioctl, .ndo_tx_timeout = hdlcdev_tx_timeout,
drivers/net/wan/c101.c +0 -1
@@ -302,7 +302,6 @@ static void c101_destroy_card(card_t *card)static const struct net_device_ops c101_ops = { .ndo_open = c101_open, .ndo_stop = c101_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = c101_ioctl, };
drivers/net/wan/cosa.c +0 -1
@@ -432,7 +432,6 @@ module_exit(cosa_exit);static const struct net_device_ops cosa_ops = { .ndo_open = cosa_net_open, .ndo_stop = cosa_net_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = cosa_net_ioctl, .ndo_tx_timeout = cosa_net_timeout,
drivers/net/wan/dscc4.c +0 -1
@@ -887,7 +887,6 @@ static inline int dscc4_set_quartz(struct dscc4_dev_priv *dpriv, int hz)static const struct net_device_ops dscc4_ops = { .ndo_open = dscc4_open, .ndo_stop = dscc4_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = dscc4_ioctl, .ndo_tx_timeout = dscc4_tx_timeout,
drivers/net/wan/farsync.c +0 -1
@@ -2394,7 +2394,6 @@ fst_init_card(struct fst_card_info *card)static const struct net_device_ops fst_ops = { .ndo_open = fst_open, .ndo_stop = fst_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = fst_ioctl, .ndo_tx_timeout = fst_tx_timeout,
drivers/net/wan/fsl_ucc_hdlc.c +0 -1
@@ -992,7 +992,6 @@ static const struct dev_pm_ops uhdlc_pm_ops = {static const struct net_device_ops uhdlc_ops = { .ndo_open = uhdlc_open, .ndo_stop = uhdlc_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = uhdlc_ioctl, };
drivers/net/wan/hdlc.c +2 -9
@@ -46,14 +46,6 @@ static const char* version = "HDLC support module revision 1.22";static struct hdlc_proto *first_proto; -int hdlc_change_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <68 ) || (new_mtu >HDLC_MAX_MTU )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static int hdlc_rcv (struct sk_buff *skb,struct net_device *dev,struct packet_type *p,struct net_device *orig_dev) {
@@ -237,6 +229,8 @@ static void hdlc_setup_dev(struct net_device *dev) dev->flags =IFF_POINTOPOINT |IFF_NOARP ; dev->priv_flags =IFF_WAN_HDLC ; dev->mtu =HDLC_MAX_MTU ; + dev->min_mtu =68 ; + dev->max_mtu =HDLC_MAX_MTU ; dev->type =ARPHRD_RAWHDLC ; dev->hard_header_len =16 ; dev->addr_len =0 ;
@@ -353,7 +347,6 @@ MODULE_AUTHOR("Krzysztof Halasa <[email protected]>");MODULE_DESCRIPTION ("HDLC support module" );MODULE_LICENSE ("GPL v2" ); -EXPORT_SYMBOL (hdlc_change_mtu);EXPORT_SYMBOL (hdlc_start_xmit);EXPORT_SYMBOL (hdlc_open);EXPORT_SYMBOL (hdlc_close);
drivers/net/wan/hdlc_fr.c +2 -1
@@ -1053,7 +1053,6 @@ static void pvc_setup(struct net_device *dev)static const struct net_device_ops pvc_ops = { .ndo_open = pvc_open, .ndo_stop = pvc_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = pvc_xmit, .ndo_do_ioctl = pvc_ioctl, };
@@ -1096,6 +1095,8 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) } dev->netdev_ops = &pvc_ops; dev->mtu =HDLC_MAX_MTU ; + dev->min_mtu =68 ; + dev->max_mtu =HDLC_MAX_MTU ; dev->priv_flags |=IFF_NO_QUEUE ; dev->ml_priv = pvc;
drivers/net/wan/hostess_sv11.c +0 -1
@@ -180,7 +180,6 @@ static int hostess_attach(struct net_device *dev, unsigned short encoding,static const struct net_device_ops hostess_ops = { .ndo_open = hostess_open, .ndo_stop = hostess_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hostess_ioctl, };
drivers/net/wan/ixp4xx_hss.c +0 -1
@@ -1321,7 +1321,6 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)static const struct net_device_ops hss_hdlc_ops = { .ndo_open = hss_hdlc_open, .ndo_stop = hss_hdlc_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hss_hdlc_ioctl, };
drivers/net/wan/lmc/lmc_main.c +0 -1
@@ -808,7 +808,6 @@ static int lmc_attach(struct net_device *dev, unsigned short encoding,static const struct net_device_ops lmc_ops = { .ndo_open = lmc_open, .ndo_stop = lmc_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = lmc_ioctl, .ndo_tx_timeout = lmc_driver_timeout,
drivers/net/wan/n2.c +0 -1
@@ -330,7 +330,6 @@ static void n2_destroy_card(card_t *card)static const struct net_device_ops n2_ops = { .ndo_open = n2_open, .ndo_stop = n2_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = n2_ioctl, };
drivers/net/wan/pc300too.c +0 -1
@@ -291,7 +291,6 @@ static void pc300_pci_remove_one(struct pci_dev *pdev)static const struct net_device_ops pc300_ops = { .ndo_open = pc300_open, .ndo_stop = pc300_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = pc300_ioctl, };
drivers/net/wan/pci200syn.c +0 -1
@@ -270,7 +270,6 @@ static void pci200_pci_remove_one(struct pci_dev *pdev)static const struct net_device_ops pci200_ops = { .ndo_open = pci200_open, .ndo_stop = pci200_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = pci200_ioctl, };
drivers/net/wan/sealevel.c +0 -1
@@ -174,7 +174,6 @@ static int sealevel_attach(struct net_device *dev, unsigned short encoding,static const struct net_device_ops sealevel_ops = { .ndo_open = sealevel_open, .ndo_stop = sealevel_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = sealevel_ioctl, };
drivers/net/wan/wanxl.c +0 -1
@@ -551,7 +551,6 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev)static const struct net_device_ops wanxl_ops = { .ndo_open = wanxl_open, .ndo_stop = wanxl_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = wanxl_ioctl, .ndo_get_stats = wanxl_get_stats,
drivers/tty/synclink.c +0 -1
@@ -7973,7 +7973,6 @@ static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size)static const struct net_device_ops hdlcdev_ops = { .ndo_open = hdlcdev_open, .ndo_stop = hdlcdev_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hdlcdev_ioctl, .ndo_tx_timeout = hdlcdev_tx_timeout,
drivers/tty/synclink_gt.c +0 -1
@@ -1768,7 +1768,6 @@ static void hdlcdev_rx(struct slgt_info *info, char *buf, int size)static const struct net_device_ops hdlcdev_ops = { .ndo_open = hdlcdev_open, .ndo_stop = hdlcdev_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hdlcdev_ioctl, .ndo_tx_timeout = hdlcdev_tx_timeout,
drivers/tty/synclinkmp.c +0 -1
@@ -1887,7 +1887,6 @@ static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size)static const struct net_device_ops hdlcdev_ops = { .ndo_open = hdlcdev_open, .ndo_stop = hdlcdev_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hdlcdev_ioctl, .ndo_tx_timeout = hdlcdev_tx_timeout,
include/linux/hdlc.h +0 -2
@@ -93,8 +93,6 @@ static __inline__ void debug_frame(const struct sk_buff *skb)int hdlc_open (struct net_device *dev);/* Must be called by hardware driver when HDLC device is being closed */ void hdlc_close (struct net_device *dev); -/* May be used by hardware driver */ -int hdlc_change_mtu (struct net_device *dev,int new_mtu);/* Must be pointed to by hw driver's dev->netdev_ops->ndo_start_xmit */ netdev_tx_t hdlc_start_xmit (struct sk_buff *skb,struct net_device *dev);
net/atm/lec.c +1 -10
@@ -544,15 +544,6 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,return 0 ; } -/* shamelessly stolen from drivers/net/net_init.c */ -static int lec_change_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <68 ) || (new_mtu >18190 )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static void lec_set_multicast_list (struct net_device *dev) {/*
@@ -565,7 +556,6 @@ static const struct net_device_ops lec_netdev_ops = { .ndo_open = lec_open, .ndo_stop = lec_close, .ndo_start_xmit = lec_start_xmit, - .ndo_change_mtu = lec_change_mtu, .ndo_tx_timeout = lec_tx_timeout, .ndo_set_rx_mode = lec_set_multicast_list, };
@@ -742,6 +732,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)if (!dev_lec[i])return -ENOMEM ; dev_lec[i]->netdev_ops = &lec_netdev_ops; + dev_lec[i]->max_mtu =18190 ;snprintf (dev_lec[i]->name,IFNAMSIZ ,"lec%d" , i);if (register_netdev (dev_lec[i])) {free_netdev (dev_lec[i]);
Signature · 1 line
2.10.0
Re: [PATCH net-next 3/6] net: use core MTU range checking in WAN drivers
Quoted 12 lines · Jarod Wilson
- set min/max_mtu in all hdlc drivers, remove
hdlc_change_mtu
- sentmax_mtuin lec driver, removelec_change_mtudrivers/net/wan/c101.c | 1 - drivers/net/wan/hdlc.c | 11 ++--------- drivers/net/wan/hdlc_fr.c | 3 ++- drivers/net/wan/ixp4xx_hss.c | 1 - drivers/net/wan/n2.c | 1 - drivers/net/wan/pc300too.c | 1 - drivers/net/wan/pci200syn.c | 1 - drivers/net/wan/wanxl.c | 1 - include/linux/hdlc.h | 2 --
Signature · 4 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland
PATCH 4/6 net: use core MTU range checking in core net infra
In reply to Jarod Wilsongeneve:
- Merge __geneve_change_mtu back into geneve_change_mtu, set max_mtu
- This one isn't quite as straight-forward as others, could use some closer inspection and testing
macvlan:
- set min/max_mtu
tun:
- set min/max_mtu, remove tun_net_change_mtu
vxlan:
- Merge __vxlan_change_mtu back into vxlan_change_mtu, set min/max_mtu
- This one is also not as straight-forward and could use closer inspection and testing from vxlan folks
bridge:
- set max_mtu via br_min_mtu()
openvswitch:
- set min/max_mtu, remove internal_dev_change_mtu
- note: max_mtu wasn't checked previously, it's been set to 65535, which is the largest possible size supported
sch_teql:
- set min/max_mtu (note: max_mtu previously unchecked, used max of 65535)
--- drivers/net/geneve.c | 48 +++++++++++----------------- drivers/net/macvlan.c | 6 +++- drivers/net/tun.c | 20 ++++-------- drivers/net/vxlan.c | 62 ++++++++++++++++++------------------ net/bridge/br_device.c | 9 +++--- net/openvswitch/vport-internal_dev.c | 10 ------ net/sched/sch_teql.c | 5 ++- 7 files changed, 67 insertions(+), 93 deletions(-)
drivers/net/geneve.c +19 -29
@@ -1034,39 +1034,18 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)return geneve_xmit_skb (skb, dev, info); } -static int __geneve_change_mtu (struct net_device *dev,int new_mtu,bool strict) +static int geneve_change_mtu (struct net_device *dev,int new_mtu) { -struct geneve_dev *geneve =netdev_priv (dev); -/* The max_mtu calculation does not take account of GENEVE -* options, to avoid excluding potentially valid -* configurations. +/* Only possible if called internally, ndo_change_mtu path's new_mtu +* is guaranteed to be between dev->min_mtu and dev->max_mtu. */ -int max_mtu =IP_MAX_MTU -GENEVE_BASE_HLEN - dev->hard_header_len; - -if (geneve->remote.sa.sa_family ==AF_INET6 ) - max_mtu -=sizeof (struct ipv6hdr ); -else - max_mtu -=sizeof (struct iphdr ); - -if (new_mtu <68 ) -return -EINVAL ; - -if (new_mtu > max_mtu) { -if (strict) -return -EINVAL ; - - new_mtu = max_mtu; - } +if (new_mtu > dev->max_mtu) + new_mtu = dev->max_mtu; dev->mtu = new_mtu;return 0 ; } -static int geneve_change_mtu (struct net_device *dev,int new_mtu) -{ -return __geneve_change_mtu (dev, new_mtu, true); -} -static int geneve_fill_metadata_dst (struct net_device *dev,struct sk_buff *skb) {struct ip_tunnel_info *info =skb_tunnel_info (skb);
@@ -1170,6 +1149,14 @@ static void geneve_setup(struct net_device *dev) dev->hw_features |=NETIF_F_SG |NETIF_F_HW_CSUM |NETIF_F_RXCSUM ; dev->hw_features |=NETIF_F_GSO_SOFTWARE ; +/* MTU range: 68 - (something less than 65535) */ + dev->min_mtu =ETH_MIN_MTU ; +/* The max_mtu calculation does not take account of GENEVE +* options, to avoid excluding potentially valid +* configurations. This will be further reduced by IPvX hdr size. +*/ + dev->max_mtu =IP_MAX_MTU -GENEVE_BASE_HLEN - dev->hard_header_len; +netif_keep_dst (dev); dev->priv_flags &= ~IFF_TX_SKB_SHARING ; dev->priv_flags |=IFF_LIVE_ADDR_CHANGE |IFF_NO_QUEUE ;
@@ -1285,10 +1272,13 @@ static int geneve_configure(struct net *net, struct net_device *dev,/* make enough headroom for basic scenario */ encap_len =GENEVE_BASE_HLEN +ETH_HLEN ; -if (remote->sa.sa_family ==AF_INET ) +if (remote->sa.sa_family ==AF_INET ) { encap_len +=sizeof (struct iphdr ); -else + dev->max_mtu -=sizeof (struct iphdr ); + }else { encap_len +=sizeof (struct ipv6hdr ); + dev->max_mtu -=sizeof (struct ipv6hdr ); + } dev->needed_headroom = encap_len +ETH_HLEN ;if (metadata) {
@@ -1488,7 +1478,7 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,/* openvswitch users expect packet sizes to be unrestricted, * so set the largest MTU we can. */ - err =__geneve_change_mtu (dev,IP_MAX_MTU , false); + err =geneve_change_mtu (dev,IP_MAX_MTU );if (err) goto err;
drivers/net/macvlan.c +5 -1
@@ -777,7 +777,7 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu) {struct macvlan_dev *vlan =netdev_priv (dev); -if (new_mtu <68 || vlan->lowerdev->mtu < new_mtu) +if (vlan->lowerdev->mtu < new_mtu)return -EINVAL ; dev->mtu = new_mtu;return 0 ;
@@ -1297,6 +1297,10 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,else if (dev->mtu > lowerdev->mtu)return -EINVAL ; +/* MTU range: 68 - lowerdev->max_mtu */ + dev->min_mtu =ETH_MIN_MTU ; + dev->max_mtu = lowerdev->max_mtu; +if (!tb[IFLA_ADDRESS ])eth_hw_addr_random (dev);
drivers/net/tun.c +6 -14
@@ -925,18 +925,6 @@ static void tun_net_mclist(struct net_device *dev)*/ } -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int -tun_net_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu + dev->hard_header_len >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static netdev_features_t tun_net_fix_features (struct net_device *dev,netdev_features_t features) {
@@ -1014,7 +1002,6 @@ static const struct net_device_ops tun_netdev_ops = { .ndo_open = tun_net_open, .ndo_stop = tun_net_close, .ndo_start_xmit = tun_net_xmit, - .ndo_change_mtu = tun_net_change_mtu, .ndo_fix_features = tun_net_fix_features, .ndo_select_queue = tun_select_queue,#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1029,7 +1016,6 @@ static const struct net_device_ops tap_netdev_ops = { .ndo_open = tun_net_open, .ndo_stop = tun_net_close, .ndo_start_xmit = tun_net_xmit, - .ndo_change_mtu = tun_net_change_mtu, .ndo_fix_features = tun_net_fix_features, .ndo_set_rx_mode = tun_net_mclist, .ndo_set_mac_address = eth_mac_addr,
@@ -1062,6 +1048,9 @@ static void tun_flow_uninit(struct tun_struct *tun)tun_flow_flush (tun); } +#define MIN_MTU 68 +#define MAX_MTU 65535 +/* Initialize net device. */ static void tun_net_init (struct net_device *dev) {
@@ -1092,6 +1081,9 @@ static void tun_net_init(struct net_device *dev)break ; } + + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU - dev->hard_header_len; }/* Character device part */
drivers/net/vxlan.c +31 -31
97 lines not on this page · raw message
net/bridge/br_device.c +4 -5
@@ -184,17 +184,15 @@ static struct rtnl_link_stats64 *br_get_stats64(struct net_device *dev,static int br_change_mtu (struct net_device *dev,int new_mtu) { +#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )struct net_bridge *br =netdev_priv (dev); -if (new_mtu <68 || new_mtu >br_min_mtu (br)) -return -EINVAL ; - - dev->mtu = new_mtu; -#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )/* remember the MTU in the rtable for PMTU */ dst_metric_set (&br->fake_rtable.dst,RTAX_MTU , new_mtu);#endif + dev->mtu = new_mtu; +return 0 ; }
@@ -390,6 +388,7 @@ void br_dev_setup(struct net_device *dev) dev->hw_features =COMMON_FEATURES |NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_STAG_TX ; dev->vlan_features =COMMON_FEATURES ; + dev->max_mtu =br_min_mtu (br); br->dev = dev;spin_lock_init (&br->lock);
net/openvswitch/vport-internal_dev.c +0 -10
@@ -89,15 +89,6 @@ static const struct ethtool_ops internal_dev_ethtool_ops = { .get_link = ethtool_op_get_link, }; -static int internal_dev_change_mtu (struct net_device *netdev,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - netdev->mtu = new_mtu; -return 0 ; -} -static void internal_dev_destructor (struct net_device *dev) {struct vport *vport =ovs_internal_dev_get_vport (dev);
@@ -148,7 +139,6 @@ static const struct net_device_ops internal_dev_netdev_ops = { .ndo_stop = internal_dev_stop, .ndo_start_xmit = internal_dev_xmit, .ndo_set_mac_address = eth_mac_addr, - .ndo_change_mtu = internal_dev_change_mtu, .ndo_get_stats64 = internal_get_stats, .ndo_set_rx_headroom = internal_set_rx_headroom, };
net/sched/sch_teql.c +2 -3
@@ -418,9 +418,6 @@ static int teql_master_mtu(struct net_device *dev, int new_mtu)struct teql_master *m =netdev_priv (dev);struct Qdisc *q; -if (new_mtu <68 ) -return -EINVAL ; - q = m->slaves;if (q) { do {
@@ -460,6 +457,8 @@ static __init void teql_master_setup(struct net_device *dev) dev->netdev_ops = &teql_netdev_ops; dev->type =ARPHRD_VOID ; dev->mtu =1500 ; + dev->min_mtu =68 ; + dev->max_mtu =65535 ; dev->tx_queue_len =100 ; dev->flags =IFF_NOARP ; dev->hard_header_len =LL_MAX_HEADER ;
Signature · 1 line
2.10.0
Sabrina Dubroca
maintainerRe: [PATCH net-next 4/6] net: use core MTU range checking in core net infra
Quoted 19 lines · Jarod Wilson
geneve:
- Merge__geneve_change_mtuback intogeneve_change_mtu, setmax_mtu
- This one isn't quite as straight-forward as others, could use some closer inspection and testingmacvlan:
- set min/max_mtutun:
- set min/max_mtu, removetun_net_change_mtuvxlan:
- Merge__vxlan_change_mtuback intovxlan_change_mtu, set min/max_mtu
- This one is also not as straight-forward and could use closer inspection and testing from vxlan folksbridge:
- setmax_mtuviabr_min_mtu()
Quoted 7 lines
openvswitch:
- set min/max_mtu, removeinternal_dev_change_mtu
- note:max_mtuwasn't checked previously, it's been set to 65535, which is the largest possible size supported
sch_teql:
- set min/max_mtu (note:max_mtupreviously unchecked, used max of 65535)
Nothing for other virtual netdevices? (dummy, veth, bond, etc) Their MTU is limited to 1500 now. Also missing macsec and ip_gre, probably others that are using ether_setup.
[...]
Quoted 26 lines
net/bridge/br_device.c +3
-5@@ -184,17 +184,15 @@ static struct rtnl_link_stats64 *br_get_stats64(struct net_device *dev,static int br_change_mtu (struct net_device *dev,int new_mtu) { +#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )struct net_bridge *br =netdev_priv (dev); -if (new_mtu <68 || new_mtu >br_min_mtu (br)) -return -EINVAL ; - - dev->mtu = new_mtu; -#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )/* remember the MTU in the rtable for PMTU */ dst_metric_set (&br->fake_rtable.dst,RTAX_MTU , new_mtu);#endif + dev->mtu = new_mtu; +return 0 ; }
net/bridge/br_device.c void br_dev_setup(struct net_device *dev) · line 391
Quoted 4 lines
net/bridge/br_device.c +1
-0@@ -390,6 +388,7 @@ void br_dev_setup(struct net_device *dev) dev->hw_features =COMMON_FEATURES |NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_STAG_TX ; dev->vlan_features =COMMON_FEATURES ; + dev->max_mtu =br_min_mtu (br);
br_min_mtu uses br->port_list, which is only initialized a few lines later (right after the spin_lock_init() at the end of the context of this diff).
Besides, I don't think this works: br_min_mtu(br) changes when you add and remove ports, or when you change the MTU of an enslaved device. But this makes the max MTU for the bridge fixed (to 1500).
Quoted 25 lines
net/bridge/br_device.c +0
-0br->dev = dev;spin_lock_init (&br->lock);net/openvswitch/vport-internal_dev.c +0
-9@@ -89,15 +89,6 @@ static const struct ethtool_ops internal_dev_ethtool_ops = { .get_link = ethtool_op_get_link, }; -static int internal_dev_change_mtu (struct net_device *netdev,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - netdev->mtu = new_mtu; -return 0 ; -} -static void internal_dev_destructor (struct net_device *dev) {struct vport *vport =ovs_internal_dev_get_vport (dev);
net/openvswitch/vport-internal_dev.c static const struct net_device_ops internal_dev_netdev_ops = { · line 144
Quoted 7 lines
net/openvswitch/vport-internal_dev.c +0
-1@@ -148,7 +139,6 @@ static const struct net_device_ops internal_dev_netdev_ops = { .ndo_stop = internal_dev_stop, .ndo_start_xmit = internal_dev_xmit, .ndo_set_mac_address = eth_mac_addr, - .ndo_change_mtu = internal_dev_change_mtu, .ndo_get_stats64 = internal_get_stats, .ndo_set_rx_headroom = internal_set_rx_headroom, };
vport-internal uses ether_setup, so the MTU is currently limited to 1500, no?
Signature · 1 line
Sabrina
Re: [PATCH net-next 4/6] net: use core MTU range checking in core net infra
Quoted 25 lines · Sabrina Dubroca
Quoted 24 lines · Jarod Wilson
geneve:
- Merge__geneve_change_mtuback intogeneve_change_mtu, setmax_mtu
- This one isn't quite as straight-forward as others, could use some closer inspection and testingmacvlan:
- set min/max_mtutun:
- set min/max_mtu, removetun_net_change_mtuvxlan:
- Merge__vxlan_change_mtuback intovxlan_change_mtu, set min/max_mtu
- This one is also not as straight-forward and could use closer inspection and testing from vxlan folksbridge:
- setmax_mtuviabr_min_mtu()openvswitch:
- set min/max_mtu, removeinternal_dev_change_mtu
- note:max_mtuwasn't checked previously, it's been set to 65535, which is the largest possible size supported
Quoted 6 lines
Quoted 2 lines
sch_teql:
- set min/max_mtu (note:max_mtupreviously unchecked, used max of 65535)Nothing for other virtual netdevices? (dummy, veth, bond, etc) Their MTU is limited to 1500 now. Also missing macsec and
ip_gre, probably others that are usingether_setup.
Yeah, I've clearly missed more than I thought. Doing another sweep now. I'm thinking more and more that we ought to back out the patch that sets min/max in ether_setup, save it for last, after we're sure everyone that calls it has been prepared.
Quoted 26 lines
[...]
Quoted 25 lines
net/bridge/br_device.c +3
-5@@ -184,17 +184,15 @@ static struct rtnl_link_stats64 *br_get_stats64(struct net_device *dev,static int br_change_mtu (struct net_device *dev,int new_mtu) { +#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )struct net_bridge *br =netdev_priv (dev); -if (new_mtu <68 || new_mtu >br_min_mtu (br)) -return -EINVAL ; - - dev->mtu = new_mtu; -#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )/* remember the MTU in the rtable for PMTU */ dst_metric_set (&br->fake_rtable.dst,RTAX_MTU , new_mtu);#endif + dev->mtu = new_mtu; +return 0 ; }
Quoted 9 lines
net/bridge/br_device.c void br_dev_setup(struct net_device *dev) · line 391
Quoted 5 lines
net/bridge/br_device.c +1
-0@@ -390,6 +388,7 @@ void br_dev_setup(struct net_device *dev) dev->hw_features =COMMON_FEATURES |NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_STAG_TX ; dev->vlan_features =COMMON_FEATURES ; + dev->max_mtu =br_min_mtu (br);
br_min_mtuusesbr->port_list, which is only initialized a few lines later (right after thespin_lock_init()at the end of the context of this diff).
Ah, okay, I'd just grouped it with the other dev->foo settings.
Quoted 3 lines
Besides, I don't think this works:
br_min_mtu(br)changes when you add and remove ports, or when you change the MTU of an enslaved device. But this makes the max MTU for the bridge fixed (to 1500).
Okay, how about this: set no max_mtu (or set it to IP_MAX_MTU/65535), and then retain a check against the possibly ever-changing br_min_mtu(br) in br_change_mtu()?
Quoted 23 lines
Quoted 23 lines
net/openvswitch/vport-internal_dev.c +0
-9@@ -89,15 +89,6 @@ static const struct ethtool_ops internal_dev_ethtool_ops = { .get_link = ethtool_op_get_link, }; -static int internal_dev_change_mtu (struct net_device *netdev,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - netdev->mtu = new_mtu; -return 0 ; -} -static void internal_dev_destructor (struct net_device *dev) {struct vport *vport =ovs_internal_dev_get_vport (dev);@@ -148,7 +139,6 @@ static const struct net_device_ops internal_dev_netdev_ops = { .ndo_stop = internal_dev_stop, .ndo_start_xmit = internal_dev_xmit,
Quoted 8 lines
net/openvswitch/vport-internal_dev.c static const struct net_device_ops internal_dev_netdev_ops = { · line 144
Quoted 5 lines
net/openvswitch/vport-internal_dev.c +0
-1.ndo_set_mac_address = eth_mac_addr, - .ndo_change_mtu = internal_dev_change_mtu, .ndo_get_stats64 = internal_get_stats, .ndo_set_rx_headroom = internal_set_rx_headroom, };vport-internal uses
ether_setup, so the MTU is currently limited to 1500, no?
Yeah. Sweep ongoing...
Signature · 2 lines
Jarod Wilson [email protected]
Sabrina Dubroca
maintainerRe: [PATCH net-next 4/6] net: use core MTU range checking in core net infra
Quoted 26 lines · Jarod Wilson
Quoted 25 lines · Sabrina Dubroca
Quoted 24 lines · Jarod Wilson
geneve:
- Merge__geneve_change_mtuback intogeneve_change_mtu, setmax_mtu
- This one isn't quite as straight-forward as others, could use some closer inspection and testingmacvlan:
- set min/max_mtutun:
- set min/max_mtu, removetun_net_change_mtuvxlan:
- Merge__vxlan_change_mtuback intovxlan_change_mtu, set min/max_mtu
- This one is also not as straight-forward and could use closer inspection and testing from vxlan folksbridge:
- setmax_mtuviabr_min_mtu()openvswitch:
- set min/max_mtu, removeinternal_dev_change_mtu
- note:max_mtuwasn't checked previously, it's been set to 65535, which is the largest possible size supported
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
sch_teql:
- set min/max_mtu (note:max_mtupreviously unchecked, used max of 65535)Nothing for other virtual netdevices? (dummy, veth, bond, etc) Their MTU is limited to 1500 now. Also missing macsec and
ip_gre, probably others that are usingether_setup.Yeah, I've clearly missed more than I thought. Doing another sweep now.
Thanks.
Quoted 3 lines
I'm thinking more and more that we ought to back out the patch that sets min/max in
ether_setup, save it for last, after we're sure everyone that calls it has been prepared.
I'm not sure how that would work now, if some of the patches that already went in for ethernet drivers assume that ether_setup will configure a basic {min,max}_mtu pair (at least e100 makes that assumption, but that might be the only one).
Quoted 38 lines
Quoted 26 lines
[...]
Quoted 25 lines
net/bridge/br_device.c +3
-5@@ -184,17 +184,15 @@ static struct rtnl_link_stats64 *br_get_stats64(struct net_device *dev,static int br_change_mtu (struct net_device *dev,int new_mtu) { +#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )struct net_bridge *br =netdev_priv (dev); -if (new_mtu <68 || new_mtu >br_min_mtu (br)) -return -EINVAL ; - - dev->mtu = new_mtu; -#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )/* remember the MTU in the rtable for PMTU */ dst_metric_set (&br->fake_rtable.dst,RTAX_MTU , new_mtu);#endif + dev->mtu = new_mtu; +return 0 ; }Quoted 9 lines
net/bridge/br_device.c void br_dev_setup(struct net_device *dev) · line 391
Quoted 5 lines
net/bridge/br_device.c +1
-0@@ -390,6 +388,7 @@ void br_dev_setup(struct net_device *dev) dev->hw_features =COMMON_FEATURES |NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_STAG_TX ; dev->vlan_features =COMMON_FEATURES ; + dev->max_mtu =br_min_mtu (br);
br_min_mtuusesbr->port_list, which is only initialized a few lines later (right after thespin_lock_init()at the end of the context of this diff).Ah, okay, I'd just grouped it with the other
dev->foosettings.
Quoted 7 lines
Quoted 3 lines
Besides, I don't think this works:
br_min_mtu(br)changes when you add and remove ports, or when you change the MTU of an enslaved device. But this makes the max MTU for the bridge fixed (to 1500).Okay, how about this: set no
max_mtu(or set it to IP_MAX_MTU/65535), and then retain a check against the possibly ever-changingbr_min_mtu(br)inbr_change_mtu()?
Sounds good to me.
Signature · 1 line
Sabrina
Re: [PATCH net-next 4/6] net: use core MTU range checking in core net infra
Quoted 3 lines · Sabrina Dubroca
Quoted 2 lines · Jarod Wilson
Quoted 1 line · Sabrina Dubroca
2016-10-18, 22:33:31 -0400, Jarod Wilson wrote:
...
Quoted 8 lines
Quoted 3 lines
I'm thinking more and more that we ought to back out the patch that sets min/max in
ether_setup, save it for last, after we're sure everyone that calls it has been prepared.I'm not sure how that would work now, if some of the patches that already went in for ethernet drivers assume that
ether_setupwill configure a basic {min,max}_mtu pair (at least e100 makes that assumption, but that might be the only one).
Argh. Yeah. Hrm. Would have to do the revert *and* have e100 and possibly others set their own min/max pair. So I guess it's a race to fix all the fallout... Crap.
Quoted 42 lines
Quoted 42 lines
Quoted 26 lines
[...]
Quoted 25 lines
net/bridge/br_device.c +3
-5@@ -184,17 +184,15 @@ static struct rtnl_link_stats64 *br_get_stats64(struct net_device *dev,static int br_change_mtu (struct net_device *dev,int new_mtu) { +#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )struct net_bridge *br =netdev_priv (dev); -if (new_mtu <68 || new_mtu >br_min_mtu (br)) -return -EINVAL ; - - dev->mtu = new_mtu; -#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER )/* remember the MTU in the rtable for PMTU */ dst_metric_set (&br->fake_rtable.dst,RTAX_MTU , new_mtu);#endif + dev->mtu = new_mtu; +return 0 ; }Quoted 9 lines
net/bridge/br_device.c void br_dev_setup(struct net_device *dev) · line 391
Quoted 5 lines
net/bridge/br_device.c +1
-0@@ -390,6 +388,7 @@ void br_dev_setup(struct net_device *dev) dev->hw_features =COMMON_FEATURES |NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_STAG_TX ; dev->vlan_features =COMMON_FEATURES ; + dev->max_mtu =br_min_mtu (br);
br_min_mtuusesbr->port_list, which is only initialized a few lines later (right after thespin_lock_init()at the end of the context of this diff).Ah, okay, I'd just grouped it with the other
dev->foosettings.Quoted 3 lines
Besides, I don't think this works:
br_min_mtu(br)changes when you add and remove ports, or when you change the MTU of an enslaved device. But this makes the max MTU for the bridge fixed (to 1500).
Quoted 5 lines
Quoted 3 lines
Okay, how about this: set no
max_mtu(or set it to IP_MAX_MTU/65535), and then retain a check against the possibly ever-changingbr_min_mtu(br)inbr_change_mtu()?Sounds good to me.
I think I have something here locally that looks sane. Working on a few other similar cases now.
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next 4/6] net: use core MTU range checking in core net infra
In reply to Jarod WilsonQuoted 37 lines · Jarod Wilson
drivers/net/vxlan.c +12
-15@@ -2367,43 +2367,31 @@ static void vxlan_set_multicast_list(struct net_device *dev) { } -static int __vxlan_change_mtu (struct net_device *dev, -struct net_device *lowerdev, -struct vxlan_rdst *dst,int new_mtu,bool strict) +static int vxlan_change_mtu (struct net_device *dev,int new_mtu) { -int max_mtu =IP_MAX_MTU ; - -if (lowerdev) - max_mtu = lowerdev->mtu; +struct vxlan_dev *vxlan =netdev_priv (dev); +struct vxlan_rdst *dst = &vxlan->default_dst; +struct net_device *lowerdev =__dev_get_by_index (vxlan->net, + dst->remote_ifindex); +bool use_ipv6 = false;if (dst->remote_ip.sa.sa_family ==AF_INET6 ) - max_mtu -=VXLAN6_HEADROOM ; -else - max_mtu -=VXLAN_HEADROOM ; - -if (new_mtu <68 ) -return -EINVAL ; + use_ipv6 = true; -if (new_mtu > max_mtu) { -if (strict) +/* We re-check this, because users *could* alter the mtu of the +* lower device after we've initialized dev->max_mtu. +*/ +if (lowerdev) { + dev->max_mtu = lowerdev->mtu -
drivers/net/vxlan.c static void vxlan_set_multicast_list(struct net_device *dev) · line 2393
Quoted 10 lines
drivers/net/vxlan.c +2
-2+ (use_ipv6 ?VXLAN6_HEADROOM :VXLAN_HEADROOM ); +if (new_mtu > dev->max_mtu)return -EINVAL ; - - new_mtu = max_mtu; } dev->mtu = new_mtu;return 0 ; }
Sorry for the silly question, how does the min_mtu and max_mtu stuff works? I noticed your patches but haven't looked in depth into them.
When the ndo_change_mtu callback is defined, is the dev->min_mtu and dev->max_mtu checked first and if the desired mtu is not within range, ndo_change_mtu is not called?
Or does ndo_change_mtu override the checks?
In either case, the code does not look correct. In the first case, increasing of lowerdev MTU wouldn't allow increasing of vxlan MTU without deleting and recreating the vxlan interface. In the second case, you're missing check against the min_mtu.
Quoted 44 lines
drivers/net/vxlan.c +9
-13-static int vxlan_change_mtu (struct net_device *dev,int new_mtu) -{ -struct vxlan_dev *vxlan =netdev_priv (dev); -struct vxlan_rdst *dst = &vxlan->default_dst; -struct net_device *lowerdev =__dev_get_by_index (vxlan->net, - dst->remote_ifindex); -return __vxlan_change_mtu (dev, lowerdev, dst, new_mtu, true); -} -static int vxlan_fill_metadata_dst (struct net_device *dev,struct sk_buff *skb) {struct vxlan_dev *vxlan =netdev_priv (dev);@@ -2795,6 +2783,10 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,vxlan_ether_setup (dev); } +/* MTU range: 68 - 65535 */ + dev->min_mtu =68 ; + dev->max_mtu =IP_MAX_MTU ; + vxlan->net = src_net; dst->remote_vni = conf->vni;@@ -2837,8 +2829,11 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, }#endif -if (!conf->mtu) - dev->mtu = lowerdev->mtu - (use_ipv6 ?VXLAN6_HEADROOM :VXLAN_HEADROOM ); +if (!conf->mtu) { + dev->mtu = lowerdev->mtu - + (use_ipv6 ?VXLAN6_HEADROOM :VXLAN_HEADROOM ); + dev->max_mtu = dev->mtu; + } needed_headroom = lowerdev->hard_header_len; }else if (vxlan_addr_multicast (&dst->remote_ip)) {@@ -2847,9 +2842,14 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, }if (conf->mtu) { - err =__vxlan_change_mtu (dev, lowerdev, dst, conf->mtu, false); -if (err)
drivers/net/vxlan.c static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, · line 2853
Quoted 10 lines
drivers/net/vxlan.c +8
-1-return err; +if (lowerdev) + dev->max_mtu = lowerdev->mtu; + dev->max_mtu -= (use_ipv6 ?VXLAN6_HEADROOM :VXLAN_HEADROOM ); + + dev->mtu = conf->mtu; + +if (conf->mtu > dev->max_mtu) + dev->mtu = dev->max_mtu; }
You removed the check for min_mtu but it's needed here. The conf->mtu value comes from the user space and can be anything.
drivers/net/vxlan.c static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, · line 2855
Quoted 2 lines
drivers/net/vxlan.c +0
-0if (use_ipv6 || conf->flags &VXLAN_F_COLLECT_METADATA )
Jiri
Re: [PATCH net-next 4/6] net: use core MTU range checking in core net infra
Quoted 52 lines · Jiri Benc
Quoted 37 lines · Jarod Wilson
drivers/net/vxlan.c +12
-15@@ -2367,43 +2367,31 @@ static void vxlan_set_multicast_list(struct net_device *dev) { } -static int __vxlan_change_mtu (struct net_device *dev, -struct net_device *lowerdev, -struct vxlan_rdst *dst,int new_mtu,bool strict) +static int vxlan_change_mtu (struct net_device *dev,int new_mtu) { -int max_mtu =IP_MAX_MTU ; - -if (lowerdev) - max_mtu = lowerdev->mtu; +struct vxlan_dev *vxlan =netdev_priv (dev); +struct vxlan_rdst *dst = &vxlan->default_dst; +struct net_device *lowerdev =__dev_get_by_index (vxlan->net, + dst->remote_ifindex); +bool use_ipv6 = false;if (dst->remote_ip.sa.sa_family ==AF_INET6 ) - max_mtu -=VXLAN6_HEADROOM ; -else - max_mtu -=VXLAN_HEADROOM ; - -if (new_mtu <68 ) -return -EINVAL ; + use_ipv6 = true; -if (new_mtu > max_mtu) { -if (strict) +/* We re-check this, because users *could* alter the mtu of the +* lower device after we've initialized dev->max_mtu. +*/ +if (lowerdev) { + dev->max_mtu = lowerdev->mtu -drivers/net/vxlan.c static void vxlan_set_multicast_list(struct net_device *dev) · line 2393
Quoted 10 lines
drivers/net/vxlan.c +2
-2+ (use_ipv6 ?VXLAN6_HEADROOM :VXLAN_HEADROOM ); +if (new_mtu > dev->max_mtu)return -EINVAL ; - - new_mtu = max_mtu; } dev->mtu = new_mtu;return 0 ; }Sorry for the silly question, how does the
min_mtuandmax_mtustuff works? I noticed your patches but haven't looked in depth into them.
Quoted 5 lines
When the
ndo_change_mtucallback is defined, is thedev->min_mtuanddev->max_mtuchecked first and if the desired mtu is not within range,ndo_change_mtuis not called?Or does
ndo_change_mtuoverride the checks?
The former. If the new value is outside min/max, ndo_change_mtu doesn't get called, which is exactly the chicken and egg problem I introduced by setting max_mtu to 1500 in ether_setup before having all drivers that call ether_setup set a more appropriate max_mtu first. :\
Quoted 4 lines
In either case, the code does not look correct. In the first case, increasing of lowerdev MTU wouldn't allow increasing of vxlan MTU without deleting and recreating the vxlan interface. In the second case, you're missing check against the
min_mtu.
Okay, this sounds like a similar case to bridge that Sabrina pointed out. Looks like virtual devices will need to just set no max_mtu directly (or IP_MAX_MTU), and do dynamic checks in their ndo_change_mtu if they need to compare against underlying devices on the fly.
...
Quoted 19 lines
Quoted 6 lines
drivers/net/vxlan.c +0
-2@@ -2847,9 +2842,14 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, }if (conf->mtu) { - err =__vxlan_change_mtu (dev, lowerdev, dst, conf->mtu, false); -if (err)drivers/net/vxlan.c static int vxlan_dev_configure(struct net *src_net, struct net_device *dev, · line 2853
Quoted 10 lines
drivers/net/vxlan.c +8
-1-return err; +if (lowerdev) + dev->max_mtu = lowerdev->mtu; + dev->max_mtu -= (use_ipv6 ?VXLAN6_HEADROOM :VXLAN_HEADROOM ); + + dev->mtu = conf->mtu; + +if (conf->mtu > dev->max_mtu) + dev->mtu = dev->max_mtu; }You removed the check for
min_mtubut it's needed here. Theconf->mtuvalue comes from the user space and can be anything.
Hm. Not sure why I did that... Will put it back now...
Signature · 2 lines
Jarod Wilson [email protected]
PATCH 5/6 net: use core MTU range checking in virt drivers
In reply to Jarod Wilsonhyperv_net:
- set min/max_mtu
virtio_net:
- set min/max_mtu
- remove virtnet_change_mtu
vmxnet3:
- set min/max_mtu
--- drivers/net/hyperv/hyperv_net.h | 4 ++-- drivers/net/hyperv/netvsc_drv.c | 14 +++++++------- drivers/net/virtio_net.c | 23 ++++++++++------------- drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++++--- 4 files changed, 23 insertions(+), 25 deletions(-)
drivers/net/hyperv/hyperv_net.h +2 -2
@@ -606,8 +606,8 @@ struct nvsp_message { } __packed; -#define NETVSC_MTU 65536 -#define NETVSC_MTU_MIN 68 +#define NETVSC_MTU 65535 +#define NETVSC_MTU_MIN ETH_MIN_MTU#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16)/* 16MB */ #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15)/* 15MB */
drivers/net/hyperv/netvsc_drv.c +7 -7
@@ -872,19 +872,12 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)struct netvsc_device *nvdev = ndevctx->nvdev;struct hv_device *hdev = ndevctx->device_ctx;struct netvsc_device_info device_info; -int limit =ETH_DATA_LEN ;u32 num_chn;int ret =0 ;if (ndevctx->start_remove || !nvdev || nvdev->destroy)return -ENODEV ; -if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) - limit =NETVSC_MTU -ETH_HLEN ; - -if (mtu <NETVSC_MTU_MIN || mtu > limit) -return -EINVAL ; - ret =netvsc_close (ndev);if (ret) goto out;
@@ -1343,6 +1336,13 @@ static int netvsc_probe(struct hv_device *dev,netif_carrier_off (net); +/* MTU range: 68 - 1500 or 65521 */ + net->min_mtu =NETVSC_MTU_MIN ; +if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) + net->max_mtu =NETVSC_MTU -ETH_HLEN ; +else + net->max_mtu =ETH_DATA_LEN ; +netvsc_init_settings (net); net_device_ctx =netdev_priv (net);
drivers/net/virtio_net.c +10 -13
@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,
@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; } +#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU 65535 +static int virtnet_probe (struct virtio_device *vdev) {int i, err;
@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,
@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu >= dev->min_mtu && mtu <= dev->max_mtu) { + dev->mtu = mtu;__virtio_clear_bit (vdev,VIRTIO_NET_F_MTU ); + } }if (vi->any_header_sg)
drivers/net/vmxnet3/vmxnet3_drv.c +4 -3
@@ -2969,9 +2969,6 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)struct vmxnet3_adapter *adapter =netdev_priv (netdev);int err =0 ; -if (new_mtu <VMXNET3_MIN_MTU || new_mtu >VMXNET3_MAX_MTU ) -return -EINVAL ; - netdev->mtu = new_mtu;/*
@@ -3428,6 +3425,10 @@ vmxnet3_probe_device(struct pci_dev *pdev,vmxnet3_set_ethtool_ops (netdev); netdev->watchdog_timeo =5 *HZ ; +/* MTU range: 60 - 9000 */ + netdev->min_mtu =VMXNET3_MIN_MTU ; + netdev->max_mtu =VMXNET3_MAX_MTU ; +INIT_WORK (&adapter->work, vmxnet3_reset_work);set_bit (VMXNET3_STATE_BIT_QUIESCED , &adapter->state);
Signature · 1 line
2.10.0
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
Quoted 18 lines · Jarod Wilson
hyperv_net:
- set min/max_mtu
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>Signed-off-by Jarod Wilson <[email protected]>
Quoted 1 line
---
The virtnet change looks good to me. It simplifies an enhancement that I was about to propose, so I'll let yours land first.
-Aaron
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 18 lines · Jarod Wilson
hyperv_net:
- set min/max_mtu
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>Signed-off-by Jarod Wilson <[email protected]>
Quoted 1 line
---
The virtnet change looks good to me. It simplifies an enhancement that I was about to propose, so I'll let yours land first.
-Aaron
Michael S. Tsirkin
maintainerRe: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 31 lines · Jarod Wilson
drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 6 lines
drivers/net/virtio_net.c +3
-0@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; } +#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU 65535 +
Do we need a common macro for this?
Quoted 15 lines
drivers/net/virtio_net.c +4
-0static int virtnet_probe (struct virtio_device *vdev) {int i, err;@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,
drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 1875
Quoted 7 lines
drivers/net/virtio_net.c +2
-1@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu >= dev->min_mtu && mtu <= dev->max_mtu) { + dev->mtu = mtu;__virtio_clear_bit (vdev,VIRTIO_NET_F_MTU );
I think the logic is wrong here:
If mtu is legal, we set it but do not tell host.
If it's out of range we tell host we use it
but don't actually.
Should be the reverse.
Quoted 4 lines
drivers/net/virtio_net.c +1
-0+ } }if (vi->any_header_sg)
Signature · 1 line
MST
Michael S. Tsirkin
maintainerRe: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
Quoted 35 lines · Michael S. Tsirkin
Quoted 34 lines · Jarod Wilson
drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; }
Quoted 5 lines
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 3 lines
drivers/net/virtio_net.c +3
-0+#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU 65535 +Do we need a common macro for this?
I think it's actually IP_MAX_MTU.
Quoted 38 lines
Quoted 15 lines
drivers/net/virtio_net.c +4
-0static int virtnet_probe (struct virtio_device *vdev) {int i, err;@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 1875
Quoted 7 lines
drivers/net/virtio_net.c +2
-1@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu >= dev->min_mtu && mtu <= dev->max_mtu) { + dev->mtu = mtu;__virtio_clear_bit (vdev,VIRTIO_NET_F_MTU );I think the logic is wrong here:
If mtu is legal, we set it but do not tell host.
If it's out of range we tell host we use it
but don't actually.Should be the reverse.
Quoted 4 lines
drivers/net/virtio_net.c +1
-0+ } }if (vi->any_header_sg)Signature · 1 line
MST
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
Quoted 36 lines · Michael S. Tsirkin
Quoted 35 lines · Michael S. Tsirkin
Quoted 34 lines · Jarod Wilson
drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; }
Quoted 7 lines
Quoted 5 lines
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 3 lines
drivers/net/virtio_net.c +3
-0+#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU 65535 +Do we need a common macro for this?
I think it's actually
IP_MAX_MTU.
Ah, yes, it is. I'm not sure why I didn't use that...
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
In reply to Michael S. TsirkinQuoted 36 lines · Michael S. Tsirkin
Quoted 35 lines · Michael S. Tsirkin
Quoted 34 lines · Jarod Wilson
drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; }
Quoted 7 lines
Quoted 5 lines
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 3 lines
drivers/net/virtio_net.c +3
-0+#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU 65535 +Do we need a common macro for this?
I think it's actually
IP_MAX_MTU.
Ah, yes, it is. I'm not sure why I didn't use that...
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
In reply to Michael S. TsirkinQuoted 35 lines · Michael S. Tsirkin
Quoted 34 lines · Jarod Wilson
drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; }
Quoted 5 lines
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 3 lines
drivers/net/virtio_net.c +3
-0+#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU 65535 +Do we need a common macro for this?
Probably. That value crops up in multiple drivers.
Quoted 25 lines
Quoted 15 lines
drivers/net/virtio_net.c +4
-0static int virtnet_probe (struct virtio_device *vdev) {int i, err;@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 1875
Quoted 7 lines
drivers/net/virtio_net.c +2
-1@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu >= dev->min_mtu && mtu <= dev->max_mtu) { + dev->mtu = mtu;__virtio_clear_bit (vdev,VIRTIO_NET_F_MTU );I think the logic is wrong here:
Quoted 5 lines
If mtu is legal, we set it but do not tell host.
If it's out of range we tell host we use it
but don't actually.Should be the reverse.
Ah, yes, looks like it should be:
if (mtu < dev->min_mtu || mtu > dev->max_mtu)
__virtio_clear_bit(vdev, VIRTIO_NET_F_MTU);
else
dev->mtu = mtu;Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
In reply to Michael S. TsirkinQuoted 35 lines · Michael S. Tsirkin
Quoted 34 lines · Jarod Wilson
drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; }
Quoted 5 lines
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 3 lines
drivers/net/virtio_net.c +3
-0+#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU 65535 +Do we need a common macro for this?
Probably. That value crops up in multiple drivers.
Quoted 25 lines
Quoted 15 lines
drivers/net/virtio_net.c +4
-0static int virtnet_probe (struct virtio_device *vdev) {int i, err;@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 1875
Quoted 7 lines
drivers/net/virtio_net.c +2
-1@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu >= dev->min_mtu && mtu <= dev->max_mtu) { + dev->mtu = mtu;__virtio_clear_bit (vdev,VIRTIO_NET_F_MTU );I think the logic is wrong here:
Quoted 5 lines
If mtu is legal, we set it but do not tell host.
If it's out of range we tell host we use it
but don't actually.Should be the reverse.
Ah, yes, looks like it should be:
if (mtu < dev->min_mtu || mtu > dev->max_mtu)
__virtio_clear_bit(vdev, VIRTIO_NET_F_MTU);
else
dev->mtu = mtu;Signature · 2 lines
Jarod Wilson [email protected]
Haiyang Zhang
maintainerRE: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 45 lines
-----Original Message-----
From: Jarod Wilson [mailto:[email protected]]
Sent: Tuesday, October 18, 2016 10:34 PM
To: [email protected]
Cc: Jarod Wilson <[email protected]>; [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Michael S. Tsirkin <[email protected]>; Shrikrishna Khare <[email protected]>; VMware, Inc. <[email protected]>
Subject: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
hyperv_net:
- set min/max_mtu
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>Signed-off-by Jarod Wilson <[email protected]>--- drivers/net/hyperv/hyperv_net.h | 4 ++-- drivers/net/hyperv/netvsc_drv.c | 14 +++++++------- drivers/net/virtio_net.c | 23 ++++++++++------------- drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++++--- 4 files changed, 23 insertions(+), 25 deletions(-)drivers/net/hyperv/hyperv_net.h +0
-0
drivers/net/hyperv/hyperv_net.h struct nvsp_message { · line 609
Quoted 6 lines
drivers/net/hyperv/hyperv_net.h +1
-2@@ -606,8 +606,8 @@ struct nvsp_message { } __packed; -#define NETVSC_MTU 65536 -#define NETVSC_MTU_MIN 68 +#define NETVSC_MTU 65535
Why change it to 65535? For Hyperv host, this should be 65536.
Quoted 4 lines
drivers/net/hyperv/hyperv_net.h +0
-0@@ -1343,6 +1336,13 @@ static int netvsc_probe(struct hv_device *dev,netif_carrier_off (net);
drivers/net/hyperv/hyperv_net.h static int netvsc_probe(struct hv_device *dev, · line 1348
Quoted 10 lines
drivers/net/hyperv/hyperv_net.h +7
-0+/* MTU range: 68 - 1500 or 65521 */ + net->min_mtu =NETVSC_MTU_MIN ; +if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) + net->max_mtu =NETVSC_MTU -ETH_HLEN ; +else + net->max_mtu =ETH_DATA_LEN ; +netvsc_init_settings (net); net_device_ctx =netdev_priv (net);
nvdev->nvsp_version is not set until after rndis_filter_device_add() is successfully completed.
You need to move this part to the place just before this line:
ret = register_netdev(net);
Thanks,
- Haiyang
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
Quoted 48 lines · Haiyang Zhang
Quoted 48 lines
-----Original Message-----
From: Jarod Wilson [mailto:[email protected]]
Sent: Tuesday, October 18, 2016 10:34 PM
To: [email protected]
Cc: Jarod Wilson <[email protected]>; [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Michael S. Tsirkin <[email protected]>; Shrikrishna Khare <[email protected]>; VMware, Inc. <[email protected]>
Subject: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
hyperv_net:
- set min/max_mtu
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>Signed-off-by Jarod Wilson <[email protected]>--- drivers/net/hyperv/hyperv_net.h | 4 ++-- drivers/net/hyperv/netvsc_drv.c | 14 +++++++------- drivers/net/virtio_net.c | 23 ++++++++++------------- drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++++--- 4 files changed, 23 insertions(+), 25 deletions(-)drivers/net/hyperv/hyperv_net.h +0
-0@@ -606,8 +606,8 @@ struct nvsp_message { } __packed;
Quoted 5 lines
drivers/net/hyperv/hyperv_net.h struct nvsp_message { · line 609
Quoted 3 lines
drivers/net/hyperv/hyperv_net.h +1
-2-#define NETVSC_MTU 65536 -#define NETVSC_MTU_MIN 68 +#define NETVSC_MTU 65535Why change it to 65535? For Hyperv host, this should be 65536.
Forgot to call this change out, sorry. That was changed, because of IP_MAX_MTU being 0xFFFFU -> 65535.
Quoted 13 lines
Quoted 13 lines
drivers/net/hyperv/hyperv_net.h +7
-0@@ -1343,6 +1336,13 @@ static int netvsc_probe(struct hv_device *dev,netif_carrier_off (net); +/* MTU range: 68 - 1500 or 65521 */ + net->min_mtu =NETVSC_MTU_MIN ; +if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) + net->max_mtu =NETVSC_MTU -ETH_HLEN ; +else + net->max_mtu =ETH_DATA_LEN ; +netvsc_init_settings (net);
Quoted 6 lines
drivers/net/hyperv/hyperv_net.h static int netvsc_probe(struct hv_device *dev, · line 1348
Quoted 1 line
drivers/net/hyperv/hyperv_net.h +0
-0net_device_ctx =netdev_priv (net);
nvdev->nvsp_versionis not set until afterrndis_filter_device_add()is successfully completed.
You need to move this part to the place just before this line:
ret =register_netdev(net);
Okay, will fix that up.
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
In reply to Haiyang ZhangQuoted 48 lines · Haiyang Zhang
Quoted 48 lines
-----Original Message-----
From: Jarod Wilson [mailto:[email protected]]
Sent: Tuesday, October 18, 2016 10:34 PM
To: [email protected]
Cc: Jarod Wilson <[email protected]>; [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Michael S. Tsirkin <[email protected]>; Shrikrishna Khare <[email protected]>; VMware, Inc. <[email protected]>
Subject: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
hyperv_net:
- set min/max_mtu
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>Signed-off-by Jarod Wilson <[email protected]>--- drivers/net/hyperv/hyperv_net.h | 4 ++-- drivers/net/hyperv/netvsc_drv.c | 14 +++++++------- drivers/net/virtio_net.c | 23 ++++++++++------------- drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++++--- 4 files changed, 23 insertions(+), 25 deletions(-)drivers/net/hyperv/hyperv_net.h +0
-0@@ -606,8 +606,8 @@ struct nvsp_message { } __packed;
Quoted 5 lines
drivers/net/hyperv/hyperv_net.h struct nvsp_message { · line 609
Quoted 3 lines
drivers/net/hyperv/hyperv_net.h +1
-2-#define NETVSC_MTU 65536 -#define NETVSC_MTU_MIN 68 +#define NETVSC_MTU 65535Why change it to 65535? For Hyperv host, this should be 65536.
Forgot to call this change out, sorry. That was changed, because of IP_MAX_MTU being 0xFFFFU -> 65535.
Quoted 13 lines
Quoted 13 lines
drivers/net/hyperv/hyperv_net.h +7
-0@@ -1343,6 +1336,13 @@ static int netvsc_probe(struct hv_device *dev,netif_carrier_off (net); +/* MTU range: 68 - 1500 or 65521 */ + net->min_mtu =NETVSC_MTU_MIN ; +if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) + net->max_mtu =NETVSC_MTU -ETH_HLEN ; +else + net->max_mtu =ETH_DATA_LEN ; +netvsc_init_settings (net);
Quoted 6 lines
drivers/net/hyperv/hyperv_net.h static int netvsc_probe(struct hv_device *dev, · line 1348
Quoted 1 line
drivers/net/hyperv/hyperv_net.h +0
-0net_device_ctx =netdev_priv (net);
nvdev->nvsp_versionis not set until afterrndis_filter_device_add()is successfully completed.
You need to move this part to the place just before this line:
ret =register_netdev(net);
Okay, will fix that up.
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 18 lines · Jarod Wilson
hyperv_net:
- set min/max_mtu
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>Signed-off-by Jarod Wilson <[email protected]>
Quoted 1 line
---
The vmxnet3 part of the change looks good to me.
Thanks,
Shri
Re: [PATCH net-next 5/6] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 18 lines · Jarod Wilson
hyperv_net:
- set min/max_mtu
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>Signed-off-by Jarod Wilson <[email protected]>
Quoted 1 line
---
The vmxnet3 part of the change looks good to me.
Thanks,
Shri
PATCH 5/6 net: use core MTU range checking in virt drivers
In reply to Jarod Wilsonhyperv_net:
- set min/max_mtu
virtio_net:
- set min/max_mtu
- remove virtnet_change_mtu
vmxnet3:
- set min/max_mtu
--- drivers/net/hyperv/hyperv_net.h | 4 ++-- drivers/net/hyperv/netvsc_drv.c | 14 +++++++------- drivers/net/virtio_net.c | 23 ++++++++++------------- drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++++--- 4 files changed, 23 insertions(+), 25 deletions(-)
drivers/net/hyperv/hyperv_net.h +2 -2
@@ -606,8 +606,8 @@ struct nvsp_message { } __packed; -#define NETVSC_MTU 65536 -#define NETVSC_MTU_MIN 68 +#define NETVSC_MTU 65535 +#define NETVSC_MTU_MIN ETH_MIN_MTU#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16)/* 16MB */ #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15)/* 15MB */
drivers/net/hyperv/netvsc_drv.c +7 -7
@@ -872,19 +872,12 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)struct netvsc_device *nvdev = ndevctx->nvdev;struct hv_device *hdev = ndevctx->device_ctx;struct netvsc_device_info device_info; -int limit =ETH_DATA_LEN ;u32 num_chn;int ret =0 ;if (ndevctx->start_remove || !nvdev || nvdev->destroy)return -ENODEV ; -if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) - limit =NETVSC_MTU -ETH_HLEN ; - -if (mtu <NETVSC_MTU_MIN || mtu > limit) -return -EINVAL ; - ret =netvsc_close (ndev);if (ret) goto out;
@@ -1343,6 +1336,13 @@ static int netvsc_probe(struct hv_device *dev,netif_carrier_off (net); +/* MTU range: 68 - 1500 or 65521 */ + net->min_mtu =NETVSC_MTU_MIN ; +if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) + net->max_mtu =NETVSC_MTU -ETH_HLEN ; +else + net->max_mtu =ETH_DATA_LEN ; +netvsc_init_settings (net); net_device_ctx =netdev_priv (net);
drivers/net/virtio_net.c +10 -13
@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,
@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; } +#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU 65535 +static int virtnet_probe (struct virtio_device *vdev) {int i, err;
@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,
@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu >= dev->min_mtu && mtu <= dev->max_mtu) { + dev->mtu = mtu;__virtio_clear_bit (vdev,VIRTIO_NET_F_MTU ); + } }if (vi->any_header_sg)
drivers/net/vmxnet3/vmxnet3_drv.c +4 -3
@@ -2969,9 +2969,6 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)struct vmxnet3_adapter *adapter =netdev_priv (netdev);int err =0 ; -if (new_mtu <VMXNET3_MIN_MTU || new_mtu >VMXNET3_MAX_MTU ) -return -EINVAL ; - netdev->mtu = new_mtu;/*
@@ -3428,6 +3425,10 @@ vmxnet3_probe_device(struct pci_dev *pdev,vmxnet3_set_ethtool_ops (netdev); netdev->watchdog_timeo =5 *HZ ; +/* MTU range: 60 - 9000 */ + netdev->min_mtu =VMXNET3_MIN_MTU ; + netdev->max_mtu =VMXNET3_MAX_MTU ; +INIT_WORK (&adapter->work, vmxnet3_reset_work);set_bit (VMXNET3_STATE_BIT_QUIESCED , &adapter->state);
Signature · 1 line
2.10.0
PATCH 6/6 net: use core MTU range checking in misc drivers
In reply to Jarod Wilsonfirewire-net:
- set min/max_mtu
- remove fwnet_change_mtu
nes:
- set max_mtu
- clean up nes_netdev_change_mtu
xpnet:
- set min/max_mtu
- remove xpnet_dev_change_mtu
hippi:
- set min/max_mtu
- remove hippi_change_mtu
batman-adv:
- set max_mtu
- remove batadv_interface_change_mtu
- initialization is a little async, not 100% certain that max_mtu is set in the optimal place, don't have hardware to test with
rionet:
- set min/max_mtu
- remove rionet_change_mtu
slip:
- set min/max_mtu
- streamline sl_change_mtu
--- drivers/firewire/net.c | 12 ++---------- drivers/infiniband/hw/nes/nes.c | 1 - drivers/infiniband/hw/nes/nes.h | 4 ++-- drivers/infiniband/hw/nes/nes_nic.c | 10 +++------- drivers/misc/sgi-xp/xpnet.c | 21 ++++----------------- drivers/net/hippi/rrunner.c | 1 - drivers/net/rionet.c | 15 +++------------ drivers/net/slip/slip.c | 11 +++++------ include/linux/hippidevice.h | 1 - net/802/hippi.c | 14 ++------------ net/batman-adv/soft-interface.c | 13 +------------ 11 files changed, 22 insertions(+), 81 deletions(-)
drivers/firewire/net.c +2 -10
@@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)return NETDEV_TX_OK ; } -static int fwnet_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - net->mtu = new_mtu; -return 0 ; -} -static const struct ethtool_ops fwnet_ethtool_ops = { .get_link = ethtool_op_get_link, };
@@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = { .ndo_open = fwnet_open, .ndo_stop = fwnet_stop, .ndo_start_xmit = fwnet_tx, - .ndo_change_mtu = fwnet_change_mtu, };static void fwnet_init_dev (struct net_device *net)
@@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, max_mtu = (1 << (card->max_receive +1 )) -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; net->mtu =min (1500U , max_mtu); + net->min_mtu =ETH_MIN_MTU ; + net->max_mtu = net->mtu;/* Set our hardware address while we're at it */ ha = (union fwnet_hwaddr *)net->dev_addr;
drivers/infiniband/hw/nes/nes.c +0 -1
@@ -65,7 +65,6 @@ MODULE_DESCRIPTION("NetEffect RNIC Low-level iWARP Driver");MODULE_LICENSE ("Dual BSD/GPL" );MODULE_VERSION (DRV_VERSION ); -int max_mtu =9000 ;int interrupt_mod_interval =0 ;/* Interoperability */
drivers/infiniband/hw/nes/nes.h +2 -2
@@ -83,6 +83,8 @@#define NES_FIRST_QPN 64#define NES_SW_CONTEXT_ALIGN 1024 +#define NES_MAX_MTU 9000 +#define NES_NIC_MAX_NICS 16#define NES_MAX_ARP_TABLE_SIZE 4096
@@ -169,8 +171,6 @@ do { \#include "nes_cm.h" #include "nes_mgt.h" -extern int max_mtu; -#define max_frame_len (max_mtu+ETH_HLEN)extern int interrupt_mod_interval;extern int nes_if_count;extern int mpa_version;
drivers/infiniband/hw/nes/nes_nic.c +3 -7
@@ -981,20 +981,16 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu) {struct nes_vnic *nesvnic =netdev_priv (netdev);struct nes_device *nesdev = nesvnic->nesdev; -int ret =0 ;u8 jumbomode =0 ;u32 nic_active;u32 nic_active_bit;u32 uc_all_active;u32 mc_all_active; -if ((new_mtu <ETH_ZLEN ) || (new_mtu > max_mtu)) -return -EINVAL ; - netdev->mtu = new_mtu; nesvnic->max_frame_size = new_mtu +VLAN_ETH_HLEN ; -if (netdev->mtu >1500 ) { +if (netdev->mtu >ETH_DATA_LEN ) { jumbomode=1 ; }nes_nic_init_timer_defaults (nesdev, jumbomode);
@@ -1020,7 +1016,7 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu)nes_write_indexed (nesdev,NES_IDX_NIC_UNICAST_ALL , nic_active); } -return ret; +return 0 ; }
@@ -1658,7 +1654,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev, netdev->watchdog_timeo =NES_TX_TIMEOUT ; netdev->irq = nesdev->pcidev->irq; - netdev->mtu =ETH_DATA_LEN ; + netdev->max_mtu =NES_MAX_MTU ; netdev->hard_header_len =ETH_HLEN ; netdev->addr_len =ETH_ALEN ; netdev->type =ARPHRD_ETHER ;
drivers/misc/sgi-xp/xpnet.c +4 -17
@@ -118,6 +118,8 @@ static DEFINE_SPINLOCK(xpnet_broadcast_lock);* now, the default is 64KB. */ #define XPNET_MAX_MTU (0x800000UL - L1_CACHE_BYTES) +/* 68 comes from min TCP+IP+MAC header */ +#define XPNET_MIN_MTU 68/* 32KB has been determined to be the ideal */ #define XPNET_DEF_MTU (0x8000UL)
@@ -330,22 +332,6 @@ xpnet_dev_stop(struct net_device *dev)return 0 ; } -static int -xpnet_dev_change_mtu (struct net_device *dev,int new_mtu) -{ -/* 68 comes from min TCP+IP+MAC header */ -if ((new_mtu <68 ) || (new_mtu >XPNET_MAX_MTU )) { -dev_err (xpnet,"ifconfig %s mtu %d failed; value must be " -"between 68 and %ld\n" , dev->name, new_mtu, -XPNET_MAX_MTU ); -return -EINVAL ; - } - - dev->mtu = new_mtu; -dev_dbg (xpnet,"ifconfig %s mtu set to %d\n" , dev->name, new_mtu); -return 0 ; -} -/* * Notification that the other end has received the message and * DMA'd the skb information. At this point, they are done with
@@ -519,7 +505,6 @@ static const struct net_device_ops xpnet_netdev_ops = { .ndo_open = xpnet_dev_open, .ndo_stop = xpnet_dev_stop, .ndo_start_xmit = xpnet_dev_hard_start_xmit, - .ndo_change_mtu = xpnet_dev_change_mtu, .ndo_tx_timeout = xpnet_dev_tx_timeout, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr,
@@ -555,6 +540,8 @@ xpnet_init(void) xpnet_device->netdev_ops = &xpnet_netdev_ops; xpnet_device->mtu =XPNET_DEF_MTU ; + xpnet_device->min_mtu =XPNET_MIN_MTU ; + xpnet_device->max_mtu =XPNET_MAX_MTU ;/* * Multicast assumes the LSB of the first octet is set for multicast
drivers/net/hippi/rrunner.c +0 -1
@@ -68,7 +68,6 @@ static const struct net_device_ops rr_netdev_ops = { .ndo_stop = rr_close, .ndo_do_ioctl = rr_ioctl, .ndo_start_xmit = rr_start_xmit, - .ndo_change_mtu = hippi_change_mtu, .ndo_set_mac_address = hippi_mac_addr, };
drivers/net/rionet.c +3 -12
@@ -466,17 +466,6 @@ static void rionet_set_msglevel(struct net_device *ndev, u32 value) rnet->msg_enable = value; } -static int rionet_change_mtu (struct net_device *ndev,int new_mtu) -{ -if ((new_mtu <68 ) || (new_mtu >RIONET_MAX_MTU )) { -printk (KERN_ERR "%s: Invalid MTU size %d\n" , - ndev->name, new_mtu); -return -EINVAL ; - } - ndev->mtu = new_mtu; -return 0 ; -} -static const struct ethtool_ops rionet_ethtool_ops = { .get_drvinfo = rionet_get_drvinfo, .get_msglevel = rionet_get_msglevel,
@@ -488,7 +477,6 @@ static const struct net_device_ops rionet_netdev_ops = { .ndo_open = rionet_open, .ndo_stop = rionet_close, .ndo_start_xmit = rionet_start_xmit, - .ndo_change_mtu = rionet_change_mtu, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr, };
@@ -525,6 +513,9 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev) ndev->netdev_ops = &rionet_netdev_ops; ndev->mtu =RIONET_MAX_MTU ; +/* MTU range: 68 - 4082 */ + ndev->min_mtu =ETH_MIN_MTU ; + ndev->max_mtu =RIONET_MAX_MTU ; ndev->features =NETIF_F_LLTX ;SET_NETDEV_DEV (ndev, &mport->dev); ndev->ethtool_ops = &rionet_ethtool_ops;
drivers/net/slip/slip.c +5 -6
@@ -561,12 +561,7 @@ static int sl_change_mtu(struct net_device *dev, int new_mtu) {struct slip *sl =netdev_priv (dev); -if (new_mtu <68 || new_mtu >65534 ) -return -EINVAL ; - -if (new_mtu != dev->mtu) -return sl_realloc_bufs (sl, new_mtu); -return 0 ; +return sl_realloc_bufs (sl, new_mtu); }/* Netdevice get statistics request */
@@ -663,6 +658,10 @@ static void sl_setup(struct net_device *dev) dev->addr_len =0 ; dev->tx_queue_len =10 ; +/* MTU range: 68 - 65534 */ + dev->min_mtu =68 ; + dev->max_mtu =65534 ; +/* New-style flags. */ dev->flags =IFF_NOARP |IFF_POINTOPOINT |IFF_MULTICAST ; }
include/linux/hippidevice.h +0 -1
@@ -32,7 +32,6 @@ struct hippi_cb { };__be16 hippi_type_trans (struct sk_buff *skb,struct net_device *dev); -int hippi_change_mtu (struct net_device *dev,int new_mtu);int hippi_mac_addr (struct net_device *dev,void *p);int hippi_neigh_setup_dev (struct net_device *dev,struct neigh_parms *p);struct net_device *alloc_hippi_dev (int sizeof_priv);
net/802/hippi.c +2 -12
@@ -116,18 +116,6 @@ __be16 hippi_type_trans(struct sk_buff *skb, struct net_device *dev)EXPORT_SYMBOL (hippi_type_trans); -int hippi_change_mtu (struct net_device *dev,int new_mtu) -{ -/* -* HIPPI's got these nice large MTUs. -*/ -if ((new_mtu <68 ) || (new_mtu >65280 )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -EXPORT_SYMBOL (hippi_change_mtu); -/* * For HIPPI we will actually use the lower 4 bytes of the hardware * address as the I-FIELD rather than the actual hardware address.
@@ -174,6 +162,8 @@ static void hippi_setup(struct net_device *dev) dev->type =ARPHRD_HIPPI ; dev->hard_header_len =HIPPI_HLEN ; dev->mtu =65280 ; + dev->min_mtu =68 ; + dev->max_mtu =65280 ; dev->addr_len =HIPPI_ALEN ; dev->tx_queue_len =25 /* 5 */ ;memset (dev->broadcast,0xFF ,HIPPI_ALEN );
net/batman-adv/soft-interface.c +1 -12
@@ -158,17 +158,6 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)return 0 ; } -static int batadv_interface_change_mtu (struct net_device *dev,int new_mtu) -{ -/* check ranges */ -if ((new_mtu <68 ) || (new_mtu >batadv_hardif_min_mtu (dev))) -return -EINVAL ; - - dev->mtu = new_mtu; - -return 0 ; -} -/** * batadv_interface_set_rx_mode - set the rx mode of a device * @dev: registered network device to modify
@@ -920,7 +909,6 @@ static const struct net_device_ops batadv_netdev_ops = { .ndo_vlan_rx_add_vid = batadv_interface_add_vid, .ndo_vlan_rx_kill_vid = batadv_interface_kill_vid, .ndo_set_mac_address = batadv_interface_set_mac_addr, - .ndo_change_mtu = batadv_interface_change_mtu, .ndo_set_rx_mode = batadv_interface_set_rx_mode, .ndo_start_xmit = batadv_interface_tx, .ndo_validate_addr = eth_validate_addr,
@@ -987,6 +975,7 @@ struct net_device *batadv_softif_create(struct net *net, const char *name)dev_net_set (soft_iface, net); soft_iface->rtnl_link_ops = &batadv_link_ops; + soft_iface->max_mtu =batadv_hardif_min_mtu (soft_iface); ret =register_netdevice (soft_iface);if (ret <0 ) {
Signature · 1 line
2.10.0
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
Quoted 5 lines · Jarod Wilson
CC Stefan Richter <[email protected]>CC Faisal Latif <[email protected]>CC Cliff Whickman <[email protected]>
Quoted 5 lines
CC Jes Sorensen <[email protected]>CC Marek Lindner <[email protected]>CC Simon Wunderlich <[email protected]>CC Antonio Quartulli <[email protected]>Signed-off-by Jarod Wilson <[email protected]>
Sabrina Dubroca
maintainerRe: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
In reply to Jarod Wilson2016-10-18, 22:33:33 -0400, Jarod Wilson wrote:
[...]
Quoted 7 lines
drivers/firewire/net.c +0
-0@@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)return NETDEV_TX_OK ; }
drivers/firewire/net.c static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net) · line 1360
Quoted 10 lines
drivers/firewire/net.c +0
-9-static int fwnet_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - net->mtu = new_mtu; -return 0 ; -} -
This doesn't do any upper bound checking.
Quoted 12 lines
drivers/firewire/net.c +0
-1static const struct ethtool_ops fwnet_ethtool_ops = { .get_link = ethtool_op_get_link, };@@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = { .ndo_open = fwnet_open, .ndo_stop = fwnet_stop, .ndo_start_xmit = fwnet_tx, - .ndo_change_mtu = fwnet_change_mtu, };static void fwnet_init_dev (struct net_device *net)
drivers/firewire/net.c static int fwnet_probe(struct fw_unit *unit, · line 1475
Quoted 5 lines
drivers/firewire/net.c +2
-0@@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, max_mtu = (1 << (card->max_receive +1 )) -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; net->mtu =min (1500U , max_mtu); + net->min_mtu =ETH_MIN_MTU ; + net->max_mtu = net->mtu;
But that will now prevent increasing the MTU above the initial value?
Signature · 1 line
Sabrina
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
Quoted 10 lines · On Oct 19 Sabrina Dubroca wrote:
2016-10-18, 22:33:33 -0400, Jarod Wilson wrote:
[...]Quoted 8 lines
drivers/firewire/net.c +0
-0@@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)return NETDEV_TX_OK ; }
Quoted 11 lines
drivers/firewire/net.c static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net) · line 1360
Quoted 9 lines
drivers/firewire/net.c +0
-9-static int fwnet_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - net->mtu = new_mtu; -return 0 ; -} -This doesn't do any upper bound checking.
I need to check more closely, but I think the RFC 2734 encapsulation spec and our implementation do not impose a particular upper limit. Though I guess it's bad to let userland set arbitrarily large values here.
Quoted 10 lines
Quoted 10 lines
drivers/firewire/net.c +0
-1static const struct ethtool_ops fwnet_ethtool_ops = { .get_link = ethtool_op_get_link, };@@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = { .ndo_open = fwnet_open, .ndo_stop = fwnet_stop, .ndo_start_xmit = fwnet_tx, - .ndo_change_mtu = fwnet_change_mtu, };
Quoted 9 lines
drivers/firewire/net.c static int fwnet_probe(struct fw_unit *unit, · line 1475
Quoted 7 lines
drivers/firewire/net.c +2
-0static void fwnet_init_dev (struct net_device *net)@@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, max_mtu = (1 << (card->max_receive +1 )) -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; net->mtu =min (1500U , max_mtu); + net->min_mtu =ETH_MIN_MTU ; + net->max_mtu = net->mtu;But that will now prevent increasing the MTU above the initial value?
Indeed, therefore NAK.
PS:
If the IP packet plus encapsulation header fits into IEEE 1394 packet payload, it is transported without link fragmentation. If it does not fit, link fragmentation occurs (which reduces bandwidth a bit and consumes additional buffering resources at the transmitter and the receiver).
Broadcast and multicast packets are transmitted via IEEE 1394 asynchronous stream packets at a low bus speed (because our code does not attempt to find the maximum speed and size that is supported by all potential listeners). This limits the payload to 512 bytes.
Unicast packets are transmitted via IEEE 1394 asynchronous write request packets at optimum speed. In most cases, this means that 2048 bytes payload is possible, in some cases 4096 bytes. Many CardBus FireWire cards support only 1024 bytes payload of these packets though. Furthermore, some low-speed long-haul cablings may cap the bus speed and thereby the payload size to 1024 or 512 bytes, but this is uncommon in practice.
Signature · 3 lines
Stefan Richter -======----- =-=- =-=-- http://arcgraph.de/sr/
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
Quoted 23 lines · Stefan Richter
Quoted 10 lines · On Oct 19 Sabrina Dubroca wrote:
2016-10-18, 22:33:33 -0400, Jarod Wilson wrote:
[...]Quoted 8 lines
drivers/firewire/net.c +0
-0@@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)return NETDEV_TX_OK ; }Quoted 11 lines
drivers/firewire/net.c static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net) · line 1360
Quoted 9 lines
drivers/firewire/net.c +0
-9-static int fwnet_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - net->mtu = new_mtu; -return 0 ; -} -This doesn't do any upper bound checking.
Quoted 3 lines
I need to check more closely, but I think the RFC 2734 encapsulation spec and our implementation do not impose a particular upper limit. Though I guess it's bad to let userland set arbitrarily large values here.
In which case, that would suggest using IP_MAX_MTU (65535) here.
Quoted 20 lines
Quoted 10 lines
Quoted 10 lines
drivers/firewire/net.c +0
-1static const struct ethtool_ops fwnet_ethtool_ops = { .get_link = ethtool_op_get_link, };@@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = { .ndo_open = fwnet_open, .ndo_stop = fwnet_stop, .ndo_start_xmit = fwnet_tx, - .ndo_change_mtu = fwnet_change_mtu, };Quoted 9 lines
drivers/firewire/net.c static int fwnet_probe(struct fw_unit *unit, · line 1475
Quoted 7 lines
drivers/firewire/net.c +2
-0static void fwnet_init_dev (struct net_device *net)@@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, max_mtu = (1 << (card->max_receive +1 )) -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; net->mtu =min (1500U , max_mtu); + net->min_mtu =ETH_MIN_MTU ; + net->max_mtu = net->mtu;But that will now prevent increasing the MTU above the initial value?
Quoted 1 line
Indeed, therefore NAK.
However, there's an explicit calculation for 'max_mtu' right there that I glazed right over. It would seem perhaps *that* should be used for net->max_mtu here, no?
Quoted 12 lines
PS:
If the IP packet plus encapsulation header fits into IEEE 1394 packet payload, it is transported without link fragmentation. If it does not fit, link fragmentation occurs (which reduces bandwidth a bit and consumes additional buffering resources at the transmitter and the receiver).Broadcast and multicast packets are transmitted via IEEE 1394 asynchronous stream packets at a low bus speed (because our code does not attempt to find the maximum speed and size that is supported by all potential listeners). This limits the payload to 512 bytes.
Quoted 7 lines
Unicast packets are transmitted via IEEE 1394 asynchronous write request packets at optimum speed. In most cases, this means that 2048 bytes payload is possible, in some cases 4096 bytes. Many CardBus FireWire cards support only 1024 bytes payload of these packets though. Furthermore, some low-speed long-haul cablings may cap the bus speed and thereby the payload size to 1024 or 512 bytes, but this is uncommon in practice.
Thorough as always, Stefan! :)
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
Quoted 24 lines · On Oct 19 Jarod Wilson wrote:
Quoted 23 lines · Stefan Richter
Quoted 21 lines · On Oct 19 Sabrina Dubroca wrote:
2016-10-18, 22:33:33 -0400, Jarod Wilson wrote:
[...]Quoted 7 lines
drivers/firewire/net.c +0
-0@@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)return NETDEV_TX_OK ; }drivers/firewire/net.c static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net) · line 1360
Quoted 10 lines
drivers/firewire/net.c +0
-9-static int fwnet_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - net->mtu = new_mtu; -return 0 ; -} -This doesn't do any upper bound checking.
Quoted 5 lines
Quoted 3 lines
I need to check more closely, but I think the RFC 2734 encapsulation spec and our implementation do not impose a particular upper limit. Though I guess it's bad to let userland set arbitrarily large values here.
In which case, that would suggest using
IP_MAX_MTU(65535) here.
Probably. I (or somebody) need to check the spec and the code once more.
[...]
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/firewire/net.c static int fwnet_probe(struct fw_unit *unit, · line 1475
Quoted 6 lines
drivers/firewire/net.c +2
-0@@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, max_mtu = (1 << (card->max_receive +1 )) -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; net->mtu =min (1500U , max_mtu); + net->min_mtu =ETH_MIN_MTU ; + net->max_mtu = net->mtu;But that will now prevent increasing the MTU above the initial value?
Quoted 5 lines
Quoted 1 line
Indeed, therefore NAK.
However, there's an explicit calculation for '
max_mtu' right there that I glazed right over. It would seem perhaps *that* should be used fornet->max_mtuhere, no?
No. This 'max_mtu' here is not the absolute maximum. It is only an initial MTU which has the property that link fragmentation is not going to happen (if all other peers will at least as capable as this node).
Signature · 7 lines
Stefan Richter -======----- =-=- =-==- http://arcgraph.de/sr/ -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH net-next 6/6] net: use core MTU range checking in misc drivers
Quoted 4 lines · On Oct 22 Stefan Richter wrote:
Quoted 3 lines · On Oct 19 Jarod Wilson wrote:
Quoted 2 lines · Stefan Richter
Quoted 1 line · On Oct 19 Sabrina Dubroca wrote:
2016-10-18, 22:33:33 -0400, Jarod Wilson wrote:
[...]
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
drivers/firewire/net.c static int fwnet_probe(struct fw_unit *unit, · line 1475
Quoted 6 lines
drivers/firewire/net.c +2
-0@@ -1481,6 +1471,8 @@ static int fwnet_probe(struct fw_unit *unit, max_mtu = (1 << (card->max_receive +1 )) -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; net->mtu =min (1500U , max_mtu); + net->min_mtu =ETH_MIN_MTU ; + net->max_mtu = net->mtu;But that will now prevent increasing the MTU above the initial value?
Indeed, therefore NAK.
Quoted 8 lines
Quoted 3 lines
However, there's an explicit calculation for '
max_mtu' right there that I glazed right over. It would seem perhaps *that* should be used fornet->max_mtuhere, no?No. This '
max_mtu' here is not the absolute maximum. It is only an initial MTU which has the property that link fragmentation is not going to happen (if all other peers will at least as capable as this node).
Besides, card->max_receive is about what the card can receive (at the IEEE 1394 link layer), not about what the card can send.
Signature · 3 lines
Stefan Richter -======----- =-=- =-==- http://arcgraph.de/sr/
David Miller
maintainerFrom: Jarod Wilson <[email protected]>
Date: Tue, 18 Oct 2016 22:33:27 -0400
Quoted 3 lines
This stack of patches should get absolutely everything in the kernel converted from doing their own MTU range checking to the core MTU range checking.
I'm expecting a respin of this series.
Quoted 8 lines · David Miller
From: Jarod Wilson <[email protected]>
Date: Tue, 18 Oct 2016 22:33:27 -0400Quoted 3 lines
This stack of patches should get absolutely everything in the kernel converted from doing their own MTU range checking to the core MTU range checking.
I'm expecting a respin of this series.
Absolutely. Will address all review comments, and have some additional patches to add to the series to hopefully have absolutely everything functional, asap.
Signature · 2 lines
Jarod Wilson [email protected]
v2 cover net: use core MTU range checking everywhere
In reply to Jarod WilsonThis stack of patches should get absolutely everything in the kernel converted from doing their own MTU range checking to the core MTU range checking. This second spin includes alterations to hopefully fix all concerns raised with the first, as well as including some additional changes to drivers and infrastructure where I completely missed necessary updates.
These have all been built through the 0-day build infrastructure via the (rebasing) master branch at https://github.com/jarodwilson/linux-muck, which at the time of the most recent compile across 147 configs, was based on net-next at commit 7b1536ef0aa0.
Jarod Wilson (9):
ethernet: use net core MTU range checking in more drivers
net: use core MTU range checking in USB NIC drivers
net: use core MTU range checking in wireless drivers
net: use core MTU range checking in WAN drivers
net: use core MTU range checking in core net infra
net: use core MTU range checking in virt drivers
net: use core MTU range checking in misc drivers s390/net: use net core MTU range checking ipv4/6: use core net MTU range checking
arch/um/drivers/net_kern.c | 8 --- drivers/char/pcmcia/synclink_cs.c | 1 - drivers/firewire/net.c | 18 ++---- drivers/hsi/clients/ssi_protocol.c | 14 ++--- drivers/infiniband/hw/nes/nes.c | 1 - drivers/infiniband/hw/nes/nes.h | 4 +- drivers/infiniband/hw/nes/nes_nic.c | 10 +--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 1 + drivers/message/fusion/mptlan.c | 15 ++--- drivers/misc/sgi-xp/xpnet.c | 21 ++----- drivers/net/ethernet/alteon/acenic.c | 5 +- drivers/net/ethernet/amazon/ena/ena_netdev.c | 9 +-- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 5 -- drivers/net/ethernet/amd/xgbe/xgbe-main.c | 2 + drivers/net/ethernet/broadcom/sb1250-mac.c | 12 +--- drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 4 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 6 +- .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 6 +- drivers/net/ethernet/emulex/benet/be_main.c | 22 ++------ drivers/net/ethernet/ibm/ibmveth.c | 6 +- drivers/net/ethernet/ibm/ibmvnic.c | 16 ++---- drivers/net/ethernet/jme.c | 12 ++-- drivers/net/ethernet/marvell/mv643xx_eth.c | 7 ++- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 3 + drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 3 + drivers/net/ethernet/natsemi/ns83820.c | 11 +--- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 12 ---- .../net/ethernet/qlogic/netxen/netxen_nic_main.c | 7 +++ drivers/net/ethernet/qlogic/qlge/qlge_main.c | 7 +++ drivers/net/ethernet/qualcomm/emac/emac.c | 13 ++--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 7 ++- drivers/net/fddi/skfp/skfddi.c | 1 - drivers/net/fjes/fjes_main.c | 2 + drivers/net/geneve.c | 48 +++++++--------- drivers/net/hippi/rrunner.c | 1 - drivers/net/hyperv/hyperv_net.h | 4 +- drivers/net/hyperv/netvsc_drv.c | 14 ++--- drivers/net/macsec.c | 2 + drivers/net/macvlan.c | 8 ++- drivers/net/ntb_netdev.c | 3 + drivers/net/rionet.c | 15 +---- drivers/net/slip/slip.c | 11 ++-- drivers/net/tun.c | 20 ++----- drivers/net/usb/asix_devices.c | 4 +- drivers/net/usb/ax88179_178a.c | 4 +- drivers/net/usb/cdc-phonet.c | 12 +--- drivers/net/usb/cdc_ncm.c | 5 +- drivers/net/usb/lan78xx.c | 8 +-- drivers/net/usb/r8152.c | 15 ++++- drivers/net/usb/sierra_net.c | 13 +---- drivers/net/usb/smsc75xx.c | 4 +- drivers/net/usb/usbnet.c | 4 +- drivers/net/veth.c | 17 +----- drivers/net/virtio_net.c | 23 ++++---- drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++- drivers/net/vxlan.c | 64 ++++++++++++---------- drivers/net/wan/c101.c | 1 - drivers/net/wan/cosa.c | 1 - drivers/net/wan/dscc4.c | 1 - drivers/net/wan/farsync.c | 1 - drivers/net/wan/fsl_ucc_hdlc.c | 1 - drivers/net/wan/hdlc.c | 11 +--- drivers/net/wan/hdlc_fr.c | 3 +- drivers/net/wan/hostess_sv11.c | 1 - drivers/net/wan/ixp4xx_hss.c | 1 - drivers/net/wan/lmc/lmc_main.c | 1 - drivers/net/wan/n2.c | 1 - drivers/net/wan/pc300too.c | 1 - drivers/net/wan/pci200syn.c | 1 - drivers/net/wan/sealevel.c | 1 - drivers/net/wan/wanxl.c | 1 - drivers/net/wan/x25_asy.c | 5 +- drivers/net/wimax/i2400m/netdev.c | 22 +------- 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/net/wireless/intersil/hostap/hostap_main.c | 15 +---- drivers/net/wireless/intersil/orinoco/main.c | 6 +- drivers/net/xen-netback/interface.c | 5 +- drivers/net/xen-netfront.c | 2 + drivers/s390/net/ctcm_main.c | 5 +- drivers/s390/net/netiucv.c | 24 +------- drivers/s390/net/qeth_core_main.c | 4 -- drivers/s390/net/qeth_l2_main.c | 2 + drivers/s390/net/qeth_l3_main.c | 2 + drivers/staging/unisys/include/iochannel.h | 10 ++-- drivers/staging/unisys/visornic/visornic_main.c | 4 +- drivers/staging/wlan-ng/p80211netdev.c | 18 ++---- drivers/tty/n_gsm.c | 12 +--- drivers/tty/synclink.c | 1 - drivers/tty/synclink_gt.c | 1 - drivers/tty/synclinkmp.c | 1 - drivers/usb/gadget/function/f_phonet.c | 11 +--- drivers/usb/gadget/function/u_ether.c | 14 ++--- include/linux/fddidevice.h | 1 - include/linux/hdlc.h | 2 - include/linux/hippidevice.h | 1 - include/uapi/linux/if_ether.h | 1 + net/802/fddi.c | 11 +--- net/802/hippi.c | 14 +---- net/8021q/vlan_dev.c | 3 + net/atm/lec.c | 11 +--- net/batman-adv/soft-interface.c | 13 +---- net/bridge/br_device.c | 3 +- net/hsr/hsr_device.c | 1 + net/ipv4/ip_tunnel.c | 6 +- net/ipv6/ip6_tunnel.c | 4 +- net/ipv6/ip6_vti.c | 21 +------ net/ipv6/sit.c | 14 +---- net/mac80211/iface.c | 15 ++--- net/openvswitch/vport-internal_dev.c | 10 ---- net/phonet/pep-gprs.c | 12 +--- net/sched/sch_teql.c | 5 +- 117 files changed, 316 insertions(+), 665 deletions(-)
Signature · 1 line
2.10.0
PATCH v2 1/9 ethernet: use net core MTU range checking in more drivers
Somehow, I missed a healthy number of ethernet drivers in the last pass. Most of these drivers either were in need of an updated max_mtu to make jumbo frames possible to enable again. In a few cases, also setting a different min_mtu to match previous lower bounds. There are also a few drivers that had no upper bounds checking, so they're getting a brand new ETH_MAX_MTU that is identical to IP_MAX_MTU, but accessible by includes all ethernet and ethernet-like drivers all have already.
acenic:
- min_mtu = 0, max_mtu = 9000
amazon/ena:
- min_mtu = 128, max_mtu = adapter->max_mtu
amd/xgbe:
- min_mtu = 0, max_mtu = 9000
sb1250:
- min_mtu = 0, max_mtu = 1518
cxgb3:
- min_mtu = 81, max_mtu = 65535
cxgb4:
- min_mtu = 81, max_mtu = 9600
cxgb4vf:
- min_mtu = 81, max_mtu = 65535
benet:
- min_mtu = 256, max_mtu = 9000
ibmveth:
- min_mtu = 68, max_mtu = 65535
ibmvnic:
- min_mtu = adapter->min_mtu, max_mtu = adapter->max_mtu
- remove now redundant ibmvnic_change_mtu
jme:
- min_mtu = 1280, max_mtu = 9202
mv643xx_eth:
- min_mtu = 64, max_mtu = 9500
mlxsw:
- min_mtu = 0, max_mtu = 65535
- Basically bypassing the core checks, and instead relying on dynamic checks in the respective switch drivers' ndo_change_mtu functions
ns83820:
- min_mtu = 0
- remove redundant ns83820_change_mtu, only checked for mtu > 1500
netxen:
- min_mtu = 0, max_mtu = 8000 (P2), max_mtu = 9600 (P3)
qlge:
- min_mtu = 1500, max_mtu = 9000
- driver only supports setting mtu to 1500 or 9000, so the core check only rules out < 1500 and > 9000, qlge_change_mtu still needs to check that the value is 1500 or 9000
qualcomm/emac:
- min_mtu = 46, max_mtu = 9194
xilinx_axienet:
- min_mtu = 64, max_mtu = 9000
--- drivers/net/ethernet/alteon/acenic.c | 5 ++--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 9 ++------- drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 5 ----- drivers/net/ethernet/amd/xgbe/xgbe-main.c | 2 ++ drivers/net/ethernet/broadcom/sb1250-mac.c | 12 ++---------- drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 4 ++-- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 6 ++++-- .../net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c | 6 ++---- drivers/net/ethernet/emulex/benet/be_main.c | 22 ++++------------------ drivers/net/ethernet/ibm/ibmveth.c | 6 +++--- drivers/net/ethernet/ibm/ibmvnic.c | 16 ++++------------ drivers/net/ethernet/jme.c | 12 ++++-------- drivers/net/ethernet/marvell/mv643xx_eth.c | 7 ++++--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 3 +++ drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 3 +++ drivers/net/ethernet/natsemi/ns83820.c | 11 ++--------- drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c | 12 ------------ .../net/ethernet/qlogic/netxen/netxen_nic_main.c | 7 +++++++ drivers/net/ethernet/qlogic/qlge/qlge_main.c | 7 +++++++ drivers/net/ethernet/qualcomm/emac/emac.c | 13 ++++++------- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 7 ++++--- include/uapi/linux/if_ether.h | 1 + 22 files changed, 68 insertions(+), 108 deletions(-)
drivers/net/ethernet/alteon/acenic.c +2 -3
@@ -474,6 +474,8 @@ static int acenic_probe_one(struct pci_dev *pdev, dev->features |=NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_CTAG_RX ; dev->watchdog_timeo =5 *HZ ; + dev->min_mtu =0 ; + dev->max_mtu =ACE_JUMBO_MTU ; dev->netdev_ops = &ace_netdev_ops; dev->ethtool_ops = &ace_ethtool_ops;
@@ -2548,9 +2550,6 @@ static int ace_change_mtu(struct net_device *dev, int new_mtu)struct ace_private *ap =netdev_priv (dev);struct ace_regs __iomem *regs = ap->regs; -if (new_mtu >ACE_JUMBO_MTU ) -return -EINVAL ; -writel (new_mtu +ETH_HLEN +4 , ®s->IfMtu); dev->mtu = new_mtu;
drivers/net/ethernet/amazon/ena/ena_netdev.c +2 -7
@@ -103,13 +103,6 @@ static int ena_change_mtu(struct net_device *dev, int new_mtu)struct ena_adapter *adapter =netdev_priv (dev);int ret; -if ((new_mtu > adapter->max_mtu) || (new_mtu <ENA_MIN_MTU )) { -netif_err (adapter, drv, dev, -"Invalid MTU setting. new_mtu: %d\n" , new_mtu); - -return -EINVAL ; - } - ret =ena_com_set_dev_mtu (adapter->ena_dev, new_mtu);if (!ret) {netif_dbg (adapter, drv, dev,"set MTU to %d\n" , new_mtu);
@@ -2755,6 +2748,8 @@ static void ena_set_conf_feat_params(struct ena_adapter *adapter,ena_set_dev_offloads (feat, netdev); adapter->max_mtu = feat->dev_attr.max_mtu; + netdev->max_mtu = adapter->max_mtu; + netdev->min_mtu =ENA_MIN_MTU ; }static int ena_rss_init_default (struct ena_adapter *adapter)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +0 -5
@@ -257,11 +257,6 @@ static int xgbe_calc_rx_buf_size(struct net_device *netdev, unsigned int mtu) {unsigned int rx_buf_size; -if (mtu >XGMAC_JUMBO_PACKET_MTU ) { -netdev_alert (netdev,"MTU exceeds maximum supported value\n" ); -return -EINVAL ; - } - rx_buf_size = mtu +ETH_HLEN +ETH_FCS_LEN +VLAN_HLEN ; rx_buf_size =clamp_val (rx_buf_size,XGBE_RX_MIN_BUF_SIZE ,PAGE_SIZE );
drivers/net/ethernet/amd/xgbe/xgbe-main.c +2 -0
@@ -738,6 +738,8 @@ static int xgbe_probe(struct platform_device *pdev) pdata->netdev_features = netdev->features; netdev->priv_flags |=IFF_UNICAST_FLT ; + netdev->min_mtu =0 ; + netdev->max_mtu =XGMAC_JUMBO_PACKET_MTU ;/* Use default watchdog timeout */ netdev->watchdog_timeo =0 ;
drivers/net/ethernet/broadcom/sb1250-mac.c +2 -10
@@ -2147,15 +2147,6 @@ static void sbmac_setmulti(struct sbmac_softc *sc) } } -static int sb1250_change_mtu (struct net_device *_dev,int new_mtu) -{ -if (new_mtu >ENET_PACKET_SIZE ) -return -EINVAL ; - _dev->mtu = new_mtu; -pr_info ("changing the mtu to %d\n" , new_mtu); -return 0 ; -} -static const struct net_device_ops sbmac_netdev_ops = { .ndo_open = sbmac_open, .ndo_stop = sbmac_close,
@@ -2163,7 +2154,6 @@ static const struct net_device_ops sbmac_netdev_ops = { .ndo_set_rx_mode = sbmac_set_rx_mode, .ndo_tx_timeout = sbmac_tx_timeout, .ndo_do_ioctl = sbmac_mii_ioctl, - .ndo_change_mtu = sb1250_change_mtu, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr,#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -2229,6 +2219,8 @@ static int sbmac_init(struct platform_device *pldev, long long base) dev->netdev_ops = &sbmac_netdev_ops; dev->watchdog_timeo =TX_TIMEOUT ; + dev->max_mtu =0 ; + dev->max_mtu =ENET_PACKET_SIZE ;netif_napi_add (dev, &sc->napi, sbmac_poll,16 );
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +2 -2
@@ -2531,8 +2531,6 @@ static int cxgb_change_mtu(struct net_device *dev, int new_mtu)struct adapter *adapter = pi->adapter;int ret; -if (new_mtu <81 )/* accommodate SACK */ -return -EINVAL ;if ((ret =t3_mac_set_mtu (&pi->mac, new_mtu)))return ret; dev->mtu = new_mtu;
@@ -3295,6 +3293,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->netdev_ops = &cxgb_netdev_ops; netdev->ethtool_ops = &cxgb_ethtool_ops; + netdev->min_mtu =81 ; + netdev->max_mtu =ETH_MAX_MTU ; }pci_set_drvdata (pdev, adapter);
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +4 -2
@@ -2502,8 +2502,6 @@ static int cxgb_change_mtu(struct net_device *dev, int new_mtu)int ret;struct port_info *pi =netdev_priv (dev); -if (new_mtu <81 || new_mtu >MAX_MTU )/* accommodate SACK */ -return -EINVAL ; ret =t4_set_rxmode (pi->adapter, pi->adapter->pf, pi->viid, new_mtu,-1 ,-1 ,-1 ,-1 , true);if (!ret)
@@ -4803,6 +4801,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->priv_flags |=IFF_UNICAST_FLT ; +/* MTU range: 81 - 9600 */ + netdev->min_mtu =81 ; + netdev->max_mtu =MAX_MTU ; + netdev->netdev_ops = &cxgb4_netdev_ops;#ifdef CONFIG_CHELSIO_T4_DCB netdev->dcbnl_ops = &cxgb4_dcb_ops;
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +2 -4
@@ -1108,10 +1108,6 @@ static int cxgb4vf_change_mtu(struct net_device *dev, int new_mtu)int ret;struct port_info *pi =netdev_priv (dev); -/* accommodate SACK */ -if (new_mtu <81 ) -return -EINVAL ; - ret =t4vf_set_rxmode (pi->adapter, pi->viid, new_mtu,-1 ,-1 ,-1 ,-1 , true);if (!ret)
@@ -2966,6 +2962,8 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev, netdev->features |=NETIF_F_HIGHDMA ; netdev->priv_flags |=IFF_UNICAST_FLT ; + netdev->min_mtu =81 ; + netdev->max_mtu =ETH_MAX_MTU ; netdev->netdev_ops = &cxgb4vf_netdev_ops; netdev->ethtool_ops = &cxgb4vf_ethtool_ops;
drivers/net/ethernet/emulex/benet/be_main.c +4 -18
@@ -1406,23 +1406,6 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)return NETDEV_TX_OK ; } -static int be_change_mtu (struct net_device *netdev,int new_mtu) -{ -struct be_adapter *adapter =netdev_priv (netdev); -struct device *dev = &adapter->pdev->dev; - -if (new_mtu <BE_MIN_MTU || new_mtu >BE_MAX_MTU ) { -dev_info (dev,"MTU must be between %d and %d bytes\n" , -BE_MIN_MTU ,BE_MAX_MTU ); -return -EINVAL ; - } - -dev_info (dev,"MTU changed from %d to %d bytes\n" , - netdev->mtu, new_mtu); - netdev->mtu = new_mtu; -return 0 ; -} -static inline bool be_in_all_promisc (struct be_adapter *adapter) { return (adapter->if_flags & BE_IF_FLAGS_ALL_PROMISCUOUS) ==
@@ -5216,7 +5199,6 @@ static const struct net_device_ops be_netdev_ops = { .ndo_start_xmit = be_xmit, .ndo_set_rx_mode = be_set_rx_mode, .ndo_set_mac_address = be_mac_addr_set, - .ndo_change_mtu = be_change_mtu, .ndo_get_stats64 = be_get_stats64, .ndo_validate_addr = eth_validate_addr, .ndo_vlan_rx_add_vid = be_vlan_add_vid,
@@ -5266,6 +5248,10 @@ static void be_netdev_init(struct net_device *netdev) netdev->netdev_ops = &be_netdev_ops; netdev->ethtool_ops = &be_ethtool_ops; + +/* MTU range: 256 - 9000 */ + netdev->min_mtu =BE_MIN_MTU ; + netdev->max_mtu =BE_MAX_MTU ; }static void be_cleanup (struct be_adapter *adapter)
drivers/net/ethernet/ibm/ibmveth.c +3 -3
@@ -1349,9 +1349,6 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)int i, rc;int need_restart =0 ; -if (new_mtu <IBMVETH_MIN_MTU ) -return -EINVAL ; -for (i =0 ; i <IBMVETH_NUM_BUFF_POOLS ; i++)if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size)break ;
@@ -1551,6 +1548,9 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) netdev->hw_features |=NETIF_F_TSO ; } + netdev->min_mtu =IBMVETH_MIN_MTU ; + netdev->min_mtu =ETH_MAX_MTU ; +memcpy (netdev->dev_addr, mac_addr_p,ETH_ALEN );if (firmware_has_feature (FW_FEATURE_CMO ))
drivers/net/ethernet/ibm/ibmvnic.c +4 -12
@@ -902,17 +902,6 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)return 0 ; } -static int ibmvnic_change_mtu (struct net_device *netdev,int new_mtu) -{ -struct ibmvnic_adapter *adapter =netdev_priv (netdev); - -if (new_mtu > adapter->req_mtu || new_mtu < adapter->min_mtu) -return -EINVAL ; - - netdev->mtu = new_mtu; -return 0 ; -} -static void ibmvnic_tx_timeout (struct net_device *dev) {struct ibmvnic_adapter *adapter =netdev_priv (dev);
@@ -1029,7 +1018,6 @@ static const struct net_device_ops ibmvnic_netdev_ops = { .ndo_set_rx_mode = ibmvnic_set_multi, .ndo_set_mac_address = ibmvnic_set_mac, .ndo_validate_addr = eth_validate_addr, - .ndo_change_mtu = ibmvnic_change_mtu, .ndo_tx_timeout = ibmvnic_tx_timeout, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = ibmvnic_netpoll_controller,
@@ -2638,10 +2626,12 @@ static void handle_query_cap_rsp(union ibmvnic_crq *crq,break ;case MIN_MTU : adapter->min_mtu =be64_to_cpu (crq->query_capability.number); + netdev->min_mtu = adapter->min_mtu;netdev_dbg (netdev,"min_mtu = %lld\n" , adapter->min_mtu);break ;case MAX_MTU : adapter->max_mtu =be64_to_cpu (crq->query_capability.number); + netdev->max_mtu = adapter->max_mtu;netdev_dbg (netdev,"max_mtu = %lld\n" , adapter->max_mtu);break ;case MAX_MULTICAST_FILTERS :
@@ -3654,6 +3644,8 @@ static void handle_crq_init_rsp(struct work_struct *work) goto task_failed; netdev->real_num_tx_queues = adapter->req_tx_queues; + netdev->min_mtu = adapter->min_mtu; + netdev->max_mtu = adapter->max_mtu;if (adapter->failover) { adapter->failover = false;
drivers/net/ethernet/jme.c +4 -8
@@ -2357,14 +2357,6 @@ jme_change_mtu(struct net_device *netdev, int new_mtu) {struct jme_adapter *jme =netdev_priv (netdev); -if (new_mtu == jme->old_mtu) -return 0 ; - -if (((new_mtu +ETH_HLEN ) >MAX_ETHERNET_JUMBO_PACKET_SIZE ) || - ((new_mtu) <IPV6_MIN_MTU )) -return -EINVAL ; - - netdev->mtu = new_mtu;netdev_update_features (netdev);
@@ -3063,6 +3055,10 @@ jme_init_one(struct pci_dev *pdev,if (using_dac) netdev->features |=NETIF_F_HIGHDMA ; +/* MTU range: 1280 - 9202*/ + netdev->min_mtu =IPV6_MIN_MTU ; + netdev->max_mtu =MAX_ETHERNET_JUMBO_PACKET_SIZE -ETH_HLEN ; +SET_NETDEV_DEV (netdev, &pdev->dev);pci_set_drvdata (pdev, netdev);
drivers/net/ethernet/marvell/mv643xx_eth.c +4 -3
@@ -2585,9 +2585,6 @@ static int mv643xx_eth_change_mtu(struct net_device *dev, int new_mtu) {struct mv643xx_eth_private *mp =netdev_priv (dev); -if (new_mtu <64 || new_mtu >9500 ) -return -EINVAL ; - dev->mtu = new_mtu;mv643xx_eth_recalc_skb_size (mp);tx_set_rate (mp,1000000000 ,16777216 );
@@ -3206,6 +3203,10 @@ static int mv643xx_eth_probe(struct platform_device *pdev) dev->priv_flags |=IFF_UNICAST_FLT ; dev->gso_max_segs =MV643XX_MAX_TSO_SEGS ; +/* MTU range: 64 - 9500 */ + dev->min_mtu =64 ; + dev->max_mtu =9500 ; +SET_NETDEV_DEV (dev, &pdev->dev);if (mp->shared->win_protect)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +3 -0
@@ -2284,6 +2284,9 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,NETIF_F_HW_VLAN_CTAG_FILTER |NETIF_F_HW_TC ; dev->hw_features |=NETIF_F_HW_TC ; + dev->min_mtu =0 ; + dev->max_mtu =ETH_MAX_MTU ; +/* Each packet needs to have a Tx header (metadata) on top all other * headers. */
drivers/net/ethernet/mellanox/mlxsw/switchx2.c +3 -0
@@ -994,6 +994,9 @@ static int mlxsw_sx_port_create(struct mlxsw_sx *mlxsw_sx, u8 local_port) dev->features |=NETIF_F_NETNS_LOCAL |NETIF_F_LLTX |NETIF_F_SG |NETIF_F_VLAN_CHALLENGED ; + dev->min_mtu =0 ; + dev->max_mtu =ETH_MAX_MTU ; +/* Each packet needs to have a Tx header (metadata) on top all other * headers. */
drivers/net/ethernet/natsemi/ns83820.c +2 -9
@@ -1679,14 +1679,6 @@ static void ns83820_getmac(struct ns83820 *dev, u8 *mac) } } -static int ns83820_change_mtu (struct net_device *ndev,int new_mtu) -{ -if (new_mtu >RX_BUF_SIZE ) -return -EINVAL ; - ndev->mtu = new_mtu; -return 0 ; -} -static void ns83820_set_multicast (struct net_device *ndev) {struct ns83820 *dev =PRIV (ndev);
@@ -1933,7 +1925,6 @@ static const struct net_device_ops netdev_ops = { .ndo_stop = ns83820_stop, .ndo_start_xmit = ns83820_hard_start_xmit, .ndo_get_stats = ns83820_get_stats, - .ndo_change_mtu = ns83820_change_mtu, .ndo_set_rx_mode = ns83820_set_multicast, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr,
@@ -2190,6 +2181,8 @@ static int ns83820_init_one(struct pci_dev *pci_dev, ndev->features |=NETIF_F_SG ; ndev->features |=NETIF_F_IP_CSUM ; + ndev->min_mtu =0 ; +#ifdef NS83820_VLAN_ACCEL_SUPPORT /* We also support hardware vlan acceleration */ ndev->features |=NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_HW_VLAN_CTAG_RX ;
drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c +0 -12
@@ -987,20 +987,8 @@ int netxen_send_lro_cleanup(struct netxen_adapter *adapter)int netxen_nic_change_mtu (struct net_device *netdev,int mtu) {struct netxen_adapter *adapter =netdev_priv (netdev); -int max_mtu;int rc =0 ; -if (NX_IS_REVISION_P3 (adapter->ahw.revision_id)) - max_mtu =P3_MAX_MTU ; -else - max_mtu =P2_MAX_MTU ; - -if (mtu > max_mtu) { -printk (KERN_ERR "%s: mtu > %d bytes unsupported\n" , - netdev->name, max_mtu); -return -EINVAL ; - } -if (adapter->set_mtu) rc = adapter->set_mtu (adapter, mtu);
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +7 -0
@@ -1572,6 +1572,13 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) adapter->physical_port = i; } +/* MTU range: 0 - 8000 (P2) or 9600 (P3) */ + netdev->min_mtu =0 ; +if (NX_IS_REVISION_P3 (adapter->ahw.revision_id)) + netdev->max_mtu =P3_MAX_MTU ; +else + netdev->max_mtu =P2_MAX_MTU ; +netxen_nic_clear_stats (adapter); err =netxen_setup_intr (adapter);
drivers/net/ethernet/qlogic/qlge/qlge_main.c +7 -0
@@ -4788,6 +4788,13 @@ static int qlge_probe(struct pci_dev *pdev, ndev->ethtool_ops = &qlge_ethtool_ops; ndev->watchdog_timeo =10 *HZ ; +/* MTU range: this driver only supports 1500 or 9000, so this only +* filters out values above or below, and we'll rely on +* qlge_change_mtu to make sure only 1500 or 9000 are allowed +*/ + ndev->min_mtu =ETH_DATA_LEN ; + ndev->max_mtu =9000 ; + err =register_netdev (ndev);if (err) {dev_err (&pdev->dev,"net device registration failed.\n" );
drivers/net/ethernet/qualcomm/emac/emac.c +6 -7
@@ -239,15 +239,8 @@ static void emac_rx_mode_set(struct net_device *netdev)/* Change the Maximum Transfer Unit (MTU) */ static int emac_change_mtu (struct net_device *netdev,int new_mtu) { -unsigned int max_frame = new_mtu +ETH_HLEN +ETH_FCS_LEN +VLAN_HLEN ;struct emac_adapter *adpt =netdev_priv (netdev); -if ((max_frame <EMAC_MIN_ETH_FRAME_SIZE ) || - (max_frame >EMAC_MAX_ETH_FRAME_SIZE )) { -netdev_err (adpt->netdev,"error: invalid MTU setting\n" ); -return -EINVAL ; - } -netif_info (adpt, hw, adpt->netdev,"changing MTU from %d to %d\n" , netdev->mtu, new_mtu);
@@ -679,6 +672,12 @@ static int emac_probe(struct platform_device *pdev) netdev->vlan_features |=NETIF_F_SG |NETIF_F_HW_CSUM |NETIF_F_TSO |NETIF_F_TSO6 ; +/* MTU range: 46 - 9194 */ + netdev->min_mtu =EMAC_MIN_ETH_FRAME_SIZE - + (ETH_HLEN +ETH_FCS_LEN +VLAN_HLEN ); + netdev->max_mtu =EMAC_MAX_ETH_FRAME_SIZE - + (ETH_HLEN +ETH_FCS_LEN +VLAN_HLEN ); +INIT_WORK (&adpt->work_thread, emac_work_thread);/* Initialize queues */
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4 -3
@@ -1034,9 +1034,6 @@ static int axienet_change_mtu(struct net_device *ndev, int new_mtu) XAE_TRL_SIZE) > lp->rxmem)return -EINVAL ; -if ((new_mtu >XAE_JUMBO_MTU ) || (new_mtu <64 )) -return -EINVAL ; - ndev->mtu = new_mtu;return 0 ;
@@ -1475,6 +1472,10 @@ static int axienet_probe(struct platform_device *pdev) ndev->netdev_ops = &axienet_netdev_ops; ndev->ethtool_ops = &axienet_ethtool_ops; +/* MTU range: 64 - 9000 */ + ndev->min_mtu =64 ; + ndev->max_mtu =XAE_JUMBO_MTU ; + lp =netdev_priv (ndev); lp->ndev = ndev; lp->dev = &pdev->dev;
include/uapi/linux/if_ether.h +1 -0
@@ -36,6 +36,7 @@#define ETH_FCS_LEN 4/* Octets in the FCS */ #define ETH_MIN_MTU 68/* Min IPv4 MTU per RFC791 */ +#define ETH_MAX_MTU 0xFFFFU/* 65535, same as IP_MAX_MTU */ /* * These are the defined Ethernet Protocol ID's.
Signature · 1 line
2.10.0
PATCH v2 2/9 net: use core MTU range checking in USB NIC drivers
In reply to Jarod Wilsonusbnet:
- Remove stale new_mtu <= 0 check in usbnet.c
- Set min_mtu = 0, max_mtu = 65535 (sub-drivers must set their own max_mtu and/or min_mtu as needed)
r8152:
- Set appropriate max_mtu for different variants (1500 or 9194)
lan78xx:
- Set max_mtu = 9000
asix_driver:
- max_mtu = 16384 for ax88178 variant
ax88179:
- max_mtu = 4088
cdc_ncm:
- max_mtu from hardware
cdc-phonet:
- min_mtu = 6, max_mtu = 65541
sierra_net:
- max_mtu = 1500, call usbnet_change_mtu directly
- sierra_net_change_mtu checked for MTU > 1500, then called usbnet_change_mtu, but if we set max_mtu to let the network core handle the range check, then we can simply call usbnet_change_mtu directly
smsc75xx:
- max_mtu = 9000
--- drivers/net/usb/asix_devices.c | 4 +--- drivers/net/usb/ax88179_178a.c | 4 +--- drivers/net/usb/cdc-phonet.c | 12 ++---------- drivers/net/usb/cdc_ncm.c | 5 +---- drivers/net/usb/lan78xx.c | 8 +++----- drivers/net/usb/r8152.c | 15 ++++++++++++--- drivers/net/usb/sierra_net.c | 13 ++----------- drivers/net/usb/smsc75xx.c | 4 +--- drivers/net/usb/usbnet.c | 4 ++-- 9 files changed, 25 insertions(+), 44 deletions(-)
drivers/net/usb/asix_devices.c +1 -3
@@ -1026,9 +1026,6 @@ static int ax88178_change_mtu(struct net_device *net, int new_mtu)netdev_dbg (dev->net,"ax88178_change_mtu() new_mtu=%d\n" , new_mtu); -if (new_mtu <=0 || ll_mtu >16384 ) -return -EINVAL ; -if ((ll_mtu % dev->maxpacket) ==0 )return -EDOM ;
@@ -1081,6 +1078,7 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->netdev_ops = &ax88178_netdev_ops; dev->net->ethtool_ops = &ax88178_ethtool_ops; + dev->net->max_mtu =16384 - (dev->net->hard_header_len +4 );/* Blink LEDS so users know driver saw dongle */ asix_sw_reset (dev,0 ,0 );
drivers/net/usb/ax88179_178a.c +1 -3
@@ -907,9 +907,6 @@ static int ax88179_change_mtu(struct net_device *net, int new_mtu)struct usbnet *dev =netdev_priv (net);u16 tmp16; -if (new_mtu <=0 || new_mtu >4088 ) -return -EINVAL ; - net->mtu = new_mtu; dev->hard_mtu = net->mtu + net->hard_header_len;
@@ -1266,6 +1263,7 @@ static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->netdev_ops = &ax88179_netdev_ops; dev->net->ethtool_ops = &ax88179_ethtool_ops; dev->net->needed_headroom =8 ; + dev->net->max_mtu =4088 ;/* Initialize MII structure */ dev->mii.dev = dev->net;
drivers/net/usb/cdc-phonet.c +2 -10
@@ -276,21 +276,11 @@ static int usbpn_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)return -ENOIOCTLCMD ; } -static int usbpn_set_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <PHONET_MIN_MTU ) || (new_mtu >PHONET_MAX_MTU )) -return -EINVAL ; - - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops usbpn_ops = { .ndo_open = usbpn_open, .ndo_stop = usbpn_close, .ndo_start_xmit = usbpn_xmit, .ndo_do_ioctl = usbpn_ioctl, - .ndo_change_mtu = usbpn_set_mtu, };static void usbpn_setup (struct net_device *dev)
@@ -301,6 +291,8 @@ static void usbpn_setup(struct net_device *dev) dev->type =ARPHRD_PHONET ; dev->flags =IFF_POINTOPOINT |IFF_NOARP ; dev->mtu =PHONET_MAX_MTU ; + dev->min_mtu =PHONET_MIN_MTU ; + dev->max_mtu =PHONET_MAX_MTU ; dev->hard_header_len =1 ; dev->dev_addr[0 ] =PN_MEDIA_USB ; dev->addr_len =1 ;
drivers/net/usb/cdc_ncm.c +1 -4
@@ -740,10 +740,6 @@ static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)int cdc_ncm_change_mtu (struct net_device *net,int new_mtu) {struct usbnet *dev =netdev_priv (net); -int maxmtu =cdc_ncm_max_dgram_size (dev) -cdc_ncm_eth_hlen (dev); - -if (new_mtu <=0 || new_mtu > maxmtu) -return -EINVAL ; net->mtu = new_mtu;cdc_ncm_set_dgram_size (dev, new_mtu +cdc_ncm_eth_hlen (dev));
@@ -909,6 +905,7 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_/* must handle MTU changes */ dev->net->netdev_ops = &cdc_ncm_netdev_ops; + dev->net->max_mtu =cdc_ncm_max_dgram_size (dev) -cdc_ncm_eth_hlen (dev);return 0 ;
drivers/net/usb/lan78xx.c +3 -5
@@ -1980,11 +1980,6 @@ static int lan78xx_change_mtu(struct net_device *netdev, int new_mtu)int old_rx_urb_size = dev->rx_urb_size;int ret; -if (new_mtu >MAX_SINGLE_PACKET_SIZE ) -return -EINVAL ; - -if (new_mtu <=0 ) -return -EINVAL ;/* no second zero-length packet read wanted after mtu-sized packets */ if ((ll_mtu % dev->maxpacket) ==0 )return -EDOM ;
@@ -3388,6 +3383,9 @@ static int lan78xx_probe(struct usb_interface *intf,if (netdev->mtu > (dev->hard_mtu - netdev->hard_header_len)) netdev->mtu = dev->hard_mtu - netdev->hard_header_len; +/* MTU range: 68 - 9000 */ + netdev->max_mtu =MAX_SINGLE_PACKET_SIZE ; + dev->ep_blkin = (intf->cur_altsetting)->endpoint +0 ; dev->ep_blkout = (intf->cur_altsetting)->endpoint +1 ; dev->ep_intr = (intf->cur_altsetting)->endpoint +2 ;
drivers/net/usb/r8152.c +12 -3
@@ -4119,9 +4119,6 @@ static int rtl8152_change_mtu(struct net_device *dev, int new_mtu)break ; } -if (new_mtu <68 || new_mtu >RTL8153_MAX_MTU ) -return -EINVAL ; - ret =usb_autopm_get_interface (tp->intf);if (ret <0 )return ret;
@@ -4311,6 +4308,18 @@ static int rtl8152_probe(struct usb_interface *intf, netdev->ethtool_ops = &ops;netif_set_gso_max_size (netdev,RTL_LIMITED_TSO_SIZE ); +/* MTU range: 68 - 1500 or 9194 */ + netdev->min_mtu =ETH_MIN_MTU ; +switch (tp->version) { +case RTL_VER_01 : +case RTL_VER_02 : + netdev->max_mtu =ETH_DATA_LEN ; +break ; +default : + netdev->max_mtu =RTL8153_MAX_MTU ; +break ; + } + tp->mii.dev = netdev; tp->mii.mdio_read = read_mii_word; tp->mii.mdio_write = write_mii_word;
drivers/net/usb/sierra_net.c +2 -11
@@ -165,7 +165,6 @@ struct lsi_umts {/* Forward definitions */ static void sierra_sync_timer (unsigned long syncdata); -static int sierra_net_change_mtu (struct net_device *net,int new_mtu);/* Our own net device operations structure */ static const struct net_device_ops sierra_net_device_ops = {
@@ -173,7 +172,7 @@ static const struct net_device_ops sierra_net_device_ops = { .ndo_stop = usbnet_stop, .ndo_start_xmit = usbnet_start_xmit, .ndo_tx_timeout = usbnet_tx_timeout, - .ndo_change_mtu = sierra_net_change_mtu, + .ndo_change_mtu = usbnet_change_mtu, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, };
@@ -622,15 +621,6 @@ static const struct ethtool_ops sierra_net_ethtool_ops = { .nway_reset = usbnet_nway_reset, }; -/* MTU can not be more than 1500 bytes, enforce it. */ -static int sierra_net_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu >SIERRA_NET_MAX_SUPPORTED_MTU ) -return -EINVAL ; - -return usbnet_change_mtu (net, new_mtu); -} -static int sierra_net_get_fw_attr (struct usbnet *dev,u16 *datap) {int result =0 ;
@@ -720,6 +710,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->hard_header_len +=SIERRA_NET_HIP_EXT_HDR_LEN ; dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; + dev->net->max_mtu =SIERRA_NET_MAX_SUPPORTED_MTU ;/* Set up the netdev */ dev->net->flags |=IFF_NOARP ;
drivers/net/usb/smsc75xx.c +1 -3
@@ -925,9 +925,6 @@ static int smsc75xx_change_mtu(struct net_device *netdev, int new_mtu)struct usbnet *dev =netdev_priv (netdev);int ret; -if (new_mtu >MAX_SINGLE_PACKET_SIZE ) -return -EINVAL ; - ret =smsc75xx_set_rx_max_frame_length (dev, new_mtu +ETH_HLEN );if (ret <0 ) {netdev_warn (dev->net,"Failed to set mac rx frame length\n" );
@@ -1448,6 +1445,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->flags |=IFF_MULTICAST ; dev->net->hard_header_len +=SMSC75XX_TX_OVERHEAD ; dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; + dev->net->max_mtu =MAX_SINGLE_PACKET_SIZE ;return 0 ; }
drivers/net/usb/usbnet.c +2 -2
@@ -384,8 +384,6 @@ int usbnet_change_mtu (struct net_device *net, int new_mtu)int old_hard_mtu = dev->hard_mtu;int old_rx_urb_size = dev->rx_urb_size; -if (new_mtu <=0 ) -return -EINVAL ;// no second zero-length packet read wanted after mtu-sized packets if ((ll_mtu % dev->maxpacket) ==0 )return -EDOM ;
@@ -1669,6 +1667,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)* bind() should set rx_urb_size in that case. */ dev->hard_mtu = net->mtu + net->hard_header_len; + net->min_mtu =0 ; + net->max_mtu =ETH_MAX_MTU ; net->netdev_ops = &usbnet_netdev_ops; net->watchdog_timeo =TX_TIMEOUT_JIFFIES ;
Signature · 1 line
2.10.0
PATCH v2 3/9 net: use core MTU range checking in wireless drivers
In reply to Jarod Wilson- 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
- set min/max_mtu in net/mac80211/iface.c and remove ieee80211_change_mtu
- set min/max_mtu in wimax/i2400m and remove i2400m_change_mtu
- set min/max_mtu in intersil/hostap and remove prism2_change_mtu
- set min/max_mtu in intersil/orinoco
- set min/max_mtu in tty/n_gsm and remove gsm_change_mtu
--- drivers/net/wimax/i2400m/netdev.c | 22 ++-------------------- 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/net/wireless/intersil/hostap/hostap_main.c | 15 ++------------- drivers/net/wireless/intersil/orinoco/main.c | 6 +++--- drivers/staging/wlan-ng/p80211netdev.c | 18 +++++------------- drivers/tty/n_gsm.c | 12 ++---------- net/mac80211/iface.c | 15 ++++----------- 13 files changed, 34 insertions(+), 119 deletions(-)
drivers/net/wimax/i2400m/netdev.c +2 -20
@@ -395,25 +395,6 @@ netdev_tx_t i2400m_hard_start_xmit(struct sk_buff *skb,static -int i2400m_change_mtu (struct net_device *net_dev,int new_mtu) -{ -int result; -struct i2400m *i2400m =net_dev_to_i2400m (net_dev); -struct device *dev =i2400m_dev (i2400m); - -if (new_mtu >=I2400M_MAX_MTU ) { -dev_err (dev,"Cannot change MTU to %d (max is %d)\n" , - new_mtu,I2400M_MAX_MTU ); - result = -EINVAL ; - }else { - net_dev->mtu = new_mtu; - result =0 ; - } -return result; -} - - -static void i2400m_tx_timeout (struct net_device *net_dev) {/*
@@ -590,7 +571,6 @@ static const struct net_device_ops i2400m_netdev_ops = { .ndo_stop = i2400m_stop, .ndo_start_xmit = i2400m_hard_start_xmit, .ndo_tx_timeout = i2400m_tx_timeout, - .ndo_change_mtu = i2400m_change_mtu, }; static void i2400m_get_drvinfo(struct net_device *net_dev,
@@ -621,6 +601,8 @@ void i2400m_netdev_setup(struct net_device *net_dev)d_fnstart (3 ,NULL ,"(net_dev %p)\n" , net_dev);ether_setup (net_dev); net_dev->mtu =I2400M_MAX_MTU ; + net_dev->min_mtu =0 ; + net_dev->max_mtu =I2400M_MAX_MTU ; net_dev->tx_queue_len =I2400M_TX_QLEN ; net_dev->features =NETIF_F_VLAN_CHALLENGED
drivers/net/wireless/ath/wil6210/netdev.c +1 -16
@@ -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 ; }
drivers/net/wireless/atmel/atmel.c +4 -9
@@ -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))) {
drivers/net/wireless/cisco/airo.c +3 -11
@@ -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);
drivers/net/wireless/intel/ipw2x00/ipw2100.c +2 -1
@@ -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
drivers/net/wireless/intel/ipw2x00/ipw2200.c +6 -2
@@ -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" );
drivers/net/wireless/intel/ipw2x00/libipw.h +0 -1
@@ -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);
drivers/net/wireless/intel/ipw2x00/libipw_module.c +0 -9
@@ -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;
drivers/net/wireless/intersil/hostap/hostap_main.c +2 -13
@@ -765,16 +765,6 @@ static void hostap_set_multicast_list(struct net_device *dev) } -static int prism2_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <PRISM2_MIN_MTU || new_mtu >PRISM2_MAX_MTU ) -return -EINVAL ; - - dev->mtu = new_mtu; -return 0 ; -} - -static void prism2_tx_timeout (struct net_device *dev) {struct hostap_interface *iface;
@@ -813,7 +803,6 @@ static const struct net_device_ops hostap_netdev_ops = { .ndo_do_ioctl = hostap_ioctl, .ndo_set_mac_address = prism2_set_mac_address, .ndo_set_rx_mode = hostap_set_multicast_list, - .ndo_change_mtu = prism2_change_mtu, .ndo_tx_timeout = prism2_tx_timeout, .ndo_validate_addr = eth_validate_addr, };
@@ -826,7 +815,6 @@ static const struct net_device_ops hostap_mgmt_netdev_ops = { .ndo_do_ioctl = hostap_ioctl, .ndo_set_mac_address = prism2_set_mac_address, .ndo_set_rx_mode = hostap_set_multicast_list, - .ndo_change_mtu = prism2_change_mtu, .ndo_tx_timeout = prism2_tx_timeout, .ndo_validate_addr = eth_validate_addr, };
@@ -839,7 +827,6 @@ static const struct net_device_ops hostap_master_ops = { .ndo_do_ioctl = hostap_ioctl, .ndo_set_mac_address = prism2_set_mac_address, .ndo_set_rx_mode = hostap_set_multicast_list, - .ndo_change_mtu = prism2_change_mtu, .ndo_tx_timeout = prism2_tx_timeout, .ndo_validate_addr = eth_validate_addr, };
@@ -851,6 +838,8 @@ void hostap_setup_dev(struct net_device *dev, local_info_t *local, iface =netdev_priv (dev);ether_setup (dev); + dev->min_mtu =PRISM2_MIN_MTU ; + dev->max_mtu =PRISM2_MAX_MTU ; dev->priv_flags &= ~IFF_TX_SKB_SHARING ;/* kernel callbacks */
drivers/net/wireless/intersil/orinoco/main.c +3 -3
@@ -322,9 +322,6 @@ int orinoco_change_mtu(struct net_device *dev, int new_mtu) {struct orinoco_private *priv =ndev_priv (dev); -if ((new_mtu <ORINOCO_MIN_MTU ) || (new_mtu >ORINOCO_MAX_MTU )) -return -EINVAL ; -/* MTU + encapsulation + header length */ if ((new_mtu +ENCAPS_OVERHEAD +sizeof (struct ieee80211_hdr )) > (priv->nicbuf_size -ETH_HLEN ))
@@ -2288,6 +2285,9 @@ int orinoco_if_add(struct orinoco_private *priv, dev->base_addr = base_addr; dev->irq = irq; + dev->min_mtu =ORINOCO_MIN_MTU ; + dev->max_mtu =ORINOCO_MAX_MTU ; +SET_NETDEV_DEV (dev, priv->dev); ret =register_netdev (dev);if (ret)
drivers/staging/wlan-ng/p80211netdev.c +5 -13
@@ -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);
drivers/tty/n_gsm.c +2 -10
@@ -2711,15 +2711,6 @@ static void gsm_mux_rx_netchar(struct gsm_dlci *dlci,return ; } -static int gsm_change_mtu (struct net_device *net,int new_mtu) -{ -struct gsm_mux_net *mux_net =netdev_priv (net); -if ((new_mtu <8 ) || (new_mtu > mux_net->dlci->gsm->mtu)) -return -EINVAL ; - net->mtu = new_mtu; -return 0 ; -} -static void gsm_mux_net_init (struct net_device *net) {static const struct net_device_ops gsm_netdev_ops = {
@@ -2728,7 +2719,6 @@ static void gsm_mux_net_init(struct net_device *net) .ndo_start_xmit = gsm_mux_net_start_xmit, .ndo_tx_timeout = gsm_mux_net_tx_timeout, .ndo_get_stats = gsm_mux_net_get_stats, - .ndo_change_mtu = gsm_change_mtu, }; net->netdev_ops = &gsm_netdev_ops;
@@ -2787,6 +2777,8 @@ static int gsm_create_network(struct gsm_dlci *dlci, struct gsm_netconfig *nc)return -ENOMEM ; } net->mtu = dlci->gsm->mtu; + net->min_mtu =8 ; + net->max_mtu = dlci->gsm->mtu; mux_net =netdev_priv (net); mux_net->dlci = dlci;kref_init (&mux_net->ref);
net/mac80211/iface.c +4 -11
@@ -150,15 +150,6 @@ void ieee80211_recalc_idle(struct ieee80211_local *local)ieee80211_hw_config (local, change); } -static int ieee80211_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <256 || new_mtu >IEEE80211_MAX_DATA_LEN ) -return -EINVAL ; - - dev->mtu = new_mtu; -return 0 ; -} -static int ieee80211_verify_mac (struct ieee80211_sub_if_data *sdata,u8 *addr,bool check_dup) {
@@ -1166,7 +1157,6 @@ static const struct net_device_ops ieee80211_dataif_ops = { .ndo_uninit = ieee80211_uninit, .ndo_start_xmit = ieee80211_subif_start_xmit, .ndo_set_rx_mode = ieee80211_set_multicast_list, - .ndo_change_mtu = ieee80211_change_mtu, .ndo_set_mac_address = ieee80211_change_mac, .ndo_select_queue = ieee80211_netdev_select_queue, .ndo_get_stats64 = ieee80211_get_stats64,
@@ -1200,7 +1190,6 @@ static const struct net_device_ops ieee80211_monitorif_ops = { .ndo_uninit = ieee80211_uninit, .ndo_start_xmit = ieee80211_monitor_start_xmit, .ndo_set_rx_mode = ieee80211_set_multicast_list, - .ndo_change_mtu = ieee80211_change_mtu, .ndo_set_mac_address = ieee80211_change_mac, .ndo_select_queue = ieee80211_monitor_select_queue, .ndo_get_stats64 = ieee80211_get_stats64,
@@ -1884,6 +1873,10 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,netdev_set_default_ethtool_ops (ndev, &ieee80211_ethtool_ops); +/* MTU range: 256 - 2304 */ + ndev->min_mtu =256 ; + ndev->max_mtu =IEEE80211_MAX_DATA_LEN ; + ret =register_netdevice (ndev);if (ret) {ieee80211_if_free (ndev);
Signature · 1 line
2.10.0
Re: [PATCH net-next v2 3/9] net: use core MTU range checking in wireless drivers
Quoted 7 lines · Jarod Wilson
- set
max_mtuin wil6210 driver
- setmax_mtuin atmel driver
- set min/max_mtu in cisco airo driver, removeairo_change_mtu
- set min/max_mtu in ipw2100/ipw2200 drivers, removelibipw_change_mtu
- set min/max_mtu in p80211netdev, removewlan_change_mtu
- set min/max_mtu innet/mac80211/iface.cand removeieee80211_change_mtu
For the mac80211 part,
Dave, I'm assuming you'll pick this up, but if you prefer not to I can also coordinate with Kalle to take this through our trees.
johannes
David Miller
maintainerRe: [PATCH net-next v2 3/9] net: use core MTU range checking in wireless drivers
From: Johannes Berg <[email protected]>
Date: Thu, 20 Oct 2016 20:22:35 +0200
Quoted 9 lines · Jarod Wilson
Quoted 7 lines
- set
max_mtuin wil6210 driver
- setmax_mtuin atmel driver
- set min/max_mtu in cisco airo driver, removeairo_change_mtu
- set min/max_mtu in ipw2100/ipw2200 drivers, removelibipw_change_mtu
- set min/max_mtu in p80211netdev, removewlan_change_mtu
- set min/max_mtu innet/mac80211/iface.cand removeieee80211_change_mtu
Quoted 6 lines
For the mac80211 part,
Acked-by Johannes Berg <[email protected]>Dave, I'm assuming you'll pick this up, but if you prefer not to I can also coordinate with Kalle to take this through our trees.
Yeah I'll get this, thanks for asking.
PATCH v2 4/9 net: use core MTU range checking in WAN drivers
In reply to Jarod Wilson- set min/max_mtu in all hdlc drivers, remove hdlc_change_mtu
- sent max_mtu in lec driver, remove lec_change_mtu
- set min/max_mtu in x25_asy driver
--- drivers/char/pcmcia/synclink_cs.c | 1 - drivers/net/wan/c101.c | 1 - drivers/net/wan/cosa.c | 1 - drivers/net/wan/dscc4.c | 1 - drivers/net/wan/farsync.c | 1 - drivers/net/wan/fsl_ucc_hdlc.c | 1 - drivers/net/wan/hdlc.c | 11 ++--------- drivers/net/wan/hdlc_fr.c | 3 ++- drivers/net/wan/hostess_sv11.c | 1 - drivers/net/wan/ixp4xx_hss.c | 1 - drivers/net/wan/lmc/lmc_main.c | 1 - drivers/net/wan/n2.c | 1 - drivers/net/wan/pc300too.c | 1 - drivers/net/wan/pci200syn.c | 1 - drivers/net/wan/sealevel.c | 1 - drivers/net/wan/wanxl.c | 1 - drivers/net/wan/x25_asy.c | 5 ++--- drivers/tty/synclink.c | 1 - drivers/tty/synclink_gt.c | 1 - drivers/tty/synclinkmp.c | 1 - include/linux/hdlc.h | 2 -- net/atm/lec.c | 11 +---------- 22 files changed, 7 insertions(+), 42 deletions(-)
drivers/char/pcmcia/synclink_cs.c +0 -1
@@ -4248,7 +4248,6 @@ static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size)static const struct net_device_ops hdlcdev_ops = { .ndo_open = hdlcdev_open, .ndo_stop = hdlcdev_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hdlcdev_ioctl, .ndo_tx_timeout = hdlcdev_tx_timeout,
drivers/net/wan/c101.c +0 -1
@@ -302,7 +302,6 @@ static void c101_destroy_card(card_t *card)static const struct net_device_ops c101_ops = { .ndo_open = c101_open, .ndo_stop = c101_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = c101_ioctl, };
drivers/net/wan/cosa.c +0 -1
@@ -432,7 +432,6 @@ module_exit(cosa_exit);static const struct net_device_ops cosa_ops = { .ndo_open = cosa_net_open, .ndo_stop = cosa_net_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = cosa_net_ioctl, .ndo_tx_timeout = cosa_net_timeout,
drivers/net/wan/dscc4.c +0 -1
@@ -887,7 +887,6 @@ static inline int dscc4_set_quartz(struct dscc4_dev_priv *dpriv, int hz)static const struct net_device_ops dscc4_ops = { .ndo_open = dscc4_open, .ndo_stop = dscc4_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = dscc4_ioctl, .ndo_tx_timeout = dscc4_tx_timeout,
drivers/net/wan/farsync.c +0 -1
@@ -2394,7 +2394,6 @@ fst_init_card(struct fst_card_info *card)static const struct net_device_ops fst_ops = { .ndo_open = fst_open, .ndo_stop = fst_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = fst_ioctl, .ndo_tx_timeout = fst_tx_timeout,
drivers/net/wan/fsl_ucc_hdlc.c +0 -1
@@ -992,7 +992,6 @@ static const struct dev_pm_ops uhdlc_pm_ops = {static const struct net_device_ops uhdlc_ops = { .ndo_open = uhdlc_open, .ndo_stop = uhdlc_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = uhdlc_ioctl, };
drivers/net/wan/hdlc.c +2 -9
@@ -46,14 +46,6 @@ static const char* version = "HDLC support module revision 1.22";static struct hdlc_proto *first_proto; -int hdlc_change_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <68 ) || (new_mtu >HDLC_MAX_MTU )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static int hdlc_rcv (struct sk_buff *skb,struct net_device *dev,struct packet_type *p,struct net_device *orig_dev) {
@@ -237,6 +229,8 @@ static void hdlc_setup_dev(struct net_device *dev) dev->flags =IFF_POINTOPOINT |IFF_NOARP ; dev->priv_flags =IFF_WAN_HDLC ; dev->mtu =HDLC_MAX_MTU ; + dev->min_mtu =68 ; + dev->max_mtu =HDLC_MAX_MTU ; dev->type =ARPHRD_RAWHDLC ; dev->hard_header_len =16 ; dev->addr_len =0 ;
@@ -353,7 +347,6 @@ MODULE_AUTHOR("Krzysztof Halasa <[email protected]>");MODULE_DESCRIPTION ("HDLC support module" );MODULE_LICENSE ("GPL v2" ); -EXPORT_SYMBOL (hdlc_change_mtu);EXPORT_SYMBOL (hdlc_start_xmit);EXPORT_SYMBOL (hdlc_open);EXPORT_SYMBOL (hdlc_close);
drivers/net/wan/hdlc_fr.c +2 -1
@@ -1053,7 +1053,6 @@ static void pvc_setup(struct net_device *dev)static const struct net_device_ops pvc_ops = { .ndo_open = pvc_open, .ndo_stop = pvc_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = pvc_xmit, .ndo_do_ioctl = pvc_ioctl, };
@@ -1096,6 +1095,8 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) } dev->netdev_ops = &pvc_ops; dev->mtu =HDLC_MAX_MTU ; + dev->min_mtu =68 ; + dev->max_mtu =HDLC_MAX_MTU ; dev->priv_flags |=IFF_NO_QUEUE ; dev->ml_priv = pvc;
drivers/net/wan/hostess_sv11.c +0 -1
@@ -180,7 +180,6 @@ static int hostess_attach(struct net_device *dev, unsigned short encoding,static const struct net_device_ops hostess_ops = { .ndo_open = hostess_open, .ndo_stop = hostess_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hostess_ioctl, };
drivers/net/wan/ixp4xx_hss.c +0 -1
@@ -1321,7 +1321,6 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)static const struct net_device_ops hss_hdlc_ops = { .ndo_open = hss_hdlc_open, .ndo_stop = hss_hdlc_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hss_hdlc_ioctl, };
drivers/net/wan/lmc/lmc_main.c +0 -1
@@ -808,7 +808,6 @@ static int lmc_attach(struct net_device *dev, unsigned short encoding,static const struct net_device_ops lmc_ops = { .ndo_open = lmc_open, .ndo_stop = lmc_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = lmc_ioctl, .ndo_tx_timeout = lmc_driver_timeout,
drivers/net/wan/n2.c +0 -1
@@ -330,7 +330,6 @@ static void n2_destroy_card(card_t *card)static const struct net_device_ops n2_ops = { .ndo_open = n2_open, .ndo_stop = n2_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = n2_ioctl, };
drivers/net/wan/pc300too.c +0 -1
@@ -291,7 +291,6 @@ static void pc300_pci_remove_one(struct pci_dev *pdev)static const struct net_device_ops pc300_ops = { .ndo_open = pc300_open, .ndo_stop = pc300_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = pc300_ioctl, };
drivers/net/wan/pci200syn.c +0 -1
@@ -270,7 +270,6 @@ static void pci200_pci_remove_one(struct pci_dev *pdev)static const struct net_device_ops pci200_ops = { .ndo_open = pci200_open, .ndo_stop = pci200_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = pci200_ioctl, };
drivers/net/wan/sealevel.c +0 -1
@@ -174,7 +174,6 @@ static int sealevel_attach(struct net_device *dev, unsigned short encoding,static const struct net_device_ops sealevel_ops = { .ndo_open = sealevel_open, .ndo_stop = sealevel_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = sealevel_ioctl, };
drivers/net/wan/wanxl.c +0 -1
@@ -551,7 +551,6 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev)static const struct net_device_ops wanxl_ops = { .ndo_open = wanxl_open, .ndo_stop = wanxl_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = wanxl_ioctl, .ndo_get_stats = wanxl_get_stats,
drivers/net/wan/x25_asy.c +2 -3
@@ -124,9 +124,6 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)unsigned char *xbuff, *rbuff;int len; -if (newmtu >65534 ) -return -EINVAL ; - len =2 * newmtu; xbuff =kmalloc (len +4 ,GFP_ATOMIC ); rbuff =kmalloc (len +4 ,GFP_ATOMIC );
@@ -751,6 +748,8 @@ static void x25_asy_setup(struct net_device *dev)*/ dev->mtu =SL_MTU ; + dev->min_mtu =0 ; + dev->max_mtu =65534 ; dev->netdev_ops = &x25_asy_netdev_ops; dev->watchdog_timeo =HZ *20 ; dev->hard_header_len =0 ;
drivers/tty/synclink.c +0 -1
@@ -7973,7 +7973,6 @@ static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size)static const struct net_device_ops hdlcdev_ops = { .ndo_open = hdlcdev_open, .ndo_stop = hdlcdev_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hdlcdev_ioctl, .ndo_tx_timeout = hdlcdev_tx_timeout,
drivers/tty/synclink_gt.c +0 -1
@@ -1768,7 +1768,6 @@ static void hdlcdev_rx(struct slgt_info *info, char *buf, int size)static const struct net_device_ops hdlcdev_ops = { .ndo_open = hdlcdev_open, .ndo_stop = hdlcdev_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hdlcdev_ioctl, .ndo_tx_timeout = hdlcdev_tx_timeout,
drivers/tty/synclinkmp.c +0 -1
@@ -1887,7 +1887,6 @@ static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size)static const struct net_device_ops hdlcdev_ops = { .ndo_open = hdlcdev_open, .ndo_stop = hdlcdev_close, - .ndo_change_mtu = hdlc_change_mtu, .ndo_start_xmit = hdlc_start_xmit, .ndo_do_ioctl = hdlcdev_ioctl, .ndo_tx_timeout = hdlcdev_tx_timeout,
include/linux/hdlc.h +0 -2
@@ -93,8 +93,6 @@ static __inline__ void debug_frame(const struct sk_buff *skb)int hdlc_open (struct net_device *dev);/* Must be called by hardware driver when HDLC device is being closed */ void hdlc_close (struct net_device *dev); -/* May be used by hardware driver */ -int hdlc_change_mtu (struct net_device *dev,int new_mtu);/* Must be pointed to by hw driver's dev->netdev_ops->ndo_start_xmit */ netdev_tx_t hdlc_start_xmit (struct sk_buff *skb,struct net_device *dev);
net/atm/lec.c +1 -10
@@ -544,15 +544,6 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,return 0 ; } -/* shamelessly stolen from drivers/net/net_init.c */ -static int lec_change_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <68 ) || (new_mtu >18190 )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static void lec_set_multicast_list (struct net_device *dev) {/*
@@ -565,7 +556,6 @@ static const struct net_device_ops lec_netdev_ops = { .ndo_open = lec_open, .ndo_stop = lec_close, .ndo_start_xmit = lec_start_xmit, - .ndo_change_mtu = lec_change_mtu, .ndo_tx_timeout = lec_tx_timeout, .ndo_set_rx_mode = lec_set_multicast_list, };
@@ -742,6 +732,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)if (!dev_lec[i])return -ENOMEM ; dev_lec[i]->netdev_ops = &lec_netdev_ops; + dev_lec[i]->max_mtu =18190 ;snprintf (dev_lec[i]->name,IFNAMSIZ ,"lec%d" , i);if (register_netdev (dev_lec[i])) {free_netdev (dev_lec[i]);
Signature · 1 line
2.10.0
PATCH v2 5/9 net: use core MTU range checking in core net infra
In reply to Jarod Wilsongeneve:
- Merge __geneve_change_mtu back into geneve_change_mtu, set max_mtu
- This one isn't quite as straight-forward as others, could use some closer inspection and testing
macvlan:
- set min/max_mtu
tun:
- set min/max_mtu, remove tun_net_change_mtu
vxlan:
- Merge __vxlan_change_mtu back into vxlan_change_mtu
- Set max_mtu to IP_MAX_MTU and retain dynamic MTU range checks in change_mtu function
- This one is also not as straight-forward and could use closer inspection and testing from vxlan folks
bridge:
- set max_mtu of IP_MAX_MTU and retain dynamic MTU range checks in change_mtu function
openvswitch:
- set min/max_mtu, remove internal_dev_change_mtu
- note: max_mtu wasn't checked previously, it's been set to 65535, which is the largest possible size supported
sch_teql:
- set min/max_mtu (note: max_mtu previously unchecked, used max of 65535)
macsec:
- min_mtu = 0, max_mtu = 65535
macvlan:
- min_mtu = 0, max_mtu = 65535
ntb_netdev:
- min_mtu = 0, max_mtu = 65535
veth:
- min_mtu = 68, max_mtu = 65535
8021q:
- min_mtu = 0, max_mtu = 65535
--- drivers/net/geneve.c | 48 +++++++++++---------------- drivers/net/macsec.c | 2 ++ drivers/net/macvlan.c | 8 ++++- drivers/net/ntb_netdev.c | 3 ++ drivers/net/tun.c | 20 ++++------- drivers/net/veth.c | 17 ++-------- drivers/net/vxlan.c | 64 +++++++++++++++++++----------------- net/8021q/vlan_dev.c | 3 ++ net/bridge/br_device.c | 3 +- net/openvswitch/vport-internal_dev.c | 10 ------ net/sched/sch_teql.c | 5 ++- 11 files changed, 81 insertions(+), 102 deletions(-)
drivers/net/geneve.c +19 -29
@@ -1034,39 +1034,18 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)return geneve_xmit_skb (skb, dev, info); } -static int __geneve_change_mtu (struct net_device *dev,int new_mtu,bool strict) +static int geneve_change_mtu (struct net_device *dev,int new_mtu) { -struct geneve_dev *geneve =netdev_priv (dev); -/* The max_mtu calculation does not take account of GENEVE -* options, to avoid excluding potentially valid -* configurations. +/* Only possible if called internally, ndo_change_mtu path's new_mtu +* is guaranteed to be between dev->min_mtu and dev->max_mtu. */ -int max_mtu =IP_MAX_MTU -GENEVE_BASE_HLEN - dev->hard_header_len; - -if (geneve->remote.sa.sa_family ==AF_INET6 ) - max_mtu -=sizeof (struct ipv6hdr ); -else - max_mtu -=sizeof (struct iphdr ); - -if (new_mtu <68 ) -return -EINVAL ; - -if (new_mtu > max_mtu) { -if (strict) -return -EINVAL ; - - new_mtu = max_mtu; - } +if (new_mtu > dev->max_mtu) + new_mtu = dev->max_mtu; dev->mtu = new_mtu;return 0 ; } -static int geneve_change_mtu (struct net_device *dev,int new_mtu) -{ -return __geneve_change_mtu (dev, new_mtu, true); -} -static int geneve_fill_metadata_dst (struct net_device *dev,struct sk_buff *skb) {struct ip_tunnel_info *info =skb_tunnel_info (skb);
@@ -1170,6 +1149,14 @@ static void geneve_setup(struct net_device *dev) dev->hw_features |=NETIF_F_SG |NETIF_F_HW_CSUM |NETIF_F_RXCSUM ; dev->hw_features |=NETIF_F_GSO_SOFTWARE ; +/* MTU range: 68 - (something less than 65535) */ + dev->min_mtu =ETH_MIN_MTU ; +/* The max_mtu calculation does not take account of GENEVE +* options, to avoid excluding potentially valid +* configurations. This will be further reduced by IPvX hdr size. +*/ + dev->max_mtu =IP_MAX_MTU -GENEVE_BASE_HLEN - dev->hard_header_len; +netif_keep_dst (dev); dev->priv_flags &= ~IFF_TX_SKB_SHARING ; dev->priv_flags |=IFF_LIVE_ADDR_CHANGE |IFF_NO_QUEUE ;
@@ -1285,10 +1272,13 @@ static int geneve_configure(struct net *net, struct net_device *dev,/* make enough headroom for basic scenario */ encap_len =GENEVE_BASE_HLEN +ETH_HLEN ; -if (remote->sa.sa_family ==AF_INET ) +if (remote->sa.sa_family ==AF_INET ) { encap_len +=sizeof (struct iphdr ); -else + dev->max_mtu -=sizeof (struct iphdr ); + }else { encap_len +=sizeof (struct ipv6hdr ); + dev->max_mtu -=sizeof (struct ipv6hdr ); + } dev->needed_headroom = encap_len +ETH_HLEN ;if (metadata) {
@@ -1488,7 +1478,7 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,/* openvswitch users expect packet sizes to be unrestricted, * so set the largest MTU we can. */ - err =__geneve_change_mtu (dev,IP_MAX_MTU , false); + err =geneve_change_mtu (dev,IP_MAX_MTU );if (err) goto err;
drivers/net/macsec.c +2 -0
@@ -2970,6 +2970,8 @@ static void macsec_free_netdev(struct net_device *dev)static void macsec_setup (struct net_device *dev) {ether_setup (dev); + dev->min_mtu =0 ; + dev->max_mtu =ETH_MAX_MTU ; dev->priv_flags |=IFF_NO_QUEUE ; dev->netdev_ops = &macsec_netdev_ops; dev->destructor = macsec_free_netdev;
drivers/net/macvlan.c +7 -1
@@ -777,7 +777,7 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu) {struct macvlan_dev *vlan =netdev_priv (dev); -if (new_mtu <68 || vlan->lowerdev->mtu < new_mtu) +if (vlan->lowerdev->mtu < new_mtu)return -EINVAL ; dev->mtu = new_mtu;return 0 ;
@@ -1085,6 +1085,8 @@ void macvlan_common_setup(struct net_device *dev) {ether_setup (dev); + dev->min_mtu =0 ; + dev->max_mtu =ETH_MAX_MTU ; dev->priv_flags &= ~IFF_TX_SKB_SHARING ;netif_keep_dst (dev); dev->priv_flags |=IFF_UNICAST_FLT ;
@@ -1297,6 +1299,10 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,else if (dev->mtu > lowerdev->mtu)return -EINVAL ; +/* MTU range: 68 - lowerdev->max_mtu */ + dev->min_mtu =ETH_MIN_MTU ; + dev->max_mtu = lowerdev->max_mtu; +if (!tb[IFLA_ADDRESS ])eth_hw_addr_random (dev);
drivers/net/ntb_netdev.c +3 -0
@@ -433,6 +433,9 @@ static int ntb_netdev_probe(struct device *client_dev) ndev->netdev_ops = &ntb_netdev_ops; ndev->ethtool_ops = &ntb_ethtool_ops; + ndev->min_mtu =0 ; + ndev->max_mtu =ETH_MAX_MTU ; + dev->qp =ntb_transport_create_queue (ndev, client_dev, &ntb_netdev_handlers);if (!dev->qp) {
drivers/net/tun.c +6 -14
@@ -925,18 +925,6 @@ static void tun_net_mclist(struct net_device *dev)*/ } -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int -tun_net_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu + dev->hard_header_len >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static netdev_features_t tun_net_fix_features (struct net_device *dev,netdev_features_t features) {
@@ -1014,7 +1002,6 @@ static const struct net_device_ops tun_netdev_ops = { .ndo_open = tun_net_open, .ndo_stop = tun_net_close, .ndo_start_xmit = tun_net_xmit, - .ndo_change_mtu = tun_net_change_mtu, .ndo_fix_features = tun_net_fix_features, .ndo_select_queue = tun_select_queue,#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1029,7 +1016,6 @@ static const struct net_device_ops tap_netdev_ops = { .ndo_open = tun_net_open, .ndo_stop = tun_net_close, .ndo_start_xmit = tun_net_xmit, - .ndo_change_mtu = tun_net_change_mtu, .ndo_fix_features = tun_net_fix_features, .ndo_set_rx_mode = tun_net_mclist, .ndo_set_mac_address = eth_mac_addr,
@@ -1062,6 +1048,9 @@ static void tun_flow_uninit(struct tun_struct *tun)tun_flow_flush (tun); } +#define MIN_MTU 68 +#define MAX_MTU 65535 +/* Initialize net device. */ static void tun_net_init (struct net_device *dev) {
@@ -1092,6 +1081,9 @@ static void tun_net_init(struct net_device *dev)break ; } + + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU - dev->hard_header_len; }/* Character device part */
drivers/net/veth.c +3 -14
@@ -23,9 +23,6 @@#define DRV_NAME "veth"#define DRV_VERSION "1.0" -#define MIN_MTU 68/* Min L3 MTU */ -#define MAX_MTU 65535/* Max L3 MTU (arbitrary) */ -struct pcpu_vstats {u64 packets;u64 bytes;
@@ -216,17 +213,9 @@ static int veth_close(struct net_device *dev)return 0 ; } -static int is_valid_veth_mtu (int new_mtu) +static int is_valid_veth_mtu (int mtu) { -return new_mtu >=MIN_MTU && new_mtu <=MAX_MTU ; -} - -static int veth_change_mtu (struct net_device *dev,int new_mtu) -{ -if (!is_valid_veth_mtu (new_mtu)) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; +return mtu >=ETH_MIN_MTU && mtu <=ETH_MAX_MTU ; }static int veth_dev_init (struct net_device *dev)
@@ -300,7 +289,6 @@ static const struct net_device_ops veth_netdev_ops = { .ndo_open = veth_open, .ndo_stop = veth_close, .ndo_start_xmit = veth_xmit, - .ndo_change_mtu = veth_change_mtu, .ndo_get_stats64 = veth_get_stats64, .ndo_set_rx_mode = veth_set_multicast_list, .ndo_set_mac_address = eth_mac_addr,
@@ -337,6 +325,7 @@ static void veth_setup(struct net_device *dev)NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX); dev->destructor = veth_dev_free; + dev->max_mtu =ETH_MAX_MTU ; dev->hw_features =VETH_FEATURES ; dev->hw_enc_features =VETH_FEATURES ;
drivers/net/vxlan.c +34 -30
99 lines not on this page · raw message
net/8021q/vlan_dev.c +3 -0
@@ -826,5 +826,8 @@ void vlan_setup(struct net_device *dev) dev->destructor = vlan_dev_free; dev->ethtool_ops = &vlan_ethtool_ops; + dev->min_mtu =0 ; + dev->max_mtu =ETH_MAX_MTU ; +eth_zero_addr (dev->broadcast); }
net/bridge/br_device.c +2 -1
@@ -185,7 +185,7 @@ static struct rtnl_link_stats64 *br_get_stats64(struct net_device *dev,static int br_change_mtu (struct net_device *dev,int new_mtu) {struct net_bridge *br =netdev_priv (dev); -if (new_mtu <68 || new_mtu >br_min_mtu (br)) +if (new_mtu >br_min_mtu (br))return -EINVAL ; dev->mtu = new_mtu;
@@ -410,6 +410,7 @@ void br_dev_setup(struct net_device *dev) br->bridge_hello_time = br->hello_time =2 *HZ ; br->bridge_forward_delay = br->forward_delay =15 *HZ ; br->ageing_time =BR_DEFAULT_AGEING_TIME ; + dev->max_mtu =ETH_MAX_MTU ;br_netfilter_rtable_init (br);br_stp_timer_init (br);
net/openvswitch/vport-internal_dev.c +0 -10
@@ -89,15 +89,6 @@ static const struct ethtool_ops internal_dev_ethtool_ops = { .get_link = ethtool_op_get_link, }; -static int internal_dev_change_mtu (struct net_device *netdev,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - netdev->mtu = new_mtu; -return 0 ; -} -static void internal_dev_destructor (struct net_device *dev) {struct vport *vport =ovs_internal_dev_get_vport (dev);
@@ -148,7 +139,6 @@ static const struct net_device_ops internal_dev_netdev_ops = { .ndo_stop = internal_dev_stop, .ndo_start_xmit = internal_dev_xmit, .ndo_set_mac_address = eth_mac_addr, - .ndo_change_mtu = internal_dev_change_mtu, .ndo_get_stats64 = internal_get_stats, .ndo_set_rx_headroom = internal_set_rx_headroom, };
net/sched/sch_teql.c +2 -3
@@ -418,9 +418,6 @@ static int teql_master_mtu(struct net_device *dev, int new_mtu)struct teql_master *m =netdev_priv (dev);struct Qdisc *q; -if (new_mtu <68 ) -return -EINVAL ; - q = m->slaves;if (q) { do {
@@ -460,6 +457,8 @@ static __init void teql_master_setup(struct net_device *dev) dev->netdev_ops = &teql_netdev_ops; dev->type =ARPHRD_VOID ; dev->mtu =1500 ; + dev->min_mtu =68 ; + dev->max_mtu =65535 ; dev->tx_queue_len =100 ; dev->flags =IFF_NOARP ; dev->hard_header_len =LL_MAX_HEADER ;
Signature · 1 line
2.10.0
PATCH v2 6/9 net: use core MTU range checking in virt drivers
In reply to Jarod Wilsonhyperv_net:
- set min/max_mtu, per Haiyang, after rndis_filter_device_add
virtio_net:
- set min/max_mtu
- remove virtnet_change_mtu
vmxnet3:
- set min/max_mtu
xen-netback:
- min_mtu = 0, max_mtu = 65517
xen-netfront:
- min_mtu = 0, max_mtu = 65535
unisys/visor:
- clean up defines a little to not clash with network core or add redundat definitions
--- drivers/net/hyperv/hyperv_net.h | 4 ++-- drivers/net/hyperv/netvsc_drv.c | 14 +++++++------- drivers/net/virtio_net.c | 23 ++++++++++------------- drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++++--- drivers/net/xen-netback/interface.c | 5 ++++- drivers/net/xen-netfront.c | 2 ++ drivers/staging/unisys/include/iochannel.h | 10 ++++------ drivers/staging/unisys/visornic/visornic_main.c | 4 ++-- 8 files changed, 35 insertions(+), 34 deletions(-)
drivers/net/hyperv/hyperv_net.h +2 -2
@@ -606,8 +606,8 @@ struct nvsp_message { } __packed; -#define NETVSC_MTU 65536 -#define NETVSC_MTU_MIN 68 +#define NETVSC_MTU 65535 +#define NETVSC_MTU_MIN ETH_MIN_MTU#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16)/* 16MB */ #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15)/* 15MB */
drivers/net/hyperv/netvsc_drv.c +7 -7
@@ -872,19 +872,12 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)struct netvsc_device *nvdev = ndevctx->nvdev;struct hv_device *hdev = ndevctx->device_ctx;struct netvsc_device_info device_info; -int limit =ETH_DATA_LEN ;u32 num_chn;int ret =0 ;if (ndevctx->start_remove || !nvdev || nvdev->destroy)return -ENODEV ; -if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) - limit =NETVSC_MTU -ETH_HLEN ; - -if (mtu <NETVSC_MTU_MIN || mtu > limit) -return -EINVAL ; - ret =netvsc_close (ndev);if (ret) goto out;
@@ -1402,6 +1395,13 @@ static int netvsc_probe(struct hv_device *dev,netif_set_real_num_tx_queues (net, nvdev->num_chn);netif_set_real_num_rx_queues (net, nvdev->num_chn); +/* MTU range: 68 - 1500 or 65521 */ + net->min_mtu =NETVSC_MTU_MIN ; +if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) + net->max_mtu =NETVSC_MTU -ETH_HLEN ; +else + net->max_mtu =ETH_DATA_LEN ; + ret =register_netdev (net);if (ret !=0 ) {pr_err ("Unable to register netdev.\n" );
drivers/net/virtio_net.c +10 -13
@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,
@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; } +#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU ETH_MAX_MTU +static int virtnet_probe (struct virtio_device *vdev) {int i, err;
@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,
@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu < dev->min_mtu || mtu > dev->max_mtu)__virtio_clear_bit (vdev,VIRTIO_NET_F_MTU ); +else + dev->mtu = mtu; }if (vi->any_header_sg)
drivers/net/vmxnet3/vmxnet3_drv.c +4 -3
@@ -2969,9 +2969,6 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)struct vmxnet3_adapter *adapter =netdev_priv (netdev);int err =0 ; -if (new_mtu <VMXNET3_MIN_MTU || new_mtu >VMXNET3_MAX_MTU ) -return -EINVAL ; - netdev->mtu = new_mtu;/*
@@ -3428,6 +3425,10 @@ vmxnet3_probe_device(struct pci_dev *pdev,vmxnet3_set_ethtool_ops (netdev); netdev->watchdog_timeo =5 *HZ ; +/* MTU range: 60 - 9000 */ + netdev->min_mtu =VMXNET3_MIN_MTU ; + netdev->max_mtu =VMXNET3_MAX_MTU ; +INIT_WORK (&adapter->work, vmxnet3_reset_work);set_bit (VMXNET3_STATE_BIT_QUIESCED , &adapter->state);
drivers/net/xen-netback/interface.c +4 -1
@@ -302,7 +302,7 @@ static int xenvif_close(struct net_device *dev)static int xenvif_change_mtu (struct net_device *dev,int mtu) {struct xenvif *vif =netdev_priv (dev); -int max = vif->can_sg ?65535 -VLAN_ETH_HLEN :ETH_DATA_LEN ; +int max = vif->can_sg ?ETH_MAX_MTU -VLAN_ETH_HLEN :ETH_DATA_LEN ;if (mtu > max)return -EINVAL ;
@@ -471,6 +471,9 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid, dev->tx_queue_len =XENVIF_QUEUE_LENGTH ; + dev->min_mtu =0 ; + dev->max_mtu =ETH_MAX_MTU -VLAN_ETH_HLEN ; +/* * Initialise a dummy MAC address. We choose the numerically * largest non-broadcast address to prevent the address getting
drivers/net/xen-netfront.c +2 -0
@@ -1329,6 +1329,8 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev) netdev->features |= netdev->hw_features; netdev->ethtool_ops = &xennet_ethtool_ops; + netdev->min_mtu =0 ; + netdev->max_mtu =XEN_NETIF_MAX_TX_SIZE ;SET_NETDEV_DEV (netdev, &dev->dev); np->netdev = netdev;
drivers/staging/unisys/include/iochannel.h +4 -6
@@ -113,12 +113,10 @@ enum net_types { }; -#define ETH_HEADER_SIZE 14/* size of ethernet header */ -#define ETH_MIN_DATA_SIZE 46/* minimum eth data size */ -#define ETH_MIN_PACKET_SIZE (ETH_HEADER_SIZE + ETH_MIN_DATA_SIZE) +#define ETH_MIN_PACKET_SIZE (ETH_HLEN + ETH_MIN_DATA_SIZE) -#define ETH_MAX_MTU 16384/* maximum data size */ +#define VISOR_ETH_MAX_MTU 16384/* maximum data size */ #ifndef MAX_MACADDR_LEN #define MAX_MACADDR_LEN 6/* number of bytes in MAC address */
@@ -288,7 +286,7 @@ struct net_pkt_xmt {int len;/* full length of data in the packet */ int num_frags;/* number of fragments in frags containing data */ struct phys_info frags[MAX_PHYS_INFO ];/* physical page information */ -char ethhdr[ETH_HEADER_SIZE ];/* the ethernet header */ +char ethhdr[ETH_HLEN ];/* the ethernet header */ struct {/* these are needed for csum at uisnic end */ u8 valid;/* 1 = struct is valid - else ignore */
@@ -323,7 +321,7 @@ struct net_pkt_xmtdone {*/ #define RCVPOST_BUF_SIZE 4032#define MAX_NET_RCV_CHAIN \ - ((ETH_MAX_MTU + ETH_HEADER_SIZE + RCVPOST_BUF_SIZE - 1) \ + ((VISOR_ETH_MAX_MTU + ETH_HLEN + RCVPOST_BUF_SIZE - 1) \ / RCVPOST_BUF_SIZE)struct net_pkt_rcvpost {
drivers/staging/unisys/visornic/visornic_main.c +2 -2
@@ -791,7 +791,7 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)* pointing to */ firstfraglen = skb->len - skb->data_len; -if (firstfraglen <ETH_HEADER_SIZE ) { +if (firstfraglen <ETH_HLEN ) {spin_unlock_irqrestore (&devdata->priv_lock, flags); devdata->busy_cnt++; dev_err(&netdev->dev,
@@ -864,7 +864,7 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)/* copy ethernet header from first frag into ocmdrsp * - everything else will be pass in frags & DMA'ed */ -memcpy (cmdrsp->net.xmt.ethhdr, skb->data,ETH_HEADER_SIZE ); +memcpy (cmdrsp->net.xmt.ethhdr, skb->data,ETH_HLEN );/* copy frags info - from skb->data we need to only provide access * beyond eth header */
Signature · 1 line
2.10.0
RE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Quoted 47 lines
-----Original Message-----
From: Jarod Wilson [mailto:[email protected]]
Sent: Thursday, October 20, 2016 1:55 PM
To: [email protected]
Cc: Jarod Wilson <[email protected]>; [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Michael S. Tsirkin <[email protected]>; Shrikrishna Khare <[email protected]>; VMware, Inc. <[email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>; David Kershner <[email protected]>
Subject: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
hyperv_net:
- set min/max_mtu, per Haiyang, afterrndis_filter_device_add
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuxen-netback:
-min_mtu= 0,max_mtu= 65517xen-netfront:
-min_mtu= 0,max_mtu= 65535unisys/visor:
- clean up defines a little to not clash with network core or add redundat definitionsCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>CC Wei Liu <[email protected]>CC Paul Durrant <[email protected]>CC David Kershner <[email protected]>Signed-off-by Jarod Wilson <[email protected]>
Quoted 1 line
---
The hv_netvsc changes look fine. Thanks.
Kershner, David A
Reviewed-byRE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Quoted 66 lines
-----Original Message-----
From: Haiyang Zhang [mailto:[email protected]]
Sent: Thursday, October 20, 2016 2:05 PM
To: Jarod Wilson <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; KY Srinivasan <[email protected]>; Michael S. Tsirkin <[email protected]>; Shrikrishna Khare <[email protected]>; VMware, Inc. <pv- [email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>; Kershner, David A <[email protected]>
Subject: RE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt driversQuoted 7 lines
-----Original Message-----
From: Jarod Wilson [mailto:[email protected]]
Sent: Thursday, October 20, 2016 1:55 PM
To: [email protected]
Cc: Jarod Wilson <[email protected]>; [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>;Michael S.
Quoted 1 line
Tsirkin <[email protected]>; Shrikrishna Khare <[email protected]>;
VMware,
Quoted 37 lines
Inc. <[email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>; David Kershner <[email protected]>
Subject: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
hyperv_net:
- set min/max_mtu, per Haiyang, afterrndis_filter_device_add
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuxen-netback:
-min_mtu= 0,max_mtu= 65517xen-netfront:
-min_mtu= 0,max_mtu= 65535unisys/visor:
- clean up defines a little to not clash with network core or add redundat definitionsCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>CC Wei Liu <[email protected]>CC Paul Durrant <[email protected]>CC David Kershner <[email protected]>Signed-off-by Jarod Wilson <[email protected]>Quoted 1 line
---
Quoted 4 lines
The
hv_netvscchanges look fine. Thanks.Reviewed-by Haiyang Zhang <[email protected]>
The visornic changes look good.
RE: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 47 lines
-----Original Message-----
From: Jarod Wilson [mailto:[email protected]]
Sent: Thursday, October 20, 2016 1:55 PM
To: [email protected]
Cc: Jarod Wilson <[email protected]>; [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Michael S. Tsirkin <[email protected]>; Shrikrishna Khare <[email protected]>; VMware, Inc. <[email protected]>; Wei Liu <[email protected]>; Paul Durrant <[email protected]>; David Kershner <[email protected]>
Subject: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
hyperv_net:
- set min/max_mtu, per Haiyang, afterrndis_filter_device_add
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuxen-netback:
-min_mtu= 0,max_mtu= 65517xen-netfront:
-min_mtu= 0,max_mtu= 65535unisys/visor:
- clean up defines a little to not clash with network core or add redundat definitionsCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>CC Wei Liu <[email protected]>CC Paul Durrant <[email protected]>CC David Kershner <[email protected]>Signed-off-by Jarod Wilson <[email protected]>
Quoted 1 line
---
The hv_netvsc changes look fine. Thanks.
Michael S. Tsirkin
maintainerRe: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 125 lines · Jarod Wilson
hyperv_net:
- set min/max_mtu, per Haiyang, afterrndis_filter_device_add
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtu
vmxnet3:
- set min/max_mtuxen-netback:
-min_mtu= 0,max_mtu= 65517xen-netfront:
-min_mtu= 0,max_mtu= 65535unisys/visor:
- clean up defines a little to not clash with network core or add redundat definitionsCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>CC Wei Liu <[email protected]>CC Paul Durrant <[email protected]>CC David Kershner <[email protected]>Signed-off-by Jarod Wilson <[email protected]>--- drivers/net/hyperv/hyperv_net.h | 4 ++-- drivers/net/hyperv/netvsc_drv.c | 14 +++++++------- drivers/net/virtio_net.c | 23 ++++++++++------------- drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++++--- drivers/net/xen-netback/interface.c | 5 ++++- drivers/net/xen-netfront.c | 2 ++ drivers/staging/unisys/include/iochannel.h | 10 ++++------ drivers/staging/unisys/visornic/visornic_main.c | 4 ++-- 8 files changed, 35 insertions(+), 34 deletions(-)drivers/net/hyperv/hyperv_net.h +2
-2@@ -606,8 +606,8 @@ struct nvsp_message { } __packed; -#define NETVSC_MTU 65536 -#define NETVSC_MTU_MIN 68 +#define NETVSC_MTU 65535 +#define NETVSC_MTU_MIN ETH_MIN_MTU#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16)/* 16MB */ #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15)/* 15MB */ drivers/net/hyperv/netvsc_drv.c +7
-7@@ -872,19 +872,12 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)struct netvsc_device *nvdev = ndevctx->nvdev;struct hv_device *hdev = ndevctx->device_ctx;struct netvsc_device_info device_info; -int limit =ETH_DATA_LEN ;u32 num_chn;int ret =0 ;if (ndevctx->start_remove || !nvdev || nvdev->destroy)return -ENODEV ; -if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) - limit =NETVSC_MTU -ETH_HLEN ; - -if (mtu <NETVSC_MTU_MIN || mtu > limit) -return -EINVAL ; - ret =netvsc_close (ndev);if (ret) goto out;@@ -1402,6 +1395,13 @@ static int netvsc_probe(struct hv_device *dev,netif_set_real_num_tx_queues (net, nvdev->num_chn);netif_set_real_num_rx_queues (net, nvdev->num_chn); +/* MTU range: 68 - 1500 or 65521 */ + net->min_mtu =NETVSC_MTU_MIN ; +if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) + net->max_mtu =NETVSC_MTU -ETH_HLEN ; +else + net->max_mtu =ETH_DATA_LEN ; + ret =register_netdev (net);if (ret !=0 ) {pr_err ("Unable to register netdev.\n" );drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 6 lines
drivers/net/virtio_net.c +3
-0@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; } +#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU ETH_MAX_MTU +
Can we drop these btw?
Quoted 15 lines
drivers/net/virtio_net.c +4
-0static int virtnet_probe (struct virtio_device *vdev) {int i, err;@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,
drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 1873
Quoted 5 lines
drivers/net/virtio_net.c +1
-1@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu < dev->min_mtu || mtu > dev->max_mtu)
In fact the > max_mtu branch does not make sense since a 16 bit value can't exceed MAX_MTU.
Quoted 128 lines
drivers/net/virtio_net.c +2
-0__virtio_clear_bit (vdev,VIRTIO_NET_F_MTU ); + else + dev->mtu = mtu; }if (vi->any_header_sg)drivers/net/vmxnet3/vmxnet3_drv.c +4
-3@@ -2969,9 +2969,6 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)struct vmxnet3_adapter *adapter =netdev_priv (netdev);int err =0 ; -if (new_mtu <VMXNET3_MIN_MTU || new_mtu >VMXNET3_MAX_MTU ) -return -EINVAL ; - netdev->mtu = new_mtu;/* @@ -3428,6 +3425,10 @@ vmxnet3_probe_device(struct pci_dev *pdev,vmxnet3_set_ethtool_ops (netdev); netdev->watchdog_timeo =5 *HZ ; +/* MTU range: 60 - 9000 */ + netdev->min_mtu =VMXNET3_MIN_MTU ; + netdev->max_mtu =VMXNET3_MAX_MTU ; +INIT_WORK (&adapter->work, vmxnet3_reset_work);set_bit (VMXNET3_STATE_BIT_QUIESCED , &adapter->state);drivers/net/xen-netback/interface.c +4
-1@@ -302,7 +302,7 @@ static int xenvif_close(struct net_device *dev)static int xenvif_change_mtu (struct net_device *dev,int mtu) {struct xenvif *vif =netdev_priv (dev); -int max = vif->can_sg ?65535 -VLAN_ETH_HLEN :ETH_DATA_LEN ; +int max = vif->can_sg ?ETH_MAX_MTU -VLAN_ETH_HLEN :ETH_DATA_LEN ;if (mtu > max)return -EINVAL ;@@ -471,6 +471,9 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid, dev->tx_queue_len =XENVIF_QUEUE_LENGTH ; + dev->min_mtu =0 ; + dev->max_mtu =ETH_MAX_MTU -VLAN_ETH_HLEN ; +/* * Initialise a dummy MAC address. We choose the numerically * largest non-broadcast address to prevent the address getting drivers/net/xen-netfront.c +2
-0@@ -1329,6 +1329,8 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev) netdev->features |= netdev->hw_features; netdev->ethtool_ops = &xennet_ethtool_ops; + netdev->min_mtu =0 ; + netdev->max_mtu =XEN_NETIF_MAX_TX_SIZE ;SET_NETDEV_DEV (netdev, &dev->dev); np->netdev = netdev;drivers/staging/unisys/include/iochannel.h +4
-6@@ -113,12 +113,10 @@ enum net_types { }; -#define ETH_HEADER_SIZE 14/* size of ethernet header */ -#define ETH_MIN_DATA_SIZE 46/* minimum eth data size */ -#define ETH_MIN_PACKET_SIZE (ETH_HEADER_SIZE + ETH_MIN_DATA_SIZE) +#define ETH_MIN_PACKET_SIZE (ETH_HLEN + ETH_MIN_DATA_SIZE) -#define ETH_MAX_MTU 16384/* maximum data size */ +#define VISOR_ETH_MAX_MTU 16384/* maximum data size */ #ifndef MAX_MACADDR_LEN #define MAX_MACADDR_LEN 6/* number of bytes in MAC address */ @@ -288,7 +286,7 @@ struct net_pkt_xmt {int len;/* full length of data in the packet */ int num_frags;/* number of fragments in frags containing data */ struct phys_info frags[MAX_PHYS_INFO ];/* physical page information */ -char ethhdr[ETH_HEADER_SIZE ];/* the ethernet header */ +char ethhdr[ETH_HLEN ];/* the ethernet header */ struct {/* these are needed for csum at uisnic end */ u8 valid;/* 1 = struct is valid - else ignore */ @@ -323,7 +321,7 @@ struct net_pkt_xmtdone {*/ #define RCVPOST_BUF_SIZE 4032#define MAX_NET_RCV_CHAIN \ - ((ETH_MAX_MTU + ETH_HEADER_SIZE + RCVPOST_BUF_SIZE - 1) \ + ((VISOR_ETH_MAX_MTU + ETH_HLEN + RCVPOST_BUF_SIZE - 1) \ / RCVPOST_BUF_SIZE)struct net_pkt_rcvpost {drivers/staging/unisys/visornic/visornic_main.c +2
-2@@ -791,7 +791,7 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)* pointing to */ firstfraglen = skb->len - skb->data_len; -if (firstfraglen <ETH_HEADER_SIZE ) { +if (firstfraglen <ETH_HLEN ) {spin_unlock_irqrestore (&devdata->priv_lock, flags); devdata->busy_cnt++; dev_err(&netdev->dev,@@ -864,7 +864,7 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)/* copy ethernet header from first frag into ocmdrsp * - everything else will be pass in frags & DMA'ed */ -memcpy (cmdrsp->net.xmt.ethhdr, skb->data,ETH_HEADER_SIZE ); +memcpy (cmdrsp->net.xmt.ethhdr, skb->data,ETH_HLEN );/* copy frags info - from skb->data we need to only provide access * beyond eth header */ Signature · 1 line
2.10.0
Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Quoted 1 line · Michael S. Tsirkin
On Thu, Oct 20, 2016 at 01:55:21PM -0400, Jarod Wilson wrote:
...
Quoted 34 lines
Quoted 34 lines
drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; }
Quoted 5 lines
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 3 lines
drivers/net/virtio_net.c +3
-0+#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU ETH_MAX_MTU +Can we drop these btw?
Bah. Yeah. Should have just used them directly. I didn't add ETH_MAX_MTU until after doing the virtio_net changes, so I missed that.
Quoted 7 lines
Quoted 7 lines
drivers/net/virtio_net.c +0
-0static int virtnet_probe (struct virtio_device *vdev) {int i, err;@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features;
Quoted 16 lines
drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 1873
Quoted 13 lines
drivers/net/virtio_net.c +5
-1+/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu < dev->min_mtu || mtu > dev->max_mtu)In fact the >
max_mtubranch does not make sense since a 16 bit value can't exceedMAX_MTU.
Hm. mtu is declared as an int, not sure if there's any sort of type promotion to be worried about (not an area I know much/anything about). Certainly something that could be looked into as a minor optimization, though it's only in a probe path and shouldn't hurt anything, so ... meh?
Signature · 2 lines
Jarod Wilson [email protected]
Michael S. Tsirkin
maintainerRe: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Quoted 70 lines · Jarod Wilson
Quoted 1 line · Michael S. Tsirkin
On Thu, Oct 20, 2016 at 01:55:21PM -0400, Jarod Wilson wrote:
...
Quoted 34 lines
Quoted 34 lines
drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; }Quoted 5 lines
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 3 lines
drivers/net/virtio_net.c +3
-0+#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU ETH_MAX_MTU +Can we drop these btw?
Bah. Yeah. Should have just used them directly. I didn't add
ETH_MAX_MTUuntil after doing thevirtio_netchanges, so I missed that.Quoted 7 lines
Quoted 7 lines
drivers/net/virtio_net.c +0
-0static int virtnet_probe (struct virtio_device *vdev) {int i, err;@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features;Quoted 16 lines
drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 1873
Quoted 13 lines
drivers/net/virtio_net.c +5
-1+/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu < dev->min_mtu || mtu > dev->max_mtu)In fact the >
max_mtubranch does not make sense since a 16 bit value can't exceedMAX_MTU.
Quoted 2 lines
Hm. mtu is declared as an int, not sure if there's any sort of type promotion to be worried about (not an area I know much/anything about).
Not by design, that's for sure.
Quoted 2 lines
Certainly something that could be looked into as a minor optimization, though it's only in a probe path and shouldn't hurt anything, so ... meh?
Right. Aaron said he's working on a patch that essentially does dev->max_mtu = mtu after validation, so this part will look a bit silly there.
Quoted 3 lines
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
Quoted 71 lines · Michael S. Tsirkin
Quoted 70 lines · Jarod Wilson
Quoted 1 line · Michael S. Tsirkin
On Thu, Oct 20, 2016 at 01:55:21PM -0400, Jarod Wilson wrote:
...
Quoted 34 lines
Quoted 34 lines
drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; }Quoted 5 lines
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 3 lines
drivers/net/virtio_net.c +3
-0+#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU ETH_MAX_MTU +Can we drop these btw?
Bah. Yeah. Should have just used them directly. I didn't add
ETH_MAX_MTUuntil after doing thevirtio_netchanges, so I missed that.Quoted 23 lines
Quoted 15 lines
drivers/net/virtio_net.c +4
-0static int virtnet_probe (struct virtio_device *vdev) {int i, err;@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 1873
Quoted 5 lines
drivers/net/virtio_net.c +1
-1@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu < dev->min_mtu || mtu > dev->max_mtu)In fact the >
max_mtubranch does not make sense since a 16 bit value can't exceedMAX_MTU.
Quoted 4 lines
Quoted 2 lines
Hm. mtu is declared as an int, not sure if there's any sort of type promotion to be worried about (not an area I know much/anything about).
Not by design, that's for sure.
If you're really worried, we could declare it as a u16. The value returned from virtio_cread16 is type u16, and there are no type promotion rules I'm aware of that would do the wrong thing there.
Quoted 6 lines
Quoted 2 lines
Certainly something that could be looked into as a minor optimization, though it's only in a probe path and shouldn't hurt anything, so ... meh?
Right. Aaron said he's working on a patch that essentially does
dev->max_mtu= mtu after validation, so this part will look a bit silly there.
Agreed, but I can do that in my patch if you don't want the extra churn.
-Aaron
Michael S. Tsirkin
maintainerRe: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 125 lines · Jarod Wilson
hyperv_net:
- set min/max_mtu, per Haiyang, afterrndis_filter_device_add
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtu
vmxnet3:
- set min/max_mtuxen-netback:
-min_mtu= 0,max_mtu= 65517xen-netfront:
-min_mtu= 0,max_mtu= 65535unisys/visor:
- clean up defines a little to not clash with network core or add redundat definitionsCC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>CC Wei Liu <[email protected]>CC Paul Durrant <[email protected]>CC David Kershner <[email protected]>Signed-off-by Jarod Wilson <[email protected]>--- drivers/net/hyperv/hyperv_net.h | 4 ++-- drivers/net/hyperv/netvsc_drv.c | 14 +++++++------- drivers/net/virtio_net.c | 23 ++++++++++------------- drivers/net/vmxnet3/vmxnet3_drv.c | 7 ++++--- drivers/net/xen-netback/interface.c | 5 ++++- drivers/net/xen-netfront.c | 2 ++ drivers/staging/unisys/include/iochannel.h | 10 ++++------ drivers/staging/unisys/visornic/visornic_main.c | 4 ++-- 8 files changed, 35 insertions(+), 34 deletions(-)drivers/net/hyperv/hyperv_net.h +2
-2@@ -606,8 +606,8 @@ struct nvsp_message { } __packed; -#define NETVSC_MTU 65536 -#define NETVSC_MTU_MIN 68 +#define NETVSC_MTU 65535 +#define NETVSC_MTU_MIN ETH_MIN_MTU#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16)/* 16MB */ #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15)/* 15MB */ drivers/net/hyperv/netvsc_drv.c +7
-7@@ -872,19 +872,12 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)struct netvsc_device *nvdev = ndevctx->nvdev;struct hv_device *hdev = ndevctx->device_ctx;struct netvsc_device_info device_info; -int limit =ETH_DATA_LEN ;u32 num_chn;int ret =0 ;if (ndevctx->start_remove || !nvdev || nvdev->destroy)return -ENODEV ; -if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) - limit =NETVSC_MTU -ETH_HLEN ; - -if (mtu <NETVSC_MTU_MIN || mtu > limit) -return -EINVAL ; - ret =netvsc_close (ndev);if (ret) goto out;@@ -1402,6 +1395,13 @@ static int netvsc_probe(struct hv_device *dev,netif_set_real_num_tx_queues (net, nvdev->num_chn);netif_set_real_num_rx_queues (net, nvdev->num_chn); +/* MTU range: 68 - 1500 or 65521 */ + net->min_mtu =NETVSC_MTU_MIN ; +if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 ) + net->max_mtu =NETVSC_MTU -ETH_HLEN ; +else + net->max_mtu =ETH_DATA_LEN ; + ret =register_netdev (net);if (ret !=0 ) {pr_err ("Unable to register netdev.\n" );drivers/net/virtio_net.c +0
-12@@ -1419,17 +1419,6 @@ static const struct ethtool_ops virtnet_ethtool_ops = { .set_settings = virtnet_set_settings, }; -#define MIN_MTU 68 -#define MAX_MTU 65535 - -static int virtnet_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <MIN_MTU || new_mtu >MAX_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,@@ -1437,7 +1426,6 @@ static const struct net_device_ops virtnet_netdev = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = virtnet_set_mac_address, .ndo_set_rx_mode = virtnet_set_rx_mode, - .ndo_change_mtu = virtnet_change_mtu, .ndo_get_stats64 = virtnet_stats, .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
drivers/net/virtio_net.c static bool virtnet_validate_features(struct virtio_device *vdev) · line 1741
Quoted 6 lines
drivers/net/virtio_net.c +3
-0@@ -1748,6 +1736,9 @@ static bool virtnet_validate_features(struct virtio_device *vdev)return true; } +#define MIN_MTU ETH_MIN_MTU +#define MAX_MTU ETH_MAX_MTU +
Can we drop these btw?
Quoted 15 lines
drivers/net/virtio_net.c +4
-0static int virtnet_probe (struct virtio_device *vdev) {int i, err;@@ -1821,6 +1812,10 @@ static int virtnet_probe(struct virtio_device *vdev) dev->vlan_features = dev->features; +/* MTU range: 68 - 65535 */ + dev->min_mtu =MIN_MTU ; + dev->max_mtu =MAX_MTU ; +/* Configuration may specify what MAC to use. Otherwise random. */ if (virtio_has_feature (vdev,VIRTIO_NET_F_MAC )) virtio_cread_bytes(vdev,
drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 1873
Quoted 5 lines
drivers/net/virtio_net.c +1
-1@@ -1875,8 +1870,10 @@ static int virtnet_probe(struct virtio_device *vdev) mtu =virtio_cread16 (vdev, offsetof(struct virtio_net_config , mtu)); -if (virtnet_change_mtu (dev, mtu)) +if (mtu < dev->min_mtu || mtu > dev->max_mtu)
In fact the > max_mtu branch does not make sense since a 16 bit value can't exceed MAX_MTU.
Quoted 128 lines
drivers/net/virtio_net.c +2
-0__virtio_clear_bit (vdev,VIRTIO_NET_F_MTU ); + else + dev->mtu = mtu; }if (vi->any_header_sg)drivers/net/vmxnet3/vmxnet3_drv.c +4
-3@@ -2969,9 +2969,6 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)struct vmxnet3_adapter *adapter =netdev_priv (netdev);int err =0 ; -if (new_mtu <VMXNET3_MIN_MTU || new_mtu >VMXNET3_MAX_MTU ) -return -EINVAL ; - netdev->mtu = new_mtu;/* @@ -3428,6 +3425,10 @@ vmxnet3_probe_device(struct pci_dev *pdev,vmxnet3_set_ethtool_ops (netdev); netdev->watchdog_timeo =5 *HZ ; +/* MTU range: 60 - 9000 */ + netdev->min_mtu =VMXNET3_MIN_MTU ; + netdev->max_mtu =VMXNET3_MAX_MTU ; +INIT_WORK (&adapter->work, vmxnet3_reset_work);set_bit (VMXNET3_STATE_BIT_QUIESCED , &adapter->state);drivers/net/xen-netback/interface.c +4
-1@@ -302,7 +302,7 @@ static int xenvif_close(struct net_device *dev)static int xenvif_change_mtu (struct net_device *dev,int mtu) {struct xenvif *vif =netdev_priv (dev); -int max = vif->can_sg ?65535 -VLAN_ETH_HLEN :ETH_DATA_LEN ; +int max = vif->can_sg ?ETH_MAX_MTU -VLAN_ETH_HLEN :ETH_DATA_LEN ;if (mtu > max)return -EINVAL ;@@ -471,6 +471,9 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid, dev->tx_queue_len =XENVIF_QUEUE_LENGTH ; + dev->min_mtu =0 ; + dev->max_mtu =ETH_MAX_MTU -VLAN_ETH_HLEN ; +/* * Initialise a dummy MAC address. We choose the numerically * largest non-broadcast address to prevent the address getting drivers/net/xen-netfront.c +2
-0@@ -1329,6 +1329,8 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev) netdev->features |= netdev->hw_features; netdev->ethtool_ops = &xennet_ethtool_ops; + netdev->min_mtu =0 ; + netdev->max_mtu =XEN_NETIF_MAX_TX_SIZE ;SET_NETDEV_DEV (netdev, &dev->dev); np->netdev = netdev;drivers/staging/unisys/include/iochannel.h +4
-6@@ -113,12 +113,10 @@ enum net_types { }; -#define ETH_HEADER_SIZE 14/* size of ethernet header */ -#define ETH_MIN_DATA_SIZE 46/* minimum eth data size */ -#define ETH_MIN_PACKET_SIZE (ETH_HEADER_SIZE + ETH_MIN_DATA_SIZE) +#define ETH_MIN_PACKET_SIZE (ETH_HLEN + ETH_MIN_DATA_SIZE) -#define ETH_MAX_MTU 16384/* maximum data size */ +#define VISOR_ETH_MAX_MTU 16384/* maximum data size */ #ifndef MAX_MACADDR_LEN #define MAX_MACADDR_LEN 6/* number of bytes in MAC address */ @@ -288,7 +286,7 @@ struct net_pkt_xmt {int len;/* full length of data in the packet */ int num_frags;/* number of fragments in frags containing data */ struct phys_info frags[MAX_PHYS_INFO ];/* physical page information */ -char ethhdr[ETH_HEADER_SIZE ];/* the ethernet header */ +char ethhdr[ETH_HLEN ];/* the ethernet header */ struct {/* these are needed for csum at uisnic end */ u8 valid;/* 1 = struct is valid - else ignore */ @@ -323,7 +321,7 @@ struct net_pkt_xmtdone {*/ #define RCVPOST_BUF_SIZE 4032#define MAX_NET_RCV_CHAIN \ - ((ETH_MAX_MTU + ETH_HEADER_SIZE + RCVPOST_BUF_SIZE - 1) \ + ((VISOR_ETH_MAX_MTU + ETH_HLEN + RCVPOST_BUF_SIZE - 1) \ / RCVPOST_BUF_SIZE)struct net_pkt_rcvpost {drivers/staging/unisys/visornic/visornic_main.c +2
-2@@ -791,7 +791,7 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)* pointing to */ firstfraglen = skb->len - skb->data_len; -if (firstfraglen <ETH_HEADER_SIZE ) { +if (firstfraglen <ETH_HLEN ) {spin_unlock_irqrestore (&devdata->priv_lock, flags); devdata->busy_cnt++; dev_err(&netdev->dev,@@ -864,7 +864,7 @@ visornic_xmit(struct sk_buff *skb, struct net_device *netdev)/* copy ethernet header from first frag into ocmdrsp * - everything else will be pass in frags & DMA'ed */ -memcpy (cmdrsp->net.xmt.ethhdr, skb->data,ETH_HEADER_SIZE ); +memcpy (cmdrsp->net.xmt.ethhdr, skb->data,ETH_HLEN );/* copy frags info - from skb->data we need to only provide access * beyond eth header */ Signature · 1 line
2.10.0
Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 20 lines · Jarod Wilson
hyperv_net:
- set min/max_mtu, per Haiyang, afterrndis_filter_device_add
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuxen-netback:
-min_mtu= 0,max_mtu= 65517xen-netfront:
-min_mtu= 0,max_mtu= 65535unisys/visor:
- clean up defines a little to not clash with network core or add redundat definitions
Quoted 11 lines
CC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>CC Wei Liu <[email protected]>CC Paul Durrant <[email protected]>CC David Kershner <[email protected]>Signed-off-by Jarod Wilson <[email protected]>
Re: [PATCH net-next v2 6/9] net: use core MTU range checking in virt drivers
In reply to Jarod WilsonQuoted 20 lines · Jarod Wilson
hyperv_net:
- set min/max_mtu, per Haiyang, afterrndis_filter_device_add
virtio_net:
- set min/max_mtu
- removevirtnet_change_mtuvmxnet3:
- set min/max_mtuxen-netback:
-min_mtu= 0,max_mtu= 65517xen-netfront:
-min_mtu= 0,max_mtu= 65535unisys/visor:
- clean up defines a little to not clash with network core or add redundat definitions
Quoted 11 lines
CC "K. Y. Srinivasan" <[email protected]>CC Haiyang Zhang <[email protected]>CC "Michael S. Tsirkin" <[email protected]>CC Shrikrishna Khare <[email protected]>CC "VMware, Inc." <[email protected]>CC Wei Liu <[email protected]>CC Paul Durrant <[email protected]>CC David Kershner <[email protected]>Signed-off-by Jarod Wilson <[email protected]>
PATCH v2 7/9 net: use core MTU range checking in misc drivers
In reply to Jarod Wilsonfirewire-net:
- set min/max_mtu
- remove fwnet_change_mtu
nes:
- set max_mtu
- clean up nes_netdev_change_mtu
xpnet:
- set min/max_mtu
- remove xpnet_dev_change_mtu
hippi:
- set min/max_mtu
- remove hippi_change_mtu
batman-adv:
- set max_mtu
- remove batadv_interface_change_mtu
- initialization is a little async, not 100% certain that max_mtu is set in the optimal place, don't have hardware to test with
rionet:
- set min/max_mtu
- remove rionet_change_mtu
slip:
- set min/max_mtu
- streamline sl_change_mtu
um/net_kern:
- remove pointless ndo_change_mtu
hsi/clients/ssi_protocol:
- use core MTU range checking
- remove now redundant ssip_pn_set_mtu
ipoib:
- set a default max MTU value
- Note: ipoib's actual max MTU can vary, depending on if the device is in connected mode or not, so we'll just set the max_mtu value to the max possible, and let the ndo_change_mtu function continue to validate any new MTU change requests with checks for CM or not. Note that ipoib has no min_mtu set, and thus, the network core's mtu > 0 check is the only lower bounds here.
mptlan:
- use net core MTU range checking
- remove now redundant mpt_lan_change_mtu
fddi:
- min_mtu = 21, max_mtu = 4470
- remove now redundant fddi_change_mtu (including export)
fjes:
- min_mtu = 8192, max_mtu = 65536
- The max_mtu value is actually one over IP_MAX_MTU here, but the idea is to get past the core net MTU range checks so fjes_change_mtu can validate a new MTU against what it supports (see fjes_support_mtu in fjes_hw.c)
hsr:
- min_mtu = 0 (calls ether_setup, max_mtu is 1500)
f_phonet:
- min_mtu = 6, max_mtu = 65541
u_ether:
- min_mtu = 14, max_mtu = 15412
phonet/pep-gprs:
- min_mtu = 576, max_mtu = 65530
- remove redundant gprs_set_mtu
--- arch/um/drivers/net_kern.c | 8 -------- drivers/firewire/net.c | 18 ++++-------------- drivers/hsi/clients/ssi_protocol.c | 14 ++++---------- drivers/infiniband/hw/nes/nes.c | 1 - drivers/infiniband/hw/nes/nes.h | 4 ++-- drivers/infiniband/hw/nes/nes_nic.c | 10 +++------- drivers/infiniband/ulp/ipoib/ipoib_main.c | 1 + drivers/message/fusion/mptlan.c | 15 ++++----------- drivers/misc/sgi-xp/xpnet.c | 21 ++++----------------- drivers/net/fddi/skfp/skfddi.c | 1 - drivers/net/fjes/fjes_main.c | 2 ++ drivers/net/hippi/rrunner.c | 1 - drivers/net/rionet.c | 15 +++------------ drivers/net/slip/slip.c | 11 +++++------ drivers/usb/gadget/function/f_phonet.c | 11 ++--------- drivers/usb/gadget/function/u_ether.c | 14 ++++---------- include/linux/fddidevice.h | 1 - include/linux/hippidevice.h | 1 - net/802/fddi.c | 11 ++--------- net/802/hippi.c | 14 ++------------ net/batman-adv/soft-interface.c | 13 +------------ net/hsr/hsr_device.c | 1 + net/phonet/pep-gprs.c | 12 ++---------- 23 files changed, 46 insertions(+), 154 deletions(-)
arch/um/drivers/net_kern.c +0 -8
@@ -256,13 +256,6 @@ static void uml_net_tx_timeout(struct net_device *dev)netif_wake_queue (dev); } -static int uml_net_change_mtu (struct net_device *dev,int new_mtu) -{ - dev->mtu = new_mtu; - -return 0 ; -} -#ifdef CONFIG_NET_POLL_CONTROLLER static void uml_net_poll_controller (struct net_device *dev) {
@@ -374,7 +367,6 @@ static const struct net_device_ops uml_netdev_ops = { .ndo_set_rx_mode = uml_net_set_multicast_list, .ndo_tx_timeout = uml_net_tx_timeout, .ndo_set_mac_address = eth_mac_addr, - .ndo_change_mtu = uml_net_change_mtu, .ndo_validate_addr = eth_validate_addr, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = uml_net_poll_controller,
drivers/firewire/net.c +4 -14
@@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)return NETDEV_TX_OK ; } -static int fwnet_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - net->mtu = new_mtu; -return 0 ; -} -static const struct ethtool_ops fwnet_ethtool_ops = { .get_link = ethtool_op_get_link, };
@@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = { .ndo_open = fwnet_open, .ndo_stop = fwnet_stop, .ndo_start_xmit = fwnet_tx, - .ndo_change_mtu = fwnet_change_mtu, };static void fwnet_init_dev (struct net_device *net)
@@ -1435,7 +1425,6 @@ static int fwnet_probe(struct fw_unit *unit,struct net_device *net;bool allocated_netdev = false;struct fwnet_device *dev; -unsigned max_mtu;int ret;union fwnet_hwaddr *ha;
@@ -1478,9 +1467,10 @@ static int fwnet_probe(struct fw_unit *unit,* Use the RFC 2734 default 1500 octets or the maximum payload * as initial MTU */ - max_mtu = (1 << (card->max_receive +1 )) - -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; - net->mtu =min (1500U , max_mtu); + net->max_mtu = (1 << (card->max_receive +1 )) + -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; + net->mtu =min (1500U , net->max_mtu); + net->min_mtu =ETH_MIN_MTU ;/* Set our hardware address while we're at it */ ha = (union fwnet_hwaddr *)net->dev_addr;
drivers/hsi/clients/ssi_protocol.c +4 -10
@@ -960,15 +960,6 @@ static int ssip_pn_stop(struct net_device *dev)return 0 ; } -static int ssip_pn_set_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu >SSIP_MAX_MTU || new_mtu <PHONET_MIN_MTU ) -return -EINVAL ; - dev->mtu = new_mtu; - -return 0 ; -} -static void ssip_xmit_work (struct work_struct *work) { struct ssi_protocol *ssi =
@@ -1060,7 +1051,6 @@ static const struct net_device_ops ssip_pn_ops = { .ndo_open = ssip_pn_open, .ndo_stop = ssip_pn_stop, .ndo_start_xmit = ssip_pn_xmit, - .ndo_change_mtu = ssip_pn_set_mtu, };static void ssip_pn_setup (struct net_device *dev)
@@ -1136,6 +1126,10 @@ static int ssi_protocol_probe(struct device *dev) goto out1; } +/* MTU range: 6 - 65535 */ + ssi->netdev->min_mtu =PHONET_MIN_MTU ; + ssi->netdev->max_mtu =SSIP_MAX_MTU ; +SET_NETDEV_DEV (ssi->netdev, dev);netif_carrier_off (ssi->netdev); err =register_netdev (ssi->netdev);
drivers/infiniband/hw/nes/nes.c +0 -1
@@ -65,7 +65,6 @@ MODULE_DESCRIPTION("NetEffect RNIC Low-level iWARP Driver");MODULE_LICENSE ("Dual BSD/GPL" );MODULE_VERSION (DRV_VERSION ); -int max_mtu =9000 ;int interrupt_mod_interval =0 ;/* Interoperability */
drivers/infiniband/hw/nes/nes.h +2 -2
@@ -83,6 +83,8 @@#define NES_FIRST_QPN 64#define NES_SW_CONTEXT_ALIGN 1024 +#define NES_MAX_MTU 9000 +#define NES_NIC_MAX_NICS 16#define NES_MAX_ARP_TABLE_SIZE 4096
@@ -169,8 +171,6 @@ do { \#include "nes_cm.h" #include "nes_mgt.h" -extern int max_mtu; -#define max_frame_len (max_mtu+ETH_HLEN)extern int interrupt_mod_interval;extern int nes_if_count;extern int mpa_version;
drivers/infiniband/hw/nes/nes_nic.c +3 -7
@@ -981,20 +981,16 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu) {struct nes_vnic *nesvnic =netdev_priv (netdev);struct nes_device *nesdev = nesvnic->nesdev; -int ret =0 ;u8 jumbomode =0 ;u32 nic_active;u32 nic_active_bit;u32 uc_all_active;u32 mc_all_active; -if ((new_mtu <ETH_ZLEN ) || (new_mtu > max_mtu)) -return -EINVAL ; - netdev->mtu = new_mtu; nesvnic->max_frame_size = new_mtu +VLAN_ETH_HLEN ; -if (netdev->mtu >1500 ) { +if (netdev->mtu >ETH_DATA_LEN ) { jumbomode=1 ; }nes_nic_init_timer_defaults (nesdev, jumbomode);
@@ -1020,7 +1016,7 @@ static int nes_netdev_change_mtu(struct net_device *netdev, int new_mtu)nes_write_indexed (nesdev,NES_IDX_NIC_UNICAST_ALL , nic_active); } -return ret; +return 0 ; }
@@ -1658,7 +1654,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev, netdev->watchdog_timeo =NES_TX_TIMEOUT ; netdev->irq = nesdev->pcidev->irq; - netdev->mtu =ETH_DATA_LEN ; + netdev->max_mtu =NES_MAX_MTU ; netdev->hard_header_len =ETH_HLEN ; netdev->addr_len =ETH_ALEN ; netdev->type =ARPHRD_ETHER ;
drivers/infiniband/ulp/ipoib/ipoib_main.c +1 -0
@@ -2017,6 +2017,7 @@ static struct net_device *ipoib_add_port(const char *format,/* MTU will be reset when mcast join happens */ priv->dev->mtu =IPOIB_UD_MTU (priv->max_ib_mtu); priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu; + priv->dev->max_mtu =IPOIB_CM_MTU ; priv->dev->neigh_priv_len =sizeof (struct ipoib_neigh );
drivers/message/fusion/mptlan.c +4 -11
@@ -549,16 +549,6 @@ mpt_lan_close(struct net_device *dev) }/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ -static int -mpt_lan_change_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <MPT_LAN_MIN_MTU ) || (new_mtu >MPT_LAN_MAX_MTU )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} - -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* Tx timeout handler. */ static void mpt_lan_tx_timeout (struct net_device *dev)
@@ -1304,7 +1294,6 @@ static const struct net_device_ops mpt_netdev_ops = { .ndo_open = mpt_lan_open, .ndo_stop = mpt_lan_close, .ndo_start_xmit = mpt_lan_sdu_send, - .ndo_change_mtu = mpt_lan_change_mtu, .ndo_tx_timeout = mpt_lan_tx_timeout, };
@@ -1375,6 +1364,10 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) dev->netdev_ops = &mpt_netdev_ops; dev->watchdog_timeo =MPT_LAN_TX_TIMEOUT ; +/* MTU range: 96 - 65280 */ + dev->min_mtu =MPT_LAN_MIN_MTU ; + dev->max_mtu =MPT_LAN_MAX_MTU ; + dlprintk((KERN_INFO MYNAM ": Finished registering dev " "and setting initial values\n"));
drivers/misc/sgi-xp/xpnet.c +4 -17
@@ -118,6 +118,8 @@ static DEFINE_SPINLOCK(xpnet_broadcast_lock);* now, the default is 64KB. */ #define XPNET_MAX_MTU (0x800000UL - L1_CACHE_BYTES) +/* 68 comes from min TCP+IP+MAC header */ +#define XPNET_MIN_MTU 68/* 32KB has been determined to be the ideal */ #define XPNET_DEF_MTU (0x8000UL)
@@ -330,22 +332,6 @@ xpnet_dev_stop(struct net_device *dev)return 0 ; } -static int -xpnet_dev_change_mtu (struct net_device *dev,int new_mtu) -{ -/* 68 comes from min TCP+IP+MAC header */ -if ((new_mtu <68 ) || (new_mtu >XPNET_MAX_MTU )) { -dev_err (xpnet,"ifconfig %s mtu %d failed; value must be " -"between 68 and %ld\n" , dev->name, new_mtu, -XPNET_MAX_MTU ); -return -EINVAL ; - } - - dev->mtu = new_mtu; -dev_dbg (xpnet,"ifconfig %s mtu set to %d\n" , dev->name, new_mtu); -return 0 ; -} -/* * Notification that the other end has received the message and * DMA'd the skb information. At this point, they are done with
@@ -519,7 +505,6 @@ static const struct net_device_ops xpnet_netdev_ops = { .ndo_open = xpnet_dev_open, .ndo_stop = xpnet_dev_stop, .ndo_start_xmit = xpnet_dev_hard_start_xmit, - .ndo_change_mtu = xpnet_dev_change_mtu, .ndo_tx_timeout = xpnet_dev_tx_timeout, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr,
@@ -555,6 +540,8 @@ xpnet_init(void) xpnet_device->netdev_ops = &xpnet_netdev_ops; xpnet_device->mtu =XPNET_DEF_MTU ; + xpnet_device->min_mtu =XPNET_MIN_MTU ; + xpnet_device->max_mtu =XPNET_MAX_MTU ;/* * Multicast assumes the LSB of the first octet is set for multicast
drivers/net/fddi/skfp/skfddi.c +0 -1
@@ -166,7 +166,6 @@ static const struct net_device_ops skfp_netdev_ops = { .ndo_stop = skfp_close, .ndo_start_xmit = skfp_send_pkt, .ndo_get_stats = skfp_ctl_get_stats, - .ndo_change_mtu = fddi_change_mtu, .ndo_set_rx_mode = skfp_ctl_set_multicast_list, .ndo_set_mac_address = skfp_ctl_set_mac_address, .ndo_do_ioctl = skfp_ioctl,
drivers/net/fjes/fjes_main.c +2 -0
@@ -1316,6 +1316,8 @@ static void fjes_netdev_setup(struct net_device *netdev) netdev->netdev_ops = &fjes_netdev_ops;fjes_set_ethtool_ops (netdev); netdev->mtu = fjes_support_mtu[3 ]; + netdev->min_mtu = fjes_support_mtu[0 ]; + netdev->max_mtu = fjes_support_mtu[3 ]; netdev->flags |=IFF_BROADCAST ; netdev->features |=NETIF_F_HW_CSUM |NETIF_F_HW_VLAN_CTAG_FILTER ; }
drivers/net/hippi/rrunner.c +0 -1
@@ -68,7 +68,6 @@ static const struct net_device_ops rr_netdev_ops = { .ndo_stop = rr_close, .ndo_do_ioctl = rr_ioctl, .ndo_start_xmit = rr_start_xmit, - .ndo_change_mtu = hippi_change_mtu, .ndo_set_mac_address = hippi_mac_addr, };
drivers/net/rionet.c +3 -12
@@ -466,17 +466,6 @@ static void rionet_set_msglevel(struct net_device *ndev, u32 value) rnet->msg_enable = value; } -static int rionet_change_mtu (struct net_device *ndev,int new_mtu) -{ -if ((new_mtu <68 ) || (new_mtu >RIONET_MAX_MTU )) { -printk (KERN_ERR "%s: Invalid MTU size %d\n" , - ndev->name, new_mtu); -return -EINVAL ; - } - ndev->mtu = new_mtu; -return 0 ; -} -static const struct ethtool_ops rionet_ethtool_ops = { .get_drvinfo = rionet_get_drvinfo, .get_msglevel = rionet_get_msglevel,
@@ -488,7 +477,6 @@ static const struct net_device_ops rionet_netdev_ops = { .ndo_open = rionet_open, .ndo_stop = rionet_close, .ndo_start_xmit = rionet_start_xmit, - .ndo_change_mtu = rionet_change_mtu, .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = eth_mac_addr, };
@@ -525,6 +513,9 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev) ndev->netdev_ops = &rionet_netdev_ops; ndev->mtu =RIONET_MAX_MTU ; +/* MTU range: 68 - 4082 */ + ndev->min_mtu =ETH_MIN_MTU ; + ndev->max_mtu =RIONET_MAX_MTU ; ndev->features =NETIF_F_LLTX ;SET_NETDEV_DEV (ndev, &mport->dev); ndev->ethtool_ops = &rionet_ethtool_ops;
drivers/net/slip/slip.c +5 -6
@@ -561,12 +561,7 @@ static int sl_change_mtu(struct net_device *dev, int new_mtu) {struct slip *sl =netdev_priv (dev); -if (new_mtu <68 || new_mtu >65534 ) -return -EINVAL ; - -if (new_mtu != dev->mtu) -return sl_realloc_bufs (sl, new_mtu); -return 0 ; +return sl_realloc_bufs (sl, new_mtu); }/* Netdevice get statistics request */
@@ -663,6 +658,10 @@ static void sl_setup(struct net_device *dev) dev->addr_len =0 ; dev->tx_queue_len =10 ; +/* MTU range: 68 - 65534 */ + dev->min_mtu =68 ; + dev->max_mtu =65534 ; +/* New-style flags. */ dev->flags =IFF_NOARP |IFF_POINTOPOINT |IFF_MULTICAST ; }
drivers/usb/gadget/function/f_phonet.c +2 -9
@@ -261,19 +261,10 @@ static int pn_net_xmit(struct sk_buff *skb, struct net_device *dev)return NETDEV_TX_OK ; } -static int pn_net_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <PHONET_MIN_MTU ) || (new_mtu >PHONET_MAX_MTU )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops pn_netdev_ops = { .ndo_open = pn_net_open, .ndo_stop = pn_net_close, .ndo_start_xmit = pn_net_xmit, - .ndo_change_mtu = pn_net_mtu, };static void pn_net_setup (struct net_device *dev)
@@ -282,6 +273,8 @@ static void pn_net_setup(struct net_device *dev) dev->type =ARPHRD_PHONET ; dev->flags =IFF_POINTOPOINT |IFF_NOARP ; dev->mtu =PHONET_DEV_MTU ; + dev->min_mtu =PHONET_MIN_MTU ; + dev->max_mtu =PHONET_MAX_MTU ; dev->hard_header_len =1 ; dev->dev_addr[0 ] =PN_MEDIA_USB ; dev->addr_len =1 ;
drivers/usb/gadget/function/u_ether.c +4 -10
@@ -142,15 +142,6 @@ static inline int qlen(struct usb_gadget *gadget, unsigned qmult)/* NETWORK DRIVER HOOKUP (to the layer above this driver) */ -static int ueth_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu <=ETH_HLEN || new_mtu >GETHER_MAX_ETH_FRAME_LEN ) -return -ERANGE ; - net->mtu = new_mtu; - -return 0 ; -} -static void eth_get_drvinfo (struct net_device *net,struct ethtool_drvinfo *p) {struct eth_dev *dev =netdev_priv (net);
@@ -736,7 +727,6 @@ static const struct net_device_ops eth_netdev_ops = { .ndo_open = eth_open, .ndo_stop = eth_stop, .ndo_start_xmit = eth_start_xmit, - .ndo_change_mtu = ueth_change_mtu, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, };
@@ -799,6 +789,10 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g, net->ethtool_ops = &ops; +/* MTU range: 14 - 15412 */ + net->min_mtu =ETH_HLEN ; + net->max_mtu =GETHER_MAX_ETH_FRAME_LEN ; + dev->gadget = g;SET_NETDEV_DEV (net, &g->dev);SET_NETDEV_DEVTYPE (net, &gadget_type);
include/linux/fddidevice.h +0 -1
@@ -26,7 +26,6 @@#ifdef __KERNEL____be16 fddi_type_trans (struct sk_buff *skb,struct net_device *dev); -int fddi_change_mtu (struct net_device *dev,int new_mtu);struct net_device *alloc_fddidev (int sizeof_priv);#endif
include/linux/hippidevice.h +0 -1
@@ -32,7 +32,6 @@ struct hippi_cb { };__be16 hippi_type_trans (struct sk_buff *skb,struct net_device *dev); -int hippi_change_mtu (struct net_device *dev,int new_mtu);int hippi_mac_addr (struct net_device *dev,void *p);int hippi_neigh_setup_dev (struct net_device *dev,struct neigh_parms *p);struct net_device *alloc_hippi_dev (int sizeof_priv);
net/802/fddi.c +2 -9
@@ -141,15 +141,6 @@ __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev)EXPORT_SYMBOL (fddi_type_trans); -int fddi_change_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <FDDI_K_SNAP_HLEN ) || (new_mtu >FDDI_K_SNAP_DLEN )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -EXPORT_SYMBOL (fddi_change_mtu); -static const struct header_ops fddi_header_ops = { .create = fddi_header, };
@@ -161,6 +152,8 @@ static void fddi_setup(struct net_device *dev) dev->type =ARPHRD_FDDI ; dev->hard_header_len =FDDI_K_SNAP_HLEN +3 ;/* Assume 802.2 SNAP hdr len + 3 pad bytes */ dev->mtu =FDDI_K_SNAP_DLEN ;/* Assume max payload of 802.2 SNAP frame */ + dev->min_mtu =FDDI_K_SNAP_HLEN ; + dev->max_mtu =FDDI_K_SNAP_DLEN ; dev->addr_len =FDDI_K_ALEN ; dev->tx_queue_len =100 ;/* Long queues on FDDI */ dev->flags =IFF_BROADCAST |IFF_MULTICAST ;
net/802/hippi.c +2 -12
@@ -116,18 +116,6 @@ __be16 hippi_type_trans(struct sk_buff *skb, struct net_device *dev)EXPORT_SYMBOL (hippi_type_trans); -int hippi_change_mtu (struct net_device *dev,int new_mtu) -{ -/* -* HIPPI's got these nice large MTUs. -*/ -if ((new_mtu <68 ) || (new_mtu >65280 )) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -EXPORT_SYMBOL (hippi_change_mtu); -/* * For HIPPI we will actually use the lower 4 bytes of the hardware * address as the I-FIELD rather than the actual hardware address.
@@ -174,6 +162,8 @@ static void hippi_setup(struct net_device *dev) dev->type =ARPHRD_HIPPI ; dev->hard_header_len =HIPPI_HLEN ; dev->mtu =65280 ; + dev->min_mtu =68 ; + dev->max_mtu =65280 ; dev->addr_len =HIPPI_ALEN ; dev->tx_queue_len =25 /* 5 */ ;memset (dev->broadcast,0xFF ,HIPPI_ALEN );
net/batman-adv/soft-interface.c +1 -12
@@ -158,17 +158,6 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)return 0 ; } -static int batadv_interface_change_mtu (struct net_device *dev,int new_mtu) -{ -/* check ranges */ -if ((new_mtu <68 ) || (new_mtu >batadv_hardif_min_mtu (dev))) -return -EINVAL ; - - dev->mtu = new_mtu; - -return 0 ; -} -/** * batadv_interface_set_rx_mode - set the rx mode of a device * @dev: registered network device to modify
@@ -920,7 +909,6 @@ static const struct net_device_ops batadv_netdev_ops = { .ndo_vlan_rx_add_vid = batadv_interface_add_vid, .ndo_vlan_rx_kill_vid = batadv_interface_kill_vid, .ndo_set_mac_address = batadv_interface_set_mac_addr, - .ndo_change_mtu = batadv_interface_change_mtu, .ndo_set_rx_mode = batadv_interface_set_rx_mode, .ndo_start_xmit = batadv_interface_tx, .ndo_validate_addr = eth_validate_addr,
@@ -987,6 +975,7 @@ struct net_device *batadv_softif_create(struct net *net, const char *name)dev_net_set (soft_iface, net); soft_iface->rtnl_link_ops = &batadv_link_ops; + soft_iface->max_mtu =batadv_hardif_min_mtu (soft_iface); ret =register_netdevice (soft_iface);if (ret <0 ) {
net/hsr/hsr_device.c +1 -0
@@ -398,6 +398,7 @@ void hsr_dev_setup(struct net_device *dev)random_ether_addr (dev->dev_addr);ether_setup (dev); + dev->min_mtu =0 ; dev->header_ops = &hsr_header_ops; dev->netdev_ops = &hsr_device_ops;SET_NETDEV_DEVTYPE (dev, &hsr_type);
net/phonet/pep-gprs.c +2 -10
@@ -217,20 +217,10 @@ static netdev_tx_t gprs_xmit(struct sk_buff *skb, struct net_device *dev)return NETDEV_TX_OK ; } -static int gprs_set_mtu (struct net_device *dev,int new_mtu) -{ -if ((new_mtu <576 ) || (new_mtu > (PHONET_MAX_MTU -11 ))) -return -EINVAL ; - - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops gprs_netdev_ops = { .ndo_open = gprs_open, .ndo_stop = gprs_close, .ndo_start_xmit = gprs_xmit, - .ndo_change_mtu = gprs_set_mtu, };static void gprs_setup (struct net_device *dev)
@@ -239,6 +229,8 @@ static void gprs_setup(struct net_device *dev) dev->type =ARPHRD_PHONET_PIPE ; dev->flags =IFF_POINTOPOINT |IFF_NOARP ; dev->mtu =GPRS_DEFAULT_MTU ; + dev->min_mtu =576 ; + dev->max_mtu = (PHONET_MAX_MTU -11 ); dev->hard_header_len =0 ; dev->addr_len =0 ; dev->tx_queue_len =10 ;
Signature · 1 line
2.10.0
Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
Signature · 2 lines
Rémi Denis-Courmont http://www.remlab.net/CV.pdf
Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
In reply to Jarod WilsonHi,
Quoted 3 lines · Jarod Wilson
hsi/clients/ssi_protocol:
- use core MTU range checking
- remove now redundantssip_pn_set_mtu
-- Sebastian
Sven Eckelmann
maintainerRe: [net-next,v2,7/9] net: use core MTU range checking in misc drivers
In reply to Jarod WilsonOn Donnerstag, 20. Oktober 2016 13:55:22 CEST Jarod Wilson wrote:
[...]
Quoted 5 lines
batman-adv:
- setmax_mtu
- removebatadv_interface_change_mtu
- initialization is a little async, not 100% certain thatmax_mtuis set in the optimal place, don't have hardware to test with
batman-adv is creating a virtual interface - so there are no hardware requirements (ok, ethernet compatible hardware - even when only virtual/emulated).
[...]
Quoted 31 lines
net/batman-adv/soft-interface.c +0
-12@@ -158,17 +158,6 @@ static int batadv_interface_set_mac_addr(struct net_device *dev, void *p)return 0 ; } -static int batadv_interface_change_mtu (struct net_device *dev,int new_mtu) -{ -/* check ranges */ -if ((new_mtu <68 ) || (new_mtu >batadv_hardif_min_mtu (dev))) -return -EINVAL ; - - dev->mtu = new_mtu; - -return 0 ; -} -/** * batadv_interface_set_rx_mode - set the rx mode of a device * @dev: registered network device to modify @@ -920,7 +909,6 @@ static const struct net_device_ops batadv_netdev_ops = { .ndo_vlan_rx_add_vid = batadv_interface_add_vid, .ndo_vlan_rx_kill_vid = batadv_interface_kill_vid, .ndo_set_mac_address = batadv_interface_set_mac_addr, - .ndo_change_mtu = batadv_interface_change_mtu, .ndo_set_rx_mode = batadv_interface_set_rx_mode, .ndo_start_xmit = batadv_interface_tx, .ndo_validate_addr = eth_validate_addr,
net/batman-adv/soft-interface.c struct net_device *batadv_softif_create(struct net *net, const char *name) · line 981
Quoted 7 lines
net/batman-adv/soft-interface.c +1
-0@@ -987,6 +975,7 @@ struct net_device *batadv_softif_create(struct net *net, const char *name)dev_net_set (soft_iface, net); soft_iface->rtnl_link_ops = &batadv_link_ops; + soft_iface->max_mtu =batadv_hardif_min_mtu (soft_iface); ret =register_netdevice (soft_iface);if (ret <0 ) {
This looks bogus to me. You are now setting max_mtu during initialization of the virtual interface. But at this time no slave interfaces were added to the master batman-adv interface. So the batadv_hardif_min_mtu will not return the correct value here. Especially if you don't have fragmentation enabled.
So this change looks like a bug to me
Kind regards,
Sven
Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
In reply to Jarod WilsonQuoted 3 lines · On Oct 20 Jarod Wilson wrote:
firewire-net:
- set min/max_mtu
- removefwnet_change_mtu
[...]
Quoted 2 lines
drivers/firewire/net.c +0
-0
[...]
Quoted 4 lines
drivers/firewire/net.c +0
-0@@ -1478,9 +1467,10 @@ static int fwnet_probe(struct fw_unit *unit,* Use the RFC 2734 default 1500 octets or the maximum payload * as initial MTU */
drivers/firewire/net.c static int fwnet_probe(struct fw_unit *unit, · line 1476
Quoted 10 lines
drivers/firewire/net.c +4
-3- max_mtu = (1 << (card->max_receive +1 )) - -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; - net->mtu =min (1500U , max_mtu); + net->max_mtu = (1 << (card->max_receive +1 )) + -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; + net->mtu =min (1500U , net->max_mtu); + net->min_mtu =ETH_MIN_MTU ;/* Set our hardware address while we're at it */ ha = (union fwnet_hwaddr *)net->dev_addr;
Please preserve the current behavior, i.e. do not enforce any particular upper bound. (Especially none based on the local link layer controller's max_receive parameter.)
BTW, after having read RFC 2734, RFC 3146, and the code, I am convinced that net->mtu should be initialized to 1500, not less. But such a change should be done in a separate patch.
Signature · 3 lines
Stefan Richter -======----- =-=- =-==- http://arcgraph.de/sr/
Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
Adding Cc: linux1394-devel, dropping several Ccs, no additional comment.
Quoted 61 lines · On Oct 22 Stefan Richter wrote:
Quoted 3 lines · On Oct 20 Jarod Wilson wrote:
firewire-net:
- set min/max_mtu
- removefwnet_change_mtu[...]
Quoted 38 lines
drivers/firewire/net.c +0
-11@@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net) return NETDEV_TX_OK; } -static int fwnet_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - net->mtu = new_mtu; -return 0 ; -} -static const struct ethtool_ops fwnet_ethtool_ops = { .get_link = ethtool_op_get_link, };@@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = { .ndo_open = fwnet_open, .ndo_stop = fwnet_stop, .ndo_start_xmit = fwnet_tx, - .ndo_change_mtu = fwnet_change_mtu, };static void fwnet_init_dev (struct net_device *net)@@ -1435,7 +1425,6 @@ static int fwnet_probe(struct fw_unit *unit,struct net_device *net;bool allocated_netdev = false;struct fwnet_device *dev; -unsigned max_mtu;int ret;union fwnet_hwaddr *ha;@@ -1478,9 +1467,10 @@ static int fwnet_probe(struct fw_unit *unit,* Use the RFC 2734 default 1500 octets or the maximum payload * as initial MTU */ drivers/firewire/net.c static int fwnet_probe(struct fw_unit *unit, · line 1476
Quoted 10 lines
drivers/firewire/net.c +4
-3- max_mtu = (1 << (card->max_receive +1 )) - -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; - net->mtu =min (1500U , max_mtu); + net->max_mtu = (1 << (card->max_receive +1 )) + -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; + net->mtu =min (1500U , net->max_mtu); + net->min_mtu =ETH_MIN_MTU ;/* Set our hardware address while we're at it */ ha = (union fwnet_hwaddr *)net->dev_addr;Please preserve the current behavior, i.e. do not enforce any particular upper bound. (Especially none based on the local link layer controller's
max_receiveparameter.)BTW, after having read RFC 2734, RFC 3146, and the code, I am convinced that
net->mtushould be initialized to 1500, not less. But such a change should be done in a separate patch.
Signature · 3 lines
Stefan Richter -======----- =-=- =-==- http://arcgraph.de/sr/
Re: [PATCH net-next v2 7/9] net: use core MTU range checking in misc drivers
Quoted 64 lines · Stefan Richter
Adding Cc: linux1394-devel, dropping several Ccs, no additional comment.
Quoted 61 lines · On Oct 22 Stefan Richter wrote:
Quoted 3 lines · On Oct 20 Jarod Wilson wrote:
firewire-net:
- set min/max_mtu
- removefwnet_change_mtu[...]
Quoted 38 lines
drivers/firewire/net.c +0
-11@@ -1349,15 +1349,6 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net) return NETDEV_TX_OK; } -static int fwnet_change_mtu (struct net_device *net,int new_mtu) -{ -if (new_mtu <68 ) -return -EINVAL ; - - net->mtu = new_mtu; -return 0 ; -} -static const struct ethtool_ops fwnet_ethtool_ops = { .get_link = ethtool_op_get_link, };@@ -1366,7 +1357,6 @@ static const struct net_device_ops fwnet_netdev_ops = { .ndo_open = fwnet_open, .ndo_stop = fwnet_stop, .ndo_start_xmit = fwnet_tx, - .ndo_change_mtu = fwnet_change_mtu, };static void fwnet_init_dev (struct net_device *net)@@ -1435,7 +1425,6 @@ static int fwnet_probe(struct fw_unit *unit,struct net_device *net;bool allocated_netdev = false;struct fwnet_device *dev; -unsigned max_mtu;int ret;union fwnet_hwaddr *ha;@@ -1478,9 +1467,10 @@ static int fwnet_probe(struct fw_unit *unit,* Use the RFC 2734 default 1500 octets or the maximum payload * as initial MTU */ drivers/firewire/net.c static int fwnet_probe(struct fw_unit *unit, · line 1476
Quoted 10 lines
drivers/firewire/net.c +4
-3- max_mtu = (1 << (card->max_receive +1 )) - -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; - net->mtu =min (1500U , max_mtu); + net->max_mtu = (1 << (card->max_receive +1 )) + -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; + net->mtu =min (1500U , net->max_mtu); + net->min_mtu =ETH_MIN_MTU ;/* Set our hardware address while we're at it */ ha = (union fwnet_hwaddr *)net->dev_addr;Please preserve the current behavior, i.e. do not enforce any particular upper bound. (Especially none based on the local link layer controller's
max_receiveparameter.)BTW, after having read RFC 2734, RFC 3146, and the code, I am convinced that
net->mtushould be initialized to 1500, not less. But such a change should be done in a separate patch.
Okay, since it's already merged in net-next, I can do a follow-up patch here to set max_mtu to ETH_MAX_MTU (65535), which is the largest possible size the kernel can handle, so far as I can tell. But as long as I'm going to be in here, if we just want to use an initial mtu of 1500, I could clean that up at the same time, and entirely remove the max_mtu calculation stuff, if that's what you think is more correct here.
Signature · 2 lines
Jarod Wilson [email protected]
PATCH 1/2 firewire: net: fix maximum possible MTU
Commit b3e3893e1253 ("net: use core MTU range checking in misc drivers") mistakenly introduced an upper limit for firewire-net's MTU based on the local link layer controller's reception capability. Revert this. Neither RFC 2734 nor our implementation impose any particular upper limit.
Actually, to be on the safe side and to make the code explicit, set ETH_MAX_MTU = 65535 as upper limit now.
(I replaced sizeof(struct rfc2734_header) by the equivalent RFC2374_FRAG_HDR_SIZE in order to avoid distracting long/int conversions.)
--- drivers/firewire/net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/firewire/net.c +4 -3
@@ -1467,10 +1467,11 @@ static int fwnet_probe(struct fw_unit *unit,* Use the RFC 2734 default 1500 octets or the maximum payload * as initial MTU */ - net->max_mtu = (1 << (card->max_receive +1 )) - -sizeof (struct rfc2734_header ) -IEEE1394_GASP_HDR_SIZE ; - net->mtu =min (1500U , net->max_mtu); + net->mtu =min (1500U , + (1U << (card->max_receive +1 )) + -RFC2374_FRAG_HDR_SIZE -IEEE1394_GASP_HDR_SIZE ); net->min_mtu =ETH_MIN_MTU ; + net->max_mtu =ETH_MAX_MTU ;/* Set our hardware address while we're at it */ ha = (union fwnet_hwaddr *)net->dev_addr;
Signature · 3 lines
Stefan Richter -======----- =-=- =-=== http://arcgraph.de/sr/
PATCH 2/2 firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards
firewire-net, like the older eth1394 driver, reduced the initial MTU to less than 1500 octets if the local link layer controller's asynchronous packet reception limit was lower.
This is bogus, since this reception limit does not have anything to do with the transmission limit. Neither did this reduction affect the TX path positively, nor could it prevent link fragmentation at the RX path.
Many FireWire CardBus cards have a max_rec of 9, causing an initial MTU of 1024 - 16 = 1008. RFC 2734 and RFC 3146 allow a minimum max_rec = 8, which would result in an initial MTU of 512 - 16 = 496. On such cards, IPv6 could only be employed if the MTU was manually increased to 1280 or more, i.e. IPv6 would not work without intervention from userland.
We now always initialize the MTU to 1500, which is the default according to RFC 2734 and RFC 3146.
On a VIA VT6316 based CardBus card which was affected by this, changing the MTU from 1008 to 1500 also increases TX bandwidth by 6 %. RX remains unaffected.
--- drivers/firewire/net.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/firewire/net.c +1 -7
@@ -1463,13 +1463,7 @@ static int fwnet_probe(struct fw_unit *unit, goto out; dev->local_fifo = dev->handler.offset; -/* -* Use the RFC 2734 default 1500 octets or the maximum payload -* as initial MTU -*/ - net->mtu =min (1500U , - (1U << (card->max_receive +1 )) - -RFC2374_FRAG_HDR_SIZE -IEEE1394_GASP_HDR_SIZE ); + net->mtu =1500U ; net->min_mtu =ETH_MIN_MTU ; net->max_mtu =ETH_MAX_MTU ;
Signature · 7 lines
Stefan Richter -======----- =-=- =-=== http://arcgraph.de/sr/ ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Re: [PATCH net-next 2/2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards
Quoted 35 lines · Stefan Richter
firewire-net, like the older eth1394 driver, reduced the initial MTU to less than 1500 octets if the local link layer controller's asynchronous packet reception limit was lower.
This is bogus, since this reception limit does not have anything to do with the transmission limit. Neither did this reduction affect the TX path positively, nor could it prevent link fragmentation at the RX path.
Many FireWire CardBus cards have a
max_recof 9, causing an initial MTU of 1024 - 16 = 1008. RFC 2734 and RFC 3146 allow a minimummax_rec= 8, which would result in an initial MTU of 512 - 16 = 496. On such cards, IPv6 could only be employed if the MTU was manually increased to 1280 or more, i.e. IPv6 would not work without intervention from userland.We now always initialize the MTU to 1500, which is the default according to RFC 2734 and RFC 3146.
On a VIA VT6316 based CardBus card which was affected by this, changing the MTU from 1008 to 1500 also increases TX bandwidth by 6 %. RX remains unaffected.
CC Jarod Wilson <[email protected]>Signed-off-by Stefan Richter <[email protected]>--- drivers/firewire/net.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/firewire/net.c +0
-0@@ -1463,13 +1463,7 @@ static int fwnet_probe(struct fw_unit *unit, goto out;
drivers/firewire/net.c static int fwnet_probe(struct fw_unit *unit, · line 1466
Quoted 10 lines
drivers/firewire/net.c +1
-7dev->local_fifo = dev->handler.offset; -/* -* Use the RFC 2734 default 1500 octets or the maximum payload -* as initial MTU -*/ - net->mtu =min (1500U , - (1U << (card->max_receive +1 )) - -RFC2374_FRAG_HDR_SIZE -IEEE1394_GASP_HDR_SIZE ); + net->mtu =1500U ;
Should be able to do just net->mtu = ETH_DATA_LEN;
Signature · 2 lines
Jarod Wilson [email protected]
PATCH v2 2/2 firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards
firewire-net, like the older eth1394 driver, reduced the initial MTU to less than 1500 octets if the local link layer controller's asynchronous packet reception limit was lower.
This is bogus, since this reception limit does not have anything to do with the transmission limit. Neither did this reduction affect the TX path positively, nor could it prevent link fragmentation at the RX path.
Many FireWire CardBus cards have a max_rec of 9, causing an initial MTU of 1024 - 16 = 1008. RFC 2734 and RFC 3146 allow a minimum max_rec = 8, which would result in an initial MTU of 512 - 16 = 496. On such cards, IPv6 could only be employed if the MTU was manually increased to 1280 or more, i.e. IPv6 would not work without intervention from userland.
We now always initialize the MTU to 1500, which is the default according to RFC 2734 and RFC 3146.
On a VIA VT6316 based CardBus card which was affected by this, changing the MTU from 1008 to 1500 also increases TX bandwidth by 6 %. RX remains unaffected.
---
v2: use ETH_DATA_LEN, add comment
drivers/firewire/net.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/firewire/net.c +2 -7
@@ -1463,13 +1463,8 @@ static int fwnet_probe(struct fw_unit *unit, goto out; dev->local_fifo = dev->handler.offset; -/* -* Use the RFC 2734 default 1500 octets or the maximum payload -* as initial MTU -*/ - net->mtu =min (1500U , - (1U << (card->max_receive +1 )) - -RFC2374_FRAG_HDR_SIZE -IEEE1394_GASP_HDR_SIZE ); +/* MTU range: 68 - 65535, RFC 2734 default: 1500 */ + net->mtu =ETH_DATA_LEN ; net->min_mtu =ETH_MIN_MTU ; net->max_mtu =ETH_MAX_MTU ;
Signature · 12 lines
2.7.3 -- Stefan Richter -======----- =-=- ==--- http://arcgraph.de/sr/ ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Re: [PATCH net-next 2/2 v2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards
Quoted 21 lines · Stefan Richter
firewire-net, like the older eth1394 driver, reduced the initial MTU to less than 1500 octets if the local link layer controller's asynchronous packet reception limit was lower.
This is bogus, since this reception limit does not have anything to do with the transmission limit. Neither did this reduction affect the TX path positively, nor could it prevent link fragmentation at the RX path.
Many FireWire CardBus cards have a
max_recof 9, causing an initial MTU of 1024 - 16 = 1008. RFC 2734 and RFC 3146 allow a minimummax_rec= 8, which would result in an initial MTU of 512 - 16 = 496. On such cards, IPv6 could only be employed if the MTU was manually increased to 1280 or more, i.e. IPv6 would not work without intervention from userland.We now always initialize the MTU to 1500, which is the default according to RFC 2734 and RFC 3146.
On a VIA VT6316 based CardBus card which was affected by this, changing the MTU from 1008 to 1500 also increases TX bandwidth by 6 %. RX remains unaffected.
Quoted 6 lines
CC Jarod Wilson <[email protected]>Signed-off-by Stefan Richter <[email protected]>---
v2: useETH_DATA_LEN, add comment
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next 2/2] firewire: net: set initial MTU = 1500 unconditionally, fix IPv6 on some CardBus cards
In reply to Stefan RichterFrom: Stefan Richter <[email protected]>
Date: Sun, 23 Oct 2016 16:30:56 +0200
Quoted 17 lines
firewire-net, like the older eth1394 driver, reduced the initial MTU to less than 1500 octets if the local link layer controller's asynchronous packet reception limit was lower.
This is bogus, since this reception limit does not have anything to do with the transmission limit. Neither did this reduction affect the TX path positively, nor could it prevent link fragmentation at the RX path.
Many FireWire CardBus cards have a
max_recof 9, causing an initial MTU of 1024 - 16 = 1008. RFC 2734 and RFC 3146 allow a minimummax_rec= 8, which would result in an initial MTU of 512 - 16 = 496. On such cards, IPv6 could only be employed if the MTU was manually increased to 1280 or more, i.e. IPv6 would not work without intervention from userland.We now always initialize the MTU to 1500, which is the default according to RFC 2734 and RFC 3146.
Quoted 8 lines
On a VIA VT6316 based CardBus card which was affected by this, changing the MTU from 1008 to 1500 also increases TX bandwidth by 6 %. RX remains unaffected.
CC Jarod Wilson <[email protected]>Signed-off-by Stefan Richter <[email protected]>
Applied.
------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers Did the resurgence of CLI tooling catch you by surprise? Reconnect with the command line and become more productive. Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
PATCH 1/1 firewire: net: really fix maximum possible MTU
In reply to Stefan RichterThe maximum unicast datagram size /without/ link fragmentation is 4096 - 4 = 4092 (max IEEE 1394 async payload size at >= S800 bus speed, minus unfragmented encapssulation header). Max broadcast datagram size without fragmentation is 8 bytes less than that (due to GASP header).
The maximum datagram size /with/ link fragmentation is 0xfff = 4095 for unicast and broadcast. This is because the RFC 2734 fragment encapsulation header field for datagram size is only 12 bits wide.
--- drivers/firewire/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firewire/net.c +1 -1
@@ -1465,7 +1465,7 @@ static int fwnet_probe(struct fw_unit *unit, net->mtu =1500U ; net->min_mtu =ETH_MIN_MTU ; - net->max_mtu =ETH_MAX_MTU ; + net->max_mtu =0xfff ;/* Set our hardware address while we're at it */ ha = (union fwnet_hwaddr *)net->dev_addr;
Signature · 3 lines
Stefan Richter -======----- =-=- ===-= http://arcgraph.de/sr/
Re: [PATCH net-next] firewire: net: really fix maximum possible MTU
From: Stefan Richter <[email protected]>
Date: Sat, 29 Oct 2016 22:16:58 +0200
Quoted 11 lines
The maximum unicast datagram size /without/ link fragmentation is 4096 - 4 = 4092 (max IEEE 1394 async payload size at >= S800 bus speed, minus unfragmented encapssulation header). Max broadcast datagram size without fragmentation is 8 bytes less than that (due to GASP header).
The maximum datagram size /with/ link fragmentation is
0xfff= 4095 for unicast and broadcast. This is because the RFC 2734 fragment encapsulation header field for datagram size is only 12 bits wide.Fixes 5d48f00d836a('firewire: net: fix maximum possible MTU')Signed-off-by Stefan Richter <[email protected]>
Applied, thanks.
Re: [PATCH net-next 1/2] firewire: net: fix maximum possible MTU
In reply to Stefan RichterQuoted 8 lines · Stefan Richter
Commit
b3e3893e1253("net: use core MTU range checking in misc drivers") mistakenly introduced an upper limit for firewire-net's MTU based on the local link layer controller's reception capability. Revert this. Neither RFC 2734 nor our implementation impose any particular upper limit.Actually, to be on the safe side and to make the code explicit, set
ETH_MAX_MTU= 65535 as upper limit now.
Quoted 8 lines
(I replaced
sizeof(struct rfc2734_header)by the equivalentRFC2374_FRAG_HDR_SIZEin order to avoid distracting long/int conversions.)Fixes b3e3893e1253('net: use core MTU range checking in misc drivers')CC Jarod Wilson <[email protected]>Signed-off-by Stefan Richter <[email protected]>
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH net-next 1/2] firewire: net: fix maximum possible MTU
In reply to Stefan RichterFrom: Stefan Richter <[email protected]>
Date: Sun, 23 Oct 2016 16:29:03 +0200
Quoted 8 lines
Commit
b3e3893e1253("net: use core MTU range checking in misc drivers") mistakenly introduced an upper limit for firewire-net's MTU based on the local link layer controller's reception capability. Revert this. Neither RFC 2734 nor our implementation impose any particular upper limit.Actually, to be on the safe side and to make the code explicit, set
ETH_MAX_MTU= 65535 as upper limit now.
Quoted 8 lines
(I replaced
sizeof(struct rfc2734_header)by the equivalentRFC2374_FRAG_HDR_SIZEin order to avoid distracting long/int conversions.)Fixes b3e3893e1253('net: use core MTU range checking in misc drivers')CC Jarod Wilson <[email protected]>Signed-off-by Stefan Richter <[email protected]>
Applied.
------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers Did the resurgence of CLI tooling catch you by surprise? Reconnect with the command line and become more productive. Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
PATCH v2 8/9 s390/net: use net core MTU range checking
In reply to Jarod Wilsonctcm:
- min_mtu = 576, max_mtu = 65527
netiucv:
- min_mtu = 576, max_mtu = 65535
qeth:
- min_mtu = 64, max_mtu = 65535
--- drivers/s390/net/ctcm_main.c | 5 ++--- drivers/s390/net/netiucv.c | 24 ++---------------------- drivers/s390/net/qeth_core_main.c | 4 ---- drivers/s390/net/qeth_l2_main.c | 2 ++ drivers/s390/net/qeth_l3_main.c | 2 ++ 5 files changed, 8 insertions(+), 29 deletions(-)
drivers/s390/net/ctcm_main.c +2 -3
@@ -1032,9 +1032,6 @@ static int ctcm_change_mtu(struct net_device *dev, int new_mtu)struct ctcm_priv *priv;int max_bufsize; -if (new_mtu <576 || new_mtu >65527 ) -return -EINVAL ; - priv = dev->ml_priv; max_bufsize = priv->channel[CTCM_READ ]->max_bufsize;
@@ -1123,6 +1120,8 @@ void static ctcm_dev_setup(struct net_device *dev) dev->type =ARPHRD_SLIP ; dev->tx_queue_len =100 ; dev->flags =IFF_POINTOPOINT |IFF_NOARP ; + dev->min_mtu =576 ; + dev->max_mtu =65527 ; }/*
drivers/s390/net/netiucv.c +2 -22
@@ -1428,27 +1428,6 @@ static struct net_device_stats *netiucv_stats (struct net_device * dev)return &priv->stats; } -/** -* netiucv_change_mtu -* @dev: Pointer to interface struct. -* @new_mtu: The new MTU to use for this interface. -* -* Sets MTU of an interface. -* -* Returns 0 on success, -EINVAL if MTU is out of valid range. -* (valid range is 576 .. NETIUCV_MTU_MAX). -*/ -static int netiucv_change_mtu (struct net_device * dev,int new_mtu) -{ -IUCV_DBF_TEXT (trace,3 , __func__); -if (new_mtu <576 || new_mtu >NETIUCV_MTU_MAX ) { -IUCV_DBF_TEXT (setup,2 ,"given MTU out of valid range\n" ); -return -EINVAL ; - } - dev->mtu = new_mtu; -return 0 ; -} -/* * attributes in sysfs */
@@ -1986,12 +1965,13 @@ static const struct net_device_ops netiucv_netdev_ops = { .ndo_stop = netiucv_close, .ndo_get_stats = netiucv_stats, .ndo_start_xmit = netiucv_tx, - .ndo_change_mtu = netiucv_change_mtu, };static void netiucv_setup_netdevice (struct net_device *dev) { dev->mtu =NETIUCV_MTU_DEFAULT ; + dev->min_mtu =576 ; + dev->max_mtu =NETIUCV_MTU_MAX ; dev->destructor = netiucv_free_netdevice; dev->hard_header_len =NETIUCV_HDRLEN ; dev->addr_len =0 ;
drivers/s390/net/qeth_core_main.c +0 -4
@@ -4202,10 +4202,6 @@ int qeth_change_mtu(struct net_device *dev, int new_mtu)sprintf (dbf_text,"%8x" , new_mtu);QETH_CARD_TEXT (card,4 , dbf_text); -if (new_mtu <64 ) -return -EINVAL ; -if (new_mtu >65535 ) -return -EINVAL ;if ((!qeth_is_supported (card,IPA_IP_FRAGMENTATION )) && (!qeth_mtu_is_valid (card, new_mtu)))return -EINVAL ;
drivers/s390/net/qeth_l2_main.c +2 -0
@@ -1107,6 +1107,8 @@ static int qeth_l2_setup_netdev(struct qeth_card *card) card->dev->ml_priv = card; card->dev->watchdog_timeo =QETH_TX_TIMEOUT ; card->dev->mtu = card->info.initial_mtu; + card->dev->min_mtu =64 ; + card->dev->max_mtu =ETH_MAX_MTU ; card->dev->netdev_ops = &qeth_l2_netdev_ops; card->dev->ethtool_ops = (card->info.type != QETH_CARD_TYPE_OSN) ?
drivers/s390/net/qeth_l3_main.c +2 -0
@@ -3140,6 +3140,8 @@ static int qeth_l3_setup_netdev(struct qeth_card *card) card->dev->ml_priv = card; card->dev->watchdog_timeo =QETH_TX_TIMEOUT ; card->dev->mtu = card->info.initial_mtu; + card->dev->min_mtu =64 ; + card->dev->max_mtu =ETH_MAX_MTU ; card->dev->ethtool_ops = &qeth_l3_ethtool_ops; card->dev->features |=NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
Signature · 1 line
2.10.0
PATCH v2 9/9 ipv4/6: use core net MTU range checking
In reply to Jarod Wilsonipv4/ip_tunnel:
- min_mtu = 68, max_mtu = 0xFFF8 - dev->hard_header_len - t_hlen
- preserve all ndo_change_mtu checks for now to prevent regressions
ipv6/ip6_tunnel:
- min_mtu = 68, max_mtu = 0xFFF8 - dev->hard_header_len
- preserve all ndo_change_mtu checks for now to prevent regressions
ipv6/ip6_vti:
- min_mtu = 1280, max_mtu = 65535
- remove redundant vti6_change_mtu
ipv6/sit:
- min_mtu = 1280, max_mtu = 0xFFF8 - t_hlen
- remove redundant ipip6_tunnel_change_mtu
--- net/ipv4/ip_tunnel.c | 6 +++++- net/ipv6/ip6_tunnel.c | 4 +++- net/ipv6/ip6_vti.c | 21 ++------------------- net/ipv6/sit.c | 14 ++------------ 4 files changed, 12 insertions(+), 33 deletions(-)
net/ipv4/ip_tunnel.c +5 -1
@@ -358,6 +358,7 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net, {struct ip_tunnel *nt;struct net_device *dev; +int t_hlen;BUG_ON (!itn->fb_tunnel_dev); dev =__ip_tunnel_create (net, itn->fb_tunnel_dev->rtnl_link_ops, parms);
@@ -367,6 +368,9 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net, dev->mtu =ip_tunnel_bind_dev (dev); nt =netdev_priv (dev); + t_hlen = nt->hlen +sizeof (struct iphdr ); + dev->min_mtu =ETH_MIN_MTU ; + dev->max_mtu =0xFFF8 - dev->hard_header_len - t_hlen;ip_tunnel_add (itn, nt);return nt; }
@@ -929,7 +933,7 @@ int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict)int t_hlen = tunnel->hlen +sizeof (struct iphdr );int max_mtu =0xFFF8 - dev->hard_header_len - t_hlen; -if (new_mtu <68 ) +if (new_mtu <ETH_MIN_MTU )return -EINVAL ;if (new_mtu > max_mtu) {
net/ipv6/ip6_tunnel.c +3 -1
@@ -1634,7 +1634,7 @@ int ip6_tnl_change_mtu(struct net_device *dev, int new_mtu)struct ip6_tnl *tnl =netdev_priv (dev);if (tnl->parms.proto ==IPPROTO_IPIP ) { -if (new_mtu <68 ) +if (new_mtu <ETH_MIN_MTU )return -EINVAL ; }else {if (new_mtu <IPV6_MIN_MTU )
@@ -1787,6 +1787,8 @@ ip6_tnl_dev_init_gen(struct net_device *dev) dev->mtu =ETH_DATA_LEN - t_hlen;if (!(t->parms.flags &IP6_TNL_F_IGN_ENCAP_LIMIT )) dev->mtu -=8 ; + dev->min_mtu =ETH_MIN_MTU ; + dev->max_mtu =0xFFF8 - dev->hard_header_len;return 0 ;
net/ipv6/ip6_vti.c +2 -19
@@ -812,30 +812,11 @@ vti6_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)return err; } -/** -* vti6_tnl_change_mtu - change mtu manually for tunnel device -* @dev: virtual device associated with tunnel -* @new_mtu: the new mtu -* -* Return: -* 0 on success, -* %-EINVAL if mtu too small -**/ -static int vti6_change_mtu (struct net_device *dev,int new_mtu) -{ -if (new_mtu <IPV6_MIN_MTU ) -return -EINVAL ; - - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops vti6_netdev_ops = { .ndo_init = vti6_dev_init, .ndo_uninit = vti6_dev_uninit, .ndo_start_xmit = vti6_tnl_xmit, .ndo_do_ioctl = vti6_ioctl, - .ndo_change_mtu = vti6_change_mtu, .ndo_get_stats64 = ip_tunnel_get_stats64, .ndo_get_iflink = ip6_tnl_get_iflink, };
@@ -855,6 +836,8 @@ static void vti6_dev_setup(struct net_device *dev) dev->type =ARPHRD_TUNNEL6 ; dev->hard_header_len =LL_MAX_HEADER +sizeof (struct ipv6hdr ); dev->mtu =ETH_DATA_LEN ; + dev->min_mtu =IPV6_MIN_MTU ; + dev->max_mtu =IP_MAX_MTU ; dev->flags |=IFF_NOARP ; dev->addr_len =sizeof (struct in6_addr );netif_keep_dst (dev);
net/ipv6/sit.c +2 -12
@@ -1318,23 +1318,11 @@ ipip6_tunnel_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)return err; } -static int ipip6_tunnel_change_mtu (struct net_device *dev,int new_mtu) -{ -struct ip_tunnel *tunnel =netdev_priv (dev); -int t_hlen = tunnel->hlen +sizeof (struct iphdr ); - -if (new_mtu <IPV6_MIN_MTU || new_mtu >0xFFF8 - t_hlen) -return -EINVAL ; - dev->mtu = new_mtu; -return 0 ; -} -static const struct net_device_ops ipip6_netdev_ops = { .ndo_init = ipip6_tunnel_init, .ndo_uninit = ipip6_tunnel_uninit, .ndo_start_xmit = sit_tunnel_xmit, .ndo_do_ioctl = ipip6_tunnel_ioctl, - .ndo_change_mtu = ipip6_tunnel_change_mtu, .ndo_get_stats64 = ip_tunnel_get_stats64, .ndo_get_iflink = ip_tunnel_get_iflink, };
@@ -1365,6 +1353,8 @@ static void ipip6_tunnel_setup(struct net_device *dev) dev->type =ARPHRD_SIT ; dev->hard_header_len =LL_MAX_HEADER + t_hlen; dev->mtu =ETH_DATA_LEN - t_hlen; + dev->min_mtu =IPV6_MIN_MTU ; + dev->max_mtu =0xFFF8 - t_hlen; dev->flags =IFF_NOARP ;netif_keep_dst (dev); dev->addr_len =4 ;
Signature · 1 line
2.10.0
David Miller
maintainerFrom: Jarod Wilson <[email protected]>
Date: Thu, 20 Oct 2016 13:55:15 -0400
Quoted 11 lines
This stack of patches should get absolutely everything in the kernel converted from doing their own MTU range checking to the core MTU range checking. This second spin includes alterations to hopefully fix all concerns raised with the first, as well as including some additional changes to drivers and infrastructure where I completely missed necessary updates.
These have all been built through the 0-day build infrastructure via the (rebasing) master branch at https://github.com/jarodwilson/linux-muck, which at the time of the most recent compile across 147 configs, was based on net-next at commit
7b1536ef0aa0.
Series applied, hopefully this gets most of the fallout.
Thanks Jarod.