From 67cc8c5e5f3ad79f9fee6417071f4aea77726156 Mon Sep 17 00:00:00 2001 From: vivek Date: Fri, 26 Feb 2016 19:51:34 +0000 Subject: [PATCH] Zebra: Fix static NHT to work properly in a VRF Cleanup code and improve debugs as part of fixing NHT for static routes in a VRF. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp Reviewed-by: Don Slice Ticket: CM-9457 Reviewed By: CCR-4185 Testing Done: Manual verification --- zebra/zebra_rnh.c | 70 ++++++++++++----------------------------------- zebra/zebra_rnh.h | 1 - 2 files changed, 18 insertions(+), 53 deletions(-) diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index a10b31c2af..4b80dcceda 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -103,17 +103,19 @@ zebra_add_rnh (struct prefix *p, vrf_id_t vrfid, rnh_type_t type) struct route_table *table; struct route_node *rn; struct rnh *rnh = NULL; + char buf[PREFIX2STR_BUFFER]; if (IS_ZEBRA_DEBUG_NHT) { - char buf[PREFIX2STR_BUFFER]; prefix2str(p, buf, sizeof (buf)); - zlog_debug("add rnh %s in vrf %d", buf, vrfid); + zlog_debug("%u: Add RNH %s type %d", vrfid, buf, type); } table = get_rnh_table(vrfid, PREFIX_FAMILY(p), type); if (!table) { - zlog_debug("add_rnh: rnh table not found\n"); + prefix2str(p, buf, sizeof (buf)); + zlog_warn("%u: Add RNH %s type %d - table not found", + vrfid, buf, type); return NULL; } @@ -171,7 +173,8 @@ zebra_delete_rnh (struct rnh *rnh, rnh_type_t type) if (IS_ZEBRA_DEBUG_NHT) { char buf[PREFIX2STR_BUFFER]; - zlog_debug("delete rnh %s", rnh_str(rnh, buf, sizeof (buf))); + zlog_debug("%u: Del RNH %s type %d", + rnh->vrf_id, rnh_str(rnh, buf, sizeof (buf)), type); } rnh->flags |= ZEBRA_NHT_DELETED; @@ -191,9 +194,9 @@ zebra_add_rnh_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, if (IS_ZEBRA_DEBUG_NHT) { char buf[PREFIX2STR_BUFFER]; - zlog_debug("client %s registers rnh %s", - zebra_route_string(client->proto), - rnh_str(rnh, buf, sizeof (buf))); + zlog_debug("%u: Client %s registers for RNH %s type %d", + vrf_id, zebra_route_string(client->proto), + rnh_str(rnh, buf, sizeof (buf)), type); } if (!listnode_lookup(rnh->client_list, client)) { @@ -208,9 +211,9 @@ zebra_remove_rnh_client (struct rnh *rnh, struct zserv *client, rnh_type_t type) if (IS_ZEBRA_DEBUG_NHT) { char buf[PREFIX2STR_BUFFER]; - zlog_debug("client %s unregisters rnh %s", + zlog_debug("Client %s unregisters for RNH %s type %d", zebra_route_string(client->proto), - rnh_str(rnh, buf, sizeof (buf))); + rnh_str(rnh, buf, sizeof (buf)), type); } listnode_delete(rnh->client_list, client); if (list_isempty(rnh->client_list) && @@ -703,40 +706,6 @@ zebra_evaluate_rnh (vrf_id_t vrfid, int family, int force, rnh_type_t type, } } -int -zebra_dispatch_rnh_table (vrf_id_t vrf_id, int family, struct zserv *client, - rnh_type_t type) -{ - struct route_table *ntable; - struct route_node *nrn; - struct rnh *rnh; - - ntable = get_rnh_table(vrf_id, family, type); - if (!ntable) - { - zlog_debug("dispatch_rnh_table: rnh table not found\n"); - return -1; - } - - for (nrn = route_top (ntable); nrn; nrn = route_next (nrn)) - { - if (!nrn->info) - continue; - - rnh = nrn->info; - if (IS_ZEBRA_DEBUG_NHT) - { - char bufn[PREFIX2STR_BUFFER]; - prefix2str(&nrn->p, bufn, sizeof (bufn)); - zlog_debug("rnh %s - sending nexthop %s event to client %s", bufn, - rnh->state ? "reachable" : "unreachable", - zebra_route_string(client->proto)); - } - send_client(rnh, client, RNH_NEXTHOP_TYPE, vrf_id); - } - return 1; -} - void zebra_print_rnh_table (vrf_id_t vrfid, int af, struct vty *vty, rnh_type_t type) { @@ -756,14 +725,18 @@ zebra_print_rnh_table (vrf_id_t vrfid, int af, struct vty *vty, rnh_type_t type) } int -zebra_cleanup_rnh_client (vrf_id_t vrfid, int family, struct zserv *client, +zebra_cleanup_rnh_client (vrf_id_t vrf_id, int family, struct zserv *client, rnh_type_t type) { struct route_table *ntable; struct route_node *nrn; struct rnh *rnh; - ntable = get_rnh_table(vrfid, family, type); + if (IS_ZEBRA_DEBUG_NHT) + zlog_debug("%u: Client %s RNH cleanup for family %d type %d", + vrf_id, zebra_route_string(client->proto), family, type); + + ntable = get_rnh_table(vrf_id, family, type); if (!ntable) { zlog_debug("cleanup_rnh_client: rnh table not found\n"); @@ -776,13 +749,6 @@ zebra_cleanup_rnh_client (vrf_id_t vrfid, int family, struct zserv *client, continue; rnh = nrn->info; - if (IS_ZEBRA_DEBUG_NHT) - { - char bufn[PREFIX2STR_BUFFER]; - prefix2str(&nrn->p, bufn, sizeof (bufn)); - zlog_debug("rnh %s - cleaning state for client %s", bufn, - zebra_route_string(client->proto)); - } zebra_remove_rnh_client(rnh, client, type); } return 1; diff --git a/zebra/zebra_rnh.h b/zebra/zebra_rnh.h index 0732a4f927..3a57ef1bc6 100644 --- a/zebra/zebra_rnh.h +++ b/zebra/zebra_rnh.h @@ -70,7 +70,6 @@ extern void zebra_remove_rnh_client(struct rnh *rnh, struct zserv *client, rnh_type_t type); extern void zebra_evaluate_rnh(vrf_id_t vrfid, int family, int force, rnh_type_t type, struct prefix *p); -extern int zebra_dispatch_rnh_table(vrf_id_t vrfid, int family, struct zserv *cl, rnh_type_t); extern void zebra_print_rnh_table(vrf_id_t vrfid, int family, struct vty *vty, rnh_type_t); extern char *rnh_str(struct rnh *rnh, char *buf, int size); extern int zebra_cleanup_rnh_client(vrf_id_t vrf, int family, struct zserv *client, -- 2.39.5