net: use core MTU range checking in WAN drivers
authorJarod Wilson <jarod@redhat.com>
Thu, 20 Oct 2016 17:55:19 +0000 (13:55 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Oct 2016 18:51:09 +0000 (14:51 -0400)
- 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

CC: netdev@vger.kernel.org
CC: Krzysztof Halasa <khc@pm.waw.pl>
CC: Krzysztof Halasa <khalasa@piap.pl>
CC: Jan "Yenya" Kasprzak <kas@fi.muni.cz>
CC: Francois Romieu <romieu@fr.zoreil.com>
CC: Kevin Curtis <kevin.curtis@farsite.co.uk>
CC: Zhao Qiang <qiang.zhao@nxp.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
22 files changed:
drivers/char/pcmcia/synclink_cs.c
drivers/net/wan/c101.c
drivers/net/wan/cosa.c
drivers/net/wan/dscc4.c
drivers/net/wan/farsync.c
drivers/net/wan/fsl_ucc_hdlc.c
drivers/net/wan/hdlc.c
drivers/net/wan/hdlc_fr.c
drivers/net/wan/hostess_sv11.c
drivers/net/wan/ixp4xx_hss.c
drivers/net/wan/lmc/lmc_main.c
drivers/net/wan/n2.c
drivers/net/wan/pc300too.c
drivers/net/wan/pci200syn.c
drivers/net/wan/sealevel.c
drivers/net/wan/wanxl.c
drivers/net/wan/x25_asy.c
drivers/tty/synclink.c
drivers/tty/synclink_gt.c
drivers/tty/synclinkmp.c
include/linux/hdlc.h
net/atm/lec.c

index d28922d..a7dd5f4 100644 (file)
@@ -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,
index 09a5075..2371e07 100644 (file)
@@ -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,
 };
index b87fe0a..087eb26 100644 (file)
@@ -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,
index 6292259..7351e54 100644 (file)
@@ -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,
index 3c9cbf9..03696d3 100644 (file)
@@ -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,
index 6564753..e38ce4d 100644 (file)
@@ -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,
 };
index 9bd4aa8..7221a53 100644 (file)
@@ -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 <khc@pm.waw.pl>");
 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);
index b6e0cfb..eb91528 100644 (file)
@@ -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;
 
index 3d74166..dd6bb33 100644 (file)
@@ -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,
 };
index e7bbdb7..6a505c2 100644 (file)
@@ -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,
 };
index 299140c..001b779 100644 (file)
@@ -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,
index 315bf09..c8f4517 100644 (file)
@@ -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,
 };
index db36385..e1dd1ec 100644 (file)
@@ -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,
 };
index e845562..4e437c5 100644 (file)
@@ -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,
 };
index 27860b4..fbb5aa2 100644 (file)
@@ -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,
 };
index a20d688..0c73175 100644 (file)
@@ -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,
index 1bc5e93..878b05d 100644 (file)
@@ -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;
index c13e27e..415885c 100644 (file)
@@ -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,
index 7aca2d4..8267bcf 100644 (file)
@@ -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,
index dec1565..d66620f 100644 (file)
@@ -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,
index e31bcd4..97585d9 100644 (file)
@@ -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);
 
index 5d26938..779b3fa 100644 (file)
@@ -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]);