From d07067ba45397eb3b478e4c7a28c2a14ad674d4e Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 16 Oct 2018 19:17:10 +0200 Subject: [PATCH] isisd: adjust lsp size to area->lsp_size before packing IS-IS would ignore any area lsp-mtu setting configured after initial creation of the LSP since move to the new tlv serialized/deserializer. Signed-off-by: Christian Franke --- isisd/isis_lsp.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index bf61ae05b0..558bc4276b 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -522,6 +522,17 @@ struct isis_lsp *lsp_new_from_recv(struct isis_lsp_hdr *hdr, return lsp; } +static void lsp_adjust_stream(struct isis_lsp *lsp) +{ + if (lsp->pdu) { + if (STREAM_SIZE(lsp->pdu) == LLC_LEN + lsp->area->lsp_mtu) + return; + stream_free(lsp->pdu); + } + + lsp->pdu = stream_new(LLC_LEN + lsp->area->lsp_mtu); +} + 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, @@ -532,7 +543,7 @@ struct isis_lsp *lsp_new(struct isis_area *area, uint8_t *lsp_id, lsp = XCALLOC(MTYPE_ISIS_LSP, sizeof(struct isis_lsp)); lsp->area = area; - lsp->pdu = stream_new(LLC_LEN + area->lsp_mtu); + lsp_adjust_stream(lsp); /* Minimal LSP PDU size */ lsp->hdr.pdu_len = ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN; @@ -1153,6 +1164,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) struct isis_tlvs *tlvs = lsp->tlvs; lsp->tlvs = NULL; + lsp_adjust_stream(lsp); lsp_pack_pdu(lsp); size_t tlv_space = STREAM_WRITEABLE(lsp->pdu) - LLC_LEN; lsp_clear_data(lsp); @@ -1184,6 +1196,7 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) frag = lsp_next_frag(LSP_FRAGMENT(frag->hdr.lsp_id) + 1, lsp, area, level); + lsp_adjust_stream(frag); } frag->tlvs = tlvs; } @@ -1956,7 +1969,7 @@ void lsp_purge_non_exist(int level, struct isis_lsp_hdr *hdr, lsp = XCALLOC(MTYPE_ISIS_LSP, sizeof(struct isis_lsp)); lsp->area = area; lsp->level = level; - lsp->pdu = stream_new(LLC_LEN + area->lsp_mtu); + lsp_adjust_stream(lsp); lsp->age_out = ZERO_AGE_LIFETIME; memcpy(&lsp->hdr, hdr, sizeof(lsp->hdr)); -- 2.39.5