diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:56:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:56:25 +0000 |
commit | 289582b3dcbeb23328325d224c7db7de66a3a55f (patch) | |
tree | 989c36d57aab945c36e34c952f438746ce18b3bd /isisd | |
parent | Releasing progress-linux version 10.0.1-0.1~progress7.99u1. (diff) | |
download | frr-289582b3dcbeb23328325d224c7db7de66a3a55f.tar.xz frr-289582b3dcbeb23328325d224c7db7de66a3a55f.zip |
Merging upstream version 10.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'isisd')
-rw-r--r-- | isisd/isis_adjacency.c | 8 | ||||
-rw-r--r-- | isisd/isis_lfa.c | 12 | ||||
-rw-r--r-- | isisd/isis_lsp.c | 78 | ||||
-rw-r--r-- | isisd/isis_main.c | 2 | ||||
-rw-r--r-- | isisd/isis_nb_config.c | 3 | ||||
-rw-r--r-- | isisd/isis_pdu.c | 2 | ||||
-rw-r--r-- | isisd/isis_spf.c | 183 | ||||
-rw-r--r-- | isisd/isis_sr.c | 37 | ||||
-rw-r--r-- | isisd/isis_sr.h | 2 | ||||
-rw-r--r-- | isisd/isis_srv6.c | 6 | ||||
-rw-r--r-- | isisd/isis_srv6.h | 2 | ||||
-rw-r--r-- | isisd/isis_te.c | 105 | ||||
-rw-r--r-- | isisd/isis_te.h | 7 | ||||
-rw-r--r-- | isisd/isis_tlvs.c | 1030 | ||||
-rw-r--r-- | isisd/isis_zebra.c | 2 | ||||
-rw-r--r-- | isisd/isisd.c | 320 |
16 files changed, 1409 insertions, 390 deletions
diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c index cba1b91..430bee9 100644 --- a/isisd/isis_adjacency.c +++ b/isisd/isis_adjacency.c @@ -687,7 +687,7 @@ void isis_adj_print_json(struct isis_adjacency *adj, struct json_object *json, default: continue; } - backup = (sra->type == ISIS_SR_LAN_BACKUP) ? " (backup)" + backup = (sra->type == ISIS_SR_ADJ_BACKUP) ? " (backup)" : ""; json_object_string_add(adj_sid_json, "nexthop", @@ -726,13 +726,13 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty, now = time(NULL); if (adj->last_upd) { if (adj->last_upd + adj->hold_time < now) - vty_out(vty, " Expiring"); + vty_out(vty, " Expiring "); else vty_out(vty, " %-9llu", (unsigned long long)adj->last_upd + adj->hold_time - now); } else - vty_out(vty, "- "); + vty_out(vty, " - "); vty_out(vty, "%-10pSY", adj->snpa); vty_out(vty, "\n"); } @@ -862,7 +862,7 @@ void isis_adj_print_vty(struct isis_adjacency *adj, struct vty *vty, default: continue; } - backup = (sra->type == ISIS_SR_LAN_BACKUP) ? " (backup)" + backup = (sra->type == ISIS_SR_ADJ_BACKUP) ? " (backup)" : ""; vty_out(vty, " %s %s%s: %u\n", diff --git a/isisd/isis_lfa.c b/isisd/isis_lfa.c index 6f21f4c..dc8f0b9 100644 --- a/isisd/isis_lfa.c +++ b/isisd/isis_lfa.c @@ -916,9 +916,8 @@ int isis_tilfa_check(struct isis_spftree *spftree_pc, adj = isis_adj_find(spftree_pc->area, spftree_pc->level, vertex->N.id); - if (adj - && isis_sr_adj_sid_find(adj, spftree_pc->family, - ISIS_SR_LAN_BACKUP)) { + if (adj && isis_sr_adj_sid_find(adj, spftree_pc->family, + ISIS_SR_ADJ_BACKUP)) { if (IS_DEBUG_LFA) zlog_debug( "ISIS-LFA: %s %s already covered by node protection", @@ -2127,9 +2126,16 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, } vadj_primary = listnode_head(vertex->Adj_N); + if (!vadj_primary) { + if (IS_DEBUG_LFA) + zlog_debug( + "ISIS-LFA: skipping computing LFAs due to no adjacencies"); + continue; + } sadj_primary = vadj_primary->sadj; parent_vertex = listnode_head(vertex->parents); + assert(parent_vertex); prefix_metric = vertex->d_N - parent_vertex->d_N; /* diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 77573cd..c98cee0 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -442,47 +442,6 @@ void set_overload_on_start_timer(struct event *thread) isis_area_overload_bit_set(area, false); } -static void isis_reset_attach_bit(struct isis_adjacency *adj) -{ - struct isis_area *area = adj->circuit->area; - struct lspdb_head *head; - struct isis_lsp *lsp; - uint8_t lspid[ISIS_SYS_ID_LEN + 2]; - - /* - * If an L2 adjacency changed its state in L-1-2 area, we have to: - * - set the attached bit in L1 LSPs if it's the first L2 adjacency - * - remove the attached bit in L1 LSPs if it's the last L2 adjacency - */ - - if (area->is_type != IS_LEVEL_1_AND_2 || adj->level == ISIS_ADJ_LEVEL1) - return; - - if (!area->attached_bit_send) - return; - - head = &area->lspdb[IS_LEVEL_1 - 1]; - memset(lspid, 0, ISIS_SYS_ID_LEN + 2); - memcpy(lspid, area->isis->sysid, ISIS_SYS_ID_LEN); - - lsp = lsp_search(head, lspid); - if (!lsp) - return; - - if (adj->adj_state == ISIS_ADJ_UP - && !(lsp->hdr.lsp_bits & LSPBIT_ATT)) { - sched_debug("ISIS (%s): adj going up regenerate lsp-bits", - area->area_tag); - lsp_regenerate_schedule(area, IS_LEVEL_1, 0); - } else if (adj->adj_state == ISIS_ADJ_DOWN - && (lsp->hdr.lsp_bits & LSPBIT_ATT) - && !isis_level2_adj_up(area)) { - sched_debug("ISIS (%s): adj going down regenerate lsp-bits", - area->area_tag); - lsp_regenerate_schedule(area, IS_LEVEL_1, 0); - } -} - static uint8_t lsp_bits_generate(int level, int overload_bit, int attached_bit, struct isis_area *area) { @@ -746,6 +705,10 @@ void lsp_print_common(struct isis_lsp *lsp, struct vty *vty, struct json_object } } +#if CONFDATE > 20240916 +CPP_NOTICE("Remove JSON in '-' format") +#endif + void lsp_print_json(struct isis_lsp *lsp, struct json_object *json, char dynhost, struct isis *isis) { @@ -759,10 +722,20 @@ void lsp_print_json(struct isis_lsp *lsp, struct json_object *json, own_json = json_object_new_object(); json_object_object_add(json, "lsp", own_json); json_object_string_add(own_json, "id", LSPid); +#if CONFDATE > 20240916 + CPP_NOTICE("remove own key") +#endif json_object_string_add(own_json, "own", lsp->own_lsp ? "*" : " "); + if (lsp->own_lsp) + json_object_boolean_add(own_json, "ownLSP", true); json_object_int_add(json, "pdu-len", lsp->hdr.pdu_len); + json_object_int_add(json, "pduLen", lsp->hdr.pdu_len); snprintfrr(buf, sizeof(buf), "0x%08x", lsp->hdr.seqno); +#if CONFDATE > 20240916 + CPP_NOTICE("remove seq-number key") +#endif json_object_string_add(json, "seq-number", buf); + json_object_string_add(json, "seqNumber", buf); snprintfrr(buf, sizeof(buf), "0x%04hx", lsp->hdr.checksum); json_object_string_add(json, "chksum", buf); if (lsp->hdr.rem_lifetime == 0) { @@ -772,8 +745,13 @@ void lsp_print_json(struct isis_lsp *lsp, struct json_object *json, } else { json_object_int_add(json, "holdtime", lsp->hdr.rem_lifetime); } +#if CONFDATE > 20240916 + CPP_NOTICE("remove att-p-ol key") +#endif json_object_string_add( json, "att-p-ol", lsp_bits2string(lsp->hdr.lsp_bits, b, sizeof(b))); + json_object_string_add(json, "attPOl", + lsp_bits2string(lsp->hdr.lsp_bits, b, sizeof(b))); } void lsp_print_vty(struct isis_lsp *lsp, struct vty *vty, @@ -822,15 +800,24 @@ int lsp_print_all(struct vty *vty, struct json_object *json, { struct isis_lsp *lsp; int lsp_count = 0; + struct json_object *lsp_json = NULL; if (detail == ISIS_UI_LEVEL_BRIEF) { frr_each (lspdb, head, lsp) { - lsp_print_common(lsp, vty, json, dynhost, isis); + if (json) { + lsp_json = json_object_new_object(); + json_object_array_add(json, lsp_json); + } + lsp_print_common(lsp, vty, lsp_json, dynhost, isis); lsp_count++; } } else if (detail == ISIS_UI_LEVEL_DETAIL) { frr_each (lspdb, head, lsp) { - lsp_print_detail(lsp, vty, json, dynhost, isis); + if (json) { + lsp_json = json_object_new_object(); + json_object_array_add(json, lsp_json); + } + lsp_print_detail(lsp, vty, lsp_json, dynhost, isis); lsp_count++; } } @@ -2345,11 +2332,6 @@ static int lsp_handle_adj_state_change(struct isis_adjacency *adj) { lsp_regenerate_schedule(adj->circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0); - /* when an adjacency state changes determine if we need to - * change attach_bits in other area's LSPs - */ - isis_reset_attach_bit(adj); - return 0; } diff --git a/isisd/isis_main.c b/isisd/isis_main.c index 60ec8cd..8dd3a97 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -28,6 +28,7 @@ #include "libfrr.h" #include "routemap.h" #include "affinitymap.h" +#include "libagentx.h" #include "isisd/isis_affinitymap.h" #include "isisd/isis_constants.h" @@ -307,6 +308,7 @@ int main(int argc, char **argv, char **envp) /* * initializations */ + libagentx_init(); cmd_init_config_callbacks(isis_config_start, isis_config_end); isis_error_init(); access_list_init(); diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c index 5794e16..763b8b7 100644 --- a/isisd/isis_nb_config.c +++ b/isisd/isis_nb_config.c @@ -3821,7 +3821,8 @@ int lib_interface_isis_circuit_type_modify(struct nb_cb_modify_args *args) case NB_EV_APPLY: circuit = nb_running_get_entry(args->dnode, NULL, true); circuit->is_type_config = circ_type; - isis_circuit_is_type_set(circuit, circ_type); + if (!circuit->area || circuit->area->is_type == IS_LEVEL_1_AND_2) + isis_circuit_is_type_set(circuit, circ_type); break; } diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index 6f410d3..5be3170 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -2082,7 +2082,7 @@ static void send_hello_cb(struct event *thread) circuit->u.p2p.t_send_p2p_hello = NULL; send_hello(circuit, 1); send_hello_sched(circuit, ISIS_LEVEL1, - 1000 * circuit->hello_interval[1]); + 1000 * circuit->hello_interval[0]); return; } diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index 3b3e1fd..1197f8c 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -873,6 +873,9 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, || (mt_router_info && !mt_router_info->overload)); lspfragloop: + if (!lsp->tlvs) + return ISIS_OK; + if (lsp->hdr.seqno == 0) { zlog_warn("%s: lsp with 0 seq_num - ignore", __func__); return ISIS_WARNING; @@ -2345,9 +2348,6 @@ static void show_isis_topology_common(struct vty *vty, int levels, return; for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { - vty_out(vty, - "Area %s:", area->area_tag ? area->area_tag : "null"); - #ifndef FABRICD /* * The shapes of the flex algo spftree 2-dimensional array @@ -2362,7 +2362,12 @@ static void show_isis_topology_common(struct vty *vty, int levels, fa_data = (struct isis_flex_algo_data *)fa->data; } else fa_data = NULL; +#endif /* ifndef FABRICD */ + vty_out(vty, + "Area %s:", area->area_tag ? area->area_tag : "null"); + +#ifndef FABRICD if (algo != SR_ALGORITHM_SPF) vty_out(vty, " Algorithm %hhu\n", algo); else @@ -2426,7 +2431,7 @@ DEFUN(show_isis_topology, show_isis_topology_cmd, " [vrf <NAME|all>] topology" #ifndef FABRICD " [<level-1|level-2>]" - " [algorithm (128-255)]" + " [algorithm [(128-255)]]" #endif /* ifndef FABRICD */ , SHOW_STR PROTO_HELP VRF_CMD_HELP_STR @@ -2445,8 +2450,10 @@ DEFUN(show_isis_topology, show_isis_topology_cmd, struct isis *isis = NULL; const char *vrf_name = VRF_DEFAULT_NAME; bool all_vrf = false; + bool all_algorithm = false; int idx_vrf = 0; - uint8_t algorithm = SR_ALGORITHM_SPF; + uint16_t algorithm = SR_ALGORITHM_SPF; + #ifndef FABRICD int idx = 0; @@ -2455,8 +2462,12 @@ DEFUN(show_isis_topology, show_isis_topology_cmd, levels = ISIS_LEVEL1; if (argv_find(argv, argc, "level-2", &idx)) levels = ISIS_LEVEL2; - if (argv_find(argv, argc, "algorithm", &idx)) - algorithm = (uint8_t)strtoul(argv[idx + 1]->arg, NULL, 10); + if (argv_find(argv, argc, "algorithm", &idx)) { + if (argv_find(argv, argc, "(128-255)", &idx)) + algorithm = (uint16_t)strtoul(argv[idx]->arg, NULL, 10); + else + all_algorithm = true; + } #endif /* ifndef FABRICD */ if (!im) { @@ -2465,17 +2476,33 @@ DEFUN(show_isis_topology, show_isis_topology_cmd, } ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { + if (all_algorithm) { + for (algorithm = SR_ALGORITHM_FLEX_MIN; + algorithm <= SR_ALGORITHM_FLEX_MAX; + algorithm++) + show_isis_topology_common( + vty, levels, isis, + (uint8_t)algorithm); + } else { show_isis_topology_common(vty, levels, isis, - algorithm); - return CMD_SUCCESS; + (uint8_t)algorithm); + } } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) - show_isis_topology_common(vty, levels, isis, algorithm); + return CMD_SUCCESS; } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis == NULL) + return CMD_SUCCESS; + if (all_algorithm) { + for (algorithm = SR_ALGORITHM_FLEX_MIN; + algorithm <= SR_ALGORITHM_FLEX_MAX; algorithm++) { + show_isis_topology_common(vty, levels, isis, + (uint8_t)algorithm); + } + } else + show_isis_topology_common(vty, levels, isis, (uint8_t)algorithm); return CMD_SUCCESS; } @@ -2648,17 +2675,14 @@ DEFUN(show_isis_flex_algo, show_isis_flex_algo_cmd, ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) - show_isis_flex_algo_common(vty, isis, - flex_algo); - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) show_isis_flex_algo_common(vty, isis, flex_algo); + return CMD_SUCCESS; } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) + show_isis_flex_algo_common(vty, isis, flex_algo); return CMD_SUCCESS; } @@ -2884,7 +2908,7 @@ static void show_isis_route_common(struct vty *vty, int levels, struct isis_spftree *spftree; struct listnode *node; struct isis_area *area; - char key[8]; + char key[18]; if (!isis->area_list || isis->area_list->count == 0) return; @@ -2914,6 +2938,7 @@ static void show_isis_route_common(struct vty *vty, int levels, jstr = json_object_new_string( area->area_tag ? area->area_tag : "null"); json_object_object_add(*json, "area", jstr); + json_object_int_add(*json, "algorithm", algo); } else { vty_out(vty, "Area %s:", area->area_tag ? area->area_tag : "null"); @@ -3013,6 +3038,39 @@ static void show_isis_route_common(struct vty *vty, int levels, } } +static void show_isis_route_all_algos(struct vty *vty, int levels, + struct isis *isis, bool prefix_sid, + bool backup, json_object **json) +{ + uint16_t algo; + + json_object *json_algo = NULL, *json_algos = NULL; + + if (json) { + *json = json_object_new_object(); + json_algos = json_object_new_array(); + } + + for (algo = SR_ALGORITHM_FLEX_MIN; algo <= SR_ALGORITHM_FLEX_MAX; + algo++) { + show_isis_route_common(vty, levels, isis, prefix_sid, backup, + (uint8_t)algo, json ? &json_algo : NULL); + if (!json) + continue; + if (json_object_object_length(json_algo) == 0) { + json_object_free(json_algo); + continue; + } + json_object_object_add(json_algo, "algorithm", + json_object_new_int(algo)); + json_object_array_add(json_algos, json_algo); + } + + if (json) + json_object_object_add(*json, "algorithms", json_algos); +} + + DEFUN(show_isis_route, show_isis_route_cmd, "show " PROTO_NAME " [vrf <NAME|all>] route" @@ -3021,7 +3079,7 @@ DEFUN(show_isis_route, show_isis_route_cmd, #endif /* ifndef FABRICD */ " [<prefix-sid|backup>]" #ifndef FABRICD - " [algorithm (128-255)]" + " [algorithm [(128-255)]]" #endif /* ifndef FABRICD */ " [json$uj]", SHOW_STR PROTO_HELP VRF_FULL_CMD_HELP_STR @@ -3043,6 +3101,7 @@ DEFUN(show_isis_route, show_isis_route_cmd, struct listnode *node; const char *vrf_name = VRF_DEFAULT_NAME; bool all_vrf = false; + bool all_algorithm = false; bool prefix_sid = false; bool backup = false; bool uj = use_json(argc, argv); @@ -3069,40 +3128,50 @@ DEFUN(show_isis_route, show_isis_route_cmd, backup = true; #ifndef FABRICD - if (argv_find(argv, argc, "algorithm", &idx)) - algorithm = (uint8_t)strtoul(argv[idx + 1]->arg, NULL, 10); + if (argv_find(argv, argc, "algorithm", &idx)) { + if (argv_find(argv, argc, "(128-255)", &idx)) + algorithm = (uint8_t)strtoul(argv[idx]->arg, NULL, 10); + else + all_algorithm = true; + } #endif /* ifndef FABRICD */ if (uj) json = json_object_new_array(); - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { - show_isis_route_common( - vty, levels, isis, prefix_sid, backup, - algorithm, uj ? &json_vrf : NULL); - if (uj) { - json_object_object_add( - json_vrf, "vrf_id", - json_object_new_int( - isis->vrf_id)); - json_object_array_add(json, json_vrf); - } + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { + if (all_algorithm) + show_isis_route_all_algos(vty, levels, isis, + prefix_sid, backup, + uj ? &json_vrf : NULL); + else + show_isis_route_common(vty, levels, isis, + prefix_sid, backup, + algorithm, + uj ? &json_vrf : NULL); + if (uj) { + json_object_object_add(json_vrf, "vrf_id", + json_object_new_int( + isis->vrf_id)); + json_object_array_add(json, json_vrf); } - goto out; } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) { + goto out; + } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) { + if (all_algorithm) + show_isis_route_all_algos(vty, levels, isis, prefix_sid, + backup, uj ? &json_vrf : NULL); + else show_isis_route_common(vty, levels, isis, prefix_sid, backup, algorithm, uj ? &json_vrf : NULL); - if (uj) { - json_object_object_add( - json_vrf, "vrf_id", - json_object_new_int(isis->vrf_id)); - json_object_array_add(json, json_vrf); - } + if (uj) { + json_object_object_add(json_vrf, "vrf_id", + json_object_new_int(isis->vrf_id)); + json_object_array_add(json, json_vrf); } } @@ -3315,16 +3384,14 @@ DEFUN(show_isis_frr_summary, show_isis_frr_summary_cmd, } ISIS_FIND_VRF_ARGS(argv, argc, idx, vrf_name, all_vrf); - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) - show_isis_frr_summary_common(vty, levels, isis); - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) show_isis_frr_summary_common(vty, levels, isis); + return CMD_SUCCESS; } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) + show_isis_frr_summary_common(vty, levels, isis); return CMD_SUCCESS; } diff --git a/isisd/isis_sr.c b/isisd/isis_sr.c index 1d69dbb..f783038 100644 --- a/isisd/isis_sr.c +++ b/isisd/isis_sr.c @@ -462,8 +462,7 @@ void isis_area_delete_backup_adj_sids(struct isis_area *area, int level) struct listnode *node, *nnode; for (ALL_LIST_ELEMENTS(area->srdb.adj_sids, node, nnode, sra)) - if (sra->type == ISIS_SR_LAN_BACKUP - && (sra->adj->level & level)) + if (sra->type == ISIS_SR_ADJ_BACKUP && (sra->adj->level & level)) sr_adj_sid_del(sra); } @@ -689,7 +688,7 @@ void sr_adj_sid_add_single(struct isis_adjacency *adj, int family, bool backup, circuit->ext = isis_alloc_ext_subtlvs(); sra = XCALLOC(MTYPE_ISIS_SR_INFO, sizeof(*sra)); - sra->type = backup ? ISIS_SR_LAN_BACKUP : ISIS_SR_ADJ_NORMAL; + sra->type = backup ? ISIS_SR_ADJ_BACKUP : ISIS_SR_ADJ_NORMAL; sra->input_label = input_label; sra->nexthop.family = family; sra->nexthop.address = nexthop; @@ -819,7 +818,7 @@ static void sr_adj_sid_del(struct sr_adjacency *sra) exit(1); } - if (sra->type == ISIS_SR_LAN_BACKUP && sra->backup_nexthops) { + if (sra->type == ISIS_SR_ADJ_BACKUP && sra->backup_nexthops) { sra->backup_nexthops->del = (void (*)(void *))isis_nexthop_delete; list_delete(&sra->backup_nexthops); @@ -1021,8 +1020,6 @@ static void show_node(struct vty *vty, struct isis_area *area, int level, struct ttable *tt; char buf[128]; - vty_out(vty, " IS-IS %s SR-Nodes:\n\n", circuit_t2string(level)); - /* Prepare table. */ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); ttable_add_row(tt, "System ID|SRGB|SRLB|Algorithm|MSD"); @@ -1063,6 +1060,8 @@ static void show_node(struct vty *vty, struct isis_area *area, int level, if (tt->nrows > 1) { char *table; + vty_out(vty, " IS-IS %s SR-Nodes:\n\n", circuit_t2string(level)); + table = ttable_dump(tt, "\n"); vty_out(vty, "%s\n", table); XFREE(MTYPE_TMP, table); @@ -1074,7 +1073,7 @@ DEFUN(show_sr_node, show_sr_node_cmd, "show " PROTO_NAME " segment-routing node" #ifndef FABRICD - " [algorithm (128-255)]" + " [algorithm [(128-255)]]" #endif /* ifndef FABRICD */ , SHOW_STR PROTO_HELP @@ -1088,13 +1087,18 @@ DEFUN(show_sr_node, show_sr_node_cmd, { struct listnode *node, *inode; struct isis_area *area; - uint8_t algorithm = SR_ALGORITHM_SPF; + uint16_t algorithm = SR_ALGORITHM_SPF; + bool all_algorithm = false; struct isis *isis; #ifndef FABRICD int idx = 0; - if (argv_find(argv, argc, "algorithm", &idx)) - algorithm = (uint8_t)strtoul(argv[idx + 1]->arg, NULL, 10); + if (argv_find(argv, argc, "algorithm", &idx)) { + if (argv_find(argv, argc, "(128-255)", &idx)) + algorithm = (uint16_t)strtoul(argv[idx]->arg, NULL, 10); + else + all_algorithm = true; + } #endif /* ifndef FABRICD */ for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { @@ -1106,8 +1110,17 @@ DEFUN(show_sr_node, show_sr_node_cmd, continue; } for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; - level++) - show_node(vty, area, level, algorithm); + level++) { + if (all_algorithm) { + for (algorithm = SR_ALGORITHM_FLEX_MIN; + algorithm <= SR_ALGORITHM_FLEX_MAX; + algorithm++) + show_node(vty, area, level, + (uint8_t)algorithm); + } else + show_node(vty, area, level, + (uint8_t)algorithm); + } } } diff --git a/isisd/isis_sr.h b/isisd/isis_sr.h index 4378760..76f7768 100644 --- a/isisd/isis_sr.h +++ b/isisd/isis_sr.h @@ -82,7 +82,7 @@ struct sr_local_block { /* Segment Routing Adjacency-SID type. */ enum sr_adj_type { ISIS_SR_ADJ_NORMAL = 0, - ISIS_SR_LAN_BACKUP, + ISIS_SR_ADJ_BACKUP, }; /* Segment Routing Adjacency. */ diff --git a/isisd/isis_srv6.c b/isisd/isis_srv6.c index 1b0c706..44fd599 100644 --- a/isisd/isis_srv6.c +++ b/isisd/isis_srv6.c @@ -363,7 +363,7 @@ void isis_area_delete_backup_srv6_endx_sids(struct isis_area *area, int level) struct listnode *node, *nnode; for (ALL_LIST_ELEMENTS(area->srv6db.srv6_endx_sids, node, nnode, sra)) - if (sra->type == ISIS_SRV6_LAN_BACKUP && + if (sra->type == ISIS_SRV6_ADJ_BACKUP && (sra->adj->level & level)) srv6_endx_sid_del(sra); } @@ -420,7 +420,7 @@ void srv6_endx_sid_add_single(struct isis_adjacency *adj, bool backup, : SRV6_ENDPOINT_BEHAVIOR_END_X; sra = XCALLOC(MTYPE_ISIS_SRV6_INFO, sizeof(*sra)); - sra->type = backup ? ISIS_SRV6_LAN_BACKUP : ISIS_SRV6_ADJ_NORMAL; + sra->type = backup ? ISIS_SRV6_ADJ_BACKUP : ISIS_SRV6_ADJ_NORMAL; sra->behavior = behavior; sra->locator = chunk; sra->structure.loc_block_len = chunk->block_bits_length; @@ -538,7 +538,7 @@ void srv6_endx_sid_del(struct srv6_adjacency *sra) exit(1); } - if (sra->type == ISIS_SRV6_LAN_BACKUP && sra->backup_nexthops) { + if (sra->type == ISIS_SRV6_ADJ_BACKUP && sra->backup_nexthops) { sra->backup_nexthops->del = (void (*)(void *))isis_nexthop_delete; list_delete(&sra->backup_nexthops); diff --git a/isisd/isis_srv6.h b/isisd/isis_srv6.h index 3386436..7f16712 100644 --- a/isisd/isis_srv6.h +++ b/isisd/isis_srv6.h @@ -68,7 +68,7 @@ struct isis_srv6_locator { /* SRv6 Adjacency-SID type */ enum srv6_adj_type { ISIS_SRV6_ADJ_NORMAL = 0, - ISIS_SRV6_LAN_BACKUP, + ISIS_SRV6_ADJ_BACKUP, }; /* SRv6 Adjacency. */ diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 90b53c5..3683f74 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -488,6 +488,10 @@ void isis_link_params_update(struct isis_circuit *circuit, ext->status = EXT_ADJ_SID; else if (IS_SUBTLV(ext, EXT_LAN_ADJ_SID)) ext->status = EXT_LAN_ADJ_SID; + else if (IS_SUBTLV(ext, EXT_SRV6_LAN_ENDX_SID)) + ext->status = EXT_SRV6_LAN_ENDX_SID; + else if (IS_SUBTLV(ext, EXT_SRV6_ENDX_SID)) + ext->status = EXT_SRV6_ENDX_SID; else ext->status = 0; } @@ -793,6 +797,12 @@ static struct ls_vertex *lsp_to_vertex(struct ls_ted *ted, struct isis_lsp *lsp) lnode.msd = cap->msd; SET_FLAG(lnode.flags, LS_NODE_MSD); } + if (cap->srv6_cap.is_srv6_capable) { + SET_FLAG(lnode.flags, LS_NODE_SRV6); + lnode.srv6_cap_flags = cap->srv6_cap.flags; + memcpy(&lnode.srv6_msd, &cap->srv6_msd, + sizeof(struct isis_srv6_msd)); + } } } @@ -1048,7 +1058,51 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv, } } } + if (CHECK_FLAG(tlvs->status, EXT_SRV6_ENDX_SID)) { + struct isis_srv6_endx_sid_subtlv *endx = + (struct isis_srv6_endx_sid_subtlv *) + tlvs->srv6_endx_sid.head; + int i; + + for (; endx; endx = endx->next) { + if (endx->flags & EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG) { + i = 1; + SET_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SRV6SID); + } else { + i = 0; + SET_FLAG(attr->flags, LS_ATTR_ADJ_SRV6SID); + } + attr->adj_srv6_sid[i].flags = endx->flags; + attr->adj_srv6_sid[i].weight = endx->weight; + memcpy(&attr->adj_srv6_sid[i].sid, &endx->sid, + sizeof(struct in6_addr)); + attr->adj_srv6_sid[i].endpoint_behavior = endx->behavior; + } + } + if (CHECK_FLAG(tlvs->status, EXT_SRV6_LAN_ENDX_SID)) { + struct isis_srv6_lan_endx_sid_subtlv *lendx = + (struct isis_srv6_lan_endx_sid_subtlv *) + tlvs->srv6_lan_endx_sid.head; + int i; + for (; lendx; lendx = lendx->next) { + if (lendx->flags & EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG) { + i = 1; + SET_FLAG(attr->flags, LS_ATTR_BCK_ADJ_SRV6SID); + } else { + i = 0; + SET_FLAG(attr->flags, LS_ATTR_ADJ_SRV6SID); + } + memcpy(&attr->adj_srv6_sid[i].neighbor.sysid, + &lendx->neighbor_id, ISIS_SYS_ID_LEN); + attr->adj_srv6_sid[i].flags = lendx->flags; + attr->adj_srv6_sid[i].weight = lendx->weight; + memcpy(&attr->adj_srv6_sid[i].sid, &lendx->sid, + sizeof(struct in6_addr)); + attr->adj_srv6_sid[i].endpoint_behavior = + lendx->behavior; + } + } return attr; } @@ -1636,30 +1690,26 @@ DEFUN(show_isis_mpls_te_router, return CMD_SUCCESS; } ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, - anode, area)) { - if (!IS_MPLS_TE(area->mta)) - continue; - - show_router_id(vty, area); - } - } - return 0; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, - area)) { + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { + for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { if (!IS_MPLS_TE(area->mta)) continue; show_router_id(vty, area); } } + return 0; + } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) { + for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + if (!IS_MPLS_TE(area->mta)) + continue; + + show_router_id(vty, area); + } } return CMD_SUCCESS; @@ -2108,19 +2158,18 @@ DEFUN(show_isis_mpls_te_db, int rc = CMD_WARNING; ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { - rc = show_isis_ted(vty, argv, argc, isis); - if (rc != CMD_SUCCESS) - return rc; - } - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis) + + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { rc = show_isis_ted(vty, argv, argc, isis); + if (rc != CMD_SUCCESS) + return rc; + } + return CMD_SUCCESS; } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis) + rc = show_isis_ted(vty, argv, argc, isis); return rc; } diff --git a/isisd/isis_te.h b/isisd/isis_te.h index 5087cda..bf1dc2b 100644 --- a/isisd/isis_te.h +++ b/isisd/isis_te.h @@ -69,9 +69,10 @@ typedef enum _status_t { disable, enable, learn } status_t; /* Mode for Inter-AS LSP */ /* TODO: Check how if LSP is flooded in RFC5316 */ typedef enum _interas_mode_t { off, region, as, emulate } interas_mode_t; -#define IS_EXT_TE(e) (e && e->status != 0 \ - && e->status != EXT_ADJ_SID \ - && e->status != EXT_LAN_ADJ_SID) +#define IS_EXT_TE(e) \ + (e && e->status != 0 && e->status != EXT_ADJ_SID && \ + e->status != EXT_LAN_ADJ_SID && e->status != EXT_SRV6_ENDX_SID && \ + e->status != EXT_SRV6_LAN_ENDX_SID) #define IS_MPLS_TE(a) (a && a->status == enable) #define IS_EXPORT_TE(a) (a->export) diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c index 93ae8c6..3bb8a48 100644 --- a/isisd/isis_tlvs.c +++ b/isisd/isis_tlvs.c @@ -348,9 +348,120 @@ copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) } static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, + struct json_object *ext_json, struct sbuf *buf, int indent) { char admin_group_buf[ADMIN_GROUP_PRINT_MAX_SIZE]; + struct json_object *json; + char cnt_buf[255]; + size_t i; + int j; + + if (ext_json) { + json = json_object_new_object(); + json_object_object_add(ext_json, "asla", json); + json_object_boolean_add(json, "legacyFlag", asla->legacy); + json_object_string_addf(json, "standardApp", "0x%02x", + asla->standard_apps); + if (IS_SUBTLV(asla, EXT_ADM_GRP)) + json_object_string_addf(json, "adminGroup", "0x%x", + asla->admin_group); + if (IS_SUBTLV(asla, EXT_EXTEND_ADM_GRP) && + admin_group_nb_words(&asla->ext_admin_group) != 0) { + struct json_object *ext_adm_grp_json; + + ext_adm_grp_json = json_object_new_object(); + json_object_object_add(json, "extendedAdminGroup", + ext_adm_grp_json); + for (i = 0; + i < admin_group_nb_words(&asla->ext_admin_group); + i++) { + snprintfrr(cnt_buf, sizeof(cnt_buf), "%lu", + (unsigned long)i); + json_object_string_addf(ext_adm_grp_json, + cnt_buf, "0x%x", + asla->ext_admin_group + .bitmap.data[i]); + } + } + if (IS_SUBTLV(asla, EXT_MAX_BW)) + json_object_string_addf(json, "maxBandwithBytesSec", + "%g", asla->max_bw); + if (IS_SUBTLV(asla, EXT_MAX_RSV_BW)) + json_object_string_addf(json, "maxResBandwithBytesSec", + "%g", asla->max_rsv_bw); + if (IS_SUBTLV(asla, EXT_UNRSV_BW)) { + struct json_object *unrsv_json = + json_object_new_object(); + + json_object_object_add(json, "unrsvBandwithBytesSec", + unrsv_json); + for (j = 0; j < MAX_CLASS_TYPE; j += 1) { + snprintfrr(cnt_buf, sizeof(cnt_buf), "%d", j); + json_object_string_addf(unrsv_json, cnt_buf, + "%g", asla->unrsv_bw[j]); + } + } + if (IS_SUBTLV(asla, EXT_TE_METRIC)) + json_object_int_add(json, "teMetric", asla->te_metric); + + /* Extended metrics */ + if (IS_SUBTLV(asla, EXT_DELAY)) { + struct json_object *avg_json; + + avg_json = json_object_new_object(); + json_object_object_add(json, "avgDelay", avg_json); + json_object_string_add(avg_json, "delay", + IS_ANORMAL(asla->delay) + ? "Anomalous" + : "Normal"); + json_object_int_add(avg_json, "microSec", asla->delay); + } + if (IS_SUBTLV(asla, EXT_MM_DELAY)) { + struct json_object *avg_json; + + avg_json = json_object_new_object(); + json_object_object_add(json, "maxMinDelay", avg_json); + json_object_string_add(avg_json, "delay", + IS_ANORMAL(asla->min_delay) + ? "Anomalous" + : "Normal"); + json_object_string_addf(avg_json, "microSec", "%u / %u", + asla->min_delay & TE_EXT_MASK, + asla->max_delay & TE_EXT_MASK); + } + if (IS_SUBTLV(asla, EXT_DELAY_VAR)) + json_object_int_add(json, "delayVariationMicroSec", + asla->delay_var & TE_EXT_MASK); + if (IS_SUBTLV(asla, EXT_PKT_LOSS)) { + struct json_object *link_json; + + link_json = json_object_new_object(); + json_object_object_add(json, "linkPacketLoss", + link_json); + json_object_string_add(link_json, "loss", + IS_ANORMAL(asla->pkt_loss) + ? "Anomalous" + : "Normal"); + json_object_string_addf(link_json, "percentage", "%g", + (float)((asla->pkt_loss & + TE_EXT_MASK) * + LOSS_PRECISION)); + } + if (IS_SUBTLV(asla, EXT_RES_BW)) + json_object_string_addf(json, + "unidirResidualBandBytesSec", + "%g", (asla->res_bw)); + if (IS_SUBTLV(asla, EXT_AVA_BW)) + json_object_string_addf(json, + "unidirAvailableBandBytesSec", + "%g", (asla->ava_bw)); + if (IS_SUBTLV(asla, EXT_USE_BW)) + json_object_string_addf(json, + "unidirUtilizedBandBytesSec", + "%g", (asla->use_bw)); + return; + } sbuf_push(buf, indent, "Application Specific Link Attributes:\n"); sbuf_push(buf, indent + 2, @@ -454,6 +565,10 @@ static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, asla->use_bw); } +#if CONFDATE > 20240916 +CPP_NOTICE("Remove JSON in '-' format") +#endif + /* mtid parameter is used to manage multi-topology i.e. IPv4 / IPv6 */ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, struct sbuf *buf, struct json_object *json, @@ -470,7 +585,11 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { snprintfrr(aux_buf, sizeof(aux_buf), "0x%x", exts->adm_group); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "adm-group", aux_buf); + json_object_string_add(json, "admGroup", aux_buf); } else { sbuf_push(buf, indent, "Admin Group: 0x%08x\n", exts->adm_group); @@ -484,8 +603,23 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (IS_SUBTLV(exts, EXT_EXTEND_ADM_GRP) && admin_group_nb_words(&exts->ext_admin_group) != 0) { - if (!json) { - /* TODO json after fix show database detail json */ + if (json) { + struct json_object *ext_adm_grp_json; + size_t i; + ext_adm_grp_json = json_object_new_object(); + json_object_object_add(json, "extendedAdminGroup", + ext_adm_grp_json); + for (i = 0; + i < admin_group_nb_words(&exts->ext_admin_group); + i++) { + snprintfrr(cnt_buf, sizeof(cnt_buf), "%lu", + (unsigned long)i); + json_object_string_addf(ext_adm_grp_json, + cnt_buf, "0x%x", + exts->ext_admin_group + .bitmap.data[i]); + } + } else { sbuf_push(buf, indent, "Ext Admin Group: %s\n", admin_group_string( admin_group_buf, @@ -505,10 +639,17 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, } if (IS_SUBTLV(exts, EXT_LLRI)) { if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_int_add(json, "link-local-id", exts->local_llri); json_object_int_add(json, "link-remote-id", exts->remote_llri); + json_object_int_add(json, "linkLocalId", + exts->local_llri); + json_object_int_add(json, "linkRemoteId", + exts->remote_llri); } else { sbuf_push(buf, indent, "Link Local ID: %u\n", exts->local_llri); @@ -520,7 +661,11 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { inet_ntop(AF_INET, &exts->local_addr, aux_buf, sizeof(aux_buf)); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "local-iface-ip", aux_buf); + json_object_string_add(json, "localIfaceIp", aux_buf); } else sbuf_push(buf, indent, "Local Interface IP Address(es): %pI4\n", @@ -530,8 +675,12 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { inet_ntop(AF_INET, &exts->neigh_addr, aux_buf, sizeof(aux_buf)); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "remote-iface-ip", aux_buf); + json_object_string_add(json, "remoteIfaceIp", aux_buf); } else sbuf_push(buf, indent, "Remote Interface IP Address(es): %pI4\n", @@ -541,8 +690,12 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { inet_ntop(AF_INET6, &exts->local_addr6, aux_buf, sizeof(aux_buf)); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "local-iface-ipv6", aux_buf); + json_object_string_add(json, "localIfaceIpv6", aux_buf); } else sbuf_push(buf, indent, "Local Interface IPv6 Address(es): %pI6\n", @@ -552,8 +705,12 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { inet_ntop(AF_INET6, &exts->neigh_addr6, aux_buf, sizeof(aux_buf)); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "remote-iface-ipv6", aux_buf); + json_object_string_add(json, "remoteIfaceIpv6", aux_buf); } else sbuf_push(buf, indent, "Remote Interface IPv6 Address(es): %pI6\n", @@ -563,8 +720,13 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { snprintfrr(aux_buf, sizeof(aux_buf), "%g", exts->max_bw); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "max-bandwith-bytes-sec", aux_buf); + json_object_string_add(json, "maxBandwithBytesSec", + aux_buf); } else sbuf_push(buf, indent, "Maximum Bandwidth: %g (Bytes/sec)\n", @@ -574,8 +736,13 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { snprintfrr(aux_buf, sizeof(aux_buf), "%g", exts->max_rsv_bw); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add( json, "max-res-bandwith-bytes-sec", aux_buf); + json_object_string_add(json, "maxResBandwithBytesSec", + aux_buf); } else sbuf_push( buf, indent, @@ -585,6 +752,22 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (IS_SUBTLV(exts, EXT_UNRSV_BW)) { if (json) { struct json_object *unrsv_json; + + unrsv_json = json_object_new_object(); + json_object_object_add(json, "unrsvBandwithBytesSec", + unrsv_json); + for (int j = 0; j < MAX_CLASS_TYPE; j += 1) { + snprintfrr(cnt_buf, sizeof(cnt_buf), "%d", j); + snprintfrr(aux_buf, sizeof(aux_buf), "%g", + exts->unrsv_bw[j]); + json_object_string_add(unrsv_json, cnt_buf, + aux_buf); + } + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ unrsv_json = json_object_new_object(); json_object_object_add(json, "unrsv-bandwith-bytes-sec", unrsv_json); @@ -595,6 +778,7 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, json_object_string_add(unrsv_json, cnt_buf, aux_buf); } + /* end old deprecated key format */ } else { sbuf_push(buf, indent, "Unreserved Bandwidth:\n"); for (int j = 0; j < MAX_CLASS_TYPE; j += 2) { @@ -608,7 +792,11 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, } if (IS_SUBTLV(exts, EXT_TE_METRIC)) { if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_int_add(json, "te-metric", exts->te_metric); + json_object_int_add(json, "teMetric", exts->te_metric); } else sbuf_push(buf, indent, "Traffic Engineering Metric: %u\n", @@ -616,8 +804,13 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, } if (IS_SUBTLV(exts, EXT_RMT_AS)) { if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_int_add(json, "inter-as-te-remote-as", exts->remote_as); + json_object_int_add(json, "interAsTeRemoteAs", + exts->remote_as); } else sbuf_push(buf, indent, "Inter-AS TE Remote AS number: %u\n", @@ -627,8 +820,13 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { inet_ntop(AF_INET6, &exts->remote_ip, aux_buf, sizeof(aux_buf)); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add( json, "inter-as-te-remote-asbr-ip", aux_buf); + json_object_string_add(json, "interAsTeRemoteAsbrIp", + aux_buf); } else sbuf_push(buf, indent, "Inter-AS TE Remote ASBR IP address: %pI4\n", @@ -639,12 +837,23 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { struct json_object *avg_json; avg_json = json_object_new_object(); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_object_add(json, "avg-delay", avg_json); json_object_string_add(avg_json, "delay", IS_ANORMAL(exts->delay) ? "Anomalous" : "Normal"); json_object_int_add(avg_json, "micro-sec", exts->delay); + + avg_json = json_object_new_object(); + json_object_object_add(json, "avgDelay", avg_json); + json_object_string_add(avg_json, "delay", + IS_ANORMAL(exts->delay) + ? "Anomalous" + : "Normal"); + json_object_int_add(avg_json, "microSec", exts->delay); } else sbuf_push(buf, indent, "%s Average Link Delay: %u (micro-sec)\n", @@ -656,6 +865,9 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { struct json_object *avg_json; avg_json = json_object_new_object(); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_object_add(json, "max-min-delay", avg_json); json_object_string_add(avg_json, "delay", IS_ANORMAL(exts->min_delay) @@ -666,6 +878,17 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, exts->max_delay & TE_EXT_MASK); json_object_string_add(avg_json, "micro-sec", aux_buf); + avg_json = json_object_new_object(); + json_object_object_add(json, "maxMinDelay", avg_json); + json_object_string_add(avg_json, "delay", + IS_ANORMAL(exts->min_delay) + ? "Anomalous" + : "Normal"); + snprintfrr(aux_buf, sizeof(aux_buf), "%u / %u", + exts->min_delay & TE_EXT_MASK, + exts->max_delay & TE_EXT_MASK); + json_object_string_add(avg_json, "microSec", aux_buf); + } else sbuf_push( buf, indent, @@ -677,8 +900,13 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, } if (IS_SUBTLV(exts, EXT_DELAY_VAR)) { if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_int_add(json, "delay-variation-micro-sec", exts->delay_var & TE_EXT_MASK); + json_object_int_add(json, "delayVariationMicroSec", + exts->delay_var & TE_EXT_MASK); } else sbuf_push(buf, indent, "Delay Variation: %u (micro-sec)\n", @@ -690,6 +918,10 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, (float)((exts->pkt_loss & TE_EXT_MASK) * LOSS_PRECISION)); struct json_object *link_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif link_json = json_object_new_object(); json_object_object_add(json, "link-packet-loss", link_json); @@ -697,8 +929,18 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, IS_ANORMAL(exts->pkt_loss) ? "Anomalous" : "Normal"); + /* typo */ json_object_string_add(link_json, "percentaje", aux_buf); + + link_json = json_object_new_object(); + json_object_object_add(json, "linkPacketLoss", + link_json); + json_object_string_add(link_json, "loss", + IS_ANORMAL(exts->pkt_loss) + ? "Anomalous" + : "Normal"); + json_object_string_add(link_json, "percentage", aux_buf); } else sbuf_push(buf, indent, "%s Link Packet Loss: %g (%%)\n", IS_ANORMAL(exts->pkt_loss) ? "Anomalous" @@ -710,9 +952,15 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { snprintfrr(aux_buf, sizeof(aux_buf), "%g", (exts->res_bw)); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "unidir-residual-band-bytes-sec", aux_buf); + json_object_string_add(json, + "unidirResidualBandBytesSec", + aux_buf); } else sbuf_push( buf, indent, @@ -723,9 +971,15 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { snprintfrr(aux_buf, sizeof(aux_buf), "%g", (exts->ava_bw)); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add( json, "unidir-available-band-bytes-sec", aux_buf); + json_object_string_add(json, + "unidirAvailableBandBytesSec", + aux_buf); } else sbuf_push( buf, indent, @@ -739,6 +993,12 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, json_object_string_add(json, "unidir-utilized-band-bytes-sec", aux_buf); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + json_object_string_add(json, + "unidirUtilizedBandBytesSec", + aux_buf); } else sbuf_push( buf, indent, @@ -751,6 +1011,11 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { struct json_object *arr_adj_json, *flags_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ arr_adj_json = json_object_new_array(); json_object_object_add(json, "adj-sid", arr_adj_json); for (adj = (struct isis_adj_sid *)exts->adj_sid.head; @@ -794,6 +1059,44 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, : "0"); json_object_array_add(arr_adj_json, flags_json); } + /* end old deprecated key format */ + + arr_adj_json = json_object_new_array(); + json_object_object_add(json, "adjSid", arr_adj_json); + for (adj = (struct isis_adj_sid *)exts->adj_sid.head; + adj; adj = adj->next) { + snprintfrr(cnt_buf, sizeof(cnt_buf), "%d", + adj->sid); + flags_json = json_object_new_object(); + json_object_int_add(flags_json, "sid", adj->sid); + json_object_int_add(flags_json, "weight", + adj->weight); + json_object_boolean_add(flags_json, "flagF", + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_FFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagB", + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_BFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagV", + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagL", + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_LFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagS", + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_SFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagP", + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_PFLG + ? true + : false); + json_object_array_add(arr_adj_json, flags_json); + } } else for (adj = (struct isis_adj_sid *)exts->adj_sid.head; adj; adj = adj->next) { @@ -826,6 +1129,11 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, struct isis_lan_adj_sid *lan; if (json) { struct json_object *arr_adj_json, *flags_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ arr_adj_json = json_object_new_array(); json_object_object_add(json, "lan-adj-sid", arr_adj_json); @@ -876,6 +1184,49 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, : "0"); json_object_array_add(arr_adj_json, flags_json); } + /* end old deprecated key format */ + + arr_adj_json = json_object_new_array(); + json_object_object_add(json, "lanAdjSid", arr_adj_json); + for (lan = (struct isis_lan_adj_sid *)exts->adj_sid.head; + lan; lan = lan->next) { + if (((mtid == ISIS_MT_IPV4_UNICAST) && + (lan->family != AF_INET)) || + ((mtid == ISIS_MT_IPV6_UNICAST) && + (lan->family != AF_INET6))) + continue; + snprintfrr(cnt_buf, sizeof(cnt_buf), "%d", + lan->sid); + flags_json = json_object_new_object(); + json_object_int_add(flags_json, "sid", lan->sid); + json_object_int_add(flags_json, "weight", + lan->weight); + json_object_boolean_add(flags_json, "flagF", + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_FFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagB", + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_BFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagV", + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagL", + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_LFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagS", + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_SFLG + ? true + : false); + json_object_boolean_add(flags_json, "flagP", + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_PFLG + ? true + : false); + json_object_array_add(arr_adj_json, flags_json); + } } else for (lan = (struct isis_lan_adj_sid *) @@ -918,6 +1269,11 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) { struct json_object *arr_adj_json, *flags_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ arr_adj_json = json_object_new_array(); json_object_object_add(json, "srv6-endx-sid", arr_adj_json); @@ -955,7 +1311,47 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, json_object_array_add(arr_adj_json, flags_json); if (adj->subsubtlvs) isis_format_subsubtlvs(adj->subsubtlvs, - NULL, json, + NULL, + arr_adj_json, + indent + 4); + } + /* end old deprecated key format */ + + arr_adj_json = json_object_new_array(); + json_object_object_add(json, "srv6EndSID", arr_adj_json); + for (adj = (struct isis_srv6_endx_sid_subtlv *) + exts->srv6_endx_sid.head; + adj; adj = adj->next) { + snprintfrr(cnt_buf, sizeof(cnt_buf), "%pI6", + &adj->sid); + flags_json = json_object_new_object(); + json_object_string_addf(flags_json, "sid", + "%pI6", &adj->sid); + json_object_string_add(flags_json, "algorithm", + sr_algorithm_string( + adj->algorithm)); + json_object_int_add(flags_json, "weight", + adj->weight); + json_object_string_add(flags_json, "behavior", + seg6local_action2str( + adj->behavior)); + json_object_boolean_add( + flags_json, "flagB", + !!(adj->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG)); + json_object_boolean_add( + flags_json, "flagS", + !!(adj->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_SFLG)); + json_object_boolean_add( + flags_json, "flagP", + !!(adj->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_PFLG)); + json_object_array_add(arr_adj_json, flags_json); + if (adj->subsubtlvs) + isis_format_subsubtlvs(adj->subsubtlvs, + NULL, + arr_adj_json, indent + 4); } } else @@ -989,6 +1385,11 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, struct isis_srv6_lan_endx_sid_subtlv *lan; if (json) { struct json_object *arr_adj_json, *flags_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ arr_adj_json = json_object_new_array(); json_object_object_add(json, "srv6-lan-endx-sid", arr_adj_json); @@ -1031,7 +1432,53 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, json_object_array_add(arr_adj_json, flags_json); if (lan->subsubtlvs) isis_format_subsubtlvs(lan->subsubtlvs, - NULL, json, + NULL, + arr_adj_json, + indent + 4); + } + /* end old deprecated key format */ + + arr_adj_json = json_object_new_array(); + json_object_object_add(json, "srv6LanEndxSID", + arr_adj_json); + for (lan = (struct isis_srv6_lan_endx_sid_subtlv *) + exts->srv6_lan_endx_sid.head; + lan; lan = lan->next) { + snprintfrr(cnt_buf, sizeof(cnt_buf), "%pI6", + &lan->sid); + flags_json = json_object_new_object(); + json_object_string_addf(flags_json, "sid", + "%pI6", &lan->sid); + json_object_int_add(flags_json, "weight", + lan->weight); + json_object_string_add(flags_json, "algorithm", + sr_algorithm_string( + lan->algorithm)); + json_object_int_add(flags_json, "weight", + lan->weight); + json_object_string_add(flags_json, "behavior", + seg6local_action2str( + lan->behavior)); + json_object_boolean_add( + flags_json, "flagB", + !!(lan->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG)); + json_object_boolean_add( + flags_json, "flagS", + !!(lan->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_SFLG)); + json_object_boolean_add( + flags_json, "flagP", + !!(lan->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_PFLG)); + json_object_string_addf(flags_json, + "neighbor-id", "%pSY", + lan->neighbor_id); + json_object_array_add(arr_adj_json, flags_json); + if (lan->subsubtlvs) + isis_format_subsubtlvs(lan->subsubtlvs, + NULL, + arr_adj_json, indent + 4); } } else @@ -1063,7 +1510,7 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, } } for (ALL_LIST_ELEMENTS_RO(exts->aslas, node, asla)) - format_item_asla_subtlvs(asla, buf, indent); + format_item_asla_subtlvs(asla, json, buf, indent); } static void free_item_ext_subtlvs(struct isis_ext_subtlvs *exts) @@ -2127,15 +2574,26 @@ static void format_item_prefix_sid(uint16_t mtid, struct isis_item *i, struct isis_prefix_sid *sid = (struct isis_prefix_sid *)i; if (json) { - struct json_object *sr_json; + struct json_object *sr_json, *array_json; + sr_json = json_object_new_object(); - json_object_object_add(json, "sr", sr_json); + json_object_object_get_ex(json, "sr", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "sr", array_json); + } + json_object_array_add(array_json, sr_json); if (sid->flags & ISIS_PREFIX_SID_VALUE) { json_object_int_add(sr_json, "label", sid->value); } else { json_object_int_add(sr_json, "index", sid->value); } json_object_int_add(sr_json, "alg", sid->algorithm); + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated non boolean json") +#endif + /* old deprecated keys (no booleans) */ json_object_string_add( sr_json, "readvertised", ((sid->flags & ISIS_PREFIX_SID_READVERTISED) ? "yes" @@ -2157,6 +2615,27 @@ static void format_item_prefix_sid(uint16_t mtid, struct isis_item *i, json_object_string_add( sr_json, "local", ((sid->flags & ISIS_PREFIX_SID_LOCAL) ? "yes" : "")); + /* end deprecated keys (no booleans) */ + + struct json_object *flags_json; + + flags_json = json_object_new_object(); + json_object_object_add(sr_json, "flags", flags_json); + + json_object_boolean_add(flags_json, "readvertised", + !!(sid->flags & + ISIS_PREFIX_SID_READVERTISED)); + json_object_boolean_add(flags_json, "node", + !!(sid->flags & ISIS_PREFIX_SID_NODE)); + json_object_boolean_add(flags_json, "noPHP", + !!(sid->flags & ISIS_PREFIX_SID_NO_PHP)); + json_object_boolean_add(flags_json, "explicitNull", + !!(sid->flags & + ISIS_PREFIX_SID_EXPLICIT_NULL)); + json_object_boolean_add(flags_json, "value", + !!(sid->flags & ISIS_PREFIX_SID_VALUE)); + json_object_boolean_add(flags_json, "local", + !!(sid->flags & ISIS_PREFIX_SID_LOCAL)); } else { sbuf_push(buf, indent, "SR Prefix-SID "); @@ -2286,7 +2765,11 @@ static void format_subtlv_ipv6_source_prefix(struct prefix_ipv6 *p, char prefixbuf[PREFIX2STR_BUFFER]; if (json) { prefix2str(p, prefixbuf, sizeof(prefixbuf)); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "ipv6-src-prefix", prefixbuf); + json_object_string_add(json, "ipv6SrcPrefix", prefixbuf); } else { sbuf_push(buf, indent, "IPv6 Source Prefix: %s\n", prefix2str(p, prefixbuf, sizeof(prefixbuf))); @@ -2388,6 +2871,11 @@ static void format_subsubtlv_srv6_sid_structure( if (json) { struct json_object *sid_struct_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ sid_struct_json = json_object_new_object(); json_object_object_add(json, "srv6-sid-structure", sid_struct_json); @@ -2399,6 +2887,19 @@ static void format_subsubtlv_srv6_sid_structure( sid_struct->func_len); json_object_int_add(sid_struct_json, "arg-len", sid_struct->arg_len); + /* end old deprecated key format */ + + sid_struct_json = json_object_new_object(); + json_object_object_add(json, "srv6SidStructure", + sid_struct_json); + json_object_int_add(sid_struct_json, "locBlockLen", + sid_struct->loc_block_len); + json_object_int_add(sid_struct_json, "locNodeLen", + sid_struct->loc_node_len); + json_object_int_add(sid_struct_json, "funcLen", + sid_struct->func_len); + json_object_int_add(sid_struct_json, "argLen", + sid_struct->arg_len); } else { sbuf_push(buf, indent, "SRv6 SID Structure "); sbuf_push(buf, 0, "Locator Block length: %hhu, ", @@ -2680,6 +3181,11 @@ static void format_item_srv6_end_sid(uint16_t mtid, struct isis_item *i, if (json) { struct json_object *sid_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ sid_json = json_object_new_object(); json_object_object_add(json, "srv6-end-sid", sid_json); json_object_string_add(sid_json, "endpoint-behavior", @@ -2694,6 +3200,21 @@ static void format_item_srv6_end_sid(uint16_t mtid, struct isis_item *i, isis_format_subsubtlvs(sid->subsubtlvs, NULL, subtlvs_json, 0); } + /* end old deprecated key format */ + + sid_json = json_object_new_object(); + json_object_object_add(json, "srv6EndSid", sid_json); + json_object_string_add(sid_json, "endpointBehavior", + seg6local_action2str(sid->behavior)); + json_object_string_addf(sid_json, "sidValue", "%pI6", &sid->sid); + if (sid->subsubtlvs) { + struct json_object *subtlvs_json; + subtlvs_json = json_object_new_object(); + json_object_object_add(sid_json, "subsubtlvs", + subtlvs_json); + isis_format_subsubtlvs(sid->subsubtlvs, NULL, + subtlvs_json, 0); + } } else { sbuf_push(buf, indent, "SRv6 End SID "); sbuf_push(buf, 0, "Endpoint Behavior: %s, ", @@ -2841,9 +3362,13 @@ static void format_item_area_address(uint16_t mtid, struct isis_item *i, memcpy(iso_addr.area_addr, addr->addr, ISO_ADDR_SIZE); iso_addr.addr_len = addr->len; - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_addf(json, "area-addr", "%pIS", &iso_addr); - else + json_object_string_addf(json, "areaAddr", "%pIS", &iso_addr); + } else sbuf_push(buf, indent, "Area Address: %pIS\n", &iso_addr); } @@ -2929,11 +3454,34 @@ static void format_item_oldstyle_reach(uint16_t mtid, struct isis_item *i, snprintfrr(sys_id, ISO_SYSID_STRLEN, "%pPN", r->id); if (json) { - struct json_object *old_json; + struct json_object *old_json, *array_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ old_json = json_object_new_object(); - json_object_object_add(json, "old-reach-style", old_json); + json_object_object_get_ex(json, "old-reach-style", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "old-reach-style", + array_json); + } + json_object_array_add(array_json, old_json); json_object_string_add(old_json, "is-reach", sys_id); json_object_int_add(old_json, "metric", r->metric); + /* end old deprecated key format */ + + old_json = json_object_new_object(); + json_object_object_get_ex(json, "oldReachStyle", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "oldReachStyle", + array_json); + } + json_object_array_add(array_json, old_json); + json_object_string_add(old_json, "isReach", sys_id); + json_object_int_add(old_json, "metric", r->metric); } else sbuf_push(buf, indent, "IS Reachability: %s (Metric: %hhu)\n", sys_id, r->metric); @@ -3011,9 +3559,13 @@ static void format_item_lan_neighbor(uint16_t mtid, struct isis_item *i, char sys_id[ISO_SYSID_STRLEN]; snprintfrr(sys_id, ISO_SYSID_STRLEN, "%pSY", n->mac); - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "lan-neighbor", sys_id); - else + json_object_string_add(json, "lanNeighbor", sys_id); + } else sbuf_push(buf, indent, "LAN Neighbor: %s\n", sys_id); } @@ -3086,6 +3638,9 @@ static void format_item_lsp_entry(uint16_t mtid, struct isis_item *i, char buf[255]; struct json_object *lsp_json; lsp_json = json_object_new_object(); +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_object_add(json, "lsp-entry", lsp_json); json_object_string_add(lsp_json, "id", sys_id); snprintfrr(buf,sizeof(buf),"0x%08x",e->seqno); @@ -3093,6 +3648,15 @@ static void format_item_lsp_entry(uint16_t mtid, struct isis_item *i, snprintfrr(buf,sizeof(buf),"0x%04hx",e->checksum); json_object_string_add(lsp_json, "chksum", buf); json_object_int_add(lsp_json, "lifetime", e->checksum); + + lsp_json = json_object_new_object(); + json_object_object_add(json, "lspEntry", lsp_json); + json_object_string_add(lsp_json, "id", sys_id); + snprintfrr(buf, sizeof(buf), "0x%08x", e->seqno); + json_object_string_add(lsp_json, "seq", buf); + snprintfrr(buf, sizeof(buf), "0x%04hx", e->checksum); + json_object_string_add(lsp_json, "chksum", buf); + json_object_int_add(lsp_json, "lifetime", e->checksum); } else sbuf_push( buf, indent, @@ -3173,9 +3737,19 @@ static void format_item_extended_reach(uint16_t mtid, struct isis_item *i, snprintfrr(sys_id, ISO_SYSID_STRLEN, "%pPN", r->id); if (json) { - struct json_object *reach_json; + struct json_object *reach_json, *array_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ reach_json = json_object_new_object(); - json_object_object_add(json, "ext-reach", reach_json); + json_object_object_get_ex(json, "ext-reach", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "ext-reach", array_json); + } + json_object_array_add(array_json, reach_json); json_object_string_add( reach_json, "mt-id", (mtid == ISIS_MT_IPV4_UNICAST) ? "Extended" : "MT"); @@ -3186,7 +3760,29 @@ static void format_item_extended_reach(uint16_t mtid, struct isis_item *i, isis_mtid2str(mtid)); if (r->subtlvs) - format_item_ext_subtlvs(r->subtlvs, NULL, json, + format_item_ext_subtlvs(r->subtlvs, NULL, reach_json, + indent + 2, mtid); + /* end old deprecated key format */ + + reach_json = json_object_new_object(); + json_object_object_get_ex(json, "extReach", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "extReach", array_json); + } + json_object_array_add(array_json, reach_json); + json_object_string_add(reach_json, "mtId", + (mtid == ISIS_MT_IPV4_UNICAST) + ? "Extended" + : "MT"); + json_object_string_add(reach_json, "id", sys_id); + json_object_int_add(reach_json, "metric", r->metric); + if (mtid != ISIS_MT_IPV4_UNICAST) + json_object_string_add(reach_json, "mtName", + isis_mtid2str(mtid)); + + if (r->subtlvs) + format_item_ext_subtlvs(r->subtlvs, NULL, reach_json, indent + 2, mtid); } else { sbuf_push(buf, indent, "%s Reachability: %s (Metric: %u)", @@ -3314,13 +3910,40 @@ static void format_item_oldstyle_ip_reach(uint16_t mtid, struct isis_item *i, char prefixbuf[PREFIX2STR_BUFFER]; if (json) { - struct json_object *old_json; + struct json_object *old_json, *array_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ old_json = json_object_new_object(); - json_object_object_add(json, "old-ip-reach-style", old_json); + json_object_object_get_ex(json, "old-ip-reach-style", + &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "old-ip-reach-style", + old_json); + } + json_object_array_add(array_json, old_json); json_object_string_add(old_json, "prefix", prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf))); json_object_int_add(old_json, "metric", r->metric); - } else + /* end old deprecated key format */ + + old_json = json_object_new_object(); + json_object_object_get_ex(json, "oldIpReachStyle", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "oldIpReachStyle", + old_json); + } + json_object_array_add(array_json, old_json); + json_object_string_add(old_json, "prefix", + prefix2str(&r->prefix, prefixbuf, + sizeof(prefixbuf))); + json_object_int_add(old_json, "metric", r->metric); + return; + } sbuf_push(buf, indent, "IP Reachability: %s (Metric: %hhu)\n", prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), r->metric); @@ -3412,6 +4035,10 @@ static void format_tlv_protocols_supported(struct isis_protocols_supported *p, struct json_object *protocol_json; char buf[255]; +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ protocol_json = json_object_new_object(); json_object_object_add(json, "protocols-supported", protocol_json); @@ -3420,6 +4047,16 @@ static void format_tlv_protocols_supported(struct isis_protocols_supported *p, json_object_string_add(protocol_json, buf, nlpid2str(p->protocols[i])); } + + protocol_json = json_object_new_object(); + json_object_object_add(json, "supportedProtocols", + protocol_json); + for (uint8_t i = 0; i < p->count; i++) { + snprintfrr(buf, sizeof(buf), "%d", i); + json_object_string_add(protocol_json, buf, + nlpid2str(p->protocols[i])); + } + /* end old deprecated key format */ } else { sbuf_push(buf, indent, "Protocols Supported: "); for (uint8_t i = 0; i < p->count; i++) { @@ -3635,9 +4272,13 @@ static void format_item_global_ipv6_address(uint16_t mtid, struct isis_item *i, char addrbuf[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &a->addr, addrbuf, sizeof(addrbuf)); - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "global-ipv6", addrbuf); - else + json_object_string_add(json, "globalIpv6", addrbuf); + } else sbuf_push(buf, indent, "Global IPv6 Interface Address: %s\n", addrbuf); } @@ -3705,12 +4346,30 @@ static void format_item_mt_router_info(uint16_t mtid, struct isis_item *i, struct isis_mt_router_info *info = (struct isis_mt_router_info *)i; if (json) { - struct json_object *mt_json; + struct json_object *mt_json, *array_json; mt_json = json_object_new_object(); - json_object_object_add(json, "mt", mt_json); + json_object_object_get_ex(json, "mt", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "mt", array_json); + } + json_object_array_add(array_json, mt_json); json_object_int_add(mt_json, "mtid", info->mtid); + json_object_string_add(mt_json, "mt-description", + isis_mtid2str_fake(info->mtid)); + json_object_string_add(mt_json, "mtDescription", + isis_mtid2str(mtid)); + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated non boolean format") +#endif json_object_string_add(mt_json, "overload", info->overload?"true":"false"); json_object_string_add(mt_json, "attached", info->attached?"true":"false"); + + json_object_boolean_add(mt_json, "overloadBit", + !!info->overload); + json_object_boolean_add(mt_json, "attachedbit", + !!info->attached); } else sbuf_push(buf, indent, "MT Router Info: %s%s%s\n", isis_mtid2str_fake(info->mtid), @@ -3793,9 +4452,13 @@ static void format_tlv_te_router_id(const struct in_addr *id, struct sbuf *buf, char addrbuf[INET_ADDRSTRLEN]; inet_ntop(AF_INET, id, addrbuf, sizeof(addrbuf)); - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "te-router-id", addrbuf); - else + json_object_string_add(json, "teRouterId", addrbuf); + } else sbuf_push(buf, indent, "TE Router ID: %s\n", addrbuf); } @@ -3866,27 +4529,64 @@ static void format_item_extended_ip_reach(uint16_t mtid, struct isis_item *i, struct json_object *json, int indent) { struct isis_extended_ip_reach *r = (struct isis_extended_ip_reach *)i; + struct json_object *ext_json, *array_json; char prefixbuf[PREFIX2STR_BUFFER]; if (json) { - struct json_object *ext_json; +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ ext_json = json_object_new_object(); - json_object_object_add(json, "ext-ip-reach", ext_json); - json_object_string_add( - json, "mt-id", - (mtid == ISIS_MT_IPV4_UNICAST) ? "Extended" : "MT"); - json_object_string_add( - json, "ip-reach", - prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf))); - json_object_int_add(json, "ip-reach-metric", r->metric); - json_object_string_add(json, "down", r->down ? "yes" : ""); + json_object_object_get_ex(json, "ext-ip-reach", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "ext-ip-reach", array_json); + } + json_object_array_add(array_json, ext_json); + json_object_string_add(ext_json, "mt-id", + (mtid == ISIS_MT_IPV4_UNICAST) + ? "Extended" + : "MT"); + json_object_string_add(ext_json, "ip-reach", + prefix2str(&r->prefix, prefixbuf, + sizeof(prefixbuf))); + json_object_int_add(ext_json, "ip-reach-metric", r->metric); + json_object_string_add(ext_json, "down", r->down ? "yes" : ""); if (mtid != ISIS_MT_IPV4_UNICAST) - json_object_string_add(json, "mt-name", + json_object_string_add(ext_json, "mt-name", isis_mtid2str(mtid)); if (r->subtlvs) { struct json_object *subtlv_json; subtlv_json = json_object_new_object(); - json_object_object_add(json, "subtlvs", subtlv_json); + json_object_object_add(ext_json, "subtlvs", subtlv_json); + format_subtlvs(r->subtlvs, NULL, subtlv_json, 0); + } + /* end old deprecated key format */ + + ext_json = json_object_new_object(); + json_object_object_get_ex(json, "extIpReach", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "extIpReach", array_json); + } + json_object_array_add(array_json, ext_json); + json_object_string_add(ext_json, "mtId", + (mtid == ISIS_MT_IPV4_UNICAST) + ? "Extended" + : "MT"); + json_object_string_add(ext_json, "ipReach", + prefix2str(&r->prefix, prefixbuf, + sizeof(prefixbuf))); + json_object_int_add(ext_json, "ipReachMetric", r->metric); + json_object_boolean_add(ext_json, "down", !!r->down); + if (mtid != ISIS_MT_IPV4_UNICAST) + json_object_string_add(ext_json, "mtName", + isis_mtid2str(mtid)); + if (r->subtlvs) { + struct json_object *subtlv_json; + subtlv_json = json_object_new_object(); + json_object_object_add(ext_json, "subtlvs", subtlv_json); format_subtlvs(r->subtlvs, NULL, subtlv_json, 0); } } else { @@ -4146,9 +4846,13 @@ static void format_tlv_te_router_id_ipv6(const struct in6_addr *id, char addrbuf[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, id, addrbuf, sizeof(addrbuf)); - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "ipv6-te-router-id", addrbuf); - else + json_object_string_add(json, "ipv6TeRouterId", addrbuf); + } else sbuf_push(buf, indent, "IPv6 TE Router ID: %s\n", addrbuf); } @@ -4225,6 +4929,11 @@ static void format_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf, if (json) { struct json_object *spine_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated format */ spine_json = json_object_new_object(); json_object_object_add(json, "spine-leaf-extension", spine_json); @@ -4243,6 +4952,25 @@ static void format_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf, spine_leaf->is_spine ? "yes" : ""); json_object_string_add(spine_json, "flag-backup", spine_leaf->is_backup ? "yes" : ""); + /* end old deprecated format */ + + spine_json = json_object_new_object(); + json_object_object_add(json, "spineLeafExtension", spine_json); + if (spine_leaf->has_tier) { + snprintfrr(aux_buf, sizeof(aux_buf), "%hhu", + spine_leaf->tier); + json_object_string_add(spine_json, "tier", + (spine_leaf->tier == + ISIS_TIER_UNDEFINED) + ? "undefined" + : aux_buf); + } + json_object_boolean_add(spine_json, "flagLeaf", + spine_leaf->is_leaf ? true : false); + json_object_boolean_add(spine_json, "flagSpine", + spine_leaf->is_spine ? true : false); + json_object_boolean_add(spine_json, "flagBackup", + spine_leaf->is_backup ? true : false); } else { sbuf_push(buf, indent, "Spine-Leaf-Extension:\n"); if (spine_leaf->has_tier) { @@ -4384,6 +5112,11 @@ format_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj, snprintfrr(sys_id, ISO_SYSID_STRLEN, "%pSY", threeway_adj->neighbor_id); if (json) { struct json_object *three_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ three_json = json_object_new_object(); json_object_object_add(json, "p2p-three-way-adj", three_json); json_object_string_add( @@ -4392,11 +5125,28 @@ format_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj, json_object_int_add(three_json, "state", threeway_adj->state); json_object_int_add(three_json, "ext-local-circuit-id", threeway_adj->local_circuit_id); - if (!threeway_adj->neighbor_set) - return; - json_object_string_add(three_json, "neigh-system-id", sys_id); - json_object_int_add(three_json, "neigh-ext-circuit-id", - threeway_adj->neighbor_circuit_id); + if (threeway_adj->neighbor_set) { + json_object_string_add(three_json, "neigh-system-id", + sys_id); + json_object_int_add(three_json, "neigh-ext-circuit-id", + threeway_adj->neighbor_circuit_id); + } + /* end old deprecated key format */ + + three_json = json_object_new_object(); + json_object_object_add(json, "p2pThreeWayAdj", three_json); + json_object_string_add(three_json, "stateName", + isis_threeway_state_name( + threeway_adj->state)); + json_object_int_add(three_json, "state", threeway_adj->state); + json_object_int_add(three_json, "extLocalCircuitId", + threeway_adj->local_circuit_id); + if (threeway_adj->neighbor_set) { + json_object_string_add(three_json, "neighSystemId", + sys_id); + json_object_int_add(three_json, "neighExtCircuitId", + threeway_adj->neighbor_circuit_id); + } } else { sbuf_push(buf, indent, "P2P Three-Way Adjacency:\n"); sbuf_push(buf, indent, " State: %s (%d)\n", @@ -4500,9 +5250,51 @@ static void format_item_ipv6_reach(uint16_t mtid, struct isis_item *i, char prefixbuf[PREFIX2STR_BUFFER]; if (json) { - struct json_object *reach_json; + struct json_object *reach_json, *array_json; + + reach_json = json_object_new_object(); + json_object_object_get_ex(json, "ipv6Reach", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "ipv6Reach", array_json); + } + json_object_array_add(array_json, reach_json); + json_object_string_add(reach_json, "mtId", + (mtid == ISIS_MT_IPV4_UNICAST) ? "" + : "mt"); + json_object_string_add(reach_json, "prefix", + prefix2str(&r->prefix, prefixbuf, + sizeof(prefixbuf))); + json_object_int_add(reach_json, "metric", r->metric); + json_object_boolean_add(reach_json, "down", + r->down ? true : false); + json_object_boolean_add(reach_json, "external", + r->external ? true : false); + if (mtid != ISIS_MT_IPV4_UNICAST) { + json_object_string_add(reach_json, "mt-name", + isis_mtid2str(mtid)); + json_object_string_add(reach_json, "mtName", + isis_mtid2str(mtid)); + } + if (r->subtlvs) { + struct json_object *subtlvs_json; + subtlvs_json = json_object_new_object(); + json_object_object_add(reach_json, "subtlvs", + subtlvs_json); + format_subtlvs(r->subtlvs, NULL, subtlvs_json, 0); + } + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated JSON key format */ reach_json = json_object_new_object(); - json_object_object_add(json, "ipv6-reach", reach_json); + json_object_object_get_ex(json, "ipv6-reach", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "ipv6-reach", array_json); + } + json_object_array_add(array_json, reach_json); json_object_string_add(reach_json, "mt-id", (mtid == ISIS_MT_IPV4_UNICAST) ? "" : "mt"); @@ -4520,9 +5312,11 @@ static void format_item_ipv6_reach(uint16_t mtid, struct isis_item *i, if (r->subtlvs) { struct json_object *subtlvs_json; subtlvs_json = json_object_new_object(); - json_object_object_add(json, "subtlvs", subtlvs_json); + json_object_object_add(reach_json, "subtlvs", + subtlvs_json); format_subtlvs(r->subtlvs, NULL, subtlvs_json, 0); } + /* end deprecated key format */ } else { sbuf_push(buf, indent, "%sIPv6 Reachability: %s (Metric: %u)%s%s", @@ -4734,6 +5528,11 @@ static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, /* Router ID and Flags */ struct json_object *cap_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* deprecated JSON key format */ cap_json = json_object_new_object(); json_object_object_add(json, "router-capability", cap_json); inet_ntop(AF_INET, &router_cap->router_id, addrbuf, sizeof(addrbuf)); @@ -4744,10 +5543,26 @@ static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, json_object_string_add( cap_json, "flag-s", router_cap->flags & ISIS_ROUTER_CAP_FLAG_S ? "1" : "0"); + /* end deprecated JSON key format */ + + cap_json = json_object_new_object(); + json_object_object_add(json, "routerCapability", cap_json); + inet_ntop(AF_INET, &router_cap->router_id, addrbuf, sizeof(addrbuf)); + json_object_string_add(cap_json, "id", addrbuf); + json_object_boolean_add(cap_json, "flagD", + !!(router_cap->flags & ISIS_ROUTER_CAP_FLAG_D)); + json_object_boolean_add(cap_json, "flagS", + !!(router_cap->flags & ISIS_ROUTER_CAP_FLAG_S)); + /* Segment Routing Global Block as per RFC8667 section #3.1 */ if (router_cap->srgb.range_size != 0) { struct json_object *gb_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* deprecated old key format */ gb_json = json_object_new_object(); json_object_object_add(json, "segment-routing-gb", gb_json); json_object_string_add(gb_json, "ipv4", @@ -4760,23 +5575,52 @@ static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, router_cap->srgb.lower_bound); json_object_int_add(gb_json, "global-block-range", router_cap->srgb.range_size); + + gb_json = json_object_new_object(); + json_object_object_add(json, "segmentRoutingGb", gb_json); + json_object_boolean_add(gb_json, "ipv4", + !!IS_SR_IPV4(&router_cap->srgb)); + json_object_boolean_add(gb_json, "ipv6", + !!IS_SR_IPV6(&router_cap->srgb)); + json_object_int_add(gb_json, "globalBlockBase", + router_cap->srgb.lower_bound); + json_object_int_add(gb_json, "globalBlockRange", + router_cap->srgb.range_size); } /* Segment Routing Local Block as per RFC8667 section #3.3 */ if (router_cap->srlb.range_size != 0) { struct json_object *lb_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ lb_json = json_object_new_object(); json_object_object_add(json, "segment-routing-lb", lb_json); json_object_int_add(lb_json, "global-block-base", router_cap->srlb.lower_bound); json_object_int_add(lb_json, "global-block-range", router_cap->srlb.range_size); + /* end old deprecated key format */ + + lb_json = json_object_new_object(); + json_object_object_add(json, "segmentRoutingLb", lb_json); + json_object_int_add(lb_json, "globalBlockBase", + router_cap->srlb.lower_bound); + json_object_int_add(lb_json, "globalBlockRange", + router_cap->srlb.range_size); } /* Segment Routing Algorithms as per RFC8667 section #3.2 */ if (router_cap->algo[0] != SR_ALGORITHM_UNSET) { char buf[255]; struct json_object *alg_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ alg_json = json_object_new_object(); json_object_object_add(json, "segment-routing-algorithm", alg_json); @@ -4788,6 +5632,20 @@ static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, ? "SPF" : "Strict SPF"); } + /* end old deprecated key format */ + + alg_json = json_object_new_object(); + json_object_object_add(json, "segmentRoutingAlgorithm", + alg_json); + for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { + if (router_cap->algo[i] != SR_ALGORITHM_UNSET) { + snprintfrr(buf, sizeof(buf), "%d", i); + json_object_string_add(alg_json, buf, + router_cap->algo[i] == 0 + ? "SPF" + : "Strict SPF"); + } + } } /* Segment Routing Node MSD as per RFC8491 section #2 */ @@ -5631,16 +6489,24 @@ static void format_item_auth(uint16_t mtid, struct isis_item *i, struct isis_auth *auth = (struct isis_auth *)i; char obuf[768]; - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "test-auth", "ok"); - else + json_object_string_add(json, "testAuth", "ok"); + } else sbuf_push(buf, indent, "Authentication:\n"); switch (auth->type) { case ISIS_PASSWD_TYPE_CLEARTXT: zlog_sanitize(obuf, sizeof(obuf), auth->value, auth->length); - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "auth-pass", obuf); - else + json_object_string_add(json, "authPass", obuf); + } else sbuf_push(buf, indent, " Password: %s\n", obuf); break; case ISIS_PASSWD_TYPE_HMAC_MD5: @@ -5648,15 +6514,23 @@ static void format_item_auth(uint16_t mtid, struct isis_item *i, snprintf(obuf + 2 * j, sizeof(obuf) - 2 * j, "%02hhx", auth->value[j]); } - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "auth-hmac-md5", obuf); - else + json_object_string_add(json, "authHmacMd5", obuf); + } else sbuf_push(buf, indent, " HMAC-MD5: %s\n", obuf); break; default: - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_int_add(json, "auth-unknown", auth->type); - else + json_object_int_add(json, "authUnknown", auth->type); + } else sbuf_push(buf, indent, " Unknown (%hhu)\n", auth->type); break; @@ -5771,12 +6645,25 @@ static void format_tlv_purge_originator(struct isis_purge_originator *poi, if (json) { struct json_object *purge_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old deprecated key format */ purge_json = json_object_new_object(); json_object_object_add(json, "purge_originator", purge_json); json_object_string_add(purge_json, "id", gen_id); if (poi->sender_set) json_object_string_add(purge_json, "rec-from", sen_id); + /* end old deprecated key format */ + + purge_json = json_object_new_object(); + json_object_object_add(json, "purgeOriginator", purge_json); + + json_object_string_add(purge_json, "id", gen_id); + if (poi->sender_set) + json_object_string_add(purge_json, "recFrom", sen_id); } else { sbuf_push(buf, indent, "Purge Originator Identification:\n"); sbuf_push(buf, indent, " Generator: %s\n", gen_id); @@ -6319,6 +7206,11 @@ static void format_item_srv6_locator(uint16_t mtid, struct isis_item *i, if (json) { struct json_object *loc_json; + +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif + /* old json key format */ loc_json = json_object_new_object(); json_object_object_add(json, "srv6-locator", loc_json); json_object_int_add(loc_json, "mt-id", mtid); @@ -6340,6 +7232,26 @@ static void format_item_srv6_locator(uint16_t mtid, struct isis_item *i, subtlvs_json); format_subtlvs(loc->subtlvs, NULL, subtlvs_json, 0); } + /* old deprecated key format */ + + loc_json = json_object_new_object(); + json_object_object_add(json, "srv6Locator", loc_json); + json_object_int_add(loc_json, "mtId", mtid); + json_object_string_addf(loc_json, "prefix", "%pFX", + &loc->prefix); + json_object_int_add(loc_json, "metric", loc->metric); + json_object_boolean_add(loc_json, "flagD", + !!CHECK_FLAG(loc->flags, + ISIS_TLV_SRV6_LOCATOR_FLAG_D)); + json_object_int_add(loc_json, "algorithm", loc->algorithm); + json_object_string_add(loc_json, "MTName", isis_mtid2str(mtid)); + if (loc->subtlvs) { + struct json_object *subtlvs_json; + subtlvs_json = json_object_new_object(); + json_object_object_add(loc_json, "subtlvs", + subtlvs_json); + format_subtlvs(loc->subtlvs, NULL, subtlvs_json, 0); + } } else { sbuf_push(buf, indent, "SRv6 Locator: %pFX (Metric: %u)%s", &loc->prefix, loc->metric, @@ -6623,9 +7535,13 @@ static void format_tlvs(struct isis_tlvs *tlvs, struct sbuf *buf, struct json_ob &tlvs->area_addresses, buf, json, indent); if (tlvs->mt_router_info_empty) { - if (json) + if (json) { +#if CONFDATE > 20240916 + CPP_NOTICE("remove deprecated key format with -") +#endif json_object_string_add(json, "mt-router-info", "none"); - else + json_object_object_add(json, "mtRouterInfo", NULL); + } else sbuf_push(buf, indent, "MT Router Info: None\n"); } else { format_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index 18a0c49..2412ec5 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -454,7 +454,7 @@ void isis_zebra_send_adjacency_sid(int cmd, const struct sr_adjacency *sra) znh->labels[0] = MPLS_LABEL_IMPLICIT_NULL; /* Set backup nexthops. */ - if (sra->type == ISIS_SR_LAN_BACKUP) { + if (sra->type == ISIS_SR_ADJ_BACKUP) { int count; count = isis_zebra_add_nexthops(isis, sra->backup_nexthops, diff --git a/isisd/isisd.c b/isisd/isisd.c index 772eb97..982df08 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -988,63 +988,17 @@ int show_isis_interface_common_json(struct json_object *json, "no"); return CMD_SUCCESS; } - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - areas_json = json_object_new_array(); - json_object_object_add(json, "areas", - areas_json); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, - anode, area)) { - area_json = json_object_new_object(); - json_object_string_add( - area_json, "area", - area->area_tag ? area->area_tag - : "null"); - circuits_json = json_object_new_array(); - json_object_object_add(area_json, - "circuits", - circuits_json); - for (ALL_LIST_ELEMENTS_RO( - area->circuit_list, cnode, - circuit)) { - circuit_json = - json_object_new_object(); - json_object_int_add( - circuit_json, "circuit", - circuit->circuit_id); - if (!ifname) - isis_circuit_print_json( - circuit, - circuit_json, - detail); - else if (strcmp(circuit->interface->name, ifname) == 0) - isis_circuit_print_json( - circuit, - circuit_json, - detail); - json_object_array_add( - circuits_json, - circuit_json); - } - json_object_array_add(areas_json, - area_json); - } - } - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) { + + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { areas_json = json_object_new_array(); json_object_object_add(json, "areas", areas_json); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, - area)) { + for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { area_json = json_object_new_object(); json_object_string_add(area_json, "area", area->area_tag ? area->area_tag : "null"); - circuits_json = json_object_new_array(); json_object_object_add(area_json, "circuits", circuits_json); @@ -1055,22 +1009,56 @@ int show_isis_interface_common_json(struct json_object *json, circuit_json, "circuit", circuit->circuit_id); if (!ifname) - isis_circuit_print_json( - circuit, circuit_json, - detail); - else if ( - strcmp(circuit->interface->name, - ifname) == 0) - isis_circuit_print_json( - circuit, circuit_json, - detail); + isis_circuit_print_json(circuit, + circuit_json, + detail); + else if (strcmp(circuit->interface->name, + ifname) == 0) + isis_circuit_print_json(circuit, + circuit_json, + detail); json_object_array_add(circuits_json, circuit_json); } json_object_array_add(areas_json, area_json); } } + return CMD_SUCCESS; + } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) { + areas_json = json_object_new_array(); + json_object_object_add(json, "areas", areas_json); + for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + area_json = json_object_new_object(); + json_object_string_add(area_json, "area", + area->area_tag ? area->area_tag + : "null"); + + circuits_json = json_object_new_array(); + json_object_object_add(area_json, "circuits", + circuits_json); + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, + circuit)) { + circuit_json = json_object_new_object(); + json_object_int_add(circuit_json, "circuit", + circuit->circuit_id); + if (!ifname) + isis_circuit_print_json(circuit, + circuit_json, + detail); + else if (strcmp(circuit->interface->name, + ifname) == 0) + isis_circuit_print_json(circuit, + circuit_json, + detail); + json_object_array_add(circuits_json, + circuit_json); + } + json_object_array_add(areas_json, area_json); + } } + return CMD_SUCCESS; } @@ -1087,37 +1075,10 @@ int show_isis_interface_common_vty(struct vty *vty, const char *ifname, vty_out(vty, "IS-IS Routing Process not enabled\n"); return CMD_SUCCESS; } - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, - anode, area)) { - vty_out(vty, "Area %s:\n", - area->area_tag); - if (detail == ISIS_UI_LEVEL_BRIEF) - vty_out(vty, - " Interface CircId State Type Level\n"); - - for (ALL_LIST_ELEMENTS_RO( - area->circuit_list, cnode, - circuit)) - if (!ifname) - isis_circuit_print_vty( - circuit, vty, - detail); - else if (strcmp(circuit->interface->name, ifname) == 0) - isis_circuit_print_vty( - circuit, vty, - detail); - } - } - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, - area)) { + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { + for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { vty_out(vty, "Area %s:\n", area->area_tag); if (detail == ISIS_UI_LEVEL_BRIEF) @@ -1127,15 +1088,37 @@ int show_isis_interface_common_vty(struct vty *vty, const char *ifname, for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) if (!ifname) - isis_circuit_print_vty( - circuit, vty, detail); - else if ( - strcmp(circuit->interface->name, - ifname) == 0) - isis_circuit_print_vty( - circuit, vty, detail); + isis_circuit_print_vty(circuit, + vty, + detail); + else if (strcmp(circuit->interface->name, + ifname) == 0) + isis_circuit_print_vty(circuit, + vty, + detail); } } + return CMD_SUCCESS; + } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) { + for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + vty_out(vty, "Area %s:\n", area->area_tag); + + if (detail == ISIS_UI_LEVEL_BRIEF) + vty_out(vty, + " Interface CircId State Type Level\n"); + + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, + circuit)) + if (!ifname) + isis_circuit_print_vty(circuit, vty, + detail); + else if (strcmp(circuit->interface->name, + ifname) == 0) + isis_circuit_print_vty(circuit, vty, + detail); + } } return CMD_SUCCESS; @@ -1318,7 +1301,7 @@ static void isis_neighbor_common_vty(struct vty *vty, const char *id, if (detail == ISIS_UI_LEVEL_BRIEF) vty_out(vty, - " System Id Interface L State Holdtime SNPA\n"); + " System Id Interface L State Holdtime SNPA\n"); for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { if (circuit->circ_type == CIRCUIT_T_BROADCAST) { @@ -1376,28 +1359,23 @@ int show_isis_neighbor_common(struct vty *vty, struct json_object *json, return CMD_SUCCESS; } - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { - if (id_to_sysid(isis, id, sysid)) { - vty_out(vty, "Invalid system id %s\n", - id); - return CMD_SUCCESS; - } - isis_neighbor_common(vty, json, id, detail, - isis, sysid); - } - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) { + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { if (id_to_sysid(isis, id, sysid)) { vty_out(vty, "Invalid system id %s\n", id); return CMD_SUCCESS; } - isis_neighbor_common(vty, json, id, detail, isis, - sysid); + isis_neighbor_common(vty, json, id, detail, isis, sysid); + } + return CMD_SUCCESS; + } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) { + if (id_to_sysid(isis, id, sysid)) { + vty_out(vty, "Invalid system id %s\n", id); + return CMD_SUCCESS; } + isis_neighbor_common(vty, json, id, detail, isis, sysid); } return CMD_SUCCESS; @@ -1461,27 +1439,23 @@ int clear_isis_neighbor_common(struct vty *vty, const char *id, const char *vrf_ return CMD_SUCCESS; } - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { - if (id_to_sysid(isis, id, sysid)) { - vty_out(vty, "Invalid system id %s\n", - id); - return CMD_SUCCESS; - } - isis_neighbor_common_clear(vty, id, sysid, - isis); - } - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) { + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { if (id_to_sysid(isis, id, sysid)) { vty_out(vty, "Invalid system id %s\n", id); return CMD_SUCCESS; } isis_neighbor_common_clear(vty, id, sysid, isis); } + return CMD_SUCCESS; + } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) { + if (id_to_sysid(isis, id, sysid)) { + vty_out(vty, "Invalid system id %s\n", id); + return CMD_SUCCESS; + } + isis_neighbor_common_clear(vty, id, sysid, isis); } return CMD_SUCCESS; @@ -2234,17 +2208,16 @@ DEFUN (show_hostname, struct isis *isis; ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) - dynhn_print_all(vty, isis); - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) dynhn_print_all(vty, isis); + + return CMD_SUCCESS; } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) + dynhn_print_all(vty, isis); return CMD_SUCCESS; } @@ -2307,17 +2280,15 @@ DEFUN(show_isis_spf_ietf, show_isis_spf_ietf_cmd, return CMD_SUCCESS; } - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) - isis_spf_ietf_common(vty, isis); - - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) isis_spf_ietf_common(vty, isis); + + return CMD_SUCCESS; } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) + isis_spf_ietf_common(vty, isis); return CMD_SUCCESS; } @@ -2596,17 +2567,16 @@ DEFUN(show_isis_summary, show_isis_summary_cmd, } if (uj) json = json_object_new_object(); - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) - common_isis_summary(vty, json, isis); - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis != NULL) + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) common_isis_summary(vty, json, isis); + + return CMD_SUCCESS; } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis != NULL) + common_isis_summary(vty, json, isis); if (uj) vty_json(vty, json); @@ -2679,8 +2649,10 @@ void show_isis_database_lspdb_json(struct json_object *json, struct lspdb_head *lspdb, const char *sysid_str, int ui_level) { + struct json_object *array_json, *lsp_json; struct isis_lsp *lsp; int lsp_count; + struct json_object *lsp_arr_json; if (lspdb_count(lspdb) > 0) { lsp = lsp_for_sysid(lspdb, sysid_str, area->isis); @@ -2690,16 +2662,27 @@ void show_isis_database_lspdb_json(struct json_object *json, } if (lsp) { + json_object_object_get_ex(json, "lsps", &array_json); + if (!array_json) { + array_json = json_object_new_array(); + json_object_object_add(json, "lsps", array_json); + } + lsp_json = json_object_new_object(); + json_object_array_add(array_json, lsp_json); + if (ui_level == ISIS_UI_LEVEL_DETAIL) - lsp_print_detail(lsp, NULL, json, + lsp_print_detail(lsp, NULL, lsp_json, area->dynhostname, area->isis); else - lsp_print_json(lsp, json, area->dynhostname, + lsp_print_json(lsp, lsp_json, area->dynhostname, area->isis); } else if (sysid_str == NULL) { - lsp_count = - lsp_print_all(NULL, json, lspdb, ui_level, - area->dynhostname, area->isis); + lsp_arr_json = json_object_new_array(); + json_object_object_add(json, "lsps", lsp_arr_json); + + lsp_count = lsp_print_all(NULL, lsp_arr_json, lspdb, + ui_level, area->dynhostname, + area->isis); json_object_int_add(json, "count", lsp_count); } @@ -2765,6 +2748,8 @@ static void show_isis_database_json(struct json_object *json, const char *sysid_ json_object_object_add(area_json,"area",tag_area_json); json_object_object_add(area_json,"levels",arr_json); for (level = 0; level < ISIS_LEVELS; level++) { + if (lspdb_count(&area->lspdb[level]) == 0) + continue; lsp_json = json_object_new_object(); show_isis_database_lspdb_json(lsp_json, area, level, &area->lspdb[level], @@ -2828,19 +2813,16 @@ static int show_isis_database(struct vty *vty, struct json_object *json, const c struct listnode *node; struct isis *isis; - if (vrf_name) { - if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) - show_isis_database_common(vty, json, sysid_str, - ui_level, isis); - - return CMD_SUCCESS; - } - isis = isis_lookup_by_vrfname(vrf_name); - if (isis) + if (all_vrf) { + for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) show_isis_database_common(vty, json, sysid_str, ui_level, isis); + + return CMD_SUCCESS; } + isis = isis_lookup_by_vrfname(vrf_name); + if (isis) + show_isis_database_common(vty, json, sysid_str, ui_level, isis); return CMD_SUCCESS; } |