Skip to content

Commit 8b6b413

Browse files
jarodwilsondavem330
authored andcommitted
net: use core MTU range checking in WAN drivers
- 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: [email protected] CC: Krzysztof Halasa <[email protected]> CC: Krzysztof Halasa <[email protected]> CC: Jan "Yenya" Kasprzak <[email protected]> CC: Francois Romieu <[email protected]> CC: Kevin Curtis <[email protected]> CC: Zhao Qiang <[email protected]> Signed-off-by: Jarod Wilson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9c22b4a commit 8b6b413

File tree

22 files changed

+7
-42
lines changed

22 files changed

+7
-42
lines changed

drivers/char/pcmcia/synclink_cs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4248,7 +4248,6 @@ static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size)
42484248
static const struct net_device_ops hdlcdev_ops = {
42494249
.ndo_open = hdlcdev_open,
42504250
.ndo_stop = hdlcdev_close,
4251-
.ndo_change_mtu = hdlc_change_mtu,
42524251
.ndo_start_xmit = hdlc_start_xmit,
42534252
.ndo_do_ioctl = hdlcdev_ioctl,
42544253
.ndo_tx_timeout = hdlcdev_tx_timeout,

drivers/net/wan/c101.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ static void c101_destroy_card(card_t *card)
302302
static const struct net_device_ops c101_ops = {
303303
.ndo_open = c101_open,
304304
.ndo_stop = c101_close,
305-
.ndo_change_mtu = hdlc_change_mtu,
306305
.ndo_start_xmit = hdlc_start_xmit,
307306
.ndo_do_ioctl = c101_ioctl,
308307
};

drivers/net/wan/cosa.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ module_exit(cosa_exit);
432432
static const struct net_device_ops cosa_ops = {
433433
.ndo_open = cosa_net_open,
434434
.ndo_stop = cosa_net_close,
435-
.ndo_change_mtu = hdlc_change_mtu,
436435
.ndo_start_xmit = hdlc_start_xmit,
437436
.ndo_do_ioctl = cosa_net_ioctl,
438437
.ndo_tx_timeout = cosa_net_timeout,

drivers/net/wan/dscc4.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,6 @@ static inline int dscc4_set_quartz(struct dscc4_dev_priv *dpriv, int hz)
887887
static const struct net_device_ops dscc4_ops = {
888888
.ndo_open = dscc4_open,
889889
.ndo_stop = dscc4_close,
890-
.ndo_change_mtu = hdlc_change_mtu,
891890
.ndo_start_xmit = hdlc_start_xmit,
892891
.ndo_do_ioctl = dscc4_ioctl,
893892
.ndo_tx_timeout = dscc4_tx_timeout,

drivers/net/wan/farsync.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,6 @@ fst_init_card(struct fst_card_info *card)
23942394
static const struct net_device_ops fst_ops = {
23952395
.ndo_open = fst_open,
23962396
.ndo_stop = fst_close,
2397-
.ndo_change_mtu = hdlc_change_mtu,
23982397
.ndo_start_xmit = hdlc_start_xmit,
23992398
.ndo_do_ioctl = fst_ioctl,
24002399
.ndo_tx_timeout = fst_tx_timeout,

drivers/net/wan/fsl_ucc_hdlc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,6 @@ static const struct dev_pm_ops uhdlc_pm_ops = {
992992
static const struct net_device_ops uhdlc_ops = {
993993
.ndo_open = uhdlc_open,
994994
.ndo_stop = uhdlc_close,
995-
.ndo_change_mtu = hdlc_change_mtu,
996995
.ndo_start_xmit = hdlc_start_xmit,
997996
.ndo_do_ioctl = uhdlc_ioctl,
998997
};

drivers/net/wan/hdlc.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ static const char* version = "HDLC support module revision 1.22";
4646

4747
static struct hdlc_proto *first_proto;
4848

49-
int hdlc_change_mtu(struct net_device *dev, int new_mtu)
50-
{
51-
if ((new_mtu < 68) || (new_mtu > HDLC_MAX_MTU))
52-
return -EINVAL;
53-
dev->mtu = new_mtu;
54-
return 0;
55-
}
56-
5749
static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
5850
struct packet_type *p, struct net_device *orig_dev)
5951
{
@@ -237,6 +229,8 @@ static void hdlc_setup_dev(struct net_device *dev)
237229
dev->flags = IFF_POINTOPOINT | IFF_NOARP;
238230
dev->priv_flags = IFF_WAN_HDLC;
239231
dev->mtu = HDLC_MAX_MTU;
232+
dev->min_mtu = 68;
233+
dev->max_mtu = HDLC_MAX_MTU;
240234
dev->type = ARPHRD_RAWHDLC;
241235
dev->hard_header_len = 16;
242236
dev->addr_len = 0;
@@ -353,7 +347,6 @@ MODULE_AUTHOR("Krzysztof Halasa <[email protected]>");
353347
MODULE_DESCRIPTION("HDLC support module");
354348
MODULE_LICENSE("GPL v2");
355349

356-
EXPORT_SYMBOL(hdlc_change_mtu);
357350
EXPORT_SYMBOL(hdlc_start_xmit);
358351
EXPORT_SYMBOL(hdlc_open);
359352
EXPORT_SYMBOL(hdlc_close);

drivers/net/wan/hdlc_fr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,6 @@ static void pvc_setup(struct net_device *dev)
10531053
static const struct net_device_ops pvc_ops = {
10541054
.ndo_open = pvc_open,
10551055
.ndo_stop = pvc_close,
1056-
.ndo_change_mtu = hdlc_change_mtu,
10571056
.ndo_start_xmit = pvc_xmit,
10581057
.ndo_do_ioctl = pvc_ioctl,
10591058
};
@@ -1096,6 +1095,8 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
10961095
}
10971096
dev->netdev_ops = &pvc_ops;
10981097
dev->mtu = HDLC_MAX_MTU;
1098+
dev->min_mtu = 68;
1099+
dev->max_mtu = HDLC_MAX_MTU;
10991100
dev->priv_flags |= IFF_NO_QUEUE;
11001101
dev->ml_priv = pvc;
11011102

drivers/net/wan/hostess_sv11.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ static int hostess_attach(struct net_device *dev, unsigned short encoding,
180180
static const struct net_device_ops hostess_ops = {
181181
.ndo_open = hostess_open,
182182
.ndo_stop = hostess_close,
183-
.ndo_change_mtu = hdlc_change_mtu,
184183
.ndo_start_xmit = hdlc_start_xmit,
185184
.ndo_do_ioctl = hostess_ioctl,
186185
};

drivers/net/wan/ixp4xx_hss.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,6 @@ static int hss_hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
13211321
static const struct net_device_ops hss_hdlc_ops = {
13221322
.ndo_open = hss_hdlc_open,
13231323
.ndo_stop = hss_hdlc_close,
1324-
.ndo_change_mtu = hdlc_change_mtu,
13251324
.ndo_start_xmit = hdlc_start_xmit,
13261325
.ndo_do_ioctl = hss_hdlc_ioctl,
13271326
};

drivers/net/wan/lmc/lmc_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,6 @@ static int lmc_attach(struct net_device *dev, unsigned short encoding,
808808
static const struct net_device_ops lmc_ops = {
809809
.ndo_open = lmc_open,
810810
.ndo_stop = lmc_close,
811-
.ndo_change_mtu = hdlc_change_mtu,
812811
.ndo_start_xmit = hdlc_start_xmit,
813812
.ndo_do_ioctl = lmc_ioctl,
814813
.ndo_tx_timeout = lmc_driver_timeout,

drivers/net/wan/n2.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ static void n2_destroy_card(card_t *card)
330330
static const struct net_device_ops n2_ops = {
331331
.ndo_open = n2_open,
332332
.ndo_stop = n2_close,
333-
.ndo_change_mtu = hdlc_change_mtu,
334333
.ndo_start_xmit = hdlc_start_xmit,
335334
.ndo_do_ioctl = n2_ioctl,
336335
};

drivers/net/wan/pc300too.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ static void pc300_pci_remove_one(struct pci_dev *pdev)
291291
static const struct net_device_ops pc300_ops = {
292292
.ndo_open = pc300_open,
293293
.ndo_stop = pc300_close,
294-
.ndo_change_mtu = hdlc_change_mtu,
295294
.ndo_start_xmit = hdlc_start_xmit,
296295
.ndo_do_ioctl = pc300_ioctl,
297296
};

drivers/net/wan/pci200syn.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ static void pci200_pci_remove_one(struct pci_dev *pdev)
270270
static const struct net_device_ops pci200_ops = {
271271
.ndo_open = pci200_open,
272272
.ndo_stop = pci200_close,
273-
.ndo_change_mtu = hdlc_change_mtu,
274273
.ndo_start_xmit = hdlc_start_xmit,
275274
.ndo_do_ioctl = pci200_ioctl,
276275
};

drivers/net/wan/sealevel.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static int sealevel_attach(struct net_device *dev, unsigned short encoding,
174174
static const struct net_device_ops sealevel_ops = {
175175
.ndo_open = sealevel_open,
176176
.ndo_stop = sealevel_close,
177-
.ndo_change_mtu = hdlc_change_mtu,
178177
.ndo_start_xmit = hdlc_start_xmit,
179178
.ndo_do_ioctl = sealevel_ioctl,
180179
};

drivers/net/wan/wanxl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev)
551551
static const struct net_device_ops wanxl_ops = {
552552
.ndo_open = wanxl_open,
553553
.ndo_stop = wanxl_close,
554-
.ndo_change_mtu = hdlc_change_mtu,
555554
.ndo_start_xmit = hdlc_start_xmit,
556555
.ndo_do_ioctl = wanxl_ioctl,
557556
.ndo_get_stats = wanxl_get_stats,

drivers/net/wan/x25_asy.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
124124
unsigned char *xbuff, *rbuff;
125125
int len;
126126

127-
if (newmtu > 65534)
128-
return -EINVAL;
129-
130127
len = 2 * newmtu;
131128
xbuff = kmalloc(len + 4, GFP_ATOMIC);
132129
rbuff = kmalloc(len + 4, GFP_ATOMIC);
@@ -751,6 +748,8 @@ static void x25_asy_setup(struct net_device *dev)
751748
*/
752749

753750
dev->mtu = SL_MTU;
751+
dev->min_mtu = 0;
752+
dev->max_mtu = 65534;
754753
dev->netdev_ops = &x25_asy_netdev_ops;
755754
dev->watchdog_timeo = HZ*20;
756755
dev->hard_header_len = 0;

drivers/tty/synclink.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7973,7 +7973,6 @@ static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size)
79737973
static const struct net_device_ops hdlcdev_ops = {
79747974
.ndo_open = hdlcdev_open,
79757975
.ndo_stop = hdlcdev_close,
7976-
.ndo_change_mtu = hdlc_change_mtu,
79777976
.ndo_start_xmit = hdlc_start_xmit,
79787977
.ndo_do_ioctl = hdlcdev_ioctl,
79797978
.ndo_tx_timeout = hdlcdev_tx_timeout,

drivers/tty/synclink_gt.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,6 @@ static void hdlcdev_rx(struct slgt_info *info, char *buf, int size)
17681768
static const struct net_device_ops hdlcdev_ops = {
17691769
.ndo_open = hdlcdev_open,
17701770
.ndo_stop = hdlcdev_close,
1771-
.ndo_change_mtu = hdlc_change_mtu,
17721771
.ndo_start_xmit = hdlc_start_xmit,
17731772
.ndo_do_ioctl = hdlcdev_ioctl,
17741773
.ndo_tx_timeout = hdlcdev_tx_timeout,

drivers/tty/synclinkmp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,6 @@ static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size)
18871887
static const struct net_device_ops hdlcdev_ops = {
18881888
.ndo_open = hdlcdev_open,
18891889
.ndo_stop = hdlcdev_close,
1890-
.ndo_change_mtu = hdlc_change_mtu,
18911890
.ndo_start_xmit = hdlc_start_xmit,
18921891
.ndo_do_ioctl = hdlcdev_ioctl,
18931892
.ndo_tx_timeout = hdlcdev_tx_timeout,

include/linux/hdlc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ static __inline__ void debug_frame(const struct sk_buff *skb)
9393
int hdlc_open(struct net_device *dev);
9494
/* Must be called by hardware driver when HDLC device is being closed */
9595
void hdlc_close(struct net_device *dev);
96-
/* May be used by hardware driver */
97-
int hdlc_change_mtu(struct net_device *dev, int new_mtu);
9896
/* Must be pointed to by hw driver's dev->netdev_ops->ndo_start_xmit */
9997
netdev_tx_t hdlc_start_xmit(struct sk_buff *skb, struct net_device *dev);
10098

net/atm/lec.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,15 +544,6 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
544544
return 0;
545545
}
546546

547-
/* shamelessly stolen from drivers/net/net_init.c */
548-
static int lec_change_mtu(struct net_device *dev, int new_mtu)
549-
{
550-
if ((new_mtu < 68) || (new_mtu > 18190))
551-
return -EINVAL;
552-
dev->mtu = new_mtu;
553-
return 0;
554-
}
555-
556547
static void lec_set_multicast_list(struct net_device *dev)
557548
{
558549
/*
@@ -565,7 +556,6 @@ static const struct net_device_ops lec_netdev_ops = {
565556
.ndo_open = lec_open,
566557
.ndo_stop = lec_close,
567558
.ndo_start_xmit = lec_start_xmit,
568-
.ndo_change_mtu = lec_change_mtu,
569559
.ndo_tx_timeout = lec_tx_timeout,
570560
.ndo_set_rx_mode = lec_set_multicast_list,
571561
};
@@ -742,6 +732,7 @@ static int lecd_attach(struct atm_vcc *vcc, int arg)
742732
if (!dev_lec[i])
743733
return -ENOMEM;
744734
dev_lec[i]->netdev_ops = &lec_netdev_ops;
735+
dev_lec[i]->max_mtu = 18190;
745736
snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i);
746737
if (register_netdev(dev_lec[i])) {
747738
free_netdev(dev_lec[i]);

0 commit comments

Comments
 (0)