Hello,
When an interface has two global IPv6 addresses in the same prefix and one
of them is removed, the Direct protocol withdraws the prefix route, even
though the other address (and the kernel's connected route) is still there.
The route only comes back after `birdc restart direct1` or a BIRD restart.
This shows up with VRRP (keepalived): a router has its own address and a
virtual address in the same /64, and when the virtual address moves to the
peer, the /64 disappears from BIRD and stops being exported (OSPF/BGP),
while the router still has its own address in it. IPv4 is not affected,
because Linux marks the second IPv4 address in a subnet as secondary.
Observed with BIRD 2.0.12 (Debian bookworm) and reproduced with 2.18. The
relevant code is unchanged in current master and v3.4.0.
## Reproduction
bird.conf:
router id 192.0.2.1;
protocol device { scan time 1; }
protocol direct { ipv6; interface "dummy0"; }
Steps (in a scratch network namespace):
ip link add dummy0 type dummy; ip link set dummy0 up
ip -6 addr add 2001:db8:1::10/64 dev dummy0 nodad
ip -6 addr add 2001:db8:1::1/64 dev dummy0 nodad
bird -c bird.conf
birdc show route protocol direct1 # 2001:db8:1::/64 present
ip -6 addr del 2001:db8:1::1/64 dev dummy0
birdc show route protocol direct1 # 2001:db8:1::/64 gone
birdc show interfaces # 2001:db8:1::10/64 still listed
birdc restart direct1
birdc show route protocol direct1 # 2001:db8:1::/64 back
Output (BIRD 2.18):
## both addresses present
inet6 2001:db8:1::1/64 scope global nodad
inet6 2001:db8:1::10/64 scope global nodad
Table master6:
2001:db8:1::/64 unicast [direct1 14:15:57.592] * (240)
dev dummy0
## after removing 2001:db8:1::1 (2001:db8:1::10 remains)
inet6 2001:db8:1::10/64 scope global nodad
(show route protocol direct1: no routes)
dummy0 up (index=2)
MultiAccess Broadcast Multicast AdminUp LinkUp MTU=1500
2001:db8:1::10/64 (Preferred, scope univ)
fe80::2c27:c8ff:fe86:a4ad/64 (Preferred, scope link)
## after birdc restart direct1
Table master6:
2001:db8:1::/64 unicast [direct1 14:16:01.617] * (240)
dev dummy0
## Cause
`IA_SECONDARY` is only set from the kernel's `IFA_F_SECONDARY` flag
(sysdep/linux/netlink.c), which Linux uses for IPv4 only. So both IPv6
addresses are non-secondary, and in nest/rt-dev.c `dev_ifa_notify()` calls
`dev_update_route()` for the same prefix for each of them, with the
interface index as the route source. When either address goes down,
`dev_update_route()` withdraws that shared route
(`rte_update(c, net, NULL, src)`), regardless of the remaining address.
A possible fix: on IF_CHANGE_DOWN for a prefix route, check whether another
non-secondary address on the same interface still has the same prefix, and
if so re-announce the route from it instead of withdrawing.
Thanks,
Matthew Darwin
(bugs@mdarwin.ca)