diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 1b3491f5d38e..facd73c0755a 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -121,12 +121,11 @@ static void lsp_destroy(struct isis_lsp *lsp) if (!LSP_FRAGMENT(lsp->hdr.lsp_id)) { if (lsp->lspu.frags) { lsp_remove_frags(&lsp->area->lspdb[lsp->level - 1], - lsp->lspu.frags); + lsp->lspu.frags); list_delete(&lsp->lspu.frags); } } else { - if (lsp->lspu.zero_lsp - && lsp->lspu.zero_lsp->lspu.frags) { + if (lsp->lspu.zero_lsp && lsp->lspu.zero_lsp->lspu.frags) { listnode_delete(lsp->lspu.zero_lsp->lspu.frags, lsp); } } @@ -173,8 +172,7 @@ void lsp_search_and_destroy(struct lspdb_head *head, const uint8_t *id) * else just remove this frag, from the zero lsps' frag * list */ - if (lsp->lspu.zero_lsp - && lsp->lspu.zero_lsp->lspu.frags) + if (lsp->lspu.zero_lsp && lsp->lspu.zero_lsp->lspu.frags) listnode_delete(lsp->lspu.zero_lsp->lspu.frags, lsp); } @@ -189,17 +187,15 @@ void lsp_search_and_destroy(struct lspdb_head *head, const uint8_t *id) int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno, uint16_t checksum, uint16_t rem_lifetime) { - if (lsp->hdr.seqno == seqno && lsp->hdr.checksum == checksum - && ((lsp->hdr.rem_lifetime == 0 && rem_lifetime == 0) - || (lsp->hdr.rem_lifetime != 0 && rem_lifetime != 0))) { + if (lsp->hdr.seqno == seqno && lsp->hdr.checksum == checksum && + ((lsp->hdr.rem_lifetime == 0 && rem_lifetime == 0) || + (lsp->hdr.rem_lifetime != 0 && rem_lifetime != 0))) { if (IS_DEBUG_SNP_PACKETS) { - zlog_debug( - "ISIS-Snp (%s): Compare LSP %pLS seq 0x%08x, cksum 0x%04hx, lifetime %hus", - areatag, lsp->hdr.lsp_id, lsp->hdr.seqno, - lsp->hdr.checksum, lsp->hdr.rem_lifetime); - zlog_debug( - "ISIS-Snp (%s): is equal to ours seq 0x%08x, cksum 0x%04hx, lifetime %hus", - areatag, seqno, checksum, rem_lifetime); + zlog_debug("ISIS-Snp (%s): Compare LSP %pLS seq 0x%08x, cksum 0x%04hx, lifetime %hus", + areatag, lsp->hdr.lsp_id, lsp->hdr.seqno, + lsp->hdr.checksum, lsp->hdr.rem_lifetime); + zlog_debug("ISIS-Snp (%s): is equal to ours seq 0x%08x, cksum 0x%04hx, lifetime %hus", + areatag, seqno, checksum, rem_lifetime); } return LSP_EQUAL; } @@ -216,32 +212,27 @@ int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno, * as given * in 7.3.16.2. */ - if (seqno > lsp->hdr.seqno - || (seqno == lsp->hdr.seqno - && ((lsp->hdr.rem_lifetime != 0 && rem_lifetime == 0) - || (lsp->hdr.checksum != checksum - && lsp->hdr.rem_lifetime)))) { + if (seqno > lsp->hdr.seqno || + (seqno == lsp->hdr.seqno && + ((lsp->hdr.rem_lifetime != 0 && rem_lifetime == 0) || + (lsp->hdr.checksum != checksum && lsp->hdr.rem_lifetime)))) { if (IS_DEBUG_SNP_PACKETS) { - zlog_debug( - "ISIS-Snp (%s): Compare LSP %pLS seq 0x%08x, cksum 0x%04hx, lifetime %hus", - areatag, lsp->hdr.lsp_id, seqno, checksum, - rem_lifetime); - zlog_debug( - "ISIS-Snp (%s): is newer than ours seq 0x%08x, cksum 0x%04hx, lifetime %hus", - areatag, lsp->hdr.seqno, lsp->hdr.checksum, - lsp->hdr.rem_lifetime); + zlog_debug("ISIS-Snp (%s): Compare LSP %pLS seq 0x%08x, cksum 0x%04hx, lifetime %hus", + areatag, lsp->hdr.lsp_id, seqno, checksum, + rem_lifetime); + zlog_debug("ISIS-Snp (%s): is newer than ours seq 0x%08x, cksum 0x%04hx, lifetime %hus", + areatag, lsp->hdr.seqno, lsp->hdr.checksum, + lsp->hdr.rem_lifetime); } return LSP_NEWER; } if (IS_DEBUG_SNP_PACKETS) { - zlog_debug( - "ISIS-Snp (%s): Compare LSP %pLS seq 0x%08x, cksum 0x%04hx, lifetime %hus", - areatag, lsp->hdr.lsp_id, seqno, checksum, - rem_lifetime); - zlog_debug( - "ISIS-Snp (%s): is older than ours seq 0x%08x, cksum 0x%04hx, lifetime %hus", - areatag, lsp->hdr.seqno, lsp->hdr.checksum, - lsp->hdr.rem_lifetime); + zlog_debug("ISIS-Snp (%s): Compare LSP %pLS seq 0x%08x, cksum 0x%04hx, lifetime %hus", + areatag, lsp->hdr.lsp_id, seqno, checksum, + rem_lifetime); + zlog_debug("ISIS-Snp (%s): is older than ours seq 0x%08x, cksum 0x%04hx, lifetime %hus", + areatag, lsp->hdr.seqno, lsp->hdr.checksum, + lsp->hdr.rem_lifetime); } return LSP_OLDER; @@ -249,8 +240,8 @@ int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno, static void put_lsp_hdr(struct isis_lsp *lsp, size_t *len_pointer, bool keep) { - uint8_t pdu_type = - (lsp->level == IS_LEVEL_1) ? L1_LINK_STATE : L2_LINK_STATE; + uint8_t pdu_type = (lsp->level == IS_LEVEL_1) ? L1_LINK_STATE + : L2_LINK_STATE; struct isis_lsp_hdr *hdr = &lsp->hdr; struct stream *stream = lsp->pdu; size_t orig_getp = 0, orig_endp = 0; @@ -330,8 +321,7 @@ void lsp_inc_seqno(struct isis_lsp *lsp, uint32_t seqno) isis_te_lsp_event(lsp, LSP_INC); } -static void lsp_purge_add_poi(struct isis_lsp *lsp, - const uint8_t *sender) +static void lsp_purge_add_poi(struct isis_lsp *lsp, const uint8_t *sender) { if (lsp->area == NULL) return; @@ -347,8 +337,7 @@ static void lsp_purge_add_poi(struct isis_lsp *lsp, isis_tlvs_set_dynamic_hostname(lsp->tlvs, cmd_hostname_get()); } -static void lsp_purge(struct isis_lsp *lsp, int level, - const uint8_t *sender) +static void lsp_purge(struct isis_lsp *lsp, int level, const uint8_t *sender) { /* reset stream */ lsp_clear_data(lsp); @@ -411,15 +400,15 @@ bool isis_level2_adj_up(struct isis_area *area) continue; for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) { - if (adj->level != ISIS_ADJ_LEVEL1 - && adj->adj_state == ISIS_ADJ_UP) + if (adj->level != ISIS_ADJ_LEVEL1 && + adj->adj_state == ISIS_ADJ_UP) return true; } - } else if (circuit->circ_type == CIRCUIT_T_P2P - && circuit->u.p2p.neighbor) { + } else if (circuit->circ_type == CIRCUIT_T_P2P && + circuit->u.p2p.neighbor) { adj = circuit->u.p2p.neighbor; - if (adj->level != ISIS_ADJ_LEVEL1 - && adj->adj_state == ISIS_ADJ_UP) + if (adj->level != ISIS_ADJ_LEVEL1 && + adj->adj_state == ISIS_ADJ_UP) return true; } } @@ -469,14 +458,13 @@ static void isis_reset_attach_bit(struct isis_adjacency *adj) if (!lsp) return; - if (adj->adj_state == ISIS_ADJ_UP - && !(lsp->hdr.lsp_bits & LSPBIT_ATT)) { + if (adj->adj_state == ISIS_ADJ_UP && !(lsp->hdr.lsp_bits & LSPBIT_ATT)) { sched_debug("ISIS (%s): adj going up regenerate lsp-bits", area->area_tag); lsp_regenerate_schedule(area, IS_LEVEL_1, 0); - } else if (adj->adj_state == ISIS_ADJ_DOWN - && (lsp->hdr.lsp_bits & LSPBIT_ATT) - && !isis_level2_adj_up(area)) { + } else if (adj->adj_state == ISIS_ADJ_DOWN && + (lsp->hdr.lsp_bits & LSPBIT_ATT) && + !isis_level2_adj_up(area)) { sched_debug("ISIS (%s): adj going down regenerate lsp-bits", area->area_tag); lsp_regenerate_schedule(area, IS_LEVEL_1, 0); @@ -497,8 +485,8 @@ static uint8_t lsp_bits_generate(int level, int overload_bit, int attached_bit, /* only set the attach bit if we are a level-1-2 router and this is * a level-1 LSP and we have a level-2 adjacency up from another area */ - if (area->is_type == IS_LEVEL_1_AND_2 && level == IS_LEVEL_1 - && attached_bit && isis_level2_adj_up(area)) + if (area->is_type == IS_LEVEL_1_AND_2 && level == IS_LEVEL_1 && + attached_bit && isis_level2_adj_up(area)) lsp_bits |= LSPBIT_ATT; return lsp_bits; } @@ -523,15 +511,16 @@ static void lsp_update_data(struct isis_lsp *lsp, struct isis_lsp_hdr *hdr, lsp->tlvs = tlvs; - if (area->dynhostname && lsp->tlvs->hostname - && lsp->hdr.rem_lifetime) { - isis_dynhn_insert( - area->isis, lsp->hdr.lsp_id, lsp->tlvs->hostname, - (lsp->hdr.lsp_bits & LSPBIT_IST) == IS_LEVEL_1_AND_2 - ? IS_LEVEL_2 - : IS_LEVEL_1); + if (area->dynhostname && lsp->tlvs->hostname && lsp->hdr.rem_lifetime) { + isis_dynhn_insert(area->isis, lsp->hdr.lsp_id, + lsp->tlvs->hostname, + (lsp->hdr.lsp_bits & LSPBIT_IST) == + IS_LEVEL_1_AND_2 + ? IS_LEVEL_2 + : IS_LEVEL_1); } + lsp_regenerate_schedule(area, lsp->level, 0); return; } @@ -553,10 +542,9 @@ void lsp_update(struct isis_lsp *lsp, struct isis_lsp_hdr *hdr, struct isis_area *area, int level, bool confusion) { if (lsp->own_lsp) { - flog_err( - EC_LIB_DEVELOPMENT, - "ISIS-Upd (%s): BUG updating LSP %pLS still marked as own LSP", - area->area_tag, lsp->hdr.lsp_id); + flog_err(EC_LIB_DEVELOPMENT, + "ISIS-Upd (%s): BUG updating LSP %pLS still marked as own LSP", + area->area_tag, lsp->hdr.lsp_id); lsp_clear_data(lsp); lsp->own_lsp = 0; } @@ -611,9 +599,8 @@ static void lsp_adjust_stream(struct isis_lsp *lsp) } struct isis_lsp *lsp_new(struct isis_area *area, uint8_t *lsp_id, - uint16_t rem_lifetime, uint32_t seqno, - uint8_t lsp_bits, uint16_t checksum, - struct isis_lsp *lsp0, int level) + uint16_t rem_lifetime, uint32_t seqno, uint8_t lsp_bits, + uint16_t checksum, struct isis_lsp *lsp0, int level) { struct isis_lsp *lsp; @@ -663,8 +650,7 @@ void lsp_build_list_nonzero_ht(struct lspdb_head *head, const uint8_t *start_id, start = lspdb_find_gteq(head, &searchfor); frr_each_from (lspdb, head, lsp, start) { - if (memcmp(lsp->hdr.lsp_id, stop_id, - ISIS_SYS_ID_LEN + 2) > 0) + if (memcmp(lsp->hdr.lsp_id, stop_id, ISIS_SYS_ID_LEN + 2) > 0) break; if (lsp->hdr.rem_lifetime && lsp->hdr.seqno) @@ -736,8 +722,8 @@ static const char *lsp_bits2string(uint8_t lsp_bits, char *buf, size_t buf_size) } /* this function prints the lsp on show isis database */ -void lsp_print_common(struct isis_lsp *lsp, struct vty *vty, struct json_object *json, - char dynhost, struct isis *isis) +void lsp_print_common(struct isis_lsp *lsp, struct vty *vty, + struct json_object *json, char dynhost, struct isis *isis) { if (json) { return lsp_print_json(lsp, json, dynhost, isis); @@ -747,7 +733,7 @@ void lsp_print_common(struct isis_lsp *lsp, struct vty *vty, struct json_object } void lsp_print_json(struct isis_lsp *lsp, struct json_object *json, - char dynhost, struct isis *isis) + char dynhost, struct isis *isis) { char LSPid[255]; char age_out[8]; @@ -772,12 +758,12 @@ void lsp_print_json(struct isis_lsp *lsp, struct json_object *json, } else { json_object_int_add(json, "holdtime", lsp->hdr.rem_lifetime); } - json_object_string_add( - json, "att-p-ol", lsp_bits2string(lsp->hdr.lsp_bits, b, sizeof(b))); + json_object_string_add(json, "att-p-ol", + lsp_bits2string(lsp->hdr.lsp_bits, b, sizeof(b))); } -void lsp_print_vty(struct isis_lsp *lsp, struct vty *vty, - char dynhost, struct isis *isis) +void lsp_print_vty(struct isis_lsp *lsp, struct vty *vty, char dynhost, + struct isis *isis) { char LSPid[255]; char age_out[8]; @@ -798,8 +784,7 @@ void lsp_print_vty(struct isis_lsp *lsp, struct vty *vty, } void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, - struct json_object *json, char dynhost, - struct isis *isis) + struct json_object *json, char dynhost, struct isis *isis) { if (json) { lsp_print_json(lsp, json, dynhost, isis); @@ -843,8 +828,8 @@ static uint16_t lsp_rem_lifetime(struct isis_area *area, int level) uint16_t rem_lifetime; /* Add jitter to configured LSP lifetime */ - rem_lifetime = - isis_jitter(area->max_lsp_lifetime[level - 1], MAX_AGE_JITTER); + rem_lifetime = isis_jitter(area->max_lsp_lifetime[level - 1], + MAX_AGE_JITTER); /* No jitter if the max refresh will be less than configure gen interval */ @@ -864,13 +849,13 @@ static uint16_t lsp_refresh_time(struct isis_lsp *lsp, uint16_t rem_lifetime) uint16_t refresh_time; /* Add jitter to LSP refresh time */ - refresh_time = - isis_jitter(area->lsp_refresh[level - 1], MAX_LSP_GEN_JITTER); + refresh_time = isis_jitter(area->lsp_refresh[level - 1], + MAX_LSP_GEN_JITTER); /* RFC 4444 : make sure the refresh time is at least less than 300 * of the remaining lifetime and more than gen interval */ - if (refresh_time <= area->lsp_gen_interval[level - 1] - || refresh_time > (rem_lifetime - 300)) + if (refresh_time <= area->lsp_gen_interval[level - 1] || + refresh_time > (rem_lifetime - 300)) refresh_time = rem_lifetime - 300; /* In cornercases, refresh_time might be <= lsp_gen_interval, however @@ -885,12 +870,11 @@ static void lsp_build_internal_reach_ipv4(struct isis_lsp *lsp, struct prefix_ipv4 *ipv4, uint32_t metric) { - struct sr_prefix_cfg *pcfgs[SR_ALGORITHM_COUNT] = {NULL}; + struct sr_prefix_cfg *pcfgs[SR_ALGORITHM_COUNT] = { NULL }; if (area->oldmetric) { - lsp_debug( - "ISIS (%s): Adding old-style IP reachability for %pFX", - area->area_tag, ipv4); + lsp_debug("ISIS (%s): Adding old-style IP reachability for %pFX", + area->area_tag, ipv4); isis_tlvs_add_oldstyle_ip_reach(lsp->tlvs, ipv4, metric); } @@ -905,8 +889,8 @@ static void lsp_build_internal_reach_ipv4(struct isis_lsp *lsp, !isis_flex_algo_elected_supported(i, area)) continue; #endif /* ifndef FABRICD */ - pcfgs[i] = - isis_sr_cfg_prefix_find(area, ipv4, i); + pcfgs[i] = isis_sr_cfg_prefix_find(area, ipv4, + i); } isis_tlvs_add_extended_ip_reach(lsp->tlvs, ipv4, metric, false, @@ -919,7 +903,7 @@ static void lsp_build_internal_reach_ipv6(struct isis_lsp *lsp, struct prefix_ipv6 *ipv6, uint32_t metric) { - struct sr_prefix_cfg *pcfgs[SR_ALGORITHM_COUNT] = {NULL}; + struct sr_prefix_cfg *pcfgs[SR_ALGORITHM_COUNT] = { NULL }; lsp_debug("ISIS (%s): Adding IPv6 reachability for %pFX", area->area_tag, ipv6); @@ -961,22 +945,23 @@ static void lsp_build_ext_reach_ipv4(struct isis_lsp *lsp, metric = 0x3f; if (area->oldmetric) - isis_tlvs_add_oldstyle_ip_reach(lsp->tlvs, ipv4, - metric); + isis_tlvs_add_oldstyle_ip_reach(lsp->tlvs, ipv4, metric); if (area->newmetric) { struct sr_prefix_cfg *pcfgs[SR_ALGORITHM_COUNT] = { - NULL}; + NULL + }; if (area->srdb.enabled) for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { #ifndef FABRICD if (flex_algo_id_valid(i) && - !isis_flex_algo_elected_supported( - i, area)) + !isis_flex_algo_elected_supported(i, + area)) continue; #endif /* ifndef FABRICD */ - pcfgs[i] = isis_sr_cfg_prefix_find( - area, ipv4, i); + pcfgs[i] = isis_sr_cfg_prefix_find(area, + ipv4, + i); } isis_tlvs_add_extended_ip_reach(lsp->tlvs, ipv4, metric, @@ -988,8 +973,7 @@ static void lsp_build_ext_reach_ipv4(struct isis_lsp *lsp, static void lsp_build_ext_reach_ipv6(struct isis_lsp *lsp, struct isis_area *area) { - struct route_table *er_table = - get_ext_reach(area, AF_INET6, lsp->level); + struct route_table *er_table = get_ext_reach(area, AF_INET6, lsp->level); if (!er_table) return; @@ -1009,18 +993,19 @@ static void lsp_build_ext_reach_ipv6(struct isis_lsp *lsp, if (!src_p || !src_p->prefixlen) { struct sr_prefix_cfg *pcfgs[SR_ALGORITHM_COUNT] = { - NULL}; + NULL + }; if (area->srdb.enabled) for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { #ifndef FABRICD if (flex_algo_id_valid(i) && - !isis_flex_algo_elected_supported( - i, area)) + !isis_flex_algo_elected_supported(i, + area)) continue; #endif /* ifndef FABRICD */ - pcfgs[i] = isis_sr_cfg_prefix_find( - area, p, i); + pcfgs[i] = isis_sr_cfg_prefix_find(area, + p, i); } isis_tlvs_add_ipv6_reach(lsp->tlvs, @@ -1028,8 +1013,8 @@ static void lsp_build_ext_reach_ipv6(struct isis_lsp *lsp, p, metric, true, pcfgs); } else if (isis_area_ipv6_dstsrc_enabled(area)) { isis_tlvs_add_ipv6_dstsrc_reach(lsp->tlvs, - ISIS_MT_IPV6_DSTSRC, - p, src_p, metric); + ISIS_MT_IPV6_DSTSRC, p, + src_p, metric); } } } @@ -1093,19 +1078,17 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) /* Protocols Supported */ if (area->ip_circuits > 0 || area->ipv6_circuits > 0) { - struct nlpids nlpids = {.count = 0}; + struct nlpids nlpids = { .count = 0 }; if (area->ip_circuits > 0) { - lsp_debug( - "ISIS (%s): Found IPv4 circuit, adding IPv4 to NLPIDs", - area->area_tag); + lsp_debug("ISIS (%s): Found IPv4 circuit, adding IPv4 to NLPIDs", + area->area_tag); nlpids.nlpids[nlpids.count] = NLPID_IP; nlpids.count++; } if (area->ipv6_circuits > 0) { - lsp_debug( - "ISIS (%s): Found IPv6 circuit, adding IPv6 to NLPIDs", - area->area_tag); + lsp_debug("ISIS (%s): Found IPv6 circuit, adding IPv6 to NLPIDs", + area->area_tag); nlpids.nlpids[nlpids.count] = NLPID_IPV6; nlpids.count++; } @@ -1120,9 +1103,10 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) mt_settings = area_mt_settings(area, &mt_count); for (unsigned int i = 0; i < mt_count; i++) { - isis_tlvs_add_mt_router_info( - lsp->tlvs, mt_settings[i]->mtid, - mt_settings[i]->overload, false); + isis_tlvs_add_mt_router_info(lsp->tlvs, + mt_settings[i]->mtid, + mt_settings[i]->overload, + false); lsp_debug("ISIS (%s): MT %s", area->area_tag, isis_mtid2str(mt_settings[i]->mtid)); } @@ -1173,8 +1157,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) uint32_t range_size; /* SRGB first */ - range_size = srdb->config.srgb_upper_bound - - srdb->config.srgb_lower_bound + 1; + range_size = srdb->config.srgb_upper_bound - + srdb->config.srgb_lower_bound + 1; rcap->srgb.flags = ISIS_SUBTLV_SRGB_FLAG_I | ISIS_SUBTLV_SRGB_FLAG_V; rcap->srgb.range_size = range_size; @@ -1203,8 +1187,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) #endif /* ifndef FABRICD */ /* SRLB */ rcap->srlb.flags = 0; - range_size = srdb->config.srlb_upper_bound - - srdb->config.srlb_lower_bound + 1; + range_size = srdb->config.srlb_upper_bound - + srdb->config.srlb_lower_bound + 1; rcap->srlb.range_size = range_size; rcap->srlb.lower_bound = srdb->config.srlb_lower_bound; /* And finally MSD */ @@ -1275,7 +1259,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) * is not activate or MPLS-TE router-id not specified */ if (area->isis->router_id != 0) { - struct in_addr id = {.s_addr = area->isis->router_id}; + struct in_addr id = { .s_addr = area->isis->router_id }; lsp_debug("ISIS (%s): Adding router ID %pI4 as IPv4 tlv.", area->area_tag, &id); isis_tlvs_add_ipv4_address(lsp->tlvs, &id); @@ -1285,12 +1269,11 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) * otherwise add exactly same data as for IPv4 address */ if (area->newmetric) { - if (IS_MPLS_TE(area->mta) - && area->mta->router_id.s_addr != INADDR_ANY) + if (IS_MPLS_TE(area->mta) && + area->mta->router_id.s_addr != INADDR_ANY) id.s_addr = area->mta->router_id.s_addr; - lsp_debug( - "ISIS (%s): Adding router ID also as TE router ID tlv.", - area->area_tag); + lsp_debug("ISIS (%s): Adding router ID also as TE router ID tlv.", + area->area_tag); isis_tlvs_set_te_router_id(lsp->tlvs, &id); } } else { @@ -1298,8 +1281,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) area->area_tag); } - if (IS_MPLS_TE(area->mta) - && !IN6_IS_ADDR_UNSPECIFIED(&area->mta->router_id_ipv6)) { + if (IS_MPLS_TE(area->mta) && + !IN6_IS_ADDR_UNSPECIFIED(&area->mta->router_id_ipv6)) { lsp_debug("ISIS (%s): Adding IPv6 TE Router ID tlv.", area->area_tag); isis_tlvs_set_te_router_id_ipv6(lsp->tlvs, @@ -1310,21 +1293,27 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) area->area_tag); if (fabricd) { - lsp_debug( - "ISIS (%s): Adding tier %hhu spine-leaf-extension tlv.", - area->area_tag, fabricd_tier(area)); + lsp_debug("ISIS (%s): Adding tier %hhu spine-leaf-extension tlv.", + area->area_tag, fabricd_tier(area)); isis_tlvs_add_spine_leaf(lsp->tlvs, fabricd_tier(area), true, false, false, false); } + struct isis_adjacency *adj; + bool flag = false; + for (ALL_LIST_ELEMENTS_RO(area->adjacency_list, node, adj)) { + if (adj->level == IS_LEVEL_2) + flag = true; + } + + struct isis_circuit *circuit; for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { if (!circuit->interface) - lsp_debug( - "ISIS (%s): Processing %s circuit %p with unknown interface", - area->area_tag, - circuit_type2string(circuit->circ_type), - circuit); + lsp_debug("ISIS (%s): Processing %s circuit %p with unknown interface", + area->area_tag, + circuit_type2string(circuit->circ_type), + circuit); else lsp_debug("ISIS (%s): Processing %s circuit %s", area->area_tag, @@ -1338,9 +1327,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) } if (area->advertise_passive_only && !circuit->is_passive) { - lsp_debug( - "ISIS (%s): Circuit is not passive, ignoring.", - area->area_tag); + lsp_debug("ISIS (%s): Circuit is not passive, ignoring.", + area->area_tag); continue; } @@ -1348,10 +1336,10 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) ? circuit->metric[level - 1] : circuit->te_metric[level - 1]; + if (circuit->ip_router && circuit->ip_addrs->count > 0) { - lsp_debug( - "ISIS (%s): Circuit has IPv4 active, adding respective TLVs.", - area->area_tag); + lsp_debug("ISIS (%s): Circuit has IPv4 active, adding respective TLVs.", + area->area_tag); struct listnode *ipnode; struct prefix_ipv4 *ipv4; for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, ipnode, @@ -1360,14 +1348,60 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) metric); } + if (circuit->ipv6_router && circuit->ipv6_non_link->count > 0) { struct listnode *ipnode; struct prefix_ipv6 *ipv6; - for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, - ipnode, ipv6)) + ipnode, ipv6)) { lsp_build_internal_reach_ipv6(lsp, area, ipv6, metric); + } + } + + if (flag && (lsp->level == IS_LEVEL_2) && + (area->is_type == IS_LEVEL_1_AND_2) && + (lsp->hdr.lsp_bits != LSPBIT_ATT)) { + struct isis_lsp *lsp_tmp; + struct lspdb_head *head_tmp = &area->lspdb[0]; + if (head_tmp) { + frr_each (lspdb, head_tmp, lsp_tmp) { + if (strcmp(lsp->tlvs->hostname, lsp_tmp->tlvs->hostname) != 0) { + for (struct isis_item *i = lsp_tmp->tlvs->extended_ip_reach.head; i; i = i->next) { + struct isis_extended_ip_reach *r = (struct isis_extended_ip_reach *)i; + int count = 0; + for (struct isis_item *l = lsp->tlvs->extended_ip_reach.head; l; l = l->next) { + struct isis_extended_ip_reach *rt = (struct isis_extended_ip_reach *)l; + if (r->prefix.prefix.s_addr == rt->prefix.prefix.s_addr) { + if ((r->metric > rt->metric) || (r->metric == rt->metric)) + count++; + break; + } + } + if (count == 0) { + lsp_build_internal_reach_ipv4(lsp, area, &r->prefix, r->metric); + } + } + for (struct isis_item *i = lsp_tmp->tlvs->ipv6_reach.head; i; i = i->next) { + struct isis_ipv6_reach *r = (struct isis_ipv6_reach *)i; + int count = 0; + for (struct isis_item *l = lsp->tlvs->ipv6_reach.head; l; l = l->next) { + struct isis_ipv6_reach *rt = (struct isis_ipv6_reach *) l; + char prefixbuf_1[PREFIX2STR_BUFFER]; + char prefixbuf_2[PREFIX2STR_BUFFER]; + if (strcmp(prefix2str(&r->prefix, prefixbuf_1, sizeof(prefixbuf_1)), + prefix2str(&rt->prefix, prefixbuf_2, sizeof(prefixbuf_2))) == 0) { + if ((r->metric > rt->metric) || (r->metric == rt->metric)) + count++; + break; + } + } + if (count == 0) + lsp_build_internal_reach_ipv6(lsp, area, &r->prefix, r->metric); + } + } + } + } } switch (circuit->circ_type) { @@ -1380,38 +1414,37 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) if (LSP_PSEUDO_ID(ne_id)) { if (area->oldmetric) { - lsp_debug( - "ISIS (%s): Adding DIS %pPN as old-style neighbor", - area->area_tag, ne_id); - isis_tlvs_add_oldstyle_reach( - lsp->tlvs, ne_id, - metric); + lsp_debug("ISIS (%s): Adding DIS %pPN as old-style neighbor", + area->area_tag, ne_id); + isis_tlvs_add_oldstyle_reach(lsp->tlvs, + ne_id, + metric); } if (area->newmetric) - tlvs_add_mt_bcast( - lsp->tlvs, circuit, - level, ne_id, metric); + tlvs_add_mt_bcast(lsp->tlvs, + circuit, + level, ne_id, + metric); } } else { - lsp_debug( - "ISIS (%s): Circuit is not active for current level. Not adding IS neighbors", - area->area_tag); + lsp_debug("ISIS (%s): Circuit is not active for current level. Not adding IS neighbors", + area->area_tag); } break; case CIRCUIT_T_P2P: { struct isis_adjacency *nei = circuit->u.p2p.neighbor; - if (nei && nei->adj_state == ISIS_ADJ_UP - && (level & nei->circuit_t)) { + if (nei && nei->adj_state == ISIS_ADJ_UP && + (level & nei->circuit_t)) { uint8_t ne_id[7]; memcpy(ne_id, nei->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(ne_id) = 0; if (area->oldmetric) { - lsp_debug( - "ISIS (%s): Adding old-style is reach for %pSY", - area->area_tag, ne_id); - isis_tlvs_add_oldstyle_reach( - lsp->tlvs, ne_id, metric); + lsp_debug("ISIS (%s): Adding old-style is reach for %pSY", + area->area_tag, ne_id); + isis_tlvs_add_oldstyle_reach(lsp->tlvs, + ne_id, + metric); } if (area->newmetric) { uint32_t neighbor_metric; @@ -1425,9 +1458,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) ne_id, neighbor_metric); } } else { - lsp_debug( - "ISIS (%s): No adjacency for given level on this circuit. Not adding IS neighbors", - area->area_tag); + lsp_debug("ISIS (%s): No adjacency for given level on this circuit. Not adding IS neighbors", + area->area_tag); } } break; case CIRCUIT_T_LOOPBACK: @@ -1464,9 +1496,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) if (LSP_FRAGMENT(frag->hdr.lsp_id) == 255) { if (!fragment_overflow) { fragment_overflow = true; - zlog_warn( - "ISIS (%s): Too much information for 256 fragments", - area->area_tag); + zlog_warn("ISIS (%s): Too much information for 256 fragments", + area->area_tag); } isis_free_tlvs(tlvs); continue; @@ -1552,16 +1583,14 @@ int lsp_generate(struct isis_area *area, int level) refresh_time, &area->t_lsp_refresh[level - 1]); if (IS_DEBUG_UPDATE_PACKETS) { - zlog_debug( - "ISIS-Upd (%s): Building L%d LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus", - area->area_tag, level, newlsp->hdr.lsp_id, - newlsp->hdr.pdu_len, newlsp->hdr.seqno, - newlsp->hdr.checksum, newlsp->hdr.rem_lifetime, - refresh_time); + zlog_debug("ISIS-Upd (%s): Building L%d LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus", + area->area_tag, level, newlsp->hdr.lsp_id, + newlsp->hdr.pdu_len, newlsp->hdr.seqno, + newlsp->hdr.checksum, newlsp->hdr.rem_lifetime, + refresh_time); } - sched_debug( - "ISIS (%s): Built L%d LSP. Set triggered regenerate to non-pending.", - area->area_tag, level); + sched_debug("ISIS (%s): Built L%d LSP. Set triggered regenerate to non-pending.", + area->area_tag, level); #ifndef FABRICD /* send northbound notification */ @@ -1633,15 +1662,13 @@ static int lsp_regenerate(struct isis_area *area, int level) area->lsp_regenerate_pending[level - 1] = 0; if (IS_DEBUG_UPDATE_PACKETS) { - zlog_debug( - "ISIS-Upd (%s): Refreshed our L%d LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus", - area->area_tag, level, lsp->hdr.lsp_id, - lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum, - lsp->hdr.rem_lifetime, refresh_time); + zlog_debug("ISIS-Upd (%s): Refreshed our L%d LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus", + area->area_tag, level, lsp->hdr.lsp_id, + lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum, + lsp->hdr.rem_lifetime, refresh_time); } - sched_debug( - "ISIS (%s): Rebuilt L%d LSP. Set triggered regenerate to non-pending.", - area->area_tag, level); + sched_debug("ISIS (%s): Rebuilt L%d LSP. Set triggered regenerate to non-pending.", + area->area_tag, level); return ISIS_OK; } @@ -1671,25 +1698,23 @@ static void lsp_refresh(struct event *thread) * Throttle regeneration of LSPs (but not when BFD signalled a 'down' * message) */ - if (monotime_since(&area->last_lsp_refresh_event[level - 1], NULL) - < 100000L - && !(area->bfd_force_spf_refresh)) { + if (monotime_since(&area->last_lsp_refresh_event[level - 1], NULL) < + 100000L && + !(area->bfd_force_spf_refresh)) { sched_debug("ISIS (%s): Still unstable, postpone LSP L%d refresh", area->area_tag, level); - _lsp_regenerate_schedule(area, level, 0, false, - __func__, __FILE__, __LINE__); + _lsp_regenerate_schedule(area, level, 0, false, __func__, + __FILE__, __LINE__); return; } - sched_debug( - "ISIS (%s): LSP L%d refresh timer expired. Refreshing LSP...", - area->area_tag, level); + sched_debug("ISIS (%s): LSP L%d refresh timer expired. Refreshing LSP...", + area->area_tag, level); lsp_regenerate(area, level); } -int _lsp_regenerate_schedule(struct isis_area *area, int level, - int all_pseudo, bool postpone, - const char *func, const char *file, +int _lsp_regenerate_schedule(struct isis_area *area, int level, int all_pseudo, + bool postpone, const char *func, const char *file, int line) { struct isis_lsp *lsp; @@ -1703,11 +1728,9 @@ int _lsp_regenerate_schedule(struct isis_area *area, int level, if (area == NULL) return ISIS_ERROR; - sched_debug( - "ISIS (%s): Scheduling regeneration of %s LSPs, %sincluding PSNs Caller: %s %s:%d", - area->area_tag, circuit_t2string(level), - all_pseudo ? "" : "not ", - func, file, line); + sched_debug("ISIS (%s): Scheduling regeneration of %s LSPs, %sincluding PSNs Caller: %s %s:%d", + area->area_tag, circuit_t2string(level), + all_pseudo ? "" : "not ", func, file, line); memcpy(id, area->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(id) = LSP_FRAGMENT(id) = 0; @@ -1721,75 +1744,69 @@ int _lsp_regenerate_schedule(struct isis_area *area, int level, monotime(&area->last_lsp_refresh_event[lvl - 1]); } - sched_debug( - "ISIS (%s): Checking whether L%d needs to be scheduled", - area->area_tag, lvl); + sched_debug("ISIS (%s): Checking whether L%d needs to be scheduled", + area->area_tag, lvl); - if (area->lsp_regenerate_pending[lvl - 1] - && !(area->bfd_signalled_down)) { + if (area->lsp_regenerate_pending[lvl - 1] && + !(area->bfd_signalled_down)) { /* * Note: in case of a BFD 'down' message the refresh is * scheduled once again just to be sure */ struct timeval remain = event_timer_remain( area->t_lsp_refresh[lvl - 1]); - sched_debug( - "ISIS (%s): Regeneration is already pending, nothing todo. (Due in %lld.%03lld seconds)", - area->area_tag, (long long)remain.tv_sec, - (long long)remain.tv_usec / 1000); + sched_debug("ISIS (%s): Regeneration is already pending, nothing todo. (Due in %lld.%03lld seconds)", + area->area_tag, (long long)remain.tv_sec, + (long long)remain.tv_usec / 1000); continue; } lsp = lsp_search(&area->lspdb[lvl - 1], id); if (!lsp) { - sched_debug( - "ISIS (%s): We do not have any LSPs to regenerate, nothing todo.", - area->area_tag); + sched_debug("ISIS (%s): We do not have any LSPs to regenerate, nothing todo.", + area->area_tag); continue; } /* * Throttle avoidance */ - sched_debug( - "ISIS (%s): Will schedule regen timer. Last run was: %lld, Now is: %lld", - area->area_tag, (long long)lsp->last_generated, - (long long)now); + sched_debug("ISIS (%s): Will schedule regen timer. Last run was: %lld, Now is: %lld", + area->area_tag, (long long)lsp->last_generated, + (long long)now); EVENT_OFF(area->t_lsp_refresh[lvl - 1]); diff = now - lsp->last_generated; - if (diff < area->lsp_gen_interval[lvl - 1] - && !(area->bfd_signalled_down)) { - timeout = - 1000 * (area->lsp_gen_interval[lvl - 1] - diff); - sched_debug( - "ISIS (%s): Scheduling in %ld ms to match configured lsp_gen_interval", - area->area_tag, timeout); + if (diff < area->lsp_gen_interval[lvl - 1] && + !(area->bfd_signalled_down)) { + timeout = 1000 * + (area->lsp_gen_interval[lvl - 1] - diff); + sched_debug("ISIS (%s): Scheduling in %ld ms to match configured lsp_gen_interval", + area->area_tag, timeout); } else { /* * Schedule LSP refresh ASAP */ if (area->bfd_signalled_down) { - sched_debug( - "ISIS (%s): Scheduling immediately due to BFD 'down' message.", - area->area_tag); + sched_debug("ISIS (%s): Scheduling immediately due to BFD 'down' message.", + area->area_tag); area->bfd_signalled_down = false; area->bfd_force_spf_refresh = true; timeout = 0; } else { - int64_t time_since_last = monotime_since( - &area->last_lsp_refresh_event[lvl - 1], - NULL); + int64_t time_since_last = + monotime_since(&area->last_lsp_refresh_event + [lvl - 1], + NULL); timeout = time_since_last < 100000L - ? (100000L - time_since_last)/1000 + ? (100000L - time_since_last) / + 1000 : 0; if (timeout > 0) - sched_debug( - "ISIS (%s): Last generation was more than lsp_gen_interval ago. Scheduling for execution in %ld ms due to the instability timer.", - area->area_tag, timeout); + sched_debug("ISIS (%s): Last generation was more than lsp_gen_interval ago. Scheduling for execution in %ld ms due to the instability timer.", + area->area_tag, timeout); else - sched_debug( - "ISIS (%s): Last generation was more than lsp_gen_interval ago. Scheduling for execution now.", - area->area_tag); + sched_debug("ISIS (%s): Last generation was more than lsp_gen_interval ago. Scheduling for execution now.", + area->area_tag); } } @@ -1825,15 +1842,15 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit, lsp_clear_data(lsp); lsp->tlvs = isis_alloc_tlvs(); - lsp_debug( - "ISIS (%s): Constructing pseudo LSP %pLS for interface %s level %d", - area->area_tag, lsp->hdr.lsp_id, circuit->interface->name, - level); + lsp_debug("ISIS (%s): Constructing pseudo LSP %pLS for interface %s level %d", + area->area_tag, lsp->hdr.lsp_id, circuit->interface->name, + level); lsp->level = level; /* RFC3787 section 4 SHOULD not set overload bit in pseudo LSPs */ - lsp->hdr.lsp_bits = lsp_bits_generate( - level, 0, circuit->area->attached_bit_send, area); + lsp->hdr.lsp_bits = lsp_bits_generate(level, 0, + circuit->area->attached_bit_send, + area); /* * add self to IS neighbours @@ -1863,39 +1880,35 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit, for (ALL_LIST_ELEMENTS_RO(adj_list, node, adj)) { if (!(adj->level & level)) { - lsp_debug( - "ISIS (%s): Ignoring neighbor %pSY, level does not intersect", - area->area_tag, adj->sysid); + lsp_debug("ISIS (%s): Ignoring neighbor %pSY, level does not intersect", + area->area_tag, adj->sysid); continue; } - if (!(level == IS_LEVEL_1 - && adj->sys_type == ISIS_SYSTYPE_L1_IS) - && !(level == IS_LEVEL_1 - && adj->sys_type == ISIS_SYSTYPE_L2_IS - && adj->adj_usage == ISIS_ADJ_LEVEL1AND2) - && !(level == IS_LEVEL_2 - && adj->sys_type == ISIS_SYSTYPE_L2_IS)) { - lsp_debug( - "ISIS (%s): Ignoring neighbor %pSY, level does not match", - area->area_tag, adj->sysid); + if (!(level == IS_LEVEL_1 && + adj->sys_type == ISIS_SYSTYPE_L1_IS) && + !(level == IS_LEVEL_1 && + adj->sys_type == ISIS_SYSTYPE_L2_IS && + adj->adj_usage == ISIS_ADJ_LEVEL1AND2) && + !(level == IS_LEVEL_2 && + adj->sys_type == ISIS_SYSTYPE_L2_IS)) { + lsp_debug("ISIS (%s): Ignoring neighbor %pSY, level does not match", + area->area_tag, adj->sysid); continue; } memcpy(ne_id, adj->sysid, ISIS_SYS_ID_LEN); if (circuit->area->oldmetric) { isis_tlvs_add_oldstyle_reach(lsp->tlvs, ne_id, 0); - lsp_debug( - "ISIS (%s): Adding %pPN as old-style neighbor (peer)", - area->area_tag, ne_id); + lsp_debug("ISIS (%s): Adding %pPN as old-style neighbor (peer)", + area->area_tag, ne_id); } if (circuit->area->newmetric) { isis_tlvs_add_extended_reach(lsp->tlvs, ISIS_MT_IPV4_UNICAST, ne_id, 0, NULL); - lsp_debug( - "ISIS (%s): Adding %pPN as te-style neighbor (peer)", - area->area_tag, ne_id); + lsp_debug("ISIS (%s): Adding %pPN as te-style neighbor (peer)", + area->area_tag, ne_id); } } list_delete(&adj_list); @@ -1909,10 +1922,10 @@ int lsp_generate_pseudo(struct isis_circuit *circuit, int level) uint8_t lsp_id[ISIS_SYS_ID_LEN + 2]; uint16_t rem_lifetime, refresh_time; - if ((circuit->is_type & level) != level - || (circuit->state != C_STATE_UP) - || (circuit->circ_type != CIRCUIT_T_BROADCAST) - || (circuit->u.bc.is_dr[level - 1] == 0)) + if ((circuit->is_type & level) != level || + (circuit->state != C_STATE_UP) || + (circuit->circ_type != CIRCUIT_T_BROADCAST) || + (circuit->u.bc.is_dr[level - 1] == 0)) return ISIS_ERROR; memcpy(lsp_id, circuit->isis->sysid, ISIS_SYS_ID_LEN); @@ -1953,11 +1966,10 @@ int lsp_generate_pseudo(struct isis_circuit *circuit, int level) &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]); if (IS_DEBUG_UPDATE_PACKETS) { - zlog_debug( - "ISIS-Upd (%s): Built L%d Pseudo LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus", - circuit->area->area_tag, level, lsp->hdr.lsp_id, - lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum, - lsp->hdr.rem_lifetime, refresh_time); + zlog_debug("ISIS-Upd (%s): Built L%d Pseudo LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus", + circuit->area->area_tag, level, lsp->hdr.lsp_id, + lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum, + lsp->hdr.rem_lifetime, refresh_time); } return ISIS_OK; @@ -1970,10 +1982,10 @@ static int lsp_regenerate_pseudo(struct isis_circuit *circuit, int level) uint8_t lsp_id[ISIS_SYS_ID_LEN + 2]; uint16_t rem_lifetime, refresh_time; - if ((circuit->is_type & level) != level - || (circuit->state != C_STATE_UP) - || (circuit->circ_type != CIRCUIT_T_BROADCAST) - || (circuit->u.bc.is_dr[level - 1] == 0)) + if ((circuit->is_type & level) != level || + (circuit->state != C_STATE_UP) || + (circuit->circ_type != CIRCUIT_T_BROADCAST) || + (circuit->u.bc.is_dr[level - 1] == 0)) return ISIS_ERROR; memcpy(lsp_id, circuit->isis->sysid, ISIS_SYS_ID_LEN); @@ -2007,11 +2019,10 @@ static int lsp_regenerate_pseudo(struct isis_circuit *circuit, int level) &circuit->u.bc.t_refresh_pseudo_lsp[level - 1]); if (IS_DEBUG_UPDATE_PACKETS) { - zlog_debug( - "ISIS-Upd (%s): Refreshed L%d Pseudo LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus", - circuit->area->area_tag, level, lsp->hdr.lsp_id, - lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum, - lsp->hdr.rem_lifetime, refresh_time); + zlog_debug("ISIS-Upd (%s): Refreshed L%d Pseudo LSP %pLS, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus", + circuit->area->area_tag, level, lsp->hdr.lsp_id, + lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum, + lsp->hdr.rem_lifetime, refresh_time); } return ISIS_OK; @@ -2030,8 +2041,8 @@ static void lsp_l1_refresh_pseudo(struct event *thread) circuit->u.bc.t_refresh_pseudo_lsp[0] = NULL; circuit->lsp_regenerate_pending[0] = 0; - if ((circuit->u.bc.is_dr[0] == 0) - || (circuit->is_type & IS_LEVEL_1) == 0) { + if ((circuit->u.bc.is_dr[0] == 0) || + (circuit->is_type & IS_LEVEL_1) == 0) { memcpy(id, circuit->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(id) = circuit->circuit_id; LSP_FRAGMENT(id) = 0; @@ -2052,8 +2063,8 @@ static void lsp_l2_refresh_pseudo(struct event *thread) circuit->u.bc.t_refresh_pseudo_lsp[1] = NULL; circuit->lsp_regenerate_pending[1] = 0; - if ((circuit->u.bc.is_dr[1] == 0) - || (circuit->is_type & IS_LEVEL_2) == 0) { + if ((circuit->u.bc.is_dr[1] == 0) || + (circuit->is_type & IS_LEVEL_2) == 0) { memcpy(id, circuit->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(id) = circuit->circuit_id; LSP_FRAGMENT(id) = 0; @@ -2073,14 +2084,13 @@ int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level) int lvl; struct isis_area *area = circuit->area; - if (circuit->circ_type != CIRCUIT_T_BROADCAST - || circuit->state != C_STATE_UP) + if (circuit->circ_type != CIRCUIT_T_BROADCAST || + circuit->state != C_STATE_UP) return ISIS_OK; - sched_debug( - "ISIS (%s): Scheduling regeneration of %s pseudo LSP for interface %s", - area->area_tag, circuit_t2string(level), - circuit->interface->name); + sched_debug("ISIS (%s): Scheduling regeneration of %s pseudo LSP for interface %s", + area->area_tag, circuit_t2string(level), + circuit->interface->name); memcpy(lsp_id, area->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(lsp_id) = circuit->circuit_id; @@ -2088,9 +2098,8 @@ int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level) now = time(NULL); for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) { - sched_debug( - "ISIS (%s): Checking whether L%d pseudo LSP needs to be scheduled", - area->area_tag, lvl); + sched_debug("ISIS (%s): Checking whether L%d pseudo LSP needs to be scheduled", + area->area_tag, lvl); if (!((level & lvl) && (circuit->is_type & lvl))) { sched_debug("ISIS (%s): Level is not active on circuit", @@ -2099,63 +2108,61 @@ int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level) } if (circuit->u.bc.is_dr[lvl - 1] == 0) { - sched_debug( - "ISIS (%s): This IS is not DR, nothing to do.", - area->area_tag); + sched_debug("ISIS (%s): This IS is not DR, nothing to do.", + area->area_tag); continue; } if (circuit->lsp_regenerate_pending[lvl - 1]) { struct timeval remain = event_timer_remain( circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]); - sched_debug( - "ISIS (%s): Regenerate is already pending, nothing todo. (Due in %lld.%03lld seconds)", - area->area_tag, (long long)remain.tv_sec, - (long long)remain.tv_usec / 1000); + sched_debug("ISIS (%s): Regenerate is already pending, nothing todo. (Due in %lld.%03lld seconds)", + area->area_tag, (long long)remain.tv_sec, + (long long)remain.tv_usec / 1000); continue; } lsp = lsp_search(&circuit->area->lspdb[lvl - 1], lsp_id); if (!lsp) { - sched_debug( - "ISIS (%s): Pseudonode LSP does not exist yet, nothing to regenerate.", - area->area_tag); + sched_debug("ISIS (%s): Pseudonode LSP does not exist yet, nothing to regenerate.", + area->area_tag); continue; } /* * Throttle avoidance */ - sched_debug( - "ISIS (%s): Will schedule PSN regen timer. Last run was: %lld, Now is: %lld", - area->area_tag, (long long)lsp->last_generated, - (long long)now); + sched_debug("ISIS (%s): Will schedule PSN regen timer. Last run was: %lld, Now is: %lld", + area->area_tag, (long long)lsp->last_generated, + (long long)now); EVENT_OFF(circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]); diff = now - lsp->last_generated; if (diff < circuit->area->lsp_gen_interval[lvl - 1]) { - timeout = - 1000 * (circuit->area->lsp_gen_interval[lvl - 1] - - diff); - sched_debug( - "ISIS (%s): Sechduling in %ld ms to match configured lsp_gen_interval", - area->area_tag, timeout); + timeout = 1000 * + (circuit->area->lsp_gen_interval[lvl - 1] - + diff); + sched_debug("ISIS (%s): Sechduling in %ld ms to match configured lsp_gen_interval", + area->area_tag, timeout); } else { timeout = 100; - sched_debug( - "ISIS (%s): Last generation was more than lsp_gen_interval ago. Scheduling for execution in %ld ms.", - area->area_tag, timeout); + sched_debug("ISIS (%s): Last generation was more than lsp_gen_interval ago. Scheduling for execution in %ld ms.", + area->area_tag, timeout); } circuit->lsp_regenerate_pending[lvl - 1] = 1; if (lvl == IS_LEVEL_1) { - event_add_timer_msec( - master, lsp_l1_refresh_pseudo, circuit, timeout, - &circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]); + event_add_timer_msec(master, lsp_l1_refresh_pseudo, + circuit, timeout, + &circuit->u.bc + .t_refresh_pseudo_lsp[lvl - + 1]); } else if (lvl == IS_LEVEL_2) { - event_add_timer_msec( - master, lsp_l2_refresh_pseudo, circuit, timeout, - &circuit->u.bc.t_refresh_pseudo_lsp[lvl - 1]); + event_add_timer_msec(master, lsp_l2_refresh_pseudo, + circuit, timeout, + &circuit->u.bc + .t_refresh_pseudo_lsp[lvl - + 1]); } } @@ -2220,10 +2227,9 @@ void lsp_tick(struct event *thread) } if (lsp->age_out == 0) { - zlog_debug( - "ISIS-Upd (%s): L%u LSP %pLS seq 0x%08x aged out", - area->area_tag, lsp->level, - lsp->hdr.lsp_id, lsp->hdr.seqno); + zlog_debug("ISIS-Upd (%s): L%u LSP %pLS seq 0x%08x aged out", + area->area_tag, lsp->level, + lsp->hdr.lsp_id, lsp->hdr.seqno); /* if we're aging out fragment 0, lsp_destroy() * below will delete all other fragments too, @@ -2231,12 +2237,11 @@ void lsp_tick(struct event *thread) */ if (!LSP_FRAGMENT(lsp->hdr.lsp_id)) while (next && - !memcmp(next->hdr.lsp_id, - lsp->hdr.lsp_id, - ISIS_SYS_ID_LEN + 1)) - next = lspdb_next( - &area->lspdb[level], - next); + !memcmp(next->hdr.lsp_id, + lsp->hdr.lsp_id, + ISIS_SYS_ID_LEN + 1)) + next = lspdb_next(&area->lspdb[level], + next); lspdb_del(&area->lspdb[level], lsp); lsp_destroy(lsp); @@ -2251,9 +2256,8 @@ void lsp_tick(struct event *thread) } } - if (fabricd_init_c - && !fabricd_sync_incomplete - && !isis_tx_queue_len(fabricd_init_c->tx_queue)) { + if (fabricd_init_c && !fabricd_sync_incomplete && + !isis_tx_queue_len(fabricd_init_c->tx_queue)) { fabricd_initial_sync_finish(area); } } @@ -2314,8 +2318,7 @@ void lsp_set_all_srmflags(struct isis_lsp *lsp, bool set) struct list *circuit_list = lsp->area->circuit_list; for (ALL_LIST_ELEMENTS_RO(circuit_list, node, circuit)) { if (set) { - isis_tx_queue_add(circuit->tx_queue, lsp, - TX_LSP_NORMAL); + isis_tx_queue_add(circuit->tx_queue, lsp, TX_LSP_NORMAL); } else { isis_tx_queue_del(circuit->tx_queue, lsp); } @@ -2369,11 +2372,12 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid, /* Parse LSP */ if (lsp->tlvs) { - if (!fabricd && !pseudo_lsp && family == AF_INET - && mtid == ISIS_MT_IPV4_UNICAST) { + if (!fabricd && !pseudo_lsp && family == AF_INET && + mtid == ISIS_MT_IPV4_UNICAST) { struct isis_item_list *reachs[] = { &lsp->tlvs->oldstyle_ip_reach, - &lsp->tlvs->oldstyle_ip_reach_ext}; + &lsp->tlvs->oldstyle_ip_reach_ext + }; for (unsigned int i = 0; i < array_size(reachs); i++) { struct isis_oldstyle_ip_reach *r; @@ -2386,8 +2390,7 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid, if ((*cb)((struct prefix *)&r->prefix, r->metric, external, NULL, - arg) - == LSP_ITER_STOP) + arg) == LSP_ITER_STOP) return LSP_ITER_STOP; } } @@ -2399,8 +2402,9 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid, if (mtid == ISIS_MT_IPV4_UNICAST) ipv4_reachs = &lsp->tlvs->extended_ip_reach; else - ipv4_reachs = isis_lookup_mt_items( - &lsp->tlvs->mt_ip_reach, mtid); + ipv4_reachs = + isis_lookup_mt_items(&lsp->tlvs->mt_ip_reach, + mtid); struct isis_extended_ip_reach *r; for (r = ipv4_reachs ? (struct isis_extended_ip_reach *) @@ -2408,8 +2412,8 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid, : NULL; r; r = r->next) { if ((*cb)((struct prefix *)&r->prefix, - r->metric, false, r->subtlvs, arg) - == LSP_ITER_STOP) + r->metric, false, r->subtlvs, + arg) == LSP_ITER_STOP) return LSP_ITER_STOP; } } @@ -2421,8 +2425,9 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid, if (mtid == ISIS_MT_IPV4_UNICAST) ipv6_reachs = &lsp->tlvs->ipv6_reach; else - ipv6_reachs = isis_lookup_mt_items( - &lsp->tlvs->mt_ipv6_reach, mtid); + ipv6_reachs = + isis_lookup_mt_items(&lsp->tlvs->mt_ipv6_reach, + mtid); for (r = ipv6_reachs ? (struct isis_ipv6_reach *) ipv6_reachs->head @@ -2430,8 +2435,7 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid, r; r = r->next) { if ((*cb)((struct prefix *)&r->prefix, r->metric, r->external, r->subtlvs, - arg) - == LSP_ITER_STOP) + arg) == LSP_ITER_STOP) return LSP_ITER_STOP; } } @@ -2444,8 +2448,7 @@ int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid, continue; if (isis_lsp_iterate_ip_reach(frag, family, mtid, cb, - arg) - == LSP_ITER_STOP) + arg) == LSP_ITER_STOP) return LSP_ITER_STOP; } @@ -2476,8 +2479,7 @@ int isis_lsp_iterate_is_reach(struct isis_lsp *lsp, uint16_t mtid, (struct isis_oldstyle_reach *)head; reach; reach = reach->next) { if ((*cb)(reach->id, reach->metric, true, NULL, - arg) - == LSP_ITER_STOP) + arg) == LSP_ITER_STOP) return LSP_ITER_STOP; } } @@ -2485,16 +2487,15 @@ int isis_lsp_iterate_is_reach(struct isis_lsp *lsp, uint16_t mtid, if (pseudo_lsp || mtid == ISIS_MT_IPV4_UNICAST) te_neighs = &lsp->tlvs->extended_reach; else - te_neighs = - isis_get_mt_items(&lsp->tlvs->mt_reach, mtid); + te_neighs = isis_get_mt_items(&lsp->tlvs->mt_reach, + mtid); if (te_neighs) { head = te_neighs->head; for (struct isis_extended_reach *reach = (struct isis_extended_reach *)head; reach; reach = reach->next) { if ((*cb)(reach->id, reach->metric, false, - reach->subtlvs, arg) - == LSP_ITER_STOP) + reach->subtlvs, arg) == LSP_ITER_STOP) return LSP_ITER_STOP; } } @@ -2506,8 +2507,8 @@ int isis_lsp_iterate_is_reach(struct isis_lsp *lsp, uint16_t mtid, if (!frag->tlvs) continue; - if (isis_lsp_iterate_is_reach(frag, mtid, cb, arg) - == LSP_ITER_STOP) + if (isis_lsp_iterate_is_reach(frag, mtid, cb, arg) == + LSP_ITER_STOP) return LSP_ITER_STOP; } @@ -2517,6 +2518,5 @@ int isis_lsp_iterate_is_reach(struct isis_lsp *lsp, uint16_t mtid, void lsp_init(void) { device_startup = true; - hook_register(isis_adj_state_change_hook, - lsp_handle_adj_state_change); + hook_register(isis_adj_state_change_hook, lsp_handle_adj_state_change); }