Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipv6: Check GATEWAY in rtm_to_fib6_multipath_config().

In ip6_route_multipath_add(), we call rt6_qualify_for_ecmp() for each
entry. If it returns false, the request fails.

rt6_qualify_for_ecmp() returns false if either of the conditions below
is true:

1. f6i->fib6_flags has RTF_ADDRCONF
2. f6i->nh is not NULL
3. f6i->fib6_nh->fib_nh_gw_family is AF_UNSPEC

1 is unnecessary because rtm_to_fib6_config() never sets RTF_ADDRCONF
to cfg->fc_flags.

2. is equivalent with cfg->fc_nh_id.

3. can be replaced by checking RTF_GATEWAY in the base and each multipath
entry because AF_INET6 is set to f6i->fib6_nh->fib_nh_gw_family only when
cfg.fc_is_fdb is true or RTF_GATEWAY is set, but the former is always
false.

These checks do not require RCU and can be done earlier.

Let's perform the equivalent checks in rtm_to_fib6_multipath_config().

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250418000443.43734-5-kuniyu@amazon.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Kuniyuki Iwashima and committed by
Paolo Abeni
e6f49795 fa76c167

+9 -7
+9 -7
net/ipv6/route.c
··· 5031 5031 } 5032 5032 5033 5033 do { 5034 + bool has_gateway = cfg->fc_flags & RTF_GATEWAY; 5034 5035 int attrlen = rtnh_attrlen(rtnh); 5035 5036 5036 5037 if (attrlen > 0) { ··· 5045 5044 "Invalid IPv6 address in RTA_GATEWAY"); 5046 5045 return -EINVAL; 5047 5046 } 5047 + 5048 + has_gateway = true; 5048 5049 } 5050 + } 5051 + 5052 + if (newroute && (cfg->fc_nh_id || !has_gateway)) { 5053 + NL_SET_ERR_MSG(extack, 5054 + "Device only routes can not be added for IPv6 using the multipath API."); 5055 + return -EINVAL; 5049 5056 } 5050 5057 5051 5058 rtnh = rtnh_next(rtnh, &remaining); ··· 5395 5386 if (IS_ERR(rt)) { 5396 5387 err = PTR_ERR(rt); 5397 5388 rt = NULL; 5398 - goto cleanup; 5399 - } 5400 - if (!rt6_qualify_for_ecmp(rt)) { 5401 - err = -EINVAL; 5402 - NL_SET_ERR_MSG(extack, 5403 - "Device only routes can not be added for IPv6 using the multipath API."); 5404 - fib6_info_release(rt); 5405 5389 goto cleanup; 5406 5390 } 5407 5391