]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_vty.c
Merge pull request #10746 from ton31337/feature/show_group_type_under_rp_info_cli
[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_str.h"
33 #include "pim_ssmpingd.h"
34 #include "pim_pim.h"
35 #include "pim_oil.h"
36 #include "pim_static.h"
37 #include "pim_rp.h"
38 #include "pim_msdp.h"
39 #include "pim_ssm.h"
40 #include "pim_bfd.h"
41 #include "pim_bsm.h"
42 #include "pim_vxlan.h"
43
44 int pim_debug_config_write(struct vty *vty)
45 {
46 int writes = 0;
47
48 if (PIM_DEBUG_MSDP_EVENTS) {
49 vty_out(vty, "debug msdp events\n");
50 ++writes;
51 }
52 if (PIM_DEBUG_MSDP_PACKETS) {
53 vty_out(vty, "debug msdp packets\n");
54 ++writes;
55 }
56 if (PIM_DEBUG_MSDP_INTERNAL) {
57 vty_out(vty, "debug msdp internal\n");
58 ++writes;
59 }
60 if (PIM_DEBUG_IGMP_EVENTS) {
61 vty_out(vty, "debug igmp events\n");
62 ++writes;
63 }
64 if (PIM_DEBUG_IGMP_PACKETS) {
65 vty_out(vty, "debug igmp packets\n");
66 ++writes;
67 }
68 if (PIM_DEBUG_IGMP_TRACE) {
69 vty_out(vty, "debug igmp trace\n");
70 ++writes;
71 }
72
73 if (PIM_DEBUG_MROUTE) {
74 vty_out(vty, "debug mroute\n");
75 ++writes;
76 }
77
78 if (PIM_DEBUG_MTRACE) {
79 vty_out(vty, "debug mtrace\n");
80 ++writes;
81 }
82
83 if (PIM_DEBUG_MROUTE_DETAIL_ONLY) {
84 vty_out(vty, "debug mroute detail\n");
85 ++writes;
86 }
87
88 if (PIM_DEBUG_PIM_EVENTS) {
89 vty_out(vty, "debug pim events\n");
90 ++writes;
91 }
92 if (PIM_DEBUG_PIM_PACKETS) {
93 vty_out(vty, "debug pim packets\n");
94 ++writes;
95 }
96 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
97 vty_out(vty, "debug pim packet-dump send\n");
98 ++writes;
99 }
100 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
101 vty_out(vty, "debug pim packet-dump receive\n");
102 ++writes;
103 }
104
105 if (PIM_DEBUG_PIM_TRACE) {
106 vty_out(vty, "debug pim trace\n");
107 ++writes;
108 }
109 if (PIM_DEBUG_PIM_TRACE_DETAIL_ONLY) {
110 vty_out(vty, "debug pim trace detail\n");
111 ++writes;
112 }
113
114 if (PIM_DEBUG_ZEBRA) {
115 vty_out(vty, "debug pim zebra\n");
116 ++writes;
117 }
118
119 if (PIM_DEBUG_MLAG) {
120 vty_out(vty, "debug pim mlag\n");
121 ++writes;
122 }
123
124 if (PIM_DEBUG_BSM) {
125 vty_out(vty, "debug pim bsm\n");
126 ++writes;
127 }
128
129 if (PIM_DEBUG_VXLAN) {
130 vty_out(vty, "debug pim vxlan\n");
131 ++writes;
132 }
133
134 if (PIM_DEBUG_SSMPINGD) {
135 vty_out(vty, "debug ssmpingd\n");
136 ++writes;
137 }
138
139 if (PIM_DEBUG_PIM_HELLO) {
140 vty_out(vty, "debug pim packets hello\n");
141 ++writes;
142 }
143
144 if (PIM_DEBUG_PIM_J_P) {
145 vty_out(vty, "debug pim packets joins\n");
146 ++writes;
147 }
148
149 if (PIM_DEBUG_PIM_REG) {
150 vty_out(vty, "debug pim packets register\n");
151 ++writes;
152 }
153
154 if (PIM_DEBUG_STATIC) {
155 vty_out(vty, "debug pim static\n");
156 ++writes;
157 }
158
159 if (PIM_DEBUG_PIM_NHT) {
160 vty_out(vty, "debug pim nht\n");
161 ++writes;
162 }
163
164 if (PIM_DEBUG_PIM_NHT_RP) {
165 vty_out(vty, "debug pim nht rp\n");
166 ++writes;
167 }
168
169 return writes;
170 }
171
172 int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
173 {
174 int writes = 0;
175 struct pim_ssm *ssm = pim->ssm_info;
176 char spaces[10];
177
178 if (pim->vrf->vrf_id == VRF_DEFAULT)
179 snprintf(spaces, sizeof(spaces), "%s", "");
180 else
181 snprintf(spaces, sizeof(spaces), "%s", " ");
182
183 writes += pim_msdp_peer_config_write(vty, pim, spaces);
184 writes += pim_msdp_config_write(pim, vty, spaces);
185
186 if (!pim->send_v6_secondary) {
187 vty_out(vty, "%sno ip pim send-v6-secondary\n", spaces);
188 ++writes;
189 }
190
191 writes += pim_rp_config_write(pim, vty, spaces);
192
193 if (pim->vrf->vrf_id == VRF_DEFAULT) {
194 if (router->register_suppress_time
195 != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
196 vty_out(vty, "%s" PIM_AF_NAME " pim register-suppress-time %d\n",
197 spaces, router->register_suppress_time);
198 ++writes;
199 }
200 if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) {
201 vty_out(vty, "%s" PIM_AF_NAME " pim join-prune-interval %d\n",
202 spaces, router->t_periodic);
203 ++writes;
204 }
205
206 if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) {
207 vty_out(vty, "%s" PIM_AF_NAME " pim packets %d\n", spaces,
208 router->packet_process);
209 ++writes;
210 }
211 }
212 if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) {
213 vty_out(vty, "%s" PIM_AF_NAME " pim keep-alive-timer %d\n",
214 spaces, pim->keep_alive_time);
215 ++writes;
216 }
217 if (pim->rp_keep_alive_time != (unsigned int)PIM_RP_KEEPALIVE_PERIOD) {
218 vty_out(vty, "%s" PIM_AF_NAME " pim rp keep-alive-timer %d\n",
219 spaces, pim->rp_keep_alive_time);
220 ++writes;
221 }
222 if (ssm->plist_name) {
223 vty_out(vty, "%sip pim ssm prefix-list %s\n", spaces,
224 ssm->plist_name);
225 ++writes;
226 }
227 if (pim->register_plist) {
228 vty_out(vty, "%sip pim register-accept-list %s\n", spaces,
229 pim->register_plist);
230 ++writes;
231 }
232 if (pim->spt.switchover == PIM_SPT_INFINITY) {
233 if (pim->spt.plist)
234 vty_out(vty,
235 "%s" PIM_AF_NAME " pim spt-switchover infinity-and-beyond prefix-list %s\n",
236 spaces, pim->spt.plist);
237 else
238 vty_out(vty,
239 "%s" PIM_AF_NAME " pim spt-switchover infinity-and-beyond\n",
240 spaces);
241 ++writes;
242 }
243 if (pim->ecmp_rebalance_enable) {
244 vty_out(vty, "%sip pim ecmp rebalance\n", spaces);
245 ++writes;
246 } else if (pim->ecmp_enable) {
247 vty_out(vty, "%sip pim ecmp\n", spaces);
248 ++writes;
249 }
250
251 if (pim->igmp_watermark_limit != 0) {
252 vty_out(vty, "%sip igmp watermark-warn %u\n", spaces,
253 pim->igmp_watermark_limit);
254 ++writes;
255 }
256
257 if (pim->ssmpingd_list) {
258 struct listnode *node;
259 struct ssmpingd_sock *ss;
260 ++writes;
261 for (ALL_LIST_ELEMENTS_RO(pim->ssmpingd_list, node, ss)) {
262 char source_str[INET_ADDRSTRLEN];
263 pim_inet4_dump("<src?>", ss->source_addr, source_str,
264 sizeof(source_str));
265 vty_out(vty, "%sip ssmpingd %s\n", spaces, source_str);
266 ++writes;
267 }
268 }
269
270 if (pim->msdp.hold_time != PIM_MSDP_PEER_HOLD_TIME
271 || pim->msdp.keep_alive != PIM_MSDP_PEER_KA_TIME
272 || pim->msdp.connection_retry != PIM_MSDP_PEER_CONNECT_RETRY_TIME) {
273 vty_out(vty, "%sip msdp timers %u %u", spaces,
274 pim->msdp.hold_time, pim->msdp.keep_alive);
275 if (pim->msdp.connection_retry
276 != PIM_MSDP_PEER_CONNECT_RETRY_TIME)
277 vty_out(vty, " %u", pim->msdp.connection_retry);
278 vty_out(vty, "\n");
279 }
280
281 return writes;
282 }
283
284 #if PIM_IPV == 4
285 static int pim_igmp_config_write(struct vty *vty, int writes,
286 struct pim_interface *pim_ifp)
287 {
288 /* IF ip igmp */
289 if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
290 vty_out(vty, " ip igmp\n");
291 ++writes;
292 }
293
294 /* ip igmp version */
295 if (pim_ifp->igmp_version != IGMP_DEFAULT_VERSION) {
296 vty_out(vty, " ip igmp version %d\n", pim_ifp->igmp_version);
297 ++writes;
298 }
299
300 /* IF ip igmp query-max-response-time */
301 if (pim_ifp->gm_query_max_response_time_dsec !=
302 IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) {
303 vty_out(vty, " ip igmp query-max-response-time %d\n",
304 pim_ifp->gm_query_max_response_time_dsec);
305 ++writes;
306 }
307
308 /* IF ip igmp query-interval */
309 if (pim_ifp->gm_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL) {
310 vty_out(vty, " ip igmp query-interval %d\n",
311 pim_ifp->gm_default_query_interval);
312 ++writes;
313 }
314
315 /* IF ip igmp last-member_query-count */
316 if (pim_ifp->gm_last_member_query_count !=
317 IGMP_DEFAULT_ROBUSTNESS_VARIABLE) {
318 vty_out(vty, " ip igmp last-member-query-count %d\n",
319 pim_ifp->gm_last_member_query_count);
320 ++writes;
321 }
322
323 /* IF ip igmp last-member_query-interval */
324 if (pim_ifp->gm_specific_query_max_response_time_dsec !=
325 IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC) {
326 vty_out(vty, " ip igmp last-member-query-interval %d\n",
327 pim_ifp->gm_specific_query_max_response_time_dsec);
328 ++writes;
329 }
330
331 /* IF ip igmp join */
332 if (pim_ifp->gm_join_list) {
333 struct listnode *node;
334 struct gm_join *ij;
335 for (ALL_LIST_ELEMENTS_RO(pim_ifp->gm_join_list, node, ij)) {
336 char group_str[INET_ADDRSTRLEN];
337 char source_str[INET_ADDRSTRLEN];
338 pim_inet4_dump("<grp?>", ij->group_addr, group_str,
339 sizeof(group_str));
340 if (ij->source_addr.s_addr == INADDR_ANY) {
341 vty_out(vty, " ip igmp join %s\n", group_str);
342 } else {
343 inet_ntop(AF_INET, &ij->source_addr, source_str,
344 sizeof(source_str));
345 vty_out(vty, " ip igmp join %s %s\n", group_str,
346 source_str);
347 }
348 ++writes;
349 }
350 }
351
352 return writes;
353 }
354 #endif
355
356 int pim_config_write(struct vty *vty, int writes, struct interface *ifp,
357 struct pim_instance *pim)
358 {
359 struct pim_interface *pim_ifp = ifp->info;
360
361 if (PIM_IF_TEST_PIM(pim_ifp->options)) {
362 vty_out(vty, " " PIM_AF_NAME " pim\n");
363 ++writes;
364 }
365
366 /* IF ip pim drpriority */
367 if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) {
368 vty_out(vty, " " PIM_AF_NAME " pim drpriority %u\n",
369 pim_ifp->pim_dr_priority);
370 ++writes;
371 }
372
373 /* IF ip pim hello */
374 if (pim_ifp->pim_hello_period != PIM_DEFAULT_HELLO_PERIOD) {
375 vty_out(vty, " " PIM_AF_NAME " pim hello %d", pim_ifp->pim_hello_period);
376 if (pim_ifp->pim_default_holdtime != -1)
377 vty_out(vty, " %d", pim_ifp->pim_default_holdtime);
378 vty_out(vty, "\n");
379 ++writes;
380 }
381
382 #if PIM_IPV == 4
383 writes += pim_igmp_config_write(vty, writes, pim_ifp);
384 #endif
385
386 /* update source */
387 if (!pim_addr_is_any(pim_ifp->update_source)) {
388 vty_out(vty, " " PIM_AF_NAME " pim use-source %pPA\n",
389 &pim_ifp->update_source);
390 ++writes;
391 }
392
393 if (pim_ifp->activeactive)
394 vty_out(vty, " " PIM_AF_NAME " pim active-active\n");
395
396 /* boundary */
397 if (pim_ifp->boundary_oil_plist) {
398 vty_out(vty, " " PIM_AF_NAME " multicast boundary oil %s\n",
399 pim_ifp->boundary_oil_plist);
400 ++writes;
401 }
402
403 writes += pim_static_write_mroute(pim, vty, ifp);
404 pim_bsm_write_config(vty, ifp);
405 ++writes;
406 pim_bfd_write_config(vty, ifp);
407 ++writes;
408
409 return writes;
410 }
411
412 int pim_interface_config_write(struct vty *vty)
413 {
414 struct pim_instance *pim;
415 struct interface *ifp;
416 struct vrf *vrf;
417 int writes = 0;
418
419 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
420 pim = vrf->info;
421 if (!pim)
422 continue;
423
424 FOR_ALL_INTERFACES (pim->vrf, ifp) {
425 /* pim is enabled internally/implicitly on the vxlan
426 * termination device ipmr-lo. skip displaying that
427 * config to avoid confusion
428 */
429 if (pim_vxlan_is_term_dev_cfg(pim, ifp))
430 continue;
431
432 /* IF name */
433 if_vty_config_start(vty, ifp);
434
435 ++writes;
436
437 if (ifp->desc) {
438 vty_out(vty, " description %s\n", ifp->desc);
439 ++writes;
440 }
441
442 if (ifp->info) {
443 pim_config_write(vty, writes, ifp, pim);
444 }
445 if_vty_config_end(vty);
446
447 ++writes;
448 }
449 }
450
451 return writes;
452 }