]> git.proxmox.com Git - mirror_frr.git/commitdiff
isisd: move management of route flags out of isis_zebra.c
authorRenato Westphal <renato@opensourcerouting.org>
Wed, 7 Aug 2019 22:42:18 +0000 (19:42 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 17 Sep 2019 03:35:39 +0000 (00:35 -0300)
For better modularity, isis_zebra.c should only contain code used
to communicate with zebra. The management of route flags belongs
to isis_route.c.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
isisd/isis_route.c
isisd/isis_zebra.c
isisd/isis_zebra.h

index 636a63e29094835461966641a25ec37da2e6dc6a..a2b15b1c4d019c3529e2080901513c2815b5a8f4 100644 (file)
@@ -51,6 +51,8 @@
 
 static struct isis_nexthop *nexthoplookup(struct list *nexthops, int family,
                                          union g_addr *ip, ifindex_t ifindex);
+static void isis_route_update(struct prefix *prefix, struct prefix_ipv6 *src_p,
+                             struct isis_route_info *route_info);
 
 static struct isis_nexthop *isis_nexthop_create(int family, union g_addr *ip,
                                                ifindex_t ifindex)
@@ -343,13 +345,34 @@ static void isis_route_delete(struct route_node *rode,
                UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE);
                if (isis->debugs & DEBUG_RTE_EVENTS)
                        zlog_debug("ISIS-Rte: route delete  %s", buff);
-               isis_zebra_route_update(prefix, src_p, rinfo);
+               isis_route_update(prefix, src_p, rinfo);
        }
        isis_route_info_delete(rinfo);
        rode->info = NULL;
        route_unlock_node(rode);
 }
 
+static void isis_route_update(struct prefix *prefix, struct prefix_ipv6 *src_p,
+                             struct isis_route_info *route_info)
+{
+       if (CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ACTIVE)) {
+               if (CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
+                       return;
+
+               isis_zebra_route_add_route(prefix, src_p, route_info);
+
+               SET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
+               UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC);
+       } else {
+               if (!CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
+                       return;
+
+               isis_zebra_route_del_route(prefix, src_p, route_info);
+
+               UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
+       }
+}
+
 static void _isis_route_verify_table(struct isis_area *area,
                                     struct route_table *table,
                                     struct route_table **tables)
@@ -390,7 +413,7 @@ static void _isis_route_verify_table(struct isis_area *area,
                                buff);
                }
 
-               isis_zebra_route_update(dst_p, src_p, rinfo);
+               isis_route_update(dst_p, src_p, rinfo);
 
                if (CHECK_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE))
                        continue;
index e8481a558b430514cd1ca9eb293beb7d1308055e..d1bc20ba5a952ced2335c5ae109cb7fe3967d58f 100644 (file)
@@ -219,9 +219,9 @@ static int isis_zebra_link_params(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-static void isis_zebra_route_add_route(struct prefix *prefix,
-                                      struct prefix_ipv6 *src_p,
-                                      struct isis_route_info *route_info)
+void isis_zebra_route_add_route(struct prefix *prefix,
+                               struct prefix_ipv6 *src_p,
+                               struct isis_route_info *route_info)
 {
        struct zapi_route api;
        struct zapi_nexthop *api_nh;
@@ -229,7 +229,7 @@ static void isis_zebra_route_add_route(struct prefix *prefix,
        struct listnode *node;
        int count = 0;
 
-       if (CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
+       if (zclient->sock < 0)
                return;
 
        memset(&api, 0, sizeof(api));
@@ -292,17 +292,15 @@ static void isis_zebra_route_add_route(struct prefix *prefix,
        api.nexthop_num = count;
 
        zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
-       SET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
-       UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC);
 }
 
-static void isis_zebra_route_del_route(struct prefix *prefix,
-                                      struct prefix_ipv6 *src_p,
-                                      struct isis_route_info *route_info)
+void isis_zebra_route_del_route(struct prefix *prefix,
+                               struct prefix_ipv6 *src_p,
+                               struct isis_route_info *route_info)
 {
        struct zapi_route api;
 
-       if (!CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED))
+       if (zclient->sock < 0)
                return;
 
        memset(&api, 0, sizeof(api));
@@ -316,20 +314,6 @@ static void isis_zebra_route_del_route(struct prefix *prefix,
        }
 
        zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
-       UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED);
-}
-
-void isis_zebra_route_update(struct prefix *prefix,
-                            struct prefix_ipv6 *src_p,
-                            struct isis_route_info *route_info)
-{
-       if (zclient->sock < 0)
-               return;
-
-       if (CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ACTIVE))
-               isis_zebra_route_add_route(prefix, src_p, route_info);
-       else
-               isis_zebra_route_del_route(prefix, src_p, route_info);
 }
 
 static int isis_zebra_read(ZAPI_CALLBACK_ARGS)
index 20c10d0b2372936119f253a61387104b3515340e..d00f348c8e310da35360982c01d412c15608ee2d 100644 (file)
@@ -29,9 +29,12 @@ void isis_zebra_stop(void);
 
 struct isis_route_info;
 
-void isis_zebra_route_update(struct prefix *prefix,
-                            struct prefix_ipv6 *src_p,
-                            struct isis_route_info *route_info);
+void isis_zebra_route_add_route(struct prefix *prefix,
+                               struct prefix_ipv6 *src_p,
+                               struct isis_route_info *route_info);
+void isis_zebra_route_del_route(struct prefix *prefix,
+                               struct prefix_ipv6 *src_p,
+                               struct isis_route_info *route_info);
 int isis_distribute_list_update(int routetype);
 void isis_zebra_redistribute_set(afi_t afi, int type);
 void isis_zebra_redistribute_unset(afi_t afi, int type);