]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_vty.c
lib: enforce vrf_name_to_id by returning default_vrf when name is null
[mirror_frr.git] / pimd / pim_vty.c
1 /*
2 * PIM for Quagga
3 * Copyright (C) 2008 Everton da Silva Marques
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include <zebra.h>
21
22 #include "if.h"
23 #include "linklist.h"
24 #include "prefix.h"
25 #include "vty.h"
26 #include "vrf.h"
27 #include "plist.h"
28
29 #include "pimd.h"
30 #include "pim_vty.h"
31 #include "pim_iface.h"
32 #include "pim_cmd.h"
33 #include "pim_str.h"
34 #include "pim_ssmpingd.h"
35 #include "pim_pim.h"
36 #include "pim_oil.h"
37 #include "pim_static.h"
38 #include "pim_rp.h"
39 #include "pim_msdp.h"
40 #include "pim_ssm.h"
41 #include "pim_bfd.h"
42
43 int pim_debug_config_write(struct vty *vty)
44 {
45 int writes = 0;
46
47 if (PIM_DEBUG_MSDP_EVENTS) {
48 vty_out(vty, "debug msdp events\n");
49 ++writes;
50 }
51 if (PIM_DEBUG_MSDP_PACKETS) {
52 vty_out(vty, "debug msdp packets\n");
53 ++writes;
54 }
55 if (PIM_DEBUG_MSDP_INTERNAL) {
56 vty_out(vty, "debug msdp internal\n");
57 ++writes;
58 }
59 if (PIM_DEBUG_IGMP_EVENTS) {
60 vty_out(vty, "debug igmp events\n");
61 ++writes;
62 }
63 if (PIM_DEBUG_IGMP_PACKETS) {
64 vty_out(vty, "debug igmp packets\n");
65 ++writes;
66 }
67 if (PIM_DEBUG_IGMP_TRACE) {
68 vty_out(vty, "debug igmp trace\n");
69 ++writes;
70 }
71 if (PIM_DEBUG_IGMP_TRACE_DETAIL) {
72 vty_out(vty, "debug igmp trace detail\n");
73 ++writes;
74 }
75
76 if (PIM_DEBUG_MROUTE) {
77 vty_out(vty, "debug mroute\n");
78 ++writes;
79 }
80
81 if (PIM_DEBUG_MTRACE) {
82 vty_out(vty, "debug mtrace\n");
83 ++writes;
84 }
85
86 if (PIM_DEBUG_MROUTE_DETAIL) {
87 vty_out(vty, "debug mroute detail\n");
88 ++writes;
89 }
90
91 if (PIM_DEBUG_PIM_EVENTS) {
92 vty_out(vty, "debug pim events\n");
93 ++writes;
94 }
95 if (PIM_DEBUG_PIM_PACKETS) {
96 vty_out(vty, "debug pim packets\n");
97 ++writes;
98 }
99 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
100 vty_out(vty, "debug pim packet-dump send\n");
101 ++writes;
102 }
103 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
104 vty_out(vty, "debug pim packet-dump receive\n");
105 ++writes;
106 }
107
108 if (PIM_DEBUG_PIM_TRACE) {
109 vty_out(vty, "debug pim trace\n");
110 ++writes;
111 }
112 if (PIM_DEBUG_PIM_TRACE_DETAIL) {
113 vty_out(vty, "debug pim trace detail\n");
114 ++writes;
115 }
116
117 if (PIM_DEBUG_ZEBRA) {
118 vty_out(vty, "debug pim zebra\n");
119 ++writes;
120 }
121
122 if (PIM_DEBUG_SSMPINGD) {
123 vty_out(vty, "debug ssmpingd\n");
124 ++writes;
125 }
126
127 if (PIM_DEBUG_PIM_HELLO) {
128 vty_out(vty, "debug pim packets hello\n");
129 ++writes;
130 }
131
132 if (PIM_DEBUG_PIM_J_P) {
133 vty_out(vty, "debug pim packets joins\n");
134 ++writes;
135 }
136
137 if (PIM_DEBUG_PIM_REG) {
138 vty_out(vty, "debug pim packets register\n");
139 ++writes;
140 }
141
142 if (PIM_DEBUG_STATIC) {
143 vty_out(vty, "debug pim static\n");
144 ++writes;
145 }
146
147 if (PIM_DEBUG_PIM_NHT) {
148 vty_out(vty, "debug pim nht\n");
149 ++writes;
150 }
151
152 return writes;
153 }
154
155 int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
156 {
157 int writes = 0;
158 struct pim_ssm *ssm = pim->ssm_info;
159 char spaces[10];
160
161 if (pim->vrf_id == VRF_DEFAULT)
162 sprintf(spaces, "%s", "");
163 else
164 sprintf(spaces, "%s", " ");
165
166 writes += pim_msdp_config_write_helper(pim, vty, spaces);
167
168 if (!pim->send_v6_secondary) {
169 vty_out(vty, "%sno ip pim send-v6-secondary\n", spaces);
170 ++writes;
171 }
172
173 writes += pim_rp_config_write(pim, vty, spaces);
174
175 if (qpim_register_suppress_time
176 != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
177 vty_out(vty, "%sip pim register-suppress-time %d\n", spaces,
178 qpim_register_suppress_time);
179 ++writes;
180 }
181 if (qpim_t_periodic != PIM_DEFAULT_T_PERIODIC) {
182 vty_out(vty, "%sip pim join-prune-interval %d\n", spaces,
183 qpim_t_periodic);
184 ++writes;
185 }
186 if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) {
187 vty_out(vty, "%sip pim keep-alive-timer %d\n", spaces,
188 pim->keep_alive_time);
189 ++writes;
190 }
191 if (pim->rp_keep_alive_time != (unsigned int)PIM_RP_KEEPALIVE_PERIOD) {
192 vty_out(vty, "%sip pim rp keep-alive-timer %d\n", spaces,
193 pim->rp_keep_alive_time);
194 ++writes;
195 }
196 if (qpim_packet_process != PIM_DEFAULT_PACKET_PROCESS) {
197 vty_out(vty, "%sip pim packets %d\n", spaces,
198 qpim_packet_process);
199 ++writes;
200 }
201 if (ssm->plist_name) {
202 vty_out(vty, "%sip pim ssm prefix-list %s\n", spaces,
203 ssm->plist_name);
204 ++writes;
205 }
206 if (pim->spt.switchover == PIM_SPT_INFINITY) {
207 if (pim->spt.plist)
208 vty_out(vty,
209 "%sip pim spt-switchover infinity-and-beyond prefix-list %s\n",
210 spaces, pim->spt.plist);
211 else
212 vty_out(vty,
213 "%sip pim spt-switchover infinity-and-beyond\n",
214 spaces);
215 ++writes;
216 }
217 if (pim->ecmp_rebalance_enable) {
218 vty_out(vty, "%sip pim ecmp rebalance\n", spaces);
219 ++writes;
220 } else if (pim->ecmp_enable) {
221 vty_out(vty, "%sip pim ecmp\n", spaces);
222 ++writes;
223 }
224 if (pim->ssmpingd_list) {
225 struct listnode *node;
226 struct ssmpingd_sock *ss;
227 ++writes;
228 for (ALL_LIST_ELEMENTS_RO(pim->ssmpingd_list, node, ss)) {
229 char source_str[INET_ADDRSTRLEN];
230 pim_inet4_dump("<src?>", ss->source_addr, source_str,
231 sizeof(source_str));
232 vty_out(vty, "%sip ssmpingd %s\n", spaces, source_str);
233 ++writes;
234 }
235 }
236
237 return writes;
238 }
239
240 int pim_interface_config_write(struct vty *vty)
241 {
242 struct pim_instance *pim;
243 struct interface *ifp;
244 struct vrf *vrf;
245 int writes = 0;
246
247 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
248 pim = vrf->info;
249 if (!pim)
250 continue;
251
252 FOR_ALL_INTERFACES (pim->vrf, ifp) {
253 /* IF name */
254 if (vrf->vrf_id == VRF_DEFAULT)
255 vty_frame(vty, "interface %s\n", ifp->name);
256 else
257 vty_frame(vty, "interface %s vrf %s\n",
258 ifp->name, vrf->name);
259 ++writes;
260
261 if (ifp->desc) {
262 vty_out(vty, " description %s\n", ifp->desc);
263 ++writes;
264 }
265
266 if (ifp->info) {
267 struct pim_interface *pim_ifp = ifp->info;
268
269 if (PIM_IF_TEST_PIM(pim_ifp->options)) {
270 vty_out(vty, " ip pim\n");
271 ++writes;
272 }
273
274 /* IF ip pim drpriority */
275 if (pim_ifp->pim_dr_priority
276 != PIM_DEFAULT_DR_PRIORITY) {
277 vty_out(vty, " ip pim drpriority %u\n",
278 pim_ifp->pim_dr_priority);
279 ++writes;
280 }
281
282 /* IF ip pim hello */
283 if (pim_ifp->pim_hello_period
284 != PIM_DEFAULT_HELLO_PERIOD) {
285 vty_out(vty, " ip pim hello %d",
286 pim_ifp->pim_hello_period);
287 if (pim_ifp->pim_default_holdtime != -1)
288 vty_out(vty, " %d",
289 pim_ifp->pim_default_holdtime);
290 vty_out(vty, "\n");
291 ++writes;
292 }
293
294 /* update source */
295 if (PIM_INADDR_ISNOT_ANY(
296 pim_ifp->update_source)) {
297 char src_str[INET_ADDRSTRLEN];
298 pim_inet4_dump("<src?>",
299 pim_ifp->update_source,
300 src_str,
301 sizeof(src_str));
302 vty_out(vty, " ip pim use-source %s\n",
303 src_str);
304 ++writes;
305 }
306
307 /* IF ip igmp */
308 if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
309 vty_out(vty, " ip igmp\n");
310 ++writes;
311 }
312
313 /* ip igmp version */
314 if (pim_ifp->igmp_version
315 != IGMP_DEFAULT_VERSION) {
316 vty_out(vty, " ip igmp version %d\n",
317 pim_ifp->igmp_version);
318 ++writes;
319 }
320
321 /* IF ip igmp query-max-response-time */
322 if (pim_ifp->igmp_query_max_response_time_dsec
323 != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) {
324 vty_out(vty,
325 " ip igmp query-max-response-time %d\n",
326 pim_ifp->igmp_query_max_response_time_dsec);
327 ++writes;
328 }
329
330 /* IF ip igmp query-interval */
331 if (pim_ifp->igmp_default_query_interval
332 != IGMP_GENERAL_QUERY_INTERVAL) {
333 vty_out(vty,
334 " ip igmp query-interval %d\n",
335 pim_ifp->igmp_default_query_interval);
336 ++writes;
337 }
338
339 /* IF ip igmp join */
340 if (pim_ifp->igmp_join_list) {
341 struct listnode *node;
342 struct igmp_join *ij;
343 for (ALL_LIST_ELEMENTS_RO(
344 pim_ifp->igmp_join_list,
345 node, ij)) {
346 char group_str[INET_ADDRSTRLEN];
347 char source_str
348 [INET_ADDRSTRLEN];
349 pim_inet4_dump(
350 "<grp?>",
351 ij->group_addr,
352 group_str,
353 sizeof(group_str));
354 inet_ntop(AF_INET,
355 &ij->source_addr,
356 source_str,
357 sizeof(source_str));
358 vty_out(vty,
359 " ip igmp join %s %s\n",
360 group_str, source_str);
361 ++writes;
362 }
363 }
364
365 /* boundary */
366 if (pim_ifp->boundary_oil_plist) {
367 vty_out(vty,
368 " ip multicast boundary oil %s\n",
369 pim_ifp->boundary_oil_plist);
370 ++writes;
371 }
372
373 writes +=
374 pim_static_write_mroute(pim, vty, ifp);
375 pim_bfd_write_config(vty, ifp);
376 }
377 vty_endframe(vty, "!\n");
378 ++writes;
379 }
380 }
381
382 return writes;
383 }