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