]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Fix backup path RIB handling
authorGalaxyGorilla <sascha@netdef.org>
Tue, 15 Dec 2020 11:20:28 +0000 (11:20 +0000)
committerGalaxyGorilla <sascha@netdef.org>
Tue, 19 Jan 2021 15:32:13 +0000 (15:32 +0000)
  * Inject backup paths with proper flags
  * Add outgoing label on top of the backup label stack
  * Ignore explicit/implicit outgoing labels
  * Adjust tests

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
ospfd/ospf_zebra.c
tests/topotests/ospf-tilfa-topo1/rt1/step2/show_ip_route_link_protection.ref

index 3922c44d9c13bb47c1dcbe78d302c14e1384c490..130108d34841cd55e6c922492c7f1aeec6481528 100644 (file)
@@ -210,7 +210,7 @@ static void ospf_zebra_add_nexthop(struct ospf *ospf, struct ospf_path *path,
                api_nh_backup = &api->backup_nexthops[api->backup_nexthop_num];
                api_nh_backup->vrf_id = ospf->vrf_id;
 
-               api_nh_backup->type = NEXTHOP_TYPE_IPV4_IFINDEX;
+               api_nh_backup->type = NEXTHOP_TYPE_IPV4;
                api_nh_backup->gate.ipv4 = path->srni.backup_nexthop;
 
                api_nh_backup->label_num =
@@ -579,22 +579,33 @@ void ospf_zebra_update_prefix_sid(const struct sr_prefix *srp)
                        if (zl.nexthop_num >= MULTIPATH_NUM)
                                break;
 
-                       /* TI-LFA backup path label stack comes first, if
-                        * present */
+                       /*
+                        * TI-LFA backup path label stack comes first, if
+                        * present.
+                        */
                        if (path->srni.backup_label_stack) {
                                znh_backup = &zl.backup_nexthops
                                                      [zl.backup_nexthop_num++];
-                               znh_backup->type = NEXTHOP_TYPE_IPV4_IFINDEX;
+                               znh_backup->type = NEXTHOP_TYPE_IPV4;
                                znh_backup->gate.ipv4 =
                                        path->srni.backup_nexthop;
 
-                               znh_backup->label_num =
-                                       path->srni.backup_label_stack
-                                               ->num_labels;
                                memcpy(znh_backup->labels,
                                       path->srni.backup_label_stack->label,
                                       sizeof(mpls_label_t)
-                                              * znh_backup->label_num);
+                                              * path->srni.backup_label_stack
+                                                        ->num_labels);
+
+                               znh_backup->label_num =
+                                       path->srni.backup_label_stack
+                                               ->num_labels;
+                               if (path->srni.label_out
+                                           != MPLS_LABEL_IPV4_EXPLICIT_NULL
+                                   && path->srni.label_out
+                                              != MPLS_LABEL_IMPLICIT_NULL)
+                                       znh_backup->labels
+                                               [znh_backup->label_num++] =
+                                               path->srni.label_out;
                        }
 
                        znh = &zl.nexthops[zl.nexthop_num++];
index 0ee495ca3010e030539f5f675ecf1c60ab887192..968570e1939d779cfca0bb0b7f8d90829fdef48f 100644 (file)
@@ -78,7 +78,8 @@
         {
           "ip":"10.0.2.2",
           "labels":[
-            16050
+            16050,
+            16040
           ]
         }
       ]
         {
           "ip":"10.0.1.2",
           "labels":[
-            16040
+            16040,
+            16050
           ]
         }
       ]