mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 00:41:20 +00:00
ripngd: move "peer_list" to the ripng structure
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
parent
0c32404fdd
commit
ecece94cf1
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user