summaryrefslogtreecommitdiff
path: root/zebra/zebra_gr.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_gr.c')
-rw-r--r--zebra/zebra_gr.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/zebra/zebra_gr.c b/zebra/zebra_gr.c
index e8c7304f44..19a280c0ca 100644
--- a/zebra/zebra_gr.c
+++ b/zebra/zebra_gr.c
@@ -127,8 +127,7 @@ static void zebra_gr_client_info_delte(struct zserv *client,
THREAD_OFF(info->t_stale_removal);
- if (info->current_prefix)
- XFREE(MTYPE_TMP, info->current_prefix);
+ XFREE(MTYPE_TMP, info->current_prefix);
LOG_GR("%s: Instance info is being deleted for client %s", __func__,
zebra_route_string(client->proto));
@@ -265,30 +264,31 @@ void zebra_gr_client_reconnect(struct zserv *client)
}
/* Copy the timers */
- if (old_client) {
- client->gr_instance_count = old_client->gr_instance_count;
- client->restart_time = old_client->restart_time;
-
- LOG_GR("%s : old client %s, gr_instance_count %d", __func__,
- zebra_route_string(old_client->proto),
- old_client->gr_instance_count);
-
- if (TAILQ_FIRST(&old_client->gr_info_queue)) {
- TAILQ_CONCAT(&client->gr_info_queue,
- &old_client->gr_info_queue, gr_info);
- TAILQ_INIT(&old_client->gr_info_queue);
- }
+ if (!old_client)
+ return;
- TAILQ_FOREACH (info, &client->gr_info_queue, gr_info) {
- info->stale_client_ptr = client;
- info->stale_client = false;
- }
+ client->gr_instance_count = old_client->gr_instance_count;
+ client->restart_time = old_client->restart_time;
+
+ LOG_GR("%s : old client %s, gr_instance_count %d", __func__,
+ zebra_route_string(old_client->proto),
+ old_client->gr_instance_count);
+
+ if (TAILQ_FIRST(&old_client->gr_info_queue)) {
+ TAILQ_CONCAT(&client->gr_info_queue, &old_client->gr_info_queue,
+ gr_info);
+ TAILQ_INIT(&old_client->gr_info_queue);
+ }
- /* Delete the stale client */
- listnode_delete(zrouter.stale_client_list, old_client);
- /* Delete old client */
- XFREE(MTYPE_TMP, old_client);
+ TAILQ_FOREACH (info, &client->gr_info_queue, gr_info) {
+ info->stale_client_ptr = client;
+ info->stale_client = false;
}
+
+ /* Delete the stale client */
+ listnode_delete(zrouter.stale_client_list, old_client);
+ /* Delete old client */
+ XFREE(MTYPE_TMP, old_client);
}
/*
@@ -425,6 +425,12 @@ void zread_client_capabilities(ZAPI_HANDLER_ARGS)
return;
}
+ /* GR only for dynamic clients */
+ if (client->proto <= ZEBRA_ROUTE_CONNECT) {
+ LOG_GR("%s: GR capabilities for client %s not supported",
+ __func__, zebra_route_string(client->proto));
+ return;
+ }
/* Call the capabilities handler */
zebra_client_capabilities_handler(client, &api);
}
@@ -468,9 +474,7 @@ static int32_t zebra_gr_route_stale_delete_timer_expiry(struct thread *thread)
LOG_GR("%s: Client %s all starle routes processed", __func__,
zebra_route_string(client->proto));
- if (info->current_prefix != NULL)
- XFREE(MTYPE_TMP, info->current_prefix);
- info->current_prefix = NULL;
+ XFREE(MTYPE_TMP, info->current_prefix);
info->current_afi = 0;
zebra_gr_delete_stale_client(info);
}
@@ -516,7 +520,6 @@ static int32_t zebra_gr_delete_stale_route(struct client_gr_info *info,
struct route_entry *next;
struct route_table *table;
int32_t n = 0;
- struct prefix *p;
afi_t afi, curr_afi;
uint8_t proto;
uint16_t instance;
@@ -541,25 +544,21 @@ static int32_t zebra_gr_delete_stale_route(struct client_gr_info *info,
/* Process routes for all AFI */
for (afi = curr_afi; afi < AFI_MAX; afi++) {
table = zvrf->table[afi][SAFI_UNICAST];
- p = info->current_prefix;
if (table) {
/*
* If the current prefix is NULL then get the first
* route entry in the table
*/
- if (p == NULL) {
+ if (info->current_prefix == NULL) {
rn = route_top(table);
if (rn == NULL)
continue;
- p = XCALLOC(MTYPE_TMP, sizeof(struct prefix));
- if (p == NULL)
- return -1;
curr = rn;
- prefix_copy(p, &rn->p);
} else
/* Get the next route entry */
- curr = route_table_get_next(table, p);
+ curr = route_table_get_next(
+ table, info->current_prefix);
for (rn = curr; rn; rn = srcdest_route_next(rn)) {
RNODE_FOREACH_RE_SAFE (rn, re, next) {
@@ -583,9 +582,13 @@ static int32_t zebra_gr_delete_stale_route(struct client_gr_info *info,
*/
if ((n >= ZEBRA_MAX_STALE_ROUTE_COUNT)
&& (info->delete == false)) {
- prefix_copy(p, &rn->p);
info->current_afi = afi;
- info->current_prefix = p;
+ info->current_prefix = XCALLOC(
+ MTYPE_TMP,
+ sizeof(struct prefix));
+ prefix_copy(
+ info->current_prefix,
+ &rn->p);
return n;
}
}
@@ -595,11 +598,7 @@ static int32_t zebra_gr_delete_stale_route(struct client_gr_info *info,
* Reset the current prefix to indicate processing completion
* of the current AFI
*/
- if (info->current_prefix) {
- XFREE(MTYPE_TMP, info->current_prefix);
- info->current_prefix = NULL;
- }
- continue;
+ XFREE(MTYPE_TMP, info->current_prefix);
}
return 0;
}