summaryrefslogtreecommitdiff
path: root/zebra
diff options
context:
space:
mode:
Diffstat (limited to 'zebra')
-rw-r--r--zebra/zapi_msg.c11
-rw-r--r--zebra/zebra_gr.c49
-rw-r--r--zebra/zebra_mlag.c8
-rw-r--r--zebra/zebra_mpls.c82
-rw-r--r--zebra/zebra_nhg.c11
-rw-r--r--zebra/zebra_rib.c2
-rw-r--r--zebra/zebra_vty.c16
-rw-r--r--zebra/zserv.c4
-rw-r--r--zebra/zserv.h4
9 files changed, 107 insertions, 80 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 43bad5522c..1a5a293d11 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -1773,10 +1773,11 @@ static void zread_hello(ZAPI_HANDLER_ARGS)
client->proto = proto;
client->instance = instance;
+
+ /* Graceful restart processing for client connect */
+ zebra_gr_client_reconnect(client);
}
- /* Graceful restart processing for client connect */
- zebra_gr_client_reconnect(client);
zsend_capabilities(client, zvrf);
zebra_vrf_update_all(client);
stream_failure:
@@ -1826,7 +1827,9 @@ static void zread_mpls_labels_add(ZAPI_HANDLER_ARGS)
struct zapi_nexthop *znh;
znh = &zl.nexthops[i];
- mpls_lsp_install(zvrf, zl.type, zl.local_label, 1, znh->labels,
+
+ mpls_lsp_install(zvrf, zl.type, zl.local_label,
+ znh->label_num, znh->labels,
znh->type, &znh->gate, znh->ifindex);
if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN))
@@ -1929,7 +1932,7 @@ static void zread_mpls_labels_replace(ZAPI_HANDLER_ARGS)
znh = &zl.nexthops[i];
mpls_lsp_install(zvrf, zl.type, zl.local_label,
- 1, znh->labels, znh->type,
+ znh->label_num, znh->labels, znh->type,
&znh->gate, znh->ifindex);
if (CHECK_FLAG(zl.message, ZAPI_LABELS_FTN)) {
diff --git a/zebra/zebra_gr.c b/zebra/zebra_gr.c
index 956fe9c2c8..bda1ad6b35 100644
--- a/zebra/zebra_gr.c
+++ b/zebra/zebra_gr.c
@@ -265,30 +265,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 +426,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);
}
diff --git a/zebra/zebra_mlag.c b/zebra/zebra_mlag.c
index fc7804a409..5b721a8eac 100644
--- a/zebra/zebra_mlag.c
+++ b/zebra/zebra_mlag.c
@@ -605,7 +605,7 @@ int32_t zebra_mlag_test_mlag_internal(const char *none, const char *primary,
zsend_capabilities_all_clients();
if (zrouter.mlag_info.role != MLAG_ROLE_NONE) {
if (zrouter.mlag_info.clients_interested_cnt == 0
- && test_mlag_in_progress == false) {
+ && !test_mlag_in_progress) {
if (zrouter.mlag_info.zebra_pth_mlag == NULL)
zebra_mlag_spawn_pthread();
zrouter.mlag_info.clients_interested_cnt++;
@@ -613,7 +613,7 @@ int32_t zebra_mlag_test_mlag_internal(const char *none, const char *primary,
hook_call(zebra_mlag_private_open_channel);
}
} else {
- if (test_mlag_in_progress == true) {
+ if (test_mlag_in_progress) {
test_mlag_in_progress = false;
zrouter.mlag_info.clients_interested_cnt--;
hook_call(zebra_mlag_private_close_channel);
@@ -790,7 +790,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
vrf_name_len);
}
}
- if (cleanup == false) {
+ if (!cleanup) {
Bulk_msg.mroute_add = pay_load;
len = zebra_mlag_mroute_add_bulk__pack(&Bulk_msg,
tmp_buf);
@@ -804,7 +804,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
XFREE(MTYPE_MLAG_PBUF, pay_load[i]);
}
XFREE(MTYPE_MLAG_PBUF, pay_load);
- if (cleanup == true)
+ if (cleanup)
return -1;
} break;
case MLAG_MROUTE_DEL_BULK: {
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index fa6b952244..d373fdf370 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -93,6 +93,8 @@ static void lsp_processq_del(struct work_queue *wq, void *data);
static void lsp_processq_complete(struct work_queue *wq);
static int lsp_processq_add(zebra_lsp_t *lsp);
static void *lsp_alloc(void *p);
+/* Free lsp; sets caller's pointer to NULL */
+static void lsp_free(struct hash *lsp_table, zebra_lsp_t **plsp);
static char *nhlfe2str(zebra_nhlfe_t *nhlfe, char *buf, int size);
static int nhlfe_nhop_match(zebra_nhlfe_t *nhlfe, enum nexthop_types_t gtype,
@@ -250,14 +252,8 @@ static int lsp_install(struct zebra_vrf *zvrf, mpls_label_t label,
if (lsp_processq_add(lsp))
return -1;
} else if (!lsp->nhlfe_list
- && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Free LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
-
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
+ && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED))
+ lsp_free(lsp_table, &lsp);
return 0;
}
@@ -313,14 +309,8 @@ static int lsp_uninstall(struct zebra_vrf *zvrf, mpls_label_t label)
if (lsp_processq_add(lsp))
return -1;
} else if (!lsp->nhlfe_list
- && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Del LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
-
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
+ && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED))
+ lsp_free(lsp_table, &lsp);
return 0;
}
@@ -1047,14 +1037,8 @@ static void lsp_processq_del(struct work_queue *wq, void *data)
nhlfe_del(nhlfe);
}
- if (!lsp->nhlfe_list) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Free LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
-
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
+ if (!lsp->nhlfe_list)
+ lsp_free(lsp_table, &lsp);
}
/*
@@ -1104,6 +1088,37 @@ static void *lsp_alloc(void *p)
}
/*
+ * Dtor for an LSP: remove from ile hash, release any internal allocations,
+ * free LSP object.
+ */
+static void lsp_free(struct hash *lsp_table, zebra_lsp_t **plsp)
+{
+ zebra_lsp_t *lsp;
+ zebra_nhlfe_t *nhlfe, *nhlfe_next;
+
+ if (plsp == NULL || *plsp == NULL)
+ return;
+
+ lsp = *plsp;
+
+ if (IS_ZEBRA_DEBUG_MPLS)
+ zlog_debug("Free LSP in-label %u flags 0x%x",
+ lsp->ile.in_label, lsp->flags);
+
+ /* Free nhlfes, if any. */
+ for (nhlfe = lsp->nhlfe_list; nhlfe; nhlfe = nhlfe_next) {
+ nhlfe_next = nhlfe->next;
+
+ nhlfe_del(nhlfe);
+ }
+
+ hash_release(lsp_table, &lsp->ile);
+ XFREE(MTYPE_LSP, lsp);
+
+ *plsp = NULL;
+}
+
+/*
* Create printable string for NHLFE entry.
*/
static char *nhlfe2str(zebra_nhlfe_t *nhlfe, char *buf, int size)
@@ -1334,14 +1349,8 @@ static int mpls_lsp_uninstall_all(struct hash *lsp_table, zebra_lsp_t *lsp,
if (lsp_processq_add(lsp))
return -1;
} else if (!lsp->nhlfe_list
- && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Free LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
-
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
+ && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED))
+ lsp_free(lsp_table, &lsp);
return 0;
}
@@ -2872,14 +2881,9 @@ int mpls_lsp_uninstall(struct zebra_vrf *zvrf, enum lsp_types_t type,
/* Free LSP entry if no other NHLFEs and not scheduled. */
if (!lsp->nhlfe_list
- && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED)) {
- if (IS_ZEBRA_DEBUG_MPLS)
- zlog_debug("Free LSP in-label %u flags 0x%x",
- lsp->ile.in_label, lsp->flags);
+ && !CHECK_FLAG(lsp->flags, LSP_FLAG_SCHEDULED))
+ lsp_free(lsp_table, &lsp);
- lsp = hash_release(lsp_table, &lsp->ile);
- XFREE(MTYPE_LSP, lsp);
- }
}
return 0;
}
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index 7f81e530fb..8088b78a93 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -1637,7 +1637,16 @@ static unsigned nexthop_active_check(struct route_node *rn,
switch (nexthop->type) {
case NEXTHOP_TYPE_IFINDEX:
ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id);
- if (ifp && if_is_operative(ifp))
+ /*
+ * If the interface exists and its operative or its a kernel
+ * route and interface is up, its active. We trust kernel routes
+ * to be good.
+ */
+ if (ifp
+ && (if_is_operative(ifp)
+ || (if_is_up(ifp)
+ && (re->type == ZEBRA_ROUTE_KERNEL
+ || re->type == ZEBRA_ROUTE_SYSTEM))))
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
else
UNSET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 9185c7ad16..6a2e20d05a 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -3172,7 +3172,7 @@ void rib_update(rib_update_event_t event)
&t_rib_update_threads[event]))
rib_update_ctx_fini(&ctx); /* Already scheduled */
else if (IS_ZEBRA_DEBUG_EVENT)
- zlog_debug("%s: Schedued VRF (ALL), event %s", __func__,
+ zlog_debug("%s: Scheduled VRF (ALL), event %s", __func__,
rib_update_event2str(event));
}
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 8c719f4b6a..f903065f44 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -915,8 +915,8 @@ static void do_show_route_helper(struct vty *vty, struct zebra_vrf *zvrf,
}
}
-static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi,
- bool use_fib, bool use_json,
+static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf,
+ afi_t afi, bool use_fib, bool use_json,
route_tag_t tag,
const struct prefix *longer_prefix_p,
bool supernets_only, int type,
@@ -934,12 +934,12 @@ static void do_show_ip_route_all(struct vty *vty, struct zebra_vrf *zvrf, afi_t
if (zrt->afi != afi ||
zrt->safi != SAFI_UNICAST)
continue;
- if (zrt->table)
- do_show_ip_route(vty, zvrf_name(zvrf), afi,
- SAFI_UNICAST, use_fib, use_json,
- tag, longer_prefix_p,
- supernets_only, type,
- ospf_instance_id, zrt->tableid);
+
+ do_show_ip_route(vty, zvrf_name(zvrf), afi,
+ SAFI_UNICAST, use_fib, use_json,
+ tag, longer_prefix_p,
+ supernets_only, type,
+ ospf_instance_id, zrt->tableid);
}
}
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 2a5352a1da..299c079df1 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -568,7 +568,7 @@ static void zserv_client_free(struct zserv *client)
close(client->sock);
- if (!client->gr_instance_count) {
+ if (DYNAMIC_CLIENT_GR_DISABLED(client)) {
nroutes = rib_score_proto(client->proto,
client->instance);
zlog_notice(
@@ -610,7 +610,7 @@ static void zserv_client_free(struct zserv *client)
* If any instance are graceful restart enabled,
* client is not deleted
*/
- if (!client->gr_instance_count) {
+ if (DYNAMIC_CLIENT_GR_DISABLED(client)) {
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug("%s: Deleting client %s", __func__,
zebra_route_string(client->proto));
diff --git a/zebra/zserv.h b/zebra/zserv.h
index 77ea19202f..6a075cc9a7 100644
--- a/zebra/zserv.h
+++ b/zebra/zserv.h
@@ -229,6 +229,10 @@ struct zserv {
DECLARE_HOOK(zserv_client_connect, (struct zserv *client), (client));
DECLARE_KOOH(zserv_client_close, (struct zserv *client), (client));
+#define DYNAMIC_CLIENT_GR_DISABLED(_client) \
+ ((_client->proto <= ZEBRA_ROUTE_CONNECT) \
+ || !(_client->gr_instance_count))
+
/*
* Initialize Zebra API server.
*