1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * @copyright Copyright (C) 2015 Cumulus Networks, Inc.
10 #include "zebra/zebra_router.h"
11 #include "zebra/zapi_msg.h"
12 #include "zebra/zebra_ptm.h"
13 #include "zebra/zebra_ptm_redistribute.h"
15 static int zsend_interface_bfd_update(int cmd
, struct zserv
*client
,
16 struct interface
*ifp
, struct prefix
*dp
,
17 struct prefix
*sp
, int status
,
23 s
= stream_new(ZEBRA_MAX_PACKET_SIZ
);
25 zclient_create_header(s
, cmd
, vrf_id
);
27 stream_putl(s
, ifp
->ifindex
);
31 /* BFD destination prefix information. */
32 stream_putc(s
, dp
->family
);
33 blen
= prefix_blen(dp
);
34 stream_put(s
, &dp
->u
.prefix
, blen
);
35 stream_putc(s
, dp
->prefixlen
);
38 stream_putl(s
, status
);
40 /* BFD source prefix information. */
41 stream_putc(s
, sp
->family
);
42 blen
= prefix_blen(sp
);
43 stream_put(s
, &sp
->u
.prefix
, blen
);
44 stream_putc(s
, sp
->prefixlen
);
49 /* Write packet size. */
50 stream_putw_at(s
, 0, stream_get_endp(s
));
53 return zserv_send_message(client
, s
);
56 void zebra_interface_bfd_update(struct interface
*ifp
, struct prefix
*dp
,
57 struct prefix
*sp
, int status
, vrf_id_t vrf_id
)
59 struct listnode
*node
, *nnode
;
62 for (ALL_LIST_ELEMENTS(zrouter
.client_list
, node
, nnode
, client
)) {
63 if (!IS_BFD_ENABLED_PROTOCOL(client
->proto
))
66 /* Notify to the protocol daemons. */
67 zsend_interface_bfd_update(ZEBRA_INTERFACE_BFD_DEST_UPDATE
,
68 client
, ifp
, dp
, sp
, status
, vrf_id
);
72 static int zsend_bfd_peer_replay(int cmd
, struct zserv
*client
)
76 s
= stream_new(ZEBRA_MAX_PACKET_SIZ
);
78 zclient_create_header(s
, cmd
, VRF_DEFAULT
);
80 /* Write packet size. */
81 stream_putw_at(s
, 0, stream_get_endp(s
));
83 client
->bfd_peer_replay_cnt
++;
84 return zserv_send_message(client
, s
);
87 void zebra_bfd_peer_replay_req(void)
89 struct listnode
*node
, *nnode
;
92 for (ALL_LIST_ELEMENTS(zrouter
.client_list
, node
, nnode
, client
)) {
93 if (!IS_BFD_ENABLED_PROTOCOL(client
->proto
))
96 /* Notify to the protocol daemons. */
97 zsend_bfd_peer_replay(ZEBRA_BFD_DEST_REPLAY
, client
);