]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd, lib: add zapi_route_set_nhg_id() support
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 12 Dec 2023 20:04:49 +0000 (21:04 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 18 Dec 2023 09:08:45 +0000 (10:08 +0100)
There is no function that both sets the nhg id, and sets
the ZAPI_MESSAGE_NHG flag if the nhg id is valid.
Create a ZAPI API to do this, and apply the changes wherever
needed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_zebra.c
lib/zclient.h
sharpd/sharp_zebra.c

index a550b90e8e9659884efe583d5726b9ba0de9b647..69afc7ea97b9290b603381be4ee3b91bc0e21979 100644 (file)
@@ -1248,9 +1248,7 @@ static void bgp_zebra_announce_parse_nexthop(
        /* EVPN MAC-IP routes are installed with a L3 NHG id */
        if (nhg_id && bgp_evpn_path_es_use_nhg(bgp, info, nhg_id)) {
                mpinfo = NULL;
-               api->nhgid = *nhg_id;
-               if (*nhg_id)
-                       SET_FLAG(api->message, ZAPI_MESSAGE_NHG);
+               zapi_route_set_nhg_id(api, nhg_id);
        } else {
                mpinfo = info;
        }
index 8b6aebc2fda8be178db809b0cdf271b60dfc5da5..f249afe61e1ab4954a5b3166905cd33faba69522 100644 (file)
@@ -1169,6 +1169,15 @@ static inline void zapi_route_set_blackhole(struct zapi_route *api,
        SET_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP);
 };
 
+static inline void zapi_route_set_nhg_id(struct zapi_route *api,
+                                        uint32_t *nhg_id)
+{
+       api->nexthop_num = 0;
+       api->nhgid = *nhg_id;
+       if (api->nhgid)
+               SET_FLAG(api->message, ZAPI_MESSAGE_NHG);
+};
+
 extern enum zclient_send_status
 zclient_send_mlag_register(struct zclient *client, uint32_t bit_map);
 extern enum zclient_send_status
index ff4895189db640b99526219ccfded78af168763b..cbfa0d1cccece6985ed22c8c3398b815d0812297 100644 (file)
@@ -251,8 +251,7 @@ static bool route_add(const struct prefix *p, vrf_id_t vrf_id, uint8_t instance,
 
        /* Only send via ID if nhgroup has been successfully installed */
        if (nhgid && sharp_nhgroup_id_is_installed(nhgid)) {
-               SET_FLAG(api.message, ZAPI_MESSAGE_NHG);
-               api.nhgid = nhgid;
+               zapi_route_set_nhg_id(&api, &nhgid);
        } else {
                for (ALL_NEXTHOPS_PTR(nhg, nh)) {
                        /* Check if we set a VNI label */