mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
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: 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>
This commit is contained in:
parent
9c22b4a34e
commit
8b6b4135e4
@ -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,
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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]);
|
||||
|
Loading…
Reference in New Issue
Block a user