]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_vty.c
Merge pull request #4430 from lkrishnamoor/hostname_crash
[mirror_frr.git] / pimd / pim_vty.c
CommitLineData
12e41d03 1/*
896014f4
DL
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 */
12e41d03
DL
19
20#include <zebra.h>
21
22#include "if.h"
23#include "linklist.h"
dfe43e25
DW
24#include "prefix.h"
25#include "vty.h"
469351b3 26#include "vrf.h"
dfe43e25 27#include "plist.h"
12e41d03
DL
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"
dedccda6 35#include "pim_pim.h"
9867746a 36#include "pim_oil.h"
f91f89bc 37#include "pim_static.h"
75a26779 38#include "pim_rp.h"
3c72d654 39#include "pim_msdp.h"
15a5dafe 40#include "pim_ssm.h"
ba4eb1bc 41#include "pim_bfd.h"
16c926c8 42#include "pim_bsm.h"
7c85225c 43#include "pim_vxlan.h"
12e41d03 44
d62a17ae 45int pim_debug_config_write(struct vty *vty)
12e41d03 46{
d62a17ae 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 if (PIM_DEBUG_IGMP_TRACE_DETAIL) {
74 vty_out(vty, "debug igmp trace detail\n");
75 ++writes;
76 }
77
78 if (PIM_DEBUG_MROUTE) {
79 vty_out(vty, "debug mroute\n");
80 ++writes;
81 }
82
4d9ad5dc
MS
83 if (PIM_DEBUG_MTRACE) {
84 vty_out(vty, "debug mtrace\n");
85 ++writes;
86 }
87
d62a17ae 88 if (PIM_DEBUG_MROUTE_DETAIL) {
89 vty_out(vty, "debug mroute detail\n");
90 ++writes;
91 }
92
93 if (PIM_DEBUG_PIM_EVENTS) {
94 vty_out(vty, "debug pim events\n");
95 ++writes;
96 }
97 if (PIM_DEBUG_PIM_PACKETS) {
98 vty_out(vty, "debug pim packets\n");
99 ++writes;
100 }
101 if (PIM_DEBUG_PIM_PACKETDUMP_SEND) {
102 vty_out(vty, "debug pim packet-dump send\n");
103 ++writes;
104 }
105 if (PIM_DEBUG_PIM_PACKETDUMP_RECV) {
106 vty_out(vty, "debug pim packet-dump receive\n");
107 ++writes;
108 }
109
110 if (PIM_DEBUG_PIM_TRACE) {
111 vty_out(vty, "debug pim trace\n");
112 ++writes;
113 }
114 if (PIM_DEBUG_PIM_TRACE_DETAIL) {
115 vty_out(vty, "debug pim trace detail\n");
116 ++writes;
117 }
118
119 if (PIM_DEBUG_ZEBRA) {
120 vty_out(vty, "debug pim zebra\n");
121 ++writes;
122 }
123
16c926c8 124 if (PIM_DEBUG_BSM) {
125 vty_out(vty, "debug pim bsm\n");
126 ++writes;
127 }
128
4d913fa6
AK
129 if (PIM_DEBUG_VXLAN) {
130 vty_out(vty, "debug pim vxlan\n");
131 ++writes;
132 }
133
d62a17ae 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
40f1f31b
DS
159 if (PIM_DEBUG_PIM_NHT) {
160 vty_out(vty, "debug pim nht\n");
161 ++writes;
162 }
163
d62a17ae 164 return writes;
12e41d03
DL
165}
166
9ecb7b77 167int pim_global_config_write_worker(struct pim_instance *pim, struct vty *vty)
12e41d03 168{
d62a17ae 169 int writes = 0;
6196ed71 170 struct pim_ssm *ssm = pim->ssm_info;
0c8b717e
DS
171 char spaces[10];
172
173 if (pim->vrf_id == VRF_DEFAULT)
174 sprintf(spaces, "%s", "");
175 else
176 sprintf(spaces, "%s", " ");
12e41d03 177
84f25989 178 writes += pim_msdp_config_write(pim, vty, spaces);
d62a17ae 179
6196ed71 180 if (!pim->send_v6_secondary) {
c9657fdc 181 vty_out(vty, "%sno ip pim send-v6-secondary\n", spaces);
d62a17ae 182 ++writes;
6b775f61 183 }
12e41d03 184
0c8b717e 185 writes += pim_rp_config_write(pim, vty, spaces);
d62a17ae 186
2925dff5 187 if (router->register_suppress_time
d62a17ae 188 != PIM_REGISTER_SUPPRESSION_TIME_DEFAULT) {
c9657fdc 189 vty_out(vty, "%sip pim register-suppress-time %d\n", spaces,
2925dff5 190 router->register_suppress_time);
d62a17ae 191 ++writes;
6b775f61 192 }
5b45753e 193 if (router->t_periodic != PIM_DEFAULT_T_PERIODIC) {
c9657fdc 194 vty_out(vty, "%sip pim join-prune-interval %d\n", spaces,
5b45753e 195 router->t_periodic);
d62a17ae 196 ++writes;
197 }
19b807ca 198 if (pim->keep_alive_time != PIM_KEEPALIVE_PERIOD) {
c9657fdc 199 vty_out(vty, "%sip pim keep-alive-timer %d\n", spaces,
19b807ca 200 pim->keep_alive_time);
d62a17ae 201 ++writes;
202 }
cc14df13
DS
203 if (pim->rp_keep_alive_time != (unsigned int)PIM_RP_KEEPALIVE_PERIOD) {
204 vty_out(vty, "%sip pim rp keep-alive-timer %d\n", spaces,
205 pim->rp_keep_alive_time);
206 ++writes;
207 }
75373cca 208 if (router->packet_process != PIM_DEFAULT_PACKET_PROCESS) {
c9657fdc 209 vty_out(vty, "%sip pim packets %d\n", spaces,
75373cca 210 router->packet_process);
d62a17ae 211 ++writes;
212 }
213 if (ssm->plist_name) {
c9657fdc
DS
214 vty_out(vty, "%sip pim ssm prefix-list %s\n", spaces,
215 ssm->plist_name);
d62a17ae 216 ++writes;
217 }
6196ed71
DS
218 if (pim->spt.switchover == PIM_SPT_INFINITY) {
219 if (pim->spt.plist)
d62a17ae 220 vty_out(vty,
c9657fdc
DS
221 "%sip pim spt-switchover infinity-and-beyond prefix-list %s\n",
222 spaces, pim->spt.plist);
d62a17ae 223 else
224 vty_out(vty,
c9657fdc
DS
225 "%sip pim spt-switchover infinity-and-beyond\n",
226 spaces);
d62a17ae 227 ++writes;
228 }
4795fff7 229 if (pim->ecmp_rebalance_enable) {
c9657fdc 230 vty_out(vty, "%sip pim ecmp rebalance\n", spaces);
d62a17ae 231 ++writes;
4795fff7 232 } else if (pim->ecmp_enable) {
c9657fdc 233 vty_out(vty, "%sip pim ecmp\n", spaces);
d62a17ae 234 ++writes;
235 }
71ad9915 236 if (pim->ssmpingd_list) {
d62a17ae 237 struct listnode *node;
238 struct ssmpingd_sock *ss;
d62a17ae 239 ++writes;
71ad9915 240 for (ALL_LIST_ELEMENTS_RO(pim->ssmpingd_list, node, ss)) {
d62a17ae 241 char source_str[INET_ADDRSTRLEN];
242 pim_inet4_dump("<src?>", ss->source_addr, source_str,
243 sizeof(source_str));
c9657fdc 244 vty_out(vty, "%sip ssmpingd %s\n", spaces, source_str);
d62a17ae 245 ++writes;
246 }
247 }
248
7c85225c
AK
249 pim_vxlan_config_write(vty, spaces, &writes);
250
d62a17ae 251 return writes;
252}
12e41d03 253
d62a17ae 254int pim_interface_config_write(struct vty *vty)
255{
024d6a75 256 struct pim_instance *pim;
d62a17ae 257 struct interface *ifp;
024d6a75
DS
258 struct vrf *vrf;
259 int writes = 0;
d62a17ae 260
a2addae8 261 RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
024d6a75
DS
262 pim = vrf->info;
263 if (!pim)
264 continue;
d62a17ae 265
451fda4f 266 FOR_ALL_INTERFACES (pim->vrf, ifp) {
024d6a75
DS
267 /* IF name */
268 if (vrf->vrf_id == VRF_DEFAULT)
a8b828f3 269 vty_frame(vty, "interface %s\n", ifp->name);
024d6a75 270 else
019eb073
DS
271 vty_frame(vty, "interface %s vrf %s\n",
272 ifp->name, vrf->name);
024d6a75 273 ++writes;
d62a17ae 274
91e5b43a
RW
275 if (ifp->desc) {
276 vty_out(vty, " description %s\n", ifp->desc);
277 ++writes;
278 }
279
024d6a75
DS
280 if (ifp->info) {
281 struct pim_interface *pim_ifp = ifp->info;
d62a17ae 282
024d6a75 283 if (PIM_IF_TEST_PIM(pim_ifp->options)) {
2f5e937c 284 vty_out(vty, " ip pim\n");
024d6a75
DS
285 ++writes;
286 }
d62a17ae 287
024d6a75
DS
288 /* IF ip pim drpriority */
289 if (pim_ifp->pim_dr_priority
290 != PIM_DEFAULT_DR_PRIORITY) {
291 vty_out(vty, " ip pim drpriority %u\n",
292 pim_ifp->pim_dr_priority);
293 ++writes;
294 }
d62a17ae 295
024d6a75
DS
296 /* IF ip pim hello */
297 if (pim_ifp->pim_hello_period
298 != PIM_DEFAULT_HELLO_PERIOD) {
299 vty_out(vty, " ip pim hello %d",
300 pim_ifp->pim_hello_period);
301 if (pim_ifp->pim_default_holdtime != -1)
302 vty_out(vty, " %d",
303 pim_ifp->pim_default_holdtime);
304 vty_out(vty, "\n");
b0f525a8 305 ++writes;
024d6a75 306 }
d62a17ae 307
024d6a75
DS
308 /* update source */
309 if (PIM_INADDR_ISNOT_ANY(
310 pim_ifp->update_source)) {
311 char src_str[INET_ADDRSTRLEN];
312 pim_inet4_dump("<src?>",
313 pim_ifp->update_source,
314 src_str,
315 sizeof(src_str));
316 vty_out(vty, " ip pim use-source %s\n",
317 src_str);
318 ++writes;
319 }
d62a17ae 320
024d6a75
DS
321 /* IF ip igmp */
322 if (PIM_IF_TEST_IGMP(pim_ifp->options)) {
323 vty_out(vty, " ip igmp\n");
324 ++writes;
325 }
d62a17ae 326
024d6a75
DS
327 /* ip igmp version */
328 if (pim_ifp->igmp_version
329 != IGMP_DEFAULT_VERSION) {
330 vty_out(vty, " ip igmp version %d\n",
331 pim_ifp->igmp_version);
332 ++writes;
333 }
d62a17ae 334
024d6a75
DS
335 /* IF ip igmp query-max-response-time */
336 if (pim_ifp->igmp_query_max_response_time_dsec
337 != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) {
338 vty_out(vty,
339 " ip igmp query-max-response-time %d\n",
340 pim_ifp->igmp_query_max_response_time_dsec);
d62a17ae 341 ++writes;
342 }
d62a17ae 343
c55f7a80
DS
344 /* IF ip igmp query-interval */
345 if (pim_ifp->igmp_default_query_interval
346 != IGMP_GENERAL_QUERY_INTERVAL) {
347 vty_out(vty,
348 " ip igmp query-interval %d\n",
349 pim_ifp->igmp_default_query_interval);
350 ++writes;
351 }
352
59115451
SP
353 /* IF ip igmp last-member_query-count */
354 if (pim_ifp->igmp_last_member_query_count
355 != IGMP_DEFAULT_ROBUSTNESS_VARIABLE) {
356 vty_out(vty,
357 " ip igmp last-member-query-count %d\n",
358 pim_ifp->igmp_last_member_query_count);
359 ++writes;
360 }
361
362 /* IF ip igmp last-member_query-interval */
363 if (pim_ifp->igmp_specific_query_max_response_time_dsec
364 != IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC) {
365 vty_out(vty,
366 " ip igmp last-member-query-interval %d\n",
367 pim_ifp->igmp_specific_query_max_response_time_dsec);
368 ++writes;
369 }
370
024d6a75
DS
371 /* IF ip igmp join */
372 if (pim_ifp->igmp_join_list) {
373 struct listnode *node;
374 struct igmp_join *ij;
375 for (ALL_LIST_ELEMENTS_RO(
376 pim_ifp->igmp_join_list,
377 node, ij)) {
378 char group_str[INET_ADDRSTRLEN];
379 char source_str
380 [INET_ADDRSTRLEN];
381 pim_inet4_dump(
382 "<grp?>",
383 ij->group_addr,
384 group_str,
385 sizeof(group_str));
386 inet_ntop(AF_INET,
387 &ij->source_addr,
388 source_str,
389 sizeof(source_str));
390 vty_out(vty,
391 " ip igmp join %s %s\n",
392 group_str, source_str);
393 ++writes;
394 }
395 }
396
414d885a
DS
397 if (pim_ifp->activeactive)
398 vty_out(vty, " ip pim active-active\n");
399
b0f525a8
QY
400 /* boundary */
401 if (pim_ifp->boundary_oil_plist) {
402 vty_out(vty,
513c8462 403 " ip multicast boundary oil %s\n",
b0f525a8
QY
404 pim_ifp->boundary_oil_plist);
405 ++writes;
406 }
407
4e0bc0f0 408 writes +=
64c86530 409 pim_static_write_mroute(pim, vty, ifp);
16c926c8 410 pim_bsm_write_config(vty, ifp);
411 ++writes;
024d6a75 412 pim_bfd_write_config(vty, ifp);
16c926c8 413 ++writes;
024d6a75 414 }
a8b828f3 415 vty_endframe(vty, "!\n");
024d6a75 416 ++writes;
d62a17ae 417 }
12e41d03 418 }
12e41d03 419
d62a17ae 420 return writes;
12e41d03 421}