summaryrefslogtreecommitdiff
path: root/eigrpd/eigrpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'eigrpd/eigrpd.c')
-rw-r--r--eigrpd/eigrpd.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c
index 93f8b6f90e..e93dc0cbfa 100644
--- a/eigrpd/eigrpd.c
+++ b/eigrpd/eigrpd.c
@@ -64,8 +64,6 @@ static struct eigrp_master eigrp_master;
struct eigrp_master *eigrp_om;
-static struct eigrp *eigrp_new(const char *);
-
extern struct zclient *zclient;
extern struct in_addr router_id_zebra;
@@ -95,7 +93,7 @@ extern struct in_addr router_id_zebra;
*/
void eigrp_router_id_update(struct eigrp *eigrp)
{
- struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct vrf *vrf = vrf_lookup_by_id(eigrp->vrf_id);
struct interface *ifp;
struct in_addr router_id, router_id_old;
@@ -136,14 +134,14 @@ void eigrp_master_init(void)
}
/* Allocate new eigrp structure. */
-static struct eigrp *eigrp_new(const char *AS)
+static struct eigrp *eigrp_new(uint16_t as, vrf_id_t vrf_id)
{
struct eigrp *eigrp = XCALLOC(MTYPE_EIGRP_TOP, sizeof(struct eigrp));
- int eigrp_socket;
/* init information relevant to peers */
+ eigrp->vrf_id = vrf_id;
eigrp->vrid = 0;
- eigrp->AS = atoi(AS);
+ eigrp->AS = as;
eigrp->router_id.s_addr = 0;
eigrp->router_id_static.s_addr = 0;
eigrp->sequence_number = 1;
@@ -161,14 +159,15 @@ static struct eigrp *eigrp_new(const char *AS)
eigrp->passive_interface_default = EIGRP_IF_ACTIVE;
eigrp->networks = eigrp_topology_new();
- if ((eigrp_socket = eigrp_sock_init()) < 0) {
+ eigrp->fd = eigrp_sock_init(vrf_lookup_by_id(vrf_id));
+
+ if (eigrp->fd < 0) {
flog_err_sys(
EC_LIB_SOCKET,
"eigrp_new: fatal error: eigrp_sock_init was unable to open a socket");
exit(1);
}
- eigrp->fd = eigrp_socket;
eigrp->maxsndbuflen = getsockopt_so_sendbuf(eigrp->fd);
eigrp->ibuf = stream_new(EIGRP_PACKET_MAX_LEN + 1);
@@ -200,16 +199,15 @@ static struct eigrp *eigrp_new(const char *AS)
eigrp->routemap[EIGRP_FILTER_OUT] = NULL;
/* Distribute list install. */
- eigrp->distribute_ctx = distribute_list_ctx_create(
- vrf_lookup_by_id(VRF_DEFAULT));
+ eigrp->distribute_ctx =
+ distribute_list_ctx_create(vrf_lookup_by_id(eigrp->vrf_id));
distribute_list_add_hook(eigrp->distribute_ctx,
eigrp_distribute_update);
distribute_list_delete_hook(eigrp->distribute_ctx,
eigrp_distribute_update);
/*
- eigrp->if_rmap_ctx = if_rmap_ctx_create(
- VRF_DEFAULT_NAME);
+ eigrp->if_rmap_ctx = if_rmap_ctx_create(eigrp->vrf_id);
if_rmap_hook_add (eigrp_if_rmap_update);
if_rmap_hook_delete (eigrp_if_rmap_update);
*/
@@ -217,13 +215,13 @@ static struct eigrp *eigrp_new(const char *AS)
return eigrp;
}
-struct eigrp *eigrp_get(const char *AS)
+struct eigrp *eigrp_get(uint16_t as, vrf_id_t vrf_id)
{
struct eigrp *eigrp;
- eigrp = eigrp_lookup();
+ eigrp = eigrp_lookup(vrf_id);
if (eigrp == NULL) {
- eigrp = eigrp_new(AS);
+ eigrp = eigrp_new(as, vrf_id);
listnode_add(eigrp_om->eigrp, eigrp);
}
@@ -285,7 +283,7 @@ void eigrp_finish_final(struct eigrp *eigrp)
list_delete(&eigrp->eiflist);
list_delete(&eigrp->oi_write_q);
- eigrp_topology_free(eigrp->topology_table);
+ eigrp_topology_free(eigrp, eigrp->topology_table);
eigrp_nbr_delete(eigrp->neighbor_self);
@@ -300,10 +298,14 @@ void eigrp_finish_final(struct eigrp *eigrp)
}
/*Look for existing eigrp process*/
-struct eigrp *eigrp_lookup(void)
+struct eigrp *eigrp_lookup(vrf_id_t vrf_id)
{
- if (listcount(eigrp_om->eigrp) == 0)
- return NULL;
+ struct eigrp *eigrp;
+ struct listnode *node, *nnode;
+
+ for (ALL_LIST_ELEMENTS(eigrp_om->eigrp, node, nnode, eigrp))
+ if (eigrp->vrf_id == vrf_id)
+ return eigrp;
- return listgetdata(listhead(eigrp_om->eigrp));
+ return NULL;
}