]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_ptm_redistribute.c
zebra: Allow ns delete to happen after under/over flow checks
[mirror_frr.git] / zebra / zebra_ptm_redistribute.c
CommitLineData
c43ed2e4
DS
1/**
2 * @copyright Copyright (C) 2015 Cumulus Networks, Inc.
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
896014f4
DL
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
c43ed2e4
DS
19 */
20
21#include <zebra.h>
22#include "prefix.h"
23#include "vty.h"
24#include "stream.h"
25#include "zebra/zserv.h"
bf094f69 26#include "zebra/zapi_msg.h"
4943f243 27#include "zebra/zebra_ptm.h"
88177fe3 28#include "zebra/zebra_ptm_redistribute.h"
4a1ab8e4 29#include "zebra/zebra_memory.h"
c43ed2e4 30
d62a17ae 31static int zsend_interface_bfd_update(int cmd, struct zserv *client,
32 struct interface *ifp, struct prefix *dp,
33 struct prefix *sp, int status,
34 vrf_id_t vrf_id)
c43ed2e4 35{
d62a17ae 36 int blen;
37 struct stream *s;
38
39 /* Check this client need interface information. */
40 if (!client->ifinfo)
41 return 0;
42
1002497a 43 s = stream_new(ZEBRA_MAX_PACKET_SIZ);
d62a17ae 44
7cf15b25 45 zclient_create_header(s, cmd, vrf_id);
d62a17ae 46 if (ifp)
47 stream_putl(s, ifp->ifindex);
48 else
49 stream_putl(s, 0);
50
51 /* BFD destination prefix information. */
52 stream_putc(s, dp->family);
53 blen = prefix_blen(dp);
54 stream_put(s, &dp->u.prefix, blen);
55 stream_putc(s, dp->prefixlen);
56
57 /* BFD status */
58 stream_putl(s, status);
59
60 /* BFD source prefix information. */
61 stream_putc(s, sp->family);
62 blen = prefix_blen(sp);
63 stream_put(s, &sp->u.prefix, blen);
64 stream_putc(s, sp->prefixlen);
65
66 /* Write packet size. */
67 stream_putw_at(s, 0, stream_get_endp(s));
68
69 client->if_bfd_cnt++;
21ccc0cf 70 return zserv_send_message(client, s);
c43ed2e4
DS
71}
72
d62a17ae 73void zebra_interface_bfd_update(struct interface *ifp, struct prefix *dp,
74 struct prefix *sp, int status, vrf_id_t vrf_id)
c43ed2e4 75{
d62a17ae 76 struct listnode *node, *nnode;
77 struct zserv *client;
78
79 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
4943f243 80 if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
d62a17ae 81 continue;
82
83 /* Notify to the protocol daemons. */
84 zsend_interface_bfd_update(ZEBRA_INTERFACE_BFD_DEST_UPDATE,
85 client, ifp, dp, sp, status, vrf_id);
86 }
c43ed2e4
DS
87}
88
d62a17ae 89static int zsend_bfd_peer_replay(int cmd, struct zserv *client)
c43ed2e4 90{
d62a17ae 91 struct stream *s;
c43ed2e4 92
1002497a 93 s = stream_new(ZEBRA_MAX_PACKET_SIZ);
c43ed2e4 94
7cf15b25 95 zclient_create_header(s, cmd, VRF_DEFAULT);
c43ed2e4 96
d62a17ae 97 /* Write packet size. */
98 stream_putw_at(s, 0, stream_get_endp(s));
c43ed2e4 99
d62a17ae 100 client->bfd_peer_replay_cnt++;
21ccc0cf 101 return zserv_send_message(client, s);
c43ed2e4
DS
102}
103
d62a17ae 104void zebra_bfd_peer_replay_req(void)
c43ed2e4 105{
d62a17ae 106 struct listnode *node, *nnode;
107 struct zserv *client;
108
109 for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) {
4943f243 110 if (!IS_BFD_ENABLED_PROTOCOL(client->proto))
d62a17ae 111 continue;
112
113 /* Notify to the protocol daemons. */
114 zsend_bfd_peer_replay(ZEBRA_BFD_DEST_REPLAY, client);
115 }
c43ed2e4 116}