diff mbox series

[net,2/2] ipv6: Fix nlmsg_flags when splitting a multipath route

Message ID 20200212014107.110066-2-bpoirier@cumulusnetworks.com
State Accepted
Delegated to: David Miller
Headers show
Series [net,1/2] ipv6: Fix route replacement with dev-only route | expand

Commit Message

Benjamin Poirier Feb. 12, 2020, 1:41 a.m. UTC
When splitting an RTA_MULTIPATH request into multiple routes and adding the
second and later components, we must not simply remove NLM_F_REPLACE but
instead replace it by NLM_F_CREATE. Otherwise, it may look like the netlink
message was malformed.

For example,
	ip route add 2001:db8::1/128 dev dummy0
	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0 \
		nexthop via fe80::30:2 dev dummy0
results in the following warnings:
[ 1035.057019] IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE
[ 1035.057517] IPv6: NLM_F_CREATE should be set when creating new route

This patch makes the nlmsg sequence look equivalent for __ip6_ins_rt() to
what it would get if the multipath route had been added in multiple netlink
operations:
	ip route add 2001:db8::1/128 dev dummy0
	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0
	ip route append 2001:db8::1/128 nexthop via fe80::30:2 dev dummy0

Fixes: 27596472473a ("ipv6: fix ECMP route replacement")
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
---
 net/ipv6/route.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Michal Kubecek Feb. 12, 2020, 9:58 p.m. UTC | #1
On Wed, Feb 12, 2020 at 10:41:07AM +0900, Benjamin Poirier wrote:
> When splitting an RTA_MULTIPATH request into multiple routes and adding the
> second and later components, we must not simply remove NLM_F_REPLACE but
> instead replace it by NLM_F_CREATE. Otherwise, it may look like the netlink
> message was malformed.
> 
> For example,
> 	ip route add 2001:db8::1/128 dev dummy0
> 	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0 \
> 		nexthop via fe80::30:2 dev dummy0
> results in the following warnings:
> [ 1035.057019] IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE
> [ 1035.057517] IPv6: NLM_F_CREATE should be set when creating new route
> 
> This patch makes the nlmsg sequence look equivalent for __ip6_ins_rt() to
> what it would get if the multipath route had been added in multiple netlink
> operations:
> 	ip route add 2001:db8::1/128 dev dummy0
> 	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0
> 	ip route append 2001:db8::1/128 nexthop via fe80::30:2 dev dummy0
> 
> Fixes: 27596472473a ("ipv6: fix ECMP route replacement")
> Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>

Reviewed-by: Michal Kubecek <mkubecek@suse.cz>

> ---
>  net/ipv6/route.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 4fbdc60b4e07..2931224b674e 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -5198,6 +5198,7 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
>  		 */
>  		cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |
>  						     NLM_F_REPLACE);
> +		cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE;
>  		nhn++;
>  	}
>  
> -- 
> 2.25.0
>
David Ahern Feb. 15, 2020, 5:58 p.m. UTC | #2
On 2/11/20 6:41 PM, Benjamin Poirier wrote:
> When splitting an RTA_MULTIPATH request into multiple routes and adding the
> second and later components, we must not simply remove NLM_F_REPLACE but
> instead replace it by NLM_F_CREATE. Otherwise, it may look like the netlink
> message was malformed.
> 
> For example,
> 	ip route add 2001:db8::1/128 dev dummy0
> 	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0 \
> 		nexthop via fe80::30:2 dev dummy0
> results in the following warnings:
> [ 1035.057019] IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE
> [ 1035.057517] IPv6: NLM_F_CREATE should be set when creating new route
> 
> This patch makes the nlmsg sequence look equivalent for __ip6_ins_rt() to
> what it would get if the multipath route had been added in multiple netlink
> operations:
> 	ip route add 2001:db8::1/128 dev dummy0
> 	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0
> 	ip route append 2001:db8::1/128 nexthop via fe80::30:2 dev dummy0
> 
> Fixes: 27596472473a ("ipv6: fix ECMP route replacement")
> Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
> ---
>  net/ipv6/route.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index 4fbdc60b4e07..2931224b674e 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -5198,6 +5198,7 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
>  		 */
>  		cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |
>  						     NLM_F_REPLACE);
> +		cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE;
>  		nhn++;
>  	}
>  
> 

Reviewed-by: David Ahern <dsahern@gmail.com>
David Miller Feb. 17, 2020, 2:35 a.m. UTC | #3
From: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Date: Wed, 12 Feb 2020 10:41:07 +0900

> When splitting an RTA_MULTIPATH request into multiple routes and adding the
> second and later components, we must not simply remove NLM_F_REPLACE but
> instead replace it by NLM_F_CREATE. Otherwise, it may look like the netlink
> message was malformed.
> 
> For example,
> 	ip route add 2001:db8::1/128 dev dummy0
> 	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0 \
> 		nexthop via fe80::30:2 dev dummy0
> results in the following warnings:
> [ 1035.057019] IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE
> [ 1035.057517] IPv6: NLM_F_CREATE should be set when creating new route
> 
> This patch makes the nlmsg sequence look equivalent for __ip6_ins_rt() to
> what it would get if the multipath route had been added in multiple netlink
> operations:
> 	ip route add 2001:db8::1/128 dev dummy0
> 	ip route change 2001:db8::1/128 nexthop via fe80::30:1 dev dummy0
> 	ip route append 2001:db8::1/128 nexthop via fe80::30:2 dev dummy0
> 
> Fixes: 27596472473a ("ipv6: fix ECMP route replacement")
> Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>

Applied and queued up for -stable.
diff mbox series

Patch

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 4fbdc60b4e07..2931224b674e 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5198,6 +5198,7 @@  static int ip6_route_multipath_add(struct fib6_config *cfg,
 		 */
 		cfg->fc_nlinfo.nlh->nlmsg_flags &= ~(NLM_F_EXCL |
 						     NLM_F_REPLACE);
+		cfg->fc_nlinfo.nlh->nlmsg_flags |= NLM_F_CREATE;
 		nhn++;
 	}