]> git.puffer.fish Git - matthieu/frr.git/commitdiff
sharpd: fix deleting nhid when suppressing nexthop from nh group
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 23 Nov 2023 13:19:04 +0000 (14:19 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 30 Nov 2023 13:17:46 +0000 (14:17 +0100)
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: 5a9c0931aa95 ("sharpd: don't send invalid nexthop-groups to zebra")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
sharpd/sharp_zebra.c

index aa720bacf2a66726a9859ece8e29571868cb83b9..9ff6ba99b61ed20de3a6a264bd89126fc7af99dd 100644 (file)
@@ -563,9 +563,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;
        }