]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Remove basic duplicated function
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 6 May 2019 22:03:39 +0000 (18:03 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 9 May 2019 11:09:20 +0000 (07:09 -0400)
Combine the zebra_vrf_other_route_table and zebra_vrf_table_with_table_id
functions into 1 function.  Since they are basically the same thing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/redistribute.c
zebra/zebra_vrf.c
zebra/zebra_vrf.h

index 0071e001c642d9fb92d8ccbe93d541931f5fef16..d2bebb0e29674740c5911308bc06cce84a8733e7 100644 (file)
@@ -653,7 +653,8 @@ int zebra_import_table(afi_t afi, uint32_t table_id, uint32_t distance,
        if (afi >= AFI_MAX)
                return (-1);
 
-       table = zebra_vrf_other_route_table(afi, table_id, VRF_DEFAULT);
+       table = zebra_vrf_table_with_table_id(afi, SAFI_UNICAST,
+                                             table_id, VRF_DEFAULT);
        if (table == NULL) {
                return 0;
        } else if (IS_ZEBRA_DEBUG_RIB) {
@@ -767,8 +768,8 @@ void zebra_import_table_rm_update(const char *rmap)
                        rmap_name = zebra_get_import_table_route_map(afi, i);
                        if ((!rmap_name) || (strcmp(rmap_name, rmap) != 0))
                                continue;
-                       table = zebra_vrf_other_route_table(afi, i,
-                                                           VRF_DEFAULT);
+                       table = zebra_vrf_table_with_table_id(afi, SAFI_UNICAST,
+                                                             i, VRF_DEFAULT);
                        for (rn = route_top(table); rn; rn = route_next(rn)) {
                                /* For each entry in the non-default
                                 * routing table,
index 315d5b49053935e629e09f42be0bb4c2735d1af0..38f8adeae7b33937f6f2bec7a665bc4a079c451b 100644 (file)
@@ -320,27 +320,18 @@ struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
                                                  vrf_id_t vrf_id,
                                                  uint32_t table_id)
 {
-       struct route_table *table = NULL;
+       struct zebra_vrf *zvrf = vrf_info_lookup(vrf_id);
+
+       if (!zvrf)
+               return NULL;
 
        if (afi >= AFI_MAX || safi >= SAFI_MAX)
                return NULL;
 
-       if (vrf_id == VRF_DEFAULT) {
-               if (table_id == RT_TABLE_MAIN)
-                       table = zebra_vrf_table(afi, safi, vrf_id);
-               else
-                       table = zebra_vrf_other_route_table(afi, table_id,
-                                                           vrf_id);
-       } else if (vrf_is_backend_netns()) {
-               if (table_id == RT_TABLE_MAIN)
-                       table = zebra_vrf_table(afi, safi, vrf_id);
-               else
-                       table = zebra_vrf_other_route_table(afi, table_id,
-                                                           vrf_id);
-       } else
-               table = zebra_vrf_table(afi, safi, vrf_id);
+       if (table_id == zvrf->table_id)
+               return zebra_vrf_table(afi, safi, vrf_id);
 
-       return table;
+       return zebra_router_get_table(zvrf, table_id, afi, safi);
 }
 
 void zebra_rtable_node_cleanup(struct route_table *table,
@@ -438,32 +429,6 @@ struct route_table *zebra_vrf_table(afi_t afi, safi_t safi, vrf_id_t vrf_id)
        return zvrf->table[afi][safi];
 }
 
-struct route_table *zebra_vrf_other_route_table(afi_t afi, uint32_t table_id,
-                                               vrf_id_t vrf_id)
-{
-       struct zebra_vrf *zvrf;
-
-       zvrf = vrf_info_lookup(vrf_id);
-       if (!zvrf)
-               return NULL;
-
-       if (afi >= AFI_MAX)
-               return NULL;
-
-       if (table_id != RT_TABLE_MAIN) {
-               if (zvrf->table_id == RT_TABLE_MAIN) {
-                       /* this VRF use default table
-                        * so in all cases, it does not use specific table
-                        * so it is possible to configure tables in this VRF
-                        */
-                       return zebra_router_get_table(zvrf, table_id, afi,
-                                                     SAFI_UNICAST);
-               }
-       }
-
-       return zvrf->table[afi][SAFI_UNICAST];
-}
-
 static int vrf_config_write(struct vty *vty)
 {
        struct vrf *vrf;
index c7a64d300a8e3492e84429feb0ed54e8cd089248..49887f1b6793b20d56b13301c4a353a1f3d675f5 100644 (file)
@@ -202,8 +202,6 @@ extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *);
 extern struct zebra_vrf *zebra_vrf_alloc(void);
 extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t);
 
-extern struct route_table *
-zebra_vrf_other_route_table(afi_t afi, uint32_t table_id, vrf_id_t vrf_id);
 extern int zebra_vrf_has_config(struct zebra_vrf *zvrf);
 extern void zebra_vrf_init(void);