]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripd/rip_zebra.c
ripd: embed BFD YANG models
[mirror_frr.git] / ripd / rip_zebra.c
index 074370dc26fd3a77d441f80aaf7795c44edb973b..5bf51c2f15284bc171fcc044cf371a2704a0fce9 100644 (file)
@@ -1,21 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* RIPd and zebra interface.
  * Copyright (C) 1997, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -28,6 +13,7 @@
 #include "zclient.h"
 #include "log.h"
 #include "vrf.h"
+#include "bfd.h"
 #include "ripd/ripd.h"
 #include "ripd/rip_debug.h"
 #include "ripd/rip_interface.h"
@@ -44,7 +30,7 @@ static void rip_zebra_ipv4_send(struct rip *rip, struct route_node *rp,
        struct zapi_nexthop *api_nh;
        struct listnode *listnode = NULL;
        struct rip_info *rinfo = NULL;
-       int count = 0;
+       uint32_t count = 0;
 
        memset(&api, 0, sizeof(api));
        api.vrf_id = rip->vrf->vrf_id;
@@ -53,7 +39,7 @@ static void rip_zebra_ipv4_send(struct rip *rip, struct route_node *rp,
 
        SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
        for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
-               if (count >= MULTIPATH_NUM)
+               if (count >= zebra_ecmp_count)
                        break;
                api_nh = &api.nexthops[count];
                api_nh->vrf_id = rip->vrf->vrf_id;
@@ -211,6 +197,7 @@ void rip_zebra_vrf_register(struct vrf *vrf)
                           vrf->name, vrf->vrf_id);
 
        zclient_send_reg_requests(zclient, vrf->vrf_id);
+       bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, vrf->vrf_id);
 }
 
 void rip_zebra_vrf_deregister(struct vrf *vrf)
@@ -223,24 +210,36 @@ void rip_zebra_vrf_deregister(struct vrf *vrf)
                           vrf->name, vrf->vrf_id);
 
        zclient_send_dereg_requests(zclient, vrf->vrf_id);
+       bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_DEREGISTER, vrf->vrf_id);
 }
 
 static void rip_zebra_connected(struct zclient *zclient)
 {
        zclient_send_reg_requests(zclient, VRF_DEFAULT);
+       bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, VRF_DEFAULT);
 }
 
-void rip_zclient_init(struct thread_master *master)
+zclient_handler *const rip_handlers[] = {
+       [ZEBRA_INTERFACE_ADDRESS_ADD] = rip_interface_address_add,
+       [ZEBRA_INTERFACE_ADDRESS_DELETE] = rip_interface_address_delete,
+       [ZEBRA_INTERFACE_VRF_UPDATE] = rip_interface_vrf_update,
+       [ZEBRA_REDISTRIBUTE_ROUTE_ADD] = rip_zebra_read_route,
+       [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = rip_zebra_read_route,
+};
+
+static void rip_zebra_capabilities(struct zclient_capabilities *cap)
+{
+       zebra_ecmp_count = MIN(cap->ecmp, zebra_ecmp_count);
+}
+
+void rip_zclient_init(struct event_loop *master)
 {
        /* Set default value to the zebra client structure. */
-       zclient = zclient_new(master, &zclient_options_default);
+       zclient = zclient_new(master, &zclient_options_default, rip_handlers,
+                             array_size(rip_handlers));
        zclient_init(zclient, ZEBRA_ROUTE_RIP, 0, &ripd_privs);
        zclient->zebra_connected = rip_zebra_connected;
-       zclient->interface_address_add = rip_interface_address_add;
-       zclient->interface_address_delete = rip_interface_address_delete;
-       zclient->interface_vrf_update = rip_interface_vrf_update;
-       zclient->redistribute_route_add = rip_zebra_read_route;
-       zclient->redistribute_route_del = rip_zebra_read_route;
+       zclient->zebra_capabilities = rip_zebra_capabilities;
 }
 
 void rip_zclient_stop(void)