Message ID | 20110303.112328.59677094.davem@davemloft.net |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
On Thu, 03 Mar 2011 11:23:28 -0800 (PST) David Miller <davem@davemloft.net> wrote: > From: Julian Anastasov <ja@ssi.bg> > Date: Thu, 3 Mar 2011 15:09:22 +0200 (EET) > > > On Thu, 3 Mar 2011, Julian Anastasov wrote: > > > >> May be the problem is in inet_hash_insert(), it should > >> hash ifa_local, not ifa_address. May be they are equal for > > > > ... and of course the new __ip_dev_find should use > > ifa_local too. > > Thanks for looking into this Julian. I will look at the other > cases you found later. > > Stephen, is this sufficient to fix your problem? I suspect it is > not because fib_add_addr() adds prefixes with RTN_LOCAL to the > local routing table too :-/ > > I suspect that even if we need to handle prefixes, we can still use > the hash for optimistic lookup, and fallback to a local table FIB > inspection if that fails. > > -------------------- > ipv4: Fix __ip_dev_find() to use ifa_local instead of ifa_address. > > Reported-by: Stephen Hemminger <shemminger@vyatta.com> > Reported-by: Julian Anastasov <ja@ssi.bg> > Signed-off-by: David S. Miller <davem@davemloft.net> > VPN works now with this patch on net-next. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello, On Thu, 3 Mar 2011, David Miller wrote: > I suspect that even if we need to handle prefixes, we can still use > the hash for optimistic lookup, and fallback to a local table FIB > inspection if that fails. Yes, as ip_route_output_slow uses __ip_dev_find for fl4_src there should be some kind of fallback to local table, so that traffic from 127.0.0.2 to 127.0.0.3 or other local subnets on loopback can work. Another option is to use inet_addr_onlink but I suspect people can add many addresses on loopback: inet_addr_onlink(loopback_indev, addr, 0) Regards -- Julian Anastasov <ja@ssi.bg> -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 9038928..ff53860 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -111,7 +111,7 @@ static inline unsigned int inet_addr_hash(struct net *net, __be32 addr) static void inet_hash_insert(struct net *net, struct in_ifaddr *ifa) { - unsigned int hash = inet_addr_hash(net, ifa->ifa_address); + unsigned int hash = inet_addr_hash(net, ifa->ifa_local); spin_lock(&inet_addr_hash_lock); hlist_add_head_rcu(&ifa->hash, &inet_addr_lst[hash]); @@ -146,7 +146,7 @@ struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref) if (!net_eq(dev_net(dev), net)) continue; - if (ifa->ifa_address == addr) { + if (ifa->ifa_local == addr) { result = dev; break; }