Commit 06770843 authored by Breno Leitao's avatar Breno Leitao Committed by David S. Miller

ipv: Re-enable IP when MTU > 68

Re-enable IP when the MTU gets back to a valid size. 

This patch just checks if the in_dev is NULL on a NETDEV_CHANGEMTU event
and if MTU is valid (bigger than 68), then re-enable in_dev. 

Also a function that checks valid MTU size was created.
Signed-off-by: default avatarBreno Leitao <leitao@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9d7d7402
...@@ -1029,6 +1029,11 @@ skip: ...@@ -1029,6 +1029,11 @@ skip:
} }
} }
static inline bool inetdev_valid_mtu(unsigned mtu)
{
return mtu >= 68;
}
/* Called only under RTNL semaphore */ /* Called only under RTNL semaphore */
static int inetdev_event(struct notifier_block *this, unsigned long event, static int inetdev_event(struct notifier_block *this, unsigned long event,
...@@ -1048,6 +1053,10 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, ...@@ -1048,6 +1053,10 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
IN_DEV_CONF_SET(in_dev, NOXFRM, 1); IN_DEV_CONF_SET(in_dev, NOXFRM, 1);
IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); IN_DEV_CONF_SET(in_dev, NOPOLICY, 1);
} }
} else if (event == NETDEV_CHANGEMTU) {
/* Re-enabling IP */
if (inetdev_valid_mtu(dev->mtu))
in_dev = inetdev_init(dev);
} }
goto out; goto out;
} }
...@@ -1058,7 +1067,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, ...@@ -1058,7 +1067,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
dev->ip_ptr = NULL; dev->ip_ptr = NULL;
break; break;
case NETDEV_UP: case NETDEV_UP:
if (dev->mtu < 68) if (!inetdev_valid_mtu(dev->mtu))
break; break;
if (dev->flags & IFF_LOOPBACK) { if (dev->flags & IFF_LOOPBACK) {
struct in_ifaddr *ifa; struct in_ifaddr *ifa;
...@@ -1080,9 +1089,9 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, ...@@ -1080,9 +1089,9 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
ip_mc_down(in_dev); ip_mc_down(in_dev);
break; break;
case NETDEV_CHANGEMTU: case NETDEV_CHANGEMTU:
if (dev->mtu >= 68) if (inetdev_valid_mtu(dev->mtu))
break; break;
/* MTU falled under 68, disable IP */ /* disable IP when MTU is not enough */
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
inetdev_destroy(in_dev); inetdev_destroy(in_dev);
break; break;
......
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