]>
Commit | Line | Data |
---|---|---|
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" | |
88177fe3 | 26 | #include "zebra/zebra_ptm_redistribute.h" |
4a1ab8e4 | 27 | #include "zebra/zebra_memory.h" |
c43ed2e4 | 28 | |
d62a17ae | 29 | static int zsend_interface_bfd_update(int cmd, struct zserv *client, |
30 | struct interface *ifp, struct prefix *dp, | |
31 | struct prefix *sp, int status, | |
32 | vrf_id_t vrf_id) | |
c43ed2e4 | 33 | { |
d62a17ae | 34 | int blen; |
35 | struct stream *s; | |
36 | ||
37 | /* Check this client need interface information. */ | |
38 | if (!client->ifinfo) | |
39 | return 0; | |
40 | ||
1002497a | 41 | s = stream_new(ZEBRA_MAX_PACKET_SIZ); |
d62a17ae | 42 | |
7cf15b25 | 43 | zclient_create_header(s, cmd, vrf_id); |
d62a17ae | 44 | if (ifp) |
45 | stream_putl(s, ifp->ifindex); | |
46 | else | |
47 | stream_putl(s, 0); | |
48 | ||
49 | /* BFD destination prefix information. */ | |
50 | stream_putc(s, dp->family); | |
51 | blen = prefix_blen(dp); | |
52 | stream_put(s, &dp->u.prefix, blen); | |
53 | stream_putc(s, dp->prefixlen); | |
54 | ||
55 | /* BFD status */ | |
56 | stream_putl(s, status); | |
57 | ||
58 | /* BFD source prefix information. */ | |
59 | stream_putc(s, sp->family); | |
60 | blen = prefix_blen(sp); | |
61 | stream_put(s, &sp->u.prefix, blen); | |
62 | stream_putc(s, sp->prefixlen); | |
63 | ||
64 | /* Write packet size. */ | |
65 | stream_putw_at(s, 0, stream_get_endp(s)); | |
66 | ||
67 | client->if_bfd_cnt++; | |
1002497a | 68 | return zebra_server_send_message(client, s); |
c43ed2e4 DS |
69 | } |
70 | ||
d62a17ae | 71 | void zebra_interface_bfd_update(struct interface *ifp, struct prefix *dp, |
72 | struct prefix *sp, int status, vrf_id_t vrf_id) | |
c43ed2e4 | 73 | { |
d62a17ae | 74 | struct listnode *node, *nnode; |
75 | struct zserv *client; | |
76 | ||
77 | for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) { | |
78 | /* Supporting for OSPF, BGP and PIM */ | |
79 | if (client->proto != ZEBRA_ROUTE_OSPF | |
80 | && client->proto != ZEBRA_ROUTE_BGP | |
81 | && client->proto != ZEBRA_ROUTE_OSPF6 | |
82 | && client->proto != ZEBRA_ROUTE_PIM) | |
83 | continue; | |
84 | ||
85 | /* Notify to the protocol daemons. */ | |
86 | zsend_interface_bfd_update(ZEBRA_INTERFACE_BFD_DEST_UPDATE, | |
87 | client, ifp, dp, sp, status, vrf_id); | |
88 | } | |
c43ed2e4 DS |
89 | } |
90 | ||
d62a17ae | 91 | static int zsend_bfd_peer_replay(int cmd, struct zserv *client) |
c43ed2e4 | 92 | { |
d62a17ae | 93 | struct stream *s; |
c43ed2e4 | 94 | |
1002497a | 95 | s = stream_new(ZEBRA_MAX_PACKET_SIZ); |
c43ed2e4 | 96 | |
7cf15b25 | 97 | zclient_create_header(s, cmd, VRF_DEFAULT); |
c43ed2e4 | 98 | |
d62a17ae | 99 | /* Write packet size. */ |
100 | stream_putw_at(s, 0, stream_get_endp(s)); | |
c43ed2e4 | 101 | |
d62a17ae | 102 | client->bfd_peer_replay_cnt++; |
1002497a | 103 | return zebra_server_send_message(client, s); |
c43ed2e4 DS |
104 | } |
105 | ||
d62a17ae | 106 | void zebra_bfd_peer_replay_req(void) |
c43ed2e4 | 107 | { |
d62a17ae | 108 | struct listnode *node, *nnode; |
109 | struct zserv *client; | |
110 | ||
111 | for (ALL_LIST_ELEMENTS(zebrad.client_list, node, nnode, client)) { | |
112 | /* Supporting for BGP */ | |
113 | if ((client->proto != ZEBRA_ROUTE_BGP) | |
114 | && (client->proto != ZEBRA_ROUTE_OSPF) | |
115 | && (client->proto != ZEBRA_ROUTE_OSPF6) | |
116 | && (client->proto != ZEBRA_ROUTE_PIM)) | |
117 | continue; | |
118 | ||
119 | /* Notify to the protocol daemons. */ | |
120 | zsend_bfd_peer_replay(ZEBRA_BFD_DEST_REPLAY, client); | |
121 | } | |
c43ed2e4 | 122 | } |