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