Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zebra: invalid nexthop group if nexthop interface has no more IP address
When the last IP v4 address of an interface is deleted, Linux removes all routes using this interface without any Netlink advertisement. With the following scenarii, zebra routes are unsynchronized with the kernel ones. The first scenario: > root@ubuntu:~# ip l add dummy0 type dummy > root@ubuntu:~# ip l set dummy0 up > root@ubuntu:~# ip r > root@ubuntu:~# vtysh -c 'show ip route' > root@ubuntu:~# ip route add 1.1.1.1 dev dummy0 > root@ubuntu:~# vtysh -c "conf t" -c "ip route 3.3.3.3/32 dummy0" > root@ubuntu:~# ip r > 1.1.1.1 dev dummy0 scope link > root@ubuntu:~# vtysh -c 'show ip route' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > K>* 1.1.1.1/32 [0/0] is directly connected, dummy0, 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, dummy0, weight 1, 00:00:00 > root@ubuntu:~# ip add add 2.0.0.1/24 dev dummy0 > root@ubuntu:~# ip r > 1.1.1.1 dev dummy0 scope link > 2.0.0.0/24 dev dummy0 proto kernel scope link src 2.0.0.1 > 3.3.3.3 nhid 8 dev dummy0 proto 196 metric 20 > root@ubuntu:~# vtysh -c 'show ip route' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > K>* 1.1.1.1/32 [0/0] is directly connected, dummy0, 00:00:00 > C>* 2.0.0.0/24 is directly connected, dummy0, 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, dummy0, weight 1, 00:00:00 > root@ubuntu:~# ip add del 2.0.0.1/24 dev dummy0 > root@ubuntu:~# ip r > 3.3.3.3 nhid 8 dev dummy0 proto 196 metric 20 > root@ubuntu:~# vtysh -c 'show ip route' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > K>* 1.1.1.1/32 [0/0] is directly connected, dummy0, 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, dummy0, weight 1, 00:00:00 > root@ubuntu:~# vtysh -c 'show nexthop-group rib' > ID: 8 (zebra) > RefCnt: 1 > Uptime: 00:00:01 > VRF: default > Valid, Installed > Interface Index: 45 > is directly connected, dummy0 (vrf default), weight 1 > ID: 4 (zebra) > RefCnt: 2 > Uptime: 00:00:01 > VRF: default > Valid, Installed > Interface Index: 45 > is directly connected, dummy0 (vrf default) > ID: 6 (zebra) > RefCnt: 1 > Uptime: 00:00:01 > VRF: default > Valid, Installed > Interface Index: 45 > is directly connected, dummy0 (vrf default) The second scenario: > root@ubuntu:~# ip r > root@ubuntu:~# vtysh -c 'show ip route vrf all' > root@ubuntu:~# ip l add vrf1 type vrf table 10 > root@ubuntu:~# ip l set vrf1 up > root@ubuntu:~# ip route add 1.1.1.1 dev vrf1 > root@ubuntu:~# vtysh -c "conf t" -c "ip route 3.3.3.3/32 vrf1 nexthop-vrf vrf1" > root@ubuntu:~# ip r > 1.1.1.1 dev vrf1 scope link > root@ubuntu:~# vtysh -c 'show ip route vrf all' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > VRF default: > K>* 1.1.1.1/32 [0/0] is directly connected, vrf1 (vrf vrf1), 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, vrf1 (vrf vrf1), weight 1, 00:00:00 > root@ubuntu:~# ip add add 2.0.0.1/24 dev vrf1 > root@ubuntu:~# ip r > 1.1.1.1 dev vrf1 scope link > 3.3.3.3 nhid 6 dev vrf1 proto 196 metric 20 > root@ubuntu:~# vtysh -c 'show ip route vrf all' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > VRF default: > K>* 1.1.1.1/32 [0/0] is directly connected, vrf1 (vrf vrf1), 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, vrf1 (vrf vrf1), weight 1, 00:00:00 > > VRF vrf1: > C>* 2.0.0.0/24 is directly connected, vrf1, 00:00:00 > root@ubuntu:~# ip add del 2.0.0.1/24 dev vrf1 > root@ubuntu:~# ip r > 3.3.3.3 nhid 6 dev vrf1 proto 196 metric 20 > root@ubuntu:~# vtysh -c 'show ip route vrf all' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > VRF default: > K>* 1.1.1.1/32 [0/0] is directly connected, vrf1 (vrf vrf1), 00:00:01 > S>* 3.3.3.3/32 [1/0] is directly connected, vrf1 (vrf vrf1), weight 1, 00:00:01 > root@ubuntu:~# vtysh -c 'show nexthop-group rib' > ID: 4 (zebra) > RefCnt: 1 > Uptime: 00:00:33 > VRF: default > Valid, Installed > Interface Index: 46 > is directly connected, vrf1 (vrf vrf1) > ID: 6 (zebra) > RefCnt: 1 > Uptime: 00:00:33 > VRF: default > Valid, Installed > Interface Index: 46 > is directly connected, vrf1 (vrf vrf1), weight 1 The following scenario is working correctly: > root@ubuntu:~# ip l add vrf1 type vrf table 10 > root@ubuntu:~# ip l set vrf1 up > root@ubuntu:~# ip route add 1.1.1.1 dev vrf1 > root@ubuntu:~# vtysh -c "conf t" -c "ip route 3.3.3.3/32 vrf1 nexthop-vrf vrf1" > root@ubuntu:~# ip r > 1.1.1.1 dev vrf1 scope link > root@ubuntu:~# vtysh -c 'show ip route vrf all' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > VRF default: > K>* 1.1.1.1/32 [0/0] is directly connected, vrf1 (vrf vrf1), 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, vrf1 (vrf vrf1), weight 1, 00:00:00 > root@ubuntu:~# ip add add 2.0.0.1/24 dev vrf1 && ip add add 4.0.0.1/24 dev vrf1 > root@ubuntu:~# ip r > 1.1.1.1 dev vrf1 scope link > 3.3.3.3 nhid 4 dev vrf1 proto 196 metric 20 > root@ubuntu:~# vtysh -c 'show ip route vrf all' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > VRF default: > K>* 1.1.1.1/32 [0/0] is directly connected, vrf1 (vrf vrf1), 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, vrf1 (vrf vrf1), weight 1, 00:00:00 > > VRF vrf1: > C>* 2.0.0.0/24 is directly connected, vrf1, 00:00:00 > C>* 4.0.0.0/24 is directly connected, vrf1, 00:00:00 > root@ubuntu:~# ip add del 2.0.0.1/24 dev vrf1 > root@ubuntu:~# ip r > 1.1.1.1 dev vrf1 scope link > 3.3.3.3 nhid 4 dev vrf1 proto 196 metric 20 > root@ubuntu:~# vtysh -c 'show ip route vrf all' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > VRF default: > K>* 1.1.1.1/32 [0/0] is directly connected, vrf1 (vrf vrf1), 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, vrf1 (vrf vrf1), weight 1, 00:00:00 > > VRF vrf1: > C>* 4.0.0.0/24 is directly connected, vrf1, 00:00:00 > root@ubuntu:~# vtysh -c 'show nexthop-group rib' > ID: 2 (zebra) > RefCnt: 3 > Uptime: 00:00:01 > VRF: default > Valid, Installed > Interface Index: 47 > is directly connected, vrf1 (vrf vrf1) > ID: 4 (zebra) > RefCnt: 1 > Uptime: 00:00:01 > VRF: default > Valid, Installed > Interface Index: 47 > is directly connected, vrf1 (vrf vrf1), weight 1 Invalid "directly connected" nexthop group if the nexthop interface has no more IP address. With the patch: > root@ubuntu:~# ip l add vrf1 type vrf table 10 > root@ubuntu:~# ip l set vrf1 up > root@ubuntu:~# ip route add 1.1.1.1 dev vrf1 > root@ubuntu:~# vtysh -c "conf t" -c "ip route 3.3.3.3/32 vrf1 nexthop-vrf vrf1" > root@ubuntu:~# ip r > 1.1.1.1 dev vrf1 scope link > root@ubuntu:~# vtysh -c 'show ip route vrf all' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > VRF default: > K>* 1.1.1.1/32 [0/0] is directly connected, vrf1 (vrf vrf1), 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, vrf1 (vrf vrf1), weight 1, 00:00:00 > root@ubuntu:~# ip add add 2.0.0.1/24 dev vrf1 > root@ubuntu:~# ip r > 1.1.1.1 dev vrf1 scope link > 3.3.3.3 nhid 4 dev vrf1 proto 196 metric 20 > root@ubuntu:~# vtysh -c 'show ip route vrf all' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > VRF default: > K>* 1.1.1.1/32 [0/0] is directly connected, vrf1 (vrf vrf1), 00:00:00 > S>* 3.3.3.3/32 [1/0] is directly connected, vrf1 (vrf vrf1), weight 1, 00:00:00 > > VRF vrf1: > C>* 2.0.0.0/24 is directly connected, vrf1, 00:00:00 > root@ubuntu:~# ip add del 2.0.0.1/24 dev vrf1 > root@ubuntu:~# ip r > 3.3.3.3 nhid 4 dev vrf1 proto 196 metric 20 > root@ubuntu:~# vtysh -c 'show ip route vrf all' > Codes: K - kernel route, C - connected, S - static, R - RIP, > O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP, > T - Table, A - Babel, F - PBR, f - OpenFabric, > > - selected route, * - FIB route, q - queued, r - rejected, b - backup > t - trapped, o - offload failure > > VRF default: > S>* 3.3.3.3/32 [1/0] is directly connected, vrf1 (vrf vrf1), weight 1, 00:00:00 > root@ubuntu:~# vtysh -c 'show nexthop-group rib' > ID: 4 (zebra) > RefCnt: 1 > Uptime: 00:00:00 > VRF: default > Valid, Installed > Interface Index: 51 > is directly connected, vrf1 (vrf vrf1), weight 1 Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
- Loading branch information