]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Reflect the distance in RIB when it is changed for an arbitrary afi/safi
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Thu, 31 Oct 2019 07:53:18 +0000 (09:53 +0200)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 20 Nov 2019 19:20:39 +0000 (21:20 +0200)
debian-9# show ip route 192.168.255.2/32 longer-prefixes
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B>* 192.168.255.2/32 [20/0] via 192.168.0.1, eth1, 00:15:22
debian-9# conf
debian-9(config)# router bgp 100
debian-9(config-router)# address-family ipv4
debian-9(config-router-af)# distance bgp 123 123 123
debian-9(config-router-af)# do show ip route 192.168.255.2/32 longer-prefixes
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B>* 192.168.255.2/32 [123/0] via 192.168.0.1, eth1, 00:00:09
debian-9(config-router-af)# no distance bgp
debian-9(config-router-af)# do show ip route 192.168.255.2/32 longer-prefixes
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

B>* 192.168.255.2/32 [20/0] via 192.168.0.1, eth1, 00:00:02
debian-9(config-router-af)#

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
bgpd/bgp_route.c

index 9d5348f07964586a84c411890ae75d073da0f72a..f3b6ae1fbebfed2afb7b6ee8f3854a3008dd6775 100644 (file)
@@ -11625,6 +11625,31 @@ uint8_t bgp_distance_apply(struct prefix *p, struct bgp_path_info *pinfo,
        }
 }
 
+/* If we enter `distance bgp (1-255) (1-255) (1-255)`,
+ * we should tell ZEBRA update the routes for a specific
+ * AFI/SAFI to reflect changes in RIB.
+ */
+static void bgp_announce_routes_distance_update(struct bgp *bgp)
+{
+       afi_t afi;
+       safi_t safi;
+
+       FOREACH_AFI_SAFI (afi, safi) {
+               if (!bgp_fibupd_safi(safi))
+                       continue;
+
+               if (bgp->distance_ebgp[afi][safi]
+                   && bgp->distance_ibgp[afi][safi]
+                   && bgp->distance_local[afi][safi]) {
+                       if (BGP_DEBUG(zebra, ZEBRA))
+                               zlog_debug(
+                                       "%s: Announcing routes due to distance change afi/safi (%d/%d)",
+                                       __func__, afi, safi);
+                       bgp_zebra_announce_table(bgp, afi, safi);
+               }
+       }
+}
+
 DEFUN (bgp_distance,
        bgp_distance_cmd,
        "distance bgp (1-255) (1-255) (1-255)",
@@ -11647,6 +11672,7 @@ DEFUN (bgp_distance,
        bgp->distance_ebgp[afi][safi] = atoi(argv[idx_number]->arg);
        bgp->distance_ibgp[afi][safi] = atoi(argv[idx_number_2]->arg);
        bgp->distance_local[afi][safi] = atoi(argv[idx_number_3]->arg);
+       bgp_announce_routes_distance_update(bgp);
        return CMD_SUCCESS;
 }
 
@@ -11670,6 +11696,7 @@ DEFUN (no_bgp_distance,
        bgp->distance_ebgp[afi][safi] = 0;
        bgp->distance_ibgp[afi][safi] = 0;
        bgp->distance_local[afi][safi] = 0;
+       bgp_announce_routes_distance_update(bgp);
        return CMD_SUCCESS;
 }