install_element (BGP_NODE, &no_neighbor_bfd_cmd);
install_element (BGP_NODE, &no_neighbor_bfd_val_cmd);
install_element (BGP_NODE, &no_neighbor_bfd_type_cmd);
-
- /* Send the client registration */
- bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
}
#include "queue.h"
#include "memory.h"
#include "lib/json.h"
+#include "lib/bfd.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_mpath.h"
#include "bgpd/bgp_nexthop.h"
#include "bgpd/bgp_nht.h"
-#include "bgpd/bgp_bfd.h"
/* All information about zebra. */
struct zclient *zclient = NULL;
bgp_zebra_instance_register (bgp);
+ /* Send the client registration */
+ bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
+
/* TODO - What if we have peers and networks configured, do we have to
* kick-start them?
*/
install_element (INTERFACE_NODE, &ipv6_ospf6_bfd_cmd);
install_element (INTERFACE_NODE, &ipv6_ospf6_bfd_param_cmd);
install_element (INTERFACE_NODE, &no_ipv6_ospf6_bfd_cmd);
-
- /* Send the client registration */
- bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
}
#include "stream.h"
#include "zclient.h"
#include "memory.h"
+#include "lib/bfd.h"
#include "ospf6_proto.h"
#include "ospf6_top.h"
static void
ospf6_zebra_connected (struct zclient *zclient)
{
+ /* Send the client registration */
+ bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
+
zclient_send_reg_requests (zclient, VRF_DEFAULT);
}
install_element (INTERFACE_NODE, &ip_ospf_bfd_param_cmd);
install_element (INTERFACE_NODE, &no_ip_ospf_bfd_cmd);
install_element (INTERFACE_NODE, &no_ip_ospf_bfd_param_cmd);
-
- /* Send the client registration */
- bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
}
#include "filter.h"
#include "plist.h"
#include "log.h"
+#include "lib/bfd.h"
#include "ospfd/ospfd.h"
#include "ospfd/ospf_interface.h"
static void
ospf_zebra_connected (struct zclient *zclient)
{
+ /* Send the client registration */
+ bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER);
+
zclient_send_reg_requests (zclient, VRF_DEFAULT);
}
void
zebra_ptm_finish(void)
{
- if (ptm_cb.ptm_sock != -1)
- close(ptm_cb.ptm_sock);
+ int proto;
- if (ptm_cb.wb)
- buffer_free(ptm_cb.wb);
+ for (proto = 0; proto < ZEBRA_ROUTE_MAX; proto++)
+ if (CHECK_FLAG(ptm_cb.client_flags[proto], ZEBRA_PTM_BFD_CLIENT_FLAG_REG))
+ zebra_ptm_bfd_client_deregister(proto);
+
+ buffer_flush_all(ptm_cb.wb, ptm_cb.ptm_sock);
if (ptm_cb.out_data)
free(ptm_cb.out_data);
thread_cancel (ptm_cb.t_write);
if (ptm_cb.t_timer)
thread_cancel (ptm_cb.t_timer);
+
+ if (ptm_cb.wb)
+ buffer_free(ptm_cb.wb);
+
+ if (ptm_cb.ptm_sock != -1)
+ close(ptm_cb.ptm_sock);
}
static int
zlog_debug ("%s: Sent message (%d) %s", __func__, data_len,
ptm_cb.out_data);
zebra_ptm_send_message(ptm_cb.out_data, data_len);
+
+ SET_FLAG(ptm_cb.client_flags[client->proto], ZEBRA_PTM_BFD_CLIENT_FLAG_REG);
return 0;
}
/* BFD client deregister */
void
-zebra_ptm_bfd_client_deregister (struct zserv *client)
+zebra_ptm_bfd_client_deregister (int proto)
{
void *out_ctxt;
char tmp_buf[64];
int data_len = ZEBRA_PTM_SEND_MAX_SOCKBUF;
- if (client->proto != ZEBRA_ROUTE_OSPF && client->proto != ZEBRA_ROUTE_BGP
- && client->proto != ZEBRA_ROUTE_OSPF6)
+ if (proto != ZEBRA_ROUTE_OSPF && proto != ZEBRA_ROUTE_BGP
+ && proto != ZEBRA_ROUTE_OSPF6)
return;
if (IS_ZEBRA_DEBUG_EVENT)
- zlog_debug("bfd_client_deregister msg for client %s",
- zebra_route_string(client->proto));
+ zlog_err("bfd_client_deregister msg for client %s",
+ zebra_route_string(proto));
if (ptm_cb.ptm_sock == -1)
{
sprintf(tmp_buf, "%s", ZEBRA_PTM_BFD_CLIENT_DEREG_CMD);
ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_CMD_STR, tmp_buf);
- sprintf(tmp_buf, "%s", zebra_route_string(client->proto));
+ sprintf(tmp_buf, "%s", zebra_route_string(proto));
ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_CLIENT_FIELD,
tmp_buf);
if (IS_ZEBRA_DEBUG_SEND)
zlog_debug ("%s: Sent message (%d) %s", __func__, data_len,
ptm_cb.out_data);
+
zebra_ptm_send_message(ptm_cb.out_data, data_len);
+ UNSET_FLAG(ptm_cb.client_flags[proto], ZEBRA_PTM_BFD_CLIENT_FLAG_REG);
}
int
#define ZEBRA_PTM_MAX_SOCKBUF 3200 /* 25B *128 ports */
#define ZEBRA_PTM_SEND_MAX_SOCKBUF 512
+#define ZEBRA_PTM_BFD_CLIENT_FLAG_REG (1 << 1) /* client registered with BFD */
+
/* Zebra ptm context block */
struct zebra_ptm_cb
{
int ptm_enable;
int pid;
+ u_int8_t client_flags[ZEBRA_ROUTE_MAX];
};
#define ZEBRA_PTM_STATUS_DOWN 0
void zebra_ptm_if_init(struct zebra_if *zebra_ifp);
void zebra_ptm_if_set_ptm_state(struct interface *ifp, struct zebra_if *zebra_ifp);
void zebra_ptm_if_write (struct vty *vty, struct zebra_if *zebra_ifp);
-void zebra_ptm_bfd_client_deregister (struct zserv *client);
+void zebra_ptm_bfd_client_deregister (int proto);
#endif
zebra_client_close (struct zserv *client)
{
/* Send client de-registration to BFD */
- zebra_ptm_bfd_client_deregister(client);
+ zebra_ptm_bfd_client_deregister(client->proto);
/* Cleanup any registered nexthops - across all VRFs. */
zebra_client_close_cleanup_rnh (client);