]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: restart spf when distance is updated
authorckishimo <carles.kishimoto@gmail.com>
Mon, 31 Jan 2022 22:58:14 +0000 (23:58 +0100)
committerckishimo <carles.kishimoto@gmail.com>
Tue, 1 Feb 2022 07:51:17 +0000 (08:51 +0100)
if r1 has a route received from a neighbor with the default administrative
distance configured

    r1# sh 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, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
           f - OpenFabric,
           > - selected route, * - FIB route, q - queued, r - rejected, b - backup
           t - trapped, o - offload failure

    O>* 1.1.1.1/32 [110/20] via 10.0.12.2, r1-r2-eth0, weight 1, 00:00:41

if we change the administrative distance

    r1(config)# router ospf
    r1(config-router)# distance 50

this is not applied as there are no changes in the routing table

    r1# sh 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, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
           f - OpenFabric,
           > - selected route, * - FIB route, q - queued, r - rejected, b - backup
           t - trapped, o - offload failure

    O>* 1.1.1.1/32 [110/20] via 10.0.12.2, r1-r2-eth0, weight 1, 00:00:13

This commit will force the update of the routing table with the new configured distance

    r1# sh 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, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
           f - OpenFabric,
           > - selected route, * - FIB route, q - queued, r - rejected, b - backup
           t - trapped, o - offload failure

    O>* 1.1.1.1/32 [50/20] via 10.0.12.2, r1-r2-eth0, weight 1, 00:00:14

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
ospfd/ospf_vty.c

index 59f03f5fc603c56997fba4f1e4b25f7ccfa24f4e..beb0a6b650eb45d7abbbdf65e5e6e7031d4d89f6 100644 (file)
@@ -9478,8 +9478,13 @@ DEFUN (ospf_distance,
 {
        VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
        int idx_number = 1;
+       uint8_t distance;
 
-       ospf->distance_all = atoi(argv[idx_number]->arg);
+       distance = atoi(argv[idx_number]->arg);
+       if (ospf->distance_all != distance) {
+               ospf->distance_all = distance;
+               ospf_restart_spf(ospf);
+       }
 
        return CMD_SUCCESS;
 }
@@ -9493,7 +9498,10 @@ DEFUN (no_ospf_distance,
 {
        VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
 
-       ospf->distance_all = 0;
+       if (ospf->distance_all) {
+               ospf->distance_all = 0;
+               ospf_restart_spf(ospf);
+       }
 
        return CMD_SUCCESS;
 }