]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ripd: move global counters to the rip structure
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 4 Jan 2019 21:08:10 +0000 (19:08 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 18 Jan 2019 18:15:41 +0000 (16:15 -0200)
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>
ripd/rip_snmp.c
ripd/rip_zebra.c
ripd/ripd.c
ripd/ripd.h

index 9acc825c0ad3284c26d39cb0fa699806f79fba07..54c8a2eb8cbab014779be22d00d32378a7cbaa9a 100644 (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;
index 684614fb470aaaff9611d7ab2fbe2ec6d617a321..607dc168f4bebaff64835265d13918b21575c216 100644 (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. */
index 35ad4d818a634da179c02fbf7d0d9d9028e6751d..1e92fedb632e2d7607fe73180635c18d31036798 100644 (file)
 /* 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. */
index bc0451d88f48a5213a445a22fd37b8ea52642a29..a75e43d5dff8977521fb3233b1df5761714df0de 100644 (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))