From: Renato Westphal Date: Fri, 4 Jan 2019 21:08:10 +0000 (-0200) Subject: ripd: move global counters to the rip structure X-Git-Tag: 7.1_pulled~99^2~27 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=c08a21077faa595a76f87cc4b67d76623f045e0f;p=matthieu%2Ffrr.git 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 --- diff --git a/ripd/rip_snmp.c b/ripd/rip_snmp.c index 9acc825c0a..54c8a2eb8c 100644 --- a/ripd/rip_snmp.c +++ b/ripd/rip_snmp.c @@ -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; diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 684614fb47..607dc168f4 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -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. */ diff --git a/ripd/ripd.c b/ripd/ripd.c index 35ad4d818a..1e92fedb63 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -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. */ diff --git a/ripd/ripd.h b/ripd/ripd.h index bc0451d88f..a75e43d5df 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -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))