]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_ptm_redistribute.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / zebra_ptm_redistribute.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
c43ed2e4
DS
2/**
3 * @copyright Copyright (C) 2015 Cumulus Networks, Inc.
c43ed2e4
DS
4 */
5
6#include <zebra.h>
7#include "prefix.h"
8#include "vty.h"
9#include "stream.h"
161e9ab7 10#include "zebra/zebra_router.h"
bf094f69 11#include "zebra/zapi_msg.h"
4943f243 12#include "zebra/zebra_ptm.h"
88177fe3 13#include "zebra/zebra_ptm_redistribute.h"
c43ed2e4 14
d62a17ae 15static 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)
c43ed2e4 19{
d62a17ae 20 int blen;
21 struct stream *s;
22
1002497a 23 s = stream_new(ZEBRA_MAX_PACKET_SIZ);
d62a17ae 24
7cf15b25 25 zclient_create_header(s, cmd, vrf_id);
d62a17ae 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
72c54143
DS
46 /* c-bit bullshit */
47 stream_putc(s, 0);
48
d62a17ae 49 /* Write packet size. */
50 stream_putw_at(s, 0, stream_get_endp(s));
51
52 client->if_bfd_cnt++;
21ccc0cf 53 return zserv_send_message(client, s);
c43ed2e4
DS
54}
55
d62a17ae 56void zebra_interface_bfd_update(struct interface *ifp, struct prefix *dp,
57 struct prefix *sp, int status, vrf_id_t vrf_id)
c43ed2e4 58{
d62a17ae 59 struct listnode *node, *nnode;
60 struct zserv *client;
61
161e9ab7 62 for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
4943f243 63 if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
d62a17ae 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 }
c43ed2e4
DS
70}
71
d62a17ae 72static int zsend_bfd_peer_replay(int cmd, struct zserv *client)
c43ed2e4 73{
d62a17ae 74 struct stream *s;
c43ed2e4 75
1002497a 76 s = stream_new(ZEBRA_MAX_PACKET_SIZ);
c43ed2e4 77
7cf15b25 78 zclient_create_header(s, cmd, VRF_DEFAULT);
c43ed2e4 79
d62a17ae 80 /* Write packet size. */
81 stream_putw_at(s, 0, stream_get_endp(s));
c43ed2e4 82
d62a17ae 83 client->bfd_peer_replay_cnt++;
21ccc0cf 84 return zserv_send_message(client, s);
c43ed2e4
DS
85}
86
d62a17ae 87void zebra_bfd_peer_replay_req(void)
c43ed2e4 88{
d62a17ae 89 struct listnode *node, *nnode;
90 struct zserv *client;
91
161e9ab7 92 for (ALL_LIST_ELEMENTS(zrouter.client_list, node, nnode, client)) {
4943f243 93 if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
d62a17ae 94 continue;
95
96 /* Notify to the protocol daemons. */
97 zsend_bfd_peer_replay(ZEBRA_BFD_DEST_REPLAY, client);
98 }
c43ed2e4 99}