Commit e82621e3 authored by Zhang Shengju's avatar Zhang Shengju Committed by David S. Miller

nlmon: use core MTU range checking in nlmon driver

Since commit 61e84623 ("net: centralize net_device min/max MTU checking"),
mtu range is checked at dev_set_mtu().

This patch adds min_mtu for nlmon device and remove unnecessary
ndo_change_mtu() function.
Signed-off-by: default avatarZhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a1f5315c
...@@ -27,24 +27,6 @@ static netdev_tx_t nlmon_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -27,24 +27,6 @@ static netdev_tx_t nlmon_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
static int nlmon_is_valid_mtu(int new_mtu)
{
/* Note that in netlink we do not really have an upper limit. On
* default, we use NLMSG_GOODSIZE. Here at least we should make
* sure that it's at least the header size.
*/
return new_mtu >= (int) sizeof(struct nlmsghdr);
}
static int nlmon_change_mtu(struct net_device *dev, int new_mtu)
{
if (!nlmon_is_valid_mtu(new_mtu))
return -EINVAL;
dev->mtu = new_mtu;
return 0;
}
static int nlmon_dev_init(struct net_device *dev) static int nlmon_dev_init(struct net_device *dev)
{ {
dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats); dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats);
...@@ -124,7 +106,6 @@ static const struct net_device_ops nlmon_ops = { ...@@ -124,7 +106,6 @@ static const struct net_device_ops nlmon_ops = {
.ndo_stop = nlmon_close, .ndo_stop = nlmon_close,
.ndo_start_xmit = nlmon_xmit, .ndo_start_xmit = nlmon_xmit,
.ndo_get_stats64 = nlmon_get_stats64, .ndo_get_stats64 = nlmon_get_stats64,
.ndo_change_mtu = nlmon_change_mtu,
}; };
static void nlmon_setup(struct net_device *dev) static void nlmon_setup(struct net_device *dev)
...@@ -145,6 +126,7 @@ static void nlmon_setup(struct net_device *dev) ...@@ -145,6 +126,7 @@ static void nlmon_setup(struct net_device *dev)
* expected in most cases. * expected in most cases.
*/ */
dev->mtu = NLMSG_GOODSIZE; dev->mtu = NLMSG_GOODSIZE;
dev->min_mtu = sizeof(struct nlmsghdr);
} }
static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[]) static int nlmon_validate(struct nlattr *tb[], struct nlattr *data[])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment