]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripd/rip_snmp.c
ripd: remove the rip global variable
[mirror_frr.git] / ripd / rip_snmp.c
index 917e532e0a95b79e8f28b05701428edfe4d0a12d..5a6b71fbaaacaa1953b002047b341a9531857d7f 100644 (file)
@@ -156,17 +156,23 @@ static uint8_t *rip2Globals(struct variable *v, oid name[], size_t *length,
                            int exact, size_t *var_len,
                            WriteMethod **write_method)
 {
+       struct rip *rip;
+
        if (smux_header_generic(v, name, length, exact, var_len, write_method)
            == MATCH_FAILED)
                return NULL;
 
+       rip = rip_lookup_by_vrf_id(VRF_DEFAULT);
+       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;
@@ -207,7 +213,7 @@ static int rip_snmp_ifaddr_del(struct connected *ifc)
        if (!rn)
                return 0;
        i = rn->info;
-       if (rn && !strncmp(i->name, ifp->name, INTERFACE_NAMSIZ)) {
+       if (!strncmp(i->name, ifp->name, INTERFACE_NAMSIZ)) {
                rn->info = NULL;
                route_unlock_node(rn);
                route_unlock_node(rn);
@@ -281,9 +287,14 @@ static struct rip_peer *rip2PeerLookup(struct variable *v, oid name[],
                                       size_t *length, struct in_addr *addr,
                                       int exact)
 {
+       struct rip *rip;
        int len;
        struct rip_peer *peer;
 
+       rip = rip_lookup_by_vrf_id(VRF_DEFAULT);
+       if (!rip)
+               return NULL;
+
        if (exact) {
                /* Check the length. */
                if (*length - v->namelen != sizeof(struct in_addr) + 1)
@@ -291,7 +302,7 @@ static struct rip_peer *rip2PeerLookup(struct variable *v, oid name[],
 
                oid2in_addr(name + v->namelen, sizeof(struct in_addr), addr);
 
-               peer = rip_peer_lookup(addr);
+               peer = rip_peer_lookup(rip, addr);
 
                if (peer->domain
                    == (int)name[v->namelen + sizeof(struct in_addr)])
@@ -306,7 +317,7 @@ static struct rip_peer *rip2PeerLookup(struct variable *v, oid name[],
                oid2in_addr(name + v->namelen, len, addr);
 
                len = *length - v->namelen;
-               peer = rip_peer_lookup(addr);
+               peer = rip_peer_lookup(rip, addr);
                if (peer) {
                        if ((len < (int)sizeof(struct in_addr) + 1)
                            || (peer->domain
@@ -321,7 +332,7 @@ static struct rip_peer *rip2PeerLookup(struct variable *v, oid name[],
                                return peer;
                        }
                }
-               peer = rip_peer_lookup_next(addr);
+               peer = rip_peer_lookup_next(rip, addr);
 
                if (!peer)
                        return NULL;
@@ -402,10 +413,10 @@ static long rip2IfConfSend(struct rip_interface *ri)
                return ripVersion2;
        else if (ri->ri_send & RIPv1)
                return ripVersion1;
-       else if (rip) {
-               if (rip->version_send == RIPv2)
+       else if (ri->rip) {
+               if (ri->rip->version_send == RIPv2)
                        return ripVersion2;
-               else if (rip->version_send == RIPv1)
+               else if (ri->rip->version_send == RIPv1)
                        return ripVersion1;
        }
        return doNotSend;
@@ -423,7 +434,7 @@ static long rip2IfConfReceive(struct rip_interface *ri)
        if (!ri->running)
                return doNotReceive;
 
-       recvv = (ri->ri_receive == RI_RIP_UNSPEC) ? rip->version_recv
+       recvv = (ri->ri_receive == RI_RIP_UNSPEC) ? ri->rip->version_recv
                                                  : ri->ri_receive;
        if (recvv == RI_RIP_VERSION_1_AND_2)
                return rip1OrRip2;