netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1 net-2.6] Re-enable IP when MTU > 68
@ 2008-08-29 14:53 Breno Leitao
  2008-08-29 15:05 ` Ben Hutchings
  0 siblings, 1 reply; 6+ messages in thread
From: Breno Leitao @ 2008-08-29 14:53 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Lorandi

Actually if you run "ifconfig ethX mtu 56; ifconfig ethX mtu 1500",
then your interface will get corrupted. On an attempt to assign an IP
to the interface, it'll result in:
SIOCSIFADDR: No buffer space available
This happens because when decreasing the MTU under 68, it'll destroy the
in_dev reference forever, even after getting MTU higher than 68 bytes.

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

Signed-off-by: Breno Leitao <leitao@linux.vnet.ibm.com>

---

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 91d3d96..758b4f6 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1048,6 +1048,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, NOPOLICY, 1);
 			}
+		} else if (event == NETDEV_CHANGEMTU) {
+			/* Re-enabling IP */
+			if (dev->mtu > 68)
+				in_dev = inetdev_init(dev);
 		}
 		goto out;
 	}


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1 net-2.6] Re-enable IP when MTU > 68
  2008-08-29 14:53 [PATCH 1/1 net-2.6] Re-enable IP when MTU > 68 Breno Leitao
@ 2008-08-29 15:05 ` Ben Hutchings
  2008-08-29 15:23   ` Breno Leitao
  0 siblings, 1 reply; 6+ messages in thread
From: Ben Hutchings @ 2008-08-29 15:05 UTC (permalink / raw)
  To: Breno Leitao; +Cc: David Miller, netdev, Lorandi

Breno Leitao wrote:
[...]
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index 91d3d96..758b4f6 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -1048,6 +1048,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, NOPOLICY, 1);
>  			}
> +		} else if (event == NETDEV_CHANGEMTU) {
> +			/* Re-enabling IP */
> +			if (dev->mtu > 68)
[...]

Should be >= to match the other tests.  And it would really be cleaner to
use something like

	static inline bool inetdev_valid_mtu(unsigned mtu)
	{
		return mtu >= 68;
	}

rather than repeating the magic number.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1 net-2.6] Re-enable IP when MTU > 68
  2008-08-29 15:05 ` Ben Hutchings
@ 2008-08-29 15:23   ` Breno Leitao
  2008-08-29 20:33     ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Breno Leitao @ 2008-08-29 15:23 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: David Miller, netdev, Lorandi

Ben, 

Ben Hutchings wrote:
> Should be >= to match the other tests.  And it would really be cleaner to
> use something like
> 
> 	static inline bool inetdev_valid_mtu(unsigned mtu)
> 	{
> 		return mtu >= 68;
> 	}
Where is the best place to insert this function ?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1 net-2.6] Re-enable IP when MTU > 68
  2008-08-29 15:23   ` Breno Leitao
@ 2008-08-29 20:33     ` David Miller
  2008-08-30 17:57       ` Breno Leitao
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2008-08-29 20:33 UTC (permalink / raw)
  To: leitao; +Cc: bhutchings, netdev, rafaello

From: Breno Leitao <leitao@linux.vnet.ibm.com>
Date: Fri, 29 Aug 2008 12:23:03 -0300

> Ben, 
> 
> Ben Hutchings wrote:
> > Should be >= to match the other tests.  And it would really be cleaner to
> > use something like
> > 
> > 	static inline bool inetdev_valid_mtu(unsigned mtu)
> > 	{
> > 		return mtu >= 68;
> > 	}
> Where is the best place to insert this function ?

Right above the two places it would be called :)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1 net-2.6] Re-enable IP when MTU > 68
  2008-08-29 20:33     ` David Miller
@ 2008-08-30 17:57       ` Breno Leitao
  2008-09-03  0:29         ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Breno Leitao @ 2008-08-30 17:57 UTC (permalink / raw)
  To: David Miller, bhutchings; +Cc: netdev, rafaello

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: Breno Leitao <leitao@linux.vnet.ibm.com>

---

diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 91d3d96..27193dd 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1029,6 +1029,11 @@ skip:
 	}
 }
 
+static inline bool inetdev_valid_mtu(unsigned mtu)
+{
+	return mtu >= 68;
+}
+
 /* Called only under RTNL semaphore */
 
 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, NOPOLICY, 1);
 			}
+		} else if (event == NETDEV_CHANGEMTU) {
+			/* Re-enabling IP */
+			if (inetdev_valid_mtu(dev->mtu))
+				in_dev = inetdev_init(dev);
 		}
 		goto out;
 	}
@@ -1058,7 +1067,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
 		dev->ip_ptr = NULL;
 		break;
 	case NETDEV_UP:
-		if (dev->mtu < 68)
+		if (!inetdev_valid_mtu(dev->mtu))
 			break;
 		if (dev->flags & IFF_LOOPBACK) {
 			struct in_ifaddr *ifa;
@@ -1080,9 +1089,9 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
 		ip_mc_down(in_dev);
 		break;
 	case NETDEV_CHANGEMTU:
-		if (dev->mtu >= 68)
+		if (inetdev_valid_mtu(dev->mtu))
 			break;
-		/* MTU falled under 68, disable IP */
+		/* disable IP when MTU is not enough */
 	case NETDEV_UNREGISTER:
 		inetdev_destroy(in_dev);
 		break;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1 net-2.6] Re-enable IP when MTU > 68
  2008-08-30 17:57       ` Breno Leitao
@ 2008-09-03  0:29         ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2008-09-03  0:29 UTC (permalink / raw)
  To: leitao; +Cc: bhutchings, netdev, rafaello

From: Breno Leitao <leitao@linux.vnet.ibm.com>
Date: Sat, 30 Aug 2008 14:57:18 -0300

> 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: Breno Leitao <leitao@linux.vnet.ibm.com>

Looks good, patch applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-09-03  0:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-29 14:53 [PATCH 1/1 net-2.6] Re-enable IP when MTU > 68 Breno Leitao
2008-08-29 15:05 ` Ben Hutchings
2008-08-29 15:23   ` Breno Leitao
2008-08-29 20:33     ` David Miller
2008-08-30 17:57       ` Breno Leitao
2008-09-03  0:29         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).