]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ripngd: move "peer_list" to the ripng 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)
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ripngd/ripng_main.c
ripngd/ripng_northbound.c
ripngd/ripng_peer.c
ripngd/ripngd.c
ripngd/ripngd.h

index b7e5739ed2e683785ccec1a5e757993c6b71ece4..26d602e1a50f961ae0983ae457d66a53e8016155 100644 (file)
@@ -177,7 +177,6 @@ int main(int argc, char **argv)
        ripng_init();
        ripng_cli_init();
        zebra_init(master);
-       ripng_peer_init();
 
        frr_config_fork();
        frr_run(master);
index 69e207f443c3b18c90ff08a0e8598925e2967375..ca7a334f4ae8928f67f0c6b59eb56692be030f41 100644 (file)
@@ -581,8 +581,11 @@ ripngd_state_neighbors_neighbor_get_next(const void *parent_list_entry,
 {
        struct listnode *node;
 
+       if (!ripng)
+               return NULL;
+
        if (list_entry == NULL)
-               node = listhead(peer_list);
+               node = listhead(ripng->peer_list);
        else
                node = listnextnode((struct listnode *)list_entry);
 
@@ -612,7 +615,10 @@ ripngd_state_neighbors_neighbor_lookup_entry(const void *parent_list_entry,
 
        yang_str2ipv6(keys->key[0], &address);
 
-       for (ALL_LIST_ELEMENTS_RO(peer_list, node, peer)) {
+       if (!ripng)
+               return NULL;
+
+       for (ALL_LIST_ELEMENTS_RO(ripng->peer_list, node, peer)) {
                if (IPV6_ADDR_SAME(&peer->addr, &address))
                        return node;
        }
index 6b2a18353924921b6548a9ca877d567f1ef0c65e..f5590cf823ffa91a95f86704d920c86d6f65adf5 100644 (file)
 #include "ripngd/ripngd.h"
 #include "ripngd/ripng_nexthop.h"
 
-
-/* Linked list of RIPng peer. */
-struct list *peer_list;
-
 static struct ripng_peer *ripng_peer_new(void)
 {
        return XCALLOC(MTYPE_RIPNG_PEER, sizeof(struct ripng_peer));
@@ -53,7 +49,7 @@ struct ripng_peer *ripng_peer_lookup(struct in6_addr *addr)
        struct ripng_peer *peer;
        struct listnode *node, *nnode;
 
-       for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) {
+       for (ALL_LIST_ELEMENTS(ripng->peer_list, node, nnode, peer)) {
                if (IPV6_ADDR_SAME(&peer->addr, addr))
                        return peer;
        }
@@ -65,7 +61,7 @@ struct ripng_peer *ripng_peer_lookup_next(struct in6_addr *addr)
        struct ripng_peer *peer;
        struct listnode *node, *nnode;
 
-       for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) {
+       for (ALL_LIST_ELEMENTS(ripng->peer_list, node, nnode, peer)) {
                if (addr6_cmp(&peer->addr, addr) > 0)
                        return peer;
        }
@@ -80,7 +76,7 @@ static int ripng_peer_timeout(struct thread *t)
        struct ripng_peer *peer;
 
        peer = THREAD_ARG(t);
-       listnode_delete(peer_list, peer);
+       listnode_delete(ripng->peer_list, peer);
        ripng_peer_free(peer);
 
        return 0;
@@ -99,7 +95,7 @@ static struct ripng_peer *ripng_peer_get(struct in6_addr *addr)
        } else {
                peer = ripng_peer_new();
                peer->addr = *addr; /* XXX */
-               listnode_add_sort(peer_list, peer);
+               listnode_add_sort(ripng->peer_list, peer);
        }
 
        /* Update timeout thread. */
@@ -170,7 +166,7 @@ void ripng_peer_display(struct vty *vty)
 #define RIPNG_UPTIME_LEN 25
        char timebuf[RIPNG_UPTIME_LEN];
 
-       for (ALL_LIST_ELEMENTS(peer_list, node, nnode, peer)) {
+       for (ALL_LIST_ELEMENTS(ripng->peer_list, node, nnode, peer)) {
                vty_out(vty, "    %s \n%14s %10d %10d %10d      %s\n",
                        inet6_ntoa(peer->addr), " ", peer->recv_badpackets,
                        peer->recv_badroutes, ZEBRA_RIPNG_DISTANCE_DEFAULT,
@@ -178,13 +174,7 @@ void ripng_peer_display(struct vty *vty)
        }
 }
 
-static int ripng_peer_list_cmp(struct ripng_peer *p1, struct ripng_peer *p2)
+int ripng_peer_list_cmp(struct ripng_peer *p1, struct ripng_peer *p2)
 {
        return memcmp(&p1->addr, &p2->addr, sizeof(struct in6_addr));
 }
-
-void ripng_peer_init()
-{
-       peer_list = list_new();
-       peer_list->cmp = (int (*)(void *, void *))ripng_peer_list_cmp;
-}
index 7db8bafd38d1fff3427344859de165c06b55d5cf..2cc3bd7f1e8fbc9922da96560242c944a5519d47 100644 (file)
@@ -1805,6 +1805,8 @@ int ripng_create(int socket)
 
        /* Initialize RIPng data structures. */
        ripng->table = agg_table_init();
+       ripng->peer_list = list_new();
+       ripng->peer_list->cmp = (int (*)(void *, void *))ripng_peer_list_cmp;
        ripng->enable_if = vector_init(1);
        ripng->enable_network = agg_table_init();
        ripng->passive_interface = vector_init(1);
index 95b128f4d90bbc00c54881b8cfbb838c4dacd8ae..3e5ca18ed2396cf9489790a46c6becba055d6819 100644 (file)
@@ -108,6 +108,9 @@ struct ripng {
        /* RIPng routing information base. */
        struct agg_table *table;
 
+       /* Linked list of RIPng peers. */
+       struct list *peer_list;
+
        /* RIPng enabled interfaces. */
        vector enable_if;
 
@@ -343,7 +346,6 @@ struct ripng_offset_list {
 
 /* Extern variables. */
 extern struct ripng *ripng;
-extern struct list *peer_list;
 extern struct zebra_privs_t ripngd_privs;
 extern struct thread_master *master;
 
@@ -368,13 +370,13 @@ extern void ripng_zebra_stop(void);
 extern void ripng_redistribute_conf_update(int type);
 extern void ripng_redistribute_conf_delete(int type);
 
-extern void ripng_peer_init(void);
 extern void ripng_peer_update(struct sockaddr_in6 *, uint8_t);
 extern void ripng_peer_bad_route(struct sockaddr_in6 *);
 extern void ripng_peer_bad_packet(struct sockaddr_in6 *);
 extern void ripng_peer_display(struct vty *);
 extern struct ripng_peer *ripng_peer_lookup(struct in6_addr *);
 extern struct ripng_peer *ripng_peer_lookup_next(struct in6_addr *);
+extern int ripng_peer_list_cmp(struct ripng_peer *p1, struct ripng_peer *p2);
 
 extern struct ripng_offset_list *ripng_offset_list_new(const char *ifname);
 extern void ripng_offset_list_del(struct ripng_offset_list *offset);