Netdev List
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: netdev@vger.kernel.org
Cc: Varun Chandramohan <varunc@linux.vnet.ibm.com>,
	Gary <gary.manchon@gmail.com>,
	Breno Leitao <leitao@linux.vnet.ibm.com>,
	ecki@lina.inka.de
Subject: [PATCH] Re: Loopback address to eth0 interface and rooting goes wrong
Date: Thu, 24 Jan 2008 09:08:02 +0100	[thread overview]
Message-ID: <87myqvzlwd.fsf_-_@obelix.mork.no> (raw)
In-Reply-To: <47981623.1040100@linux.vnet.ibm.com> (Varun Chandramohan's message of "Thu, 24 Jan 2008 10:07:55 +0530")

[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]

Hello

Gary < gary.manchon (at) gmail.com > found a problem where he was unable
to recover from a bad network interface configuration 
(ifconfig eth0 127.0.0.1), ref 
http://www.uwsg.iu.edu/hypermail/linux/net/0801.2/0009.html

This was confirmed by several people.

I suspect that the problem might be this code in net/ipv4/devinet.c ,
which sets ifa_scope to RT_SCOPE_HOST if you configure a loopback
address (127/8) on any interface.  I guess it's there to protect us from
sending packets with a loopback source address, which woulnd't look too
good:

static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
{
	struct in_device *in_dev = __in_dev_get_rtnl(dev);

	ASSERT_RTNL();

	if (!in_dev) {
		inet_free_ifa(ifa);
		return -ENOBUFS;
	}
	ipv4_devconf_setall(in_dev);
	if (ifa->ifa_dev != in_dev) {
		BUG_TRAP(!ifa->ifa_dev);
		in_dev_hold(in_dev);
		ifa->ifa_dev = in_dev;
	}
	if (LOOPBACK(ifa->ifa_local))
		ifa->ifa_scope = RT_SCOPE_HOST;
	return inet_insert_ifa(ifa);
}



The real problem is that there's never anything resetting this scope if
you change the address later.  This patch adds scope reset when changing
the address.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: devinet-rt_scope-fix.patch --]
[-- Type: text/x-diff, Size: 719 bytes --]

We set the scope to RT_SCOPE_HOST if an IPv4 interface is configured with a 
loopback address (127/8).  This prevents the interface from sending packets 
out the wire.  This patch resets the scope if the address is changed again,
to restore normal functionality.

Signed-off-by: Bjorn Mork <bjorn@mork.no>

 devinet.c |    1 +
 1 file changed, 1 insertion(+)


--- linux-2.6.24-rc8.orig/net/ipv4/devinet.c	2008-01-16 05:22:48.000000000 +0100
+++ linux-2.6.24-rc8/net/ipv4/devinet.c	2008-01-23 19:17:30.000000000 +0100
@@ -753,6 +753,7 @@
 			inet_del_ifa(in_dev, ifap, 0);
 			ifa->ifa_broadcast = 0;
 			ifa->ifa_anycast = 0;
+			ifa->ifa_scope = 0;
 		}
 
 		ifa->ifa_address = ifa->ifa_local = sin->sin_addr.s_addr;

[-- Attachment #3: Type: text/plain, Size: 13 bytes --]




Bjørn

           reply	other threads:[~2008-01-24  8:30 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <47981623.1040100@linux.vnet.ibm.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87myqvzlwd.fsf_-_@obelix.mork.no \
    --to=bjorn@mork.no \
    --cc=ecki@lina.inka.de \
    --cc=gary.manchon@gmail.com \
    --cc=leitao@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=varunc@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox