summaryrefslogtreecommitdiff
path: root/zebra/zebra_snmp.c
diff options
context:
space:
mode:
authorAvneesh Sachdev <avneesh@opensourcerouting.org>2012-11-13 22:48:53 +0000
committerDavid Lamparter <equinox@opensourcerouting.org>2012-11-30 21:41:16 +0100
commit9fd92e3c4bdcc78e0f0d94d53a2d4c7b0e893fcb (patch)
treea3adf090e5ef776b8c6dc6223890a2640217a95b /zebra/zebra_snmp.c
parent5aebb9c77fc2257c9d9df72db66668fabb24fc52 (diff)
zebra: add structure to hold per-prefix state in RIB
Add the rib_dest_t structure to hold per-prefix state in the routing information base. This gives us an appropriate place to maintain the queueing state of a route_node. Queuing state was previously being stored on the first rib in the list of ribs hanging off the route_node. * zebra/rib.h - Add new structure rib_dest_t. - Remove the rn_status field from 'struct rib', it is no longer required. - Add macros (RNODE_FOREACH_RIB, RNODE_FOREACH_RIB_SAFE) for walking all 'struct ribs' corresponding to a route_node. These hide the fact that there is an intermediate rib_dest_t structure. - Add a few utility inlines to go between a rib_dest_t and associated structures. * zebra/zebra_rib.c - rib_link()/rib_unlink() Tweak for new behavior, where the 'info' pointer of a route_node points to a rib_dest_t. The list of ribs for a prefix now hangs off of the dest. Change the way we ref count route_nodes. We now hold a single ref count on a route_node if there is a corresponding rib_dest_t. - Maintain the queuing state of a route_node on the flags field of the rib_dest_t. - Add the rib_gc_dest() function, which deletes a rib_dest_t if it is no longer required. A rib_dest_t can be deleted iff there are no struct ribs hanging off of it. - Call rib_gc_dest() any time we unlink a rib from the rib_dest_t. Currently we only need to call it once, just before we return from rib_process(). * zebra/{redistribute,zebra_rib,zebra_snmp,zebra_vty}.c Use new macros to walk over route_node ribs. * lib/memtypes.c Add memory type for rib_dest_t. Signed-off-by: Avneesh Sachdev <avneesh@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra/zebra_snmp.c')
-rw-r--r--zebra/zebra_snmp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c
index f52bbcb8..e06e1443 100644
--- a/zebra/zebra_snmp.c
+++ b/zebra/zebra_snmp.c
@@ -150,7 +150,7 @@ ipFwNumber (struct variable *v, oid objid[], size_t *objid_len,
/* Return number of routing entries. */
result = 0;
for (rn = route_top (table); rn; rn = route_next (rn))
- for (rib = rn->info; rib; rib = rib->next)
+ RNODE_FOREACH_RIB (rn, rib)
result++;
return (u_char *)&result;
@@ -175,7 +175,7 @@ ipCidrNumber (struct variable *v, oid objid[], size_t *objid_len,
/* Return number of routing entries. */
result = 0;
for (rn = route_top (table); rn; rn = route_next (rn))
- for (rib = rn->info; rib; rib = rib->next)
+ RNODE_FOREACH_RIB (rn, rib)
result++;
return (u_char *)&result;
@@ -369,7 +369,7 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len,
{
if (!in_addr_cmp(&(*np)->p.u.prefix, (u_char *)&dest))
{
- for (*rib = (*np)->info; *rib; *rib = (*rib)->next)
+ RNODE_FOREACH_RIB (*np, *rib)
{
if (!in_addr_cmp((u_char *)&(*rib)->nexthop->gate.ipv4,
(u_char *)&nexthop))
@@ -388,12 +388,12 @@ get_fwtable_route_node(struct variable *v, oid objid[], size_t *objid_len,
/* Check destination first */
if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) > 0)
- for (rib2 = np2->info; rib2; rib2 = rib2->next)
+ RNODE_FOREACH_RIB (np2, rib2)
check_replace(np2, rib2, np, rib);
if (in_addr_cmp(&np2->p.u.prefix, (u_char *)&dest) == 0)
{ /* have to look at each rib individually */
- for (rib2 = np2->info; rib2; rib2 = rib2->next)
+ RNODE_FOREACH_RIB (np2, rib2)
{
int proto2, policy2;