Skip to content

Commit

Permalink
isisd: fix crash at flex-algo affinity setting
Browse files Browse the repository at this point in the history
The following causes a isisd crash.

> # cat config
> affinity-map green bit-position 0
> router isis 1
>  flex-algo 129
>   affinity exclude-any green
> # vtysh -f config

> #0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50
> FRRouting#1  0x00007f650cd32756 in core_handler (signo=6, siginfo=0x7ffc56f93070, context=0x7ffc56f92f40) at lib/sigevent.c:258
> FRRouting#2  <signal handler called>
> FRRouting#3  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> FRRouting#4  0x00007f650c91c537 in __GI_abort () at abort.c:79
> FRRouting#5  0x00007f650cd007c9 in nb_running_get_entry_worker (dnode=0x0, xpath=0x0, abort_if_not_found=true, rec_search=true) at lib/northbound.c:2531
> FRRouting#6  0x00007f650cd007f9 in nb_running_get_entry (dnode=0x55d9ad406e00, xpath=0x0, abort_if_not_found=true) at lib/northbound.c:2537
> FRRouting#7  0x000055d9ab302248 in isis_instance_flex_algo_affinity_set (args=0x7ffc56f947a0, type=2) at isisd/isis_nb_config.c:2998
> FRRouting#8  0x000055d9ab3027c0 in isis_instance_flex_algo_affinity_exclude_any_create (args=0x7ffc56f947a0) at isisd/isis_nb_config.c:3155
> FRRouting#9  0x00007f650ccfe284 in nb_callback_create (context=0x7ffc56f94d20, nb_node=0x55d9ad28b540, event=NB_EV_VALIDATE, dnode=0x55d9ad406e00, resource=0x0, errmsg=0x7ffc56f94de0 "",
>     errmsg_len=8192) at lib/northbound.c:1487
> FRRouting#10 0x00007f650ccff067 in nb_callback_configuration (context=0x7ffc56f94d20, event=NB_EV_VALIDATE, change=0x55d9ad406d40, errmsg=0x7ffc56f94de0 "", errmsg_len=8192) at lib/northbound.c:1884
> FRRouting#11 0x00007f650ccfda31 in nb_candidate_validate_code (context=0x7ffc56f94d20, candidate=0x55d9ad20d710, changes=0x7ffc56f94d38, errmsg=0x7ffc56f94de0 "", errmsg_len=8192)
>     at lib/northbound.c:1246
> FRRouting#12 0x00007f650ccfdc67 in nb_candidate_commit_prepare (context=..., candidate=0x55d9ad20d710, comment=0x0, transaction=0x7ffc56f94da0, skip_validate=false, ignore_zero_change=false,
>     errmsg=0x7ffc56f94de0 "", errmsg_len=8192) at lib/northbound.c:1317
> FRRouting#13 0x00007f650ccfdec4 in nb_candidate_commit (context=..., candidate=0x55d9ad20d710, save_transaction=true, comment=0x0, transaction_id=0x0, errmsg=0x7ffc56f94de0 "", errmsg_len=8192)
>     at lib/northbound.c:1381
> FRRouting#14 0x00007f650cd045ba in nb_cli_classic_commit (vty=0x55d9ad3f7490) at lib/northbound_cli.c:57
> FRRouting#15 0x00007f650cd04749 in nb_cli_pending_commit_check (vty=0x55d9ad3f7490) at lib/northbound_cli.c:96
> FRRouting#16 0x00007f650cc94340 in cmd_execute_command_real (vline=0x55d9ad3eea10, vty=0x55d9ad3f7490, cmd=0x0, up_level=0) at lib/command.c:1000
> FRRouting#17 0x00007f650cc94599 in cmd_execute_command (vline=0x55d9ad3eea10, vty=0x55d9ad3f7490, cmd=0x0, vtysh=0) at lib/command.c:1080
> FRRouting#18 0x00007f650cc94a0c in cmd_execute (vty=0x55d9ad3f7490, cmd=0x55d9ad401d30 "XFRR_end_configuration", matched=0x0, vtysh=0) at lib/command.c:1228
> FRRouting#19 0x00007f650cd523a4 in vty_command (vty=0x55d9ad3f7490, buf=0x55d9ad401d30 "XFRR_end_configuration") at lib/vty.c:625
> FRRouting#20 0x00007f650cd5413d in vty_execute (vty=0x55d9ad3f7490) at lib/vty.c:1388
> FRRouting#21 0x00007f650cd56353 in vtysh_read (thread=0x7ffc56f99370) at lib/vty.c:2400
> FRRouting#22 0x00007f650cd4b6fd in event_call (thread=0x7ffc56f99370) at lib/event.c:1996
> FRRouting#23 0x00007f650ccd1365 in frr_run (master=0x55d9ad103cf0) at lib/libfrr.c:1231
> FRRouting#24 0x000055d9ab29036e in main (argc=2, argv=0x7ffc56f99598, envp=0x7ffc56f995b0) at isisd/isis_main.c:354

Configuring the same in vtysh configure interactive mode works properly.
When using "vtysh -f", the northbound compatible configuration is
committed together whereas, in interactive mode, it committed line by
line. In the first situation, in validation state nb_running_get_entry()
fails because the area not yet in running.

Do not use nb_running_get_entry() northbound validation state.

Fixes: 893882e ("isisd: add isis flex-algo configuration backend")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
  • Loading branch information
louis-6wind authored and enkechen-panw committed Sep 14, 2024
1 parent bce2ff5 commit 1c4b9fe
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions isisd/isis_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2994,18 +2994,10 @@ static int isis_instance_flex_algo_affinity_set(struct nb_cb_create_args *args,
uint32_t algorithm;
const char *val;

algorithm = yang_dnode_get_uint32(args->dnode, "../../flex-algo");
area = nb_running_get_entry(args->dnode, NULL, true);
val = yang_dnode_get_string(args->dnode, ".");

switch (args->event) {
case NB_EV_VALIDATE:
fa = flex_algo_lookup(area->flex_algos, algorithm);
if (!fa) {
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,
Expand All @@ -3017,6 +3009,9 @@ 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");
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,
Expand Down Expand Up @@ -3057,18 +3052,10 @@ isis_instance_flex_algo_affinity_unset(struct nb_cb_destroy_args *args,
uint32_t algorithm;
const char *val;

algorithm = yang_dnode_get_uint32(args->dnode, "../../flex-algo");
area = nb_running_get_entry(args->dnode, NULL, true);
val = yang_dnode_get_string(args->dnode, ".");

switch (args->event) {
case NB_EV_VALIDATE:
fa = flex_algo_lookup(area->flex_algos, algorithm);
if (!fa) {
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,
Expand All @@ -3080,6 +3067,9 @@ 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");
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,
Expand Down

0 comments on commit 1c4b9fe

Please sign in to comment.