Skip to content

Commit 45f3380

Browse files
committed
Merge branch 'ipv4-fix-route-update-on-metric-change'
Paolo Abeni says: ==================== ipv4: fix route update on metric change. This fixes connected route update on some edge cases for ip addr metric change. It additionally includes self tests for the covered scenarios. The new tests fail on unpatched kernels and pass on the patched one. v1 -> v2: - add selftests ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 5ff223e + 37de3b3 commit 45f3380

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

net/ipv4/fib_frontend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ void fib_modify_prefix_metric(struct in_ifaddr *ifa, u32 new_metric)
11481148
if (!(dev->flags & IFF_UP) ||
11491149
ifa->ifa_flags & (IFA_F_SECONDARY | IFA_F_NOPREFIXROUTE) ||
11501150
ipv4_is_zeronet(prefix) ||
1151-
prefix == ifa->ifa_local || ifa->ifa_prefixlen == 32)
1151+
(prefix == ifa->ifa_local && ifa->ifa_prefixlen == 32))
11521152
return;
11531153

11541154
/* add the new */

tools/testing/selftests/net/fib_tests.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,27 @@ ipv4_addr_metric_test()
14381438
fi
14391439
log_test $rc 0 "Prefix route with metric on link up"
14401440

1441+
# explicitly check for metric changes on edge scenarios
1442+
run_cmd "$IP addr flush dev dummy2"
1443+
run_cmd "$IP addr add dev dummy2 172.16.104.0/24 metric 259"
1444+
run_cmd "$IP addr change dev dummy2 172.16.104.0/24 metric 260"
1445+
rc=$?
1446+
if [ $rc -eq 0 ]; then
1447+
check_route "172.16.104.0/24 dev dummy2 proto kernel scope link src 172.16.104.0 metric 260"
1448+
rc=$?
1449+
fi
1450+
log_test $rc 0 "Modify metric of .0/24 address"
1451+
1452+
run_cmd "$IP addr flush dev dummy2"
1453+
run_cmd "$IP addr add dev dummy2 172.16.104.1/32 peer 172.16.104.2 metric 260"
1454+
run_cmd "$IP addr change dev dummy2 172.16.104.1/32 peer 172.16.104.2 metric 261"
1455+
rc=$?
1456+
if [ $rc -eq 0 ]; then
1457+
check_route "172.16.104.2 dev dummy2 proto kernel scope link src 172.16.104.1 metric 261"
1458+
rc=$?
1459+
fi
1460+
log_test $rc 0 "Modify metric of address with peer route"
1461+
14411462
$IP li del dummy1
14421463
$IP li del dummy2
14431464
cleanup

0 commit comments

Comments
 (0)