Re: Loopback address to eth0 interface and rooting goes wrong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gary <gary.manchon@xxxxxxxxx> writes:

> I will be very interested to have a way to recover the network if
> someone find the root cause but it seems I reach my technical limit.
> Of course if anyone need more information about my configuration I am
> still in the thread.

I was able to recreate your problem, and to recover from it by doing

# ifconfig eth0 0
# ifconfig eth0 192.168.240.195 netmask 255.255.248.0
# route add default gw 192.168.240.1

from the non-working situation.

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.  The attached patch fixes this.


Bjørn

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@xxxxxxx>

 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;

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux