diff --git a/isisd/fabricd.c b/isisd/fabricd.c index e8d606bab014..059ec0d278eb 100644 --- a/isisd/fabricd.c +++ b/isisd/fabricd.c @@ -158,10 +158,9 @@ static int fabricd_handle_adj_state_change(struct isis_adjacency *arg) while (!skiplist_empty(f->neighbors)) skiplist_delete_first(f->neighbors); - struct listnode *node; struct isis_circuit *circuit; - for (ALL_LIST_ELEMENTS_RO(f->area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &f->area->circuit_list, circuit) { if (circuit->state != C_STATE_UP) continue; @@ -705,10 +704,9 @@ void fabricd_trigger_csnp(struct isis_area *area, bool circuit_scoped) if (!circuit_scoped && !f->always_send_csnp) return; - struct listnode *node; struct isis_circuit *circuit; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { if (!circuit->t_send_csnp[1]) continue; @@ -724,13 +722,12 @@ struct list *fabricd_ip_addrs(struct isis_circuit *circuit) if (listcount(circuit->ip_addrs)) return circuit->ip_addrs; - if (!fabricd || !circuit->area || !circuit->area->circuit_list) + if (!fabricd || !circuit->area) return NULL; - struct listnode *node; struct isis_circuit *c; - for (ALL_LIST_ELEMENTS_RO(circuit->area->circuit_list, node, c)) { + frr_each (isis_circuit_list, &circuit->area->circuit_list, c) { if (c->circ_type != CIRCUIT_T_LOOPBACK) continue; diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c index 1b663e8a54b1..ba97dc48fc21 100644 --- a/isisd/isis_adjacency.c +++ b/isisd/isis_adjacency.c @@ -92,7 +92,7 @@ struct isis_adjacency *isis_new_adj(const uint8_t *id, const uint8_t *snpa, } adj->adj_sids = list_new(); adj->srv6_endx_sids = list_new(); - listnode_add(circuit->area->adjacency_list, adj); + isis_area_adj_list_add_tail(&circuit->area->adjacency_list, adj); return adj; } @@ -122,13 +122,12 @@ struct isis_adjacency *isis_adj_lookup_snpa(const uint8_t *ssnpa, return NULL; } -struct isis_adjacency *isis_adj_find(const struct isis_area *area, int level, - const uint8_t *sysid) +const struct isis_adjacency *isis_adj_find(const struct isis_area *area, + int level, const uint8_t *sysid) { - struct isis_adjacency *adj; - struct listnode *node; + const struct isis_adjacency *adj; - for (ALL_LIST_ELEMENTS_RO(area->adjacency_list, node, adj)) { + frr_each (isis_area_adj_list_const, &area->adjacency_list, adj) { if (!(adj->level & level)) continue; @@ -164,7 +163,7 @@ void isis_delete_adj(void *arg) list_delete(&adj->adj_sids); list_delete(&adj->srv6_endx_sids); - listnode_delete(adj->circuit->area->adjacency_list, adj); + isis_area_adj_list_del(&adj->circuit->area->adjacency_list, adj); XFREE(MTYPE_ISIS_ADJACENCY, adj); return; } diff --git a/isisd/isis_adjacency.h b/isisd/isis_adjacency.h index 9723ac7cb5e9..3192195fb5e6 100644 --- a/isisd/isis_adjacency.h +++ b/isisd/isis_adjacency.h @@ -12,7 +12,9 @@ #ifndef _ZEBRA_ISIS_ADJACENCY_H #define _ZEBRA_ISIS_ADJACENCY_H +#include "typesafe.h" #include "isisd/isis_tlvs.h" +#include "isisd/isisd.h" DECLARE_MTYPE(ISIS_ADJACENCY_INFO); @@ -98,16 +100,22 @@ struct isis_adjacency { struct listnode *snmp_list_node; struct list *srv6_endx_sids; /* SRv6 End.X SIDs. */ + + /* Typesafe list membership for area->adjacency_list */ + struct isis_area_adj_list_item area_adj_list_item; }; +/* Typesafe list definition for adjacency_list */ +DECLARE_DLIST(isis_area_adj_list, struct isis_adjacency, area_adj_list_item); + struct isis_threeway_adj; struct isis_adjacency *isis_adj_lookup(const uint8_t *sysid, struct list *adjdb); struct isis_adjacency *isis_adj_lookup_snpa(const uint8_t *ssnpa, struct list *adjdb); -struct isis_adjacency *isis_adj_find(const struct isis_area *area, int level, - const uint8_t *sysid); +const struct isis_adjacency *isis_adj_find(const struct isis_area *area, + int level, const uint8_t *sysid); struct isis_adjacency *isis_new_adj(const uint8_t *id, const uint8_t *snpa, int level, struct isis_circuit *circuit); void isis_delete_adj(void *adj); diff --git a/isisd/isis_affinitymap.c b/isisd/isis_affinitymap.c index a6b9cf9d4cb3..ced6e9e5e8b2 100644 --- a/isisd/isis_affinitymap.c +++ b/isisd/isis_affinitymap.c @@ -15,7 +15,7 @@ static void isis_affinity_map_update(const char *affmap_name, uint16_t old_pos, uint16_t new_pos) { struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); - struct listnode *area_node, *fa_node; + struct listnode *fa_node; struct isis_area *area; struct flex_algo *fa; bool changed; @@ -23,7 +23,7 @@ static void isis_affinity_map_update(const char *affmap_name, uint16_t old_pos, if (!isis) return; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, area_node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { changed = false; for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, fa_node, fa)) { diff --git a/isisd/isis_bfd.c b/isisd/isis_bfd.c index c003b8002d8c..2454312adaa6 100644 --- a/isisd/isis_bfd.c +++ b/isisd/isis_bfd.c @@ -191,12 +191,11 @@ static int bfd_handle_adj_ip_enabled(struct isis_adjacency *adj, int family, static int bfd_handle_circuit_add_addr(struct isis_circuit *circuit) { struct isis_adjacency *adj; - struct listnode *node; if (circuit->area == NULL) return 0; - for (ALL_LIST_ELEMENTS_RO(circuit->area->adjacency_list, node, adj)) { + frr_each (isis_area_adj_list, &circuit->area->adjacency_list, adj) { if (adj->bfd_session) continue; diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index a81e18401e1c..6bcb7190c764 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -240,7 +240,7 @@ void isis_circuit_configure(struct isis_circuit *circuit, /* * Add the circuit into area */ - listnode_add(area->circuit_list, circuit); + isis_circuit_list_add_tail(&area->circuit_list, circuit); circuit->idx = flags_get_index(&area->flags); @@ -263,7 +263,7 @@ void isis_circuit_deconfigure(struct isis_circuit *circuit, /* Remove circuit from area */ assert(circuit->area == area); - listnode_delete(area->circuit_list, circuit); + isis_circuit_list_del(&area->circuit_list, circuit); circuit->area = NULL; circuit->isis = NULL; @@ -630,7 +630,7 @@ void isis_circuit_prepare(struct isis_circuit *circuit) &circuit->t_read); #else event_add_timer_msec(master, isis_receive, circuit, - listcount(circuit->area->circuit_list) * 100, + isis_circuit_list_count(&circuit->area->circuit_list) * 100, &circuit->t_read); #endif } diff --git a/isisd/isis_circuit.h b/isisd/isis_circuit.h index a5972d4cd51f..5e908c1f75d9 100644 --- a/isisd/isis_circuit.h +++ b/isisd/isis_circuit.h @@ -16,6 +16,7 @@ #include "prefix.h" #include "ferr.h" #include "nexthop.h" +#include "typesafe.h" #include "isis_constants.h" #include "isis_common.h" @@ -23,6 +24,9 @@ DECLARE_HOOK(isis_if_new_hook, (struct interface *ifp), (ifp)); +/* Typesafe list declarations for circuits */ +PREDECL_DLIST(isis_circuit_list); + struct isis_lsp; struct password { @@ -39,16 +43,16 @@ struct metric { }; struct isis_bcast_info { - uint8_t snpa[ETH_ALEN]; /* SNPA of this circuit */ - char run_dr_elect[ISIS_LEVELS]; /* Should we run dr election ? */ - struct event *t_run_dr[ISIS_LEVELS]; /* DR election thread */ - struct event *t_send_lan_hello[ISIS_LEVELS]; /* send LAN IIHs in this + uint8_t snpa[ETH_ALEN]; /* SNPA of this circuit */ + char run_dr_elect[ISIS_LEVELS]; /* Should we run dr election ? */ + struct event *t_run_dr[ISIS_LEVELS]; /* DR election thread */ + struct event *t_send_lan_hello[ISIS_LEVELS]; /* send LAN IIHs in this thread */ - struct list *adjdb[ISIS_LEVELS]; /* adjacency dbs */ - struct list *lan_neighs[ISIS_LEVELS]; /* list of lx neigh snpa */ - char is_dr[ISIS_LEVELS]; /* Are we level x DR ? */ - uint8_t l1_desig_is[ISIS_SYS_ID_LEN + 1]; /* level-1 DR */ - uint8_t l2_desig_is[ISIS_SYS_ID_LEN + 1]; /* level-2 DR */ + struct list *adjdb[ISIS_LEVELS]; /* adjacency dbs */ + struct list *lan_neighs[ISIS_LEVELS]; /* list of lx neigh snpa */ + char is_dr[ISIS_LEVELS]; /* Are we level x DR ? */ + uint8_t l1_desig_is[ISIS_SYS_ID_LEN + 1]; /* level-1 DR */ + uint8_t l2_desig_is[ISIS_SYS_ID_LEN + 1]; /* level-2 DR */ struct event *t_refresh_pseudo_lsp[ISIS_LEVELS]; /* refresh pseudo-node LSPs */ }; @@ -74,10 +78,10 @@ enum isis_hello_padding { struct isis_circuit { enum isis_circuit_state state; - uint8_t circuit_id; /* l1/l2 bcast CircuitID */ + uint8_t circuit_id; /* l1/l2 bcast CircuitID */ time_t last_uptime; struct isis *isis; - struct isis_area *area; /* back pointer to the area */ + struct isis_area *area; /* back pointer to the area */ struct interface *interface; /* interface info from z */ int fd; /* IS-IS l1/2 socket */ int sap_length; /* SAP length for DLPI */ @@ -89,8 +93,7 @@ struct isis_circuit { struct event *t_send_csnp[ISIS_LEVELS]; struct event *t_send_psnp[ISIS_LEVELS]; struct isis_tx_queue *tx_queue; - struct isis_circuit_arg - level_arg[ISIS_LEVELS]; /* used as argument for threads */ + struct isis_circuit_arg level_arg[ISIS_LEVELS]; /* used as argument for threads */ /* there is no real point in two streams, just for programming kicker */ int (*rx)(struct isis_circuit *circuit, uint8_t *ssnpa); @@ -98,47 +101,50 @@ struct isis_circuit { int (*tx)(struct isis_circuit *circuit, int level); struct stream *snd_stream; /* Stream for sending */ int idx; /* idx in S[RM|SN] flags */ -#define CIRCUIT_T_UNKNOWN 0 -#define CIRCUIT_T_BROADCAST 1 -#define CIRCUIT_T_P2P 2 -#define CIRCUIT_T_LOOPBACK 3 - int circ_type; /* type of the physical interface */ - int circ_type_config; /* config type of the physical interface */ +#define CIRCUIT_T_UNKNOWN 0 +#define CIRCUIT_T_BROADCAST 1 +#define CIRCUIT_T_P2P 2 +#define CIRCUIT_T_LOOPBACK 3 + int circ_type; /* type of the physical interface */ + int circ_type_config; /* config type of the physical interface */ union { struct isis_bcast_info bc; struct isis_p2p_info p2p; } u; - uint8_t priority[ISIS_LEVELS]; /* l1/2 IS configured priority */ + uint8_t priority[ISIS_LEVELS]; /* l1/2 IS configured priority */ enum isis_hello_padding pad_hellos; /* type of Hello PDUs padding */ - char ext_domain; /* externalDomain (boolean) */ + char ext_domain; /* externalDomain (boolean) */ int lsp_regenerate_pending[ISIS_LEVELS]; uint64_t lsp_error_counter; /* * Configurables */ - char *tag; /* area tag */ - struct isis_passwd passwd; /* Circuit rx/tx password */ - int is_type_config; /* configured circuit is type */ - int is_type; /* circuit is type == level of circuit - * differentiated from circuit type (media) */ - uint32_t hello_interval[ISIS_LEVELS]; /* hello-interval in seconds */ + char *tag; /* area tag */ + struct isis_passwd passwd; /* Circuit rx/tx password */ + int is_type_config; /* configured circuit is type */ + /* + * circuit is type == level of circuit + * differentiated from circuit type (media) + */ + int is_type; + uint32_t hello_interval[ISIS_LEVELS]; /* hello-interval in seconds */ uint16_t hello_multiplier[ISIS_LEVELS]; /* hello-multiplier */ - uint16_t csnp_interval[ISIS_LEVELS]; /* csnp-interval in seconds */ - uint16_t psnp_interval[ISIS_LEVELS]; /* psnp-interval in seconds */ + uint16_t csnp_interval[ISIS_LEVELS]; /* csnp-interval in seconds */ + uint16_t psnp_interval[ISIS_LEVELS]; /* psnp-interval in seconds */ uint8_t metric[ISIS_LEVELS]; uint32_t te_metric[ISIS_LEVELS]; struct isis_ext_subtlvs *ext; /* Extended parameters (TE + Adj SID */ - int ip_router; /* Route IP ? */ - int is_passive; /* Is Passive ? */ - struct list *mt_settings; /* IS-IS MT Settings */ - struct list *ip_addrs; /* our IP addresses */ - int ipv6_router; /* Route IPv6 ? */ - struct list *ipv6_link; /* our link local IPv6 addresses */ - struct list *ipv6_non_link; /* our non-link local IPv6 addresses */ + int ip_router; /* Route IP ? */ + int is_passive; /* Is Passive ? */ + struct list *mt_settings; /* IS-IS MT Settings */ + struct list *ip_addrs; /* our IP addresses */ + int ipv6_router; /* Route IPv6 ? */ + struct list *ipv6_link; /* our link local IPv6 addresses */ + struct list *ipv6_non_link; /* our non-link local IPv6 addresses */ uint16_t upadjcount[ISIS_LEVELS]; #define ISIS_CIRCUIT_FLAPPED_AFTER_SPF 0x01 -#define ISIS_CIRCUIT_IF_DOWN_FROM_Z 0x02 +#define ISIS_CIRCUIT_IF_DOWN_FROM_Z 0x02 uint8_t flags; bool disable_threeway_adj; struct { @@ -156,93 +162,84 @@ struct isis_circuit { /* * Counters as in 10589--11.2.5.9 */ - uint32_t adj_state_changes; /* changesInAdjacencyState */ - uint32_t init_failures; /* intialisationFailures */ - uint32_t ctrl_pdus_rxed; /* controlPDUsReceived */ - uint32_t ctrl_pdus_txed; /* controlPDUsSent */ + uint32_t adj_state_changes; /* changesInAdjacencyState */ + uint32_t init_failures; /* intialisationFailures */ + uint32_t ctrl_pdus_rxed; /* controlPDUsReceived */ + uint32_t ctrl_pdus_txed; /* controlPDUsSent */ uint32_t desig_changes[ISIS_LEVELS]; /* lanLxDesignatedIntermediateSystemChanges */ - uint32_t rej_adjacencies; /* rejectedAdjacencies */ + uint32_t rej_adjacencies; /* rejectedAdjacencies */ /* * Counters as in ietf-isis@2019-09-09.yang */ - uint32_t id_len_mismatches; /* id-len-mismatch */ + uint32_t id_len_mismatches; /* id-len-mismatch */ uint32_t max_area_addr_mismatches; /* max-area-addresses-mismatch */ - uint32_t auth_type_failures; /*authentication-type-fails */ - uint32_t auth_failures; /* authentication-fails */ + uint32_t auth_type_failures; /*authentication-type-fails */ + uint32_t auth_failures; /* authentication-fails */ uint32_t snmp_id; /* Circuit id in snmp */ - uint32_t snmp_adj_idx_gen; /* Create unique id for adjacency on creation - */ + /* Create unique id for adjacency on creation */ + uint32_t snmp_adj_idx_gen; struct list *snmp_adj_list; /* List in id order */ + /* Typesafe list membership for area->circuit_list */ + struct isis_circuit_list_item circuit_list_item; + QOBJ_FIELDS; }; DECLARE_QOBJ_TYPE(isis_circuit); +/* Typesafe list definition for circuit_list */ +DECLARE_DLIST(isis_circuit_list, struct isis_circuit, circuit_list_item); + void isis_circuit_init(void); struct isis_circuit *isis_circuit_new(struct interface *ifp, const char *tag); void isis_circuit_del(struct isis_circuit *circuit); struct isis_circuit *circuit_scan_by_ifp(struct interface *ifp); -void isis_circuit_configure(struct isis_circuit *circuit, - struct isis_area *area); -void isis_circuit_deconfigure(struct isis_circuit *circuit, - struct isis_area *area); +void isis_circuit_configure(struct isis_circuit *circuit, struct isis_area *area); +void isis_circuit_deconfigure(struct isis_circuit *circuit, struct isis_area *area); void isis_circuit_if_add(struct isis_circuit *circuit, struct interface *ifp); void isis_circuit_if_del(struct isis_circuit *circuit, struct interface *ifp); void isis_circuit_if_bind(struct isis_circuit *circuit, struct interface *ifp); -void isis_circuit_if_unbind(struct isis_circuit *circuit, - struct interface *ifp); -void isis_circuit_add_addr(struct isis_circuit *circuit, - struct connected *conn); -void isis_circuit_del_addr(struct isis_circuit *circuit, - struct connected *conn); +void isis_circuit_if_unbind(struct isis_circuit *circuit, struct interface *ifp); +void isis_circuit_add_addr(struct isis_circuit *circuit, struct connected *conn); +void isis_circuit_del_addr(struct isis_circuit *circuit, struct connected *conn); void isis_circuit_prepare(struct isis_circuit *circuit); int isis_circuit_up(struct isis_circuit *circuit); void isis_circuit_down(struct isis_circuit *circuit); void circuit_update_nlpids(struct isis_circuit *circuit); -void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty, - char detail); -void isis_circuit_print_json(struct isis_circuit *circuit, - struct json_object *json, char detail); +void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty, char detail); +void isis_circuit_print_json(struct isis_circuit *circuit, struct json_object *json, char detail); size_t isis_circuit_pdu_size(struct isis_circuit *circuit); void isis_circuit_switchover_routes(struct isis_circuit *circuit, int family, - union g_addr *nexthop_ip, - ifindex_t ifindex); + union g_addr *nexthop_ip, ifindex_t ifindex); void isis_circuit_stream(struct isis_circuit *circuit, struct stream **stream); -void isis_circuit_af_set(struct isis_circuit *circuit, bool ip_router, - bool ipv6_router); +void isis_circuit_af_set(struct isis_circuit *circuit, bool ip_router, bool ipv6_router); ferr_r isis_circuit_passive_set(struct isis_circuit *circuit, bool passive); void isis_circuit_is_type_set(struct isis_circuit *circuit, int is_type); void isis_circuit_circ_type_set(struct isis_circuit *circuit, int circ_type); -ferr_r isis_circuit_metric_set(struct isis_circuit *circuit, int level, - int metric); +ferr_r isis_circuit_metric_set(struct isis_circuit *circuit, int level, int metric); ferr_r isis_circuit_passwd_unset(struct isis_circuit *circuit); -ferr_r isis_circuit_passwd_set(struct isis_circuit *circuit, - uint8_t passwd_type, const char *passwd); -ferr_r isis_circuit_passwd_cleartext_set(struct isis_circuit *circuit, - const char *passwd); -ferr_r isis_circuit_passwd_hmac_md5_set(struct isis_circuit *circuit, - const char *passwd); +ferr_r isis_circuit_passwd_set(struct isis_circuit *circuit, uint8_t passwd_type, + const char *passwd); +ferr_r isis_circuit_passwd_cleartext_set(struct isis_circuit *circuit, const char *passwd); +ferr_r isis_circuit_passwd_hmac_md5_set(struct isis_circuit *circuit, const char *passwd); -int isis_circuit_mt_enabled_set(struct isis_circuit *circuit, uint16_t mtid, - bool enabled); +int isis_circuit_mt_enabled_set(struct isis_circuit *circuit, uint16_t mtid, bool enabled); /* Reset ISIS hello timer and send immediate hello */ void isis_reset_hello_timer(struct isis_circuit *circuit); #ifdef FABRICD DECLARE_HOOK(isis_circuit_config_write, - (struct isis_circuit *circuit, struct vty *vty), - (circuit, vty)); + (struct isis_circuit *circuit, struct vty *vty), (circuit, vty)); #endif -DECLARE_HOOK(isis_circuit_add_addr_hook, (struct isis_circuit *circuit), - (circuit)); +DECLARE_HOOK(isis_circuit_add_addr_hook, (struct isis_circuit *circuit), (circuit)); DECLARE_HOOK(isis_circuit_new_hook, (struct isis_circuit *circuit), (circuit)); DECLARE_HOOK(isis_circuit_del_hook, (struct isis_circuit *circuit), (circuit)); diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index 7a50ff658e30..84fd81295eec 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -44,9 +44,8 @@ DEFPY_YANG_NOSH(router_isis, router_isis_cmd, if (!vrf_name) vrf_name = VRF_DEFAULT_NAME; - snprintf(base_xpath, XPATH_MAXLEN, - "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag, - vrf_name); + snprintf(base_xpath, XPATH_MAXLEN, "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", + tag, vrf_name); nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); ret = nb_cli_apply_changes(vty, "%s", base_xpath); @@ -65,31 +64,28 @@ DEFPY_YANG(no_router_isis, no_router_isis_cmd, if (!vrf_name) vrf_name = VRF_DEFAULT_NAME; - if (!yang_dnode_existsf( - vty->candidate_config->dnode, - "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag, - vrf_name)) { + if (!yang_dnode_existsf(vty->candidate_config->dnode, + "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag, + vrf_name)) { vty_out(vty, "ISIS area %s not found.\n", tag); return CMD_ERR_NOTHING_TODO; } nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); - return nb_cli_apply_changes_clear_pending( - vty, "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", tag, - vrf_name); + return nb_cli_apply_changes_clear_pending(vty, + "/frr-isisd:isis/instance[area-tag='%s'][vrf='%s']", + tag, vrf_name); } -void cli_show_router_isis(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_router_isis(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *vrf = NULL; vrf = yang_dnode_get_string(dnode, "vrf"); vty_out(vty, "!\n"); - vty_out(vty, "router isis %s", - yang_dnode_get_string(dnode, "area-tag")); + vty_out(vty, "router isis %s", yang_dnode_get_string(dnode, "area-tag")); if (!strmatch(vrf, VRF_DEFAULT_NAME)) vty_out(vty, " vrf %s", yang_dnode_get_string(dnode, "vrf")); vty_out(vty, "\n"); @@ -114,10 +110,8 @@ DEFPY_YANG(ip_router_isis, ip_router_isis_cmd, "Routing process tag\n") { nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE, NULL); - nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag", NB_OP_MODIFY, - tag); - nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv4-routing", - NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag", NB_OP_MODIFY, tag); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv4-routing", NB_OP_MODIFY, "true"); return nb_cli_apply_changes(vty, NULL); } @@ -137,10 +131,8 @@ DEFPY_YANG(ip6_router_isis, ip6_router_isis_cmd, "Routing process tag\n") { nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE, NULL); - nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag", NB_OP_MODIFY, - tag); - nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing", - NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag", NB_OP_MODIFY, tag); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing", NB_OP_MODIFY, "true"); return nb_cli_apply_changes(vty, NULL); } @@ -163,8 +155,7 @@ DEFPY_YANG(no_ip_router_isis, no_ip_router_isis_cmd, { const struct lyd_node *dnode; - dnode = yang_dnode_getf(vty->candidate_config->dnode, - "%s/frr-isisd:isis", VTY_CURR_XPATH); + dnode = yang_dnode_getf(vty->candidate_config->dnode, "%s/frr-isisd:isis", VTY_CURR_XPATH); if (!dnode) return CMD_SUCCESS; @@ -173,20 +164,16 @@ DEFPY_YANG(no_ip_router_isis, no_ip_router_isis_cmd, */ if (strmatch(ip, "ipv6")) { if (!yang_dnode_get_bool(dnode, "ipv4-routing")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/ipv6-routing", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing", NB_OP_MODIFY, + "false"); } else { if (!yang_dnode_get_bool(dnode, "ipv6-routing")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/ipv4-routing", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv4-routing", NB_OP_MODIFY, + "false"); } return nb_cli_apply_changes(vty, NULL); @@ -202,22 +189,18 @@ ALIAS_HIDDEN(no_ip_router_isis, no_ip_router_isis_vrf_cmd, "Routing process tag\n" VRF_CMD_HELP_STR) -void cli_show_ip_isis_ipv4(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_ipv4(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); - vty_out(vty, " ip router isis %s\n", - yang_dnode_get_string(dnode, "../area-tag")); + vty_out(vty, " ip router isis %s\n", yang_dnode_get_string(dnode, "../area-tag")); } -void cli_show_ip_isis_ipv6(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); - vty_out(vty, " ipv6 router isis %s\n", - yang_dnode_get_string(dnode, "../area-tag")); + vty_out(vty, " ipv6 router isis %s\n", yang_dnode_get_string(dnode, "../area-tag")); } /* @@ -231,15 +214,14 @@ DEFPY_YANG(isis_bfd, { const struct lyd_node *dnode; - dnode = yang_dnode_getf(vty->candidate_config->dnode, - "%s/frr-isisd:isis", VTY_CURR_XPATH); + dnode = yang_dnode_getf(vty->candidate_config->dnode, "%s/frr-isisd:isis", VTY_CURR_XPATH); if (dnode == NULL) { vty_out(vty, "ISIS is not enabled on this circuit\n"); return CMD_SUCCESS; } - nb_cli_enqueue_change(vty, "./frr-isisd:isis/bfd-monitoring/enabled", - NB_OP_MODIFY, no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/bfd-monitoring/enabled", NB_OP_MODIFY, + no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } @@ -257,27 +239,23 @@ DEFPY_YANG(isis_bfd_profile, { const struct lyd_node *dnode; - dnode = yang_dnode_getf(vty->candidate_config->dnode, - "%s/frr-isisd:isis", VTY_CURR_XPATH); + dnode = yang_dnode_getf(vty->candidate_config->dnode, "%s/frr-isisd:isis", VTY_CURR_XPATH); if (dnode == NULL) { vty_out(vty, "ISIS is not enabled on this circuit\n"); return CMD_SUCCESS; } if (no) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/bfd-monitoring/profile", + nb_cli_enqueue_change(vty, "./frr-isisd:isis/bfd-monitoring/profile", NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/bfd-monitoring/profile", - NB_OP_MODIFY, profile); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/bfd-monitoring/profile", NB_OP_MODIFY, + profile); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_bfd_monitoring(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_bfd_monitoring(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, "enabled")) { @@ -288,8 +266,7 @@ void cli_show_ip_isis_bfd_monitoring(struct vty *vty, } if (yang_dnode_exists(dnode, "profile")) - vty_out(vty, " isis bfd profile %s\n", - yang_dnode_get_string(dnode, "profile")); + vty_out(vty, " isis bfd profile %s\n", yang_dnode_get_string(dnode, "profile")); } /* @@ -304,14 +281,12 @@ DEFPY_YANG(net, net_cmd, "[no] net WORD", snprintf(xpath, XPATH_MAXLEN, "./area-address[.='%s']", net); - nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, - NULL); + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_area_address(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_area_address(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " net %s\n", yang_dnode_get_string(dnode, NULL)); } @@ -326,8 +301,7 @@ DEFPY_YANG(is_type, is_type_cmd, "is-type $level "Act as an area router only\n") { nb_cli_enqueue_change(vty, "./is-type", NB_OP_MODIFY, - strmatch(level, "level-2-only") ? "level-2" - : level); + strmatch(level, "level-2-only") ? "level-2" : level); return nb_cli_apply_changes(vty, NULL); } @@ -345,8 +319,7 @@ DEFPY_YANG(no_is_type, no_is_type_cmd, return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_is_type(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_is_type(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { int is_type = yang_dnode_get_enum(dnode, NULL); @@ -371,14 +344,12 @@ DEFPY_YANG(dynamic_hostname, dynamic_hostname_cmd, "[no] hostname dynamic", "Dynamic hostname for IS-IS\n" "Dynamic hostname\n") { - nb_cli_enqueue_change(vty, "./dynamic-hostname", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./dynamic-hostname", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_dynamic_hostname(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_dynamic_hostname(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -394,14 +365,12 @@ DEFPY_YANG(set_overload_bit, set_overload_bit_cmd, "[no] set-overload-bit", "Reset overload bit to accept transit traffic\n" "Set overload bit to avoid any transit traffic\n") { - nb_cli_enqueue_change(vty, "./overload/enabled", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./overload/enabled", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_overload(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_overload(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); @@ -417,8 +386,7 @@ DEFPY_YANG(set_overload_bit_on_startup, set_overload_bit_on_startup_cmd, "Set overload bit on startup\n" "Set overload time in seconds\n") { - nb_cli_enqueue_change(vty, "./overload/on-startup", NB_OP_MODIFY, - val_str); + nb_cli_enqueue_change(vty, "./overload/on-startup", NB_OP_MODIFY, val_str); return nb_cli_apply_changes(vty, NULL); } @@ -430,18 +398,15 @@ DEFPY_YANG(no_set_overload_bit_on_startup, no_set_overload_bit_on_startup_cmd, "Set overload bit on startup\n" "Set overload time in seconds\n") { - nb_cli_enqueue_change(vty, "./overload/on-startup", NB_OP_DESTROY, - NULL); + nb_cli_enqueue_change(vty, "./overload/on-startup", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_overload_on_startup(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_overload_on_startup(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " set-overload-bit on-startup %s\n", - yang_dnode_get_string(dnode, NULL)); + vty_out(vty, " set-overload-bit on-startup %s\n", yang_dnode_get_string(dnode, NULL)); } /* @@ -451,14 +416,12 @@ DEFPY_YANG(advertise_high_metrics, advertise_high_metrics_cmd, "[no] advertise-high-metrics", NO_STR "Advertise high metric value on all interfaces\n") { - nb_cli_enqueue_change(vty, "./advertise-high-metrics", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./advertise-high-metrics", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_advertise_high_metrics(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_advertise_high_metrics(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (yang_dnode_get_bool(dnode, NULL)) @@ -475,14 +438,12 @@ DEFPY_YANG(attached_bit_send, attached_bit_send_cmd, "[no] attached-bit send", "Set attached bit for inter-area traffic\n" "Set attached bit in LSP sent to L1 router\n") { - nb_cli_enqueue_change(vty, "./attach-send", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./attach-send", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_attached_send(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_attached_send(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); @@ -500,14 +461,12 @@ DEFPY_YANG( "If LSP received with attached bit set, create default route to neighbor\n" "Do not process attached bit\n") { - nb_cli_enqueue_change(vty, "./attach-receive-ignore", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./attach-receive-ignore", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_attached_receive(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_attached_receive(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -543,8 +502,7 @@ DEFPY_YANG(no_metric_style, no_metric_style_cmd, return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_metric_style(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_metric_style(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { int metric = yang_dnode_get_enum(dnode, NULL); @@ -576,23 +534,19 @@ DEFPY_YANG(area_passwd, area_passwd_cmd, "Send and check PDUs on receiving\n") { nb_cli_enqueue_change(vty, "./area-password", NB_OP_CREATE, NULL); - nb_cli_enqueue_change(vty, "./area-password/password", NB_OP_MODIFY, - pwd); - nb_cli_enqueue_change(vty, "./area-password/password-type", - NB_OP_MODIFY, pwd_type); - nb_cli_enqueue_change(vty, "./area-password/authenticate-snp", - NB_OP_MODIFY, snp ? snp : "none"); + nb_cli_enqueue_change(vty, "./area-password/password", NB_OP_MODIFY, pwd); + nb_cli_enqueue_change(vty, "./area-password/password-type", NB_OP_MODIFY, pwd_type); + nb_cli_enqueue_change(vty, "./area-password/authenticate-snp", NB_OP_MODIFY, + snp ? snp : "none"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_area_pwd(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_area_pwd(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *snp; - vty_out(vty, " area-password %s %s", - yang_dnode_get_string(dnode, "password-type"), + vty_out(vty, " area-password %s %s", yang_dnode_get_string(dnode, "password-type"), yang_dnode_get_string(dnode, "password")); snp = yang_dnode_get_string(dnode, "authenticate-snp"); if (!strmatch("none", snp)) @@ -615,12 +569,10 @@ DEFPY_YANG(domain_passwd, domain_passwd_cmd, "Send and check PDUs on receiving\n") { nb_cli_enqueue_change(vty, "./domain-password", NB_OP_CREATE, NULL); - nb_cli_enqueue_change(vty, "./domain-password/password", NB_OP_MODIFY, - pwd); - nb_cli_enqueue_change(vty, "./domain-password/password-type", - NB_OP_MODIFY, pwd_type); - nb_cli_enqueue_change(vty, "./domain-password/authenticate-snp", - NB_OP_MODIFY, snp ? snp : "none"); + nb_cli_enqueue_change(vty, "./domain-password/password", NB_OP_MODIFY, pwd); + nb_cli_enqueue_change(vty, "./domain-password/password-type", NB_OP_MODIFY, pwd_type); + nb_cli_enqueue_change(vty, "./domain-password/authenticate-snp", NB_OP_MODIFY, + snp ? snp : "none"); return nb_cli_apply_changes(vty, NULL); } @@ -643,13 +595,11 @@ DEFPY_YANG(no_area_passwd, no_area_passwd_cmd, return nb_cli_apply_changes(vty, "./%s", cmd); } -void cli_show_isis_domain_pwd(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_domain_pwd(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *snp; - vty_out(vty, " domain-password %s %s", - yang_dnode_get_string(dnode, "password-type"), + vty_out(vty, " domain-password %s %s", yang_dnode_get_string(dnode, "password-type"), yang_dnode_get_string(dnode, "password")); snp = yang_dnode_get_string(dnode, "authenticate-snp"); if (!strmatch("none", snp)) @@ -669,13 +619,11 @@ DEFPY_YANG(lsp_gen_interval, lsp_gen_interval_cmd, "Minimum interval in seconds\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change( - vty, "./lsp/timers/level-1/generation-interval", - NB_OP_MODIFY, val_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/generation-interval", + NB_OP_MODIFY, val_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change( - vty, "./lsp/timers/level-2/generation-interval", - NB_OP_MODIFY, val_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/generation-interval", + NB_OP_MODIFY, val_str); return nb_cli_apply_changes(vty, NULL); } @@ -689,13 +637,11 @@ DEFPY_YANG(no_lsp_gen_interval, no_lsp_gen_interval_cmd, "Minimum interval in seconds\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change( - vty, "./lsp/timers/level-1/generation-interval", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/generation-interval", + NB_OP_MODIFY, NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change( - vty, "./lsp/timers/level-2/generation-interval", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/generation-interval", + NB_OP_MODIFY, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -712,13 +658,11 @@ DEFPY_YANG(lsp_refresh_interval, lsp_refresh_interval_cmd, "LSP refresh interval in seconds\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./lsp/timers/level-1/refresh-interval", - NB_OP_MODIFY, val_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/refresh-interval", NB_OP_MODIFY, + val_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./lsp/timers/level-2/refresh-interval", - NB_OP_MODIFY, val_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/refresh-interval", NB_OP_MODIFY, + val_str); return nb_cli_apply_changes(vty, NULL); } @@ -732,13 +676,11 @@ DEFPY_YANG(no_lsp_refresh_interval, no_lsp_refresh_interval_cmd, "LSP refresh interval in seconds\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./lsp/timers/level-1/refresh-interval", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/refresh-interval", NB_OP_MODIFY, + NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./lsp/timers/level-2/refresh-interval", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/refresh-interval", NB_OP_MODIFY, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -756,13 +698,11 @@ DEFPY_YANG(max_lsp_lifetime, max_lsp_lifetime_cmd, "LSP lifetime in seconds\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./lsp/timers/level-1/maximum-lifetime", - NB_OP_MODIFY, val_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/maximum-lifetime", NB_OP_MODIFY, + val_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./lsp/timers/level-2/maximum-lifetime", - NB_OP_MODIFY, val_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/maximum-lifetime", NB_OP_MODIFY, + val_str); return nb_cli_apply_changes(vty, NULL); } @@ -776,13 +716,11 @@ DEFPY_YANG(no_max_lsp_lifetime, no_max_lsp_lifetime_cmd, "LSP lifetime in seconds\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./lsp/timers/level-1/maximum-lifetime", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/maximum-lifetime", NB_OP_MODIFY, + NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./lsp/timers/level-2/maximum-lifetime", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/maximum-lifetime", NB_OP_MODIFY, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -804,26 +742,20 @@ DEFPY_YANG(lsp_timers, lsp_timers_cmd, "Maximum LSP lifetime in seconds\n") { if (!level || strmatch(level, "level-1")) { - nb_cli_enqueue_change( - vty, "./lsp/timers/level-1/generation-interval", - NB_OP_MODIFY, gen_str); - nb_cli_enqueue_change(vty, - "./lsp/timers/level-1/refresh-interval", - NB_OP_MODIFY, refresh_str); - nb_cli_enqueue_change(vty, - "./lsp/timers/level-1/maximum-lifetime", - NB_OP_MODIFY, lifetime_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/generation-interval", + NB_OP_MODIFY, gen_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/refresh-interval", NB_OP_MODIFY, + refresh_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/maximum-lifetime", NB_OP_MODIFY, + lifetime_str); } if (!level || strmatch(level, "level-2")) { - nb_cli_enqueue_change( - vty, "./lsp/timers/level-2/generation-interval", - NB_OP_MODIFY, gen_str); - nb_cli_enqueue_change(vty, - "./lsp/timers/level-2/refresh-interval", - NB_OP_MODIFY, refresh_str); - nb_cli_enqueue_change(vty, - "./lsp/timers/level-2/maximum-lifetime", - NB_OP_MODIFY, lifetime_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/generation-interval", + NB_OP_MODIFY, gen_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/refresh-interval", NB_OP_MODIFY, + refresh_str); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/maximum-lifetime", NB_OP_MODIFY, + lifetime_str); } return nb_cli_apply_changes(vty, NULL); @@ -843,50 +775,37 @@ DEFPY_YANG(no_lsp_timers, no_lsp_timers_cmd, "Maximum LSP lifetime in seconds\n") { if (!level || strmatch(level, "level-1")) { - nb_cli_enqueue_change( - vty, "./lsp/timers/level-1/generation-interval", - NB_OP_MODIFY, NULL); - nb_cli_enqueue_change(vty, - "./lsp/timers/level-1/refresh-interval", - NB_OP_MODIFY, NULL); - nb_cli_enqueue_change(vty, - "./lsp/timers/level-1/maximum-lifetime", + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/generation-interval", NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/refresh-interval", NB_OP_MODIFY, + NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-1/maximum-lifetime", NB_OP_MODIFY, + NULL); } if (!level || strmatch(level, "level-2")) { - nb_cli_enqueue_change( - vty, "./lsp/timers/level-2/generation-interval", - NB_OP_MODIFY, NULL); - nb_cli_enqueue_change(vty, - "./lsp/timers/level-2/refresh-interval", - NB_OP_MODIFY, NULL); - nb_cli_enqueue_change(vty, - "./lsp/timers/level-2/maximum-lifetime", + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/generation-interval", NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/refresh-interval", NB_OP_MODIFY, + NULL); + nb_cli_enqueue_change(vty, "./lsp/timers/level-2/maximum-lifetime", NB_OP_MODIFY, + NULL); } return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_lsp_timers(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) -{ - const char *l1_refresh = - yang_dnode_get_string(dnode, "level-1/refresh-interval"); - const char *l2_refresh = - yang_dnode_get_string(dnode, "level-2/refresh-interval"); - const char *l1_lifetime = - yang_dnode_get_string(dnode, "level-1/maximum-lifetime"); - const char *l2_lifetime = - yang_dnode_get_string(dnode, "level-2/maximum-lifetime"); - const char *l1_gen = - yang_dnode_get_string(dnode, "level-1/generation-interval"); - const char *l2_gen = - yang_dnode_get_string(dnode, "level-2/generation-interval"); - if (strmatch(l1_refresh, l2_refresh) - && strmatch(l1_lifetime, l2_lifetime) && strmatch(l1_gen, l2_gen)) - vty_out(vty, - " lsp-timers gen-interval %s refresh-interval %s max-lifetime %s\n", +void cli_show_isis_lsp_timers(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) +{ + const char *l1_refresh = yang_dnode_get_string(dnode, "level-1/refresh-interval"); + const char *l2_refresh = yang_dnode_get_string(dnode, "level-2/refresh-interval"); + const char *l1_lifetime = yang_dnode_get_string(dnode, "level-1/maximum-lifetime"); + const char *l2_lifetime = yang_dnode_get_string(dnode, "level-2/maximum-lifetime"); + const char *l1_gen = yang_dnode_get_string(dnode, "level-1/generation-interval"); + const char *l2_gen = yang_dnode_get_string(dnode, "level-2/generation-interval"); + + if (strmatch(l1_refresh, l2_refresh) && strmatch(l1_lifetime, l2_lifetime) && + strmatch(l1_gen, l2_gen)) + vty_out(vty, " lsp-timers gen-interval %s refresh-interval %s max-lifetime %s\n", l1_gen, l1_refresh, l1_lifetime); else { vty_out(vty, @@ -920,8 +839,7 @@ DEFPY_YANG(no_area_lsp_mtu, no_area_lsp_mtu_cmd, "no lsp-mtu [(128-4352)]", return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_lsp_mtu(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_lsp_mtu(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " lsp-mtu %s\n", yang_dnode_get_string(dnode, NULL)); } @@ -933,14 +851,12 @@ DEFPY_YANG(advertise_passive_only, advertise_passive_only_cmd, "[no] advertise-passive-only", NO_STR "Advertise prefixes of passive interfaces only\n") { - nb_cli_enqueue_change(vty, "./advertise-passive-only", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./advertise-passive-only", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_advertise_passive_only(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_advertise_passive_only(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -960,11 +876,9 @@ DEFPY_YANG(spf_interval, spf_interval_cmd, "Minimum interval between consecutive SPFs in seconds\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-1", - NB_OP_MODIFY, val_str); + nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-1", NB_OP_MODIFY, val_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-2", - NB_OP_MODIFY, val_str); + nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-2", NB_OP_MODIFY, val_str); return nb_cli_apply_changes(vty, NULL); } @@ -978,17 +892,14 @@ DEFPY_YANG(no_spf_interval, no_spf_interval_cmd, "Minimum interval between consecutive SPFs in seconds\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-1", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-1", NB_OP_MODIFY, NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-2", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-2", NB_OP_MODIFY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_spf_min_interval(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_spf_min_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *l1 = yang_dnode_get_string(dnode, "level-1"); @@ -1019,18 +930,17 @@ DEFPY_YANG(spf_delay_ietf, spf_delay_ietf_cmd, "Maximum duration needed to learn all the events related to a single failure\n" "Maximum duration needed to learn all the events related to a single failure (in milliseconds)\n") { - nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay", NB_OP_CREATE, - NULL); - nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/init-delay", - NB_OP_MODIFY, init_delay_str); - nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/short-delay", - NB_OP_MODIFY, short_delay_str); - nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/long-delay", - NB_OP_MODIFY, long_delay_str); - nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/hold-down", - NB_OP_MODIFY, holddown_str); - nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/time-to-learn", - NB_OP_MODIFY, time_to_learn_str); + nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay", NB_OP_CREATE, NULL); + nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/init-delay", NB_OP_MODIFY, + init_delay_str); + nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/short-delay", NB_OP_MODIFY, + short_delay_str); + nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/long-delay", NB_OP_MODIFY, + long_delay_str); + nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/hold-down", NB_OP_MODIFY, + holddown_str); + nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/time-to-learn", NB_OP_MODIFY, + time_to_learn_str); return nb_cli_apply_changes(vty, NULL); } @@ -1050,14 +960,12 @@ DEFPY_YANG(no_spf_delay_ietf, no_spf_delay_ietf_cmd, "Maximum duration needed to learn all the events related to a single failure\n" "Maximum duration needed to learn all the events related to a single failure (in milliseconds)\n") { - nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay", NB_OP_DESTROY, - NULL); + nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_spf_ietf_backoff(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_spf_ietf_backoff(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, @@ -1083,8 +991,7 @@ DEFPY_YANG(spf_prefix_priority, spf_prefix_priority_cmd, { char xpath[XPATH_MAXLEN]; - snprintf(xpath, XPATH_MAXLEN, - "./spf/prefix-priorities/%s/access-list-name", priority); + snprintf(xpath, XPATH_MAXLEN, "./spf/prefix-priorities/%s/access-list-name", priority); nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, acl_name); return nb_cli_apply_changes(vty, NULL); @@ -1102,19 +1009,16 @@ DEFPY_YANG(no_spf_prefix_priority, no_spf_prefix_priority_cmd, { char xpath[XPATH_MAXLEN]; - snprintf(xpath, XPATH_MAXLEN, - "./spf/prefix-priorities/%s/access-list-name", priority); + snprintf(xpath, XPATH_MAXLEN, "./spf/prefix-priorities/%s/access-list-name", priority); nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_spf_prefix_priority(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_spf_prefix_priority(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " spf prefix-priority %s %s\n", - dnode->parent->schema->name, + vty_out(vty, " spf prefix-priority %s %s\n", dnode->parent->schema->name, yang_dnode_get_string(dnode, NULL)); } @@ -1124,14 +1028,12 @@ void cli_show_isis_spf_prefix_priority(struct vty *vty, DEFPY_YANG(area_purge_originator, area_purge_originator_cmd, "[no] purge-originator", NO_STR "Use the RFC 6232 purge-originator\n") { - nb_cli_enqueue_change(vty, "./purge-originator", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./purge-originator", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_purge_origin(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_purge_origin(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); @@ -1147,14 +1049,12 @@ DEFPY_YANG(isis_admin_group_send_zero, isis_admin_group_send_zero_cmd, NO_STR "Allow sending the default admin-group value of 0x00000000.\n") { - nb_cli_enqueue_change(vty, "./admin-group-send-zero", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./admin-group-send-zero", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_admin_group_send_zero(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_admin_group_send_zero(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -1170,14 +1070,12 @@ DEFPY_HIDDEN(isis_asla_legacy_flag, isis_asla_legacy_flag_cmd, "[no] asla-legacy-flag", NO_STR "Set the legacy flag (aka. L-FLAG) in the ASLA Sub-TLV.\n") { - nb_cli_enqueue_change(vty, "./asla-legacy-flag", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./asla-legacy-flag", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_asla_legacy_flag(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_asla_legacy_flag(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -1191,8 +1089,7 @@ void cli_show_isis_asla_legacy_flag(struct vty *vty, DEFPY_YANG(isis_mpls_te_on, isis_mpls_te_on_cmd, "mpls-te on", MPLS_TE_STR "Enable the MPLS-TE functionality\n") { - nb_cli_enqueue_change(vty, "./mpls-te", NB_OP_CREATE, - NULL); + nb_cli_enqueue_change(vty, "./mpls-te", NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -1202,14 +1099,12 @@ DEFPY_YANG(no_isis_mpls_te_on, no_isis_mpls_te_on_cmd, "no mpls-te [on]", "Disable the MPLS-TE functionality\n" "Disable the MPLS-TE functionality\n") { - nb_cli_enqueue_change(vty, "./mpls-te", NB_OP_DESTROY, - NULL); + nb_cli_enqueue_change(vty, "./mpls-te", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_mpls_te(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_mpls_te(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " mpls-te on\n"); } @@ -1223,8 +1118,7 @@ DEFPY_YANG(isis_mpls_te_router_addr, isis_mpls_te_router_addr_cmd, "Stable IP address of the advertising router\n" "MPLS-TE router address in IPv4 address format\n") { - nb_cli_enqueue_change(vty, "./mpls-te/router-address", - NB_OP_MODIFY, router_address_str); + nb_cli_enqueue_change(vty, "./mpls-te/router-address", NB_OP_MODIFY, router_address_str); return nb_cli_apply_changes(vty, NULL); } @@ -1235,18 +1129,15 @@ DEFPY_YANG(no_isis_mpls_te_router_addr, no_isis_mpls_te_router_addr_cmd, "Delete IP address of the advertising router\n" "MPLS-TE router address in IPv4 address format\n") { - nb_cli_enqueue_change(vty, "./mpls-te/router-address", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./mpls-te/router-address", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_mpls_te_router_addr(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mpls_te_router_addr(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " mpls-te router-address %s\n", - yang_dnode_get_string(dnode, NULL)); + vty_out(vty, " mpls-te router-address %s\n", yang_dnode_get_string(dnode, NULL)); } /* @@ -1259,8 +1150,7 @@ DEFPY_YANG(isis_mpls_te_router_addr_v6, isis_mpls_te_router_addr_v6_cmd, "IPv6 address\n" "MPLS-TE router address in IPv6 address format\n") { - nb_cli_enqueue_change(vty, "./mpls-te/router-address-v6", NB_OP_MODIFY, - ipv6_str); + nb_cli_enqueue_change(vty, "./mpls-te/router-address-v6", NB_OP_MODIFY, ipv6_str); return nb_cli_apply_changes(vty, NULL); } @@ -1272,18 +1162,15 @@ DEFPY_YANG(no_isis_mpls_te_router_addr_v6, no_isis_mpls_te_router_addr_v6_cmd, "IPv6 address\n" "MPLS-TE router address in IPv6 address format\n") { - nb_cli_enqueue_change(vty, "./mpls-te/router-address-v6", NB_OP_DESTROY, - NULL); + nb_cli_enqueue_change(vty, "./mpls-te/router-address-v6", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_mpls_te_router_addr_ipv6(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mpls_te_router_addr_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " mpls-te router-address ipv6 %s\n", - yang_dnode_get_string(dnode, NULL)); + vty_out(vty, " mpls-te router-address ipv6 %s\n", yang_dnode_get_string(dnode, NULL)); } DEFPY_YANG(isis_mpls_te_inter_as, isis_mpls_te_inter_as_cmd, @@ -1319,8 +1206,7 @@ DEFPY_YANG(no_isis_mpls_te_export, no_isis_mpls_te_export_cmd, return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_mpls_te_export(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_mpls_te_export(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); @@ -1350,46 +1236,37 @@ DEFPY_YANG(isis_default_originate, isis_default_originate_cmd, nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); else { nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); - nb_cli_enqueue_change(vty, "./always", NB_OP_MODIFY, - always ? "true" : "false"); - nb_cli_enqueue_change(vty, "./route-map", - rmap ? NB_OP_MODIFY : NB_OP_DESTROY, + nb_cli_enqueue_change(vty, "./always", NB_OP_MODIFY, always ? "true" : "false"); + nb_cli_enqueue_change(vty, "./route-map", rmap ? NB_OP_MODIFY : NB_OP_DESTROY, rmap ? rmap : NULL); nb_cli_enqueue_change(vty, "./metric", NB_OP_MODIFY, metric_str ? metric_str : NULL); if (strmatch(ip, "ipv6") && !always) { - vty_out(vty, - "Zebra doesn't implement default-originate for IPv6 yet\n"); - vty_out(vty, - "so use with care or use default-originate always.\n"); + vty_out(vty, "Zebra doesn't implement default-originate for IPv6 yet\n"); + vty_out(vty, "so use with care or use default-originate always.\n"); } } - return nb_cli_apply_changes( - vty, "./default-information-originate/%s[level='%s']", ip, - level); + return nb_cli_apply_changes(vty, "./default-information-originate/%s[level='%s']", ip, + level); } -static void vty_print_def_origin(struct vty *vty, const struct lyd_node *dnode, - const char *family, const char *level, - bool show_defaults) +static void vty_print_def_origin(struct vty *vty, const struct lyd_node *dnode, const char *family, + const char *level, bool show_defaults) { vty_out(vty, " default-information originate %s %s", family, level); if (yang_dnode_get_bool(dnode, "always")) vty_out(vty, " always"); if (yang_dnode_exists(dnode, "route-map")) - vty_out(vty, " route-map %s", - yang_dnode_get_string(dnode, "route-map")); + vty_out(vty, " route-map %s", yang_dnode_get_string(dnode, "route-map")); if (show_defaults || !yang_dnode_is_default(dnode, "metric")) - vty_out(vty, " metric %s", - yang_dnode_get_string(dnode, "metric")); + vty_out(vty, " metric %s", yang_dnode_get_string(dnode, "metric")); vty_out(vty, "\n"); } -void cli_show_isis_def_origin_ipv4(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_def_origin_ipv4(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *level = yang_dnode_get_string(dnode, "level"); @@ -1397,8 +1274,7 @@ void cli_show_isis_def_origin_ipv4(struct vty *vty, vty_print_def_origin(vty, dnode, "ipv4", level, show_defaults); } -void cli_show_isis_def_origin_ipv6(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_def_origin_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *level = yang_dnode_get_string(dnode, "level"); @@ -1429,16 +1305,14 @@ DEFPY_YANG(isis_redistribute, isis_redistribute_cmd, nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); else { nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); - nb_cli_enqueue_change(vty, "./route-map", - route_map ? NB_OP_MODIFY : NB_OP_DESTROY, + nb_cli_enqueue_change(vty, "./route-map", route_map ? NB_OP_MODIFY : NB_OP_DESTROY, route_map ? route_map : NULL); nb_cli_enqueue_change(vty, "./metric", NB_OP_MODIFY, metric_str ? metric_str : NULL); } - return nb_cli_apply_changes( - vty, "./redistribute/%s[protocol='%s'][level='%s']", ip, proto, - level); + return nb_cli_apply_changes(vty, "./redistribute/%s[protocol='%s'][level='%s']", ip, proto, + level); } /* @@ -1473,16 +1347,13 @@ DEFPY_YANG(isis_redistribute_table, isis_redistribute_table_cmd, snprintf(xpath, sizeof(xpath), "./table[table='%s']", table_str); nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); - rv = nb_cli_apply_changes(vty, - "./redistribute/%s[protocol='table'][level='%s']", + rv = nb_cli_apply_changes(vty, "./redistribute/%s[protocol='table'][level='%s']", ip, level); if (rv == CMD_SUCCESS) { if (isis_redist_table_get_first(vty, &rtda) > 0) return CMD_SUCCESS; - nb_cli_enqueue_change(vty, "./table", NB_OP_DESTROY, - NULL); - nb_cli_apply_changes(vty, - "./redistribute/%s[protocol='table'][level='%s']", + nb_cli_enqueue_change(vty, "./table", NB_OP_DESTROY, NULL); + nb_cli_apply_changes(vty, "./redistribute/%s[protocol='table'][level='%s']", ip, level); } return CMD_SUCCESS; @@ -1494,20 +1365,16 @@ DEFPY_YANG(isis_redistribute_table, isis_redistribute_table_cmd, nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); snprintf(xpath_entry, sizeof(xpath_entry), "%s/route-map", xpath); - nb_cli_enqueue_change(vty, xpath_entry, - route_map ? NB_OP_MODIFY : NB_OP_DESTROY, + nb_cli_enqueue_change(vty, xpath_entry, route_map ? NB_OP_MODIFY : NB_OP_DESTROY, route_map ? route_map : NULL); snprintf(xpath_entry, sizeof(xpath_entry), "%s/metric", xpath); - nb_cli_enqueue_change(vty, xpath_entry, NB_OP_MODIFY, - metric_str ? metric_str : NULL); - return nb_cli_apply_changes(vty, - "./redistribute/%s[protocol='table'][level='%s']", - ip, level); + nb_cli_enqueue_change(vty, xpath_entry, NB_OP_MODIFY, metric_str ? metric_str : NULL); + return nb_cli_apply_changes(vty, "./redistribute/%s[protocol='table'][level='%s']", ip, + level); } static void vty_print_redistribute(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults, const char *family, - bool table) + bool show_defaults, const char *family, bool table) { const char *level; const char *protocol = NULL; @@ -1527,8 +1394,7 @@ static void vty_print_redistribute(struct vty *vty, const struct lyd_node *dnode } vty_out(vty, "%s", level); if (show_defaults || !yang_dnode_is_default(dnode, "metric")) - vty_out(vty, " metric %s", - yang_dnode_get_string(dnode, "%s", "metric")); + vty_out(vty, " metric %s", yang_dnode_get_string(dnode, "%s", "metric")); if (yang_dnode_exists(dnode, "route-map")) routemap = yang_dnode_get_string(dnode, "route-map"); @@ -1537,36 +1403,31 @@ static void vty_print_redistribute(struct vty *vty, const struct lyd_node *dnode vty_out(vty, "\n"); } -void cli_show_isis_redistribute_ipv4(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_redistribute_ipv4(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_print_redistribute(vty, dnode, show_defaults, "ipv4", false); } -void cli_show_isis_redistribute_ipv6(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_redistribute_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_print_redistribute(vty, dnode, show_defaults, "ipv6", false); } -void cli_show_isis_redistribute_ipv4_table(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_redistribute_ipv4_table(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_print_redistribute(vty, dnode, show_defaults, "ipv4", true); } -void cli_show_isis_redistribute_ipv6_table(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_redistribute_ipv6_table(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_print_redistribute(vty, dnode, show_defaults, "ipv6", true); } -int cli_cmp_isis_redistribute_table(const struct lyd_node *dnode1, - const struct lyd_node *dnode2) +int cli_cmp_isis_redistribute_table(const struct lyd_node *dnode1, const struct lyd_node *dnode2) { uint16_t table1 = yang_dnode_get_uint16(dnode1, "table"); uint16_t table2 = yang_dnode_get_uint16(dnode2, "table"); @@ -1597,36 +1458,29 @@ DEFPY_YANG( /* Since standard is not configurable it is not present in the * YANG model, so we need to validate it here */ - if (strmatch(topology, "standard") || - strmatch(topology, "ipv4-unicast")) { - vty_out(vty, - "Cannot configure IPv4 unicast (Standard) topology\n"); + if (strmatch(topology, "standard") || strmatch(topology, "ipv4-unicast")) { + vty_out(vty, "Cannot configure IPv4 unicast (Standard) topology\n"); return CMD_WARNING_CONFIG_FAILED; } if (strmatch(topology, "ipv4-mgmt")) - snprintf(base_xpath, XPATH_MAXLEN, - "./multi-topology/ipv4-management"); + snprintf(base_xpath, XPATH_MAXLEN, "./multi-topology/ipv4-management"); else if (strmatch(topology, "ipv6-mgmt")) - snprintf(base_xpath, XPATH_MAXLEN, - "./multi-topology/ipv6-management"); + snprintf(base_xpath, XPATH_MAXLEN, "./multi-topology/ipv6-management"); else - snprintf(base_xpath, XPATH_MAXLEN, "./multi-topology/%s", - topology); + snprintf(base_xpath, XPATH_MAXLEN, "./multi-topology/%s", topology); if (no) nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); else { nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); - nb_cli_enqueue_change(vty, "./overload", NB_OP_MODIFY, - overload ? "true" : "false"); + nb_cli_enqueue_change(vty, "./overload", NB_OP_MODIFY, overload ? "true" : "false"); } return nb_cli_apply_changes(vty, "%s", base_xpath); } -void cli_show_isis_mt_ipv4_multicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mt_ipv4_multicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " topology ipv4-multicast"); @@ -1635,8 +1489,7 @@ void cli_show_isis_mt_ipv4_multicast(struct vty *vty, vty_out(vty, "\n"); } -void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " topology ipv4-mgmt"); if (yang_dnode_get_bool(dnode, "overload")) @@ -1644,8 +1497,7 @@ void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, const struct lyd_node *dnode, vty_out(vty, "\n"); } -void cli_show_isis_mt_ipv6_unicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mt_ipv6_unicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " topology ipv6-unicast"); @@ -1654,8 +1506,7 @@ void cli_show_isis_mt_ipv6_unicast(struct vty *vty, vty_out(vty, "\n"); } -void cli_show_isis_mt_ipv6_multicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mt_ipv6_multicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " topology ipv6-multicast"); @@ -1664,8 +1515,7 @@ void cli_show_isis_mt_ipv6_multicast(struct vty *vty, vty_out(vty, "\n"); } -void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " topology ipv6-mgmt"); if (yang_dnode_get_bool(dnode, "overload")) @@ -1673,8 +1523,7 @@ void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, const struct lyd_node *dnode, vty_out(vty, "\n"); } -void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " topology ipv6-dstsrc"); if (yang_dnode_get_bool(dnode, "overload")) @@ -1691,8 +1540,7 @@ DEFPY_YANG (isis_sr_enable, SR_STR "Enable Segment Routing\n") { - nb_cli_enqueue_change(vty, "./segment-routing/enabled", NB_OP_MODIFY, - "true"); + nb_cli_enqueue_change(vty, "./segment-routing/enabled", NB_OP_MODIFY, "true"); return nb_cli_apply_changes(vty, NULL); } @@ -1704,14 +1552,12 @@ DEFPY_YANG (no_isis_sr_enable, SR_STR "Disable Segment Routing\n") { - nb_cli_enqueue_change(vty, "./segment-routing/enabled", NB_OP_MODIFY, - "false"); + nb_cli_enqueue_change(vty, "./segment-routing/enabled", NB_OP_MODIFY, "false"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_sr_enabled(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_sr_enabled(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); @@ -1734,19 +1580,15 @@ DEFPY_YANG( "The lower bound of the local block\n" "The upper bound of the local block (block size may not exceed 65535)\n") { - nb_cli_enqueue_change(vty, - "./segment-routing/label-blocks/srgb/lower-bound", - NB_OP_MODIFY, gb_lower_bound_str); - nb_cli_enqueue_change(vty, - "./segment-routing/label-blocks/srgb/upper-bound", - NB_OP_MODIFY, gb_upper_bound_str); + nb_cli_enqueue_change(vty, "./segment-routing/label-blocks/srgb/lower-bound", NB_OP_MODIFY, + gb_lower_bound_str); + nb_cli_enqueue_change(vty, "./segment-routing/label-blocks/srgb/upper-bound", NB_OP_MODIFY, + gb_upper_bound_str); - nb_cli_enqueue_change( - vty, "./segment-routing/label-blocks/srlb/lower-bound", - NB_OP_MODIFY, lb_lower_bound ? lb_lower_bound_str : NULL); - nb_cli_enqueue_change( - vty, "./segment-routing/label-blocks/srlb/upper-bound", - NB_OP_MODIFY, lb_upper_bound ? lb_upper_bound_str : NULL); + nb_cli_enqueue_change(vty, "./segment-routing/label-blocks/srlb/lower-bound", NB_OP_MODIFY, + lb_lower_bound ? lb_lower_bound_str : NULL); + nb_cli_enqueue_change(vty, "./segment-routing/label-blocks/srlb/upper-bound", NB_OP_MODIFY, + lb_upper_bound ? lb_upper_bound_str : NULL); return nb_cli_apply_changes(vty, NULL); } @@ -1762,32 +1604,26 @@ DEFPY_YANG(no_isis_sr_global_block_label_range, "The lower bound of the local block\n" "The upper bound of the local block (block size may not exceed 65535)\n") { - nb_cli_enqueue_change(vty, - "./segment-routing/label-blocks/srgb/lower-bound", - NB_OP_MODIFY, NULL); - nb_cli_enqueue_change(vty, - "./segment-routing/label-blocks/srgb/upper-bound", - NB_OP_MODIFY, NULL); - nb_cli_enqueue_change(vty, - "./segment-routing/label-blocks/srlb/lower-bound", - NB_OP_MODIFY, NULL); - nb_cli_enqueue_change(vty, - "./segment-routing/label-blocks/srlb/upper-bound", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./segment-routing/label-blocks/srgb/lower-bound", NB_OP_MODIFY, + NULL); + nb_cli_enqueue_change(vty, "./segment-routing/label-blocks/srgb/upper-bound", NB_OP_MODIFY, + NULL); + nb_cli_enqueue_change(vty, "./segment-routing/label-blocks/srlb/lower-bound", NB_OP_MODIFY, + NULL); + nb_cli_enqueue_change(vty, "./segment-routing/label-blocks/srlb/upper-bound", NB_OP_MODIFY, + NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_label_blocks(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_label_blocks(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " segment-routing global-block %s %s", yang_dnode_get_string(dnode, "srgb/lower-bound"), yang_dnode_get_string(dnode, "srgb/upper-bound")); - if (!yang_dnode_is_default(dnode, "srlb/lower-bound") - || !yang_dnode_is_default(dnode, "srlb/upper-bound")) - vty_out(vty, " local-block %s %s", - yang_dnode_get_string(dnode, "srlb/lower-bound"), + if (!yang_dnode_is_default(dnode, "srlb/lower-bound") || + !yang_dnode_is_default(dnode, "srlb/upper-bound")) + vty_out(vty, " local-block %s %s", yang_dnode_get_string(dnode, "srlb/lower-bound"), yang_dnode_get_string(dnode, "srlb/upper-bound")); vty_out(vty, "\n"); } @@ -1802,8 +1638,7 @@ DEFPY_YANG (isis_sr_node_msd, "Maximum Stack Depth for this router\n" "Maximum number of label that can be stack (1-16)\n") { - nb_cli_enqueue_change(vty, "./segment-routing/msd/node-msd", - NB_OP_MODIFY, msd_str); + nb_cli_enqueue_change(vty, "./segment-routing/msd/node-msd", NB_OP_MODIFY, msd_str); return nb_cli_apply_changes(vty, NULL); } @@ -1816,17 +1651,14 @@ DEFPY_YANG (no_isis_sr_node_msd, "Maximum Stack Depth for this router\n" "Maximum number of label that can be stack (1-16)\n") { - nb_cli_enqueue_change(vty, "./segment-routing/msd/node-msd", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./segment-routing/msd/node-msd", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_node_msd(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_node_msd(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " segment-routing node-msd %s\n", - yang_dnode_get_string(dnode, NULL)); + vty_out(vty, " segment-routing node-msd %s\n", yang_dnode_get_string(dnode, NULL)); } /* @@ -1863,17 +1695,13 @@ DEFPY_YANG (isis_sr_prefix_sid, else value = "php"; - nb_cli_enqueue_change(vty, "./last-hop-behavior", NB_OP_MODIFY, - value); + nb_cli_enqueue_change(vty, "./last-hop-behavior", NB_OP_MODIFY, value); } else - nb_cli_enqueue_change(vty, "./last-hop-behavior", NB_OP_MODIFY, - NULL); - nb_cli_enqueue_change(vty, "./n-flag-clear", NB_OP_MODIFY, - n_flag_clear ? "true" : "false"); + nb_cli_enqueue_change(vty, "./last-hop-behavior", NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./n-flag-clear", NB_OP_MODIFY, n_flag_clear ? "true" : "false"); - return nb_cli_apply_changes( - vty, "./segment-routing/prefix-sid-map/prefix-sid[prefix='%s']", - prefix_str); + return nb_cli_apply_changes(vty, "./segment-routing/prefix-sid-map/prefix-sid[prefix='%s']", + prefix_str); } DEFPY_YANG (no_isis_sr_prefix_sid, @@ -1896,13 +1724,11 @@ DEFPY_YANG (no_isis_sr_prefix_sid, { nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); - return nb_cli_apply_changes( - vty, "./segment-routing/prefix-sid-map/prefix-sid[prefix='%s']", - prefix_str); + return nb_cli_apply_changes(vty, "./segment-routing/prefix-sid-map/prefix-sid[prefix='%s']", + prefix_str); } -void cli_show_isis_prefix_sid(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_prefix_sid(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *prefix; const char *lh_behavior; @@ -1969,13 +1795,10 @@ DEFPY_YANG( else value = "php"; - nb_cli_enqueue_change(vty, "./last-hop-behavior", NB_OP_MODIFY, - value); + nb_cli_enqueue_change(vty, "./last-hop-behavior", NB_OP_MODIFY, value); } else - nb_cli_enqueue_change(vty, "./last-hop-behavior", NB_OP_MODIFY, - NULL); - nb_cli_enqueue_change(vty, "./n-flag-clear", NB_OP_MODIFY, - n_flag_clear ? "true" : "false"); + nb_cli_enqueue_change(vty, "./last-hop-behavior", NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./n-flag-clear", NB_OP_MODIFY, n_flag_clear ? "true" : "false"); return nb_cli_apply_changes( vty, @@ -2013,8 +1836,7 @@ DEFPY_YANG( } #endif /* ifndef FABRICD */ -void cli_show_isis_prefix_sid_algorithm(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_prefix_sid_algorithm(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *prefix; @@ -2066,8 +1888,7 @@ DEFPY (isis_srv6_locator, return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_srv6_locator(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_srv6_locator(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " locator %s\n", yang_dnode_get_string(dnode, NULL)); } @@ -2084,11 +1905,9 @@ DEFPY_YANG_NOSH (isis_srv6_enable, int ret; char xpath[XPATH_MAXLEN + 37]; - snprintf(xpath, sizeof(xpath), "%s/segment-routing-srv6", - VTY_CURR_XPATH); + snprintf(xpath, sizeof(xpath), "%s/segment-routing-srv6", VTY_CURR_XPATH); - nb_cli_enqueue_change(vty, "./segment-routing-srv6/enabled", - NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, "./segment-routing-srv6/enabled", NB_OP_MODIFY, "true"); ret = nb_cli_apply_changes(vty, NULL); if (ret == CMD_SUCCESS) @@ -2104,14 +1923,12 @@ DEFPY_YANG (no_isis_srv6_enable, SR_STR "Disable Segment Routing over IPv6 (SRv6)\n") { - nb_cli_enqueue_change(vty, "./segment-routing-srv6", NB_OP_DESTROY, - NULL); + nb_cli_enqueue_change(vty, "./segment-routing-srv6", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_srv6_enabled(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_srv6_enabled(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); @@ -2139,14 +1956,10 @@ DEFPY_YANG_NOSH (isis_srv6_node_msd, snprintf(xpath, sizeof(xpath), "%s/msd/node-msd", VTY_CURR_XPATH); if (no) { - nb_cli_enqueue_change(vty, "./msd/node_msd/max-segs-left", - NB_OP_DESTROY, NULL); - nb_cli_enqueue_change(vty, "./msd/node_msd/end-pop", - NB_OP_DESTROY, NULL); - nb_cli_enqueue_change(vty, "./msd/node_msd/h-encaps", - NB_OP_DESTROY, NULL); - nb_cli_enqueue_change(vty, "./msd/node_msd/end-d", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./msd/node_msd/max-segs-left", NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./msd/node_msd/end-pop", NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./msd/node_msd/h-encaps", NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./msd/node_msd/end-d", NB_OP_DESTROY, NULL); ret = nb_cli_apply_changes(vty, NULL); } else VTY_PUSH_XPATH(ISIS_SRV6_NODE_MSD_NODE, xpath); @@ -2165,11 +1978,9 @@ DEFPY_YANG (isis_srv6_node_msd_max_segs_left, "Specify Maximum Segments Left MSD\n") { if (no) - nb_cli_enqueue_change(vty, "./max-segs-left", NB_OP_DESTROY, - NULL); + nb_cli_enqueue_change(vty, "./max-segs-left", NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, "./max-segs-left", NB_OP_MODIFY, - max_segs_left_str); + nb_cli_enqueue_change(vty, "./max-segs-left", NB_OP_MODIFY, max_segs_left_str); return nb_cli_apply_changes(vty, NULL); } @@ -2187,8 +1998,7 @@ DEFPY_YANG (isis_srv6_node_msd_max_end_pop, if (no) nb_cli_enqueue_change(vty, "./max-end-pop", NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, "./max-end-pop", NB_OP_MODIFY, - max_end_pop_str); + nb_cli_enqueue_change(vty, "./max-end-pop", NB_OP_MODIFY, max_end_pop_str); return nb_cli_apply_changes(vty, NULL); } @@ -2204,11 +2014,9 @@ DEFPY_YANG (isis_srv6_node_msd_max_h_encaps, "Specify Maximum H.Encaps MSD\n") { if (no) - nb_cli_enqueue_change(vty, "./max-h-encaps", NB_OP_DESTROY, - NULL); + nb_cli_enqueue_change(vty, "./max-h-encaps", NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, "./max-h-encaps", NB_OP_MODIFY, - max_h_encaps_str); + nb_cli_enqueue_change(vty, "./max-h-encaps", NB_OP_MODIFY, max_h_encaps_str); return nb_cli_apply_changes(vty, NULL); } @@ -2226,32 +2034,26 @@ DEFPY_YANG (isis_srv6_node_msd_max_end_d, if (no) nb_cli_enqueue_change(vty, "./max-end-d", NB_OP_DESTROY, NULL); else - nb_cli_enqueue_change(vty, "./max-end-d", NB_OP_MODIFY, - max_end_d_str); + nb_cli_enqueue_change(vty, "./max-end-d", NB_OP_MODIFY, max_end_d_str); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_srv6_node_msd(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_srv6_node_msd(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " node-msd\n"); if (yang_dnode_get_uint8(dnode, "max-segs-left") != yang_get_default_uint8("%s/msd/node-msd/max-segs-left", ISIS_SRV6)) - vty_out(vty, " max-segs-left %u\n", - yang_dnode_get_uint8(dnode, "max-segs-left")); + vty_out(vty, " max-segs-left %u\n", yang_dnode_get_uint8(dnode, "max-segs-left")); if (yang_dnode_get_uint8(dnode, "max-end-pop") != yang_get_default_uint8("%s/msd/node-msd/max-end-pop", ISIS_SRV6)) - vty_out(vty, " max-end-pop %u\n", - yang_dnode_get_uint8(dnode, "max-end-pop")); + vty_out(vty, " max-end-pop %u\n", yang_dnode_get_uint8(dnode, "max-end-pop")); if (yang_dnode_get_uint8(dnode, "max-h-encaps") != yang_get_default_uint8("%s/msd/node-msd/max-h-encaps", ISIS_SRV6)) - vty_out(vty, " max-h-encaps %u\n", - yang_dnode_get_uint8(dnode, "max-h-encaps")); + vty_out(vty, " max-h-encaps %u\n", yang_dnode_get_uint8(dnode, "max-h-encaps")); if (yang_dnode_get_uint8(dnode, "max-end-d") != yang_get_default_uint8("%s/msd/node-msd/max-end-d", ISIS_SRV6)) - vty_out(vty, " max-end-d %u\n", - yang_dnode_get_uint8(dnode, "max-end-d")); + vty_out(vty, " max-end-d %u\n", yang_dnode_get_uint8(dnode, "max-end-d")); } void cli_show_isis_srv6_node_msd_end(struct vty *vty, const struct lyd_node *dnode) @@ -2269,19 +2071,15 @@ DEFPY_YANG (isis_srv6_interface, "Interface for Segment Routing over IPv6 (SRv6)\n" "Interface for Segment Routing over IPv6 (SRv6)\n") { - if (no) { - nb_cli_enqueue_change(vty, "./interface", - NB_OP_MODIFY, NULL); - } else { - nb_cli_enqueue_change(vty, "./interface", - NB_OP_MODIFY, interface); - } + if (no) + nb_cli_enqueue_change(vty, "./interface", NB_OP_MODIFY, NULL); + else + nb_cli_enqueue_change(vty, "./interface", NB_OP_MODIFY, interface); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_srv6_interface(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_srv6_interface(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " interface %s\n", yang_dnode_get_string(dnode, NULL)); } @@ -2303,40 +2101,30 @@ DEFPY_YANG (isis_frr_lfa_priority_limit, { if (!level || strmatch(level, "level-1")) { if (no) { - nb_cli_enqueue_change( - vty, - "./fast-reroute/level-1/lfa/priority-limit", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./fast-reroute/level-1/lfa/priority-limit", + NB_OP_DESTROY, NULL); } else { - nb_cli_enqueue_change( - vty, - "./fast-reroute/level-1/lfa/priority-limit", - NB_OP_CREATE, priority); + nb_cli_enqueue_change(vty, "./fast-reroute/level-1/lfa/priority-limit", + NB_OP_CREATE, priority); } } if (!level || strmatch(level, "level-2")) { if (no) { - nb_cli_enqueue_change( - vty, - "./fast-reroute/level-2/lfa/priority-limit", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./fast-reroute/level-2/lfa/priority-limit", + NB_OP_DESTROY, NULL); } else { - nb_cli_enqueue_change( - vty, - "./fast-reroute/level-2/lfa/priority-limit", - NB_OP_CREATE, priority); + nb_cli_enqueue_change(vty, "./fast-reroute/level-2/lfa/priority-limit", + NB_OP_CREATE, priority); } } return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_frr_lfa_priority_limit(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_frr_lfa_priority_limit(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " fast-reroute priority-limit %s %s\n", - yang_dnode_get_string(dnode, NULL), + vty_out(vty, " fast-reroute priority-limit %s %s\n", yang_dnode_get_string(dnode, NULL), dnode->parent->parent->schema->name); } @@ -2393,13 +2181,11 @@ DEFPY_YANG (isis_frr_lfa_tiebreaker, return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_frr_lfa_tiebreaker(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_frr_lfa_tiebreaker(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " fast-reroute lfa tiebreaker %s index %s %s\n", - yang_dnode_get_string(dnode, "type"), - yang_dnode_get_string(dnode, "index"), + yang_dnode_get_string(dnode, "type"), yang_dnode_get_string(dnode, "index"), dnode->parent->parent->schema->name); } @@ -2418,32 +2204,27 @@ DEFPY_YANG (isis_frr_lfa_load_sharing, { if (!level || strmatch(level, "level-1")) { if (no) { - nb_cli_enqueue_change( - vty, "./fast-reroute/level-1/lfa/load-sharing", - NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, "./fast-reroute/level-1/lfa/load-sharing", + NB_OP_MODIFY, "true"); } else { - nb_cli_enqueue_change( - vty, "./fast-reroute/level-1/lfa/load-sharing", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, "./fast-reroute/level-1/lfa/load-sharing", + NB_OP_MODIFY, "false"); } } if (!level || strmatch(level, "level-2")) { if (no) { - nb_cli_enqueue_change( - vty, "./fast-reroute/level-2/lfa/load-sharing", - NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, "./fast-reroute/level-2/lfa/load-sharing", + NB_OP_MODIFY, "true"); } else { - nb_cli_enqueue_change( - vty, "./fast-reroute/level-2/lfa/load-sharing", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, "./fast-reroute/level-2/lfa/load-sharing", + NB_OP_MODIFY, "false"); } } return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_frr_lfa_load_sharing(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_frr_lfa_load_sharing(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (yang_dnode_get_bool(dnode, NULL)) @@ -2467,13 +2248,11 @@ DEFPY_YANG (isis_frr_remote_lfa_plist, "Enable router ID filtering for level-2 only\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change( - vty, "./fast-reroute/level-1/remote-lfa/prefix-list", - NB_OP_MODIFY, plist); + nb_cli_enqueue_change(vty, "./fast-reroute/level-1/remote-lfa/prefix-list", + NB_OP_MODIFY, plist); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change( - vty, "./fast-reroute/level-2/remote-lfa/prefix-list", - NB_OP_MODIFY, plist); + nb_cli_enqueue_change(vty, "./fast-reroute/level-2/remote-lfa/prefix-list", + NB_OP_MODIFY, plist); return nb_cli_apply_changes(vty, NULL); } @@ -2490,24 +2269,20 @@ DEFPY_YANG (no_isis_frr_remote_lfa_plist, "Enable router ID filtering for level-2 only\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change( - vty, "./fast-reroute/level-1/remote-lfa/prefix-list", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./fast-reroute/level-1/remote-lfa/prefix-list", + NB_OP_DESTROY, NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change( - vty, "./fast-reroute/level-2/remote-lfa/prefix-list", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./fast-reroute/level-2/remote-lfa/prefix-list", + NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_frr_remote_lfa_plist(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_frr_remote_lfa_plist(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " fast-reroute remote-lfa prefix-list %s %s\n", - yang_dnode_get_string(dnode, NULL), - dnode->parent->parent->schema->name); + yang_dnode_get_string(dnode, NULL), dnode->parent->parent->schema->name); } /* @@ -2518,14 +2293,12 @@ DEFPY_YANG(isis_passive, isis_passive_cmd, "[no] isis passive", "IS-IS routing protocol\n" "Configure the passive mode for interface\n") { - nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_passive(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_passive(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); @@ -2543,12 +2316,9 @@ DEFPY_YANG(isis_passwd, isis_passwd_cmd, "isis password $type WORD$pw "Cleartext password\n" "Circuit password\n") { - nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_CREATE, - NULL); - nb_cli_enqueue_change(vty, "./frr-isisd:isis/password/password", - NB_OP_MODIFY, pwd); - nb_cli_enqueue_change(vty, "./frr-isisd:isis/password/password-type", - NB_OP_MODIFY, type); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_CREATE, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/password/password", NB_OP_MODIFY, pwd); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/password/password-type", NB_OP_MODIFY, type); return nb_cli_apply_changes(vty, NULL); } @@ -2561,17 +2331,14 @@ DEFPY_YANG(no_isis_passwd, no_isis_passwd_cmd, "no isis password [ WO "Cleartext password\n" "Circuit password\n") { - nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_DESTROY, - NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_password(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_password(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " isis password %s %s\n", - yang_dnode_get_string(dnode, "password-type"), + vty_out(vty, " isis password %s %s\n", yang_dnode_get_string(dnode, "password-type"), yang_dnode_get_string(dnode, "password")); } @@ -2587,11 +2354,11 @@ DEFPY_YANG(isis_metric, isis_metric_cmd, "Default metric value\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-1", - NB_OP_MODIFY, met_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-1", NB_OP_MODIFY, + met_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-2", - NB_OP_MODIFY, met_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-2", NB_OP_MODIFY, + met_str); return nb_cli_apply_changes(vty, NULL); } @@ -2606,17 +2373,14 @@ DEFPY_YANG(no_isis_metric, no_isis_metric_cmd, "Default metric value\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-1", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-1", NB_OP_MODIFY, NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-2", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-2", NB_OP_MODIFY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_metric(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_metric(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *l1 = yang_dnode_get_string(dnode, "level-1"); const char *l2 = yang_dnode_get_string(dnode, "level-2"); @@ -2641,13 +2405,11 @@ DEFPY_YANG(isis_hello_interval, isis_hello_interval_cmd, "Holdtime 1 seconds, interval depends on multiplier\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/hello/interval/level-1", - NB_OP_MODIFY, intv_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/interval/level-1", NB_OP_MODIFY, + intv_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/hello/interval/level-2", - NB_OP_MODIFY, intv_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/interval/level-2", NB_OP_MODIFY, + intv_str); return nb_cli_apply_changes(vty, NULL); } @@ -2662,19 +2424,16 @@ DEFPY_YANG(no_isis_hello_interval, no_isis_hello_interval_cmd, "Holdtime 1 second, interval depends on multiplier\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/hello/interval/level-1", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/interval/level-1", NB_OP_MODIFY, + NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/hello/interval/level-2", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/interval/level-2", NB_OP_MODIFY, + NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_hello_interval(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_hello_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *l1 = yang_dnode_get_string(dnode, "level-1"); @@ -2700,13 +2459,11 @@ DEFPY_YANG(isis_hello_multiplier, isis_hello_multiplier_cmd, "Hello multiplier value\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change( - vty, "./frr-isisd:isis/hello/multiplier/level-1", - NB_OP_MODIFY, mult_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/multiplier/level-1", + NB_OP_MODIFY, mult_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change( - vty, "./frr-isisd:isis/hello/multiplier/level-2", - NB_OP_MODIFY, mult_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/multiplier/level-2", + NB_OP_MODIFY, mult_str); return nb_cli_apply_changes(vty, NULL); } @@ -2721,19 +2478,16 @@ DEFPY_YANG(no_isis_hello_multiplier, no_isis_hello_multiplier_cmd, "Hello multiplier value\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change( - vty, "./frr-isisd:isis/hello/multiplier/level-1", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/multiplier/level-1", + NB_OP_MODIFY, NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change( - vty, "./frr-isisd:isis/hello/multiplier/level-2", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/multiplier/level-2", + NB_OP_MODIFY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_hello_multi(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_hello_multi(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *l1 = yang_dnode_get_string(dnode, "level-1"); const char *l2 = yang_dnode_get_string(dnode, "level-2"); @@ -2755,15 +2509,13 @@ DEFPY_YANG(isis_threeway_adj, isis_threeway_adj_cmd, "[no] isis three-way-handsh "IS-IS commands\n" "Enable/Disable three-way handshake\n") { - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/disable-three-way-handshake", - NB_OP_MODIFY, no ? "true" : "false"); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/disable-three-way-handshake", NB_OP_MODIFY, + no ? "true" : "false"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_threeway_shake(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_threeway_shake(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (yang_dnode_get_bool(dnode, NULL)) @@ -2783,21 +2535,20 @@ DEFPY_YANG(isis_hello_padding, isis_hello_padding_cmd, "Add padding to hello packets during adjacency formation only.\n") { if (no) { - nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/padding", - NB_OP_MODIFY, "disabled"); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/padding", NB_OP_MODIFY, + "disabled"); } else { - nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/padding", - NB_OP_MODIFY, + nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/padding", NB_OP_MODIFY, padding_type ? padding_type : "always"); } return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_hello_padding(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_hello_padding(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { int hello_padding_type = yang_dnode_get_enum(dnode, NULL); + if (hello_padding_type == ISIS_HELLO_PADDING_DISABLED) vty_out(vty, " no"); vty_out(vty, " isis hello padding"); @@ -2818,13 +2569,11 @@ DEFPY_YANG(csnp_interval, csnp_interval_cmd, "Specify interval for level-2 CSNPs\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/csnp-interval/level-1", - NB_OP_MODIFY, intv_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/csnp-interval/level-1", NB_OP_MODIFY, + intv_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/csnp-interval/level-2", - NB_OP_MODIFY, intv_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/csnp-interval/level-2", NB_OP_MODIFY, + intv_str); return nb_cli_apply_changes(vty, NULL); } @@ -2839,19 +2588,16 @@ DEFPY_YANG(no_csnp_interval, no_csnp_interval_cmd, "Specify interval for level-2 CSNPs\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/csnp-interval/level-1", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/csnp-interval/level-1", NB_OP_MODIFY, + NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/csnp-interval/level-2", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/csnp-interval/level-2", NB_OP_MODIFY, + NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_csnp_interval(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_csnp_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *l1 = yang_dnode_get_string(dnode, "level-1"); @@ -2877,13 +2623,11 @@ DEFPY_YANG(psnp_interval, psnp_interval_cmd, "Specify interval for level-2 PSNPs\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/psnp-interval/level-1", - NB_OP_MODIFY, intv_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/psnp-interval/level-1", NB_OP_MODIFY, + intv_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/psnp-interval/level-2", - NB_OP_MODIFY, intv_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/psnp-interval/level-2", NB_OP_MODIFY, + intv_str); return nb_cli_apply_changes(vty, NULL); } @@ -2898,19 +2642,16 @@ DEFPY_YANG(no_psnp_interval, no_psnp_interval_cmd, "Specify interval for level-2 PSNPs\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/psnp-interval/level-1", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/psnp-interval/level-1", NB_OP_MODIFY, + NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, - "./frr-isisd:isis/psnp-interval/level-2", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/psnp-interval/level-2", NB_OP_MODIFY, + NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_psnp_interval(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_psnp_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *l1 = yang_dnode_get_string(dnode, "level-1"); @@ -2944,29 +2685,23 @@ DEFPY_YANG(circuit_topology, circuit_topology_cmd, nb_cli_enqueue_change(vty, ".", NB_OP_MODIFY, no ? "false" : "true"); if (strmatch(topology, "ipv4-mgmt")) - return nb_cli_apply_changes( - vty, "./frr-isisd:isis/multi-topology/ipv4-management"); + return nb_cli_apply_changes(vty, "./frr-isisd:isis/multi-topology/ipv4-management"); else if (strmatch(topology, "ipv6-mgmt")) - return nb_cli_apply_changes( - vty, "./frr-isisd:isis/multi-topology/ipv6-management"); + return nb_cli_apply_changes(vty, "./frr-isisd:isis/multi-topology/ipv6-management"); if (strmatch(topology, "ipv4-unicast")) - return nb_cli_apply_changes( - vty, "./frr-isisd:isis/multi-topology/standard"); + return nb_cli_apply_changes(vty, "./frr-isisd:isis/multi-topology/standard"); else - return nb_cli_apply_changes( - vty, "./frr-isisd:isis/multi-topology/%s", topology); + return nb_cli_apply_changes(vty, "./frr-isisd:isis/multi-topology/%s", topology); } -void cli_show_ip_isis_mt_standard(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_mt_standard(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); vty_out(vty, " isis topology standard\n"); } -void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -2974,8 +2709,7 @@ void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, vty_out(vty, " isis topology ipv4-multicast\n"); } -void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -2983,8 +2717,7 @@ void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, vty_out(vty, " isis topology ipv4-mgmt\n"); } -void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -2992,8 +2725,7 @@ void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, vty_out(vty, " isis topology ipv6-unicast\n"); } -void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -3001,8 +2733,7 @@ void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, vty_out(vty, " isis topology ipv6-multicast\n"); } -void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -3010,8 +2741,7 @@ void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, vty_out(vty, " isis topology ipv6-mgmt\n"); } -void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -3030,9 +2760,8 @@ DEFPY_YANG(isis_circuit_type, isis_circuit_type_cmd, "Level-1-2 adjacencies are formed\n" "Level-2 only adjacencies are formed\n") { - nb_cli_enqueue_change( - vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY, - strmatch(type, "level-2-only") ? "level-2" : type); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY, + strmatch(type, "level-2-only") ? "level-2" : type); return nb_cli_apply_changes(vty, NULL); } @@ -3046,14 +2775,12 @@ DEFPY_YANG(no_isis_circuit_type, no_isis_circuit_type_cmd, "Level-1-2 adjacencies are formed\n" "Level-2 only adjacencies are formed\n") { - nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_circ_type(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_circ_type(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { int level = yang_dnode_get_enum(dnode, NULL); @@ -3070,16 +2797,14 @@ void cli_show_ip_isis_circ_type(struct vty *vty, const struct lyd_node *dnode, } } -static int ag_change(struct vty *vty, int argc, struct cmd_token **argv, - const char *xpath_base, bool no, int start_idx) +static int ag_change(struct vty *vty, int argc, struct cmd_token **argv, const char *xpath_base, + bool no, int start_idx) { char xpath[XPATH_MAXLEN]; for (int i = start_idx; i < argc; i++) { - snprintf(xpath, XPATH_MAXLEN, "%s[.='%s']", xpath_base, - argv[i]->arg); - nb_cli_enqueue_change(vty, xpath, - no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); + snprintf(xpath, XPATH_MAXLEN, "%s[.='%s']", xpath_base, argv[i]->arg); + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); } return nb_cli_apply_changes(vty, NULL); } @@ -3101,15 +2826,13 @@ DEFPY_YANG(isis_network, isis_network_cmd, "[no] isis network point-to-point", "Set network type\n" "point-to-point network type\n") { - nb_cli_enqueue_change(vty, "./frr-isisd:isis/network-type", - NB_OP_MODIFY, + nb_cli_enqueue_change(vty, "./frr-isisd:isis/network-type", NB_OP_MODIFY, no ? "broadcast" : "point-to-point"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_network_type(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_network_type(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (yang_dnode_get_enum(dnode, NULL) != CIRCUIT_T_P2P) @@ -3130,11 +2853,11 @@ DEFPY_YANG(isis_priority, isis_priority_cmd, "Specify priority for level-2 routing\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1", - NB_OP_MODIFY, prio_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1", NB_OP_MODIFY, + prio_str); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2", - NB_OP_MODIFY, prio_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2", NB_OP_MODIFY, + prio_str); return nb_cli_apply_changes(vty, NULL); } @@ -3149,17 +2872,14 @@ DEFPY_YANG(no_isis_priority, no_isis_priority_cmd, "Specify priority for level-2 routing\n") { if (!level || strmatch(level, "level-1")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1", NB_OP_MODIFY, NULL); if (!level || strmatch(level, "level-2")) - nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2", - NB_OP_MODIFY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2", NB_OP_MODIFY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_ip_isis_priority(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_priority(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *l1 = yang_dnode_get_string(dnode, "level-1"); const char *l2 = yang_dnode_get_string(dnode, "level-2"); @@ -3175,8 +2895,7 @@ void cli_show_ip_isis_priority(struct vty *vty, const struct lyd_node *dnode, /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/fast-reroute */ -void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { bool l1_enabled, l2_enabled; bool l1_node_protection, l2_node_protection; @@ -3192,11 +2911,9 @@ void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, vty_out(vty, "\n"); } else { if (l1_enabled) - vty_out(vty, - " isis fast-reroute lfa level-1\n"); + vty_out(vty, " isis fast-reroute lfa level-1\n"); if (l2_enabled) - vty_out(vty, - " isis fast-reroute lfa level-2\n"); + vty_out(vty, " isis fast-reroute lfa level-2\n"); } } @@ -3206,8 +2923,7 @@ void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, if (l1_enabled || l2_enabled) { if (l1_enabled == l2_enabled) { - vty_out(vty, - " isis fast-reroute remote-lfa tunnel mpls-ldp\n"); + vty_out(vty, " isis fast-reroute remote-lfa tunnel mpls-ldp\n"); vty_out(vty, "\n"); } else { if (l1_enabled) @@ -3222,20 +2938,15 @@ void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, /* TI-LFA */ l1_enabled = yang_dnode_get_bool(dnode, "level-1/ti-lfa/enable"); l2_enabled = yang_dnode_get_bool(dnode, "level-2/ti-lfa/enable"); - l1_node_protection = - yang_dnode_get_bool(dnode, "level-1/ti-lfa/node-protection"); - l2_node_protection = - yang_dnode_get_bool(dnode, "level-2/ti-lfa/node-protection"); - l1_link_fallback = - yang_dnode_get_bool(dnode, "level-1/ti-lfa/link-fallback"); - l2_link_fallback = - yang_dnode_get_bool(dnode, "level-2/ti-lfa/link-fallback"); + l1_node_protection = yang_dnode_get_bool(dnode, "level-1/ti-lfa/node-protection"); + l2_node_protection = yang_dnode_get_bool(dnode, "level-2/ti-lfa/node-protection"); + l1_link_fallback = yang_dnode_get_bool(dnode, "level-1/ti-lfa/link-fallback"); + l2_link_fallback = yang_dnode_get_bool(dnode, "level-2/ti-lfa/link-fallback"); if (l1_enabled || l2_enabled) { - if (l1_enabled == l2_enabled - && l1_node_protection == l2_node_protection - && l1_link_fallback == l2_link_fallback) { + if (l1_enabled == l2_enabled && l1_node_protection == l2_node_protection && + l1_link_fallback == l2_link_fallback) { vty_out(vty, " isis fast-reroute ti-lfa"); if (l1_node_protection) vty_out(vty, " node-protection"); @@ -3244,8 +2955,7 @@ void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, vty_out(vty, "\n"); } else { if (l1_enabled) { - vty_out(vty, - " isis fast-reroute ti-lfa level-1"); + vty_out(vty, " isis fast-reroute ti-lfa level-1"); if (l1_node_protection) vty_out(vty, " node-protection"); if (l1_link_fallback) @@ -3253,8 +2963,7 @@ void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, vty_out(vty, "\n"); } if (l2_enabled) { - vty_out(vty, - " isis fast-reroute ti-lfa level-2"); + vty_out(vty, " isis fast-reroute ti-lfa level-2"); if (l2_node_protection) vty_out(vty, " node-protection"); if (l2_link_fallback) @@ -3279,28 +2988,24 @@ DEFPY_YANG(isis_lfa, isis_lfa_cmd, { if (!level || strmatch(level, "level-1")) { if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/lfa/enable", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/lfa/enable", + NB_OP_MODIFY, "false"); } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/lfa/enable", - NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/lfa/enable", + NB_OP_MODIFY, "true"); } } if (!level || strmatch(level, "level-2")) { if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/lfa/enable", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/lfa/enable", + NB_OP_MODIFY, "false"); } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/lfa/enable", - NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/lfa/enable", + NB_OP_MODIFY, "true"); } } @@ -3349,13 +3054,11 @@ DEFPY_YANG(isis_lfa_exclude_interface, isis_lfa_exclude_interface_cmd, return nb_cli_apply_changes(vty, NULL); } -void cli_show_frr_lfa_exclude_interface(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_frr_lfa_exclude_interface(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " isis fast-reroute lfa %s exclude interface %s\n", - dnode->parent->parent->schema->name, - yang_dnode_get_string(dnode, NULL)); + dnode->parent->parent->schema->name, yang_dnode_get_string(dnode, NULL)); } /* @@ -3375,28 +3078,24 @@ DEFPY_YANG(isis_remote_lfa, isis_remote_lfa_cmd, { if (!level || strmatch(level, "level-1")) { if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/remote-lfa/enable", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/remote-lfa/enable", + NB_OP_MODIFY, "false"); } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/remote-lfa/enable", - NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/remote-lfa/enable", + NB_OP_MODIFY, "true"); } } if (!level || strmatch(level, "level-2")) { if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/remote-lfa/enable", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/remote-lfa/enable", + NB_OP_MODIFY, "false"); } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/remote-lfa/enable", - NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/remote-lfa/enable", + NB_OP_MODIFY, "true"); } } @@ -3420,41 +3119,35 @@ DEFPY_YANG(isis_remote_lfa_max_metric, isis_remote_lfa_max_metric_cmd, { if (!level || strmatch(level, "level-1")) { if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/remote-lfa/maximum-metric", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/remote-lfa/maximum-metric", + NB_OP_DESTROY, NULL); } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/remote-lfa/maximum-metric", - NB_OP_MODIFY, metric_str); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/remote-lfa/maximum-metric", + NB_OP_MODIFY, metric_str); } } if (!level || strmatch(level, "level-2")) { if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/remote-lfa/maximum-metric", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/remote-lfa/maximum-metric", + NB_OP_DESTROY, NULL); } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/remote-lfa/maximum-metric", - NB_OP_MODIFY, metric_str); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/remote-lfa/maximum-metric", + NB_OP_MODIFY, metric_str); } } return nb_cli_apply_changes(vty, NULL); } -void cli_show_frr_remote_lfa_max_metric(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_frr_remote_lfa_max_metric(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " isis fast-reroute remote-lfa maximum-metric %s %s\n", - yang_dnode_get_string(dnode, NULL), - dnode->parent->parent->schema->name); + yang_dnode_get_string(dnode, NULL), dnode->parent->parent->schema->name); } /* @@ -3473,62 +3166,48 @@ DEFPY_YANG(isis_ti_lfa, isis_ti_lfa_cmd, { if (!level || strmatch(level, "level-1")) { if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/enable", - NB_OP_MODIFY, "false"); - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/node-protection", - NB_OP_MODIFY, "false"); - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/link-fallback", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/enable", + NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/node-protection", + NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/link-fallback", + NB_OP_MODIFY, "false"); } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/enable", - NB_OP_MODIFY, "true"); - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/node-protection", - NB_OP_MODIFY, - node_protection ? "true" : "false"); - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/link-fallback", - NB_OP_MODIFY, link_fallback ? "true" : "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/enable", + NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/node-protection", + NB_OP_MODIFY, node_protection ? "true" : "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-1/ti-lfa/link-fallback", + NB_OP_MODIFY, link_fallback ? "true" : "false"); } } if (!level || strmatch(level, "level-2")) { if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/enable", - NB_OP_MODIFY, "false"); - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/node-protection", - NB_OP_MODIFY, "false"); - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/link-fallback", - NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/enable", + NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/node-protection", + NB_OP_MODIFY, "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/link-fallback", + NB_OP_MODIFY, "false"); } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/enable", - NB_OP_MODIFY, "true"); - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/node-protection", - NB_OP_MODIFY, - node_protection ? "true" : "false"); - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/link-fallback", - NB_OP_MODIFY, link_fallback ? "true" : "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/enable", + NB_OP_MODIFY, "true"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/node-protection", + NB_OP_MODIFY, node_protection ? "true" : "false"); + nb_cli_enqueue_change(vty, + "./frr-isisd:isis/fast-reroute/level-2/ti-lfa/link-fallback", + NB_OP_MODIFY, link_fallback ? "true" : "false"); } } @@ -3541,14 +3220,12 @@ DEFPY_YANG(isis_ti_lfa, isis_ti_lfa_cmd, DEFPY_YANG(log_adj_changes, log_adj_changes_cmd, "[no] log-adjacency-changes", NO_STR "Log changes in adjacency state\n") { - nb_cli_enqueue_change(vty, "./log-adjacency-changes", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./log-adjacency-changes", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_log_adjacency(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_log_adjacency(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); @@ -3561,14 +3238,12 @@ void cli_show_isis_log_adjacency(struct vty *vty, const struct lyd_node *dnode, DEFPY_YANG(log_pdu_drops, log_pdu_drops_cmd, "[no] log-pdu-drops", NO_STR "Log any dropped PDUs\n") { - nb_cli_enqueue_change(vty, "./log-pdu-drops", NB_OP_MODIFY, - no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./log-pdu-drops", NB_OP_MODIFY, no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_log_pdu_drops(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_log_pdu_drops(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) vty_out(vty, " no"); @@ -3594,8 +3269,7 @@ DEFPY_YANG(no_isis_mpls_ldp_sync, no_isis_mpls_ldp_sync_cmd, "no mpls ldp-sync", return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_mpls_ldp_sync(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_mpls_ldp_sync(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " mpls ldp-sync\n"); } @@ -3606,8 +3280,7 @@ DEFPY_YANG(isis_mpls_ldp_sync_holddown, isis_mpls_ldp_sync_holddown_cmd, "Time to wait for LDP-SYNC to occur before restoring interface metric\n" "Time in seconds\n") { - nb_cli_enqueue_change(vty, "./mpls/ldp-sync/holddown", NB_OP_MODIFY, - holddown_str); + nb_cli_enqueue_change(vty, "./mpls/ldp-sync/holddown", NB_OP_MODIFY, holddown_str); return nb_cli_apply_changes(vty, NULL); } @@ -3616,18 +3289,15 @@ DEFPY_YANG(no_isis_mpls_ldp_sync_holddown, no_isis_mpls_ldp_sync_holddown_cmd, "no mpls ldp-sync holddown [<(1-10000)>]", NO_STR MPLS_STR MPLS_LDP_SYNC_STR NO_MPLS_LDP_SYNC_HOLDDOWN_STR "Time in seconds\n") { - nb_cli_enqueue_change(vty, "./mpls/ldp-sync/holddown", NB_OP_DESTROY, - NULL); + nb_cli_enqueue_change(vty, "./mpls/ldp-sync/holddown", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_mpls_ldp_sync_holddown(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mpls_ldp_sync_holddown(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " mpls ldp-sync holddown %s\n", - yang_dnode_get_string(dnode, NULL)); + vty_out(vty, " mpls ldp-sync holddown %s\n", yang_dnode_get_string(dnode, NULL)); } /* @@ -3639,22 +3309,20 @@ DEFPY_YANG(isis_mpls_if_ldp_sync, isis_mpls_if_ldp_sync_cmd, { const struct lyd_node *dnode; - dnode = yang_dnode_getf(vty->candidate_config->dnode, - "%s/frr-isisd:isis", VTY_CURR_XPATH); + dnode = yang_dnode_getf(vty->candidate_config->dnode, "%s/frr-isisd:isis", VTY_CURR_XPATH); if (dnode == NULL) { vty_out(vty, "ISIS is not enabled on this circuit\n"); return CMD_SUCCESS; } - nb_cli_enqueue_change(vty, "./frr-isisd:isis/mpls/ldp-sync", - NB_OP_MODIFY, no ? "false" : "true"); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/mpls/ldp-sync", NB_OP_MODIFY, + no ? "false" : "true"); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_mpls_if_ldp_sync(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mpls_if_ldp_sync(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { if (!yang_dnode_get_bool(dnode, NULL)) @@ -3671,15 +3339,13 @@ DEFPY_YANG(isis_mpls_if_ldp_sync_holddown, isis_mpls_if_ldp_sync_holddown_cmd, { const struct lyd_node *dnode; - dnode = yang_dnode_getf(vty->candidate_config->dnode, - "%s/frr-isisd:isis", VTY_CURR_XPATH); + dnode = yang_dnode_getf(vty->candidate_config->dnode, "%s/frr-isisd:isis", VTY_CURR_XPATH); if (dnode == NULL) { vty_out(vty, "ISIS is not enabled on this circuit\n"); return CMD_SUCCESS; } - nb_cli_enqueue_change(vty, "./frr-isisd:isis/mpls/holddown", - NB_OP_MODIFY, holddown_str); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/mpls/holddown", NB_OP_MODIFY, holddown_str); return nb_cli_apply_changes(vty, NULL); } @@ -3691,25 +3357,21 @@ DEFPY_YANG(no_isis_mpls_if_ldp_sync_holddown, no_isis_mpls_if_ldp_sync_holddown_ { const struct lyd_node *dnode; - dnode = yang_dnode_getf(vty->candidate_config->dnode, - "%s/frr-isisd:isis", VTY_CURR_XPATH); + dnode = yang_dnode_getf(vty->candidate_config->dnode, "%s/frr-isisd:isis", VTY_CURR_XPATH); if (dnode == NULL) { vty_out(vty, "ISIS is not enabled on this circuit\n"); return CMD_SUCCESS; } - nb_cli_enqueue_change(vty, "./frr-isisd:isis/mpls/holddown", - NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./frr-isisd:isis/mpls/holddown", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_mpls_if_ldp_sync_holddown(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mpls_if_ldp_sync_holddown(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_out(vty, " isis mpls ldp-sync holddown %s\n", - yang_dnode_get_string(dnode, NULL)); + vty_out(vty, " isis mpls ldp-sync holddown %s\n", yang_dnode_get_string(dnode, NULL)); } DEFPY_YANG_NOSH(flex_algo, flex_algo_cmd, "flex-algo (128-255)$algorithm", @@ -3757,8 +3419,7 @@ DEFPY_YANG(advertise_definition, advertise_definition_cmd, "[no] advertise-definition", NO_STR "Advertise Local Flexible Algorithm\n") { - nb_cli_enqueue_change(vty, "./advertise-definition", - no ? NB_OP_DESTROY : NB_OP_CREATE, + nb_cli_enqueue_change(vty, "./advertise-definition", no ? NB_OP_DESTROY : NB_OP_CREATE, no ? NULL : "true"); return nb_cli_apply_changes(vty, NULL); } @@ -3802,8 +3463,7 @@ DEFPY_YANG(affinity_exclude_any, affinity_exclude_any_cmd, DEFPY_YANG(prefix_metric, prefix_metric_cmd, "[no] prefix-metric", NO_STR "Use Flex-Algo Prefix Metric\n") { - nb_cli_enqueue_change(vty, "./prefix-metric", - no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); + nb_cli_enqueue_change(vty, "./prefix-metric", no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -3812,8 +3472,7 @@ DEFPY_YANG(dplane_sr_mpls, dplane_sr_mpls_cmd, "[no] dataplane sr-mpls", "Advertise and participate in the specified Data-Planes\n" "Advertise and participate in SR-MPLS data-plane\n") { - nb_cli_enqueue_change(vty, "./dplane-sr-mpls", - no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); + nb_cli_enqueue_change(vty, "./dplane-sr-mpls", no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -3822,9 +3481,7 @@ DEFPY_HIDDEN(dplane_srv6, dplane_srv6_cmd, "[no] dataplane srv6", "Advertise and participate in the specified Data-Planes\n" "Advertise and participate in SRv6 data-plane\n") { - - nb_cli_enqueue_change(vty, "./dplane-srv6", - no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); + nb_cli_enqueue_change(vty, "./dplane-srv6", no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -3833,8 +3490,7 @@ DEFPY_HIDDEN(dplane_ip, dplane_ip_cmd, "[no] dataplane ip", "Advertise and participate in the specified Data-Planes\n" "Advertise and participate in IP data-plane\n") { - nb_cli_enqueue_change(vty, "./dplane-ip", - no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); + nb_cli_enqueue_change(vty, "./dplane-ip", no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -3865,8 +3521,7 @@ DEFPY_YANG(metric_type, metric_type_cmd, "However, participation in a Flex-Algorithm with such a metric is not yet supported.\n", type); - nb_cli_enqueue_change(vty, "./metric-type", - no ? NB_OP_DESTROY : NB_OP_MODIFY, + nb_cli_enqueue_change(vty, "./metric-type", no ? NB_OP_DESTROY : NB_OP_MODIFY, no ? NULL : type); return nb_cli_apply_changes(vty, NULL); } @@ -3876,14 +3531,12 @@ DEFPY_YANG(priority, priority_cmd, "[no] priority (0-255)$priority", "Flex-Algo definition priority\n" "Priority value\n") { - nb_cli_enqueue_change(vty, "./priority", - no ? NB_OP_DESTROY : NB_OP_MODIFY, + nb_cli_enqueue_change(vty, "./priority", no ? NB_OP_DESTROY : NB_OP_MODIFY, no ? NULL : priority_str); return nb_cli_apply_changes(vty, NULL); } -void cli_show_isis_flex_algo(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults) +void cli_show_isis_flex_algo(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { uint32_t algorithm; enum flex_algo_metric_type metric_type; @@ -3909,8 +3562,7 @@ void cli_show_isis_flex_algo(struct vty *vty, const struct lyd_node *dnode, if (yang_dnode_exists(dnode, "metric-type")) { metric_type = yang_dnode_get_enum(dnode, "metric-type"); if (metric_type != MT_IGP) { - flex_algo_metric_type_print(type_str, sizeof(type_str), - metric_type); + flex_algo_metric_type_print(type_str, sizeof(type_str), metric_type); vty_out(vty, " metric-type %s\n", type_str); } } @@ -3921,30 +3573,24 @@ void cli_show_isis_flex_algo(struct vty *vty, const struct lyd_node *dnode, vty_out(vty, " priority %u\n", priority); } - if (yang_dnode_exists(dnode, - "./affinity-include-alls/affinity-include-all")) { + if (yang_dnode_exists(dnode, "./affinity-include-alls/affinity-include-all")) { vty_out(vty, " affinity include-all"); - yang_dnode_iterate( - ag_iter_cb, vty, dnode, - "./affinity-include-alls/affinity-include-all"); + yang_dnode_iterate(ag_iter_cb, vty, dnode, + "./affinity-include-alls/affinity-include-all"); vty_out(vty, "\n"); } - if (yang_dnode_exists( - dnode, "./affinity-include-anies/affinity-include-any")) { + if (yang_dnode_exists(dnode, "./affinity-include-anies/affinity-include-any")) { vty_out(vty, " affinity include-any"); - yang_dnode_iterate( - ag_iter_cb, vty, dnode, - "./affinity-include-anies/affinity-include-any"); + yang_dnode_iterate(ag_iter_cb, vty, dnode, + "./affinity-include-anies/affinity-include-any"); vty_out(vty, "\n"); } - if (yang_dnode_exists( - dnode, "./affinity-exclude-anies/affinity-exclude-any")) { + if (yang_dnode_exists(dnode, "./affinity-exclude-anies/affinity-exclude-any")) { vty_out(vty, " affinity exclude-any"); - yang_dnode_iterate( - ag_iter_cb, vty, dnode, - "./affinity-exclude-anies/affinity-exclude-any"); + yang_dnode_iterate(ag_iter_cb, vty, dnode, + "./affinity-exclude-anies/affinity-exclude-any"); vty_out(vty, "\n"); } } @@ -4055,14 +3701,10 @@ void isis_cli_init(void) install_element(ISIS_SRV6_NODE, &isis_srv6_locator_cmd); install_element(ISIS_SRV6_NODE, &isis_srv6_node_msd_cmd); install_element(ISIS_SRV6_NODE, &isis_srv6_interface_cmd); - install_element(ISIS_SRV6_NODE_MSD_NODE, - &isis_srv6_node_msd_max_segs_left_cmd); - install_element(ISIS_SRV6_NODE_MSD_NODE, - &isis_srv6_node_msd_max_end_pop_cmd); - install_element(ISIS_SRV6_NODE_MSD_NODE, - &isis_srv6_node_msd_max_h_encaps_cmd); - install_element(ISIS_SRV6_NODE_MSD_NODE, - &isis_srv6_node_msd_max_end_d_cmd); + install_element(ISIS_SRV6_NODE_MSD_NODE, &isis_srv6_node_msd_max_segs_left_cmd); + install_element(ISIS_SRV6_NODE_MSD_NODE, &isis_srv6_node_msd_max_end_pop_cmd); + install_element(ISIS_SRV6_NODE_MSD_NODE, &isis_srv6_node_msd_max_h_encaps_cmd); + install_element(ISIS_SRV6_NODE_MSD_NODE, &isis_srv6_node_msd_max_end_d_cmd); install_element(INTERFACE_NODE, &isis_passive_cmd); diff --git a/isisd/isis_flex_algo.c b/isisd/isis_flex_algo.c index fbe249ab5abd..d603a052a4e8 100644 --- a/isisd/isis_flex_algo.c +++ b/isisd/isis_flex_algo.c @@ -51,10 +51,10 @@ void *isis_flex_algo_data_alloc(void *voidarg) for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) { if (!(arg->area->is_type & level)) continue; - data->spftree[tree][level - 1] = isis_spftree_new( - arg->area, &arg->area->lspdb[level - 1], - arg->area->isis->sysid, level, tree, - SPF_TYPE_FORWARD, 0, arg->algorithm); + data->spftree[tree][level - 1] = + isis_spftree_new(arg->area, &arg->area->lspdb[level - 1], + arg->area->isis->sysid, level, tree, + SPF_TYPE_FORWARD, 0, arg->algorithm); } } @@ -68,14 +68,12 @@ void isis_flex_algo_data_free(void *voiddata) for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) if (data->spftree[tree][level - 1]) - isis_spftree_del( - data->spftree[tree][level - 1]); + isis_spftree_del(data->spftree[tree][level - 1]); XFREE(MTYPE_FLEX_ALGO, data); } static struct isis_router_cap_fad * -isis_flex_algo_definition_cmp(struct isis_router_cap_fad *elected, - struct isis_router_cap_fad *fa) +isis_flex_algo_definition_cmp(struct isis_router_cap_fad *elected, struct isis_router_cap_fad *fa) { if (!elected || fa->fad.priority > elected->fad.priority || (fa->fad.priority == elected->fad.priority && @@ -100,9 +98,9 @@ isis_flex_algo_definition_cmp(struct isis_router_cap_fad *elected, * local definition from LSDB for the election. * @return elected flex-algo-definition object if exist, else NULL */ -static struct isis_router_cap_fad * -_isis_flex_algo_elected(int algorithm, const struct isis_area *area, - struct isis_router_cap_fad **fad) +static struct isis_router_cap_fad *_isis_flex_algo_elected(int algorithm, + const struct isis_area *area, + struct isis_router_cap_fad **fad) { struct flex_algo *flex_ago; const struct isis_lsp *lsp; @@ -152,8 +150,7 @@ _isis_flex_algo_elected(int algorithm, const struct isis_area *area, return elected; } -struct isis_router_cap_fad *isis_flex_algo_elected(int algorithm, - const struct isis_area *area) +struct isis_router_cap_fad *isis_flex_algo_elected(int algorithm, const struct isis_area *area) { return _isis_flex_algo_elected(algorithm, area, NULL); } @@ -203,15 +200,14 @@ _isis_flex_algo_elected_supported(int algorithm, const struct isis_area *area, return NULL; } -struct isis_router_cap_fad * -isis_flex_algo_elected_supported(int algorithm, const struct isis_area *area) +struct isis_router_cap_fad *isis_flex_algo_elected_supported(int algorithm, + const struct isis_area *area) { return _isis_flex_algo_elected_supported(algorithm, area, NULL); } struct isis_router_cap_fad * -isis_flex_algo_elected_supported_local_fad(int algorithm, - const struct isis_area *area, +isis_flex_algo_elected_supported_local_fad(int algorithm, const struct isis_area *area, struct isis_router_cap_fad **fad) { return _isis_flex_algo_elected_supported(algorithm, area, fad); @@ -235,8 +231,7 @@ bool sr_algorithm_participated(const struct isis_lsp *lsp, uint8_t algorithm) return false; } -bool isis_flex_algo_constraint_drop(struct isis_spftree *spftree, - struct isis_lsp *lsp, +bool isis_flex_algo_constraint_drop(struct isis_spftree *spftree, struct isis_lsp *lsp, struct isis_extended_reach *reach) { bool ret; @@ -248,8 +243,7 @@ bool isis_flex_algo_constraint_drop(struct isis_spftree *spftree, uint32_t link_ext_admin_group_bitmap0; struct admin_group *link_ext_admin_group = NULL; - fad = isis_flex_algo_elected_supported(spftree->algorithm, - spftree->area); + fad = isis_flex_algo_elected_supported(spftree->algorithm, spftree->area); if (!fad) return true; @@ -261,10 +255,8 @@ bool isis_flex_algo_constraint_drop(struct isis_spftree *spftree, link_admin_group = &subtlvs->adm_group; if (IS_SUBTLV(subtlvs, EXT_EXTEND_ADM_GRP) && - admin_group_nb_words(&subtlvs->ext_admin_group) != - 0) - link_ext_admin_group = - &subtlvs->ext_admin_group; + admin_group_nb_words(&subtlvs->ext_admin_group) != 0) + link_ext_admin_group = &subtlvs->ext_admin_group; } else { if (IS_SUBTLV(asla, EXT_ADM_GRP)) link_admin_group = &asla->admin_group; @@ -280,21 +272,18 @@ bool isis_flex_algo_constraint_drop(struct isis_spftree *spftree, * bits of the EAG SHOULD report this mismatch to the operator. */ if (link_admin_group && link_ext_admin_group) { - link_ext_admin_group_bitmap0 = - admin_group_get_offset(link_ext_admin_group, 0); + link_ext_admin_group_bitmap0 = admin_group_get_offset(link_ext_admin_group, 0); if (*link_admin_group != link_ext_admin_group_bitmap0) - zlog_warn( - "ISIS-SPF: LSP from %pPN neighbor %pPN. Admin-group 0x%08x differs from ext admin-group 0x%08x.", - lsp->hdr.lsp_id, reach->id, *link_admin_group, - link_ext_admin_group_bitmap0); + zlog_warn("ISIS-SPF: LSP from %pPN neighbor %pPN. Admin-group 0x%08x differs from ext admin-group 0x%08x.", + lsp->hdr.lsp_id, reach->id, *link_admin_group, + link_ext_admin_group_bitmap0); } /* * Exclude Any */ if (!admin_group_zero(&fad->fad.admin_group_exclude_any)) { - ret = admin_group_match_any(&fad->fad.admin_group_exclude_any, - link_admin_group, + ret = admin_group_match_any(&fad->fad.admin_group_exclude_any, link_admin_group, link_ext_admin_group); if (ret) return true; @@ -304,8 +293,7 @@ bool isis_flex_algo_constraint_drop(struct isis_spftree *spftree, * Include Any */ if (!admin_group_zero(&fad->fad.admin_group_include_any)) { - ret = admin_group_match_any(&fad->fad.admin_group_include_any, - link_admin_group, + ret = admin_group_match_any(&fad->fad.admin_group_include_any, link_admin_group, link_ext_admin_group); if (!ret) return true; @@ -315,8 +303,7 @@ bool isis_flex_algo_constraint_drop(struct isis_spftree *spftree, * Include All */ if (!admin_group_zero(&fad->fad.admin_group_include_all)) { - ret = admin_group_match_all(&fad->fad.admin_group_include_all, - link_admin_group, + ret = admin_group_match_all(&fad->fad.admin_group_include_all, link_admin_group, link_ext_admin_group); if (!ret) return true; diff --git a/isisd/isis_ldp_sync.c b/isisd/isis_ldp_sync.c index 40b85a0c963c..d3bcd8669f78 100644 --- a/isisd/isis_ldp_sync.c +++ b/isisd/isis_ldp_sync.c @@ -81,7 +81,6 @@ int isis_ldp_sync_state_update(struct ldp_igp_sync_if_state state) int isis_ldp_sync_announce_update(struct ldp_igp_sync_announce announce) { struct isis_area *area; - struct listnode *anode, *cnode; struct isis_circuit *circuit; struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); @@ -98,11 +97,11 @@ int isis_ldp_sync_announce_update(struct ldp_igp_sync_announce announce) * set cost to LSInfinity * send request to LDP for LDP-SYNC state for each interface */ - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_area_list, &isis->area_list, area) { if (!CHECK_FLAG(area->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) continue; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) isis_ldp_sync_if_start(circuit, true); } @@ -382,7 +381,6 @@ void isis_ldp_sync_holddown_timer_add(struct isis_circuit *circuit) void isis_ldp_sync_handle_client_close(struct zapi_client_close_info *info) { struct isis_area *area; - struct listnode *anode, *cnode; struct isis_circuit *circuit; struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); @@ -400,11 +398,11 @@ void isis_ldp_sync_handle_client_close(struct zapi_client_close_info *info) */ zlog_err("%s: LDP down", __func__); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_area_list, &isis->area_list, area) { if (!CHECK_FLAG(area->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) continue; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) isis_ldp_sync_ldp_fail(circuit); } } @@ -416,12 +414,11 @@ void isis_ldp_sync_handle_client_close(struct zapi_client_close_info *info) void isis_area_ldp_sync_enable(struct isis_area *area) { struct isis_circuit *circuit; - struct listnode *node; if (!CHECK_FLAG(area->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) { SET_FLAG(area->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE); - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) isis_if_ldp_sync_enable(circuit); } } @@ -429,10 +426,9 @@ void isis_area_ldp_sync_enable(struct isis_area *area) void isis_area_ldp_sync_disable(struct isis_area *area) { struct isis_circuit *circuit; - struct listnode *node; if (CHECK_FLAG(area->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) { - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) isis_if_ldp_sync_disable(circuit); UNSET_FLAG(area->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE); @@ -445,7 +441,6 @@ void isis_area_ldp_sync_disable(struct isis_area *area) void isis_area_ldp_sync_set_holddown(struct isis_area *area, uint16_t holddown) { struct isis_circuit *circuit; - struct listnode *node; if (holddown == LDP_IGP_SYNC_HOLDDOWN_DEFAULT) UNSET_FLAG(area->ldp_sync_cmd.flags, LDP_SYNC_FLAG_HOLDDOWN); @@ -454,7 +449,7 @@ void isis_area_ldp_sync_set_holddown(struct isis_area *area, uint16_t holddown) area->ldp_sync_cmd.holddown = holddown; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) isis_if_set_ldp_sync_holddown(circuit); } @@ -611,7 +606,6 @@ DEFUN (show_isis_mpls_ldp_interface, { char *ifname = NULL; int idx_intf = 0; - struct listnode *anode, *cnode; struct isis_area *area; struct isis_circuit *circuit; struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); @@ -625,8 +619,8 @@ DEFUN (show_isis_mpls_ldp_interface, if (argv_find(argv, argc, "INTERFACE", &idx_intf)) ifname = argv[idx_intf]->arg; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) + frr_each (isis_area_list, &isis->area_list, area) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) if (!ifname) isis_circuit_ldp_sync_print_vty(circuit, vty); else if (strcmp(circuit->interface->name, ifname) diff --git a/isisd/isis_lfa.c b/isisd/isis_lfa.c index 5869cdd56562..3f395d3d62e9 100644 --- a/isisd/isis_lfa.c +++ b/isisd/isis_lfa.c @@ -82,8 +82,7 @@ void isis_spf_node_list_clear(struct isis_spf_nodes *nodes) * * @return Pointer to new IS-IS SPF node structure. */ -struct isis_spf_node *isis_spf_node_new(struct isis_spf_nodes *nodes, - const uint8_t *sysid) +struct isis_spf_node *isis_spf_node_new(struct isis_spf_nodes *nodes, const uint8_t *sysid) { struct isis_spf_node *node; @@ -104,8 +103,7 @@ struct isis_spf_node *isis_spf_node_new(struct isis_spf_nodes *nodes, * * @return Pointer to SPF node if found, NULL otherwise */ -struct isis_spf_node *isis_spf_node_find(const struct isis_spf_nodes *nodes, - const uint8_t *sysid) +struct isis_spf_node *isis_spf_node_find(const struct isis_spf_nodes *nodes, const uint8_t *sysid) { struct isis_spf_node node = {}; @@ -121,8 +119,7 @@ struct isis_spf_node *isis_spf_node_find(const struct isis_spf_nodes *nodes, * * @return -1 (a < b), 0 (a == b) or +1 (a > b) */ -int lfa_tiebreaker_cmp(const struct lfa_tiebreaker *a, - const struct lfa_tiebreaker *b) +int lfa_tiebreaker_cmp(const struct lfa_tiebreaker *a, const struct lfa_tiebreaker *b) { if (a->index < b->index) return -1; @@ -151,12 +148,10 @@ void isis_lfa_tiebreakers_init(struct isis_area *area, int level) */ void isis_lfa_tiebreakers_clear(struct isis_area *area, int level) { - while (lfa_tiebreaker_tree_count(&area->lfa_tiebreakers[level - 1]) - > 0) { + while (lfa_tiebreaker_tree_count(&area->lfa_tiebreakers[level - 1]) > 0) { struct lfa_tiebreaker *tie_b; - tie_b = lfa_tiebreaker_tree_first( - &area->lfa_tiebreakers[level - 1]); + tie_b = lfa_tiebreaker_tree_first(&area->lfa_tiebreakers[level - 1]); isis_lfa_tiebreaker_delete(area, level, tie_b); } } @@ -171,8 +166,7 @@ void isis_lfa_tiebreakers_clear(struct isis_area *area, int level) * * @return Pointer to new LFA tie-breaker structure. */ -struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area, - int level, uint8_t index, +struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area, int level, uint8_t index, enum lfa_tiebreaker_type type) { struct lfa_tiebreaker *tie_b; @@ -193,8 +187,7 @@ struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area, * @param level IS-IS level * @param tie_b Pointer to LFA tie-breaker structure */ -void isis_lfa_tiebreaker_delete(struct isis_area *area, int level, - struct lfa_tiebreaker *tie_b) +void isis_lfa_tiebreaker_delete(struct isis_area *area, int level, struct lfa_tiebreaker *tie_b) { lfa_tiebreaker_tree_del(&area->lfa_tiebreakers[level - 1], tie_b); XFREE(MTYPE_ISIS_LFA_TIEBREAKER, tie_b); @@ -228,9 +221,9 @@ static void lfa_excl_interface_hash_free(void *arg) */ void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level) { - circuit->lfa_excluded_ifaces[level - 1] = hash_create( - lfa_excl_interface_hash_make, lfa_excl_interface_hash_cmp, - "LFA Excluded Interfaces"); + circuit->lfa_excluded_ifaces[level - 1] = hash_create(lfa_excl_interface_hash_make, + lfa_excl_interface_hash_cmp, + "LFA Excluded Interfaces"); } /** @@ -240,8 +233,7 @@ void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level) */ void isis_lfa_excluded_ifaces_delete(struct isis_circuit *circuit, int level) { - hash_clean_and_free(&circuit->lfa_excluded_ifaces[level - 1], - lfa_excl_interface_hash_free); + hash_clean_and_free(&circuit->lfa_excluded_ifaces[level - 1], lfa_excl_interface_hash_free); } /** @@ -251,8 +243,7 @@ void isis_lfa_excluded_ifaces_delete(struct isis_circuit *circuit, int level) * @param level IS-IS level * @param ifname Excluded interface name */ -void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level, - const char *ifname) +void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level, const char *ifname) { (void)hash_get(circuit->lfa_excluded_ifaces[level - 1], (char *)ifname, lfa_excl_interface_hash_alloc); @@ -265,13 +256,11 @@ void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level, * @param level IS-IS level * @param ifname Excluded interface name */ -void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level, - const char *ifname) +void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level, const char *ifname) { char *found; - found = hash_lookup(circuit->lfa_excluded_ifaces[level - 1], - (char *)ifname); + found = hash_lookup(circuit->lfa_excluded_ifaces[level - 1], (char *)ifname); if (found) { hash_release(circuit->lfa_excluded_ifaces[level - 1], found); lfa_excl_interface_hash_free(found); @@ -285,11 +274,9 @@ void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level, * @param level IS-IS level * @param ifname Excluded interface name */ -bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level, - const char *ifname) +bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level, const char *ifname) { - return hash_lookup(circuit->lfa_excluded_ifaces[level - 1], - (char *)ifname); + return hash_lookup(circuit->lfa_excluded_ifaces[level - 1], (char *)ifname); } /** @@ -303,8 +290,7 @@ bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level, * @return true if the adjacency needs to be excised, false * otherwise */ -bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree, - const uint8_t *id) +bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree, const uint8_t *id) { const struct lfa_protected_resource *resource; @@ -331,8 +317,7 @@ bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree, * * @return true if the node needs to be excised, false otherwise */ -bool isis_lfa_excise_node_check(const struct isis_spftree *spftree, - const uint8_t *id) +bool isis_lfa_excise_node_check(const struct isis_spftree *spftree, const uint8_t *id) { const struct lfa_protected_resource *resource; @@ -358,10 +343,8 @@ struct tilfa_find_pnode_prefix_sid_args { int algorithm; }; -static int tilfa_find_pnode_prefix_sid_cb(const struct prefix *prefix, - uint32_t metric, bool external, - struct isis_subtlvs *subtlvs, - void *arg) +static int tilfa_find_pnode_prefix_sid_cb(const struct prefix *prefix, uint32_t metric, + bool external, struct isis_subtlvs *subtlvs, void *arg) { struct tilfa_find_pnode_prefix_sid_args *args = arg; struct isis_prefix_sid *psid; @@ -369,8 +352,7 @@ static int tilfa_find_pnode_prefix_sid_cb(const struct prefix *prefix, if (!subtlvs || subtlvs->prefix_sids.count == 0) return LSP_ITER_CONTINUE; - for (psid = (struct isis_prefix_sid *)subtlvs->prefix_sids.head; psid; - psid = psid->next) { + for (psid = (struct isis_prefix_sid *)subtlvs->prefix_sids.head; psid; psid = psid->next) { /* Require the node flag to be set. */ if (!CHECK_FLAG(psid->flags, ISIS_PREFIX_SID_NODE)) continue; @@ -383,8 +365,7 @@ static int tilfa_find_pnode_prefix_sid_cb(const struct prefix *prefix, } /* Find Prefix-SID associated to a System ID. */ -static uint32_t tilfa_find_pnode_prefix_sid(struct isis_spftree *spftree, - const uint8_t *sysid) +static uint32_t tilfa_find_pnode_prefix_sid(struct isis_spftree *spftree, const uint8_t *sysid) { struct isis_lsp *lsp; struct tilfa_find_pnode_prefix_sid_args args; @@ -407,10 +388,8 @@ struct tilfa_find_qnode_adj_sid_args { mpls_label_t label; }; -static int tilfa_find_qnode_adj_sid_cb(const uint8_t *id, uint32_t metric, - bool oldmetric, - struct isis_ext_subtlvs *subtlvs, - void *arg) +static int tilfa_find_qnode_adj_sid_cb(const uint8_t *id, uint32_t metric, bool oldmetric, + struct isis_ext_subtlvs *subtlvs, void *arg) { struct tilfa_find_qnode_adj_sid_args *args = arg; struct isis_adj_sid *adj_sid; @@ -440,8 +419,7 @@ static mpls_label_t tilfa_find_qnode_adj_sid(struct isis_spftree *spftree, args.qnode_sysid = qnode_sysid; args.label = MPLS_INVALID_LABEL; - isis_lsp_iterate_is_reach(lsp, spftree->mtid, - tilfa_find_qnode_adj_sid_cb, &args); + isis_lsp_iterate_is_reach(lsp, spftree->mtid, tilfa_find_qnode_adj_sid_cb, &args); return args.label; } @@ -451,10 +429,9 @@ static mpls_label_t tilfa_find_qnode_adj_sid(struct isis_spftree *spftree, * needs to be computed separately for each adjacency since different * neighbors can have different SRGBs. */ -static struct mpls_label_stack * -tilfa_compute_label_stack(struct lspdb_head *lspdb, - const struct isis_spf_adj *sadj, - const struct list *repair_list) +static struct mpls_label_stack *tilfa_compute_label_stack(struct lspdb_head *lspdb, + const struct isis_spf_adj *sadj, + const struct list *repair_list) { struct mpls_label_stack *label_stack; struct isis_tilfa_sid *sid; @@ -463,9 +440,8 @@ tilfa_compute_label_stack(struct lspdb_head *lspdb, /* Allocate label stack. */ label_stack = XCALLOC(MTYPE_ISIS_NEXTHOP_LABELS, - sizeof(struct mpls_label_stack) - + listcount(repair_list) - * sizeof(mpls_label_t)); + sizeof(struct mpls_label_stack) + + listcount(repair_list) * sizeof(mpls_label_t)); label_stack->num_labels = listcount(repair_list); for (ALL_LIST_ELEMENTS_RO(repair_list, node, sid)) { @@ -481,18 +457,16 @@ tilfa_compute_label_stack(struct lspdb_head *lspdb, target_node = sadj->id; srgb = isis_sr_find_srgb(lspdb, target_node); if (!srgb) { - zlog_warn("%s: SRGB not found for node %s", - __func__, + zlog_warn("%s: SRGB not found for node %s", __func__, print_sys_hostname(target_node)); goto error; } /* Check if the SID index falls inside the SRGB. */ if (sid->value.index.value >= srgb->range_size) { - flog_warn( - EC_ISIS_SID_OVERFLOW, - "%s: SID index %u falls outside remote SRGB range", - __func__, sid->value.index.value); + flog_warn(EC_ISIS_SID_OVERFLOW, + "%s: SID index %u falls outside remote SRGB range", + __func__, sid->value.index.value); goto error; } @@ -507,8 +481,7 @@ tilfa_compute_label_stack(struct lspdb_head *lspdb, label = sid->value.label; break; default: - flog_err(EC_LIB_DEVELOPMENT, - "%s: unknown TI-LFA SID type [%u]", __func__, + flog_err(EC_LIB_DEVELOPMENT, "%s: unknown TI-LFA SID type [%u]", __func__, sid->type); exit(1); } @@ -522,8 +495,7 @@ tilfa_compute_label_stack(struct lspdb_head *lspdb, return NULL; } -static int tilfa_repair_list_apply(struct isis_spftree *spftree, - struct isis_vertex *vertex_dest, +static int tilfa_repair_list_apply(struct isis_spftree *spftree, struct isis_vertex *vertex_dest, const struct isis_vertex *vertex_pnode, const struct list *repair_list) { @@ -544,16 +516,14 @@ static int tilfa_repair_list_apply(struct isis_spftree *spftree, if (!isis_vertex_adj_exists(spftree, vertex_pnode, sadj)) continue; - label_stack = tilfa_compute_label_stack(spftree->lspdb, sadj, - repair_list); + label_stack = tilfa_compute_label_stack(spftree->lspdb, sadj, repair_list); if (!label_stack) { char buf[VID2STR_BUFFER]; vid2string(vertex_dest, buf, sizeof(buf)); - zlog_warn( - "%s: %s %s adjacency %s: failed to compute label stack", - __func__, vtype2string(vertex_dest->type), buf, - print_sys_hostname(sadj->id)); + zlog_warn("%s: %s %s adjacency %s: failed to compute label stack", + __func__, vtype2string(vertex_dest->type), buf, + print_sys_hostname(sadj->id)); return -1; } @@ -587,8 +557,7 @@ static bool lfa_ext_p_space_check(const struct isis_spftree *spftree_pc, struct isis_spf_adj *sadj = vadj->sadj; struct isis_spf_node *adj_node; - adj_node = - isis_spf_node_find(&spftree_old->adj_nodes, sadj->id); + adj_node = isis_spf_node_find(&spftree_old->adj_nodes, sadj->id); if (!adj_node) continue; @@ -607,12 +576,10 @@ static bool lfa_q_space_check(const struct isis_spftree *spftree_pc, } /* This is a recursive function. */ -static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, - struct isis_vertex *vertex_dest, +static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, struct isis_vertex *vertex_dest, const struct isis_vertex *vertex, const struct isis_vertex *vertex_child, - struct isis_spf_nodes *used_pnodes, - struct list *repair_list) + struct isis_spf_nodes *used_pnodes, struct list *repair_list) { struct isis_vertex *pvertex; struct listnode *node; @@ -624,8 +591,7 @@ static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, if (IS_DEBUG_LFA) { vid2string(vertex, buf, sizeof(buf)); - zlog_debug("ISIS-LFA: vertex %s %s", vtype2string(vertex->type), - buf); + zlog_debug("ISIS-LFA: vertex %s %s", vtype2string(vertex->type), buf); } /* Push original Prefix-SID label when necessary. */ @@ -635,9 +601,8 @@ static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, sid_index = vertex->N.ip.sr.sid.value; if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: pushing Prefix-SID to %pFX (index %u)", - &vertex->N.ip.p.dest, sid_index); + zlog_debug("ISIS-LFA: pushing Prefix-SID to %pFX (index %u)", + &vertex->N.ip.p.dest, sid_index); sid_dest.type = TILFA_SID_PREFIX; sid_dest.value.index.value = sid_index; sid_dest.value.index.remote = true; @@ -648,8 +613,7 @@ static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, if (!vertex_child) goto parents; - if (vertex->type != VTYPE_NONPSEUDO_IS - && vertex->type != VTYPE_NONPSEUDO_TE_IS) + if (vertex->type != VTYPE_NONPSEUDO_IS && vertex->type != VTYPE_NONPSEUDO_TE_IS) goto parents; if (!VTYPE_IS(vertex_child->type)) vertex_child = NULL; @@ -659,9 +623,8 @@ static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, is_qnode = lfa_q_space_check(spftree_pc, vertex); /* Push Adj-SID label when necessary. */ - if ((!is_qnode - || spftree_pc->lfa.protected_resource.type == LFA_NODE_PROTECTION) - && vertex_child) { + if ((!is_qnode || spftree_pc->lfa.protected_resource.type == LFA_NODE_PROTECTION) && + vertex_child) { /* * If vertex is the penultimate hop router, then pushing an * Adj-SID towards the final hop means that the No-PHP flag of @@ -669,11 +632,9 @@ static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, * removing the previously added Prefix-SID from the repair list * when those conditions are met. */ - if (vertex->depth == (vertex_dest->depth - 2) - && VTYPE_IP(vertex_dest->type) - && vertex_dest->N.ip.sr.present - && !CHECK_FLAG(vertex_dest->N.ip.sr.sid.flags, - ISIS_PREFIX_SID_NO_PHP)) { + if (vertex->depth == (vertex_dest->depth - 2) && VTYPE_IP(vertex_dest->type) && + vertex_dest->N.ip.sr.present && + !CHECK_FLAG(vertex_dest->N.ip.sr.sid.flags, ISIS_PREFIX_SID_NO_PHP)) { list_delete_all_node(repair_list); } @@ -686,11 +647,9 @@ static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, return -1; } if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: pushing %s->%s Adj-SID (label %u)", - print_sys_hostname(vertex->N.id), - print_sys_hostname(vertex_child->N.id), - label_qnode); + zlog_debug("ISIS-LFA: pushing %s->%s Adj-SID (label %u)", + print_sys_hostname(vertex->N.id), + print_sys_hostname(vertex_child->N.id), label_qnode); sid_qnode.type = TILFA_SID_ADJ; sid_qnode.value.label = label_qnode; listnode_add_head(repair_list, &sid_qnode); @@ -701,49 +660,39 @@ static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, /* The same P-node can't be used more than once. */ if (isis_spf_node_find(used_pnodes, vertex->N.id)) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: skipping already used P-node"); + zlog_debug("ISIS-LFA: skipping already used P-node"); return 0; } isis_spf_node_new(used_pnodes, vertex->N.id); if (!vertex_child) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: destination is within Ext-P-Space"); + zlog_debug("ISIS-LFA: destination is within Ext-P-Space"); return 0; } - sid_index = - tilfa_find_pnode_prefix_sid(spftree_pc, vertex->N.id); + sid_index = tilfa_find_pnode_prefix_sid(spftree_pc, vertex->N.id); if (sid_index == UINT32_MAX) { - zlog_warn( - "ISIS-LFA: failed to find Prefix-SID corresponding to PQ-node %s", - print_sys_hostname(vertex->N.id)); + zlog_warn("ISIS-LFA: failed to find Prefix-SID corresponding to PQ-node %s", + print_sys_hostname(vertex->N.id)); return -1; } if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: pushing Node-SID to %s (index %u)", - print_sys_hostname(vertex->N.id), sid_index); + zlog_debug("ISIS-LFA: pushing Node-SID to %s (index %u)", + print_sys_hostname(vertex->N.id), sid_index); sid_pnode.type = TILFA_SID_PREFIX; sid_pnode.value.index.value = sid_index; listnode_add_head(repair_list, &sid_pnode); /* Apply repair list. */ - if (spftree_pc->area->srdb.config.msd - && listcount(repair_list) - > spftree_pc->area->srdb.config.msd) { - zlog_warn( - "ISIS-LFA: list of repair segments exceeds locally configured MSD (%u > %u)", - listcount(repair_list), - spftree_pc->area->srdb.config.msd); + if (spftree_pc->area->srdb.config.msd && + listcount(repair_list) > spftree_pc->area->srdb.config.msd) { + zlog_warn("ISIS-LFA: list of repair segments exceeds locally configured MSD (%u > %u)", + listcount(repair_list), spftree_pc->area->srdb.config.msd); return -1; } - if (tilfa_repair_list_apply(spftree_pc, vertex_dest, vertex, - repair_list) - != 0) + if (tilfa_repair_list_apply(spftree_pc, vertex_dest, vertex, repair_list) != 0) return -1; return 0; } @@ -756,9 +705,8 @@ static int tilfa_build_repair_list(struct isis_spftree *spftree_pc, ecmp = (listcount(vertex->parents) > 1) ? true : false; repair_list_parent = ecmp ? list_dup(repair_list) : repair_list; - ret = tilfa_build_repair_list(spftree_pc, vertex_dest, pvertex, - vertex, used_pnodes, - repair_list_parent); + ret = tilfa_build_repair_list(spftree_pc, vertex_dest, pvertex, vertex, + used_pnodes, repair_list_parent); if (ecmp) list_delete(&repair_list_parent); if (ret != 0) @@ -780,36 +728,31 @@ static const char *lfa_protection_type2str(enum lfa_protection_type type) } } -static const char * -lfa_protected_resource2str(const struct lfa_protected_resource *resource) +static const char *lfa_protected_resource2str(const struct lfa_protected_resource *resource) { const uint8_t *fail_id; static char buffer[128]; fail_id = resource->adjacency; - snprintf(buffer, sizeof(buffer), "%s.%u's failure (%s)", - print_sys_hostname(fail_id), LSP_PSEUDO_ID(fail_id), - lfa_protection_type2str(resource->type)); + snprintf(buffer, sizeof(buffer), "%s.%u's failure (%s)", print_sys_hostname(fail_id), + LSP_PSEUDO_ID(fail_id), lfa_protection_type2str(resource->type)); return buffer; } -static bool -spf_adj_check_is_affected(const struct isis_spf_adj *sadj, - const struct lfa_protected_resource *resource, - const uint8_t *root_sysid, bool reverse) +static bool spf_adj_check_is_affected(const struct isis_spf_adj *sadj, + const struct lfa_protected_resource *resource, + const uint8_t *root_sysid, bool reverse) { - if (!!CHECK_FLAG(sadj->flags, F_ISIS_SPF_ADJ_BROADCAST) - != !!LSP_PSEUDO_ID(resource->adjacency)) + if (!!CHECK_FLAG(sadj->flags, F_ISIS_SPF_ADJ_BROADCAST) != + !!LSP_PSEUDO_ID(resource->adjacency)) return false; if (CHECK_FLAG(sadj->flags, F_ISIS_SPF_ADJ_BROADCAST)) { - if (!memcmp(sadj->lan.desig_is_id, resource->adjacency, - ISIS_SYS_ID_LEN + 1)) + if (!memcmp(sadj->lan.desig_is_id, resource->adjacency, ISIS_SYS_ID_LEN + 1)) return true; } else { - if (!reverse - && !memcmp(sadj->id, resource->adjacency, ISIS_SYS_ID_LEN)) + if (!reverse && !memcmp(sadj->id, resource->adjacency, ISIS_SYS_ID_LEN)) return true; if (reverse && !memcmp(sadj->id, root_sysid, ISIS_SYS_ID_LEN)) return true; @@ -819,10 +762,9 @@ spf_adj_check_is_affected(const struct isis_spf_adj *sadj, } /* Check if the given vertex is affected by a given local failure. */ -static bool -spf_vertex_check_is_affected(const struct isis_vertex *vertex, - const uint8_t *root_sysid, - const struct lfa_protected_resource *resource) +static bool spf_vertex_check_is_affected(const struct isis_vertex *vertex, + const uint8_t *root_sysid, + const struct lfa_protected_resource *resource) { struct isis_vertex_adj *vadj; struct listnode *node; @@ -835,8 +777,7 @@ spf_vertex_check_is_affected(const struct isis_vertex *vertex, for (ALL_LIST_ELEMENTS_RO(vertex->Adj_N, node, vadj)) { struct isis_spf_adj *sadj = vadj->sadj; - if (spf_adj_check_is_affected(sadj, resource, root_sysid, - false)) + if (spf_adj_check_is_affected(sadj, resource, root_sysid, false)) affected_nhs++; } @@ -857,13 +798,12 @@ static bool lfa_check_needs_protection(const struct isis_spftree *spftree_pc, struct isis_vertex *vertex_old; /* Only local adjacencies need TI-LFA Adj-SID protection. */ - if (spftree_pc->type == SPF_TYPE_TI_LFA && VTYPE_IS(vertex->type) - && !isis_adj_find(spftree_pc->area, spftree_pc->level, - vertex->N.id)) + if (spftree_pc->type == SPF_TYPE_TI_LFA && VTYPE_IS(vertex->type) && + !isis_adj_find(spftree_pc->area, spftree_pc->level, vertex->N.id)) return false; - vertex_old = isis_find_vertex(&spftree_pc->lfa.old.spftree->paths, - &vertex->N, vertex->type); + vertex_old = isis_find_vertex(&spftree_pc->lfa.old.spftree->paths, &vertex->N, + vertex->type); if (!vertex_old) return false; @@ -871,9 +811,8 @@ static bool lfa_check_needs_protection(const struct isis_spftree *spftree_pc, if (CHECK_FLAG(vertex_old->flags, F_ISIS_VERTEX_LFA_PROTECTED)) return false; - return spf_vertex_check_is_affected( - vertex_old, spftree_pc->sysid, - &spftree_pc->lfa.protected_resource); + return spf_vertex_check_is_affected(vertex_old, spftree_pc->sysid, + &spftree_pc->lfa.protected_resource); } /** @@ -885,8 +824,7 @@ static bool lfa_check_needs_protection(const struct isis_spftree *spftree_pc, * * @return 0 if the vertex needs to be protected, -1 otherwise */ -int isis_tilfa_check(struct isis_spftree *spftree_pc, - struct isis_vertex *vertex) +int isis_tilfa_check(struct isis_spftree *spftree_pc, struct isis_vertex *vertex) { struct isis_spf_nodes used_pnodes; char buf[VID2STR_BUFFER]; @@ -898,12 +836,9 @@ int isis_tilfa_check(struct isis_spftree *spftree_pc, if (!lfa_check_needs_protection(spftree_pc, vertex)) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: %s %s unaffected by %s", - vtype2string(vertex->type), - vid2string(vertex, buf, sizeof(buf)), - lfa_protected_resource2str( - &spftree_pc->lfa.protected_resource)); + zlog_debug("ISIS-LFA: %s %s unaffected by %s", vtype2string(vertex->type), + vid2string(vertex, buf, sizeof(buf)), + lfa_protected_resource2str(&spftree_pc->lfa.protected_resource)); return -1; } @@ -912,17 +847,14 @@ int isis_tilfa_check(struct isis_spftree *spftree_pc, * Check if the route/adjacency was already covered by node protection. */ if (VTYPE_IS(vertex->type)) { - struct isis_adjacency *adj; + const struct isis_adjacency *adj; - 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_ADJ_BACKUP)) { + 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_ADJ_BACKUP)) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: %s %s already covered by node protection", - vtype2string(vertex->type), - vid2string(vertex, buf, sizeof(buf))); + zlog_debug("ISIS-LFA: %s %s already covered by node protection", + vtype2string(vertex->type), + vid2string(vertex, buf, sizeof(buf))); return -1; } @@ -933,46 +865,37 @@ int isis_tilfa_check(struct isis_spftree *spftree_pc, route_table = spftree_pc->lfa.old.spftree->route_table_backup; if (route_node_lookup(route_table, &vertex->N.ip.p.dest)) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: %s %s already covered by node protection", - vtype2string(vertex->type), - vid2string(vertex, buf, sizeof(buf))); + zlog_debug("ISIS-LFA: %s %s already covered by node protection", + vtype2string(vertex->type), + vid2string(vertex, buf, sizeof(buf))); return -1; } } if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: computing repair path(s) of %s %s w.r.t %s", - vtype2string(vertex->type), - vid2string(vertex, buf, sizeof(buf)), - lfa_protected_resource2str( - &spftree_pc->lfa.protected_resource)); + zlog_debug("ISIS-LFA: computing repair path(s) of %s %s w.r.t %s", + vtype2string(vertex->type), vid2string(vertex, buf, sizeof(buf)), + lfa_protected_resource2str(&spftree_pc->lfa.protected_resource)); /* Create base repair list. */ repair_list = list_new(); isis_spf_node_list_init(&used_pnodes); - ret = tilfa_build_repair_list(spftree_pc, vertex, vertex, NULL, - &used_pnodes, repair_list); + ret = tilfa_build_repair_list(spftree_pc, vertex, vertex, NULL, &used_pnodes, repair_list); isis_spf_node_list_clear(&used_pnodes); list_delete(&repair_list); if (ret != 0) - zlog_warn( - "ISIS-LFA: failed to compute repair path(s) of %s %s w.r.t %s", - vtype2string(vertex->type), - vid2string(vertex, buf, sizeof(buf)), - lfa_protected_resource2str( - &spftree_pc->lfa.protected_resource)); + zlog_warn("ISIS-LFA: failed to compute repair path(s) of %s %s w.r.t %s", + vtype2string(vertex->type), vid2string(vertex, buf, sizeof(buf)), + lfa_protected_resource2str(&spftree_pc->lfa.protected_resource)); return ret; } -static bool -spf_adj_node_is_affected(struct isis_spf_node *adj_node, - const struct lfa_protected_resource *resource, - const uint8_t *root_sysid) +static bool spf_adj_node_is_affected(struct isis_spf_node *adj_node, + const struct lfa_protected_resource *resource, + const uint8_t *root_sysid) { struct isis_spf_adj *sadj; struct listnode *node; @@ -980,8 +903,7 @@ spf_adj_node_is_affected(struct isis_spf_node *adj_node, for (ALL_LIST_ELEMENTS_RO(adj_node->adjacencies, node, sadj)) { if (sadj->metric != adj_node->best_metric) continue; - if (spf_adj_check_is_affected(sadj, resource, root_sysid, - false)) + if (spf_adj_check_is_affected(sadj, resource, root_sysid, false)) return true; } @@ -989,8 +911,8 @@ spf_adj_node_is_affected(struct isis_spf_node *adj_node, } static bool vertex_is_affected(struct isis_spftree *spftree_root, - const struct isis_spf_nodes *adj_nodes, - bool p_space, const struct isis_vertex *vertex, + const struct isis_spf_nodes *adj_nodes, bool p_space, + const struct isis_vertex *vertex, const struct lfa_protected_resource *resource) { struct isis_vertex *pvertex; @@ -1009,14 +931,12 @@ static bool vertex_is_affected(struct isis_spftree *spftree_root, } /* Check if either the vertex or its parent is the root node. */ - if (memcmp(vertex->N.id, spftree_root->sysid, ISIS_SYS_ID_LEN) - && memcmp(pvertex->N.id, spftree_root->sysid, - ISIS_SYS_ID_LEN)) + if (memcmp(vertex->N.id, spftree_root->sysid, ISIS_SYS_ID_LEN) && + memcmp(pvertex->N.id, spftree_root->sysid, ISIS_SYS_ID_LEN)) goto parents; /* Get SPT of the parent vertex. */ - if (!memcmp(pvertex->N.id, spftree_root->sysid, - ISIS_SYS_ID_LEN)) + if (!memcmp(pvertex->N.id, spftree_root->sysid, ISIS_SYS_ID_LEN)) spftree_parent = spftree_root; else { struct isis_spf_node *adj_node; @@ -1029,21 +949,18 @@ static bool vertex_is_affected(struct isis_spftree *spftree_root, } /* Get paths pvertex uses to reach vertex. */ - vertex_child = isis_find_vertex(&spftree_parent->paths, - &vertex->N, vertex->type); + vertex_child = isis_find_vertex(&spftree_parent->paths, &vertex->N, vertex->type); if (!vertex_child) goto parents; /* Check if any of these paths use the protected resource. */ for (ALL_LIST_ELEMENTS_RO(vertex_child->Adj_N, vnode, vadj)) - if (spf_adj_check_is_affected(vadj->sadj, resource, - spftree_root->sysid, + if (spf_adj_check_is_affected(vadj->sadj, resource, spftree_root->sysid, reverse)) return true; - parents: - if (vertex_is_affected(spftree_root, adj_nodes, p_space, - pvertex, resource)) +parents: + if (vertex_is_affected(spftree_root, adj_nodes, p_space, pvertex, resource)) return true; } @@ -1051,10 +968,8 @@ static bool vertex_is_affected(struct isis_spftree *spftree_root, } /* Calculate set of nodes reachable without using the protected interface. */ -static void lfa_calc_reach_nodes(struct isis_spftree *spftree, - struct isis_spftree *spftree_root, - const struct isis_spf_nodes *adj_nodes, - bool p_space, +static void lfa_calc_reach_nodes(struct isis_spftree *spftree, struct isis_spftree *spftree_root, + const struct isis_spf_nodes *adj_nodes, bool p_space, const struct lfa_protected_resource *resource, struct isis_spf_nodes *nodes) { @@ -1075,12 +990,10 @@ static void lfa_calc_reach_nodes(struct isis_spftree *spftree, if (isis_spf_node_find(nodes, vertex->N.id)) continue; - if (!vertex_is_affected(spftree_root, adj_nodes, p_space, - vertex, resource)) { + if (!vertex_is_affected(spftree_root, adj_nodes, p_space, vertex, resource)) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: adding %s", - vid2string(vertex, buf, sizeof(buf))); + zlog_debug("ISIS-LFA: adding %s", + vid2string(vertex, buf, sizeof(buf))); isis_spf_node_new(nodes, vertex->N.id); } @@ -1099,11 +1012,10 @@ struct isis_spftree *isis_spf_reverse_run(const struct isis_spftree *spftree) { struct isis_spftree *spftree_reverse; - spftree_reverse = isis_spftree_new( - spftree->area, spftree->lspdb, spftree->sysid, spftree->level, - spftree->tree_id, SPF_TYPE_REVERSE, - F_SPFTREE_NO_ADJACENCIES | F_SPFTREE_NO_ROUTES, - spftree->algorithm); + spftree_reverse = isis_spftree_new(spftree->area, spftree->lspdb, spftree->sysid, + spftree->level, spftree->tree_id, SPF_TYPE_REVERSE, + F_SPFTREE_NO_ADJACENCIES | F_SPFTREE_NO_ROUTES, + spftree->algorithm); isis_run_spf(spftree_reverse); return spftree_reverse; @@ -1128,12 +1040,10 @@ static void lfa_calc_pq_spaces(struct isis_spftree *spftree_pc, if (IS_DEBUG_LFA) zlog_debug("ISIS-LFA: computing P-space (self)"); - lfa_calc_reach_nodes(spftree, spftree, adj_nodes, true, resource, - &spftree_pc->lfa.p_space); + lfa_calc_reach_nodes(spftree, spftree, adj_nodes, true, resource, &spftree_pc->lfa.p_space); RB_FOREACH (adj_node, isis_spf_nodes, adj_nodes) { - if (spf_adj_node_is_affected(adj_node, resource, - spftree->sysid)) { + if (spf_adj_node_is_affected(adj_node, resource, spftree->sysid)) { if (IS_DEBUG_LFA) zlog_debug("ISIS-LFA: computing Q-space (%s)", print_sys_hostname(adj_node->sysid)); @@ -1145,20 +1055,16 @@ static void lfa_calc_pq_spaces(struct isis_spftree *spftree_pc, */ if (!adj_node->lfa.spftree_reverse) adj_node->lfa.spftree_reverse = - isis_spf_reverse_run( - adj_node->lfa.spftree); + isis_spf_reverse_run(adj_node->lfa.spftree); - lfa_calc_reach_nodes(adj_node->lfa.spftree_reverse, - spftree_reverse, adj_nodes, false, - resource, - &spftree_pc->lfa.q_space); + lfa_calc_reach_nodes(adj_node->lfa.spftree_reverse, spftree_reverse, + adj_nodes, false, resource, &spftree_pc->lfa.q_space); } else { if (IS_DEBUG_LFA) zlog_debug("ISIS-LFA: computing P-space (%s)", print_sys_hostname(adj_node->sysid)); - lfa_calc_reach_nodes(adj_node->lfa.spftree, spftree, - adj_nodes, true, resource, - &adj_node->lfa.p_space); + lfa_calc_reach_nodes(adj_node->lfa.spftree, spftree, adj_nodes, true, + resource, &adj_node->lfa.p_space); } } } @@ -1173,8 +1079,7 @@ static void lfa_calc_pq_spaces(struct isis_spftree *spftree_pc, * * @return Pointer to the post-convergence SPF tree */ -struct isis_spftree *isis_tilfa_compute(struct isis_area *area, - struct isis_spftree *spftree, +struct isis_spftree *isis_tilfa_compute(struct isis_area *area, struct isis_spftree *spftree, struct isis_spftree *spftree_reverse, struct lfa_protected_resource *resource) { @@ -1189,17 +1094,14 @@ struct isis_spftree *isis_tilfa_compute(struct isis_area *area, if (resource->type == LFA_NODE_PROTECTION) { isis_spf_node_list_init(&resource->nodes); RB_FOREACH (adj_node, isis_spf_nodes, &spftree->adj_nodes) { - if (spf_adj_node_is_affected(adj_node, resource, - spftree->sysid)) - isis_spf_node_new(&resource->nodes, - adj_node->sysid); + if (spf_adj_node_is_affected(adj_node, resource, spftree->sysid)) + isis_spf_node_new(&resource->nodes, adj_node->sysid); } } /* Create post-convergence SPF tree. */ - spftree_pc = isis_spftree_new(area, spftree->lspdb, spftree->sysid, - spftree->level, spftree->tree_id, - SPF_TYPE_TI_LFA, spftree->flags, + spftree_pc = isis_spftree_new(area, spftree->lspdb, spftree->sysid, spftree->level, + spftree->tree_id, SPF_TYPE_TI_LFA, spftree->flags, spftree->algorithm); spftree_pc->lfa.old.spftree = spftree; spftree_pc->lfa.old.spftree_reverse = spftree_reverse; @@ -1209,9 +1111,8 @@ struct isis_spftree *isis_tilfa_compute(struct isis_area *area, lfa_calc_pq_spaces(spftree_pc, resource); if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: computing the post convergence SPT w.r.t. %s", - lfa_protected_resource2str(resource)); + zlog_debug("ISIS-LFA: computing the post convergence SPT w.r.t. %s", + lfa_protected_resource2str(resource)); /* Re-run SPF in the local node to find the post-convergence paths. */ isis_run_spf(spftree_pc); @@ -1245,11 +1146,11 @@ int isis_spf_run_neighbors(struct isis_spftree *spftree) print_sys_hostname(adj_node->sysid)); /* Compute the SPT on behalf of the neighbor. */ - adj_node->lfa.spftree = isis_spftree_new( - spftree->area, spftree->lspdb, adj_node->sysid, - spftree->level, spftree->tree_id, SPF_TYPE_FORWARD, - F_SPFTREE_NO_ADJACENCIES | F_SPFTREE_NO_ROUTES, - spftree->algorithm); + adj_node->lfa.spftree = + isis_spftree_new(spftree->area, spftree->lspdb, adj_node->sysid, + spftree->level, spftree->tree_id, SPF_TYPE_FORWARD, + F_SPFTREE_NO_ADJACENCIES | F_SPFTREE_NO_ROUTES, + spftree->algorithm); isis_run_spf(adj_node->lfa.spftree); } @@ -1273,11 +1174,10 @@ static struct in_addr *rlfa_pq_node_rtr_id(struct isis_spftree *spftree, } /* Find PQ node by intersecting the P/Q spaces. This is a recursive function. */ -static const struct in_addr * -rlfa_find_pq_node(struct isis_spftree *spftree_pc, - struct isis_vertex *vertex_dest, - const struct isis_vertex *vertex, - const struct isis_vertex *vertex_child) +static const struct in_addr *rlfa_find_pq_node(struct isis_spftree *spftree_pc, + struct isis_vertex *vertex_dest, + const struct isis_vertex *vertex, + const struct isis_vertex *vertex_child) { struct isis_area *area = spftree_pc->area; int level = spftree_pc->level; @@ -1287,8 +1187,7 @@ rlfa_find_pq_node(struct isis_spftree *spftree_pc, if (!vertex_child) goto parents; - if (vertex->type != VTYPE_NONPSEUDO_IS - && vertex->type != VTYPE_NONPSEUDO_TE_IS) + if (vertex->type != VTYPE_NONPSEUDO_IS && vertex->type != VTYPE_NONPSEUDO_TE_IS) goto parents; if (!VTYPE_IS(vertex_child->type)) vertex_child = NULL; @@ -1308,9 +1207,8 @@ rlfa_find_pq_node(struct isis_spftree *spftree_pc, char buf[VID2STR_BUFFER]; vid2string(vertex, buf, sizeof(buf)); - zlog_debug( - "ISIS-LFA: tentative PQ node (%s %s) doesn't have a router-ID", - vtype2string(vertex->type), buf); + zlog_debug("ISIS-LFA: tentative PQ node (%s %s) doesn't have a router-ID", + vtype2string(vertex->type), buf); } goto parents; } @@ -1318,9 +1216,8 @@ rlfa_find_pq_node(struct isis_spftree *spftree_pc, max_metric = spftree_pc->lfa.remote.max_metric; if (max_metric && vertex->d_N > max_metric) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: skipping PQ node %pI4 (maximum metric)", - rtr_id_pq); + zlog_debug("ISIS-LFA: skipping PQ node %pI4 (maximum metric)", + rtr_id_pq); goto parents; } @@ -1333,9 +1230,8 @@ rlfa_find_pq_node(struct isis_spftree *spftree_pc, p.u.prefix4 = *rtr_id_pq; if (prefix_list_apply(plist, &p) == PREFIX_DENY) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: PQ node %pI4 filtered by prefix-list", - rtr_id_pq); + zlog_debug("ISIS-LFA: PQ node %pI4 filtered by prefix-list", + rtr_id_pq); goto parents; } } @@ -1350,8 +1246,7 @@ rlfa_find_pq_node(struct isis_spftree *spftree_pc, for (ALL_LIST_ELEMENTS_RO(vertex->parents, node, pvertex)) { const struct in_addr *rtr_id_pq; - rtr_id_pq = rlfa_find_pq_node(spftree_pc, vertex_dest, pvertex, - vertex); + rtr_id_pq = rlfa_find_pq_node(spftree_pc, vertex_dest, pvertex, vertex); if (rtr_id_pq) return rtr_id_pq; } @@ -1364,8 +1259,7 @@ int rlfa_cmp(const struct rlfa *a, const struct rlfa *b) return prefix_cmp(&a->prefix, &b->prefix); } -static struct rlfa *rlfa_add(struct isis_spftree *spftree, - struct isis_vertex *vertex, +static struct rlfa *rlfa_add(struct isis_spftree *spftree, struct isis_vertex *vertex, struct in_addr pq_address) { struct rlfa *rlfa; @@ -1386,8 +1280,7 @@ static void rlfa_delete(struct isis_spftree *spftree, struct rlfa *rlfa) XFREE(MTYPE_ISIS_RLFA, rlfa); } -static struct rlfa *rlfa_lookup(struct isis_spftree *spftree, - union prefixconstptr pu) +static struct rlfa *rlfa_lookup(struct isis_spftree *spftree, union prefixconstptr pu) { struct rlfa s = {}; @@ -1405,8 +1298,7 @@ static void isis_area_verify_routes_cb(struct event *event) isis_area_verify_routes(area); } -static mpls_label_t rlfa_nexthop_label(struct isis_spftree *spftree, - struct isis_vertex_adj *vadj, +static mpls_label_t rlfa_nexthop_label(struct isis_spftree *spftree, struct isis_vertex_adj *vadj, struct zapi_rlfa_response *response) { struct isis_spf_adj *sadj = vadj->sadj; @@ -1422,13 +1314,10 @@ static mpls_label_t rlfa_nexthop_label(struct isis_spftree *spftree, for (unsigned int i = 0; i < response->nexthop_num; i++) { switch (response->nexthops[i].family) { case AF_INET: - for (unsigned int j = 0; j < adj->ipv4_address_count; - j++) { + for (unsigned int j = 0; j < adj->ipv4_address_count; j++) { struct in_addr addr = adj->ipv4_addresses[j]; - if (!IPV4_ADDR_SAME( - &addr, - &response->nexthops[i].gate.ipv4)) + if (!IPV4_ADDR_SAME(&addr, &response->nexthops[i].gate.ipv4)) continue; return response->nexthops[i].label; @@ -1438,9 +1327,7 @@ static mpls_label_t rlfa_nexthop_label(struct isis_spftree *spftree, for (unsigned int j = 0; j < adj->ll_ipv6_count; j++) { struct in6_addr addr = adj->ll_ipv6_addrs[j]; - if (!IPV6_ADDR_SAME( - &addr, - &response->nexthops[i].gate.ipv6)) + if (!IPV6_ADDR_SAME(&addr, &response->nexthops[i].gate.ipv6)) continue; return response->nexthops[i].label; @@ -1472,9 +1359,8 @@ int isis_rlfa_activate(struct isis_spftree *spftree, struct rlfa *rlfa, ldp_label = rlfa_nexthop_label(spftree, vadj, response); if (ldp_label == MPLS_INVALID_LABEL) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: failed to activate RLFA: missing LDP label to reach PQ node through %pSY", - vadj->sadj->id); + zlog_debug("ISIS-LFA: failed to activate RLFA: missing LDP label to reach PQ node through %pSY", + vadj->sadj->id); return -1; } @@ -1482,15 +1368,13 @@ int isis_rlfa_activate(struct isis_spftree *spftree, struct rlfa *rlfa, num_labels++; if (response->pq_label != MPLS_LABEL_IMPLICIT_NULL) num_labels++; - if (vadj->sr.present - && vadj->sr.label != MPLS_LABEL_IMPLICIT_NULL) + if (vadj->sr.present && vadj->sr.label != MPLS_LABEL_IMPLICIT_NULL) num_labels++; /* Allocate label stack. */ - label_stack = - XCALLOC(MTYPE_ISIS_NEXTHOP_LABELS, - sizeof(struct mpls_label_stack) - + num_labels * sizeof(mpls_label_t)); + label_stack = XCALLOC(MTYPE_ISIS_NEXTHOP_LABELS, + sizeof(struct mpls_label_stack) + + num_labels * sizeof(mpls_label_t)); label_stack->num_labels = num_labels; /* Push label allocated by the nexthop (outer label). */ @@ -1500,22 +1384,18 @@ int isis_rlfa_activate(struct isis_spftree *spftree, struct rlfa *rlfa, if (response->pq_label != MPLS_LABEL_IMPLICIT_NULL) label_stack->label[i++] = response->pq_label; /* Preserve the original Prefix-SID label when it's present. */ - if (vadj->sr.present - && vadj->sr.label != MPLS_LABEL_IMPLICIT_NULL) + if (vadj->sr.present && vadj->sr.label != MPLS_LABEL_IMPLICIT_NULL) label_stack->label[i++] = vadj->sr.label; vadj->label_stack = label_stack; } - isis_route_create(&vertex->N.ip.p.dest, &vertex->N.ip.p.src, - vertex->d_N, vertex->depth, &vertex->N.ip.sr, - vertex->Adj_N, true, area, - spftree->route_table_backup); + isis_route_create(&vertex->N.ip.p.dest, &vertex->N.ip.p.src, vertex->d_N, vertex->depth, + &vertex->N.ip.sr, vertex->Adj_N, true, area, spftree->route_table_backup); spftree->lfa.protection_counters.rlfa[vertex->N.ip.priority] += 1; event_cancel(&area->t_rlfa_rib_update); - event_add_timer(master, isis_area_verify_routes_cb, area, 2, - &area->t_rlfa_rib_update); + event_add_timer(master, isis_area_verify_routes_cb, area, 2, &area->t_rlfa_rib_update); return 0; } @@ -1533,8 +1413,7 @@ void isis_rlfa_deactivate(struct isis_spftree *spftree, struct rlfa *rlfa) spftree->lfa.protection_counters.rlfa[vertex->N.ip.priority] -= 1; event_cancel(&area->t_rlfa_rib_update); - event_add_timer(master, isis_area_verify_routes_cb, area, 2, - &area->t_rlfa_rib_update); + event_add_timer(master, isis_area_verify_routes_cb, area, 2, &area->t_rlfa_rib_update); } void isis_rlfa_list_init(struct isis_spftree *spftree) @@ -1570,8 +1449,7 @@ void isis_rlfa_process_ldp_response(struct zapi_rlfa_response *response) if (!isis) return; - area = isis_area_lookup(response->igp.isis.area_tag, - response->igp.vrf_id); + area = isis_area_lookup(response->igp.isis.area_tag, response->igp.vrf_id); if (!area) return; @@ -1595,24 +1473,20 @@ void isis_rlfa_process_ldp_response(struct zapi_rlfa_response *response) rlfa = rlfa_lookup(spftree, &response->destination); if (!rlfa) { - zlog_warn( - "ISIS-LFA: couldn't find Remote-LFA %pFX received from LDP", - &response->destination); + zlog_warn("ISIS-LFA: couldn't find Remote-LFA %pFX received from LDP", + &response->destination); return; } if (response->pq_label != MPLS_INVALID_LABEL) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: activating/updating RLFA for %pFX", - &rlfa->prefix); + zlog_debug("ISIS-LFA: activating/updating RLFA for %pFX", &rlfa->prefix); if (isis_rlfa_activate(spftree, rlfa, response) != 0) isis_rlfa_deactivate(spftree, rlfa); } else { if (IS_DEBUG_LFA) - zlog_debug("ISIS-LFA: deactivating RLFA for %pFX", - &rlfa->prefix); + zlog_debug("ISIS-LFA: deactivating RLFA for %pFX", &rlfa->prefix); isis_rlfa_deactivate(spftree, rlfa); } @@ -1622,7 +1496,6 @@ void isis_ldp_rlfa_handle_client_close(struct zapi_client_close_info *info) { struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); struct isis_area *area; - struct listnode *node; if (!isis) return; @@ -1634,10 +1507,9 @@ void isis_ldp_rlfa_handle_client_close(struct zapi_client_close_info *info) if (IS_DEBUG_LFA) zlog_debug("ISIS-LFA: LDP is down, deactivating all RLFAs"); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) { - for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; - level++) { + for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { struct isis_spftree *spftree; if (!(area->is_type & level)) @@ -1659,8 +1531,7 @@ void isis_ldp_rlfa_handle_client_close(struct zapi_client_close_info *info) * @param spftree_pc The post-convergence SPF tree * @param vertex IS-IS SPF vertex to check */ -void isis_rlfa_check(struct isis_spftree *spftree_pc, - struct isis_vertex *vertex) +void isis_rlfa_check(struct isis_spftree *spftree_pc, struct isis_vertex *vertex) { struct isis_spftree *spftree_old = spftree_pc->lfa.old.spftree; struct rlfa *rlfa; @@ -1669,23 +1540,17 @@ void isis_rlfa_check(struct isis_spftree *spftree_pc, if (!lfa_check_needs_protection(spftree_pc, vertex)) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: %s %s unaffected by %s", - vtype2string(vertex->type), - vid2string(vertex, buf, sizeof(buf)), - lfa_protected_resource2str( - &spftree_pc->lfa.protected_resource)); + zlog_debug("ISIS-LFA: %s %s unaffected by %s", vtype2string(vertex->type), + vid2string(vertex, buf, sizeof(buf)), + lfa_protected_resource2str(&spftree_pc->lfa.protected_resource)); return; } if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: computing repair path(s) of %s %s w.r.t %s", - vtype2string(vertex->type), - vid2string(vertex, buf, sizeof(buf)), - lfa_protected_resource2str( - &spftree_pc->lfa.protected_resource)); + zlog_debug("ISIS-LFA: computing repair path(s) of %s %s w.r.t %s", + vtype2string(vertex->type), vid2string(vertex, buf, sizeof(buf)), + lfa_protected_resource2str(&spftree_pc->lfa.protected_resource)); /* Find PQ node. */ rtr_id_pq = rlfa_find_pq_node(spftree_pc, vertex, vertex, NULL); @@ -1714,10 +1579,8 @@ void isis_rlfa_check(struct isis_spftree *spftree_pc, * * @return Pointer to the post-convergence SPF tree */ -struct isis_spftree *isis_rlfa_compute(struct isis_area *area, - struct isis_spftree *spftree, - struct isis_spftree *spftree_reverse, - uint32_t max_metric, +struct isis_spftree *isis_rlfa_compute(struct isis_area *area, struct isis_spftree *spftree, + struct isis_spftree *spftree_reverse, uint32_t max_metric, struct lfa_protected_resource *resource) { struct isis_spftree *spftree_pc; @@ -1727,9 +1590,8 @@ struct isis_spftree *isis_rlfa_compute(struct isis_area *area, lfa_protected_resource2str(resource)); /* Create post-convergence SPF tree. */ - spftree_pc = isis_spftree_new(area, spftree->lspdb, spftree->sysid, - spftree->level, spftree->tree_id, - SPF_TYPE_RLFA, spftree->flags, + spftree_pc = isis_spftree_new(area, spftree->lspdb, spftree->sysid, spftree->level, + spftree->tree_id, SPF_TYPE_RLFA, spftree->flags, spftree->algorithm); spftree_pc->lfa.old.spftree = spftree; spftree_pc->lfa.old.spftree_reverse = spftree_reverse; @@ -1740,9 +1602,8 @@ struct isis_spftree *isis_rlfa_compute(struct isis_area *area, lfa_calc_pq_spaces(spftree_pc, resource); if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: computing the post convergence SPT w.r.t. %s", - lfa_protected_resource2str(resource)); + zlog_debug("ISIS-LFA: computing the post convergence SPT w.r.t. %s", + lfa_protected_resource2str(resource)); /* Re-run SPF in the local node to find the post-convergence paths. */ isis_run_spf(spftree_pc); @@ -1752,17 +1613,14 @@ struct isis_spftree *isis_rlfa_compute(struct isis_area *area, /* Calculate the distance from the root node to the given IP destination. */ static int lfa_calc_dist_destination(struct isis_spftree *spftree, - const struct isis_vertex *vertex_N, - uint32_t *distance) + const struct isis_vertex *vertex_N, uint32_t *distance) { struct isis_vertex *vertex, *vertex_best = NULL; switch (spftree->family) { case AF_INET: - for (int vtype = VTYPE_IPREACH_INTERNAL; - vtype <= VTYPE_IPREACH_TE; vtype++) { - vertex = isis_find_vertex( - &spftree->paths, &vertex_N->N.ip.p.dest, vtype); + for (int vtype = VTYPE_IPREACH_INTERNAL; vtype <= VTYPE_IPREACH_TE; vtype++) { + vertex = isis_find_vertex(&spftree->paths, &vertex_N->N.ip.p.dest, vtype); if (!vertex) continue; @@ -1772,10 +1630,9 @@ static int lfa_calc_dist_destination(struct isis_spftree *spftree, } break; case AF_INET6: - for (int vtype = VTYPE_IP6REACH_INTERNAL; - vtype <= VTYPE_IP6REACH_EXTERNAL; vtype++) { - vertex = isis_find_vertex( - &spftree->paths, &vertex_N->N.ip.p.dest, vtype); + for (int vtype = VTYPE_IP6REACH_INTERNAL; vtype <= VTYPE_IP6REACH_EXTERNAL; + vtype++) { + vertex = isis_find_vertex(&spftree->paths, &vertex_N->N.ip.p.dest, vtype); if (!vertex) continue; @@ -1799,13 +1656,12 @@ static int lfa_calc_dist_destination(struct isis_spftree *spftree, } /* Calculate the distance from the root node to the given node. */ -static int lfa_calc_dist_node(struct isis_spftree *spftree, - const uint8_t *sysid, uint32_t *distance) +static int lfa_calc_dist_node(struct isis_spftree *spftree, const uint8_t *sysid, + uint32_t *distance) { struct isis_vertex *vertex, *vertex_best = NULL; - for (int vtype = VTYPE_PSEUDO_IS; vtype <= VTYPE_NONPSEUDO_TE_IS; - vtype++) { + for (int vtype = VTYPE_PSEUDO_IS; vtype <= VTYPE_NONPSEUDO_TE_IS; vtype++) { vertex = isis_find_vertex(&spftree->paths, sysid, vtype); if (!vertex) continue; @@ -1827,10 +1683,8 @@ static int lfa_calc_dist_node(struct isis_spftree *spftree, * Check loop-free criterion (RFC 5286's inequality 1): * - Dist_opt(N, D) < Dist_opt(N, S) + Dist_opt(S, D) */ -static bool clfa_loop_free_check(struct isis_spftree *spftree, - struct isis_vertex *vertex_S_D, - struct isis_spf_adj *sadj_primary, - struct isis_spf_adj *sadj_N, +static bool clfa_loop_free_check(struct isis_spftree *spftree, struct isis_vertex *vertex_S_D, + struct isis_spf_adj *sadj_primary, struct isis_spf_adj *sadj_N, uint32_t *path_metric) { struct isis_spf_node *node_N; @@ -1842,9 +1696,7 @@ static bool clfa_loop_free_check(struct isis_spftree *spftree, assert(node_N); /* Distance from N to D. */ - if (lfa_calc_dist_destination(node_N->lfa.spftree, vertex_S_D, - &dist_N_D) - != 0) + if (lfa_calc_dist_destination(node_N->lfa.spftree, vertex_S_D, &dist_N_D) != 0) return false; /* Distance from N to S (or PN). */ @@ -1852,17 +1704,14 @@ static bool clfa_loop_free_check(struct isis_spftree *spftree, static uint8_t pn_sysid[ISIS_SYS_ID_LEN + 1]; memcpy(pn_sysid, sadj_primary->id, ISIS_SYS_ID_LEN + 1); - if (lfa_calc_dist_node(node_N->lfa.spftree, pn_sysid, &dist_N_S) - != 0) + if (lfa_calc_dist_node(node_N->lfa.spftree, pn_sysid, &dist_N_S) != 0) return false; } else { static uint8_t root_sysid[ISIS_SYS_ID_LEN + 1]; memcpy(root_sysid, spftree->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(root_sysid) = 0; - if (lfa_calc_dist_node(node_N->lfa.spftree, root_sysid, - &dist_N_S) - != 0) + if (lfa_calc_dist_node(node_N->lfa.spftree, root_sysid, &dist_N_S) != 0) return false; } @@ -1873,8 +1722,7 @@ static bool clfa_loop_free_check(struct isis_spftree *spftree, dist_S_D -= sadj_primary->metric; if (IS_DEBUG_LFA) - zlog_debug("ISIS-LFA: loop-free check: %u < %u + %u", dist_N_D, - dist_N_S, dist_S_D); + zlog_debug("ISIS-LFA: loop-free check: %u < %u + %u", dist_N_D, dist_N_S, dist_S_D); if (dist_N_D < (dist_N_S + dist_S_D)) { *path_metric = sadj_N->metric + dist_N_D; @@ -1888,8 +1736,7 @@ static bool clfa_loop_free_check(struct isis_spftree *spftree, * Check loop-free criterion (RFC 5286's inequality 2): * - Distance_opt(N, D) < Distance_opt(S, D) */ -static bool clfa_downstream_check(struct isis_spftree *spftree, - struct isis_vertex *vertex_S_D, +static bool clfa_downstream_check(struct isis_spftree *spftree, struct isis_vertex *vertex_S_D, struct isis_spf_adj *sadj_N) { struct isis_spf_node *node_N; @@ -1900,9 +1747,7 @@ static bool clfa_downstream_check(struct isis_spftree *spftree, assert(node_N); /* Distance from N to D. */ - if (lfa_calc_dist_destination(node_N->lfa.spftree, vertex_S_D, - &dist_N_D) - != 0) + if (lfa_calc_dist_destination(node_N->lfa.spftree, vertex_S_D, &dist_N_D) != 0) return false; /* Distance from S (or PN) to D. */ @@ -1910,8 +1755,7 @@ static bool clfa_downstream_check(struct isis_spftree *spftree, dist_S_D = vertex_S_D->d_N; if (IS_DEBUG_LFA) - zlog_debug("ISIS-LFA: downstream check: %u < %u", dist_N_D, - dist_S_D); + zlog_debug("ISIS-LFA: downstream check: %u < %u", dist_N_D, dist_S_D); if (dist_N_D < dist_S_D) return true; @@ -1923,10 +1767,8 @@ static bool clfa_downstream_check(struct isis_spftree *spftree, * Check loop-free criterion (RFC 5286's inequality 3): * - Dist_opt(N, D) < Dist_opt(N, E) + Dist_opt(E, D) */ -static bool clfa_node_protecting_check(struct isis_spftree *spftree, - struct isis_vertex *vertex_S_D, - struct isis_spf_adj *sadj_N, - struct isis_spf_adj *sadj_E) +static bool clfa_node_protecting_check(struct isis_spftree *spftree, struct isis_vertex *vertex_S_D, + struct isis_spf_adj *sadj_N, struct isis_spf_adj *sadj_E) { struct isis_spf_node *node_N, *node_E; uint32_t dist_N_D; @@ -1939,34 +1781,28 @@ static bool clfa_node_protecting_check(struct isis_spftree *spftree, assert(node_E); /* Distance from N to D. */ - if (lfa_calc_dist_destination(node_N->lfa.spftree, vertex_S_D, - &dist_N_D) - != 0) + if (lfa_calc_dist_destination(node_N->lfa.spftree, vertex_S_D, &dist_N_D) != 0) return false; /* Distance from N to E. */ - if (lfa_calc_dist_node(node_N->lfa.spftree, node_E->sysid, &dist_N_E) - != 0) + if (lfa_calc_dist_node(node_N->lfa.spftree, node_E->sysid, &dist_N_E) != 0) return false; /* Distance from E to D. */ - if (lfa_calc_dist_destination(node_E->lfa.spftree, vertex_S_D, - &dist_E_D) - != 0) + if (lfa_calc_dist_destination(node_E->lfa.spftree, vertex_S_D, &dist_E_D) != 0) return false; if (IS_DEBUG_LFA) - zlog_debug("ISIS-LFA: node protecting check: %u < %u + %u", - dist_N_D, dist_N_E, dist_E_D); + zlog_debug("ISIS-LFA: node protecting check: %u < %u + %u", dist_N_D, dist_N_E, + dist_E_D); return (dist_N_D < (dist_N_E + dist_E_D)); } -static struct list * -isis_lfa_tiebreakers(struct isis_area *area, struct isis_spftree *spftree, - struct lfa_protected_resource *resource, - struct isis_vertex *vertex, - struct isis_spf_adj *sadj_primary, struct list *lfa_list) +static struct list *isis_lfa_tiebreakers(struct isis_area *area, struct isis_spftree *spftree, + struct lfa_protected_resource *resource, + struct isis_vertex *vertex, + struct isis_spf_adj *sadj_primary, struct list *lfa_list) { struct lfa_tiebreaker *tie_b; int level = spftree->level; @@ -1980,8 +1816,7 @@ isis_lfa_tiebreakers(struct isis_area *area, struct isis_spftree *spftree, return filtered_lfa_list; /* Check tiebreakers in ascending order by index. */ - frr_each (lfa_tiebreaker_tree, &area->lfa_tiebreakers[level - 1], - tie_b) { + frr_each (lfa_tiebreaker_tree, &area->lfa_tiebreakers[level - 1], tie_b) { struct isis_vertex_adj *lfa; struct listnode *node, *nnode; uint32_t best_metric = UINT32_MAX; @@ -1990,17 +1825,13 @@ isis_lfa_tiebreakers(struct isis_area *area, struct isis_spftree *spftree, switch (tie_b->type) { case LFA_TIEBREAKER_DOWNSTREAM: - for (ALL_LIST_ELEMENTS(tent_lfa_list, node, nnode, - lfa)) { - if (clfa_downstream_check(spftree, vertex, - lfa->sadj)) + for (ALL_LIST_ELEMENTS(tent_lfa_list, node, nnode, lfa)) { + if (clfa_downstream_check(spftree, vertex, lfa->sadj)) continue; if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: LFA %s doesn't satisfy the downstream condition", - print_sys_hostname( - lfa->sadj->id)); + zlog_debug("ISIS-LFA: LFA %s doesn't satisfy the downstream condition", + print_sys_hostname(lfa->sadj->id)); listnode_delete(tent_lfa_list, lfa); } break; @@ -2012,32 +1843,25 @@ isis_lfa_tiebreakers(struct isis_area *area, struct isis_spftree *spftree, } /* Remove LFAs that don't have the best metric. */ - for (ALL_LIST_ELEMENTS(tent_lfa_list, node, nnode, - lfa)) { + for (ALL_LIST_ELEMENTS(tent_lfa_list, node, nnode, lfa)) { if (lfa->lfa_metric == best_metric) continue; if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: LFA %s doesn't have the lowest cost metric", - print_sys_hostname( - lfa->sadj->id)); + zlog_debug("ISIS-LFA: LFA %s doesn't have the lowest cost metric", + print_sys_hostname(lfa->sadj->id)); listnode_delete(tent_lfa_list, lfa); } break; case LFA_TIEBREAKER_NODE_PROTECTING: - for (ALL_LIST_ELEMENTS(tent_lfa_list, node, nnode, - lfa)) { - if (clfa_node_protecting_check(spftree, vertex, - lfa->sadj, + for (ALL_LIST_ELEMENTS(tent_lfa_list, node, nnode, lfa)) { + if (clfa_node_protecting_check(spftree, vertex, lfa->sadj, sadj_primary)) continue; if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: LFA %s doesn't provide node protection", - print_sys_hostname( - lfa->sadj->id)); + zlog_debug("ISIS-LFA: LFA %s doesn't provide node protection", + print_sys_hostname(lfa->sadj->id)); listnode_delete(tent_lfa_list, lfa); } break; @@ -2074,8 +1898,7 @@ isis_lfa_tiebreakers(struct isis_area *area, struct isis_spftree *spftree, } void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, - struct isis_spftree *spftree, - struct lfa_protected_resource *resource) + struct isis_spftree *spftree, struct lfa_protected_resource *resource) { struct isis_vertex *vertex, *parent_vertex; struct listnode *vnode, *snode; @@ -2102,23 +1925,19 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, vid2string(vertex, buf, sizeof(buf)); - if (!spf_vertex_check_is_affected(vertex, spftree->sysid, - resource)) { + if (!spf_vertex_check_is_affected(vertex, spftree->sysid, resource)) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: %s %s unaffected by %s", - vtype2string(vertex->type), buf, - lfa_protected_resource2str(resource)); + zlog_debug("ISIS-LFA: %s %s unaffected by %s", + vtype2string(vertex->type), buf, + lfa_protected_resource2str(resource)); continue; } if (IS_DEBUG_LFA) - zlog_debug("ISIS-LFA: checking %s %s w.r.t %s", - vtype2string(vertex->type), buf, - lfa_protected_resource2str(resource)); + zlog_debug("ISIS-LFA: checking %s %s w.r.t %s", vtype2string(vertex->type), + buf, lfa_protected_resource2str(resource)); - if (vertex->N.ip.priority - > area->lfa_priority_limit[level - 1]) { + if (vertex->N.ip.priority > area->lfa_priority_limit[level - 1]) { if (IS_DEBUG_LFA) zlog_debug( "ISIS-LFA: skipping computing LFAs due to low prefix priority"); @@ -2158,48 +1977,40 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, * Skip nexthops that are along a link whose cost is * infinite. */ - if (CHECK_FLAG(sadj_N->flags, - F_ISIS_SPF_ADJ_METRIC_INFINITY)) + if (CHECK_FLAG(sadj_N->flags, F_ISIS_SPF_ADJ_METRIC_INFINITY)) continue; /* Skip nexthops that have the overload bit set. */ if (spftree->mtid != ISIS_MT_IPV4_UNICAST) { struct isis_mt_router_info *mt_router_info; - mt_router_info = - isis_tlvs_lookup_mt_router_info( - sadj_N->lsp->tlvs, - spftree->mtid); + mt_router_info = isis_tlvs_lookup_mt_router_info(sadj_N->lsp->tlvs, + spftree->mtid); if (mt_router_info && mt_router_info->overload) continue; - } else if (ISIS_MASK_LSP_OL_BIT( - sadj_N->lsp->hdr.lsp_bits)) + } else if (ISIS_MASK_LSP_OL_BIT(sadj_N->lsp->hdr.lsp_bits)) continue; /* Skip primary nexthop. */ - if (spf_adj_check_is_affected(sadj_N, resource, NULL, - false)) + if (spf_adj_check_is_affected(sadj_N, resource, NULL, false)) continue; /* Skip excluded interfaces as per the configuration. */ - if (circuit - && isis_lfa_excluded_iface_check( - circuit, level, - sadj_N->adj->circuit->interface->name)) + if (circuit && + isis_lfa_excluded_iface_check(circuit, level, + sadj_N->adj->circuit->interface->name)) continue; if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: checking candidate LFA %s", - print_sys_hostname(sadj_N->id)); + zlog_debug("ISIS-LFA: checking candidate LFA %s", + print_sys_hostname(sadj_N->id)); /* Check loop-free criterion. */ - if (!clfa_loop_free_check(spftree, vertex, sadj_primary, - sadj_N, &path_metric)) { + if (!clfa_loop_free_check(spftree, vertex, sadj_primary, sadj_N, + &path_metric)) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: LFA condition not met for %s", - print_sys_hostname(sadj_N->id)); + zlog_debug("ISIS-LFA: LFA condition not met for %s", + print_sys_hostname(sadj_N->id)); continue; } @@ -2208,24 +2019,22 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, best_metric = lfa_metric; if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: %s is a valid loop-free alternate", - print_sys_hostname(sadj_N->id)); + zlog_debug("ISIS-LFA: %s is a valid loop-free alternate", + print_sys_hostname(sadj_N->id)); if (vertex->N.ip.sr.present) { psid = &vertex->N.ip.sr.sid; if (path_metric == sadj_N->metric) last_hop = true; } - lfa = isis_vertex_adj_add(spftree, vertex, lfa_list, - sadj_N, psid, last_hop); + lfa = isis_vertex_adj_add(spftree, vertex, lfa_list, sadj_N, psid, + last_hop); lfa->lfa_metric = lfa_metric; } if (list_isempty(lfa_list)) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: no valid local LFAs found"); + zlog_debug("ISIS-LFA: no valid local LFAs found"); list_delete(&lfa_list); continue; } @@ -2233,28 +2042,23 @@ void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, SET_FLAG(vertex->flags, F_ISIS_VERTEX_LFA_PROTECTED); /* Check tie-breakers. */ - filtered_lfa_list = - isis_lfa_tiebreakers(area, spftree, resource, vertex, - sadj_primary, lfa_list); + filtered_lfa_list = isis_lfa_tiebreakers(area, spftree, resource, vertex, + sadj_primary, lfa_list); /* Create backup route using the best LFAs. */ allow_ecmp = area->lfa_load_sharing[level - 1]; - isis_route_create(&vertex->N.ip.p.dest, &vertex->N.ip.p.src, - best_metric, vertex->depth, &vertex->N.ip.sr, - filtered_lfa_list, allow_ecmp, area, - spftree->route_table_backup); - spftree->lfa.protection_counters.lfa[vertex->N.ip.priority] += - 1; + isis_route_create(&vertex->N.ip.p.dest, &vertex->N.ip.p.src, best_metric, + vertex->depth, &vertex->N.ip.sr, filtered_lfa_list, allow_ecmp, + area, spftree->route_table_backup); + spftree->lfa.protection_counters.lfa[vertex->N.ip.priority] += 1; list_delete(&filtered_lfa_list); list_delete(&lfa_list); } } -static void isis_spf_run_tilfa(struct isis_area *area, - struct isis_circuit *circuit, - struct isis_spftree *spftree, - struct isis_spftree *spftree_reverse, +static void isis_spf_run_tilfa(struct isis_area *area, struct isis_circuit *circuit, + struct isis_spftree *spftree, struct isis_spftree *spftree_reverse, struct lfa_protected_resource *resource) { struct isis_spftree *spftree_pc_link; @@ -2263,8 +2067,7 @@ static void isis_spf_run_tilfa(struct isis_area *area, /* Compute node protecting repair paths first (if necessary). */ if (circuit->tilfa_node_protection[spftree->level - 1]) { resource->type = LFA_NODE_PROTECTION; - spftree_pc_node = isis_tilfa_compute(area, spftree, - spftree_reverse, resource); + spftree_pc_node = isis_tilfa_compute(area, spftree, spftree_reverse, resource); isis_spftree_del(spftree_pc_node); /* don't do link protection unless link-fallback is configured @@ -2275,8 +2078,7 @@ static void isis_spf_run_tilfa(struct isis_area *area, /* Compute link protecting repair paths. */ resource->type = LFA_LINK_PROTECTION; - spftree_pc_link = - isis_tilfa_compute(area, spftree, spftree_reverse, resource); + spftree_pc_link = isis_tilfa_compute(area, spftree, spftree_reverse, resource); isis_spftree_del(spftree_pc_link); } @@ -2290,19 +2092,17 @@ void isis_spf_run_lfa(struct isis_area *area, struct isis_spftree *spftree) { struct isis_spftree *spftree_reverse = NULL; struct isis_circuit *circuit; - struct listnode *node; int level = spftree->level; /* Run reverse SPF locally. */ - if (area->rlfa_protected_links[level - 1] > 0 - || area->tilfa_protected_links[level - 1] > 0) + if (area->rlfa_protected_links[level - 1] > 0 || area->tilfa_protected_links[level - 1] > 0) spftree_reverse = isis_spf_reverse_run(spftree); /* Run forward SPF on all adjacent routers. */ isis_spf_run_neighbors(spftree); /* Check which interfaces are protected. */ - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { struct lfa_protected_resource resource = {}; struct isis_adjacency *adj; static uint8_t null_sysid[ISIS_SYS_ID_LEN + 1]; @@ -2310,24 +2110,20 @@ void isis_spf_run_lfa(struct isis_area *area, struct isis_spftree *spftree) if (!(circuit->is_type & level)) continue; - if (!circuit->lfa_protection[level - 1] - && !circuit->tilfa_protection[level - 1]) + if (!circuit->lfa_protection[level - 1] && !circuit->tilfa_protection[level - 1]) continue; /* Fill in the protected resource. */ switch (circuit->circ_type) { case CIRCUIT_T_BROADCAST: if (level == ISIS_LEVEL1) - memcpy(resource.adjacency, - circuit->u.bc.l1_desig_is, + memcpy(resource.adjacency, circuit->u.bc.l1_desig_is, ISIS_SYS_ID_LEN + 1); else - memcpy(resource.adjacency, - circuit->u.bc.l2_desig_is, + memcpy(resource.adjacency, circuit->u.bc.l2_desig_is, ISIS_SYS_ID_LEN + 1); /* Do nothing if no DR was elected yet. */ - if (!memcmp(resource.adjacency, null_sysid, - ISIS_SYS_ID_LEN + 1)) + if (!memcmp(resource.adjacency, null_sysid, ISIS_SYS_ID_LEN + 1)) continue; break; case CIRCUIT_T_P2P: @@ -2351,19 +2147,15 @@ void isis_spf_run_lfa(struct isis_area *area, struct isis_spftree *spftree) /* Run remote LFA. */ assert(spftree_reverse); - max_metric = - circuit->rlfa_max_metric[level - 1]; - spftree_pc = isis_rlfa_compute( - area, spftree, spftree_reverse, - max_metric, &resource); - listnode_add(spftree->lfa.remote.pc_spftrees, - spftree_pc); + max_metric = circuit->rlfa_max_metric[level - 1]; + spftree_pc = isis_rlfa_compute(area, spftree, spftree_reverse, + max_metric, &resource); + listnode_add(spftree->lfa.remote.pc_spftrees, spftree_pc); } } else if (circuit->tilfa_protection[level - 1]) { /* Run TI-LFA. */ assert(spftree_reverse); - isis_spf_run_tilfa(area, circuit, spftree, - spftree_reverse, &resource); + isis_spf_run_tilfa(area, circuit, spftree, spftree_reverse, &resource); } } diff --git a/isisd/isis_lfa.h b/isisd/isis_lfa.h index 58ff115b021d..875ccbf68d7b 100644 --- a/isisd/isis_lfa.h +++ b/isisd/isis_lfa.h @@ -28,10 +28,8 @@ struct lfa_tiebreaker { enum lfa_tiebreaker_type type; struct isis_area *area; }; -int lfa_tiebreaker_cmp(const struct lfa_tiebreaker *a, - const struct lfa_tiebreaker *b); -DECLARE_RBTREE_UNIQ(lfa_tiebreaker_tree, struct lfa_tiebreaker, entry, - lfa_tiebreaker_cmp); +int lfa_tiebreaker_cmp(const struct lfa_tiebreaker *a, const struct lfa_tiebreaker *b); +DECLARE_RBTREE_UNIQ(lfa_tiebreaker_tree, struct lfa_tiebreaker, entry, lfa_tiebreaker_cmp); struct rlfa { struct rlfa_tree_item entry; @@ -121,29 +119,20 @@ struct isis_vertex; /* Prototypes. */ void isis_spf_node_list_init(struct isis_spf_nodes *nodes); void isis_spf_node_list_clear(struct isis_spf_nodes *nodes); -struct isis_spf_node *isis_spf_node_new(struct isis_spf_nodes *nodes, - const uint8_t *sysid); -struct isis_spf_node *isis_spf_node_find(const struct isis_spf_nodes *nodes, - const uint8_t *sysid); +struct isis_spf_node *isis_spf_node_new(struct isis_spf_nodes *nodes, const uint8_t *sysid); +struct isis_spf_node *isis_spf_node_find(const struct isis_spf_nodes *nodes, const uint8_t *sysid); void isis_lfa_tiebreakers_init(struct isis_area *area, int level); void isis_lfa_tiebreakers_clear(struct isis_area *area, int level); -struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area, - int level, uint8_t index, +struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area, int level, uint8_t index, enum lfa_tiebreaker_type type); -void isis_lfa_tiebreaker_delete(struct isis_area *area, int level, - struct lfa_tiebreaker *tie_b); +void isis_lfa_tiebreaker_delete(struct isis_area *area, int level, struct lfa_tiebreaker *tie_b); void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level); void isis_lfa_excluded_ifaces_delete(struct isis_circuit *circuit, int level); -void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level, - const char *ifname); -void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level, - const char *ifname); -bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level, - const char *ifname); -bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree, - const uint8_t *id); -bool isis_lfa_excise_node_check(const struct isis_spftree *spftree, - const uint8_t *id); +void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level, const char *ifname); +void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level, const char *ifname); +bool isis_lfa_excluded_iface_check(struct isis_circuit *circuit, int level, const char *ifname); +bool isis_lfa_excise_adj_check(const struct isis_spftree *spftree, const uint8_t *id); +bool isis_lfa_excise_node_check(const struct isis_spftree *spftree, const uint8_t *id); struct isis_spftree *isis_spf_reverse_run(const struct isis_spftree *spftree); int isis_spf_run_neighbors(struct isis_spftree *spftree); int isis_rlfa_activate(struct isis_spftree *spftree, struct rlfa *rlfa, @@ -154,19 +143,15 @@ void isis_rlfa_list_clear(struct isis_spftree *spftree); void isis_rlfa_process_ldp_response(struct zapi_rlfa_response *response); void isis_ldp_rlfa_handle_client_close(struct zapi_client_close_info *info); void isis_rlfa_check(struct isis_spftree *spftree, struct isis_vertex *vertex); -struct isis_spftree *isis_rlfa_compute(struct isis_area *area, - struct isis_spftree *spftree, - struct isis_spftree *spftree_reverse, - uint32_t max_metric, +struct isis_spftree *isis_rlfa_compute(struct isis_area *area, struct isis_spftree *spftree, + struct isis_spftree *spftree_reverse, uint32_t max_metric, struct lfa_protected_resource *resource); void isis_lfa_compute(struct isis_area *area, struct isis_circuit *circuit, - struct isis_spftree *spftree, - struct lfa_protected_resource *resource); + struct isis_spftree *spftree, struct lfa_protected_resource *resource); void isis_spf_run_lfa(struct isis_area *area, struct isis_spftree *spftree); int isis_tilfa_check(struct isis_spftree *spftree, struct isis_vertex *vertex); -struct isis_spftree * -isis_tilfa_compute(struct isis_area *area, struct isis_spftree *spftree, - struct isis_spftree *spftree_reverse, - struct lfa_protected_resource *protected_resource); +struct isis_spftree *isis_tilfa_compute(struct isis_area *area, struct isis_spftree *spftree, + struct isis_spftree *spftree_reverse, + struct lfa_protected_resource *protected_resource); #endif /* _FRR_ISIS_LFA_H */ diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index da2b81b279d0..bdab7931e508 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -103,13 +103,12 @@ static void lsp_remove_frags(struct lspdb_head *head, struct list *frags); static void lsp_destroy(struct isis_lsp *lsp) { - struct listnode *cnode; struct isis_circuit *circuit; if (!lsp) return; - for (ALL_LIST_ELEMENTS_RO(lsp->area->circuit_list, cnode, circuit)) + frr_each (isis_circuit_list, &lsp->area->circuit_list, circuit) isis_tx_queue_del(circuit->tx_queue, lsp); ISIS_FLAGS_CLEAR_ALL(lsp->SSNflags); @@ -406,7 +405,7 @@ static void lsp_seqno_update(struct isis_lsp *lsp0) bool isis_level2_adj_up(struct isis_area *area) { - struct listnode *node, *cnode; + struct listnode *node; struct isis_circuit *circuit; struct list *adjdb; struct isis_adjacency *adj; @@ -414,7 +413,7 @@ bool isis_level2_adj_up(struct isis_area *area) if (area->is_type == IS_LEVEL_1) return false; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { if (circuit->circ_type == CIRCUIT_T_BROADCAST) { adjdb = circuit->u.bc.adjdb[1]; if (!adjdb || !adjdb->count) @@ -1075,7 +1074,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) lsp_add_auth(lsp); - isis_tlvs_add_area_addresses(lsp->tlvs, area->area_addrs); + isis_tlvs_add_area_addresses(lsp->tlvs, &area->area_addrs); /* Protocols Supported */ if (area->ip_circuits > 0 || area->ipv6_circuits > 0) { @@ -1298,7 +1297,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) } struct isis_circuit *circuit; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { if (!circuit->interface) lsp_debug( "ISIS (%s): Processing %s circuit %p with unknown interface", @@ -1669,7 +1668,6 @@ int _lsp_regenerate_schedule(struct isis_area *area, int level, uint8_t id[ISIS_SYS_ID_LEN + 2]; time_t now, diff; long timeout; - struct listnode *cnode; struct isis_circuit *circuit; int lvl; @@ -1773,7 +1771,7 @@ int _lsp_regenerate_schedule(struct isis_area *area, int level, } if (all_pseudo) { - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) lsp_regenerate_schedule_pseudo(circuit, level); } @@ -2276,7 +2274,6 @@ void lsp_purge_non_exist(int level, struct isis_lsp_hdr *hdr, void lsp_set_all_srmflags(struct isis_lsp *lsp, bool set) { - struct listnode *node; struct isis_circuit *circuit; assert(lsp); @@ -2284,8 +2281,7 @@ void lsp_set_all_srmflags(struct isis_lsp *lsp, bool set) if (!lsp->area) return; - struct list *circuit_list = lsp->area->circuit_list; - for (ALL_LIST_ELEMENTS_RO(circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &lsp->area->circuit_list, circuit) { if (set) { isis_tx_queue_add(circuit->tx_queue, lsp, TX_LSP_NORMAL); diff --git a/isisd/isis_main.c b/isisd/isis_main.c index 042cfd746608..24b40de912e8 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -105,15 +105,23 @@ static FRR_NORETURN void terminate(int i) isis_terminate(); isis_sr_term(); isis_srv6_term(); + mt_fini(); isis_zebra_stop(); - isis_master_terminate(); + /* + * Must call vrf_terminate and prefix_list_reset before + * isis_master_terminate, because their callbacks (isis_vrf_disable, + * isis_prefix_list_update) iterate over im->isis which is finalized + * by isis_master_terminate. + */ route_map_finish(); prefix_list_reset(); + vrf_terminate(); + #ifndef FABRICD isis_affinity_map_terminate(); #endif - vrf_terminate(); + isis_master_terminate(); frr_fini(); exit(i); @@ -197,12 +205,11 @@ static const struct frr_yang_module_info *const isisd_yang_modules[] = { static void isis_config_finish(struct event *t) { - struct listnode *node, *inode; struct isis *isis; struct isis_area *area; - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, area) config_end_lsp_generate(area); } } diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c index 238285277f2e..088b8016cc45 100644 --- a/isisd/isis_misc.c +++ b/isisd/isis_misc.c @@ -320,7 +320,6 @@ const char *print_sys_hostname(const uint8_t *sysid) { struct isis_dynhn *dyn; struct isis *isis = NULL; - struct listnode *node; struct isis_area *area = NULL; if (!sysid) @@ -331,7 +330,7 @@ const char *print_sys_hostname(const uint8_t *sysid) if (area && area->dynhostname && !CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) return cmd_hostname_get(); - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { + frr_each (isis_instance_list, &im->isis, isis) { area = isis_area_lookup_by_sysid(isis->sysid); dyn = dynhn_find_by_id(isis, sysid); if (area && area->dynhostname && dyn) diff --git a/isisd/isis_mt.c b/isisd/isis_mt.c index 65ba395ffc81..8d70d1fa8efb 100644 --- a/isisd/isis_mt.c +++ b/isisd/isis_mt.c @@ -19,6 +19,14 @@ DEFINE_MTYPE_STATIC(ISISD, MT_AREA_SETTING, "ISIS MT Area Setting"); DEFINE_MTYPE_STATIC(ISISD, MT_CIRCUIT_SETTING, "ISIS MT Circuit Setting"); DEFINE_MTYPE_STATIC(ISISD, MT_ADJ_INFO, "ISIS MT Adjacency Info"); +/* Static buffers for MT settings - freed by mt_fini() */ +static struct isis_area_mt_setting **area_mt_setting_buf; +static unsigned int area_mt_setting_buf_size; +static struct isis_circuit_mt_setting **circuit_mt_setting_buf; +static unsigned int circuit_mt_setting_buf_size; +static uint16_t *circuit_bcast_mt_set_buf; +static unsigned int circuit_bcast_mt_set_buf_size; + bool isis_area_ipv6_dstsrc_enabled(struct isis_area *area) { struct isis_area_mt_setting *area_mt_setting; @@ -198,7 +206,7 @@ bool area_is_mt(struct isis_area *area) if (setting->enabled && setting->mtid != ISIS_MT_IPV4_UNICAST) return true; } - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { for (ALL_LIST_ELEMENTS_RO(circuit->mt_settings, node2, csetting)) { if (!csetting->enabled @@ -213,9 +221,6 @@ bool area_is_mt(struct isis_area *area) struct isis_area_mt_setting **area_mt_settings(struct isis_area *area, unsigned int *mt_count) { - static unsigned int size = 0; - static struct isis_area_mt_setting **rv = NULL; - unsigned int count = 0; struct listnode *node; struct isis_area_mt_setting *setting; @@ -225,16 +230,16 @@ struct isis_area_mt_setting **area_mt_settings(struct isis_area *area, continue; count++; - if (count > size) { - rv = XREALLOC(MTYPE_MT_AREA_SETTING, rv, - count * sizeof(*rv)); - size = count; + if (count > area_mt_setting_buf_size) { + area_mt_setting_buf = XREALLOC(MTYPE_MT_AREA_SETTING, area_mt_setting_buf, + count * sizeof(*area_mt_setting_buf)); + area_mt_setting_buf_size = count; } - rv[count - 1] = setting; + area_mt_setting_buf[count - 1] = setting; } *mt_count = count; - return rv; + return area_mt_setting_buf; } /* Circuit specific MT settings api */ @@ -313,9 +318,6 @@ static int circuit_write_mt_settings(struct isis_circuit *circuit, struct isis_circuit_mt_setting ** circuit_mt_settings(struct isis_circuit *circuit, unsigned int *mt_count) { - static unsigned int size = 0; - static struct isis_circuit_mt_setting **rv = NULL; - struct isis_area_mt_setting **area_settings; unsigned int area_count; @@ -341,16 +343,17 @@ circuit_mt_settings(struct isis_circuit *circuit, unsigned int *mt_count) continue; count++; - if (count > size) { - rv = XREALLOC(MTYPE_MT_AREA_SETTING, rv, - count * sizeof(*rv)); - size = count; + if (count > circuit_mt_setting_buf_size) { + circuit_mt_setting_buf = XREALLOC(MTYPE_MT_AREA_SETTING, + circuit_mt_setting_buf, + count * sizeof(*circuit_mt_setting_buf)); + circuit_mt_setting_buf_size = count; } - rv[count - 1] = setting; + circuit_mt_setting_buf[count - 1] = setting; } *mt_count = count; - return rv; + return circuit_mt_setting_buf; } /* ADJ specific MT API */ @@ -478,8 +481,6 @@ static void mt_set_add(uint16_t **mt_set, unsigned int *size, static uint16_t *circuit_bcast_mt_set(struct isis_circuit *circuit, int level, unsigned int *mt_count) { - static uint16_t *rv; - static unsigned int size; struct listnode *node; struct isis_adjacency *adj; @@ -494,11 +495,12 @@ static uint16_t *circuit_bcast_mt_set(struct isis_circuit *circuit, int level, if (adj->adj_state != ISIS_ADJ_UP) continue; for (unsigned int i = 0; i < adj->mt_count; i++) - mt_set_add(&rv, &size, &count, adj->mt_set[i]); + mt_set_add(&circuit_bcast_mt_set_buf, &circuit_bcast_mt_set_buf_size, + &count, adj->mt_set[i]); } *mt_count = count; - return rv; + return circuit_bcast_mt_set_buf; } static void tlvs_add_mt_set(struct isis_area *area, struct isis_tlvs *tlvs, @@ -557,3 +559,13 @@ void mt_init(void) circuit_write_mt_settings); #endif } + +void mt_fini(void) +{ + XFREE(MTYPE_MT_AREA_SETTING, area_mt_setting_buf); + area_mt_setting_buf_size = 0; + XFREE(MTYPE_MT_AREA_SETTING, circuit_mt_setting_buf); + circuit_mt_setting_buf_size = 0; + XFREE(MTYPE_MT_AREA_SETTING, circuit_bcast_mt_set_buf); + circuit_bcast_mt_set_buf_size = 0; +} diff --git a/isisd/isis_mt.h b/isisd/isis_mt.h index 9b0df9bb7843..2a8ebdda1b39 100644 --- a/isisd/isis_mt.h +++ b/isisd/isis_mt.h @@ -110,4 +110,5 @@ void tlvs_add_mt_bcast(struct isis_tlvs *tlvs, struct isis_circuit *circuit, void tlvs_add_mt_p2p(struct isis_tlvs *tlvs, struct isis_circuit *circuit, uint8_t *id, uint32_t metric); void mt_init(void); +void mt_fini(void); #endif diff --git a/isisd/isis_nb.h b/isisd/isis_nb.h index 7f5b347a3374..ffa5564eb523 100644 --- a/isisd/isis_nb.h +++ b/isisd/isis_nb.h @@ -33,41 +33,26 @@ int isis_instance_admin_group_send_zero_modify(struct nb_cb_modify_args *args); int isis_instance_asla_legacy_flag_modify(struct nb_cb_modify_args *args); int isis_instance_lsp_mtu_modify(struct nb_cb_modify_args *args); int isis_instance_advertise_passive_only_modify(struct nb_cb_modify_args *args); -int isis_instance_lsp_refresh_interval_level_1_modify( - struct nb_cb_modify_args *args); -int isis_instance_lsp_refresh_interval_level_2_modify( - struct nb_cb_modify_args *args); -int isis_instance_lsp_maximum_lifetime_level_1_modify( - struct nb_cb_modify_args *args); -int isis_instance_lsp_maximum_lifetime_level_2_modify( - struct nb_cb_modify_args *args); -int isis_instance_lsp_generation_interval_level_1_modify( - struct nb_cb_modify_args *args); -int isis_instance_lsp_generation_interval_level_2_modify( - struct nb_cb_modify_args *args); +int isis_instance_lsp_refresh_interval_level_1_modify(struct nb_cb_modify_args *args); +int isis_instance_lsp_refresh_interval_level_2_modify(struct nb_cb_modify_args *args); +int isis_instance_lsp_maximum_lifetime_level_1_modify(struct nb_cb_modify_args *args); +int isis_instance_lsp_maximum_lifetime_level_2_modify(struct nb_cb_modify_args *args); +int isis_instance_lsp_generation_interval_level_1_modify(struct nb_cb_modify_args *args); +int isis_instance_lsp_generation_interval_level_2_modify(struct nb_cb_modify_args *args); int isis_instance_spf_ietf_backoff_delay_create(struct nb_cb_create_args *args); -int isis_instance_spf_ietf_backoff_delay_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_spf_ietf_backoff_delay_init_delay_modify( - struct nb_cb_modify_args *args); -int isis_instance_spf_ietf_backoff_delay_short_delay_modify( - struct nb_cb_modify_args *args); -int isis_instance_spf_ietf_backoff_delay_long_delay_modify( - struct nb_cb_modify_args *args); -int isis_instance_spf_ietf_backoff_delay_hold_down_modify( - struct nb_cb_modify_args *args); -int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify( - struct nb_cb_modify_args *args); -int isis_instance_spf_minimum_interval_level_1_modify( - struct nb_cb_modify_args *args); -int isis_instance_spf_minimum_interval_level_2_modify( - struct nb_cb_modify_args *args); +int isis_instance_spf_ietf_backoff_delay_destroy(struct nb_cb_destroy_args *args); +int isis_instance_spf_ietf_backoff_delay_init_delay_modify(struct nb_cb_modify_args *args); +int isis_instance_spf_ietf_backoff_delay_short_delay_modify(struct nb_cb_modify_args *args); +int isis_instance_spf_ietf_backoff_delay_long_delay_modify(struct nb_cb_modify_args *args); +int isis_instance_spf_ietf_backoff_delay_hold_down_modify(struct nb_cb_modify_args *args); +int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify(struct nb_cb_modify_args *args); +int isis_instance_spf_minimum_interval_level_1_modify(struct nb_cb_modify_args *args); +int isis_instance_spf_minimum_interval_level_2_modify(struct nb_cb_modify_args *args); int isis_instance_spf_prefix_priorities_critical_access_list_name_modify( struct nb_cb_modify_args *args); int isis_instance_spf_prefix_priorities_critical_access_list_name_destroy( struct nb_cb_destroy_args *args); -int isis_instance_spf_prefix_priorities_high_access_list_name_modify( - struct nb_cb_modify_args *args); +int isis_instance_spf_prefix_priorities_high_access_list_name_modify(struct nb_cb_modify_args *args); int isis_instance_spf_prefix_priorities_high_access_list_name_destroy( struct nb_cb_destroy_args *args); int isis_instance_spf_prefix_priorities_medium_access_list_name_modify( @@ -77,134 +62,79 @@ int isis_instance_spf_prefix_priorities_medium_access_list_name_destroy( int isis_instance_area_password_create(struct nb_cb_create_args *args); int isis_instance_area_password_destroy(struct nb_cb_destroy_args *args); int isis_instance_area_password_password_modify(struct nb_cb_modify_args *args); -int isis_instance_area_password_password_type_modify( - struct nb_cb_modify_args *args); -int isis_instance_area_password_authenticate_snp_modify( - struct nb_cb_modify_args *args); +int isis_instance_area_password_password_type_modify(struct nb_cb_modify_args *args); +int isis_instance_area_password_authenticate_snp_modify(struct nb_cb_modify_args *args); int isis_instance_domain_password_create(struct nb_cb_create_args *args); int isis_instance_domain_password_destroy(struct nb_cb_destroy_args *args); -int isis_instance_domain_password_password_modify( - struct nb_cb_modify_args *args); -int isis_instance_domain_password_password_type_modify( - struct nb_cb_modify_args *args); -int isis_instance_domain_password_authenticate_snp_modify( - struct nb_cb_modify_args *args); -int isis_instance_default_information_originate_ipv4_create( - struct nb_cb_create_args *args); -int isis_instance_default_information_originate_ipv4_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_default_information_originate_ipv4_always_modify( - struct nb_cb_modify_args *args); +int isis_instance_domain_password_password_modify(struct nb_cb_modify_args *args); +int isis_instance_domain_password_password_type_modify(struct nb_cb_modify_args *args); +int isis_instance_domain_password_authenticate_snp_modify(struct nb_cb_modify_args *args); +int isis_instance_default_information_originate_ipv4_create(struct nb_cb_create_args *args); +int isis_instance_default_information_originate_ipv4_destroy(struct nb_cb_destroy_args *args); +int isis_instance_default_information_originate_ipv4_always_modify(struct nb_cb_modify_args *args); int isis_instance_default_information_originate_ipv4_route_map_modify( struct nb_cb_modify_args *args); int isis_instance_default_information_originate_ipv4_route_map_destroy( struct nb_cb_destroy_args *args); -int isis_instance_default_information_originate_ipv4_metric_modify( - struct nb_cb_modify_args *args); -int isis_instance_default_information_originate_ipv6_create( - struct nb_cb_create_args *args); -int isis_instance_default_information_originate_ipv6_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_default_information_originate_ipv6_always_modify( - struct nb_cb_modify_args *args); +int isis_instance_default_information_originate_ipv4_metric_modify(struct nb_cb_modify_args *args); +int isis_instance_default_information_originate_ipv6_create(struct nb_cb_create_args *args); +int isis_instance_default_information_originate_ipv6_destroy(struct nb_cb_destroy_args *args); +int isis_instance_default_information_originate_ipv6_always_modify(struct nb_cb_modify_args *args); int isis_instance_default_information_originate_ipv6_route_map_modify( struct nb_cb_modify_args *args); int isis_instance_default_information_originate_ipv6_route_map_destroy( struct nb_cb_destroy_args *args); -int isis_instance_default_information_originate_ipv6_metric_modify( - struct nb_cb_modify_args *args); +int isis_instance_default_information_originate_ipv6_metric_modify(struct nb_cb_modify_args *args); int isis_instance_redistribute_ipv4_create(struct nb_cb_create_args *args); int isis_instance_redistribute_ipv4_destroy(struct nb_cb_destroy_args *args); -int isis_instance_redistribute_ipv4_route_map_modify( - struct nb_cb_modify_args *args); -int isis_instance_redistribute_ipv4_route_map_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_redistribute_ipv4_metric_modify( - struct nb_cb_modify_args *args); -int isis_instance_redistribute_ipv4_metric_destroy( - struct nb_cb_destroy_args *args); +int isis_instance_redistribute_ipv4_route_map_modify(struct nb_cb_modify_args *args); +int isis_instance_redistribute_ipv4_route_map_destroy(struct nb_cb_destroy_args *args); +int isis_instance_redistribute_ipv4_metric_modify(struct nb_cb_modify_args *args); +int isis_instance_redistribute_ipv4_metric_destroy(struct nb_cb_destroy_args *args); int isis_instance_redistribute_ipv4_table_create(struct nb_cb_create_args *args); -int isis_instance_redistribute_ipv4_table_destroy( - struct nb_cb_destroy_args *args); +int isis_instance_redistribute_ipv4_table_destroy(struct nb_cb_destroy_args *args); int isis_instance_redistribute_ipv6_create(struct nb_cb_create_args *args); int isis_instance_redistribute_ipv6_destroy(struct nb_cb_destroy_args *args); -int isis_instance_redistribute_ipv6_route_map_modify( - struct nb_cb_modify_args *args); -int isis_instance_redistribute_ipv6_route_map_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_redistribute_ipv6_metric_modify( - struct nb_cb_modify_args *args); -int isis_instance_redistribute_ipv6_metric_destroy( - struct nb_cb_destroy_args *args); +int isis_instance_redistribute_ipv6_route_map_modify(struct nb_cb_modify_args *args); +int isis_instance_redistribute_ipv6_route_map_destroy(struct nb_cb_destroy_args *args); +int isis_instance_redistribute_ipv6_metric_modify(struct nb_cb_modify_args *args); +int isis_instance_redistribute_ipv6_metric_destroy(struct nb_cb_destroy_args *args); int isis_instance_redistribute_ipv6_table_create(struct nb_cb_create_args *args); -int isis_instance_redistribute_ipv6_table_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_multi_topology_ipv4_multicast_create( - struct nb_cb_create_args *args); -int isis_instance_multi_topology_ipv4_multicast_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_multi_topology_ipv4_multicast_overload_modify( - struct nb_cb_modify_args *args); -int isis_instance_multi_topology_ipv4_management_create( - struct nb_cb_create_args *args); -int isis_instance_multi_topology_ipv4_management_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_multi_topology_ipv4_management_overload_modify( - struct nb_cb_modify_args *args); -int isis_instance_multi_topology_ipv6_unicast_create( - struct nb_cb_create_args *args); -int isis_instance_multi_topology_ipv6_unicast_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_multi_topology_ipv6_unicast_overload_modify( - struct nb_cb_modify_args *args); -int isis_instance_multi_topology_ipv6_multicast_create( - struct nb_cb_create_args *args); -int isis_instance_multi_topology_ipv6_multicast_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_multi_topology_ipv6_multicast_overload_modify( - struct nb_cb_modify_args *args); -int isis_instance_multi_topology_ipv6_management_create( - struct nb_cb_create_args *args); -int isis_instance_multi_topology_ipv6_management_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_multi_topology_ipv6_management_overload_modify( - struct nb_cb_modify_args *args); -int isis_instance_multi_topology_ipv6_dstsrc_create( - struct nb_cb_create_args *args); -int isis_instance_multi_topology_ipv6_dstsrc_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_multi_topology_ipv6_dstsrc_overload_modify( - struct nb_cb_modify_args *args); -int isis_instance_fast_reroute_level_1_lfa_load_sharing_modify( - struct nb_cb_modify_args *args); -int isis_instance_fast_reroute_level_1_lfa_priority_limit_modify( - struct nb_cb_modify_args *args); -int isis_instance_fast_reroute_level_1_lfa_priority_limit_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_fast_reroute_level_1_lfa_tiebreaker_create( - struct nb_cb_create_args *args); -int isis_instance_fast_reroute_level_1_lfa_tiebreaker_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_fast_reroute_level_1_lfa_tiebreaker_type_modify( - struct nb_cb_modify_args *args); -int isis_instance_fast_reroute_level_1_remote_lfa_prefix_list_modify( - struct nb_cb_modify_args *args); +int isis_instance_redistribute_ipv6_table_destroy(struct nb_cb_destroy_args *args); +int isis_instance_multi_topology_ipv4_multicast_create(struct nb_cb_create_args *args); +int isis_instance_multi_topology_ipv4_multicast_destroy(struct nb_cb_destroy_args *args); +int isis_instance_multi_topology_ipv4_multicast_overload_modify(struct nb_cb_modify_args *args); +int isis_instance_multi_topology_ipv4_management_create(struct nb_cb_create_args *args); +int isis_instance_multi_topology_ipv4_management_destroy(struct nb_cb_destroy_args *args); +int isis_instance_multi_topology_ipv4_management_overload_modify(struct nb_cb_modify_args *args); +int isis_instance_multi_topology_ipv6_unicast_create(struct nb_cb_create_args *args); +int isis_instance_multi_topology_ipv6_unicast_destroy(struct nb_cb_destroy_args *args); +int isis_instance_multi_topology_ipv6_unicast_overload_modify(struct nb_cb_modify_args *args); +int isis_instance_multi_topology_ipv6_multicast_create(struct nb_cb_create_args *args); +int isis_instance_multi_topology_ipv6_multicast_destroy(struct nb_cb_destroy_args *args); +int isis_instance_multi_topology_ipv6_multicast_overload_modify(struct nb_cb_modify_args *args); +int isis_instance_multi_topology_ipv6_management_create(struct nb_cb_create_args *args); +int isis_instance_multi_topology_ipv6_management_destroy(struct nb_cb_destroy_args *args); +int isis_instance_multi_topology_ipv6_management_overload_modify(struct nb_cb_modify_args *args); +int isis_instance_multi_topology_ipv6_dstsrc_create(struct nb_cb_create_args *args); +int isis_instance_multi_topology_ipv6_dstsrc_destroy(struct nb_cb_destroy_args *args); +int isis_instance_multi_topology_ipv6_dstsrc_overload_modify(struct nb_cb_modify_args *args); +int isis_instance_fast_reroute_level_1_lfa_load_sharing_modify(struct nb_cb_modify_args *args); +int isis_instance_fast_reroute_level_1_lfa_priority_limit_modify(struct nb_cb_modify_args *args); +int isis_instance_fast_reroute_level_1_lfa_priority_limit_destroy(struct nb_cb_destroy_args *args); +int isis_instance_fast_reroute_level_1_lfa_tiebreaker_create(struct nb_cb_create_args *args); +int isis_instance_fast_reroute_level_1_lfa_tiebreaker_destroy(struct nb_cb_destroy_args *args); +int isis_instance_fast_reroute_level_1_lfa_tiebreaker_type_modify(struct nb_cb_modify_args *args); +int isis_instance_fast_reroute_level_1_remote_lfa_prefix_list_modify(struct nb_cb_modify_args *args); int isis_instance_fast_reroute_level_1_remote_lfa_prefix_list_destroy( struct nb_cb_destroy_args *args); -int isis_instance_fast_reroute_level_2_lfa_load_sharing_modify( - struct nb_cb_modify_args *args); -int isis_instance_fast_reroute_level_2_lfa_priority_limit_modify( - struct nb_cb_modify_args *args); -int isis_instance_fast_reroute_level_2_lfa_priority_limit_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_fast_reroute_level_2_lfa_tiebreaker_create( - struct nb_cb_create_args *args); -int isis_instance_fast_reroute_level_2_lfa_tiebreaker_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_fast_reroute_level_2_lfa_tiebreaker_type_modify( - struct nb_cb_modify_args *args); -int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_modify( - struct nb_cb_modify_args *args); +int isis_instance_fast_reroute_level_2_lfa_load_sharing_modify(struct nb_cb_modify_args *args); +int isis_instance_fast_reroute_level_2_lfa_priority_limit_modify(struct nb_cb_modify_args *args); +int isis_instance_fast_reroute_level_2_lfa_priority_limit_destroy(struct nb_cb_destroy_args *args); +int isis_instance_fast_reroute_level_2_lfa_tiebreaker_create(struct nb_cb_create_args *args); +int isis_instance_fast_reroute_level_2_lfa_tiebreaker_destroy(struct nb_cb_destroy_args *args); +int isis_instance_fast_reroute_level_2_lfa_tiebreaker_type_modify(struct nb_cb_modify_args *args); +int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_modify(struct nb_cb_modify_args *args); int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_destroy( struct nb_cb_destroy_args *args); int isis_instance_log_adjacency_changes_modify(struct nb_cb_modify_args *args); @@ -212,12 +142,9 @@ int isis_instance_log_pdu_drops_modify(struct nb_cb_modify_args *args); int isis_instance_mpls_te_create(struct nb_cb_create_args *args); int isis_instance_mpls_te_destroy(struct nb_cb_destroy_args *args); int isis_instance_mpls_te_router_address_modify(struct nb_cb_modify_args *args); -int isis_instance_mpls_te_router_address_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_mpls_te_router_address_ipv6_modify( - struct nb_cb_modify_args *args); -int isis_instance_mpls_te_router_address_ipv6_destroy( - struct nb_cb_destroy_args *args); +int isis_instance_mpls_te_router_address_destroy(struct nb_cb_destroy_args *args); +int isis_instance_mpls_te_router_address_ipv6_modify(struct nb_cb_modify_args *args); +int isis_instance_mpls_te_router_address_ipv6_destroy(struct nb_cb_destroy_args *args); int isis_instance_mpls_te_export_modify(struct nb_cb_modify_args *args); int lib_interface_isis_create(struct nb_cb_create_args *args); int lib_interface_isis_destroy(struct nb_cb_destroy_args *args); @@ -225,34 +152,20 @@ int lib_interface_isis_area_tag_modify(struct nb_cb_modify_args *args); int lib_interface_isis_ipv4_routing_modify(struct nb_cb_modify_args *args); int lib_interface_isis_ipv6_routing_modify(struct nb_cb_modify_args *args); int lib_interface_isis_circuit_type_modify(struct nb_cb_modify_args *args); -void lib_interface_isis_bfd_monitoring_apply_finish( - struct nb_cb_apply_finish_args *args); -int lib_interface_isis_bfd_monitoring_enabled_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_bfd_monitoring_profile_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_bfd_monitoring_profile_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_segment_routing_enabled_modify( - struct nb_cb_modify_args *args); -int isis_instance_segment_routing_enabled_modify( - struct nb_cb_modify_args *args); -int isis_instance_segment_routing_srgb_lower_bound_modify( - struct nb_cb_modify_args *args); -int isis_instance_segment_routing_srgb_upper_bound_modify( - struct nb_cb_modify_args *args); -int isis_instance_segment_routing_srlb_lower_bound_modify( - struct nb_cb_modify_args *args); -int isis_instance_segment_routing_srlb_upper_bound_modify( - struct nb_cb_modify_args *args); -int isis_instance_segment_routing_msd_node_msd_modify( - struct nb_cb_modify_args *args); -int isis_instance_segment_routing_msd_node_msd_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_segment_routing_prefix_sid_map_prefix_sid_create( - struct nb_cb_create_args *args); -int isis_instance_segment_routing_prefix_sid_map_prefix_sid_destroy( - struct nb_cb_destroy_args *args); +void lib_interface_isis_bfd_monitoring_apply_finish(struct nb_cb_apply_finish_args *args); +int lib_interface_isis_bfd_monitoring_enabled_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_bfd_monitoring_profile_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_bfd_monitoring_profile_destroy(struct nb_cb_destroy_args *args); +int isis_instance_segment_routing_enabled_modify(struct nb_cb_modify_args *args); +int isis_instance_segment_routing_enabled_modify(struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srgb_lower_bound_modify(struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srgb_upper_bound_modify(struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srlb_lower_bound_modify(struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srlb_upper_bound_modify(struct nb_cb_modify_args *args); +int isis_instance_segment_routing_msd_node_msd_modify(struct nb_cb_modify_args *args); +int isis_instance_segment_routing_msd_node_msd_destroy(struct nb_cb_destroy_args *args); +int isis_instance_segment_routing_prefix_sid_map_prefix_sid_create(struct nb_cb_create_args *args); +int isis_instance_segment_routing_prefix_sid_map_prefix_sid_destroy(struct nb_cb_destroy_args *args); int isis_instance_segment_routing_prefix_sid_map_prefix_sid_sid_value_type_modify( struct nb_cb_modify_args *args); int isis_instance_segment_routing_prefix_sid_map_prefix_sid_sid_value_modify( @@ -261,10 +174,8 @@ int isis_instance_segment_routing_prefix_sid_map_prefix_sid_last_hop_behavior_mo struct nb_cb_modify_args *args); int isis_instance_segment_routing_prefix_sid_map_prefix_sid_n_flag_clear_modify( struct nb_cb_modify_args *args); -int isis_instance_segment_routing_algorithm_prefix_sid_create( - struct nb_cb_create_args *args); -int isis_instance_segment_routing_algorithm_prefix_sid_destroy( - struct nb_cb_destroy_args *args); +int isis_instance_segment_routing_algorithm_prefix_sid_create(struct nb_cb_create_args *args); +int isis_instance_segment_routing_algorithm_prefix_sid_destroy(struct nb_cb_destroy_args *args); int isis_instance_segment_routing_algorithm_prefix_sid_pre_validate( struct nb_cb_pre_validate_args *args); void isis_instance_segment_routing_algorithm_prefix_sid_apply_finish( @@ -279,95 +190,61 @@ int isis_instance_segment_routing_algorithm_prefix_sid_n_flag_clear_modify( struct nb_cb_modify_args *args); int isis_instance_flex_algo_create(struct nb_cb_create_args *args); int isis_instance_flex_algo_destroy(struct nb_cb_destroy_args *args); -int isis_instance_flex_algo_advertise_definition_modify( - struct nb_cb_modify_args *args); -int isis_instance_flex_algo_advertise_definition_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_flex_algo_affinity_include_any_create( - struct nb_cb_create_args *args); -int isis_instance_flex_algo_affinity_include_any_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_flex_algo_affinity_include_all_create( - struct nb_cb_create_args *args); -int isis_instance_flex_algo_affinity_include_all_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_flex_algo_affinity_exclude_any_create( - struct nb_cb_create_args *args); -int isis_instance_flex_algo_affinity_exclude_any_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_flex_algo_prefix_metric_create( - struct nb_cb_create_args *args); -int isis_instance_flex_algo_prefix_metric_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_flex_algo_dplane_sr_mpls_create( - struct nb_cb_create_args *args); -int isis_instance_flex_algo_dplane_sr_mpls_destroy( - struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_advertise_definition_modify(struct nb_cb_modify_args *args); +int isis_instance_flex_algo_advertise_definition_destroy(struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_affinity_include_any_create(struct nb_cb_create_args *args); +int isis_instance_flex_algo_affinity_include_any_destroy(struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_affinity_include_all_create(struct nb_cb_create_args *args); +int isis_instance_flex_algo_affinity_include_all_destroy(struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_affinity_exclude_any_create(struct nb_cb_create_args *args); +int isis_instance_flex_algo_affinity_exclude_any_destroy(struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_prefix_metric_create(struct nb_cb_create_args *args); +int isis_instance_flex_algo_prefix_metric_destroy(struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_dplane_sr_mpls_create(struct nb_cb_create_args *args); +int isis_instance_flex_algo_dplane_sr_mpls_destroy(struct nb_cb_destroy_args *args); int isis_instance_flex_algo_dplane_srv6_create(struct nb_cb_create_args *args); -int isis_instance_flex_algo_dplane_srv6_destroy( - struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_dplane_srv6_destroy(struct nb_cb_destroy_args *args); int isis_instance_flex_algo_dplane_ip_create(struct nb_cb_create_args *args); int isis_instance_flex_algo_dplane_ip_destroy(struct nb_cb_destroy_args *args); int isis_instance_flex_algo_metric_type_modify(struct nb_cb_modify_args *args); int isis_instance_flex_algo_priority_modify(struct nb_cb_modify_args *args); int isis_instance_flex_algo_priority_destroy(struct nb_cb_destroy_args *args); int isis_instance_flex_algo_frr_disable_modify(struct nb_cb_modify_args *args); -int isis_instance_flex_algo_frr_disable_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_flex_algo_affinity_mapping_create( - struct nb_cb_create_args *args); -int isis_instance_flex_algo_affinity_mapping_destroy( - struct nb_cb_destroy_args *args); -int isis_instance_flex_algo_affinity_mapping_value_modify( - struct nb_cb_modify_args *args); -int isis_instance_flex_algo_affinity_mapping_value_destroy( - struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_frr_disable_destroy(struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_affinity_mapping_create(struct nb_cb_create_args *args); +int isis_instance_flex_algo_affinity_mapping_destroy(struct nb_cb_destroy_args *args); +int isis_instance_flex_algo_affinity_mapping_value_modify(struct nb_cb_modify_args *args); +int isis_instance_flex_algo_affinity_mapping_value_destroy(struct nb_cb_destroy_args *args); void cli_show_isis_srv6_end(struct vty *vty, const struct lyd_node *dnode); -int isis_instance_segment_routing_srv6_enabled_modify( - struct nb_cb_modify_args *args); -void cli_show_isis_srv6_enabled(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -int isis_instance_segment_routing_srv6_locator_modify( - struct nb_cb_modify_args *args); -int isis_instance_segment_routing_srv6_locator_destroy( - struct nb_cb_destroy_args *args); -void cli_show_isis_srv6_locator(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); +int isis_instance_segment_routing_srv6_enabled_modify(struct nb_cb_modify_args *args); +void cli_show_isis_srv6_enabled(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +int isis_instance_segment_routing_srv6_locator_modify(struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srv6_locator_destroy(struct nb_cb_destroy_args *args); +void cli_show_isis_srv6_locator(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); int isis_instance_segment_routing_srv6_msd_node_msd_max_segs_left_modify( struct nb_cb_modify_args *args); int isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_modify( struct nb_cb_modify_args *args); int isis_instance_segment_routing_srv6_msd_node_msd_max_h_encaps_modify( struct nb_cb_modify_args *args); -int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_modify( - struct nb_cb_modify_args *args); -void cli_show_isis_srv6_node_msd(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_modify(struct nb_cb_modify_args *args); +void cli_show_isis_srv6_node_msd(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); void cli_show_isis_srv6_node_msd_end(struct vty *vty, const struct lyd_node *dnode); -int isis_instance_segment_routing_srv6_interface_modify( - struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srv6_interface_modify(struct nb_cb_modify_args *args); void cli_show_isis_srv6_interface(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); + bool show_defaults); int isis_instance_mpls_ldp_sync_destroy(struct nb_cb_destroy_args *args); int isis_instance_mpls_ldp_sync_create(struct nb_cb_create_args *args); int isis_instance_mpls_ldp_sync_holddown_modify(struct nb_cb_modify_args *args); -int lib_interface_isis_csnp_interval_level_1_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_csnp_interval_level_2_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_psnp_interval_level_1_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_psnp_interval_level_2_modify( - struct nb_cb_modify_args *args); +int lib_interface_isis_csnp_interval_level_1_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_csnp_interval_level_2_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_psnp_interval_level_1_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_psnp_interval_level_2_modify(struct nb_cb_modify_args *args); int lib_interface_isis_hello_padding_modify(struct nb_cb_modify_args *args); -int lib_interface_isis_hello_interval_level_1_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_hello_interval_level_2_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_hello_multiplier_level_1_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_hello_multiplier_level_2_modify( - struct nb_cb_modify_args *args); +int lib_interface_isis_hello_interval_level_1_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_hello_interval_level_2_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_hello_multiplier_level_1_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_hello_multiplier_level_2_modify(struct nb_cb_modify_args *args); int lib_interface_isis_metric_level_1_modify(struct nb_cb_modify_args *args); int lib_interface_isis_metric_level_2_modify(struct nb_cb_modify_args *args); int lib_interface_isis_priority_level_1_modify(struct nb_cb_modify_args *args); @@ -377,89 +254,67 @@ int lib_interface_isis_passive_modify(struct nb_cb_modify_args *args); int lib_interface_isis_password_create(struct nb_cb_create_args *args); int lib_interface_isis_password_destroy(struct nb_cb_destroy_args *args); int lib_interface_isis_password_password_modify(struct nb_cb_modify_args *args); -int lib_interface_isis_password_password_type_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_disable_three_way_handshake_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_multi_topology_standard_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_multi_topology_ipv4_multicast_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_multi_topology_ipv4_management_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_multi_topology_ipv6_unicast_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_multi_topology_ipv6_multicast_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_multi_topology_ipv6_management_modify( - struct nb_cb_modify_args *args); -int lib_interface_isis_multi_topology_ipv6_dstsrc_modify( - struct nb_cb_modify_args *args); +int lib_interface_isis_password_password_type_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_disable_three_way_handshake_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_multi_topology_standard_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_multi_topology_ipv4_multicast_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_multi_topology_ipv4_management_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_multi_topology_ipv6_unicast_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_multi_topology_ipv6_multicast_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_multi_topology_ipv6_management_modify(struct nb_cb_modify_args *args); +int lib_interface_isis_multi_topology_ipv6_dstsrc_modify(struct nb_cb_modify_args *args); int lib_interface_isis_mpls_ldp_sync_modify(struct nb_cb_modify_args *args); int lib_interface_isis_mpls_holddown_modify(struct nb_cb_modify_args *args); int lib_interface_isis_mpls_holddown_destroy(struct nb_cb_destroy_args *args); -int lib_interface_isis_fast_reroute_level_1_lfa_enable_modify( - struct nb_cb_modify_args *args); +int lib_interface_isis_fast_reroute_level_1_lfa_enable_modify(struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_1_lfa_exclude_interface_create( struct nb_cb_create_args *args); int lib_interface_isis_fast_reroute_level_1_lfa_exclude_interface_destroy( struct nb_cb_destroy_args *args); -int lib_interface_isis_fast_reroute_level_1_remote_lfa_enable_modify( - struct nb_cb_modify_args *args); +int lib_interface_isis_fast_reroute_level_1_remote_lfa_enable_modify(struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_1_remote_lfa_maximum_metric_modify( struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_1_remote_lfa_maximum_metric_destroy( struct nb_cb_destroy_args *args); -int lib_interface_isis_fast_reroute_level_1_ti_lfa_enable_modify( - struct nb_cb_modify_args *args); +int lib_interface_isis_fast_reroute_level_1_ti_lfa_enable_modify(struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_1_ti_lfa_node_protection_modify( struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_1_ti_lfa_link_fallback_modify( struct nb_cb_modify_args *args); -int lib_interface_isis_fast_reroute_level_2_lfa_enable_modify( - struct nb_cb_modify_args *args); +int lib_interface_isis_fast_reroute_level_2_lfa_enable_modify(struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_2_lfa_exclude_interface_create( struct nb_cb_create_args *args); int lib_interface_isis_fast_reroute_level_2_lfa_exclude_interface_destroy( struct nb_cb_destroy_args *args); -int lib_interface_isis_fast_reroute_level_2_remote_lfa_enable_modify( - struct nb_cb_modify_args *args); +int lib_interface_isis_fast_reroute_level_2_remote_lfa_enable_modify(struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_2_remote_lfa_maximum_metric_modify( struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_2_remote_lfa_maximum_metric_destroy( struct nb_cb_destroy_args *args); -int lib_interface_isis_fast_reroute_level_2_ti_lfa_enable_modify( - struct nb_cb_modify_args *args); +int lib_interface_isis_fast_reroute_level_2_ti_lfa_enable_modify(struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_2_ti_lfa_node_protection_modify( struct nb_cb_modify_args *args); int lib_interface_isis_fast_reroute_level_2_ti_lfa_link_fallback_modify( struct nb_cb_modify_args *args); -struct yang_data * -lib_interface_state_isis_get_elem(struct nb_cb_get_elem_args *args); -const void *lib_interface_state_isis_adjacencies_adjacency_get_next( - struct nb_cb_get_next_args *args); -struct yang_data * -lib_interface_state_isis_adjacencies_adjacency_neighbor_sys_type_get_elem( +struct yang_data *lib_interface_state_isis_get_elem(struct nb_cb_get_elem_args *args); +const void * +lib_interface_state_isis_adjacencies_adjacency_get_next(struct nb_cb_get_next_args *args); +struct yang_data *lib_interface_state_isis_adjacencies_adjacency_neighbor_sys_type_get_elem( struct nb_cb_get_elem_args *args); -struct yang_data * -lib_interface_state_isis_adjacencies_adjacency_neighbor_sysid_get_elem( +struct yang_data *lib_interface_state_isis_adjacencies_adjacency_neighbor_sysid_get_elem( struct nb_cb_get_elem_args *args); struct yang_data * lib_interface_state_isis_adjacencies_adjacency_neighbor_extended_circuit_id_get_elem( struct nb_cb_get_elem_args *args); -struct yang_data * -lib_interface_state_isis_adjacencies_adjacency_neighbor_snpa_get_elem( - struct nb_cb_get_elem_args *args); -struct yang_data * -lib_interface_state_isis_adjacencies_adjacency_hold_timer_get_elem( +struct yang_data *lib_interface_state_isis_adjacencies_adjacency_neighbor_snpa_get_elem( struct nb_cb_get_elem_args *args); -struct yang_data * -lib_interface_state_isis_adjacencies_adjacency_neighbor_priority_get_elem( +struct yang_data *lib_interface_state_isis_adjacencies_adjacency_hold_timer_get_elem( struct nb_cb_get_elem_args *args); -struct yang_data *lib_interface_state_isis_adjacencies_adjacency_state_get_elem( +struct yang_data *lib_interface_state_isis_adjacencies_adjacency_neighbor_priority_get_elem( struct nb_cb_get_elem_args *args); -const void * -lib_interface_state_isis_adjacencies_adjacency_adjacency_sids_adjacency_sid_get_next( +struct yang_data * +lib_interface_state_isis_adjacencies_adjacency_state_get_elem(struct nb_cb_get_elem_args *args); +const void *lib_interface_state_isis_adjacencies_adjacency_adjacency_sids_adjacency_sid_get_next( struct nb_cb_get_next_args *args); struct yang_data * lib_interface_state_isis_adjacencies_adjacency_adjacency_sids_adjacency_sid_af_get_elem( @@ -488,355 +343,250 @@ lib_interface_state_isis_adjacencies_adjacency_lan_adjacency_sids_lan_adjacency_ struct yang_data * lib_interface_state_isis_adjacencies_adjacency_lan_adjacency_sids_lan_adjacency_sid_protection_requested_get_elem( struct nb_cb_get_elem_args *args); -struct yang_data * -lib_interface_state_isis_event_counters_adjacency_changes_get_elem( - struct nb_cb_get_elem_args *args); -struct yang_data * -lib_interface_state_isis_event_counters_adjacency_number_get_elem( - struct nb_cb_get_elem_args *args); -struct yang_data *lib_interface_state_isis_event_counters_init_fails_get_elem( +struct yang_data *lib_interface_state_isis_event_counters_adjacency_changes_get_elem( struct nb_cb_get_elem_args *args); struct yang_data * -lib_interface_state_isis_event_counters_adjacency_rejects_get_elem( - struct nb_cb_get_elem_args *args); +lib_interface_state_isis_event_counters_adjacency_number_get_elem(struct nb_cb_get_elem_args *args); struct yang_data * -lib_interface_state_isis_event_counters_id_len_mismatch_get_elem( +lib_interface_state_isis_event_counters_init_fails_get_elem(struct nb_cb_get_elem_args *args); +struct yang_data *lib_interface_state_isis_event_counters_adjacency_rejects_get_elem( struct nb_cb_get_elem_args *args); struct yang_data * -lib_interface_state_isis_event_counters_max_area_addresses_mismatch_get_elem( +lib_interface_state_isis_event_counters_id_len_mismatch_get_elem(struct nb_cb_get_elem_args *args); +struct yang_data *lib_interface_state_isis_event_counters_max_area_addresses_mismatch_get_elem( struct nb_cb_get_elem_args *args); -struct yang_data * -lib_interface_state_isis_event_counters_authentication_type_fails_get_elem( +struct yang_data *lib_interface_state_isis_event_counters_authentication_type_fails_get_elem( struct nb_cb_get_elem_args *args); -struct yang_data * -lib_interface_state_isis_event_counters_authentication_fails_get_elem( +struct yang_data *lib_interface_state_isis_event_counters_authentication_fails_get_elem( struct nb_cb_get_elem_args *args); /* Optional 'pre_validate' callbacks. */ int isis_instance_segment_routing_prefix_sid_map_prefix_sid_pre_validate( struct nb_cb_pre_validate_args *args); -int isis_instance_segment_routing_label_blocks_pre_validate( - struct nb_cb_pre_validate_args *args); +int isis_instance_segment_routing_label_blocks_pre_validate(struct nb_cb_pre_validate_args *args); /* Optional 'apply_finish' callbacks. */ void ietf_backoff_delay_apply_finish(struct nb_cb_apply_finish_args *args); void area_password_apply_finish(struct nb_cb_apply_finish_args *args); void domain_password_apply_finish(struct nb_cb_apply_finish_args *args); void default_info_origin_apply_finish(const struct lyd_node *dnode, int family); -void default_info_origin_ipv4_apply_finish( - struct nb_cb_apply_finish_args *args); -void default_info_origin_ipv6_apply_finish( - struct nb_cb_apply_finish_args *args); +void default_info_origin_ipv4_apply_finish(struct nb_cb_apply_finish_args *args); +void default_info_origin_ipv6_apply_finish(struct nb_cb_apply_finish_args *args); void redistribute_apply_finish(const struct lyd_node *dnode, int family); void redistribute_ipv4_apply_finish(struct nb_cb_apply_finish_args *args); void redistribute_ipv6_apply_finish(struct nb_cb_apply_finish_args *args); -void isis_instance_segment_routing_srgb_apply_finish( - struct nb_cb_apply_finish_args *args); -void isis_instance_segment_routing_srlb_apply_finish( - struct nb_cb_apply_finish_args *args); +void isis_instance_segment_routing_srgb_apply_finish(struct nb_cb_apply_finish_args *args); +void isis_instance_segment_routing_srlb_apply_finish(struct nb_cb_apply_finish_args *args); void isis_instance_segment_routing_prefix_sid_map_prefix_sid_apply_finish( struct nb_cb_apply_finish_args *args); /* Optional 'cli_show' callbacks. */ -void cli_show_router_isis(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); +void cli_show_router_isis(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); void cli_show_router_isis_end(struct vty *vty, const struct lyd_node *dnode); -void cli_show_ip_isis_ipv4(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_ipv6(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_bfd_monitoring(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_ipv4(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_ip_isis_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_ip_isis_bfd_monitoring(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_area_address(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_is_type(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_dynamic_hostname(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_area_address(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_is_type(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_dynamic_hostname(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_attached_send(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_attached_receive(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_attached_send(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_attached_receive(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_overload(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_overload_on_startup(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_overload(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_overload_on_startup(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_advertise_high_metrics(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_advertise_high_metrics(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_metric_style(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_area_pwd(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_domain_pwd(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_lsp_timers(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_lsp_mtu(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_advertise_passive_only(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_metric_style(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_area_pwd(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_domain_pwd(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_lsp_timers(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_lsp_mtu(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_advertise_passive_only(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_spf_min_interval(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_spf_min_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_spf_ietf_backoff(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_spf_ietf_backoff(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_spf_prefix_priority(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_spf_prefix_priority(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_purge_origin(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mpls_te(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_admin_group_send_zero(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_purge_origin(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_mpls_te(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_admin_group_send_zero(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_asla_legacy_flag(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_asla_legacy_flag(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_mpls_te_router_addr(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mpls_te_router_addr(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_mpls_te_router_addr_ipv6(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mpls_te_router_addr_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); void cli_show_isis_mpls_te_export(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_def_origin_ipv4(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_def_origin_ipv4(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_def_origin_ipv6(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_def_origin_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_redistribute_ipv4(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_redistribute_ipv4(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_redistribute_ipv6(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_redistribute_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_mt_ipv4_multicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mt_ipv4_multicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_redistribute_ipv4_table(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_redistribute_ipv4_table(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_redistribute_ipv6_table(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_redistribute_ipv6_table(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mt_ipv6_unicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_mt_ipv6_unicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_mt_ipv6_multicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mt_ipv6_multicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); +void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_sr_enabled(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_label_blocks(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_node_msd(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_prefix_sid(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_prefix_sid_algorithm(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_sr_enabled(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_label_blocks(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_node_msd(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_prefix_sid(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_prefix_sid_algorithm(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_frr_lfa_priority_limit(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_frr_lfa_priority_limit(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_frr_lfa_tiebreaker(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_frr_lfa_tiebreaker(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_frr_lfa_load_sharing(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_frr_lfa_load_sharing(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_frr_remote_lfa_plist(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_frr_remote_lfa_plist(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_passive(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_password(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_metric(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_hello_interval(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_passive(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_ip_isis_password(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_ip_isis_metric(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_ip_isis_hello_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); void cli_show_ip_isis_hello_multi(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_threeway_shake(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_threeway_shake(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_hello_padding(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_hello_padding(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_csnp_interval(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_csnp_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_psnp_interval(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_psnp_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); void cli_show_ip_isis_mt_standard(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_frr_lfa_exclude_interface(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_frr_lfa_exclude_interface(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_frr_remote_lfa_max_metric(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_frr_remote_lfa_max_metric(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_circ_type(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_ip_isis_network_type(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_circ_type(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_ip_isis_network_type(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_ip_isis_priority(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_log_adjacency(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_log_pdu_drops(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mpls_ldp_sync(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); -void cli_show_isis_mpls_ldp_sync_holddown(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_ip_isis_priority(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_log_adjacency(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_log_pdu_drops(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_mpls_ldp_sync(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_mpls_ldp_sync_holddown(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_mpls_if_ldp_sync(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mpls_if_ldp_sync(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_mpls_if_ldp_sync_holddown(struct vty *vty, - const struct lyd_node *dnode, +void cli_show_isis_mpls_if_ldp_sync_holddown(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); -void cli_show_isis_flex_algo(struct vty *vty, const struct lyd_node *dnode, - bool show_defaults); +void cli_show_isis_flex_algo(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); void cli_show_isis_flex_algo_end(struct vty *vty, const struct lyd_node *dnode); /* Notifications. */ void isis_notif_db_overload(const struct isis_area *area, bool overload); -void isis_notif_lsp_too_large(const struct isis_circuit *circuit, - uint32_t pdu_size, const uint8_t *lsp_id); +void isis_notif_lsp_too_large(const struct isis_circuit *circuit, uint32_t pdu_size, + const uint8_t *lsp_id); void isis_notif_if_state_change(const struct isis_circuit *circuit, bool down); void isis_notif_corrupted_lsp(const struct isis_area *area, const uint8_t *lsp_id); /* currently unused */ -void isis_notif_lsp_exceed_max(const struct isis_area *area, - const uint8_t *lsp_id); -void isis_notif_max_area_addr_mismatch(const struct isis_circuit *circuit, - uint8_t max_area_addrs, +void isis_notif_lsp_exceed_max(const struct isis_area *area, const uint8_t *lsp_id); +void isis_notif_max_area_addr_mismatch(const struct isis_circuit *circuit, uint8_t max_area_addrs, const char *raw_pdu, size_t raw_pdu_len); void isis_notif_authentication_type_failure(const struct isis_circuit *circuit, - const char *raw_pdu, - size_t raw_pdu_len); -void isis_notif_authentication_failure(const struct isis_circuit *circuit, - const char *raw_pdu, size_t raw_pdu_len); -void isis_notif_adj_state_change(const struct isis_adjacency *adj, - int new_state, const char *reason); -void isis_notif_reject_adjacency(const struct isis_circuit *circuit, - const char *reason, const char *raw_pdu, - size_t raw_pdu_len); -void isis_notif_area_mismatch(const struct isis_circuit *circuit, - const char *raw_pdu, size_t raw_pdu_len); + const char *raw_pdu, size_t raw_pdu_len); +void isis_notif_authentication_failure(const struct isis_circuit *circuit, const char *raw_pdu, + size_t raw_pdu_len); +void isis_notif_adj_state_change(const struct isis_adjacency *adj, int new_state, + const char *reason); +void isis_notif_reject_adjacency(const struct isis_circuit *circuit, const char *reason, + const char *raw_pdu, size_t raw_pdu_len); +void isis_notif_area_mismatch(const struct isis_circuit *circuit, const char *raw_pdu, + size_t raw_pdu_len); void isis_notif_lsp_received(const struct isis_circuit *circuit, const uint8_t *lsp_id, uint32_t seqno, time_t timestamp, const char *sys_id); void isis_notif_lsp_gen(const struct isis_area *area, const uint8_t *lsp_id, uint32_t seqno, time_t timestamp); -void isis_notif_id_len_mismatch(const struct isis_circuit *circuit, - uint8_t rcv_id_len, const char *raw_pdu, - size_t raw_pdu_len); -void isis_notif_version_skew(const struct isis_circuit *circuit, - uint8_t version, const char *raw_pdu, - size_t raw_pdu_len); -void isis_notif_lsp_error(const struct isis_circuit *circuit, - const uint8_t *lsp_id, const char *raw_pdu, - size_t raw_pdu_len, uint32_t offset, +void isis_notif_id_len_mismatch(const struct isis_circuit *circuit, uint8_t rcv_id_len, + const char *raw_pdu, size_t raw_pdu_len); +void isis_notif_version_skew(const struct isis_circuit *circuit, uint8_t version, + const char *raw_pdu, size_t raw_pdu_len); +void isis_notif_lsp_error(const struct isis_circuit *circuit, const uint8_t *lsp_id, + const char *raw_pdu, size_t raw_pdu_len, uint32_t offset, uint8_t tlv_type); -void isis_notif_seqno_skipped(const struct isis_circuit *circuit, - const uint8_t *lsp_id); -void isis_notif_own_lsp_purge(const struct isis_circuit *circuit, - const uint8_t *lsp_id); +void isis_notif_seqno_skipped(const struct isis_circuit *circuit, const uint8_t *lsp_id); +void isis_notif_own_lsp_purge(const struct isis_circuit *circuit, const uint8_t *lsp_id); /* cmp */ -int cli_cmp_isis_redistribute_table(const struct lyd_node *dnode1, - const struct lyd_node *dnode2); +int cli_cmp_isis_redistribute_table(const struct lyd_node *dnode1, const struct lyd_node *dnode2); /* We also declare hook for every notification */ DECLARE_HOOK(isis_hook_db_overload, (const struct isis_area *area), (area)); DECLARE_HOOK(isis_hook_lsp_too_large, - (const struct isis_circuit *circuit, uint32_t pdu_size, - const uint8_t *lsp_id), + (const struct isis_circuit *circuit, uint32_t pdu_size, const uint8_t *lsp_id), (circuit, pdu_size, lsp_id)); /* Note: no isis_hook_corrupted_lsp - because this notificaiton is not used */ -DECLARE_HOOK(isis_hook_lsp_exceed_max, - (const struct isis_area *area, const uint8_t *lsp_id), +DECLARE_HOOK(isis_hook_lsp_exceed_max, (const struct isis_area *area, const uint8_t *lsp_id), (area, lsp_id)); DECLARE_HOOK(isis_hook_max_area_addr_mismatch, - (const struct isis_circuit *circuit, uint8_t max_addrs, - const char *raw_pdu, size_t raw_pdu_len), + (const struct isis_circuit *circuit, uint8_t max_addrs, const char *raw_pdu, + size_t raw_pdu_len), (circuit, max_addrs, raw_pdu, raw_pdu_len)); DECLARE_HOOK(isis_hook_authentication_type_failure, - (const struct isis_circuit *circuit, const char *raw_pdu, - size_t raw_pdu_len), + (const struct isis_circuit *circuit, const char *raw_pdu, size_t raw_pdu_len), (circuit, raw_pdu, raw_pdu_len)); DECLARE_HOOK(isis_hook_authentication_failure, - (const struct isis_circuit *circuit, const char *raw_pdu, - size_t raw_pdu_len), + (const struct isis_circuit *circuit, const char *raw_pdu, size_t raw_pdu_len), (circuit, raw_pdu, raw_pdu_len)); -DECLARE_HOOK(isis_hook_adj_state_change, (const struct isis_adjacency *adj), - (adj)); +DECLARE_HOOK(isis_hook_adj_state_change, (const struct isis_adjacency *adj), (adj)); DECLARE_HOOK(isis_hook_reject_adjacency, - (const struct isis_circuit *circuit, const char *pdu, - size_t pdu_len), + (const struct isis_circuit *circuit, const char *pdu, size_t pdu_len), (circuit, pdu, pdu_len)); DECLARE_HOOK(isis_hook_area_mismatch, - (const struct isis_circuit *circuit, const char *raw_pdu, - size_t raw_pdu_len), + (const struct isis_circuit *circuit, const char *raw_pdu, size_t raw_pdu_len), (circuit)); DECLARE_HOOK(isis_hook_id_len_mismatch, - (const struct isis_circuit *circuit, uint8_t rcv_id_len, - const char *raw_pdu, size_t raw_pdu_len), + (const struct isis_circuit *circuit, uint8_t rcv_id_len, const char *raw_pdu, + size_t raw_pdu_len), (circuit, rcv_id_len, raw_pdu, raw_pdu_len)); DECLARE_HOOK(isis_hook_version_skew, - (const struct isis_circuit *circuit, uint8_t version, - const char *raw_pdu, size_t raw_pdu_len), + (const struct isis_circuit *circuit, uint8_t version, const char *raw_pdu, + size_t raw_pdu_len), (circuit)); DECLARE_HOOK(isis_hook_lsp_error, - (const struct isis_circuit *circuit, const uint8_t *lsp_id, - const char *raw_pdu, size_t raw_pdu_len), + (const struct isis_circuit *circuit, const uint8_t *lsp_id, const char *raw_pdu, + size_t raw_pdu_len), (circuit)); -DECLARE_HOOK(isis_hook_seqno_skipped, - (const struct isis_circuit *circuit, const uint8_t *lsp_id), +DECLARE_HOOK(isis_hook_seqno_skipped, (const struct isis_circuit *circuit, const uint8_t *lsp_id), (circuit, lsp_id)); -DECLARE_HOOK(isis_hook_own_lsp_purge, - (const struct isis_circuit *circuit, const uint8_t *lsp_id), +DECLARE_HOOK(isis_hook_own_lsp_purge, (const struct isis_circuit *circuit, const uint8_t *lsp_id), (circuit, lsp_id)); #endif /* ISISD_ISIS_NB_H_ */ diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c index 6bd3b39bc712..baf666e718f5 100644 --- a/isisd/isis_nb_config.c +++ b/isisd/isis_nb_config.c @@ -86,7 +86,7 @@ int isis_instance_destroy(struct nb_cb_destroy_args *args) isis = area->isis; isis_area_destroy(area); - if (listcount(isis->area_list) == 0) + if (isis_area_list_count(&isis->area_list) == 0) isis_finish(isis); return NB_OK; @@ -139,7 +139,6 @@ int isis_instance_area_address_create(struct nb_cb_create_args *args) { struct isis_area *area; struct iso_address addr, *addrr = NULL, *addrp = NULL; - struct listnode *node; struct sysid_iter iter; uint8_t buff[255]; const char *net_title = yang_dnode_get_string(args->dnode, NULL); @@ -149,28 +148,24 @@ int isis_instance_area_address_create(struct nb_cb_create_args *args) addr.addr_len = dotformat2buff(buff, net_title); memcpy(addr.area_addr, buff, addr.addr_len); if (addr.area_addr[addr.addr_len - 1] != 0) { - snprintf( - args->errmsg, args->errmsg_len, - "nsel byte (last byte) in area address must be 0"); + snprintf(args->errmsg, args->errmsg_len, + "nsel byte (last byte) in area address must be 0"); return NB_ERR_VALIDATION; } iter.addr = &addr; iter.same = true; - yang_dnode_iterate(sysid_iter_cb, &iter, args->dnode, - "../area-address"); + yang_dnode_iterate(sysid_iter_cb, &iter, args->dnode, "../area-address"); if (!iter.same) { - snprintf( - args->errmsg, args->errmsg_len, - "System ID must not change when defining additional area addresses"); + snprintf(args->errmsg, args->errmsg_len, + "System ID must not change when defining additional area addresses"); return NB_ERR_VALIDATION; } break; case NB_EV_PREPARE: - addrr = XMALLOC(MTYPE_ISIS_AREA_ADDR, - sizeof(struct iso_address)); + addrr = XMALLOC(MTYPE_ISIS_AREA_ADDR, sizeof(struct iso_address)); addrr->addr_len = dotformat2buff(buff, net_title); memcpy(addrr->area_addr, buff, addrr->addr_len); args->resource->ptr = addrr; @@ -187,19 +182,15 @@ int isis_instance_area_address_create(struct nb_cb_create_args *args) /* * First area address - get the SystemID for this router */ - memcpy(area->isis->sysid, GETSYSID(addrr), - ISIS_SYS_ID_LEN); + memcpy(area->isis->sysid, GETSYSID(addrr), ISIS_SYS_ID_LEN); area->isis->sysid_set = 1; } else { /* check that we don't already have this address */ - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, - addrp)) { - if ((addrp->addr_len + ISIS_SYS_ID_LEN - + ISIS_NSEL_LEN) - != (addrr->addr_len)) + frr_each (iso_address_list, &area->area_addrs, addrp) { + if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != + (addrr->addr_len)) continue; - if (!memcmp(addrp->area_addr, addrr->area_addr, - addrr->addr_len)) { + if (!memcmp(addrp->area_addr, addrr->area_addr, addrr->addr_len)) { XFREE(MTYPE_ISIS_AREA_ADDR, addrr); return NB_OK; /* silent fail */ } @@ -208,11 +199,10 @@ int isis_instance_area_address_create(struct nb_cb_create_args *args) /*Forget the systemID part of the address */ addrr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN); - assert(area->area_addrs); /* to silence scan-build sillyness */ - listnode_add(area->area_addrs, addrr); + iso_address_list_add_tail(&area->area_addrs, addrr); /* only now we can safely generate our LSPs for this area */ - if (listcount(area->area_addrs) > 0) { + if (iso_address_list_count(&area->area_addrs) > 0) { if (area->is_type & IS_LEVEL_1) lsp_generate(area, IS_LEVEL_1); if (area->is_type & IS_LEVEL_2) @@ -227,11 +217,9 @@ int isis_instance_area_address_create(struct nb_cb_create_args *args) int isis_instance_area_address_destroy(struct nb_cb_destroy_args *args) { struct iso_address addr, *addrp = NULL; - struct listnode *node; uint8_t buff[255]; struct isis_area *area; const char *net_title; - struct listnode *cnode; struct isis_circuit *circuit; int lvl; @@ -243,22 +231,21 @@ int isis_instance_area_address_destroy(struct nb_cb_destroy_args *args) memcpy(addr.area_addr, buff, (int)addr.addr_len); area = nb_running_get_entry(args->dnode, NULL, true); - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) { - if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len - && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len)) + frr_each (iso_address_list, &area->area_addrs, addrp) { + if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len && + !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len)) break; } if (!addrp) return NB_ERR_INCONSISTENCY; - listnode_delete(area->area_addrs, addrp); + iso_address_list_del(&area->area_addrs, addrp); /* * Last area address - reset the SystemID for this router */ - if (!memcmp(addrp->area_addr + addrp->addr_len, area->isis->sysid, - ISIS_SYS_ID_LEN) && - listcount(area->area_addrs) == 0) { - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) + if (!memcmp(addrp->area_addr + addrp->addr_len, area->isis->sysid, ISIS_SYS_ID_LEN) && + iso_address_list_count(&area->area_addrs) == 0) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) { if (circuit->u.bc.is_dr[lvl - 1]) isis_dr_resign(circuit, lvl); @@ -397,8 +384,7 @@ int isis_instance_metric_style_modify(struct nb_cb_modify_args *args) { struct isis_area *area; bool old_metric, new_metric; - enum isis_metric_style metric_style = - yang_dnode_get_enum(args->dnode, NULL); + enum isis_metric_style metric_style = yang_dnode_get_enum(args->dnode, NULL); if (args->event != NB_EV_APPLY) return NB_OK; @@ -445,28 +431,20 @@ int isis_instance_admin_group_send_zero_modify(struct nb_cb_modify_args *args) area->admin_group_send_zero = yang_dnode_get_bool(args->dnode, NULL); if (area->admin_group_send_zero) { - for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, - fa)) { - admin_group_allow_explicit_zero( - &fa->admin_group_exclude_any); - admin_group_allow_explicit_zero( - &fa->admin_group_include_any); - admin_group_allow_explicit_zero( - &fa->admin_group_include_all); + for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, fa)) { + admin_group_allow_explicit_zero(&fa->admin_group_exclude_any); + admin_group_allow_explicit_zero(&fa->admin_group_include_any); + admin_group_allow_explicit_zero(&fa->admin_group_include_all); } } else { - for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, - fa)) { - admin_group_disallow_explicit_zero( - &fa->admin_group_exclude_any); - admin_group_disallow_explicit_zero( - &fa->admin_group_include_any); - admin_group_disallow_explicit_zero( - &fa->admin_group_include_all); + for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, fa)) { + admin_group_disallow_explicit_zero(&fa->admin_group_exclude_any); + admin_group_disallow_explicit_zero(&fa->admin_group_include_any); + admin_group_disallow_explicit_zero(&fa->admin_group_include_all); } } - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) isis_link_params_update(circuit, circuit->interface); lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); @@ -537,8 +515,7 @@ int isis_instance_advertise_passive_only_modify(struct nb_cb_modify_args *args) /* * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/refresh-interval */ -int isis_instance_lsp_refresh_interval_level_1_modify( - struct nb_cb_modify_args *args) +int isis_instance_lsp_refresh_interval_level_1_modify(struct nb_cb_modify_args *args) { struct isis_area *area; uint16_t refr_int; @@ -556,8 +533,7 @@ int isis_instance_lsp_refresh_interval_level_1_modify( /* * XPath: /frr-isisd:isis/instance/lsp/timers/level-2/refresh-interval */ -int isis_instance_lsp_refresh_interval_level_2_modify( - struct nb_cb_modify_args *args) +int isis_instance_lsp_refresh_interval_level_2_modify(struct nb_cb_modify_args *args) { struct isis_area *area; uint16_t refr_int; @@ -575,8 +551,7 @@ int isis_instance_lsp_refresh_interval_level_2_modify( /* * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/maximum-lifetime */ -int isis_instance_lsp_maximum_lifetime_level_1_modify( - struct nb_cb_modify_args *args) +int isis_instance_lsp_maximum_lifetime_level_1_modify(struct nb_cb_modify_args *args) { struct isis_area *area; uint16_t max_lt; @@ -594,8 +569,7 @@ int isis_instance_lsp_maximum_lifetime_level_1_modify( /* * XPath: /frr-isisd:isis/instance/lsp/timers/level-2/maximum-lifetime */ -int isis_instance_lsp_maximum_lifetime_level_2_modify( - struct nb_cb_modify_args *args) +int isis_instance_lsp_maximum_lifetime_level_2_modify(struct nb_cb_modify_args *args) { struct isis_area *area; uint16_t max_lt; @@ -613,8 +587,7 @@ int isis_instance_lsp_maximum_lifetime_level_2_modify( /* * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/generation-interval */ -int isis_instance_lsp_generation_interval_level_1_modify( - struct nb_cb_modify_args *args) +int isis_instance_lsp_generation_interval_level_1_modify(struct nb_cb_modify_args *args) { struct isis_area *area; uint16_t gen_int; @@ -632,8 +605,7 @@ int isis_instance_lsp_generation_interval_level_1_modify( /* * XPath: /frr-isisd:isis/instance/lsp/timers/level-2/generation-interval */ -int isis_instance_lsp_generation_interval_level_2_modify( - struct nb_cb_modify_args *args) +int isis_instance_lsp_generation_interval_level_2_modify(struct nb_cb_modify_args *args) { struct isis_area *area; uint16_t gen_int; @@ -657,23 +629,20 @@ void ietf_backoff_delay_apply_finish(struct nb_cb_apply_finish_args *args) long short_delay = yang_dnode_get_uint16(args->dnode, "short-delay"); long long_delay = yang_dnode_get_uint16(args->dnode, "long-delay"); long holddown = yang_dnode_get_uint16(args->dnode, "hold-down"); - long timetolearn = - yang_dnode_get_uint16(args->dnode, "time-to-learn"); + long timetolearn = yang_dnode_get_uint16(args->dnode, "time-to-learn"); struct isis_area *area = nb_running_get_entry(args->dnode, NULL, true); size_t bufsiz = strlen(area->area_tag) + sizeof("IS-IS Lx"); char *buf = XCALLOC(MTYPE_TMP, bufsiz); snprintf(buf, bufsiz, "IS-IS %s L1", area->area_tag); spf_backoff_free(area->spf_delay_ietf[0]); - area->spf_delay_ietf[0] = - spf_backoff_new(master, buf, init_delay, short_delay, - long_delay, holddown, timetolearn); + area->spf_delay_ietf[0] = spf_backoff_new(master, buf, init_delay, short_delay, long_delay, + holddown, timetolearn); snprintf(buf, bufsiz, "IS-IS %s L2", area->area_tag); spf_backoff_free(area->spf_delay_ietf[1]); - area->spf_delay_ietf[1] = - spf_backoff_new(master, buf, init_delay, short_delay, - long_delay, holddown, timetolearn); + area->spf_delay_ietf[1] = spf_backoff_new(master, buf, init_delay, short_delay, long_delay, + holddown, timetolearn); XFREE(MTYPE_TMP, buf); } @@ -684,8 +653,7 @@ int isis_instance_spf_ietf_backoff_delay_create(struct nb_cb_create_args *args) return NB_OK; } -int isis_instance_spf_ietf_backoff_delay_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_spf_ietf_backoff_delay_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; @@ -704,8 +672,7 @@ int isis_instance_spf_ietf_backoff_delay_destroy( /* * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/init-delay */ -int isis_instance_spf_ietf_backoff_delay_init_delay_modify( - struct nb_cb_modify_args *args) +int isis_instance_spf_ietf_backoff_delay_init_delay_modify(struct nb_cb_modify_args *args) { /* All the work is done in the apply_finish */ return NB_OK; @@ -714,8 +681,7 @@ int isis_instance_spf_ietf_backoff_delay_init_delay_modify( /* * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/short-delay */ -int isis_instance_spf_ietf_backoff_delay_short_delay_modify( - struct nb_cb_modify_args *args) +int isis_instance_spf_ietf_backoff_delay_short_delay_modify(struct nb_cb_modify_args *args) { /* All the work is done in the apply_finish */ return NB_OK; @@ -724,8 +690,7 @@ int isis_instance_spf_ietf_backoff_delay_short_delay_modify( /* * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/long-delay */ -int isis_instance_spf_ietf_backoff_delay_long_delay_modify( - struct nb_cb_modify_args *args) +int isis_instance_spf_ietf_backoff_delay_long_delay_modify(struct nb_cb_modify_args *args) { /* All the work is done in the apply_finish */ return NB_OK; @@ -734,8 +699,7 @@ int isis_instance_spf_ietf_backoff_delay_long_delay_modify( /* * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/hold-down */ -int isis_instance_spf_ietf_backoff_delay_hold_down_modify( - struct nb_cb_modify_args *args) +int isis_instance_spf_ietf_backoff_delay_hold_down_modify(struct nb_cb_modify_args *args) { /* All the work is done in the apply_finish */ return NB_OK; @@ -744,8 +708,7 @@ int isis_instance_spf_ietf_backoff_delay_hold_down_modify( /* * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay/time-to-learn */ -int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify( - struct nb_cb_modify_args *args) +int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify(struct nb_cb_modify_args *args) { /* All the work is done in the apply_finish */ return NB_OK; @@ -754,8 +717,7 @@ int isis_instance_spf_ietf_backoff_delay_time_to_learn_modify( /* * XPath: /frr-isisd:isis/instance/spf/minimum-interval/level-1 */ -int isis_instance_spf_minimum_interval_level_1_modify( - struct nb_cb_modify_args *args) +int isis_instance_spf_minimum_interval_level_1_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -771,8 +733,7 @@ int isis_instance_spf_minimum_interval_level_1_modify( /* * XPath: /frr-isisd:isis/instance/spf/minimum-interval/level-2 */ -int isis_instance_spf_minimum_interval_level_2_modify( - struct nb_cb_modify_args *args) +int isis_instance_spf_minimum_interval_level_2_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -835,8 +796,7 @@ int isis_instance_spf_prefix_priorities_critical_access_list_name_destroy( /* * XPath: /frr-isisd:isis/instance/spf/prefix-priorities/high/access-list-name */ -int isis_instance_spf_prefix_priorities_high_access_list_name_modify( - struct nb_cb_modify_args *args) +int isis_instance_spf_prefix_priorities_high_access_list_name_modify(struct nb_cb_modify_args *args) { struct isis_area *area; const char *acl_name; @@ -858,8 +818,7 @@ int isis_instance_spf_prefix_priorities_high_access_list_name_modify( return NB_OK; } -int isis_instance_spf_prefix_priorities_high_access_list_name_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_spf_prefix_priorities_high_access_list_name_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; struct spf_prefix_priority_acl *ppa; @@ -881,8 +840,7 @@ int isis_instance_spf_prefix_priorities_high_access_list_name_destroy( /* * XPath: /frr-isisd:isis/instance/spf/prefix-priorities/medium/access-list-name */ -int isis_instance_spf_prefix_priorities_medium_access_list_name_modify( - struct nb_cb_modify_args *args) +int isis_instance_spf_prefix_priorities_medium_access_list_name_modify(struct nb_cb_modify_args *args) { struct isis_area *area; const char *acl_name; @@ -932,17 +890,14 @@ void area_password_apply_finish(struct nb_cb_apply_finish_args *args) const char *password = yang_dnode_get_string(args->dnode, "password"); struct isis_area *area = nb_running_get_entry(args->dnode, NULL, true); int pass_type = yang_dnode_get_enum(args->dnode, "password-type"); - uint8_t snp_auth = - yang_dnode_get_enum(args->dnode, "authenticate-snp"); + uint8_t snp_auth = yang_dnode_get_enum(args->dnode, "authenticate-snp"); switch (pass_type) { case ISIS_PASSWD_TYPE_CLEARTXT: - isis_area_passwd_cleartext_set(area, IS_LEVEL_1, password, - snp_auth); + isis_area_passwd_cleartext_set(area, IS_LEVEL_1, password, snp_auth); break; case ISIS_PASSWD_TYPE_HMAC_MD5: - isis_area_passwd_hmac_md5_set(area, IS_LEVEL_1, password, - snp_auth); + isis_area_passwd_hmac_md5_set(area, IS_LEVEL_1, password, snp_auth); break; } } @@ -978,8 +933,7 @@ int isis_instance_area_password_password_modify(struct nb_cb_modify_args *args) /* * XPath: /frr-isisd:isis/instance/area-password/password-type */ -int isis_instance_area_password_password_type_modify( - struct nb_cb_modify_args *args) +int isis_instance_area_password_password_type_modify(struct nb_cb_modify_args *args) { /* actual setting is done in apply_finish */ return NB_OK; @@ -988,8 +942,7 @@ int isis_instance_area_password_password_type_modify( /* * XPath: /frr-isisd:isis/instance/area-password/authenticate-snp */ -int isis_instance_area_password_authenticate_snp_modify( - struct nb_cb_modify_args *args) +int isis_instance_area_password_authenticate_snp_modify(struct nb_cb_modify_args *args) { /* actual setting is done in apply_finish */ return NB_OK; @@ -1003,17 +956,14 @@ void domain_password_apply_finish(struct nb_cb_apply_finish_args *args) const char *password = yang_dnode_get_string(args->dnode, "password"); struct isis_area *area = nb_running_get_entry(args->dnode, NULL, true); int pass_type = yang_dnode_get_enum(args->dnode, "password-type"); - uint8_t snp_auth = - yang_dnode_get_enum(args->dnode, "authenticate-snp"); + uint8_t snp_auth = yang_dnode_get_enum(args->dnode, "authenticate-snp"); switch (pass_type) { case ISIS_PASSWD_TYPE_CLEARTXT: - isis_area_passwd_cleartext_set(area, IS_LEVEL_2, password, - snp_auth); + isis_area_passwd_cleartext_set(area, IS_LEVEL_2, password, snp_auth); break; case ISIS_PASSWD_TYPE_HMAC_MD5: - isis_area_passwd_hmac_md5_set(area, IS_LEVEL_2, password, - snp_auth); + isis_area_passwd_hmac_md5_set(area, IS_LEVEL_2, password, snp_auth); break; } } @@ -1040,8 +990,7 @@ int isis_instance_domain_password_destroy(struct nb_cb_destroy_args *args) /* * XPath: /frr-isisd:isis/instance/domain-password/password */ -int isis_instance_domain_password_password_modify( - struct nb_cb_modify_args *args) +int isis_instance_domain_password_password_modify(struct nb_cb_modify_args *args) { /* actual setting is done in apply_finish */ return NB_OK; @@ -1050,8 +999,7 @@ int isis_instance_domain_password_password_modify( /* * XPath: /frr-isisd:isis/instance/domain-password/password-type */ -int isis_instance_domain_password_password_type_modify( - struct nb_cb_modify_args *args) +int isis_instance_domain_password_password_type_modify(struct nb_cb_modify_args *args) { /* actual setting is done in apply_finish */ return NB_OK; @@ -1060,8 +1008,7 @@ int isis_instance_domain_password_password_type_modify( /* * XPath: /frr-isisd:isis/instance/domain-password/authenticate-snp */ -int isis_instance_domain_password_authenticate_snp_modify( - struct nb_cb_modify_args *args) +int isis_instance_domain_password_authenticate_snp_modify(struct nb_cb_modify_args *args) { /* actual setting is done in apply_finish */ return NB_OK; @@ -1081,9 +1028,8 @@ void default_info_origin_apply_finish(const struct lyd_node *dnode, int family) if (yang_dnode_get_bool(dnode, "always")) { originate_type = DEFAULT_ORIGINATE_ALWAYS; } else if (family == AF_INET6) { - zlog_warn( - "%s: Zebra doesn't implement default-originate for IPv6 yet, so use with care or use default-originate always.", - __func__); + zlog_warn("%s: Zebra doesn't implement default-originate for IPv6 yet, so use with care or use default-originate always.", + __func__); } if (yang_dnode_exists(dnode, "metric")) @@ -1091,8 +1037,7 @@ void default_info_origin_apply_finish(const struct lyd_node *dnode, int family) if (yang_dnode_exists(dnode, "route-map")) routemap = yang_dnode_get_string(dnode, "route-map"); - isis_redist_set(area, level, family, DEFAULT_ROUTE, metric, routemap, - originate_type, 0); + isis_redist_set(area, level, family, DEFAULT_ROUTE, metric, routemap, originate_type, 0); } void default_info_origin_ipv4_apply_finish(struct nb_cb_apply_finish_args *args) @@ -1105,15 +1050,13 @@ void default_info_origin_ipv6_apply_finish(struct nb_cb_apply_finish_args *args) default_info_origin_apply_finish(args->dnode, AF_INET6); } -int isis_instance_default_information_originate_ipv4_create( - struct nb_cb_create_args *args) +int isis_instance_default_information_originate_ipv4_create(struct nb_cb_create_args *args) { /* It's all done by default_info_origin_apply_finish */ return NB_OK; } -int isis_instance_default_information_originate_ipv4_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_default_information_originate_ipv4_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; int level; @@ -1131,8 +1074,7 @@ int isis_instance_default_information_originate_ipv4_destroy( /* * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/always */ -int isis_instance_default_information_originate_ipv4_always_modify( - struct nb_cb_modify_args *args) +int isis_instance_default_information_originate_ipv4_always_modify(struct nb_cb_modify_args *args) { /* It's all done by default_info_origin_apply_finish */ return NB_OK; @@ -1141,8 +1083,7 @@ int isis_instance_default_information_originate_ipv4_always_modify( /* * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/route-map */ -int isis_instance_default_information_originate_ipv4_route_map_modify( - struct nb_cb_modify_args *args) +int isis_instance_default_information_originate_ipv4_route_map_modify(struct nb_cb_modify_args *args) { /* It's all done by default_info_origin_apply_finish */ return NB_OK; @@ -1158,8 +1099,7 @@ int isis_instance_default_information_originate_ipv4_route_map_destroy( /* * XPath: /frr-isisd:isis/instance/default-information-originate/ipv4/metric */ -int isis_instance_default_information_originate_ipv4_metric_modify( - struct nb_cb_modify_args *args) +int isis_instance_default_information_originate_ipv4_metric_modify(struct nb_cb_modify_args *args) { /* It's all done by default_info_origin_apply_finish */ return NB_OK; @@ -1168,15 +1108,13 @@ int isis_instance_default_information_originate_ipv4_metric_modify( /* * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6 */ -int isis_instance_default_information_originate_ipv6_create( - struct nb_cb_create_args *args) +int isis_instance_default_information_originate_ipv6_create(struct nb_cb_create_args *args) { /* It's all done by default_info_origin_apply_finish */ return NB_OK; } -int isis_instance_default_information_originate_ipv6_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_default_information_originate_ipv6_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; int level; @@ -1194,8 +1132,7 @@ int isis_instance_default_information_originate_ipv6_destroy( /* * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/always */ -int isis_instance_default_information_originate_ipv6_always_modify( - struct nb_cb_modify_args *args) +int isis_instance_default_information_originate_ipv6_always_modify(struct nb_cb_modify_args *args) { /* It's all done by default_info_origin_apply_finish */ return NB_OK; @@ -1204,8 +1141,7 @@ int isis_instance_default_information_originate_ipv6_always_modify( /* * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/route-map */ -int isis_instance_default_information_originate_ipv6_route_map_modify( - struct nb_cb_modify_args *args) +int isis_instance_default_information_originate_ipv6_route_map_modify(struct nb_cb_modify_args *args) { /* It's all done by default_info_origin_apply_finish */ return NB_OK; @@ -1221,8 +1157,7 @@ int isis_instance_default_information_originate_ipv6_route_map_destroy( /* * XPath: /frr-isisd:isis/instance/default-information-originate/ipv6/metric */ -int isis_instance_default_information_originate_ipv6_metric_modify( - struct nb_cb_modify_args *args) +int isis_instance_default_information_originate_ipv6_metric_modify(struct nb_cb_modify_args *args) { /* It's all done by default_info_origin_apply_finish */ return NB_OK; @@ -1287,15 +1222,13 @@ int isis_instance_redistribute_ipv4_destroy(struct nb_cb_destroy_args *args) * XPath: /frr-isisd:isis/instance/redistribute/ipv4/route-map * XPath: /frr-isisd:isis/instance/redistribute/ipv4/table/route-map */ -int isis_instance_redistribute_ipv4_route_map_modify( - struct nb_cb_modify_args *args) +int isis_instance_redistribute_ipv4_route_map_modify(struct nb_cb_modify_args *args) { /* It's all done by redistribute_apply_finish */ return NB_OK; } -int isis_instance_redistribute_ipv4_route_map_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_redistribute_ipv4_route_map_destroy(struct nb_cb_destroy_args *args) { /* It's all done by redistribute_apply_finish */ return NB_OK; @@ -1305,8 +1238,7 @@ int isis_instance_redistribute_ipv4_route_map_destroy( * XPath: /frr-isisd:isis/instance/redistribute/ipv4/metric * XPath: /frr-isisd:isis/instance/redistribute/ipv4/table/metric */ -int isis_instance_redistribute_ipv4_metric_modify( - struct nb_cb_modify_args *args) +int isis_instance_redistribute_ipv4_metric_modify(struct nb_cb_modify_args *args) { /* It's all done by redistribute_apply_finish */ return NB_OK; @@ -1392,15 +1324,13 @@ int isis_instance_redistribute_ipv6_destroy(struct nb_cb_destroy_args *args) /* * XPath: /frr-isisd:isis/instance/redistribute/ipv6/route-map */ -int isis_instance_redistribute_ipv6_route_map_modify( - struct nb_cb_modify_args *args) +int isis_instance_redistribute_ipv6_route_map_modify(struct nb_cb_modify_args *args) { /* It's all done by redistribute_apply_finish */ return NB_OK; } -int isis_instance_redistribute_ipv6_route_map_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_redistribute_ipv6_route_map_destroy(struct nb_cb_destroy_args *args) { /* It's all done by redistribute_apply_finish */ return NB_OK; @@ -1409,8 +1339,7 @@ int isis_instance_redistribute_ipv6_route_map_destroy( /* * XPath: /frr-isisd:isis/instance/redistribute/ipv6/metric */ -int isis_instance_redistribute_ipv6_metric_modify( - struct nb_cb_modify_args *args) +int isis_instance_redistribute_ipv6_metric_modify(struct nb_cb_modify_args *args) { /* It's all done by redistribute_apply_finish */ return NB_OK; @@ -1446,10 +1375,9 @@ int isis_instance_redistribute_ipv6_table_destroy(struct nb_cb_destroy_args *arg /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-multicast */ -static int isis_multi_topology_common(enum nb_event event, - const struct lyd_node *dnode, - char *errmsg, size_t errmsg_len, - const char *topology, bool create) +static int isis_multi_topology_common(enum nb_event event, const struct lyd_node *dnode, + char *errmsg, size_t errmsg_len, const char *topology, + bool create) { struct isis_area *area; struct isis_area_mt_setting *setting; @@ -1458,8 +1386,7 @@ static int isis_multi_topology_common(enum nb_event event, switch (event) { case NB_EV_VALIDATE: if (mtid == (uint16_t)-1) { - snprintf(errmsg, errmsg_len, "Unknown topology %s", - topology); + snprintf(errmsg, errmsg_len, "Unknown topology %s", topology); return NB_ERR_VALIDATION; } break; @@ -1477,8 +1404,7 @@ static int isis_multi_topology_common(enum nb_event event, return NB_OK; } -static int isis_multi_topology_overload_common(enum nb_event event, - const struct lyd_node *dnode, +static int isis_multi_topology_overload_common(enum nb_event event, const struct lyd_node *dnode, const char *topology) { struct isis_area *area; @@ -1498,182 +1424,145 @@ static int isis_multi_topology_overload_common(enum nb_event event, return NB_OK; } -int isis_instance_multi_topology_ipv4_multicast_create( - struct nb_cb_create_args *args) +int isis_instance_multi_topology_ipv4_multicast_create(struct nb_cb_create_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv4-multicast", true); } -int isis_instance_multi_topology_ipv4_multicast_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_multi_topology_ipv4_multicast_destroy(struct nb_cb_destroy_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv4-multicast", false); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-multicast/overload */ -int isis_instance_multi_topology_ipv4_multicast_overload_modify( - struct nb_cb_modify_args *args) +int isis_instance_multi_topology_ipv4_multicast_overload_modify(struct nb_cb_modify_args *args) { - return isis_multi_topology_overload_common(args->event, args->dnode, - "ipv4-multicast"); + return isis_multi_topology_overload_common(args->event, args->dnode, "ipv4-multicast"); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-management */ -int isis_instance_multi_topology_ipv4_management_create( - struct nb_cb_create_args *args) +int isis_instance_multi_topology_ipv4_management_create(struct nb_cb_create_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv4-mgmt", true); } -int isis_instance_multi_topology_ipv4_management_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_multi_topology_ipv4_management_destroy(struct nb_cb_destroy_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv4-mgmt", false); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv4-management/overload */ -int isis_instance_multi_topology_ipv4_management_overload_modify( - struct nb_cb_modify_args *args) +int isis_instance_multi_topology_ipv4_management_overload_modify(struct nb_cb_modify_args *args) { - return isis_multi_topology_overload_common(args->event, args->dnode, - "ipv4-mgmt"); + return isis_multi_topology_overload_common(args->event, args->dnode, "ipv4-mgmt"); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-unicast */ -int isis_instance_multi_topology_ipv6_unicast_create( - struct nb_cb_create_args *args) +int isis_instance_multi_topology_ipv6_unicast_create(struct nb_cb_create_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv6-unicast", true); } -int isis_instance_multi_topology_ipv6_unicast_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_multi_topology_ipv6_unicast_destroy(struct nb_cb_destroy_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv6-unicast", false); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-unicast/overload */ -int isis_instance_multi_topology_ipv6_unicast_overload_modify( - struct nb_cb_modify_args *args) +int isis_instance_multi_topology_ipv6_unicast_overload_modify(struct nb_cb_modify_args *args) { - return isis_multi_topology_overload_common(args->event, args->dnode, - "ipv6-unicast"); + return isis_multi_topology_overload_common(args->event, args->dnode, "ipv6-unicast"); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-multicast */ -int isis_instance_multi_topology_ipv6_multicast_create( - struct nb_cb_create_args *args) +int isis_instance_multi_topology_ipv6_multicast_create(struct nb_cb_create_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv6-multicast", true); } -int isis_instance_multi_topology_ipv6_multicast_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_multi_topology_ipv6_multicast_destroy(struct nb_cb_destroy_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv6-multicast", false); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-multicast/overload */ -int isis_instance_multi_topology_ipv6_multicast_overload_modify( - struct nb_cb_modify_args *args) +int isis_instance_multi_topology_ipv6_multicast_overload_modify(struct nb_cb_modify_args *args) { - return isis_multi_topology_overload_common(args->event, args->dnode, - "ipv6-multicast"); + return isis_multi_topology_overload_common(args->event, args->dnode, "ipv6-multicast"); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-management */ -int isis_instance_multi_topology_ipv6_management_create( - struct nb_cb_create_args *args) +int isis_instance_multi_topology_ipv6_management_create(struct nb_cb_create_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv6-mgmt", true); } -int isis_instance_multi_topology_ipv6_management_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_multi_topology_ipv6_management_destroy(struct nb_cb_destroy_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv6-mgmt", false); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-management/overload */ -int isis_instance_multi_topology_ipv6_management_overload_modify( - struct nb_cb_modify_args *args) +int isis_instance_multi_topology_ipv6_management_overload_modify(struct nb_cb_modify_args *args) { - return isis_multi_topology_overload_common(args->event, args->dnode, - "ipv6-mgmt"); + return isis_multi_topology_overload_common(args->event, args->dnode, "ipv6-mgmt"); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-dstsrc */ -int isis_instance_multi_topology_ipv6_dstsrc_create( - struct nb_cb_create_args *args) +int isis_instance_multi_topology_ipv6_dstsrc_create(struct nb_cb_create_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv6-dstsrc", true); } -int isis_instance_multi_topology_ipv6_dstsrc_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_multi_topology_ipv6_dstsrc_destroy(struct nb_cb_destroy_args *args) { - return isis_multi_topology_common(args->event, args->dnode, - args->errmsg, args->errmsg_len, + return isis_multi_topology_common(args->event, args->dnode, args->errmsg, args->errmsg_len, "ipv6-dstsrc", false); } /* * XPath: /frr-isisd:isis/instance/multi-topology/ipv6-dstsrc/overload */ -int isis_instance_multi_topology_ipv6_dstsrc_overload_modify( - struct nb_cb_modify_args *args) +int isis_instance_multi_topology_ipv6_dstsrc_overload_modify(struct nb_cb_modify_args *args) { - return isis_multi_topology_overload_common(args->event, args->dnode, - "ipv6-dstsrc"); + return isis_multi_topology_overload_common(args->event, args->dnode, "ipv6-dstsrc"); } /* * XPath: /frr-isisd:isis/instance/fast-reroute/level-1/lfa/load-sharing */ -int isis_instance_fast_reroute_level_1_lfa_load_sharing_modify( - struct nb_cb_modify_args *args) +int isis_instance_fast_reroute_level_1_lfa_load_sharing_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -1690,8 +1579,7 @@ int isis_instance_fast_reroute_level_1_lfa_load_sharing_modify( /* * XPath: /frr-isisd:isis/instance/fast-reroute/level-1/lfa/priority-limit */ -int isis_instance_fast_reroute_level_1_lfa_priority_limit_modify( - struct nb_cb_modify_args *args) +int isis_instance_fast_reroute_level_1_lfa_priority_limit_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -1705,8 +1593,7 @@ int isis_instance_fast_reroute_level_1_lfa_priority_limit_modify( return NB_OK; } -int isis_instance_fast_reroute_level_1_lfa_priority_limit_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_fast_reroute_level_1_lfa_priority_limit_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; @@ -1723,8 +1610,7 @@ int isis_instance_fast_reroute_level_1_lfa_priority_limit_destroy( /* * XPath: /frr-isisd:isis/instance/fast-reroute/level-1/lfa/tiebreaker */ -int isis_instance_fast_reroute_level_1_lfa_tiebreaker_create( - struct nb_cb_create_args *args) +int isis_instance_fast_reroute_level_1_lfa_tiebreaker_create(struct nb_cb_create_args *args) { struct isis_area *area; uint8_t index; @@ -1745,8 +1631,7 @@ int isis_instance_fast_reroute_level_1_lfa_tiebreaker_create( return NB_OK; } -int isis_instance_fast_reroute_level_1_lfa_tiebreaker_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_fast_reroute_level_1_lfa_tiebreaker_destroy(struct nb_cb_destroy_args *args) { struct lfa_tiebreaker *tie_b; struct isis_area *area; @@ -1765,8 +1650,7 @@ int isis_instance_fast_reroute_level_1_lfa_tiebreaker_destroy( /* * XPath: /frr-isisd:isis/instance/fast-reroute/level-1/remote-lfa/prefix-list */ -int isis_instance_fast_reroute_level_1_remote_lfa_prefix_list_modify( - struct nb_cb_modify_args *args) +int isis_instance_fast_reroute_level_1_remote_lfa_prefix_list_modify(struct nb_cb_modify_args *args) { struct isis_area *area; const char *plist_name; @@ -1784,8 +1668,7 @@ int isis_instance_fast_reroute_level_1_remote_lfa_prefix_list_modify( return NB_OK; } -int isis_instance_fast_reroute_level_1_remote_lfa_prefix_list_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_fast_reroute_level_1_remote_lfa_prefix_list_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; @@ -1804,8 +1687,7 @@ int isis_instance_fast_reroute_level_1_remote_lfa_prefix_list_destroy( /* * XPath: /frr-isisd:isis/instance/fast-reroute/level-2/lfa/load-sharing */ -int isis_instance_fast_reroute_level_2_lfa_load_sharing_modify( - struct nb_cb_modify_args *args) +int isis_instance_fast_reroute_level_2_lfa_load_sharing_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -1821,8 +1703,7 @@ int isis_instance_fast_reroute_level_2_lfa_load_sharing_modify( /* * XPath: /frr-isisd:isis/instance/fast-reroute/level-2/lfa/priority-limit */ -int isis_instance_fast_reroute_level_2_lfa_priority_limit_modify( - struct nb_cb_modify_args *args) +int isis_instance_fast_reroute_level_2_lfa_priority_limit_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -1835,8 +1716,7 @@ int isis_instance_fast_reroute_level_2_lfa_priority_limit_modify( return NB_OK; } -int isis_instance_fast_reroute_level_2_lfa_priority_limit_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_fast_reroute_level_2_lfa_priority_limit_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; @@ -1852,8 +1732,7 @@ int isis_instance_fast_reroute_level_2_lfa_priority_limit_destroy( /* * XPath: /frr-isisd:isis/instance/fast-reroute/level-2/lfa/tiebreaker */ -int isis_instance_fast_reroute_level_2_lfa_tiebreaker_create( - struct nb_cb_create_args *args) +int isis_instance_fast_reroute_level_2_lfa_tiebreaker_create(struct nb_cb_create_args *args) { struct isis_area *area; uint8_t index; @@ -1874,8 +1753,7 @@ int isis_instance_fast_reroute_level_2_lfa_tiebreaker_create( return NB_OK; } -int isis_instance_fast_reroute_level_2_lfa_tiebreaker_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_fast_reroute_level_2_lfa_tiebreaker_destroy(struct nb_cb_destroy_args *args) { struct lfa_tiebreaker *tie_b; struct isis_area *area; @@ -1894,8 +1772,7 @@ int isis_instance_fast_reroute_level_2_lfa_tiebreaker_destroy( /* * XPath: /frr-isisd:isis/instance/fast-reroute/level-2/remote-lfa/prefix-list */ -int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_modify( - struct nb_cb_modify_args *args) +int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_modify(struct nb_cb_modify_args *args) { struct isis_area *area; const char *plist_name; @@ -1913,8 +1790,7 @@ int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_modify( return NB_OK; } -int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_fast_reroute_level_2_remote_lfa_prefix_list_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; @@ -1999,8 +1875,7 @@ int isis_instance_mpls_te_destroy(struct nb_cb_destroy_args *args) /* Reoriginate STD_TE & GMPLS circuits */ lsp_regenerate_schedule(area, area->is_type, 0); - zlog_debug("ISIS-TE(%s): Disabled MPLS Traffic Engineering", - area->area_tag); + zlog_debug("ISIS-TE(%s): Disabled MPLS Traffic Engineering", area->area_tag); return NB_OK; } @@ -2031,8 +1906,7 @@ int isis_instance_mpls_te_router_address_modify(struct nb_cb_modify_args *args) return NB_OK; } -int isis_instance_mpls_te_router_address_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_mpls_te_router_address_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; @@ -2056,8 +1930,7 @@ int isis_instance_mpls_te_router_address_destroy( /* * XPath: /frr-isisd:isis/instance/mpls-te/router-address-v6 */ -int isis_instance_mpls_te_router_address_ipv6_modify( - struct nb_cb_modify_args *args) +int isis_instance_mpls_te_router_address_ipv6_modify(struct nb_cb_modify_args *args) { struct in6_addr value; struct isis_area *area; @@ -2082,8 +1955,7 @@ int isis_instance_mpls_te_router_address_ipv6_modify( return NB_OK; } -int isis_instance_mpls_te_router_address_ipv6_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_mpls_te_router_address_ipv6_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; @@ -2138,8 +2010,7 @@ int isis_instance_mpls_te_export_modify(struct nb_cb_modify_args *args) /* * XPath: /frr-isisd:isis/instance/segment-routing/enabled */ -int isis_instance_segment_routing_enabled_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_enabled_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -2167,8 +2038,7 @@ int isis_instance_segment_routing_enabled_modify( /* * XPath: /frr-isisd:isis/instance/segment-routing/label-blocks */ -int isis_instance_segment_routing_label_blocks_pre_validate( - struct nb_cb_pre_validate_args *args) +int isis_instance_segment_routing_label_blocks_pre_validate(struct nb_cb_pre_validate_args *args) { uint32_t srgb_lbound; uint32_t srgb_ubound; @@ -2182,25 +2052,23 @@ int isis_instance_segment_routing_label_blocks_pre_validate( /* Check that the block size does not exceed 65535 */ if ((srgb_ubound - srgb_lbound + 1) > 65535) { - snprintf( - args->errmsg, args->errmsg_len, - "New SR Global Block (%u/%u) exceed the limit of 65535", - srgb_lbound, srgb_ubound); + snprintf(args->errmsg, args->errmsg_len, + "New SR Global Block (%u/%u) exceed the limit of 65535", srgb_lbound, + srgb_ubound); return NB_ERR_VALIDATION; } if ((srlb_ubound - srlb_lbound + 1) > 65535) { snprintf(args->errmsg, args->errmsg_len, - "New SR Local Block (%u/%u) exceed the limit of 65535", - srlb_lbound, srlb_ubound); + "New SR Local Block (%u/%u) exceed the limit of 65535", srlb_lbound, + srlb_ubound); return NB_ERR_VALIDATION; } /* Validate SRGB against SRLB */ if (!((srgb_ubound < srlb_lbound) || (srgb_lbound > srlb_ubound))) { - snprintf( - args->errmsg, args->errmsg_len, - "SR Global Block (%u/%u) conflicts with Local Block (%u/%u)", - srgb_lbound, srgb_ubound, srlb_lbound, srlb_ubound); + snprintf(args->errmsg, args->errmsg_len, + "SR Global Block (%u/%u) conflicts with Local Block (%u/%u)", srgb_lbound, + srgb_ubound, srlb_lbound, srlb_ubound); return NB_ERR_VALIDATION; } @@ -2211,8 +2079,7 @@ int isis_instance_segment_routing_label_blocks_pre_validate( * XPath: /frr-isisd:isis/instance/segment-routing/label-blocks/srgb */ -void isis_instance_segment_routing_srgb_apply_finish( - struct nb_cb_apply_finish_args *args) +void isis_instance_segment_routing_srgb_apply_finish(struct nb_cb_apply_finish_args *args) { struct isis_area *area; uint32_t lower_bound, upper_bound; @@ -2227,16 +2094,15 @@ void isis_instance_segment_routing_srgb_apply_finish( /* * XPath: /frr-isisd:isis/instance/segment-routing/label-blocks/srgb/lower-bound */ -int isis_instance_segment_routing_srgb_lower_bound_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_srgb_lower_bound_modify(struct nb_cb_modify_args *args) { uint32_t lower_bound = yang_dnode_get_uint32(args->dnode, NULL); switch (args->event) { case NB_EV_VALIDATE: if (!IS_MPLS_UNRESERVED_LABEL(lower_bound)) { - snprintf(args->errmsg, args->errmsg_len, - "Invalid SRGB lower bound: %u", lower_bound); + snprintf(args->errmsg, args->errmsg_len, "Invalid SRGB lower bound: %u", + lower_bound); return NB_ERR_VALIDATION; } break; @@ -2252,16 +2118,15 @@ int isis_instance_segment_routing_srgb_lower_bound_modify( /* * XPath: /frr-isisd:isis/instance/segment-routing/label-blocks/srgb/upper-bound */ -int isis_instance_segment_routing_srgb_upper_bound_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_srgb_upper_bound_modify(struct nb_cb_modify_args *args) { uint32_t upper_bound = yang_dnode_get_uint32(args->dnode, NULL); switch (args->event) { case NB_EV_VALIDATE: if (!IS_MPLS_UNRESERVED_LABEL(upper_bound)) { - snprintf(args->errmsg, args->errmsg_len, - "Invalid SRGB upper bound: %u", upper_bound); + snprintf(args->errmsg, args->errmsg_len, "Invalid SRGB upper bound: %u", + upper_bound); return NB_ERR_VALIDATION; } break; @@ -2277,8 +2142,7 @@ int isis_instance_segment_routing_srgb_upper_bound_modify( /* * XPath: /frr-isisd:isis/instance/segment-routing/label-blocks/srlb */ -void isis_instance_segment_routing_srlb_apply_finish( - struct nb_cb_apply_finish_args *args) +void isis_instance_segment_routing_srlb_apply_finish(struct nb_cb_apply_finish_args *args) { struct isis_area *area; uint32_t lower_bound, upper_bound; @@ -2293,16 +2157,15 @@ void isis_instance_segment_routing_srlb_apply_finish( /* * XPath: /frr-isisd:isis/instance/segment-routing/label-blocks/srlb/lower-bound */ -int isis_instance_segment_routing_srlb_lower_bound_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_srlb_lower_bound_modify(struct nb_cb_modify_args *args) { uint32_t lower_bound = yang_dnode_get_uint32(args->dnode, NULL); switch (args->event) { case NB_EV_VALIDATE: if (!IS_MPLS_UNRESERVED_LABEL(lower_bound)) { - snprintf(args->errmsg, args->errmsg_len, - "Invalid SRLB lower bound: %u", lower_bound); + snprintf(args->errmsg, args->errmsg_len, "Invalid SRLB lower bound: %u", + lower_bound); return NB_ERR_VALIDATION; } break; @@ -2318,16 +2181,15 @@ int isis_instance_segment_routing_srlb_lower_bound_modify( /* * XPath: /frr-isisd:isis/instance/segment-routing/label-blocks/srlb/upper-bound */ -int isis_instance_segment_routing_srlb_upper_bound_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_srlb_upper_bound_modify(struct nb_cb_modify_args *args) { uint32_t upper_bound = yang_dnode_get_uint32(args->dnode, NULL); switch (args->event) { case NB_EV_VALIDATE: if (!IS_MPLS_UNRESERVED_LABEL(upper_bound)) { - snprintf(args->errmsg, args->errmsg_len, - "Invalid SRLB upper bound: %u", upper_bound); + snprintf(args->errmsg, args->errmsg_len, "Invalid SRLB upper bound: %u", + upper_bound); return NB_ERR_VALIDATION; } break; @@ -2343,8 +2205,7 @@ int isis_instance_segment_routing_srlb_upper_bound_modify( /* * XPath: /frr-isisd:isis/instance/segment-routing/msd/node-msd */ -int isis_instance_segment_routing_msd_node_msd_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_msd_node_msd_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -2360,8 +2221,7 @@ int isis_instance_segment_routing_msd_node_msd_modify( return NB_OK; } -int isis_instance_segment_routing_msd_node_msd_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_segment_routing_msd_node_msd_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; @@ -2380,8 +2240,7 @@ int isis_instance_segment_routing_msd_node_msd_destroy( /* * XPath: /frr-isisd:isis/instance/segment-routing/prefix-sid-map/prefix-sid */ -int isis_instance_segment_routing_prefix_sid_map_prefix_sid_create( - struct nb_cb_create_args *args) +int isis_instance_segment_routing_prefix_sid_map_prefix_sid_create(struct nb_cb_create_args *args) { struct isis_area *area; struct prefix prefix; @@ -2399,8 +2258,7 @@ int isis_instance_segment_routing_prefix_sid_map_prefix_sid_create( return NB_OK; } -int isis_instance_segment_routing_prefix_sid_map_prefix_sid_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_segment_routing_prefix_sid_map_prefix_sid_destroy(struct nb_cb_destroy_args *args) { struct sr_prefix_cfg *pcfg; struct isis_area *area; @@ -2430,10 +2288,8 @@ int isis_instance_segment_routing_prefix_sid_map_prefix_sid_pre_validate( struct isis_prefix_sid psid = {}; yang_dnode_get_prefix(&prefix, args->dnode, "prefix"); - srgb_lbound = yang_dnode_get_uint32( - args->dnode, "../../label-blocks/srgb/lower-bound"); - srgb_ubound = yang_dnode_get_uint32( - args->dnode, "../../label-blocks/srgb/upper-bound"); + srgb_lbound = yang_dnode_get_uint32(args->dnode, "../../label-blocks/srgb/lower-bound"); + srgb_ubound = yang_dnode_get_uint32(args->dnode, "../../label-blocks/srgb/upper-bound"); sid = yang_dnode_get_uint32(args->dnode, "sid-value"); sid_type = yang_dnode_get_enum(args->dnode, "sid-value-type"); @@ -2444,15 +2300,13 @@ int isis_instance_segment_routing_prefix_sid_map_prefix_sid_pre_validate( case SR_SID_VALUE_TYPE_INDEX: if (sid >= srgb_range) { snprintf(args->errmsg, args->errmsg_len, - "SID index %u falls outside local SRGB range", - sid); + "SID index %u falls outside local SRGB range", sid); return NB_ERR_VALIDATION; } break; case SR_SID_VALUE_TYPE_ABSOLUTE: if (!IS_MPLS_UNRESERVED_LABEL(sid)) { - snprintf(args->errmsg, args->errmsg_len, - "Invalid absolute SID %u", sid); + snprintf(args->errmsg, args->errmsg_len, "Invalid absolute SID %u", sid); return NB_ERR_VALIDATION; } SET_FLAG(psid.flags, ISIS_PREFIX_SID_VALUE); @@ -2465,8 +2319,7 @@ int isis_instance_segment_routing_prefix_sid_map_prefix_sid_pre_validate( area = nb_running_get_entry(area_dnode, NULL, false); if (area) { for (int tree = SPFTREE_IPV4; tree < SPFTREE_COUNT; tree++) { - for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; - level++) { + for (int level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) { struct isis_spftree *spftree; struct isis_vertex *vertex_psid; @@ -2476,22 +2329,15 @@ int isis_instance_segment_routing_prefix_sid_map_prefix_sid_pre_validate( if (!spftree) continue; - vertex_psid = isis_spf_prefix_sid_lookup( - spftree, &psid); - if (vertex_psid - && !prefix_same(&vertex_psid->N.ip.p.dest, - &prefix)) { - snprintfrr( - args->errmsg, args->errmsg_len, - "Prefix-SID collision detected, SID %s %u is already in use by prefix %pFX (L%u)", - CHECK_FLAG( - psid.flags, - ISIS_PREFIX_SID_VALUE) - ? "label" - : "index", - psid.value, - &vertex_psid->N.ip.p.dest, - level); + vertex_psid = isis_spf_prefix_sid_lookup(spftree, &psid); + if (vertex_psid && + !prefix_same(&vertex_psid->N.ip.p.dest, &prefix)) { + snprintfrr(args->errmsg, args->errmsg_len, + "Prefix-SID collision detected, SID %s %u is already in use by prefix %pFX (L%u)", + CHECK_FLAG(psid.flags, ISIS_PREFIX_SID_VALUE) + ? "label" + : "index", + psid.value, &vertex_psid->N.ip.p.dest, level); return NB_ERR_VALIDATION; } } @@ -2587,8 +2433,7 @@ int isis_instance_segment_routing_prefix_sid_map_prefix_sid_n_flag_clear_modify( * XPath: * /frr-isisd:isis/instance/segment-routing/algorithm-prefix-sids/algorithm-prefix-sid */ -int isis_instance_segment_routing_algorithm_prefix_sid_create( - struct nb_cb_create_args *args) +int isis_instance_segment_routing_algorithm_prefix_sid_create(struct nb_cb_create_args *args) { struct isis_area *area; struct prefix prefix; @@ -2609,8 +2454,7 @@ int isis_instance_segment_routing_algorithm_prefix_sid_create( return NB_OK; } -int isis_instance_segment_routing_algorithm_prefix_sid_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_segment_routing_algorithm_prefix_sid_destroy(struct nb_cb_destroy_args *args) { struct sr_prefix_cfg *pcfg; struct isis_area *area; @@ -2640,10 +2484,8 @@ int isis_instance_segment_routing_algorithm_prefix_sid_pre_validate( struct isis_prefix_sid psid = {}; yang_dnode_get_prefix(&prefix, args->dnode, "prefix"); - srgb_lbound = yang_dnode_get_uint32( - args->dnode, "../../label-blocks/srgb/lower-bound"); - srgb_ubound = yang_dnode_get_uint32( - args->dnode, "../../label-blocks/srgb/upper-bound"); + srgb_lbound = yang_dnode_get_uint32(args->dnode, "../../label-blocks/srgb/lower-bound"); + srgb_ubound = yang_dnode_get_uint32(args->dnode, "../../label-blocks/srgb/upper-bound"); sid = yang_dnode_get_uint32(args->dnode, "sid-value"); sid_type = yang_dnode_get_enum(args->dnode, "sid-value-type"); @@ -2654,15 +2496,13 @@ int isis_instance_segment_routing_algorithm_prefix_sid_pre_validate( case SR_SID_VALUE_TYPE_INDEX: if (sid >= srgb_range) { snprintf(args->errmsg, args->errmsg_len, - "SID index %u falls outside local SRGB range", - sid); + "SID index %u falls outside local SRGB range", sid); return NB_ERR_VALIDATION; } break; case SR_SID_VALUE_TYPE_ABSOLUTE: if (!IS_MPLS_UNRESERVED_LABEL(sid)) { - snprintf(args->errmsg, args->errmsg_len, - "Invalid absolute SID %u", sid); + snprintf(args->errmsg, args->errmsg_len, "Invalid absolute SID %u", sid); return NB_ERR_VALIDATION; } SET_FLAG(psid.flags, ISIS_PREFIX_SID_VALUE); @@ -2687,19 +2527,13 @@ int isis_instance_segment_routing_algorithm_prefix_sid_pre_validate( if (!spftree) continue; - vertex_psid = - isis_spf_prefix_sid_lookup(spftree, &psid); - if (vertex_psid && - !prefix_same(&vertex_psid->N.ip.p.dest, &prefix)) { - snprintfrr( - args->errmsg, args->errmsg_len, - "Prefix-SID collision detected, SID %s %u is already in use by prefix %pFX (L%u)", - CHECK_FLAG(psid.flags, - ISIS_PREFIX_SID_VALUE) - ? "label" - : "index", - psid.value, &vertex_psid->N.ip.p.dest, - level); + vertex_psid = isis_spf_prefix_sid_lookup(spftree, &psid); + if (vertex_psid && !prefix_same(&vertex_psid->N.ip.p.dest, &prefix)) { + snprintfrr(args->errmsg, args->errmsg_len, + "Prefix-SID collision detected, SID %s %u is already in use by prefix %pFX (L%u)", + CHECK_FLAG(psid.flags, ISIS_PREFIX_SID_VALUE) ? "label" + : "index", + psid.value, &vertex_psid->N.ip.p.dest, level); return NB_ERR_VALIDATION; } } @@ -2800,7 +2634,6 @@ int isis_instance_flex_algo_create(struct nb_cb_create_args *args) struct flex_algo *fa; bool advertise, update_te; struct isis_circuit *circuit; - struct listnode *node; uint32_t algorithm; uint32_t priority = FLEX_ALGO_PRIO_DEFAULT; struct isis_flex_algo_alloc_arg arg; @@ -2818,18 +2651,13 @@ int isis_instance_flex_algo_create(struct nb_cb_create_args *args) fa->priority = priority; fa->advertise_definition = advertise; if (area->admin_group_send_zero) { - admin_group_allow_explicit_zero( - &fa->admin_group_exclude_any); - admin_group_allow_explicit_zero( - &fa->admin_group_include_any); - admin_group_allow_explicit_zero( - &fa->admin_group_include_all); + admin_group_allow_explicit_zero(&fa->admin_group_exclude_any); + admin_group_allow_explicit_zero(&fa->admin_group_include_any); + admin_group_allow_explicit_zero(&fa->admin_group_include_all); } if (update_te) { - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, - circuit)) - isis_link_params_update_asla(circuit, - circuit->interface); + frr_each (isis_circuit_list, &area->circuit_list, circuit) + isis_link_params_update_asla(circuit, circuit->interface); } lsp_regenerate_schedule(area, area->is_type, 0); break; @@ -2861,9 +2689,8 @@ int isis_instance_flex_algo_destroy(struct nb_cb_destroy_args *args) flex_algo_free(area->flex_algos, fa); } if (list_isempty(area->flex_algos->flex_algos)) { - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) - isis_link_params_update_asla(circuit, - circuit->interface); + frr_each (isis_circuit_list, &area->circuit_list, circuit) + isis_link_params_update_asla(circuit, circuit->interface); } lsp_regenerate_schedule(area, area->is_type, 0); @@ -2873,8 +2700,7 @@ int isis_instance_flex_algo_destroy(struct nb_cb_destroy_args *args) /* * XPath: /frr-isisd:isis/instance/flex-algos/flex-algo/advertise-definition */ -int isis_instance_flex_algo_advertise_definition_modify( - struct nb_cb_modify_args *args) +int isis_instance_flex_algo_advertise_definition_modify(struct nb_cb_modify_args *args) { struct isis_area *area; struct flex_algo *fa; @@ -2890,8 +2716,7 @@ int isis_instance_flex_algo_advertise_definition_modify( area = nb_running_get_entry(args->dnode, NULL, true); fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } fa->advertise_definition = advertise; @@ -2906,8 +2731,7 @@ int isis_instance_flex_algo_advertise_definition_modify( return NB_OK; } -int isis_instance_flex_algo_advertise_definition_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_flex_algo_advertise_definition_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; struct flex_algo *fa; @@ -2923,8 +2747,7 @@ int isis_instance_flex_algo_advertise_definition_destroy( fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } fa->advertise_definition = false; @@ -2933,8 +2756,7 @@ int isis_instance_flex_algo_advertise_definition_destroy( return NB_OK; } -static int isis_instance_flex_algo_affinity_set(struct nb_cb_create_args *args, - int type) +static int isis_instance_flex_algo_affinity_set(struct nb_cb_create_args *args, int type) { char xpathr[XPATH_MAXLEN]; struct lyd_node *dnode; @@ -2950,11 +2772,10 @@ static int isis_instance_flex_algo_affinity_set(struct nb_cb_create_args *args, switch (args->event) { case NB_EV_VALIDATE: snprintf(xpathr, sizeof(xpathr), - "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']/value", - val); + "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']/value", val); if (!yang_dnode_get(args->dnode, xpathr)) { - snprintf(args->errmsg, args->errmsg_len, - "affinity map %s isn't found", val); + snprintf(args->errmsg, args->errmsg_len, "affinity map %s isn't found", + val); return NB_ERR_VALIDATION; } break; @@ -2962,22 +2783,19 @@ static int isis_instance_flex_algo_affinity_set(struct nb_cb_create_args *args, case NB_EV_ABORT: break; case NB_EV_APPLY: - algorithm = yang_dnode_get_uint32(args->dnode, - "../../flex-algo"); + algorithm = yang_dnode_get_uint32(args->dnode, "../../flex-algo"); area = nb_running_get_entry(args->dnode, NULL, true); fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } snprintf(xpathr, sizeof(xpathr), - "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']/value", - val); + "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']/value", val); dnode = yang_dnode_get(args->dnode, xpathr); if (!dnode) { - snprintf(args->errmsg, args->errmsg_len, - "affinity map %s isn't found", val); + snprintf(args->errmsg, args->errmsg_len, "affinity map %s isn't found", + val); return NB_ERR_RESOURCE; } if (type == AFFINITY_INCLUDE_ANY) @@ -2998,9 +2816,7 @@ static int isis_instance_flex_algo_affinity_set(struct nb_cb_create_args *args, return NB_OK; } -static int -isis_instance_flex_algo_affinity_unset(struct nb_cb_destroy_args *args, - int type) +static int isis_instance_flex_algo_affinity_unset(struct nb_cb_destroy_args *args, int type) { struct affinity_map *map; struct isis_area *area; @@ -3015,8 +2831,8 @@ isis_instance_flex_algo_affinity_unset(struct nb_cb_destroy_args *args, case NB_EV_VALIDATE: map = affinity_map_get(val); if (!map) { - snprintf(args->errmsg, args->errmsg_len, - "affinity map %s isn't found", val); + snprintf(args->errmsg, args->errmsg_len, "affinity map %s isn't found", + val); return NB_ERR_VALIDATION; } break; @@ -3024,19 +2840,17 @@ isis_instance_flex_algo_affinity_unset(struct nb_cb_destroy_args *args, case NB_EV_ABORT: break; case NB_EV_APPLY: - algorithm = yang_dnode_get_uint32(args->dnode, - "../../flex-algo"); + algorithm = yang_dnode_get_uint32(args->dnode, "../../flex-algo"); area = nb_running_get_entry(args->dnode, NULL, true); fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } map = affinity_map_get(val); if (!map) { - snprintf(args->errmsg, args->errmsg_len, - "affinity map %s isn't found", val); + snprintf(args->errmsg, args->errmsg_len, "affinity map %s isn't found", + val); return NB_ERR_RESOURCE; } if (type == AFFINITY_INCLUDE_ANY) @@ -3062,51 +2876,42 @@ isis_instance_flex_algo_affinity_unset(struct nb_cb_destroy_args *args, * XPath: * /frr-isisd:isis/instance/flex-algos/flex-algo/affinity-include-anies/affinity-include-any */ -int isis_instance_flex_algo_affinity_include_any_create( - struct nb_cb_create_args *args) +int isis_instance_flex_algo_affinity_include_any_create(struct nb_cb_create_args *args) { return isis_instance_flex_algo_affinity_set(args, AFFINITY_INCLUDE_ANY); } -int isis_instance_flex_algo_affinity_include_any_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_flex_algo_affinity_include_any_destroy(struct nb_cb_destroy_args *args) { - return isis_instance_flex_algo_affinity_unset(args, - AFFINITY_INCLUDE_ANY); + return isis_instance_flex_algo_affinity_unset(args, AFFINITY_INCLUDE_ANY); } /* * XPath: * /frr-isisd:isis/instance/flex-algos/flex-algo/affinity-include-alls/affinity-include-all */ -int isis_instance_flex_algo_affinity_include_all_create( - struct nb_cb_create_args *args) +int isis_instance_flex_algo_affinity_include_all_create(struct nb_cb_create_args *args) { return isis_instance_flex_algo_affinity_set(args, AFFINITY_INCLUDE_ALL); } -int isis_instance_flex_algo_affinity_include_all_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_flex_algo_affinity_include_all_destroy(struct nb_cb_destroy_args *args) { - return isis_instance_flex_algo_affinity_unset(args, - AFFINITY_INCLUDE_ALL); + return isis_instance_flex_algo_affinity_unset(args, AFFINITY_INCLUDE_ALL); } /* * XPath: * /frr-isisd:isis/instance/flex-algos/flex-algo/affinity-exclude-anies/affinity-exclude-any */ -int isis_instance_flex_algo_affinity_exclude_any_create( - struct nb_cb_create_args *args) +int isis_instance_flex_algo_affinity_exclude_any_create(struct nb_cb_create_args *args) { return isis_instance_flex_algo_affinity_set(args, AFFINITY_EXCLUDE_ANY); } -int isis_instance_flex_algo_affinity_exclude_any_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_flex_algo_affinity_exclude_any_destroy(struct nb_cb_destroy_args *args) { - return isis_instance_flex_algo_affinity_unset(args, - AFFINITY_EXCLUDE_ANY); + return isis_instance_flex_algo_affinity_unset(args, AFFINITY_EXCLUDE_ANY); } /* @@ -3128,8 +2933,7 @@ int isis_instance_flex_algo_prefix_metric_create(struct nb_cb_create_args *args) return NB_ERR_RESOURCE; fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } SET_FLAG(fa->flags, FAD_FLAG_M); @@ -3144,8 +2948,7 @@ int isis_instance_flex_algo_prefix_metric_create(struct nb_cb_create_args *args) return NB_OK; } -int isis_instance_flex_algo_prefix_metric_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_flex_algo_prefix_metric_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; struct flex_algo *fa; @@ -3161,8 +2964,7 @@ int isis_instance_flex_algo_prefix_metric_destroy( fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } UNSET_FLAG(fa->flags, FAD_FLAG_M); @@ -3177,8 +2979,7 @@ int isis_instance_flex_algo_prefix_metric_destroy( return NB_OK; } -static int isis_instance_flex_algo_dplane_set(struct nb_cb_create_args *args, - int type) +static int isis_instance_flex_algo_dplane_set(struct nb_cb_create_args *args, int type) { struct isis_area *area; struct flex_algo *fa; @@ -3194,8 +2995,7 @@ static int isis_instance_flex_algo_dplane_set(struct nb_cb_create_args *args, fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } SET_FLAG(fa->dataplanes, type); @@ -3217,8 +3017,7 @@ static int isis_instance_flex_algo_dplane_set(struct nb_cb_create_args *args, return NB_OK; } -static int isis_instance_flex_algo_dplane_unset(struct nb_cb_destroy_args *args, - int type) +static int isis_instance_flex_algo_dplane_unset(struct nb_cb_destroy_args *args, int type) { struct isis_area *area; struct flex_algo *fa; @@ -3234,8 +3033,7 @@ static int isis_instance_flex_algo_dplane_unset(struct nb_cb_destroy_args *args, fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } UNSET_FLAG(fa->dataplanes, type); @@ -3254,14 +3052,12 @@ static int isis_instance_flex_algo_dplane_unset(struct nb_cb_destroy_args *args, * XPath: /frr-isisd:isis/instance/flex-algos/flex-algo/dplane-sr-mpls */ -int isis_instance_flex_algo_dplane_sr_mpls_create( - struct nb_cb_create_args *args) +int isis_instance_flex_algo_dplane_sr_mpls_create(struct nb_cb_create_args *args) { return isis_instance_flex_algo_dplane_set(args, FLEX_ALGO_SR_MPLS); } -int isis_instance_flex_algo_dplane_sr_mpls_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_flex_algo_dplane_sr_mpls_destroy(struct nb_cb_destroy_args *args) { return isis_instance_flex_algo_dplane_unset(args, FLEX_ALGO_SR_MPLS); } @@ -3316,8 +3112,7 @@ int isis_instance_flex_algo_metric_type_modify(struct nb_cb_modify_args *args) fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } fa->metric_type = metric_type; @@ -3354,8 +3149,7 @@ int isis_instance_flex_algo_priority_modify(struct nb_cb_modify_args *args) fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } fa->priority = priority; @@ -3388,8 +3182,7 @@ int isis_instance_flex_algo_priority_destroy(struct nb_cb_destroy_args *args) fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); + snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } fa->priority = priority; @@ -3407,8 +3200,7 @@ int isis_instance_flex_algo_priority_destroy(struct nb_cb_destroy_args *args) /* * XPath: /frr-isisd:isis/instance/segment-routing-srv6/enabled */ -int isis_instance_segment_routing_srv6_enabled_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_srv6_enabled_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -3420,12 +3212,10 @@ int isis_instance_segment_routing_srv6_enabled_modify( if (area->srv6db.config.enabled) { if (IS_DEBUG_EVENTS) - zlog_debug( - "Segment Routing over IPv6 (SRv6): OFF -> ON"); + zlog_debug("Segment Routing over IPv6 (SRv6): OFF -> ON"); } else { if (IS_DEBUG_EVENTS) - zlog_debug( - "Segment Routing over IPv6 (SRv6): ON -> OFF"); + zlog_debug("Segment Routing over IPv6 (SRv6): ON -> OFF"); } /* Regenerate LSPs to advertise SRv6 capabilities or signal that the @@ -3438,8 +3228,7 @@ int isis_instance_segment_routing_srv6_enabled_modify( /* * XPath: /frr-isisd:isis/instance/segment-routing-srv6/locator */ -int isis_instance_segment_routing_srv6_locator_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_srv6_locator_modify(struct nb_cb_modify_args *args) { struct isis_area *area; const char *loc_name; @@ -3447,15 +3236,14 @@ int isis_instance_segment_routing_srv6_locator_modify( if (args->event != NB_EV_APPLY) return NB_OK; - area = nb_running_get_entry(lyd_parent(lyd_parent(args->dnode)), NULL, - true); + area = nb_running_get_entry(lyd_parent(lyd_parent(args->dnode)), NULL, true); loc_name = yang_dnode_get_string(args->dnode, NULL); if (strncmp(loc_name, area->srv6db.config.srv6_locator_name, sizeof(area->srv6db.config.srv6_locator_name)) == 0) { - snprintf(args->errmsg, args->errmsg_len, - "SRv6 locator %s is already configured", loc_name); + snprintf(args->errmsg, args->errmsg_len, "SRv6 locator %s is already configured", + loc_name); return NB_ERR_NO_CHANGES; } @@ -3472,11 +3260,9 @@ int isis_instance_segment_routing_srv6_locator_modify( strlcpy(area->srv6db.config.srv6_locator_name, loc_name, sizeof(area->srv6db.config.srv6_locator_name)); - sr_debug("Configured SRv6 locator %s for IS-IS area %s", loc_name, - area->area_tag); + sr_debug("Configured SRv6 locator %s for IS-IS area %s", loc_name, area->area_tag); - sr_debug("Trying to get locator %s for IS-IS area %s", loc_name, - area->area_tag); + sr_debug("Trying to get locator %s for IS-IS area %s", loc_name, area->area_tag); if (isis_zebra_srv6_manager_get_locator(loc_name) < 0) return NB_ERR; @@ -3484,8 +3270,7 @@ int isis_instance_segment_routing_srv6_locator_modify( return NB_OK; } -int isis_instance_segment_routing_srv6_locator_destroy( - struct nb_cb_destroy_args *args) +int isis_instance_segment_routing_srv6_locator_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; const char *loc_name; @@ -3493,8 +3278,7 @@ int isis_instance_segment_routing_srv6_locator_destroy( if (args->event != NB_EV_APPLY) return NB_OK; - area = nb_running_get_entry(lyd_parent(lyd_parent(args->dnode)), NULL, - true); + area = nb_running_get_entry(lyd_parent(lyd_parent(args->dnode)), NULL, true); loc_name = yang_dnode_get_string(args->dnode, NULL); @@ -3503,8 +3287,8 @@ int isis_instance_segment_routing_srv6_locator_destroy( if (strncmp(loc_name, area->srv6db.config.srv6_locator_name, sizeof(area->srv6db.config.srv6_locator_name)) != 0) { sr_debug("SRv6 locator %s is not configured", loc_name); - snprintf(args->errmsg, args->errmsg_len, - "SRv6 locator %s is not configured", loc_name); + snprintf(args->errmsg, args->errmsg_len, "SRv6 locator %s is not configured", + loc_name); return NB_ERR_NO_CHANGES; } @@ -3513,8 +3297,7 @@ int isis_instance_segment_routing_srv6_locator_destroy( return NB_ERR; } - sr_debug("Deleted SRv6 locator %s for IS-IS area %s", loc_name, - area->area_tag); + sr_debug("Deleted SRv6 locator %s for IS-IS area %s", loc_name, area->area_tag); return NB_OK; } @@ -3531,8 +3314,7 @@ int isis_instance_segment_routing_srv6_msd_node_msd_max_segs_left_modify( return NB_OK; area = nb_running_get_entry(args->dnode, NULL, true); - area->srv6db.config.max_seg_left_msd = yang_dnode_get_uint8(args->dnode, - NULL); + area->srv6db.config.max_seg_left_msd = yang_dnode_get_uint8(args->dnode, NULL); /* Update and regenerate LSP */ lsp_regenerate_schedule(area, area->is_type, 0); @@ -3543,8 +3325,7 @@ int isis_instance_segment_routing_srv6_msd_node_msd_max_segs_left_modify( /* * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-end-pop */ -int isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -3552,8 +3333,7 @@ int isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_modify( return NB_OK; area = nb_running_get_entry(args->dnode, NULL, true); - area->srv6db.config.max_end_pop_msd = yang_dnode_get_uint8(args->dnode, - NULL); + area->srv6db.config.max_end_pop_msd = yang_dnode_get_uint8(args->dnode, NULL); /* Update and regenerate LSP */ lsp_regenerate_schedule(area, area->is_type, 0); @@ -3573,8 +3353,7 @@ int isis_instance_segment_routing_srv6_msd_node_msd_max_h_encaps_modify( return NB_OK; area = nb_running_get_entry(args->dnode, NULL, true); - area->srv6db.config.max_h_encaps_msd = yang_dnode_get_uint8(args->dnode, - NULL); + area->srv6db.config.max_h_encaps_msd = yang_dnode_get_uint8(args->dnode, NULL); /* Update and regenerate LSP */ lsp_regenerate_schedule(area, area->is_type, 0); @@ -3585,8 +3364,7 @@ int isis_instance_segment_routing_srv6_msd_node_msd_max_h_encaps_modify( /* * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-end-d */ -int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_modify(struct nb_cb_modify_args *args) { struct isis_area *area; @@ -3594,8 +3372,7 @@ int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_modify( return NB_OK; area = nb_running_get_entry(args->dnode, NULL, true); - area->srv6db.config.max_end_d_msd = yang_dnode_get_uint8(args->dnode, - NULL); + area->srv6db.config.max_end_d_msd = yang_dnode_get_uint8(args->dnode, NULL); /* Update and regenerate LSP */ lsp_regenerate_schedule(area, area->is_type, 0); @@ -3606,8 +3383,7 @@ int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_modify( /* * XPath: /frr-isisd:isis/instance/segment-routing-srv6/interface */ -int isis_instance_segment_routing_srv6_interface_modify( - struct nb_cb_modify_args *args) +int isis_instance_segment_routing_srv6_interface_modify(struct nb_cb_modify_args *args) { struct isis_area *area; const char *ifname; @@ -3615,13 +3391,11 @@ int isis_instance_segment_routing_srv6_interface_modify( if (args->event != NB_EV_APPLY) return NB_OK; - area = nb_running_get_entry(lyd_parent(lyd_parent(args->dnode)), NULL, - true); + area = nb_running_get_entry(lyd_parent(lyd_parent(args->dnode)), NULL, true); ifname = yang_dnode_get_string(args->dnode, NULL); - sr_debug("Changing SRv6 interface for IS-IS area %s to %s", - area->area_tag, ifname); + sr_debug("Changing SRv6 interface for IS-IS area %s to %s", area->area_tag, ifname); isis_srv6_interface_set(area, ifname); @@ -3638,8 +3412,7 @@ int isis_instance_mpls_ldp_sync_create(struct nb_cb_create_args *args) switch (args->event) { case NB_EV_VALIDATE: - vrfname = yang_dnode_get_string( - lyd_parent(lyd_parent(args->dnode)), "./vrf"); + vrfname = yang_dnode_get_string(lyd_parent(lyd_parent(args->dnode)), "./vrf"); if (strcmp(vrfname, VRF_DEFAULT_NAME)) { snprintf(args->errmsg, args->errmsg_len, @@ -3682,9 +3455,8 @@ int isis_instance_mpls_ldp_sync_holddown_modify(struct nb_cb_modify_args *args) switch (args->event) { case NB_EV_VALIDATE: - vrfname = yang_dnode_get_string( - lyd_parent(lyd_parent(lyd_parent(args->dnode))), - "./vrf"); + vrfname = yang_dnode_get_string(lyd_parent(lyd_parent(lyd_parent(args->dnode))), + "./vrf"); if (strcmp(vrfname, VRF_DEFAULT_NAME)) { snprintf(args->errmsg, args->errmsg_len, @@ -3750,8 +3522,7 @@ int lib_interface_isis_area_tag_modify(struct nb_cb_modify_args *args) struct isis_circuit *circuit; if (args->event == NB_EV_VALIDATE) { - circuit = nb_running_get_entry_non_rec(lyd_parent(args->dnode), - NULL, false); + circuit = nb_running_get_entry_non_rec(lyd_parent(args->dnode), NULL, false); if (circuit) { snprintf(args->errmsg, args->errmsg_len, "Changing area tag is not allowed"); @@ -3827,8 +3598,7 @@ int lib_interface_isis_ipv6_routing_modify(struct nb_cb_modify_args *args) /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring */ -void lib_interface_isis_bfd_monitoring_apply_finish( - struct nb_cb_apply_finish_args *args) +void lib_interface_isis_bfd_monitoring_apply_finish(struct nb_cb_apply_finish_args *args) { struct isis_circuit *circuit; @@ -3839,8 +3609,7 @@ void lib_interface_isis_bfd_monitoring_apply_finish( /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring/enabled */ -int lib_interface_isis_bfd_monitoring_enabled_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_bfd_monitoring_enabled_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; @@ -3856,8 +3625,7 @@ int lib_interface_isis_bfd_monitoring_enabled_modify( /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring/profile */ -int lib_interface_isis_bfd_monitoring_profile_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_bfd_monitoring_profile_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; @@ -3866,14 +3634,12 @@ int lib_interface_isis_bfd_monitoring_profile_modify( circuit = nb_running_get_entry(args->dnode, NULL, true); XFREE(MTYPE_TMP, circuit->bfd_config.profile); - circuit->bfd_config.profile = - XSTRDUP(MTYPE_TMP, yang_dnode_get_string(args->dnode, NULL)); + circuit->bfd_config.profile = XSTRDUP(MTYPE_TMP, yang_dnode_get_string(args->dnode, NULL)); return NB_OK; } -int lib_interface_isis_bfd_monitoring_profile_destroy( - struct nb_cb_destroy_args *args) +int lib_interface_isis_bfd_monitoring_profile_destroy(struct nb_cb_destroy_args *args) { struct isis_circuit *circuit; @@ -3889,8 +3655,7 @@ int lib_interface_isis_bfd_monitoring_profile_destroy( /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-1 */ -int lib_interface_isis_csnp_interval_level_1_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_csnp_interval_level_1_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; @@ -3906,8 +3671,7 @@ int lib_interface_isis_csnp_interval_level_1_modify( /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval/level-2 */ -int lib_interface_isis_csnp_interval_level_2_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_csnp_interval_level_2_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; @@ -3923,8 +3687,7 @@ int lib_interface_isis_csnp_interval_level_2_modify( /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-1 */ -int lib_interface_isis_psnp_interval_level_1_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_psnp_interval_level_1_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; @@ -3940,8 +3703,7 @@ int lib_interface_isis_psnp_interval_level_1_modify( /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval/level-2 */ -int lib_interface_isis_psnp_interval_level_2_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_psnp_interval_level_2_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; @@ -3973,8 +3735,7 @@ int lib_interface_isis_hello_padding_modify(struct nb_cb_modify_args *args) /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1 */ -int lib_interface_isis_hello_interval_level_1_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_hello_interval_level_1_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; uint32_t interval; @@ -3992,8 +3753,7 @@ int lib_interface_isis_hello_interval_level_1_modify( /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-2 */ -int lib_interface_isis_hello_interval_level_2_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_hello_interval_level_2_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; uint32_t interval; @@ -4011,8 +3771,7 @@ int lib_interface_isis_hello_interval_level_2_modify( /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-1 */ -int lib_interface_isis_hello_multiplier_level_1_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_hello_multiplier_level_1_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; uint16_t multi; @@ -4030,8 +3789,7 @@ int lib_interface_isis_hello_multiplier_level_1_modify( /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier/level-2 */ -int lib_interface_isis_hello_multiplier_level_2_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_hello_multiplier_level_2_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; uint16_t multi; @@ -4128,17 +3886,14 @@ int lib_interface_isis_network_type_modify(struct nb_cb_modify_args *args) if (!circuit) break; if (circuit->circ_type == CIRCUIT_T_LOOPBACK) { - snprintf( - args->errmsg, args->errmsg_len, - "Cannot change network type on loopback interface"); + snprintf(args->errmsg, args->errmsg_len, + "Cannot change network type on loopback interface"); return NB_ERR_VALIDATION; } - if (net_type == CIRCUIT_T_BROADCAST - && circuit->state == C_STATE_UP - && !if_is_broadcast(circuit->interface)) { - snprintf( - args->errmsg, args->errmsg_len, - "Cannot configure non-broadcast interface for broadcast operation"); + if (net_type == CIRCUIT_T_BROADCAST && circuit->state == C_STATE_UP && + !if_is_broadcast(circuit->interface)) { + snprintf(args->errmsg, args->errmsg_len, + "Cannot configure non-broadcast interface for broadcast operation"); return NB_ERR_VALIDATION; } break; @@ -4214,8 +3969,7 @@ int lib_interface_isis_password_password_modify(struct nb_cb_modify_args *args) /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/password/password-type */ -int lib_interface_isis_password_password_type_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_password_password_type_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; uint8_t pass_type; @@ -4234,8 +3988,7 @@ int lib_interface_isis_password_password_type_modify( * XPath: * /frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake */ -int lib_interface_isis_disable_three_way_handshake_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_disable_three_way_handshake_modify(struct nb_cb_modify_args *args) { struct isis_circuit *circuit; @@ -4248,9 +4001,9 @@ int lib_interface_isis_disable_three_way_handshake_modify( return NB_OK; } -static int lib_interface_isis_multi_topology_common( - enum nb_event event, const struct lyd_node *dnode, char *errmsg, - size_t errmsg_len, uint16_t mtid) +static int lib_interface_isis_multi_topology_common(enum nb_event event, + const struct lyd_node *dnode, char *errmsg, + size_t errmsg_len, uint16_t mtid) { struct isis_circuit *circuit; bool value; @@ -4274,83 +4027,69 @@ static int lib_interface_isis_multi_topology_common( * XPath: * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/standard */ -int lib_interface_isis_multi_topology_standard_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_multi_topology_standard_modify(struct nb_cb_modify_args *args) { - return lib_interface_isis_multi_topology_common( - args->event, args->dnode, args->errmsg, args->errmsg_len, - ISIS_MT_STANDARD); + return lib_interface_isis_multi_topology_common(args->event, args->dnode, args->errmsg, + args->errmsg_len, ISIS_MT_STANDARD); } /* * XPath: * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-multicast */ -int lib_interface_isis_multi_topology_ipv4_multicast_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_multi_topology_ipv4_multicast_modify(struct nb_cb_modify_args *args) { - return lib_interface_isis_multi_topology_common( - args->event, args->dnode, args->errmsg, args->errmsg_len, - ISIS_MT_IPV4_MULTICAST); + return lib_interface_isis_multi_topology_common(args->event, args->dnode, args->errmsg, + args->errmsg_len, ISIS_MT_IPV4_MULTICAST); } /* * XPath: * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv4-management */ -int lib_interface_isis_multi_topology_ipv4_management_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_multi_topology_ipv4_management_modify(struct nb_cb_modify_args *args) { - return lib_interface_isis_multi_topology_common( - args->event, args->dnode, args->errmsg, args->errmsg_len, - ISIS_MT_IPV4_MGMT); + return lib_interface_isis_multi_topology_common(args->event, args->dnode, args->errmsg, + args->errmsg_len, ISIS_MT_IPV4_MGMT); } /* * XPath: * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-unicast */ -int lib_interface_isis_multi_topology_ipv6_unicast_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_multi_topology_ipv6_unicast_modify(struct nb_cb_modify_args *args) { - return lib_interface_isis_multi_topology_common( - args->event, args->dnode, args->errmsg, args->errmsg_len, - ISIS_MT_IPV6_UNICAST); + return lib_interface_isis_multi_topology_common(args->event, args->dnode, args->errmsg, + args->errmsg_len, ISIS_MT_IPV6_UNICAST); } /* * XPath: * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-multicast */ -int lib_interface_isis_multi_topology_ipv6_multicast_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_multi_topology_ipv6_multicast_modify(struct nb_cb_modify_args *args) { - return lib_interface_isis_multi_topology_common( - args->event, args->dnode, args->errmsg, args->errmsg_len, - ISIS_MT_IPV6_MULTICAST); + return lib_interface_isis_multi_topology_common(args->event, args->dnode, args->errmsg, + args->errmsg_len, ISIS_MT_IPV6_MULTICAST); } /* * XPath: * /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-management */ -int lib_interface_isis_multi_topology_ipv6_management_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_multi_topology_ipv6_management_modify(struct nb_cb_modify_args *args) { - return lib_interface_isis_multi_topology_common( - args->event, args->dnode, args->errmsg, args->errmsg_len, - ISIS_MT_IPV6_MGMT); + return lib_interface_isis_multi_topology_common(args->event, args->dnode, args->errmsg, + args->errmsg_len, ISIS_MT_IPV6_MGMT); } /* * XPath: /frr-interface:lib/interface/frr-isisd:isis/multi-topology/ipv6-dstsrc */ -int lib_interface_isis_multi_topology_ipv6_dstsrc_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_multi_topology_ipv6_dstsrc_modify(struct nb_cb_modify_args *args) { - return lib_interface_isis_multi_topology_common( - args->event, args->dnode, args->errmsg, args->errmsg_len, - ISIS_MT_IPV6_DSTSRC); + return lib_interface_isis_multi_topology_common(args->event, args->dnode, args->errmsg, + args->errmsg_len, ISIS_MT_IPV6_DSTSRC); } /* @@ -4442,8 +4181,7 @@ int lib_interface_isis_mpls_holddown_destroy(struct nb_cb_destroy_args *args) * XPath: * /frr-interface:lib/interface/frr-isisd:isis/fast-reroute/level-1/lfa/enable */ -int lib_interface_isis_fast_reroute_level_1_lfa_enable_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_fast_reroute_level_1_lfa_enable_modify(struct nb_cb_modify_args *args) { struct isis_area *area; struct isis_circuit *circuit; @@ -4519,8 +4257,7 @@ int lib_interface_isis_fast_reroute_level_1_lfa_exclude_interface_destroy( * XPath: * /frr-interface:lib/interface/frr-isisd:isis/fast-reroute/level-1/remote-lfa/enable */ -int lib_interface_isis_fast_reroute_level_1_remote_lfa_enable_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_fast_reroute_level_1_remote_lfa_enable_modify(struct nb_cb_modify_args *args) { struct isis_area *area; struct isis_circuit *circuit; @@ -4592,8 +4329,7 @@ int lib_interface_isis_fast_reroute_level_1_remote_lfa_maximum_metric_destroy( * XPath: * /frr-interface:lib/interface/frr-isisd:isis/fast-reroute/level-1/ti-lfa/enable */ -int lib_interface_isis_fast_reroute_level_1_ti_lfa_enable_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_fast_reroute_level_1_ti_lfa_enable_modify(struct nb_cb_modify_args *args) { struct isis_area *area; struct isis_circuit *circuit; @@ -4633,8 +4369,7 @@ int lib_interface_isis_fast_reroute_level_1_ti_lfa_node_protection_modify( return NB_OK; circuit = nb_running_get_entry(args->dnode, NULL, true); - circuit->tilfa_node_protection[0] = - yang_dnode_get_bool(args->dnode, NULL); + circuit->tilfa_node_protection[0] = yang_dnode_get_bool(args->dnode, NULL); area = circuit->area; if (area) @@ -4657,8 +4392,7 @@ int lib_interface_isis_fast_reroute_level_1_ti_lfa_link_fallback_modify( return NB_OK; circuit = nb_running_get_entry(args->dnode, NULL, true); - circuit->tilfa_link_fallback[0] = - yang_dnode_get_bool(args->dnode, NULL); + circuit->tilfa_link_fallback[0] = yang_dnode_get_bool(args->dnode, NULL); area = circuit->area; if (area) @@ -4671,8 +4405,7 @@ int lib_interface_isis_fast_reroute_level_1_ti_lfa_link_fallback_modify( * XPath: * /frr-interface:lib/interface/frr-isisd:isis/fast-reroute/level-2/lfa/enable */ -int lib_interface_isis_fast_reroute_level_2_lfa_enable_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_fast_reroute_level_2_lfa_enable_modify(struct nb_cb_modify_args *args) { struct isis_area *area; struct isis_circuit *circuit; @@ -4748,8 +4481,7 @@ int lib_interface_isis_fast_reroute_level_2_lfa_exclude_interface_destroy( * XPath: * /frr-interface:lib/interface/frr-isisd:isis/fast-reroute/level-2/remote-lfa/enable */ -int lib_interface_isis_fast_reroute_level_2_remote_lfa_enable_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_fast_reroute_level_2_remote_lfa_enable_modify(struct nb_cb_modify_args *args) { struct isis_area *area; struct isis_circuit *circuit; @@ -4821,8 +4553,7 @@ int lib_interface_isis_fast_reroute_level_2_remote_lfa_maximum_metric_destroy( * XPath: * /frr-interface:lib/interface/frr-isisd:isis/fast-reroute/level-2/ti-lfa/enable */ -int lib_interface_isis_fast_reroute_level_2_ti_lfa_enable_modify( - struct nb_cb_modify_args *args) +int lib_interface_isis_fast_reroute_level_2_ti_lfa_enable_modify(struct nb_cb_modify_args *args) { struct isis_area *area; struct isis_circuit *circuit; @@ -4862,8 +4593,7 @@ int lib_interface_isis_fast_reroute_level_2_ti_lfa_node_protection_modify( return NB_OK; circuit = nb_running_get_entry(args->dnode, NULL, true); - circuit->tilfa_node_protection[1] = - yang_dnode_get_bool(args->dnode, NULL); + circuit->tilfa_node_protection[1] = yang_dnode_get_bool(args->dnode, NULL); area = circuit->area; if (area) @@ -4886,8 +4616,7 @@ int lib_interface_isis_fast_reroute_level_2_ti_lfa_link_fallback_modify( return NB_OK; circuit = nb_running_get_entry(args->dnode, NULL, true); - circuit->tilfa_link_fallback[1] = - yang_dnode_get_bool(args->dnode, NULL); + circuit->tilfa_link_fallback[1] = yang_dnode_get_bool(args->dnode, NULL); area = circuit->area; if (area) diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index b24751b682f4..31ca229a54c7 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -163,7 +163,7 @@ static int process_p2p_hello(struct iih_info *iih) (iih->circuit->is_type_config == IS_LEVEL_1_AND_2) && (iih->circ_type == IS_LEVEL_1))) { if (!isis_tlvs_area_addresses_match(iih->tlvs, - iih->circuit->area + &iih->circuit->area ->area_addrs)) { if (IS_DEBUG_ADJ_PACKETS) { zlog_debug("ISIS-Adj (%s): Rcvd P2P IIH from (%s), cir type %s, cir id %u, length %u", @@ -201,7 +201,7 @@ static int process_p2p_hello(struct iih_info *iih) iih->calculated_type = IS_LEVEL_1_AND_2; if (!isis_tlvs_area_addresses_match(iih->tlvs, - iih->circuit->area + &iih->circuit->area ->area_addrs)) { iih->calculated_type = IS_LEVEL_2; } @@ -277,7 +277,7 @@ static int process_p2p_hello(struct iih_info *iih) /* 8.2.5.2 a) a match was detected */ if (isis_tlvs_area_addresses_match(iih->tlvs, - iih->circuit->area->area_addrs)) { + &iih->circuit->area->area_addrs)) { /* 8.2.5.2 a) 2) If the calculated type is L1 - table 5 */ if (iih->calculated_type == IS_LEVEL_1) { switch (iih->circ_type) { @@ -362,7 +362,7 @@ static int process_p2p_hello(struct iih_info *iih) } } /* 8.2.5.2 b) if no match was detected */ - else if (listcount(iih->circuit->area->area_addrs) > 0) { + else if (iso_address_list_count(&iih->circuit->area->area_addrs) > 0) { if (iih->calculated_type == IS_LEVEL_1) { /* 8.2.5.2 b) 1) is_type L1 and adj is not up */ if (adj->adj_state != ISIS_ADJ_UP) { @@ -789,10 +789,10 @@ static int process_hello(uint8_t pdu_type, struct isis_circuit *circuit, } if (!p2p_hello - && (listcount(circuit->area->area_addrs) == 0 + && (iso_address_list_count(&circuit->area->area_addrs) == 0 || (level == ISIS_LEVEL1 && !isis_tlvs_area_addresses_match( - iih.tlvs, circuit->area->area_addrs)))) { + iih.tlvs, &circuit->area->area_addrs)))) { if (IS_DEBUG_ADJ_PACKETS) { zlog_debug( "ISIS-Adj (%s): Area mismatch, level %d IIH on %s", @@ -1956,12 +1956,12 @@ int send_hello(struct isis_circuit *circuit, int level) isis_tlvs_add_auth(tlvs, &circuit->passwd); - if (!listcount(circuit->area->area_addrs)) { + if (!iso_address_list_count(&circuit->area->area_addrs)) { isis_free_tlvs(tlvs); return ISIS_WARNING; } - isis_tlvs_add_area_addresses(tlvs, circuit->area->area_addrs); + isis_tlvs_add_area_addresses(tlvs, &circuit->area->area_addrs); if (circuit->circ_type == CIRCUIT_T_BROADCAST) { isis_tlvs_add_lan_neighbors( diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 8357cde42e5d..07da90211660 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -305,7 +305,6 @@ void isis_redist_add(struct isis *isis, int type, struct prefix *p, struct route_table *ei_table = get_ext_info(isis, family); struct route_node *ei_node; struct isis_ext_info *info; - struct listnode *node; struct isis_area *area; int level; struct isis_redist *redist; @@ -337,7 +336,7 @@ void isis_redist_add(struct isis *isis, int type, struct prefix *p, type = DEFAULT_ROUTE; } - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) + frr_each (isis_area_list, &isis->area_list, area) for (level = 1; level <= ISIS_LEVELS; level++) { redist = isis_redist_lookup(area, family, type, level, table); @@ -355,7 +354,6 @@ void isis_redist_delete(struct isis *isis, int type, struct prefix *p, int family = p->family; struct route_table *ei_table = get_ext_info(isis, family); struct route_node *ei_node; - struct listnode *node; struct isis_area *area; int level; struct isis_redist *redist; @@ -391,7 +389,7 @@ void isis_redist_delete(struct isis *isis, int type, struct prefix *p, } route_unlock_node(ei_node); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) + frr_each (isis_area_list, &isis->area_list, area) for (level = ISIS_LEVEL1; level <= ISIS_LEVEL2; level++) { redist = isis_redist_lookup(area, family, type, level, table); diff --git a/isisd/isis_route.c b/isisd/isis_route.c index 0a0c6341d6f3..445a959f5835 100644 --- a/isisd/isis_route.c +++ b/isisd/isis_route.c @@ -38,24 +38,22 @@ #include "isis_zebra.h" #include "isis_flex_algo.h" -DEFINE_MTYPE_STATIC(ISISD, ISIS_NEXTHOP, "ISIS nexthop"); +DEFINE_MTYPE_STATIC(ISISD, ISIS_NEXTHOP, "ISIS nexthop"); DEFINE_MTYPE_STATIC(ISISD, ISIS_ROUTE_INFO, "ISIS route info"); DEFINE_MTYPE_STATIC(ISISD, ISIS_ROUTE_TABLE_INFO, "ISIS route table info"); DEFINE_HOOK(isis_route_update_hook, - (struct isis_area * area, struct prefix *prefix, + (struct isis_area *area, struct prefix *prefix, struct isis_route_info *route_info), (area, prefix, route_info)); -static struct isis_nexthop *nexthoplookup(struct list *nexthops, int family, - union g_addr *ip, ifindex_t ifindex); +static struct isis_nexthop *nexthoplookup(struct list *nexthops, int family, union g_addr *ip, + ifindex_t ifindex); static void isis_route_update(struct isis_area *area, struct prefix *prefix, - struct prefix_ipv6 *src_p, - struct isis_route_info *route_info); + struct prefix_ipv6 *src_p, struct isis_route_info *route_info); -static struct mpls_label_stack * -label_stack_dup(const struct mpls_label_stack *const orig) +static struct mpls_label_stack *label_stack_dup(const struct mpls_label_stack *const orig) { struct mpls_label_stack *copy; int array_size; @@ -64,15 +62,14 @@ label_stack_dup(const struct mpls_label_stack *const orig) return NULL; array_size = orig->num_labels * sizeof(mpls_label_t); - copy = XCALLOC(MTYPE_ISIS_NEXTHOP_LABELS, - sizeof(struct mpls_label_stack) + array_size); + copy = XCALLOC(MTYPE_ISIS_NEXTHOP_LABELS, sizeof(struct mpls_label_stack) + array_size); copy->num_labels = orig->num_labels; memcpy(copy->label, orig->label, array_size); return copy; } -static struct isis_nexthop * -isis_nexthop_create(int family, const union g_addr *const ip, ifindex_t ifindex) +static struct isis_nexthop *isis_nexthop_create(int family, const union g_addr *const ip, + ifindex_t ifindex) { struct isis_nexthop *nexthop; @@ -85,8 +82,7 @@ isis_nexthop_create(int family, const union g_addr *const ip, ifindex_t ifindex) return nexthop; } -static struct isis_nexthop * -isis_nexthop_dup(const struct isis_nexthop *const orig) +static struct isis_nexthop *isis_nexthop_dup(const struct isis_nexthop *const orig) { struct isis_nexthop *nexthop; @@ -119,8 +115,8 @@ static struct list *isis_nexthop_list_dup(const struct list *orig) return copy; } -static struct isis_nexthop *nexthoplookup(struct list *nexthops, int family, - union g_addr *ip, ifindex_t ifindex) +static struct isis_nexthop *nexthoplookup(struct list *nexthops, int family, union g_addr *ip, + ifindex_t ifindex) { struct listnode *node; struct isis_nexthop *nh; @@ -148,8 +144,7 @@ static struct isis_nexthop *nexthoplookup(struct list *nexthops, int family, continue; break; default: - flog_err(EC_LIB_DEVELOPMENT, - "%s: unknown address family [%d]", __func__, + flog_err(EC_LIB_DEVELOPMENT, "%s: unknown address family [%d]", __func__, family); exit(1); } @@ -160,9 +155,8 @@ static struct isis_nexthop *nexthoplookup(struct list *nexthops, int family, return NULL; } -void adjinfo2nexthop(int family, struct list *nexthops, - struct isis_adjacency *adj, struct isis_sr_psid_info *sr, - struct mpls_label_stack *label_stack) +void adjinfo2nexthop(int family, struct list *nexthops, struct isis_adjacency *adj, + struct isis_sr_psid_info *sr, struct mpls_label_stack *label_stack) { struct isis_nexthop *nh; union g_addr ip = {}; @@ -174,9 +168,8 @@ void adjinfo2nexthop(int family, struct list *nexthops, if (!nexthoplookup(nexthops, AF_INET, &ip, adj->circuit->interface->ifindex)) { - nh = isis_nexthop_create( - AF_INET, &ip, - adj->circuit->interface->ifindex); + nh = isis_nexthop_create(AF_INET, &ip, + adj->circuit->interface->ifindex); memcpy(nh->sysid, adj->sysid, sizeof(nh->sysid)); if (sr) nh->sr = *sr; @@ -192,9 +185,8 @@ void adjinfo2nexthop(int family, struct list *nexthops, if (!nexthoplookup(nexthops, AF_INET6, &ip, adj->circuit->interface->ifindex)) { - nh = isis_nexthop_create( - AF_INET6, &ip, - adj->circuit->interface->ifindex); + nh = isis_nexthop_create(AF_INET6, &ip, + adj->circuit->interface->ifindex); memcpy(nh->sysid, adj->sysid, sizeof(nh->sysid)); if (sr) nh->sr = *sr; @@ -205,14 +197,12 @@ void adjinfo2nexthop(int family, struct list *nexthops, } break; default: - flog_err(EC_LIB_DEVELOPMENT, "%s: unknown address family [%d]", - __func__, family); + flog_err(EC_LIB_DEVELOPMENT, "%s: unknown address family [%d]", __func__, family); exit(1); } } -static void isis_route_add_dummy_nexthops(struct isis_route_info *rinfo, - const uint8_t *sysid, +static void isis_route_add_dummy_nexthops(struct isis_route_info *rinfo, const uint8_t *sysid, struct isis_sr_psid_info *sr, struct mpls_label_stack *label_stack) { @@ -225,10 +215,10 @@ static void isis_route_add_dummy_nexthops(struct isis_route_info *rinfo, listnode_add(rinfo->nexthops, nh); } -static struct isis_route_info * -isis_route_info_new(struct prefix *prefix, struct prefix_ipv6 *src_p, - uint32_t cost, uint32_t depth, struct isis_sr_psid_info *sr, - struct list *adjacencies, bool allow_ecmp) +static struct isis_route_info *isis_route_info_new(struct prefix *prefix, + struct prefix_ipv6 *src_p, uint32_t cost, + uint32_t depth, struct isis_sr_psid_info *sr, + struct list *adjacencies, bool allow_ecmp) { struct isis_route_info *rinfo; struct isis_vertex_adj *vadj; @@ -248,20 +238,17 @@ isis_route_info_new(struct prefix *prefix, struct prefix_ipv6 *src_p, * environment. */ if (CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) { - isis_route_add_dummy_nexthops(rinfo, sadj->id, vsr, - label_stack); + isis_route_add_dummy_nexthops(rinfo, sadj->id, vsr, label_stack); if (!allow_ecmp) break; continue; } /* check for force resync this route */ - if (CHECK_FLAG(adj->circuit->flags, - ISIS_CIRCUIT_FLAPPED_AFTER_SPF)) + if (CHECK_FLAG(adj->circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF)) SET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC); - adjinfo2nexthop(prefix->family, rinfo->nexthops, adj, vsr, - label_stack); + adjinfo2nexthop(prefix->family, rinfo->nexthops, adj, vsr, label_stack); if (!allow_ecmp) break; } @@ -270,8 +257,8 @@ isis_route_info_new(struct prefix *prefix, struct prefix_ipv6 *src_p, rinfo->depth = depth; rinfo->sr_algo[sr->algorithm] = *sr; rinfo->sr_algo[sr->algorithm].nexthops = rinfo->nexthops; - rinfo->sr_algo[sr->algorithm].nexthops_backup = - rinfo->backup ? rinfo->backup->nexthops : NULL; + rinfo->sr_algo[sr->algorithm].nexthops_backup = rinfo->backup ? rinfo->backup->nexthops + : NULL; return rinfo; } @@ -285,14 +272,12 @@ static void isis_route_info_delete(struct isis_route_info *route_info) if (route_info->sr_algo[i].nexthops == route_info->nexthops) continue; - route_info->sr_algo[i].nexthops->del = - (void (*)(void *))isis_nexthop_delete; + route_info->sr_algo[i].nexthops->del = (void (*)(void *))isis_nexthop_delete; list_delete(&route_info->sr_algo[i].nexthops); } if (route_info->nexthops) { - route_info->nexthops->del = - (void (*)(void *))isis_nexthop_delete; + route_info->nexthops->del = (void (*)(void *))isis_nexthop_delete; list_delete(&route_info->nexthops); } @@ -326,8 +311,7 @@ uint8_t isis_route_table_algorithm(const struct route_table *table) return info ? info->algorithm : 0; } -static bool isis_sr_psid_info_same(struct isis_sr_psid_info *new, - struct isis_sr_psid_info *old) +static bool isis_sr_psid_info_same(struct isis_sr_psid_info *new, struct isis_sr_psid_info *old) { if (new->present != old->present) return false; @@ -335,8 +319,7 @@ static bool isis_sr_psid_info_same(struct isis_sr_psid_info *new, if (new->label != old->label) return false; - if (new->sid.flags != old->sid.flags - || new->sid.value != old->sid.value) + if (new->sid.flags != old->sid.flags || new->sid.value != old->sid.value) return false; if (new->sid.algorithm != old->sid.algorithm) @@ -345,8 +328,7 @@ static bool isis_sr_psid_info_same(struct isis_sr_psid_info *new, return true; } -static bool isis_label_stack_same(struct mpls_label_stack *new, - struct mpls_label_stack *old) +static bool isis_label_stack_same(struct mpls_label_stack *new, struct mpls_label_stack *old) { if (!new && !old) return true; @@ -354,31 +336,27 @@ static bool isis_label_stack_same(struct mpls_label_stack *new, return false; if (new->num_labels != old->num_labels) return false; - if (memcmp(&new->label, &old->label, - sizeof(mpls_label_t) * new->num_labels)) + if (memcmp(&new->label, &old->label, sizeof(mpls_label_t) * new->num_labels)) return false; return true; } -static int isis_route_info_same(struct isis_route_info *new, - struct isis_route_info *old, char *buf, - size_t buf_size) +static int isis_route_info_same(struct isis_route_info *new, struct isis_route_info *old, + char *buf, size_t buf_size) { struct listnode *node; struct isis_nexthop *new_nh, *old_nh; if (new->cost != old->cost) { if (buf) - snprintf(buf, buf_size, "cost (old: %u, new: %u)", - old->cost, new->cost); + snprintf(buf, buf_size, "cost (old: %u, new: %u)", old->cost, new->cost); return 0; } if (new->depth != old->depth) { if (buf) - snprintf(buf, buf_size, "depth (old: %u, new: %u)", - old->depth, new->depth); + snprintf(buf, buf_size, "depth (old: %u, new: %u)", old->depth, new->depth); return 0; } @@ -391,11 +369,9 @@ static int isis_route_info_same(struct isis_route_info *new, if (!isis_sr_psid_info_same(&new_sr_algo, &old_sr_algo)) { if (buf) - snprintf( - buf, buf_size, - "SR input label algo-%u (old: %s, new: %s)", - i, old_sr_algo.present ? "yes" : "no", - new_sr_algo.present ? "yes" : "no"); + snprintf(buf, buf_size, "SR input label algo-%u (old: %s, new: %s)", + i, old_sr_algo.present ? "yes" : "no", + new_sr_algo.present ? "yes" : "no"); return 0; } } @@ -408,12 +384,10 @@ static int isis_route_info_same(struct isis_route_info *new, } for (ALL_LIST_ELEMENTS_RO(new->nexthops, node, new_nh)) { - old_nh = nexthoplookup(old->nexthops, new_nh->family, - &new_nh->ip, new_nh->ifindex); + old_nh = nexthoplookup(old->nexthops, new_nh->family, &new_nh->ip, new_nh->ifindex); if (!old_nh) { if (buf) - snprintf(buf, buf_size, - "new nhop"); /* TODO: print nhop */ + snprintf(buf, buf_size, "new nhop"); /* TODO: print nhop */ return 0; } if (!isis_sr_psid_info_same(&new_nh->sr, &old_nh->sr)) { @@ -421,8 +395,7 @@ static int isis_route_info_same(struct isis_route_info *new, snprintf(buf, buf_size, "nhop SR label"); return 0; } - if (!isis_label_stack_same(new_nh->label_stack, - old_nh->label_stack)) { + if (!isis_label_stack_same(new_nh->label_stack, old_nh->label_stack)) { if (buf) snprintf(buf, buf_size, "nhop label stack"); return 0; @@ -430,8 +403,8 @@ static int isis_route_info_same(struct isis_route_info *new, } /* only the resync flag needs to be checked */ - if (CHECK_FLAG(new->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC) - != CHECK_FLAG(old->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC)) { + if (CHECK_FLAG(new->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC) != + CHECK_FLAG(old->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC)) { if (buf) snprintf(buf, buf_size, "resync flag"); return 0; @@ -440,11 +413,11 @@ static int isis_route_info_same(struct isis_route_info *new, return 1; } -struct isis_route_info * -isis_route_create(struct prefix *prefix, struct prefix_ipv6 *src_p, - uint32_t cost, uint32_t depth, struct isis_sr_psid_info *sr, - struct list *adjacencies, bool allow_ecmp, - struct isis_area *area, struct route_table *table) +struct isis_route_info *isis_route_create(struct prefix *prefix, struct prefix_ipv6 *src_p, + uint32_t cost, uint32_t depth, + struct isis_sr_psid_info *sr, struct list *adjacencies, + bool allow_ecmp, struct isis_area *area, + struct route_table *table) { struct route_node *route_node; struct isis_route_info *rinfo_new, *rinfo_old, *route_info = NULL; @@ -453,46 +426,39 @@ isis_route_create(struct prefix *prefix, struct prefix_ipv6 *src_p, if (!table) return NULL; - rinfo_new = isis_route_info_new(prefix, src_p, cost, depth, sr, - adjacencies, allow_ecmp); + rinfo_new = isis_route_info_new(prefix, src_p, cost, depth, sr, adjacencies, allow_ecmp); route_node = srcdest_rnode_get(table, prefix, src_p); rinfo_old = route_node->info; if (!rinfo_old) { if (IS_DEBUG_RTE_EVENTS) - zlog_debug("ISIS-Rte (%s) route created: %pFX", - area->area_tag, prefix); + zlog_debug("ISIS-Rte (%s) route created: %pFX", area->area_tag, prefix); route_info = rinfo_new; UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } else { route_unlock_node(route_node); #ifdef EXTREME_DEBUG if (IS_DEBUG_RTE_EVENTS) - zlog_debug("ISIS-Rte (%s) route already exists: %pFX", - area->area_tag, prefix); + zlog_debug("ISIS-Rte (%s) route already exists: %pFX", area->area_tag, + prefix); #endif /* EXTREME_DEBUG */ - if (isis_route_info_same(rinfo_new, rinfo_old, change_buf, - sizeof(change_buf))) { + if (isis_route_info_same(rinfo_new, rinfo_old, change_buf, sizeof(change_buf))) { #ifdef EXTREME_DEBUG if (IS_DEBUG_RTE_EVENTS) - zlog_debug( - "ISIS-Rte (%s) route unchanged: %pFX", - area->area_tag, prefix); + zlog_debug("ISIS-Rte (%s) route unchanged: %pFX", area->area_tag, + prefix); #endif /* EXTREME_DEBUG */ isis_route_info_delete(rinfo_new); route_info = rinfo_old; } else { if (IS_DEBUG_RTE_EVENTS) - zlog_debug( - "ISIS-Rte (%s): route changed: %pFX, change: %s", - area->area_tag, prefix, change_buf); + zlog_debug("ISIS-Rte (%s): route changed: %pFX, change: %s", + area->area_tag, prefix, change_buf); for (int i = 0; i < SR_ALGORITHM_COUNT; i++) - rinfo_new->sr_algo_previous[i] = - rinfo_old->sr_algo[i]; + rinfo_new->sr_algo_previous[i] = rinfo_old->sr_algo[i]; isis_route_info_delete(rinfo_old); route_info = rinfo_new; - UNSET_FLAG(route_info->flag, - ISIS_ROUTE_FLAG_ZEBRA_SYNCED); + UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } } @@ -502,8 +468,7 @@ isis_route_create(struct prefix *prefix, struct prefix_ipv6 *src_p, return route_info; } -void isis_route_delete(struct isis_area *area, struct route_node *rode, - struct route_table *table) +void isis_route_delete(struct isis_area *area, struct route_node *rode, struct route_table *table) { struct isis_route_info *rinfo; char buff[SRCDEST2STR_BUFFER]; @@ -519,9 +484,7 @@ void isis_route_delete(struct isis_area *area, struct route_node *rode, rinfo = rode->info; if (rinfo == NULL) { if (IS_DEBUG_RTE_EVENTS) - zlog_debug( - "ISIS-Rte: tried to delete non-existent route %s", - buff); + zlog_debug("ISIS-Rte: tried to delete non-existent route %s", buff); return; } @@ -536,8 +499,7 @@ void isis_route_delete(struct isis_area *area, struct route_node *rode, route_unlock_node(rode); } -static void isis_route_remove_previous_sid(struct isis_area *area, - struct prefix *prefix, +static void isis_route_remove_previous_sid(struct isis_area *area, struct prefix *prefix, struct isis_route_info *route_info) { /* @@ -547,11 +509,9 @@ static void isis_route_remove_previous_sid(struct isis_area *area, for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { if (route_info->sr_algo_previous[i].present && (!route_info->sr_algo[i].present || - route_info->sr_algo_previous[i].label != - route_info->sr_algo[i].label)) - isis_zebra_prefix_sid_uninstall( - area, prefix, route_info, - &route_info->sr_algo_previous[i]); + route_info->sr_algo_previous[i].label != route_info->sr_algo[i].label)) + isis_zebra_prefix_sid_uninstall(area, prefix, route_info, + &route_info->sr_algo_previous[i]); } } @@ -562,8 +522,7 @@ static void set_merge_route_info_sr_algo(struct isis_route_info *mrinfo, if (rinfo->sr_algo[i].present) { assert(i == rinfo->sr_algo[i].algorithm); assert(rinfo->nexthops); - assert(rinfo->backup ? rinfo->backup->nexthops != NULL - : true); + assert(rinfo->backup ? rinfo->backup->nexthops != NULL : true); if (mrinfo->sr_algo[i].nexthops != NULL && mrinfo->sr_algo[i].nexthops != mrinfo->nexthops) { @@ -573,8 +532,8 @@ static void set_merge_route_info_sr_algo(struct isis_route_info *mrinfo, } mrinfo->sr_algo[i] = rinfo->sr_algo[i]; - mrinfo->sr_algo[i].nexthops = isis_nexthop_list_dup( - rinfo->sr_algo[i].nexthops); + mrinfo->sr_algo[i].nexthops = + isis_nexthop_list_dup(rinfo->sr_algo[i].nexthops); } } @@ -583,8 +542,7 @@ static void set_merge_route_info_sr_algo(struct isis_route_info *mrinfo, } static void isis_route_update(struct isis_area *area, struct prefix *prefix, - struct prefix_ipv6 *src_p, - struct isis_route_info *route_info) + struct prefix_ipv6 *src_p, struct isis_route_info *route_info) { if (area == NULL) return; @@ -596,8 +554,7 @@ static void isis_route_update(struct isis_area *area, struct prefix *prefix, isis_route_remove_previous_sid(area, prefix, route_info); /* Install route. */ - isis_zebra_route_add_route(area->isis, prefix, src_p, - route_info); + isis_zebra_route_add_route(area->isis, prefix, src_p, route_info); for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { struct isis_sr_psid_info sr_algo; @@ -608,11 +565,9 @@ static void isis_route_update(struct isis_area *area, struct prefix *prefix, * Install/reinstall Prefix-SID label. */ if (sr_algo.present) - isis_zebra_prefix_sid_install(area, prefix, - &sr_algo); + isis_zebra_prefix_sid_install(area, prefix, &sr_algo); - hook_call(isis_route_update_hook, area, prefix, - route_info); + hook_call(isis_route_update_hook, area, prefix, route_info); } hook_call(isis_route_update_hook, area, prefix, route_info); @@ -623,23 +578,19 @@ static void isis_route_update(struct isis_area *area, struct prefix *prefix, /* Uninstall Prefix-SID label. */ for (int i = 0; i < SR_ALGORITHM_COUNT; i++) if (route_info->sr_algo[i].present) - isis_zebra_prefix_sid_uninstall( - area, prefix, route_info, - &route_info->sr_algo[i]); + isis_zebra_prefix_sid_uninstall(area, prefix, route_info, + &route_info->sr_algo[i]); /* Uninstall route. */ - isis_zebra_route_del_route(area->isis, prefix, src_p, - route_info); + isis_zebra_route_del_route(area->isis, prefix, src_p, route_info); hook_call(isis_route_update_hook, area, prefix, route_info); UNSET_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } } -static void _isis_route_verify_table(struct isis_area *area, - struct route_table *table, - struct route_table *table_backup, - struct route_table **tables) +static void _isis_route_verify_table(struct isis_area *area, struct route_table *table, + struct route_table *table_backup, struct route_table **tables) { struct route_node *rnode, *drnode; struct isis_route_info *rinfo; @@ -648,8 +599,7 @@ static void _isis_route_verify_table(struct isis_area *area, #endif /* EXTREME_DEBUG */ uint8_t algorithm = isis_route_table_algorithm(table); - for (rnode = route_top(table); rnode; - rnode = srcdest_route_next(rnode)) { + for (rnode = route_top(table); rnode; rnode = srcdest_route_next(rnode)) { if (rnode->info == NULL) continue; rinfo = rnode->info; @@ -657,49 +607,38 @@ static void _isis_route_verify_table(struct isis_area *area, struct prefix *dst_p; struct prefix_ipv6 *src_p; - srcdest_rnode_prefixes(rnode, - (const struct prefix **)&dst_p, + srcdest_rnode_prefixes(rnode, (const struct prefix **)&dst_p, (const struct prefix **)&src_p); /* Link primary route to backup route. */ if (table_backup) { struct route_node *rnode_bck; - rnode_bck = srcdest_rnode_lookup(table_backup, dst_p, - src_p); + rnode_bck = srcdest_rnode_lookup(table_backup, dst_p, src_p); if (rnode_bck) { rinfo->backup = rnode_bck->info; - rinfo->sr_algo[algorithm].nexthops_backup = - rinfo->backup->nexthops; - UNSET_FLAG(rinfo->flag, - ISIS_ROUTE_FLAG_ZEBRA_SYNCED); + rinfo->sr_algo[algorithm].nexthops_backup = rinfo->backup->nexthops; + UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } else if (rinfo->backup) { rinfo->backup = NULL; - rinfo->sr_algo[algorithm].nexthops_backup = - NULL; - UNSET_FLAG(rinfo->flag, - ISIS_ROUTE_FLAG_ZEBRA_SYNCED); + rinfo->sr_algo[algorithm].nexthops_backup = NULL; + UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } } #ifdef EXTREME_DEBUG if (IS_DEBUG_RTE_EVENTS) { srcdest2str(dst_p, src_p, buff, sizeof(buff)); - zlog_debug( - "ISIS-Rte (%s): route validate: %s %s %s %s", - area->area_tag, - (CHECK_FLAG(rinfo->flag, - ISIS_ROUTE_FLAG_ZEBRA_SYNCED) - ? "synced" - : "not-synced"), - (CHECK_FLAG(rinfo->flag, - ISIS_ROUTE_FLAG_ZEBRA_RESYNC) - ? "resync" - : "not-resync"), - (CHECK_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE) - ? "active" - : "inactive"), - buff); + zlog_debug("ISIS-Rte (%s): route validate: %s %s %s %s", area->area_tag, + (CHECK_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED) + ? "synced" + : "not-synced"), + (CHECK_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC) + ? "resync" + : "not-resync"), + (CHECK_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE) ? "active" + : "inactive"), + buff); } #endif /* EXTREME_DEBUG */ @@ -738,16 +677,14 @@ static void _isis_route_verify_table(struct isis_area *area, } } -static void _isis_route_verify_merge(struct isis_area *area, - struct route_table **tables, - struct route_table **tables_backup, - int tree); +static void _isis_route_verify_merge(struct isis_area *area, struct route_table **tables, + struct route_table **tables_backup, int tree); void isis_route_verify_table(struct isis_area *area, struct route_table *table, struct route_table *table_backup, int tree) { - struct route_table *tables[SR_ALGORITHM_COUNT] = {table}; - struct route_table *tables_backup[SR_ALGORITHM_COUNT] = {table_backup}; + struct route_table *tables[SR_ALGORITHM_COUNT] = { table }; + struct route_table *tables_backup[SR_ALGORITHM_COUNT] = { table_backup }; #ifndef FABRICD int tables_next = 1; int level = area->is_type == IS_LEVEL_1 ? ISIS_LEVEL1 : ISIS_LEVEL2; @@ -757,12 +694,10 @@ void isis_route_verify_table(struct isis_area *area, struct route_table *table, for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, fa)) { data = fa->data; - tables[tables_next] = - data->spftree[tree][level - 1]->route_table; - tables_backup[tables_next] = - data->spftree[tree][level - 1]->route_table_backup; - _isis_route_verify_table(area, tables[tables_next], - tables_backup[tables_next], NULL); + tables[tables_next] = data->spftree[tree][level - 1]->route_table; + tables_backup[tables_next] = data->spftree[tree][level - 1]->route_table_backup; + _isis_route_verify_table(area, tables[tables_next], tables_backup[tables_next], + NULL); tables_next++; } #endif /* ifndef FABRICD */ @@ -780,22 +715,18 @@ void isis_route_verify_table(struct isis_area *area, struct route_table *table, * * FIXME: Is it right place to do it at all? Maybe we should push both levels * to the RIB with different zebra route types and let RIB handle this? */ -void isis_route_verify_merge(struct isis_area *area, - struct route_table *level1_table, +void isis_route_verify_merge(struct isis_area *area, struct route_table *level1_table, struct route_table *level1_table_backup, struct route_table *level2_table, struct route_table *level2_table_backup, int tree) { - struct route_table *tables[] = {level1_table, level2_table, NULL}; - struct route_table *tables_backup[] = {level1_table_backup, - level2_table_backup, NULL}; + struct route_table *tables[] = { level1_table, level2_table, NULL }; + struct route_table *tables_backup[] = { level1_table_backup, level2_table_backup, NULL }; _isis_route_verify_merge(area, tables, tables_backup, tree); } -static void _isis_route_verify_merge(struct isis_area *area, - struct route_table **tables, - struct route_table **tables_backup, - int tree) +static void _isis_route_verify_merge(struct isis_area *area, struct route_table **tables, + struct route_table **tables_backup, int tree) { struct route_table *merge; struct route_node *rnode, *mrnode; @@ -804,8 +735,8 @@ static void _isis_route_verify_merge(struct isis_area *area, for (int i = 0; tables[i]; i++) { uint8_t algorithm = isis_route_table_algorithm(tables[i]); - for (rnode = route_top(tables[i]); rnode; - rnode = srcdest_route_next(rnode)) { + + for (rnode = route_top(tables[i]); rnode; rnode = srcdest_route_next(rnode)) { struct isis_route_info *rinfo = rnode->info; struct route_node *rnode_bck; @@ -815,25 +746,19 @@ static void _isis_route_verify_merge(struct isis_area *area, struct prefix *prefix; struct prefix_ipv6 *src_p; - srcdest_rnode_prefixes(rnode, - (const struct prefix **)&prefix, + srcdest_rnode_prefixes(rnode, (const struct prefix **)&prefix, (const struct prefix **)&src_p); /* Link primary route to backup route. */ - rnode_bck = srcdest_rnode_lookup(tables_backup[i], - prefix, src_p); + rnode_bck = srcdest_rnode_lookup(tables_backup[i], prefix, src_p); if (rnode_bck) { rinfo->backup = rnode_bck->info; - rinfo->sr_algo[algorithm].nexthops_backup = - rinfo->backup->nexthops; - UNSET_FLAG(rinfo->flag, - ISIS_ROUTE_FLAG_ZEBRA_SYNCED); + rinfo->sr_algo[algorithm].nexthops_backup = rinfo->backup->nexthops; + UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } else if (rinfo->backup) { rinfo->backup = NULL; - rinfo->sr_algo[algorithm].nexthops_backup = - NULL; - UNSET_FLAG(rinfo->flag, - ISIS_ROUTE_FLAG_ZEBRA_SYNCED); + rinfo->sr_algo[algorithm].nexthops_backup = NULL; + UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); } mrnode = srcdest_rnode_get(merge, prefix, src_p); @@ -842,33 +767,22 @@ static void _isis_route_verify_merge(struct isis_area *area, route_unlock_node(mrnode); set_merge_route_info_sr_algo(mrinfo, rinfo); - if (CHECK_FLAG(mrinfo->flag, - ISIS_ROUTE_FLAG_ACTIVE)) { + if (CHECK_FLAG(mrinfo->flag, ISIS_ROUTE_FLAG_ACTIVE)) { /* Clear the ZEBRA_SYNCED flag on the * L2 route when L1 wins, otherwise L2 * won't get reinstalled when L1 * disappears. */ - UNSET_FLAG( - rinfo->flag, - ISIS_ROUTE_FLAG_ZEBRA_SYNCED - ); + UNSET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); continue; - } else if (CHECK_FLAG(rinfo->flag, - ISIS_ROUTE_FLAG_ACTIVE)) { + } else if (CHECK_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ACTIVE)) { /* Clear the ZEBRA_SYNCED flag on the L1 * route when L2 wins, otherwise L1 * won't get reinstalled when it * reappears. */ - UNSET_FLAG( - mrinfo->flag, - ISIS_ROUTE_FLAG_ZEBRA_SYNCED - ); - } else if ( - CHECK_FLAG( - mrinfo->flag, - ISIS_ROUTE_FLAG_ZEBRA_SYNCED)) { + UNSET_FLAG(mrinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED); + } else if (CHECK_FLAG(mrinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED)) { continue; } } else { @@ -881,8 +795,7 @@ static void _isis_route_verify_merge(struct isis_area *area, route_table_finish(merge); } -void isis_route_invalidate_table(struct isis_area *area, - struct route_table *table) +void isis_route_invalidate_table(struct isis_area *area, struct route_table *table) { struct route_node *rode; struct isis_route_info *rinfo; @@ -905,10 +818,8 @@ void isis_route_invalidate_table(struct isis_area *area, } } -void isis_route_switchover_nexthop(struct isis_area *area, - struct route_table *table, int family, - union g_addr *nexthop_addr, - ifindex_t ifindex) +void isis_route_switchover_nexthop(struct isis_area *area, struct route_table *table, int family, + union g_addr *nexthop_addr, ifindex_t ifindex) { const char *ifname = NULL, *vrfname = NULL; struct isis_route_info *rinfo; @@ -923,13 +834,11 @@ void isis_route_switchover_nexthop(struct isis_area *area, vrfname = vrf_id_to_name(vrf_id); ifname = ifindex2ifname(ifindex, vrf_id); } - zlog_debug("%s: initiating fast-reroute %s on VRF %s iface %s", - __func__, family2str(family), vrfname ? vrfname : "", - ifname ? ifname : ""); + zlog_debug("%s: initiating fast-reroute %s on VRF %s iface %s", __func__, + family2str(family), vrfname ? vrfname : "", ifname ? ifname : ""); } - for (rnode = route_top(table); rnode; - rnode = srcdest_route_next(rnode)) { + for (rnode = route_top(table); rnode; rnode = srcdest_route_next(rnode)) { if (!rnode->info) continue; rinfo = rnode->info; @@ -937,8 +846,7 @@ void isis_route_switchover_nexthop(struct isis_area *area, if (!rinfo->backup) continue; - if (!nexthoplookup(rinfo->nexthops, family, nexthop_addr, - ifindex)) + if (!nexthoplookup(rinfo->nexthops, family, nexthop_addr, ifindex)) continue; srcdest_rnode_prefixes(rnode, (const struct prefix **)&prefix, diff --git a/isisd/isis_route.h b/isisd/isis_route.h index d9572336af5d..b77fbf807eb8 100644 --- a/isisd/isis_route.h +++ b/isisd/isis_route.h @@ -25,9 +25,9 @@ struct isis_nexthop { }; struct isis_route_info { -#define ISIS_ROUTE_FLAG_ACTIVE 0x01 /* active route for the prefix */ -#define ISIS_ROUTE_FLAG_ZEBRA_SYNCED 0x02 /* set when route synced to zebra */ -#define ISIS_ROUTE_FLAG_ZEBRA_RESYNC 0x04 /* set when route needs to sync */ +#define ISIS_ROUTE_FLAG_ACTIVE 0x01 /* active route for the prefix */ +#define ISIS_ROUTE_FLAG_ZEBRA_SYNCED 0x02 /* set when route synced to zebra */ +#define ISIS_ROUTE_FLAG_ZEBRA_RESYNC 0x04 /* set when route needs to sync */ uint8_t flag; uint32_t cost; uint32_t depth; @@ -42,21 +42,19 @@ struct isis_route_table_info { }; DECLARE_HOOK(isis_route_update_hook, - (struct isis_area * area, struct prefix *prefix, + (struct isis_area *area, struct prefix *prefix, struct isis_route_info *route_info), (area, prefix, route_info)); void isis_nexthop_delete(struct isis_nexthop *nexthop); -void adjinfo2nexthop(int family, struct list *nexthops, - struct isis_adjacency *adj, struct isis_sr_psid_info *sr, - struct mpls_label_stack *label_stack); -struct isis_route_info * -isis_route_create(struct prefix *prefix, struct prefix_ipv6 *src_p, - uint32_t cost, uint32_t depth, struct isis_sr_psid_info *sr, - struct list *adjacencies, bool allow_ecmp, - struct isis_area *area, struct route_table *table); -void isis_route_delete(struct isis_area *area, struct route_node *rode, - struct route_table *table); +void adjinfo2nexthop(int family, struct list *nexthops, struct isis_adjacency *adj, + struct isis_sr_psid_info *sr, struct mpls_label_stack *label_stack); +struct isis_route_info *isis_route_create(struct prefix *prefix, struct prefix_ipv6 *src_p, + uint32_t cost, uint32_t depth, + struct isis_sr_psid_info *sr, struct list *adjacencies, + bool allow_ecmp, struct isis_area *area, + struct route_table *table); +void isis_route_delete(struct isis_area *area, struct route_node *rode, struct route_table *table); /* Walk the given table and install new routes to zebra and remove old ones. * route status is tracked using ISIS_ROUTE_FLAG_ACTIVE */ @@ -64,25 +62,20 @@ void isis_route_verify_table(struct isis_area *area, struct route_table *table, struct route_table *table_backup, int tree); /* Same as isis_route_verify_table, but merge L1 and L2 routes before */ -void isis_route_verify_merge(struct isis_area *area, - struct route_table *level1_table, +void isis_route_verify_merge(struct isis_area *area, struct route_table *level1_table, struct route_table *level1_table_backup, struct route_table *level2_table, struct route_table *level2_table_backup, int tree); /* Unset ISIS_ROUTE_FLAG_ACTIVE on all routes. Used before running spf. */ -void isis_route_invalidate_table(struct isis_area *area, - struct route_table *table); +void isis_route_invalidate_table(struct isis_area *area, struct route_table *table); /* Cleanup route node when freeing routing table. */ -void isis_route_node_cleanup(struct route_table *table, - struct route_node *node); +void isis_route_node_cleanup(struct route_table *table, struct route_node *node); -void isis_route_switchover_nexthop(struct isis_area *area, - struct route_table *table, int family, - union g_addr *nexthop_addr, - ifindex_t ifindex); +void isis_route_switchover_nexthop(struct isis_area *area, struct route_table *table, int family, + union g_addr *nexthop_addr, ifindex_t ifindex); struct isis_route_table_info *isis_route_table_info_alloc(uint8_t algorithm); void isis_route_table_info_free(void *info); diff --git a/isisd/isis_routemap.c b/isisd/isis_routemap.c index 7aaba08c44e8..f62ce2e0d3bc 100644 --- a/isisd/isis_routemap.c +++ b/isisd/isis_routemap.c @@ -237,15 +237,15 @@ static const struct route_map_rule_cmd route_set_metric_cmd = { static void isis_route_map_update(const char *name) { struct isis *isis; - struct listnode *node, *lnode; + struct listnode *lnode; struct isis_area *area; int type; int level; int protocol; struct isis_redist *redist; - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) + frr_each (isis_instance_list, &im->isis, isis) + frr_each (isis_area_list, &isis->area_list, area) for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++) for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++) for (level = 0; level < ISIS_LEVELS; level++) { diff --git a/isisd/isis_snmp.c b/isisd/isis_snmp.c index 24320e9ed947..63fd6df5c2c3 100644 --- a/isisd/isis_snmp.c +++ b/isisd/isis_snmp.c @@ -839,18 +839,17 @@ static int isis_snmp_area_addr_lookup_exact(oid *oid_idx, size_t oid_idx_len, size_t addr_len; struct isis_area *area = NULL; struct iso_address *addr = NULL; - struct listnode *addr_node; struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); if (isis == NULL) return 0; - if (list_isempty(isis->area_list)) { + if (isis_area_list_count(&isis->area_list) == 0) { /* Area is not configured yet */ return 0; } - area = listgetdata(listhead(isis->area_list)); + area = isis_area_list_first(&isis->area_list); int res = isis_snmp_conv_exact(cmp_buf, sizeof(cmp_buf), &addr_len, oid_idx, oid_idx_len); @@ -861,7 +860,7 @@ static int isis_snmp_area_addr_lookup_exact(oid *oid_idx, size_t oid_idx_len, return 0; } - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, addr_node, addr)) { + frr_each (iso_address_list, &area->area_addrs, addr) { if (addr->addr_len != addr_len) continue; @@ -889,18 +888,17 @@ static int isis_snmp_area_addr_lookup_next(oid *oid_idx, size_t oid_idx_len, struct isis_area *area = NULL; struct iso_address *found_addr = NULL; struct iso_address *addr = NULL; - struct listnode *addr_node; struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); if (isis == NULL) return 0; - if (list_isempty(isis->area_list)) { + if (isis_area_list_count(&isis->area_list) == 0) { /* Area is not configured yet */ return 0; } - area = listgetdata(listhead(isis->area_list)); + area = isis_area_list_first(&isis->area_list); int res = isis_snmp_conv_next(cmp_buf, sizeof(cmp_buf), &addr_len, &try_exact, oid_idx, oid_idx_len); @@ -908,7 +906,7 @@ static int isis_snmp_area_addr_lookup_next(oid *oid_idx, size_t oid_idx_len, if (!res) return 0; - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, addr_node, addr)) { + frr_each (iso_address_list, &area->area_addrs, addr) { if (addr->addr_len < addr_len) continue; @@ -1415,8 +1413,8 @@ static uint8_t *isis_snmp_find_sys_object(struct variable *v, oid *name, if (isis == NULL) return NULL; - if (!list_isempty(isis->area_list)) - area = listgetdata(listhead(isis->area_list)); + if (isis_area_list_count(&isis->area_list) > 0) + area = isis_area_list_first(&isis->area_list); /* Check whether the instance identifier is valid */ if (smux_header_generic(v, name, length, exact, var_len, write_method) @@ -1816,8 +1814,8 @@ static uint8_t *isis_snmp_find_sys_level(struct variable *v, oid *name, area = NULL; - if (!list_isempty(isis->area_list)) - area = listgetdata(listhead(isis->area_list)); + if (isis_area_list_count(&isis->area_list) > 0) + area = isis_area_list_first(&isis->area_list); level_match = 0; @@ -1951,8 +1949,8 @@ static uint8_t *isis_snmp_find_system_counter(struct variable *v, oid *name, area = NULL; - if (!list_isempty(isis->area_list)) - area = listgetdata(listhead(isis->area_list)); + if (isis_area_list_count(&isis->area_list) > 0) + area = isis_area_list_first(&isis->area_list); level_match = 0; diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index 72202cc1a690..21486691dae9 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -49,16 +49,27 @@ #include "fabricd.h" #include "isis_spf_private.h" -DEFINE_MTYPE_STATIC(ISISD, ISIS_SPFTREE, "ISIS SPFtree"); -DEFINE_MTYPE_STATIC(ISISD, ISIS_SPF_RUN, "ISIS SPF Run Info"); -DEFINE_MTYPE_STATIC(ISISD, ISIS_SPF_ADJ, "ISIS SPF Adjacency"); -DEFINE_MTYPE_STATIC(ISISD, ISIS_VERTEX, "ISIS vertex"); +DEFINE_MTYPE_STATIC(ISISD, ISIS_SPFTREE, "ISIS SPFtree"); +DEFINE_MTYPE_STATIC(ISISD, ISIS_SPF_RUN, "ISIS SPF Run Info"); +DEFINE_MTYPE_STATIC(ISISD, ISIS_SPF_ADJ, "ISIS SPF Adjacency"); +DEFINE_MTYPE_STATIC(ISISD, ISIS_SPF_ADJ_REF, "ISIS SPF Adjacency Ref"); +DEFINE_MTYPE_STATIC(ISISD, ISIS_VERTEX, "ISIS vertex"); DEFINE_MTYPE_STATIC(ISISD, ISIS_VERTEX_ADJ, "ISIS SPF Vertex Adjacency"); +/* + * Temporary adjacency reference for SPF computation. + * Wraps isis_adjacency pointer to allow using typesafe list. + */ +PREDECL_DLIST(spf_adj_list); +struct spf_adj_ref { + struct isis_adjacency *adj; + struct spf_adj_list_item item; +}; +DECLARE_DLIST(spf_adj_list, struct spf_adj_ref, item); + static void spf_adj_list_parse_lsp(struct isis_spftree *spftree, - struct list *adj_list, struct isis_lsp *lsp, - const uint8_t *pseudo_nodeid, - uint32_t pseudo_metric); + struct spf_adj_list_head *adj_list, struct isis_lsp *lsp, + const uint8_t *pseudo_nodeid, uint32_t pseudo_metric); /* * supports the given af ? @@ -104,8 +115,7 @@ static void remove_excess_adjs(struct list *adjs) if (candidate_adj->sys_type > adj->sys_type) continue; - comp = memcmp(candidate_adj->sysid, adj->sysid, - ISIS_SYS_ID_LEN); + comp = memcmp(candidate_adj->sysid, adj->sysid, ISIS_SYS_ID_LEN); if (comp > 0) { excess = node; continue; @@ -171,8 +181,7 @@ const char *vid2string(const struct isis_vertex *vertex, char *buff, int size) } if (VTYPE_IP(vertex->type)) { - srcdest2str(&vertex->N.ip.p.dest, &vertex->N.ip.p.src, buff, - size); + srcdest2str(&vertex->N.ip.p.dest, &vertex->N.ip.p.src, buff, size); return buff; } @@ -184,10 +193,8 @@ static bool prefix_sid_cmp(const void *value1, const void *value2) const struct isis_vertex *c1 = value1; const struct isis_vertex *c2 = value2; - if (CHECK_FLAG(c1->N.ip.sr.sid.flags, - ISIS_PREFIX_SID_VALUE | ISIS_PREFIX_SID_LOCAL) - != CHECK_FLAG(c2->N.ip.sr.sid.flags, - ISIS_PREFIX_SID_VALUE | ISIS_PREFIX_SID_LOCAL)) + if (CHECK_FLAG(c1->N.ip.sr.sid.flags, ISIS_PREFIX_SID_VALUE | ISIS_PREFIX_SID_LOCAL) != + CHECK_FLAG(c2->N.ip.sr.sid.flags, ISIS_PREFIX_SID_VALUE | ISIS_PREFIX_SID_LOCAL)) return false; return c1->N.ip.sr.sid.value == c2->N.ip.sr.sid.value; @@ -216,8 +223,7 @@ void isis_vertex_adj_free(void *arg) XFREE(MTYPE_ISIS_VERTEX_ADJ, vadj); } -static struct isis_vertex *isis_vertex_new(struct isis_spftree *spftree, - void *id, +static struct isis_vertex *isis_vertex_new(struct isis_spftree *spftree, void *id, enum vertextype vtype) { struct isis_vertex *vertex; @@ -232,8 +238,7 @@ static struct isis_vertex *isis_vertex_new(struct isis_spftree *spftree, if (CHECK_FLAG(spftree->flags, F_SPFTREE_HOPCOUNT_METRIC)) { vertex->firsthops = hash_create(isis_vertex_queue_hash_key, - isis_vertex_queue_hash_cmp, - NULL); + isis_vertex_queue_hash_cmp, NULL); } return vertex; @@ -249,26 +254,24 @@ void isis_vertex_del(struct isis_vertex *vertex) XFREE(MTYPE_ISIS_VERTEX, vertex); } -struct isis_vertex_adj * -isis_vertex_adj_add(struct isis_spftree *spftree, struct isis_vertex *vertex, - struct list *vadj_list, struct isis_spf_adj *sadj, - struct isis_prefix_sid *psid, bool last_hop) +struct isis_vertex_adj *isis_vertex_adj_add(struct isis_spftree *spftree, + struct isis_vertex *vertex, struct list *vadj_list, + struct isis_spf_adj *sadj, + struct isis_prefix_sid *psid, bool last_hop) { struct isis_vertex_adj *vadj; vadj = XCALLOC(MTYPE_ISIS_VERTEX_ADJ, sizeof(*vadj)); vadj->sadj = sadj; if (spftree->area->srdb.enabled && psid) { - if (vertex->N.ip.sr.present - && vertex->N.ip.sr.sid.value != psid->value) - zlog_warn( - "ISIS-SPF: ignoring different Prefix-SID for route %pFX", - &vertex->N.ip.p.dest); + if (vertex->N.ip.sr.present && vertex->N.ip.sr.sid.value != psid->value) + zlog_warn("ISIS-SPF: ignoring different Prefix-SID for route %pFX", + &vertex->N.ip.p.dest); else { vadj->sr.sid = *psid; - vadj->sr.label = sr_prefix_out_label( - spftree->lspdb, vertex->N.ip.p.dest.family, - psid, sadj->id, last_hop); + vadj->sr.label = sr_prefix_out_label(spftree->lspdb, + vertex->N.ip.p.dest.family, psid, + sadj->id, last_hop); if (vadj->sr.label != MPLS_INVALID_LABEL) vadj->sr.present = true; } @@ -278,8 +281,7 @@ isis_vertex_adj_add(struct isis_spftree *spftree, struct isis_vertex *vertex, return vadj; } -static void isis_vertex_adj_del(struct isis_vertex *vertex, - struct isis_adjacency *adj) +static void isis_vertex_adj_del(struct isis_vertex *vertex, struct isis_adjacency *adj) { struct isis_vertex_adj *vadj; struct listnode *node, *nextnode; @@ -296,8 +298,7 @@ static void isis_vertex_adj_del(struct isis_vertex *vertex, return; } -bool isis_vertex_adj_exists(const struct isis_spftree *spftree, - const struct isis_vertex *vertex, +bool isis_vertex_adj_exists(const struct isis_spftree *spftree, const struct isis_vertex *vertex, const struct isis_spf_adj *sadj) { struct isis_vertex_adj *tmp; @@ -305,8 +306,7 @@ bool isis_vertex_adj_exists(const struct isis_spftree *spftree, for (ALL_LIST_ELEMENTS_RO(vertex->Adj_N, node, tmp)) { if (CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES)) { - if (memcmp(sadj->id, tmp->sadj->id, sizeof(sadj->id)) - == 0) + if (memcmp(sadj->id, tmp->sadj->id, sizeof(sadj->id)) == 0) return true; } else { if (sadj->adj == tmp->sadj->adj) @@ -332,8 +332,7 @@ static void _isis_spftree_init(struct isis_spftree *tree) tree->route_table->cleanup = isis_route_node_cleanup; tree->route_table->info = isis_route_table_info_alloc(tree->algorithm); tree->route_table_backup = srcdest_table_init(); - tree->route_table_backup->info = - isis_route_table_info_alloc(tree->algorithm); + tree->route_table_backup->info = isis_route_table_info_alloc(tree->algorithm); tree->route_table_backup->cleanup = isis_route_node_cleanup; tree->prefix_sids = hash_create(prefix_sid_key_make, prefix_sid_cmp, "SR Prefix-SID Entries"); @@ -348,10 +347,9 @@ static void _isis_spftree_init(struct isis_spftree *tree) } } -struct isis_spftree * -isis_spftree_new(struct isis_area *area, struct lspdb_head *lspdb, - const uint8_t *sysid, int level, enum spf_tree_id tree_id, - enum spf_type type, uint8_t flags, uint8_t algorithm) +struct isis_spftree *isis_spftree_new(struct isis_area *area, struct lspdb_head *lspdb, + const uint8_t *sysid, int level, enum spf_tree_id tree_id, + enum spf_type type, uint8_t flags, uint8_t algorithm) { struct isis_spftree *tree; @@ -384,8 +382,7 @@ static void _isis_spftree_del(struct isis_spftree *spftree) isis_zebra_rlfa_unregister_all(spftree); isis_rlfa_list_clear(spftree); list_delete(&spftree->lfa.remote.pc_spftrees); - if (spftree->type == SPF_TYPE_RLFA - || spftree->type == SPF_TYPE_TI_LFA) { + if (spftree->type == SPF_TYPE_RLFA || spftree->type == SPF_TYPE_TI_LFA) { isis_spf_node_list_clear(&spftree->lfa.q_space); isis_spf_node_list_clear(&spftree->lfa.p_space); } @@ -393,7 +390,7 @@ static void _isis_spftree_del(struct isis_spftree *spftree) list_delete(&spftree->sadj_list); isis_vertex_queue_free(&spftree->tents); isis_vertex_queue_free(&spftree->paths); - info = spftree->route_table->info; + info = spftree->route_table->info; backup_info = spftree->route_table_backup->info; route_table_finish(spftree->route_table); route_table_finish(spftree->route_table_backup); @@ -419,8 +416,7 @@ static void isis_spftree_clear(struct isis_spftree *spftree) } #endif /* ifndef FABRICD */ -static void isis_spftree_adj_del(struct isis_spftree *spftree, - struct isis_adjacency *adj) +static void isis_spftree_adj_del(struct isis_spftree *spftree, struct isis_adjacency *adj) { struct listnode *node; struct isis_vertex *v; @@ -441,10 +437,10 @@ void spftree_area_init(struct isis_area *area) if (area->spftree[tree][level - 1]) continue; - area->spftree[tree][level - 1] = isis_spftree_new( - area, &area->lspdb[level - 1], - area->isis->sysid, level, tree, - SPF_TYPE_FORWARD, 0, SR_ALGORITHM_SPF); + area->spftree[tree][level - 1] = + isis_spftree_new(area, &area->lspdb[level - 1], area->isis->sysid, + level, tree, SPF_TYPE_FORWARD, 0, + SR_ALGORITHM_SPF); } } } @@ -477,8 +473,7 @@ static int spf_adj_state_change(struct isis_adjacency *adj) continue; if (!area->spftree[tree][level - 1]) continue; - isis_spftree_adj_del(area->spftree[tree][level - 1], - adj); + isis_spftree_adj_del(area->spftree[tree][level - 1], adj); } } @@ -492,8 +487,7 @@ static int spf_adj_state_change(struct isis_adjacency *adj) * Find the system LSP: returns the LSP in our LSP database * associated with the given system ID. */ -struct isis_lsp *isis_root_system_lsp(struct lspdb_head *lspdb, - const uint8_t *sysid) +struct isis_lsp *isis_root_system_lsp(struct lspdb_head *lspdb, const uint8_t *sysid) { struct isis_lsp *lsp; uint8_t lspid[ISIS_SYS_ID_LEN + 2]; @@ -518,18 +512,15 @@ static struct isis_vertex *isis_spf_add_root(struct isis_spftree *spftree) #endif /* EXTREME_DEBUG */ vertex = isis_vertex_new(spftree, spftree->sysid, - spftree->area->oldmetric - ? VTYPE_NONPSEUDO_IS - : VTYPE_NONPSEUDO_TE_IS); + spftree->area->oldmetric ? VTYPE_NONPSEUDO_IS + : VTYPE_NONPSEUDO_TE_IS); isis_vertex_queue_append(&spftree->paths, vertex); #ifdef EXTREME_DEBUG if (IS_DEBUG_SPF_EVENTS) - zlog_debug( - "ISIS-SPF: A:%hhu added this IS %s %s depth %d dist %d to PATHS", - spftree->algorithm, vtype2string(vertex->type), - vid2string(vertex, buff, sizeof(buff)), vertex->depth, - vertex->d_N); + zlog_debug("ISIS-SPF: A:%hhu added this IS %s %s depth %d dist %d to PATHS", + spftree->algorithm, vtype2string(vertex->type), + vid2string(vertex, buff, sizeof(buff)), vertex->depth, vertex->d_N); #endif /* EXTREME_DEBUG */ return vertex; @@ -543,8 +534,7 @@ static void vertex_add_parent_firsthop(struct hash_bucket *bucket, void *arg) (void)hash_get(vertex->firsthops, hop, hash_alloc_intern); } -static void vertex_update_firsthops(struct isis_vertex *vertex, - struct isis_vertex *parent) +static void vertex_update_firsthops(struct isis_vertex *vertex, struct isis_vertex *parent) { if (vertex->d_N <= 2) (void)hash_get(vertex->firsthops, vertex, hash_alloc_intern); @@ -558,10 +548,11 @@ static void vertex_update_firsthops(struct isis_vertex *vertex, /* * Add a vertex to TENT sorted by cost and by vertextype on tie break situation */ -static struct isis_vertex * -isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, void *id, - uint32_t cost, int depth, struct isis_spf_adj *sadj, - struct isis_prefix_sid *psid, struct isis_vertex *parent) +static struct isis_vertex *isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, + void *id, uint32_t cost, int depth, + struct isis_spf_adj *sadj, + struct isis_prefix_sid *psid, + struct isis_vertex *parent) { struct isis_vertex *vertex; struct listnode *node; @@ -570,18 +561,16 @@ isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, void *id, vertex = isis_find_vertex(&spftree->paths, id, vtype); if (vertex != NULL) { - zlog_err( - "%s: vertex %s of type %s already in PATH; check for sysId collisions with established neighbors", - __func__, vid2string(vertex, buff, sizeof(buff)), - vtype2string(vertex->type)); + zlog_err("%s: vertex %s of type %s already in PATH; check for sysId collisions with established neighbors", + __func__, vid2string(vertex, buff, sizeof(buff)), + vtype2string(vertex->type)); return NULL; } vertex = isis_find_vertex(&spftree->tents, id, vtype); if (vertex != NULL) { - zlog_err( - "%s: vertex %s of type %s already in TENT; check for sysId collisions with established neighbors", - __func__, vid2string(vertex, buff, sizeof(buff)), - vtype2string(vertex->type)); + zlog_err("%s: vertex %s of type %s already in TENT; check for sysId collisions with established neighbors", + __func__, vid2string(vertex, buff, sizeof(buff)), + vtype2string(vertex->type)); return NULL; } @@ -596,26 +585,20 @@ isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, void *id, * Check if the Prefix-SID is already in use by another prefix. */ vertex_psid = isis_spf_prefix_sid_lookup(spftree, psid); - if (vertex_psid - && !prefix_same(&vertex_psid->N.ip.p.dest, - &vertex->N.ip.p.dest)) { - flog_warn( - EC_ISIS_SID_COLLISION, - "ISIS-Sr (%s): collision detected, prefixes %pFX and %pFX share the same SID %s (%u)", - area->area_tag, &vertex->N.ip.p.dest, - &vertex_psid->N.ip.p.dest, - CHECK_FLAG(psid->flags, ISIS_PREFIX_SID_VALUE) - ? "label" - : "index", - psid->value); + if (vertex_psid && !prefix_same(&vertex_psid->N.ip.p.dest, &vertex->N.ip.p.dest)) { + flog_warn(EC_ISIS_SID_COLLISION, + "ISIS-Sr (%s): collision detected, prefixes %pFX and %pFX share the same SID %s (%u)", + area->area_tag, &vertex->N.ip.p.dest, &vertex_psid->N.ip.p.dest, + CHECK_FLAG(psid->flags, ISIS_PREFIX_SID_VALUE) ? "label" + : "index", + psid->value); psid = NULL; } else { bool local; local = (vertex->depth == 1); vertex->N.ip.sr.sid = *psid; - vertex->N.ip.sr.label = - sr_prefix_in_label(area, psid, local); + vertex->N.ip.sr.label = sr_prefix_in_label(area, psid, local); vertex->N.ip.sr.algorithm = psid->algorithm; if (vertex->N.ip.sr.label != MPLS_INVALID_LABEL) @@ -623,15 +606,13 @@ isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, void *id, #ifndef FABRICD if (flex_algo_id_valid(spftree->algorithm) && - !isis_flex_algo_elected_supported( - spftree->algorithm, spftree->area)) { + !isis_flex_algo_elected_supported(spftree->algorithm, spftree->area)) { vertex->N.ip.sr.present = false; vertex->N.ip.sr.label = MPLS_INVALID_LABEL; } #endif /* ifndef FABRICD */ - (void)hash_get(spftree->prefix_sids, vertex, - hash_alloc_intern); + (void)hash_get(spftree->prefix_sids, vertex, hash_alloc_intern); } } @@ -647,32 +628,27 @@ isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, void *id, struct isis_vertex_adj *parent_vadj; for (ALL_LIST_ELEMENTS_RO(parent->Adj_N, node, parent_vadj)) - isis_vertex_adj_add(spftree, vertex, vertex->Adj_N, - parent_vadj->sadj, psid, last_hop); + isis_vertex_adj_add(spftree, vertex, vertex->Adj_N, parent_vadj->sadj, + psid, last_hop); } else if (sadj) { - isis_vertex_adj_add(spftree, vertex, vertex->Adj_N, sadj, psid, - last_hop); + isis_vertex_adj_add(spftree, vertex, vertex->Adj_N, sadj, psid, last_hop); } #ifdef EXTREME_DEBUG if (IS_DEBUG_SPF_EVENTS) - zlog_debug( - "ISIS-SPF: A:%hhu add to TENT %s %s %s depth %d dist %d adjcount %d", - spftree->algorithm, print_sys_hostname(vertex->N.id), - vtype2string(vertex->type), - vid2string(vertex, buff, sizeof(buff)), vertex->depth, - vertex->d_N, listcount(vertex->Adj_N)); + zlog_debug("ISIS-SPF: A:%hhu add to TENT %s %s %s depth %d dist %d adjcount %d", + spftree->algorithm, print_sys_hostname(vertex->N.id), + vtype2string(vertex->type), vid2string(vertex, buff, sizeof(buff)), + vertex->depth, vertex->d_N, listcount(vertex->Adj_N)); #endif /* EXTREME_DEBUG */ isis_vertex_queue_insert(&spftree->tents, vertex); return vertex; } -static void isis_spf_add_local(struct isis_spftree *spftree, - enum vertextype vtype, void *id, +static void isis_spf_add_local(struct isis_spftree *spftree, enum vertextype vtype, void *id, struct isis_spf_adj *sadj, uint32_t cost, - struct isis_prefix_sid *psid, - struct isis_vertex *parent) + struct isis_prefix_sid *psid, struct isis_vertex *parent) { struct isis_vertex *vertex; @@ -684,17 +660,14 @@ static void isis_spf_add_local(struct isis_spftree *spftree, if (sadj) { bool last_hop = (vertex->depth == 2); - isis_vertex_adj_add(spftree, vertex, - vertex->Adj_N, sadj, psid, + isis_vertex_adj_add(spftree, vertex, vertex->Adj_N, sadj, psid, last_hop); } /* d) */ - if (!CHECK_FLAG(spftree->flags, - F_SPFTREE_NO_ADJACENCIES) - && listcount(vertex->Adj_N) > ISIS_MAX_PATH_SPLITS) + if (!CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES) && + listcount(vertex->Adj_N) > ISIS_MAX_PATH_SPLITS) remove_excess_adjs(vertex->Adj_N); - if (parent && (listnode_lookup(vertex->parents, parent) - == NULL)) + if (parent && (listnode_lookup(vertex->parents, parent) == NULL)) listnode_add(vertex->parents, parent); return; } else if (vertex->d_N < cost) { @@ -712,9 +685,8 @@ static void isis_spf_add_local(struct isis_spftree *spftree, return; } -static void process_N(struct isis_spftree *spftree, enum vertextype vtype, - void *id, uint32_t dist, uint16_t depth, - struct isis_prefix_sid *psid, struct isis_vertex *parent) +static void process_N(struct isis_spftree *spftree, enum vertextype vtype, void *id, uint32_t dist, + uint16_t depth, struct isis_prefix_sid *psid, struct isis_vertex *parent) { struct isis_vertex *vertex; #ifdef EXTREME_DEBUG @@ -723,8 +695,7 @@ static void process_N(struct isis_spftree *spftree, enum vertextype vtype, assert(spftree && parent); - if (CHECK_FLAG(spftree->flags, F_SPFTREE_HOPCOUNT_METRIC) - && !VTYPE_IS(vtype)) + if (CHECK_FLAG(spftree->flags, F_SPFTREE_HOPCOUNT_METRIC) && !VTYPE_IS(vtype)) return; struct prefix_pair p; @@ -751,12 +722,10 @@ static void process_N(struct isis_spftree *spftree, enum vertextype vtype, if (vertex) { #ifdef EXTREME_DEBUG if (IS_DEBUG_SPF_EVENTS) - zlog_debug( - "ISIS-SPF: A:%hhu process_N %s %s %s dist %d already found from PATH", - spftree->algorithm, - print_sys_hostname(vertex->N.id), - vtype2string(vtype), - vid2string(vertex, buff, sizeof(buff)), dist); + zlog_debug("ISIS-SPF: A:%hhu process_N %s %s %s dist %d already found from PATH", + spftree->algorithm, print_sys_hostname(vertex->N.id), + vtype2string(vtype), vid2string(vertex, buff, sizeof(buff)), + dist); #endif /* EXTREME_DEBUG */ assert(dist >= vertex->d_N); return; @@ -768,38 +737,27 @@ static void process_N(struct isis_spftree *spftree, enum vertextype vtype, /* 1) */ #ifdef EXTREME_DEBUG if (IS_DEBUG_SPF_EVENTS) - zlog_debug( - "ISIS-SPF: A:%hhu process_N %s %s %s dist %d parent %s adjcount %d", - spftree->algorithm, - print_sys_hostname(vertex->N.id), - vtype2string(vtype), - vid2string(vertex, buff, sizeof(buff)), dist, - (parent ? print_sys_hostname(parent->N.id) - : "null"), - (parent ? listcount(parent->Adj_N) : 0)); + zlog_debug("ISIS-SPF: A:%hhu process_N %s %s %s dist %d parent %s adjcount %d", + spftree->algorithm, print_sys_hostname(vertex->N.id), + vtype2string(vtype), vid2string(vertex, buff, sizeof(buff)), + dist, (parent ? print_sys_hostname(parent->N.id) : "null"), + (parent ? listcount(parent->Adj_N) : 0)); #endif /* EXTREME_DEBUG */ if (vertex->d_N == dist) { struct listnode *node; struct isis_vertex_adj *parent_vadj; - for (ALL_LIST_ELEMENTS_RO(parent->Adj_N, node, - parent_vadj)) - if (!isis_vertex_adj_exists( - spftree, vertex, - parent_vadj->sadj)) { + for (ALL_LIST_ELEMENTS_RO(parent->Adj_N, node, parent_vadj)) + if (!isis_vertex_adj_exists(spftree, vertex, parent_vadj->sadj)) { bool last_hop = (vertex->depth == 2); - isis_vertex_adj_add(spftree, vertex, - vertex->Adj_N, - parent_vadj->sadj, - psid, last_hop); + isis_vertex_adj_add(spftree, vertex, vertex->Adj_N, + parent_vadj->sadj, psid, last_hop); } - if (CHECK_FLAG(spftree->flags, - F_SPFTREE_HOPCOUNT_METRIC)) + if (CHECK_FLAG(spftree->flags, F_SPFTREE_HOPCOUNT_METRIC)) vertex_update_firsthops(vertex, parent); /* 2) */ - if (!CHECK_FLAG(spftree->flags, - F_SPFTREE_NO_ADJACENCIES) - && listcount(vertex->Adj_N) > ISIS_MAX_PATH_SPLITS) + if (!CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES) && + listcount(vertex->Adj_N) > ISIS_MAX_PATH_SPLITS) remove_excess_adjs(vertex->Adj_N); if (listnode_lookup(vertex->parents, parent) == NULL) listnode_add(vertex->parents, parent); @@ -816,11 +774,9 @@ static void process_N(struct isis_spftree *spftree, enum vertextype vtype, #ifdef EXTREME_DEBUG if (IS_DEBUG_SPF_EVENTS) - zlog_debug( - "ISIS-SPF: A:%hhu process_N add2tent %s %s dist %d parent %s", - spftree->algorithm, print_sys_hostname(id), - vtype2string(vtype), dist, - (parent ? print_sys_hostname(parent->N.id) : "null")); + zlog_debug("ISIS-SPF: A:%hhu process_N add2tent %s %s dist %d parent %s", + spftree->algorithm, print_sys_hostname(id), vtype2string(vtype), dist, + (parent ? print_sys_hostname(parent->N.id) : "null")); #endif /* EXTREME_DEBUG */ isis_spf_add2tent(spftree, vtype, id, dist, depth, NULL, psid, parent); @@ -830,10 +786,8 @@ static void process_N(struct isis_spftree *spftree, enum vertextype vtype, /* * C.2.6 Step 1 */ -static int isis_spf_process_lsp(struct isis_spftree *spftree, - struct isis_lsp *lsp, uint32_t cost, - uint16_t depth, uint8_t *root_sysid, - struct isis_vertex *parent) +static int isis_spf_process_lsp(struct isis_spftree *spftree, struct isis_lsp *lsp, uint32_t cost, + uint16_t depth, uint8_t *root_sysid, struct isis_vertex *parent) { bool pseudo_lsp = LSP_PSEUDO_ID(lsp->hdr.lsp_id); struct listnode *fragnode = NULL; @@ -856,21 +810,20 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, return ISIS_OK; if (spftree->mtid != ISIS_MT_IPV4_UNICAST) - mt_router_info = isis_tlvs_lookup_mt_router_info(lsp->tlvs, - spftree->mtid); + mt_router_info = isis_tlvs_lookup_mt_router_info(lsp->tlvs, spftree->mtid); - if (!pseudo_lsp && (spftree->mtid == ISIS_MT_IPV4_UNICAST - && !speaks(lsp->tlvs->protocols_supported.protocols, - lsp->tlvs->protocols_supported.count, - spftree->family)) - && !mt_router_info) + if (!pseudo_lsp && + (spftree->mtid == ISIS_MT_IPV4_UNICAST && + !speaks(lsp->tlvs->protocols_supported.protocols, + lsp->tlvs->protocols_supported.count, spftree->family)) && + !mt_router_info) return ISIS_OK; /* RFC3787 section 4 SHOULD ignore overload bit in pseudo LSPs */ - bool no_overload = (pseudo_lsp - || (spftree->mtid == ISIS_MT_IPV4_UNICAST - && !ISIS_MASK_LSP_OL_BIT(lsp->hdr.lsp_bits)) - || (mt_router_info && !mt_router_info->overload)); + bool no_overload = (pseudo_lsp || + (spftree->mtid == ISIS_MT_IPV4_UNICAST && + !ISIS_MASK_LSP_OL_BIT(lsp->hdr.lsp_bits)) || + (mt_router_info && !mt_router_info->overload)); lspfragloop: if (!lsp->tlvs) @@ -883,38 +836,31 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, #ifdef EXTREME_DEBUG if (IS_DEBUG_SPF_EVENTS) - zlog_debug("ISIS-SPF: A:%hhu process_lsp %s", - spftree->algorithm, + zlog_debug("ISIS-SPF: A:%hhu process_lsp %s", spftree->algorithm, print_sys_hostname(lsp->hdr.lsp_id)); #endif /* EXTREME_DEBUG */ if (no_overload) { - if ((pseudo_lsp || spftree->mtid == ISIS_MT_IPV4_UNICAST) - && spftree->area->oldmetric) { + if ((pseudo_lsp || spftree->mtid == ISIS_MT_IPV4_UNICAST) && + spftree->area->oldmetric) { struct isis_oldstyle_reach *r; - for (r = (struct isis_oldstyle_reach *) - lsp->tlvs->oldstyle_reach.head; - r; r = r->next) { + for (r = (struct isis_oldstyle_reach *)lsp->tlvs->oldstyle_reach.head; r; + r = r->next) { if (fabricd) continue; /* C.2.6 a) */ /* Two way connectivity */ - if (!LSP_PSEUDO_ID(r->id) - && !memcmp(r->id, root_sysid, - ISIS_SYS_ID_LEN)) + if (!LSP_PSEUDO_ID(r->id) && + !memcmp(r->id, root_sysid, ISIS_SYS_ID_LEN)) continue; - if (!pseudo_lsp - && !memcmp(r->id, null_sysid, - ISIS_SYS_ID_LEN)) + if (!pseudo_lsp && !memcmp(r->id, null_sysid, ISIS_SYS_ID_LEN)) continue; dist = cost + r->metric; process_N(spftree, - LSP_PSEUDO_ID(r->id) - ? VTYPE_PSEUDO_IS - : VTYPE_NONPSEUDO_IS, - (void *)r->id, dist, depth + 1, NULL, - parent); + LSP_PSEUDO_ID(r->id) ? VTYPE_PSEUDO_IS + : VTYPE_NONPSEUDO_IS, + (void *)r->id, dist, depth + 1, NULL, parent); } } @@ -923,72 +869,55 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, if (pseudo_lsp || spftree->mtid == ISIS_MT_IPV4_UNICAST) te_neighs = &lsp->tlvs->extended_reach; else - te_neighs = isis_lookup_mt_items( - &lsp->tlvs->mt_reach, spftree->mtid); + te_neighs = isis_lookup_mt_items(&lsp->tlvs->mt_reach, + spftree->mtid); struct isis_extended_reach *er; - for (er = te_neighs ? (struct isis_extended_reach *) - te_neighs->head - : NULL; + for (er = te_neighs ? (struct isis_extended_reach *)te_neighs->head : NULL; er; er = er->next) { /* C.2.6 a) */ /* Two way connectivity */ - if (!LSP_PSEUDO_ID(er->id) - && !memcmp(er->id, root_sysid, - ISIS_SYS_ID_LEN)) + if (!LSP_PSEUDO_ID(er->id) && + !memcmp(er->id, root_sysid, ISIS_SYS_ID_LEN)) continue; - if (!pseudo_lsp - && !memcmp(er->id, null_sysid, - ISIS_SYS_ID_LEN)) + if (!pseudo_lsp && !memcmp(er->id, null_sysid, ISIS_SYS_ID_LEN)) continue; #ifndef FABRICD if (flex_algo_id_valid(spftree->algorithm) && - (!sr_algorithm_participated( - lsp, spftree->algorithm) || - isis_flex_algo_constraint_drop(spftree, - lsp, er))) + (!sr_algorithm_participated(lsp, spftree->algorithm) || + isis_flex_algo_constraint_drop(spftree, lsp, er))) continue; #endif /* ifndef FABRICD */ - dist = cost - + (CHECK_FLAG(spftree->flags, - F_SPFTREE_HOPCOUNT_METRIC) - ? 1 - : er->metric); + dist = cost + (CHECK_FLAG(spftree->flags, F_SPFTREE_HOPCOUNT_METRIC) + ? 1 + : er->metric); process_N(spftree, - LSP_PSEUDO_ID(er->id) - ? VTYPE_PSEUDO_TE_IS - : VTYPE_NONPSEUDO_TE_IS, - (void *)er->id, dist, depth + 1, NULL, - parent); + LSP_PSEUDO_ID(er->id) ? VTYPE_PSEUDO_TE_IS + : VTYPE_NONPSEUDO_TE_IS, + (void *)er->id, dist, depth + 1, NULL, parent); } } } - if (!fabricd && !pseudo_lsp && spftree->family == AF_INET - && spftree->mtid == ISIS_MT_IPV4_UNICAST - && spftree->area->oldmetric) { - struct isis_item_list *reachs[] = { - &lsp->tlvs->oldstyle_ip_reach, - &lsp->tlvs->oldstyle_ip_reach_ext}; + if (!fabricd && !pseudo_lsp && spftree->family == AF_INET && + spftree->mtid == ISIS_MT_IPV4_UNICAST && spftree->area->oldmetric) { + struct isis_item_list *reachs[] = { &lsp->tlvs->oldstyle_ip_reach, + &lsp->tlvs->oldstyle_ip_reach_ext }; for (unsigned int i = 0; i < array_size(reachs); i++) { - vtype = i ? VTYPE_IPREACH_EXTERNAL - : VTYPE_IPREACH_INTERNAL; + vtype = i ? VTYPE_IPREACH_EXTERNAL : VTYPE_IPREACH_INTERNAL; memset(&ip_info, 0, sizeof(ip_info)); ip_info.dest.family = AF_INET; struct isis_oldstyle_ip_reach *r; - for (r = (struct isis_oldstyle_ip_reach *)reachs[i] - ->head; - r; r = r->next) { + for (r = (struct isis_oldstyle_ip_reach *)reachs[i]->head; r; r = r->next) { dist = cost + r->metric; ip_info.dest.u.prefix4 = r->prefix.prefix; ip_info.dest.prefixlen = r->prefix.prefixlen; - process_N(spftree, vtype, &ip_info, - dist, depth + 1, NULL, parent); + process_N(spftree, vtype, &ip_info, dist, depth + 1, NULL, parent); } } } @@ -1002,17 +931,13 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, if (spftree->mtid == ISIS_MT_IPV4_UNICAST) ipv4_reachs = &lsp->tlvs->extended_ip_reach; else - ipv4_reachs = isis_lookup_mt_items( - &lsp->tlvs->mt_ip_reach, spftree->mtid); + ipv4_reachs = isis_lookup_mt_items(&lsp->tlvs->mt_ip_reach, spftree->mtid); memset(&ip_info, 0, sizeof(ip_info)); ip_info.dest.family = AF_INET; struct isis_extended_ip_reach *r; - for (r = ipv4_reachs - ? (struct isis_extended_ip_reach *) - ipv4_reachs->head - : NULL; + for (r = ipv4_reachs ? (struct isis_extended_ip_reach *)ipv4_reachs->head : NULL; r; r = r->next) { dist = cost + r->metric; ip_info.dest.u.prefix4 = r->prefix.prefix; @@ -1021,31 +946,24 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, /* Parse list of Prefix-SID subTLVs if SR is enabled */ has_valid_psid = false; if (spftree->area->srdb.enabled && r->subtlvs) { - for (struct isis_item *i = - r->subtlvs->prefix_sids.head; - i; i = i->next) { - struct isis_prefix_sid *psid = - (struct isis_prefix_sid *)i; - - if (psid->algorithm != - spftree->algorithm) + for (struct isis_item *i = r->subtlvs->prefix_sids.head; i; + i = i->next) { + struct isis_prefix_sid *psid = (struct isis_prefix_sid *)i; + + if (psid->algorithm != spftree->algorithm) continue; #ifndef FABRICD - if (flex_algo_id_valid( - spftree->algorithm) && - (!sr_algorithm_participated( - lsp, spftree->algorithm) || - !isis_flex_algo_elected_supported( - spftree->algorithm, - spftree->area))) + if (flex_algo_id_valid(spftree->algorithm) && + (!sr_algorithm_participated(lsp, spftree->algorithm) || + !isis_flex_algo_elected_supported(spftree->algorithm, + spftree->area))) continue; #endif /* ifndef FABRICD */ has_valid_psid = true; - process_N(spftree, VTYPE_IPREACH_TE, - &ip_info, dist, depth + 1, - psid, parent); + process_N(spftree, VTYPE_IPREACH_TE, &ip_info, dist, + depth + 1, psid, parent); /* * Stop the Prefix-SID iteration since * we only support the SPF algorithm for @@ -1055,8 +973,8 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, } } if (!has_valid_psid) - process_N(spftree, VTYPE_IPREACH_TE, &ip_info, - dist, depth + 1, NULL, parent); + process_N(spftree, VTYPE_IPREACH_TE, &ip_info, dist, depth + 1, + NULL, parent); } } @@ -1065,34 +983,27 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, if (spftree->mtid == ISIS_MT_IPV4_UNICAST) ipv6_reachs = &lsp->tlvs->ipv6_reach; else - ipv6_reachs = isis_lookup_mt_items( - &lsp->tlvs->mt_ipv6_reach, spftree->mtid); + ipv6_reachs = isis_lookup_mt_items(&lsp->tlvs->mt_ipv6_reach, + spftree->mtid); struct isis_ipv6_reach *r; - for (r = ipv6_reachs - ? (struct isis_ipv6_reach *)ipv6_reachs->head - : NULL; - r; r = r->next) { + for (r = ipv6_reachs ? (struct isis_ipv6_reach *)ipv6_reachs->head : NULL; r; + r = r->next) { dist = cost + r->metric; - vtype = r->external ? VTYPE_IP6REACH_EXTERNAL - : VTYPE_IP6REACH_INTERNAL; + vtype = r->external ? VTYPE_IP6REACH_EXTERNAL : VTYPE_IP6REACH_INTERNAL; memset(&ip_info, 0, sizeof(ip_info)); ip_info.dest.family = AF_INET6; ip_info.dest.u.prefix6 = r->prefix.prefix; ip_info.dest.prefixlen = r->prefix.prefixlen; if (spftree->area->srdb.enabled && r->subtlvs && - r->subtlvs->source_prefix && - r->subtlvs->source_prefix->prefixlen) { + r->subtlvs->source_prefix && r->subtlvs->source_prefix->prefixlen) { if (spftree->tree_id != SPFTREE_DSTSRC) { char buff[VID2STR_BUFFER]; zlog_warn("Ignoring dest-src route %s in non dest-src topology", - srcdest2str( - &ip_info.dest, - r->subtlvs->source_prefix, - buff, sizeof(buff) - ) - ); + srcdest2str(&ip_info.dest, + r->subtlvs->source_prefix, buff, + sizeof(buff))); continue; } ip_info.src = *r->subtlvs->source_prefix; @@ -1101,30 +1012,23 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, /* Parse list of Prefix-SID subTLVs */ has_valid_psid = false; if (r->subtlvs) { - for (struct isis_item *i = - r->subtlvs->prefix_sids.head; - i; i = i->next) { - struct isis_prefix_sid *psid = - (struct isis_prefix_sid *)i; - - if (psid->algorithm != - spftree->algorithm) + for (struct isis_item *i = r->subtlvs->prefix_sids.head; i; + i = i->next) { + struct isis_prefix_sid *psid = (struct isis_prefix_sid *)i; + + if (psid->algorithm != spftree->algorithm) continue; #ifndef FABRICD - if (flex_algo_id_valid( - spftree->algorithm) && - (!sr_algorithm_participated( - lsp, spftree->algorithm) || - !isis_flex_algo_elected_supported( - spftree->algorithm, - spftree->area))) + if (flex_algo_id_valid(spftree->algorithm) && + (!sr_algorithm_participated(lsp, spftree->algorithm) || + !isis_flex_algo_elected_supported(spftree->algorithm, + spftree->area))) continue; #endif /* ifndef FABRICD */ has_valid_psid = true; - process_N(spftree, vtype, &ip_info, - dist, depth + 1, psid, + process_N(spftree, vtype, &ip_info, dist, depth + 1, psid, parent); /* * Stop the Prefix-SID iteration since @@ -1135,21 +1039,18 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, } } if (!has_valid_psid) - process_N(spftree, vtype, &ip_info, dist, - depth + 1, NULL, parent); + process_N(spftree, vtype, &ip_info, dist, depth + 1, NULL, parent); } /* Process SRv6 Locator TLVs */ - struct isis_item_list *srv6_locators = isis_lookup_mt_items( - &lsp->tlvs->srv6_locator, spftree->mtid); + struct isis_item_list *srv6_locators = + isis_lookup_mt_items(&lsp->tlvs->srv6_locator, spftree->mtid); struct isis_srv6_locator_tlv *loc; - for (loc = srv6_locators ? (struct isis_srv6_locator_tlv *) - srv6_locators->head + for (loc = srv6_locators ? (struct isis_srv6_locator_tlv *)srv6_locators->head : NULL; loc; loc = loc->next) { - if (loc->algorithm != SR_ALGORITHM_SPF) continue; @@ -1167,9 +1068,7 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, them. If we find the SRv6 Locator in some Prefix Reachbility TLV then it means that we have already processed it before and we can skip it. */ - for (r = ipv6_reachs ? (struct isis_ipv6_reach *) - ipv6_reachs->head - : NULL; + for (r = ipv6_reachs ? (struct isis_ipv6_reach *)ipv6_reachs->head : NULL; r; r = r->next) { if (prefix_same((struct prefix *)&r->prefix, (struct prefix *)&loc->prefix)) @@ -1179,8 +1078,7 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, /* SRv6 locator not present in Prefix Reachability TLV, * let's process it */ if (!loc_is_in_ipv6_reach) - process_N(spftree, vtype, &ip_info, dist, - depth + 1, NULL, parent); + process_N(spftree, vtype, &ip_info, dist, depth + 1, NULL, parent); } } @@ -1191,16 +1089,13 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, * level-2 | level1-2 areas then add a default route toward * this neighbor */ - if ((lsp->hdr.lsp_bits & LSPBIT_ATT) == LSPBIT_ATT - && !spftree->area->attached_bit_rcv_ignore - && (spftree->area->is_type & IS_LEVEL_1) - && !isis_level2_adj_up(spftree->area)) { + if ((lsp->hdr.lsp_bits & LSPBIT_ATT) == LSPBIT_ATT && + !spftree->area->attached_bit_rcv_ignore && (spftree->area->is_type & IS_LEVEL_1) && + !isis_level2_adj_up(spftree->area)) { memset(&ip_info, 0, sizeof(ip_info)); if (IS_DEBUG_RTE_EVENTS) - zlog_debug("ISIS-Spf (%pLS): add default %s route", - lsp->hdr.lsp_id, - spftree->family == AF_INET ? "ipv4" - : "ipv6"); + zlog_debug("ISIS-Spf (%pLS): add default %s route", lsp->hdr.lsp_id, + spftree->family == AF_INET ? "ipv4" : "ipv6"); if (spftree->family == AF_INET) { ip_info.dest.family = AF_INET; @@ -1209,8 +1104,7 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, ip_info.dest.family = AF_INET6; vtype = VTYPE_IP6REACH_INTERNAL; } - process_N(spftree, vtype, &ip_info, cost, depth + 1, NULL, - parent); + process_N(spftree, vtype, &ip_info, cost, depth + 1, NULL, parent); } if (fragnode == NULL) @@ -1226,13 +1120,14 @@ static int isis_spf_process_lsp(struct isis_spftree *spftree, return ISIS_OK; } -static struct isis_adjacency *adj_find(struct list *adj_list, const uint8_t *id, - int level, uint16_t mtid, int family) +static struct spf_adj_ref *adj_find(struct spf_adj_list_head *adj_list, const uint8_t *id, + int level, uint16_t mtid, int family) { - struct isis_adjacency *adj; - struct listnode *node; + struct spf_adj_ref *ref; + + frr_each (spf_adj_list, adj_list, ref) { + struct isis_adjacency *adj = ref->adj; - for (ALL_LIST_ELEMENTS_RO(adj_list, node, adj)) { if (!(adj->level & level)) continue; if (memcmp(adj->sysid, id, ISIS_SYS_ID_LEN) != 0) @@ -1241,10 +1136,10 @@ static struct isis_adjacency *adj_find(struct list *adj_list, const uint8_t *id, continue; if (!adj_has_mt(adj, mtid)) continue; - if (mtid == ISIS_MT_IPV4_UNICAST - && !speaks(adj->nlpids.nlpids, adj->nlpids.count, family)) + if (mtid == ISIS_MT_IPV4_UNICAST && + !speaks(adj->nlpids.nlpids, adj->nlpids.count, family)) continue; - return adj; + return ref; } return NULL; @@ -1255,10 +1150,8 @@ struct spf_preload_tent_ip_reach_args { struct isis_vertex *parent; }; -static int isis_spf_preload_tent_ip_reach_cb(const struct prefix *prefix, - uint32_t metric, bool external, - struct isis_subtlvs *subtlvs, - void *arg) +static int isis_spf_preload_tent_ip_reach_cb(const struct prefix *prefix, uint32_t metric, + bool external, struct isis_subtlvs *subtlvs, void *arg) { struct spf_preload_tent_ip_reach_args *args = arg; struct isis_spftree *spftree = args->spftree; @@ -1282,17 +1175,14 @@ static int isis_spf_preload_tent_ip_reach_cb(const struct prefix *prefix, /* Parse list of Prefix-SID subTLVs if SR is enabled */ if (spftree->area->srdb.enabled && subtlvs) { - for (struct isis_item *i = subtlvs->prefix_sids.head; i; - i = i->next) { - struct isis_prefix_sid *psid = - (struct isis_prefix_sid *)i; + for (struct isis_item *i = subtlvs->prefix_sids.head; i; i = i->next) { + struct isis_prefix_sid *psid = (struct isis_prefix_sid *)i; if (psid->algorithm != spftree->algorithm) continue; has_valid_psid = true; - isis_spf_add_local(spftree, vtype, &ip_info, NULL, 0, - psid, parent); + isis_spf_add_local(spftree, vtype, &ip_info, NULL, 0, psid, parent); /* * Stop the Prefix-SID iteration since we only support @@ -1302,16 +1192,13 @@ static int isis_spf_preload_tent_ip_reach_cb(const struct prefix *prefix, } } if (!has_valid_psid) - isis_spf_add_local(spftree, vtype, &ip_info, NULL, 0, NULL, - parent); + isis_spf_add_local(spftree, vtype, &ip_info, NULL, 0, NULL, parent); return LSP_ITER_CONTINUE; } -static void isis_spf_preload_tent(struct isis_spftree *spftree, - uint8_t *root_sysid, - struct isis_lsp *root_lsp, - struct isis_vertex *parent) +static void isis_spf_preload_tent(struct isis_spftree *spftree, uint8_t *root_sysid, + struct isis_lsp *root_lsp, struct isis_vertex *parent) { struct spf_preload_tent_ip_reach_args ip_reach_args; struct isis_spf_adj *sadj; @@ -1320,9 +1207,8 @@ static void isis_spf_preload_tent(struct isis_spftree *spftree, if (!CHECK_FLAG(spftree->flags, F_SPFTREE_HOPCOUNT_METRIC)) { ip_reach_args.spftree = spftree; ip_reach_args.parent = parent; - isis_lsp_iterate_ip_reach( - root_lsp, spftree->family, spftree->mtid, - isis_spf_preload_tent_ip_reach_cb, &ip_reach_args); + isis_lsp_iterate_ip_reach(root_lsp, spftree->family, spftree->mtid, + isis_spf_preload_tent_ip_reach_cb, &ip_reach_args); } /* Iterate over adjacencies. */ @@ -1337,25 +1223,19 @@ static void isis_spf_preload_tent(struct isis_spftree *spftree, if (isis_lfa_excise_adj_check(spftree, adj_id)) { if (IS_DEBUG_LFA) - zlog_debug("ISIS-SPF: excising adjacency %pPN", - sadj->id); + zlog_debug("ISIS-SPF: excising adjacency %pPN", sadj->id); continue; } - metric = CHECK_FLAG(spftree->flags, F_SPFTREE_HOPCOUNT_METRIC) - ? 1 - : sadj->metric; + metric = CHECK_FLAG(spftree->flags, F_SPFTREE_HOPCOUNT_METRIC) ? 1 : sadj->metric; if (!LSP_PSEUDO_ID(sadj->id)) { isis_spf_add_local(spftree, - CHECK_FLAG(sadj->flags, - F_ISIS_SPF_ADJ_OLDMETRIC) + CHECK_FLAG(sadj->flags, F_ISIS_SPF_ADJ_OLDMETRIC) ? VTYPE_NONPSEUDO_IS : VTYPE_NONPSEUDO_TE_IS, - sadj->id, sadj, metric, NULL, - parent); + sadj->id, sadj, metric, NULL, parent); } else if (sadj->lsp) { - isis_spf_process_lsp(spftree, sadj->lsp, metric, 0, - spftree->sysid, parent); + isis_spf_process_lsp(spftree, sadj->lsp, metric, 0, spftree->sysid, parent); } } } @@ -1365,10 +1245,8 @@ struct spf_adj_find_reverse_metric_args { uint32_t reverse_metric; }; -static int spf_adj_find_reverse_metric_cb(const uint8_t *id, uint32_t metric, - bool oldmetric, - struct isis_ext_subtlvs *subtlvs, - void *arg) +static int spf_adj_find_reverse_metric_cb(const uint8_t *id, uint32_t metric, bool oldmetric, + struct isis_ext_subtlvs *subtlvs, void *arg) { struct spf_adj_find_reverse_metric_args *args = arg; @@ -1419,8 +1297,7 @@ static void spf_adj_get_reverse_metrics(struct isis_spftree *spftree) id_self = spftree->sysid; args.id_self = id_self; args.reverse_metric = UINT32_MAX; - isis_lsp_iterate_is_reach(lsp_adj, spftree->mtid, - spf_adj_find_reverse_metric_cb, + isis_lsp_iterate_is_reach(lsp_adj, spftree->mtid, spf_adj_find_reverse_metric_cb, &args); if (args.reverse_metric == UINT32_MAX) { /* Delete one-way adjacency. */ @@ -1432,11 +1309,9 @@ static void spf_adj_get_reverse_metrics(struct isis_spftree *spftree) } } -static void spf_adj_list_parse_tlv(struct isis_spftree *spftree, - struct list *adj_list, const uint8_t *id, - const uint8_t *desig_is_id, - uint32_t pseudo_metric, uint32_t metric, - bool oldmetric, +static void spf_adj_list_parse_tlv(struct isis_spftree *spftree, struct spf_adj_list_head *adj_list, + const uint8_t *id, const uint8_t *desig_is_id, + uint32_t pseudo_metric, uint32_t metric, bool oldmetric, struct isis_ext_subtlvs *subtlvs) { struct isis_spf_adj *sadj; @@ -1453,16 +1328,14 @@ static void spf_adj_list_parse_tlv(struct isis_spftree *spftree, LSP_FRAGMENT(lspid) = 0; lsp = lsp_search(spftree->lspdb, lspid); if (lsp == NULL || lsp->hdr.rem_lifetime == 0) { - zlog_warn("ISIS-SPF: No LSP found from root to L%d %pLS", - spftree->level, lspid); + zlog_warn("ISIS-SPF: No LSP found from root to L%d %pLS", spftree->level, lspid); return; } sadj = XCALLOC(MTYPE_ISIS_SPF_ADJ, sizeof(*sadj)); memcpy(sadj->id, id, sizeof(sadj->id)); if (desig_is_id) { - memcpy(sadj->lan.desig_is_id, desig_is_id, - sizeof(sadj->lan.desig_is_id)); + memcpy(sadj->lan.desig_is_id, desig_is_id, sizeof(sadj->lan.desig_is_id)); SET_FLAG(flags, F_ISIS_SPF_ADJ_BROADCAST); sadj->metric = pseudo_metric; } else @@ -1477,19 +1350,18 @@ static void spf_adj_list_parse_tlv(struct isis_spftree *spftree, sadj->flags = flags; /* Set real adjacency. */ - if (!CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES) - && !LSP_PSEUDO_ID(id)) { - struct isis_adjacency *adj; + if (!CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES) && !LSP_PSEUDO_ID(id)) { + struct spf_adj_ref *ref; - adj = adj_find(adj_list, id, spftree->level, spftree->mtid, - spftree->family); - if (!adj) { + ref = adj_find(adj_list, id, spftree->level, spftree->mtid, spftree->family); + if (!ref) { XFREE(MTYPE_ISIS_SPF_ADJ, sadj); return; } - listnode_delete(adj_list, adj); - sadj->adj = adj; + spf_adj_list_del(adj_list, ref); + sadj->adj = ref->adj; + XFREE(MTYPE_ISIS_SPF_ADJ_REF, ref); } /* Add adjacency to the list. */ @@ -1512,9 +1384,8 @@ static void spf_adj_list_parse_tlv(struct isis_spftree *spftree, } static void spf_adj_list_parse_lsp(struct isis_spftree *spftree, - struct list *adj_list, struct isis_lsp *lsp, - const uint8_t *pseudo_nodeid, - uint32_t pseudo_metric) + struct spf_adj_list_head *adj_list, struct isis_lsp *lsp, + const uint8_t *pseudo_nodeid, uint32_t pseudo_metric) { bool pseudo_lsp = LSP_PSEUDO_ID(lsp->hdr.lsp_id); struct isis_lsp *frag; @@ -1529,25 +1400,20 @@ static void spf_adj_list_parse_lsp(struct isis_spftree *spftree, if (lsp->tlvs) { if (pseudo_lsp || spftree->mtid == ISIS_MT_IPV4_UNICAST) { head = lsp->tlvs->oldstyle_reach.head; - for (struct isis_oldstyle_reach *reach = - (struct isis_oldstyle_reach *)head; + for (struct isis_oldstyle_reach *reach = (struct isis_oldstyle_reach *)head; reach; reach = reach->next) { - spf_adj_list_parse_tlv( - spftree, adj_list, reach->id, - pseudo_nodeid, pseudo_metric, - reach->metric, true, NULL); + spf_adj_list_parse_tlv(spftree, adj_list, reach->id, pseudo_nodeid, + pseudo_metric, reach->metric, true, NULL); } } if (pseudo_lsp || spftree->mtid == ISIS_MT_IPV4_UNICAST) te_neighs = &lsp->tlvs->extended_reach; else - te_neighs = isis_get_mt_items(&lsp->tlvs->mt_reach, - spftree->mtid); + te_neighs = isis_get_mt_items(&lsp->tlvs->mt_reach, spftree->mtid); if (te_neighs) { head = te_neighs->head; - for (struct isis_extended_reach *reach = - (struct isis_extended_reach *)head; + for (struct isis_extended_reach *reach = (struct isis_extended_reach *)head; reach; reach = reach->next) { #ifndef FABRICD /* @@ -1555,17 +1421,14 @@ static void spf_adj_list_parse_lsp(struct isis_spftree *spftree, * affinity attribute */ if (flex_algo_id_valid(spftree->algorithm) && - (!sr_algorithm_participated( - lsp, spftree->algorithm) || - isis_flex_algo_constraint_drop( - spftree, lsp, reach))) + (!sr_algorithm_participated(lsp, spftree->algorithm) || + isis_flex_algo_constraint_drop(spftree, lsp, reach))) continue; #endif /* ifndef FABRICD */ - spf_adj_list_parse_tlv( - spftree, adj_list, reach->id, - pseudo_nodeid, pseudo_metric, - reach->metric, false, reach->subtlvs); + spf_adj_list_parse_tlv(spftree, adj_list, reach->id, pseudo_nodeid, + pseudo_metric, reach->metric, false, + reach->subtlvs); } } } @@ -1578,23 +1441,33 @@ static void spf_adj_list_parse_lsp(struct isis_spftree *spftree, if (!frag->tlvs) continue; - spf_adj_list_parse_lsp(spftree, adj_list, frag, pseudo_nodeid, - pseudo_metric); + spf_adj_list_parse_lsp(spftree, adj_list, frag, pseudo_nodeid, pseudo_metric); } } -static void isis_spf_build_adj_list(struct isis_spftree *spftree, - struct isis_lsp *lsp) +static void isis_spf_build_adj_list(struct isis_spftree *spftree, struct isis_lsp *lsp) { - struct list *adj_list = NULL; + struct spf_adj_list_head adj_list; + struct isis_adjacency *adj; + struct spf_adj_ref *ref; + + spf_adj_list_init(&adj_list); - if (!CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES)) - adj_list = list_dup(spftree->area->adjacency_list); + if (!CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES)) { + frr_each (isis_area_adj_list, &spftree->area->adjacency_list, adj) { + ref = XCALLOC(MTYPE_ISIS_SPF_ADJ_REF, sizeof(*ref)); + ref->adj = adj; + spf_adj_list_add_tail(&adj_list, ref); + } + } - spf_adj_list_parse_lsp(spftree, adj_list, lsp, NULL, 0); + spf_adj_list_parse_lsp(spftree, &adj_list, lsp, NULL, 0); - if (!CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES)) - list_delete(&adj_list); + /* Free any remaining adjacency references */ + while ((ref = spf_adj_list_pop(&adj_list)) != NULL) + XFREE(MTYPE_ISIS_SPF_ADJ_REF, ref); + + spf_adj_list_fini(&adj_list); if (spftree->type == SPF_TYPE_REVERSE) spf_adj_get_reverse_metrics(spftree); @@ -1604,8 +1477,7 @@ static void isis_spf_build_adj_list(struct isis_spftree *spftree, * The parent(s) for vertex is set when added to TENT list * now we just put the child pointer(s) in place */ -static void add_to_paths(struct isis_spftree *spftree, - struct isis_vertex *vertex) +static void add_to_paths(struct isis_spftree *spftree, struct isis_vertex *vertex) { #ifdef EXTREME_DEBUG char buff[VID2STR_BUFFER]; @@ -1617,13 +1489,10 @@ static void add_to_paths(struct isis_spftree *spftree, #ifdef EXTREME_DEBUG if (IS_DEBUG_SPF_EVENTS) - zlog_debug( - "ISIS-SPF: A:%hhu S:%p added %s %s %s depth %d dist %d to PATHS", - spftree->algorithm, spftree, - print_sys_hostname(vertex->N.id), - vtype2string(vertex->type), - vid2string(vertex, buff, sizeof(buff)), vertex->depth, - vertex->d_N); + zlog_debug("ISIS-SPF: A:%hhu S:%p added %s %s %s depth %d dist %d to PATHS", + spftree->algorithm, spftree, print_sys_hostname(vertex->N.id), + vtype2string(vertex->type), vid2string(vertex, buff, sizeof(buff)), + vertex->depth, vertex->d_N); #endif /* EXTREME_DEBUG */ } @@ -1638,20 +1507,19 @@ static void init_spt(struct isis_spftree *spftree, int mtid) isis_zebra_rlfa_unregister_all(spftree); isis_rlfa_list_clear(spftree); list_delete_all_node(spftree->lfa.remote.pc_spftrees); - memset(&spftree->lfa.protection_counters, 0, - sizeof(spftree->lfa.protection_counters)); + memset(&spftree->lfa.protection_counters, 0, sizeof(spftree->lfa.protection_counters)); spftree->mtid = mtid; } -static enum spf_prefix_priority -spf_prefix_priority(struct isis_spftree *spftree, struct isis_vertex *vertex) +static enum spf_prefix_priority spf_prefix_priority(struct isis_spftree *spftree, + struct isis_vertex *vertex) { struct isis_area *area = spftree->area; struct prefix *prefix = &vertex->N.ip.p.dest; - for (int priority = SPF_PREFIX_PRIO_CRITICAL; - priority <= SPF_PREFIX_PRIO_MEDIUM; priority++) { + for (int priority = SPF_PREFIX_PRIO_CRITICAL; priority <= SPF_PREFIX_PRIO_MEDIUM; + priority++) { struct spf_prefix_priority_acl *ppa; enum filter_type ret = FILTER_PERMIT; @@ -1678,34 +1546,30 @@ spf_prefix_priority(struct isis_spftree *spftree, struct isis_vertex *vertex) return SPF_PREFIX_PRIO_LOW; } -static void spf_path_process(struct isis_spftree *spftree, - struct isis_vertex *vertex) +static void spf_path_process(struct isis_spftree *spftree, struct isis_vertex *vertex) { struct isis_area *area = spftree->area; int level = spftree->level; char buff[VID2STR_BUFFER]; - if (spftree->type == SPF_TYPE_TI_LFA && VTYPE_IS(vertex->type) - && !CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES)) { + if (spftree->type == SPF_TYPE_TI_LFA && VTYPE_IS(vertex->type) && + !CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES)) { if (listcount(vertex->Adj_N) > 0) { - struct isis_adjacency *adj; + const struct isis_adjacency *adj; if (isis_tilfa_check(spftree, vertex) != 0) return; adj = isis_adj_find(area, level, vertex->N.id); if (adj) - sr_adj_sid_add_single(adj, spftree->family, - true, vertex->Adj_N); + sr_adj_sid_add_single(adj, spftree->family, true, vertex->Adj_N); } else if (IS_DEBUG_SPF_EVENTS) - zlog_debug( - "ISIS-SPF: no adjacencies, do not install backup Adj-SID for %s depth %d dist %d", - vid2string(vertex, buff, sizeof(buff)), - vertex->depth, vertex->d_N); + zlog_debug("ISIS-SPF: no adjacencies, do not install backup Adj-SID for %s depth %d dist %d", + vid2string(vertex, buff, sizeof(buff)), vertex->depth, + vertex->d_N); } - if (VTYPE_IP(vertex->type) - && !CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ROUTES)) { + if (VTYPE_IP(vertex->type) && !CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ROUTES)) { enum spf_prefix_priority priority; priority = spf_prefix_priority(spftree, vertex); @@ -1718,16 +1582,11 @@ static void spf_path_process(struct isis_spftree *spftree, switch (spftree->type) { case SPF_TYPE_RLFA: case SPF_TYPE_TI_LFA: - if (priority - > area->lfa_priority_limit[level - 1]) { + if (priority > area->lfa_priority_limit[level - 1]) { if (IS_DEBUG_LFA) - zlog_debug( - "ISIS-LFA: skipping %s %s (low prefix priority)", - vtype2string( - vertex->type), - vid2string( - vertex, buff, - sizeof(buff))); + zlog_debug("ISIS-LFA: skipping %s %s (low prefix priority)", + vtype2string(vertex->type), + vid2string(vertex, buff, sizeof(buff))); return; } break; @@ -1747,8 +1606,8 @@ static void spf_path_process(struct isis_spftree *spftree, pre_spftree = spftree->lfa.old.spftree; route_table = pre_spftree->route_table_backup; allow_ecmp = area->lfa_load_sharing[level - 1]; - pre_spftree->lfa.protection_counters - .tilfa[vertex->N.ip.priority] += 1; + pre_spftree->lfa.protection_counters.tilfa[vertex->N.ip.priority] += + 1; break; case SPF_TYPE_FORWARD: case SPF_TYPE_REVERSE: @@ -1760,11 +1619,10 @@ static void spf_path_process(struct isis_spftree *spftree, * routes). */ if (vertex->depth > 1) { - spftree->lfa.protection_counters - .total[priority] += 1; + spftree->lfa.protection_counters.total[priority] += 1; if (listcount(vertex->Adj_N) > 1) - spftree->lfa.protection_counters - .ecmp[priority] += 1; + spftree->lfa.protection_counters.ecmp[priority] += + 1; } break; } @@ -1772,30 +1630,23 @@ static void spf_path_process(struct isis_spftree *spftree, #ifdef EXTREME_DEBUG struct isis_route_info *ri = #endif /* EXTREME_DEBUG */ - isis_route_create(&vertex->N.ip.p.dest, - &vertex->N.ip.p.src, - vertex->d_N, vertex->depth, - &vertex->N.ip.sr, - vertex->Adj_N, allow_ecmp, - area, route_table); + isis_route_create(&vertex->N.ip.p.dest, &vertex->N.ip.p.src, + vertex->d_N, vertex->depth, &vertex->N.ip.sr, + vertex->Adj_N, allow_ecmp, area, route_table); #ifdef EXTREME_DEBUG - zlog_debug( - "ISIS-SPF: A:%hhu create route pfx %pFX dist %d, sr.algo %d, table %p, rv %p", - spftree->algorithm, &vertex->N.ip.p.dest, - vertex->d_N, vertex->N.ip.sr.algorithm, - route_table, ri); + zlog_debug("ISIS-SPF: A:%hhu create route pfx %pFX dist %d, sr.algo %d, table %p, rv %p", + spftree->algorithm, &vertex->N.ip.p.dest, vertex->d_N, + vertex->N.ip.sr.algorithm, route_table, ri); #endif /* EXTREME_DEBUG */ } else if (IS_DEBUG_SPF_EVENTS) - zlog_debug( - "ISIS-SPF: no adjacencies, do not install route for %s depth %d dist %d", - vid2string(vertex, buff, sizeof(buff)), - vertex->depth, vertex->d_N); + zlog_debug("ISIS-SPF: no adjacencies, do not install route for %s depth %d dist %d", + vid2string(vertex, buff, sizeof(buff)), vertex->depth, + vertex->d_N); } } -static void isis_spf_loop(struct isis_spftree *spftree, - uint8_t *root_sysid) +static void isis_spf_loop(struct isis_spftree *spftree, uint8_t *root_sysid) { struct isis_vertex *vertex; struct isis_lsp *lsp; @@ -1805,10 +1656,9 @@ static void isis_spf_loop(struct isis_spftree *spftree, vertex = isis_vertex_queue_pop(&spftree->tents); #ifdef EXTREME_DEBUG - zlog_debug( - "ISIS-SPF: A:%hhu get TENT node %s %s depth %d dist %d to PATHS", - spftree->algorithm, print_sys_hostname(vertex->N.id), - vtype2string(vertex->type), vertex->depth, vertex->d_N); + zlog_debug("ISIS-SPF: A:%hhu get TENT node %s %s depth %d dist %d to PATHS", + spftree->algorithm, print_sys_hostname(vertex->N.id), + vtype2string(vertex->type), vertex->depth, vertex->d_N); #endif /* EXTREME_DEBUG */ add_to_paths(spftree, vertex); @@ -1817,13 +1667,11 @@ static void isis_spf_loop(struct isis_spftree *spftree, lsp = lsp_for_vertex(spftree, vertex); if (!lsp) { - zlog_warn("ISIS-SPF: No LSP found for %pPN", - vertex->N.id); + zlog_warn("ISIS-SPF: No LSP found for %pPN", vertex->N.id); continue; } - isis_spf_process_lsp(spftree, lsp, vertex->d_N, vertex->depth, - root_sysid, vertex); + isis_spf_process_lsp(spftree, lsp, vertex->d_N, vertex->depth, root_sysid, vertex); } /* Generate routes once the SPT is formed. */ @@ -1832,8 +1680,7 @@ static void isis_spf_loop(struct isis_spftree *spftree, switch (vertex->type) { case VTYPE_IPREACH_INTERNAL: case VTYPE_IPREACH_EXTERNAL: - if (isis_find_vertex(&spftree->paths, &vertex->N, - VTYPE_IPREACH_TE)) + if (isis_find_vertex(&spftree->paths, &vertex->N, VTYPE_IPREACH_TE)) continue; break; case VTYPE_PSEUDO_IS: @@ -1851,15 +1698,13 @@ static void isis_spf_loop(struct isis_spftree *spftree, } } -struct isis_spftree *isis_run_hopcount_spf(struct isis_area *area, - uint8_t *sysid, +struct isis_spftree *isis_run_hopcount_spf(struct isis_area *area, uint8_t *sysid, struct isis_spftree *spftree) { if (!spftree) - spftree = isis_spftree_new( - area, &area->lspdb[IS_LEVEL_2 - 1], sysid, ISIS_LEVEL2, - SPFTREE_IPV4, SPF_TYPE_FORWARD, - F_SPFTREE_HOPCOUNT_METRIC, SR_ALGORITHM_SPF); + spftree = isis_spftree_new(area, &area->lspdb[IS_LEVEL_2 - 1], sysid, ISIS_LEVEL2, + SPFTREE_IPV4, SPF_TYPE_FORWARD, + F_SPFTREE_HOPCOUNT_METRIC, SR_ALGORITHM_SPF); init_spt(spftree, ISIS_MT_IPV4_UNICAST); if (!memcmp(sysid, area->isis->sysid, ISIS_SYS_ID_LEN)) { @@ -1874,13 +1719,11 @@ struct isis_spftree *isis_run_hopcount_spf(struct isis_area *area, */ root_vertex = isis_spf_add_root(spftree); - isis_spf_preload_tent(spftree, sysid, root_lsp, - root_vertex); + isis_spf_preload_tent(spftree, sysid, root_lsp, root_vertex); } } else { - isis_vertex_queue_insert( - &spftree->tents, - isis_vertex_new(spftree, sysid, VTYPE_NONPSEUDO_TE_IS)); + isis_vertex_queue_insert(&spftree->tents, + isis_vertex_new(spftree, sysid, VTYPE_NONPSEUDO_TE_IS)); } isis_spf_loop(spftree, sysid); @@ -1905,8 +1748,7 @@ void isis_run_spf(struct isis_spftree *spftree) root_lsp = isis_root_system_lsp(spftree->lspdb, spftree->sysid); if (root_lsp == NULL) { - zlog_err("ISIS-SPF: could not find own l%d LSP!", - spftree->level); + zlog_err("ISIS-SPF: could not find own l%d LSP!", spftree->level); return; } @@ -1916,8 +1758,8 @@ void isis_run_spf(struct isis_spftree *spftree) mtid = ISIS_MT_IPV4_UNICAST; break; case SPFTREE_IPV6: - mt_router_info = isis_tlvs_lookup_mt_router_info( - root_lsp->tlvs, ISIS_MT_IPV6_UNICAST); + mt_router_info = isis_tlvs_lookup_mt_router_info(root_lsp->tlvs, + ISIS_MT_IPV6_UNICAST); if (mt_router_info) mtid = ISIS_MT_IPV6_UNICAST; else @@ -1927,9 +1769,7 @@ void isis_run_spf(struct isis_spftree *spftree) mtid = ISIS_MT_IPV6_DSTSRC; break; case SPFTREE_COUNT: - zlog_err( - "%s should never be called with SPFTREE_COUNT as argument!", - __func__); + zlog_err("%s should never be called with SPFTREE_COUNT as argument!", __func__); exit(1); } @@ -1942,23 +1782,19 @@ void isis_run_spf(struct isis_spftree *spftree) * Flexible-Algorithm. */ if (flex_algo_id_valid(spftree->algorithm)) { - flex_algo_enabled = isis_flex_algo_elected_supported( - spftree->algorithm, spftree->area); + flex_algo_enabled = isis_flex_algo_elected_supported(spftree->algorithm, + spftree->area); if (flex_algo_enabled != - flex_algo_get_state(spftree->area->flex_algos, - spftree->algorithm)) { + flex_algo_get_state(spftree->area->flex_algos, spftree->algorithm)) { /* actual state is inconsistent with local LSP */ - lsp_regenerate_schedule(spftree->area, - spftree->area->is_type, 0); + lsp_regenerate_schedule(spftree->area, spftree->area->is_type, 0); goto out; } if (!flex_algo_enabled) { if (!CHECK_FLAG(spftree->flags, F_SPFTREE_DISABLED)) { isis_spftree_clear(spftree); SET_FLAG(spftree->flags, F_SPFTREE_DISABLED); - lsp_regenerate_schedule(spftree->area, - spftree->area->is_type, - 0); + lsp_regenerate_schedule(spftree->area, spftree->area->is_type, 0); } goto out; } @@ -1978,8 +1814,7 @@ void isis_run_spf(struct isis_spftree *spftree) /* * C.2.7 Step 2 */ - if (!isis_vertex_queue_count(&spftree->tents) - && (IS_DEBUG_SPF_EVENTS)) { + if (!isis_vertex_queue_count(&spftree->tents) && (IS_DEBUG_SPF_EVENTS)) { zlog_warn("ISIS-SPF: TENT is empty SPF-root:%s", print_sys_hostname(spftree->sysid)); } @@ -1991,8 +1826,7 @@ void isis_run_spf(struct isis_spftree *spftree) /* flex-algo */ if (CHECK_FLAG(spftree->flags, F_SPFTREE_DISABLED)) { UNSET_FLAG(spftree->flags, F_SPFTREE_DISABLED); - lsp_regenerate_schedule(spftree->area, spftree->area->is_type, - 0); + lsp_regenerate_schedule(spftree->area, spftree->area->is_type, 0); } out: @@ -2000,38 +1834,33 @@ void isis_run_spf(struct isis_spftree *spftree) spftree->runcount++; spftree->last_run_timestamp = time(NULL); spftree->last_run_monotime = monotime(&time_end); - spftree->last_run_duration = - ((time_end.tv_sec - time_start.tv_sec) * 1000000) - + (time_end.tv_usec - time_start.tv_usec); + spftree->last_run_duration = ((time_end.tv_sec - time_start.tv_sec) * 1000000) + + (time_end.tv_usec - time_start.tv_usec); } -static void isis_run_spf_with_protection(struct isis_area *area, - struct isis_spftree *spftree) +static void isis_run_spf_with_protection(struct isis_area *area, struct isis_spftree *spftree) { /* Run forward SPF locally. */ memcpy(spftree->sysid, area->isis->sysid, ISIS_SYS_ID_LEN); isis_run_spf(spftree); /* Run LFA protection if configured. */ - if (area->lfa_protected_links[spftree->level - 1] > 0 - || area->tilfa_protected_links[spftree->level - 1] > 0) + if (area->lfa_protected_links[spftree->level - 1] > 0 || + area->tilfa_protected_links[spftree->level - 1] > 0) isis_spf_run_lfa(area, spftree); } -void isis_spf_verify_routes(struct isis_area *area, struct isis_spftree **trees, - int tree) +void isis_spf_verify_routes(struct isis_area *area, struct isis_spftree **trees, int tree) { if (area->is_type == IS_LEVEL_1) { - isis_route_verify_table(area, trees[0]->route_table, - trees[0]->route_table_backup, tree); + isis_route_verify_table(area, trees[0]->route_table, trees[0]->route_table_backup, + tree); } else if (area->is_type == IS_LEVEL_2) { - isis_route_verify_table(area, trees[1]->route_table, - trees[1]->route_table_backup, tree); + isis_route_verify_table(area, trees[1]->route_table, trees[1]->route_table_backup, + tree); } else { - isis_route_verify_merge(area, trees[0]->route_table, - trees[0]->route_table_backup, - trees[1]->route_table, - trees[1]->route_table_backup, tree); + isis_route_verify_merge(area, trees[0]->route_table, trees[0]->route_table_backup, + trees[1]->route_table, trees[1]->route_table_backup, tree); } } @@ -2047,18 +1876,15 @@ void isis_spf_invalidate_routes(struct isis_spftree *tree) route_table_finish(tree->route_table_backup); isis_route_table_info_free(backup_info); tree->route_table_backup = srcdest_table_init(); - tree->route_table_backup->info = - isis_route_table_info_alloc(tree->algorithm); + tree->route_table_backup->info = isis_route_table_info_alloc(tree->algorithm); tree->route_table_backup->cleanup = isis_route_node_cleanup; } -void isis_spf_switchover_routes(struct isis_area *area, - struct isis_spftree **trees, int family, - union g_addr *nexthop_ip, ifindex_t ifindex, - int level) +void isis_spf_switchover_routes(struct isis_area *area, struct isis_spftree **trees, int family, + union g_addr *nexthop_ip, ifindex_t ifindex, int level) { - isis_route_switchover_nexthop(area, trees[level - 1]->route_table, - family, nexthop_ip, ifindex); + isis_route_switchover_nexthop(area, trees[level - 1]->route_table, family, nexthop_ip, + ifindex); } static void isis_run_spf_cb(struct event *event) @@ -2067,9 +1893,9 @@ static void isis_run_spf_cb(struct event *event) struct isis_area *area = run->area; int level = run->level; int have_run = 0; - struct listnode *node; struct isis_circuit *circuit; #ifndef FABRICD + struct listnode *node; struct flex_algo *fa; struct isis_flex_algo_data *data; #endif /* ifndef FABRICD */ @@ -2078,8 +1904,7 @@ static void isis_run_spf_cb(struct event *event) if (!(area->is_type & level)) { if (IS_DEBUG_SPF_EVENTS) - zlog_warn("ISIS-SPF (%s) area does not share level", - area->area_tag); + zlog_warn("ISIS-SPF (%s) area does not share level", area->area_tag); return; } @@ -2087,38 +1912,30 @@ static void isis_run_spf_cb(struct event *event) isis_area_invalidate_routes(area, level); if (IS_DEBUG_SPF_EVENTS) - zlog_debug("ISIS-SPF (%s) L%d SPF needed, periodic SPF", - area->area_tag, level); + zlog_debug("ISIS-SPF (%s) L%d SPF needed, periodic SPF", area->area_tag, level); if (area->ip_circuits) { - isis_run_spf_with_protection( - area, area->spftree[SPFTREE_IPV4][level - 1]); + isis_run_spf_with_protection(area, area->spftree[SPFTREE_IPV4][level - 1]); #ifndef FABRICD - for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, - fa)) { + for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, fa)) { data = fa->data; - isis_run_spf_with_protection( - area, data->spftree[SPFTREE_IPV4][level - 1]); + isis_run_spf_with_protection(area, data->spftree[SPFTREE_IPV4][level - 1]); } #endif /* ifndef FABRICD */ have_run = 1; } if (area->ipv6_circuits) { - isis_run_spf_with_protection( - area, area->spftree[SPFTREE_IPV6][level - 1]); + isis_run_spf_with_protection(area, area->spftree[SPFTREE_IPV6][level - 1]); #ifndef FABRICD - for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, - fa)) { + for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node, fa)) { data = fa->data; - isis_run_spf_with_protection( - area, data->spftree[SPFTREE_IPV6][level - 1]); + isis_run_spf_with_protection(area, data->spftree[SPFTREE_IPV6][level - 1]); } #endif /* ifndef FABRICD */ have_run = 1; } if (area->ipv6_circuits && isis_area_ipv6_dstsrc_enabled(area)) { - isis_run_spf_with_protection( - area, area->spftree[SPFTREE_DSTSRC][level - 1]); + isis_run_spf_with_protection(area, area->spftree[SPFTREE_DSTSRC][level - 1]); have_run = 1; } @@ -2128,7 +1945,7 @@ static void isis_run_spf_cb(struct event *event) isis_area_verify_routes(area); /* walk all circuits and reset any spf specific flags */ - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) UNSET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF); fabricd_run_spf(area); @@ -2149,8 +1966,8 @@ void isis_spf_timer_free(void *run) XFREE(MTYPE_ISIS_SPF_RUN, run); } -int _isis_spf_schedule(struct isis_area *area, int level, - const char *func, const char *file, int line) +int _isis_spf_schedule(struct isis_area *area, int level, const char *func, const char *file, + int line) { struct isis_spftree *spftree; time_t now; @@ -2173,9 +1990,8 @@ int _isis_spf_schedule(struct isis_area *area, int level, assert(area->is_type & level); if (IS_DEBUG_SPF_EVENTS) { - zlog_debug( - "ISIS-SPF (%s) L%d SPF schedule called, lastrun %ld sec ago Caller: %s %s:%d", - area->area_tag, level, diff, func, file, line); + zlog_debug("ISIS-SPF (%s) L%d SPF schedule called, lastrun %ld sec ago Caller: %s %s:%d", + area->area_tag, level, diff, func, file, line); } event_cancel(&area->t_rlfa_rib_update); @@ -2184,13 +2000,11 @@ int _isis_spf_schedule(struct isis_area *area, int level, * to * restart holdoff timer - compare * draft-ietf-rtgwg-backoff-algo-04 */ - long delay = - spf_backoff_schedule(area->spf_delay_ietf[level - 1]); + long delay = spf_backoff_schedule(area->spf_delay_ietf[level - 1]); if (area->spf_timer[level - 1]) return ISIS_OK; - event_add_timer_msec(master, isis_run_spf_cb, - isis_run_spf_arg(area, level), delay, + event_add_timer_msec(master, isis_run_spf_cb, isis_run_spf_arg(area, level), delay, &area->spf_timer[level - 1]); return ISIS_OK; } @@ -2200,8 +2014,8 @@ int _isis_spf_schedule(struct isis_area *area, int level, /* wait configured min_spf_interval before doing the SPF */ long timer; - if (diff >= area->min_spf_interval[level - 1] - || area->bfd_force_spf_refresh) { + + if (diff >= area->min_spf_interval[level - 1] || area->bfd_force_spf_refresh) { /* * Last run is more than min interval ago or BFD signalled a * 'down' message, schedule immediate run @@ -2209,27 +2023,26 @@ int _isis_spf_schedule(struct isis_area *area, int level, timer = 0; if (area->bfd_force_spf_refresh) { - zlog_debug( - "ISIS-SPF (%s) L%d SPF scheduled immediately due to BFD 'down' message", - area->area_tag, level); + zlog_debug("ISIS-SPF (%s) L%d SPF scheduled immediately due to BFD 'down' message", + area->area_tag, level); area->bfd_force_spf_refresh = false; } } else { timer = area->min_spf_interval[level - 1] - diff; } - event_add_timer(master, isis_run_spf_cb, isis_run_spf_arg(area, level), - timer, &area->spf_timer[level - 1]); + event_add_timer(master, isis_run_spf_cb, isis_run_spf_arg(area, level), timer, + &area->spf_timer[level - 1]); if (IS_DEBUG_SPF_EVENTS) - zlog_debug("ISIS-SPF (%s) L%d SPF scheduled %ld sec from now", - area->area_tag, level, timer); + zlog_debug("ISIS-SPF (%s) L%d SPF scheduled %ld sec from now", area->area_tag, + level, timer); return ISIS_OK; } -static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue, - uint8_t *root_sysid, struct json_object **json) +static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue, uint8_t *root_sysid, + struct json_object **json) { struct listnode *node; struct isis_vertex *vertex; @@ -2252,12 +2065,11 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue, ttable_rowseps(tt, 0, BOTTOM, true, '-'); for (ALL_QUEUE_ELEMENTS_RO(queue, node, vertex)) { - if (VTYPE_IS(vertex->type) - && memcmp(vertex->N.id, root_sysid, ISIS_SYS_ID_LEN) == 0) { + if (VTYPE_IS(vertex->type) && + memcmp(vertex->N.id, root_sysid, ISIS_SYS_ID_LEN) == 0) { /* display here */ - ttable_add_row(tt, "%s|%s|%s|%s|%s|%s", - print_sys_hostname(root_sysid), "", "", - "", "", ""); + ttable_add_row(tt, "%s|%s|%s|%s|%s|%s", print_sys_hostname(root_sysid), "", + "", "", "", ""); continue; } @@ -2269,13 +2081,10 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue, snprintf(vertex_name, sizeof(vertex_name), "%s", vid2string(vertex, buff, sizeof(buff))); - snprintf(vertex_typestr, sizeof(vertex_typestr), "%s", - vtype2string(vertex->type)); - snprintf(vertex_metricstr, sizeof(vertex_metricstr), "%u", - vertex->d_N); - for (unsigned int i = 0; - i < MAX(vertex->Adj_N ? listcount(vertex->Adj_N) : 0, - vertex->parents ? listcount(vertex->parents) : 0); + snprintf(vertex_typestr, sizeof(vertex_typestr), "%s", vtype2string(vertex->type)); + snprintf(vertex_metricstr, sizeof(vertex_metricstr), "%u", vertex->d_N); + for (unsigned int i = 0; i < MAX(vertex->Adj_N ? listcount(vertex->Adj_N) : 0, + vertex->parents ? listcount(vertex->parents) : 0); i++) { if (anode) { vadj = listgetdata(anode); @@ -2293,9 +2102,8 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue, if (rows) { /* display here */ - ttable_add_row(tt, "%s|%s|%s|%s|%s|%s", - vertex_name, vertex_typestr, - vertex_metricstr, vertex_nexthop, + ttable_add_row(tt, "%s|%s|%s|%s|%s|%s", vertex_name, + vertex_typestr, vertex_metricstr, vertex_nexthop, vertex_interface, vertex_parent); /* store the first 3 elements */ @@ -2307,13 +2115,10 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue, if (vadj) { struct isis_spf_adj *sadj = vadj->sadj; - snprintf(vertex_nexthop, sizeof(vertex_nexthop), - "%s", print_sys_hostname(sadj->id)); - snprintf(vertex_interface, - sizeof(vertex_interface), "%s", - sadj->adj ? sadj->adj->circuit - ->interface->name - : "-"); + snprintf(vertex_nexthop, sizeof(vertex_nexthop), "%s", + print_sys_hostname(sadj->id)); + snprintf(vertex_interface, sizeof(vertex_interface), "%s", + sadj->adj ? sadj->adj->circuit->interface->name : "-"); } if (pvertex) { @@ -2321,31 +2126,26 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue, vertex_nexthop[0] = '\0'; vertex_interface[0] = '\0'; } - snprintf(vertex_parent, sizeof(vertex_parent), - "%s(%d)", - vid2string(pvertex, buff, sizeof(buff)), - pvertex->type); + snprintf(vertex_parent, sizeof(vertex_parent), "%s(%d)", + vid2string(pvertex, buff, sizeof(buff)), pvertex->type); } ++rows; } - ttable_add_row(tt, "%s|%s|%s|%s|%s|%s", vertex_name, - vertex_typestr, vertex_metricstr, vertex_nexthop, - vertex_interface, vertex_parent); + ttable_add_row(tt, "%s|%s|%s|%s|%s|%s", vertex_name, vertex_typestr, + vertex_metricstr, vertex_nexthop, vertex_interface, vertex_parent); } if (json == NULL) { table = ttable_dump(tt, "\n"); vty_out(vty, "%s\n", table); XFREE(MTYPE_TMP_TTABLE, table); } else - *json = ttable_json_with_json_text( - tt, "ssdsss", - "vertex|type|metric|nextHop|interface|parent"); + *json = ttable_json_with_json_text(tt, "ssdsss", + "vertex|type|metric|nextHop|interface|parent"); ttable_del(tt); } -void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree, - struct json_object **json) +void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree, struct json_object **json) { const char *tree_id_text = NULL; @@ -2368,16 +2168,14 @@ void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree, } if (!json) - vty_out(vty, "IS-IS paths to level-%d routers %s\n", - spftree->level, tree_id_text); + vty_out(vty, "IS-IS paths to level-%d routers %s\n", spftree->level, tree_id_text); isis_print_paths(vty, &spftree->paths, spftree->sysid, json); if (!json) vty_out(vty, "\n"); } -static void show_isis_topology_common(struct vty *vty, int levels, - struct isis *isis, uint8_t algo, +static void show_isis_topology_common(struct vty *vty, int levels, struct isis *isis, uint8_t algo, json_object **json) { #ifndef FABRICD @@ -2385,18 +2183,17 @@ static void show_isis_topology_common(struct vty *vty, int levels, struct flex_algo *fa; #endif /* ifndef FABRICD */ struct isis_spftree *spftree; - struct listnode *node; struct isis_area *area; json_object *json_level = NULL, *jstr = NULL, *json_val; char key[18]; - if (!isis->area_list || isis->area_list->count == 0) + if (isis_area_list_count(&isis->area_list) == 0) return; if (json) *json = json_object_new_object(); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { #ifndef FABRICD /* * The shapes of the flex algo spftree 2-dimensional array @@ -2414,13 +2211,11 @@ static void show_isis_topology_common(struct vty *vty, int levels, #endif /* ifndef FABRICD */ if (json) { - jstr = json_object_new_string( - area->area_tag ? area->area_tag : "null"); + 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"); + vty_out(vty, "Area %s:", area->area_tag ? area->area_tag : "null"); #ifndef FABRICD if (algo != SR_ALGORITHM_SPF) @@ -2436,9 +2231,8 @@ static void show_isis_topology_common(struct vty *vty, int levels, if (json) { json_level = json_object_new_object(); - jstr = json_object_new_string( - area->area_tag ? area->area_tag - : "null"); + jstr = json_object_new_string(area->area_tag ? area->area_tag + : "null"); json_object_object_add(json_level, "area", jstr); } @@ -2446,55 +2240,38 @@ static void show_isis_topology_common(struct vty *vty, int levels, json_val = NULL; #ifndef FABRICD if (fa_data) - spftree = fa_data->spftree[SPFTREE_IPV4] - [level - 1]; + spftree = fa_data->spftree[SPFTREE_IPV4][level - 1]; else #endif /* ifndef FABRICD */ - spftree = area->spftree[SPFTREE_IPV4] - [level - 1]; + spftree = area->spftree[SPFTREE_IPV4][level - 1]; - isis_print_spftree(vty, spftree, - json ? &json_val : NULL); - if (json && json_val) { - json_object_object_add(json_level, - "ipv4-paths", - json_val); - } + isis_print_spftree(vty, spftree, json ? &json_val : NULL); + if (json && json_val) + json_object_object_add(json_level, "ipv4-paths", json_val); } if (area->ipv6_circuits > 0) { json_val = NULL; #ifndef FABRICD if (fa_data) - spftree = fa_data->spftree[SPFTREE_IPV6] - [level - 1]; + spftree = fa_data->spftree[SPFTREE_IPV6][level - 1]; else #endif /* ifndef FABRICD */ - spftree = area->spftree[SPFTREE_IPV6] - [level - 1]; - isis_print_spftree(vty, spftree, - json ? &json_val : NULL); - if (json && json_val) { - json_object_object_add(json_level, - "ipv6-paths", - json_val); - } + spftree = area->spftree[SPFTREE_IPV6][level - 1]; + isis_print_spftree(vty, spftree, json ? &json_val : NULL); + if (json && json_val) + json_object_object_add(json_level, "ipv6-paths", json_val); } if (isis_area_ipv6_dstsrc_enabled(area)) { json_val = NULL; #ifndef FABRICD if (fa_data) - spftree = - fa_data->spftree[SPFTREE_DSTSRC] - [level - 1]; + spftree = fa_data->spftree[SPFTREE_DSTSRC][level - 1]; else #endif /* ifndef FABRICD */ - spftree = area->spftree[SPFTREE_DSTSRC] - [level - 1]; - isis_print_spftree(vty, spftree, - json ? &json_val : NULL); + spftree = area->spftree[SPFTREE_DSTSRC][level - 1]; + isis_print_spftree(vty, spftree, json ? &json_val : NULL); if (json && json_val) { - json_object_object_add(json_level, - "ipv6-dstsrc-paths", + json_object_object_add(json_level, "ipv6-dstsrc-paths", json_val); } } @@ -2507,14 +2284,11 @@ static void show_isis_topology_common(struct vty *vty, int levels, if (fabricd_spftree(area)) { json_val = NULL; - vty_out(vty, - "IS-IS paths to level-2 routers with hop-by-hop metric\n"); - isis_print_paths(vty, &fabricd_spftree(area)->paths, - isis->sysid, json ? &json_val : NULL); + vty_out(vty, "IS-IS paths to level-2 routers with hop-by-hop metric\n"); + isis_print_paths(vty, &fabricd_spftree(area)->paths, isis->sysid, + json ? &json_val : NULL); if (json && json_val) - json_object_object_add(json_level, - "fabricd-paths", - json_val); + json_object_object_add(json_level, "fabricd-paths", json_val); else vty_out(vty, "\n"); } @@ -2545,7 +2319,6 @@ DEFUN(show_isis_topology, show_isis_topology_cmd, ) { int levels = ISIS_LEVELS; - struct listnode *node; struct isis *isis = NULL; const char *vrf_name = VRF_DEFAULT_NAME; bool all_vrf = false; @@ -2581,25 +2354,20 @@ DEFUN(show_isis_topology, show_isis_topology_cmd, json = json_object_new_array(); if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { + frr_each (isis_instance_list, &im->isis, isis) { if (all_algorithm) { for (algorithm = SR_ALGORITHM_FLEX_MIN; - algorithm <= SR_ALGORITHM_FLEX_MAX; - algorithm++) - show_isis_topology_common(vty, levels, - isis, + algorithm <= SR_ALGORITHM_FLEX_MAX; algorithm++) + show_isis_topology_common(vty, levels, isis, (uint8_t)algorithm, - uj ? &json_vrf - : NULL); + uj ? &json_vrf : NULL); } else { - show_isis_topology_common(vty, levels, isis, - (uint8_t)algorithm, + show_isis_topology_common(vty, levels, isis, (uint8_t)algorithm, uj ? &json_vrf : NULL); } if (uj) { json_object_object_add(json_vrf, "vrf_id", - json_object_new_int( - isis->vrf_id)); + json_object_new_int(isis->vrf_id)); json_object_array_add(json, json_vrf); } } @@ -2609,25 +2377,21 @@ DEFUN(show_isis_topology, show_isis_topology_cmd, 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, + for (algorithm = SR_ALGORITHM_FLEX_MIN; algorithm <= SR_ALGORITHM_FLEX_MAX; + algorithm++) { + show_isis_topology_common(vty, levels, isis, (uint8_t)algorithm, uj ? &json_vrf : NULL); } } else show_isis_topology_common(vty, levels, isis, (uint8_t)algorithm, uj ? &json_vrf : NULL); if (uj) { - json_object_object_add(json_vrf, "vrf_id", - json_object_new_int(isis->vrf_id)); + json_object_object_add(json_vrf, "vrf_id", json_object_new_int(isis->vrf_id)); json_object_array_add(json, json_vrf); } out: if (uj) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext(json, - JSON_C_TO_STRING_PRETTY)); + vty_out(vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } @@ -2635,38 +2399,34 @@ DEFUN(show_isis_topology, show_isis_topology_cmd, } #ifndef FABRICD -static void show_isis_flex_algo_display_eag(struct vty *vty, char *buf, - int indent, +static void show_isis_flex_algo_display_eag(struct vty *vty, char *buf, int indent, struct admin_group *admin_group) { if (admin_group_zero(admin_group)) vty_out(vty, "not-set\n"); else { vty_out(vty, "%s\n", - admin_group_string(buf, ADMIN_GROUP_PRINT_MAX_SIZE, - indent, admin_group)); + admin_group_string(buf, ADMIN_GROUP_PRINT_MAX_SIZE, indent, admin_group)); admin_group_print(buf, indent, admin_group); if (buf[0] != '\0') vty_out(vty, " Bit positions: %s\n", buf); } } -static void show_isis_flex_algo_common(struct vty *vty, struct isis *isis, - uint8_t algorithm) +static void show_isis_flex_algo_common(struct vty *vty, struct isis *isis, uint8_t algorithm) { struct isis_router_cap_fad *router_fad; char buf[ADMIN_GROUP_PRINT_MAX_SIZE]; struct admin_group *admin_group; struct isis_area *area; - struct listnode *node; struct flex_algo *fa; int indent, algo; bool fad_identical, fad_supported; - if (!isis->area_list || isis->area_list->count == 0) + if (isis_area_list_count(&isis->area_list) == 0) return; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { /* * The shapes of the flex algo spftree 2-dimensional array * and the area spftree 2-dimensional array are not guaranteed @@ -2674,16 +2434,14 @@ static void show_isis_flex_algo_common(struct vty *vty, struct isis *isis, */ for (algo = 0; algo < SR_ALGORITHM_COUNT; algo++) { - if (algorithm != SR_ALGORITHM_UNSET && - algorithm != algo) + if (algorithm != SR_ALGORITHM_UNSET && algorithm != algo) continue; fa = flex_algo_lookup(area->flex_algos, algo); if (!fa) continue; - vty_out(vty, "Area %s:", - area->area_tag ? area->area_tag : "null"); + vty_out(vty, "Area %s:", area->area_tag ? area->area_tag : "null"); vty_out(vty, " Algorithm %d\n", algo); vty_out(vty, "\n"); @@ -2703,11 +2461,9 @@ static void show_isis_flex_algo_common(struct vty *vty, struct isis *isis, router_fad = isis_flex_algo_elected(algo, area); - vty_out(vty, - " Elected and running Flexible-Algorithm Definition:\n"); + vty_out(vty, " Elected and running Flexible-Algorithm Definition:\n"); if (router_fad) - vty_out(vty, " Source: %pSY\n", - router_fad->sysid); + vty_out(vty, " Source: %pSY\n", router_fad->sysid); else vty_out(vty, " Source: Not found\n"); @@ -2716,57 +2472,42 @@ static void show_isis_flex_algo_common(struct vty *vty, struct isis *isis, continue; } - fad_identical = - flex_algo_definition_cmp(fa, &router_fad->fad); - fad_supported = - isis_flex_algo_supported(&router_fad->fad); - vty_out(vty, " Priority: %d\n", - router_fad->fad.priority); - vty_out(vty, " Equal to local: %s\n", - fad_identical ? "yes" : "no"); + fad_identical = flex_algo_definition_cmp(fa, &router_fad->fad); + fad_supported = isis_flex_algo_supported(&router_fad->fad); + vty_out(vty, " Priority: %d\n", router_fad->fad.priority); + vty_out(vty, " Equal to local: %s\n", fad_identical ? "yes" : "no"); vty_out(vty, " Local state: %s\n", - fad_supported - ? "enabled" - : "disabled (unsupported definition)"); + fad_supported ? "enabled" : "disabled (unsupported definition)"); vty_out(vty, " Calculation type: "); if (router_fad->fad.calc_type == 0) vty_out(vty, "spf\n"); else vty_out(vty, "%d\n", router_fad->fad.calc_type); vty_out(vty, " Metric type: %s\n", - flex_algo_metric_type_print( - buf, sizeof(buf), - router_fad->fad.metric_type)); + flex_algo_metric_type_print(buf, sizeof(buf), + router_fad->fad.metric_type)); vty_out(vty, " Prefix-metric: %s\n", - CHECK_FLAG(router_fad->fad.flags, FAD_FLAG_M) - ? "enabled" - : "disabled"); - if (router_fad->fad.flags != 0 && - router_fad->fad.flags != FAD_FLAG_M) - vty_out(vty, " Flags: 0x%x\n", - router_fad->fad.flags); + CHECK_FLAG(router_fad->fad.flags, FAD_FLAG_M) ? "enabled" + : "disabled"); + if (router_fad->fad.flags != 0 && router_fad->fad.flags != FAD_FLAG_M) + vty_out(vty, " Flags: 0x%x\n", router_fad->fad.flags); vty_out(vty, " Exclude SRLG: %s\n", - router_fad->fad.exclude_srlg ? "enabled" - : "disabled"); + router_fad->fad.exclude_srlg ? "enabled" : "disabled"); admin_group = &router_fad->fad.admin_group_exclude_any; indent = vty_out(vty, " Exclude-any admin-group: "); - show_isis_flex_algo_display_eag(vty, buf, indent, - admin_group); + show_isis_flex_algo_display_eag(vty, buf, indent, admin_group); admin_group = &router_fad->fad.admin_group_include_all; indent = vty_out(vty, " Include-all admin-group: "); - show_isis_flex_algo_display_eag(vty, buf, indent, - admin_group); + show_isis_flex_algo_display_eag(vty, buf, indent, admin_group); admin_group = &router_fad->fad.admin_group_include_any; indent = vty_out(vty, " Include-any admin-group: "); - show_isis_flex_algo_display_eag(vty, buf, indent, - admin_group); + show_isis_flex_algo_display_eag(vty, buf, indent, admin_group); if (router_fad->fad.unsupported_subtlv) - vty_out(vty, - " Unsupported sub-TLV: Present (see logs)"); + vty_out(vty, " Unsupported sub-TLV: Present (see logs)"); vty_out(vty, "\n"); } @@ -2783,7 +2524,6 @@ DEFUN(show_isis_flex_algo, show_isis_flex_algo_cmd, "Algorithm number\n") { struct isis *isis; - struct listnode *node; const char *vrf_name = VRF_DEFAULT_NAME; bool all_vrf = false; int idx = 0; @@ -2803,7 +2543,7 @@ DEFUN(show_isis_flex_algo, show_isis_flex_algo_cmd, ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) + frr_each (isis_instance_list, &im->isis, isis) show_isis_flex_algo_common(vty, isis, flex_algo); return CMD_SUCCESS; } @@ -2816,8 +2556,8 @@ DEFUN(show_isis_flex_algo, show_isis_flex_algo_cmd, #endif /* ifndef FABRICD */ static void isis_print_route(struct ttable *tt, const struct prefix *prefix, - struct isis_route_info *rinfo, bool prefix_sid, - bool no_adjacencies, bool json) + struct isis_route_info *rinfo, bool prefix_sid, bool no_adjacencies, + bool json) { struct isis_nexthop *nexthop; struct listnode *node; @@ -2826,27 +2566,22 @@ static void isis_print_route(struct ttable *tt, const struct prefix *prefix, (void)prefix2str(prefix, buf_prefix, sizeof(buf_prefix)); for (int alg = 0; alg < SR_ALGORITHM_COUNT; alg++) { - for (ALL_LIST_ELEMENTS_RO(rinfo->sr_algo[alg].nexthops, node, - nexthop)) { + for (ALL_LIST_ELEMENTS_RO(rinfo->sr_algo[alg].nexthops, node, nexthop)) { struct interface *ifp; char buf_iface[BUFSIZ]; char buf_nhop[BUFSIZ]; if (!no_adjacencies) { - inet_ntop(nexthop->family, &nexthop->ip, - buf_nhop, sizeof(buf_nhop)); - ifp = if_lookup_by_index(nexthop->ifindex, - VRF_DEFAULT); + inet_ntop(nexthop->family, &nexthop->ip, buf_nhop, + sizeof(buf_nhop)); + ifp = if_lookup_by_index(nexthop->ifindex, VRF_DEFAULT); if (ifp) - strlcpy(buf_iface, ifp->name, - sizeof(buf_iface)); + strlcpy(buf_iface, ifp->name, sizeof(buf_iface)); else - snprintf(buf_iface, sizeof(buf_iface), - "ifindex %u", + snprintf(buf_iface, sizeof(buf_iface), "ifindex %u", nexthop->ifindex); } else { - strlcpy(buf_nhop, - print_sys_hostname(nexthop->sysid), + strlcpy(buf_nhop, print_sys_hostname(nexthop->sysid), sizeof(buf_nhop)); strlcpy(buf_iface, "-", sizeof(buf_iface)); } @@ -2859,64 +2594,49 @@ static void isis_print_route(struct ttable *tt, const struct prefix *prefix, snprintf(buf_sid, sizeof(buf_sid), "%u", rinfo->sr_algo[alg].sid.value); sr_op2str(buf_lblop, sizeof(buf_lblop), - rinfo->sr_algo[alg].label, - nexthop->sr.label); + rinfo->sr_algo[alg].label, nexthop->sr.label); } else if (alg == SR_ALGORITHM_SPF) { strlcpy(buf_sid, "-", sizeof(buf_sid)); - strlcpy(buf_lblop, "-", - sizeof(buf_lblop)); + strlcpy(buf_lblop, "-", sizeof(buf_lblop)); } else { continue; } if (first || json) { - ttable_add_row(tt, - "%s|%u|%s|%s|%s|%s|%d", - buf_prefix, rinfo->cost, - buf_iface, buf_nhop, - buf_sid, buf_lblop, alg); + ttable_add_row(tt, "%s|%u|%s|%s|%s|%s|%d", buf_prefix, + rinfo->cost, buf_iface, buf_nhop, buf_sid, + buf_lblop, alg); first = false; } else - ttable_add_row(tt, "||%s|%s|%s|%s|%d", - buf_iface, buf_nhop, + ttable_add_row(tt, "||%s|%s|%s|%s|%d", buf_iface, buf_nhop, buf_sid, buf_lblop, alg); } else { char buf_labels[BUFSIZ] = {}; if (nexthop->label_stack) { - for (int i = 0; - i < - nexthop->label_stack->num_labels; - i++) { + for (int i = 0; i < nexthop->label_stack->num_labels; i++) { char buf_label[BUFSIZ]; - label2str(nexthop->label_stack - ->label[i], - 0, buf_label, - sizeof(buf_label)); + label2str(nexthop->label_stack->label[i], 0, + buf_label, sizeof(buf_label)); if (i != 0) strlcat(buf_labels, "/", sizeof(buf_labels)); - strlcat(buf_labels, buf_label, - sizeof(buf_labels)); + strlcat(buf_labels, buf_label, sizeof(buf_labels)); } } else if (nexthop->sr.present) - label2str(nexthop->sr.label, 0, - buf_labels, + label2str(nexthop->sr.label, 0, buf_labels, sizeof(buf_labels)); else - strlcpy(buf_labels, "-", - sizeof(buf_labels)); + strlcpy(buf_labels, "-", sizeof(buf_labels)); if (first || json) { - ttable_add_row(tt, "%s|%u|%s|%s|%s", - buf_prefix, rinfo->cost, - buf_iface, buf_nhop, + ttable_add_row(tt, "%s|%u|%s|%s|%s", buf_prefix, + rinfo->cost, buf_iface, buf_nhop, buf_labels); first = false; } else - ttable_add_row(tt, "||%s|%s|%s", - buf_iface, buf_nhop, + ttable_add_row(tt, "||%s|%s|%s", buf_iface, buf_nhop, buf_labels); } } @@ -2929,28 +2649,25 @@ static void isis_print_route(struct ttable *tt, const struct prefix *prefix, if (rinfo->sr_algo[SR_ALGORITHM_SPF].present) { snprintf(buf_sid, sizeof(buf_sid), "%u", - rinfo->sr_algo[SR_ALGORITHM_SPF] - .sid.value); - sr_op2str( - buf_lblop, sizeof(buf_lblop), - rinfo->sr_algo[SR_ALGORITHM_SPF].label, - MPLS_LABEL_IMPLICIT_NULL); + rinfo->sr_algo[SR_ALGORITHM_SPF].sid.value); + sr_op2str(buf_lblop, sizeof(buf_lblop), + rinfo->sr_algo[SR_ALGORITHM_SPF].label, + MPLS_LABEL_IMPLICIT_NULL); } else { strlcpy(buf_sid, "-", sizeof(buf_sid)); strlcpy(buf_lblop, "-", sizeof(buf_lblop)); } - ttable_add_row(tt, "%s|%u|%s|%s|%s|%s", buf_prefix, - rinfo->cost, "-", "-", buf_sid, - buf_lblop); + ttable_add_row(tt, "%s|%u|%s|%s|%s|%s", buf_prefix, rinfo->cost, "-", "-", + buf_sid, buf_lblop); } else - ttable_add_row(tt, "%s|%u|%s|%s|%s", buf_prefix, - rinfo->cost, "-", "-", "-"); + ttable_add_row(tt, "%s|%u|%s|%s|%s", buf_prefix, rinfo->cost, "-", "-", + "-"); } } -void isis_print_routes(struct vty *vty, struct isis_spftree *spftree, - struct json_object **json, bool prefix_sid, bool backup) +void isis_print_routes(struct vty *vty, struct isis_spftree *spftree, struct json_object **json, + bool prefix_sid, bool backup) { struct route_table *route_table; struct ttable *tt; @@ -2977,15 +2694,13 @@ void isis_print_routes(struct vty *vty, struct isis_spftree *spftree, } if (json == NULL) - vty_out(vty, "IS-IS %s %s routing table:\n\n", - circuit_t2string(spftree->level), tree_id_text); + vty_out(vty, "IS-IS %s %s routing table:\n\n", circuit_t2string(spftree->level), + tree_id_text); /* Prepare table. */ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); if (prefix_sid) - ttable_add_row( - tt, - "Prefix|Metric|Interface|Nexthop|SID|Label Op.|Algo"); + ttable_add_row(tt, "Prefix|Metric|Interface|Nexthop|SID|Label Op.|Algo"); else ttable_add_row(tt, "Prefix|Metric|Interface|Nexthop|Label(s)"); tt->style.cell.rpad = 2; @@ -2996,8 +2711,7 @@ void isis_print_routes(struct vty *vty, struct isis_spftree *spftree, if (CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES)) no_adjacencies = true; - route_table = - (backup) ? spftree->route_table_backup : spftree->route_table; + route_table = (backup) ? spftree->route_table_backup : spftree->route_table; for (rn = route_top(route_table); rn; rn = route_next(rn)) { struct isis_route_info *rinfo; @@ -3005,8 +2719,7 @@ void isis_print_routes(struct vty *vty, struct isis_spftree *spftree, if (!rinfo) continue; - isis_print_route(tt, &rn->p, rinfo, prefix_sid, no_adjacencies, - json != NULL); + isis_print_route(tt, &rn->p, rinfo, prefix_sid, no_adjacencies, json != NULL); } /* Dump the generated table. */ @@ -3026,10 +2739,8 @@ void isis_print_routes(struct vty *vty, struct isis_spftree *spftree, ttable_del(tt); } -static void show_isis_route_common(struct vty *vty, int levels, - struct isis *isis, bool prefix_sid, - bool backup, uint8_t algo, - json_object **json) +static void show_isis_route_common(struct vty *vty, int levels, struct isis *isis, bool prefix_sid, + bool backup, uint8_t algo, json_object **json) { json_object *json_level = NULL, *jstr = NULL, *json_val; #ifndef FABRICD @@ -3037,17 +2748,16 @@ static void show_isis_route_common(struct vty *vty, int levels, struct flex_algo *fa; #endif /* ifndef FABRICD */ struct isis_spftree *spftree; - struct listnode *node; struct isis_area *area; char key[18]; - if (!isis->area_list || isis->area_list->count == 0) + if (isis_area_list_count(&isis->area_list) == 0) return; if (json) *json = json_object_new_object(); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { #ifndef FABRICD /* * The shapes of the flex algo spftree 2-dimensional array @@ -3066,13 +2776,11 @@ static void show_isis_route_common(struct vty *vty, int levels, #endif /* ifndef FABRICD */ if (json) { - jstr = json_object_new_string( - area->area_tag ? area->area_tag : "null"); + 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"); + 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); @@ -3087,97 +2795,70 @@ static void show_isis_route_common(struct vty *vty, int levels, if (json) { json_level = json_object_new_object(); - jstr = json_object_new_string( - area->area_tag ? area->area_tag - : "null"); - json_object_object_add(json_level, "area", - jstr); + jstr = json_object_new_string(area->area_tag ? area->area_tag + : "null"); + json_object_object_add(json_level, "area", jstr); } if (area->ip_circuits > 0) { json_val = NULL; #ifndef FABRICD if (fa_data) - spftree = fa_data->spftree[SPFTREE_IPV4] - [level - 1]; + spftree = fa_data->spftree[SPFTREE_IPV4][level - 1]; else #endif /* ifndef FABRICD */ - spftree = area->spftree[SPFTREE_IPV4] - [level - 1]; + spftree = area->spftree[SPFTREE_IPV4][level - 1]; - isis_print_spftree(vty, spftree, - json ? &json_val : NULL); + isis_print_spftree(vty, spftree, json ? &json_val : NULL); if (json && json_val) { - json_object_object_add(json_level, - "ipv4-paths", - json_val); + json_object_object_add(json_level, "ipv4-paths", json_val); json_val = NULL; } - isis_print_routes(vty, spftree, - json ? &json_val : NULL, + isis_print_routes(vty, spftree, json ? &json_val : NULL, prefix_sid, backup); - if (json && json_val) { - json_object_object_add( - json_level, "ipv4", json_val); - } + if (json && json_val) + json_object_object_add(json_level, "ipv4", json_val); } if (area->ipv6_circuits > 0) { json_val = NULL; #ifndef FABRICD if (fa_data) - spftree = fa_data->spftree[SPFTREE_IPV6] - [level - 1]; + spftree = fa_data->spftree[SPFTREE_IPV6][level - 1]; else #endif /* ifndef FABRICD */ - spftree = area->spftree[SPFTREE_IPV6] - [level - 1]; + spftree = area->spftree[SPFTREE_IPV6][level - 1]; - isis_print_spftree(vty, spftree, - json ? &json_val : NULL); + isis_print_spftree(vty, spftree, json ? &json_val : NULL); if (json && json_val) { - json_object_object_add(json_level, - "ipv6-paths", - json_val); + json_object_object_add(json_level, "ipv6-paths", json_val); json_val = NULL; } - isis_print_routes(vty, spftree, - json ? &json_val : NULL, + isis_print_routes(vty, spftree, json ? &json_val : NULL, prefix_sid, backup); - if (json && json_val) { - json_object_object_add( - json_level, "ipv6", json_val); - } + if (json && json_val) + json_object_object_add(json_level, "ipv6", json_val); } if (isis_area_ipv6_dstsrc_enabled(area)) { json_val = NULL; #ifndef FABRICD if (fa_data) - spftree = - fa_data->spftree[SPFTREE_DSTSRC] - [level - 1]; + spftree = fa_data->spftree[SPFTREE_DSTSRC][level - 1]; else #endif /* ifndef FABRICD */ - spftree = area->spftree[SPFTREE_DSTSRC] - [level - 1]; + spftree = area->spftree[SPFTREE_DSTSRC][level - 1]; - isis_print_spftree(vty, spftree, - json ? &json_val : NULL); + isis_print_spftree(vty, spftree, json ? &json_val : NULL); if (json && json_val) { - json_object_object_add(json_level, - "ipv6-dstsrc-paths", + json_object_object_add(json_level, "ipv6-dstsrc-paths", json_val); json_val = NULL; } - isis_print_routes(vty, spftree, - json ? &json_val : NULL, + isis_print_routes(vty, spftree, json ? &json_val : NULL, prefix_sid, backup); - if (json && json_val) { - json_object_object_add(json_level, - "ipv6-dstsrc", - json_val); - } + if (json && json_val) + json_object_object_add(json_level, "ipv6-dstsrc", json_val); } if (json) { snprintf(key, sizeof(key), "level-%d", level); @@ -3187,9 +2868,8 @@ 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) +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; @@ -3200,18 +2880,16 @@ static void show_isis_route_all_algos(struct vty *vty, int levels, 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); + 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_object_add(json_algo, "algorithm", json_object_new_int(algo)); json_object_array_add(json_algos, json_algo); } @@ -3247,7 +2925,6 @@ DEFUN(show_isis_route, show_isis_route_cmd, { int levels; struct isis *isis; - struct listnode *node; const char *vrf_name = VRF_DEFAULT_NAME; bool all_vrf = false; bool all_algorithm = false; @@ -3289,20 +2966,16 @@ DEFUN(show_isis_route, show_isis_route_cmd, json = json_object_new_array(); if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { + frr_each (isis_instance_list, &im->isis, isis) { if (all_algorithm) - show_isis_route_all_algos(vty, levels, isis, - prefix_sid, backup, + 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); + 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_new_int(isis->vrf_id)); json_object_array_add(json, json_vrf); } } @@ -3311,11 +2984,10 @@ DEFUN(show_isis_route, show_isis_route_cmd, 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); + 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, + 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", @@ -3326,17 +2998,14 @@ DEFUN(show_isis_route, show_isis_route_cmd, out: if (uj) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); + vty_out(vty, "%s\n", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } return CMD_SUCCESS; } -static void isis_print_frr_summary_line(struct ttable *tt, - const char *protection, +static void isis_print_frr_summary_line(struct ttable *tt, const char *protection, uint32_t counters[SPF_PREFIX_PRIO_MAX]) { uint32_t critical, high, medium, low, total; @@ -3347,14 +3016,11 @@ static void isis_print_frr_summary_line(struct ttable *tt, low = counters[SPF_PREFIX_PRIO_LOW]; total = critical + high + medium + low; - ttable_add_row(tt, "%s|%u|%u|%u|%u|%u", protection, critical, high, - medium, low, total); + ttable_add_row(tt, "%s|%u|%u|%u|%u|%u", protection, critical, high, medium, low, total); } -static void -isis_print_frr_summary_line_coverage(struct ttable *tt, const char *protection, - double counters[SPF_PREFIX_PRIO_MAX], - double total) +static void isis_print_frr_summary_line_coverage(struct ttable *tt, const char *protection, + double counters[SPF_PREFIX_PRIO_MAX], double total) { double critical, high, medium, low; @@ -3364,19 +3030,18 @@ isis_print_frr_summary_line_coverage(struct ttable *tt, const char *protection, low = counters[SPF_PREFIX_PRIO_LOW] * 100; total *= 100; - ttable_add_row(tt, "%s|%.2f%%|%.2f%%|%.2f%%|%.2f%%|%.2f%%", protection, - critical, high, medium, low, total); + ttable_add_row(tt, "%s|%.2f%%|%.2f%%|%.2f%%|%.2f%%|%.2f%%", protection, critical, high, + medium, low, total); } -static void isis_print_frr_summary(struct vty *vty, - struct isis_spftree *spftree) +static void isis_print_frr_summary(struct vty *vty, struct isis_spftree *spftree) { struct ttable *tt; char *table; const char *tree_id_text = NULL; - uint32_t protectd[SPF_PREFIX_PRIO_MAX] = {0}; - uint32_t unprotected[SPF_PREFIX_PRIO_MAX] = {0}; - double coverage[SPF_PREFIX_PRIO_MAX] = {0}; + uint32_t protectd[SPF_PREFIX_PRIO_MAX] = { 0 }; + uint32_t unprotected[SPF_PREFIX_PRIO_MAX] = { 0 }; + double coverage[SPF_PREFIX_PRIO_MAX] = { 0 }; uint32_t protected_total = 0, grand_total = 0; double coverage_total; @@ -3398,30 +3063,27 @@ static void isis_print_frr_summary(struct vty *vty, return; } - vty_out(vty, " IS-IS %s %s Fast ReRoute summary:\n\n", - circuit_t2string(spftree->level), tree_id_text); + vty_out(vty, " IS-IS %s %s Fast ReRoute summary:\n\n", circuit_t2string(spftree->level), + tree_id_text); /* Prepare table. */ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); - ttable_add_row( - tt, - "Protection \\ Priority|Critical|High |Medium |Low |Total"); + ttable_add_row(tt, "Protection \\ Priority|Critical|High |Medium |Low |Total"); tt->style.cell.rpad = 2; tt->style.corner = '+'; ttable_restyle(tt); ttable_rowseps(tt, 0, BOTTOM, true, '-'); /* Compute unprotected and coverage totals. */ - for (int priority = SPF_PREFIX_PRIO_CRITICAL; - priority < SPF_PREFIX_PRIO_MAX; priority++) { + for (int priority = SPF_PREFIX_PRIO_CRITICAL; priority < SPF_PREFIX_PRIO_MAX; priority++) { uint32_t *lfa = spftree->lfa.protection_counters.lfa; uint32_t *rlfa = spftree->lfa.protection_counters.rlfa; uint32_t *tilfa = spftree->lfa.protection_counters.tilfa; uint32_t *ecmp = spftree->lfa.protection_counters.ecmp; uint32_t *total = spftree->lfa.protection_counters.total; - protectd[priority] = lfa[priority] + rlfa[priority] - + tilfa[priority] + ecmp[priority]; + protectd[priority] = lfa[priority] + rlfa[priority] + tilfa[priority] + + ecmp[priority]; /* Safeguard to protect against possible inconsistencies. */ if (protectd[priority] > total[priority]) protectd[priority] = total[priority]; @@ -3432,8 +3094,7 @@ static void isis_print_frr_summary(struct vty *vty, if (!total[priority]) coverage[priority] = 0; else - coverage[priority] = - protectd[priority] / (double)total[priority]; + coverage[priority] = protectd[priority] / (double)total[priority]; } if (!grand_total) @@ -3442,17 +3103,13 @@ static void isis_print_frr_summary(struct vty *vty, coverage_total = protected_total / (double)grand_total; /* Add rows. */ - isis_print_frr_summary_line(tt, "Classic LFA", - spftree->lfa.protection_counters.lfa); - isis_print_frr_summary_line(tt, "Remote LFA", - spftree->lfa.protection_counters.rlfa); + isis_print_frr_summary_line(tt, "Classic LFA", spftree->lfa.protection_counters.lfa); + isis_print_frr_summary_line(tt, "Remote LFA", spftree->lfa.protection_counters.rlfa); isis_print_frr_summary_line(tt, "Topology Independent LFA", spftree->lfa.protection_counters.tilfa); - isis_print_frr_summary_line(tt, "ECMP", - spftree->lfa.protection_counters.ecmp); + isis_print_frr_summary_line(tt, "ECMP", spftree->lfa.protection_counters.ecmp); isis_print_frr_summary_line(tt, "Unprotected", unprotected); - isis_print_frr_summary_line_coverage(tt, "Protection coverage", - coverage, coverage_total); + isis_print_frr_summary_line_coverage(tt, "Protection coverage", coverage, coverage_total); /* Dump the generated table. */ table = ttable_dump(tt, "\n"); @@ -3461,38 +3118,27 @@ static void isis_print_frr_summary(struct vty *vty, ttable_del(tt); } -static void show_isis_frr_summary_common(struct vty *vty, int levels, - struct isis *isis) +static void show_isis_frr_summary_common(struct vty *vty, int levels, struct isis *isis) { - struct listnode *node; struct isis_area *area; - if (!isis->area_list || isis->area_list->count == 0) + if (isis_area_list_count(&isis->area_list) == 0) return; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { - vty_out(vty, "Area %s:\n", - area->area_tag ? area->area_tag : "null"); + frr_each (isis_area_list, &isis->area_list, area) { + vty_out(vty, "Area %s:\n", area->area_tag ? area->area_tag : "null"); for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { if ((level & levels) == 0) continue; - if (area->ip_circuits > 0) { - isis_print_frr_summary( - vty, - area->spftree[SPFTREE_IPV4][level - 1]); - } - if (area->ipv6_circuits > 0) { - isis_print_frr_summary( - vty, - area->spftree[SPFTREE_IPV6][level - 1]); - } - if (isis_area_ipv6_dstsrc_enabled(area)) { - isis_print_frr_summary( - vty, area->spftree[SPFTREE_DSTSRC] - [level - 1]); - } + if (area->ip_circuits > 0) + isis_print_frr_summary(vty, area->spftree[SPFTREE_IPV4][level - 1]); + if (area->ipv6_circuits > 0) + isis_print_frr_summary(vty, area->spftree[SPFTREE_IPV6][level - 1]); + if (isis_area_ipv6_dstsrc_enabled(area)) + isis_print_frr_summary(vty, + area->spftree[SPFTREE_DSTSRC][level - 1]); } } } @@ -3515,7 +3161,6 @@ DEFUN(show_isis_frr_summary, show_isis_frr_summary_cmd, { int levels; struct isis *isis; - struct listnode *node; const char *vrf_name = VRF_DEFAULT_NAME; bool all_vrf = false; int idx = 0; @@ -3534,7 +3179,7 @@ DEFUN(show_isis_frr_summary, show_isis_frr_summary_cmd, } if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) + frr_each (isis_instance_list, &im->isis, isis) show_isis_frr_summary_common(vty, levels, isis); return CMD_SUCCESS; } @@ -3566,8 +3211,7 @@ void isis_spf_print(struct isis_spftree *spftree, struct vty *vty) vty_out_timestr(vty, spftree->last_run_timestamp); vty_out(vty, "\n"); - vty_out(vty, " last run duration : %" PRIu64 " usec\n", - last_run_duration); + vty_out(vty, " last run duration : %" PRIu64 " usec\n", last_run_duration); vty_out(vty, " run count : %u\n", spftree->runcount); } @@ -3579,7 +3223,6 @@ void isis_spf_print_json(struct isis_spftree *spftree, struct json_object *json) cur -= spftree->last_run_timestamp; frrtime_to_interval(cur, uptime, sizeof(uptime)); json_object_string_add(json, "last-run-elapsed", uptime); - json_object_int_add(json, "last-run-duration-usec", - spftree->last_run_duration); + json_object_int_add(json, "last-run-duration-usec", spftree->last_run_duration); json_object_int_add(json, "last-run-count", spftree->runcount); } diff --git a/isisd/isis_spf_private.h b/isisd/isis_spf_private.h index 763673063cfa..fd09346c9d59 100644 --- a/isisd/isis_spf_private.h +++ b/isisd/isis_spf_private.h @@ -57,15 +57,15 @@ struct isis_vertex { enum spf_prefix_priority priority; } ip; } N; - uint32_t d_N; /* d(N) Distance from this IS */ - uint16_t depth; /* The depth in the imaginary tree */ - struct list *Adj_N; /* {Adj(N)} next hop or neighbor list */ - struct list *parents; /* list of parents for ECMP */ + uint32_t d_N; /* d(N) Distance from this IS */ + uint16_t depth; /* The depth in the imaginary tree */ + struct list *Adj_N; /* {Adj(N)} next hop or neighbor list */ + struct list *parents; /* list of parents for ECMP */ struct hash *firsthops; /* first two hops to neighbor */ uint64_t insert_counter; uint8_t flags; }; -#define F_ISIS_VERTEX_LFA_PROTECTED 0x01 +#define F_ISIS_VERTEX_LFA_PROTECTED 0x01 /* Vertex Queue and associated functions */ @@ -78,8 +78,7 @@ struct isis_vertex_queue { uint64_t insert_counter; }; -__attribute__((__unused__)) -static unsigned isis_vertex_queue_hash_key(const void *vp) +__attribute__((__unused__)) static unsigned isis_vertex_queue_hash_key(const void *vp) { const struct isis_vertex *vertex = vp; @@ -94,8 +93,7 @@ static unsigned isis_vertex_queue_hash_key(const void *vp) return jhash(vertex->N.id, ISIS_SYS_ID_LEN + 1, 0x55aa5a5a); } -__attribute__((__unused__)) -static bool isis_vertex_queue_hash_cmp(const void *a, const void *b) +__attribute__((__unused__)) static bool isis_vertex_queue_hash_cmp(const void *a, const void *b) { const struct isis_vertex *va = a, *vb = b; @@ -107,8 +105,7 @@ static bool isis_vertex_queue_hash_cmp(const void *a, const void *b) return false; return prefix_cmp((const struct prefix *)&va->N.ip.p.src, - (const struct prefix *)&vb->N.ip.p.src) - == 0; + (const struct prefix *)&vb->N.ip.p.src) == 0; } return memcmp(va->N.id, vb->N.id, ISIS_SYS_ID_LEN + 1) == 0; @@ -118,8 +115,7 @@ static bool isis_vertex_queue_hash_cmp(const void *a, const void *b) * Compares vertizes for sorting in the TENT list. Returns true * if candidate should be considered before current, false otherwise. */ -__attribute__((__unused__)) static int isis_vertex_queue_tent_cmp(const void *a, - const void *b) +__attribute__((__unused__)) static int isis_vertex_queue_tent_cmp(const void *a, const void *b) { const struct isis_vertex *va = a; const struct isis_vertex *vb = b; @@ -145,15 +141,13 @@ __attribute__((__unused__)) static int isis_vertex_queue_tent_cmp(const void *a, return 0; } -__attribute__((__unused__)) -static struct skiplist *isis_vertex_queue_skiplist(void) +__attribute__((__unused__)) static struct skiplist *isis_vertex_queue_skiplist(void) { return skiplist_new(0, isis_vertex_queue_tent_cmp, NULL); } -__attribute__((__unused__)) -static void isis_vertex_queue_init(struct isis_vertex_queue *queue, - const char *name, bool ordered) +__attribute__((__unused__)) static void isis_vertex_queue_init(struct isis_vertex_queue *queue, + const char *name, bool ordered) { if (ordered) { queue->insert_counter = 1; @@ -162,30 +156,26 @@ static void isis_vertex_queue_init(struct isis_vertex_queue *queue, queue->insert_counter = 0; queue->l.list = list_new(); } - queue->hash = hash_create(isis_vertex_queue_hash_key, - isis_vertex_queue_hash_cmp, name); + queue->hash = hash_create(isis_vertex_queue_hash_key, isis_vertex_queue_hash_cmp, name); } void isis_vertex_del(struct isis_vertex *vertex); -bool isis_vertex_adj_exists(const struct isis_spftree *spftree, - const struct isis_vertex *vertex, +bool isis_vertex_adj_exists(const struct isis_spftree *spftree, const struct isis_vertex *vertex, const struct isis_spf_adj *sadj); void isis_vertex_adj_free(void *arg); -struct isis_vertex_adj * -isis_vertex_adj_add(struct isis_spftree *spftree, struct isis_vertex *vertex, - struct list *vadj_list, struct isis_spf_adj *sadj, - struct isis_prefix_sid *psid, bool last_hop); +struct isis_vertex_adj *isis_vertex_adj_add(struct isis_spftree *spftree, + struct isis_vertex *vertex, struct list *vadj_list, + struct isis_spf_adj *sadj, + struct isis_prefix_sid *psid, bool last_hop); -__attribute__((__unused__)) -static void isis_vertex_queue_clear(struct isis_vertex_queue *queue) +__attribute__((__unused__)) static void isis_vertex_queue_clear(struct isis_vertex_queue *queue) { hash_clean(queue->hash, NULL); if (queue->insert_counter) { struct isis_vertex *vertex; - while (0 == skiplist_first(queue->l.slist, NULL, - (void **)&vertex)) { + while (0 == skiplist_first(queue->l.slist, NULL, (void **)&vertex)) { isis_vertex_del(vertex); skiplist_delete_first(queue->l.slist); } @@ -197,8 +187,7 @@ static void isis_vertex_queue_clear(struct isis_vertex_queue *queue) } } -__attribute__((__unused__)) -static void isis_vertex_queue_free(struct isis_vertex_queue *queue) +__attribute__((__unused__)) static void isis_vertex_queue_free(struct isis_vertex_queue *queue) { isis_vertex_queue_clear(queue); @@ -212,15 +201,14 @@ static void isis_vertex_queue_free(struct isis_vertex_queue *queue) list_delete(&queue->l.list); } -__attribute__((__unused__)) -static unsigned int isis_vertex_queue_count(struct isis_vertex_queue *queue) +__attribute__((__unused__)) static unsigned int +isis_vertex_queue_count(struct isis_vertex_queue *queue) { return hashcount(queue->hash); } -__attribute__((__unused__)) -static void isis_vertex_queue_append(struct isis_vertex_queue *queue, - struct isis_vertex *vertex) +__attribute__((__unused__)) static void isis_vertex_queue_append(struct isis_vertex_queue *queue, + struct isis_vertex *vertex) { assert(!queue->insert_counter); @@ -232,8 +220,8 @@ static void isis_vertex_queue_append(struct isis_vertex_queue *queue, assert(inserted == vertex); } -__attribute__((__unused__)) -static struct isis_vertex *isis_vertex_queue_last(struct isis_vertex_queue *queue) +__attribute__((__unused__)) static struct isis_vertex * +isis_vertex_queue_last(struct isis_vertex_queue *queue) { struct listnode *tail; @@ -243,9 +231,8 @@ static struct isis_vertex *isis_vertex_queue_last(struct isis_vertex_queue *queu return listgetdata(tail); } -__attribute__((__unused__)) -static void isis_vertex_queue_insert(struct isis_vertex_queue *queue, - struct isis_vertex *vertex) +__attribute__((__unused__)) static void isis_vertex_queue_insert(struct isis_vertex_queue *queue, + struct isis_vertex *vertex) { assert(queue->insert_counter); vertex->insert_counter = queue->insert_counter++; @@ -258,8 +245,7 @@ static void isis_vertex_queue_insert(struct isis_vertex_queue *queue, assert(inserted == vertex); } -__attribute__((__unused__)) -static struct isis_vertex * +__attribute__((__unused__)) static struct isis_vertex * isis_vertex_queue_pop(struct isis_vertex_queue *queue) { assert(queue->insert_counter); @@ -275,9 +261,8 @@ isis_vertex_queue_pop(struct isis_vertex_queue *queue) return rv; } -__attribute__((__unused__)) -static void isis_vertex_queue_delete(struct isis_vertex_queue *queue, - struct isis_vertex *vertex) +__attribute__((__unused__)) static void isis_vertex_queue_delete(struct isis_vertex_queue *queue, + struct isis_vertex *vertex) { assert(queue->insert_counter); @@ -285,8 +270,7 @@ static void isis_vertex_queue_delete(struct isis_vertex_queue *queue, hash_release(queue->hash, vertex); } -#define ALL_QUEUE_ELEMENTS_RO(queue, node, data) \ - ALL_LIST_ELEMENTS_RO((queue)->l.list, node, data) +#define ALL_QUEUE_ELEMENTS_RO(queue, node, data) ALL_LIST_ELEMENTS_RO((queue)->l.list, node, data) /* End of vertex queue definitions */ @@ -299,8 +283,8 @@ struct isis_spftree { struct hash *prefix_sids; /* SR Prefix-SIDs. */ struct list *sadj_list; struct isis_spf_nodes adj_nodes; - struct isis_area *area; /* back pointer to area */ - unsigned int runcount; /* number of runs since uptime */ + struct isis_area *area; /* back pointer to area */ + unsigned int runcount; /* number of runs since uptime */ time_t last_run_timestamp; /* last run timestamp as wall time for display */ time_t last_run_monotime; /* last run as monotime for scheduling */ time_t last_run_duration; /* last run duration in msec */ @@ -353,16 +337,15 @@ struct isis_spftree { uint8_t flags; }; #define F_SPFTREE_HOPCOUNT_METRIC 0x01 -#define F_SPFTREE_NO_ROUTES 0x02 -#define F_SPFTREE_NO_ADJACENCIES 0x04 +#define F_SPFTREE_NO_ROUTES 0x02 +#define F_SPFTREE_NO_ADJACENCIES 0x04 #ifndef FABRICD /* flex-algo */ #define F_SPFTREE_DISABLED 0x08 #endif /* ifndef FABRICD */ -__attribute__((__unused__)) -static void isis_vertex_id_init(struct isis_vertex *vertex, const void *id, - enum vertextype vtype) +__attribute__((__unused__)) static void isis_vertex_id_init(struct isis_vertex *vertex, + const void *id, enum vertextype vtype) { vertex->type = vtype; @@ -375,10 +358,8 @@ static void isis_vertex_id_init(struct isis_vertex *vertex, const void *id, } } -__attribute__((__unused__)) -static struct isis_vertex *isis_find_vertex(struct isis_vertex_queue *queue, - const void *id, - enum vertextype vtype) +__attribute__((__unused__)) static struct isis_vertex * +isis_find_vertex(struct isis_vertex_queue *queue, const void *id, enum vertextype vtype) { struct isis_vertex querier; @@ -386,9 +367,8 @@ static struct isis_vertex *isis_find_vertex(struct isis_vertex_queue *queue, return hash_lookup(queue->hash, &querier); } -__attribute__((__unused__)) -static struct isis_lsp *lsp_for_vertex(struct isis_spftree *spftree, - struct isis_vertex *vertex) +__attribute__((__unused__)) static struct isis_lsp *lsp_for_vertex(struct isis_spftree *spftree, + struct isis_vertex *vertex) { uint8_t lsp_id[ISIS_SYS_ID_LEN + 2]; diff --git a/isisd/isis_sr.c b/isisd/isis_sr.c index 118438421308..627ca0cd5acb 100644 --- a/isisd/isis_sr.c +++ b/isisd/isis_sr.c @@ -40,8 +40,7 @@ DEFINE_MTYPE_STATIC(ISISD, ISIS_SR_INFO, "ISIS segment routing information"); static void sr_local_block_delete(struct isis_area *area); static int sr_local_block_init(struct isis_area *area); -static void sr_adj_sid_update(struct sr_adjacency *sra, - struct sr_local_block *srlb); +static void sr_adj_sid_update(struct sr_adjacency *sra, struct sr_local_block *srlb); static void sr_adj_sid_del(struct sr_adjacency *sra); /* --- RB-Tree Management functions ----------------------------------------- */ @@ -69,8 +68,7 @@ static inline int sr_prefix_sid_cfg_compare(const struct sr_prefix_cfg *a, return 0; } -DECLARE_RBTREE_UNIQ(srdb_prefix_cfg, struct sr_prefix_cfg, entry, - sr_prefix_sid_cfg_compare); +DECLARE_RBTREE_UNIQ(srdb_prefix_cfg, struct sr_prefix_cfg, entry, sr_prefix_sid_cfg_compare); /** * Find SRGB associated to a System ID. @@ -80,8 +78,7 @@ DECLARE_RBTREE_UNIQ(srdb_prefix_cfg, struct sr_prefix_cfg, entry, * * @return Pointer to SRGB if found, NULL otherwise */ -struct isis_sr_block *isis_sr_find_srgb(struct lspdb_head *lspdb, - const uint8_t *sysid) +struct isis_sr_block *isis_sr_find_srgb(struct lspdb_head *lspdb, const uint8_t *sysid) { struct isis_lsp *lsp; @@ -89,8 +86,7 @@ struct isis_sr_block *isis_sr_find_srgb(struct lspdb_head *lspdb, if (!lsp) return NULL; - if (!lsp->tlvs->router_cap - || lsp->tlvs->router_cap->srgb.range_size == 0) + if (!lsp->tlvs->router_cap || lsp->tlvs->router_cap->srgb.range_size == 0) return NULL; return &lsp->tlvs->router_cap->srgb; @@ -105,28 +101,24 @@ struct isis_sr_block *isis_sr_find_srgb(struct lspdb_head *lspdb, * * @return MPLS label or MPLS_INVALID_LABEL in case of SRGB overflow */ -mpls_label_t sr_prefix_in_label(struct isis_area *area, - struct isis_prefix_sid *psid, bool local) +mpls_label_t sr_prefix_in_label(struct isis_area *area, struct isis_prefix_sid *psid, bool local) { /* * No need to assign a label for local Prefix-SIDs unless the no-PHP * flag is set. */ - if (local - && (!CHECK_FLAG(psid->flags, ISIS_PREFIX_SID_NO_PHP) - || CHECK_FLAG(psid->flags, ISIS_PREFIX_SID_EXPLICIT_NULL))) + if (local && (!CHECK_FLAG(psid->flags, ISIS_PREFIX_SID_NO_PHP) || + CHECK_FLAG(psid->flags, ISIS_PREFIX_SID_EXPLICIT_NULL))) return MPLS_INVALID_LABEL; /* Return SID value as MPLS label if it is an Absolute SID */ - if (CHECK_FLAG(psid->flags, - ISIS_PREFIX_SID_VALUE | ISIS_PREFIX_SID_LOCAL)) + if (CHECK_FLAG(psid->flags, ISIS_PREFIX_SID_VALUE | ISIS_PREFIX_SID_LOCAL)) return psid->value; /* Check that SID index falls inside the SRGB */ - if (psid->value >= (area->srdb.config.srgb_upper_bound - - area->srdb.config.srgb_lower_bound + 1)) { - flog_warn(EC_ISIS_SID_OVERFLOW, - "%s: SID index %u falls outside local SRGB range", + if (psid->value >= + (area->srdb.config.srgb_upper_bound - area->srdb.config.srgb_lower_bound + 1)) { + flog_warn(EC_ISIS_SID_OVERFLOW, "%s: SID index %u falls outside local SRGB range", __func__, psid->value); return MPLS_INVALID_LABEL; } @@ -146,8 +138,7 @@ mpls_label_t sr_prefix_in_label(struct isis_area *area, * * @return MPLS label or MPLS_INVALID_LABEL in case of error */ -mpls_label_t sr_prefix_out_label(struct lspdb_head *lspdb, int family, - struct isis_prefix_sid *psid, +mpls_label_t sr_prefix_out_label(struct lspdb_head *lspdb, int family, struct isis_prefix_sid *psid, const uint8_t *nh_sysid, bool last_hop) { struct isis_sr_block *nh_srgb; @@ -166,8 +157,7 @@ mpls_label_t sr_prefix_out_label(struct lspdb_head *lspdb, int family, } /* Return SID value as MPLS label if it is an Absolute SID */ - if (CHECK_FLAG(psid->flags, - ISIS_PREFIX_SID_VALUE | ISIS_PREFIX_SID_LOCAL)) { + if (CHECK_FLAG(psid->flags, ISIS_PREFIX_SID_VALUE | ISIS_PREFIX_SID_LOCAL)) { /* * V/L SIDs have local significance, so only adjacent routers * can use them (RFC8667 section #2.1.1.1) @@ -186,13 +176,12 @@ mpls_label_t sr_prefix_out_label(struct lspdb_head *lspdb, int family, * Check if the nexthop can handle SR-MPLS encapsulated IPv4 or * IPv6 packets. */ - if ((family == AF_INET && !IS_SR_IPV4(nh_srgb)) - || (family == AF_INET6 && !IS_SR_IPV6(nh_srgb))) + if ((family == AF_INET && !IS_SR_IPV4(nh_srgb)) || + (family == AF_INET6 && !IS_SR_IPV6(nh_srgb))) return MPLS_INVALID_LABEL; if (psid->value >= nh_srgb->range_size) { - flog_warn(EC_ISIS_SID_OVERFLOW, - "%s: SID index %u falls outside remote SRGB range", + flog_warn(EC_ISIS_SID_OVERFLOW, "%s: SID index %u falls outside remote SRGB range", __func__, psid->value); return MPLS_INVALID_LABEL; } @@ -211,8 +200,7 @@ mpls_label_t sr_prefix_out_label(struct lspdb_head *lspdb, int family, * * @return True if the interface/address pair corresponds to a Node-SID */ -static bool sr_prefix_is_node_sid(const struct interface *ifp, - const struct prefix *prefix) +static bool sr_prefix_is_node_sid(const struct interface *ifp, const struct prefix *prefix) { return (if_is_loopback(ifp) && is_host_route(prefix)); } @@ -227,13 +215,12 @@ static bool sr_prefix_is_node_sid(const struct interface *ifp, * * @return 0 on success, -1 otherwise */ -int isis_sr_cfg_srgb_update(struct isis_area *area, uint32_t lower_bound, - uint32_t upper_bound) +int isis_sr_cfg_srgb_update(struct isis_area *area, uint32_t lower_bound, uint32_t upper_bound) { struct isis_sr_db *srdb = &area->srdb; - sr_debug("ISIS-Sr (%s): Update SRGB with new range [%u/%u]", - area->area_tag, lower_bound, upper_bound); + sr_debug("ISIS-Sr (%s): Update SRGB with new range [%u/%u]", area->area_tag, lower_bound, + upper_bound); /* Just store new SRGB values if Label Manager is not available. * SRGB will be configured later when SR start */ @@ -245,9 +232,9 @@ int isis_sr_cfg_srgb_update(struct isis_area *area, uint32_t lower_bound, /* Label Manager is ready, start by releasing the old SRGB. */ if (srdb->srgb_active) { - isis_zebra_release_label_range(srdb->config.srgb_lower_bound, + isis_zebra_release_label_range(srdb->config.srgb_lower_bound, srdb->config.srgb_upper_bound); - srdb->srgb_active = false; + srdb->srgb_active = false; } srdb->config.srgb_lower_bound = lower_bound; @@ -255,18 +242,16 @@ int isis_sr_cfg_srgb_update(struct isis_area *area, uint32_t lower_bound, if (srdb->enabled) { /* then request new SRGB if SR is enabled. */ - if (isis_zebra_request_label_range( - srdb->config.srgb_lower_bound, - srdb->config.srgb_upper_bound - - srdb->config.srgb_lower_bound + 1) < 0) { + if (isis_zebra_request_label_range(srdb->config.srgb_lower_bound, + srdb->config.srgb_upper_bound - + srdb->config.srgb_lower_bound + 1) < 0) { srdb->srgb_active = false; return -1; } else srdb->srgb_active = true; - sr_debug(" |- Got new SRGB [%u/%u]", - srdb->config.srgb_lower_bound, + sr_debug(" |- Got new SRGB [%u/%u]", srdb->config.srgb_lower_bound, srdb->config.srgb_upper_bound); lsp_regenerate_schedule(area, area->is_type, 0); @@ -289,15 +274,14 @@ int isis_sr_cfg_srgb_update(struct isis_area *area, uint32_t lower_bound, * * @return 0 on success, -1 otherwise */ -int isis_sr_cfg_srlb_update(struct isis_area *area, uint32_t lower_bound, - uint32_t upper_bound) +int isis_sr_cfg_srlb_update(struct isis_area *area, uint32_t lower_bound, uint32_t upper_bound) { struct isis_sr_db *srdb = &area->srdb; struct listnode *node; struct sr_adjacency *sra; - sr_debug("ISIS-Sr (%s): Update SRLB with new range [%u/%u]", - area->area_tag, lower_bound, upper_bound); + sr_debug("ISIS-Sr (%s): Update SRLB with new range [%u/%u]", area->area_tag, lower_bound, + upper_bound); /* Just store new SRLB values if Label Manager is not available. * SRLB will be configured later when SR start */ @@ -340,8 +324,7 @@ int isis_sr_cfg_srlb_update(struct isis_area *area, uint32_t lower_bound, * * @return Newly added Prefix-SID configuration structure */ -struct sr_prefix_cfg *isis_sr_cfg_prefix_add(struct isis_area *area, - const struct prefix *prefix, +struct sr_prefix_cfg *isis_sr_cfg_prefix_add(struct isis_area *area, const struct prefix *prefix, uint8_t algorithm) { struct sr_prefix_cfg *pcfg; @@ -355,10 +338,10 @@ struct sr_prefix_cfg *isis_sr_cfg_prefix_add(struct isis_area *area, pcfg->algorithm = algorithm; /* Pull defaults from the YANG module. */ - pcfg->sid_type = yang_get_default_enum( - "%s/prefix-sid-map/prefix-sid/sid-value-type", ISIS_SR); - pcfg->last_hop_behavior = yang_get_default_enum( - "%s/prefix-sid-map/prefix-sid/last-hop-behavior", ISIS_SR); + pcfg->sid_type = yang_get_default_enum("%s/prefix-sid-map/prefix-sid/sid-value-type", + ISIS_SR); + pcfg->last_hop_behavior = + yang_get_default_enum("%s/prefix-sid-map/prefix-sid/last-hop-behavior", ISIS_SR); /* Mark as node Sid if the prefix is host and configured in loopback */ ifp = if_lookup_prefix(prefix, VRF_DEFAULT); @@ -380,10 +363,8 @@ void isis_sr_cfg_prefix_del(struct sr_prefix_cfg *pcfg) { struct isis_area *area = pcfg->area; - sr_debug("ISIS-Sr (%s): Delete local Prefix-SID %pFX %s %u", - area->area_tag, &pcfg->prefix, - pcfg->sid_type == SR_SID_VALUE_TYPE_INDEX ? "index" : "label", - pcfg->sid); + sr_debug("ISIS-Sr (%s): Delete local Prefix-SID %pFX %s %u", area->area_tag, &pcfg->prefix, + pcfg->sid_type == SR_SID_VALUE_TYPE_INDEX ? "index" : "label", pcfg->sid); srdb_prefix_cfg_del(&area->srdb.config.prefix_sids, pcfg); XFREE(MTYPE_ISIS_SR_INFO, pcfg); @@ -397,8 +378,7 @@ void isis_sr_cfg_prefix_del(struct sr_prefix_cfg *pcfg) * * @return Configured Prefix-SID structure if found, NULL otherwise */ -struct sr_prefix_cfg *isis_sr_cfg_prefix_find(struct isis_area *area, - union prefixconstptr prefix, +struct sr_prefix_cfg *isis_sr_cfg_prefix_find(struct isis_area *area, union prefixconstptr prefix, uint8_t algorithm) { struct sr_prefix_cfg pcfg = {}; @@ -487,10 +467,9 @@ static int sr_local_block_init(struct isis_area *area) * Request SRLB to the label manager. If the allocation fails, return * an error to disable SR until a new SRLB is successfully allocated. */ - if (isis_zebra_request_label_range( - srdb->config.srlb_lower_bound, - srdb->config.srlb_upper_bound - - srdb->config.srlb_lower_bound + 1)) { + if (isis_zebra_request_label_range(srdb->config.srlb_lower_bound, + srdb->config.srlb_upper_bound - + srdb->config.srlb_lower_bound + 1)) { srlb->active = false; return -1; } @@ -506,8 +485,7 @@ static int sr_local_block_init(struct isis_area *area) srlb->max_block = (srlb->end - srlb->start + 1) / SRLB_BLOCK_SIZE; if (((srlb->end - srlb->start + 1) % SRLB_BLOCK_SIZE) != 0) srlb->max_block++; - srlb->used_mark = XCALLOC(MTYPE_ISIS_SR_INFO, - srlb->max_block * SRLB_BLOCK_SIZE); + srlb->used_mark = XCALLOC(MTYPE_ISIS_SR_INFO, srlb->max_block * SRLB_BLOCK_SIZE); srlb->active = true; return 0; @@ -527,8 +505,7 @@ static void sr_local_block_delete(struct isis_area *area) if (!srlb->active) return; - sr_debug("ISIS-Sr (%s): Remove SRLB [%u/%u]", area->area_tag, - srlb->start, srlb->end); + sr_debug("ISIS-Sr (%s): Remove SRLB [%u/%u]", area->area_tag, srlb->start, srlb->end); /* First release the label block */ isis_zebra_release_label_range(srdb->config.srlb_lower_bound, @@ -580,8 +557,7 @@ static mpls_label_t sr_local_block_request_label(struct sr_local_block *srlb) } if (srlb->current == size) - zlog_warn( - "SR: Warning, SRLB is depleted and next label request will fail"); + zlog_warn("SR: Warning, SRLB is depleted and next label request will fail"); return label; } @@ -594,17 +570,15 @@ static mpls_label_t sr_local_block_request_label(struct sr_local_block *srlb) * * @return 0 on success or -1 if label falls outside SRLB */ -static int sr_local_block_release_label(struct sr_local_block *srlb, - mpls_label_t label) +static int sr_local_block_release_label(struct sr_local_block *srlb, mpls_label_t label) { uint32_t index; uint64_t pos; /* Check that label falls inside the SRLB */ if ((label < srlb->start) || (label > srlb->end)) { - flog_warn(EC_ISIS_SID_OVERFLOW, - "%s: Returning label %u is outside SRLB [%u/%u]", - __func__, label, srlb->start, srlb->end); + flog_warn(EC_ISIS_SID_OVERFLOW, "%s: Returning label %u is outside SRLB [%u/%u]", + __func__, label, srlb->start, srlb->end); return -1; } @@ -616,8 +590,7 @@ static int sr_local_block_release_label(struct sr_local_block *srlb, if (srlb->used_mark[index] != 0xFFFFFFFFFFFFFFFF) { for (pos = 0; pos < SRLB_BLOCK_SIZE; pos++) if (!((1ULL << pos) & srlb->used_mark[index])) { - srlb->current = - index * SRLB_BLOCK_SIZE + pos; + srlb->current = index * SRLB_BLOCK_SIZE + pos; break; } break; @@ -627,8 +600,7 @@ static int sr_local_block_release_label(struct sr_local_block *srlb, return 0; } -static bool sr_adj_same_subnet_ipv4(struct in_addr ipv4, - struct isis_circuit *circuit) +static bool sr_adj_same_subnet_ipv4(struct in_addr ipv4, struct isis_circuit *circuit) { struct listnode *node; struct prefix ipv4_adj; @@ -646,8 +618,7 @@ static bool sr_adj_same_subnet_ipv4(struct in_addr ipv4, return false; } -static bool sr_adj_same_subnet_ipv6(struct in6_addr *ipv6, - struct isis_circuit *circuit) +static bool sr_adj_same_subnet_ipv6(struct in6_addr *ipv6, struct isis_circuit *circuit) { struct listnode *node; struct prefix ipv6_adj; @@ -681,8 +652,8 @@ static bool sr_adj_same_subnet_ipv6(struct in6_addr *ipv6, * @param backup True to initialize backup Adjacency SID * @param nexthops List of backup nexthops (for backup Adj-SIDs only) */ -void sr_adj_sid_add_single(struct isis_adjacency *adj, int family, bool backup, - struct list *nexthops) +void sr_adj_sid_add_single(const struct isis_adjacency *adj, int family, + bool backup, struct list *nexthops) { struct isis_circuit *circuit = adj->circuit; struct isis_area *area = circuit->area; @@ -717,8 +688,7 @@ void sr_adj_sid_add_single(struct isis_adjacency *adj, int family, bool backup, nexthop.ipv6 = adj->ll_ipv6_addrs[0]; break; default: - flog_err(EC_LIB_DEVELOPMENT, - "%s: unexpected address-family: %u", __func__, family); + flog_err(EC_LIB_DEVELOPMENT, "%s: unexpected address-family: %u", __func__, family); exit(1); } @@ -753,8 +723,7 @@ void sr_adj_sid_add_single(struct isis_adjacency *adj, int family, bool backup, struct mpls_label_stack *label_stack; label_stack = vadj->label_stack; - adjinfo2nexthop(family, sra->backup_nexthops, tadj, NULL, - label_stack); + adjinfo2nexthop(family, sra->backup_nexthops, tadj, NULL, label_stack); } } @@ -765,8 +734,7 @@ void sr_adj_sid_add_single(struct isis_adjacency *adj, int family, bool backup, ladj_sid->family = family; ladj_sid->flags = flags; ladj_sid->weight = 0; - memcpy(ladj_sid->neighbor_id, adj->sysid, - sizeof(ladj_sid->neighbor_id)); + memcpy(ladj_sid->neighbor_id, adj->sysid, sizeof(ladj_sid->neighbor_id)); ladj_sid->sid = input_label; isis_tlvs_add_lan_adj_sid(circuit->ext, ladj_sid); sra->u.ladj_sid = ladj_sid; @@ -782,8 +750,8 @@ void sr_adj_sid_add_single(struct isis_adjacency *adj, int family, bool backup, sra->u.adj_sid = adj_sid; break; default: - flog_err(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", - __func__, circuit->circ_type); + flog_err(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", __func__, + circuit->circ_type); exit(1); } @@ -806,8 +774,7 @@ static void sr_adj_sid_add(struct isis_adjacency *adj, int family) sr_adj_sid_add_single(adj, family, false, NULL); } -static void sr_adj_sid_update(struct sr_adjacency *sra, - struct sr_local_block *srlb) +static void sr_adj_sid_update(struct sr_adjacency *sra, struct sr_local_block *srlb) { struct isis_circuit *circuit = sra->adj->circuit; @@ -827,8 +794,8 @@ static void sr_adj_sid_update(struct sr_adjacency *sra, sra->u.adj_sid->sid = sra->input_label; break; default: - flog_warn(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", - __func__, circuit->circ_type); + flog_warn(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", __func__, + circuit->circ_type); break; } @@ -853,24 +820,21 @@ static void sr_adj_sid_del(struct sr_adjacency *sra) /* Release dynamic label and remove subTLVs */ switch (circuit->circ_type) { case CIRCUIT_T_BROADCAST: - sr_local_block_release_label(&area->srdb.srlb, - sra->u.ladj_sid->sid); + sr_local_block_release_label(&area->srdb.srlb, sra->u.ladj_sid->sid); isis_tlvs_del_lan_adj_sid(circuit->ext, sra->u.ladj_sid); break; case CIRCUIT_T_P2P: - sr_local_block_release_label(&area->srdb.srlb, - sra->u.adj_sid->sid); + sr_local_block_release_label(&area->srdb.srlb, sra->u.adj_sid->sid); isis_tlvs_del_adj_sid(circuit->ext, sra->u.adj_sid); break; default: - flog_err(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", - __func__, circuit->circ_type); + flog_err(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", __func__, + circuit->circ_type); exit(1); } if (sra->type == ISIS_SR_ADJ_BACKUP && sra->backup_nexthops) { - sra->backup_nexthops->del = - (void (*)(void *))isis_nexthop_delete; + sra->backup_nexthops->del = (void (*)(void *))isis_nexthop_delete; list_delete(&sra->backup_nexthops); } @@ -887,7 +851,7 @@ static void sr_adj_sid_del(struct sr_adjacency *sra) * @param family Inet Family (IPv4 or IPv6) * @param type Adjacency SID type */ -struct sr_adjacency *isis_sr_adj_sid_find(struct isis_adjacency *adj, +struct sr_adjacency *isis_sr_adj_sid_find(const struct isis_adjacency *adj, int family, enum sr_adj_type type) { struct sr_adjacency *sra; @@ -934,8 +898,7 @@ static int sr_adj_state_change(struct isis_adjacency *adj) * * @return 0 */ -static int sr_adj_ip_enabled(struct isis_adjacency *adj, int family, - bool global) +static int sr_adj_ip_enabled(struct isis_adjacency *adj, int family, bool global) { if (!adj->circuit->area->srdb.enabled || global) return 0; @@ -955,8 +918,7 @@ static int sr_adj_ip_enabled(struct isis_adjacency *adj, int family, * * @return 0 */ -static int sr_adj_ip_disabled(struct isis_adjacency *adj, int family, - bool global) +static int sr_adj_ip_disabled(struct isis_adjacency *adj, int family, bool global) { struct sr_adjacency *sra; struct listnode *node, *nnode; @@ -981,7 +943,7 @@ static int sr_adj_ip_disabled(struct isis_adjacency *adj, int family, */ int sr_if_addr_update(struct interface *ifp) { - struct sr_prefix_cfg *pcfgs[SR_ALGORITHM_COUNT] = {NULL}; + struct sr_prefix_cfg *pcfgs[SR_ALGORITHM_COUNT] = { NULL }; struct isis_circuit *circuit; struct isis_area *area; struct connected *connected; @@ -998,8 +960,7 @@ int sr_if_addr_update(struct interface *ifp) frr_each (if_connected, ifp->connected, connected) { for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { - pcfgs[i] = isis_sr_cfg_prefix_find( - area, connected->address, i); + pcfgs[i] = isis_sr_cfg_prefix_find(area, connected->address, i); if (!pcfgs[i]) continue; @@ -1027,8 +988,7 @@ int sr_if_addr_update(struct interface *ifp) * * @return String containing LFIB operation in human readable format */ -char *sr_op2str(char *buf, size_t size, mpls_label_t label_in, - mpls_label_t label_out) +char *sr_op2str(char *buf, size_t size, mpls_label_t label_in, mpls_label_t label_out) { if (size < 24) return NULL; @@ -1063,8 +1023,7 @@ char *sr_op2str(char *buf, size_t size, mpls_label_t label_in, * @param area IS-IS area * @param level IS-IS level */ -static void show_node(struct vty *vty, struct isis_area *area, int level, - uint8_t algo) +static void show_node(struct vty *vty, struct isis_area *area, int level, uint8_t algo) { struct isis_lsp *lsp; struct ttable *tt; @@ -1098,12 +1057,11 @@ static void show_node(struct vty *vty, struct isis_area *area, int level, snprintf(buf, sizeof(buf), "Flex-Algo %d", algo); #endif /* ifndef FABRICD */ - ttable_add_row(tt, "%pSY|%u - %u|%u - %u|%s|%u", - lsp->hdr.lsp_id, cap->srgb.lower_bound, + ttable_add_row(tt, "%pSY|%u - %u|%u - %u|%s|%u", lsp->hdr.lsp_id, + cap->srgb.lower_bound, cap->srgb.lower_bound + cap->srgb.range_size - 1, cap->srlb.lower_bound, - cap->srlb.lower_bound + cap->srlb.range_size - 1, - buf, cap->msd); + cap->srlb.lower_bound + cap->srlb.range_size - 1, buf, cap->msd); } /* Dump the generated table. */ @@ -1135,7 +1093,6 @@ DEFUN(show_sr_node, show_sr_node_cmd, #endif /* ifndef FABRICD */ ) { - struct listnode *node, *inode; struct isis_area *area; uint16_t algorithm = SR_ALGORITHM_SPF; bool all_algorithm = false; @@ -1151,25 +1108,20 @@ DEFUN(show_sr_node, show_sr_node_cmd, } #endif /* ifndef FABRICD */ - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { - vty_out(vty, "Area %s:\n", - area->area_tag ? area->area_tag : "null"); + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, area) { + vty_out(vty, "Area %s:\n", area->area_tag ? area->area_tag : "null"); if (!area->srdb.enabled) { vty_out(vty, " Segment Routing is disabled\n"); continue; } - for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; - level++) { + for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { if (all_algorithm) { for (algorithm = SR_ALGORITHM_FLEX_MIN; - algorithm <= SR_ALGORITHM_FLEX_MAX; - algorithm++) - show_node(vty, area, level, - (uint8_t)algorithm); + algorithm <= SR_ALGORITHM_FLEX_MAX; algorithm++) + show_node(vty, area, level, (uint8_t)algorithm); } else - show_node(vty, area, level, - (uint8_t)algorithm); + show_node(vty, area, level, (uint8_t)algorithm); } } } @@ -1208,14 +1160,12 @@ int isis_sr_start(struct isis_area *area) { struct isis_sr_db *srdb = &area->srdb; struct isis_adjacency *adj; - struct listnode *node; /* First start Label Manager if not ready */ if (!isis_zebra_label_manager_ready()) if (isis_zebra_label_manager_connect() < 0) { /* Re-attempt to connect to Label Manager in 1 sec. */ - event_add_timer(master, sr_start_label_manager, area, 1, - &srdb->t_start_lm); + event_add_timer(master, sr_start_label_manager, area, 1, &srdb->t_start_lm); return -1; } @@ -1229,22 +1179,19 @@ int isis_sr_start(struct isis_area *area) * is successfully allocated. */ if (!srdb->srgb_active) { - if (isis_zebra_request_label_range( - srdb->config.srgb_lower_bound, - srdb->config.srgb_upper_bound - - srdb->config.srgb_lower_bound + 1) - < 0) { + if (isis_zebra_request_label_range(srdb->config.srgb_lower_bound, + srdb->config.srgb_upper_bound - + srdb->config.srgb_lower_bound + 1) < 0) { srdb->srgb_active = false; return -1; } else srdb->srgb_active = true; } - sr_debug("ISIS-Sr: Starting Segment Routing for area %s", - area->area_tag); + sr_debug("ISIS-Sr: Starting Segment Routing for area %s", area->area_tag); /* Create Adjacency-SIDs from existing IS-IS Adjacencies. */ - for (ALL_LIST_ELEMENTS_RO(area->adjacency_list, node, adj)) { + frr_each (isis_area_adj_list, &area->adjacency_list, adj) { if (adj->ipv4_address_count > 0) sr_adj_sid_add(adj, AF_INET); if (adj->ll_ipv6_count > 0) @@ -1270,8 +1217,7 @@ void isis_sr_stop(struct isis_area *area) struct sr_adjacency *sra; struct listnode *node, *nnode; - sr_debug("ISIS-Sr: Stopping Segment Routing for area %s", - area->area_tag); + sr_debug("ISIS-Sr: Stopping Segment Routing for area %s", area->area_tag); /* Disable any re-attempt to connect to Label Manager */ event_cancel(&srdb->t_start_lm); @@ -1305,8 +1251,7 @@ void isis_sr_area_init(struct isis_area *area) { struct isis_sr_db *srdb = &area->srdb; - sr_debug("ISIS-Sr (%s): Initialize Segment Routing SRDB", - area->area_tag); + sr_debug("ISIS-Sr (%s): Initialize Segment Routing SRDB", area->area_tag); /* Initialize Segment Routing Data Base */ memset(srdb, 0, sizeof(*srdb)); @@ -1315,14 +1260,14 @@ void isis_sr_area_init(struct isis_area *area) /* Pull defaults from the YANG module. */ #ifndef FABRICD srdb->config.enabled = yang_get_default_bool("%s/enabled", ISIS_SR); - srdb->config.srgb_lower_bound = yang_get_default_uint32( - "%s/label-blocks/srgb/lower-bound", ISIS_SR); - srdb->config.srgb_upper_bound = yang_get_default_uint32( - "%s/label-blocks/srgb/upper-bound", ISIS_SR); - srdb->config.srlb_lower_bound = yang_get_default_uint32( - "%s/label-blocks/srlb/lower-bound", ISIS_SR); - srdb->config.srlb_upper_bound = yang_get_default_uint32( - "%s/label-blocks/srlb/upper-bound", ISIS_SR); + srdb->config.srgb_lower_bound = yang_get_default_uint32("%s/label-blocks/srgb/lower-bound", + ISIS_SR); + srdb->config.srgb_upper_bound = yang_get_default_uint32("%s/label-blocks/srgb/upper-bound", + ISIS_SR); + srdb->config.srlb_lower_bound = yang_get_default_uint32("%s/label-blocks/srlb/lower-bound", + ISIS_SR); + srdb->config.srlb_upper_bound = yang_get_default_uint32("%s/label-blocks/srlb/upper-bound", + ISIS_SR); #else srdb->config.enabled = false; srdb->config.srgb_lower_bound = SRGB_LOWER_BOUND; diff --git a/isisd/isis_sr.h b/isisd/isis_sr.h index 76f776825da5..6a3e3f5d4abb 100644 --- a/isisd/isis_sr.h +++ b/isisd/isis_sr.h @@ -109,7 +109,7 @@ struct sr_adjacency { } u; /* Back pointer to IS-IS adjacency. */ - struct isis_adjacency *adj; + const struct isis_adjacency *adj; }; /* SID type. NOTE: these values must be in sync with the YANG module. */ @@ -216,9 +216,9 @@ isis_sr_cfg_prefix_find(struct isis_area *area, union prefixconstptr prefix, extern void isis_sr_prefix_cfg2subtlv(const struct sr_prefix_cfg *pcfg, bool external, struct isis_prefix_sid *psid); -extern void sr_adj_sid_add_single(struct isis_adjacency *adj, int family, +extern void sr_adj_sid_add_single(const struct isis_adjacency *adj, int family, bool backup, struct list *nexthops); -extern struct sr_adjacency *isis_sr_adj_sid_find(struct isis_adjacency *adj, +extern struct sr_adjacency *isis_sr_adj_sid_find(const struct isis_adjacency *adj, int family, enum sr_adj_type type); extern void isis_area_delete_backup_adj_sids(struct isis_area *area, int level); diff --git a/isisd/isis_srv6.c b/isisd/isis_srv6.c index 6f372c05cff6..60563cb1a2d4 100644 --- a/isisd/isis_srv6.c +++ b/isisd/isis_srv6.c @@ -31,9 +31,8 @@ DEFINE_MTYPE_STATIC(ISISD, ISIS_SRV6_INFO, "ISIS SRv6 information"); * @param sid SRv6 SID configuration * @param structure_subsubtlv SRv6 SID Structure Sub-Sub-TLV to be updated */ -void isis_srv6_sid_structure2subsubtlv( - const struct isis_srv6_sid *sid, - struct isis_srv6_sid_structure_subsubtlv *structure_subsubtlv) +void isis_srv6_sid_structure2subsubtlv(const struct isis_srv6_sid *sid, + struct isis_srv6_sid_structure_subsubtlv *structure_subsubtlv) { /* Set Locator Block length */ structure_subsubtlv->loc_block_len = sid->structure.loc_block_len; @@ -113,10 +112,8 @@ bool isis_srv6_locator_unset(struct isis_area *area) /* Delete SRv6 SIDs */ for (ALL_LIST_ELEMENTS(area->srv6db.srv6_sids, node, nnode, sid)) { - sr_debug( - "Deleting SRv6 SID (locator %s, sid %pI6) from IS-IS area %s", - area->srv6db.config.srv6_locator_name, &sid->sid, - area->area_tag); + sr_debug("Deleting SRv6 SID (locator %s, sid %pI6) from IS-IS area %s", + area->srv6db.config.srv6_locator_name, &sid->sid, area->area_tag); /* Uninstall the SRv6 SID from the forwarding plane through * Zebra */ @@ -150,18 +147,14 @@ bool isis_srv6_locator_unset(struct isis_area *area) } /* Inform Zebra that we are releasing the SRv6 locator */ - ret = isis_zebra_srv6_manager_release_locator_chunk( - area->srv6db.config.srv6_locator_name); + ret = isis_zebra_srv6_manager_release_locator_chunk(area->srv6db.config.srv6_locator_name); if (ret < 0) return false; /* Delete chunks */ - for (ALL_LIST_ELEMENTS(area->srv6db.srv6_locator_chunks, node, nnode, - chunk)) { - sr_debug( - "Releasing chunk of locator %s (prefix %pFX) for IS-IS area %s", - area->srv6db.config.srv6_locator_name, &chunk->prefix, - area->area_tag); + for (ALL_LIST_ELEMENTS(area->srv6db.srv6_locator_chunks, node, nnode, chunk)) { + sr_debug("Releasing chunk of locator %s (prefix %pFX) for IS-IS area %s", + area->srv6db.config.srv6_locator_name, &chunk->prefix, area->area_tag); listnode_delete(area->srv6db.srv6_locator_chunks, chunk); srv6_locator_chunk_free(&chunk); @@ -200,7 +193,8 @@ void isis_srv6_interface_set(struct isis_area *area, const char *ifname) return; } - sr_debug("SRv6 interface for IS-IS area %s changed (old interface: %s, new interface: %s)", area->area_tag, area->srv6db.config.srv6_ifname, ifname); + sr_debug("SRv6 interface for IS-IS area %s changed (old interface: %s, new interface: %s)", + area->area_tag, area->srv6db.config.srv6_ifname, ifname); /* Walk through all SIDs and uninstall them from the data plane */ for (ALL_LIST_ELEMENTS_RO(area->srv6db.srv6_sids, node, sid)) { @@ -211,7 +205,8 @@ void isis_srv6_interface_set(struct isis_area *area, const char *ifname) strlcpy(area->srv6db.config.srv6_ifname, ifname, sizeof(area->srv6db.config.srv6_ifname)); if (!if_lookup_by_name(area->srv6db.config.srv6_ifname, VRF_DEFAULT)) { - sr_debug("Interface %s not yet exist in data plane, deferring SIDs installation until it's created", area->srv6db.config.srv6_ifname); + sr_debug("Interface %s not yet exist in data plane, deferring SIDs installation until it's created", + area->srv6db.config.srv6_ifname); return; } @@ -232,10 +227,9 @@ void isis_srv6_interface_set(struct isis_area *area, const char *ifname) * * @result the allocated SID on success, NULL otherwise */ -struct isis_srv6_sid * -isis_srv6_sid_alloc(struct isis_area *area, struct srv6_locator *locator, - enum srv6_endpoint_behavior_codepoint behavior, - struct in6_addr *sid_value) +struct isis_srv6_sid *isis_srv6_sid_alloc(struct isis_area *area, struct srv6_locator *locator, + enum srv6_endpoint_behavior_codepoint behavior, + struct in6_addr *sid_value) { struct isis_srv6_sid *sid = NULL; @@ -274,8 +268,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_ADJ_BACKUP && - (sra->adj->level & level)) + if (sra->type == ISIS_SRV6_ADJ_BACKUP && (sra->adj->level & level)) srv6_endx_sid_del(sra); } @@ -289,8 +282,8 @@ void isis_area_delete_backup_srv6_endx_sids(struct isis_area *area, int level) * @param nexthops List of backup nexthops (for backup End.X SIDs only) * @param sid_value SID value associated to be associated with the adjacency */ -void srv6_endx_sid_add_single(struct isis_adjacency *adj, bool backup, - struct list *nexthops, struct in6_addr *sid_value) +void srv6_endx_sid_add_single(struct isis_adjacency *adj, bool backup, struct list *nexthops, + struct in6_addr *sid_value) { struct isis_circuit *circuit = adj->circuit; struct isis_area *area = circuit->area; @@ -305,8 +298,7 @@ void srv6_endx_sid_add_single(struct isis_adjacency *adj, bool backup, if (!area || !area->srv6db.srv6_locator) return; - sr_debug("ISIS-SRv6 (%s): Add %s End.X SID", area->area_tag, - backup ? "Backup" : "Primary"); + sr_debug("ISIS-SRv6 (%s): Add %s End.X SID", area->area_tag, backup ? "Backup" : "Primary"); /* Determine nexthop IP address */ if (!circuit->ipv6_router || !adj->ll_ipv6_count) @@ -343,26 +335,22 @@ void srv6_endx_sid_add_single(struct isis_adjacency *adj, bool backup, /* SRv6 LAN End.X SID for Broadcast interface section #8.2 */ case CIRCUIT_T_BROADCAST: ladj_sid = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(*ladj_sid)); - memcpy(ladj_sid->neighbor_id, adj->sysid, - sizeof(ladj_sid->neighbor_id)); + memcpy(ladj_sid->neighbor_id, adj->sysid, sizeof(ladj_sid->neighbor_id)); ladj_sid->flags = flags; ladj_sid->algorithm = SR_ALGORITHM_SPF; ladj_sid->weight = 0; ladj_sid->behavior = sra->behavior; ladj_sid->sid = sra->sid; - ladj_sid->subsubtlvs = isis_alloc_subsubtlvs( - ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID); - ladj_sid->subsubtlvs->srv6_sid_structure = XCALLOC( - MTYPE_ISIS_SUBSUBTLV, - sizeof(*ladj_sid->subsubtlvs->srv6_sid_structure)); + ladj_sid->subsubtlvs = isis_alloc_subsubtlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID); + ladj_sid->subsubtlvs->srv6_sid_structure = + XCALLOC(MTYPE_ISIS_SUBSUBTLV, + sizeof(*ladj_sid->subsubtlvs->srv6_sid_structure)); ladj_sid->subsubtlvs->srv6_sid_structure->loc_block_len = sra->structure.loc_block_len; ladj_sid->subsubtlvs->srv6_sid_structure->loc_node_len = sra->structure.loc_node_len; - ladj_sid->subsubtlvs->srv6_sid_structure->func_len = - sra->structure.func_len; - ladj_sid->subsubtlvs->srv6_sid_structure->arg_len = - sra->structure.arg_len; + ladj_sid->subsubtlvs->srv6_sid_structure->func_len = sra->structure.func_len; + ladj_sid->subsubtlvs->srv6_sid_structure->arg_len = sra->structure.arg_len; isis_tlvs_add_srv6_lan_endx_sid(circuit->ext, ladj_sid); sra->u.lendx_sid = ladj_sid; break; @@ -374,25 +362,21 @@ void srv6_endx_sid_add_single(struct isis_adjacency *adj, bool backup, adj_sid->weight = 0; adj_sid->behavior = sra->behavior; adj_sid->sid = sra->sid; - adj_sid->subsubtlvs = isis_alloc_subsubtlvs( - ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID); - adj_sid->subsubtlvs->srv6_sid_structure = XCALLOC( - MTYPE_ISIS_SUBSUBTLV, - sizeof(*adj_sid->subsubtlvs->srv6_sid_structure)); + adj_sid->subsubtlvs = isis_alloc_subsubtlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID); + adj_sid->subsubtlvs->srv6_sid_structure = + XCALLOC(MTYPE_ISIS_SUBSUBTLV, + sizeof(*adj_sid->subsubtlvs->srv6_sid_structure)); adj_sid->subsubtlvs->srv6_sid_structure->loc_block_len = sra->structure.loc_block_len; - adj_sid->subsubtlvs->srv6_sid_structure->loc_node_len = - sra->structure.loc_node_len; - adj_sid->subsubtlvs->srv6_sid_structure->func_len = - sra->structure.func_len; - adj_sid->subsubtlvs->srv6_sid_structure->arg_len = - sra->structure.arg_len; + adj_sid->subsubtlvs->srv6_sid_structure->loc_node_len = sra->structure.loc_node_len; + adj_sid->subsubtlvs->srv6_sid_structure->func_len = sra->structure.func_len; + adj_sid->subsubtlvs->srv6_sid_structure->arg_len = sra->structure.arg_len; isis_tlvs_add_srv6_endx_sid(circuit->ext, adj_sid); sra->u.endx_sid = adj_sid; break; default: - flog_err(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", - __func__, circuit->circ_type); + flog_err(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", __func__, + circuit->circ_type); exit(1); } @@ -437,14 +421,13 @@ void srv6_endx_sid_del(struct srv6_adjacency *sra) isis_tlvs_del_srv6_endx_sid(circuit->ext, sra->u.endx_sid); break; default: - flog_err(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", - __func__, circuit->circ_type); + flog_err(EC_LIB_DEVELOPMENT, "%s: unexpected circuit type: %u", __func__, + circuit->circ_type); exit(1); } if (sra->type == ISIS_SRV6_ADJ_BACKUP && sra->backup_nexthops) { - sra->backup_nexthops->del = - (void (*)(void *))isis_nexthop_delete; + sra->backup_nexthops->del = (void (*)(void *))isis_nexthop_delete; list_delete(&sra->backup_nexthops); } @@ -460,8 +443,7 @@ void srv6_endx_sid_del(struct srv6_adjacency *sra) * @param adj IS-IS Adjacency * @param type SRv6 End.X SID type */ -struct srv6_adjacency *isis_srv6_endx_sid_find(struct isis_adjacency *adj, - enum srv6_adj_type type) +struct srv6_adjacency *isis_srv6_endx_sid_find(struct isis_adjacency *adj, enum srv6_adj_type type) { struct srv6_adjacency *sra; struct listnode *node; @@ -507,11 +489,9 @@ static int srv6_adj_state_change(struct isis_adjacency *adj) * * @return 0 */ -static int srv6_adj_ip_enabled(struct isis_adjacency *adj, int family, - bool global) +static int srv6_adj_ip_enabled(struct isis_adjacency *adj, int family, bool global) { - if (!adj->circuit->area->srv6db.config.enabled || global || - family != AF_INET6) + if (!adj->circuit->area->srv6db.config.enabled || global || family != AF_INET6) return 0; isis_zebra_request_srv6_sid_endx(adj); @@ -529,14 +509,12 @@ static int srv6_adj_ip_enabled(struct isis_adjacency *adj, int family, * * @return 0 */ -static int srv6_adj_ip_disabled(struct isis_adjacency *adj, int family, - bool global) +static int srv6_adj_ip_disabled(struct isis_adjacency *adj, int family, bool global) { struct srv6_adjacency *sra; struct listnode *node, *nnode; - if (!adj->circuit->area->srv6db.config.enabled || global || - family != AF_INET6) + if (!adj->circuit->area->srv6db.config.enabled || global || family != AF_INET6) return 0; for (ALL_LIST_ELEMENTS(adj->srv6_endx_sids, node, nnode, sra)) @@ -561,9 +539,8 @@ static void show_node(struct vty *vty, struct isis_area *area, int level) /* Prepare table. */ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); - ttable_add_row( - tt, - "System ID|Algorithm|SRH Max SL|SRH Max End Pop|SRH Max H.encaps|SRH Max End D"); + ttable_add_row(tt, + "System ID|Algorithm|SRH Max SL|SRH Max End Pop|SRH Max H.encaps|SRH Max End D"); tt->style.cell.rpad = 2; tt->style.corner = '+'; ttable_restyle(tt); @@ -579,12 +556,9 @@ static void show_node(struct vty *vty, struct isis_area *area, int level) continue; ttable_add_row(tt, "%pSY|%s|%u|%u|%u|%u", lsp->hdr.lsp_id, - cap->algo[0] == SR_ALGORITHM_SPF ? "SPF" - : "S-SPF", - cap->srv6_msd.max_seg_left_msd, - cap->srv6_msd.max_end_pop_msd, - cap->srv6_msd.max_h_encaps_msd, - cap->srv6_msd.max_end_d_msd); + cap->algo[0] == SR_ALGORITHM_SPF ? "SPF" : "S-SPF", + cap->srv6_msd.max_seg_left_msd, cap->srv6_msd.max_end_pop_msd, + cap->srv6_msd.max_h_encaps_msd, cap->srv6_msd.max_end_d_msd); } /* Dump the generated table. */ @@ -606,20 +580,17 @@ DEFUN(show_srv6_node, show_srv6_node_cmd, "Segment-Routing over IPv6 (SRv6)\n" "SRv6 node\n") { - struct listnode *node, *inode; struct isis_area *area; struct isis *isis; - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { - vty_out(vty, "Area %s:\n", - area->area_tag ? area->area_tag : "null"); + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, area) { + vty_out(vty, "Area %s:\n", area->area_tag ? area->area_tag : "null"); if (!area->srv6db.config.enabled) { vty_out(vty, " SRv6 is disabled\n"); continue; } - for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; - level++) + for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) show_node(vty, area, level); } } @@ -630,7 +601,7 @@ DEFUN(show_srv6_node, show_srv6_node_cmd, int isis_srv6_ifp_up_notify(struct interface *ifp) { struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); - struct listnode *node, *node2; + struct listnode *node2; struct isis_area *area; struct isis_srv6_sid *sid; @@ -638,7 +609,7 @@ int isis_srv6_ifp_up_notify(struct interface *ifp) return 0; /* Walk through all areas of the ISIS instance */ - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { /* Skip area, if SRv6 is not enabled */ if (!area->srv6db.config.enabled) continue; @@ -647,7 +618,8 @@ int isis_srv6_ifp_up_notify(struct interface *ifp) if (strncmp(area->srv6db.config.srv6_ifname, ifp->name, IF_NAMESIZE)) continue; - sr_debug("Interface %s went up. Installing SIDs for area %s in data plane", ifp->name, area->area_tag); + sr_debug("Interface %s went up. Installing SIDs for area %s in data plane", + ifp->name, area->area_tag); /* Walk through all SIDs and re-install them into the data plane with the newly configured interface */ for (ALL_LIST_ELEMENTS_RO(area->srv6db.srv6_sids, node2, sid)) { @@ -668,13 +640,12 @@ int isis_srv6_ifp_up_notify(struct interface *ifp) void isis_srv6_locators_request(void) { struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); - struct listnode *node; struct isis_area *area; if (!isis) return; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) + frr_each (isis_area_list, &isis->area_list, area) if (area->srv6db.config.enabled && area->srv6db.config.srv6_locator_name[0] != '\0' && !area->srv6db.srv6_locator) isis_zebra_srv6_manager_get_locator(area->srv6db.config.srv6_locator_name); @@ -694,8 +665,7 @@ void isis_srv6_area_init(struct isis_area *area) srv6db = &area->srv6db; - sr_debug("ISIS-SRv6 (%s): Initialize Segment Routing SRv6 DB", - area->area_tag); + sr_debug("ISIS-SRv6 (%s): Initialize Segment Routing SRv6 DB", area->area_tag); /* Initialize SRv6 Data Base */ memset(srv6db, 0, sizeof(*srv6db)); @@ -704,24 +674,24 @@ void isis_srv6_area_init(struct isis_area *area) /* Pull defaults from the YANG module */ #ifndef FABRICD srv6db->config.enabled = yang_get_default_bool("%s/enabled", ISIS_SRV6); - srv6db->config.max_seg_left_msd = - yang_get_default_uint8("%s/msd/node-msd/max-segs-left", - ISIS_SRV6); - srv6db->config.max_end_pop_msd = - yang_get_default_uint8("%s/msd/node-msd/max-end-pop", ISIS_SRV6); - srv6db->config.max_h_encaps_msd = - yang_get_default_uint8("%s/msd/node-msd/max-h-encaps", - ISIS_SRV6); - srv6db->config.max_end_d_msd = - yang_get_default_uint8("%s/msd/node-msd/max-end-d", ISIS_SRV6); - strlcpy(srv6db->config.srv6_ifname, yang_get_default_string("%s/interface", ISIS_SRV6), sizeof(srv6db->config.srv6_ifname)); + srv6db->config.max_seg_left_msd = yang_get_default_uint8("%s/msd/node-msd/max-segs-left", + ISIS_SRV6); + srv6db->config.max_end_pop_msd = yang_get_default_uint8("%s/msd/node-msd/max-end-pop", + ISIS_SRV6); + srv6db->config.max_h_encaps_msd = yang_get_default_uint8("%s/msd/node-msd/max-h-encaps", + ISIS_SRV6); + srv6db->config.max_end_d_msd = yang_get_default_uint8("%s/msd/node-msd/max-end-d", + ISIS_SRV6); + strlcpy(srv6db->config.srv6_ifname, yang_get_default_string("%s/interface", ISIS_SRV6), + sizeof(srv6db->config.srv6_ifname)); #else srv6db->config.enabled = false; srv6db->config.max_seg_left_msd = ISIS_DEFAULT_SRV6_MAX_SEG_LEFT_MSD; srv6db->config.max_end_pop_msd = ISIS_DEFAULT_SRV6_MAX_END_POP_MSD; srv6db->config.max_h_encaps_msd = ISIS_DEFAULT_SRV6_MAX_H_ENCAPS_MSD; srv6db->config.max_end_d_msd = ISIS_DEFAULT_SRV6_MAX_END_D_MSD; - strlcpy(srv6db->config.srv6_ifname, DEFAULT_SRV6_IFNAME, sizeof(srv6db->config.srv6_ifname)); + strlcpy(srv6db->config.srv6_ifname, DEFAULT_SRV6_IFNAME, + sizeof(srv6db->config.srv6_ifname)); #endif /* Initialize SRv6 Locator chunks list */ @@ -748,8 +718,7 @@ void isis_srv6_area_term(struct isis_area *area) /* Uninstall all local SRv6 End.X SIDs */ if (area->srv6db.config.enabled) - for (ALL_LIST_ELEMENTS(area->srv6db.srv6_endx_sids, node, nnode, - sra)) + for (ALL_LIST_ELEMENTS(area->srv6db.srv6_endx_sids, node, nnode, sra)) srv6_endx_sid_del(sra); /* Free SRv6 Locator chunks list */ diff --git a/isisd/isis_srv6.h b/isisd/isis_srv6.h index c2d610736762..89c20bded363 100644 --- a/isisd/isis_srv6.h +++ b/isisd/isis_srv6.h @@ -13,10 +13,10 @@ #include "lib/srv6.h" #include "isisd/isis_tlvs.h" -#define ISIS_DEFAULT_SRV6_MAX_SEG_LEFT_MSD 3 -#define ISIS_DEFAULT_SRV6_MAX_END_POP_MSD 3 -#define ISIS_DEFAULT_SRV6_MAX_H_ENCAPS_MSD 2 -#define ISIS_DEFAULT_SRV6_MAX_END_D_MSD 5 +#define ISIS_DEFAULT_SRV6_MAX_SEG_LEFT_MSD 3 +#define ISIS_DEFAULT_SRV6_MAX_END_POP_MSD 3 +#define ISIS_DEFAULT_SRV6_MAX_H_ENCAPS_MSD 2 +#define ISIS_DEFAULT_SRV6_MAX_END_D_MSD 5 /* SRv6 SID structure */ struct isis_srv6_sid_structure { @@ -149,10 +149,9 @@ bool isis_srv6_locator_unset(struct isis_area *area); void isis_srv6_interface_set(struct isis_area *area, const char *ifname); -struct isis_srv6_sid * -isis_srv6_sid_alloc(struct isis_area *area, struct srv6_locator *locator, - enum srv6_endpoint_behavior_codepoint behavior, - struct in6_addr *sid_value); +struct isis_srv6_sid *isis_srv6_sid_alloc(struct isis_area *area, struct srv6_locator *locator, + enum srv6_endpoint_behavior_codepoint behavior, + struct in6_addr *sid_value); extern void isis_srv6_sid_free(struct isis_srv6_sid *sid); void isis_srv6_locators_request(void); @@ -171,12 +170,11 @@ void isis_srv6_end_sid2subtlv(const struct isis_srv6_sid *sid, void isis_srv6_locator2tlv(const struct isis_srv6_locator *loc, struct isis_srv6_locator_tlv *loc_tlv); -void srv6_endx_sid_add_single(struct isis_adjacency *adj, bool backup, - struct list *nexthops, struct in6_addr *sid_value); +void srv6_endx_sid_add_single(struct isis_adjacency *adj, bool backup, struct list *nexthops, + struct in6_addr *sid_value); void srv6_endx_sid_add(struct isis_adjacency *adj, struct in6_addr *sid_value); void srv6_endx_sid_del(struct srv6_adjacency *sra); -struct srv6_adjacency *isis_srv6_endx_sid_find(struct isis_adjacency *adj, - enum srv6_adj_type type); +struct srv6_adjacency *isis_srv6_endx_sid_find(struct isis_adjacency *adj, enum srv6_adj_type type); void isis_area_delete_backup_srv6_endx_sids(struct isis_area *area, int level); int isis_srv6_ifp_up_notify(struct interface *ifp); diff --git a/isisd/isis_te.c b/isisd/isis_te.c index cf92ae46e9a5..e06c2233136a 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -49,7 +49,7 @@ #include "isisd/isis_te.h" #include "isisd/isis_zebra.h" -DEFINE_MTYPE_STATIC(ISISD, ISIS_MPLS_TE, "ISIS MPLS_TE parameters"); +DEFINE_MTYPE_STATIC(ISISD, ISIS_MPLS_TE, "ISIS MPLS_TE parameters"); static void isis_mpls_te_circuit_ip_update(struct isis_circuit *circuit); @@ -64,18 +64,15 @@ static void isis_mpls_te_circuit_ip_update(struct isis_circuit *circuit); */ void isis_mpls_te_create(struct isis_area *area) { - struct listnode *node; struct isis_circuit *circuit; if (!area) return; if (area->mta == NULL) { - struct mpls_te_area *new; - zlog_debug("ISIS-TE(%s): Initialize MPLS Traffic Engineering", - area->area_tag); + zlog_debug("ISIS-TE(%s): Initialize MPLS Traffic Engineering", area->area_tag); new = XCALLOC(MTYPE_ISIS_MPLS_TE, sizeof(struct mpls_te_area)); @@ -101,7 +98,7 @@ void isis_mpls_te_create(struct isis_area *area) /* Update Extended TLVs according to Interface link parameters * and neighbor IP addresses */ - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { isis_link_params_update(circuit, circuit->interface); isis_mpls_te_circuit_ip_update(circuit); } @@ -114,7 +111,6 @@ void isis_mpls_te_create(struct isis_area *area) */ void isis_mpls_te_disable(struct isis_area *area) { - struct listnode *node; struct isis_circuit *circuit; if (!area->mta) @@ -126,7 +122,7 @@ void isis_mpls_te_disable(struct isis_area *area) ls_ted_clean(area->mta->ted); /* Disable Extended SubTLVs on all circuit */ - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { if (!IS_EXT_TE(circuit->ext)) continue; @@ -142,7 +138,6 @@ void isis_mpls_te_disable(struct isis_area *area) void isis_mpls_te_term(struct isis_area *area) { - struct listnode *node; struct isis_circuit *circuit; if (!area->mta) @@ -154,7 +149,7 @@ void isis_mpls_te_term(struct isis_area *area) /* Remove Extended SubTLVs */ zlog_info(" |- Remove Extended SubTLVS for all circuit"); - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { zlog_info(" |- Call isis_del_ext_subtlvs()"); isis_del_ext_subtlvs(circuit->ext); circuit->ext = NULL; @@ -164,8 +159,7 @@ void isis_mpls_te_term(struct isis_area *area) XFREE(MTYPE_ISIS_MPLS_TE, area->mta); } -void isis_link_params_update_asla(struct isis_circuit *circuit, - struct interface *ifp) +void isis_link_params_update_asla(struct isis_circuit *circuit, struct interface *ifp) { struct isis_asla_subtlvs *asla; struct listnode *node, *nnode; @@ -209,8 +203,7 @@ void isis_link_params_update_asla(struct isis_circuit *circuit, UNSET_SUBTLV(asla, EXT_ADM_GRP); if (IS_PARAM_SET(ifp->link_params, LP_EXTEND_ADM_GRP)) { - admin_group_copy(&asla->ext_admin_group, - &ifp->link_params->ext_admin_grp); + admin_group_copy(&asla->ext_admin_group, &ifp->link_params->ext_admin_grp); SET_SUBTLV(asla, EXT_EXTEND_ADM_GRP); } else UNSET_SUBTLV(asla, EXT_EXTEND_ADM_GRP); @@ -218,8 +211,7 @@ void isis_link_params_update_asla(struct isis_circuit *circuit, /* Send admin-group zero for better compatibility * https://www.rfc-editor.org/rfc/rfc7308#section-2.3.2 */ - if (circuit->area->admin_group_send_zero && - !IS_SUBTLV(asla, EXT_ADM_GRP) && + if (circuit->area->admin_group_send_zero && !IS_SUBTLV(asla, EXT_ADM_GRP) && !IS_SUBTLV(asla, EXT_EXTEND_ADM_GRP)) { asla->admin_group = 0; SET_SUBTLV(asla, EXT_ADM_GRP); @@ -268,8 +260,7 @@ void isis_link_params_update_asla(struct isis_circuit *circuit, if (IS_PARAM_SET(ifp->link_params, LP_UNRSV_BW)) { for (i = 0; i < MAX_CLASS_TYPE; i++) - asla->unrsv_bw[i] = - ifp->link_params->unrsv_bw[i]; + asla->unrsv_bw[i] = ifp->link_params->unrsv_bw[i]; SET_SUBTLV(asla, EXT_UNRSV_BW); } else UNSET_SUBTLV(asla, EXT_UNRSV_BW); @@ -318,8 +309,7 @@ void isis_link_params_update_asla(struct isis_circuit *circuit, /* Main initialization / update function of the MPLS TE Circuit context */ /* Call when interface TE Link parameters are modified */ -void isis_link_params_update(struct isis_circuit *circuit, - struct interface *ifp) +void isis_link_params_update(struct isis_circuit *circuit, struct interface *ifp) { int i; struct prefix_ipv4 *addr; @@ -340,8 +330,7 @@ void isis_link_params_update(struct isis_circuit *circuit, /* Check if MPLS TE Circuit context has not been already created */ if (circuit->ext == NULL) { circuit->ext = isis_alloc_ext_subtlvs(); - te_debug(" |- Allocated new Ext-subTLVs for interface %s", - ifp->name); + te_debug(" |- Allocated new Ext-subTLVs for interface %s", ifp->name); } ext = circuit->ext; @@ -356,8 +345,7 @@ void isis_link_params_update(struct isis_circuit *circuit, UNSET_SUBTLV(ext, EXT_ADM_GRP); if (IS_PARAM_SET(ifp->link_params, LP_EXTEND_ADM_GRP)) { - admin_group_copy(&ext->ext_admin_group, - &ifp->link_params->ext_admin_grp); + admin_group_copy(&ext->ext_admin_group, &ifp->link_params->ext_admin_grp); SET_SUBTLV(ext, EXT_EXTEND_ADM_GRP); } else UNSET_SUBTLV(ext, EXT_EXTEND_ADM_GRP); @@ -365,8 +353,7 @@ void isis_link_params_update(struct isis_circuit *circuit, /* Send admin-group zero for better compatibility * https://www.rfc-editor.org/rfc/rfc7308#section-2.3.2 */ - if (circuit->area->admin_group_send_zero && - !IS_SUBTLV(ext, EXT_ADM_GRP) && + if (circuit->area->admin_group_send_zero && !IS_SUBTLV(ext, EXT_ADM_GRP) && !IS_SUBTLV(ext, EXT_EXTEND_ADM_GRP)) { ext->adm_group = 0; SET_SUBTLV(ext, EXT_ADM_GRP); @@ -387,8 +374,7 @@ void isis_link_params_update(struct isis_circuit *circuit, /* If known, register local IPv6 addr from ip_addr list */ if (listcount(circuit->ipv6_non_link) != 0) { addr6 = (struct prefix_ipv6 *)listgetdata( - (struct listnode *)listhead( - circuit->ipv6_non_link)); + (struct listnode *)listhead(circuit->ipv6_non_link)); IPV6_ADDR_COPY(&ext->local_addr6, &addr6->prefix); SET_SUBTLV(ext, EXT_LOCAL_ADDR6); } else @@ -415,8 +401,7 @@ void isis_link_params_update(struct isis_circuit *circuit, if (IS_PARAM_SET(ifp->link_params, LP_UNRSV_BW)) { for (i = 0; i < MAX_CLASS_TYPE; i++) - ext->unrsv_bw[i] = - ifp->link_params->unrsv_bw[i]; + ext->unrsv_bw[i] = ifp->link_params->unrsv_bw[i]; SET_SUBTLV(ext, EXT_UNRSV_BW); } else UNSET_SUBTLV(ext, EXT_UNRSV_BW); @@ -482,11 +467,9 @@ void isis_link_params_update(struct isis_circuit *circuit, UNSET_SUBTLV(ext, EXT_RMT_AS); UNSET_SUBTLV(ext, EXT_RMT_IP); } - te_debug(" |- New MPLS-TE link parameters status 0x%x", - ext->status); + te_debug(" |- New MPLS-TE link parameters status 0x%x", ext->status); } else { - te_debug(" |- Reset Extended subTLVs status 0x%x", - ext->status); + te_debug(" |- Reset Extended subTLVs status 0x%x", ext->status); /* Reset TE subTLVs keeping SR one's */ if (IS_SUBTLV(ext, EXT_ADJ_SID)) ext->status = EXT_ADJ_SID; @@ -505,8 +488,7 @@ void isis_link_params_update(struct isis_circuit *circuit, return; } -static int _isis_mpls_te_adj_ip_enabled(struct isis_adjacency *adj, int family, - bool global) +static int _isis_mpls_te_adj_ip_enabled(struct isis_adjacency *adj, int family, bool global) { struct isis_circuit *circuit; struct isis_ext_subtlvs *ext; @@ -525,8 +507,7 @@ static int _isis_mpls_te_adj_ip_enabled(struct isis_adjacency *adj, int family, if (!circuit->ip_router || !adj->ipv4_address_count) UNSET_SUBTLV(ext, EXT_NEIGH_ADDR); else { - IPV4_ADDR_COPY(&ext->neigh_addr, - &adj->ipv4_addresses[0]); + IPV4_ADDR_COPY(&ext->neigh_addr, &adj->ipv4_addresses[0]); SET_SUBTLV(ext, EXT_NEIGH_ADDR); } break; @@ -543,8 +524,7 @@ static int _isis_mpls_te_adj_ip_enabled(struct isis_adjacency *adj, int family, if (!circuit->ipv6_router || !adj->global_ipv6_count) UNSET_SUBTLV(ext, EXT_NEIGH_ADDR6); else { - IPV6_ADDR_COPY(&ext->neigh_addr6, - &adj->global_ipv6_addrs[0]); + IPV6_ADDR_COPY(&ext->neigh_addr6, &adj->global_ipv6_addrs[0]); SET_SUBTLV(ext, EXT_NEIGH_ADDR6); } break; @@ -555,8 +535,7 @@ static int _isis_mpls_te_adj_ip_enabled(struct isis_adjacency *adj, int family, return 0; } -static int isis_mpls_te_adj_ip_enabled(struct isis_adjacency *adj, int family, - bool global) +static int isis_mpls_te_adj_ip_enabled(struct isis_adjacency *adj, int family, bool global) { int ret; @@ -572,8 +551,7 @@ static int isis_mpls_te_adj_ip_enabled(struct isis_adjacency *adj, int family, return ret; } -static int _isis_mpls_te_adj_ip_disabled(struct isis_adjacency *adj, int family, - bool global) +static int _isis_mpls_te_adj_ip_disabled(struct isis_adjacency *adj, int family, bool global) { struct isis_circuit *circuit; struct isis_ext_subtlvs *ext; @@ -606,8 +584,7 @@ static int _isis_mpls_te_adj_ip_disabled(struct isis_adjacency *adj, int family, return 0; } -static int isis_mpls_te_adj_ip_disabled(struct isis_adjacency *adj, int family, - bool global) +static int isis_mpls_te_adj_ip_disabled(struct isis_adjacency *adj, int family, bool global) { int ret; @@ -674,12 +651,11 @@ int isis_mpls_te_update(struct interface *ifp) isis_link_params_update(circuit, ifp); /* ... and LSP */ - if (circuit->area && - (IS_MPLS_TE(circuit->area->mta) + if (circuit->area && (IS_MPLS_TE(circuit->area->mta) #ifndef FABRICD - || !list_isempty(circuit->area->flex_algos->flex_algos) + || !list_isempty(circuit->area->flex_algos->flex_algos) #endif /* ifndef FABRICD */ - )) + )) lsp_regenerate_schedule(circuit->area, circuit->is_type, 0); rc = 0; @@ -736,7 +712,7 @@ static struct ls_vertex *lsp_to_vertex(struct ls_ted *ted, struct isis_lsp *lsp) struct ls_vertex *vertex = NULL; struct ls_node *old, lnode = {}; struct isis_tlvs *tlvs; - const struct in_addr inaddr_any = {.s_addr = INADDR_ANY}; + const struct in_addr inaddr_any = { .s_addr = INADDR_ANY }; /* Sanity check */ if (!ted || !lsp) @@ -770,8 +746,7 @@ static struct ls_vertex *lsp_to_vertex(struct ls_ted *ted, struct isis_lsp *lsp) SET_FLAG(lnode.flags, LS_NODE_ROUTER_ID); } if (tlvs->te_router_id_ipv6) { - IPV6_ADDR_COPY(&lnode.router_id6, - tlvs->te_router_id_ipv6); + IPV6_ADDR_COPY(&lnode.router_id6, tlvs->te_router_id_ipv6); SET_FLAG(lnode.flags, LS_NODE_ROUTER_ID6); } if (tlvs->hostname) { @@ -781,8 +756,7 @@ static struct ls_vertex *lsp_to_vertex(struct ls_ted *ted, struct isis_lsp *lsp) if (tlvs->router_cap) { struct isis_router_cap *cap = tlvs->router_cap; - if (cap->srgb.lower_bound != 0 - && cap->srgb.range_size != 0) { + if (cap->srgb.lower_bound != 0 && cap->srgb.range_size != 0) { SET_FLAG(lnode.flags, LS_NODE_SR); lnode.srgb.flag = cap->srgb.flags; lnode.srgb.lower_bound = cap->srgb.lower_bound; @@ -791,8 +765,7 @@ static struct ls_vertex *lsp_to_vertex(struct ls_ted *ted, struct isis_lsp *lsp) lnode.algo[i] = cap->algo[i]; } - if (cap->srlb.lower_bound != 0 - && cap->srlb.range_size != 0) { + if (cap->srlb.lower_bound != 0 && cap->srlb.range_size != 0) { lnode.srlb.lower_bound = cap->srlb.lower_bound; lnode.srlb.range_size = cap->srlb.range_size; SET_FLAG(lnode.flags, LS_NODE_SRLB); @@ -883,15 +856,14 @@ static struct ls_edge *get_edge(struct ls_ted *ted, struct ls_attributes *attr) if (CHECK_FLAG(edge->attributes->flags, LS_ATTR_LOCAL_ADDR)) te_debug(" |- %s Edge (%pI4) from Extended Reach. %pI4", - edge->status == NEW ? "Create" : "Found", - &edge->key.k.addr, &attr->standard.local); + edge->status == NEW ? "Create" : "Found", &edge->key.k.addr, + &attr->standard.local); else if (CHECK_FLAG(edge->attributes->flags, LS_ATTR_LOCAL_ADDR6)) te_debug(" |- %s Edge (%pI6) from Extended Reach. %pI6", - edge->status == NEW ? "Create" : "Found", - &edge->key.k.addr6, &attr->standard.local6); + edge->status == NEW ? "Create" : "Found", &edge->key.k.addr6, + &attr->standard.local6); else - te_debug(" |- %s Edge (%" PRIu64 ")", - edge->status == NEW ? "Create" : "Found", + te_debug(" |- %s Edge (%" PRIu64 ")", edge->status == NEW ? "Create" : "Found", edge->key.k.link_id); return edge; @@ -906,11 +878,10 @@ static struct ls_edge *get_edge(struct ls_ted *ted, struct ls_attributes *attr) * * @return New Link State attributes if success, NULL otherwise */ -static struct ls_attributes *get_attributes(struct ls_node_id adv, - struct isis_ext_subtlvs *tlvs) +static struct ls_attributes *get_attributes(struct ls_node_id adv, struct isis_ext_subtlvs *tlvs) { struct ls_attributes *attr; - struct in_addr local = {.s_addr = INADDR_ANY}; + struct in_addr local = { .s_addr = INADDR_ANY }; struct in6_addr local6 = in6addr_any; uint32_t local_id = 0; @@ -935,8 +906,7 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv, SET_FLAG(attr->flags, LS_ATTR_ADM_GRP); } if (CHECK_FLAG(tlvs->status, EXT_EXTEND_ADM_GRP)) { - admin_group_copy(&attr->ext_admin_group, - &tlvs->ext_admin_group); + admin_group_copy(&attr->ext_admin_group, &tlvs->ext_admin_group); SET_FLAG(attr->flags, LS_ATTR_EXT_ADM_GRP); } if (CHECK_FLAG(tlvs->status, EXT_LLRI)) { @@ -950,8 +920,7 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv, SET_FLAG(attr->flags, LS_ATTR_NEIGH_ADDR); } if (CHECK_FLAG(tlvs->status, EXT_NEIGH_ADDR6)) { - memcpy(&attr->standard.remote6, &tlvs->neigh_addr6, - IPV6_MAX_BYTELEN); + memcpy(&attr->standard.remote6, &tlvs->neigh_addr6, IPV6_MAX_BYTELEN); SET_FLAG(attr->flags, LS_ATTR_NEIGH_ADDR6); } if (CHECK_FLAG(tlvs->status, EXT_MAX_BW)) { @@ -963,8 +932,7 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv, SET_FLAG(attr->flags, LS_ATTR_MAX_RSV_BW); } if (CHECK_FLAG(tlvs->status, EXT_UNRSV_BW)) { - memcpy(&attr->standard.unrsv_bw, tlvs->unrsv_bw, - ISIS_SUBTLV_UNRSV_BW_SIZE); + memcpy(&attr->standard.unrsv_bw, tlvs->unrsv_bw, ISIS_SUBTLV_UNRSV_BW_SIZE); SET_FLAG(attr->flags, LS_ATTR_UNRSV_BW); } if (CHECK_FLAG(tlvs->status, EXT_TE_METRIC)) { @@ -1009,8 +977,7 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv, SET_FLAG(attr->flags, LS_ATTR_USE_BW); } if (CHECK_FLAG(tlvs->status, EXT_ADJ_SID)) { - struct isis_adj_sid *adj = - (struct isis_adj_sid *)tlvs->adj_sid.head; + struct isis_adj_sid *adj = (struct isis_adj_sid *)tlvs->adj_sid.head; int i; for (; adj; adj = adj->next) { i = adj->flags & EXT_SUBTLV_LINK_ADJ_SID_BFLG ? 1 : 0; @@ -1035,8 +1002,7 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv, } } if (CHECK_FLAG(tlvs->status, EXT_LAN_ADJ_SID)) { - struct isis_lan_adj_sid *ladj = - (struct isis_lan_adj_sid *)tlvs->lan_sid.head; + struct isis_lan_adj_sid *ladj = (struct isis_lan_adj_sid *)tlvs->lan_sid.head; int i; for (; ladj; ladj = ladj->next) { i = ladj->flags & EXT_SUBTLV_LINK_ADJ_SID_BFLG ? 1 : 0; @@ -1044,8 +1010,8 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv, attr->adj_sid[i].flags = ladj->flags; attr->adj_sid[i].weight = ladj->weight; attr->adj_sid[i].sid = ladj->sid; - memcpy(&attr->adj_sid[i].neighbor.sysid, - &ladj->neighbor_id, ISIS_SYS_ID_LEN); + memcpy(&attr->adj_sid[i].neighbor.sysid, &ladj->neighbor_id, + ISIS_SYS_ID_LEN); switch (i) { case ADJ_PRI_IPV4: SET_FLAG(attr->flags, LS_ATTR_ADJ_SID); @@ -1064,8 +1030,7 @@ 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; + (struct isis_srv6_endx_sid_subtlv *)tlvs->srv6_endx_sid.head; int i; for (; endx; endx = endx->next) { @@ -1078,15 +1043,13 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv, } 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)); + 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; + (struct isis_srv6_lan_endx_sid_subtlv *)tlvs->srv6_lan_endx_sid.head; int i; for (; lendx; lendx = lendx->next) { @@ -1097,14 +1060,12 @@ static struct ls_attributes *get_attributes(struct ls_node_id adv, 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); + 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; + memcpy(&attr->adj_srv6_sid[i].sid, &lendx->sid, sizeof(struct in6_addr)); + attr->adj_srv6_sid[i].endpoint_behavior = lendx->behavior; } } return attr; @@ -1179,19 +1140,17 @@ static int lsp_to_edge_cb(const uint8_t *id, uint32_t metric, bool old_metric, /* Try to update remote Link from remote address or reachability ID */ if (edge->key.family == AF_INET) - te_debug(" |- Link Edge (%pI4) to destination vertex (%s)", - &edge->key.k.addr, print_sys_hostname(id)); + te_debug(" |- Link Edge (%pI4) to destination vertex (%s)", &edge->key.k.addr, + print_sys_hostname(id)); else if (edge->key.family == AF_INET6) - te_debug(" |- Link Edge (%pI6) to destination vertex (%s)", - &edge->key.k.addr6, print_sys_hostname(id)); + te_debug(" |- Link Edge (%pI6) to destination vertex (%s)", &edge->key.k.addr6, + print_sys_hostname(id)); else if (edge->key.family == AF_LOCAL) - te_debug(" |- Link Edge (%" PRIu64 - ") to destination vertex (%s)", + te_debug(" |- Link Edge (%" PRIu64 ") to destination vertex (%s)", edge->key.k.link_id, print_sys_hostname(id)); else - te_debug( - " |- Link Edge (Unknown) to destination vertex (%s)", - print_sys_hostname(id)); + te_debug(" |- Link Edge (Unknown) to destination vertex (%s)", + print_sys_hostname(id)); /* Then search if there is a reverse Edge to link them */ dst = ls_find_edge_by_destination(args->ted, edge->attributes); @@ -1231,9 +1190,8 @@ static int lsp_to_edge_cb(const uint8_t *id, uint32_t metric, bool old_metric, * * @return 0 if success, -1 otherwise */ -static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, - bool external, struct isis_subtlvs *subtlvs, - void *arg) +static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, bool external, + struct isis_subtlvs *subtlvs, void *arg) { struct isis_te_args *args = (struct isis_te_args *)arg; struct ls_vertex *vertex; @@ -1267,8 +1225,7 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, if (prefix->family == AF_INET && prefix->prefixlen < IPV4_MAX_BITLEN) { std = NULL; for (ALL_LIST_ELEMENTS_RO(vertex->outgoing_edges, node, edge)) { - if (!CHECK_FLAG(edge->attributes->flags, - LS_ATTR_LOCAL_ADDR)) + if (!CHECK_FLAG(edge->attributes->flags, LS_ATTR_LOCAL_ADDR)) continue; p.u.prefix4 = edge->attributes->standard.local; @@ -1283,12 +1240,10 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, if (std) p.u.prefix4 = std->local; - } else if (prefix->family == AF_INET6 - && prefix->prefixlen < IPV6_MAX_BITLEN) { + } else if (prefix->family == AF_INET6 && prefix->prefixlen < IPV6_MAX_BITLEN) { std = NULL; for (ALL_LIST_ELEMENTS_RO(vertex->outgoing_edges, node, edge)) { - if (!CHECK_FLAG(edge->attributes->flags, - LS_ATTR_LOCAL_ADDR6)) + if (!CHECK_FLAG(edge->attributes->flags, LS_ATTR_LOCAL_ADDR6)) continue; p.u.prefix6 = edge->attributes->standard.local6; @@ -1313,12 +1268,10 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, subnet->status = DELETE; isis_te_export(LS_MSG_TYPE_PREFIX, subnet); } - te_debug(" |- Remove subnet with prefix %pFX", - &subnet->key); + te_debug(" |- Remove subnet with prefix %pFX", &subnet->key); ls_subnet_del_all(args->ted, subnet); } - te_debug(" |- Adjust prefix %pFX with local address to: %pFX", - prefix, &p); + te_debug(" |- Adjust prefix %pFX with local address to: %pFX", prefix, &p); } /* Search existing Subnet in TED ... */ @@ -1333,12 +1286,11 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, } ls_pref = subnet->ls_pref; - te_debug(" |- %s Subnet from prefix %pFX", - subnet->status == NEW ? "Create" : "Found", &p); + te_debug(" |- %s Subnet from prefix %pFX", subnet->status == NEW ? "Create" : "Found", + &p); /* Update Metric */ - if (!CHECK_FLAG(ls_pref->flags, LS_PREF_METRIC) - || (ls_pref->metric != metric)) { + if (!CHECK_FLAG(ls_pref->flags, LS_PREF_METRIC) || (ls_pref->metric != metric)) { ls_pref->metric = metric; SET_FLAG(ls_pref->flags, LS_PREF_METRIC); if (subnet->status != NEW) @@ -1358,8 +1310,8 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, sr.sid_flag = psid->flags; sr.sid = psid->value; - if (!CHECK_FLAG(ls_pref->flags, LS_PREF_SR) - || !memcmp(&ls_pref->sr, &sr, sizeof(struct ls_sid))) { + if (!CHECK_FLAG(ls_pref->flags, LS_PREF_SR) || + !memcmp(&ls_pref->sr, &sr, sizeof(struct ls_sid))) { memcpy(&ls_pref->sr, &sr, sizeof(struct ls_sid)); SET_FLAG(ls_pref->flags, LS_PREF_SR); if (subnet->status != NEW) @@ -1384,8 +1336,7 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric, struct isis_srv6_end_sid_subtlv *psid; struct ls_srv6_sid sr = {}; - psid = (struct isis_srv6_end_sid_subtlv *) - subtlvs->srv6_end_sids.head; + psid = (struct isis_srv6_end_sid_subtlv *)subtlvs->srv6_end_sids.head; sr.behavior = psid->behavior; sr.flags = psid->flags; memcpy(&sr.sid, &psid->sid, sizeof(struct in6_addr)); @@ -1442,14 +1393,12 @@ static void isis_te_parse_lsp(struct mpls_te_area *mta, struct isis_lsp *lsp) ted = mta->ted; - te_debug("ISIS-TE(%s): Parse LSP %pSY", lsp->area->area_tag, - lsp->hdr.lsp_id); + te_debug("ISIS-TE(%s): Parse LSP %pSY", lsp->area->area_tag, lsp->hdr.lsp_id); /* First parse LSP to obtain the corresponding Vertex */ vertex = lsp_to_vertex(ted, lsp); if (!vertex) { - zlog_warn("Unable to build Vertex from LSP %pSY. Abort!", - lsp->hdr.lsp_id); + zlog_warn("Unable to build Vertex from LSP %pSY. Abort!", lsp->hdr.lsp_id); return; } @@ -1472,25 +1421,18 @@ static void isis_te_parse_lsp(struct mpls_te_area *mta, struct isis_lsp *lsp) args.ted = ted; args.vertex = vertex; args.export = mta->export; - isis_lsp_iterate_is_reach(lsp, ISIS_MT_IPV4_UNICAST, lsp_to_edge_cb, - &args); + isis_lsp_iterate_is_reach(lsp, ISIS_MT_IPV4_UNICAST, lsp_to_edge_cb, &args); - isis_lsp_iterate_is_reach(lsp, ISIS_MT_IPV6_UNICAST, lsp_to_edge_cb, - &args); + isis_lsp_iterate_is_reach(lsp, ISIS_MT_IPV6_UNICAST, lsp_to_edge_cb, &args); /* Process all Extended IP (v4 & v6) in LSP (all fragments) */ args.srv6_locator = false; - isis_lsp_iterate_ip_reach(lsp, AF_INET, ISIS_MT_IPV4_UNICAST, - lsp_to_subnet_cb, &args); - isis_lsp_iterate_ip_reach(lsp, AF_INET6, ISIS_MT_IPV6_UNICAST, - lsp_to_subnet_cb, &args); - isis_lsp_iterate_ip_reach(lsp, AF_INET6, ISIS_MT_IPV4_UNICAST, - lsp_to_subnet_cb, &args); + isis_lsp_iterate_ip_reach(lsp, AF_INET, ISIS_MT_IPV4_UNICAST, lsp_to_subnet_cb, &args); + isis_lsp_iterate_ip_reach(lsp, AF_INET6, ISIS_MT_IPV6_UNICAST, lsp_to_subnet_cb, &args); + isis_lsp_iterate_ip_reach(lsp, AF_INET6, ISIS_MT_IPV4_UNICAST, lsp_to_subnet_cb, &args); args.srv6_locator = true; - isis_lsp_iterate_srv6_locator(lsp, ISIS_MT_STANDARD, lsp_to_subnet_cb, - &args); - isis_lsp_iterate_srv6_locator(lsp, ISIS_MT_IPV6_UNICAST, - lsp_to_subnet_cb, &args); + isis_lsp_iterate_srv6_locator(lsp, ISIS_MT_STANDARD, lsp_to_subnet_cb, &args); + isis_lsp_iterate_srv6_locator(lsp, ISIS_MT_IPV6_UNICAST, lsp_to_subnet_cb, &args); /* Clean remaining Orphan Edges or Subnets */ if (IS_EXPORT_TE(mta)) @@ -1519,8 +1461,8 @@ static void isis_te_delete_lsp(struct mpls_te_area *mta, struct isis_lsp *lsp) if (!IS_MPLS_TE(mta) || !mta->ted || !lsp) return; - te_debug("ISIS-TE(%s): Delete Link State TED objects from LSP %pSY", - lsp->area->area_tag, lsp->hdr.lsp_id); + te_debug("ISIS-TE(%s): Delete Link State TED objects from LSP %pSY", lsp->area->area_tag, + lsp->hdr.lsp_id); /* Compute Link State Node ID from IS-IS sysID ... */ if (lsp->level == ISIS_LEVEL1) @@ -1638,21 +1580,18 @@ void isis_te_lsp_event(struct isis_lsp *lsp, enum lsp_event event) */ int isis_te_sync_ted(struct zapi_opaque_reg_info dst) { - struct listnode *node, *inode; struct isis *isis; struct isis_area *area; struct mpls_te_area *mta; int rc = -1; - te_debug("ISIS-TE(%s): Received TED synchro from client %d", __func__, - dst.proto); + te_debug("ISIS-TE(%s): Received TED synchro from client %d", __func__, dst.proto); /* For each area, send TED if TE distribution is enabled */ - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, area) { mta = area->mta; if (IS_MPLS_TE(mta) && IS_EXPORT_TE(mta)) { - te_debug(" |- Export TED from area %s", - area->area_tag); + te_debug(" |- Export TED from area %s", area->area_tag); rc = ls_sync_ted(mta->ted, isis_zclient, &dst); if (rc != 0) return rc; @@ -1687,13 +1626,11 @@ static void show_router_id(struct vty *vty, struct isis_area *area) vty_out(vty, "Area %s:\n", area->area_tag); if (area->mta->router_id.s_addr != 0) { - vty_out(vty, " MPLS-TE IPv4 Router-Address: %pI4\n", - &area->mta->router_id); + vty_out(vty, " MPLS-TE IPv4 Router-Address: %pI4\n", &area->mta->router_id); no_match = false; } if (!IN6_IS_ADDR_UNSPECIFIED(&area->mta->router_id_ipv6)) { - vty_out(vty, " MPLS-TE IPv6 Router-Address: %pI6\n", - &area->mta->router_id_ipv6); + vty_out(vty, " MPLS-TE IPv6 Router-Address: %pI6\n", &area->mta->router_id_ipv6); no_match = false; } if (no_match) @@ -1708,8 +1645,6 @@ DEFUN(show_isis_mpls_te_router, VRF_CMD_HELP_STR "All VRFs\n" MPLS_TE_STR "Router information\n") { - - struct listnode *anode, *inode; struct isis_area *area; struct isis *isis = NULL; const char *vrf_name = VRF_DEFAULT_NAME; @@ -1723,8 +1658,8 @@ DEFUN(show_isis_mpls_te_router, ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, area) { if (!IS_MPLS_TE(area->mta)) continue; @@ -1735,7 +1670,7 @@ DEFUN(show_isis_mpls_te_router, } isis = isis_lookup_by_vrfname(vrf_name); if (isis != NULL) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_area_list, &isis->area_list, area) { if (!IS_MPLS_TE(area->mta)) continue; @@ -1746,8 +1681,7 @@ DEFUN(show_isis_mpls_te_router, return CMD_SUCCESS; } -static void show_ext_sub(struct vty *vty, char *name, - struct isis_ext_subtlvs *ext) +static void show_ext_sub(struct vty *vty, char *name, struct isis_ext_subtlvs *ext) { struct sbuf buf; char ibuf[PREFIX2STR_BUFFER]; @@ -1762,86 +1696,63 @@ static void show_ext_sub(struct vty *vty, char *name, sbuf_reset(&buf); if (IS_SUBTLV(ext, EXT_ADM_GRP)) - sbuf_push(&buf, 4, "Administrative Group: 0x%x\n", - ext->adm_group); + sbuf_push(&buf, 4, "Administrative Group: 0x%x\n", ext->adm_group); if (IS_SUBTLV(ext, EXT_LLRI)) { - sbuf_push(&buf, 4, "Link Local ID: %u\n", - ext->local_llri); - sbuf_push(&buf, 4, "Link Remote ID: %u\n", - ext->remote_llri); + sbuf_push(&buf, 4, "Link Local ID: %u\n", ext->local_llri); + sbuf_push(&buf, 4, "Link Remote ID: %u\n", ext->remote_llri); } if (IS_SUBTLV(ext, EXT_LOCAL_ADDR)) - sbuf_push(&buf, 4, "Local Interface IP Address(es): %pI4\n", - &ext->local_addr); + sbuf_push(&buf, 4, "Local Interface IP Address(es): %pI4\n", &ext->local_addr); if (IS_SUBTLV(ext, EXT_NEIGH_ADDR)) - sbuf_push(&buf, 4, "Remote Interface IP Address(es): %pI4\n", - &ext->neigh_addr); + sbuf_push(&buf, 4, "Remote Interface IP Address(es): %pI4\n", &ext->neigh_addr); if (IS_SUBTLV(ext, EXT_LOCAL_ADDR6)) sbuf_push(&buf, 4, "Local Interface IPv6 Address(es): %s\n", - inet_ntop(AF_INET6, &ext->local_addr6, ibuf, - PREFIX2STR_BUFFER)); + inet_ntop(AF_INET6, &ext->local_addr6, ibuf, PREFIX2STR_BUFFER)); if (IS_SUBTLV(ext, EXT_NEIGH_ADDR6)) sbuf_push(&buf, 4, "Remote Interface IPv6 Address(es): %s\n", - inet_ntop(AF_INET6, &ext->local_addr6, ibuf, - PREFIX2STR_BUFFER)); + inet_ntop(AF_INET6, &ext->local_addr6, ibuf, PREFIX2STR_BUFFER)); if (IS_SUBTLV(ext, EXT_MAX_BW)) - sbuf_push(&buf, 4, "Maximum Bandwidth: %g (Bytes/sec)\n", - ext->max_bw); + sbuf_push(&buf, 4, "Maximum Bandwidth: %g (Bytes/sec)\n", ext->max_bw); if (IS_SUBTLV(ext, EXT_MAX_RSV_BW)) - sbuf_push(&buf, 4, - "Maximum Reservable Bandwidth: %g (Bytes/sec)\n", + sbuf_push(&buf, 4, "Maximum Reservable Bandwidth: %g (Bytes/sec)\n", ext->max_rsv_bw); if (IS_SUBTLV(ext, EXT_UNRSV_BW)) { sbuf_push(&buf, 4, "Unreserved Bandwidth:\n"); for (int j = 0; j < MAX_CLASS_TYPE; j += 2) { - sbuf_push(&buf, 4 + 2, - "[%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", - j, ext->unrsv_bw[j], - j + 1, ext->unrsv_bw[j + 1]); + sbuf_push(&buf, 4 + 2, "[%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", j, + ext->unrsv_bw[j], j + 1, ext->unrsv_bw[j + 1]); } } if (IS_SUBTLV(ext, EXT_TE_METRIC)) - sbuf_push(&buf, 4, "Traffic Engineering Metric: %u\n", - ext->te_metric); + sbuf_push(&buf, 4, "Traffic Engineering Metric: %u\n", ext->te_metric); if (IS_SUBTLV(ext, EXT_RMT_AS)) - sbuf_push(&buf, 4, - "Inter-AS TE Remote AS number: %u\n", - ext->remote_as); + sbuf_push(&buf, 4, "Inter-AS TE Remote AS number: %u\n", ext->remote_as); if (IS_SUBTLV(ext, EXT_RMT_IP)) - sbuf_push(&buf, 4, - "Inter-AS TE Remote ASBR IP address: %pI4\n", - &ext->remote_ip); + sbuf_push(&buf, 4, "Inter-AS TE Remote ASBR IP address: %pI4\n", &ext->remote_ip); if (IS_SUBTLV(ext, EXT_DELAY)) - sbuf_push(&buf, 4, - "%s Average Link Delay: %u (micro-sec)\n", + sbuf_push(&buf, 4, "%s Average Link Delay: %u (micro-sec)\n", IS_ANORMAL(ext->delay) ? "Anomalous" : "Normal", ext->delay & TE_EXT_MASK); if (IS_SUBTLV(ext, EXT_MM_DELAY)) { sbuf_push(&buf, 4, "%s Min/Max Link Delay: %u / %u (micro-sec)\n", IS_ANORMAL(ext->min_delay) ? "Anomalous" : "Normal", - ext->min_delay & TE_EXT_MASK, - ext->max_delay & TE_EXT_MASK); + ext->min_delay & TE_EXT_MASK, ext->max_delay & TE_EXT_MASK); } if (IS_SUBTLV(ext, EXT_DELAY_VAR)) - sbuf_push(&buf, 4, - "Delay Variation: %u (micro-sec)\n", + sbuf_push(&buf, 4, "Delay Variation: %u (micro-sec)\n", ext->delay_var & TE_EXT_MASK); if (IS_SUBTLV(ext, EXT_PKT_LOSS)) sbuf_push(&buf, 4, "%s Link Packet Loss: %g (%%)\n", IS_ANORMAL(ext->pkt_loss) ? "Anomalous" : "Normal", - (float)((ext->pkt_loss & TE_EXT_MASK) - * LOSS_PRECISION)); + (float)((ext->pkt_loss & TE_EXT_MASK) * LOSS_PRECISION)); if (IS_SUBTLV(ext, EXT_RES_BW)) - sbuf_push(&buf, 4, - "Unidirectional Residual Bandwidth: %g (Bytes/sec)\n", + sbuf_push(&buf, 4, "Unidirectional Residual Bandwidth: %g (Bytes/sec)\n", ext->res_bw); if (IS_SUBTLV(ext, EXT_AVA_BW)) - sbuf_push(&buf, 4, - "Unidirectional Available Bandwidth: %g (Bytes/sec)\n", + sbuf_push(&buf, 4, "Unidirectional Available Bandwidth: %g (Bytes/sec)\n", ext->ava_bw); if (IS_SUBTLV(ext, EXT_USE_BW)) - sbuf_push(&buf, 4, - "Unidirectional Utilized Bandwidth: %g (Bytes/sec)\n", + sbuf_push(&buf, 4, "Unidirectional Utilized Bandwidth: %g (Bytes/sec)\n", ext->use_bw); vty_multiline(vty, "", "%s", sbuf_buf(&buf)); @@ -1860,7 +1771,6 @@ DEFUN (show_isis_mpls_te_interface, "Interface information\n" "Interface name\n") { - struct listnode *anode, *cnode, *inode; struct isis_area *area; struct isis_circuit *circuit; struct interface *ifp; @@ -1874,20 +1784,15 @@ DEFUN (show_isis_mpls_te_interface, if (argc == idx_interface) { /* Show All Interfaces. */ - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, - area)) { - + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, area) { if (!IS_MPLS_TE(area->mta)) continue; vty_out(vty, "Area %s:\n", area->area_tag); - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, - cnode, circuit)) - show_ext_sub(vty, - circuit->interface->name, - circuit->ext); + frr_each (isis_circuit_list, &area->circuit_list, circuit) + show_ext_sub(vty, circuit->interface->name, circuit->ext); } } } else { @@ -1898,9 +1803,7 @@ DEFUN (show_isis_mpls_te_interface, else { circuit = circuit_scan_by_ifp(ifp); if (!circuit) - vty_out(vty, - "ISIS is not enabled on circuit %s\n", - ifp->name); + vty_out(vty, "ISIS is not enabled on circuit %s\n", ifp->name); else show_ext_sub(vty, ifp->name, circuit->ext); } @@ -1919,13 +1822,12 @@ DEFUN (show_isis_mpls_te_interface, * * @return Vertex if found, NULL otherwise */ -static struct ls_vertex *vertex_for_arg(struct ls_ted *ted, const char *id, - struct isis *isis) +static struct ls_vertex *vertex_for_arg(struct ls_ted *ted, const char *id, struct isis *isis) { - char sysid[255] = {0}; + char sysid[255] = { 0 }; uint8_t number[3]; const char *pos; - uint8_t lspid[ISIS_SYS_ID_LEN + 2] = {0}; + uint8_t lspid[ISIS_SYS_ID_LEN + 2] = { 0 }; struct isis_dynhn *dynhn; uint64_t key = 0; @@ -1946,16 +1848,14 @@ static struct ls_vertex *vertex_for_arg(struct ls_ted *ted, const char *id, pos = id + strlen(id) - 3; if (strncmp(pos, "-", 1) == 0) { memcpy(number, ++pos, 2); - lspid[ISIS_SYS_ID_LEN + 1] = - (uint8_t)strtol((char *)number, NULL, 16); + lspid[ISIS_SYS_ID_LEN + 1] = (uint8_t)strtol((char *)number, NULL, 16); pos -= 4; if (strncmp(pos, ".", 1) != 0) return NULL; } if (strncmp(pos, ".", 1) == 0) { memcpy(number, ++pos, 2); - lspid[ISIS_SYS_ID_LEN] = - (uint8_t)strtol((char *)number, NULL, 16); + lspid[ISIS_SYS_ID_LEN] = (uint8_t)strtol((char *)number, NULL, 16); sysid[pos - id - 1] = '\0'; } } @@ -1993,8 +1893,8 @@ static struct ls_vertex *vertex_for_arg(struct ls_ted *ted, const char *id, * * @return Command Success if OK, Command Warning otherwise */ -static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc, - struct isis_area *area, struct isis *isis) +static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc, struct isis_area *area, + struct isis *isis) { int idx; char *id; @@ -2021,8 +1921,7 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc, if (uj) json = json_object_new_object(); else - vty_out(vty, "Area %s:\n", - area->area_tag ? area->area_tag : "null"); + vty_out(vty, "Area %s:\n", area->area_tag ? area->area_tag : "null"); if (argv[argc - 1]->arg && strmatch(argv[argc - 1]->text, "detail")) detail = true; @@ -2030,8 +1929,7 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc, idx = 4; if (argv_find(argv, argc, "vertex", &idx)) { /* Show Vertex */ - id = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg - : NULL; + id = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; if (!id) vertex = NULL; else if (!strncmp(id, "self", 4)) @@ -2053,9 +1951,7 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc, /* Show Edge */ if (argv_find(argv, argc, "A.B.C.D", &idx)) { if (!inet_pton(AF_INET, argv[idx]->arg, &ip_addr)) { - vty_out(vty, - "Specified Edge ID %s is invalid\n", - argv[idx]->arg); + vty_out(vty, "Specified Edge ID %s is invalid\n", argv[idx]->arg); return CMD_WARNING_CONFIG_FAILED; } /* Get the Edge from the Link State Database */ @@ -2063,15 +1959,12 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc, IPV4_ADDR_COPY(&key.k.addr, &ip_addr); edge = ls_find_edge_by_key(ted, key); if (!edge) { - vty_out(vty, "No edge found for ID %pI4\n", - &ip_addr); + vty_out(vty, "No edge found for ID %pI4\n", &ip_addr); return CMD_WARNING; } } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { if (!inet_pton(AF_INET6, argv[idx]->arg, &ip6_addr)) { - vty_out(vty, - "Specified Edge ID %s is invalid\n", - argv[idx]->arg); + vty_out(vty, "Specified Edge ID %s is invalid\n", argv[idx]->arg); return CMD_WARNING_CONFIG_FAILED; } /* Get the Edge from the Link State Database */ @@ -2079,8 +1972,7 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc, IPV6_ADDR_COPY(&key.k.addr6, &ip6_addr); edge = ls_find_edge_by_key(ted, key); if (!edge) { - vty_out(vty, "No edge found for ID %pI6\n", - &ip6_addr); + vty_out(vty, "No edge found for ID %pI6\n", &ip6_addr); return CMD_WARNING; } } else @@ -2095,28 +1987,24 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc, /* Show Subnet */ if (argv_find(argv, argc, "A.B.C.D/M", &idx)) { if (!str2prefix(argv[idx]->arg, &pref)) { - vty_out(vty, "Invalid prefix format %s\n", - argv[idx]->arg); + vty_out(vty, "Invalid prefix format %s\n", argv[idx]->arg); return CMD_WARNING_CONFIG_FAILED; } /* Get the Subnet from the Link State Database */ subnet = ls_find_subnet(ted, &pref); if (!subnet) { - vty_out(vty, "No subnet found for ID %pFX\n", - &pref); + vty_out(vty, "No subnet found for ID %pFX\n", &pref); return CMD_WARNING; } } else if (argv_find(argv, argc, "X:X::X:X/M", &idx)) { if (!str2prefix(argv[idx]->arg, &pref)) { - vty_out(vty, "Invalid prefix format %s\n", - argv[idx]->arg); + vty_out(vty, "Invalid prefix format %s\n", argv[idx]->arg); return CMD_WARNING_CONFIG_FAILED; } /* Get the Subnet from the Link State Database */ subnet = ls_find_subnet(ted, &pref); if (!subnet) { - vty_out(vty, "No subnet found for ID %pFX\n", - &pref); + vty_out(vty, "No subnet found for ID %pFX\n", &pref); return CMD_WARNING; } } else @@ -2148,14 +2036,12 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc, * @return Command Success if OK, Command Warning otherwise */ -static int show_isis_ted(struct vty *vty, struct cmd_token *argv[], int argc, - struct isis *isis) +static int show_isis_ted(struct vty *vty, struct cmd_token *argv[], int argc, struct isis *isis) { - struct listnode *node; struct isis_area *area; int rc; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { rc = show_ted(vty, argv, argc, area, isis); if (rc != CMD_SUCCESS) return rc; @@ -2184,14 +2070,13 @@ DEFUN(show_isis_mpls_te_db, int idx_vrf = 0; const char *vrf_name = VRF_DEFAULT_NAME; bool all_vrf = false; - struct listnode *node; struct isis *isis; int rc = CMD_WARNING; ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { + frr_each (isis_instance_list, &im->isis, isis) { rc = show_isis_ted(vty, argv, argc, isis); if (rc != CMD_SUCCESS) return rc; @@ -2210,7 +2095,6 @@ DEFUN(show_isis_mpls_te_db, /* Initialize MPLS_TE */ void isis_mpls_te_init(void) { - /* Register Circuit and Adjacency hook */ hook_register(isis_if_new_hook, isis_mpls_te_update); hook_register(isis_adj_ip_enabled_hook, isis_mpls_te_adj_ip_enabled); diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c index e485829f5217..af2df5d1f9e6 100644 --- a/isisd/isis_tlvs.c +++ b/isisd/isis_tlvs.c @@ -40,26 +40,22 @@ #include "isisd/isis_sr.h" #include "isisd/isis_flex_algo.h" -#define TLV_SIZE_MISMATCH(log, indent, target) \ - sbuf_push(log, indent, \ - "TLV size does not match expected size for " target "!\n") +#define TLV_SIZE_MISMATCH(log, indent, target) \ + sbuf_push(log, indent, "TLV size does not match expected size for " target "!\n") DEFINE_MTYPE_STATIC(ISISD, ISIS_TLV, "ISIS TLVs"); DEFINE_MTYPE(ISISD, ISIS_SUBTLV, "ISIS Sub-TLVs"); DEFINE_MTYPE(ISISD, ISIS_SUBSUBTLV, "ISIS Sub-Sub-TLVs"); DEFINE_MTYPE_STATIC(ISISD, ISIS_MT_ITEM_LIST, "ISIS MT Item Lists"); -typedef int (*unpack_tlv_func)(enum isis_tlv_context context, uint8_t tlv_type, - uint8_t tlv_len, struct stream *s, - struct sbuf *log, void *dest, int indent); -typedef int (*pack_item_func)(struct isis_item *item, struct stream *s, - size_t *min_length); +typedef int (*unpack_tlv_func)(enum isis_tlv_context context, uint8_t tlv_type, uint8_t tlv_len, + struct stream *s, struct sbuf *log, void *dest, int indent); +typedef int (*pack_item_func)(struct isis_item *item, struct stream *s, size_t *min_length); typedef void (*free_item_func)(struct isis_item *i); -typedef int (*unpack_item_func)(uint16_t mtid, uint8_t len, struct stream *s, - struct sbuf *log, void *dest, int indent); -typedef void (*format_item_func)(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent); +typedef int (*unpack_item_func)(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, + void *dest, int indent); +typedef void (*format_item_func)(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent); typedef struct isis_item *(*copy_item_func)(struct isis_item *i); struct tlv_ops { @@ -84,11 +80,10 @@ struct pack_order_entry { enum how_to_pack how_to_pack; size_t what_to_pack; }; -#define PACK_ENTRY(t, h, w) \ - { \ - .context = ISIS_CONTEXT_LSP, .type = ISIS_TLV_##t, \ - .how_to_pack = (h), \ - .what_to_pack = offsetof(struct isis_tlvs, w), \ +#define PACK_ENTRY(t, h, w) \ + { \ + .context = ISIS_CONTEXT_LSP, .type = ISIS_TLV_##t, .how_to_pack = (h), \ + .what_to_pack = offsetof(struct isis_tlvs, w), \ } static const struct pack_order_entry pack_order[] = { @@ -119,16 +114,12 @@ static const struct tlv_ops *const tlv_table[ISIS_CONTEXT_MAX][ISIS_TLV_MAX]; static void append_item(struct isis_item_list *dest, struct isis_item *item); static void init_item_list(struct isis_item_list *items); -static struct isis_subsubtlvs * -isis_copy_subsubtlvs(struct isis_subsubtlvs *subsubtlvs); -static void isis_format_subsubtlvs(struct isis_subsubtlvs *subsubtlvs, - struct sbuf *buf, struct json_object *json, - int indent); -static int isis_pack_subsubtlvs(struct isis_subsubtlvs *subsubtlvs, - struct stream *s); -static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len, - struct stream *stream, struct sbuf *log, void *dest, - int indent, bool *unpacked_known_tlvs); +static struct isis_subsubtlvs *isis_copy_subsubtlvs(struct isis_subsubtlvs *subsubtlvs); +static void isis_format_subsubtlvs(struct isis_subsubtlvs *subsubtlvs, struct sbuf *buf, + struct json_object *json, int indent); +static int isis_pack_subsubtlvs(struct isis_subsubtlvs *subsubtlvs, struct stream *s); +static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len, struct stream *stream, + struct sbuf *log, void *dest, int indent, bool *unpacked_known_tlvs); static void isis_free_subsubtlvs(struct isis_subsubtlvs *subsubtlvs); static void isis_tlvs_del_asla_free(void *arg); @@ -205,8 +196,7 @@ void isis_del_ext_subtlvs(struct isis_ext_subtlvs *ext) * Multi-Topology. Special 4096 value i.e. first R flag set is used to indicate * that MT is disabled i.e. IS-IS is working with a Single Topology. */ -static struct isis_ext_subtlvs * -copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) +static struct isis_ext_subtlvs *copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) { struct isis_ext_subtlvs *rv = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(*rv)); struct isis_adj_sid *adj; @@ -244,13 +234,10 @@ copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) UNSET_SUBTLV(rv, EXT_SRV6_LAN_ENDX_SID); /* Copy Adj SID list for IPv4 & IPv6 in function of MT ID */ - for (adj = (struct isis_adj_sid *)exts->adj_sid.head; adj != NULL; - adj = adj->next) { - if ((mtid != ISIS_MT_DISABLE) - && (((mtid == ISIS_MT_IPV4_UNICAST) - && (adj->family != AF_INET)) - || ((mtid == ISIS_MT_IPV6_UNICAST) - && (adj->family != AF_INET6)))) + for (adj = (struct isis_adj_sid *)exts->adj_sid.head; adj != NULL; adj = adj->next) { + if ((mtid != ISIS_MT_DISABLE) && + (((mtid == ISIS_MT_IPV4_UNICAST) && (adj->family != AF_INET)) || + ((mtid == ISIS_MT_IPV6_UNICAST) && (adj->family != AF_INET6)))) continue; struct isis_adj_sid *new; @@ -265,13 +252,10 @@ copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) } /* Same for LAN Adj SID */ - for (lan = (struct isis_lan_adj_sid *)exts->lan_sid.head; lan != NULL; - lan = lan->next) { - if ((mtid != ISIS_MT_DISABLE) - && (((mtid == ISIS_MT_IPV4_UNICAST) - && (lan->family != AF_INET)) - || ((mtid == ISIS_MT_IPV6_UNICAST) - && (lan->family != AF_INET6)))) + for (lan = (struct isis_lan_adj_sid *)exts->lan_sid.head; lan != NULL; lan = lan->next) { + if ((mtid != ISIS_MT_DISABLE) && + (((mtid == ISIS_MT_IPV4_UNICAST) && (lan->family != AF_INET)) || + ((mtid == ISIS_MT_IPV6_UNICAST) && (lan->family != AF_INET6)))) continue; struct isis_lan_adj_sid *new; @@ -287,8 +271,7 @@ copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) } /* Copy SRv6 End.X SID list for IPv4 & IPv6 in function of MT ID */ - for (srv6_adj = (struct isis_srv6_endx_sid_subtlv *) - exts->srv6_endx_sid.head; + for (srv6_adj = (struct isis_srv6_endx_sid_subtlv *)exts->srv6_endx_sid.head; srv6_adj != NULL; srv6_adj = srv6_adj->next) { if ((mtid != 65535) && (mtid != ISIS_MT_DISABLE) && ((mtid != ISIS_MT_IPV6_UNICAST))) @@ -296,8 +279,7 @@ copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) struct isis_srv6_endx_sid_subtlv *new; - new = XCALLOC(MTYPE_ISIS_SUBTLV, - sizeof(struct isis_srv6_endx_sid_subtlv)); + new = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(struct isis_srv6_endx_sid_subtlv)); new->flags = srv6_adj->flags; new->algorithm = srv6_adj->algorithm; new->weight = srv6_adj->weight; @@ -308,8 +290,7 @@ copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) SET_SUBTLV(rv, EXT_SRV6_ENDX_SID); } /* Same for SRv6 LAN End.X SID */ - for (srv6_lan = (struct isis_srv6_lan_endx_sid_subtlv *) - exts->srv6_lan_endx_sid.head; + for (srv6_lan = (struct isis_srv6_lan_endx_sid_subtlv *)exts->srv6_lan_endx_sid.head; srv6_lan != NULL; srv6_lan = srv6_lan->next) { if ((mtid != 65535) && (mtid != ISIS_MT_DISABLE) && ((mtid != ISIS_MT_IPV6_UNICAST))) @@ -317,8 +298,7 @@ copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) struct isis_srv6_lan_endx_sid_subtlv *new; - new = XCALLOC(MTYPE_ISIS_SUBTLV, - sizeof(struct isis_srv6_lan_endx_sid_subtlv)); + new = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(struct isis_srv6_lan_endx_sid_subtlv)); memcpy(new->neighbor_id, srv6_lan->neighbor_id, 6); new->flags = srv6_lan->flags; new->algorithm = srv6_lan->algorithm; @@ -333,13 +313,11 @@ copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) rv->aslas = list_new(); for (ALL_LIST_ELEMENTS(exts->aslas, node, nnode, asla)) { - new_asla = XCALLOC(MTYPE_ISIS_SUBTLV, - sizeof(struct isis_asla_subtlvs)); + new_asla = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(struct isis_asla_subtlvs)); memcpy(new_asla, asla, sizeof(struct isis_asla_subtlvs)); new_asla->ext_admin_group.bitmap.data = NULL; - admin_group_copy(&new_asla->ext_admin_group, - &asla->ext_admin_group); + admin_group_copy(&new_asla->ext_admin_group, &asla->ext_admin_group); listnode_add(rv->aslas, new_asla); } @@ -350,8 +328,7 @@ copy_item_ext_subtlvs(struct isis_ext_subtlvs *exts, uint16_t mtid) return rv; } -static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, - struct json_object *ext_json, +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]; @@ -364,45 +341,34 @@ static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, 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); + 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); + 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]); + 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); + 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); + 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(); + struct json_object *unrsv_json = json_object_new_object(); - json_object_object_add(json, "unrsvBandwithBytesSec", - unrsv_json); + 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]); + json_object_string_addf(unrsv_json, cnt_buf, "%g", + asla->unrsv_bw[j]); } } if (IS_SUBTLV(asla, EXT_TE_METRIC)) @@ -415,9 +381,7 @@ static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, 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"); + IS_ANORMAL(asla->delay) ? "Anomalous" : "Normal"); json_object_int_add(avg_json, "microSec", asla->delay); } if (IS_SUBTLV(asla, EXT_MM_DELAY)) { @@ -426,9 +390,8 @@ static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, 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"); + 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); @@ -440,38 +403,29 @@ static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, struct json_object *link_json; link_json = json_object_new_object(); - json_object_object_add(json, "linkPacketLoss", - link_json); + json_object_object_add(json, "linkPacketLoss", link_json); json_object_string_add(link_json, "loss", - IS_ANORMAL(asla->pkt_loss) - ? "Anomalous" - : "Normal"); + IS_ANORMAL(asla->pkt_loss) ? "Anomalous" : "Normal"); json_object_string_addf(link_json, "percentage", "%g", - (float)((asla->pkt_loss & - TE_EXT_MASK) * + (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)); + 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)); + 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)); + 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, - "L flag: %u, SA-Length: %u, UDA-Length: %u\n", asla->legacy, + sbuf_push(buf, indent + 2, "L flag: %u, SA-Length: %u, UDA-Length: %u\n", asla->legacy, asla->standard_apps_length, asla->user_def_apps_length); - sbuf_push(buf, indent + 2, "Standard Applications: 0x%02x", - asla->standard_apps); + sbuf_push(buf, indent + 2, "Standard Applications: 0x%02x", asla->standard_apps); if (asla->standard_apps) { uint8_t bit = asla->standard_apps; if (bit & ISIS_SABM_FLAG_R) @@ -484,66 +438,49 @@ static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, sbuf_push(buf, 0, " Flex-Algo"); } sbuf_push(buf, 0, "\n"); - sbuf_push(buf, indent + 2, "User Defined Applications: 0x%02x\n", - asla->user_def_apps); + sbuf_push(buf, indent + 2, "User Defined Applications: 0x%02x\n", asla->user_def_apps); if (IS_SUBTLV(asla, EXT_ADM_GRP)) { - sbuf_push(buf, indent + 2, "Admin Group: 0x%08x\n", - asla->admin_group); + sbuf_push(buf, indent + 2, "Admin Group: 0x%08x\n", asla->admin_group); sbuf_push(buf, indent + 4, "Bit positions: %s\n", - admin_group_standard_print( - admin_group_buf, - indent + 2 + strlen("Admin Group: "), - asla->admin_group)); + admin_group_standard_print(admin_group_buf, + indent + 2 + strlen("Admin Group: "), + asla->admin_group)); } if (IS_SUBTLV(asla, EXT_EXTEND_ADM_GRP) && admin_group_nb_words(&asla->ext_admin_group) != 0) { sbuf_push(buf, indent + 2, "Ext Admin Group: %s\n", - admin_group_string( - admin_group_buf, ADMIN_GROUP_PRINT_MAX_SIZE, - indent + 2 + strlen("Ext Admin Group: "), - &asla->ext_admin_group)); - admin_group_print(admin_group_buf, - indent + 2 + strlen("Ext Admin Group: "), + admin_group_string(admin_group_buf, ADMIN_GROUP_PRINT_MAX_SIZE, + indent + 2 + strlen("Ext Admin Group: "), + &asla->ext_admin_group)); + admin_group_print(admin_group_buf, indent + 2 + strlen("Ext Admin Group: "), &asla->ext_admin_group); if (admin_group_buf[0] != '\0' && - (buf->pos + strlen(admin_group_buf) + - SBUF_DEFAULT_SIZE / 2) < buf->size) - sbuf_push(buf, indent + 4, "Bit positions: %s\n", - admin_group_buf); + (buf->pos + strlen(admin_group_buf) + SBUF_DEFAULT_SIZE / 2) < buf->size) + sbuf_push(buf, indent + 4, "Bit positions: %s\n", admin_group_buf); } if (IS_SUBTLV(asla, EXT_MAX_BW)) - sbuf_push(buf, indent + 2, - "Maximum Bandwidth: %g (Bytes/sec)\n", asla->max_bw); + sbuf_push(buf, indent + 2, "Maximum Bandwidth: %g (Bytes/sec)\n", asla->max_bw); if (IS_SUBTLV(asla, EXT_MAX_RSV_BW)) - sbuf_push(buf, indent + 2, - "Maximum Reservable Bandwidth: %g (Bytes/sec)\n", + sbuf_push(buf, indent + 2, "Maximum Reservable Bandwidth: %g (Bytes/sec)\n", asla->max_rsv_bw); if (IS_SUBTLV(asla, EXT_UNRSV_BW)) { sbuf_push(buf, indent + 2, "Unreserved Bandwidth:\n"); for (j = 0; j < MAX_CLASS_TYPE; j += 2) { - sbuf_push( - buf, indent + 2, - "[%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", - j, asla->unrsv_bw[j], j + 1, - asla->unrsv_bw[j + 1]); + sbuf_push(buf, indent + 2, "[%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", + j, asla->unrsv_bw[j], j + 1, asla->unrsv_bw[j + 1]); } } if (IS_SUBTLV(asla, EXT_TE_METRIC)) - sbuf_push(buf, indent + 2, "Traffic Engineering Metric: %u\n", - asla->te_metric); + sbuf_push(buf, indent + 2, "Traffic Engineering Metric: %u\n", asla->te_metric); /* Extended metrics */ if (IS_SUBTLV(asla, EXT_DELAY)) - sbuf_push(buf, indent + 2, - "%s Average Link Delay: %u (micro-sec)\n", - IS_ANORMAL(asla->delay) ? "Anomalous" : "Normal", - asla->delay); + sbuf_push(buf, indent + 2, "%s Average Link Delay: %u (micro-sec)\n", + IS_ANORMAL(asla->delay) ? "Anomalous" : "Normal", asla->delay); if (IS_SUBTLV(asla, EXT_MM_DELAY)) { - sbuf_push(buf, indent + 2, - "%s Min/Max Link Delay: %u / %u (micro-sec)\n", + sbuf_push(buf, indent + 2, "%s Min/Max Link Delay: %u / %u (micro-sec)\n", IS_ANORMAL(asla->min_delay) ? "Anomalous" : "Normal", - asla->min_delay & TE_EXT_MASK, - asla->max_delay & TE_EXT_MASK); + asla->min_delay & TE_EXT_MASK, asla->max_delay & TE_EXT_MASK); } if (IS_SUBTLV(asla, EXT_DELAY_VAR)) { sbuf_push(buf, indent + 2, "Delay Variation: %u (micro-sec)\n", @@ -552,26 +489,21 @@ static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, if (IS_SUBTLV(asla, EXT_PKT_LOSS)) sbuf_push(buf, indent + 2, "%s Link Packet Loss: %g (%%)\n", IS_ANORMAL(asla->pkt_loss) ? "Anomalous" : "Normal", - (float)((asla->pkt_loss & TE_EXT_MASK) * - LOSS_PRECISION)); + (float)((asla->pkt_loss & TE_EXT_MASK) * LOSS_PRECISION)); if (IS_SUBTLV(asla, EXT_RES_BW)) - sbuf_push(buf, indent + 2, - "Unidir. Residual Bandwidth: %g (Bytes/sec)\n", + sbuf_push(buf, indent + 2, "Unidir. Residual Bandwidth: %g (Bytes/sec)\n", asla->res_bw); if (IS_SUBTLV(asla, EXT_AVA_BW)) - sbuf_push(buf, indent + 2, - "Unidir. Available Bandwidth: %g (Bytes/sec)\n", + sbuf_push(buf, indent + 2, "Unidir. Available Bandwidth: %g (Bytes/sec)\n", asla->ava_bw); if (IS_SUBTLV(asla, EXT_USE_BW)) - sbuf_push(buf, indent + 2, - "Unidir. Utilized Bandwidth: %g (Bytes/sec)\n", + sbuf_push(buf, indent + 2, "Unidir. Utilized Bandwidth: %g (Bytes/sec)\n", asla->use_bw); } /* 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, - int indent, uint16_t mtid) +static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, struct sbuf *buf, + struct json_object *json, int indent, uint16_t mtid) { char admin_group_buf[ADMIN_GROUP_PRINT_MAX_SIZE]; char aux_buf[255]; @@ -582,17 +514,14 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, /* Standard metrics */ if (IS_SUBTLV(exts, EXT_ADM_GRP)) { if (json) { - snprintfrr(aux_buf, sizeof(aux_buf), "0x%x", - exts->adm_group); + snprintfrr(aux_buf, sizeof(aux_buf), "0x%x", exts->adm_group); json_object_string_add(json, "admGroup", aux_buf); } else { - sbuf_push(buf, indent, "Admin Group: 0x%08x\n", - exts->adm_group); + sbuf_push(buf, indent, "Admin Group: 0x%08x\n", exts->adm_group); sbuf_push(buf, indent + 2, "Bit positions: %s\n", - admin_group_standard_print( - admin_group_buf, - indent + strlen("Admin Group: "), - exts->adm_group)); + admin_group_standard_print(admin_group_buf, + indent + strlen("Admin Group: "), + exts->adm_group)); } } @@ -602,134 +531,97 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, 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]); + 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, - ADMIN_GROUP_PRINT_MAX_SIZE, - indent + strlen("Ext Admin Group: "), - &exts->ext_admin_group)); - admin_group_print(admin_group_buf, - indent + strlen("Ext Admin Group: "), + admin_group_string(admin_group_buf, ADMIN_GROUP_PRINT_MAX_SIZE, + indent + strlen("Ext Admin Group: "), + &exts->ext_admin_group)); + admin_group_print(admin_group_buf, indent + strlen("Ext Admin Group: "), &exts->ext_admin_group); - if (admin_group_buf[0] != '\0' && - (buf->pos + strlen(admin_group_buf) + - SBUF_DEFAULT_SIZE / 2) < buf->size) - sbuf_push(buf, indent + 2, - "Bit positions: %s\n", - admin_group_buf); + if (admin_group_buf[0] != '\0' && (buf->pos + strlen(admin_group_buf) + + SBUF_DEFAULT_SIZE / 2) < buf->size) + sbuf_push(buf, indent + 2, "Bit positions: %s\n", admin_group_buf); } } if (IS_SUBTLV(exts, EXT_LLRI)) { if (json) { - json_object_int_add(json, "linkLocalId", - exts->local_llri); - json_object_int_add(json, "linkRemoteId", - 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); - sbuf_push(buf, indent, "Link Remote ID: %u\n", - exts->remote_llri); + sbuf_push(buf, indent, "Link Local ID: %u\n", exts->local_llri); + sbuf_push(buf, indent, "Link Remote ID: %u\n", exts->remote_llri); } } if (IS_SUBTLV(exts, EXT_LOCAL_ADDR)) { if (json) { - inet_ntop(AF_INET, &exts->local_addr, aux_buf, - sizeof(aux_buf)); + inet_ntop(AF_INET, &exts->local_addr, aux_buf, sizeof(aux_buf)); json_object_string_add(json, "localIfaceIp", aux_buf); } else - sbuf_push(buf, indent, - "Local Interface IP Address(es): %pI4\n", + sbuf_push(buf, indent, "Local Interface IP Address(es): %pI4\n", &exts->local_addr); } if (IS_SUBTLV(exts, EXT_NEIGH_ADDR)) { if (json) { - inet_ntop(AF_INET, &exts->neigh_addr, aux_buf, - sizeof(aux_buf)); + inet_ntop(AF_INET, &exts->neigh_addr, aux_buf, sizeof(aux_buf)); json_object_string_add(json, "remoteIfaceIp", aux_buf); } else - sbuf_push(buf, indent, - "Remote Interface IP Address(es): %pI4\n", + sbuf_push(buf, indent, "Remote Interface IP Address(es): %pI4\n", &exts->neigh_addr); } if (IS_SUBTLV(exts, EXT_LOCAL_ADDR6)) { if (json) { - inet_ntop(AF_INET6, &exts->local_addr6, aux_buf, - sizeof(aux_buf)); + inet_ntop(AF_INET6, &exts->local_addr6, aux_buf, sizeof(aux_buf)); json_object_string_add(json, "localIfaceIpv6", aux_buf); } else - sbuf_push(buf, indent, - "Local Interface IPv6 Address(es): %pI6\n", + sbuf_push(buf, indent, "Local Interface IPv6 Address(es): %pI6\n", &exts->local_addr6); } if (IS_SUBTLV(exts, EXT_NEIGH_ADDR6)) { if (json) { - inet_ntop(AF_INET6, &exts->neigh_addr6, aux_buf, - sizeof(aux_buf)); + inet_ntop(AF_INET6, &exts->neigh_addr6, aux_buf, sizeof(aux_buf)); json_object_string_add(json, "remoteIfaceIpv6", aux_buf); } else - sbuf_push(buf, indent, - "Remote Interface IPv6 Address(es): %pI6\n", + sbuf_push(buf, indent, "Remote Interface IPv6 Address(es): %pI6\n", &exts->neigh_addr6); } if (IS_SUBTLV(exts, EXT_MAX_BW)) { if (json) { - snprintfrr(aux_buf, sizeof(aux_buf), "%g", - exts->max_bw); - json_object_string_add(json, "maxBandwithBytesSec", - aux_buf); + snprintfrr(aux_buf, sizeof(aux_buf), "%g", exts->max_bw); + json_object_string_add(json, "maxBandwithBytesSec", aux_buf); } else - sbuf_push(buf, indent, - "Maximum Bandwidth: %g (Bytes/sec)\n", - exts->max_bw); + sbuf_push(buf, indent, "Maximum Bandwidth: %g (Bytes/sec)\n", exts->max_bw); } if (IS_SUBTLV(exts, EXT_MAX_RSV_BW)) { if (json) { - snprintfrr(aux_buf, sizeof(aux_buf), "%g", - exts->max_rsv_bw); - json_object_string_add(json, "maxResBandwithBytesSec", - aux_buf); + snprintfrr(aux_buf, sizeof(aux_buf), "%g", exts->max_rsv_bw); + json_object_string_add(json, "maxResBandwithBytesSec", aux_buf); } else - sbuf_push( - buf, indent, - "Maximum Reservable Bandwidth: %g (Bytes/sec)\n", - exts->max_rsv_bw); + sbuf_push(buf, indent, "Maximum Reservable Bandwidth: %g (Bytes/sec)\n", + exts->max_rsv_bw); } 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); + 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); + snprintfrr(aux_buf, sizeof(aux_buf), "%g", exts->unrsv_bw[j]); + json_object_string_add(unrsv_json, cnt_buf, aux_buf); } } else { sbuf_push(buf, indent, "Unreserved Bandwidth:\n"); for (int j = 0; j < MAX_CLASS_TYPE; j += 2) { - sbuf_push( - buf, indent + 2, - "[%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", - j, exts->unrsv_bw[j], j + 1, - exts->unrsv_bw[j + 1]); + sbuf_push(buf, indent + 2, + "[%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", j, + exts->unrsv_bw[j], j + 1, exts->unrsv_bw[j + 1]); } } } @@ -737,28 +629,21 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (json) json_object_int_add(json, "teMetric", exts->te_metric); else - sbuf_push(buf, indent, - "Traffic Engineering Metric: %u\n", - exts->te_metric); + sbuf_push(buf, indent, "Traffic Engineering Metric: %u\n", exts->te_metric); } if (IS_SUBTLV(exts, EXT_RMT_AS)) { if (json) - json_object_int_add(json, "interAsTeRemoteAs", - 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", + sbuf_push(buf, indent, "Inter-AS TE Remote AS number: %u\n", exts->remote_as); } if (IS_SUBTLV(exts, EXT_RMT_IP)) { if (json) { - inet_ntop(AF_INET6, &exts->remote_ip, aux_buf, - sizeof(aux_buf)); - json_object_string_add(json, "interAsTeRemoteAsbrIp", - aux_buf); + inet_ntop(AF_INET6, &exts->remote_ip, aux_buf, sizeof(aux_buf)); + json_object_string_add(json, "interAsTeRemoteAsbrIp", aux_buf); } else - sbuf_push(buf, indent, - "Inter-AS TE Remote ASBR IP address: %pI4\n", + sbuf_push(buf, indent, "Inter-AS TE Remote ASBR IP address: %pI4\n", &exts->remote_ip); } /* Extended metrics */ @@ -769,15 +654,11 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, 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"); + 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", - IS_ANORMAL(exts->delay) ? "Anomalous" - : "Normal", + sbuf_push(buf, indent, "%s Average Link Delay: %u (micro-sec)\n", + IS_ANORMAL(exts->delay) ? "Anomalous" : "Normal", exts->delay & TE_EXT_MASK); } if (IS_SUBTLV(exts, EXT_MM_DELAY)) { @@ -787,92 +668,64 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, 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"); + 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); + 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, - "%s Min/Max Link Delay: %u / %u (micro-sec)\n", - IS_ANORMAL(exts->min_delay) ? "Anomalous" - : "Normal", - exts->min_delay & TE_EXT_MASK, - exts->max_delay & TE_EXT_MASK); + sbuf_push(buf, indent, "%s Min/Max Link Delay: %u / %u (micro-sec)\n", + IS_ANORMAL(exts->min_delay) ? "Anomalous" : "Normal", + exts->min_delay & TE_EXT_MASK, exts->max_delay & TE_EXT_MASK); } if (IS_SUBTLV(exts, EXT_DELAY_VAR)) { if (json) json_object_int_add(json, "delayVariationMicroSec", exts->delay_var & TE_EXT_MASK); else - sbuf_push(buf, indent, - "Delay Variation: %u (micro-sec)\n", + sbuf_push(buf, indent, "Delay Variation: %u (micro-sec)\n", exts->delay_var & TE_EXT_MASK); } if (IS_SUBTLV(exts, EXT_PKT_LOSS)) { if (json) { snprintfrr(aux_buf, sizeof(aux_buf), "%g", - (float)((exts->pkt_loss & TE_EXT_MASK) * - LOSS_PRECISION)); + (float)((exts->pkt_loss & TE_EXT_MASK) * LOSS_PRECISION)); struct json_object *link_json; link_json = json_object_new_object(); - json_object_object_add(json, "linkPacketLoss", - link_json); + json_object_object_add(json, "linkPacketLoss", link_json); json_object_string_add(link_json, "loss", - IS_ANORMAL(exts->pkt_loss) - ? "Anomalous" - : "Normal"); + 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" - : "Normal", - (float)((exts->pkt_loss & TE_EXT_MASK) * - LOSS_PRECISION)); + IS_ANORMAL(exts->pkt_loss) ? "Anomalous" : "Normal", + (float)((exts->pkt_loss & TE_EXT_MASK) * LOSS_PRECISION)); } if (IS_SUBTLV(exts, EXT_RES_BW)) { if (json) { - snprintfrr(aux_buf, sizeof(aux_buf), "%g", - (exts->res_bw)); - json_object_string_add(json, - "unidirResidualBandBytesSec", - aux_buf); + snprintfrr(aux_buf, sizeof(aux_buf), "%g", (exts->res_bw)); + json_object_string_add(json, "unidirResidualBandBytesSec", aux_buf); } else - sbuf_push( - buf, indent, - "Unidir. Residual Bandwidth: %g (Bytes/sec)\n", - exts->res_bw); + sbuf_push(buf, indent, "Unidir. Residual Bandwidth: %g (Bytes/sec)\n", + exts->res_bw); } if (IS_SUBTLV(exts, EXT_AVA_BW)) { if (json) { - snprintfrr(aux_buf, sizeof(aux_buf), "%g", - (exts->ava_bw)); - json_object_string_add(json, - "unidirAvailableBandBytesSec", - aux_buf); + snprintfrr(aux_buf, sizeof(aux_buf), "%g", (exts->ava_bw)); + json_object_string_add(json, "unidirAvailableBandBytesSec", aux_buf); } else - sbuf_push( - buf, indent, - "Unidir. Available Bandwidth: %g (Bytes/sec)\n", - exts->ava_bw); + sbuf_push(buf, indent, "Unidir. Available Bandwidth: %g (Bytes/sec)\n", + exts->ava_bw); } if (IS_SUBTLV(exts, EXT_USE_BW)) { if (json) { - snprintfrr(aux_buf, sizeof(aux_buf), "%g", - (exts->use_bw)); - json_object_string_add(json, - "unidirUtilizedBandBytesSec", - aux_buf); + snprintfrr(aux_buf, sizeof(aux_buf), "%g", (exts->use_bw)); + json_object_string_add(json, "unidirUtilizedBandBytesSec", aux_buf); } else - sbuf_push( - buf, indent, - "Unidir. Utilized Bandwidth: %g (Bytes/sec)\n", - exts->use_bw); + sbuf_push(buf, indent, "Unidir. Utilized Bandwidth: %g (Bytes/sec)\n", + exts->use_bw); } /* Segment Routing Adjacency as per RFC8667 section #2.2.1 */ if (IS_SUBTLV(exts, EXT_ADJ_SID)) { @@ -883,15 +736,12 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, 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); + for (adj = (struct isis_adj_sid *)exts->adj_sid.head; adj; + adj = adj->next) { + snprintfrr(cnt_buf, sizeof(cnt_buf), "%d", adj->sid); adj_sid_json = json_object_new_object(); - json_object_int_add(adj_sid_json, "sid", - adj->sid); - json_object_int_add(adj_sid_json, "weight", - adj->weight); + json_object_int_add(adj_sid_json, "sid", adj->sid); + json_object_int_add(adj_sid_json, "weight", adj->weight); json_object_boolean_add(adj_sid_json, "flagF", adj->flags & EXT_SUBTLV_LINK_ADJ_SID_FFLG ? true @@ -916,34 +766,20 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, adj->flags & EXT_SUBTLV_LINK_ADJ_SID_PFLG ? true : false); - json_object_array_add(arr_adj_json, - adj_sid_json); + json_object_array_add(arr_adj_json, adj_sid_json); } } else - for (adj = (struct isis_adj_sid *)exts->adj_sid.head; - adj; adj = adj->next) { - sbuf_push( - buf, indent, - "Adjacency-SID: %u, Weight: %hhu, Flags: F:%c B:%c, V:%c, L:%c, S:%c, P:%c\n", - adj->sid, adj->weight, - adj->flags & EXT_SUBTLV_LINK_ADJ_SID_FFLG - ? '1' - : '0', - adj->flags & EXT_SUBTLV_LINK_ADJ_SID_BFLG - ? '1' - : '0', - adj->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG - ? '1' - : '0', - adj->flags & EXT_SUBTLV_LINK_ADJ_SID_LFLG - ? '1' - : '0', - adj->flags & EXT_SUBTLV_LINK_ADJ_SID_SFLG - ? '1' - : '0', - adj->flags & EXT_SUBTLV_LINK_ADJ_SID_PFLG - ? '1' - : '0'); + for (adj = (struct isis_adj_sid *)exts->adj_sid.head; adj; + adj = adj->next) { + sbuf_push(buf, indent, + "Adjacency-SID: %u, Weight: %hhu, Flags: F:%c B:%c, V:%c, L:%c, S:%c, P:%c\n", + adj->sid, adj->weight, + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_FFLG ? '1' : '0', + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_BFLG ? '1' : '0', + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG ? '1' : '0', + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_LFLG ? '1' : '0', + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_SFLG ? '1' : '0', + adj->flags & EXT_SUBTLV_LINK_ADJ_SID_PFLG ? '1' : '0'); } } /* Segment Routing LAN-Adjacency as per RFC8667 section #2.2.2 */ @@ -954,20 +790,15 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, 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))) + 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); + snprintfrr(cnt_buf, sizeof(cnt_buf), "%d", lan->sid); lan_adj_json = json_object_new_object(); - json_object_int_add(lan_adj_json, "sid", - lan->sid); - json_object_int_add(lan_adj_json, "weight", - lan->weight); + json_object_int_add(lan_adj_json, "sid", lan->sid); + json_object_int_add(lan_adj_json, "weight", lan->weight); json_object_boolean_add(lan_adj_json, "flagF", lan->flags & EXT_SUBTLV_LINK_ADJ_SID_FFLG ? true @@ -992,43 +823,26 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, lan->flags & EXT_SUBTLV_LINK_ADJ_SID_PFLG ? true : false); - json_object_array_add(arr_adj_json, - lan_adj_json); + json_object_array_add(arr_adj_json, lan_adj_json); } } else - for (lan = (struct isis_lan_adj_sid *) - exts->lan_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))) + for (lan = (struct isis_lan_adj_sid *)exts->lan_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; - sbuf_push( - buf, indent, - "Lan-Adjacency-SID: %u, Weight: %hhu, Flags: F:%c B:%c, V:%c, L:%c, S:%c, P:%c\n" - " Neighbor-ID: %pSY\n", - lan->sid, lan->weight, - lan->flags & EXT_SUBTLV_LINK_ADJ_SID_FFLG - ? '1' - : '0', - lan->flags & EXT_SUBTLV_LINK_ADJ_SID_BFLG - ? '1' - : '0', - lan->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG - ? '1' - : '0', - lan->flags & EXT_SUBTLV_LINK_ADJ_SID_LFLG - ? '1' - : '0', - lan->flags & EXT_SUBTLV_LINK_ADJ_SID_SFLG - ? '1' - : '0', - lan->flags & EXT_SUBTLV_LINK_ADJ_SID_PFLG - ? '1' - : '0', - lan->neighbor_id); + sbuf_push(buf, indent, + "Lan-Adjacency-SID: %u, Weight: %hhu, Flags: F:%c B:%c, V:%c, L:%c, S:%c, P:%c\n" + " Neighbor-ID: %pSY\n", + lan->sid, lan->weight, + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_FFLG ? '1' : '0', + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_BFLG ? '1' : '0', + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG ? '1' : '0', + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_LFLG ? '1' : '0', + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_SFLG ? '1' : '0', + lan->flags & EXT_SUBTLV_LINK_ADJ_SID_PFLG ? '1' : '0', + lan->neighbor_id); } } /* SRv6 End.X SID as per RFC9352 section #8.1 */ @@ -1039,49 +853,35 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, struct json_object *arr_adj_json, *srv6_endx_sid_json; arr_adj_json = json_object_new_array(); - json_object_object_add(json, "srv6EndXSID", - arr_adj_json); - for (adj = (struct isis_srv6_endx_sid_subtlv *) - exts->srv6_endx_sid.head; + json_object_object_add(json, "srv6EndXSID", 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); + snprintfrr(cnt_buf, sizeof(cnt_buf), "%pI6", &adj->sid); srv6_endx_sid_json = json_object_new_object(); - json_object_string_addf(srv6_endx_sid_json, - "sid", "%pI6", + json_object_string_addf(srv6_endx_sid_json, "sid", "%pI6", &adj->sid); - json_object_string_add(srv6_endx_sid_json, - "algorithm", - sr_algorithm_string( - adj->algorithm)); - json_object_int_add(srv6_endx_sid_json, - "weight", adj->weight); + json_object_string_add(srv6_endx_sid_json, "algorithm", + sr_algorithm_string(adj->algorithm)); + json_object_int_add(srv6_endx_sid_json, "weight", adj->weight); json_object_string_add(srv6_endx_sid_json, "behavior", srv6_endpoint_behavior_codepoint2str( adj->behavior)); - json_object_boolean_add( - srv6_endx_sid_json, "flagB", - !!(adj->flags & - EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG)); - json_object_boolean_add( - srv6_endx_sid_json, "flagS", - !!(adj->flags & - EXT_SUBTLV_LINK_SRV6_ENDX_SID_SFLG)); - json_object_boolean_add( - srv6_endx_sid_json, "flagP", - !!(adj->flags & - EXT_SUBTLV_LINK_SRV6_ENDX_SID_PFLG)); - json_object_array_add(arr_adj_json, - srv6_endx_sid_json); + json_object_boolean_add(srv6_endx_sid_json, "flagB", + !!(adj->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG)); + json_object_boolean_add(srv6_endx_sid_json, "flagS", + !!(adj->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_SFLG)); + json_object_boolean_add(srv6_endx_sid_json, "flagP", + !!(adj->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_PFLG)); + json_object_array_add(arr_adj_json, srv6_endx_sid_json); if (adj->subsubtlvs) - isis_format_subsubtlvs(adj->subsubtlvs, - NULL, - srv6_endx_sid_json, - indent + 4); + isis_format_subsubtlvs(adj->subsubtlvs, NULL, + srv6_endx_sid_json, indent + 4); } } else - for (adj = (struct isis_srv6_endx_sid_subtlv *) - exts->srv6_endx_sid.head; + for (adj = (struct isis_srv6_endx_sid_subtlv *)exts->srv6_endx_sid.head; adj; adj = adj->next) { sbuf_push(buf, indent, "SRv6 End.X SID: %pI6, Algorithm: %s, Weight: %hhu, Endpoint Behavior: %s, Flags: B:%c, S:%c, P:%c\n", @@ -1095,8 +895,7 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, adj->flags & EXT_SUBTLV_LINK_SRV6_ENDX_SID_PFLG ? '1' : '0'); if (adj->subsubtlvs) - isis_format_subsubtlvs(adj->subsubtlvs, - buf, NULL, + isis_format_subsubtlvs(adj->subsubtlvs, buf, NULL, indent + 4); } } @@ -1104,55 +903,39 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (IS_SUBTLV(exts, EXT_SRV6_LAN_ENDX_SID)) { struct isis_srv6_lan_endx_sid_subtlv *lan; if (json) { - struct json_object *arr_adj_json, - *srv6_lan_endx_sid_json; + struct json_object *arr_adj_json, *srv6_lan_endx_sid_json; arr_adj_json = json_object_new_array(); - json_object_object_add(json, "srv6LanEndxSID", - arr_adj_json); + 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); - srv6_lan_endx_sid_json = - json_object_new_object(); - json_object_string_addf(srv6_lan_endx_sid_json, - "sid", "%pI6", + snprintfrr(cnt_buf, sizeof(cnt_buf), "%pI6", &lan->sid); + srv6_lan_endx_sid_json = json_object_new_object(); + json_object_string_addf(srv6_lan_endx_sid_json, "sid", "%pI6", &lan->sid); - json_object_int_add(srv6_lan_endx_sid_json, - "weight", lan->weight); - json_object_string_add(srv6_lan_endx_sid_json, - "algorithm", - sr_algorithm_string( - lan->algorithm)); - json_object_int_add(srv6_lan_endx_sid_json, - "weight", lan->weight); + json_object_int_add(srv6_lan_endx_sid_json, "weight", lan->weight); + json_object_string_add(srv6_lan_endx_sid_json, "algorithm", + sr_algorithm_string(lan->algorithm)); + json_object_int_add(srv6_lan_endx_sid_json, "weight", lan->weight); json_object_string_add(srv6_lan_endx_sid_json, "behavior", srv6_endpoint_behavior_codepoint2str( lan->behavior)); - json_object_boolean_add( - srv6_lan_endx_sid_json, "flagB", - !!(lan->flags & - EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG)); - json_object_boolean_add( - srv6_lan_endx_sid_json, "flagS", - !!(lan->flags & - EXT_SUBTLV_LINK_SRV6_ENDX_SID_SFLG)); - json_object_boolean_add( - srv6_lan_endx_sid_json, "flagP", - !!(lan->flags & - EXT_SUBTLV_LINK_SRV6_ENDX_SID_PFLG)); - json_object_string_addf(srv6_lan_endx_sid_json, - "neighborID", "%pSY", - lan->neighbor_id); - json_object_array_add(arr_adj_json, - srv6_lan_endx_sid_json); + json_object_boolean_add(srv6_lan_endx_sid_json, "flagB", + !!(lan->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG)); + json_object_boolean_add(srv6_lan_endx_sid_json, "flagS", + !!(lan->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_SFLG)); + json_object_boolean_add(srv6_lan_endx_sid_json, "flagP", + !!(lan->flags & + EXT_SUBTLV_LINK_SRV6_ENDX_SID_PFLG)); + json_object_string_addf(srv6_lan_endx_sid_json, "neighborID", + "%pSY", lan->neighbor_id); + json_object_array_add(arr_adj_json, srv6_lan_endx_sid_json); if (lan->subsubtlvs) - isis_format_subsubtlvs(lan->subsubtlvs, - NULL, - srv6_lan_endx_sid_json, - indent + 4); + isis_format_subsubtlvs(lan->subsubtlvs, NULL, + srv6_lan_endx_sid_json, indent + 4); } } else for (lan = (struct isis_srv6_lan_endx_sid_subtlv *) @@ -1172,8 +955,7 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, : '0', lan->neighbor_id); if (lan->subsubtlvs) - isis_format_subsubtlvs(lan->subsubtlvs, - buf, NULL, + isis_format_subsubtlvs(lan->subsubtlvs, buf, NULL, indent + 4); } } @@ -1181,13 +963,13 @@ static void format_item_ext_subtlvs(struct isis_ext_subtlvs *exts, format_item_asla_subtlvs(asla, json, buf, indent); } -static void free_item_ext_subtlvs(struct isis_ext_subtlvs *exts) +static void free_item_ext_subtlvs(struct isis_ext_subtlvs *exts) { isis_del_ext_subtlvs(exts); } -static int pack_item_ext_subtlv_asla(struct isis_asla_subtlvs *asla, - struct stream *s, size_t *min_len) +static int pack_item_ext_subtlv_asla(struct isis_asla_subtlvs *asla, struct stream *s, + size_t *min_len) { size_t subtlv_len; size_t subtlv_len_pos; @@ -1297,8 +1079,7 @@ static int pack_item_ext_subtlv_asla(struct isis_asla_subtlvs *asla, return 0; } -static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts, - struct stream *s, size_t *min_len) +static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts, struct stream *s, size_t *min_len) { struct isis_asla_subtlvs *asla; struct listnode *node; @@ -1430,8 +1211,7 @@ static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts, if (IS_SUBTLV(exts, EXT_ADJ_SID)) { struct isis_adj_sid *adj; - for (adj = (struct isis_adj_sid *)exts->adj_sid.head; adj; - adj = adj->next) { + for (adj = (struct isis_adj_sid *)exts->adj_sid.head; adj; adj = adj->next) { stream_putc(s, ISIS_SUBTLV_ADJ_SID); size = ISIS_SUBTLV_ADJ_SID_SIZE; if (!(adj->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG)) @@ -1443,15 +1223,13 @@ static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts, stream_put3(s, adj->sid); else stream_putl(s, adj->sid); - } } /* Segment Routing LAN-Adjacency as per RFC8667 section #2.2.2 */ if (IS_SUBTLV(exts, EXT_LAN_ADJ_SID)) { struct isis_lan_adj_sid *lan; - for (lan = (struct isis_lan_adj_sid *)exts->lan_sid.head; lan; - lan = lan->next) { + for (lan = (struct isis_lan_adj_sid *)exts->lan_sid.head; lan; lan = lan->next) { stream_putc(s, ISIS_SUBTLV_LAN_ADJ_SID); size = ISIS_SUBTLV_LAN_ADJ_SID_SIZE; if (!(lan->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG)) @@ -1472,9 +1250,8 @@ static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts, size_t subtlv_len; size_t subtlv_len_pos; - for (adj = (struct isis_srv6_endx_sid_subtlv *) - exts->srv6_endx_sid.head; - adj; adj = adj->next) { + for (adj = (struct isis_srv6_endx_sid_subtlv *)exts->srv6_endx_sid.head; adj; + adj = adj->next) { stream_putc(s, ISIS_SUBTLV_SRV6_ENDX_SID); subtlv_len_pos = stream_get_endp(s); @@ -1493,8 +1270,7 @@ static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts, } else { /* No Sub-Sub-TLVs */ if (STREAM_WRITEABLE(s) < 1) { - *min_len = - ISIS_SUBTLV_SRV6_ENDX_SID_SIZE; + *min_len = ISIS_SUBTLV_SRV6_ENDX_SID_SIZE; return 1; } @@ -1513,8 +1289,7 @@ static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts, size_t subtlv_len; size_t subtlv_len_pos; - for (lan = (struct isis_srv6_lan_endx_sid_subtlv *) - exts->srv6_lan_endx_sid.head; + for (lan = (struct isis_srv6_lan_endx_sid_subtlv *)exts->srv6_lan_endx_sid.head; lan; lan = lan->next) { stream_putc(s, ISIS_SUBTLV_SRV6_LAN_ENDX_SID); @@ -1535,8 +1310,7 @@ static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts, } else { /* No Sub-Sub-TLVs */ if (STREAM_WRITEABLE(s) < 1) { - *min_len = - ISIS_SUBTLV_SRV6_LAN_ENDX_SID_SIZE; + *min_len = ISIS_SUBTLV_SRV6_LAN_ENDX_SID_SIZE; return 1; } @@ -1559,10 +1333,8 @@ static int pack_item_ext_subtlvs(struct isis_ext_subtlvs *exts, return 0; } -static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, - struct stream *s, struct sbuf *log, - int indent, - struct isis_ext_subtlvs *exts) +static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, struct stream *s, + struct sbuf *log, int indent, struct isis_ext_subtlvs *exts) { /* Standard App Identifier Bit Flags/Length */ uint8_t sabm_flag_len; @@ -1594,8 +1366,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, asla->user_def_apps_length = ASLA_APPS_LENGTH_MASK & uabm_flag_len; readable -= ISIS_SUBSUBTLV_HDR_SIZE; - if (readable < - asla->standard_apps_length + asla->user_def_apps_length) { + if (readable < asla->standard_apps_length + asla->user_def_apps_length) { TLV_SIZE_MISMATCH(log, indent, "ASLA"); return -1; } @@ -1603,8 +1374,8 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, if ((asla->standard_apps_length > ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH) || (asla->user_def_apps_length > ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH)) { zlog_err("Standard or User-Defined Application Identifier Bit Mask Length greater than %u bytes. Received respectively a length of %u and %u bytes.", - ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH, - asla->standard_apps_length, asla->user_def_apps_length); + ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH, asla->standard_apps_length, + asla->user_def_apps_length); stream_forward_getp(s, readable); return -1; } @@ -1633,8 +1404,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, switch (subsubtlv_type) { case ISIS_SUBTLV_ADMIN_GRP: if (subsubtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "ASLA Adm Group"); + TLV_SIZE_MISMATCH(log, indent, "ASLA Adm Group"); stream_forward_getp(s, subsubtlv_len); } else { asla->admin_group = stream_getl(s); @@ -1647,15 +1417,13 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, for (size_t i = 0; i < nb_groups; i++) { uint32_t val = stream_getl(s); - admin_group_bulk_set(&asla->ext_admin_group, - val, i); + admin_group_bulk_set(&asla->ext_admin_group, val, i); } SET_SUBTLV(asla, EXT_EXTEND_ADM_GRP); break; case ISIS_SUBTLV_MAX_BW: if (subsubtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Maximum Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Maximum Bandwidth"); stream_forward_getp(s, subsubtlv_len); } else { asla->max_bw = stream_getf(s); @@ -1664,9 +1432,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, break; case ISIS_SUBTLV_MAX_RSV_BW: if (subsubtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH( - log, indent, - "Maximum Reservable Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Maximum Reservable Bandwidth"); stream_forward_getp(s, subsubtlv_len); } else { asla->max_rsv_bw = stream_getf(s); @@ -1675,8 +1441,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, break; case ISIS_SUBTLV_UNRSV_BW: if (subsubtlv_len != ISIS_SUBTLV_UNRSV_BW_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Unreserved Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Unreserved Bandwidth"); stream_forward_getp(s, subsubtlv_len); } else { for (int i = 0; i < MAX_CLASS_TYPE; i++) @@ -1686,8 +1451,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, break; case ISIS_SUBTLV_TE_METRIC: if (subsubtlv_len != ISIS_SUBTLV_TE_METRIC_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Traffic Engineering Metric"); + TLV_SIZE_MISMATCH(log, indent, "Traffic Engineering Metric"); stream_forward_getp(s, subsubtlv_len); } else { asla->te_metric = stream_get3(s); @@ -1697,8 +1461,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, /* Extended Metrics as defined in RFC 7810 */ case ISIS_SUBTLV_AV_DELAY: if (subsubtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Average Link Delay"); + TLV_SIZE_MISMATCH(log, indent, "Average Link Delay"); stream_forward_getp(s, subsubtlv_len); } else { asla->delay = stream_getl(s); @@ -1707,8 +1470,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, break; case ISIS_SUBTLV_MM_DELAY: if (subsubtlv_len != ISIS_SUBTLV_MM_DELAY_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Min/Max Link Delay"); + TLV_SIZE_MISMATCH(log, indent, "Min/Max Link Delay"); stream_forward_getp(s, subsubtlv_len); } else { asla->min_delay = stream_getl(s); @@ -1718,8 +1480,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, break; case ISIS_SUBTLV_DELAY_VAR: if (subsubtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Delay Variation"); + TLV_SIZE_MISMATCH(log, indent, "Delay Variation"); stream_forward_getp(s, subsubtlv_len); } else { asla->delay_var = stream_getl(s); @@ -1728,8 +1489,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, break; case ISIS_SUBTLV_PKT_LOSS: if (subsubtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Link Packet Loss"); + TLV_SIZE_MISMATCH(log, indent, "Link Packet Loss"); stream_forward_getp(s, subsubtlv_len); } else { asla->pkt_loss = stream_getl(s); @@ -1738,9 +1498,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, break; case ISIS_SUBTLV_RES_BW: if (subsubtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH( - log, indent, - "Unidirectional Residual Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Unidirectional Residual Bandwidth"); stream_forward_getp(s, subsubtlv_len); } else { asla->res_bw = stream_getf(s); @@ -1749,9 +1507,8 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, break; case ISIS_SUBTLV_AVA_BW: if (subsubtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH( - log, indent, - "Unidirectional Available Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, + "Unidirectional Available Bandwidth"); stream_forward_getp(s, subsubtlv_len); } else { asla->ava_bw = stream_getf(s); @@ -1760,9 +1517,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, break; case ISIS_SUBTLV_USE_BW: if (subsubtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH( - log, indent, - "Unidirectional Utilized Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Unidirectional Utilized Bandwidth"); stream_forward_getp(s, subsubtlv_len); } else { asla->use_bw = stream_getf(s); @@ -1770,8 +1525,7 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, } break; default: - zlog_debug("unknown (t,l)=(%u,%u)", subsubtlv_type, - subsubtlv_len); + zlog_debug("unknown (t,l)=(%u,%u)", subsubtlv_type, subsubtlv_len); stream_forward_getp(s, subsubtlv_len); break; } @@ -1783,8 +1537,8 @@ static int unpack_item_ext_subtlv_asla(uint16_t mtid, uint8_t subtlv_len, return 0; } -static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, - struct sbuf *log, void *dest, int indent) +static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, + void *dest, int indent) { uint8_t sum = 0; uint8_t subtlv_type; @@ -1807,11 +1561,9 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, subtlv_type = stream_getc(s); subtlv_len = stream_getc(s); if (subtlv_len > len - sum - ISIS_SUBTLV_HDR_SIZE) { - sbuf_push( - log, indent, - "TLV %hhu: Available data %u is less than TLV size %u !\n", - subtlv_type, len - sum - ISIS_SUBTLV_HDR_SIZE, - subtlv_len); + sbuf_push(log, indent, + "TLV %hhu: Available data %u is less than TLV size %u !\n", + subtlv_type, len - sum - ISIS_SUBTLV_HDR_SIZE, subtlv_len); return 1; } @@ -1819,8 +1571,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, /* Standard Metric as defined in RFC5305 */ case ISIS_SUBTLV_ADMIN_GRP: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Administrative Group"); + TLV_SIZE_MISMATCH(log, indent, "Administrative Group"); stream_forward_getp(s, subtlv_len); } else { exts->adm_group = stream_getl(s); @@ -1831,8 +1582,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, nb_groups = subtlv_len / sizeof(uint32_t); for (size_t i = 0; i < nb_groups; i++) { val = stream_getl(s); - admin_group_bulk_set(&exts->ext_admin_group, - val, i); + admin_group_bulk_set(&exts->ext_admin_group, val, i); } SET_SUBTLV(exts, EXT_EXTEND_ADM_GRP); break; @@ -1848,8 +1598,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_LOCAL_IPADDR: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Local IP address"); + TLV_SIZE_MISMATCH(log, indent, "Local IP address"); stream_forward_getp(s, subtlv_len); } else { stream_get(&exts->local_addr.s_addr, s, 4); @@ -1858,8 +1607,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_RMT_IPADDR: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Remote IP address"); + TLV_SIZE_MISMATCH(log, indent, "Remote IP address"); stream_forward_getp(s, subtlv_len); } else { stream_get(&exts->neigh_addr.s_addr, s, 4); @@ -1868,8 +1616,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_LOCAL_IPADDR6: if (subtlv_len != ISIS_SUBTLV_IPV6_ADDR_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Local IPv6 address"); + TLV_SIZE_MISMATCH(log, indent, "Local IPv6 address"); stream_forward_getp(s, subtlv_len); } else { stream_get(&exts->local_addr6, s, 16); @@ -1878,8 +1625,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_RMT_IPADDR6: if (subtlv_len != ISIS_SUBTLV_IPV6_ADDR_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Remote IPv6 address"); + TLV_SIZE_MISMATCH(log, indent, "Remote IPv6 address"); stream_forward_getp(s, subtlv_len); } else { stream_get(&exts->neigh_addr6, s, 16); @@ -1888,8 +1634,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_MAX_BW: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Maximum Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Maximum Bandwidth"); stream_forward_getp(s, subtlv_len); } else { exts->max_bw = stream_getf(s); @@ -1898,9 +1643,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_MAX_RSV_BW: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH( - log, indent, - "Maximum Reservable Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Maximum Reservable Bandwidth"); stream_forward_getp(s, subtlv_len); } else { exts->max_rsv_bw = stream_getf(s); @@ -1909,8 +1652,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_UNRSV_BW: if (subtlv_len != ISIS_SUBTLV_UNRSV_BW_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Unreserved Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Unreserved Bandwidth"); stream_forward_getp(s, subtlv_len); } else { for (int i = 0; i < MAX_CLASS_TYPE; i++) @@ -1920,8 +1662,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_TE_METRIC: if (subtlv_len != ISIS_SUBTLV_TE_METRIC_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Traffic Engineering Metric"); + TLV_SIZE_MISMATCH(log, indent, "Traffic Engineering Metric"); stream_forward_getp(s, subtlv_len); } else { exts->te_metric = stream_get3(s); @@ -1930,8 +1671,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_RAS: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Remote AS number"); + TLV_SIZE_MISMATCH(log, indent, "Remote AS number"); stream_forward_getp(s, subtlv_len); } else { exts->remote_as = stream_getl(s); @@ -1940,8 +1680,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_RIP: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Remote ASBR IP Address"); + TLV_SIZE_MISMATCH(log, indent, "Remote ASBR IP Address"); stream_forward_getp(s, subtlv_len); } else { stream_get(&exts->remote_ip.s_addr, s, 4); @@ -1951,8 +1690,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, /* Extended Metrics as defined in RFC 7810 */ case ISIS_SUBTLV_AV_DELAY: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Average Link Delay"); + TLV_SIZE_MISMATCH(log, indent, "Average Link Delay"); stream_forward_getp(s, subtlv_len); } else { exts->delay = stream_getl(s); @@ -1961,8 +1699,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_MM_DELAY: if (subtlv_len != ISIS_SUBTLV_MM_DELAY_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Min/Max Link Delay"); + TLV_SIZE_MISMATCH(log, indent, "Min/Max Link Delay"); stream_forward_getp(s, subtlv_len); } else { exts->min_delay = stream_getl(s); @@ -1972,8 +1709,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_DELAY_VAR: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Delay Variation"); + TLV_SIZE_MISMATCH(log, indent, "Delay Variation"); stream_forward_getp(s, subtlv_len); } else { exts->delay_var = stream_getl(s); @@ -1982,8 +1718,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_PKT_LOSS: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Link Packet Loss"); + TLV_SIZE_MISMATCH(log, indent, "Link Packet Loss"); stream_forward_getp(s, subtlv_len); } else { exts->pkt_loss = stream_getl(s); @@ -1992,9 +1727,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_RES_BW: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH( - log, indent, - "Unidirectional Residual Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Unidirectional Residual Bandwidth"); stream_forward_getp(s, subtlv_len); } else { exts->res_bw = stream_getf(s); @@ -2003,9 +1736,8 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_AVA_BW: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH( - log, indent, - "Unidirectional Available Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, + "Unidirectional Available Bandwidth"); stream_forward_getp(s, subtlv_len); } else { exts->ava_bw = stream_getf(s); @@ -2014,9 +1746,7 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; case ISIS_SUBTLV_USE_BW: if (subtlv_len != ISIS_SUBTLV_DEF_SIZE) { - TLV_SIZE_MISMATCH( - log, indent, - "Unidirectional Utilized Bandwidth"); + TLV_SIZE_MISMATCH(log, indent, "Unidirectional Utilized Bandwidth"); stream_forward_getp(s, subtlv_len); } else { exts->use_bw = stream_getf(s); @@ -2025,32 +1755,27 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, break; /* Segment Routing Adjacency as per RFC8667 section #2.2.1 */ case ISIS_SUBTLV_ADJ_SID: - if (subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE - && subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE + 1) { + if (subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE && + subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE + 1) { TLV_SIZE_MISMATCH(log, indent, "Adjacency SID"); stream_forward_getp(s, subtlv_len); } else { struct isis_adj_sid *adj; - adj = XCALLOC(MTYPE_ISIS_SUBTLV, - sizeof(struct isis_adj_sid)); + adj = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(struct isis_adj_sid)); adj->flags = stream_getc(s); adj->weight = stream_getc(s); - if (adj->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG - && subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "Adjacency SID"); + if (adj->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG && + subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE) { + TLV_SIZE_MISMATCH(log, indent, "Adjacency SID"); stream_forward_getp(s, subtlv_len - 2); XFREE(MTYPE_ISIS_SUBTLV, adj); break; } - if (!(adj->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG) - && subtlv_len - != ISIS_SUBTLV_ADJ_SID_SIZE - + 1) { - TLV_SIZE_MISMATCH(log, indent, - "Adjacency SID"); + if (!(adj->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG) && + subtlv_len != ISIS_SUBTLV_ADJ_SID_SIZE + 1) { + TLV_SIZE_MISMATCH(log, indent, "Adjacency SID"); stream_forward_getp(s, subtlv_len - 2); XFREE(MTYPE_ISIS_SUBTLV, adj); break; @@ -2066,49 +1791,36 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, adj->family = AF_INET; if (mtid == ISIS_MT_IPV6_UNICAST) adj->family = AF_INET6; - append_item(&exts->adj_sid, - (struct isis_item *)adj); + append_item(&exts->adj_sid, (struct isis_item *)adj); SET_SUBTLV(exts, EXT_ADJ_SID); } break; /* Segment Routing LAN-Adjacency as per RFC8667 section 2.2.2 */ case ISIS_SUBTLV_LAN_ADJ_SID: - if (subtlv_len != ISIS_SUBTLV_LAN_ADJ_SID_SIZE - && subtlv_len != ISIS_SUBTLV_LAN_ADJ_SID_SIZE + 1) { - TLV_SIZE_MISMATCH(log, indent, - "LAN-Adjacency SID"); + if (subtlv_len != ISIS_SUBTLV_LAN_ADJ_SID_SIZE && + subtlv_len != ISIS_SUBTLV_LAN_ADJ_SID_SIZE + 1) { + TLV_SIZE_MISMATCH(log, indent, "LAN-Adjacency SID"); stream_forward_getp(s, subtlv_len); } else { struct isis_lan_adj_sid *lan; - lan = XCALLOC(MTYPE_ISIS_SUBTLV, - sizeof(struct isis_lan_adj_sid)); + lan = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(struct isis_lan_adj_sid)); lan->flags = stream_getc(s); lan->weight = stream_getc(s); - stream_get(&(lan->neighbor_id), s, - ISIS_SYS_ID_LEN); - - if (lan->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG - && subtlv_len - != ISIS_SUBTLV_LAN_ADJ_SID_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "LAN-Adjacency SID"); - stream_forward_getp( - s, subtlv_len - 2 - - ISIS_SYS_ID_LEN); + stream_get(&(lan->neighbor_id), s, ISIS_SYS_ID_LEN); + + if (lan->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG && + subtlv_len != ISIS_SUBTLV_LAN_ADJ_SID_SIZE) { + TLV_SIZE_MISMATCH(log, indent, "LAN-Adjacency SID"); + stream_forward_getp(s, subtlv_len - 2 - ISIS_SYS_ID_LEN); XFREE(MTYPE_ISIS_SUBTLV, lan); break; } - if (!(lan->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG) - && subtlv_len - != ISIS_SUBTLV_LAN_ADJ_SID_SIZE - + 1) { - TLV_SIZE_MISMATCH(log, indent, - "LAN-Adjacency SID"); - stream_forward_getp( - s, subtlv_len - 2 - - ISIS_SYS_ID_LEN); + if (!(lan->flags & EXT_SUBTLV_LINK_ADJ_SID_VFLG) && + subtlv_len != ISIS_SUBTLV_LAN_ADJ_SID_SIZE + 1) { + TLV_SIZE_MISMATCH(log, indent, "LAN-Adjacency SID"); + stream_forward_getp(s, subtlv_len - 2 - ISIS_SYS_ID_LEN); XFREE(MTYPE_ISIS_SUBTLV, lan); break; } @@ -2123,24 +1835,20 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, lan->family = AF_INET; if (mtid == ISIS_MT_IPV6_UNICAST) lan->family = AF_INET6; - append_item(&exts->lan_sid, - (struct isis_item *)lan); + append_item(&exts->lan_sid, (struct isis_item *)lan); SET_SUBTLV(exts, EXT_LAN_ADJ_SID); } break; /* SRv6 End.X SID as per RFC9352 section #8.1 */ case ISIS_SUBTLV_SRV6_ENDX_SID: if (subtlv_len < ISIS_SUBTLV_SRV6_ENDX_SID_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "SRv6 End.X SID"); + TLV_SIZE_MISMATCH(log, indent, "SRv6 End.X SID"); stream_forward_getp(s, subtlv_len); } else { struct isis_srv6_endx_sid_subtlv *adj; - adj = XCALLOC( - MTYPE_ISIS_SUBTLV, - sizeof(struct - isis_srv6_endx_sid_subtlv)); + adj = XCALLOC(MTYPE_ISIS_SUBTLV, + sizeof(struct isis_srv6_endx_sid_subtlv)); adj->flags = stream_getc(s); adj->algorithm = stream_getc(s); adj->weight = stream_getc(s); @@ -2152,11 +1860,9 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID); bool unpacked_known_tlvs = false; - if (unpack_tlvs( - ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID, - subsubtlv_len, s, log, - adj->subsubtlvs, indent + 4, - &unpacked_known_tlvs)) { + if (unpack_tlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID, + subsubtlv_len, s, log, adj->subsubtlvs, indent + 4, + &unpacked_known_tlvs)) { XFREE(MTYPE_ISIS_SUBTLV, adj); break; } @@ -2165,26 +1871,21 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, adj->subsubtlvs = NULL; } - append_item(&exts->srv6_endx_sid, - (struct isis_item *)adj); + append_item(&exts->srv6_endx_sid, (struct isis_item *)adj); SET_SUBTLV(exts, EXT_SRV6_ENDX_SID); } break; /* SRv6 LAN End.X SID as per RFC9352 section #8.2 */ case ISIS_SUBTLV_SRV6_LAN_ENDX_SID: if (subtlv_len < ISIS_SUBTLV_SRV6_LAN_ENDX_SID_SIZE) { - TLV_SIZE_MISMATCH(log, indent, - "SRv6 LAN End.X SID"); + TLV_SIZE_MISMATCH(log, indent, "SRv6 LAN End.X SID"); stream_forward_getp(s, subtlv_len); } else { struct isis_srv6_lan_endx_sid_subtlv *lan; - lan = XCALLOC( - MTYPE_ISIS_SUBTLV, - sizeof(struct - isis_srv6_lan_endx_sid_subtlv)); - stream_get(&(lan->neighbor_id), s, - ISIS_SYS_ID_LEN); + lan = XCALLOC(MTYPE_ISIS_SUBTLV, + sizeof(struct isis_srv6_lan_endx_sid_subtlv)); + stream_get(&(lan->neighbor_id), s, ISIS_SYS_ID_LEN); lan->flags = stream_getc(s); lan->algorithm = stream_getc(s); lan->weight = stream_getc(s); @@ -2196,11 +1897,9 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID); bool unpacked_known_tlvs = false; - if (unpack_tlvs( - ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID, - subsubtlv_len, s, log, - lan->subsubtlvs, indent + 4, - &unpacked_known_tlvs)) { + if (unpack_tlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_ENDX_SID, + subsubtlv_len, s, log, lan->subsubtlvs, indent + 4, + &unpacked_known_tlvs)) { XFREE(MTYPE_ISIS_SUBTLV, lan); break; } @@ -2209,15 +1908,13 @@ static int unpack_item_ext_subtlvs(uint16_t mtid, uint8_t len, struct stream *s, lan->subsubtlvs = NULL; } - append_item(&exts->srv6_lan_endx_sid, - (struct isis_item *)lan); + append_item(&exts->srv6_lan_endx_sid, (struct isis_item *)lan); SET_SUBTLV(exts, EXT_SRV6_LAN_ENDX_SID); } break; case ISIS_SUBTLV_ASLA: - if (unpack_item_ext_subtlv_asla(mtid, subtlv_len, s, - log, indent, - exts) < 0) { + if (unpack_item_ext_subtlv_asla(mtid, subtlv_len, s, log, indent, exts) < + 0) { sbuf_push(log, indent, "TLV parse error"); } break; @@ -2244,9 +1941,8 @@ static struct isis_item *copy_item_prefix_sid(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_prefix_sid(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_item_prefix_sid(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { struct isis_prefix_sid *sid = (struct isis_prefix_sid *)i; @@ -2273,15 +1969,12 @@ static void format_item_prefix_sid(uint16_t mtid, struct isis_item *i, 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)); + !!(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)); + !!(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", @@ -2296,15 +1989,10 @@ static void format_item_prefix_sid(uint16_t mtid, struct isis_item *i, } sbuf_push(buf, 0, "Algorithm: %hhu, ", sid->algorithm); sbuf_push(buf, 0, "Flags:%s%s%s%s%s%s\n", - sid->flags & ISIS_PREFIX_SID_READVERTISED - ? " READVERTISED" - : "", + sid->flags & ISIS_PREFIX_SID_READVERTISED ? " READVERTISED" : "", sid->flags & ISIS_PREFIX_SID_NODE ? " NODE" : "", - sid->flags & ISIS_PREFIX_SID_NO_PHP ? " NO-PHP" - : " PHP", - sid->flags & ISIS_PREFIX_SID_EXPLICIT_NULL - ? " EXPLICIT-NULL" - : "", + sid->flags & ISIS_PREFIX_SID_NO_PHP ? " NO-PHP" : " PHP", + sid->flags & ISIS_PREFIX_SID_EXPLICIT_NULL ? " EXPLICIT-NULL" : "", sid->flags & ISIS_PREFIX_SID_VALUE ? " VALUE" : "", sid->flags & ISIS_PREFIX_SID_LOCAL ? " LOCAL" : ""); } @@ -2315,8 +2003,7 @@ static void free_item_prefix_sid(struct isis_item *i) XFREE(MTYPE_ISIS_SUBTLV, i); } -static int pack_item_prefix_sid(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_prefix_sid(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_prefix_sid *sid = (struct isis_prefix_sid *)i; @@ -2339,25 +2026,22 @@ static int pack_item_prefix_sid(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_prefix_sid(uint16_t mtid, uint8_t len, struct stream *s, - struct sbuf *log, void *dest, int indent) +static int unpack_item_prefix_sid(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, + void *dest, int indent) { struct isis_subtlvs *subtlvs = dest; - struct isis_prefix_sid sid = { - }; + struct isis_prefix_sid sid = {}; sbuf_push(log, indent, "Unpacking SR Prefix-SID...\n"); if (len < 5) { sbuf_push(log, indent, - "Not enough data left. (expected 5 or more bytes, got %hhu)\n", - len); + "Not enough data left. (expected 5 or more bytes, got %hhu)\n", len); return 1; } sid.flags = stream_getc(s); - if (!!(sid.flags & ISIS_PREFIX_SID_VALUE) - != !!(sid.flags & ISIS_PREFIX_SID_LOCAL)) { + if (!!(sid.flags & ISIS_PREFIX_SID_VALUE) != !!(sid.flags & ISIS_PREFIX_SID_LOCAL)) { sbuf_push(log, indent, "Flags implausible: Local Flag needs to match Value Flag\n"); return 1; } @@ -2377,8 +2061,7 @@ static int unpack_item_prefix_sid(uint16_t mtid, uint8_t len, struct stream *s, if (sid.flags & ISIS_PREFIX_SID_VALUE) { sid.value = stream_get3(s); if (!IS_MPLS_UNRESERVED_LABEL(sid.value)) { - sbuf_push(log, indent, "Invalid absolute SID %u\n", - sid.value); + sbuf_push(log, indent, "Invalid absolute SID %u\n", sid.value); return 1; } } else { @@ -2404,10 +2087,8 @@ static struct prefix_ipv6 *copy_subtlv_ipv6_source_prefix(struct prefix_ipv6 *p) return rv; } -static void format_subtlv_ipv6_source_prefix(struct prefix_ipv6 *p, - struct sbuf *buf, - struct json_object *json, - int indent) +static void format_subtlv_ipv6_source_prefix(struct prefix_ipv6 *p, struct sbuf *buf, + struct json_object *json, int indent) { if (!p) return; @@ -2422,8 +2103,7 @@ static void format_subtlv_ipv6_source_prefix(struct prefix_ipv6 *p, } } -static int pack_subtlv_ipv6_source_prefix(struct prefix_ipv6 *p, - struct stream *s) +static int pack_subtlv_ipv6_source_prefix(struct prefix_ipv6 *p, struct stream *s) { if (!p) return 0; @@ -2438,9 +2118,8 @@ static int pack_subtlv_ipv6_source_prefix(struct prefix_ipv6 *p, return 0; } -static int unpack_subtlv_ipv6_source_prefix(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, +static int unpack_subtlv_ipv6_source_prefix(enum isis_tlv_context context, uint8_t tlv_type, + uint8_t tlv_len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_subtlvs *subtlvs = dest; @@ -2452,32 +2131,27 @@ static int unpack_subtlv_ipv6_source_prefix(enum isis_tlv_context context, if (tlv_len < 1) { sbuf_push(log, indent, - "Not enough data left. (expected 1 or more bytes, got %hhu)\n", - tlv_len); + "Not enough data left. (expected 1 or more bytes, got %hhu)\n", tlv_len); return 1; } p.prefixlen = stream_getc(s); if (p.prefixlen > IPV6_MAX_BITLEN) { - sbuf_push(log, indent, "Prefixlen %u is implausible for IPv6\n", - p.prefixlen); + sbuf_push(log, indent, "Prefixlen %u is implausible for IPv6\n", p.prefixlen); return 1; } if (tlv_len != 1 + PSIZE(p.prefixlen)) { - sbuf_push( - log, indent, - "TLV size differs from expected size for the prefixlen. (expected %u but got %hhu)\n", - 1 + PSIZE(p.prefixlen), tlv_len); + sbuf_push(log, indent, + "TLV size differs from expected size for the prefixlen. (expected %u but got %hhu)\n", + 1 + PSIZE(p.prefixlen), tlv_len); return 1; } stream_get(&p.prefix, s, PSIZE(p.prefixlen)); if (subtlvs->source_prefix) { - sbuf_push( - log, indent, - "WARNING: source prefix Sub-TLV present multiple times.\n"); + sbuf_push(log, indent, "WARNING: source prefix Sub-TLV present multiple times.\n"); /* Ignore all but first occurrence of the source prefix Sub-TLV */ return 0; @@ -2491,14 +2165,12 @@ static int unpack_subtlv_ipv6_source_prefix(enum isis_tlv_context context, /* Functions related to Sub-Sub-TLV 1 SRv6 SID Structure * as per RFC 9352 section #9 */ static struct isis_srv6_sid_structure_subsubtlv * -copy_subsubtlv_srv6_sid_structure( - struct isis_srv6_sid_structure_subsubtlv *sid_struct) +copy_subsubtlv_srv6_sid_structure(struct isis_srv6_sid_structure_subsubtlv *sid_struct) { if (!sid_struct) return NULL; - struct isis_srv6_sid_structure_subsubtlv *rv = - XCALLOC(MTYPE_ISIS_SUBSUBTLV, sizeof(*rv)); + struct isis_srv6_sid_structure_subsubtlv *rv = XCALLOC(MTYPE_ISIS_SUBSUBTLV, sizeof(*rv)); rv->loc_block_len = sid_struct->loc_block_len; rv->loc_node_len = sid_struct->loc_node_len; @@ -2508,9 +2180,9 @@ copy_subsubtlv_srv6_sid_structure( return rv; } -static void format_subsubtlv_srv6_sid_structure( - struct isis_srv6_sid_structure_subsubtlv *sid_struct, struct sbuf *buf, - struct json_object *json, int indent) +static void +format_subsubtlv_srv6_sid_structure(struct isis_srv6_sid_structure_subsubtlv *sid_struct, + struct sbuf *buf, struct json_object *json, int indent) { if (!sid_struct) return; @@ -2519,38 +2191,28 @@ static void format_subsubtlv_srv6_sid_structure( struct json_object *sid_struct_json; 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); + 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, ", - sid_struct->loc_block_len); - sbuf_push(buf, 0, "Locator Node length: %hhu, ", - sid_struct->loc_node_len); - sbuf_push(buf, 0, "Function length: %hhu, ", - sid_struct->func_len); - sbuf_push(buf, 0, "Argument length: %hhu, ", - sid_struct->arg_len); + sbuf_push(buf, 0, "Locator Block length: %hhu, ", sid_struct->loc_block_len); + sbuf_push(buf, 0, "Locator Node length: %hhu, ", sid_struct->loc_node_len); + sbuf_push(buf, 0, "Function length: %hhu, ", sid_struct->func_len); + sbuf_push(buf, 0, "Argument length: %hhu, ", sid_struct->arg_len); sbuf_push(buf, 0, "\n"); } } -static void free_subsubtlv_srv6_sid_structure( - struct isis_srv6_sid_structure_subsubtlv *sid_struct) +static void free_subsubtlv_srv6_sid_structure(struct isis_srv6_sid_structure_subsubtlv *sid_struct) { XFREE(MTYPE_ISIS_SUBSUBTLV, sid_struct); } -static int pack_subsubtlv_srv6_sid_structure( - struct isis_srv6_sid_structure_subsubtlv *sid_struct, struct stream *s) +static int pack_subsubtlv_srv6_sid_structure(struct isis_srv6_sid_structure_subsubtlv *sid_struct, + struct stream *s) { if (!sid_struct) return 0; @@ -2569,19 +2231,18 @@ static int pack_subsubtlv_srv6_sid_structure( return 0; } -static int unpack_subsubtlv_srv6_sid_structure( - enum isis_tlv_context context, uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, void *dest, int indent) +static int unpack_subsubtlv_srv6_sid_structure(enum isis_tlv_context context, uint8_t tlv_type, + uint8_t tlv_len, struct stream *s, struct sbuf *log, + void *dest, int indent) { struct isis_subsubtlvs *subsubtlvs = dest; struct isis_srv6_sid_structure_subsubtlv sid_struct = {}; sbuf_push(log, indent, "Unpacking SRv6 SID Structure...\n"); if (tlv_len != 4) { - sbuf_push( - log, indent, - "Invalid SRv6 SID Structure Sub-Sub-TLV size. (Expected 4 bytes, got %hhu)\n", - tlv_len); + sbuf_push(log, indent, + "Invalid SRv6 SID Structure Sub-Sub-TLV size. (Expected 4 bytes, got %hhu)\n", + tlv_len); return 1; } @@ -2590,28 +2251,24 @@ static int unpack_subsubtlv_srv6_sid_structure( sid_struct.func_len = stream_getc(s); sid_struct.arg_len = stream_getc(s); - subsubtlvs->srv6_sid_structure = - copy_subsubtlv_srv6_sid_structure(&sid_struct); + subsubtlvs->srv6_sid_structure = copy_subsubtlv_srv6_sid_structure(&sid_struct); return 0; } -static struct isis_item *copy_item(enum isis_tlv_context context, - enum isis_tlv_type type, +static struct isis_item *copy_item(enum isis_tlv_context context, enum isis_tlv_type type, struct isis_item *item); static void copy_items(enum isis_tlv_context context, enum isis_tlv_type type, struct isis_item_list *src, struct isis_item_list *dest); -static void format_items_(uint16_t mtid, enum isis_tlv_context context, - enum isis_tlv_type type, struct isis_item_list *items, - struct sbuf *buf, struct json_object *json, +static void format_items_(uint16_t mtid, enum isis_tlv_context context, enum isis_tlv_type type, + struct isis_item_list *items, struct sbuf *buf, struct json_object *json, int indent); #define format_items(...) format_items_(ISIS_MT_IPV4_UNICAST, __VA_ARGS__) static void free_items(enum isis_tlv_context context, enum isis_tlv_type type, struct isis_item_list *items); -static int pack_items_(uint16_t mtid, enum isis_tlv_context context, - enum isis_tlv_type type, struct isis_item_list *items, - struct stream *s, struct isis_tlvs **fragment_tlvs, - const struct pack_order_entry *pe, +static int pack_items_(uint16_t mtid, enum isis_tlv_context context, enum isis_tlv_type type, + struct isis_item_list *items, struct stream *s, + struct isis_tlvs **fragment_tlvs, const struct pack_order_entry *pe, struct isis_tlvs *(*new_fragment)(struct list *l), struct list *new_fragment_arg); #define pack_items(...) pack_items_(ISIS_MT_IPV4_UNICAST, __VA_ARGS__) @@ -2628,8 +2285,7 @@ struct isis_subsubtlvs *isis_alloc_subsubtlvs(enum isis_tlv_context context) return result; } -static struct isis_subsubtlvs * -isis_copy_subsubtlvs(struct isis_subsubtlvs *subsubtlvs) +static struct isis_subsubtlvs *isis_copy_subsubtlvs(struct isis_subsubtlvs *subsubtlvs) { if (!subsubtlvs) return NULL; @@ -2638,18 +2294,15 @@ isis_copy_subsubtlvs(struct isis_subsubtlvs *subsubtlvs) rv->context = subsubtlvs->context; - rv->srv6_sid_structure = copy_subsubtlv_srv6_sid_structure( - subsubtlvs->srv6_sid_structure); + rv->srv6_sid_structure = copy_subsubtlv_srv6_sid_structure(subsubtlvs->srv6_sid_structure); return rv; } -static void isis_format_subsubtlvs(struct isis_subsubtlvs *subsubtlvs, - struct sbuf *buf, struct json_object *json, - int indent) +static void isis_format_subsubtlvs(struct isis_subsubtlvs *subsubtlvs, struct sbuf *buf, + struct json_object *json, int indent) { - format_subsubtlv_srv6_sid_structure(subsubtlvs->srv6_sid_structure, buf, - json, indent); + format_subsubtlv_srv6_sid_structure(subsubtlvs->srv6_sid_structure, buf, json, indent); } static void isis_free_subsubtlvs(struct isis_subsubtlvs *subsubtlvs) @@ -2662,8 +2315,7 @@ static void isis_free_subsubtlvs(struct isis_subsubtlvs *subsubtlvs) XFREE(MTYPE_ISIS_SUBSUBTLV, subsubtlvs); } -static int isis_pack_subsubtlvs(struct isis_subsubtlvs *subsubtlvs, - struct stream *s) +static int isis_pack_subsubtlvs(struct isis_subsubtlvs *subsubtlvs, struct stream *s) { int rv; size_t subsubtlv_len_pos = stream_get_endp(s); @@ -2673,8 +2325,7 @@ static int isis_pack_subsubtlvs(struct isis_subsubtlvs *subsubtlvs, stream_putc(s, 0); /* Put 0 as Sub-Sub-TLVs length, filled in later */ - rv = pack_subsubtlv_srv6_sid_structure(subsubtlvs->srv6_sid_structure, - s); + rv = pack_subsubtlv_srv6_sid_structure(subsubtlvs->srv6_sid_structure, s); if (rv) return rv; @@ -2710,14 +2361,13 @@ static struct isis_subtlvs *copy_subtlvs(struct isis_subtlvs *subtlvs) rv->context = subtlvs->context; - copy_items(subtlvs->context, ISIS_SUBTLV_PREFIX_SID, - &subtlvs->prefix_sids, &rv->prefix_sids); + copy_items(subtlvs->context, ISIS_SUBTLV_PREFIX_SID, &subtlvs->prefix_sids, + &rv->prefix_sids); - rv->source_prefix = - copy_subtlv_ipv6_source_prefix(subtlvs->source_prefix); + rv->source_prefix = copy_subtlv_ipv6_source_prefix(subtlvs->source_prefix); - copy_items(subtlvs->context, ISIS_SUBTLV_SRV6_END_SID, - &subtlvs->srv6_end_sids, &rv->srv6_end_sids); + copy_items(subtlvs->context, ISIS_SUBTLV_SRV6_END_SID, &subtlvs->srv6_end_sids, + &rv->srv6_end_sids); return rv; } @@ -2725,13 +2375,13 @@ static struct isis_subtlvs *copy_subtlvs(struct isis_subtlvs *subtlvs) static void format_subtlvs(struct isis_subtlvs *subtlvs, struct sbuf *buf, struct json_object *json, int indent) { - format_items(subtlvs->context, ISIS_SUBTLV_PREFIX_SID, - &subtlvs->prefix_sids, buf, json, indent); + format_items(subtlvs->context, ISIS_SUBTLV_PREFIX_SID, &subtlvs->prefix_sids, buf, json, + indent); format_subtlv_ipv6_source_prefix(subtlvs->source_prefix, buf, json, indent); - format_items(subtlvs->context, ISIS_SUBTLV_SRV6_END_SID, - &subtlvs->srv6_end_sids, buf, json, indent); + format_items(subtlvs->context, ISIS_SUBTLV_SRV6_END_SID, &subtlvs->srv6_end_sids, buf, + json, indent); } static void isis_free_subtlvs(struct isis_subtlvs *subtlvs) @@ -2739,13 +2389,11 @@ static void isis_free_subtlvs(struct isis_subtlvs *subtlvs) if (!subtlvs) return; - free_items(subtlvs->context, ISIS_SUBTLV_PREFIX_SID, - &subtlvs->prefix_sids); + free_items(subtlvs->context, ISIS_SUBTLV_PREFIX_SID, &subtlvs->prefix_sids); XFREE(MTYPE_ISIS_SUBTLV, subtlvs->source_prefix); - free_items(subtlvs->context, ISIS_SUBTLV_SRV6_END_SID, - &subtlvs->srv6_end_sids); + free_items(subtlvs->context, ISIS_SUBTLV_SRV6_END_SID, &subtlvs->srv6_end_sids); XFREE(MTYPE_ISIS_SUBTLV, subtlvs); } @@ -2760,8 +2408,8 @@ static int pack_subtlvs(struct isis_subtlvs *subtlvs, struct stream *s) stream_putc(s, 0); /* Put 0 as subtlvs length, filled in later */ - rv = pack_items(subtlvs->context, ISIS_SUBTLV_PREFIX_SID, - &subtlvs->prefix_sids, s, NULL, NULL, NULL, NULL); + rv = pack_items(subtlvs->context, ISIS_SUBTLV_PREFIX_SID, &subtlvs->prefix_sids, s, NULL, + NULL, NULL, NULL); if (rv) return rv; @@ -2769,8 +2417,8 @@ static int pack_subtlvs(struct isis_subtlvs *subtlvs, struct stream *s) if (rv) return rv; - rv = pack_items(subtlvs->context, ISIS_SUBTLV_SRV6_END_SID, - &subtlvs->srv6_end_sids, s, NULL, NULL, NULL, NULL); + rv = pack_items(subtlvs->context, ISIS_SUBTLV_SRV6_END_SID, &subtlvs->srv6_end_sids, s, + NULL, NULL, NULL, NULL); if (rv) return rv; @@ -2782,17 +2430,14 @@ static int pack_subtlvs(struct isis_subtlvs *subtlvs, struct stream *s) return 0; } -static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len, - struct stream *stream, struct sbuf *log, void *dest, - int indent, bool *unpacked_known_tlvs); +static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len, struct stream *stream, + struct sbuf *log, void *dest, int indent, bool *unpacked_known_tlvs); /* Functions for Sub-TLV 5 SRv6 End SID as per RFC 9352 section #7.2 */ static struct isis_item *copy_item_srv6_end_sid(struct isis_item *i) { - struct isis_srv6_end_sid_subtlv *sid = - (struct isis_srv6_end_sid_subtlv *)i; - struct isis_srv6_end_sid_subtlv *rv = - XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(*rv)); + struct isis_srv6_end_sid_subtlv *sid = (struct isis_srv6_end_sid_subtlv *)i; + struct isis_srv6_end_sid_subtlv *rv = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(*rv)); rv->behavior = sid->behavior; rv->sid = sid->sid; @@ -2801,12 +2446,10 @@ static struct isis_item *copy_item_srv6_end_sid(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_srv6_end_sid(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_item_srv6_end_sid(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { - struct isis_srv6_end_sid_subtlv *sid = - (struct isis_srv6_end_sid_subtlv *)i; + struct isis_srv6_end_sid_subtlv *sid = (struct isis_srv6_end_sid_subtlv *)i; if (json) { struct json_object *sid_json; @@ -2819,10 +2462,8 @@ static void format_item_srv6_end_sid(uint16_t mtid, struct isis_item *i, 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); + 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 "); @@ -2832,26 +2473,22 @@ static void format_item_srv6_end_sid(uint16_t mtid, struct isis_item *i, if (sid->subsubtlvs) { sbuf_push(buf, indent, " Sub-Sub-TLVs:\n"); - isis_format_subsubtlvs(sid->subsubtlvs, buf, NULL, - indent + 4); + isis_format_subsubtlvs(sid->subsubtlvs, buf, NULL, indent + 4); } } } static void free_item_srv6_end_sid(struct isis_item *i) { - struct isis_srv6_end_sid_subtlv *item = - (struct isis_srv6_end_sid_subtlv *)i; + struct isis_srv6_end_sid_subtlv *item = (struct isis_srv6_end_sid_subtlv *)i; isis_free_subsubtlvs(item->subsubtlvs); XFREE(MTYPE_ISIS_SUBTLV, i); } -static int pack_item_srv6_end_sid(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_srv6_end_sid(struct isis_item *i, struct stream *s, size_t *min_len) { - struct isis_srv6_end_sid_subtlv *sid = - (struct isis_srv6_end_sid_subtlv *)i; + struct isis_srv6_end_sid_subtlv *sid = (struct isis_srv6_end_sid_subtlv *)i; if (STREAM_WRITEABLE(s) < 19) { *min_len = 19; @@ -2881,8 +2518,7 @@ static int pack_item_srv6_end_sid(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_srv6_end_sid(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, +static int unpack_item_srv6_end_sid(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_subtlvs *subtlvs = dest; @@ -2894,10 +2530,8 @@ static int unpack_item_srv6_end_sid(uint16_t mtid, uint8_t len, consume = 19; if (len < consume) { - sbuf_push( - log, indent, - "Not enough data left. (expected 19 or more bytes, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left. (expected 19 or more bytes, got %hhu)\n", len); goto out; } @@ -2907,15 +2541,13 @@ static int unpack_item_srv6_end_sid(uint16_t mtid, uint8_t len, sid->behavior = stream_getw(s); stream_get(&sid->sid, s, IPV6_MAX_BYTELEN); - format_item_srv6_end_sid(mtid, (struct isis_item *)sid, log, NULL, - indent + 2); + format_item_srv6_end_sid(mtid, (struct isis_item *)sid, log, NULL, indent + 2); /* Process Sub-Sub-TLVs */ consume += 1; if (len < consume) { - sbuf_push( - log, indent, - "Expected 1 byte of Sub-Sub-TLV len, but no more data persent.\n"); + sbuf_push(log, indent, + "Expected 1 byte of Sub-Sub-TLV len, but no more data persent.\n"); goto out; } subsubtlv_len = stream_getc(s); @@ -2928,13 +2560,11 @@ static int unpack_item_srv6_end_sid(uint16_t mtid, uint8_t len, goto out; } - sid->subsubtlvs = - isis_alloc_subsubtlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_END_SID); + sid->subsubtlvs = isis_alloc_subsubtlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_END_SID); bool unpacked_known_tlvs = false; - if (unpack_tlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_END_SID, subsubtlv_len, s, - log, sid->subsubtlvs, indent + 4, - &unpacked_known_tlvs)) { + if (unpack_tlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_END_SID, subsubtlv_len, s, log, + sid->subsubtlvs, indent + 4, &unpacked_known_tlvs)) { goto out; } if (!unpacked_known_tlvs) { @@ -2962,9 +2592,8 @@ static struct isis_item *copy_item_area_address(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_area_address(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_item_area_address(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { struct isis_area_address *addr = (struct isis_area_address *)i; struct iso_address iso_addr; @@ -2982,8 +2611,7 @@ static void free_item_area_address(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_area_address(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_area_address(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_area_address *addr = (struct isis_area_address *)i; @@ -2996,8 +2624,7 @@ static int pack_item_area_address(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_area_address(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, +static int unpack_item_area_address(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; @@ -3005,10 +2632,9 @@ static int unpack_item_area_address(uint16_t mtid, uint8_t len, sbuf_push(log, indent, "Unpack area address...\n"); if (len < 1) { - sbuf_push( - log, indent, - "Not enough data left. (Expected 1 byte of address length, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left. (Expected 1 byte of address length, got %hhu)\n", + len); goto out; } @@ -3016,22 +2642,21 @@ static int unpack_item_area_address(uint16_t mtid, uint8_t len, rv->len = stream_getc(s); if (len < 1 + rv->len) { - sbuf_push(log, indent, "Not enough data left. (Expected %hhu bytes of address, got %u)\n", + sbuf_push(log, indent, + "Not enough data left. (Expected %hhu bytes of address, got %u)\n", rv->len, len - 1); goto out; } if (rv->len < 1 || rv->len > 20) { - sbuf_push(log, indent, - "Implausible area address length %hhu\n", - rv->len); + sbuf_push(log, indent, "Implausible area address length %hhu\n", rv->len); goto out; } stream_get(rv->addr, s, rv->len); - format_item_area_address(ISIS_MT_IPV4_UNICAST, (struct isis_item *)rv, - log, NULL, indent + 2); + format_item_area_address(ISIS_MT_IPV4_UNICAST, (struct isis_item *)rv, log, NULL, + indent + 2); append_item(&tlvs->area_addresses, (struct isis_item *)rv); return 0; out: @@ -3050,8 +2675,7 @@ static struct isis_item *copy_item_oldstyle_reach(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_oldstyle_reach(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, +static void format_item_oldstyle_reach(uint16_t mtid, struct isis_item *i, struct sbuf *buf, struct json_object *json, int indent) { struct isis_oldstyle_reach *r = (struct isis_oldstyle_reach *)i; @@ -3065,15 +2689,13 @@ static void format_item_oldstyle_reach(uint16_t mtid, struct isis_item *i, 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_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); + sbuf_push(buf, indent, "IS Reachability: %s (Metric: %hhu)\n", sys_id, r->metric); } static void free_item_oldstyle_reach(struct isis_item *i) @@ -3081,8 +2703,7 @@ static void free_item_oldstyle_reach(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_oldstyle_reach(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_oldstyle_reach(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_oldstyle_reach *r = (struct isis_oldstyle_reach *)i; @@ -3100,18 +2721,16 @@ static int pack_item_oldstyle_reach(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_oldstyle_reach(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, - void *dest, int indent) +static int unpack_item_oldstyle_reach(uint16_t mtid, uint8_t len, struct stream *s, + struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; sbuf_push(log, indent, "Unpack oldstyle reach...\n"); if (len < 11) { - sbuf_push( - log, indent, - "Not enough data left.(Expected 11 bytes of reach information, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left.(Expected 11 bytes of reach information, got %hhu)\n", + len); return 1; } @@ -3124,8 +2743,7 @@ static int unpack_item_oldstyle_reach(uint16_t mtid, uint8_t len, stream_forward_getp(s, 3); /* Skip other metrics */ stream_get(rv->id, s, 7); - format_item_oldstyle_reach(mtid, (struct isis_item *)rv, log, NULL, - indent + 2); + format_item_oldstyle_reach(mtid, (struct isis_item *)rv, log, NULL, indent + 2); append_item(&tlvs->oldstyle_reach, (struct isis_item *)rv); return 0; } @@ -3140,9 +2758,8 @@ static struct isis_item *copy_item_lan_neighbor(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_lan_neighbor(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_item_lan_neighbor(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { struct isis_lan_neighbor *n = (struct isis_lan_neighbor *)i; char sys_id[ISO_SYSID_STRLEN]; @@ -3159,8 +2776,7 @@ static void free_item_lan_neighbor(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_lan_neighbor(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_lan_neighbor(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_lan_neighbor *n = (struct isis_lan_neighbor *)i; @@ -3174,18 +2790,15 @@ static int pack_item_lan_neighbor(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_lan_neighbor(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, +static int unpack_item_lan_neighbor(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; sbuf_push(log, indent, "Unpack LAN neighbor...\n"); if (len < 6) { - sbuf_push( - log, indent, - "Not enough data left.(Expected 6 bytes of mac, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left.(Expected 6 bytes of mac, got %hhu)\n", len); return 1; } @@ -3211,9 +2824,8 @@ static struct isis_item *copy_item_lsp_entry(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_lsp_entry(uint16_t mtid, struct isis_item *i, - struct sbuf *sbuf, struct json_object *json, - int indent) +static void format_item_lsp_entry(uint16_t mtid, struct isis_item *i, struct sbuf *sbuf, + struct json_object *json, int indent) { struct isis_lsp_entry *e = (struct isis_lsp_entry *)i; char sys_id[ISO_SYSID_STRLEN]; @@ -3232,8 +2844,7 @@ static void format_item_lsp_entry(uint16_t mtid, struct isis_item *i, json_object_string_add(lsp_json, "chksum", buf); json_object_int_add(lsp_json, "lifetime", e->checksum); } else - sbuf_push(sbuf, indent, - "LSP Entry: %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus\n", + sbuf_push(sbuf, indent, "LSP Entry: %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus\n", sys_id, e->seqno, e->checksum, e->rem_lifetime); } @@ -3242,8 +2853,7 @@ static void free_item_lsp_entry(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_lsp_entry(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_lsp_entry(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_lsp_entry *e = (struct isis_lsp_entry *)i; @@ -3260,17 +2870,15 @@ static int pack_item_lsp_entry(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_lsp_entry(uint16_t mtid, uint8_t len, struct stream *s, - struct sbuf *log, void *dest, int indent) +static int unpack_item_lsp_entry(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, + void *dest, int indent) { struct isis_tlvs *tlvs = dest; sbuf_push(log, indent, "Unpack LSP entry...\n"); if (len < 16) { - sbuf_push( - log, indent, - "Not enough data left. (Expected 16 bytes of LSP info, got %hhu", - len); + sbuf_push(log, indent, + "Not enough data left. (Expected 16 bytes of LSP info, got %hhu", len); return 1; } @@ -3301,8 +2909,7 @@ static struct isis_item *copy_item_extended_reach(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_extended_reach(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, +static void format_item_extended_reach(uint16_t mtid, struct isis_item *i, struct sbuf *buf, struct json_object *json, int indent) { struct isis_extended_reach *r = (struct isis_extended_reach *)i; @@ -3320,29 +2927,23 @@ static void format_item_extended_reach(uint16_t mtid, struct isis_item *i, } json_object_array_add(array_json, reach_json); json_object_string_add(reach_json, "mtId", - (mtid == ISIS_MT_IPV4_UNICAST) - ? "Extended" - : "MT"); + (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)); + 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); + format_item_ext_subtlvs(r->subtlvs, NULL, reach_json, indent + 2, mtid); } else { sbuf_push(buf, indent, "%s Reachability: %s (Metric: %u)", - (mtid == ISIS_MT_IPV4_UNICAST) ? "Extended" : "MT", - sys_id, r->metric); + (mtid == ISIS_MT_IPV4_UNICAST) ? "Extended" : "MT", sys_id, r->metric); if (mtid != ISIS_MT_IPV4_UNICAST) sbuf_push(buf, 0, " %s", isis_mtid2str(mtid)); sbuf_push(buf, 0, "\n"); if (r->subtlvs) - format_item_ext_subtlvs(r->subtlvs, buf, NULL, - indent + 2, mtid); + format_item_ext_subtlvs(r->subtlvs, buf, NULL, indent + 2, mtid); } } @@ -3355,8 +2956,7 @@ static void free_item_extended_reach(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, item); } -static int pack_item_extended_reach(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_extended_reach(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_extended_reach *r = (struct isis_extended_reach *)i; size_t len; @@ -3370,7 +2970,7 @@ static int pack_item_extended_reach(struct isis_item *i, struct stream *s, stream_put(s, r->id, sizeof(r->id)); stream_put3(s, r->metric); len_pos = stream_get_endp(s); - /* Real length will be adjust after adding subTLVs */ + /* Real length will be adjust after adding subTLVs */ stream_putc(s, 11); if (r->subtlvs) pack_item_ext_subtlvs(r->subtlvs, s, min_len); @@ -3380,9 +2980,8 @@ static int pack_item_extended_reach(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_extended_reach(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, - void *dest, int indent) +static int unpack_item_extended_reach(uint16_t mtid, uint8_t len, struct stream *s, + struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; struct isis_extended_reach *rv = NULL; @@ -3400,8 +2999,7 @@ static int unpack_item_extended_reach(uint16_t mtid, uint8_t len, if (len < 11) { sbuf_push(log, indent, - "Not enough data left. (expected 11 or more bytes, got %hhu)\n", - len); + "Not enough data left. (expected 11 or more bytes, got %hhu)\n", len); goto out; } @@ -3417,18 +3015,14 @@ static int unpack_item_extended_reach(uint16_t mtid, uint8_t len, goto out; } - sbuf_push(log, indent, "Storing %hhu bytes of subtlvs\n", - subtlv_len); + sbuf_push(log, indent, "Storing %hhu bytes of subtlvs\n", subtlv_len); if (subtlv_len) { - if (unpack_item_ext_subtlvs(mtid, subtlv_len, s, log, rv, - indent + 4)) { + if (unpack_item_ext_subtlvs(mtid, subtlv_len, s, log, rv, indent + 4)) goto out; - } } - format_item_extended_reach(mtid, (struct isis_item *)rv, log, NULL, - indent + 2); + format_item_extended_reach(mtid, (struct isis_item *)rv, log, NULL, indent + 2); append_item(items, (struct isis_item *)rv); return 0; out: @@ -3442,16 +3036,14 @@ static int unpack_item_extended_reach(uint16_t mtid, uint8_t len, static struct isis_item *copy_item_oldstyle_ip_reach(struct isis_item *i) { struct isis_oldstyle_ip_reach *r = (struct isis_oldstyle_ip_reach *)i; - struct isis_oldstyle_ip_reach *rv = - XCALLOC(MTYPE_ISIS_TLV, sizeof(*rv)); + struct isis_oldstyle_ip_reach *rv = XCALLOC(MTYPE_ISIS_TLV, sizeof(*rv)); rv->metric = r->metric; rv->prefix = r->prefix; return (struct isis_item *)rv; } -static void format_item_oldstyle_ip_reach(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, +static void format_item_oldstyle_ip_reach(uint16_t mtid, struct isis_item *i, struct sbuf *buf, struct json_object *json, int indent) { struct isis_oldstyle_ip_reach *r = (struct isis_oldstyle_ip_reach *)i; @@ -3464,19 +3056,16 @@ static void format_item_oldstyle_ip_reach(uint16_t mtid, struct isis_item *i, 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_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))); + 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); + prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), r->metric); } static void free_item_oldstyle_ip_reach(struct isis_item *i) @@ -3484,8 +3073,7 @@ static void free_item_oldstyle_ip_reach(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_oldstyle_ip_reach(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_oldstyle_ip_reach(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_oldstyle_ip_reach *r = (struct isis_oldstyle_ip_reach *)i; @@ -3507,21 +3095,18 @@ static int pack_item_oldstyle_ip_reach(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_oldstyle_ip_reach(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, - void *dest, int indent) +static int unpack_item_oldstyle_ip_reach(uint16_t mtid, uint8_t len, struct stream *s, + struct sbuf *log, void *dest, int indent) { sbuf_push(log, indent, "Unpack oldstyle ip reach...\n"); if (len < 12) { - sbuf_push( - log, indent, - "Not enough data left.(Expected 12 bytes of reach information, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left.(Expected 12 bytes of reach information, got %hhu)\n", + len); return 1; } - struct isis_oldstyle_ip_reach *rv = - XCALLOC(MTYPE_ISIS_TLV, sizeof(*rv)); + struct isis_oldstyle_ip_reach *rv = XCALLOC(MTYPE_ISIS_TLV, sizeof(*rv)); rv->metric = stream_getc(s); if ((rv->metric & 0x7f) != rv->metric) { sbuf_push(log, indent, "Metric has unplausible format\n"); @@ -3532,11 +3117,11 @@ static int unpack_item_oldstyle_ip_reach(uint16_t mtid, uint8_t len, stream_get(&rv->prefix.prefix, s, 4); struct in_addr mask; + stream_get(&mask, s, 4); rv->prefix.prefixlen = ip_masklen(mask); - format_item_oldstyle_ip_reach(mtid, (struct isis_item *)rv, log, NULL, - indent + 2); + format_item_oldstyle_ip_reach(mtid, (struct isis_item *)rv, log, NULL, indent + 2); append_item(dest, (struct isis_item *)rv); return 0; } @@ -3554,8 +3139,7 @@ static void copy_tlv_protocols_supported(struct isis_protocols_supported *src, memcpy(dest->protocols, src->protocols, src->count); } -static void format_tlv_protocols_supported(struct isis_protocols_supported *p, - struct sbuf *sbuf, +static void format_tlv_protocols_supported(struct isis_protocols_supported *p, struct sbuf *sbuf, struct json_object *json, int indent) { if (!p || !p->count || !p->protocols) @@ -3566,12 +3150,10 @@ static void format_tlv_protocols_supported(struct isis_protocols_supported *p, char buf[255]; protocol_json = json_object_new_object(); - json_object_object_add(json, "supportedProtocols", - protocol_json); + 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])); + json_object_string_add(protocol_json, buf, nlpid2str(p->protocols[i])); } } else { sbuf_push(sbuf, indent, "Protocols Supported: "); @@ -3588,8 +3170,7 @@ static void free_tlv_protocols_supported(struct isis_protocols_supported *p) XFREE(MTYPE_ISIS_TLV, p->protocols); } -static int pack_tlv_protocols_supported(struct isis_protocols_supported *p, - struct stream *s) +static int pack_tlv_protocols_supported(struct isis_protocols_supported *p, struct stream *s) { if (!p || !p->count || !p->protocols) return 0; @@ -3603,9 +3184,8 @@ static int pack_tlv_protocols_supported(struct isis_protocols_supported *p, return 0; } -static int unpack_tlv_protocols_supported(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, +static int unpack_tlv_protocols_supported(enum isis_tlv_context context, uint8_t tlv_type, + uint8_t tlv_len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; @@ -3616,9 +3196,8 @@ static int unpack_tlv_protocols_supported(enum isis_tlv_context context, return 0; } if (tlvs->protocols_supported.protocols) { - sbuf_push( - log, indent, - "WARNING: protocols supported TLV present multiple times.\n"); + sbuf_push(log, indent, + "WARNING: protocols supported TLV present multiple times.\n"); stream_forward_getp(s, tlv_len); return 0; } @@ -3627,8 +3206,7 @@ static int unpack_tlv_protocols_supported(enum isis_tlv_context context, tlvs->protocols_supported.protocols = XCALLOC(MTYPE_ISIS_TLV, tlv_len); stream_get(tlvs->protocols_supported.protocols, s, tlv_len); - format_tlv_protocols_supported(&tlvs->protocols_supported, log, NULL, - indent + 2); + format_tlv_protocols_supported(&tlvs->protocols_supported, log, NULL, indent + 2); return 0; } @@ -3642,9 +3220,8 @@ static struct isis_item *copy_item_ipv4_address(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_ipv4_address(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_item_ipv4_address(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { struct isis_ipv4_address *a = (struct isis_ipv4_address *)i; char addrbuf[INET_ADDRSTRLEN]; @@ -3662,8 +3239,7 @@ static void free_item_ipv4_address(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_ipv4_address(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_ipv4_address(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_ipv4_address *a = (struct isis_ipv4_address *)i; @@ -3677,18 +3253,16 @@ static int pack_item_ipv4_address(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_ipv4_address(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, +static int unpack_item_ipv4_address(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; sbuf_push(log, indent, "Unpack IPv4 Interface address...\n"); if (len < 4) { - sbuf_push( - log, indent, - "Not enough data left.(Expected 4 bytes of IPv4 address, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left.(Expected 4 bytes of IPv4 address, got %hhu)\n", + len); return 1; } @@ -3711,9 +3285,8 @@ static struct isis_item *copy_item_ipv6_address(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_ipv6_address(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_item_ipv6_address(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { struct isis_ipv6_address *a = (struct isis_ipv6_address *)i; char addrbuf[INET6_ADDRSTRLEN]; @@ -3730,8 +3303,7 @@ static void free_item_ipv6_address(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_ipv6_address(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_ipv6_address(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_ipv6_address *a = (struct isis_ipv6_address *)i; @@ -3745,18 +3317,16 @@ static int pack_item_ipv6_address(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_ipv6_address(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, +static int unpack_item_ipv6_address(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; sbuf_push(log, indent, "Unpack IPv6 Interface address...\n"); if (len < 16) { - sbuf_push( - log, indent, - "Not enough data left.(Expected 16 bytes of IPv6 address, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left.(Expected 16 bytes of IPv6 address, got %hhu)\n", + len); return 1; } @@ -3779,10 +3349,8 @@ static struct isis_item *copy_item_global_ipv6_address(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_global_ipv6_address(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, - struct json_object *json, - int indent) +static void format_item_global_ipv6_address(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { struct isis_ipv6_address *a = (struct isis_ipv6_address *)i; char addrbuf[INET6_ADDRSTRLEN]; @@ -3791,8 +3359,7 @@ static void format_item_global_ipv6_address(uint16_t mtid, struct isis_item *i, if (json) json_object_string_add(json, "globalIpv6", addrbuf); else - sbuf_push(buf, indent, "Global IPv6 Interface Address: %s\n", - addrbuf); + sbuf_push(buf, indent, "Global IPv6 Interface Address: %s\n", addrbuf); } static void free_item_global_ipv6_address(struct isis_item *i) @@ -3800,8 +3367,7 @@ static void free_item_global_ipv6_address(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_global_ipv6_address(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_global_ipv6_address(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_ipv6_address *a = (struct isis_ipv6_address *)i; @@ -3815,26 +3381,23 @@ static int pack_item_global_ipv6_address(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_global_ipv6_address(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, - void *dest, int indent) +static int unpack_item_global_ipv6_address(uint16_t mtid, uint8_t len, struct stream *s, + struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; sbuf_push(log, indent, "Unpack Global IPv6 Interface address...\n"); if (len < IPV6_MAX_BYTELEN) { - sbuf_push( - log, indent, - "Not enough data left.(Expected 16 bytes of IPv6 address, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left.(Expected 16 bytes of IPv6 address, got %hhu)\n", + len); return 1; } struct isis_ipv6_address *rv = XCALLOC(MTYPE_ISIS_TLV, sizeof(*rv)); stream_get(&rv->addr, s, IPV6_MAX_BYTELEN); - format_item_global_ipv6_address(mtid, (struct isis_item *)rv, log, NULL, - indent + 2); + format_item_global_ipv6_address(mtid, (struct isis_item *)rv, log, NULL, indent + 2); append_item(&tlvs->global_ipv6_address, (struct isis_item *)rv); return 0; } @@ -3851,8 +3414,7 @@ static struct isis_item *copy_item_mt_router_info(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_mt_router_info(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, +static void format_item_mt_router_info(uint16_t mtid, struct isis_item *i, struct sbuf *buf, struct json_object *json, int indent) { struct isis_mt_router_info *info = (struct isis_mt_router_info *)i; @@ -3867,20 +3429,14 @@ static void format_item_mt_router_info(uint16_t mtid, struct isis_item *i, } 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)); - - json_object_boolean_add(mt_json, "overloadBit", - !!info->overload); - json_object_boolean_add(mt_json, "attachedbit", - !!info->attached); + json_object_string_add(mt_json, "mt-description", isis_mtid2str_fake(info->mtid)); + json_object_string_add(mt_json, "mtDescription", isis_mtid2str(mtid)); + + 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), - info->overload ? " Overload" : "", - info->attached ? " Attached" : ""); + sbuf_push(buf, indent, "MT Router Info: %s%s%s\n", isis_mtid2str_fake(info->mtid), + info->overload ? " Overload" : "", info->attached ? " Attached" : ""); } static void free_item_mt_router_info(struct isis_item *i) @@ -3888,8 +3444,7 @@ static void free_item_mt_router_info(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_mt_router_info(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_mt_router_info(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_mt_router_info *info = (struct isis_mt_router_info *)i; @@ -3910,18 +3465,15 @@ static int pack_item_mt_router_info(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_mt_router_info(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, - void *dest, int indent) +static int unpack_item_mt_router_info(uint16_t mtid, uint8_t len, struct stream *s, + struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; sbuf_push(log, indent, "Unpack MT Router info...\n"); if (len < 2) { - sbuf_push( - log, indent, - "Not enough data left.(Expected 2 bytes of MT info, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left.(Expected 2 bytes of MT info, got %hhu)\n", len); return 1; } @@ -3932,8 +3484,7 @@ static int unpack_item_mt_router_info(uint16_t mtid, uint8_t len, rv->attached = entry & ISIS_MT_AT_MASK; rv->mtid = entry & ISIS_MT_MASK; - format_item_mt_router_info(mtid, (struct isis_item *)rv, log, NULL, - indent + 2); + format_item_mt_router_info(mtid, (struct isis_item *)rv, log, NULL, indent + 2); append_item(&tlvs->mt_router_info, (struct isis_item *)rv); return 0; } @@ -3983,10 +3534,8 @@ static int pack_tlv_te_router_id(const struct in_addr *id, struct stream *s) return 0; } -static int unpack_tlv_te_router_id(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, - void *dest, int indent) +static int unpack_tlv_te_router_id(enum isis_tlv_context context, uint8_t tlv_type, uint8_t tlv_len, + struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; @@ -3997,8 +3546,7 @@ static int unpack_tlv_te_router_id(enum isis_tlv_context context, } if (tlvs->te_router_id) { - sbuf_push(log, indent, - "WARNING: TE Router ID present multiple times.\n"); + sbuf_push(log, indent, "WARNING: TE Router ID present multiple times.\n"); stream_forward_getp(s, tlv_len); return 0; } @@ -4015,8 +3563,7 @@ static int unpack_tlv_te_router_id(enum isis_tlv_context context, static struct isis_item *copy_item_extended_ip_reach(struct isis_item *i) { struct isis_extended_ip_reach *r = (struct isis_extended_ip_reach *)i; - struct isis_extended_ip_reach *rv = - XCALLOC(MTYPE_ISIS_TLV, sizeof(*rv)); + struct isis_extended_ip_reach *rv = XCALLOC(MTYPE_ISIS_TLV, sizeof(*rv)); rv->metric = r->metric; rv->down = r->down; @@ -4026,8 +3573,7 @@ static struct isis_item *copy_item_extended_ip_reach(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_extended_ip_reach(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, +static void format_item_extended_ip_reach(uint16_t mtid, struct isis_item *i, struct sbuf *buf, struct json_object *json, int indent) { struct isis_extended_ip_reach *r = (struct isis_extended_ip_reach *)i; @@ -4043,17 +3589,13 @@ static void format_item_extended_ip_reach(uint16_t mtid, struct isis_item *i, } json_object_array_add(array_json, ext_json); json_object_string_add(ext_json, "mtId", - (mtid == ISIS_MT_IPV4_UNICAST) - ? "Extended" - : "MT"); + (mtid == ISIS_MT_IPV4_UNICAST) ? "Extended" : "MT"); json_object_string_add(ext_json, "ipReach", - prefix2str(&r->prefix, prefixbuf, - sizeof(prefixbuf))); + 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)); + json_object_string_add(ext_json, "mtName", isis_mtid2str(mtid)); if (r->subtlvs) { struct json_object *subtlv_json; subtlv_json = json_object_new_object(); @@ -4063,8 +3605,8 @@ static void format_item_extended_ip_reach(uint16_t mtid, struct isis_item *i, } else { sbuf_push(buf, indent, "%s IP Reachability: %s (Metric: %u)%s", (mtid == ISIS_MT_IPV4_UNICAST) ? "Extended" : "MT", - prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), - r->metric, r->down ? " Down" : ""); + prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), r->metric, + r->down ? " Down" : ""); if (mtid != ISIS_MT_IPV4_UNICAST) sbuf_push(buf, 0, " %s", isis_mtid2str(mtid)); sbuf_push(buf, 0, "\n"); @@ -4078,14 +3620,13 @@ static void format_item_extended_ip_reach(uint16_t mtid, struct isis_item *i, static void free_item_extended_ip_reach(struct isis_item *i) { - struct isis_extended_ip_reach *item = - (struct isis_extended_ip_reach *)i; + struct isis_extended_ip_reach *item = (struct isis_extended_ip_reach *)i; + isis_free_subtlvs(item->subtlvs); XFREE(MTYPE_ISIS_TLV, item); } -static int pack_item_extended_ip_reach(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_extended_ip_reach(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_extended_ip_reach *r = (struct isis_extended_ip_reach *)i; uint8_t control; @@ -4113,9 +3654,8 @@ static int pack_item_extended_ip_reach(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, - void *dest, int indent) +static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len, struct stream *s, + struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; struct isis_extended_ip_reach *rv = NULL; @@ -4135,8 +3675,7 @@ static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len, consume = 5; if (len < consume) { sbuf_push(log, indent, - "Not enough data left. (expected 5 or more bytes, got %hhu)\n", - len); + "Not enough data left. (expected 5 or more bytes, got %hhu)\n", len); goto out; } @@ -4164,10 +3703,8 @@ static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len, in_addr_t orig_prefix = rv->prefix.prefix.s_addr; apply_mask_ipv4(&rv->prefix); if (orig_prefix != rv->prefix.prefix.s_addr) - sbuf_push(log, indent + 2, - "WARNING: Prefix had hostbits set.\n"); - format_item_extended_ip_reach(mtid, (struct isis_item *)rv, log, NULL, - indent + 2); + sbuf_push(log, indent + 2, "WARNING: Prefix had hostbits set.\n"); + format_item_extended_ip_reach(mtid, (struct isis_item *)rv, log, NULL, indent + 2); if (control & ISIS_EXTENDED_IP_REACH_SUBTLV) { consume += 1; @@ -4186,16 +3723,15 @@ static int unpack_item_extended_ip_reach(uint16_t mtid, uint8_t len, if (len < consume) { sbuf_push(log, indent, "Expected %hhu bytes of subtlvs, but only %u bytes available.\n", - subtlv_len, - len - 6 - PSIZE(rv->prefix.prefixlen)); + subtlv_len, len - 6 - PSIZE(rv->prefix.prefixlen)); goto out; } rv->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_IP_REACH); bool unpacked_known_tlvs = false; - if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_IP_REACH, subtlv_len, s, - log, rv->subtlvs, indent + 4, &unpacked_known_tlvs)) { + if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_IP_REACH, subtlv_len, s, log, rv->subtlvs, + indent + 4, &unpacked_known_tlvs)) { goto out; } if (!unpacked_known_tlvs) { @@ -4255,9 +3791,8 @@ static int pack_tlv_dynamic_hostname(const char *hostname, struct stream *s) return 0; } -static int unpack_tlv_dynamic_hostname(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, +static int unpack_tlv_dynamic_hostname(enum isis_tlv_context context, uint8_t tlv_type, + uint8_t tlv_len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; @@ -4269,8 +3804,7 @@ static int unpack_tlv_dynamic_hostname(enum isis_tlv_context context, } if (tlvs->hostname) { - sbuf_push(log, indent, - "WARNING: Hostname present multiple times.\n"); + sbuf_push(log, indent, "WARNING: Hostname present multiple times.\n"); stream_forward_getp(s, tlv_len); return 0; } @@ -4281,16 +3815,15 @@ static int unpack_tlv_dynamic_hostname(enum isis_tlv_context context, bool sane = true; for (uint8_t i = 0; i < tlv_len; i++) { - if ((unsigned char)tlvs->hostname[i] > 127 - || !isprint((unsigned char)tlvs->hostname[i])) { + if ((unsigned char)tlvs->hostname[i] > 127 || + !isprint((unsigned char)tlvs->hostname[i])) { sane = false; tlvs->hostname[i] = '?'; } } if (!sane) { - sbuf_push( - log, indent, - "WARNING: Hostname contained non-printable/non-ascii characters.\n"); + sbuf_push(log, indent, + "WARNING: Hostname contained non-printable/non-ascii characters.\n"); } return 0; @@ -4308,8 +3841,7 @@ static struct in6_addr *copy_tlv_te_router_id_ipv6(const struct in6_addr *id) return rv; } -static void format_tlv_te_router_id_ipv6(const struct in6_addr *id, - struct sbuf *buf, +static void format_tlv_te_router_id_ipv6(const struct in6_addr *id, struct sbuf *buf, struct json_object *json, int indent) { if (!id) @@ -4328,8 +3860,7 @@ static void free_tlv_te_router_id_ipv6(struct in6_addr *id) XFREE(MTYPE_ISIS_TLV, id); } -static int pack_tlv_te_router_id_ipv6(const struct in6_addr *id, - struct stream *s) +static int pack_tlv_te_router_id_ipv6(const struct in6_addr *id, struct stream *s) { if (!id) return 0; @@ -4343,9 +3874,8 @@ static int pack_tlv_te_router_id_ipv6(const struct in6_addr *id, return 0; } -static int unpack_tlv_te_router_id_ipv6(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, +static int unpack_tlv_te_router_id_ipv6(enum isis_tlv_context context, uint8_t tlv_type, + uint8_t tlv_len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; @@ -4357,9 +3887,7 @@ static int unpack_tlv_te_router_id_ipv6(enum isis_tlv_context context, } if (tlvs->te_router_id_ipv6) { - sbuf_push( - log, indent, - "WARNING: IPv6 TE Router ID present multiple times.\n"); + sbuf_push(log, indent, "WARNING: IPv6 TE Router ID present multiple times.\n"); stream_forward_getp(s, tlv_len); return 0; } @@ -4373,8 +3901,7 @@ static int unpack_tlv_te_router_id_ipv6(enum isis_tlv_context context, /* Functions related to TLV 150 Spine-Leaf-Extension */ -static struct isis_spine_leaf *copy_tlv_spine_leaf( - const struct isis_spine_leaf *spine_leaf) +static struct isis_spine_leaf *copy_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf) { if (!spine_leaf) return NULL; @@ -4385,9 +3912,8 @@ static struct isis_spine_leaf *copy_tlv_spine_leaf( return rv; } -static void format_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf, struct sbuf *buf, + struct json_object *json, int indent) { if (!spine_leaf) return; @@ -4400,16 +3926,13 @@ static void format_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf, 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); + snprintfrr(aux_buf, sizeof(aux_buf), "%hhu", spine_leaf->tier); json_object_string_add(spine_json, "tier", - (spine_leaf->tier == - ISIS_TIER_UNDEFINED) + (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, "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", @@ -4417,16 +3940,13 @@ static void format_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf, } else { sbuf_push(buf, indent, "Spine-Leaf-Extension:\n"); if (spine_leaf->has_tier) { - if (spine_leaf->tier == ISIS_TIER_UNDEFINED) { + if (spine_leaf->tier == ISIS_TIER_UNDEFINED) sbuf_push(buf, indent, " Tier: undefined\n"); - } else { - sbuf_push(buf, indent, " Tier: %hhu\n", - spine_leaf->tier); - } + else + sbuf_push(buf, indent, " Tier: %hhu\n", spine_leaf->tier); } - sbuf_push(buf, indent, " Flags:%s%s%s\n", - spine_leaf->is_leaf ? " LEAF" : "", + sbuf_push(buf, indent, " Flags:%s%s%s\n", spine_leaf->is_leaf ? " LEAF" : "", spine_leaf->is_spine ? " SPINE" : "", spine_leaf->is_backup ? " BACKUP" : ""); } @@ -4437,13 +3957,12 @@ static void free_tlv_spine_leaf(struct isis_spine_leaf *spine_leaf) XFREE(MTYPE_ISIS_TLV, spine_leaf); } -#define ISIS_SPINE_LEAF_FLAG_TIER 0x08 +#define ISIS_SPINE_LEAF_FLAG_TIER 0x08 #define ISIS_SPINE_LEAF_FLAG_BACKUP 0x04 -#define ISIS_SPINE_LEAF_FLAG_SPINE 0x02 -#define ISIS_SPINE_LEAF_FLAG_LEAF 0x01 +#define ISIS_SPINE_LEAF_FLAG_SPINE 0x02 +#define ISIS_SPINE_LEAF_FLAG_LEAF 0x01 -static int pack_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf, - struct stream *s) +static int pack_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf, struct stream *s) { if (!spine_leaf) return 0; @@ -4477,10 +3996,8 @@ static int pack_tlv_spine_leaf(const struct isis_spine_leaf *spine_leaf, return 0; } -static int unpack_tlv_spine_leaf(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, - void *dest, int indent) +static int unpack_tlv_spine_leaf(enum isis_tlv_context context, uint8_t tlv_type, uint8_t tlv_len, + struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; @@ -4531,8 +4048,7 @@ const char *isis_threeway_state_name(enum isis_threeway_state state) } } -static struct isis_threeway_adj *copy_tlv_threeway_adj( - const struct isis_threeway_adj *threeway_adj) +static struct isis_threeway_adj *copy_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj) { if (!threeway_adj) return NULL; @@ -4543,9 +4059,8 @@ static struct isis_threeway_adj *copy_tlv_threeway_adj( return rv; } -static void -format_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj, - struct sbuf *buf, struct json_object *json, int indent) +static void format_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj, struct sbuf *buf, + struct json_object *json, int indent) { char sys_id[ISO_SYSID_STRLEN]; @@ -4559,22 +4074,19 @@ format_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj, 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)); + 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_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", - isis_threeway_state_name(threeway_adj->state), - threeway_adj->state); + isis_threeway_state_name(threeway_adj->state), threeway_adj->state); sbuf_push(buf, indent, " Extended Local Circuit ID: %u\n", threeway_adj->local_circuit_id); if (!threeway_adj->neighbor_set) @@ -4591,8 +4103,7 @@ static void free_tlv_threeway_adj(struct isis_threeway_adj *threeway_adj) XFREE(MTYPE_ISIS_TLV, threeway_adj); } -static int pack_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj, - struct stream *s) +static int pack_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj, struct stream *s) { if (!threeway_adj) return 0; @@ -4615,10 +4126,8 @@ static int pack_tlv_threeway_adj(const struct isis_threeway_adj *threeway_adj, return 0; } -static int unpack_tlv_threeway_adj(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, - void *dest, int indent) +static int unpack_tlv_threeway_adj(enum isis_tlv_context context, uint8_t tlv_type, uint8_t tlv_len, + struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; @@ -4665,9 +4174,8 @@ static struct isis_item *copy_item_ipv6_reach(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_ipv6_reach(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_item_ipv6_reach(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { struct isis_ipv6_reach *r = (struct isis_ipv6_reach *)i; char prefixbuf[PREFIX2STR_BUFFER]; @@ -4683,36 +4191,27 @@ static void format_item_ipv6_reach(uint16_t mtid, struct isis_item *i, } json_object_array_add(array_json, reach_json); json_object_string_add(reach_json, "mtId", - (mtid == ISIS_MT_IPV4_UNICAST) ? "" - : "mt"); + (mtid == ISIS_MT_IPV4_UNICAST) ? "" : "mt"); json_object_string_add(reach_json, "prefix", - prefix2str(&r->prefix, prefixbuf, - sizeof(prefixbuf))); + 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); + 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)); + 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); + json_object_object_add(reach_json, "subtlvs", subtlvs_json); format_subtlvs(r->subtlvs, NULL, subtlvs_json, 0); } } else { - sbuf_push(buf, indent, - "%sIPv6 Reachability: %s (Metric: %u)%s%s", + sbuf_push(buf, indent, "%sIPv6 Reachability: %s (Metric: %u)%s%s", (mtid == ISIS_MT_IPV4_UNICAST) ? "" : "MT ", - prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), - r->metric, r->down ? " Down" : "", - r->external ? " External" : ""); + prefix2str(&r->prefix, prefixbuf, sizeof(prefixbuf)), r->metric, + r->down ? " Down" : "", r->external ? " External" : ""); if (mtid != ISIS_MT_IPV4_UNICAST) sbuf_push(buf, 0, " %s", isis_mtid2str(mtid)); sbuf_push(buf, 0, "\n"); @@ -4732,8 +4231,7 @@ static void free_item_ipv6_reach(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, item); } -static int pack_item_ipv6_reach(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_ipv6_reach(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_ipv6_reach *r = (struct isis_ipv6_reach *)i; uint8_t control; @@ -4759,8 +4257,8 @@ static int pack_item_ipv6_reach(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s, - struct sbuf *log, void *dest, int indent) +static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, + void *dest, int indent) { struct isis_tlvs *tlvs = dest; struct isis_ipv6_reach *rv = NULL; @@ -4779,8 +4277,7 @@ static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s, consume = 6; if (len < consume) { sbuf_push(log, indent, - "Not enough data left. (expected 6 or more bytes, got %hhu)\n", - len); + "Not enough data left. (expected 6 or more bytes, got %hhu)\n", len); goto out; } @@ -4811,8 +4308,7 @@ static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s, apply_mask_ipv6(&rv->prefix); if (memcmp(&orig_prefix, &rv->prefix.prefix, sizeof(orig_prefix))) - sbuf_push(log, indent + 2, - "WARNING: Prefix had hostbits set.\n"); + sbuf_push(log, indent + 2, "WARNING: Prefix had hostbits set.\n"); format_item_ipv6_reach(mtid, (struct isis_item *)rv, log, NULL, indent + 2); if (control & ISIS_IPV6_REACH_SUBTLV) { @@ -4832,16 +4328,15 @@ static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s, if (len < consume) { sbuf_push(log, indent, "Expected %hhu bytes of subtlvs, but only %u bytes available.\n", - subtlv_len, - len - 6 - PSIZE(rv->prefix.prefixlen)); + subtlv_len, len - 6 - PSIZE(rv->prefix.prefixlen)); goto out; } rv->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_IPV6_REACH); bool unpacked_known_tlvs = false; - if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_IPV6_REACH, subtlv_len, s, - log, rv->subtlvs, indent + 4, &unpacked_known_tlvs)) { + if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_IPV6_REACH, subtlv_len, s, log, rv->subtlvs, + indent + 4, &unpacked_known_tlvs)) { goto out; } if (!unpacked_known_tlvs) { @@ -4859,8 +4354,7 @@ static int unpack_item_ipv6_reach(uint16_t mtid, uint8_t len, struct stream *s, } /* Functions related to TLV 242 Router Capability as per RFC7981 */ -static struct isis_router_cap *copy_tlv_router_cap( - const struct isis_router_cap *router_cap) +static struct isis_router_cap *copy_tlv_router_cap(const struct isis_router_cap *router_cap) { struct isis_router_cap *rv; @@ -4879,19 +4373,15 @@ static struct isis_router_cap *copy_tlv_router_cap( sc_fad = router_cap->fads[i]; if (!sc_fad) continue; - rv_fad = XMALLOC(MTYPE_ISIS_TLV, - sizeof(struct isis_router_cap_fad)); + rv_fad = XMALLOC(MTYPE_ISIS_TLV, sizeof(struct isis_router_cap_fad)); *rv_fad = *sc_fad; rv_fad->fad.admin_group_exclude_any.bitmap.data = NULL; rv_fad->fad.admin_group_include_any.bitmap.data = NULL; rv_fad->fad.admin_group_include_all.bitmap.data = NULL; - assert(bf_is_inited( - sc_fad->fad.admin_group_exclude_any.bitmap)); - assert(bf_is_inited( - sc_fad->fad.admin_group_include_any.bitmap)); - assert(bf_is_inited( - sc_fad->fad.admin_group_include_all.bitmap)); + assert(bf_is_inited(sc_fad->fad.admin_group_exclude_any.bitmap)); + assert(bf_is_inited(sc_fad->fad.admin_group_include_any.bitmap)); + assert(bf_is_inited(sc_fad->fad.admin_group_include_all.bitmap)); admin_group_copy(&rv_fad->fad.admin_group_exclude_any, &sc_fad->fad.admin_group_exclude_any); @@ -4908,7 +4398,7 @@ static struct isis_router_cap *copy_tlv_router_cap( } static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, - struct json_object *json) + struct json_object *json) { char addrbuf[INET_ADDRSTRLEN]; @@ -4922,10 +4412,8 @@ static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, 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)); + 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 */ @@ -4934,14 +4422,10 @@ static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, 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); + 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 */ @@ -4950,10 +4434,8 @@ static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, 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); + 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 */ @@ -4962,15 +4444,13 @@ static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, struct json_object *alg_json; alg_json = json_object_new_object(); - json_object_object_add(json, "segmentRoutingAlgorithm", - alg_json); + 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"); + router_cap->algo[i] == 0 ? "SPF" + : "Strict SPF"); } } } @@ -4980,8 +4460,8 @@ static void format_tlv_router_cap_json(const struct isis_router_cap *router_cap, json_object_int_add(json, "msd", router_cap->msd); } -static void format_tlv_router_cap(const struct isis_router_cap *router_cap, - struct sbuf *buf, int indent) +static void format_tlv_router_cap(const struct isis_router_cap *router_cap, struct sbuf *buf, + int indent) { char addrbuf[INET_ADDRSTRLEN]; @@ -4997,19 +4477,16 @@ static void format_tlv_router_cap(const struct isis_router_cap *router_cap, /* Segment Routing Global Block as per RFC8667 section #3.1 */ if (router_cap->srgb.range_size != 0) - sbuf_push( - buf, indent, - " Segment Routing: I:%s V:%s, Global Block Base: %u Range: %u\n", - IS_SR_IPV4(&router_cap->srgb) ? "1" : "0", - IS_SR_IPV6(&router_cap->srgb) ? "1" : "0", - router_cap->srgb.lower_bound, - router_cap->srgb.range_size); + sbuf_push(buf, indent, + " Segment Routing: I:%s V:%s, Global Block Base: %u Range: %u\n", + IS_SR_IPV4(&router_cap->srgb) ? "1" : "0", + IS_SR_IPV6(&router_cap->srgb) ? "1" : "0", router_cap->srgb.lower_bound, + router_cap->srgb.range_size); /* Segment Routing Local Block as per RFC8667 section #3.3 */ if (router_cap->srlb.range_size != 0) sbuf_push(buf, indent, " SR Local Block Base: %u Range: %u\n", - router_cap->srlb.lower_bound, - router_cap->srlb.range_size); + router_cap->srlb.lower_bound, router_cap->srlb.range_size); /* Segment Routing Algorithms as per RFC8667 section #3.2 */ if (router_cap->algo[0] != SR_ALGORITHM_UNSET) { @@ -5017,14 +4494,12 @@ static void format_tlv_router_cap(const struct isis_router_cap *router_cap, for (int i = 0; i < SR_ALGORITHM_COUNT; i++) if (router_cap->algo[i] != SR_ALGORITHM_UNSET) sbuf_push(buf, indent, " %u: %s\n", i, - sr_algorithm_string( - router_cap->algo[i])); + sr_algorithm_string(router_cap->algo[i])); } /* Segment Routing Node MSD as per RFC8491 section #2 */ if (router_cap->msd != 0) - sbuf_push(buf, indent, " Node Maximum SID Depth: %u\n", - router_cap->msd); + sbuf_push(buf, indent, " Node Maximum SID Depth: %u\n", router_cap->msd); #ifndef FABRICD /* Flex-Algo */ @@ -5038,49 +4513,41 @@ static void format_tlv_router_cap(const struct isis_router_cap *router_cap, if (!fad) continue; - sbuf_push(buf, indent, " Flex-Algo Definition: %d\n", - fad->fad.algorithm); - sbuf_push(buf, indent, " Metric-Type: %d\n", - fad->fad.metric_type); - sbuf_push(buf, indent, " Calc-Type: %d\n", - fad->fad.calc_type); + sbuf_push(buf, indent, " Flex-Algo Definition: %d\n", fad->fad.algorithm); + sbuf_push(buf, indent, " Metric-Type: %d\n", fad->fad.metric_type); + sbuf_push(buf, indent, " Calc-Type: %d\n", fad->fad.calc_type); sbuf_push(buf, indent, " Priority: %d\n", fad->fad.priority); indent2 = indent + strlen(" Exclude-Any: "); admin_group = &fad->fad.admin_group_exclude_any; sbuf_push(buf, indent, " Exclude-Any: "); sbuf_push(buf, 0, "%s\n", - admin_group_string(admin_group_buf, - ADMIN_GROUP_PRINT_MAX_SIZE, - indent2, admin_group)); + admin_group_string(admin_group_buf, ADMIN_GROUP_PRINT_MAX_SIZE, indent2, + admin_group)); indent2 = indent + strlen(" Include-Any: "); admin_group = &fad->fad.admin_group_include_any; sbuf_push(buf, indent, " Include-Any: "); sbuf_push(buf, 0, "%s\n", - admin_group_string(admin_group_buf, - ADMIN_GROUP_PRINT_MAX_SIZE, - indent2, admin_group)); + admin_group_string(admin_group_buf, ADMIN_GROUP_PRINT_MAX_SIZE, indent2, + admin_group)); indent2 = indent + strlen(" Include-All: "); admin_group = &fad->fad.admin_group_include_all; sbuf_push(buf, indent, " Include-All: "); sbuf_push(buf, 0, "%s\n", - admin_group_string(admin_group_buf, - ADMIN_GROUP_PRINT_MAX_SIZE, - indent2, admin_group)); + admin_group_string(admin_group_buf, ADMIN_GROUP_PRINT_MAX_SIZE, indent2, + admin_group)); sbuf_push(buf, indent, " M-Flag: %c\n", CHECK_FLAG(fad->fad.flags, FAD_FLAG_M) ? '1' : '0'); if (fad->fad.flags != 0 && fad->fad.flags != FAD_FLAG_M) - sbuf_push(buf, indent, " Flags: 0x%x\n", - fad->fad.flags); + sbuf_push(buf, indent, " Flags: 0x%x\n", fad->fad.flags); if (fad->fad.exclude_srlg) sbuf_push(buf, indent, " Exclude SRLG: Enabled\n"); if (fad->fad.unsupported_subtlv) - sbuf_push(buf, indent, - " Got an unsupported sub-TLV: Yes\n"); + sbuf_push(buf, indent, " Got an unsupported sub-TLV: Yes\n"); } #endif /* ifndef FABRICD */ @@ -5113,24 +4580,20 @@ static void free_tlv_router_cap(struct isis_router_cap *router_cap) } #ifndef FABRICD -static size_t -isis_router_cap_fad_sub_tlv_len(const struct isis_router_cap_fad *fad) +static size_t isis_router_cap_fad_sub_tlv_len(const struct isis_router_cap_fad *fad) { size_t sz = ISIS_SUBTLV_FAD_MIN_SIZE; uint32_t admin_group_length; - admin_group_length = - admin_group_nb_words(&fad->fad.admin_group_exclude_any); + admin_group_length = admin_group_nb_words(&fad->fad.admin_group_exclude_any); if (admin_group_length) sz += sizeof(uint32_t) * admin_group_length + 2; - admin_group_length = - admin_group_nb_words(&fad->fad.admin_group_include_any); + admin_group_length = admin_group_nb_words(&fad->fad.admin_group_include_any); if (admin_group_length) sz += sizeof(uint32_t) * admin_group_length + 2; - admin_group_length = - admin_group_nb_words(&fad->fad.admin_group_include_all); + admin_group_length = admin_group_nb_words(&fad->fad.admin_group_include_all); if (admin_group_length) sz += sizeof(uint32_t) * admin_group_length + 2; @@ -5151,8 +4614,7 @@ static size_t isis_router_cap_tlv_size(const struct isis_router_cap *router_cap) #endif /* ifndef FABRICD */ int nb_algo, nb_msd; - if ((router_cap->srgb.range_size != 0) && - (router_cap->srgb.lower_bound != 0)) { + if ((router_cap->srgb.range_size != 0) && (router_cap->srgb.lower_bound != 0)) { sz += 2 + ISIS_SUBTLV_SID_LABEL_RANGE_SIZE; sz += 2 + ISIS_SUBTLV_SID_LABEL_SIZE; @@ -5160,8 +4622,7 @@ static size_t isis_router_cap_tlv_size(const struct isis_router_cap *router_cap) if (nb_algo != 0) sz += 2 + nb_algo; - if ((router_cap->srlb.range_size != 0) && - (router_cap->srlb.lower_bound != 0)) { + if ((router_cap->srlb.range_size != 0) && (router_cap->srlb.lower_bound != 0)) { sz += 2 + ISIS_SUBTLV_SID_LABEL_RANGE_SIZE; sz += 2 + ISIS_SUBTLV_SID_LABEL_SIZE; } @@ -5174,8 +4635,7 @@ static size_t isis_router_cap_tlv_size(const struct isis_router_cap *router_cap) for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { if (!router_cap->fads[i]) continue; - fad_sz = 2 + - isis_router_cap_fad_sub_tlv_len(router_cap->fads[i]); + fad_sz = 2 + isis_router_cap_fad_sub_tlv_len(router_cap->fads[i]); if (((sz + fad_sz) % 256) < (sz % 256)) sz += 2 + ISIS_ROUTER_CAP_SIZE + fad_sz; else @@ -5184,32 +4644,26 @@ static size_t isis_router_cap_tlv_size(const struct isis_router_cap *router_cap) #endif /* ifndef FABRICD */ if (router_cap->srv6_cap.is_srv6_capable) { - sz += ISIS_SUBTLV_TYPE_FIELD_SIZE + - ISIS_SUBTLV_LENGTH_FIELD_SIZE + + sz += ISIS_SUBTLV_TYPE_FIELD_SIZE + ISIS_SUBTLV_LENGTH_FIELD_SIZE + ISIS_SUBTLV_SRV6_CAPABILITIES_SIZE; nb_algo = isis_tlvs_sr_algo_count(router_cap); if (nb_algo != 0) - sz += ISIS_SUBTLV_TYPE_FIELD_SIZE + - ISIS_SUBTLV_LENGTH_FIELD_SIZE + nb_algo; + sz += ISIS_SUBTLV_TYPE_FIELD_SIZE + ISIS_SUBTLV_LENGTH_FIELD_SIZE + nb_algo; nb_msd = router_cap->srv6_msd.max_seg_left_msd + router_cap->srv6_msd.max_end_pop_msd + - router_cap->srv6_msd.max_h_encaps_msd + - router_cap->srv6_msd.max_end_d_msd; + router_cap->srv6_msd.max_h_encaps_msd + router_cap->srv6_msd.max_end_d_msd; if (nb_msd != 0) - sz += ISIS_SUBTLV_TYPE_FIELD_SIZE + - ISIS_SUBTLV_LENGTH_FIELD_SIZE + - (ISIS_SUBTLV_NODE_MSD_TYPE_SIZE + - ISIS_SUBTLV_NODE_MSD_VALUE_SIZE) * + sz += ISIS_SUBTLV_TYPE_FIELD_SIZE + ISIS_SUBTLV_LENGTH_FIELD_SIZE + + (ISIS_SUBTLV_NODE_MSD_TYPE_SIZE + ISIS_SUBTLV_NODE_MSD_VALUE_SIZE) * nb_msd; } return sz; } -static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, - struct stream *s) +static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, struct stream *s) { size_t tlv_len, len_pos; uint8_t nb_algo; @@ -5230,8 +4684,7 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, stream_putc(s, router_cap->flags); /* Add SRGB if set as per RFC8667 section #3.1 */ - if ((router_cap->srgb.range_size != 0) - && (router_cap->srgb.lower_bound != 0)) { + if ((router_cap->srgb.range_size != 0) && (router_cap->srgb.lower_bound != 0)) { stream_putc(s, ISIS_SUBTLV_SID_LABEL_RANGE); stream_putc(s, ISIS_SUBTLV_SID_LABEL_RANGE_SIZE); stream_putc(s, router_cap->srgb.flags); @@ -5252,8 +4705,7 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, } /* Local Block if defined as per RFC8667 section #3.3 */ - if ((router_cap->srlb.range_size != 0) - && (router_cap->srlb.lower_bound != 0)) { + if ((router_cap->srlb.range_size != 0) && (router_cap->srlb.lower_bound != 0)) { stream_putc(s, ISIS_SUBTLV_SRLB); stream_putc(s, ISIS_SUBTLV_SID_LABEL_RANGE_SIZE); /* No Flags are defined for SRLB */ @@ -5364,16 +4816,13 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, stream_putc(s, ISIS_SUBTLV_ALGORITHM); stream_putc(s, nb_algo); for (int i = 0; i < SR_ALGORITHM_COUNT; i++) - if (router_cap->algo[i] != - SR_ALGORITHM_UNSET) - stream_putc(s, - router_cap->algo[i]); + if (router_cap->algo[i] != SR_ALGORITHM_UNSET) + stream_putc(s, router_cap->algo[i]); } } /* And finish with MSDs if set as per RFC 9352 section #4 */ - if (router_cap->srv6_msd.max_seg_left_msd + - router_cap->srv6_msd.max_end_pop_msd + + if (router_cap->srv6_msd.max_seg_left_msd + router_cap->srv6_msd.max_end_pop_msd + router_cap->srv6_msd.max_h_encaps_msd + router_cap->srv6_msd.max_end_d_msd != 0) { @@ -5387,34 +4836,25 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, /* RFC 9352 section #4.1 */ if (router_cap->srv6_msd.max_seg_left_msd != 0) { stream_putc(s, ISIS_SUBTLV_SRV6_MAX_SL_MSD); - stream_putc( - s, - router_cap->srv6_msd.max_seg_left_msd); + stream_putc(s, router_cap->srv6_msd.max_seg_left_msd); } /* RFC 9352 section #4.2 */ if (router_cap->srv6_msd.max_end_pop_msd != 0) { - stream_putc(s, - ISIS_SUBTLV_SRV6_MAX_END_POP_MSD); - stream_putc( - s, - router_cap->srv6_msd.max_end_pop_msd); + stream_putc(s, ISIS_SUBTLV_SRV6_MAX_END_POP_MSD); + stream_putc(s, router_cap->srv6_msd.max_end_pop_msd); } /* RFC 9352 section #4.3 */ if (router_cap->srv6_msd.max_h_encaps_msd != 0) { - stream_putc(s, - ISIS_SUBTLV_SRV6_MAX_H_ENCAPS_MSD); - stream_putc( - s, - router_cap->srv6_msd.max_h_encaps_msd); + stream_putc(s, ISIS_SUBTLV_SRV6_MAX_H_ENCAPS_MSD); + stream_putc(s, router_cap->srv6_msd.max_h_encaps_msd); } /* RFC 9352 section #4.4 */ if (router_cap->srv6_msd.max_end_d_msd != 0) { stream_putc(s, ISIS_SUBTLV_SRV6_MAX_END_D_MSD); - stream_putc(s, - router_cap->srv6_msd.max_end_d_msd); + stream_putc(s, router_cap->srv6_msd.max_end_d_msd); } /* Adjust Node MSD Sub-TLV length which depends on MSDs @@ -5431,10 +4871,8 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, return 0; } -static int unpack_tlv_router_cap(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, void *dest, - int indent) +static int unpack_tlv_router_cap(enum isis_tlv_context context, uint8_t tlv_type, uint8_t tlv_len, + struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; struct isis_router_cap *rcap; @@ -5454,8 +4892,7 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, if (!tlvs->router_cap) { /* First Router Capability TLV. * Allocate router cap structure and initialize SR Algorithms */ - tlvs->router_cap = XCALLOC(MTYPE_ISIS_TLV, - sizeof(struct isis_router_cap)); + tlvs->router_cap = XCALLOC(MTYPE_ISIS_TLV, sizeof(struct isis_router_cap)); for (int i = 0; i < SR_ALGORITHM_COUNT; i++) tlvs->router_cap->algo[i] = SR_ALGORITHM_UNSET; } @@ -5479,9 +4916,8 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, length = stream_getc(s); if (length > STREAM_READABLE(s) || length > subtlv_len - 2) { - sbuf_push( - log, indent, - "WARNING: Router Capability subTLV length too large compared to expected size\n"); + sbuf_push(log, indent, + "WARNING: Router Capability subTLV length too large compared to expected size\n"); stream_forward_getp(s, STREAM_READABLE(s)); return 0; } @@ -5489,8 +4925,7 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, switch (type) { case ISIS_SUBTLV_SID_LABEL_RANGE: /* Check that SRGB is correctly formated */ - if (length < SUBTLV_RANGE_LABEL_SIZE - || length > SUBTLV_RANGE_INDEX_SIZE) { + if (length < SUBTLV_RANGE_LABEL_SIZE || length > SUBTLV_RANGE_INDEX_SIZE) { stream_forward_getp(s, length); break; } @@ -5505,14 +4940,14 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, stream_getc(s); size = stream_getc(s); - if (size == ISIS_SUBTLV_SID_LABEL_SIZE - && length != SUBTLV_RANGE_LABEL_SIZE) { + if (size == ISIS_SUBTLV_SID_LABEL_SIZE && + length != SUBTLV_RANGE_LABEL_SIZE) { stream_forward_getp(s, length - 6); break; } - if (size == ISIS_SUBTLV_SID_INDEX_SIZE - && length != SUBTLV_RANGE_INDEX_SIZE) { + if (size == ISIS_SUBTLV_SID_INDEX_SIZE && + length != SUBTLV_RANGE_INDEX_SIZE) { stream_forward_getp(s, length - 6); break; } @@ -5527,10 +4962,10 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, } /* SRGB sanity checks. */ - if (rcap->srgb.range_size == 0 - || (rcap->srgb.lower_bound <= MPLS_LABEL_RESERVED_MAX) - || ((rcap->srgb.lower_bound + rcap->srgb.range_size - 1) - > MPLS_LABEL_UNRESERVED_MAX)) { + if (rcap->srgb.range_size == 0 || + (rcap->srgb.lower_bound <= MPLS_LABEL_RESERVED_MAX) || + ((rcap->srgb.lower_bound + rcap->srgb.range_size - 1) > + MPLS_LABEL_UNRESERVED_MAX)) { sbuf_push(log, indent, "Invalid label range. Reset SRGB\n"); rcap->srgb.lower_bound = 0; rcap->srgb.range_size = 0; @@ -5557,8 +4992,7 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, break; case ISIS_SUBTLV_SRLB: /* Check that SRLB is correctly formated */ - if (length < SUBTLV_RANGE_LABEL_SIZE - || length > SUBTLV_RANGE_INDEX_SIZE) { + if (length < SUBTLV_RANGE_LABEL_SIZE || length > SUBTLV_RANGE_INDEX_SIZE) { stream_forward_getp(s, length); break; } @@ -5574,14 +5008,14 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, stream_getc(s); size = stream_getc(s); - if (size == ISIS_SUBTLV_SID_LABEL_SIZE - && length != SUBTLV_RANGE_LABEL_SIZE) { + if (size == ISIS_SUBTLV_SID_LABEL_SIZE && + length != SUBTLV_RANGE_LABEL_SIZE) { stream_forward_getp(s, length - 6); break; } - if (size == ISIS_SUBTLV_SID_INDEX_SIZE - && length != SUBTLV_RANGE_INDEX_SIZE) { + if (size == ISIS_SUBTLV_SID_INDEX_SIZE && + length != SUBTLV_RANGE_INDEX_SIZE) { stream_forward_getp(s, length - 6); break; } @@ -5596,10 +5030,10 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, } /* SRLB sanity checks. */ - if (rcap->srlb.range_size == 0 - || (rcap->srlb.lower_bound <= MPLS_LABEL_RESERVED_MAX) - || ((rcap->srlb.lower_bound + rcap->srlb.range_size - 1) - > MPLS_LABEL_UNRESERVED_MAX)) { + if (rcap->srlb.range_size == 0 || + (rcap->srlb.lower_bound <= MPLS_LABEL_RESERVED_MAX) || + ((rcap->srlb.lower_bound + rcap->srlb.range_size - 1) > + MPLS_LABEL_UNRESERVED_MAX)) { sbuf_push(log, indent, "Invalid label range. Reset SRLB\n"); rcap->srlb.lower_bound = 0; rcap->srlb.range_size = 0; @@ -5611,14 +5045,11 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, break; case ISIS_SUBTLV_NODE_MSD: - sbuf_push(log, indent, - "Unpacking Node MSD sub-TLV...\n"); + sbuf_push(log, indent, "Unpacking Node MSD sub-TLV...\n"); /* Check that MSD is correctly formated */ if (length % 2) { - sbuf_push( - log, indent, - "WARNING: Unexpected MSD sub-TLV length\n"); + sbuf_push(log, indent, "WARNING: Unexpected MSD sub-TLV length\n"); stream_forward_getp(s, length); break; } @@ -5641,41 +5072,35 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, case ISIS_SUBTLV_SRV6_MAX_SL_MSD: /* SRv6 Maximum Segments Left MSD Type * as per RFC 9352 section #4.1 */ - rcap->srv6_msd.max_seg_left_msd = - stream_getc(s); + rcap->srv6_msd.max_seg_left_msd = stream_getc(s); break; case ISIS_SUBTLV_SRV6_MAX_END_POP_MSD: /* SRv6 Maximum End Pop MSD Type as per * RFC 9352 section #4.2 */ - rcap->srv6_msd.max_end_pop_msd = - stream_getc(s); + rcap->srv6_msd.max_end_pop_msd = stream_getc(s); break; case ISIS_SUBTLV_SRV6_MAX_H_ENCAPS_MSD: /* SRv6 Maximum H.Encaps MSD Type as per * RFC 9352 section #4.3 */ - rcap->srv6_msd.max_h_encaps_msd = - stream_getc(s); + rcap->srv6_msd.max_h_encaps_msd = stream_getc(s); break; case ISIS_SUBTLV_SRV6_MAX_END_D_MSD: /* SRv6 Maximum End D MSD Type as per * RFC 9352 section #4.4 */ - rcap->srv6_msd.max_end_d_msd = - stream_getc(s); + rcap->srv6_msd.max_end_d_msd = stream_getc(s); break; default: /* Unknown MSD, let's skip it */ - sbuf_push( - log, indent, - "WARNING: Skipping unknown MSD Type %hhu (1 byte)\n", - msd_type); + sbuf_push(log, indent, + "WARNING: Skipping unknown MSD Type %hhu (1 byte)\n", + msd_type); stream_forward_getp(s, 1); } } break; #ifndef FABRICD case ISIS_SUBTLV_FAD: - fad = XCALLOC(MTYPE_ISIS_TLV, - sizeof(struct isis_router_cap_fad)); + fad = XCALLOC(MTYPE_ISIS_TLV, sizeof(struct isis_router_cap_fad)); fad->fad.algorithm = stream_getc(s); fad->fad.metric_type = stream_getc(s); fad->fad.calc_type = stream_getc(s); @@ -5734,10 +5159,9 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, stream_forward_getp(s, subsubtlv_len); break; default: - sbuf_push( - log, indent, - "Received an unsupported Flex-Algo sub-TLV type %u\n", - subsubtlv_type); + sbuf_push(log, indent, + "Received an unsupported Flex-Algo sub-TLV type %u\n", + subsubtlv_type); fad->fad.unsupported_subtlv = true; stream_forward_getp(s, subsubtlv_len); break; @@ -5747,25 +5171,21 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, break; #endif /* ifndef FABRICD */ case ISIS_SUBTLV_SRV6_CAPABILITIES: - sbuf_push(log, indent, - "Unpacking SRv6 Capabilities sub-TLV...\n"); + sbuf_push(log, indent, "Unpacking SRv6 Capabilities sub-TLV...\n"); /* Check that SRv6 capabilities sub-TLV is correctly * formated */ if (length < ISIS_SUBTLV_SRV6_CAPABILITIES_SIZE) { - sbuf_push( - log, indent, - "WARNING: Unexpected SRv6 Capabilities sub-TLV size (expected %d or more bytes, got %hhu)\n", - ISIS_SUBTLV_SRV6_CAPABILITIES_SIZE, - length); + sbuf_push(log, indent, + "WARNING: Unexpected SRv6 Capabilities sub-TLV size (expected %d or more bytes, got %hhu)\n", + ISIS_SUBTLV_SRV6_CAPABILITIES_SIZE, length); stream_forward_getp(s, length); break; } /* Only one SRv6 capabilities is supported. Skip * subsequent one */ if (rcap->srv6_cap.is_srv6_capable) { - sbuf_push( - log, indent, - "WARNING: SRv6 Capabilities sub-TLV present multiple times, ignoring.\n"); + sbuf_push(log, indent, + "WARNING: SRv6 Capabilities sub-TLV present multiple times, ignoring.\n"); stream_forward_getp(s, length); break; } @@ -5779,12 +5199,9 @@ static int unpack_tlv_router_cap(enum isis_tlv_context context, * by IS-IS. */ if (length > ISIS_SUBTLV_SRV6_CAPABILITIES_SIZE) - sbuf_push( - log, indent, - "Skipping unknown sub-TLV (%hhu bytes)\n", - length); - stream_forward_getp( - s, length - ISIS_SUBTLV_SRV6_CAPABILITIES_SIZE); + sbuf_push(log, indent, "Skipping unknown sub-TLV (%hhu bytes)\n", + length); + stream_forward_getp(s, length - ISIS_SUBTLV_SRV6_CAPABILITIES_SIZE); break; default: @@ -5808,9 +5225,8 @@ static struct isis_item *copy_item_auth(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_auth(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_item_auth(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { struct isis_auth *auth = (struct isis_auth *)i; char obuf[768]; @@ -5828,10 +5244,8 @@ static void format_item_auth(uint16_t mtid, struct isis_item *i, sbuf_push(buf, indent, " Password: %s\n", obuf); break; case ISIS_PASSWD_TYPE_HMAC_MD5: - for (unsigned int j = 0; j < 16; j++) { - snprintf(obuf + 2 * j, sizeof(obuf) - 2 * j, "%02hhx", - auth->value[j]); - } + for (unsigned int j = 0; j < 16; j++) + snprintf(obuf + 2 * j, sizeof(obuf) - 2 * j, "%02hhx", auth->value[j]); if (json) json_object_string_add(json, "authHmacMd5", obuf); else @@ -5841,8 +5255,7 @@ static void format_item_auth(uint16_t mtid, struct isis_item *i, if (json) json_object_int_add(json, "authUnknown", auth->type); else - sbuf_push(buf, indent, " Unknown (%hhu)\n", - auth->type); + sbuf_push(buf, indent, " Unknown (%hhu)\n", auth->type); break; } } @@ -5852,8 +5265,7 @@ static void free_item_auth(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, i); } -static int pack_item_auth(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_auth(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_auth *auth = (struct isis_auth *)i; @@ -5886,17 +5298,15 @@ static int pack_item_auth(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_auth(uint16_t mtid, uint8_t len, struct stream *s, - struct sbuf *log, void *dest, int indent) +static int unpack_item_auth(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, + void *dest, int indent) { struct isis_tlvs *tlvs = dest; sbuf_push(log, indent, "Unpack Auth TLV...\n"); if (len < 1) { - sbuf_push( - log, indent, - "Not enough data left.(Expected 1 bytes of auth type, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left.(Expected 1 bytes of auth type, got %hhu)\n", len); return 1; } @@ -5906,10 +5316,9 @@ static int unpack_item_auth(uint16_t mtid, uint8_t len, struct stream *s, rv->length = len - 1; if (rv->type == ISIS_PASSWD_TYPE_HMAC_MD5 && rv->length != 16) { - sbuf_push( - log, indent, - "Unexpected auth length for HMAC-MD5 (expected 16, got %hhu)\n", - rv->length); + sbuf_push(log, indent, + "Unexpected auth length for HMAC-MD5 (expected 16, got %hhu)\n", + rv->length); XFREE(MTYPE_ISIS_TLV, rv); return 1; } @@ -5923,8 +5332,7 @@ static int unpack_item_auth(uint16_t mtid, uint8_t len, struct stream *s, /* Functions related to TLV 13 Purge Originator */ -static struct isis_purge_originator *copy_tlv_purge_originator( - struct isis_purge_originator *poi) +static struct isis_purge_originator *copy_tlv_purge_originator(struct isis_purge_originator *poi) { if (!poi) return NULL; @@ -5939,8 +5347,7 @@ static struct isis_purge_originator *copy_tlv_purge_originator( return rv; } -static void format_tlv_purge_originator(struct isis_purge_originator *poi, - struct sbuf *buf, +static void format_tlv_purge_originator(struct isis_purge_originator *poi, struct sbuf *buf, struct json_object *json, int indent) { char sen_id[ISO_SYSID_STRLEN]; @@ -5975,8 +5382,7 @@ static void free_tlv_purge_originator(struct isis_purge_originator *poi) XFREE(MTYPE_ISIS_TLV, poi); } -static int pack_tlv_purge_originator(struct isis_purge_originator *poi, - struct stream *s) +static int pack_tlv_purge_originator(struct isis_purge_originator *poi, struct stream *s) { if (!poi) return 0; @@ -5998,9 +5404,8 @@ static int pack_tlv_purge_originator(struct isis_purge_originator *poi, return 0; } -static int unpack_tlv_purge_originator(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, +static int unpack_tlv_purge_originator(enum isis_tlv_context context, uint8_t tlv_type, + uint8_t tlv_len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; @@ -6008,7 +5413,8 @@ static int unpack_tlv_purge_originator(enum isis_tlv_context context, sbuf_push(log, indent, "Unpacking Purge Originator Identification TLV...\n"); if (tlv_len < 7) { - sbuf_push(log, indent, "Not enough data left. (Expected at least 7 bytes, got %hhu)\n", tlv_len); + sbuf_push(log, indent, + "Not enough data left. (Expected at least 7 bytes, got %hhu)\n", tlv_len); return 1; } @@ -6019,7 +5425,8 @@ static int unpack_tlv_purge_originator(enum isis_tlv_context context, } else if (number_of_ids == 2) { poi.sender_set = true; } else { - sbuf_push(log, indent, "Got invalid value for number of system IDs: %hhu)\n", number_of_ids); + sbuf_push(log, indent, "Got invalid value for number of system IDs: %hhu)\n", + number_of_ids); return 1; } @@ -6052,8 +5459,7 @@ static void init_item_list(struct isis_item_list *items) items->count = 0; } -static struct isis_item *copy_item(enum isis_tlv_context context, - enum isis_tlv_type type, +static struct isis_item *copy_item(enum isis_tlv_context context, enum isis_tlv_type type, struct isis_item *item) { const struct tlv_ops *ops = tlv_table[context][type]; @@ -6077,9 +5483,8 @@ static void copy_items(enum isis_tlv_context context, enum isis_tlv_type type, } } -static void format_item(uint16_t mtid, enum isis_tlv_context context, - enum isis_tlv_type type, struct isis_item *i, - struct sbuf *buf, struct json_object *json, int indent) +static void format_item(uint16_t mtid, enum isis_tlv_context context, enum isis_tlv_type type, + struct isis_item *i, struct sbuf *buf, struct json_object *json, int indent) { const struct tlv_ops *ops = tlv_table[context][type]; @@ -6091,9 +5496,8 @@ static void format_item(uint16_t mtid, enum isis_tlv_context context, assert(!"Unknown item tlv type!"); } -static void format_items_(uint16_t mtid, enum isis_tlv_context context, - enum isis_tlv_type type, struct isis_item_list *items, - struct sbuf *buf, struct json_object *json, +static void format_items_(uint16_t mtid, enum isis_tlv_context context, enum isis_tlv_type type, + struct isis_item_list *items, struct sbuf *buf, struct json_object *json, int indent) { struct isis_item *i; @@ -6102,8 +5506,8 @@ static void format_items_(uint16_t mtid, enum isis_tlv_context context, format_item(mtid, context, type, i, buf, json, indent); } -static void free_item(enum isis_tlv_context tlv_context, - enum isis_tlv_type tlv_type, struct isis_item *item) +static void free_item(enum isis_tlv_context tlv_context, enum isis_tlv_type tlv_type, + struct isis_item *item) { const struct tlv_ops *ops = tlv_table[tlv_context][tlv_type]; @@ -6126,9 +5530,8 @@ static void free_items(enum isis_tlv_context context, enum isis_tlv_type type, } } -static int pack_item(enum isis_tlv_context context, enum isis_tlv_type type, - struct isis_item *i, struct stream *s, size_t *min_len, - struct isis_tlvs **fragment_tlvs, +static int pack_item(enum isis_tlv_context context, enum isis_tlv_type type, struct isis_item *i, + struct stream *s, size_t *min_len, struct isis_tlvs **fragment_tlvs, const struct pack_order_entry *pe, uint16_t mtid) { const struct tlv_ops *ops = tlv_table[context][type]; @@ -6141,8 +5544,7 @@ static int pack_item(enum isis_tlv_context context, enum isis_tlv_type type, return 1; } -static void add_item_to_fragment(struct isis_item *i, - const struct pack_order_entry *pe, +static void add_item_to_fragment(struct isis_item *i, const struct pack_order_entry *pe, struct isis_tlvs *fragment_tlvs, uint16_t mtid) { struct isis_item_list *l; @@ -6158,10 +5560,9 @@ static void add_item_to_fragment(struct isis_item *i, append_item(l, copy_item(pe->context, pe->type, i)); } -static int pack_items_(uint16_t mtid, enum isis_tlv_context context, - enum isis_tlv_type type, struct isis_item_list *items, - struct stream *s, struct isis_tlvs **fragment_tlvs, - const struct pack_order_entry *pe, +static int pack_items_(uint16_t mtid, enum isis_tlv_context context, enum isis_tlv_type type, + struct isis_item_list *items, struct stream *s, + struct isis_tlvs **fragment_tlvs, const struct pack_order_entry *pe, struct isis_tlvs *(*new_fragment)(struct list *l), struct list *new_fragment_arg) { @@ -6181,8 +5582,7 @@ static int pack_items_(uint16_t mtid, enum isis_tlv_context context, len_pos = stream_get_endp(s); stream_putc(s, 0); /* Put 0 as length for now */ - if (context == ISIS_CONTEXT_LSP && IS_COMPAT_MT_TLV(type) - && mtid != ISIS_MT_IPV4_UNICAST) { + if (context == ISIS_CONTEXT_LSP && IS_COMPAT_MT_TLV(type) && mtid != ISIS_MT_IPV4_UNICAST) { if (STREAM_WRITEABLE(s) < 2) goto too_long; stream_putw(s, mtid); @@ -6204,8 +5604,7 @@ static int pack_items_(uint16_t mtid, enum isis_tlv_context context, last_len = len = 0; for (item = item ? item : items->head; item; item = item->next) { - rv = pack_item(context, type, item, s, &min_len, fragment_tlvs, - pe, mtid); + rv = pack_item(context, type, item, s, &min_len, fragment_tlvs, pe, mtid); if (rv) goto too_long; @@ -6218,9 +5617,8 @@ static int pack_items_(uint16_t mtid, enum isis_tlv_context context, } /* Multiple prefix-sids don't go into one TLV, so always break */ - if (type == ISIS_SUBTLV_PREFIX_SID - && (context == ISIS_CONTEXT_SUBTLV_IP_REACH - || context == ISIS_CONTEXT_SUBTLV_IPV6_REACH)) { + if (type == ISIS_SUBTLV_PREFIX_SID && (context == ISIS_CONTEXT_SUBTLV_IP_REACH || + context == ISIS_CONTEXT_SUBTLV_IPV6_REACH)) { item = item->next; break; } @@ -6301,9 +5699,8 @@ static struct isis_item *last_item(struct isis_item_list *list) return container_of(list->tail, struct isis_item, next); } -static int unpack_item(uint16_t mtid, enum isis_tlv_context context, - uint8_t tlv_type, uint8_t len, struct stream *s, - struct sbuf *log, void *dest, int indent) +static int unpack_item(uint16_t mtid, enum isis_tlv_context context, uint8_t tlv_type, uint8_t len, + struct stream *s, struct sbuf *log, void *dest, int indent) { const struct tlv_ops *ops = tlv_table[context][tlv_type]; @@ -6315,10 +5712,8 @@ static int unpack_item(uint16_t mtid, enum isis_tlv_context context, return 1; } -static int unpack_tlv_with_items(enum isis_tlv_context context, - uint8_t tlv_type, uint8_t tlv_len, - struct stream *s, struct sbuf *log, void *dest, - int indent) +static int unpack_tlv_with_items(enum isis_tlv_context context, uint8_t tlv_type, uint8_t tlv_len, + struct stream *s, struct sbuf *log, void *dest, int indent) { size_t tlv_start; size_t tlv_pos; @@ -6331,8 +5726,7 @@ static int unpack_tlv_with_items(enum isis_tlv_context context, if (context == ISIS_CONTEXT_LSP && (IS_COMPAT_MT_TLV(tlv_type) || tlv_type == ISIS_TLV_SRV6_LOCATOR)) { if (tlv_len < 2) { - sbuf_push(log, indent, - "TLV is too short to contain MTID\n"); + sbuf_push(log, indent, "TLV is too short to contain MTID\n"); return 1; } mtid = stream_getw(s) & ISIS_MT_MASK; @@ -6344,36 +5738,31 @@ static int unpack_tlv_with_items(enum isis_tlv_context context, mtid = ISIS_MT_IPV4_UNICAST; } - if (context == ISIS_CONTEXT_LSP - && tlv_type == ISIS_TLV_OLDSTYLE_REACH) { + if (context == ISIS_CONTEXT_LSP && tlv_type == ISIS_TLV_OLDSTYLE_REACH) { if (tlv_len - tlv_pos < 1) { - sbuf_push(log, indent, - "TLV is too short for old style reach\n"); + sbuf_push(log, indent, "TLV is too short for old style reach\n"); return 1; } stream_forward_getp(s, 1); tlv_pos += 1; } - if (context == ISIS_CONTEXT_LSP - && tlv_type == ISIS_TLV_OLDSTYLE_IP_REACH) { + if (context == ISIS_CONTEXT_LSP && tlv_type == ISIS_TLV_OLDSTYLE_IP_REACH) { struct isis_tlvs *tlvs = dest; dest = &tlvs->oldstyle_ip_reach; - } else if (context == ISIS_CONTEXT_LSP - && tlv_type == ISIS_TLV_OLDSTYLE_IP_REACH_EXT) { + } else if (context == ISIS_CONTEXT_LSP && tlv_type == ISIS_TLV_OLDSTYLE_IP_REACH_EXT) { struct isis_tlvs *tlvs = dest; dest = &tlvs->oldstyle_ip_reach_ext; } - if (context == ISIS_CONTEXT_LSP - && tlv_type == ISIS_TLV_MT_ROUTER_INFO) { + if (context == ISIS_CONTEXT_LSP && tlv_type == ISIS_TLV_MT_ROUTER_INFO) { struct isis_tlvs *tlvs = dest; tlvs->mt_router_info_empty = (tlv_pos >= (size_t)tlv_len); } while (tlv_pos < (size_t)tlv_len) { - rv = unpack_item(mtid, context, tlv_type, tlv_len - tlv_pos, s, - log, dest, indent + 2); + rv = unpack_item(mtid, context, tlv_type, tlv_len - tlv_pos, s, log, dest, + indent + 2); if (rv) return rv; @@ -6385,8 +5774,7 @@ static int unpack_tlv_with_items(enum isis_tlv_context context, /* Functions to manipulate mt_item_lists */ -static int isis_mt_item_list_cmp(const struct isis_item_list *a, - const struct isis_item_list *b) +static int isis_mt_item_list_cmp(const struct isis_item_list *a, const struct isis_item_list *b) { if (a->mtid < b->mtid) return -1; @@ -6398,8 +5786,7 @@ static int isis_mt_item_list_cmp(const struct isis_item_list *a, RB_PROTOTYPE(isis_mt_item_list, isis_item_list, mt_tree, isis_mt_item_list_cmp); RB_GENERATE(isis_mt_item_list, isis_item_list, mt_tree, isis_mt_item_list_cmp); -struct isis_item_list *isis_get_mt_items(struct isis_mt_item_list *m, - uint16_t mtid) +struct isis_item_list *isis_get_mt_items(struct isis_mt_item_list *m, uint16_t mtid) { struct isis_item_list *rv; @@ -6414,16 +5801,15 @@ struct isis_item_list *isis_get_mt_items(struct isis_mt_item_list *m, return rv; } -struct isis_item_list *isis_lookup_mt_items(struct isis_mt_item_list *m, - uint16_t mtid) +struct isis_item_list *isis_lookup_mt_items(struct isis_mt_item_list *m, uint16_t mtid) { - struct isis_item_list key = {.mtid = mtid}; + struct isis_item_list key = { .mtid = mtid }; return RB_FIND(isis_mt_item_list, m, &key); } -static void free_mt_items(enum isis_tlv_context context, - enum isis_tlv_type type, struct isis_mt_item_list *m) +static void free_mt_items(enum isis_tlv_context context, enum isis_tlv_type type, + struct isis_mt_item_list *m) { struct isis_item_list *n, *nnext; @@ -6434,8 +5820,7 @@ static void free_mt_items(enum isis_tlv_context context, } } -static void format_mt_items(enum isis_tlv_context context, - enum isis_tlv_type type, +static void format_mt_items(enum isis_tlv_context context, enum isis_tlv_type type, struct isis_mt_item_list *m, struct sbuf *buf, struct json_object *json, int indent) { @@ -6448,8 +5833,7 @@ static void format_mt_items(enum isis_tlv_context context, static int pack_mt_items(enum isis_tlv_context context, enum isis_tlv_type type, struct isis_mt_item_list *m, struct stream *s, - struct isis_tlvs **fragment_tlvs, - const struct pack_order_entry *pe, + struct isis_tlvs **fragment_tlvs, const struct pack_order_entry *pe, struct isis_tlvs *(*new_fragment)(struct list *l), struct list *new_fragment_arg) { @@ -6458,8 +5842,8 @@ static int pack_mt_items(enum isis_tlv_context context, enum isis_tlv_type type, RB_FOREACH (n, isis_mt_item_list, m) { int rv; - rv = pack_items_(n->mtid, context, type, n, s, fragment_tlvs, - pe, new_fragment, new_fragment_arg); + rv = pack_items_(n->mtid, context, type, n, s, fragment_tlvs, pe, new_fragment, + new_fragment_arg); if (rv) return rv; } @@ -6467,10 +5851,8 @@ static int pack_mt_items(enum isis_tlv_context context, enum isis_tlv_type type, return 0; } -static void copy_mt_items(enum isis_tlv_context context, - enum isis_tlv_type type, - struct isis_mt_item_list *src, - struct isis_mt_item_list *dest) +static void copy_mt_items(enum isis_tlv_context context, enum isis_tlv_type type, + struct isis_mt_item_list *src, struct isis_mt_item_list *dest) { struct isis_item_list *n; @@ -6496,9 +5878,8 @@ static struct isis_item *copy_item_srv6_locator(struct isis_item *i) return (struct isis_item *)rv; } -static void format_item_srv6_locator(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, - int indent) +static void format_item_srv6_locator(uint16_t mtid, struct isis_item *i, struct sbuf *buf, + struct json_object *json, int indent) { struct isis_srv6_locator_tlv *loc = (struct isis_srv6_locator_tlv *)i; @@ -6508,27 +5889,22 @@ static void format_item_srv6_locator(uint16_t mtid, struct isis_item *i, 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_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)); + !!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); + 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, - CHECK_FLAG(loc->flags, ISIS_TLV_SRV6_LOCATOR_FLAG_D) - ? " D-flag" - : ""); + sbuf_push(buf, indent, "SRv6 Locator: %pFX (Metric: %u)%s", &loc->prefix, + loc->metric, + CHECK_FLAG(loc->flags, ISIS_TLV_SRV6_LOCATOR_FLAG_D) ? " D-flag" : ""); sbuf_push(buf, 0, " %s\n", isis_mtid2str(mtid)); if (loc->subtlvs) { @@ -6546,8 +5922,7 @@ static void free_item_srv6_locator(struct isis_item *i) XFREE(MTYPE_ISIS_TLV, item); } -static int pack_item_srv6_locator(struct isis_item *i, struct stream *s, - size_t *min_len) +static int pack_item_srv6_locator(struct isis_item *i, struct stream *s, size_t *min_len) { struct isis_srv6_locator_tlv *loc = (struct isis_srv6_locator_tlv *)i; @@ -6562,8 +5937,7 @@ static int pack_item_srv6_locator(struct isis_item *i, struct stream *s, /* Locator size */ stream_putc(s, loc->prefix.prefixlen); /* Locator prefix */ - stream_put(s, &loc->prefix.prefix.s6_addr, - PSIZE(loc->prefix.prefixlen)); + stream_put(s, &loc->prefix.prefix.s6_addr, PSIZE(loc->prefix.prefixlen)); if (loc->subtlvs) { /* Pack Sub-TLVs */ @@ -6583,8 +5957,7 @@ static int pack_item_srv6_locator(struct isis_item *i, struct stream *s, return 0; } -static int unpack_item_srv6_locator(uint16_t mtid, uint8_t len, - struct stream *s, struct sbuf *log, +static int unpack_item_srv6_locator(uint16_t mtid, uint8_t len, struct stream *s, struct sbuf *log, void *dest, int indent) { struct isis_tlvs *tlvs = dest; @@ -6598,10 +5971,8 @@ static int unpack_item_srv6_locator(uint16_t mtid, uint8_t len, sbuf_push(log, indent, "Unpacking SRv6 Locator...\n"); consume = 7; if (len < consume) { - sbuf_push( - log, indent, - "Not enough data left. (expected 7 or more bytes, got %hhu)\n", - len); + sbuf_push(log, indent, + "Not enough data left. (expected 7 or more bytes, got %hhu)\n", len); goto out; } @@ -6621,10 +5992,9 @@ static int unpack_item_srv6_locator(uint16_t mtid, uint8_t len, consume += PSIZE(rv->prefix.prefixlen); if (len < consume) { - sbuf_push( - log, indent, - "Expected %u bytes of prefix, but only %u bytes available.\n", - PSIZE(rv->prefix.prefixlen), len - 7); + sbuf_push(log, indent, + "Expected %u bytes of prefix, but only %u bytes available.\n", + PSIZE(rv->prefix.prefixlen), len - 7); goto out; } stream_get(&rv->prefix.prefix.s6_addr, s, PSIZE(rv->prefix.prefixlen)); @@ -6632,16 +6002,13 @@ static int unpack_item_srv6_locator(uint16_t mtid, uint8_t len, struct in6_addr orig_locator = rv->prefix.prefix; apply_mask_ipv6(&rv->prefix); if (memcmp(&orig_locator, &rv->prefix.prefix, sizeof(orig_locator))) - sbuf_push(log, indent + 2, - "WARNING: SRv6 Locator had hostbits set.\n"); - format_item_srv6_locator(mtid, (struct isis_item *)rv, log, NULL, - indent + 2); + sbuf_push(log, indent + 2, "WARNING: SRv6 Locator had hostbits set.\n"); + format_item_srv6_locator(mtid, (struct isis_item *)rv, log, NULL, indent + 2); consume += 1; if (len < consume) { - sbuf_push( - log, indent, - "Expected 1 byte of subtlv len, but no more data persent.\n"); + sbuf_push(log, indent, + "Expected 1 byte of subtlv len, but no more data persent.\n"); goto out; } subtlv_len = stream_getc(s); @@ -6649,21 +6016,17 @@ static int unpack_item_srv6_locator(uint16_t mtid, uint8_t len, if (subtlv_len) { consume += subtlv_len; if (len < consume) { - sbuf_push( - log, indent, - "Expected %hhu bytes of subtlvs, but only %u bytes available.\n", - subtlv_len, - len - 7 - PSIZE(rv->prefix.prefixlen)); + sbuf_push(log, indent, + "Expected %hhu bytes of subtlvs, but only %u bytes available.\n", + subtlv_len, len - 7 - PSIZE(rv->prefix.prefixlen)); goto out; } - rv->subtlvs = - isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_SRV6_LOCATOR); + rv->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_SRV6_LOCATOR); bool unpacked_known_tlvs = false; - if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_SRV6_LOCATOR, subtlv_len, s, - log, rv->subtlvs, indent + 4, - &unpacked_known_tlvs)) { + if (unpack_tlvs(ISIS_CONTEXT_SUBTLV_SRV6_LOCATOR, subtlv_len, s, log, rv->subtlvs, + indent + 4, &unpacked_known_tlvs)) { goto out; } if (!unpacked_known_tlvs) { @@ -6714,71 +6077,61 @@ struct isis_tlvs *isis_copy_tlvs(struct isis_tlvs *tlvs) { struct isis_tlvs *rv = XCALLOC(MTYPE_ISIS_TLV, sizeof(*rv)); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_AUTH, &tlvs->isis_auth, - &rv->isis_auth); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_AUTH, &tlvs->isis_auth, &rv->isis_auth); - rv->purge_originator = - copy_tlv_purge_originator(tlvs->purge_originator); + rv->purge_originator = copy_tlv_purge_originator(tlvs->purge_originator); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, - &tlvs->area_addresses, &rv->area_addresses); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, &tlvs->area_addresses, + &rv->area_addresses); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, - &tlvs->mt_router_info, &rv->mt_router_info); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, &tlvs->mt_router_info, + &rv->mt_router_info); rv->mt_router_info_empty = tlvs->mt_router_info_empty; - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_REACH, - &tlvs->oldstyle_reach, &rv->oldstyle_reach); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_REACH, &tlvs->oldstyle_reach, + &rv->oldstyle_reach); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_LAN_NEIGHBORS, - &tlvs->lan_neighbor, &rv->lan_neighbor); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_LAN_NEIGHBORS, &tlvs->lan_neighbor, + &rv->lan_neighbor); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_LSP_ENTRY, &tlvs->lsp_entries, - &rv->lsp_entries); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_LSP_ENTRY, &tlvs->lsp_entries, &rv->lsp_entries); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_REACH, - &tlvs->extended_reach, &rv->extended_reach); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_REACH, &tlvs->extended_reach, + &rv->extended_reach); - copy_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_REACH, &tlvs->mt_reach, - &rv->mt_reach); + copy_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_REACH, &tlvs->mt_reach, &rv->mt_reach); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH, - &tlvs->oldstyle_ip_reach, &rv->oldstyle_ip_reach); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH, &tlvs->oldstyle_ip_reach, + &rv->oldstyle_ip_reach); - copy_tlv_protocols_supported(&tlvs->protocols_supported, - &rv->protocols_supported); + copy_tlv_protocols_supported(&tlvs->protocols_supported, &rv->protocols_supported); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH_EXT, - &tlvs->oldstyle_ip_reach_ext, &rv->oldstyle_ip_reach_ext); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH_EXT, &tlvs->oldstyle_ip_reach_ext, + &rv->oldstyle_ip_reach_ext); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV4_ADDRESS, &tlvs->ipv4_address, - &rv->ipv4_address); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV4_ADDRESS, &tlvs->ipv4_address, &rv->ipv4_address); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_ADDRESS, &tlvs->ipv6_address, - &rv->ipv6_address); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_ADDRESS, &tlvs->ipv6_address, &rv->ipv6_address); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_GLOBAL_IPV6_ADDRESS, - &tlvs->global_ipv6_address, &rv->global_ipv6_address); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_GLOBAL_IPV6_ADDRESS, &tlvs->global_ipv6_address, + &rv->global_ipv6_address); rv->te_router_id = copy_tlv_te_router_id(tlvs->te_router_id); - rv->te_router_id_ipv6 = - copy_tlv_te_router_id_ipv6(tlvs->te_router_id_ipv6); + rv->te_router_id_ipv6 = copy_tlv_te_router_id_ipv6(tlvs->te_router_id_ipv6); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_IP_REACH, - &tlvs->extended_ip_reach, &rv->extended_ip_reach); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_IP_REACH, &tlvs->extended_ip_reach, + &rv->extended_ip_reach); - copy_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IP_REACH, - &tlvs->mt_ip_reach, &rv->mt_ip_reach); + copy_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IP_REACH, &tlvs->mt_ip_reach, &rv->mt_ip_reach); rv->hostname = copy_tlv_dynamic_hostname(tlvs->hostname); - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_REACH, &tlvs->ipv6_reach, - &rv->ipv6_reach); + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_REACH, &tlvs->ipv6_reach, &rv->ipv6_reach); - copy_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IPV6_REACH, - &tlvs->mt_ipv6_reach, &rv->mt_ipv6_reach); + copy_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IPV6_REACH, &tlvs->mt_ipv6_reach, + &rv->mt_ipv6_reach); rv->threeway_adj = copy_tlv_threeway_adj(tlvs->threeway_adj); @@ -6786,24 +6139,23 @@ struct isis_tlvs *isis_copy_tlvs(struct isis_tlvs *tlvs) rv->spine_leaf = copy_tlv_spine_leaf(tlvs->spine_leaf); - copy_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_SRV6_LOCATOR, - &tlvs->srv6_locator, &rv->srv6_locator); + copy_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_SRV6_LOCATOR, &tlvs->srv6_locator, + &rv->srv6_locator); return rv; } -static void format_tlvs(struct isis_tlvs *tlvs, struct sbuf *buf, struct json_object *json, int indent) +static void format_tlvs(struct isis_tlvs *tlvs, struct sbuf *buf, struct json_object *json, + int indent) { - format_tlv_protocols_supported(&tlvs->protocols_supported, buf, json, - indent); + format_tlv_protocols_supported(&tlvs->protocols_supported, buf, json, indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_AUTH, &tlvs->isis_auth, buf, - json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_AUTH, &tlvs->isis_auth, buf, json, indent); format_tlv_purge_originator(tlvs->purge_originator, buf, json, indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, - &tlvs->area_addresses, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, &tlvs->area_addresses, buf, json, + indent); if (tlvs->mt_router_info_empty) { if (json) @@ -6811,67 +6163,63 @@ static void format_tlvs(struct isis_tlvs *tlvs, struct sbuf *buf, struct json_ob else sbuf_push(buf, indent, "MT Router Info: None\n"); } else { - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, - &tlvs->mt_router_info, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, &tlvs->mt_router_info, buf, + json, indent); } - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_REACH, - &tlvs->oldstyle_reach, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_REACH, &tlvs->oldstyle_reach, buf, json, + indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_LAN_NEIGHBORS, - &tlvs->lan_neighbor, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_LAN_NEIGHBORS, &tlvs->lan_neighbor, buf, json, + indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_LSP_ENTRY, &tlvs->lsp_entries, - buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_LSP_ENTRY, &tlvs->lsp_entries, buf, json, indent); format_tlv_dynamic_hostname(tlvs->hostname, buf, json, indent); format_tlv_te_router_id(tlvs->te_router_id, buf, json, indent); - format_tlv_te_router_id_ipv6(tlvs->te_router_id_ipv6, buf, json, - indent); + format_tlv_te_router_id_ipv6(tlvs->te_router_id_ipv6, buf, json, indent); if (json) format_tlv_router_cap_json(tlvs->router_cap, json); else format_tlv_router_cap(tlvs->router_cap, buf, indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_REACH, - &tlvs->extended_reach, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_REACH, &tlvs->extended_reach, buf, json, + indent); - format_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_REACH, &tlvs->mt_reach, - buf, json, indent); + format_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_REACH, &tlvs->mt_reach, buf, json, indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH, - &tlvs->oldstyle_ip_reach, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH, &tlvs->oldstyle_ip_reach, buf, + json, indent); format_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH_EXT, &tlvs->oldstyle_ip_reach_ext, buf, json, indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV4_ADDRESS, - &tlvs->ipv4_address, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV4_ADDRESS, &tlvs->ipv4_address, buf, json, + indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_ADDRESS, - &tlvs->ipv6_address, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_ADDRESS, &tlvs->ipv6_address, buf, json, + indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_GLOBAL_IPV6_ADDRESS, - &tlvs->global_ipv6_address, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_GLOBAL_IPV6_ADDRESS, &tlvs->global_ipv6_address, + buf, json, indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_IP_REACH, - &tlvs->extended_ip_reach, buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_IP_REACH, &tlvs->extended_ip_reach, buf, + json, indent); - format_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IP_REACH, - &tlvs->mt_ip_reach, buf, json, indent); + format_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IP_REACH, &tlvs->mt_ip_reach, buf, json, + indent); - format_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_REACH, &tlvs->ipv6_reach, - buf, json, indent); + format_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_REACH, &tlvs->ipv6_reach, buf, json, indent); - format_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IPV6_REACH, - &tlvs->mt_ipv6_reach, buf, json, indent); + format_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IPV6_REACH, &tlvs->mt_ipv6_reach, buf, json, + indent); format_tlv_threeway_adj(tlvs->threeway_adj, buf, json, indent); format_tlv_spine_leaf(tlvs->spine_leaf, buf, json, indent); - format_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_SRV6_LOCATOR, - &tlvs->srv6_locator, buf, json, indent); + format_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_SRV6_LOCATOR, &tlvs->srv6_locator, buf, json, + indent); } const char *isis_format_tlvs(struct isis_tlvs *tlvs, struct json_object *json) @@ -6898,44 +6246,30 @@ void isis_free_tlvs(struct isis_tlvs *tlvs) free_items(ISIS_CONTEXT_LSP, ISIS_TLV_AUTH, &tlvs->isis_auth); free_tlv_purge_originator(tlvs->purge_originator); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, - &tlvs->area_addresses); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, - &tlvs->mt_router_info); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_REACH, - &tlvs->oldstyle_reach); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_LAN_NEIGHBORS, - &tlvs->lan_neighbor); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, &tlvs->area_addresses); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, &tlvs->mt_router_info); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_REACH, &tlvs->oldstyle_reach); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_LAN_NEIGHBORS, &tlvs->lan_neighbor); free_items(ISIS_CONTEXT_LSP, ISIS_TLV_LSP_ENTRY, &tlvs->lsp_entries); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_REACH, - &tlvs->extended_reach); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_REACH, &tlvs->extended_reach); free_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_REACH, &tlvs->mt_reach); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH, - &tlvs->oldstyle_ip_reach); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH, &tlvs->oldstyle_ip_reach); free_tlv_protocols_supported(&tlvs->protocols_supported); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH_EXT, - &tlvs->oldstyle_ip_reach_ext); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV4_ADDRESS, - &tlvs->ipv4_address); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_ADDRESS, - &tlvs->ipv6_address); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_GLOBAL_IPV6_ADDRESS, - &tlvs->global_ipv6_address); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_OLDSTYLE_IP_REACH_EXT, &tlvs->oldstyle_ip_reach_ext); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV4_ADDRESS, &tlvs->ipv4_address); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_ADDRESS, &tlvs->ipv6_address); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_GLOBAL_IPV6_ADDRESS, &tlvs->global_ipv6_address); free_tlv_te_router_id(tlvs->te_router_id); free_tlv_te_router_id_ipv6(tlvs->te_router_id_ipv6); - free_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_IP_REACH, - &tlvs->extended_ip_reach); - free_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IP_REACH, - &tlvs->mt_ip_reach); + free_items(ISIS_CONTEXT_LSP, ISIS_TLV_EXTENDED_IP_REACH, &tlvs->extended_ip_reach); + free_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IP_REACH, &tlvs->mt_ip_reach); free_tlv_dynamic_hostname(tlvs->hostname); free_items(ISIS_CONTEXT_LSP, ISIS_TLV_IPV6_REACH, &tlvs->ipv6_reach); - free_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IPV6_REACH, - &tlvs->mt_ipv6_reach); + free_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_IPV6_REACH, &tlvs->mt_ipv6_reach); free_tlv_threeway_adj(tlvs->threeway_adj); free_tlv_router_cap(tlvs->router_cap); free_tlv_spine_leaf(tlvs->spine_leaf); - free_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_SRV6_LOCATOR, - &tlvs->srv6_locator); + free_mt_items(ISIS_CONTEXT_LSP, ISIS_TLV_SRV6_LOCATOR, &tlvs->srv6_locator); XFREE(MTYPE_ISIS_TLV, tlvs); } @@ -6961,27 +6295,22 @@ static void add_padding(struct stream *s) } #define LSP_REM_LIFETIME_OFF 10 -#define LSP_CHECKSUM_OFF 24 -static void safe_auth_md5(struct stream *s, uint16_t *checksum, - uint16_t *rem_lifetime) +#define LSP_CHECKSUM_OFF 24 +static void safe_auth_md5(struct stream *s, uint16_t *checksum, uint16_t *rem_lifetime) { - memcpy(rem_lifetime, STREAM_DATA(s) + LSP_REM_LIFETIME_OFF, - sizeof(*rem_lifetime)); + memcpy(rem_lifetime, STREAM_DATA(s) + LSP_REM_LIFETIME_OFF, sizeof(*rem_lifetime)); memset(STREAM_DATA(s) + LSP_REM_LIFETIME_OFF, 0, sizeof(*rem_lifetime)); memcpy(checksum, STREAM_DATA(s) + LSP_CHECKSUM_OFF, sizeof(*checksum)); memset(STREAM_DATA(s) + LSP_CHECKSUM_OFF, 0, sizeof(*checksum)); } -static void restore_auth_md5(struct stream *s, uint16_t checksum, - uint16_t rem_lifetime) +static void restore_auth_md5(struct stream *s, uint16_t checksum, uint16_t rem_lifetime) { - memcpy(STREAM_DATA(s) + LSP_REM_LIFETIME_OFF, &rem_lifetime, - sizeof(rem_lifetime)); + memcpy(STREAM_DATA(s) + LSP_REM_LIFETIME_OFF, &rem_lifetime, sizeof(rem_lifetime)); memcpy(STREAM_DATA(s) + LSP_CHECKSUM_OFF, &checksum, sizeof(checksum)); } -static void update_auth_hmac_md5(struct isis_auth *auth, struct stream *s, - bool is_lsp) +static void update_auth_hmac_md5(struct isis_auth *auth, struct stream *s, bool is_lsp) { uint8_t digest[16]; uint16_t checksum = 0, rem_lifetime = 0; @@ -6991,14 +6320,12 @@ static void update_auth_hmac_md5(struct isis_auth *auth, struct stream *s, memset(STREAM_DATA(s) + auth->offset, 0, 16); #ifdef CRYPTO_OPENSSL - uint8_t *result = (uint8_t *)HMAC(EVP_md5(), auth->passwd, - auth->plength, STREAM_DATA(s), + uint8_t *result = (uint8_t *)HMAC(EVP_md5(), auth->passwd, auth->plength, STREAM_DATA(s), stream_get_endp(s), NULL, NULL); memcpy(digest, result, 16); #elif CRYPTO_INTERNAL - hmac_md5(STREAM_DATA(s), stream_get_endp(s), auth->passwd, - auth->plength, digest); + hmac_md5(STREAM_DATA(s), stream_get_endp(s), auth->passwd, auth->plength, digest); #endif memcpy(auth->value, digest, 16); memcpy(STREAM_DATA(s) + auth->offset, digest, 16); @@ -7017,9 +6344,8 @@ static void update_auth(struct isis_tlvs *tlvs, struct stream *s, bool is_lsp) } } -static int handle_pack_entry(const struct pack_order_entry *pe, - struct isis_tlvs *tlvs, struct stream *stream, - struct isis_tlvs **fragment_tlvs, +static int handle_pack_entry(const struct pack_order_entry *pe, struct isis_tlvs *tlvs, + struct stream *stream, struct isis_tlvs **fragment_tlvs, struct isis_tlvs *(*new_fragment)(struct list *l), struct list *new_fragment_arg) { @@ -7027,24 +6353,20 @@ static int handle_pack_entry(const struct pack_order_entry *pe, if (pe->how_to_pack == ISIS_ITEMS) { struct isis_item_list *l; - l = (struct isis_item_list *)(((char *)tlvs) - + pe->what_to_pack); - rv = pack_items(pe->context, pe->type, l, stream, fragment_tlvs, - pe, new_fragment, new_fragment_arg); + l = (struct isis_item_list *)(((char *)tlvs) + pe->what_to_pack); + rv = pack_items(pe->context, pe->type, l, stream, fragment_tlvs, pe, new_fragment, + new_fragment_arg); } else { struct isis_mt_item_list *l; - l = (struct isis_mt_item_list *)(((char *)tlvs) - + pe->what_to_pack); - rv = pack_mt_items(pe->context, pe->type, l, stream, - fragment_tlvs, pe, new_fragment, - new_fragment_arg); + l = (struct isis_mt_item_list *)(((char *)tlvs) + pe->what_to_pack); + rv = pack_mt_items(pe->context, pe->type, l, stream, fragment_tlvs, pe, + new_fragment, new_fragment_arg); } return rv; } -static int pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, - struct isis_tlvs *fragment_tlvs, +static int pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, struct isis_tlvs *fragment_tlvs, struct isis_tlvs *(*new_fragment)(struct list *l), struct list *new_fragment_arg) { @@ -7053,9 +6375,8 @@ static int pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, /* When fragmenting, don't add auth as it's already accounted for in the * size we are given. */ if (!fragment_tlvs) { - rv = pack_items(ISIS_CONTEXT_LSP, ISIS_TLV_AUTH, - &tlvs->isis_auth, stream, NULL, NULL, NULL, - NULL); + rv = pack_items(ISIS_CONTEXT_LSP, ISIS_TLV_AUTH, &tlvs->isis_auth, stream, NULL, + NULL, NULL, NULL); if (rv) return rv; } @@ -7064,26 +6385,23 @@ static int pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, if (rv) return rv; if (fragment_tlvs) { - fragment_tlvs->purge_originator = - copy_tlv_purge_originator(tlvs->purge_originator); + fragment_tlvs->purge_originator = copy_tlv_purge_originator(tlvs->purge_originator); } rv = pack_tlv_protocols_supported(&tlvs->protocols_supported, stream); if (rv) return rv; if (fragment_tlvs) { - copy_tlv_protocols_supported( - &tlvs->protocols_supported, - &fragment_tlvs->protocols_supported); + copy_tlv_protocols_supported(&tlvs->protocols_supported, + &fragment_tlvs->protocols_supported); } - rv = pack_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, - &tlvs->area_addresses, stream, NULL, NULL, NULL, NULL); + rv = pack_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, &tlvs->area_addresses, stream, + NULL, NULL, NULL, NULL); if (rv) return rv; if (fragment_tlvs) { - copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, - &tlvs->area_addresses, + copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_AREA_ADDRESSES, &tlvs->area_addresses, &fragment_tlvs->area_addresses); } @@ -7096,15 +6414,13 @@ static int pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, if (fragment_tlvs) fragment_tlvs->mt_router_info_empty = true; } else { - rv = pack_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, - &tlvs->mt_router_info, stream, NULL, NULL, NULL, - NULL); + rv = pack_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, &tlvs->mt_router_info, + stream, NULL, NULL, NULL, NULL); if (rv) return rv; if (fragment_tlvs) { copy_items(ISIS_CONTEXT_LSP, ISIS_TLV_MT_ROUTER_INFO, - &tlvs->mt_router_info, - &fragment_tlvs->mt_router_info); + &tlvs->mt_router_info, &fragment_tlvs->mt_router_info); } } @@ -7112,54 +6428,43 @@ static int pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, if (rv) return rv; if (fragment_tlvs) - fragment_tlvs->hostname = - copy_tlv_dynamic_hostname(tlvs->hostname); + fragment_tlvs->hostname = copy_tlv_dynamic_hostname(tlvs->hostname); rv = pack_tlv_router_cap(tlvs->router_cap, stream); if (rv) return rv; - if (fragment_tlvs) { - fragment_tlvs->router_cap = - copy_tlv_router_cap(tlvs->router_cap); - } + if (fragment_tlvs) + fragment_tlvs->router_cap = copy_tlv_router_cap(tlvs->router_cap); rv = pack_tlv_te_router_id(tlvs->te_router_id, stream); if (rv) return rv; - if (fragment_tlvs) { - fragment_tlvs->te_router_id = - copy_tlv_te_router_id(tlvs->te_router_id); - } + if (fragment_tlvs) + fragment_tlvs->te_router_id = copy_tlv_te_router_id(tlvs->te_router_id); rv = pack_tlv_te_router_id_ipv6(tlvs->te_router_id_ipv6, stream); if (rv) return rv; - if (fragment_tlvs) { + if (fragment_tlvs) fragment_tlvs->te_router_id_ipv6 = copy_tlv_te_router_id_ipv6(tlvs->te_router_id_ipv6); - } rv = pack_tlv_threeway_adj(tlvs->threeway_adj, stream); if (rv) return rv; - if (fragment_tlvs) { - fragment_tlvs->threeway_adj = - copy_tlv_threeway_adj(tlvs->threeway_adj); - } + if (fragment_tlvs) + fragment_tlvs->threeway_adj = copy_tlv_threeway_adj(tlvs->threeway_adj); rv = pack_tlv_spine_leaf(tlvs->spine_leaf, stream); if (rv) return rv; - if (fragment_tlvs) { - fragment_tlvs->spine_leaf = - copy_tlv_spine_leaf(tlvs->spine_leaf); - } + if (fragment_tlvs) + fragment_tlvs->spine_leaf = copy_tlv_spine_leaf(tlvs->spine_leaf); - for (size_t pack_idx = 0; pack_idx < array_size(pack_order); - pack_idx++) { + for (size_t pack_idx = 0; pack_idx < array_size(pack_order); pack_idx++) { rv = handle_pack_entry(&pack_order[pack_idx], tlvs, stream, - fragment_tlvs ? &fragment_tlvs : NULL, - new_fragment, new_fragment_arg); + fragment_tlvs ? &fragment_tlvs : NULL, new_fragment, + new_fragment_arg); if (rv) return rv; @@ -7168,8 +6473,8 @@ static int pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, return 0; } -int isis_pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, - size_t len_pointer, bool pad, bool is_lsp) +int isis_pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, size_t len_pointer, bool pad, + bool is_lsp) { int rv; @@ -7180,9 +6485,8 @@ int isis_pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, if (pad) add_padding(stream); - if (len_pointer != (size_t)-1) { + if (len_pointer != (size_t)-1) stream_putw_at(stream, len_pointer, stream_get_endp(stream)); - } update_auth(tlvs, stream, is_lsp); @@ -7214,20 +6518,16 @@ struct list *isis_fragment_tlvs(struct isis_tlvs *tlvs, size_t size) return rv; } -static int unpack_tlv_unknown(enum isis_tlv_context context, uint8_t tlv_type, - uint8_t tlv_len, struct stream *s, - struct sbuf *log, int indent) +static int unpack_tlv_unknown(enum isis_tlv_context context, uint8_t tlv_type, uint8_t tlv_len, + struct stream *s, struct sbuf *log, int indent) { stream_forward_getp(s, tlv_len); - sbuf_push(log, indent, - "Skipping unknown TLV %hhu (%hhu bytes)\n", - tlv_type, tlv_len); + sbuf_push(log, indent, "Skipping unknown TLV %hhu (%hhu bytes)\n", tlv_type, tlv_len); return 0; } -static int unpack_tlv(enum isis_tlv_context context, size_t avail_len, - struct stream *stream, struct sbuf *log, void *dest, - int indent, bool *unpacked_known_tlvs) +static int unpack_tlv(enum isis_tlv_context context, size_t avail_len, struct stream *stream, + struct sbuf *log, void *dest, int indent, bool *unpacked_known_tlvs) { uint8_t tlv_type, tlv_len; const struct tlv_ops *ops; @@ -7235,19 +6535,15 @@ static int unpack_tlv(enum isis_tlv_context context, size_t avail_len, sbuf_push(log, indent, "Unpacking TLV...\n"); if (avail_len < 2) { - sbuf_push( - log, indent + 2, - "Available data %zu too short to contain a TLV header.\n", - avail_len); + sbuf_push(log, indent + 2, + "Available data %zu too short to contain a TLV header.\n", avail_len); return 1; } tlv_type = stream_getc(stream); tlv_len = stream_getc(stream); - sbuf_push(log, indent + 2, - "Found TLV of type %hhu and len %hhu.\n", - tlv_type, tlv_len); + sbuf_push(log, indent + 2, "Found TLV of type %hhu and len %hhu.\n", tlv_type, tlv_len); if (avail_len < ((size_t)tlv_len) + 2) { sbuf_push(log, indent + 2, @@ -7260,17 +6556,14 @@ static int unpack_tlv(enum isis_tlv_context context, size_t avail_len, if (ops && ops->unpack) { if (unpacked_known_tlvs) *unpacked_known_tlvs = true; - return ops->unpack(context, tlv_type, tlv_len, stream, log, - dest, indent + 2); + return ops->unpack(context, tlv_type, tlv_len, stream, log, dest, indent + 2); } - return unpack_tlv_unknown(context, tlv_type, tlv_len, stream, log, - indent + 2); + return unpack_tlv_unknown(context, tlv_type, tlv_len, stream, log, indent + 2); } -static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len, - struct stream *stream, struct sbuf *log, void *dest, - int indent, bool *unpacked_known_tlvs) +static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len, struct stream *stream, + struct sbuf *log, void *dest, int indent, bool *unpacked_known_tlvs) { int rv; size_t tlv_start, tlv_pos; @@ -7282,8 +6575,8 @@ static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len, (context == ISIS_CONTEXT_LSP) ? "TLVs" : "sub-TLVs"); while (tlv_pos < avail_len) { - rv = unpack_tlv(context, avail_len - tlv_pos, stream, log, dest, - indent + 2, unpacked_known_tlvs); + rv = unpack_tlv(context, avail_len - tlv_pos, stream, log, dest, indent + 2, + unpacked_known_tlvs); if (rv) return rv; @@ -7293,8 +6586,8 @@ static int unpack_tlvs(enum isis_tlv_context context, size_t avail_len, return 0; } -int isis_unpack_tlvs(size_t avail_len, struct stream *stream, - struct isis_tlvs **dest, const char **log) +int isis_unpack_tlvs(size_t avail_len, struct stream *stream, struct isis_tlvs **dest, + const char **log) { static struct sbuf logbuf; int indent = 0; @@ -7313,8 +6606,7 @@ int isis_unpack_tlvs(size_t avail_len, struct stream *stream, } result = isis_alloc_tlvs(); - rv = unpack_tlvs(ISIS_CONTEXT_LSP, avail_len, stream, &logbuf, result, - indent, NULL); + rv = unpack_tlvs(ISIS_CONTEXT_LSP, avail_len, stream, &logbuf, result, indent, NULL); *log = sbuf_buf(&logbuf); *dest = result; @@ -7322,38 +6614,37 @@ int isis_unpack_tlvs(size_t avail_len, struct stream *stream, return rv; } -#define TLV_OPS(_name_, _desc_) \ - static const struct tlv_ops tlv_##_name_##_ops = { \ - .name = _desc_, .unpack = unpack_tlv_##_name_, \ +#define TLV_OPS(_name_, _desc_) \ + static const struct tlv_ops tlv_##_name_##_ops = { \ + .name = _desc_, \ + .unpack = unpack_tlv_##_name_, \ } -#define ITEM_TLV_OPS(_name_, _desc_) \ - static const struct tlv_ops tlv_##_name_##_ops = { \ - .name = _desc_, \ - .unpack = unpack_tlv_with_items, \ - \ - .pack_item = pack_item_##_name_, \ - .free_item = free_item_##_name_, \ - .unpack_item = unpack_item_##_name_, \ - .format_item = format_item_##_name_, \ - .copy_item = copy_item_##_name_} +#define ITEM_TLV_OPS(_name_, _desc_) \ + static const struct tlv_ops tlv_##_name_##_ops = { .name = _desc_, \ + .unpack = unpack_tlv_with_items, \ + \ + .pack_item = pack_item_##_name_, \ + .free_item = free_item_##_name_, \ + .unpack_item = unpack_item_##_name_, \ + .format_item = format_item_##_name_, \ + .copy_item = copy_item_##_name_ } -#define SUBTLV_OPS(_name_, _desc_) \ - static const struct tlv_ops subtlv_##_name_##_ops = { \ - .name = _desc_, .unpack = unpack_subtlv_##_name_, \ +#define SUBTLV_OPS(_name_, _desc_) \ + static const struct tlv_ops subtlv_##_name_##_ops = { \ + .name = _desc_, \ + .unpack = unpack_subtlv_##_name_, \ } -#define ITEM_SUBTLV_OPS(_name_, _desc_) \ - ITEM_TLV_OPS(_name_, _desc_) +#define ITEM_SUBTLV_OPS(_name_, _desc_) ITEM_TLV_OPS(_name_, _desc_) -#define SUBSUBTLV_OPS(_name_, _desc_) \ - static const struct tlv_ops subsubtlv_##_name_##_ops = { \ - .name = _desc_, \ - .unpack = unpack_subsubtlv_##_name_, \ +#define SUBSUBTLV_OPS(_name_, _desc_) \ + static const struct tlv_ops subsubtlv_##_name_##_ops = { \ + .name = _desc_, \ + .unpack = unpack_subsubtlv_##_name_, \ } -#define ITEM_SUBSUBTLV_OPS(_name_, _desc_) \ - ITEM_TLV_OPS(_name_, _desc_) +#define ITEM_SUBSUBTLV_OPS(_name_, _desc_) ITEM_TLV_OPS(_name_, _desc_) ITEM_TLV_OPS(area_address, "TLV 1 Area Addresses"); ITEM_TLV_OPS(oldstyle_reach, "TLV 2 IS Reachability"); @@ -7450,8 +6741,7 @@ void isis_tlvs_add_auth(struct isis_tlvs *tlvs, struct isis_passwd *passwd) auth->type = passwd->type; auth->plength = passwd->len; - memcpy(auth->passwd, passwd->passwd, - MIN(sizeof(auth->passwd), sizeof(passwd->passwd))); + memcpy(auth->passwd, passwd->passwd, MIN(sizeof(auth->passwd), sizeof(passwd->passwd))); if (auth->type == ISIS_PASSWD_TYPE_CLEARTXT) { auth->length = passwd->len; @@ -7462,15 +6752,12 @@ void isis_tlvs_add_auth(struct isis_tlvs *tlvs, struct isis_passwd *passwd) append_item(&tlvs->isis_auth, (struct isis_item *)auth); } -void isis_tlvs_add_area_addresses(struct isis_tlvs *tlvs, - struct list *addresses) +void isis_tlvs_add_area_addresses(struct isis_tlvs *tlvs, struct iso_address_list_head *addresses) { - struct listnode *node; struct iso_address *area_addr; - for (ALL_LIST_ELEMENTS_RO(addresses, node, area_addr)) { - struct isis_area_address *a = - XCALLOC(MTYPE_ISIS_TLV, sizeof(*a)); + frr_each (iso_address_list, addresses, area_addr) { + struct isis_area_address *a = XCALLOC(MTYPE_ISIS_TLV, sizeof(*a)); a->len = area_addr->addr_len; memcpy(a->addr, area_addr->area_addr, ISO_ADDR_SIZE); @@ -7484,31 +6771,27 @@ void isis_tlvs_add_lan_neighbors(struct isis_tlvs *tlvs, struct list *neighbors) uint8_t *snpa; for (ALL_LIST_ELEMENTS_RO(neighbors, node, snpa)) { - struct isis_lan_neighbor *n = - XCALLOC(MTYPE_ISIS_TLV, sizeof(*n)); + struct isis_lan_neighbor *n = XCALLOC(MTYPE_ISIS_TLV, sizeof(*n)); memcpy(n->mac, snpa, 6); append_item(&tlvs->lan_neighbor, (struct isis_item *)n); } } -void isis_tlvs_set_protocols_supported(struct isis_tlvs *tlvs, - struct nlpids *nlpids) +void isis_tlvs_set_protocols_supported(struct isis_tlvs *tlvs, struct nlpids *nlpids) { tlvs->protocols_supported.count = nlpids->count; XFREE(MTYPE_ISIS_TLV, tlvs->protocols_supported.protocols); if (nlpids->count) { - tlvs->protocols_supported.protocols = - XCALLOC(MTYPE_ISIS_TLV, nlpids->count); - memcpy(tlvs->protocols_supported.protocols, nlpids->nlpids, - nlpids->count); + tlvs->protocols_supported.protocols = XCALLOC(MTYPE_ISIS_TLV, nlpids->count); + memcpy(tlvs->protocols_supported.protocols, nlpids->nlpids, nlpids->count); } else { tlvs->protocols_supported.protocols = NULL; } } -void isis_tlvs_add_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid, - bool overload, bool attached) +void isis_tlvs_add_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid, bool overload, + bool attached) { struct isis_mt_router_info *i = XCALLOC(MTYPE_ISIS_TLV, sizeof(*i)); @@ -7526,8 +6809,7 @@ void isis_tlvs_add_ipv4_address(struct isis_tlvs *tlvs, struct in_addr *addr) } -void isis_tlvs_add_ipv4_addresses(struct isis_tlvs *tlvs, - struct list *addresses) +void isis_tlvs_add_ipv4_addresses(struct isis_tlvs *tlvs, struct list *addresses) { struct listnode *node; struct prefix_ipv4 *ip_addr; @@ -7541,8 +6823,7 @@ void isis_tlvs_add_ipv4_addresses(struct isis_tlvs *tlvs, } } -void isis_tlvs_add_ipv6_addresses(struct isis_tlvs *tlvs, - struct list *addresses) +void isis_tlvs_add_ipv6_addresses(struct isis_tlvs *tlvs, struct list *addresses) { struct listnode *node; struct prefix_ipv6 *ip_addr; @@ -7552,8 +6833,7 @@ void isis_tlvs_add_ipv6_addresses(struct isis_tlvs *tlvs, if (addr_count >= 15) break; - struct isis_ipv6_address *a = - XCALLOC(MTYPE_ISIS_TLV, sizeof(*a)); + struct isis_ipv6_address *a = XCALLOC(MTYPE_ISIS_TLV, sizeof(*a)); a->addr = ip_addr->prefix; append_item(&tlvs->ipv6_address, (struct isis_item *)a); @@ -7561,8 +6841,7 @@ void isis_tlvs_add_ipv6_addresses(struct isis_tlvs *tlvs, } } -void isis_tlvs_add_global_ipv6_addresses(struct isis_tlvs *tlvs, - struct list *addresses) +void isis_tlvs_add_global_ipv6_addresses(struct isis_tlvs *tlvs, struct list *addresses) { struct listnode *node; struct prefix_ipv6 *ip_addr; @@ -7572,8 +6851,7 @@ void isis_tlvs_add_global_ipv6_addresses(struct isis_tlvs *tlvs, if (addr_count >= 15) break; - struct isis_ipv6_address *a = - XCALLOC(MTYPE_ISIS_TLV, sizeof(*a)); + struct isis_ipv6_address *a = XCALLOC(MTYPE_ISIS_TLV, sizeof(*a)); a->addr = ip_addr->prefix; append_item(&tlvs->global_ipv6_address, (struct isis_item *)a); @@ -7581,20 +6859,16 @@ void isis_tlvs_add_global_ipv6_addresses(struct isis_tlvs *tlvs, } } -typedef bool (*auth_validator_func)(struct isis_passwd *passwd, - struct stream *stream, +typedef bool (*auth_validator_func)(struct isis_passwd *passwd, struct stream *stream, struct isis_auth *auth, bool is_lsp); -static bool auth_validator_cleartxt(struct isis_passwd *passwd, - struct stream *stream, +static bool auth_validator_cleartxt(struct isis_passwd *passwd, struct stream *stream, struct isis_auth *auth, bool is_lsp) { - return (auth->length == passwd->len - && !memcmp(auth->value, passwd->passwd, passwd->len)); + return (auth->length == passwd->len && !memcmp(auth->value, passwd->passwd, passwd->len)); } -static bool auth_validator_hmac_md5(struct isis_passwd *passwd, - struct stream *stream, +static bool auth_validator_hmac_md5(struct isis_passwd *passwd, struct stream *stream, struct isis_auth *auth, bool is_lsp) { uint8_t digest[16]; @@ -7606,14 +6880,12 @@ static bool auth_validator_hmac_md5(struct isis_passwd *passwd, memset(STREAM_DATA(stream) + auth->offset, 0, 16); #ifdef CRYPTO_OPENSSL - uint8_t *result = (uint8_t *)HMAC(EVP_md5(), passwd->passwd, - passwd->len, STREAM_DATA(stream), - stream_get_endp(stream), NULL, NULL); + uint8_t *result = (uint8_t *)HMAC(EVP_md5(), passwd->passwd, passwd->len, + STREAM_DATA(stream), stream_get_endp(stream), NULL, NULL); memcpy(digest, result, 16); #elif CRYPTO_INTERNAL - hmac_md5(STREAM_DATA(stream), stream_get_endp(stream), passwd->passwd, - passwd->len, digest); + hmac_md5(STREAM_DATA(stream), stream_get_endp(stream), passwd->passwd, passwd->len, digest); #endif memcpy(STREAM_DATA(stream) + auth->offset, auth->value, 16); @@ -7626,8 +6898,8 @@ static bool auth_validator_hmac_md5(struct isis_passwd *passwd, } static const auth_validator_func auth_validators[] = { - [ISIS_PASSWD_TYPE_CLEARTXT] = auth_validator_cleartxt, - [ISIS_PASSWD_TYPE_HMAC_MD5] = auth_validator_hmac_md5, + [ISIS_PASSWD_TYPE_CLEARTXT] = auth_validator_cleartxt, + [ISIS_PASSWD_TYPE_HMAC_MD5] = auth_validator_hmac_md5, }; int isis_tlvs_auth_is_valid(struct isis_tlvs *tlvs, struct isis_passwd *passwd, @@ -7638,8 +6910,7 @@ int isis_tlvs_auth_is_valid(struct isis_tlvs *tlvs, struct isis_passwd *passwd, return ISIS_AUTH_OK; /* If we don't known how to validate the auth, return invalid */ - if (passwd->type >= array_size(auth_validators) - || !auth_validators[passwd->type]) + if (passwd->type >= array_size(auth_validators) || !auth_validators[passwd->type]) return ISIS_AUTH_NO_VALIDATOR; struct isis_auth *auth_head = (struct isis_auth *)tlvs->isis_auth.head; @@ -7661,20 +6932,17 @@ int isis_tlvs_auth_is_valid(struct isis_tlvs *tlvs, struct isis_passwd *passwd, return ISIS_AUTH_FAILURE; } -bool isis_tlvs_area_addresses_match(struct isis_tlvs *tlvs, - struct list *addresses) +bool isis_tlvs_area_addresses_match(struct isis_tlvs *tlvs, struct iso_address_list_head *addresses) { struct isis_area_address *addr_head; addr_head = (struct isis_area_address *)tlvs->area_addresses.head; - for (struct isis_area_address *addr = addr_head; addr; - addr = addr->next) { - struct listnode *node; + for (struct isis_area_address *addr = addr_head; addr; addr = addr->next) { struct iso_address *a; - for (ALL_LIST_ELEMENTS_RO(addresses, node, a)) { - if (a->addr_len == addr->len - && !memcmp(a->area_addr, addr->addr, addr->len)) + frr_each (iso_address_list, addresses, a) { + if (a->addr_len == addr->len && + !memcmp(a->area_addr, addr->addr, addr->len)) return true; } } @@ -7682,8 +6950,7 @@ bool isis_tlvs_area_addresses_match(struct isis_tlvs *tlvs, return false; } -static void tlvs_area_addresses_to_adj(struct isis_tlvs *tlvs, - struct isis_adjacency *adj, +static void tlvs_area_addresses_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj, bool *changed) { if (adj->area_address_count != tlvs->area_addresses.count) { @@ -7691,9 +6958,9 @@ static void tlvs_area_addresses_to_adj(struct isis_tlvs *tlvs, *changed = true; adj->area_address_count = tlvs->area_addresses.count; - adj->area_addresses = XREALLOC( - MTYPE_ISIS_ADJACENCY_INFO, adj->area_addresses, - adj->area_address_count * sizeof(*adj->area_addresses)); + adj->area_addresses = + XREALLOC(MTYPE_ISIS_ADJACENCY_INFO, adj->area_addresses, + adj->area_address_count * sizeof(*adj->area_addresses)); for (; oc < adj->area_address_count; oc++) { adj->area_addresses[oc].addr_len = 0; @@ -7705,14 +6972,12 @@ static void tlvs_area_addresses_to_adj(struct isis_tlvs *tlvs, struct isis_area_address *addr = NULL; for (unsigned int i = 0; i < tlvs->area_addresses.count; i++) { if (!addr) - addr = (struct isis_area_address *) - tlvs->area_addresses.head; + addr = (struct isis_area_address *)tlvs->area_addresses.head; else addr = addr->next; - if (adj->area_addresses[i].addr_len == addr->len - && !memcmp(adj->area_addresses[i].area_addr, addr->addr, - addr->len)) { + if (adj->area_addresses[i].addr_len == addr->len && + !memcmp(adj->area_addresses[i].area_addr, addr->addr, addr->len)) { continue; } @@ -7722,8 +6987,7 @@ static void tlvs_area_addresses_to_adj(struct isis_tlvs *tlvs, } } -static void tlvs_protocols_supported_to_adj(struct isis_tlvs *tlvs, - struct isis_adjacency *adj, +static void tlvs_protocols_supported_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj, bool *changed) { bool ipv4_supported = false, ipv6_supported = false; @@ -7751,8 +7015,8 @@ static void tlvs_protocols_supported_to_adj(struct isis_tlvs *tlvs, reduced.count = 0; } - if (adj->nlpids.count == reduced.count - && !memcmp(adj->nlpids.nlpids, reduced.nlpids, reduced.count)) + if (adj->nlpids.count == reduced.count && + !memcmp(adj->nlpids.nlpids, reduced.nlpids, reduced.count)) return; *changed = true; @@ -7761,14 +7025,13 @@ static void tlvs_protocols_supported_to_adj(struct isis_tlvs *tlvs, } DEFINE_HOOK(isis_adj_ip_enabled_hook, - (struct isis_adjacency * adj, int family, bool global), + (struct isis_adjacency *adj, int family, bool global), (adj, family, global)); DEFINE_HOOK(isis_adj_ip_disabled_hook, - (struct isis_adjacency * adj, int family, bool global), + (struct isis_adjacency *adj, int family, bool global), (adj, family, global)); -static void tlvs_ipv4_addresses_to_adj(struct isis_tlvs *tlvs, - struct isis_adjacency *adj, +static void tlvs_ipv4_addresses_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj, bool *changed) { bool ipv4_enabled = false; @@ -7783,26 +7046,22 @@ static void tlvs_ipv4_addresses_to_adj(struct isis_tlvs *tlvs, *changed = true; adj->ipv4_address_count = tlvs->ipv4_address.count; - adj->ipv4_addresses = XREALLOC( - MTYPE_ISIS_ADJACENCY_INFO, adj->ipv4_addresses, - adj->ipv4_address_count * sizeof(*adj->ipv4_addresses)); + adj->ipv4_addresses = + XREALLOC(MTYPE_ISIS_ADJACENCY_INFO, adj->ipv4_addresses, + adj->ipv4_address_count * sizeof(*adj->ipv4_addresses)); - for (; oc < adj->ipv4_address_count; oc++) { - memset(&adj->ipv4_addresses[oc], 0, - sizeof(adj->ipv4_addresses[oc])); - } + for (; oc < adj->ipv4_address_count; oc++) + memset(&adj->ipv4_addresses[oc], 0, sizeof(adj->ipv4_addresses[oc])); } struct isis_ipv4_address *addr = NULL; for (unsigned int i = 0; i < tlvs->ipv4_address.count; i++) { if (!addr) - addr = (struct isis_ipv4_address *) - tlvs->ipv4_address.head; + addr = (struct isis_ipv4_address *)tlvs->ipv4_address.head; else addr = addr->next; - if (!memcmp(&adj->ipv4_addresses[i], &addr->addr, - sizeof(addr->addr))) + if (!memcmp(&adj->ipv4_addresses[i], &addr->addr, sizeof(addr->addr))) continue; *changed = true; @@ -7813,8 +7072,7 @@ static void tlvs_ipv4_addresses_to_adj(struct isis_tlvs *tlvs, hook_call(isis_adj_ip_enabled_hook, adj, AF_INET, false); } -static void tlvs_ipv6_addresses_to_adj(struct isis_tlvs *tlvs, - struct isis_adjacency *adj, +static void tlvs_ipv6_addresses_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj, bool *changed) { bool ipv6_enabled = false; @@ -7829,26 +7087,21 @@ static void tlvs_ipv6_addresses_to_adj(struct isis_tlvs *tlvs, *changed = true; adj->ll_ipv6_count = tlvs->ipv6_address.count; - adj->ll_ipv6_addrs = XREALLOC( - MTYPE_ISIS_ADJACENCY_INFO, adj->ll_ipv6_addrs, - adj->ll_ipv6_count * sizeof(*adj->ll_ipv6_addrs)); + adj->ll_ipv6_addrs = XREALLOC(MTYPE_ISIS_ADJACENCY_INFO, adj->ll_ipv6_addrs, + adj->ll_ipv6_count * sizeof(*adj->ll_ipv6_addrs)); - for (; oc < adj->ll_ipv6_count; oc++) { - memset(&adj->ll_ipv6_addrs[oc], 0, - sizeof(adj->ll_ipv6_addrs[oc])); - } + for (; oc < adj->ll_ipv6_count; oc++) + memset(&adj->ll_ipv6_addrs[oc], 0, sizeof(adj->ll_ipv6_addrs[oc])); } struct isis_ipv6_address *addr = NULL; for (unsigned int i = 0; i < tlvs->ipv6_address.count; i++) { if (!addr) - addr = (struct isis_ipv6_address *) - tlvs->ipv6_address.head; + addr = (struct isis_ipv6_address *)tlvs->ipv6_address.head; else addr = addr->next; - if (!memcmp(&adj->ll_ipv6_addrs[i], &addr->addr, - sizeof(addr->addr))) + if (!memcmp(&adj->ll_ipv6_addrs[i], &addr->addr, sizeof(addr->addr))) continue; *changed = true; @@ -7860,16 +7113,14 @@ static void tlvs_ipv6_addresses_to_adj(struct isis_tlvs *tlvs, } -static void tlvs_global_ipv6_addresses_to_adj(struct isis_tlvs *tlvs, - struct isis_adjacency *adj, +static void tlvs_global_ipv6_addresses_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj, bool *changed) { bool global_ipv6_enabled = false; if (adj->global_ipv6_count == 0 && tlvs->global_ipv6_address.count > 0) global_ipv6_enabled = true; - else if (adj->global_ipv6_count > 0 - && tlvs->global_ipv6_address.count == 0) + else if (adj->global_ipv6_count > 0 && tlvs->global_ipv6_address.count == 0) hook_call(isis_adj_ip_disabled_hook, adj, AF_INET6, true); if (adj->global_ipv6_count != tlvs->global_ipv6_address.count) { @@ -7877,27 +7128,22 @@ static void tlvs_global_ipv6_addresses_to_adj(struct isis_tlvs *tlvs, *changed = true; adj->global_ipv6_count = tlvs->global_ipv6_address.count; - adj->global_ipv6_addrs = XREALLOC( - MTYPE_ISIS_ADJACENCY_INFO, adj->global_ipv6_addrs, - adj->global_ipv6_count - * sizeof(*adj->global_ipv6_addrs)); - - for (; oc < adj->global_ipv6_count; oc++) { - memset(&adj->global_ipv6_addrs[oc], 0, - sizeof(adj->global_ipv6_addrs[oc])); - } + adj->global_ipv6_addrs = + XREALLOC(MTYPE_ISIS_ADJACENCY_INFO, adj->global_ipv6_addrs, + adj->global_ipv6_count * sizeof(*adj->global_ipv6_addrs)); + + for (; oc < adj->global_ipv6_count; oc++) + memset(&adj->global_ipv6_addrs[oc], 0, sizeof(adj->global_ipv6_addrs[oc])); } struct isis_ipv6_address *addr = NULL; for (unsigned int i = 0; i < tlvs->global_ipv6_address.count; i++) { if (!addr) - addr = (struct isis_ipv6_address *) - tlvs->global_ipv6_address.head; + addr = (struct isis_ipv6_address *)tlvs->global_ipv6_address.head; else addr = addr->next; - if (!memcmp(&adj->global_ipv6_addrs[i], &addr->addr, - sizeof(addr->addr))) + if (!memcmp(&adj->global_ipv6_addrs[i], &addr->addr, sizeof(addr->addr))) continue; *changed = true; @@ -7908,8 +7154,7 @@ static void tlvs_global_ipv6_addresses_to_adj(struct isis_tlvs *tlvs, hook_call(isis_adj_ip_enabled_hook, adj, AF_INET6, true); } -void isis_tlvs_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj, - bool *changed) +void isis_tlvs_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj, bool *changed) { *changed = false; @@ -7946,9 +7191,8 @@ void isis_tlvs_add_lsp_entry(struct isis_tlvs *tlvs, struct isis_lsp *lsp) append_item(&tlvs->lsp_entries, (struct isis_item *)entry); } -void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id, - uint8_t *stop_id, uint16_t num_lsps, - struct lspdb_head *head, +void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id, uint8_t *stop_id, + uint16_t num_lsps, struct lspdb_head *head, struct isis_lsp **last_lsp) { struct isis_lsp searchfor; @@ -7960,8 +7204,8 @@ void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id, return; frr_each_from (lspdb, head, lsp, first) { - if (memcmp(lsp->hdr.lsp_id, stop_id, sizeof(lsp->hdr.lsp_id)) - > 0 || tlvs->lsp_entries.count == num_lsps) + if (memcmp(lsp->hdr.lsp_id, stop_id, sizeof(lsp->hdr.lsp_id)) > 0 || + tlvs->lsp_entries.count == num_lsps) break; isis_tlvs_add_lsp_entry(tlvs, lsp); @@ -7969,8 +7213,7 @@ void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id, } } -void isis_tlvs_set_dynamic_hostname(struct isis_tlvs *tlvs, - const char *hostname) +void isis_tlvs_set_dynamic_hostname(struct isis_tlvs *tlvs, const char *hostname) { XFREE(MTYPE_ISIS_TLV, tlvs->hostname); if (hostname) @@ -7990,9 +7233,8 @@ struct isis_router_cap *isis_tlvs_init_router_capability(struct isis_tlvs *tlvs) } #ifndef FABRICD -void isis_tlvs_set_router_capability_fad(struct isis_tlvs *tlvs, - struct flex_algo *fa, int algorithm, - uint8_t *sysid) +void isis_tlvs_set_router_capability_fad(struct isis_tlvs *tlvs, struct flex_algo *fa, + int algorithm, uint8_t *sysid) { struct isis_router_cap_fad *rcap_fad; @@ -8001,8 +7243,7 @@ void isis_tlvs_set_router_capability_fad(struct isis_tlvs *tlvs, rcap_fad = tlvs->router_cap->fads[algorithm]; if (!rcap_fad) - rcap_fad = XCALLOC(MTYPE_ISIS_TLV, - sizeof(struct isis_router_cap_fad)); + rcap_fad = XCALLOC(MTYPE_ISIS_TLV, sizeof(struct isis_router_cap_fad)); memset(rcap_fad->sysid, 0, ISIS_SYS_ID_LEN + 2); memcpy(rcap_fad->sysid, sysid, ISIS_SYS_ID_LEN); @@ -8013,12 +7254,9 @@ void isis_tlvs_set_router_capability_fad(struct isis_tlvs *tlvs, rcap_fad->fad.admin_group_include_any.bitmap.data = NULL; rcap_fad->fad.admin_group_include_all.bitmap.data = NULL; - admin_group_copy(&rcap_fad->fad.admin_group_exclude_any, - &fa->admin_group_exclude_any); - admin_group_copy(&rcap_fad->fad.admin_group_include_any, - &fa->admin_group_include_any); - admin_group_copy(&rcap_fad->fad.admin_group_include_all, - &fa->admin_group_include_all); + admin_group_copy(&rcap_fad->fad.admin_group_exclude_any, &fa->admin_group_exclude_any); + admin_group_copy(&rcap_fad->fad.admin_group_include_any, &fa->admin_group_include_any); + admin_group_copy(&rcap_fad->fad.admin_group_include_all, &fa->admin_group_include_all); tlvs->router_cap->fads[algorithm] = rcap_fad; } @@ -8034,8 +7272,7 @@ int isis_tlvs_sr_algo_count(const struct isis_router_cap *cap) return count; } -void isis_tlvs_set_te_router_id(struct isis_tlvs *tlvs, - const struct in_addr *id) +void isis_tlvs_set_te_router_id(struct isis_tlvs *tlvs, const struct in_addr *id) { XFREE(MTYPE_ISIS_TLV, tlvs->te_router_id); if (!id) @@ -8044,8 +7281,7 @@ void isis_tlvs_set_te_router_id(struct isis_tlvs *tlvs, memcpy(tlvs->te_router_id, id, sizeof(*id)); } -void isis_tlvs_set_te_router_id_ipv6(struct isis_tlvs *tlvs, - const struct in6_addr *id) +void isis_tlvs_set_te_router_id_ipv6(struct isis_tlvs *tlvs, const struct in6_addr *id) { XFREE(MTYPE_ISIS_TLV, tlvs->te_router_id_ipv6); if (!id) @@ -8054,8 +7290,8 @@ void isis_tlvs_set_te_router_id_ipv6(struct isis_tlvs *tlvs, memcpy(tlvs->te_router_id_ipv6, id, sizeof(*id)); } -void isis_tlvs_add_oldstyle_ip_reach(struct isis_tlvs *tlvs, - struct prefix_ipv4 *dest, uint8_t metric) +void isis_tlvs_add_oldstyle_ip_reach(struct isis_tlvs *tlvs, struct prefix_ipv4 *dest, + uint8_t metric) { struct isis_oldstyle_ip_reach *r = XCALLOC(MTYPE_ISIS_TLV, sizeof(*r)); @@ -8066,16 +7302,14 @@ void isis_tlvs_add_oldstyle_ip_reach(struct isis_tlvs *tlvs, } /* Add IS-IS SR Adjacency-SID subTLVs */ -void isis_tlvs_add_adj_sid(struct isis_ext_subtlvs *exts, - struct isis_adj_sid *adj) +void isis_tlvs_add_adj_sid(struct isis_ext_subtlvs *exts, struct isis_adj_sid *adj) { append_item(&exts->adj_sid, (struct isis_item *)adj); SET_SUBTLV(exts, EXT_ADJ_SID); } /* Delete IS-IS SR Adjacency-SID subTLVs */ -void isis_tlvs_del_adj_sid(struct isis_ext_subtlvs *exts, - struct isis_adj_sid *adj) +void isis_tlvs_del_adj_sid(struct isis_ext_subtlvs *exts, struct isis_adj_sid *adj) { delete_item(&exts->adj_sid, (struct isis_item *)adj); XFREE(MTYPE_ISIS_SUBTLV, adj); @@ -8084,16 +7318,14 @@ void isis_tlvs_del_adj_sid(struct isis_ext_subtlvs *exts, } /* Add IS-IS SR LAN-Adjacency-SID subTLVs */ -void isis_tlvs_add_lan_adj_sid(struct isis_ext_subtlvs *exts, - struct isis_lan_adj_sid *lan) +void isis_tlvs_add_lan_adj_sid(struct isis_ext_subtlvs *exts, struct isis_lan_adj_sid *lan) { append_item(&exts->lan_sid, (struct isis_item *)lan); SET_SUBTLV(exts, EXT_LAN_ADJ_SID); } /* Delete IS-IS SR LAN-Adjacency-SID subTLVs */ -void isis_tlvs_del_lan_adj_sid(struct isis_ext_subtlvs *exts, - struct isis_lan_adj_sid *lan) +void isis_tlvs_del_lan_adj_sid(struct isis_ext_subtlvs *exts, struct isis_lan_adj_sid *lan) { delete_item(&exts->lan_sid, (struct isis_item *)lan); XFREE(MTYPE_ISIS_SUBTLV, lan); @@ -8147,15 +7379,14 @@ static void isis_tlvs_del_asla_free(void *arg) XFREE(MTYPE_ISIS_SUBTLV, asla); } -void isis_tlvs_del_asla_flex_algo(struct isis_ext_subtlvs *ext, - struct isis_asla_subtlvs *asla) +void isis_tlvs_del_asla_flex_algo(struct isis_ext_subtlvs *ext, struct isis_asla_subtlvs *asla) { listnode_delete(ext->aslas, asla); isis_tlvs_del_asla_free(asla); } -struct isis_asla_subtlvs * -isis_tlvs_find_alloc_asla(struct isis_ext_subtlvs *ext, uint8_t standard_apps) +struct isis_asla_subtlvs *isis_tlvs_find_alloc_asla(struct isis_ext_subtlvs *ext, + uint8_t standard_apps) { struct isis_asla_subtlvs *asla; struct listnode *node; @@ -8194,10 +7425,8 @@ void isis_tlvs_free_asla(struct isis_ext_subtlvs *ext, uint8_t standard_apps) } } -void isis_tlvs_add_extended_ip_reach(struct isis_tlvs *tlvs, - struct prefix_ipv4 *dest, uint32_t metric, - bool external, - struct sr_prefix_cfg **pcfgs) +void isis_tlvs_add_extended_ip_reach(struct isis_tlvs *tlvs, struct prefix_ipv4 *dest, + uint32_t metric, bool external, struct sr_prefix_cfg **pcfgs) { struct isis_extended_ip_reach *r = XCALLOC(MTYPE_ISIS_TLV, sizeof(*r)); @@ -8217,19 +7446,16 @@ void isis_tlvs_add_extended_ip_reach(struct isis_tlvs *tlvs, isis_sr_prefix_cfg2subtlv(pcfg, external, psid); if (!r->subtlvs) - r->subtlvs = isis_alloc_subtlvs( - ISIS_CONTEXT_SUBTLV_IP_REACH); - append_item(&r->subtlvs->prefix_sids, - (struct isis_item *)psid); + r->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_IP_REACH); + append_item(&r->subtlvs->prefix_sids, (struct isis_item *)psid); } } append_item(&tlvs->extended_ip_reach, (struct isis_item *)r); } -void isis_tlvs_add_ipv6_reach(struct isis_tlvs *tlvs, uint16_t mtid, - struct prefix_ipv6 *dest, uint32_t metric, - bool external, struct sr_prefix_cfg **pcfgs) +void isis_tlvs_add_ipv6_reach(struct isis_tlvs *tlvs, uint16_t mtid, struct prefix_ipv6 *dest, + uint32_t metric, bool external, struct sr_prefix_cfg **pcfgs) { struct isis_ipv6_reach *r = XCALLOC(MTYPE_ISIS_TLV, sizeof(*r)); @@ -8248,37 +7474,31 @@ void isis_tlvs_add_ipv6_reach(struct isis_tlvs *tlvs, uint16_t mtid, isis_sr_prefix_cfg2subtlv(pcfg, external, psid); if (!r->subtlvs) - r->subtlvs = isis_alloc_subtlvs( - ISIS_CONTEXT_SUBTLV_IPV6_REACH); - append_item(&r->subtlvs->prefix_sids, - (struct isis_item *)psid); + r->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_IPV6_REACH); + append_item(&r->subtlvs->prefix_sids, (struct isis_item *)psid); } } struct isis_item_list *l; - l = (mtid == ISIS_MT_IPV4_UNICAST) - ? &tlvs->ipv6_reach - : isis_get_mt_items(&tlvs->mt_ipv6_reach, mtid); + l = (mtid == ISIS_MT_IPV4_UNICAST) ? &tlvs->ipv6_reach + : isis_get_mt_items(&tlvs->mt_ipv6_reach, mtid); append_item(l, (struct isis_item *)r); } void isis_tlvs_add_ipv6_dstsrc_reach(struct isis_tlvs *tlvs, uint16_t mtid, - struct prefix_ipv6 *dest, - struct prefix_ipv6 *src, + struct prefix_ipv6 *dest, struct prefix_ipv6 *src, uint32_t metric) { isis_tlvs_add_ipv6_reach(tlvs, mtid, dest, metric, false, NULL); - struct isis_item_list *l = isis_get_mt_items(&tlvs->mt_ipv6_reach, - mtid); + struct isis_item_list *l = isis_get_mt_items(&tlvs->mt_ipv6_reach, mtid); - struct isis_ipv6_reach *r = (struct isis_ipv6_reach*)last_item(l); + struct isis_ipv6_reach *r = (struct isis_ipv6_reach *)last_item(l); r->subtlvs = isis_alloc_subtlvs(ISIS_CONTEXT_SUBTLV_IPV6_REACH); r->subtlvs->source_prefix = XCALLOC(MTYPE_ISIS_SUBTLV, sizeof(*src)); memcpy(r->subtlvs->source_prefix, src, sizeof(*src)); } -void isis_tlvs_add_oldstyle_reach(struct isis_tlvs *tlvs, uint8_t *id, - uint8_t metric) +void isis_tlvs_add_oldstyle_reach(struct isis_tlvs *tlvs, uint8_t *id, uint8_t metric) { struct isis_oldstyle_reach *r = XCALLOC(MTYPE_ISIS_TLV, sizeof(*r)); @@ -8287,9 +7507,8 @@ void isis_tlvs_add_oldstyle_reach(struct isis_tlvs *tlvs, uint8_t *id, append_item(&tlvs->oldstyle_reach, (struct isis_item *)r); } -void isis_tlvs_add_extended_reach(struct isis_tlvs *tlvs, uint16_t mtid, - uint8_t *id, uint32_t metric, - struct isis_ext_subtlvs *exts) +void isis_tlvs_add_extended_reach(struct isis_tlvs *tlvs, uint16_t mtid, uint8_t *id, + uint32_t metric, struct isis_ext_subtlvs *exts) { struct isis_extended_reach *r = XCALLOC(MTYPE_ISIS_TLV, sizeof(*r)); @@ -8306,10 +7525,8 @@ void isis_tlvs_add_extended_reach(struct isis_tlvs *tlvs, uint16_t mtid, append_item(l, (struct isis_item *)r); } -void isis_tlvs_add_threeway_adj(struct isis_tlvs *tlvs, - enum isis_threeway_state state, - uint32_t local_circuit_id, - const uint8_t *neighbor_id, +void isis_tlvs_add_threeway_adj(struct isis_tlvs *tlvs, enum isis_threeway_state state, + uint32_t local_circuit_id, const uint8_t *neighbor_id, uint32_t neighbor_circuit_id) { assert(!tlvs->threeway_adj); @@ -8325,9 +7542,8 @@ void isis_tlvs_add_threeway_adj(struct isis_tlvs *tlvs, } } -void isis_tlvs_add_spine_leaf(struct isis_tlvs *tlvs, uint8_t tier, - bool has_tier, bool is_leaf, bool is_spine, - bool is_backup) +void isis_tlvs_add_spine_leaf(struct isis_tlvs *tlvs, uint8_t tier, bool has_tier, bool is_leaf, + bool is_spine, bool is_backup) { assert(!tlvs->spine_leaf); @@ -8343,15 +7559,13 @@ void isis_tlvs_add_spine_leaf(struct isis_tlvs *tlvs, uint8_t tier, tlvs->spine_leaf->is_backup = is_backup; } -struct isis_mt_router_info * -isis_tlvs_lookup_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid) +struct isis_mt_router_info *isis_tlvs_lookup_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid) { if (!tlvs || tlvs->mt_router_info_empty) return NULL; struct isis_mt_router_info *rv; - for (rv = (struct isis_mt_router_info *)tlvs->mt_router_info.head; rv; - rv = rv->next) { + for (rv = (struct isis_mt_router_info *)tlvs->mt_router_info.head; rv; rv = rv->next) { if (rv->mtid == mtid) return rv; } @@ -8359,14 +7573,12 @@ isis_tlvs_lookup_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid) return NULL; } -void isis_tlvs_set_purge_originator(struct isis_tlvs *tlvs, - const uint8_t *generator, +void isis_tlvs_set_purge_originator(struct isis_tlvs *tlvs, const uint8_t *generator, const uint8_t *sender) { assert(!tlvs->purge_originator); - tlvs->purge_originator = XCALLOC(MTYPE_ISIS_TLV, - sizeof(*tlvs->purge_originator)); + tlvs->purge_originator = XCALLOC(MTYPE_ISIS_TLV, sizeof(*tlvs->purge_originator)); memcpy(tlvs->purge_originator->generator, generator, sizeof(tlvs->purge_originator->generator)); if (sender) { @@ -8382,15 +7594,14 @@ void isis_subsubtlvs_set_srv6_sid_structure(struct isis_subsubtlvs *subsubtlvs, { assert(!subsubtlvs->srv6_sid_structure); - subsubtlvs->srv6_sid_structure = XCALLOC( - MTYPE_ISIS_SUBSUBTLV, sizeof(*subsubtlvs->srv6_sid_structure)); + subsubtlvs->srv6_sid_structure = XCALLOC(MTYPE_ISIS_SUBSUBTLV, + sizeof(*subsubtlvs->srv6_sid_structure)); isis_srv6_sid_structure2subsubtlv(sid, subsubtlvs->srv6_sid_structure); } /* Add an SRv6 End SID to the SRv6 End SID Sub-TLV */ -void isis_subtlvs_add_srv6_end_sid(struct isis_subtlvs *subtlvs, - struct isis_srv6_sid *sid) +void isis_subtlvs_add_srv6_end_sid(struct isis_subtlvs *subtlvs, struct isis_srv6_sid *sid) { struct isis_srv6_end_sid_subtlv *sid_subtlv; @@ -8419,8 +7630,7 @@ void isis_subtlvs_add_srv6_end_sid(struct isis_subtlvs *subtlvs, isis_srv6_end_sid2subtlv(sid, sid_subtlv); /* Add the SRv6 SID Structure Sub-Sub-TLV */ - sid_subtlv->subsubtlvs = - isis_alloc_subsubtlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_END_SID); + sid_subtlv->subsubtlvs = isis_alloc_subsubtlvs(ISIS_CONTEXT_SUBSUBTLV_SRV6_END_SID); isis_subsubtlvs_set_srv6_sid_structure(sid_subtlv->subsubtlvs, sid); /* Append the SRv6 End SID Sub-TLV to the Sub-TLVs list */ @@ -8434,8 +7644,7 @@ void isis_tlvs_add_srv6_locator(struct isis_tlvs *tlvs, uint16_t mtid, bool subtlvs_present = false; struct listnode *node; struct isis_srv6_sid *sid; - struct isis_srv6_locator_tlv *loc_tlv = - XCALLOC(MTYPE_ISIS_TLV, sizeof(*loc_tlv)); + struct isis_srv6_locator_tlv *loc_tlv = XCALLOC(MTYPE_ISIS_TLV, sizeof(*loc_tlv)); /* Fill in the SRv6 Locator TLV according to the SRv6 Locator * configuration */ diff --git a/isisd/isis_tlvs.h b/isisd/isis_tlvs.h index 5798d318f267..e41bc3c8f114 100644 --- a/isisd/isis_tlvs.h +++ b/isisd/isis_tlvs.h @@ -17,7 +17,7 @@ #include "prefix.h" #include "flex_algo.h" #include "affinitymap.h" - +#include "lib/iso.h" #include "lib/srv6.h" @@ -126,13 +126,13 @@ struct isis_threeway_adj { }; /* Segment Routing subTLV's as per RFC8667 */ -#define ISIS_SUBTLV_SRGB_FLAG_I 0x80 -#define ISIS_SUBTLV_SRGB_FLAG_V 0x40 -#define IS_SR_IPV4(srgb) ((srgb)->flags & ISIS_SUBTLV_SRGB_FLAG_I) -#define IS_SR_IPV6(srgb) ((srgb)->flags & ISIS_SUBTLV_SRGB_FLAG_V) -#define SUBTLV_SR_BLOCK_SIZE 6 -#define SUBTLV_RANGE_INDEX_SIZE 10 -#define SUBTLV_RANGE_LABEL_SIZE 9 +#define ISIS_SUBTLV_SRGB_FLAG_I 0x80 +#define ISIS_SUBTLV_SRGB_FLAG_V 0x40 +#define IS_SR_IPV4(srgb) ((srgb)->flags & ISIS_SUBTLV_SRGB_FLAG_I) +#define IS_SR_IPV6(srgb) ((srgb)->flags & ISIS_SUBTLV_SRGB_FLAG_V) +#define SUBTLV_SR_BLOCK_SIZE 6 +#define SUBTLV_RANGE_INDEX_SIZE 10 +#define SUBTLV_RANGE_LABEL_SIZE 9 /* Structure aggregating SR Global (SRGB) or Local (SRLB) Block info */ struct isis_sr_block { @@ -143,11 +143,11 @@ struct isis_sr_block { /* Prefix-SID sub-TLVs flags */ #define ISIS_PREFIX_SID_READVERTISED 0x80 -#define ISIS_PREFIX_SID_NODE 0x40 -#define ISIS_PREFIX_SID_NO_PHP 0x20 +#define ISIS_PREFIX_SID_NODE 0x40 +#define ISIS_PREFIX_SID_NO_PHP 0x20 #define ISIS_PREFIX_SID_EXPLICIT_NULL 0x10 -#define ISIS_PREFIX_SID_VALUE 0x08 -#define ISIS_PREFIX_SID_LOCAL 0x04 +#define ISIS_PREFIX_SID_VALUE 0x08 +#define ISIS_PREFIX_SID_LOCAL 0x04 struct isis_prefix_sid { struct isis_prefix_sid *next; @@ -158,12 +158,12 @@ struct isis_prefix_sid { }; /* Adj-SID and LAN-Ajd-SID sub-TLVs flags */ -#define EXT_SUBTLV_LINK_ADJ_SID_FFLG 0x80 -#define EXT_SUBTLV_LINK_ADJ_SID_BFLG 0x40 -#define EXT_SUBTLV_LINK_ADJ_SID_VFLG 0x20 -#define EXT_SUBTLV_LINK_ADJ_SID_LFLG 0x10 -#define EXT_SUBTLV_LINK_ADJ_SID_SFLG 0x08 -#define EXT_SUBTLV_LINK_ADJ_SID_PFLG 0x04 +#define EXT_SUBTLV_LINK_ADJ_SID_FFLG 0x80 +#define EXT_SUBTLV_LINK_ADJ_SID_BFLG 0x40 +#define EXT_SUBTLV_LINK_ADJ_SID_VFLG 0x20 +#define EXT_SUBTLV_LINK_ADJ_SID_LFLG 0x10 +#define EXT_SUBTLV_LINK_ADJ_SID_SFLG 0x08 +#define EXT_SUBTLV_LINK_ADJ_SID_PFLG 0x04 struct isis_adj_sid { struct isis_adj_sid *next; @@ -185,12 +185,12 @@ struct isis_lan_adj_sid { }; /* RFC 4971 & RFC 7981 */ -#define ISIS_ROUTER_CAP_FLAG_S 0x01 -#define ISIS_ROUTER_CAP_FLAG_D 0x02 -#define ISIS_ROUTER_CAP_SIZE 5 +#define ISIS_ROUTER_CAP_FLAG_S 0x01 +#define ISIS_ROUTER_CAP_FLAG_D 0x02 +#define ISIS_ROUTER_CAP_SIZE 5 -#define MSD_TYPE_BASE_MPLS_IMPOSITION 0x01 -#define MSD_TLV_SIZE 2 +#define MSD_TYPE_BASE_MPLS_IMPOSITION 0x01 +#define MSD_TLV_SIZE 2 #ifndef FABRICD struct isis_router_cap_fad; @@ -221,9 +221,9 @@ struct isis_srv6_end_sid_subtlv { }; /* SRv6 End.X SID and SRv6 LAN End.X SID sub-TLVs flags */ -#define EXT_SUBTLV_LINK_SRV6_ENDX_SID_PFLG 0x20 -#define EXT_SUBTLV_LINK_SRV6_ENDX_SID_SFLG 0x40 -#define EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG 0x80 +#define EXT_SUBTLV_LINK_SRV6_ENDX_SID_PFLG 0x20 +#define EXT_SUBTLV_LINK_SRV6_ENDX_SID_SFLG 0x40 +#define EXT_SUBTLV_LINK_SRV6_ENDX_SID_BFLG 0x80 /* SRv6 End.X SID Sub-TLV as per RFC 9352 section #8.1 */ struct isis_srv6_endx_sid_subtlv { @@ -287,8 +287,7 @@ struct isis_srv6_cap { uint16_t flags; #define ISIS_SUBTLV_SRV6_FLAG_O 0x4000 -#define SUPPORTS_SRV6_OAM(srv6) \ - (CHECK_FLAG((srv6)->flags, ISIS_SUBTLV_SRV6_FLAG_O)) +#define SUPPORTS_SRV6_OAM(srv6) (CHECK_FLAG((srv6)->flags, ISIS_SUBTLV_SRV6_FLAG_O)) }; struct isis_router_cap { @@ -382,10 +381,8 @@ enum isis_auth_result { RB_HEAD(isis_mt_item_list, isis_item_list); -struct isis_item_list *isis_get_mt_items(struct isis_mt_item_list *m, - uint16_t mtid); -struct isis_item_list *isis_lookup_mt_items(struct isis_mt_item_list *m, - uint16_t mtid); +struct isis_item_list *isis_get_mt_items(struct isis_mt_item_list *m, uint16_t mtid); +struct isis_item_list *isis_lookup_mt_items(struct isis_mt_item_list *m, uint16_t mtid); struct isis_tlvs { struct isis_item_list isis_auth; @@ -624,36 +621,36 @@ enum ext_subsubtlv_types { }; /* Macros to manage the optional presence of EXT subTLVs */ -#define SET_SUBTLV(s, t) ((s->status) |= (t)) +#define SET_SUBTLV(s, t) ((s->status) |= (t)) #define UNSET_SUBTLV(s, t) ((s->status) &= ~(t)) -#define IS_SUBTLV(s, t) (s->status & t) -#define RESET_SUBTLV(s) (s->status = 0) -#define NO_SUBTLV(s) (s->status == 0) - -#define EXT_DISABLE 0x000000 -#define EXT_ADM_GRP 0x000001 -#define EXT_LLRI 0x000002 -#define EXT_LOCAL_ADDR 0x000004 -#define EXT_NEIGH_ADDR 0x000008 -#define EXT_LOCAL_ADDR6 0x000010 -#define EXT_NEIGH_ADDR6 0x000020 -#define EXT_MAX_BW 0x000040 -#define EXT_MAX_RSV_BW 0x000080 -#define EXT_UNRSV_BW 0x000100 -#define EXT_TE_METRIC 0x000200 -#define EXT_RMT_AS 0x000400 -#define EXT_RMT_IP 0x000800 -#define EXT_ADJ_SID 0x001000 -#define EXT_LAN_ADJ_SID 0x002000 -#define EXT_DELAY 0x004000 -#define EXT_MM_DELAY 0x008000 -#define EXT_DELAY_VAR 0x010000 -#define EXT_PKT_LOSS 0x020000 -#define EXT_RES_BW 0x040000 -#define EXT_AVA_BW 0x080000 -#define EXT_USE_BW 0x100000 -#define EXT_EXTEND_ADM_GRP 0x200000 -#define EXT_SRV6_ENDX_SID 0x400000 +#define IS_SUBTLV(s, t) (s->status & t) +#define RESET_SUBTLV(s) (s->status = 0) +#define NO_SUBTLV(s) (s->status == 0) + +#define EXT_DISABLE 0x000000 +#define EXT_ADM_GRP 0x000001 +#define EXT_LLRI 0x000002 +#define EXT_LOCAL_ADDR 0x000004 +#define EXT_NEIGH_ADDR 0x000008 +#define EXT_LOCAL_ADDR6 0x000010 +#define EXT_NEIGH_ADDR6 0x000020 +#define EXT_MAX_BW 0x000040 +#define EXT_MAX_RSV_BW 0x000080 +#define EXT_UNRSV_BW 0x000100 +#define EXT_TE_METRIC 0x000200 +#define EXT_RMT_AS 0x000400 +#define EXT_RMT_IP 0x000800 +#define EXT_ADJ_SID 0x001000 +#define EXT_LAN_ADJ_SID 0x002000 +#define EXT_DELAY 0x004000 +#define EXT_MM_DELAY 0x008000 +#define EXT_DELAY_VAR 0x010000 +#define EXT_PKT_LOSS 0x020000 +#define EXT_RES_BW 0x040000 +#define EXT_AVA_BW 0x080000 +#define EXT_USE_BW 0x100000 +#define EXT_EXTEND_ADM_GRP 0x200000 +#define EXT_SRV6_ENDX_SID 0x400000 #define EXT_SRV6_LAN_ENDX_SID 0x800000 /* @@ -671,33 +668,32 @@ enum ext_subsubtlv_types { #define IS_ANORMAL(v) (v & TE_EXT_ANORMAL) struct isis_ext_subtlvs { - uint32_t status; - uint32_t adm_group; /* Resource Class/Color - RFC 5305 */ + uint32_t adm_group; /* Resource Class/Color - RFC 5305 */ struct admin_group ext_admin_group; /* Res. Class/Color - RFC 7308 */ /* Link Local/Remote Identifiers - RFC 5307 */ uint32_t local_llri; uint32_t remote_llri; - struct in_addr local_addr; /* Local IP Address - RFC 5305 */ - struct in_addr neigh_addr; /* Neighbor IP Address - RFC 5305 */ + struct in_addr local_addr; /* Local IP Address - RFC 5305 */ + struct in_addr neigh_addr; /* Neighbor IP Address - RFC 5305 */ struct in6_addr local_addr6; /* Local IPv6 Address - RFC 6119 */ struct in6_addr neigh_addr6; /* Neighbor IPv6 Address - RFC 6119 */ - float max_bw; /* Maximum Bandwidth - RFC 5305 */ - float max_rsv_bw; /* Maximum Reservable Bandwidth - RFC 5305 */ - float unrsv_bw[8]; /* Unreserved Bandwidth - RFC 5305 */ - uint32_t te_metric; /* Traffic Engineering Metric - RFC 5305 */ - uint32_t remote_as; /* Remote AS Number sub-TLV - RFC5316 */ - struct in_addr remote_ip; /* IPv4 Remote ASBR ID Sub-TLV - RFC5316 */ - - uint32_t delay; /* Average Link Delay - RFC 8570 */ + float max_bw; /* Maximum Bandwidth - RFC 5305 */ + float max_rsv_bw; /* Maximum Reservable Bandwidth - RFC 5305 */ + float unrsv_bw[8]; /* Unreserved Bandwidth - RFC 5305 */ + uint32_t te_metric; /* Traffic Engineering Metric - RFC 5305 */ + uint32_t remote_as; /* Remote AS Number sub-TLV - RFC5316 */ + struct in_addr remote_ip; /* IPv4 Remote ASBR ID Sub-TLV - RFC5316 */ + + uint32_t delay; /* Average Link Delay - RFC 8570 */ uint32_t min_delay; /* Low Link Delay - RFC 8570 */ uint32_t max_delay; /* High Link Delay - RFC 8570 */ uint32_t delay_var; /* Link Delay Variation i.e. Jitter - RFC 8570 */ - uint32_t pkt_loss; /* Unidirectional Link Packet Loss - RFC 8570 */ - float res_bw; /* Unidirectional Residual Bandwidth - RFC 8570 */ - float ava_bw; /* Unidirectional Available Bandwidth - RFC 8570 */ - float use_bw; /* Unidirectional Utilized Bandwidth - RFC 8570 */ + uint32_t pkt_loss; /* Unidirectional Link Packet Loss - RFC 8570 */ + float res_bw; /* Unidirectional Residual Bandwidth - RFC 8570 */ + float ava_bw; /* Unidirectional Available Bandwidth - RFC 8570 */ + float use_bw; /* Unidirectional Utilized Bandwidth - RFC 8570 */ /* Segment Routing Adjacency & LAN Adjacency Segment ID */ struct isis_item_list adj_sid; @@ -716,10 +712,10 @@ struct isis_ext_subtlvs { #define ISIS_SABM_FLAG_L 0x20 /* Loop-Free Alternate */ #define ISIS_SABM_FLAG_X 0x10 /* Flex-Algorithm - RFC9350 */ -#define ASLA_APP_IDENTIFIER_BIT_LENGTH 1 +#define ASLA_APP_IDENTIFIER_BIT_LENGTH 1 #define ASLA_APP_IDENTIFIER_BIT_MAX_LENGTH 8 -#define ASLA_LEGACY_FLAG 0x80 -#define ASLA_APPS_LENGTH_MASK 0x7f +#define ASLA_LEGACY_FLAG 0x80 +#define ASLA_APPS_LENGTH_MASK 0x7f struct isis_asla_subtlvs { uint32_t status; @@ -735,155 +731,125 @@ struct isis_asla_subtlvs { uint32_t admin_group; struct admin_group ext_admin_group; /* Res. Class/Color - RFC 7308 */ float max_bw; /* Maximum Bandwidth - RFC 5305 */ - float max_rsv_bw; /* Maximum Reservable Bandwidth - RFC 5305 */ - float unrsv_bw[8]; /* Unreserved Bandwidth - RFC 5305 */ - uint32_t te_metric; /* Traffic Engineering Metric - RFC 5305 */ - uint32_t delay; /* Average Link Delay - RFC 8570 */ - uint32_t min_delay; /* Low Link Delay - RFC 8570 */ - uint32_t max_delay; /* High Link Delay - RFC 8570 */ - uint32_t delay_var; /* Link Delay Variation i.e. Jitter - RFC 8570 */ - uint32_t pkt_loss; /* Unidirectional Link Packet Loss - RFC 8570 */ - float res_bw; /* Unidirectional Residual Bandwidth - RFC 8570 */ - float ava_bw; /* Unidirectional Available Bandwidth - RFC 8570 */ - float use_bw; /* Unidirectional Utilized Bandwidth - RFC 8570 */ -}; - -#define IS_COMPAT_MT_TLV(tlv_type) \ - ((tlv_type == ISIS_TLV_MT_REACH) || (tlv_type == ISIS_TLV_MT_IP_REACH) \ - || (tlv_type == ISIS_TLV_MT_IPV6_REACH)) + float max_rsv_bw; /* Maximum Reservable Bandwidth - RFC 5305 */ + float unrsv_bw[8]; /* Unreserved Bandwidth - RFC 5305 */ + uint32_t te_metric; /* Traffic Engineering Metric - RFC 5305 */ + uint32_t delay; /* Average Link Delay - RFC 8570 */ + uint32_t min_delay; /* Low Link Delay - RFC 8570 */ + uint32_t max_delay; /* High Link Delay - RFC 8570 */ + uint32_t delay_var; /* Link Delay Variation i.e. Jitter - RFC 8570 */ + uint32_t pkt_loss; /* Unidirectional Link Packet Loss - RFC 8570 */ + float res_bw; /* Unidirectional Residual Bandwidth - RFC 8570 */ + float ava_bw; /* Unidirectional Available Bandwidth - RFC 8570 */ + float use_bw; /* Unidirectional Utilized Bandwidth - RFC 8570 */ +}; + +#define IS_COMPAT_MT_TLV(tlv_type) \ + ((tlv_type == ISIS_TLV_MT_REACH) || (tlv_type == ISIS_TLV_MT_IP_REACH) || \ + (tlv_type == ISIS_TLV_MT_IPV6_REACH)) struct stream; -int isis_pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, - size_t len_pointer, bool pad, bool is_lsp); +int isis_pack_tlvs(struct isis_tlvs *tlvs, struct stream *stream, size_t len_pointer, bool pad, + bool is_lsp); void isis_free_tlvs(struct isis_tlvs *tlvs); struct isis_tlvs *isis_alloc_tlvs(void); struct isis_subsubtlvs *isis_alloc_subsubtlvs(enum isis_tlv_context context); -int isis_unpack_tlvs(size_t avail_len, struct stream *stream, - struct isis_tlvs **dest, const char **error_log); +int isis_unpack_tlvs(size_t avail_len, struct stream *stream, struct isis_tlvs **dest, + const char **error_log); const char *isis_format_tlvs(struct isis_tlvs *tlvs, struct json_object *json); struct isis_tlvs *isis_copy_tlvs(struct isis_tlvs *tlvs); struct list *isis_fragment_tlvs(struct isis_tlvs *tlvs, size_t size); -#define ISIS_EXTENDED_IP_REACH_DOWN 0x80 +#define ISIS_EXTENDED_IP_REACH_DOWN 0x80 #define ISIS_EXTENDED_IP_REACH_SUBTLV 0x40 -#define ISIS_IPV6_REACH_DOWN 0x80 +#define ISIS_IPV6_REACH_DOWN 0x80 #define ISIS_IPV6_REACH_EXTERNAL 0x40 -#define ISIS_IPV6_REACH_SUBTLV 0x20 +#define ISIS_IPV6_REACH_SUBTLV 0x20 #ifndef ISIS_MT_MASK -#define ISIS_MT_MASK 0x0fff -#define ISIS_MT_OL_MASK 0x8000 -#define ISIS_MT_AT_MASK 0x4000 +#define ISIS_MT_MASK 0x0fff +#define ISIS_MT_OL_MASK 0x8000 +#define ISIS_MT_AT_MASK 0x4000 #endif void isis_tlvs_add_auth(struct isis_tlvs *tlvs, struct isis_passwd *passwd); -void isis_tlvs_add_area_addresses(struct isis_tlvs *tlvs, - struct list *addresses); -void isis_tlvs_add_lan_neighbors(struct isis_tlvs *tlvs, - struct list *neighbors); -void isis_tlvs_set_protocols_supported(struct isis_tlvs *tlvs, - struct nlpids *nlpids); -void isis_tlvs_add_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid, - bool overload, bool attached); +void isis_tlvs_add_area_addresses(struct isis_tlvs *tlvs, struct iso_address_list_head *addresses); +void isis_tlvs_add_lan_neighbors(struct isis_tlvs *tlvs, struct list *neighbors); +void isis_tlvs_set_protocols_supported(struct isis_tlvs *tlvs, struct nlpids *nlpids); +void isis_tlvs_add_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid, bool overload, + bool attached); void isis_tlvs_add_ipv4_address(struct isis_tlvs *tlvs, struct in_addr *addr); -void isis_tlvs_add_ipv4_addresses(struct isis_tlvs *tlvs, - struct list *addresses); -void isis_tlvs_add_ipv6_addresses(struct isis_tlvs *tlvs, - struct list *addresses); -void isis_tlvs_add_global_ipv6_addresses(struct isis_tlvs *tlvs, - struct list *addresses); +void isis_tlvs_add_ipv4_addresses(struct isis_tlvs *tlvs, struct list *addresses); +void isis_tlvs_add_ipv6_addresses(struct isis_tlvs *tlvs, struct list *addresses); +void isis_tlvs_add_global_ipv6_addresses(struct isis_tlvs *tlvs, struct list *addresses); int isis_tlvs_auth_is_valid(struct isis_tlvs *tlvs, struct isis_passwd *passwd, struct stream *stream, bool is_lsp); bool isis_tlvs_area_addresses_match(struct isis_tlvs *tlvs, - struct list *addresses); + struct iso_address_list_head *addresses); struct isis_adjacency; -void isis_tlvs_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj, - bool *changed); +void isis_tlvs_to_adj(struct isis_tlvs *tlvs, struct isis_adjacency *adj, bool *changed); bool isis_tlvs_own_snpa_found(struct isis_tlvs *tlvs, uint8_t *snpa); void isis_tlvs_add_lsp_entry(struct isis_tlvs *tlvs, struct isis_lsp *lsp); -void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id, - uint8_t *stop_id, uint16_t num_lsps, - struct lspdb_head *lspdb, +void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id, uint8_t *stop_id, + uint16_t num_lsps, struct lspdb_head *lspdb, struct isis_lsp **last_lsp); -void isis_tlvs_set_dynamic_hostname(struct isis_tlvs *tlvs, - const char *hostname); -struct isis_router_cap * -isis_tlvs_init_router_capability(struct isis_tlvs *tlvs); +void isis_tlvs_set_dynamic_hostname(struct isis_tlvs *tlvs, const char *hostname); +struct isis_router_cap *isis_tlvs_init_router_capability(struct isis_tlvs *tlvs); struct isis_area; struct isis_flex_algo; -void isis_tlvs_set_router_capability_fad(struct isis_tlvs *tlvs, - struct flex_algo *fa, int algorithm, - uint8_t *sysid); +void isis_tlvs_set_router_capability_fad(struct isis_tlvs *tlvs, struct flex_algo *fa, + int algorithm, uint8_t *sysid); struct isis_area; int isis_tlvs_sr_algo_count(const struct isis_router_cap *cap); -void isis_tlvs_set_te_router_id(struct isis_tlvs *tlvs, - const struct in_addr *id); -void isis_tlvs_set_te_router_id_ipv6(struct isis_tlvs *tlvs, - const struct in6_addr *id); -void isis_tlvs_add_oldstyle_ip_reach(struct isis_tlvs *tlvs, - struct prefix_ipv4 *dest, uint8_t metric); -void isis_tlvs_add_extended_ip_reach(struct isis_tlvs *tlvs, - struct prefix_ipv4 *dest, uint32_t metric, - bool external, - struct sr_prefix_cfg **pcfgs); -void isis_tlvs_add_ipv6_reach(struct isis_tlvs *tlvs, uint16_t mtid, - struct prefix_ipv6 *dest, uint32_t metric, - bool external, struct sr_prefix_cfg **pcfgs); +void isis_tlvs_set_te_router_id(struct isis_tlvs *tlvs, const struct in_addr *id); +void isis_tlvs_set_te_router_id_ipv6(struct isis_tlvs *tlvs, const struct in6_addr *id); +void isis_tlvs_add_oldstyle_ip_reach(struct isis_tlvs *tlvs, struct prefix_ipv4 *dest, + uint8_t metric); +void isis_tlvs_add_extended_ip_reach(struct isis_tlvs *tlvs, struct prefix_ipv4 *dest, + uint32_t metric, bool external, struct sr_prefix_cfg **pcfgs); +void isis_tlvs_add_ipv6_reach(struct isis_tlvs *tlvs, uint16_t mtid, struct prefix_ipv6 *dest, + uint32_t metric, bool external, struct sr_prefix_cfg **pcfgs); void isis_tlvs_add_ipv6_dstsrc_reach(struct isis_tlvs *tlvs, uint16_t mtid, - struct prefix_ipv6 *dest, - struct prefix_ipv6 *src, + struct prefix_ipv6 *dest, struct prefix_ipv6 *src, uint32_t metric); struct isis_ext_subtlvs *isis_alloc_ext_subtlvs(void); void isis_del_ext_subtlvs(struct isis_ext_subtlvs *ext); -void isis_tlvs_add_adj_sid(struct isis_ext_subtlvs *exts, - struct isis_adj_sid *adj); -void isis_tlvs_del_adj_sid(struct isis_ext_subtlvs *exts, - struct isis_adj_sid *adj); -void isis_tlvs_add_lan_adj_sid(struct isis_ext_subtlvs *exts, - struct isis_lan_adj_sid *lan); -void isis_tlvs_del_lan_adj_sid(struct isis_ext_subtlvs *exts, - struct isis_lan_adj_sid *lan); - -void isis_tlvs_del_asla_flex_algo(struct isis_ext_subtlvs *ext, - struct isis_asla_subtlvs *asla); -struct isis_asla_subtlvs * -isis_tlvs_find_alloc_asla(struct isis_ext_subtlvs *ext, uint8_t standard_apps); +void isis_tlvs_add_adj_sid(struct isis_ext_subtlvs *exts, struct isis_adj_sid *adj); +void isis_tlvs_del_adj_sid(struct isis_ext_subtlvs *exts, struct isis_adj_sid *adj); +void isis_tlvs_add_lan_adj_sid(struct isis_ext_subtlvs *exts, struct isis_lan_adj_sid *lan); +void isis_tlvs_del_lan_adj_sid(struct isis_ext_subtlvs *exts, struct isis_lan_adj_sid *lan); + +void isis_tlvs_del_asla_flex_algo(struct isis_ext_subtlvs *ext, struct isis_asla_subtlvs *asla); +struct isis_asla_subtlvs *isis_tlvs_find_alloc_asla(struct isis_ext_subtlvs *ext, + uint8_t standard_apps); void isis_tlvs_free_asla(struct isis_ext_subtlvs *ext, uint8_t standard_apps); -void isis_tlvs_add_oldstyle_reach(struct isis_tlvs *tlvs, uint8_t *id, - uint8_t metric); -void isis_tlvs_add_extended_reach(struct isis_tlvs *tlvs, uint16_t mtid, - uint8_t *id, uint32_t metric, - struct isis_ext_subtlvs *subtlvs); +void isis_tlvs_add_oldstyle_reach(struct isis_tlvs *tlvs, uint8_t *id, uint8_t metric); +void isis_tlvs_add_extended_reach(struct isis_tlvs *tlvs, uint16_t mtid, uint8_t *id, + uint32_t metric, struct isis_ext_subtlvs *subtlvs); const char *isis_threeway_state_name(enum isis_threeway_state state); -void isis_tlvs_add_threeway_adj(struct isis_tlvs *tlvs, - enum isis_threeway_state state, - uint32_t local_circuit_id, - const uint8_t *neighbor_id, +void isis_tlvs_add_threeway_adj(struct isis_tlvs *tlvs, enum isis_threeway_state state, + uint32_t local_circuit_id, const uint8_t *neighbor_id, uint32_t neighbor_circuit_id); -void isis_tlvs_add_spine_leaf(struct isis_tlvs *tlvs, uint8_t tier, - bool has_tier, bool is_leaf, bool is_spine, - bool is_backup); +void isis_tlvs_add_spine_leaf(struct isis_tlvs *tlvs, uint8_t tier, bool has_tier, bool is_leaf, + bool is_spine, bool is_backup); -struct isis_mt_router_info * -isis_tlvs_lookup_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid); +struct isis_mt_router_info *isis_tlvs_lookup_mt_router_info(struct isis_tlvs *tlvs, uint16_t mtid); -void isis_tlvs_set_purge_originator(struct isis_tlvs *tlvs, - const uint8_t *generator, +void isis_tlvs_set_purge_originator(struct isis_tlvs *tlvs, const uint8_t *generator, const uint8_t *sender); void isis_subsubtlvs_set_srv6_sid_structure(struct isis_subsubtlvs *subsubtlvs, struct isis_srv6_sid *sid); -void isis_subtlvs_add_srv6_end_sid(struct isis_subtlvs *subtlvs, - struct isis_srv6_sid *sid); +void isis_subtlvs_add_srv6_end_sid(struct isis_subtlvs *subtlvs, struct isis_srv6_sid *sid); void isis_tlvs_add_srv6_locator(struct isis_tlvs *tlvs, uint16_t mtid, struct isis_srv6_locator *loc); diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c index 75f6384da018..8560e898cba4 100644 --- a/isisd/isis_vty_fabricd.c +++ b/isisd/isis_vty_fabricd.c @@ -156,7 +156,6 @@ DEFUN (show_lsp_flooding, if (argc == 4) lspid = argv[3]->arg; - struct listnode *node; struct isis_area *area; struct isis *isis = NULL; @@ -167,7 +166,7 @@ DEFUN (show_lsp_flooding, return CMD_SUCCESS; } - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { struct lspdb_head *head = &area->lspdb[ISIS_LEVEL2 - 1]; struct isis_lsp *lsp; @@ -614,10 +613,9 @@ DEFUN (no_spf_interval, static int isis_vty_lsp_mtu_set(struct vty *vty, unsigned int lsp_mtu) { VTY_DECLVAR_CONTEXT(isis_area, area); - struct listnode *node; struct isis_circuit *circuit; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { if (circuit->state != C_STATE_INIT && circuit->state != C_STATE_UP) continue; diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index 047c5371b16a..a6d2d64febf0 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -52,7 +52,6 @@ static struct zclient *zclient_sync; static int isis_router_id_update_zebra(ZAPI_CALLBACK_ARGS) { struct isis_area *area; - struct listnode *node; struct prefix router_id; struct isis *isis = NULL; @@ -67,8 +66,8 @@ static int isis_router_id_update_zebra(ZAPI_CALLBACK_ARGS) return 0; isis->router_id = router_id.u.prefix4.s_addr; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) - if (listcount(area->area_addrs) > 0) + frr_each (isis_area_list, &isis->area_list, area) + if (iso_address_list_count(&area->area_addrs) > 0) lsp_regenerate_schedule(area, area->is_type, 0); return 0; @@ -686,7 +685,6 @@ static void request_srv6_sids(struct isis_area *area) { struct srv6_sid_ctx ctx = {}; struct in6_addr sid_value = {}; - struct listnode *node; struct isis_adjacency *adj; bool ret; @@ -706,7 +704,7 @@ static void request_srv6_sids(struct isis_area *area) } /* Create SRv6 End.X SIDs from existing IS-IS Adjacencies */ - for (ALL_LIST_ELEMENTS_RO(area->adjacency_list, node, adj)) { + frr_each (isis_area_adj_list, &area->adjacency_list, adj) { if (adj->ll_ipv6_count > 0) isis_zebra_request_srv6_sid_endx(adj); } @@ -1190,7 +1188,6 @@ static int isis_zebra_process_srv6_locator_internal(struct srv6_locator *locator { struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); struct isis_area *area; - struct listnode *node; if (!isis || !locator) return -1; @@ -1201,7 +1198,7 @@ static int isis_zebra_process_srv6_locator_internal(struct srv6_locator *locator locator->function_bits_length, locator->argument_bits_length); /* Walk through all areas of the ISIS instance */ - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { /* * Check if the IS-IS area is configured to use the received * locator @@ -1279,7 +1276,7 @@ static int isis_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS) loc.argument_bits_length); /* Walk through all areas of the ISIS instance */ - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { if (strncmp(area->srv6db.config.srv6_locator_name, loc.name, sizeof(area->srv6db.config.srv6_locator_name)) != 0) continue; @@ -1444,7 +1441,7 @@ static int isis_zebra_srv6_sid_notify(ZAPI_CALLBACK_ARGS) enum zapi_srv6_sid_notify note; uint32_t sid_func; struct isis_area *area; - struct listnode *node, *nnode, *n; + struct listnode *node, *nnode; char buf[256]; struct srv6_locator *locator; struct prefix_ipv6 tmp_prefix; @@ -1467,7 +1464,7 @@ static int isis_zebra_srv6_sid_notify(ZAPI_CALLBACK_ARGS) __func__, srv6_sid_ctx2str(buf, sizeof(buf), &ctx), &sid_addr, sid_func, zapi_srv6_sid_notify2str(note)); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { if (!area->srv6db.config.enabled || !area->srv6db.srv6_locator) continue; @@ -1527,8 +1524,7 @@ static int isis_zebra_srv6_sid_notify(ZAPI_CALLBACK_ARGS) } else if (ctx.behavior == ZEBRA_SEG6_LOCAL_ACTION_END_X) { - for (ALL_LIST_ELEMENTS_RO(area->adjacency_list, - n, adj)) { + frr_each (isis_area_adj_list, &area->adjacency_list, adj) { /* Check if the End.X SID is for this adjacecny */ if (adj->ll_ipv6_count == 0 || memcmp(&adj->ll_ipv6_addrs[0], diff --git a/isisd/isisd.c b/isisd/isisd.c index 742b02d0c9d6..e4986bc56f86 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -154,9 +154,8 @@ void isis_vrf_unlink(struct isis *isis, struct vrf *vrf) struct isis *isis_lookup_by_vrfid(vrf_id_t vrf_id) { struct isis *isis; - struct listnode *node; - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) + frr_each (isis_instance_list, &im->isis, isis) if (isis->vrf_id == vrf_id) return isis; @@ -166,9 +165,8 @@ struct isis *isis_lookup_by_vrfid(vrf_id_t vrf_id) struct isis *isis_lookup_by_vrfname(const char *vrfname) { struct isis *isis; - struct listnode *node; - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) + frr_each (isis_instance_list, &im->isis, isis) if (isis->name && vrfname && strcmp(isis->name, vrfname) == 0) return isis; @@ -178,9 +176,8 @@ struct isis *isis_lookup_by_vrfname(const char *vrfname) struct isis *isis_lookup_by_sysid(const uint8_t *sysid) { struct isis *isis; - struct listnode *node; - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) + frr_each (isis_instance_list, &im->isis, isis) if (!memcmp(isis->sysid, sysid, ISIS_SYS_ID_LEN)) return isis; @@ -191,13 +188,13 @@ void isis_master_init(struct event_loop *mst) { memset(&isis_master, 0, sizeof(isis_master)); im = &isis_master; - im->isis = list_new(); + isis_instance_list_init(&im->isis); im->master = mst; } void isis_master_terminate(void) { - list_delete(&im->isis); + isis_instance_list_fini(&im->isis); } struct isis *isis_new(const char *vrf_name) @@ -229,12 +226,12 @@ struct isis *isis_new(const char *vrf_name) isis->max_area_addrs = ISIS_DEFAULT_MAX_AREA_ADDRESSES; isis->process_id = getpid(); isis->router_id = 0; - isis->area_list = list_new(); + isis_area_list_init(&isis->area_list); isis->uptime = time(NULL); isis->snmp_notifications = 1; dyn_cache_init(isis); - listnode_add(im->isis, isis); + isis_instance_list_add_tail(&im->isis, isis); return isis; } @@ -242,14 +239,12 @@ struct isis *isis_new(const char *vrf_name) void isis_finish(struct isis *isis) { struct isis_area *area; - struct listnode *node, *nnode; + struct vrf *vrf = NULL; - for (ALL_LIST_ELEMENTS(isis->area_list, node, nnode, area)) + frr_each_safe (isis_area_list, &isis->area_list, area) isis_area_destroy(area); - struct vrf *vrf = NULL; - - listnode_delete(im->isis, isis); + isis_instance_list_del(&im->isis, isis); isis_zebra_vrf_deregister(isis); @@ -259,7 +254,7 @@ void isis_finish(struct isis *isis) XFREE(MTYPE_ISIS_NAME, isis->name); isis_redist_free(isis); - list_delete(&isis->area_list); + isis_area_list_fini(&isis->area_list); dyn_cache_finish(isis); XFREE(MTYPE_ISIS, isis); } @@ -322,7 +317,7 @@ struct isis_area *isis_area_create(const char *area_tag, const char *vrf_name) if (isis == NULL) isis = isis_new(vrf_name); - listnode_add(isis->area_list, area); + isis_area_list_add_tail(&isis->area_list, area); area->isis = isis; /* @@ -351,10 +346,9 @@ struct isis_area *isis_area_create(const char *area_tag, const char *vrf_name) spftree_area_init(area); - area->circuit_list = list_new(); - area->adjacency_list = list_new(); - area->area_addrs = list_new(); - area->area_addrs->del = isis_area_address_delete; + isis_circuit_list_init(&area->circuit_list); + isis_area_adj_list_init(&area->adjacency_list); + iso_address_list_init(&area->area_addrs); if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) event_add_timer(master, lsp_tick, area, 1, &area->t_tick); @@ -462,14 +456,13 @@ struct isis_area *isis_area_lookup_by_vrf(const char *area_tag, const char *vrf_name) { struct isis_area *area; - struct listnode *node; struct isis *isis = NULL; isis = isis_lookup_by_vrfname(vrf_name); if (isis == NULL) return NULL; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) + frr_each (isis_area_list, &isis->area_list, area) if (strcmp(area->area_tag, area_tag) == 0) return area; @@ -479,14 +472,13 @@ struct isis_area *isis_area_lookup_by_vrf(const char *area_tag, struct isis_area *isis_area_lookup(const char *area_tag, vrf_id_t vrf_id) { struct isis_area *area; - struct listnode *node; struct isis *isis; isis = isis_lookup_by_vrfid(vrf_id); if (isis == NULL) return NULL; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) + frr_each (isis_area_list, &isis->area_list, area) if ((area->area_tag == NULL && area_tag == NULL) || (area->area_tag && area_tag && strcmp(area->area_tag, area_tag) == 0)) @@ -498,7 +490,6 @@ struct isis_area *isis_area_lookup(const char *area_tag, vrf_id_t vrf_id) struct isis_area *isis_area_lookup_by_sysid(const uint8_t *sysid) { struct isis_area *area; - struct listnode *node; struct isis *isis; struct iso_address *addr = NULL; @@ -506,14 +497,14 @@ struct isis_area *isis_area_lookup_by_sysid(const uint8_t *sysid) if (isis == NULL) return NULL; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { - if (listcount(area->area_addrs) > 0) { - addr = listgetdata(listhead(area->area_addrs)); + frr_each (isis_area_list, &isis->area_list, area) { + addr = iso_address_list_first(&area->area_addrs); + if (addr != NULL) { if (!memcmp(addr->area_addr + addr->addr_len, sysid, ISIS_SYS_ID_LEN)) return area; - } } + } return NULL; } @@ -541,7 +532,6 @@ int isis_area_get(struct vty *vty, const char *area_tag) void isis_area_destroy(struct isis_area *area) { - struct listnode *node, *nnode; struct isis_circuit *circuit; struct iso_address *addr; @@ -550,20 +540,33 @@ void isis_area_destroy(struct isis_area *area) if (fabricd) fabricd_finish(area->fabricd); - if (area->circuit_list) { - for (ALL_LIST_ELEMENTS(area->circuit_list, node, nnode, - circuit)) - isis_area_del_circuit(area, circuit); + /* + * Must destroy LSP database before circuit list, because lsp_destroy + * iterates over circuit_list to remove LSPs from tx queues. + */ + lsp_db_fini(&area->lspdb[0]); + lsp_db_fini(&area->lspdb[1]); + + /* + * Must terminate SR before MPLS-TE, because SR adj_sids reference + * structures inside circuit->ext which isis_mpls_te_term frees. + * isis_sr_area_term also disables SR, so adj state change hooks + * during circuit cleanup won't try to access freed memory. + */ + isis_sr_area_term(area); + isis_srv6_area_term(area); + + isis_mpls_te_term(area); + + frr_each_safe (isis_circuit_list, &area->circuit_list, circuit) + isis_area_del_circuit(area, circuit); + + isis_circuit_list_fini(&area->circuit_list); - list_delete(&area->circuit_list); - } if (area->flags.free_idcs) list_delete(&area->flags.free_idcs); - list_delete(&area->adjacency_list); - - lsp_db_fini(&area->lspdb[0]); - lsp_db_fini(&area->lspdb[1]); + isis_area_adj_list_fini(&area->adjacency_list); /* invalidate and verify to delete all routes from zebra */ isis_area_invalidate_routes(area, area->is_type); @@ -573,11 +576,6 @@ void isis_area_destroy(struct isis_area *area) flex_algos_free(area->flex_algos); #endif /* ifndef FABRICD */ - isis_sr_area_term(area); - isis_srv6_area_term(area); - - isis_mpls_te_term(area); - spftree_area_del(area); if (area->spf_timer[0]) @@ -593,8 +591,8 @@ void isis_area_destroy(struct isis_area *area) if (!CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) isis_redist_area_finish(area); - if (listcount(area->area_addrs) > 0) { - addr = listgetdata(listhead(area->area_addrs)); + addr = iso_address_list_first(&area->area_addrs); + if (addr != NULL) { if (!memcmp(addr->area_addr + addr->addr_len, area->isis->sysid, ISIS_SYS_ID_LEN)) { memset(area->isis->sysid, 0, ISIS_SYS_ID_LEN); @@ -602,7 +600,9 @@ void isis_area_destroy(struct isis_area *area) } } - list_delete(&area->area_addrs); + while ((addr = iso_address_list_pop(&area->area_addrs))) + XFREE(MTYPE_ISIS_AREA_ADDR, addr); + iso_address_list_fini(&area->area_addrs); for (int i = SPF_PREFIX_PRIO_CRITICAL; i <= SPF_PREFIX_PRIO_MEDIUM; i++) { @@ -621,7 +621,7 @@ void isis_area_destroy(struct isis_area *area) event_cancel_event(master, area); - listnode_delete(area->isis->area_list, area); + isis_area_list_del(&area->isis->area_list, area); free(area->area_tag); @@ -658,14 +658,14 @@ static int isis_vrf_delete(struct vrf *vrf) static void isis_set_redist_vrf_bitmaps(struct isis *isis, bool set) { - struct listnode *node, *lnode; + struct listnode *lnode; struct isis_area *area; int type; int level; int protocol; struct isis_redist *redist; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) + frr_each (isis_area_list, &isis->area_list, area) for (protocol = 0; protocol < REDIST_PROTOCOL_COUNT; protocol++) for (type = 0; type < ZEBRA_ROUTE_MAX + 1; type++) for (level = 0; level < ISIS_LEVELS; level++) { @@ -789,14 +789,13 @@ void isis_vrf_init(void) void isis_terminate(void) { struct isis *isis; - struct listnode *node, *nnode; bfd_protocol_integration_set_shutdown(true); - if (listcount(im->isis) == 0) + if (isis_instance_list_count(&im->isis) == 0) return; - for (ALL_LIST_ELEMENTS(im->isis, node, nnode, isis)) + frr_each_safe (isis_instance_list, &im->isis, isis) isis_finish(isis); } @@ -804,10 +803,9 @@ void isis_filter_update(struct access_list *access) { struct isis *isis; struct isis_area *area; - struct listnode *node, *anode; - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, area) { for (int i = SPF_PREFIX_PRIO_CRITICAL; i <= SPF_PREFIX_PRIO_MEDIUM; i++) { struct spf_prefix_priority_acl *ppa; @@ -827,10 +825,9 @@ void isis_prefix_list_update(struct prefix_list *plist) { struct isis *isis; struct isis_area *area; - struct listnode *node, *anode; - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, area) { for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { const char *plist_name = @@ -884,12 +881,11 @@ int area_net_title(struct vty *vty, const char *net_title) VTY_DECLVAR_CONTEXT(isis_area, area); struct iso_address *addr; struct iso_address *addrp; - struct listnode *node; uint8_t buff[255]; /* We check that we are not over the maximal number of addresses */ - if (listcount(area->area_addrs) >= area->isis->max_area_addrs) { + if (iso_address_list_count(&area->area_addrs) >= area->isis->max_area_addrs) { vty_out(vty, "Maximum of area addresses (%d) already reached \n", area->isis->max_area_addrs); @@ -940,7 +936,7 @@ int area_net_title(struct vty *vty, const char *net_title) } /* now we see that we don't already have this address */ - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) { + frr_each (iso_address_list, &area->area_addrs, addrp) { if ((addrp->addr_len + ISIS_SYS_ID_LEN + ISIS_NSEL_LEN) != (addr->addr_len)) continue; @@ -956,10 +952,10 @@ int area_net_title(struct vty *vty, const char *net_title) * Forget the systemID part of the address */ addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN); - listnode_add(area->area_addrs, addr); + iso_address_list_add_tail(&area->area_addrs, addr); /* only now we can safely generate our LSPs for this area */ - if (listcount(area->area_addrs) > 0) { + if (iso_address_list_count(&area->area_addrs) > 0) { if (area->is_type & IS_LEVEL_1) lsp_generate(area, IS_LEVEL_1); if (area->is_type & IS_LEVEL_2) @@ -973,7 +969,6 @@ int area_clear_net_title(struct vty *vty, const char *net_title) { VTY_DECLVAR_CONTEXT(isis_area, area); struct iso_address addr, *addrp = NULL; - struct listnode *node; uint8_t buff[255]; addr.addr_len = dotformat2buff(buff, net_title); @@ -986,7 +981,7 @@ int area_clear_net_title(struct vty *vty, const char *net_title) memcpy(addr.area_addr, buff, (int)addr.addr_len); - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node, addrp)) + frr_each (iso_address_list, &area->area_addrs, addrp) if ((addrp->addr_len + ISIS_SYS_ID_LEN + 1) == addr.addr_len && !memcmp(addrp->area_addr, addr.area_addr, addr.addr_len)) break; @@ -997,13 +992,13 @@ int area_clear_net_title(struct vty *vty, const char *net_title) return CMD_ERR_NO_MATCH; } - listnode_delete(area->area_addrs, addrp); + iso_address_list_del(&area->area_addrs, addrp); XFREE(MTYPE_ISIS_AREA_ADDR, addrp); /* * Last area address - reset the SystemID for this router */ - if (listcount(area->area_addrs) == 0) { + if (iso_address_list_count(&area->area_addrs) == 0) { memset(area->isis->sysid, 0, ISIS_SYS_ID_LEN); area->isis->sysid_set = 0; if (IS_DEBUG_EVENTS) @@ -1033,7 +1028,6 @@ int show_isis_interface_common_json(struct json_object *json, const char *ifname, char detail, const char *vrf_name, bool all_vrf) { - struct listnode *anode, *cnode, *inode; struct isis_area *area; struct isis_circuit *circuit; struct isis *isis; @@ -1047,10 +1041,10 @@ int show_isis_interface_common_json(struct json_object *json, } if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { + frr_each (isis_instance_list, &im->isis, 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)) { + frr_each (isis_area_list, &isis->area_list, area) { area_json = json_object_new_object(); json_object_string_add(area_json, "area", area->area_tag @@ -1059,8 +1053,7 @@ int show_isis_interface_common_json(struct json_object *json, 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)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { circuit_json = json_object_new_object(); json_object_int_add( circuit_json, "circuit", @@ -1086,7 +1079,7 @@ int show_isis_interface_common_json(struct json_object *json, 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)) { + frr_each (isis_area_list, &isis->area_list, area) { area_json = json_object_new_object(); json_object_string_add(area_json, "area", area->area_tag ? area->area_tag @@ -1095,8 +1088,7 @@ int show_isis_interface_common_json(struct json_object *json, 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)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { circuit_json = json_object_new_object(); json_object_int_add(circuit_json, "circuit", circuit->circuit_id); @@ -1123,7 +1115,6 @@ int show_isis_interface_common_vty(struct vty *vty, const char *ifname, char detail, const char *vrf_name, bool all_vrf) { - struct listnode *anode, *cnode, *inode; struct isis_area *area; struct isis_circuit *circuit; struct isis *isis; @@ -1134,16 +1125,15 @@ int show_isis_interface_common_vty(struct vty *vty, const char *ifname, } if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, 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)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) if (!ifname) isis_circuit_print_vty(circuit, vty, @@ -1159,15 +1149,14 @@ int show_isis_interface_common_vty(struct vty *vty, const char *ifname, } isis = isis_lookup_by_vrfname(vrf_name); if (isis != NULL) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_area_list, &isis->area_list, 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)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) if (!ifname) isis_circuit_print_vty(circuit, vty, detail); @@ -1290,7 +1279,7 @@ static void isis_neighbor_common_json(struct json_object *json, const char *id, char detail, struct isis *isis, uint8_t *sysid) { - struct listnode *anode, *cnode, *node; + struct listnode *node; struct isis_area *area; struct isis_circuit *circuit; struct list *adjdb; @@ -1301,14 +1290,14 @@ static void isis_neighbor_common_json(struct json_object *json, const char *id, areas_json = json_object_new_array(); json_object_object_add(json, "areas", areas_json); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_area_list, &isis->area_list, 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)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { circuit_json = json_object_new_object(); json_object_int_add(circuit_json, "circuit", circuit->circuit_id); @@ -1346,21 +1335,21 @@ static void isis_neighbor_common_vty(struct vty *vty, const char *id, char detail, struct isis *isis, uint8_t *sysid) { - struct listnode *anode, *cnode, *node; + struct listnode *node; struct isis_area *area; struct isis_circuit *circuit; struct list *adjdb; struct isis_adjacency *adj; int i; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { + frr_each (isis_area_list, &isis->area_list, area) { vty_out(vty, "Area %s:\n", area->area_tag); if (detail == ISIS_UI_LEVEL_BRIEF) vty_out(vty, " System Id Interface L State Holdtime SNPA\n"); - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { if (circuit->circ_type == CIRCUIT_T_BROADCAST) { for (i = 0; i < 2; i++) { adjdb = circuit->u.bc.adjdb[i]; @@ -1407,7 +1396,6 @@ int show_isis_neighbor_common(struct vty *vty, struct json_object *json, const char *id, char detail, const char *vrf_name, bool all_vrf) { - struct listnode *node; uint8_t sysid[ISIS_SYS_ID_LEN]; struct isis *isis; @@ -1417,7 +1405,7 @@ int show_isis_neighbor_common(struct vty *vty, struct json_object *json, } if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { + frr_each (isis_instance_list, &im->isis, isis) { if (id_to_sysid(isis, id, sysid)) { vty_out(vty, "Invalid system id %s\n", id); return CMD_SUCCESS; @@ -1441,15 +1429,15 @@ int show_isis_neighbor_common(struct vty *vty, struct json_object *json, static void isis_neighbor_common_clear(struct vty *vty, const char *id, uint8_t *sysid, struct isis *isis) { - struct listnode *anode, *cnode, *node, *nnode; + struct listnode *node, *nnode; struct isis_area *area; struct isis_circuit *circuit; struct list *adjdb; struct isis_adjacency *adj; int i; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, anode, area)) { - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) { + frr_each (isis_area_list, &isis->area_list, area) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { if (circuit->circ_type == CIRCUIT_T_BROADCAST) { for (i = 0; i < 2; i++) { adjdb = circuit->u.bc.adjdb[i]; @@ -1487,7 +1475,6 @@ static void isis_neighbor_common_clear(struct vty *vty, const char *id, int clear_isis_neighbor_common(struct vty *vty, const char *id, const char *vrf_name, bool all_vrf) { - struct listnode *node; uint8_t sysid[ISIS_SYS_ID_LEN]; struct isis *isis; @@ -1497,7 +1484,7 @@ int clear_isis_neighbor_common(struct vty *vty, const char *id, const char *vrf_ } if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { + frr_each (isis_instance_list, &im->isis, isis) { if (id_to_sysid(isis, id, sysid)) { vty_out(vty, "Invalid system id %s\n", id); return CMD_SUCCESS; @@ -2266,7 +2253,6 @@ DEFUN (show_hostname, "All VRFs\n" "IS-IS Dynamic hostname mapping\n") { - struct listnode *node; const char *vrf_name = VRF_DEFAULT_NAME; bool all_vrf = false; int idx_vrf = 0; @@ -2275,7 +2261,7 @@ DEFUN (show_hostname, ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf); if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) + frr_each (isis_instance_list, &im->isis, isis) dynhn_print_all(vty, isis); return CMD_SUCCESS; @@ -2289,10 +2275,9 @@ DEFUN (show_hostname, static void isis_spf_ietf_common(struct vty *vty, struct isis *isis) { - struct listnode *node; struct isis_area *area; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { vty_out(vty, "vrf : %s\n", isis->name); vty_out(vty, "Area %s:\n", area->area_tag ? area->area_tag : "null"); @@ -2332,7 +2317,6 @@ DEFUN(show_isis_spf_ietf, show_isis_spf_ietf_cmd, "All VRFs\n" "SPF delay IETF information\n") { - struct listnode *node; struct isis *isis; int idx_vrf = 0; const char *vrf_name = VRF_DEFAULT_NAME; @@ -2346,7 +2330,7 @@ DEFUN(show_isis_spf_ietf, show_isis_spf_ietf_cmd, } if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) + frr_each (isis_instance_list, &im->isis, isis) isis_spf_ietf_common(vty, isis); return CMD_SUCCESS; @@ -2396,7 +2380,6 @@ static void common_isis_summary_json(struct json_object *json, int level; json_object *vrf_json, *areas_json, *area_json, *tx_pdu_json, *rx_pdu_json, *levels_json, *level_json; - struct listnode *node, *node2; struct isis_area *area; time_t cur; char uptime[MONOTIME_STRLEN]; @@ -2412,11 +2395,10 @@ static void common_isis_summary_json(struct json_object *json, cur -= isis->uptime; frrtime_to_interval(cur, uptime, sizeof(uptime)); json_object_string_add(vrf_json, "up-time", uptime); - if (isis->area_list) - json_object_int_add(vrf_json, "number-areas", isis->area_list->count); + json_object_int_add(vrf_json, "number-areas", isis_area_list_count(&isis->area_list)); areas_json = json_object_new_array(); json_object_object_add(vrf_json, "areas", areas_json); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { area_json = json_object_new_object(); json_object_string_add(area_json, "area", area->area_tag ? area->area_tag @@ -2431,10 +2413,9 @@ static void common_isis_summary_json(struct json_object *json, : stier); } - if (listcount(area->area_addrs) > 0) { + { struct iso_address *area_addr; - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2, - area_addr)) + frr_each (iso_address_list, &area->area_addrs, area_addr) json_object_string_addf(area_json, "net", "%pISl", area_addr); } @@ -2503,7 +2484,6 @@ static void common_isis_summary_json(struct json_object *json, static void common_isis_summary_vty(struct vty *vty, struct isis *isis) { - struct listnode *node, *node2; struct isis_area *area; int level; @@ -2516,10 +2496,9 @@ static void common_isis_summary_vty(struct vty *vty, struct isis *isis) vty_out_timestr(vty, isis->uptime); vty_out(vty, "\n"); - if (isis->area_list) - vty_out(vty, "Number of areas : %d\n", isis->area_list->count); + vty_out(vty, "Number of areas : %zu\n", isis_area_list_count(&isis->area_list)); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { vty_out(vty, "Area %s:\n", area->area_tag ? area->area_tag : "null"); @@ -2531,10 +2510,9 @@ static void common_isis_summary_vty(struct vty *vty, struct isis *isis) vty_out(vty, " Tier: %hhu\n", tier); } - if (listcount(area->area_addrs) > 0) { + if (iso_address_list_count(&area->area_addrs) > 0) { struct iso_address *area_addr; - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, node2, - area_addr)) + frr_each (iso_address_list, &area->area_addrs, area_addr) vty_out(vty, " Net: %pISl\n", area_addr); } @@ -2604,11 +2582,10 @@ static void common_isis_summary_vty(struct vty *vty, struct isis *isis) static void common_isis_summary(struct vty *vty, struct json_object *json, const char *vrf_name, bool all_vrf) { - struct listnode *node; struct isis *isis; if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) { + frr_each (isis_instance_list, &im->isis, isis) { if (json) common_isis_summary_json(json, isis); else @@ -2800,17 +2777,16 @@ void show_isis_database_lspdb_vty(struct vty *vty, struct isis_area *area, static void show_isis_database_json(struct json_object *json, const char *sysid_str, int ui_level, struct isis *isis) { - struct listnode *node; struct isis_area *area; int level; struct json_object *tag_area_json,*area_json, *lsp_json, *area_arr_json, *arr_json; - if (isis->area_list->count == 0) + if (isis_area_list_count(&isis->area_list) == 0) return; area_arr_json = json_object_new_array(); json_object_object_add(json, "areas", area_arr_json); - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { area_json = json_object_new_object(); tag_area_json = json_object_new_object(); json_object_string_add(tag_area_json, "name", @@ -2836,14 +2812,13 @@ static void show_isis_database_json(struct json_object *json, const char *sysid_ static void show_isis_database_vty(struct vty *vty, const char *sysid_str, int ui_level, struct isis *isis) { - struct listnode *node; struct isis_area *area; int level; - if (isis->area_list->count == 0) + if (isis_area_list_count(&isis->area_list) == 0) return; - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_area_list, &isis->area_list, area) { vty_out(vty, "Area %s:\n", area->area_tag ? area->area_tag : "null"); @@ -2883,11 +2858,10 @@ static void show_isis_database_common(struct vty *vty, struct json_object *json, static int show_isis_database(struct vty *vty, struct json_object *json, const char *sysid_str, int ui_level, const char *vrf_name, bool all_vrf) { - struct listnode *node; struct isis *isis; if (all_vrf) { - for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) + frr_each (isis_instance_list, &im->isis, isis) show_isis_database_common(vty, json, sysid_str, ui_level, isis); @@ -3230,7 +3204,6 @@ static void area_resign_level(struct isis_area *area, int level) void isis_area_is_type_set(struct isis_area *area, int is_type) { - struct listnode *node; struct isis_circuit *circuit; if (IS_DEBUG_EVENTS) @@ -3274,16 +3247,16 @@ void isis_area_is_type_set(struct isis_area *area, int is_type) * IS type. Otherwise use circuit's configured IS type. */ if (area->is_type != IS_LEVEL_1_AND_2) { - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) isis_circuit_is_type_set(circuit, is_type); } else { - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) + frr_each (isis_circuit_list, &area->circuit_list, circuit) isis_circuit_is_type_set(circuit, circuit->is_type_config); } spftree_area_init(area); - if (listcount(area->area_addrs) > 0) { + if (iso_address_list_count(&area->area_addrs) > 0) { if (is_type & IS_LEVEL_1) lsp_generate(area, IS_LEVEL_1); if (is_type & IS_LEVEL_2) @@ -3340,7 +3313,7 @@ void isis_area_overload_on_startup_set(struct isis_area *area, void config_end_lsp_generate(struct isis_area *area) { - if (listcount(area->area_addrs) > 0) { + if (iso_address_list_count(&area->area_addrs) > 0) { if (CHECK_FLAG(area->is_type, IS_LEVEL_1)) lsp_generate(area, IS_LEVEL_1); if (CHECK_FLAG(area->is_type, IS_LEVEL_2)) @@ -3351,7 +3324,6 @@ void config_end_lsp_generate(struct isis_area *area) void isis_area_advertise_high_metrics_set(struct isis_area *area, bool advertise_high_metrics) { - struct listnode *node; struct isis_circuit *circuit; int max_metric; char xpath[XPATH_MAXLEN]; @@ -3370,7 +3342,7 @@ void isis_area_advertise_high_metrics_set(struct isis_area *area, else max_metric = MAX_NARROW_LINK_METRIC; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { isis_circuit_metric_set(circuit, IS_LEVEL_1, max_metric); isis_circuit_metric_set(circuit, IS_LEVEL_2, @@ -3380,7 +3352,7 @@ void isis_area_advertise_high_metrics_set(struct isis_area *area, area->advertise_high_metrics = true; } else { area->advertise_high_metrics = false; - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + frr_each (isis_circuit_list, &area->circuit_list, circuit) { /* Get configured metric */ snprintf(xpath, XPATH_MAXLEN, "/frr-interface:lib/interface[name='%s']", @@ -3556,7 +3528,6 @@ static int isis_config_write(struct vty *vty) { int write = 0; struct isis_area *area; - struct listnode *node, *node2, *inode; struct isis *isis; if (!im) { @@ -3564,16 +3535,15 @@ static int isis_config_write(struct vty *vty) return CMD_SUCCESS; } - for (ALL_LIST_ELEMENTS_RO(im->isis, inode, isis)) { - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { + frr_each (isis_instance_list, &im->isis, isis) { + frr_each (isis_area_list, &isis->area_list, area) { /* ISIS - Area name */ vty_out(vty, "router " PROTO_NAME " %s\n", area->area_tag); write++; /* ISIS - Net */ - if (listcount(area->area_addrs) > 0) { + if (iso_address_list_count(&area->area_addrs) > 0) { struct iso_address *area_addr; - for (ALL_LIST_ELEMENTS_RO(area->area_addrs, - node2, area_addr)) { + frr_each (iso_address_list, &area->area_addrs, area_addr) { vty_out(vty, " net %pISl\n", area_addr); write++; } diff --git a/isisd/isisd.h b/isisd/isisd.h index 1415fe9fb75f..62363151585c 100644 --- a/isisd/isisd.h +++ b/isisd/isisd.h @@ -12,6 +12,7 @@ #include "vty.h" #include "memory.h" +#include "typesafe.h" #include "isisd/isis_constants.h" #include "isisd/isis_common.h" @@ -29,6 +30,11 @@ DECLARE_MGROUP(ISISD); +/* Typesafe list declarations */ +PREDECL_DLIST(isis_instance_list); +PREDECL_DLIST(isis_area_list); +PREDECL_DLIST(isis_area_adj_list); + #ifdef FABRICD static const bool fabricd = true; #define PROTO_TYPE ZEBRA_ROUTE_OPENFABRIC @@ -74,7 +80,7 @@ struct fabricd; struct isis_master { /* ISIS instance. */ - struct list *isis; + struct isis_instance_list_head isis; /* ISIS thread master. */ struct event_loop *master; /* Various global options */ @@ -92,7 +98,7 @@ struct isis { int sysid_set; uint8_t sysid[ISIS_SYS_ID_LEN]; /* SystemID for this IS */ uint32_t router_id; /* Router ID from zebra */ - struct list *area_list; /* list of IS-IS areas */ + struct isis_area_list_head area_list; /* list of IS-IS areas */ uint8_t max_area_addrs; /* maximumAreaAdresses */ struct iso_address *man_area_addrs; /* manualAreaAddresses */ time_t uptime; /* when did we start */ @@ -102,8 +108,14 @@ struct isis { struct list *dyn_cache; struct route_table *ext_info[REDIST_PROTOCOL_COUNT]; + + /* Typesafe list membership for im->isis */ + struct isis_instance_list_item instance_list_item; }; +/* Typesafe list definition for instance_list */ +DECLARE_DLIST(isis_instance_list, struct isis, instance_list_item); + extern struct isis_master *im; extern struct event *t_isis_cfg; @@ -133,8 +145,8 @@ struct isis_area { struct isis_spftree *spftree[SPFTREE_COUNT][ISIS_LEVELS]; #define DEFAULT_LSP_MTU 1497 unsigned int lsp_mtu; /* Size of LSPs to generate */ - struct list *circuit_list; /* IS-IS circuits */ - struct list *adjacency_list; /* IS-IS adjacencies */ + struct isis_circuit_list_head circuit_list; /* IS-IS circuits */ + struct isis_area_adj_list_head adjacency_list; /* IS-IS adjacencies */ struct flags flags; struct event *t_tick; /* LSP walker */ struct event *t_lsp_refresh[ISIS_LEVELS]; @@ -176,7 +188,7 @@ struct isis_area { /* identifies the routing instance */ char *area_tag; /* area addresses for this area */ - struct list *area_addrs; + struct iso_address_list_head area_addrs; uint16_t max_lsp_lifetime[ISIS_LEVELS]; char is_type; /* level-1 level-1-2 or level-2-only */ /* are we overloaded? */ @@ -261,10 +273,16 @@ struct isis_area { uint64_t id_len_mismatches[2]; uint64_t lsp_error_counter[2]; + /* Typesafe list membership for isis->area_list */ + struct isis_area_list_item area_list_item; + QOBJ_FIELDS; }; DECLARE_QOBJ_TYPE(isis_area); +/* Typesafe list definition for area_list */ +DECLARE_DLIST(isis_area_list, struct isis_area, area_list_item); + DECLARE_MTYPE(ISIS_ACL_NAME); /* isis_area->spf_prefix_prioritites */ DECLARE_MTYPE(ISIS_AREA_ADDR); /* isis_area->area_addrs */ DECLARE_MTYPE(ISIS_PLIST_NAME); diff --git a/lib/flex_algo.h b/lib/flex_algo.h index cb46f0cfb0e5..b1558bab544e 100644 --- a/lib/flex_algo.h +++ b/lib/flex_algo.h @@ -79,8 +79,8 @@ struct flex_algo { /* which dataplane must be used for the algorithm */ #define FLEX_ALGO_SR_MPLS 0x01 -#define FLEX_ALGO_SRV6 0x02 -#define FLEX_ALGO_IP 0x04 +#define FLEX_ALGO_SRV6 0x02 +#define FLEX_ALGO_IP 0x04 uint8_t dataplanes; /* True if the Algorithm is locally enabled (ie. a definition has been @@ -110,14 +110,11 @@ struct flex_algos { /* * Flex-Algo Utilities */ -struct flex_algos *flex_algos_alloc(flex_algo_allocator_t allocator, - flex_algo_releaser_t releaser); +struct flex_algos *flex_algos_alloc(flex_algo_allocator_t allocator, flex_algo_releaser_t releaser); void flex_algos_free(struct flex_algos *flex_algos); -struct flex_algo *flex_algo_alloc(struct flex_algos *flex_algos, - uint8_t algorithm, void *arg); +struct flex_algo *flex_algo_alloc(struct flex_algos *flex_algos, uint8_t algorithm, void *arg); void flex_algo_free(struct flex_algos *flex_algos, struct flex_algo *fa); -struct flex_algo *flex_algo_lookup(struct flex_algos *flex_algos, - uint8_t algorithm); +struct flex_algo *flex_algo_lookup(struct flex_algos *flex_algos, uint8_t algorithm); bool flex_algo_definition_cmp(struct flex_algo *fa1, struct flex_algo *fa2); bool flex_algo_id_valid(uint16_t algorithm); char *flex_algo_metric_type_print(char *type_str, size_t sz, @@ -125,6 +122,5 @@ char *flex_algo_metric_type_print(char *type_str, size_t sz, bool flex_algo_get_state(struct flex_algos *flex_algos, uint8_t algorithm); -void flex_algo_set_state(struct flex_algos *flex_algos, uint8_t algorithm, - bool state); +void flex_algo_set_state(struct flex_algos *flex_algos, uint8_t algorithm, bool state); #endif /* _FRR_FLEX_ALGO_H */ diff --git a/lib/iso.h b/lib/iso.h index bdc9d3903140..8e9df8cee656 100644 --- a/lib/iso.h +++ b/lib/iso.h @@ -11,16 +11,26 @@ #define LIB_ISO_H_ #include "compiler.h" +#include "typesafe.h" /* len of "xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx" + '\0' */ #define ISO_ADDR_STRLEN 51 #define ISO_ADDR_MIN 8 #define ISO_ADDR_SIZE 20 + +/* Predeclare typesafe list for isis_area->area_addrs */ +PREDECL_DLIST(iso_address_list); + struct iso_address { uint8_t addr_len; uint8_t area_addr[ISO_ADDR_SIZE]; + + /* Typesafe list linkage for isis_area->area_addrs */ + struct iso_address_list_item item; }; +DECLARE_DLIST(iso_address_list, struct iso_address, item); + /* len of "xxxx.xxxx.xxxx.xx-xx" + '\0' */ #define ISO_SYSID_STRLEN 21 diff --git a/lib/typesafe.h b/lib/typesafe.h index 9e07cfc785c0..686cf49133f9 100644 --- a/lib/typesafe.h +++ b/lib/typesafe.h @@ -438,7 +438,7 @@ macro_inline type *prefix ## _del(struct prefix##_head *h, type *item) \ macro_inline type *prefix ## _pop(struct prefix##_head *h) \ { \ struct dlist_item *ditem = h->dh.hitem.next; \ - if (ditem == &h->dh.hitem) \ + if (!ditem || ditem == &h->dh.hitem) \ return NULL; \ ditem->prev->next = ditem->next; \ ditem->next->prev = ditem->prev; \ diff --git a/tests/isisd/test_common.c b/tests/isisd/test_common.c index 2f779b6047a0..674eaa611c11 100644 --- a/tests/isisd/test_common.c +++ b/tests/isisd/test_common.c @@ -20,20 +20,18 @@ int isis_sock_init(struct isis_circuit *circuit) return 0; } -const struct isis_test_node * -test_topology_find_node(const struct isis_topology *topology, - const char *hostname, uint8_t pseudonode_id) +const struct isis_test_node *test_topology_find_node(const struct isis_topology *topology, + const char *hostname, uint8_t pseudonode_id) { for (size_t i = 0; topology->nodes[i].hostname[0]; i++) - if (strmatch(hostname, topology->nodes[i].hostname) - && pseudonode_id == topology->nodes[i].pseudonode_id) + if (strmatch(hostname, topology->nodes[i].hostname) && + pseudonode_id == topology->nodes[i].pseudonode_id) return &topology->nodes[i]; return NULL; } -const struct isis_topology * -test_topology_find(struct isis_topology *topologies, uint16_t number) +const struct isis_topology *test_topology_find(struct isis_topology *topologies, uint16_t number) { for (size_t i = 0; topologies[i].number; i++) if (topologies[i].number == number) @@ -42,8 +40,8 @@ test_topology_find(struct isis_topology *topologies, uint16_t number) return NULL; } -static const struct isis_test_node * -test_find_adjacency(const struct isis_test_node *tnode, const char *hostname) +static const struct isis_test_node *test_find_adjacency(const struct isis_test_node *tnode, + const char *hostname) { for (size_t i = 0; tnode->adjacencies[i].hostname[0]; i++) { const struct isis_test_adj *tadj; @@ -74,8 +72,7 @@ mpls_label_t test_topology_node_ldp_label(const struct isis_topology *topology, return MPLS_INVALID_LABEL; } -static struct isis_lsp *lsp_add(struct lspdb_head *lspdb, - struct isis_area *area, int level, +static struct isis_lsp *lsp_add(struct lspdb_head *lspdb, struct isis_area *area, int level, const uint8_t *sysid, uint8_t pseudonode_id) { struct isis_lsp *lsp; @@ -92,13 +89,12 @@ static struct isis_lsp *lsp_add(struct lspdb_head *lspdb, return lsp; } -static void lsp_add_ip_reach(struct isis_lsp *lsp, - const struct isis_test_node *tnode, +static void lsp_add_ip_reach(struct isis_lsp *lsp, const struct isis_test_node *tnode, const char *prefix_str, uint32_t *next_sid_index) { struct prefix prefix; struct sr_prefix_cfg pcfg = {}; - struct sr_prefix_cfg *pcfg_p[SR_ALGORITHM_COUNT] = {NULL}; + struct sr_prefix_cfg *pcfg_p[SR_ALGORITHM_COUNT] = { NULL }; if (str2prefix(prefix_str, &prefix) != 1) { zlog_debug("%s: invalid network: %s", __func__, prefix_str); @@ -116,19 +112,16 @@ static void lsp_add_ip_reach(struct isis_lsp *lsp, } if (prefix.family == AF_INET) - isis_tlvs_add_extended_ip_reach(lsp->tlvs, - (struct prefix_ipv4 *)&prefix, - 10, false, pcfg_p); + isis_tlvs_add_extended_ip_reach(lsp->tlvs, (struct prefix_ipv4 *)&prefix, 10, + false, pcfg_p); else isis_tlvs_add_ipv6_reach(lsp->tlvs, ISIS_MT_IPV6_UNICAST, - (struct prefix_ipv6 *)&prefix, 10, - false, pcfg_p); + (struct prefix_ipv6 *)&prefix, 10, false, pcfg_p); } -static void lsp_add_reach(struct isis_lsp *lsp, - const struct isis_test_node *tnode, - const uint8_t *ne_id, uint8_t pseudonode_id, - uint32_t metric, int family, mpls_label_t *next_label) +static void lsp_add_reach(struct isis_lsp *lsp, const struct isis_test_node *tnode, + const uint8_t *ne_id, uint8_t pseudonode_id, uint32_t metric, int family, + mpls_label_t *next_label) { uint8_t nodeid[ISIS_SYS_ID_LEN + 1]; uint16_t mtid; @@ -154,15 +147,13 @@ static void lsp_add_reach(struct isis_lsp *lsp, isis_tlvs_add_adj_sid(ext, adj_sid); } - mtid = (family == AF_INET) ? ISIS_MT_IPV4_UNICAST - : ISIS_MT_IPV6_UNICAST; + mtid = (family == AF_INET) ? ISIS_MT_IPV4_UNICAST : ISIS_MT_IPV6_UNICAST; isis_tlvs_add_extended_reach(lsp->tlvs, mtid, nodeid, metric, ext); isis_del_ext_subtlvs(ext); } -static void lsp_add_router_capability(struct isis_lsp *lsp, - const struct isis_test_node *tnode) +static void lsp_add_router_capability(struct isis_lsp *lsp, const struct isis_test_node *tnode) { struct isis_router_cap *cap; @@ -172,39 +163,30 @@ static void lsp_add_router_capability(struct isis_lsp *lsp, cap = isis_tlvs_init_router_capability(lsp->tlvs); if (inet_pton(AF_INET, tnode->router_id, &cap->router_id) != 1) { - zlog_debug("%s: invalid router-id: %s", __func__, - tnode->router_id); + zlog_debug("%s: invalid router-id: %s", __func__, tnode->router_id); return; } if (CHECK_FLAG(tnode->flags, F_ISIS_TEST_NODE_SR)) { - cap->srgb.flags = - ISIS_SUBTLV_SRGB_FLAG_I | ISIS_SUBTLV_SRGB_FLAG_V; - cap->srgb.lower_bound = tnode->srgb.lower_bound - ? tnode->srgb.lower_bound - : SRGB_DFTL_LOWER_BOUND; - cap->srgb.range_size = tnode->srgb.range_size - ? tnode->srgb.range_size - : SRGB_DFTL_RANGE_SIZE; + cap->srgb.flags = ISIS_SUBTLV_SRGB_FLAG_I | ISIS_SUBTLV_SRGB_FLAG_V; + cap->srgb.lower_bound = tnode->srgb.lower_bound ? tnode->srgb.lower_bound + : SRGB_DFTL_LOWER_BOUND; + cap->srgb.range_size = tnode->srgb.range_size ? tnode->srgb.range_size + : SRGB_DFTL_RANGE_SIZE; cap->algo[0] = SR_ALGORITHM_SPF; cap->algo[1] = SR_ALGORITHM_UNSET; } - } -static void lsp_add_mt_router_info(struct isis_lsp *lsp, - const struct isis_test_node *tnode) +static void lsp_add_mt_router_info(struct isis_lsp *lsp, const struct isis_test_node *tnode) { if (tnode->protocols.ipv4) - isis_tlvs_add_mt_router_info(lsp->tlvs, ISIS_MT_IPV4_UNICAST, 0, - false); + isis_tlvs_add_mt_router_info(lsp->tlvs, ISIS_MT_IPV4_UNICAST, 0, false); if (tnode->protocols.ipv6) - isis_tlvs_add_mt_router_info(lsp->tlvs, ISIS_MT_IPV6_UNICAST, 0, - false); + isis_tlvs_add_mt_router_info(lsp->tlvs, ISIS_MT_IPV6_UNICAST, 0, false); } -static void lsp_add_protocols_supported(struct isis_lsp *lsp, - const struct isis_test_node *tnode) +static void lsp_add_protocols_supported(struct isis_lsp *lsp, const struct isis_test_node *tnode) { struct nlpids nlpids = {}; @@ -223,9 +205,8 @@ static void lsp_add_protocols_supported(struct isis_lsp *lsp, } static int topology_load_node_level(const struct isis_topology *topology, - const struct isis_test_node *tnode, - size_t tnode_index, struct isis_area *area, - struct lspdb_head *lspdb, int level) + const struct isis_test_node *tnode, size_t tnode_index, + struct isis_area *area, struct lspdb_head *lspdb, int level) { struct isis_lsp *lsp; uint32_t next_sid_index = (tnode_index + 1) * 10; @@ -239,13 +220,11 @@ static int topology_load_node_level(const struct isis_topology *topology, /* Add IP Reachability Information. */ for (size_t i = 0; tnode->networks[i]; i++) { if (i > MAX_NETWORKS) { - zlog_debug( - "%s: node has too many networks (maximum is %u)", - __func__, MAX_NETWORKS); + zlog_debug("%s: node has too many networks (maximum is %u)", __func__, + MAX_NETWORKS); return -1; } - lsp_add_ip_reach(lsp, tnode, tnode->networks[i], - &next_sid_index); + lsp_add_ip_reach(lsp, tnode, tnode->networks[i], &next_sid_index); } /* Add IS Reachability Information. */ @@ -254,59 +233,51 @@ static int topology_load_node_level(const struct isis_topology *topology, const struct isis_test_node *tadj_node; if (i > MAX_ADJACENCIES) { - zlog_debug( - "%s: node has too many adjacencies (maximum is %u)", - __func__, MAX_ADJACENCIES); + zlog_debug("%s: node has too many adjacencies (maximum is %u)", __func__, + MAX_ADJACENCIES); return -1; } tadj = &tnode->adjacencies[i]; - tadj_node = test_topology_find_node(topology, tadj->hostname, - tadj->pseudonode_id); + tadj_node = test_topology_find_node(topology, tadj->hostname, tadj->pseudonode_id); if (!tadj_node) { - zlog_debug( - "%s: node \"%s\" has an adjacency with non-existing node \"%s\"", - __func__, tnode->hostname, tadj->hostname); + zlog_debug("%s: node \"%s\" has an adjacency with non-existing node \"%s\"", + __func__, tnode->hostname, tadj->hostname); return -1; } if (!test_find_adjacency(tadj_node, tnode->hostname)) { - zlog_debug( - "%s: node \"%s\" has an one-way adjacency with node \"%s\"", - __func__, tnode->hostname, tadj->hostname); + zlog_debug("%s: node \"%s\" has an one-way adjacency with node \"%s\"", + __func__, tnode->hostname, tadj->hostname); return -1; } - if (tnode->pseudonode_id || tadj_node->pseudonode_id - || (tnode->protocols.ipv4 && tadj_node->protocols.ipv4)) - lsp_add_reach(lsp, tnode, tadj_node->sysid, - tadj_node->pseudonode_id, tadj->metric, - AF_INET, &next_label); - if (tadj_node->pseudonode_id - || (tnode->protocols.ipv6 && tadj_node->protocols.ipv6)) - lsp_add_reach(lsp, tnode, tadj_node->sysid, - tadj_node->pseudonode_id, tadj->metric, - AF_INET6, &next_label); + if (tnode->pseudonode_id || tadj_node->pseudonode_id || + (tnode->protocols.ipv4 && tadj_node->protocols.ipv4)) + lsp_add_reach(lsp, tnode, tadj_node->sysid, tadj_node->pseudonode_id, + tadj->metric, AF_INET, &next_label); + if (tadj_node->pseudonode_id || + (tnode->protocols.ipv6 && tadj_node->protocols.ipv6)) + lsp_add_reach(lsp, tnode, tadj_node->sysid, tadj_node->pseudonode_id, + tadj->metric, AF_INET6, &next_label); } return 0; } static int topology_load_node(const struct isis_topology *topology, - const struct isis_test_node *tnode, - size_t tnode_index, struct isis_area *area, - struct lspdb_head lspdb[]) + const struct isis_test_node *tnode, size_t tnode_index, + struct isis_area *area, struct lspdb_head lspdb[]) { int ret; - isis_dynhn_insert(area->isis, tnode->sysid, tnode->hostname, - tnode->level); + isis_dynhn_insert(area->isis, tnode->sysid, tnode->hostname, tnode->level); for (int level = IS_LEVEL_1; level <= IS_LEVEL_2; level++) { if ((tnode->level & level) == 0) continue; - ret = topology_load_node_level(topology, tnode, tnode_index, - area, &lspdb[level - 1], level); + ret = topology_load_node_level(topology, tnode, tnode_index, area, + &lspdb[level - 1], level); if (ret != 0) return ret; } @@ -314,8 +285,8 @@ static int topology_load_node(const struct isis_topology *topology, return 0; } -int test_topology_load(const struct isis_topology *topology, - struct isis_area *area, struct lspdb_head lspdb[]) +int test_topology_load(const struct isis_topology *topology, struct isis_area *area, + struct lspdb_head lspdb[]) { for (int level = IS_LEVEL_1; level <= IS_LEVEL_2; level++) lsp_db_init(&lspdb[level - 1]); @@ -325,9 +296,8 @@ int test_topology_load(const struct isis_topology *topology, int ret; if (i > MAX_NODES) { - zlog_debug( - "%s: topology has too many nodes (maximum is %u)", - __func__, MAX_NODES); + zlog_debug("%s: topology has too many nodes (maximum is %u)", __func__, + MAX_NODES); return -1; } diff --git a/tests/isisd/test_common.h b/tests/isisd/test_common.h index f0c5493c9dee..b1667082618c 100644 --- a/tests/isisd/test_common.h +++ b/tests/isisd/test_common.h @@ -11,13 +11,13 @@ #include "isisd/isis_spf.h" #include "isisd/isis_spf_private.h" -#define MAX_HOSTNAME 16 -#define MAX_NETWORKS 8 +#define MAX_HOSTNAME 16 +#define MAX_NETWORKS 8 #define MAX_ADJACENCIES 8 -#define MAX_NODES 12 +#define MAX_NODES 12 #define SRGB_DFTL_LOWER_BOUND 16000 -#define SRGB_DFTL_RANGE_SIZE 8000 +#define SRGB_DFTL_RANGE_SIZE 8000 struct isis_test_adj { char hostname[MAX_HOSTNAME]; @@ -52,16 +52,14 @@ struct isis_topology { /* Prototypes. */ extern int isis_sock_init(struct isis_circuit *circuit); -extern const struct isis_test_node * -test_topology_find_node(const struct isis_topology *topology, - const char *hostname, uint8_t pseudonode_id); -extern const struct isis_topology * -test_topology_find(struct isis_topology *test_topologies, uint16_t number); -extern mpls_label_t -test_topology_node_ldp_label(const struct isis_topology *topology, - struct in_addr router_id); -extern int test_topology_load(const struct isis_topology *topology, - struct isis_area *area, +extern const struct isis_test_node *test_topology_find_node(const struct isis_topology *topology, + const char *hostname, + uint8_t pseudonode_id); +extern const struct isis_topology *test_topology_find(struct isis_topology *test_topologies, + uint16_t number); +extern mpls_label_t test_topology_node_ldp_label(const struct isis_topology *topology, + struct in_addr router_id); +extern int test_topology_load(const struct isis_topology *topology, struct isis_area *area, struct lspdb_head lspdb[]); /* Global variables. */ diff --git a/tests/isisd/test_isis_lspdb.c b/tests/isisd/test_isis_lspdb.c index 9be9abceb501..701988f2ca1d 100644 --- a/tests/isisd/test_isis_lspdb.c +++ b/tests/isisd/test_isis_lspdb.c @@ -84,5 +84,6 @@ int main(int argc, char **argv) struct isis *isis = NULL; isis = calloc(1, sizeof(*isis)); test_lsp_build_list_nonzero_ht(); + free(isis); return 0; } diff --git a/tests/isisd/test_isis_spf.c b/tests/isisd/test_isis_spf.c index bbafe7204ebf..e2ee911b5859 100644 --- a/tests/isisd/test_isis_spf.c +++ b/tests/isisd/test_isis_spf.c @@ -34,24 +34,22 @@ enum test_type { }; #define F_DISPLAY_LSPDB 0x01 -#define F_IPV4_ONLY 0x02 -#define F_IPV6_ONLY 0x04 -#define F_LEVEL1_ONLY 0x08 -#define F_LEVEL2_ONLY 0x10 +#define F_IPV4_ONLY 0x02 +#define F_IPV6_ONLY 0x04 +#define F_LEVEL1_ONLY 0x08 +#define F_LEVEL2_ONLY 0x10 static void test_run_spf(struct vty *vty, const struct isis_topology *topology, - const struct isis_test_node *root, - struct isis_area *area, struct lspdb_head *lspdb, - int level, int tree, bool reverse) + const struct isis_test_node *root, struct isis_area *area, + struct lspdb_head *lspdb, int level, int tree, bool reverse) { struct isis_spftree *spftree; enum spf_type spf_type; /* Run SPF. */ spf_type = reverse ? SPF_TYPE_REVERSE : SPF_TYPE_FORWARD; - spftree = isis_spftree_new(area, lspdb, root->sysid, level, tree, - spf_type, F_SPFTREE_NO_ADJACENCIES, - SR_ALGORITHM_SPF); + spftree = isis_spftree_new(area, lspdb, root->sysid, level, tree, spf_type, + F_SPFTREE_NO_ADJACENCIES, SR_ALGORITHM_SPF); isis_run_spf(spftree); /* Print the SPT and the corresponding routing table. */ @@ -63,9 +61,8 @@ static void test_run_spf(struct vty *vty, const struct isis_topology *topology, } static void test_run_lfa(struct vty *vty, const struct isis_topology *topology, - const struct isis_test_node *root, - struct isis_area *area, struct lspdb_head *lspdb, - int level, int tree, + const struct isis_test_node *root, struct isis_area *area, + struct lspdb_head *lspdb, int level, int tree, struct lfa_protected_resource *protected_resource) { struct isis_spftree *spftree_self; @@ -73,9 +70,8 @@ static void test_run_lfa(struct vty *vty, const struct isis_topology *topology, /* Run forward SPF in the root node. */ flags = F_SPFTREE_NO_ADJACENCIES; - spftree_self = - isis_spftree_new(area, lspdb, root->sysid, level, tree, - SPF_TYPE_FORWARD, flags, SR_ALGORITHM_SPF); + spftree_self = isis_spftree_new(area, lspdb, root->sysid, level, tree, SPF_TYPE_FORWARD, + flags, SR_ALGORITHM_SPF); isis_run_spf(spftree_self); /* Run forward SPF on all adjacent routers. */ @@ -96,9 +92,8 @@ static void test_run_lfa(struct vty *vty, const struct isis_topology *topology, } static void test_run_rlfa(struct vty *vty, const struct isis_topology *topology, - const struct isis_test_node *root, - struct isis_area *area, struct lspdb_head *lspdb, - int level, int tree, + const struct isis_test_node *root, struct isis_area *area, + struct lspdb_head *lspdb, int level, int tree, struct lfa_protected_resource *protected_resource) { struct isis_spftree *spftree_self; @@ -110,9 +105,8 @@ static void test_run_rlfa(struct vty *vty, const struct isis_topology *topology, /* Run forward SPF in the root node. */ flags = F_SPFTREE_NO_ADJACENCIES; - spftree_self = - isis_spftree_new(area, lspdb, root->sysid, level, tree, - SPF_TYPE_FORWARD, flags, SR_ALGORITHM_SPF); + spftree_self = isis_spftree_new(area, lspdb, root->sysid, level, tree, SPF_TYPE_FORWARD, + flags, SR_ALGORITHM_SPF); isis_run_spf(spftree_self); /* Run reverse SPF in the root node. */ @@ -125,8 +119,7 @@ static void test_run_rlfa(struct vty *vty, const struct isis_topology *topology, isis_lfa_compute(area, NULL, spftree_self, protected_resource); /* Compute the remote LFA repair paths. */ - spftree_pc = isis_rlfa_compute(area, spftree_self, spftree_reverse, 0, - protected_resource); + spftree_pc = isis_rlfa_compute(area, spftree_self, spftree_reverse, 0, protected_resource); /* Print the extended P-space and Q-space. */ vty_out(vty, "P-space (self):\n"); @@ -136,8 +129,7 @@ static void test_run_rlfa(struct vty *vty, const struct isis_topology *topology, RB_FOREACH (spf_node, isis_spf_nodes, &spftree_self->adj_nodes) { if (RB_EMPTY(isis_spf_nodes, &spf_node->lfa.p_space)) continue; - vty_out(vty, "P-space (%s):\n", - print_sys_hostname(spf_node->sysid)); + vty_out(vty, "P-space (%s):\n", print_sys_hostname(spf_node->sysid)); RB_FOREACH (node, isis_spf_nodes, &spf_node->lfa.p_space) vty_out(vty, " %s\n", print_sys_hostname(node->sysid)); vty_out(vty, "\n"); @@ -157,8 +149,7 @@ static void test_run_rlfa(struct vty *vty, const struct isis_topology *topology, frr_each_safe (rlfa_tree, &spftree_self->lfa.remote.rlfas, rlfa) { struct zapi_rlfa_response response = {}; - response.pq_label = test_topology_node_ldp_label( - topology, rlfa->pq_address); + response.pq_label = test_topology_node_ldp_label(topology, rlfa->pq_address); assert(response.pq_label != MPLS_INVALID_LABEL); isis_rlfa_activate(spftree_self, rlfa, &response); } @@ -176,11 +167,9 @@ static void test_run_rlfa(struct vty *vty, const struct isis_topology *topology, isis_spftree_del(spftree_pc); } -static void test_run_ti_lfa(struct vty *vty, - const struct isis_topology *topology, - const struct isis_test_node *root, - struct isis_area *area, struct lspdb_head *lspdb, - int level, int tree, +static void test_run_ti_lfa(struct vty *vty, const struct isis_topology *topology, + const struct isis_test_node *root, struct isis_area *area, + struct lspdb_head *lspdb, int level, int tree, struct lfa_protected_resource *protected_resource) { struct isis_spftree *spftree_self; @@ -191,9 +180,8 @@ static void test_run_ti_lfa(struct vty *vty, /* Run forward SPF in the root node. */ flags = F_SPFTREE_NO_ADJACENCIES; - spftree_self = - isis_spftree_new(area, lspdb, root->sysid, level, tree, - SPF_TYPE_FORWARD, flags, SR_ALGORITHM_SPF); + spftree_self = isis_spftree_new(area, lspdb, root->sysid, level, tree, SPF_TYPE_FORWARD, + flags, SR_ALGORITHM_SPF); isis_run_spf(spftree_self); /* Run reverse SPF in the root node. */ @@ -203,8 +191,7 @@ static void test_run_ti_lfa(struct vty *vty, isis_spf_run_neighbors(spftree_self); /* Compute the TI-LFA repair paths. */ - spftree_pc = isis_tilfa_compute(area, spftree_self, spftree_reverse, - protected_resource); + spftree_pc = isis_tilfa_compute(area, spftree_self, spftree_reverse, protected_resource); /* Print the extended P-space and Q-space. */ vty_out(vty, "P-space (self):\n"); @@ -214,8 +201,7 @@ static void test_run_ti_lfa(struct vty *vty, RB_FOREACH (spf_node, isis_spf_nodes, &spftree_self->adj_nodes) { if (RB_EMPTY(isis_spf_nodes, &spf_node->lfa.p_space)) continue; - vty_out(vty, "P-space (%s):\n", - print_sys_hostname(spf_node->sysid)); + vty_out(vty, "P-space (%s):\n", print_sys_hostname(spf_node->sysid)); RB_FOREACH (node, isis_spf_nodes, &spf_node->lfa.p_space) vty_out(vty, " %s\n", print_sys_hostname(node->sysid)); vty_out(vty, "\n"); @@ -238,9 +224,9 @@ static void test_run_ti_lfa(struct vty *vty, } static int test_run(struct vty *vty, const struct isis_topology *topology, - const struct isis_test_node *root, enum test_type test_type, - uint8_t flags, enum lfa_protection_type protection_type, - const char *fail_sysid_str, uint8_t fail_pseudonode_id) + const struct isis_test_node *root, enum test_type test_type, uint8_t flags, + enum lfa_protection_type protection_type, const char *fail_sysid_str, + uint8_t fail_pseudonode_id) { struct isis_area *area; struct lfa_protected_resource protected_resource = {}; @@ -261,7 +247,7 @@ static int test_run(struct vty *vty, const struct isis_topology *topology, addr->addr_len = dotformat2buff(buff, net_title); memcpy(addr->area_addr, buff, addr->addr_len); addr->addr_len -= (ISIS_SYS_ID_LEN + ISIS_NSEL_LEN); - listnode_add(area->area_addrs, addr); + iso_address_list_add_tail(&area->area_addrs, addr); if (test_topology_load(topology, area, area->lspdb) != 0) { vty_out(vty, "%% Failed to load topology\n"); return CMD_WARNING; @@ -274,8 +260,7 @@ static int test_run(struct vty *vty, const struct isis_topology *topology, dynhn = dynhn_find_by_name(area->isis, fail_sysid_str); if (dynhn == NULL) { - vty_out(vty, "Invalid system id %s\n", - fail_sysid_str); + vty_out(vty, "Invalid system id %s\n", fail_sysid_str); return CMD_WARNING; } memcpy(fail_id, dynhn->id, ISIS_SYS_ID_LEN); @@ -283,8 +268,7 @@ static int test_run(struct vty *vty, const struct isis_topology *topology, protected_resource.type = protection_type; memcpy(protected_resource.adjacency, fail_id, ISIS_SYS_ID_LEN); - LSP_PSEUDO_ID(protected_resource.adjacency) = - fail_pseudonode_id; + LSP_PSEUDO_ID(protected_resource.adjacency) = fail_pseudonode_id; } for (int level = IS_LEVEL_1; level <= IS_LEVEL_2; level++) { @@ -297,50 +281,46 @@ static int test_run(struct vty *vty, const struct isis_topology *topology, /* Print the LDPDB. */ if (CHECK_FLAG(flags, F_DISPLAY_LSPDB)) - show_isis_database_lspdb_vty(vty, area, level - 1, - &area->lspdb[level - 1], NULL, - ISIS_UI_LEVEL_DETAIL); + show_isis_database_lspdb_vty(vty, area, level - 1, &area->lspdb[level - 1], + NULL, ISIS_UI_LEVEL_DETAIL); for (int tree = SPFTREE_IPV4; tree <= SPFTREE_IPV6; tree++) { - if (tree == SPFTREE_IPV4 - && CHECK_FLAG(flags, F_IPV6_ONLY)) + if (tree == SPFTREE_IPV4 && CHECK_FLAG(flags, F_IPV6_ONLY)) continue; - if (tree == SPFTREE_IPV6 - && CHECK_FLAG(flags, F_IPV4_ONLY)) + if (tree == SPFTREE_IPV6 && CHECK_FLAG(flags, F_IPV4_ONLY)) continue; switch (test_type) { case TEST_SPF: - test_run_spf(vty, topology, root, area, - &area->lspdb[level - 1], level, - tree, false); + test_run_spf(vty, topology, root, area, &area->lspdb[level - 1], + level, tree, false); break; case TEST_REVERSE_SPF: - test_run_spf(vty, topology, root, area, - &area->lspdb[level - 1], level, - tree, true); + test_run_spf(vty, topology, root, area, &area->lspdb[level - 1], + level, tree, true); break; case TEST_LFA: - test_run_lfa(vty, topology, root, area, - &area->lspdb[level - 1], level, - tree, &protected_resource); + test_run_lfa(vty, topology, root, area, &area->lspdb[level - 1], + level, tree, &protected_resource); break; case TEST_RLFA: - test_run_rlfa(vty, topology, root, area, - &area->lspdb[level - 1], level, - tree, &protected_resource); + test_run_rlfa(vty, topology, root, area, &area->lspdb[level - 1], + level, tree, &protected_resource); break; case TEST_TI_LFA: - test_run_ti_lfa(vty, topology, root, area, - &area->lspdb[level - 1], level, - tree, &protected_resource); + test_run_ti_lfa(vty, topology, root, area, &area->lspdb[level - 1], + level, tree, &protected_resource); break; } } } /* Cleanup IS-IS area. */ + struct isis *isis = area->isis; + isis_area_destroy(area); + if (isis_area_list_count(&isis->area_list) == 0) + isis_finish(isis); return CMD_SUCCESS; } @@ -400,8 +380,7 @@ DEFUN(test_isis, test_isis_cmd, topology_number = atoi(argv[idx + 1]->arg); topology = test_topology_find(test_topologies, topology_number); if (!topology) { - vty_out(vty, "%% Topology \"%s\" not found\n", - argv[idx + 1]->arg); + vty_out(vty, "%% Topology \"%s\" not found\n", argv[idx + 1]->arg); return CMD_WARNING; } @@ -423,24 +402,21 @@ DEFUN(test_isis, test_isis_cmd, fail_sysid_str = argv[idx + 2]->arg; if (argv_find(argv, argc, "pseudonode-id", &idx)) - fail_pseudonode_id = - strtoul(argv[idx + 1]->arg, NULL, 10); + fail_pseudonode_id = strtoul(argv[idx + 1]->arg, NULL, 10); protection_type = LFA_LINK_PROTECTION; } else if (argv_find(argv, argc, "remote-lfa", &idx)) { test_type = TEST_RLFA; fail_sysid_str = argv[idx + 2]->arg; if (argv_find(argv, argc, "pseudonode-id", &idx)) - fail_pseudonode_id = - strtoul(argv[idx + 1]->arg, NULL, 10); + fail_pseudonode_id = strtoul(argv[idx + 1]->arg, NULL, 10); protection_type = LFA_LINK_PROTECTION; } else if (argv_find(argv, argc, "ti-lfa", &idx)) { test_type = TEST_TI_LFA; fail_sysid_str = argv[idx + 2]->arg; if (argv_find(argv, argc, "pseudonode-id", &idx)) - fail_pseudonode_id = - strtoul(argv[idx + 1]->arg, NULL, 10); + fail_pseudonode_id = strtoul(argv[idx + 1]->arg, NULL, 10); if (argv_find(argv, argc, "node-protection", &idx)) protection_type = LFA_NODE_PROTECTION; else @@ -460,8 +436,8 @@ DEFUN(test_isis, test_isis_cmd, else if (argv_find(argv, argc, "level-2-only", &idx)) SET_FLAG(flags, F_LEVEL2_ONLY); - return test_run(vty, topology, root, test_type, flags, protection_type, - fail_sysid_str, fail_pseudonode_id); + return test_run(vty, topology, root, test_type, flags, protection_type, fail_sysid_str, + fail_pseudonode_id); } static void vty_do_exit(int isexit) @@ -478,16 +454,15 @@ static void vty_do_exit(int isexit) exit(0); } -struct option longopts[] = {{"help", no_argument, NULL, 'h'}, - {"debug", no_argument, NULL, 'd'}, - {0}}; +struct option longopts[] = { { "help", no_argument, NULL, 'h' }, + { "debug", no_argument, NULL, 'd' }, + { 0 } }; /* Help information display. */ static void usage(char *progname, int status) { if (status != 0) - fprintf(stderr, "Try `%s --help' for more information.\n", - progname); + fprintf(stderr, "Try `%s --help' for more information.\n", progname); else { printf("Usage : %s [OPTION...]\n\ isisd SPF test program.\n\n\