Skip to contentSkip to conversation

net/ipv6: use configured matric when add peer route

PATCH Superseded Hangbin Liu 4 participants 6 messages Feb 28, 2020 – Mar 1, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ipv6: use configured matric when add peer route

When we add peer address with metric configured, IPv4 could set the dest metric correctly, but IPv6 do not. e.g.

]# ip addr add 192.0.2.1 peer 192.0.2.2/32 dev eth1 metric 20 ]# ip route show dev eth1
192.0.2.2 proto kernel scope link src 192.0.2.1 metric 20 ]# ip addr add 2001:db8::1 peer 2001:db8::2/128 dev eth1 metric 20 ]# ip -6 route show dev eth1
2001:db8::1 proto kernel metric 20 pref medium 2001:db8::2 proto kernel metric 256 pref medium

Fix this by using configured matric instead of default one.

Fixes 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
---
 net/ipv6/addrconf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv6/addrconf.c +3 -3
index cb493e15959c..164c71c54b5c 100644
@@ -5983,9 +5983,9 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
 		if (ifp->idev->cnf.forwarding)
 			addrconf_join_anycast(ifp);
 		if (!ipv6_addr_any(&ifp->peer_addr))
-			addrconf_prefix_route(&ifp->peer_addr, 128, 0,
-					      ifp->idev->dev, 0, 0,
-					      GFP_ATOMIC);
+			addrconf_prefix_route(&ifp->peer_addr, 128,
+					      ifp->rt_priority, ifp->idev->dev,
+					      0, 0, GFP_ATOMIC);
 		break;
 	case RTM_DELADDR:
 		if (ifp->idev->cnf.forwarding)
Signature · 1 line
2.19.2
#1 lore raw
Quoted 12 lines · Hangbin Liu

When we add peer address with metric configured, IPv4 could set the dest metric correctly, but IPv6 do not. e.g.

]# ip addr add 192.0.2.1 peer 192.0.2.2/32 dev eth1 metric 20 ]# ip route show dev eth1
192.0.2.2 proto kernel scope link src 192.0.2.1 metric 20 ]# ip addr add 2001:db8::1 peer 2001:db8::2/128 dev eth1 metric 20 ]# ip -6 route show dev eth1
2001:db8::1 proto kernel metric 20 pref medium 2001:db8::2 proto kernel metric 256 pref medium

Quoted 6 lines

Fix this by using configured matric instead of default one.

Fixes 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")

---

noticed the typo in the patch title : s/matric/metric/

Quoted 23 lines
 net/ipv6/addrconf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv6/addrconf.c +3 -4
index cb493e15959c..164c71c54b5c 100644
@@ -5983,9 +5983,9 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
                if (ifp->idev->cnf.forwarding)
                        addrconf_join_anycast(ifp);
                if (!ipv6_addr_any(&ifp->peer_addr))
-                       addrconf_prefix_route(&ifp->peer_addr, 128, 0,
-                                             ifp->idev->dev, 0, 0,
-                                             GFP_ATOMIC);
+                       addrconf_prefix_route(&ifp->peer_addr, 128,
+                                             ifp->rt_priority, ifp->idev->dev,
+                                             0, 0, GFP_ATOMIC);
                break;
        case RTM_DELADDR:
                if (ifp->idev->cnf.forwarding)
--

2.19.2

Reviewed-by on v1 1/1
#2 lore raw
In reply to Hangbin Liu
Quoted 28 lines · Hangbin Liu

When we add peer address with metric configured, IPv4 could set the dest metric correctly, but IPv6 do not. e.g.

]# ip addr add 192.0.2.1 peer 192.0.2.2/32 dev eth1 metric 20 ]# ip route show dev eth1
192.0.2.2 proto kernel scope link src 192.0.2.1 metric 20 ]# ip addr add 2001:db8::1 peer 2001:db8::2/128 dev eth1 metric 20 ]# ip -6 route show dev eth1
2001:db8::1 proto kernel metric 20 pref medium 2001:db8::2 proto kernel metric 256 pref medium

Fix this by using configured matric instead of default one.

