diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2016-10-30 22:50:26 +0100 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2016-11-28 19:18:35 +0100 |
commit | 661512bf053ecc3d441bb8938dcd4541ae7ffc33 (patch) | |
tree | 01233125543e939ed1e5bd23c050509755c5db50 | |
parent | lib/zebra: put vrf_get() on a diet (diff) | |
download | frr-661512bf053ecc3d441bb8938dcd4541ae7ffc33.tar.xz frr-661512bf053ecc3d441bb8938dcd4541ae7ffc33.zip |
zebra/lib: remove redundant fields from zebra_vrf
There's no need to duplicate the 'vrf_id' and 'name' fields from the 'vrf'
structure into the 'zebra_vrf' structure. Instead of that, add a back
pointer in 'zebra_vrf' that should point to the associated 'vrf' structure.
Additionally, modify the vrf callbacks to pass the whole vrf structure
as a parameter. This allow us to make further simplifications in the code.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
-rw-r--r-- | bgpd/bgp_main.c | 32 | ||||
-rw-r--r-- | lib/vrf.c | 18 | ||||
-rw-r--r-- | lib/vrf.h | 2 | ||||
-rw-r--r-- | zebra/redistribute.c | 16 | ||||
-rw-r--r-- | zebra/router-id.c | 16 | ||||
-rw-r--r-- | zebra/rt_netlink.c | 4 | ||||
-rw-r--r-- | zebra/rtadv.c | 8 | ||||
-rw-r--r-- | zebra/zebra_fpm.c | 2 | ||||
-rw-r--r-- | zebra/zebra_fpm_netlink.c | 2 | ||||
-rw-r--r-- | zebra/zebra_mpls.c | 4 | ||||
-rw-r--r-- | zebra/zebra_ptm.c | 8 | ||||
-rw-r--r-- | zebra/zebra_rib.c | 32 | ||||
-rw-r--r-- | zebra/zebra_static.c | 2 | ||||
-rw-r--r-- | zebra/zebra_vrf.c | 69 | ||||
-rw-r--r-- | zebra/zebra_vrf.h | 21 | ||||
-rw-r--r-- | zebra/zebra_vty.c | 58 | ||||
-rw-r--r-- | zebra/zserv.c | 58 |
17 files changed, 164 insertions, 188 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 4e31eb344..91eacc932 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -308,38 +308,33 @@ bgp_exit (int status) } static int -bgp_vrf_new (vrf_id_t vrf_id, const char *name, void **info) +bgp_vrf_new (struct vrf *vrf) { if (BGP_DEBUG (zebra, ZEBRA)) - zlog_debug ("VRF Created: %s(%d)", name, vrf_id); + zlog_debug ("VRF Created: %s(%d)", vrf->name, vrf->vrf_id); return 0; } static int -bgp_vrf_delete (vrf_id_t vrf_id, const char *name, void **info) +bgp_vrf_delete (struct vrf *vrf) { if (BGP_DEBUG (zebra, ZEBRA)) - zlog_debug ("VRF Deletion: %s(%d)", name, vrf_id); + zlog_debug ("VRF Deletion: %s(%d)", vrf->name, vrf->vrf_id); return 0; } static int -bgp_vrf_enable (vrf_id_t vrf_id, const char *name, void **info) +bgp_vrf_enable (struct vrf *vrf) { - struct vrf *vrf; struct bgp *bgp; vrf_id_t old_vrf_id; - vrf = vrf_lookup_by_id (vrf_id); - if (!vrf) // unexpected - return -1; - if (BGP_DEBUG (zebra, ZEBRA)) - zlog_debug("VRF enable add %s id %d", name, vrf_id); + zlog_debug("VRF enable add %s id %d", vrf->name, vrf->vrf_id); - bgp = bgp_lookup_by_name(name); + bgp = bgp_lookup_by_name (vrf->name); if (bgp) { old_vrf_id = bgp->vrf_id; @@ -356,23 +351,18 @@ bgp_vrf_enable (vrf_id_t vrf_id, const char *name, void **info) } static int -bgp_vrf_disable (vrf_id_t vrf_id, const char *name, void **info) +bgp_vrf_disable (struct vrf *vrf) { - struct vrf *vrf; struct bgp *bgp; vrf_id_t old_vrf_id; - if (vrf_id == VRF_DEFAULT) + if (vrf->vrf_id == VRF_DEFAULT) return 0; - vrf = vrf_lookup_by_id (vrf_id); - if (!vrf) // unexpected - return -1; - if (BGP_DEBUG (zebra, ZEBRA)) - zlog_debug("VRF disable %s id %d", name, vrf_id); + zlog_debug("VRF disable %s id %d", vrf->name, vrf->vrf_id); - bgp = bgp_lookup_by_name(name); + bgp = bgp_lookup_by_name (vrf->name); if (bgp) { old_vrf_id = bgp->vrf_id; @@ -53,10 +53,10 @@ int debug_vrf = 0; /* Holding VRF hooks */ struct vrf_master { - int (*vrf_new_hook) (vrf_id_t, const char *, void **); - int (*vrf_delete_hook) (vrf_id_t, const char *, void **); - int (*vrf_enable_hook) (vrf_id_t, const char *, void **); - int (*vrf_disable_hook) (vrf_id_t, const char *, void **); + int (*vrf_new_hook) (struct vrf *); + int (*vrf_delete_hook) (struct vrf *); + int (*vrf_enable_hook) (struct vrf *); + int (*vrf_disable_hook) (struct vrf *); } vrf_master = {0,}; static int vrf_is_enabled (struct vrf *vrf); @@ -143,7 +143,7 @@ vrf_get (vrf_id_t vrf_id, const char *name) } if (new && vrf_master.vrf_new_hook) - (*vrf_master.vrf_new_hook) (vrf_id, name, &vrf->info); + (*vrf_master.vrf_new_hook) (vrf); return vrf; } @@ -159,7 +159,7 @@ vrf_delete (struct vrf *vrf) vrf_disable (vrf); if (vrf_master.vrf_delete_hook) - (*vrf_master.vrf_delete_hook) (vrf->vrf_id, vrf->name, &vrf->info); + (*vrf_master.vrf_delete_hook) (vrf); QOBJ_UNREG (vrf); if_terminate (&vrf->iflist); @@ -209,7 +209,7 @@ vrf_enable (struct vrf *vrf) SET_FLAG (vrf->status, VRF_ACTIVE); if (vrf_master.vrf_enable_hook) - (*vrf_master.vrf_enable_hook) (vrf->vrf_id, vrf->name, &vrf->info); + (*vrf_master.vrf_enable_hook) (vrf); return 1; } @@ -234,13 +234,13 @@ vrf_disable (struct vrf *vrf) //Pending: see why this statement. if (vrf_master.vrf_disable_hook) - (*vrf_master.vrf_disable_hook) (vrf->vrf_id, vrf->name, &vrf->info); + (*vrf_master.vrf_disable_hook) (vrf); } /* Add a VRF hook. Please add hooks before calling vrf_init(). */ void -vrf_add_hook (int type, int (*func)(vrf_id_t, const char *, void **)) +vrf_add_hook (int type, int (*func)(struct vrf *)) { if (debug_vrf) zlog_debug ("%s: Add Hook %d to function %p", __PRETTY_FUNCTION__, @@ -108,7 +108,7 @@ extern struct vrf_name_head vrfs_by_name; * - param 2: the address of the user data pointer (the user data * can be stored in or freed from there) */ -extern void vrf_add_hook (int, int (*)(vrf_id_t, const char *, void **)); +extern void vrf_add_hook (int, int (*)(struct vrf *)); extern struct vrf *vrf_lookup_by_id (vrf_id_t); extern struct vrf *vrf_lookup_by_name (const char *); diff --git a/zebra/redistribute.c b/zebra/redistribute.c index c74485bb3..9c7ef5f12 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -262,13 +262,13 @@ zebra_redistribute_add (int command, struct zserv *client, int length, if (! redist_check_instance (&client->mi_redist[afi][type], instance)) { redist_add_instance (&client->mi_redist[afi][type], instance); - zebra_redistribute (client, type, instance, zvrf->vrf_id); + zebra_redistribute (client, type, instance, zvrf_id (zvrf)); } } else { - if (! vrf_bitmap_check (client->redist[afi][type], zvrf->vrf_id)) + if (! vrf_bitmap_check (client->redist[afi][type], zvrf_id (zvrf))) { - vrf_bitmap_set (client->redist[afi][type], zvrf->vrf_id); - zebra_redistribute (client, type, 0, zvrf->vrf_id); + vrf_bitmap_set (client->redist[afi][type], zvrf_id (zvrf)); + zebra_redistribute (client, type, 0, zvrf_id (zvrf)); } } } @@ -296,22 +296,22 @@ zebra_redistribute_delete (int command, struct zserv *client, int length, if (instance) redist_del_instance (&client->mi_redist[afi][type], instance); else - vrf_bitmap_unset (client->redist[afi][type], zvrf->vrf_id); + vrf_bitmap_unset (client->redist[afi][type], zvrf_id (zvrf)); } void zebra_redistribute_default_add (int command, struct zserv *client, int length, struct zebra_vrf *zvrf) { - vrf_bitmap_set (client->redist_default, zvrf->vrf_id); - zebra_redistribute_default (client, zvrf->vrf_id); + vrf_bitmap_set (client->redist_default, zvrf_id (zvrf)); + zebra_redistribute_default (client, zvrf_id (zvrf)); } void zebra_redistribute_default_delete (int command, struct zserv *client, int length, struct zebra_vrf *zvrf) { - vrf_bitmap_unset (client->redist_default, zvrf->vrf_id); + vrf_bitmap_unset (client->redist_default, zvrf_id (zvrf)); } /* Interface up information. */ diff --git a/zebra/router-id.c b/zebra/router-id.c index 079961139..0aa1bdc77 100644 --- a/zebra/router-id.c +++ b/zebra/router-id.c @@ -138,7 +138,7 @@ router_id_add_address (struct connected *ifc) if (router_id_bad_address (ifc)) return; - router_id_get (&before, zvrf->vrf_id); + router_id_get (&before, zvrf_id (zvrf)); if (!strncmp (ifc->ifp->name, "lo", 2) || !strncmp (ifc->ifp->name, "dummy", 5)) @@ -149,13 +149,13 @@ router_id_add_address (struct connected *ifc) if (!router_id_find_node (l, ifc)) listnode_add_sort (l, ifc); - router_id_get (&after, zvrf->vrf_id); + router_id_get (&after, zvrf_id (zvrf)); if (prefix_same (&before, &after)) return; for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client)) - zsend_router_id_update (client, &after, zvrf->vrf_id); + zsend_router_id_update (client, &after, zvrf_id (zvrf)); } void @@ -172,7 +172,7 @@ router_id_del_address (struct connected *ifc) if (router_id_bad_address (ifc)) return; - router_id_get (&before, zvrf->vrf_id); + router_id_get (&before, zvrf_id (zvrf)); if (!strncmp (ifc->ifp->name, "lo", 2) || !strncmp (ifc->ifp->name, "dummy", 5)) @@ -183,13 +183,13 @@ router_id_del_address (struct connected *ifc) if ((c = router_id_find_node (l, ifc))) listnode_delete (l, c); - router_id_get (&after, zvrf->vrf_id); + router_id_get (&after, zvrf_id (zvrf)); if (prefix_same (&before, &after)) return; for (ALL_LIST_ELEMENTS_RO (zebrad.client_list, node, client)) - zsend_router_id_update (client, &after, zvrf->vrf_id); + zsend_router_id_update (client, &after, zvrf_id (zvrf)); } void @@ -202,14 +202,14 @@ router_id_write (struct vty *vty) if ((zvrf = vrf->info) != NULL) if (zvrf->rid_user_assigned.u.prefix4.s_addr) { - if (zvrf->vrf_id == VRF_DEFAULT) + if (zvrf_id (zvrf) == VRF_DEFAULT) vty_out (vty, "router-id %s%s", inet_ntoa (zvrf->rid_user_assigned.u.prefix4), VTY_NEWLINE); else vty_out (vty, "router-id %s vrf %s%s", inet_ntoa (zvrf->rid_user_assigned.u.prefix4), - zvrf->name, + zvrf_name (zvrf), VTY_NEWLINE); } } diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index b18bf1ef7..c04f9188f 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -107,7 +107,7 @@ vrf_lookup_by_table (u_int32_t table_id) (zvrf->table_id != table_id)) continue; - return zvrf->vrf_id; + return zvrf_id (zvrf); } return VRF_DEFAULT; @@ -1069,7 +1069,7 @@ _netlink_route_debug( zlog_debug ("netlink_route_multipath() (%s): %s %s vrf %u type %s", routedesc, nl_msg_type_to_str (cmd), - prefix2str (p, buf, sizeof(buf)), zvrf->vrf_id, + prefix2str (p, buf, sizeof(buf)), zvrf_id (zvrf), (nexthop) ? nexthop_type_to_str (nexthop->type) : "UNK"); } } diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 1ab7ac147..26c83bc6a 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -826,7 +826,7 @@ zebra_interface_radv_set (struct zserv *client, int sock, u_short length, if (IS_ZEBRA_DEBUG_EVENT) zlog_debug("%u: IF %u RA %s from client %s, interval %ds", - zvrf->vrf_id, ifindex, enable ? "enable" : "disable", + zvrf_id (zvrf), ifindex, enable ? "enable" : "disable", zebra_route_string(client->proto), ra_interval); /* Locate interface and check VRF match. */ @@ -834,14 +834,14 @@ zebra_interface_radv_set (struct zserv *client, int sock, u_short length, if (!ifp) { zlog_warn("%u: IF %u RA %s client %s - interface unknown", - zvrf->vrf_id, ifindex, enable ? "enable" : "disable", + zvrf_id (zvrf), ifindex, enable ? "enable" : "disable", zebra_route_string(client->proto)); return; } - if (ifp->vrf_id != zvrf->vrf_id) + if (ifp->vrf_id != zvrf_id (zvrf)) { zlog_warn("%u: IF %u RA %s client %s - VRF mismatch, IF VRF %u", - zvrf->vrf_id, ifindex, enable ? "enable" : "disable", + zvrf_id (zvrf), ifindex, enable ? "enable" : "disable", zebra_route_string(client->proto), ifp->vrf_id); return; } diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 343ce1776..5920cde29 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -348,7 +348,7 @@ zfpm_is_table_for_fpm (struct route_table *table) * We only send the unicast tables in the main instance to the FPM * at this point. */ - if (info->zvrf->vrf_id != 0) + if (zvrf_id (info->zvrf) != 0) return 0; if (info->safi != SAFI_UNICAST) diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 654329860..be77e91a5 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -245,7 +245,7 @@ netlink_route_info_fill (netlink_route_info_t *ri, int cmd, ri->af = rib_dest_af (dest); ri->nlmsg_type = cmd; - ri->rtm_table = rib_dest_vrf (dest)->vrf_id; + ri->rtm_table = zvrf_id (rib_dest_vrf (dest)); ri->rtm_protocol = RTPROT_UNSPEC; /* diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index b64cab625..2ed0ce767 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1268,7 +1268,7 @@ mpls_ftn_update (int add, struct zebra_vrf *zvrf, enum lsp_types_t type, struct nexthop *nexthop; /* Lookup table. */ - table = zebra_vrf_table (family2afi(prefix->family), SAFI_UNICAST, zvrf->vrf_id); + table = zebra_vrf_table (family2afi(prefix->family), SAFI_UNICAST, zvrf_id (zvrf)); if (! table) return -1; @@ -1502,7 +1502,7 @@ mpls_ldp_ftn_uninstall_all (struct zebra_vrf *zvrf, int afi) int update; /* Process routes of interested address-families. */ - table = zebra_vrf_table (afi, SAFI_UNICAST, zvrf->vrf_id); + table = zebra_vrf_table (afi, SAFI_UNICAST, zvrf_id (zvrf)); if (!table) return; diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index fe1f6e0e6..e6d13b507 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -768,9 +768,9 @@ zebra_ptm_bfd_dst_register (struct zserv *client, int sock, u_short length, ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_MAX_HOP_CNT_FIELD, tmp_buf); - if (zvrf->vrf_id != VRF_DEFAULT) + if (zvrf_id (zvrf) != VRF_DEFAULT) ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_VRF_NAME_FIELD, - zvrf->name); + zvrf_name (zvrf)); } else { @@ -915,9 +915,9 @@ zebra_ptm_bfd_dst_deregister (struct zserv *client, int sock, u_short length, ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); } #endif /* HAVE_IPV6 */ - if (zvrf->vrf_id != VRF_DEFAULT) + if (zvrf_id (zvrf) != VRF_DEFAULT) ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_VRF_NAME_FIELD, - zvrf->name); + zvrf_name (zvrf)); } else { diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 9d9b10457..54caeba89 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1353,7 +1353,7 @@ rib_gc_dest (struct route_node *rn) zvrf = rib_dest_vrf (dest); if (IS_ZEBRA_DEBUG_RIB) - rnode_debug (rn, zvrf->vrf_id, "removing dest from table"); + rnode_debug (rn, zvrf_id (zvrf), "removing dest from table"); dest->rnode = NULL; XFREE (MTYPE_RIB_DEST, dest); @@ -1386,7 +1386,7 @@ rib_process_add_fib(struct zebra_vrf *zvrf, struct route_node *rn, { inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN); zlog_debug ("%u:%s/%d: Adding route rn %p, rib %p (type %d)", - zvrf->vrf_id, buf, rn->p.prefixlen, rn, new, new->type); + zvrf_id (zvrf), buf, rn->p.prefixlen, rn, new, new->type); } if (!RIB_SYSTEM_ROUTE (new)) @@ -1395,7 +1395,7 @@ rib_process_add_fib(struct zebra_vrf *zvrf, struct route_node *rn, { inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN); zlog_warn ("%u:%s/%d: Route install failed", - zvrf->vrf_id, buf, rn->p.prefixlen); + zvrf_id (zvrf), buf, rn->p.prefixlen); } } @@ -1415,7 +1415,7 @@ rib_process_del_fib(struct zebra_vrf *zvrf, struct route_node *rn, { inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN); zlog_debug ("%u:%s/%d: Deleting route rn %p, rib %p (type %d)", - zvrf->vrf_id, buf, rn->p.prefixlen, rn, old, old->type); + zvrf_id (zvrf), buf, rn->p.prefixlen, rn, old, old->type); } if (!RIB_SYSTEM_ROUTE (old)) @@ -1464,11 +1464,11 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, { if (new != old) zlog_debug ("%u:%s/%d: Updating route rn %p, rib %p (type %d) " - "old %p (type %d)", zvrf->vrf_id, buf, rn->p.prefixlen, + "old %p (type %d)", zvrf_id (zvrf), buf, rn->p.prefixlen, rn, new, new->type, old, old->type); else zlog_debug ("%u:%s/%d: Updating route rn %p, rib %p (type %d)", - zvrf->vrf_id, buf, rn->p.prefixlen, rn, new, new->type); + zvrf_id (zvrf), buf, rn->p.prefixlen, rn, new, new->type); } /* Non-system route should be installed. */ if (!RIB_SYSTEM_ROUTE (new)) @@ -1478,7 +1478,7 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, installed = 0; inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN); zlog_warn ("%u:%s/%d: Route install failed", - zvrf->vrf_id, buf, rn->p.prefixlen); + zvrf_id (zvrf), buf, rn->p.prefixlen); } } @@ -1512,12 +1512,12 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, { if (new != old) zlog_debug ("%u:%s/%d: Deleting route rn %p, rib %p (type %d) " - "old %p (type %d) - %s", zvrf->vrf_id, buf, rn->p.prefixlen, + "old %p (type %d) - %s", zvrf_id (zvrf), buf, rn->p.prefixlen, rn, new, new->type, old, old->type, nh_active ? "install failed" : "nexthop inactive"); else zlog_debug ("%u:%s/%d: Deleting route rn %p, rib %p (type %d) - %s", - zvrf->vrf_id, buf, rn->p.prefixlen, rn, new, new->type, + zvrf_id (zvrf), buf, rn->p.prefixlen, rn, new, new->type, nh_active ? "install failed" : "nexthop inactive"); } @@ -1627,7 +1627,7 @@ rib_process (struct route_node *rn) if (dest) { zvrf = rib_dest_vrf (dest); - vrf_id = zvrf->vrf_id; + vrf_id = zvrf_id (zvrf); } if (IS_ZEBRA_DEBUG_RIB) @@ -2027,7 +2027,7 @@ process_subq (struct list * subq, u_char qindex) { inet_ntop (rnode->p.family, &rnode->p.u.prefix, buf, INET6_ADDRSTRLEN); zlog_debug ("%u:%s/%d: rn %p dequeued from sub-queue %u", - zvrf ? zvrf->vrf_id : 0, buf, rnode->p.prefixlen, rnode, qindex); + zvrf ? zvrf_id (zvrf) : 0, buf, rnode->p.prefixlen, rnode, qindex); } if (rnode->info) @@ -2066,10 +2066,10 @@ meta_queue_process_complete (struct work_queue *dummy) continue; zvrf->flags &= ~ZEBRA_VRF_RIB_SCHEDULED; - zebra_evaluate_rnh(zvrf->vrf_id, AF_INET, 0, RNH_NEXTHOP_TYPE, NULL); - zebra_evaluate_rnh(zvrf->vrf_id, AF_INET, 0, RNH_IMPORT_CHECK_TYPE, NULL); - zebra_evaluate_rnh(zvrf->vrf_id, AF_INET6, 0, RNH_NEXTHOP_TYPE, NULL); - zebra_evaluate_rnh(zvrf->vrf_id, AF_INET6, 0, RNH_IMPORT_CHECK_TYPE, NULL); + zebra_evaluate_rnh(zvrf_id (zvrf), AF_INET, 0, RNH_NEXTHOP_TYPE, NULL); + zebra_evaluate_rnh(zvrf_id (zvrf), AF_INET, 0, RNH_IMPORT_CHECK_TYPE, NULL); + zebra_evaluate_rnh(zvrf_id (zvrf), AF_INET6, 0, RNH_NEXTHOP_TYPE, NULL); + zebra_evaluate_rnh(zvrf_id (zvrf), AF_INET6, 0, RNH_IMPORT_CHECK_TYPE, NULL); } /* Schedule LSPs for processing, if needed. */ @@ -2077,7 +2077,7 @@ meta_queue_process_complete (struct work_queue *dummy) if (mpls_should_lsps_be_processed(zvrf)) { if (IS_ZEBRA_DEBUG_MPLS) - zlog_debug ("%u: Scheduling all LSPs upon RIB completion", zvrf->vrf_id); + zlog_debug ("%u: Scheduling all LSPs upon RIB completion", zvrf_id (zvrf)); zebra_mpls_lsp_schedule (zvrf); mpls_unmark_lsps_for_processing(zvrf); } diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index 32ba90ef9..a7a68bd0d 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -422,7 +422,7 @@ static_add_route (afi_t afi, safi_t safi, u_char type, struct prefix *p, si->distance = distance; si->flags = flags; si->tag = tag; - si->vrf_id = zvrf->vrf_id; + si->vrf_id = zvrf_id (zvrf); si->ifindex = ifindex; if (si->ifindex) strcpy(si->ifname, ifname); diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 94e5d49c2..fbfa70d63 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -45,7 +45,7 @@ zebra_vrf_add_update (struct zebra_vrf *zvrf) struct zserv *client; if (IS_ZEBRA_DEBUG_EVENT) - zlog_debug ("MESSAGE: ZEBRA_VRF_ADD %s", zvrf->name); + zlog_debug ("MESSAGE: ZEBRA_VRF_ADD %s", zvrf_name (zvrf)); for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) zsend_vrf_add (client, zvrf); @@ -58,7 +58,7 @@ zebra_vrf_delete_update (struct zebra_vrf *zvrf) struct zserv *client; if (IS_ZEBRA_DEBUG_EVENT) - zlog_debug ("MESSAGE: ZEBRA_VRF_DELETE %s", zvrf->name); + zlog_debug ("MESSAGE: ZEBRA_VRF_DELETE %s", zvrf_name (zvrf)); for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client)) zsend_vrf_delete (client, zvrf); @@ -78,32 +78,18 @@ zebra_vrf_update_all (struct zserv *client) /* Callback upon creating a new VRF. */ static int -zebra_vrf_new (vrf_id_t vrf_id, const char *name, void **info) +zebra_vrf_new (struct vrf *vrf) { - struct zebra_vrf *zvrf = *info; + struct zebra_vrf *zvrf; if (IS_ZEBRA_DEBUG_EVENT) - zlog_info ("ZVRF %s with id %u", name, vrf_id); - - if (! zvrf) - { - zvrf = zebra_vrf_lookup_by_name (name); - if (!zvrf) - { - zvrf = zebra_vrf_alloc (vrf_id, name); - zvrf->zns = zebra_ns_lookup (NS_DEFAULT); /* Point to the global (single) NS */ - *info = (void *)zvrf; - router_id_init (zvrf); - } - else - { - *info = (void *)zvrf; - router_id_init (zvrf); - } - } + zlog_info ("ZVRF %s with id %u", vrf->name, vrf->vrf_id); - if (zvrf->vrf_id == VRF_UNKNOWN) - zvrf->vrf_id = vrf_id; + zvrf = zebra_vrf_alloc (); + zvrf->zns = zebra_ns_lookup (NS_DEFAULT); /* Point to the global (single) NS */ + router_id_init (zvrf); + vrf->info = zvrf; + zvrf->vrf = vrf; return 0; } @@ -154,9 +140,9 @@ zebra_vrf_static_route_interface_fixup (struct interface *ifp) /* Callback upon enabling a VRF. */ static int -zebra_vrf_enable (vrf_id_t vrf_id, const char *name, void **info) +zebra_vrf_enable (struct vrf *vrf) { - struct zebra_vrf *zvrf = (struct zebra_vrf *) (*info); + struct zebra_vrf *zvrf = vrf->info; struct route_table *stable = NULL; struct route_node *rn = NULL; struct static_route *si = NULL; @@ -180,7 +166,7 @@ zebra_vrf_enable (vrf_id_t vrf_id, const char *name, void **info) if (rn->info) { si = rn->info; - si->vrf_id = vrf_id; + si->vrf_id = vrf->vrf_id; if (si->ifindex) { ifp = if_lookup_by_name_vrf (si->ifname, si->vrf_id); @@ -200,9 +186,9 @@ zebra_vrf_enable (vrf_id_t vrf_id, const char *name, void **info) /* Callback upon disabling a VRF. */ static int -zebra_vrf_disable (vrf_id_t vrf_id, const char *name, void **info) +zebra_vrf_disable (struct vrf *vrf) { - struct zebra_vrf *zvrf = (struct zebra_vrf *)(*info); + struct zebra_vrf *zvrf = vrf->info; struct route_table *stable = NULL; struct route_node *rn = NULL; afi_t afi; @@ -210,7 +196,7 @@ zebra_vrf_disable (vrf_id_t vrf_id, const char *name, void **info) if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug ("VRF %s id %u is now disabled.", - zvrf->name, zvrf->vrf_id); + zvrf_name (zvrf), zvrf_id (zvrf)); for (afi = AFI_IP; afi < AFI_MAX; afi++) { @@ -231,9 +217,9 @@ zebra_vrf_disable (vrf_id_t vrf_id, const char *name, void **info) } static int -zebra_vrf_delete (vrf_id_t vrf_id, const char *name, void **info) +zebra_vrf_delete (struct vrf *vrf) { - struct zebra_vrf *zvrf = (struct zebra_vrf *) (*info); + struct zebra_vrf *zvrf = vrf->info; assert (zvrf); @@ -245,9 +231,9 @@ zebra_vrf_delete (vrf_id_t vrf_id, const char *name, void **info) list_delete_all_node (zvrf->rid_all_sorted_list); list_delete_all_node (zvrf->rid_lo_sorted_list); - zvrf->vrf_id = VRF_UNKNOWN; + vrf->vrf_id = VRF_UNKNOWN; + vrf->info = NULL; - *info = NULL; return 0; } @@ -300,7 +286,7 @@ zebra_vrf_table_create (struct zebra_vrf *zvrf, afi_t afi, safi_t safi) /* Allocate new zebra VRF. */ struct zebra_vrf * -zebra_vrf_alloc (vrf_id_t vrf_id, const char *name) +zebra_vrf_alloc (void) { struct zebra_vrf *zvrf; @@ -322,15 +308,6 @@ zebra_vrf_alloc (vrf_id_t vrf_id, const char *name) zvrf->import_check_table[AFI_IP] = route_table_init(); zvrf->import_check_table[AFI_IP6] = route_table_init(); - /* Set VRF ID */ - zvrf->vrf_id = vrf_id; - - if (name) - { - strncpy (zvrf->name, name, strlen(name)); - zvrf->name[strlen(name)] = '\0'; - } - zebra_mpls_init_tables (zvrf); return zvrf; @@ -452,9 +429,9 @@ vrf_config_write (struct vty *vty) RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { zvrf = vrf->info; - if (! zvrf || strcmp (zvrf->name, VRF_DEFAULT_NAME)) + if (! zvrf || strcmp (zvrf_name (zvrf), VRF_DEFAULT_NAME)) { - vty_out (vty, "vrf %s%s", zvrf->name, VTY_NEWLINE); + vty_out (vty, "vrf %s%s", zvrf_name (zvrf), VTY_NEWLINE); vty_out (vty, "!%s", VTY_NEWLINE); } } diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h index 824736564..8c4f0b4a2 100644 --- a/zebra/zebra_vrf.h +++ b/zebra/zebra_vrf.h @@ -28,11 +28,8 @@ /* Routing table instance. */ struct zebra_vrf { - /* Identifier. */ - vrf_id_t vrf_id; - - /* Routing table name. */ - char name[VRF_NAMSIZ]; + /* Back pointer */ + struct vrf *vrf; /* Description. */ char *desc; @@ -86,6 +83,18 @@ struct zebra_vrf #define MPLS_FLAG_SCHEDULE_LSPS (1 << 0) }; +static inline vrf_id_t +zvrf_id (struct zebra_vrf *zvrf) +{ + return zvrf->vrf->vrf_id; +} + +static inline const char * +zvrf_name (struct zebra_vrf *zvrf) +{ + return zvrf->vrf->name; +} + struct route_table * zebra_vrf_table_with_table_id (afi_t afi, safi_t safi, vrf_id_t vrf_id, u_int32_t table_id); @@ -94,7 +103,7 @@ extern void zebra_vrf_static_route_interface_fixup (struct interface *ifp); extern void zebra_vrf_update_all (struct zserv *client); extern struct zebra_vrf *zebra_vrf_lookup_by_id (vrf_id_t vrf_id); extern struct zebra_vrf *zebra_vrf_lookup_by_name (const char *); -extern struct zebra_vrf *zebra_vrf_alloc (vrf_id_t, 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_static_table (afi_t, safi_t, struct zebra_vrf *zvrf); extern struct route_table *zebra_vrf_other_route_table (afi_t afi, u_int32_t table_id, diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 4ae12559a..84106e7ff 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -183,7 +183,7 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, ret = inet_aton (gate_str, &gate); if (!ret) { - struct interface *ifp = if_lookup_by_name_vrf (gate_str, zvrf->vrf_id); + struct interface *ifp = if_lookup_by_name_vrf (gate_str, zvrf_id (zvrf)); if (!ifp) { vty_out (vty, "%% Unknown interface: %s%s", gate_str, VTY_NEWLINE); @@ -2025,7 +2025,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) if (rib->vrf_id != VRF_DEFAULT) { zvrf = vrf_info_lookup(rib->vrf_id); - vty_out (vty, ", vrf %s", zvrf->name); + vty_out (vty, ", vrf %s", zvrf_name (zvrf)); } if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) vty_out (vty, ", best"); @@ -2459,7 +2459,7 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, safi_t safi, return CMD_SUCCESS; } - if (zvrf->vrf_id == VRF_UNKNOWN) + if (zvrf_id (zvrf) == VRF_UNKNOWN) { if (use_json) vty_out (vty, "{}%s", VTY_NEWLINE); @@ -2468,7 +2468,7 @@ do_show_ip_route (struct vty *vty, const char *vrf_name, safi_t safi, return CMD_SUCCESS; } - table = zebra_vrf_table (AFI_IP, safi, zvrf->vrf_id); + table = zebra_vrf_table (AFI_IP, safi, zvrf_id (zvrf)); if (! table) { if (use_json) @@ -2575,8 +2575,8 @@ DEFUN (show_ip_nht_vrf_all, RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) if ((zvrf = vrf->info) != NULL) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); - zebra_print_rnh_table(zvrf->vrf_id, AF_INET, vty, RNH_NEXTHOP_TYPE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); + zebra_print_rnh_table(zvrf_id (zvrf), AF_INET, vty, RNH_NEXTHOP_TYPE); } return CMD_SUCCESS; @@ -2620,8 +2620,8 @@ DEFUN (show_ipv6_nht_vrf_all, RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) if ((zvrf = vrf->info) != NULL) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); - zebra_print_rnh_table(zvrf->vrf_id, AF_INET6, vty, RNH_NEXTHOP_TYPE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); + zebra_print_rnh_table(zvrf_id (zvrf), AF_INET6, vty, RNH_NEXTHOP_TYPE); } return CMD_SUCCESS; @@ -3098,7 +3098,7 @@ vty_show_ip_route_summary (struct vty *vty, struct route_table *table) vty_out (vty, "%-20s %-20s %s (vrf %s)%s", "Route Source", "Routes", "FIB", - ((rib_table_info_t *)table->info)->zvrf->name, + zvrf_name (((rib_table_info_t *)table->info)->zvrf), VTY_NEWLINE); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) @@ -3179,7 +3179,7 @@ vty_show_ip_route_summary_prefix (struct vty *vty, struct route_table *table) vty_out (vty, "%-20s %-20s %s (vrf %s)%s", "Route Source", "Prefix Routes", "FIB", - ((rib_table_info_t *)table->info)->zvrf->name, + zvrf_name (((rib_table_info_t *)table->info)->zvrf), VTY_NEWLINE); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) @@ -3310,7 +3310,7 @@ DEFUN (show_ip_route_vrf_all, if (vrf_header) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); vrf_header = 0; } vty_show_ip_route (vty, rn, rib, NULL); @@ -3364,7 +3364,7 @@ DEFUN (show_ip_route_vrf_all_tag, if (vrf_header) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); vrf_header = 0; } vty_show_ip_route (vty, rn, rib, NULL); @@ -3420,7 +3420,7 @@ DEFUN (show_ip_route_vrf_all_prefix_longer, if (vrf_header) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); vrf_header = 0; } vty_show_ip_route (vty, rn, rib, NULL); @@ -3473,7 +3473,7 @@ DEFUN (show_ip_route_vrf_all_supernets, if (vrf_header) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); vrf_header = 0; } vty_show_ip_route (vty, rn, rib, NULL); @@ -3529,7 +3529,7 @@ DEFUN (show_ip_route_vrf_all_protocol, if (vrf_header) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); vrf_header = 0; } vty_show_ip_route (vty, rn, rib, NULL); @@ -3722,7 +3722,7 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd) vty_out (vty, " %d", si->distance); if (si->vrf_id != VRF_DEFAULT) - vty_out (vty, " vrf %s", zvrf ? zvrf->name : ""); + vty_out (vty, " vrf %s", zvrf ? zvrf_name (zvrf) : ""); /* Label information */ if (si->snh_label.num_labels) @@ -3855,7 +3855,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, } type = STATIC_IPV6_GATEWAY_IFINDEX; gate = &gate_addr; - ifp = if_lookup_by_name_vrf (ifname, zvrf->vrf_id); + ifp = if_lookup_by_name_vrf (ifname, zvrf_id (zvrf)); if (!ifp) { vty_out (vty, "%% Malformed Interface name %s%s", ifname, VTY_NEWLINE); @@ -3873,7 +3873,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, else { type = STATIC_IFINDEX; - ifp = if_lookup_by_name_vrf (gate_str, zvrf->vrf_id); + ifp = if_lookup_by_name_vrf (gate_str, zvrf_id (zvrf)); if (!ifp) { vty_out (vty, "%% Malformed Interface name %s%s", gate_str, VTY_NEWLINE); @@ -4934,7 +4934,7 @@ DEFUN (show_ipv6_route, return CMD_SUCCESS; } - if (zvrf->vrf_id == VRF_UNKNOWN) + if (zvrf_id (zvrf) == VRF_UNKNOWN) { if (uj) vty_out (vty, "{}%s", VTY_NEWLINE); @@ -4943,7 +4943,7 @@ DEFUN (show_ipv6_route, return CMD_SUCCESS; } else - vrf_id = zvrf->vrf_id; + vrf_id = zvrf_id (zvrf); } table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); @@ -5438,7 +5438,7 @@ DEFUN (show_ipv6_route_vrf_all, if (vrf_header) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); vrf_header = 0; } vty_show_ip_route (vty, rn, rib, NULL); @@ -5492,7 +5492,7 @@ DEFUN (show_ipv6_route_vrf_all_tag, if (vrf_header) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); vrf_header = 0; } vty_show_ip_route (vty, rn, rib, NULL); @@ -5549,7 +5549,7 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer, if (vrf_header) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); vrf_header = 0; } vty_show_ip_route (vty, rn, rib, NULL); @@ -5604,7 +5604,7 @@ DEFUN (show_ipv6_route_vrf_all_protocol, if (vrf_header) { - vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf->name, VTY_NEWLINE); + vty_out (vty, "%sVRF %s:%s", VTY_NEWLINE, zvrf_name (zvrf), VTY_NEWLINE); vrf_header = 0; } vty_show_ip_route (vty, rn, rib, NULL); @@ -5838,7 +5838,7 @@ static_config_ipv6 (struct vty *vty) if (si->vrf_id != VRF_DEFAULT) { - vty_out (vty, " vrf %s", zvrf->name); + vty_out (vty, " vrf %s", zvrf_name (zvrf)); } /* Label information */ @@ -5888,14 +5888,14 @@ DEFUN (show_vrf, RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { zvrf = vrf->info; - if (! zvrf || ! zvrf->vrf_id) + if (! zvrf || ! zvrf_id (zvrf)) continue; - vty_out (vty, "vrf %s ", zvrf->name); - if (zvrf->vrf_id == VRF_UNKNOWN) + vty_out (vty, "vrf %s ", zvrf_name (zvrf)); + if (zvrf_id (zvrf) == VRF_UNKNOWN) vty_out (vty, "inactive"); else - vty_out (vty, "id %u table %u", zvrf->vrf_id, zvrf->table_id); + vty_out (vty, "id %u table %u", zvrf_id (zvrf), zvrf->table_id); vty_out (vty, "%s", VTY_NEWLINE); } diff --git a/zebra/zserv.c b/zebra/zserv.c index 947e7324d..83d7d0f81 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -185,7 +185,7 @@ static void zserv_encode_vrf (struct stream *s, struct zebra_vrf *zvrf) { /* Interface information. */ - stream_put (s, zvrf->name, VRF_NAMSIZ); + stream_put (s, zvrf_name (zvrf), VRF_NAMSIZ); /* Write packet size. */ stream_putw_at (s, 0, stream_get_endp (s)); @@ -241,7 +241,7 @@ zsend_vrf_add (struct zserv *client, struct zebra_vrf *zvrf) s = client->obuf; stream_reset (s); - zserv_create_header (s, ZEBRA_VRF_ADD, zvrf->vrf_id); + zserv_create_header (s, ZEBRA_VRF_ADD, zvrf_id (zvrf)); zserv_encode_vrf (s, zvrf); client->vrfadd_cnt++; @@ -257,7 +257,7 @@ zsend_vrf_delete (struct zserv *client, struct zebra_vrf *zvrf) s = client->obuf; stream_reset (s); - zserv_create_header (s, ZEBRA_VRF_DELETE, zvrf->vrf_id); + zserv_create_header (s, ZEBRA_VRF_DELETE, zvrf_id (zvrf)); zserv_encode_vrf (s, zvrf); client->vrfdel_cnt++; @@ -850,7 +850,7 @@ zserv_rnh_register (struct zserv *client, int sock, u_short length, p.family); return -1; } - rnh = zebra_add_rnh(&p, zvrf->vrf_id, type); + rnh = zebra_add_rnh(&p, zvrf_id (zvrf), type); if (type == RNH_NEXTHOP_TYPE) { if (flags && !CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED)) @@ -866,9 +866,9 @@ zserv_rnh_register (struct zserv *client, int sock, u_short length, UNSET_FLAG(rnh->flags, ZEBRA_NHT_EXACT_MATCH); } - zebra_add_rnh_client(rnh, client, type, zvrf->vrf_id); + zebra_add_rnh_client(rnh, client, type, zvrf_id (zvrf)); /* Anything not AF_INET/INET6 has been filtered out above */ - zebra_evaluate_rnh(zvrf->vrf_id, p.family, 1, type, &p); + zebra_evaluate_rnh(zvrf_id (zvrf), p.family, 1, type, &p); } return 0; } @@ -911,7 +911,7 @@ zserv_rnh_unregister (struct zserv *client, int sock, u_short length, p.family); return -1; } - rnh = zebra_lookup_rnh(&p, zvrf->vrf_id, type); + rnh = zebra_lookup_rnh(&p, zvrf_id (zvrf), type); if (rnh) { client->nh_dereg_time = quagga_monotime(); @@ -939,7 +939,7 @@ zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struc stream_reset (s); /* Fill in result. */ - zserv_create_header (s, ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB, zvrf->vrf_id); + zserv_create_header (s, ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB, zvrf_id (zvrf)); stream_put_in_addr (s, &addr); if (rib) @@ -1010,7 +1010,7 @@ zread_interface_add (struct zserv *client, u_short length, struct zebra_vrf *zvr struct interface *ifp; /* Interface information is needed. */ - vrf_bitmap_set (client->ifinfo, zvrf->vrf_id); + vrf_bitmap_set (client->ifinfo, zvrf_id (zvrf)); RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) { @@ -1034,7 +1034,7 @@ zread_interface_add (struct zserv *client, u_short length, struct zebra_vrf *zvr static int zread_interface_delete (struct zserv *client, u_short length, struct zebra_vrf *zvrf) { - vrf_bitmap_unset (client->ifinfo, zvrf->vrf_id); + vrf_bitmap_unset (client->ifinfo, zvrf_id (zvrf)); return 0; } @@ -1091,7 +1091,7 @@ zread_ipv4_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) stream_get (&p.u.prefix4, s, PSIZE (p.prefixlen)); /* VRF ID */ - rib->vrf_id = zvrf->vrf_id; + rib->vrf_id = zvrf_id (zvrf); /* Nexthop parse. */ if (CHECK_FLAG (message, ZAPI_MESSAGE_NEXTHOP)) @@ -1243,7 +1243,7 @@ zread_ipv4_delete (struct zserv *client, u_short length, struct zebra_vrf *zvrf) table_id = zvrf->table_id; - rib_delete (AFI_IP, api.safi, zvrf->vrf_id, api.type, api.instance, + rib_delete (AFI_IP, api.safi, zvrf_id (zvrf), api.type, api.instance, api.flags, &p, nexthop_p, ifindex, table_id); client->v4_route_del_cnt++; return 0; @@ -1257,7 +1257,7 @@ zread_ipv4_nexthop_lookup_mrib (struct zserv *client, u_short length, struct zeb struct rib *rib; addr.s_addr = stream_get_ipv4 (client->ibuf); - rib = rib_match_ipv4_multicast (zvrf->vrf_id, addr, NULL); + rib = rib_match_ipv4_multicast (zvrf_id (zvrf), addr, NULL); return zsend_ipv4_nexthop_lookup_mrib (client, addr, rib, zvrf); } @@ -1301,7 +1301,7 @@ zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct stream_get (&p.u.prefix4, s, PSIZE (p.prefixlen)); /* VRF ID */ - rib->vrf_id = zvrf->vrf_id; + rib->vrf_id = zvrf_id (zvrf); /* We need to give nh-addr, nh-ifindex with the same next-hop object * to the rib to ensure that IPv6 multipathing works; need to coalesce @@ -1498,7 +1498,7 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf) rib->mtu = 0; /* VRF ID */ - rib->vrf_id = zvrf->vrf_id; + rib->vrf_id = zvrf_id (zvrf); rib->table = zvrf->table_id; ret = rib_add_multipath (AFI_IP6, safi, &p, rib); @@ -1582,10 +1582,10 @@ zread_ipv6_delete (struct zserv *client, u_short length, struct zebra_vrf *zvrf) api.tag = 0; if (IN6_IS_ADDR_UNSPECIFIED (&nexthop)) - rib_delete (AFI_IP6, api.safi, zvrf->vrf_id, api.type, api.instance, + rib_delete (AFI_IP6, api.safi, zvrf_id (zvrf), api.type, api.instance, api.flags, &p, NULL, ifindex, client->rtm_table); else - rib_delete (AFI_IP6, api.safi, zvrf->vrf_id, api.type, api.instance, + rib_delete (AFI_IP6, api.safi, zvrf_id (zvrf), api.type, api.instance, api.flags, &p, pnexthop, ifindex, client->rtm_table); client->v6_route_del_cnt++; @@ -1599,18 +1599,18 @@ zread_router_id_add (struct zserv *client, u_short length, struct zebra_vrf *zvr struct prefix p; /* Router-id information is needed. */ - vrf_bitmap_set (client->ridinfo, zvrf->vrf_id); + vrf_bitmap_set (client->ridinfo, zvrf_id (zvrf)); - router_id_get (&p, zvrf->vrf_id); + router_id_get (&p, zvrf_id (zvrf)); - return zsend_router_id_update (client, &p, zvrf->vrf_id); + return zsend_router_id_update (client, &p, zvrf_id (zvrf)); } /* Unregister zebra server router-id information. */ static int zread_router_id_delete (struct zserv *client, u_short length, struct zebra_vrf *zvrf) { - vrf_bitmap_unset (client->ridinfo, zvrf->vrf_id); + vrf_bitmap_unset (client->ridinfo, zvrf_id (zvrf)); return 0; } @@ -1648,10 +1648,10 @@ zread_vrf_unregister (struct zserv *client, u_short length, struct zebra_vrf *zv for (afi = AFI_IP; afi < AFI_MAX; afi++) for (i = 0; i < ZEBRA_ROUTE_MAX; i++) - vrf_bitmap_unset (client->redist[afi][i], zvrf->vrf_id); - vrf_bitmap_unset (client->redist_default, zvrf->vrf_id); - vrf_bitmap_unset (client->ifinfo, zvrf->vrf_id); - vrf_bitmap_unset (client->ridinfo, zvrf->vrf_id); + vrf_bitmap_unset (client->redist[afi][i], zvrf_id (zvrf)); + vrf_bitmap_unset (client->redist_default, zvrf_id (zvrf)); + vrf_bitmap_unset (client->ifinfo, zvrf_id (zvrf)); + vrf_bitmap_unset (client->ridinfo, zvrf_id (zvrf)); return 0; } @@ -1729,10 +1729,10 @@ zebra_client_close_cleanup_rnh (struct zserv *client) { if ((zvrf = vrf->info) != NULL) { - zebra_cleanup_rnh_client(zvrf->vrf_id, AF_INET, client, RNH_NEXTHOP_TYPE); - zebra_cleanup_rnh_client(zvrf->vrf_id, AF_INET6, client, RNH_NEXTHOP_TYPE); - zebra_cleanup_rnh_client(zvrf->vrf_id, AF_INET, client, RNH_IMPORT_CHECK_TYPE); - zebra_cleanup_rnh_client(zvrf->vrf_id, AF_INET6, client, RNH_IMPORT_CHECK_TYPE); + zebra_cleanup_rnh_client(zvrf_id (zvrf), AF_INET, client, RNH_NEXTHOP_TYPE); + zebra_cleanup_rnh_client(zvrf_id (zvrf), AF_INET6, client, RNH_NEXTHOP_TYPE); + zebra_cleanup_rnh_client(zvrf_id (zvrf), AF_INET, client, RNH_IMPORT_CHECK_TYPE); + zebra_cleanup_rnh_client(zvrf_id (zvrf), AF_INET6, client, RNH_IMPORT_CHECK_TYPE); if (client->proto == ZEBRA_ROUTE_LDP) { hash_iterate(zvrf->lsp_table, mpls_ldp_lsp_uninstall_all, |