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 d28922df01d754d88e91ca8d34054ce4375c0781..a7dd5f4f2c5a66a536e0cfd9e7a83a1a17255bfa 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 09a50751763b1990f1b778ef62051c06743675c2..2371e078afbbd57ac696467df456c6e55393baaf 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 b87fe0a01c69ff3bb53b609632f5016eb8806073..087eb266601fc81f4b62ee95008a7b2ece8353a4 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 6292259804634e0c6251e23dd8eb7213f16211fb..7351e5440ed78b74aa383de3d26ae74add0a4499 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 3c9cbf908ec73cd95a75d59a289eef5e68e5f414..03696d35ee9cce109812a8215c4e3b7d118764e5 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 65647533b4014844f1c0b0e7d5ab25b71e0b94ed..e38ce4da3efbf8af30c89556e8a896e1c5314bea 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 9bd4aa8083ce787cc93ed5cfe416175b8f2b7d24..7221a53b8b14444fc497a0b3eb5a86f8ece733a9 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 b6e0cfb095d35c716fbdc22c99a4907ca75b33c1..eb915281197efc98a0fae96cc9dcdd2691a21ee3 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 3d741663fd677a42eb2a3823e54412cf8afe7ee0..dd6bb3364ad2330ed662abbaaa192d9d24967f3d 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 e7bbdb7af53ac7dcbdd21d12705613054efe8626..6a505c26a3e74416c0461b677871a81e2b543041 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 299140c04556979b9fc75b2a43211b325c81243a..001b7796740dc3b6a78214cc42fb42978140ab44 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 315bf09d6a2026aea0068eee58b893ef1431fcae..c8f4517db3a0be3dbc82bc382b7941e2f8418158 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 db363856e0b52aff1a4f2f6d9ac4416ccd7d031b..e1dd1ec18d64c0a4eb6d16bd5c85d0dec485ee36 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 e8455621390e2abbb4d19f4e7b9a1a1950bcc810..4e437c599e9a5b9384dca958e4efa9395739e471 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 27860b4f59081a46f71ad4f5baa2f7605ef8e17c..fbb5aa2c4d8faf415c2463440f3adbfd5b0721c2 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 a20d688d259570467d83585962815f42be5bd38d..0c7317520ed396a2a2448a21b62e08cd1debdfc4 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 1bc5e93d2a342181503e85e2f2729d6e983dd31f..878b05d06fc7abc64450d8a46ef842d3375a8f0f 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 c13e27ecb0b7f441379dd6cec89ed084892fa057..415885c56435c0450149277b1e66f959f0def47e 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 7aca2d4670e4a3aaf3636acc5f8dd1c3f288bfd3..8267bcf2405ed5734af331a3437b8b8986303a1f 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 dec156586de1bdfcf9ed1439523a884267ff02df..d66620f7eaa3f1e94adcdf6310d730eed57d3d05 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 e31bcd4c7859e5d01405868090246f4f94a984a2..97585d9679f3de7f2dff7f46aa2cb377a63c219e 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 5d2693826afb6a84f8f614129bd9c4abf2824f9e..779b3fa6052d68648c3f8b7a8d3f85292be453e1 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]);