]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_ptm_redistribute.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / zebra_ptm_redistribute.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /**
3 * @copyright Copyright (C) 2015 Cumulus Networks, Inc.
4 */
5
6 #include <zebra.h>
7 #include "prefix.h"
8 #include "vty.h"
9 #include "stream.h"
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"
14
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,
18 vrf_id_t vrf_id)
19 {
20 int blen;
21 struct stream *s;
22
23 s = stream_new(ZEBRA_MAX_PACKET_SIZ);
24
25 zclient_create_header(s, cmd, vrf_id);
26 if (ifp)
27 stream_putl(s, ifp->ifindex);
28 else
29 stream_putl(s, 0);
30
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);
36
37 /* BFD status */
38 stream_putl(s, status);
39
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);
45
46 /* c-bit bullshit */
47 stream_putc(s, 0);
48
49 /* Write packet size. */
50 stream_putw_at(s, 0, stream_get_endp(s));
51
52 client->if_bfd_cnt++;
53 return zserv_send_message(client, s);
54 }
55
56 void zebra_interface_bfd_update(struct interface *ifp, struct prefix *dp,
57 struct prefix *sp, int status, vrf_id_t vrf_id)
58 {
59 struct listnode *node, *nnode;
60 struct zserv *client;
61
62 for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
63 if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
64 continue;
65
66 /* Notify to the protocol daemons. */
67 zsend_interface_bfd_update(ZEBRA_INTERFACE_BFD_DEST_UPDATE,
68 client, ifp, dp, sp, status, vrf_id);
69 }
70 }
71
72 static int zsend_bfd_peer_replay(int cmd, struct zserv *client)
73 {
74 struct stream *s;
75
76 s = stream_new(ZEBRA_MAX_PACKET_SIZ);
77
78 zclient_create_header(s, cmd, VRF_DEFAULT);
79
80 /* Write packet size. */
81 stream_putw_at(s, 0, stream_get_endp(s));
82
83 client->bfd_peer_replay_cnt++;
84 return zserv_send_message(client, s);
85 }
86
87 void zebra_bfd_peer_replay_req(void)
88 {
89 struct listnode *node, *nnode;
90 struct zserv *client;
91
92 for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
93 if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
94 continue;
95
96 /* Notify to the protocol daemons. */
97 zsend_bfd_peer_replay(ZEBRA_BFD_DEST_REPLAY, client);
98 }
99 }