summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2019-01-04 19:08:10 -0200
committerRenato Westphal <renato@opensourcerouting.org>2019-01-18 16:15:41 -0200
commitecece94cf1be254d89868cec95cc9d4b04264a6b (patch)
treedc082aba1b4d4d12392804951f93f4076be7a151
parent0c32404fddcf80034f4fd3d76c7cc12fd71b4e25 (diff)
ripngd: move "peer_list" to the ripng structure
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
-rw-r--r--ripngd/ripng_main.c1
-rw-r--r--ripngd/ripng_northbound.c10
-rw-r--r--ripngd/ripng_peer.c22
-rw-r--r--ripngd/ripngd.c2
-rw-r--r--ripngd/ripngd.h6
5 files changed, 20 insertions, 21 deletions
diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c
index b7e5739ed2..26d602e1a5 100644
--- a/ripngd/ripng_main.c
+++ b/ripngd/ripng_main.c
@@ -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);
diff --git a/ripngd/ripng_northbound.c b/ripngd/ripng_northbound.c
index 69e207f443..ca7a334f4a 100644
--- a/ripngd/ripng_northbound.c
+++ b/ripngd/ripng_northbound.c
@@ -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;
}
diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c
index 6b2a183539..f5590cf823 100644
--- a/ripngd/ripng_peer.c
+++ b/ripngd/ripng_peer.c
@@ -34,10 +34,6 @@
#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;
-}
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 7db8bafd38..2cc3bd7f1e 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -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);
diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h
index 95b128f4d9..3e5ca18ed2 100644
--- a/ripngd/ripngd.h
+++ b/ripngd/ripngd.h
@@ -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);