All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net/ipv6: use configured matric when add peer route
@ 2020-02-28  9:18 Hangbin Liu
  2020-02-28 16:32 ` Roopa Prabhu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hangbin Liu @ 2020-02-28  9:18 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern, Jianlin Shi, David Miller, 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.

Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 net/ipv6/addrconf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index cb493e15959c..164c71c54b5c 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net/ipv6: use configured matric when add peer route
  2020-02-28  9:18 [PATCH net] net/ipv6: use configured matric when add peer route Hangbin Liu
@ 2020-02-28 16:32 ` Roopa Prabhu
  2020-02-28 16:50 ` David Ahern
  2020-02-29  9:27 ` [PATCHv2 net] net/ipv6: use configured metric " Hangbin Liu
  2 siblings, 0 replies; 6+ messages in thread
From: Roopa Prabhu @ 2020-02-28 16:32 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, David Ahern, Jianlin Shi, David Miller

On Fri, Feb 28, 2020 at 1:19 AM Hangbin Liu <liuhangbin@gmail.com> wrote:
>
> 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.
>
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Fixes: 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---

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


>  net/ipv6/addrconf.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index cb493e15959c..164c71c54b5c 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net/ipv6: use configured matric when add peer route
  2020-02-28  9:18 [PATCH net] net/ipv6: use configured matric when add peer route Hangbin Liu
  2020-02-28 16:32 ` Roopa Prabhu
@ 2020-02-28 16:50 ` David Ahern
  2020-02-29  9:29   ` Hangbin Liu
  2020-02-29  9:27 ` [PATCHv2 net] net/ipv6: use configured metric " Hangbin Liu
  2 siblings, 1 reply; 6+ messages in thread
From: David Ahern @ 2020-02-28 16:50 UTC (permalink / raw)
  To: Hangbin Liu, netdev; +Cc: Jianlin Shi, David Miller

On 2/28/20 2:18 AM, Hangbin Liu wrote:
> 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.
> 
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Fixes: 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  net/ipv6/addrconf.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index cb493e15959c..164c71c54b5c 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -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;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.

Reviewed-by: David Ahern <dsahern@gmail.com>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCHv2 net] net/ipv6: use configured metric when add peer route
  2020-02-28  9:18 [PATCH net] net/ipv6: use configured matric when add peer route Hangbin Liu
  2020-02-28 16:32 ` Roopa Prabhu
  2020-02-28 16:50 ` David Ahern
@ 2020-02-29  9:27 ` Hangbin Liu
  2020-03-01  5:56   ` David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Hangbin Liu @ 2020-02-29  9:27 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern, Jianlin Shi, David Miller, Roopa Prabhu, 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.

Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
Reviewed-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

---
v2: fix metric typo
---
 net/ipv6/addrconf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index cb493e15959c..164c71c54b5c 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net] net/ipv6: use configured matric when add peer route
  2020-02-28 16:50 ` David Ahern
@ 2020-02-29  9:29   ` Hangbin Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Hangbin Liu @ 2020-02-29  9:29 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, Jianlin Shi, David Miller

On Fri, Feb 28, 2020 at 09:50:45AM -0700, David Ahern wrote:
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCHv2 net] net/ipv6: use configured metric when add peer route
  2020-02-29  9:27 ` [PATCHv2 net] net/ipv6: use configured metric " Hangbin Liu
@ 2020-03-01  5:56   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2020-03-01  5:56 UTC (permalink / raw)
  To: liuhangbin; +Cc: netdev, dsahern, jishi, roopa

From: Hangbin Liu <liuhangbin@gmail.com>
Date: Sat, 29 Feb 2020 17:27:13 +0800

> 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.
> 
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Fixes: 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
> Reviewed-by: David Ahern <dsahern@gmail.com>
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> 
> ---
> v2: fix metric typo

Applied and queued up for -stable, thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-01  5:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-28  9:18 [PATCH net] net/ipv6: use configured matric when add peer route Hangbin Liu
2020-02-28 16:32 ` Roopa Prabhu
2020-02-28 16:50 ` David Ahern
2020-02-29  9:29   ` Hangbin Liu
2020-02-29  9:27 ` [PATCHv2 net] net/ipv6: use configured metric " Hangbin Liu
2020-03-01  5:56   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.