Commit 650638a7 authored by Shijie Luo's avatar Shijie Luo Committed by David S. Miller

ipv4: fix confirm_addr_indev() when enable route_localnet

When arp_ignore=3, the NIC won't reply for scope host addresses, but
if enable route_locanet, we need to reply ip address with head 127 and
scope RT_SCOPE_HOST.

Fixes: d0daebc3 ("ipv4: Add interface option to enable routing of 127.0.0.0/8")
Signed-off-by: default avatarShijie Luo <luoshijie1@huawei.com>
Signed-off-by: default avatarZhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d8c444d5
...@@ -1356,14 +1356,20 @@ EXPORT_SYMBOL(inet_select_addr); ...@@ -1356,14 +1356,20 @@ EXPORT_SYMBOL(inet_select_addr);
static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst, static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst,
__be32 local, int scope) __be32 local, int scope)
{ {
unsigned char localnet_scope = RT_SCOPE_HOST;
const struct in_ifaddr *ifa; const struct in_ifaddr *ifa;
__be32 addr = 0; __be32 addr = 0;
int same = 0; int same = 0;
if (unlikely(IN_DEV_ROUTE_LOCALNET(in_dev)))
localnet_scope = RT_SCOPE_LINK;
in_dev_for_each_ifa_rcu(ifa, in_dev) { in_dev_for_each_ifa_rcu(ifa, in_dev) {
unsigned char min_scope = min(ifa->ifa_scope, localnet_scope);
if (!addr && if (!addr &&
(local == ifa->ifa_local || !local) && (local == ifa->ifa_local || !local) &&
ifa->ifa_scope <= scope) { min_scope <= scope) {
addr = ifa->ifa_local; addr = ifa->ifa_local;
if (same) if (same)
break; break;
...@@ -1378,7 +1384,7 @@ static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst, ...@@ -1378,7 +1384,7 @@ static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst,
if (inet_ifa_match(addr, ifa)) if (inet_ifa_match(addr, ifa))
break; break;
/* No, then can we use new local src? */ /* No, then can we use new local src? */
if (ifa->ifa_scope <= scope) { if (min_scope <= scope) {
addr = ifa->ifa_local; addr = ifa->ifa_local;
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