diff options
author | Olivier Dugeon <olivier.dugeon@orange.com> | 2019-04-15 16:11:40 +0200 |
---|---|---|
committer | Olivier Dugeon <olivier.dugeon@orange.com> | 2019-04-15 16:22:38 +0200 |
commit | 9c95fe698634d1663b9f321b588ac4f81d8492c6 (patch) | |
tree | afb291410a270fd94935108c9a2b2abf315d9fba /isisd/isis_northbound.c | |
parent | Merge pull request #4130 from donaldsharp/show_frr (diff) | |
download | frr-9c95fe698634d1663b9f321b588ac4f81d8492c6.tar.xz frr-9c95fe698634d1663b9f321b588ac4f81d8492c6.zip |
Issue #4032: Add IS-IS-TE support per Area
- Change MPLS-TE from global to per Area
- Add new mpls_te_area structure to area in replacement of global variable
isisMPLS_TE
- Move mpls-te frmo global to instance in frr-isisd.yang
- Change code in isis_te.c, isis_northbound.c, isis_cli.c, isis_pdu.c,
isis_lsp.c and isis_zebra.c accordingly
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Diffstat (limited to 'isisd/isis_northbound.c')
-rw-r--r-- | isisd/isis_northbound.c | 92 |
1 files changed, 58 insertions, 34 deletions
diff --git a/isisd/isis_northbound.c b/isisd/isis_northbound.c index 2d1d6f592..503536780 100644 --- a/isisd/isis_northbound.c +++ b/isisd/isis_northbound.c @@ -1395,19 +1395,40 @@ isis_instance_log_adjacency_changes_modify(enum nb_event event, } /* - * XPath: /frr-isisd:isis/mpls-te + * XPath: /frr-isisd:isis/instance/mpls-te */ -static int isis_mpls_te_create(enum nb_event event, +static int isis_instance_mpls_te_create(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) { struct listnode *node; + struct isis_area *area; struct isis_circuit *circuit; if (event != NB_EV_APPLY) return NB_OK; - isisMplsTE.status = enable; + area = yang_dnode_get_entry(dnode, true); + if (area->mta == NULL) { + + struct mpls_te_area *new; + + zlog_debug("ISIS MPLS-TE: Initialize area %s", + area->area_tag); + + new = XCALLOC(MTYPE_ISIS_MPLS_TE, sizeof(struct mpls_te_area)); + + /* Initialize MPLS_TE structure */ + new->status = enable; + new->level = 0; + new->inter_as = off; + new->interas_areaid.s_addr = 0; + new->router_id.s_addr = 0; + + area->mta = new; + } else { + area->mta->status = enable; + } /* * Following code is intended to handle two cases; @@ -1417,11 +1438,11 @@ static int isis_mpls_te_create(enum nb_event event, * MPLS_TE flag * 2) MPLS-TE was once enabled then disabled, and now enabled again. */ - for (ALL_LIST_ELEMENTS_RO(isisMplsTE.cir_list, node, circuit)) { + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { if (circuit->mtc == NULL || IS_FLOOD_AS(circuit->mtc->type)) continue; - if ((circuit->mtc->status == disable) + if (!IS_MPLS_TE(circuit->mtc) && HAS_LINK_PARAMS(circuit->interface)) circuit->mtc->status = enable; else @@ -1436,19 +1457,24 @@ static int isis_mpls_te_create(enum nb_event event, return NB_OK; } -static int isis_mpls_te_destroy(enum nb_event event, +static int isis_instance_mpls_te_destroy(enum nb_event event, const struct lyd_node *dnode) { struct listnode *node; + struct isis_area *area; struct isis_circuit *circuit; if (event != NB_EV_APPLY) return NB_OK; - isisMplsTE.status = disable; + area = yang_dnode_get_entry(dnode, true); + if (IS_MPLS_TE(area->mta)) + area->mta->status = disable; + else + return NB_OK; /* Flush LSP if circuit engage */ - for (ALL_LIST_ELEMENTS_RO(isisMplsTE.cir_list, node, circuit)) { + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { if (circuit->mtc == NULL || (circuit->mtc->status == disable)) continue; @@ -1465,55 +1491,53 @@ static int isis_mpls_te_destroy(enum nb_event event, } /* - * XPath: /frr-isisd:isis/mpls-te/router-address + * XPath: /frr-isisd:isis/instance/mpls-te/router-address */ -static int isis_mpls_te_router_address_modify(enum nb_event event, +static int isis_instance_mpls_te_router_address_modify(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) { struct in_addr value; - struct listnode *node; struct isis_area *area; if (event != NB_EV_APPLY) return NB_OK; - yang_dnode_get_ipv4(&value, dnode, NULL); - isisMplsTE.router_id.s_addr = value.s_addr; + area = yang_dnode_get_entry(dnode, true); /* only proceed if MPLS-TE is enabled */ - if (isisMplsTE.status == disable) + if (!IS_MPLS_TE(area->mta)) return NB_OK; - /* Update main Router ID in isis global structure */ - isis->router_id = value.s_addr; + /* Update Area Router ID */ + yang_dnode_get_ipv4(&value, dnode, NULL); + area->mta->router_id.s_addr = value.s_addr; + /* And re-schedule LSP update */ - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) - if (listcount(area->area_addrs) > 0) - lsp_regenerate_schedule(area, area->is_type, 0); + if (listcount(area->area_addrs) > 0) + lsp_regenerate_schedule(area, area->is_type, 0); return NB_OK; } -static int isis_mpls_te_router_address_destroy(enum nb_event event, +static int isis_instance_mpls_te_router_address_destroy(enum nb_event event, const struct lyd_node *dnode) { - struct listnode *node; struct isis_area *area; if (event != NB_EV_APPLY) return NB_OK; - isisMplsTE.router_id.s_addr = INADDR_ANY; + area = yang_dnode_get_entry(dnode, true); /* only proceed if MPLS-TE is enabled */ - if (isisMplsTE.status == disable) + if (!IS_MPLS_TE(area->mta)) return NB_OK; - /* Update main Router ID in isis global structure */ - isis->router_id = 0; + /* Reset Area Router ID */ + area->mta->router_id.s_addr = INADDR_ANY; + /* And re-schedule LSP update */ - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) - if (listcount(area->area_addrs) > 0) - lsp_regenerate_schedule(area, area->is_type, 0); + if (listcount(area->area_addrs) > 0) + lsp_regenerate_schedule(area, area->is_type, 0); return NB_OK; } @@ -3049,15 +3073,15 @@ const struct frr_yang_module_info frr_isisd_info = { .cbs.cli_show = cli_show_isis_log_adjacency, }, { - .xpath = "/frr-isisd:isis/mpls-te", - .cbs.create = isis_mpls_te_create, - .cbs.destroy = isis_mpls_te_destroy, + .xpath = "/frr-isisd:isis/instance/mpls-te", + .cbs.create = isis_instance_mpls_te_create, + .cbs.destroy = isis_instance_mpls_te_destroy, .cbs.cli_show = cli_show_isis_mpls_te, }, { - .xpath = "/frr-isisd:isis/mpls-te/router-address", - .cbs.modify = isis_mpls_te_router_address_modify, - .cbs.destroy = isis_mpls_te_router_address_destroy, + .xpath = "/frr-isisd:isis/instance/mpls-te/router-address", + .cbs.modify = isis_instance_mpls_te_router_address_modify, + .cbs.destroy = isis_instance_mpls_te_router_address_destroy, .cbs.cli_show = cli_show_isis_mpls_te_router_addr, }, { |