Fixes 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
---
 net/ipv6/addrconf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv6/addrconf.c +0 -0
index cb493e15959c..164c71c54b5c 100644
@@ -5983,9 +5983,9 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
 		if (ifp->idev->cnf.forwarding)
 			addrconf_join_anycast(ifp);

net/ipv6/addrconf.c static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) · line 5991

Quoted 10 lines
net/ipv6/addrconf.c +3 -3
 		if (!ipv6_addr_any(&ifp->peer_addr))
-			addrconf_prefix_route(&ifp->peer_addr, 128, 0,
-					      ifp->idev->dev, 0, 0,
-					      GFP_ATOMIC);
+			addrconf_prefix_route(&ifp->peer_addr, 128,
+					      ifp->rt_priority, ifp->idev->dev,
+					      0, 0, GFP_ATOMIC);
 		break;tools/testing/selftests/net
 	case RTM_DELADDR:
 		if (ifp->idev->cnf.forwarding)

ugh, missed that one. Thanks for the patch. Please add the tests in the commit message to tools/testing/selftests/net/fib_tests.sh, ipv{4,6}_addr_metric_test sections.

(and s/matric/metric/ in a couple of places as noted by roopa)

#3 lore raw
Quoted 3 lines · David Ahern

ugh, missed that one. Thanks for the patch. Please add the tests in the commit message to tools/testing/selftests/net/fib_tests.sh, ipv{4,6}_addr_metric_test sections.

I will, thanks

#4 lore raw

PATCH v2 1/1 net/ipv6: use configured metric when add peer route

In reply to Hangbin Liu

When we add peer address with metric configured, IPv4 could set the dest metric correctly, but IPv6 do not. e.g.

]# ip addr add 192.0.2.1 peer 192.0.2.2/32 dev eth1 metric 20 ]# ip route show dev eth1
192.0.2.2 proto kernel scope link src 192.0.2.1 metric 20 ]# ip addr add 2001:db8::1 peer 2001:db8::2/128 dev eth1 metric 20 ]# ip -6 route show dev eth1
2001:db8::1 proto kernel metric 20 pref medium 2001:db8::2 proto kernel metric 256 pref medium

Fix this by using configured metric instead of default one.

Fixes 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")

---
v2: fix metric typo

---
 net/ipv6/addrconf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv6/addrconf.c +3 -3
index cb493e15959c..164c71c54b5c 100644
@@ -5983,9 +5983,9 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
 		if (ifp->idev->cnf.forwarding)
 			addrconf_join_anycast(ifp);
 		if (!ipv6_addr_any(&ifp->peer_addr))
-			addrconf_prefix_route(&ifp->peer_addr, 128, 0,
-					      ifp->idev->dev, 0, 0,
-					      GFP_ATOMIC);
+			addrconf_prefix_route(&ifp->peer_addr, 128,
+					      ifp->rt_priority, ifp->idev->dev,
+					      0, 0, GFP_ATOMIC);
 		break;
 	case RTM_DELADDR:
 		if (ifp->idev->cnf.forwarding)
Signature · 1 line
2.19.2
maintainer
#5 lore raw

Re: [PATCHv2 net] net/ipv6: use configured metric when add peer route

From: Hangbin Liu <[email protected]>
Date: Sat, 29 Feb 2020 17:27:13 +0800

Quoted 13 lines

When we add peer address with metric configured, IPv4 could set the dest metric correctly, but IPv6 do not. e.g.

]# ip addr add 192.0.2.1 peer 192.0.2.2/32 dev eth1 metric 20 ]# ip route show dev eth1
192.0.2.2 proto kernel scope link src 192.0.2.1 metric 20 ]# ip addr add 2001:db8::1 peer 2001:db8::2/128 dev eth1 metric 20 ]# ip -6 route show dev eth1
2001:db8::1 proto kernel metric 20 pref medium 2001:db8::2 proto kernel metric 256 pref medium

Fix this by using configured metric instead of default one.

Quoted 7 lines
Fixes 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")

---
v2: fix metric typo

Applied and queued up for -stable, thank you.