diff options
Diffstat (limited to 'isisd/isis_lsp.c')
| -rw-r--r-- | isisd/isis_lsp.c | 121 |
1 files changed, 53 insertions, 68 deletions
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 63303e2308..90c7c0efb5 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -200,16 +200,12 @@ int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno, || (lsp->hdr.rem_lifetime != 0 && rem_lifetime != 0))) { if (IS_DEBUG_SNP_PACKETS) { zlog_debug( - "ISIS-Snp (%s): Compare LSP %s seq 0x%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 - "s", + "ISIS-Snp (%s): Compare LSP %s seq 0x%08x, cksum 0x%04hx, lifetime %hus", areatag, rawlspid_print(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%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 - "s", + "ISIS-Snp (%s): is equal to ours seq 0x%08x, cksum 0x%04hx, lifetime %hus", areatag, seqno, checksum, rem_lifetime); } return LSP_EQUAL; @@ -234,28 +230,22 @@ int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno, && lsp->hdr.rem_lifetime)))) { if (IS_DEBUG_SNP_PACKETS) { zlog_debug( - "ISIS-Snp (%s): Compare LSP %s seq 0x%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 - "s", + "ISIS-Snp (%s): Compare LSP %s seq 0x%08x, cksum 0x%04hx, lifetime %hus", areatag, rawlspid_print(lsp->hdr.lsp_id), seqno, checksum, rem_lifetime); zlog_debug( - "ISIS-Snp (%s): is newer than ours seq 0x%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 - "s", + "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 %s seq 0x%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 "s", + zlog_debug("ISIS-Snp (%s): Compare LSP %s seq 0x%08x, cksum 0x%04hx, lifetime %hus", areatag, rawlspid_print(lsp->hdr.lsp_id), seqno, checksum, rem_lifetime); zlog_debug( - "ISIS-Snp (%s): is older than ours seq 0x%08" PRIx32 - ", cksum 0x%04" PRIx16 ", lifetime %" PRIu16 "s", + "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); } @@ -348,13 +338,17 @@ void lsp_inc_seqno(struct isis_lsp *lsp, uint32_t seqno) static void lsp_purge_add_poi(struct isis_lsp *lsp, const uint8_t *sender) { + if (lsp->area == NULL) + return; + if (!lsp->area->purge_originator) return; /* add purge originator identification */ if (!lsp->tlvs) lsp->tlvs = isis_alloc_tlvs(); - isis_tlvs_set_purge_originator(lsp->tlvs, isis->sysid, sender); + isis_tlvs_set_purge_originator(lsp->tlvs, lsp->area->isis->sysid, + sender); isis_tlvs_set_dynamic_hostname(lsp->tlvs, cmd_hostname_get()); } @@ -601,7 +595,8 @@ static void lsp_set_time(struct isis_lsp *lsp) stream_putw_at(lsp->pdu, 10, lsp->hdr.rem_lifetime); } -void lspid_print(uint8_t *lsp_id, char *dest, char dynhost, char frag) +void lspid_print(uint8_t *lsp_id, char *dest, char dynhost, char frag, + struct isis *isis) { struct isis_dynhn *dyn = NULL; char id[SYSID_STRLEN]; @@ -617,6 +612,7 @@ void lspid_print(uint8_t *lsp_id, char *dest, char dynhost, char frag) snprintf(id, sizeof(id), "%.14s", cmd_hostname_get()); else memcpy(id, sysid_print(lsp_id), 15); + if (frag) sprintf(dest, "%s.%02x-%02x", id, LSP_PSEUDO_ID(lsp_id), LSP_FRAGMENT(lsp_id)); @@ -648,29 +644,31 @@ 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(struct isis_lsp *lsp, struct vty *vty, char dynhost) +void lsp_print(struct isis_lsp *lsp, struct vty *vty, char dynhost, + struct isis *isis) { char LSPid[255]; char age_out[8]; char b[200]; - lspid_print(lsp->hdr.lsp_id, LSPid, dynhost, 1); + lspid_print(lsp->hdr.lsp_id, LSPid, dynhost, 1, isis); vty_out(vty, "%-21s%c ", LSPid, lsp->own_lsp ? '*' : ' '); - vty_out(vty, "%5" PRIu16 " ", lsp->hdr.pdu_len); - vty_out(vty, "0x%08" PRIx32 " ", lsp->hdr.seqno); - vty_out(vty, "0x%04" PRIx16 " ", lsp->hdr.checksum); + vty_out(vty, "%5hu ", lsp->hdr.pdu_len); + vty_out(vty, "0x%08x ", lsp->hdr.seqno); + vty_out(vty, "0x%04hx ", lsp->hdr.checksum); if (lsp->hdr.rem_lifetime == 0) { snprintf(age_out, sizeof(age_out), "(%d)", lsp->age_out); age_out[7] = '\0'; vty_out(vty, "%7s ", age_out); } else - vty_out(vty, " %5" PRIu16 " ", lsp->hdr.rem_lifetime); + vty_out(vty, " %5hu ", lsp->hdr.rem_lifetime); vty_out(vty, "%s\n", lsp_bits2string(lsp->hdr.lsp_bits, b, sizeof(b))); } -void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost) +void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost, + struct isis *isis) { - lsp_print(lsp, vty, dynhost); + lsp_print(lsp, vty, dynhost, isis); if (lsp->tlvs) vty_multiline(vty, " ", "%s", isis_format_tlvs(lsp->tlvs)); vty_out(vty, "\n"); @@ -678,19 +676,19 @@ void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost) /* print all the lsps info in the local lspdb */ int lsp_print_all(struct vty *vty, struct lspdb_head *head, char detail, - char dynhost) + char dynhost, struct isis *isis) { struct isis_lsp *lsp; int lsp_count = 0; if (detail == ISIS_UI_LEVEL_BRIEF) { frr_each (lspdb, head, lsp) { - lsp_print(lsp, vty, dynhost); + lsp_print(lsp, vty, dynhost, isis); lsp_count++; } } else if (detail == ISIS_UI_LEVEL_DETAIL) { frr_each (lspdb, head, lsp) { - lsp_print_detail(lsp, vty, dynhost); + lsp_print_detail(lsp, vty, dynhost, isis); lsp_count++; } } @@ -923,10 +921,10 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) } /* Add Router Capability TLV. */ - if (isis->router_id != 0) { + if (area->isis->router_id != 0) { struct isis_router_cap cap = {}; - cap.router_id.s_addr = isis->router_id; + cap.router_id.s_addr = area->isis->router_id; /* Add SR Sub-TLVs if SR is enabled. */ if (area->srdb.enabled) { @@ -964,8 +962,8 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) * into LSP. TE router ID will be the same if MPLS-TE * is not activate or MPLS-TE router-id not specified */ - if (isis->router_id != 0) { - struct in_addr id = {.s_addr = isis->router_id}; + if (area->isis->router_id != 0) { + struct in_addr id = {.s_addr = area->isis->router_id}; inet_ntop(AF_INET, &id, buf, sizeof(buf)); lsp_debug("ISIS (%s): Adding router ID %s as IPv4 tlv.", area->area_tag, buf); @@ -994,7 +992,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) if (fabricd) { lsp_debug( - "ISIS (%s): Adding tier %" PRIu8 " spine-leaf-extension tlv.", + "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); @@ -1220,7 +1218,8 @@ int lsp_generate(struct isis_area *area, int level) return ISIS_ERROR; memset(&lspid, 0, ISIS_SYS_ID_LEN + 2); - memcpy(&lspid, isis->sysid, ISIS_SYS_ID_LEN); + + memcpy(&lspid, area->isis->sysid, ISIS_SYS_ID_LEN); /* only builds the lsp if the area shares the level */ oldlsp = lsp_search(&area->lspdb[level - 1], lspid); @@ -1256,9 +1255,7 @@ int lsp_generate(struct isis_area *area, int level) &area->t_lsp_refresh[level - 1]); if (IS_DEBUG_UPDATE_PACKETS) { - zlog_debug("ISIS-Upd (%s): Building L%d LSP %s, len %" PRIu16 - ", seq 0x%08" PRIx32 ", cksum 0x%04" PRIx16 - ", lifetime %" PRIu16 "s refresh %" PRIu16 "s", + zlog_debug("ISIS-Upd (%s): Building L%d LSP %s, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus", area->area_tag, level, rawlspid_print(newlsp->hdr.lsp_id), newlsp->hdr.pdu_len, newlsp->hdr.seqno, @@ -1293,9 +1290,8 @@ static int lsp_regenerate(struct isis_area *area, int level) return ISIS_ERROR; head = &area->lspdb[level - 1]; - memset(lspid, 0, ISIS_SYS_ID_LEN + 2); - memcpy(lspid, isis->sysid, ISIS_SYS_ID_LEN); + memcpy(lspid, area->isis->sysid, ISIS_SYS_ID_LEN); lsp = lsp_search(head, lspid); @@ -1341,9 +1337,7 @@ static int lsp_regenerate(struct isis_area *area, int level) if (IS_DEBUG_UPDATE_PACKETS) { zlog_debug( - "ISIS-Upd (%s): Refreshed our L%d LSP %s, len %" PRIu16 - ", seq 0x%08" PRIx32 ", cksum 0x%04" PRIx16 - ", lifetime %" PRIu16 "s refresh %" PRIu16 "s", + "ISIS-Upd (%s): Refreshed our L%d LSP %s, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus refresh %hus", area->area_tag, level, rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum, lsp->hdr.rem_lifetime, refresh_time); @@ -1413,13 +1407,12 @@ int _lsp_regenerate_schedule(struct isis_area *area, int level, return ISIS_ERROR; sched_debug( - "ISIS (%s): Scheduling regeneration of %s LSPs, %sincluding PSNs" - " Caller: %s %s:%d", + "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, isis->sysid, ISIS_SYS_ID_LEN); + memcpy(id, area->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(id) = LSP_FRAGMENT(id) = 0; now = time(NULL); @@ -1444,8 +1437,7 @@ int _lsp_regenerate_schedule(struct isis_area *area, int level, struct timeval remain = thread_timer_remain( area->t_lsp_refresh[lvl - 1]); sched_debug( - "ISIS (%s): Regeneration is already pending, nothing todo." - " (Due in %lld.%03lld seconds)", + "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; @@ -1541,7 +1533,7 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit, */ uint8_t ne_id[ISIS_SYS_ID_LEN + 1]; - memcpy(ne_id, isis->sysid, ISIS_SYS_ID_LEN); + memcpy(ne_id, area->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(ne_id) = 0; if (circuit->area->oldmetric) { @@ -1553,7 +1545,7 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit, } if (circuit->area->newmetric) { isis_tlvs_add_extended_reach(lsp->tlvs, ISIS_MT_IPV4_UNICAST, - ne_id, 0, circuit->ext); + ne_id, 0, NULL); lsp_debug( "ISIS (%s): Adding %s.%02x as te-style neighbor (self)", area->area_tag, sysid_print(ne_id), @@ -1595,7 +1587,7 @@ static void lsp_build_pseudo(struct isis_lsp *lsp, struct isis_circuit *circuit, if (circuit->area->newmetric) { isis_tlvs_add_extended_reach(lsp->tlvs, ISIS_MT_IPV4_UNICAST, - ne_id, 0, circuit->ext); + ne_id, 0, NULL); lsp_debug( "ISIS (%s): Adding %s.%02x as te-style neighbor (peer)", area->area_tag, sysid_print(ne_id), @@ -1619,7 +1611,7 @@ int lsp_generate_pseudo(struct isis_circuit *circuit, int level) || (circuit->u.bc.is_dr[level - 1] == 0)) return ISIS_ERROR; - memcpy(lsp_id, isis->sysid, ISIS_SYS_ID_LEN); + memcpy(lsp_id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN); LSP_FRAGMENT(lsp_id) = 0; LSP_PSEUDO_ID(lsp_id) = circuit->circuit_id; @@ -1656,9 +1648,7 @@ int lsp_generate_pseudo(struct isis_circuit *circuit, int level) if (IS_DEBUG_UPDATE_PACKETS) { zlog_debug( - "ISIS-Upd (%s): Built L%d Pseudo LSP %s, len %" PRIu16 - ", seq 0x%08" PRIx32 ", cksum 0x%04" PRIx16 - ", lifetime %" PRIu16 "s, refresh %" PRIu16 "s", + "ISIS-Upd (%s): Built L%d Pseudo LSP %s, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus", circuit->area->area_tag, level, rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum, @@ -1681,7 +1671,7 @@ static int lsp_regenerate_pseudo(struct isis_circuit *circuit, int level) || (circuit->u.bc.is_dr[level - 1] == 0)) return ISIS_ERROR; - memcpy(lsp_id, isis->sysid, ISIS_SYS_ID_LEN); + memcpy(lsp_id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(lsp_id) = circuit->circuit_id; LSP_FRAGMENT(lsp_id) = 0; @@ -1713,9 +1703,7 @@ static int lsp_regenerate_pseudo(struct isis_circuit *circuit, int level) if (IS_DEBUG_UPDATE_PACKETS) { zlog_debug( - "ISIS-Upd (%s): Refreshed L%d Pseudo LSP %s, len %" PRIu16 - ", seq 0x%08" PRIx32 ", cksum 0x%04" PRIx16 - ", lifetime %" PRIu16 "s, refresh %" PRIu16 "s", + "ISIS-Upd (%s): Refreshed L%d Pseudo LSP %s, len %hu, seq 0x%08x, cksum 0x%04hx, lifetime %hus, refresh %hus", circuit->area->area_tag, level, rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.pdu_len, lsp->hdr.seqno, lsp->hdr.checksum, @@ -1740,7 +1728,7 @@ static int lsp_l1_refresh_pseudo(struct thread *thread) if ((circuit->u.bc.is_dr[0] == 0) || (circuit->is_type & IS_LEVEL_1) == 0) { - memcpy(id, isis->sysid, ISIS_SYS_ID_LEN); + memcpy(id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(id) = circuit->circuit_id; LSP_FRAGMENT(id) = 0; lsp_purge_pseudo(id, circuit, IS_LEVEL_1); @@ -1762,7 +1750,7 @@ static int lsp_l2_refresh_pseudo(struct thread *thread) if ((circuit->u.bc.is_dr[1] == 0) || (circuit->is_type & IS_LEVEL_2) == 0) { - memcpy(id, isis->sysid, ISIS_SYS_ID_LEN); + memcpy(id, circuit->area->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(id) = circuit->circuit_id; LSP_FRAGMENT(id) = 0; lsp_purge_pseudo(id, circuit, IS_LEVEL_2); @@ -1790,7 +1778,7 @@ int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level) area->area_tag, circuit_t2string(level), circuit->interface->name); - memcpy(lsp_id, isis->sysid, ISIS_SYS_ID_LEN); + memcpy(lsp_id, area->isis->sysid, ISIS_SYS_ID_LEN); LSP_PSEUDO_ID(lsp_id) = circuit->circuit_id; LSP_FRAGMENT(lsp_id) = 0; now = time(NULL); @@ -1817,8 +1805,7 @@ int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level) struct timeval remain = thread_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)", + "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; @@ -1851,8 +1838,7 @@ int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level) } else { timeout = 100; sched_debug( - "ISIS (%s): Last generation was more than lsp_gen_interval ago." - " Scheduling for execution in %ld ms.", + "ISIS (%s): Last generation was more than lsp_gen_interval ago. Scheduling for execution in %ld ms.", area->area_tag, timeout); } @@ -1930,8 +1916,7 @@ int lsp_tick(struct thread *thread) if (lsp->age_out == 0) { zlog_debug( - "ISIS-Upd (%s): L%u LSP %s seq " - "0x%08" PRIx32 " aged out", + "ISIS-Upd (%s): L%u LSP %s seq 0x%08x aged out", area->area_tag, lsp->level, rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.seqno); |
