diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-06-15 19:48:18 +0200 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2019-08-07 03:41:05 +0200 |
commit | e944996140173700f73281cf7efc444377eec331 (patch) | |
tree | e6cebd6e8c5a1979e5d22be74256120bb71d94ce /eigrpd | |
parent | eigrpd: Create a socket per vrf for communication (diff) | |
download | frr-e944996140173700f73281cf7efc444377eec331.tar.xz frr-e944996140173700f73281cf7efc444377eec331.zip |
eigrpd: Add `router eigrp AS [vrf NAME]` and various stuff
Add the ability to parse `router eigrp AS [vrf NAME]` and
modify eigrp_lookup to actually handle a vrf_id for us.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'eigrpd')
-rw-r--r-- | eigrpd/eigrp_cli.c | 26 | ||||
-rw-r--r-- | eigrpd/eigrp_filter.c | 4 | ||||
-rw-r--r-- | eigrpd/eigrp_fsm.c | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_hello.c | 4 | ||||
-rw-r--r-- | eigrpd/eigrp_interface.c | 5 | ||||
-rw-r--r-- | eigrpd/eigrp_neighbor.c | 2 | ||||
-rw-r--r-- | eigrpd/eigrp_northbound.c | 16 | ||||
-rw-r--r-- | eigrpd/eigrp_topology.c | 6 | ||||
-rw-r--r-- | eigrpd/eigrp_vty.c | 20 | ||||
-rw-r--r-- | eigrpd/eigrp_zebra.c | 4 | ||||
-rw-r--r-- | eigrpd/eigrpd.c | 22 | ||||
-rw-r--r-- | eigrpd/eigrpd.h | 4 |
12 files changed, 63 insertions, 52 deletions
diff --git a/eigrpd/eigrp_cli.c b/eigrpd/eigrp_cli.c index ba657a7d5..a93d4c828 100644 --- a/eigrpd/eigrp_cli.c +++ b/eigrpd/eigrp_cli.c @@ -40,17 +40,18 @@ DEFPY_NOSH( router_eigrp, router_eigrp_cmd, - "router eigrp (1-65535)$as", + "router eigrp (1-65535)$as [vrf NAME]", ROUTER_STR EIGRP_STR - AS_STR) + AS_STR + VRF_CMD_HELP_STR) { char xpath[XPATH_MAXLEN]; int rv; snprintf(xpath, sizeof(xpath), - "/frr-eigrpd:eigrpd/instance[asn='%s'][vrf='']", - as_str); + "/frr-eigrpd:eigrpd/instance[asn='%s'][vrf='%s']", + as_str, vrf ? vrf : VRF_DEFAULT_NAME); nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); rv = nb_cli_apply_changes(vty, NULL); @@ -60,20 +61,21 @@ DEFPY_NOSH( return rv; } -DEFPY_NOSH( +DEFPY( no_router_eigrp, no_router_eigrp_cmd, - "no router eigrp (1-65535)$as", + "no router eigrp (1-65535)$as [vrf NAME]", NO_STR ROUTER_STR EIGRP_STR - AS_STR) + AS_STR + VRF_CMD_HELP_STR) { char xpath[XPATH_MAXLEN]; snprintf(xpath, sizeof(xpath), - "/frr-eigrpd:eigrpd/instance[asn='%s'][vrf='']", - as_str); + "/frr-eigrpd:eigrpd/instance[asn='%s'][vrf='%s']", + as_str, vrf ? vrf : VRF_DEFAULT_NAME); nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); @@ -83,8 +85,12 @@ void eigrp_cli_show_header(struct vty *vty, struct lyd_node *dnode, bool show_defaults) { const char *asn = yang_dnode_get_string(dnode, "./asn"); + const char *vrf = yang_dnode_get_string(dnode, "./vrf"); - vty_out(vty, "router eigrp %s\n", asn); + vty_out(vty, "router eigrp %s", asn); + if (strcmp(vrf, VRF_DEFAULT_NAME)) + vty_out(vty, " vrf %s", vrf); + vty_out(vty, "\n"); } void eigrp_cli_show_end_header(struct vty *vty, struct lyd_node *dnode) diff --git a/eigrpd/eigrp_filter.c b/eigrpd/eigrp_filter.c index 4d356398c..ef658bafe 100644 --- a/eigrpd/eigrp_filter.c +++ b/eigrpd/eigrp_filter.c @@ -74,7 +74,7 @@ void eigrp_distribute_update(struct distribute_ctx *ctx, /* if no interface address is present, set list to eigrp process struct */ - e = eigrp_lookup(); + e = eigrp_lookup(VRF_DEFAULT); assert(e != NULL); /* Check if distribute-list was set for process or interface */ @@ -288,7 +288,7 @@ void eigrp_distribute_update_interface(struct interface *ifp) struct distribute *dist; struct eigrp *eigrp; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(ifp->vrf_id); if (!eigrp) return; dist = distribute_lookup(eigrp->distribute_ctx, ifp->name); diff --git a/eigrpd/eigrp_fsm.c b/eigrpd/eigrp_fsm.c index 4d6d73e20..77fd3a9d7 100644 --- a/eigrpd/eigrp_fsm.c +++ b/eigrpd/eigrp_fsm.c @@ -499,7 +499,7 @@ int eigrp_fsm_event_keep_state(struct eigrp_fsm_action_message *msg) if (msg->packet_type == EIGRP_OPC_QUERY) eigrp_send_reply(msg->adv_router, prefix); prefix->req_action |= EIGRP_FSM_NEED_UPDATE; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); assert(eigrp); listnode_add(eigrp->topology_changes_internalIPV4, prefix); diff --git a/eigrpd/eigrp_hello.c b/eigrpd/eigrp_hello.c index fc011c5e5..a69fb8110 100644 --- a/eigrpd/eigrp_hello.c +++ b/eigrpd/eigrp_hello.c @@ -495,7 +495,7 @@ static uint16_t eigrp_sequence_encode(struct stream *s) size_t backup_end, size_end; int found; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { return 0; } @@ -547,7 +547,7 @@ static uint16_t eigrp_next_sequence_encode(struct stream *s) uint16_t length = EIGRP_NEXT_SEQUENCE_TLV_SIZE; struct eigrp *eigrp; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { return 0; } diff --git a/eigrpd/eigrp_interface.c b/eigrpd/eigrp_interface.c index c52a98ee2..8b2bd9dc4 100644 --- a/eigrpd/eigrp_interface.c +++ b/eigrpd/eigrp_interface.c @@ -329,10 +329,7 @@ void eigrp_if_free(struct eigrp_interface *ei, int source) { struct prefix dest_addr; struct eigrp_prefix_entry *pe; - struct eigrp *eigrp = eigrp_lookup(); - - if (!eigrp) - return; + struct eigrp *eigrp = ei->eigrp; if (source == INTERFACE_DOWN_BY_VTY) { THREAD_OFF(ei->t_hello); diff --git a/eigrpd/eigrp_neighbor.c b/eigrpd/eigrp_neighbor.c index 66dd5f341..71124dfd0 100644 --- a/eigrpd/eigrp_neighbor.c +++ b/eigrpd/eigrp_neighbor.c @@ -302,7 +302,7 @@ int eigrp_nbr_count_get(void) struct eigrp_interface *iface; struct listnode *node, *node2, *nnode2; struct eigrp_neighbor *nbr; - struct eigrp *eigrp = eigrp_lookup(); + struct eigrp *eigrp = eigrp_lookup(VRF_DEFAULT); uint32_t counter; if (eigrp == NULL) { diff --git a/eigrpd/eigrp_northbound.c b/eigrpd/eigrp_northbound.c index 5eecc3332..4ccce2ebb 100644 --- a/eigrpd/eigrp_northbound.c +++ b/eigrpd/eigrp_northbound.c @@ -79,14 +79,18 @@ static int eigrpd_instance_create(enum nb_event event, union nb_resource *resource) { struct eigrp *eigrp; + const char *vrf; + vrf_id_t vrfid; switch (event) { case NB_EV_VALIDATE: /* NOTHING */ break; case NB_EV_PREPARE: - eigrp = eigrp_get(yang_dnode_get_string(dnode, "./asn"), - VRF_DEFAULT); + vrf = yang_dnode_get_string(dnode, "./vrf"); + vrfid = vrf_name_to_id(vrf); + + eigrp = eigrp_get(yang_dnode_get_uint16(dnode, "./asn"), vrfid); resource->ptr = eigrp; break; case NB_EV_ABORT: @@ -1185,8 +1189,8 @@ static int lib_interface_eigrp_instance_create(enum nb_event event, break; } - eigrp = eigrp_get(yang_dnode_get_string(dnode, "./asn"), - VRF_DEFAULT); + eigrp = eigrp_get(yang_dnode_get_uint16(dnode, "./asn"), + ifp->vrf_id); eif = eigrp_interface_lookup(eigrp, ifp->name); if (eif == NULL) return NB_ERR_INCONSISTENCY; @@ -1197,8 +1201,8 @@ static int lib_interface_eigrp_instance_create(enum nb_event event, break; case NB_EV_APPLY: ifp = nb_running_get_entry(dnode, NULL, true); - eigrp = eigrp_get(yang_dnode_get_string(dnode, "./asn"), - VRF_DEFAULT); + eigrp = eigrp_get(yang_dnode_get_uint16(dnode, "./asn"), + ifp->vrf_id); eif = eigrp_interface_lookup(eigrp, ifp->name); if (eif == NULL) return NB_ERR_INCONSISTENCY; diff --git a/eigrpd/eigrp_topology.c b/eigrpd/eigrp_topology.c index e861cdb33..4ca7cd19d 100644 --- a/eigrpd/eigrp_topology.c +++ b/eigrpd/eigrp_topology.c @@ -173,7 +173,7 @@ void eigrp_nexthop_entry_add(struct eigrp_prefix_entry *node, void eigrp_prefix_entry_delete(struct route_table *table, struct eigrp_prefix_entry *pe) { - struct eigrp *eigrp = eigrp_lookup(); + struct eigrp *eigrp = eigrp_lookup(VRF_DEFAULT); struct eigrp_nexthop_entry *ne; struct listnode *node, *nnode; struct route_node *rn; @@ -434,7 +434,7 @@ void eigrp_topology_update_node_flags(struct eigrp_prefix_entry *dest) { struct listnode *node; struct eigrp_nexthop_entry *entry; - struct eigrp *eigrp = eigrp_lookup(); + struct eigrp *eigrp = eigrp_lookup(VRF_DEFAULT); assert(eigrp); @@ -466,7 +466,7 @@ void eigrp_topology_update_node_flags(struct eigrp_prefix_entry *dest) void eigrp_update_routing_table(struct eigrp_prefix_entry *prefix) { - struct eigrp *eigrp = eigrp_lookup(); + struct eigrp *eigrp = eigrp_lookup(VRF_DEFAULT); struct list *successors; struct listnode *node; struct eigrp_nexthop_entry *entry; diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c index da376d0a3..022b0e305 100644 --- a/eigrpd/eigrp_vty.c +++ b/eigrpd/eigrp_vty.c @@ -96,7 +96,7 @@ DEFPY (show_ip_eigrp_topology_all, struct eigrp_prefix_entry *tn; struct route_node *rn; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; @@ -132,7 +132,7 @@ DEFPY (show_ip_eigrp_topology, struct route_node *rn; struct prefix cmp; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; @@ -184,7 +184,7 @@ DEFUN (show_ip_eigrp_interfaces, bool detail = false; const char *ifname = NULL; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, "EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; @@ -228,7 +228,7 @@ DEFUN (show_ip_eigrp_neighbors, int idx = 0; const char *ifname = NULL; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; @@ -271,7 +271,7 @@ DEFUN (clear_ip_eigrp_neighbors, struct eigrp_neighbor *nbr; /* Check if eigrp process is enabled */ - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; @@ -327,7 +327,7 @@ DEFUN (clear_ip_eigrp_neighbors_int, int idx = 0; /* Check if eigrp process is enabled */ - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; @@ -390,7 +390,7 @@ DEFUN (clear_ip_eigrp_neighbors_IP, } /* Check if eigrp process is enabled */ - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; @@ -426,7 +426,7 @@ DEFUN (clear_ip_eigrp_neighbors_soft, struct eigrp *eigrp; /* Check if eigrp process is enabled */ - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; @@ -455,7 +455,7 @@ DEFUN (clear_ip_eigrp_neighbors_int_soft, struct eigrp_interface *ei; /* Check if eigrp process is enabled */ - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; @@ -496,7 +496,7 @@ DEFUN (clear_ip_eigrp_neighbors_IP_soft, } /* Check if eigrp process is enabled */ - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(VRF_DEFAULT); if (eigrp == NULL) { vty_out(vty, " EIGRP Routing Process not enabled\n"); return CMD_SUCCESS; diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index 921a52166..125259382 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -79,7 +79,7 @@ static int eigrp_router_id_update_zebra(ZAPI_CALLBACK_ARGS) router_id_zebra = router_id.u.prefix4; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(vrf_id); if (eigrp != NULL) eigrp_router_id_update(eigrp); @@ -137,7 +137,7 @@ static int eigrp_zebra_read_route(ZAPI_CALLBACK_ARGS) if (IPV4_NET127(ntohl(api.prefix.u.prefix4.s_addr))) return 0; - eigrp = eigrp_lookup(); + eigrp = eigrp_lookup(vrf_id); if (eigrp == NULL) return 0; diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c index 6b93fe664..eb99016d5 100644 --- a/eigrpd/eigrpd.c +++ b/eigrpd/eigrpd.c @@ -134,14 +134,14 @@ void eigrp_master_init(void) } /* Allocate new eigrp structure. */ -static struct eigrp *eigrp_new(const char *AS, vrf_id_t vrf_id) +static struct eigrp *eigrp_new(uint16_t as, vrf_id_t vrf_id) { struct eigrp *eigrp = XCALLOC(MTYPE_EIGRP_TOP, sizeof(struct eigrp)); /* 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; @@ -215,13 +215,13 @@ static struct eigrp *eigrp_new(const char *AS, vrf_id_t vrf_id) return eigrp; } -struct eigrp *eigrp_get(const char *AS, vrf_id_t vrf_id) +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, vrf_id); + eigrp = eigrp_new(as, vrf_id); listnode_add(eigrp_om->eigrp, eigrp); } @@ -298,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; } diff --git a/eigrpd/eigrpd.h b/eigrpd/eigrpd.h index aab81e4a7..6b4d45d1f 100644 --- a/eigrpd/eigrpd.h +++ b/eigrpd/eigrpd.h @@ -48,8 +48,8 @@ extern void eigrp_master_init(void); extern void eigrp_terminate(void); extern void eigrp_finish_final(struct eigrp *); extern void eigrp_finish(struct eigrp *); -extern struct eigrp *eigrp_get(const char *as, vrf_id_t vrf_id); -extern struct eigrp *eigrp_lookup(void); +extern struct eigrp *eigrp_get(uint16_t as, vrf_id_t vrf_id); +extern struct eigrp *eigrp_lookup(vrf_id_t vrf_id); extern void eigrp_router_id_update(struct eigrp *); /* eigrp_cli.c */ |