summaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorShijie Luo <luoshijie1@huawei.com>2019-06-18 11:14:04 -0400
committerDavid S. Miller <davem@davemloft.net>2019-06-24 12:02:47 -0400
commit650638a7c6e60a198573873972aafb065f200056 (patch)
tree166e0579777bd8bc91309f9da84dd8420f7c22b0 /net/ipv4
parentd8c444d540beaa39aff834c5b83df7e86a1ae765 (diff)
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: d0daebc3d622 ("ipv4: Add interface option to enable routing of 127.0.0.0/8") Signed-off-by: Shijie Luo <luoshijie1@huawei.com> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/devinet.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 6fd4628d10b9..7874303220c5 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1356,14 +1356,20 @@ EXPORT_SYMBOL(inet_select_addr);
1356static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst, 1356static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst,
1357 __be32 local, int scope) 1357 __be32 local, int scope)
1358{ 1358{
1359 unsigned char localnet_scope = RT_SCOPE_HOST;
1359 const struct in_ifaddr *ifa; 1360 const struct in_ifaddr *ifa;
1360 __be32 addr = 0; 1361 __be32 addr = 0;
1361 int same = 0; 1362 int same = 0;
1362 1363
1364 if (unlikely(IN_DEV_ROUTE_LOCALNET(in_dev)))
1365 localnet_scope = RT_SCOPE_LINK;
1366
1363 in_dev_for_each_ifa_rcu(ifa, in_dev) { 1367 in_dev_for_each_ifa_rcu(ifa, in_dev) {
1368 unsigned char min_scope = min(ifa->ifa_scope, localnet_scope);
1369
1364 if (!addr && 1370 if (!addr &&
1365 (local == ifa->ifa_local || !local) && 1371 (local == ifa->ifa_local || !local) &&
1366 ifa->ifa_scope <= scope) { 1372 min_scope <= scope) {
1367 addr = ifa->ifa_local; 1373 addr = ifa->ifa_local;
1368 if (same) 1374 if (same)
1369 break; 1375 break;
@@ -1378,7 +1384,7 @@ static __be32 confirm_addr_indev(struct in_device *in_dev, __be32 dst,
1378 if (inet_ifa_match(addr, ifa)) 1384 if (inet_ifa_match(addr, ifa))
1379 break; 1385 break;
1380 /* No, then can we use new local src? */ 1386 /* No, then can we use new local src? */
1381 if (ifa->ifa_scope <= scope) { 1387 if (min_scope <= scope) {
1382 addr = ifa->ifa_local; 1388 addr = ifa->ifa_local;
1383 break; 1389 break;
1384 } 1390 }