ripd: move global counters to the rip structure

The only sideeffect of this change is that these counters will be
reset when RIP is deconfigured and then configured again, but this
shouldn't be a problem as the RIP MIB isn't specific about this.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2019-01-04 19:08:10 -02:00
parent 241987a816
commit c08a21077f
4 changed files with 16 additions and 14 deletions

View file

@ -160,13 +160,16 @@ static uint8_t *rip2Globals(struct variable *v, oid name[], size_t *length,
== MATCH_FAILED)
return NULL;
if (!rip)
return NULL;
/* Retrun global counter. */
switch (v->magic) {
case RIP2GLOBALROUTECHANGES:
return SNMP_INTEGER(rip_global_route_changes);
return SNMP_INTEGER(rip->counters.route_changes);
break;
case RIP2GLOBALQUERIES:
return SNMP_INTEGER(rip_global_queries);
return SNMP_INTEGER(rip->counters.queries);
break;
default:
return NULL;

View file

@ -101,7 +101,7 @@ static void rip_zebra_ipv4_send(struct route_node *rp, uint8_t cmd)
inet_ntoa(rp->p.u.prefix4), rp->p.prefixlen);
}
rip_global_route_changes++;
rip->counters.route_changes++;
}
/* Add/update ECMP routes to zebra. */

View file

@ -53,12 +53,6 @@
/* RIP Structure. */
struct rip *rip = NULL;
/* RIP route changes. */
long rip_global_route_changes = 0;
/* RIP queries. */
long rip_global_queries = 0;
/* Prototypes. */
static void rip_output_process(struct connected *, struct sockaddr_in *, int,
uint8_t);
@ -1633,7 +1627,7 @@ static void rip_request_process(struct rip_packet *packet, int size,
(void)rip_send_packet((uint8_t *)packet, size, from, ifc);
}
rip_global_queries++;
rip->counters.queries++;
}
/* First entry point of RIP packet. */

View file

@ -169,6 +169,15 @@ struct rip {
/* For distribute-list container */
struct distribute_ctx *distribute_ctx;
/* Counters for SNMP. */
struct {
/* RIP route changes. */
long route_changes;
/* RIP queries. */
long queries;
} counters;
};
/* RIP routing table entry which belong to rip_packet. */
@ -474,10 +483,6 @@ extern struct zebra_privs_t ripd_privs;
/* Master thread strucutre. */
extern struct thread_master *master;
/* RIP statistics for SNMP. */
extern long rip_global_route_changes;
extern long rip_global_queries;
DECLARE_HOOK(rip_ifaddr_add, (struct connected * ifc), (ifc))
DECLARE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc))