Re: IPv4 saddr do not match with selected output device in double default gateways scene

From: Ziyang Xuan (William)
Date: Wed Mar 09 2022 - 22:20:32 EST


> On 3/7/22 11:41 PM, Ziyang Xuan (William) wrote:
>> Create VLAN devices and add default gateways with following commands:
>>
>> # ip link add link eth2 dev eth2.71 type vlan id 71
>> # ip link add link eth2 dev eth2.72 type vlan id 72
>> # ip addr add 192.168.71.41/24 dev eth2.71
>> # ip addr add 192.168.72.41/24 dev eth2.72
>> # ip link set eth2.71 up
>> # ip link set eth2.72 up
>> # route add -net default gw 192.168.71.1 dev eth2.71
>> # route add -net default gw 192.168.72.1 dev eth2.72
>>
>
> ...
>
>> We can find that IPv4 saddr "192.168.72.41" do not match with selected VLAN device "eth2.71".
>>
>> I tracked the related processes, and found that user space program uses connect() firstly, then sends UDP packet.
>>
>
> ...
>
>> Deep tracking, it because fa->fa_default has changed in fib_select_default() after first __ip_route_output_key() process,
>> and a new fib_nh is selected in fib_select_default() within the second __ip_route_output_key() process but not update flowi4.
>> So the phenomenon described at the beginning happens.
>>
>> Does it a kernel bug or a user problem? If it is a kernel bug, is there any good solution?
>
> That is a known problem with multipath routes.
> .
>

Does the community have a plan to address it?