Skip to content

Commit

Permalink
isisd: fix crash when a sys-id a configured after a flex-algo definition
Browse files Browse the repository at this point in the history
A isisd crash happens when the IS-IS system-id is defined after a
flex-algo definition and before IS-IS segment-routing.

After the isisd startup, do:
> router isis 1
>  is-type level-1
>  flex-algo 128
>   advertise-definition
>   dataplane sr-mpls
>   affinity include-all blue green
>  net 49.0000.0000.0000.1000.00

It causes this crash:
> #0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50
> #1  0x00007fb9403c2ac4 in core_handler (signo=6, siginfo=0x7ffd6a538130, context=0x7ffd6a538000) at /build/tools-build-framework/output/_packages/cp-routing/src/lib/sigevent.c:262
> #2  <signal handler called>
> #3  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> FRRouting#4  0x00007fb9400c0859 in __GI_abort () at abort.c:79
> FRRouting#5  0x00007fb940400608 in _zlog_assert_failed ( xref=0x559ed6e3baa0 <_xref.21401>, extra=0x0) at /build/tools-build-framework/output/_packages/cp-routing/src/lib/zlog.c:557
> FRRouting#6  0x0000559ed6d8191e in copy_tlv_router_cap (router_cap=0x559ed7d7b8b0) at /build/tools-build-framework/output/_packages/cp-routing/src/isisd/isis_tlvs.c:3681
> FRRouting#7  0x0000559ed6d86133 in pack_tlvs (tlvs=0x559ed7d7b4f0,  stream=0x559ed7d7c1e0, fragment_tlvs=0x559ed7d7c7d0,  new_fragment=0x559ed6d863ab <new_fragment>,  new_fragment_arg=0x559ed7d70c50) at /build/tools-build-framework/output/_packages/cp-routing/src/isisd/isis_tlvs.c:5393
> FRRouting#8  0x0000559ed6d8644b in isis_fragment_tlvs (tlvs=0x559ed7d7b4f0, size=1470) at /build/tools-build-framework/output/_packages/cp-routing/src/isisd/isis_tlvs.c:5476
> FRRouting#9  0x0000559ed6d4b014 in lsp_build (lsp=0x559ed7d7adb0, area=0x559ed7d40a40) at /build/tools-build-framework/output/_packages/cp-routing/src/isisd/isis_lsp.c:1361
> FRRouting#10 0x0000559ed6d4b496 in lsp_generate (area=0x559ed7d40a40, level=1) at /build/tools-build-framework/output/_packages/cp-routing/src/isisd/isis_lsp.c:1434
> FRRouting#11 0x0000559ed6d9fee5 in isis_instance_area_address_create ( args=0x7ffd6a54fe70) at /build/tools-build-framework/output/_packages/cp-routing/src/isisd/isis_nb_config.c:229
> FRRouting#12 0x00007fb940393e1f in nb_callback_create (context=0x7ffd6a550480,  nb_node=0x559ed7b8ad70, event=NB_EV_APPLY, dnode=0x559ed7d54e20,  resource=0x559ed7d7aa28, errmsg=0x7ffd6a550490 "", errmsg_len=8192) at /build/tools-build-framework/output/_packages/cp-routing/src/lib/northbound.c:1035

isis_lsp_set_router_capability_fad() only sets cap_fad[fa->algorithm]
when segment-routing is enabled. cap_fad[fa->algorithm] admin-group data
pointers are not allocated when segment-routing is off. However, when
setting the flex-algo definition into router capabilities,
cap_fad[fa->algorithm] is copied. Flex-algo definitions are set even
segment-routing is not set (which complies with the flex-algo IETF
draft). When copying the router capability later, a crash happens
because a admin-group pointer is NULL.

Set cap_fad[fa->algorithm] even if segment-routing is off.

Fixes: 93b0b7f ("isisd: add isis flex-algo lsp advertisement")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
  • Loading branch information
louis-6wind committed Oct 18, 2022
1 parent fc32d97 commit e04704c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions isisd/isis_lsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,14 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)

cap.router_id.s_addr = area->isis->router_id;

for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos, node,
fa)) {
if (!fa->advertise_definition)
continue;
isis_lsp_set_router_capability_fad(
area, &cap_fad[fa->algorithm], fa);
}

/* Add SR Sub-TLVs if SR is enabled. */
if (area->srdb.enabled) {
struct isis_sr_db *srdb = &area->srdb;
Expand All @@ -1135,9 +1143,6 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area)
for (ALL_LIST_ELEMENTS_RO(area->flex_algos->flex_algos,
node, fa)) {
if (fa->advertise_definition) {
isis_lsp_set_router_capability_fad(
area, &cap_fad[fa->algorithm],
fa);
rcap_fad = &cap_fad[fa->algorithm];
} else
rcap_fad = NULL;
Expand Down

0 comments on commit e04704c

Please sign in to comment.