Skip to content

Commit

Permalink
sharpd: fix deleting nhid when suppressing nexthop from nh group
Browse files Browse the repository at this point in the history
When removing the last nexthop from a nexthop-group, the nexthop
group remains in the zebra contexts:

> ubuntu2204(config)# nexthop-group gdgd
> 2023/11/23 14:06:36 SHARP: [Q5NBA-GN1BG] NHG ID assigned: 179687502
> ubuntu2204(config-nh-group)# nexthop 192.0.2.7 loop1
> ubuntu2204(config-nh-group)# 2023/11/23 14:06:38 ZEBRA: [VNMVB-91G3G] _netlink_nexthop_build_group: ID (179687502): group 338
> 2023/11/23 14:06:38 ZEBRA: [R43C6-KYHWT] netlink_nexthop_msg_encode: RTM_NEWNEXTHOP, id=179687502
> 2023/11/23 14:06:38 ZEBRA: [HYEHE-CQZ9G] nl_batch_send: netlink-dp (NS 0), batch size=44, msg cnt=1
> 2023/11/23 14:06:38 SHARP: [JWRCN-N9K90] Installed nhg 179687502
>
> ubuntu2204(config-nh-group)# no nexthop 192.0.2.7 loop1
> 2023/11/23 14:06:47 SHARP: [Y2G2F-ZTW6M] nhg_add: nhg 179687502 not sent: no valid nexthops
> ubuntu2204(config-nh-group)# do show nexthop-group rib 179687502
> ID: 179687502 (sharp)
>      RefCnt: 1
>      Uptime: 00:00:23
>      VRF: default
>      Valid, Installed
>      Depends: (338)
>            via 192.0.2.7, loop1 (vrf default), weight 1

Fix this by sending an NHG_DEL message when no nexthops are attached,
and when the id was already installed.

Fixes: 5a9c093 ("sharpd: don't send invalid nexthop-groups to zebra")

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Nov 27, 2023
1 parent 77ff93b commit 6d0c978
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sharpd/sharp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,15 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
}

if (api_nhg.nexthop_num == 0) {
zlog_debug("%s: nhg %u not sent: no valid nexthops", __func__,
id);
is_valid = false;
if (sharp_nhgroup_id_is_installed(id)) {
zlog_debug("%s: nhg %u: no nexthops, deleting nexthop group", __func__,
id);
zclient_nhg_send(zclient, ZEBRA_NHG_DEL, &api_nhg);
} else {
zlog_debug("%s: nhg %u not sent: no valid nexthops", __func__,
id);
is_valid = false;
}
goto done;
}

Expand Down

0 comments on commit 6d0c978

Please sign in to comment.