3 * Copyright (C) 2008 Everton da Silva Marques
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.
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.
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
31 #include "pim_iface.h"
34 #include "pim_ssmpingd.h"
37 #include "pim_static.h"
43 #include "pim_vxlan.h"
45 int pim_debug_config_write(struct vty
*vty
)
49 if (PIM_DEBUG_MSDP_EVENTS
) {
50 vty_out(vty
, "debug msdp events\n");
53 if (PIM_DEBUG_MSDP_PACKETS
) {
54 vty_out(vty
, "debug msdp packets\n");
57 if (PIM_DEBUG_MSDP_INTERNAL
) {
58 vty_out(vty
, "debug msdp internal\n");
61 if (PIM_DEBUG_IGMP_EVENTS
) {
62 vty_out(vty
, "debug igmp events\n");
65 if (PIM_DEBUG_IGMP_PACKETS
) {
66 vty_out(vty
, "debug igmp packets\n");
69 if (PIM_DEBUG_IGMP_TRACE
) {
70 vty_out(vty
, "debug igmp trace\n");
74 if (PIM_DEBUG_MROUTE
) {
75 vty_out(vty
, "debug mroute\n");
79 if (PIM_DEBUG_MTRACE
) {
80 vty_out(vty
, "debug mtrace\n");
84 if (PIM_DEBUG_MROUTE_DETAIL_ONLY
) {
85 vty_out(vty
, "debug mroute detail\n");
89 if (PIM_DEBUG_PIM_EVENTS
) {
90 vty_out(vty
, "debug pim events\n");
93 if (PIM_DEBUG_PIM_PACKETS
) {
94 vty_out(vty
, "debug pim packets\n");
97 if (PIM_DEBUG_PIM_PACKETDUMP_SEND
) {
98 vty_out(vty
, "debug pim packet-dump send\n");
101 if (PIM_DEBUG_PIM_PACKETDUMP_RECV
) {
102 vty_out(vty
, "debug pim packet-dump receive\n");
106 if (PIM_DEBUG_PIM_TRACE
) {
107 vty_out(vty
, "debug pim trace\n");
110 if (PIM_DEBUG_PIM_TRACE_DETAIL_ONLY
) {
111 vty_out(vty
, "debug pim trace detail\n");
115 if (PIM_DEBUG_ZEBRA
) {
116 vty_out(vty
, "debug pim zebra\n");
120 if (PIM_DEBUG_MLAG
) {
121 vty_out(vty
, "debug pim mlag\n");
126 vty_out(vty
, "debug pim bsm\n");
130 if (PIM_DEBUG_VXLAN
) {
131 vty_out(vty
, "debug pim vxlan\n");
135 if (PIM_DEBUG_SSMPINGD
) {
136 vty_out(vty
, "debug ssmpingd\n");
140 if (PIM_DEBUG_PIM_HELLO
) {
141 vty_out(vty
, "debug pim packets hello\n");
145 if (PIM_DEBUG_PIM_J_P
) {
146 vty_out(vty
, "debug pim packets joins\n");
150 if (PIM_DEBUG_PIM_REG
) {
151 vty_out(vty
, "debug pim packets register\n");
155 if (PIM_DEBUG_STATIC
) {
156 vty_out(vty
, "debug pim static\n");
160 if (PIM_DEBUG_PIM_NHT
) {
161 vty_out(vty
, "debug pim nht\n");
168 int pim_global_config_write_worker(struct pim_instance
*pim
, struct vty
*vty
)
171 struct pim_ssm
*ssm
= pim
->ssm_info
;
174 if (pim
->vrf
->vrf_id
== VRF_DEFAULT
)
175 snprintf(spaces
, sizeof(spaces
), "%s", "");
177 snprintf(spaces
, sizeof(spaces
), "%s", " ");
179 writes
+= pim_msdp_peer_config_write(vty
, pim
, spaces
);
180 writes
+= pim_msdp_config_write(pim
, vty
, spaces
);
182 if (!pim
->send_v6_secondary
) {
183 vty_out(vty
, "%sno ip pim send-v6-secondary\n", spaces
);
187 writes
+= pim_rp_config_write(pim
, vty
, spaces
);
189 if (pim
->vrf
->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
);
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
);
202 if (router
->packet_process
!= PIM_DEFAULT_PACKET_PROCESS
) {
203 vty_out(vty
, "%sip pim packets %d\n", spaces
,
204 router
->packet_process
);
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
);
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
);
218 if (ssm
->plist_name
) {
219 vty_out(vty
, "%sip pim ssm prefix-list %s\n", spaces
,
223 if (pim
->register_plist
) {
224 vty_out(vty
, "%sip pim register-accept-list %s\n", spaces
,
225 pim
->register_plist
);
228 if (pim
->spt
.switchover
== PIM_SPT_INFINITY
) {
231 "%sip pim spt-switchover infinity-and-beyond prefix-list %s\n",
232 spaces
, pim
->spt
.plist
);
235 "%sip pim spt-switchover infinity-and-beyond\n",
239 if (pim
->ecmp_rebalance_enable
) {
240 vty_out(vty
, "%sip pim ecmp rebalance\n", spaces
);
242 } else if (pim
->ecmp_enable
) {
243 vty_out(vty
, "%sip pim ecmp\n", spaces
);
247 if (pim
->igmp_watermark_limit
!= 0) {
248 vty_out(vty
, "%sip igmp watermark-warn %u\n", spaces
,
249 pim
->igmp_watermark_limit
);
253 if (pim
->ssmpingd_list
) {
254 struct listnode
*node
;
255 struct ssmpingd_sock
*ss
;
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
,
261 vty_out(vty
, "%sip ssmpingd %s\n", spaces
, source_str
);
266 if (pim
->msdp
.hold_time
!= PIM_MSDP_PEER_HOLD_TIME
267 || pim
->msdp
.keep_alive
!= PIM_MSDP_PEER_KA_TIME
268 || pim
->msdp
.connection_retry
!= PIM_MSDP_PEER_CONNECT_RETRY_TIME
) {
269 vty_out(vty
, "%sip msdp timers %u %u", spaces
,
270 pim
->msdp
.hold_time
, pim
->msdp
.keep_alive
);
271 if (pim
->msdp
.connection_retry
272 != PIM_MSDP_PEER_CONNECT_RETRY_TIME
)
273 vty_out(vty
, " %u", pim
->msdp
.connection_retry
);
280 int pim_interface_config_write(struct vty
*vty
)
282 struct pim_instance
*pim
;
283 struct interface
*ifp
;
287 RB_FOREACH (vrf
, vrf_name_head
, &vrfs_by_name
) {
292 FOR_ALL_INTERFACES (pim
->vrf
, ifp
) {
293 /* pim is enabled internally/implicitly on the vxlan
294 * termination device ipmr-lo. skip displaying that
295 * config to avoid confusion
297 if (pim_vxlan_is_term_dev_cfg(pim
, ifp
))
301 if (vrf
->vrf_id
== VRF_DEFAULT
)
302 vty_frame(vty
, "interface %s\n", ifp
->name
);
304 vty_frame(vty
, "interface %s vrf %s\n",
305 ifp
->name
, vrf
->name
);
309 vty_out(vty
, " description %s\n", ifp
->desc
);
314 struct pim_interface
*pim_ifp
= ifp
->info
;
316 if (PIM_IF_TEST_PIM(pim_ifp
->options
)) {
317 vty_out(vty
, " ip pim\n");
321 /* IF ip pim drpriority */
322 if (pim_ifp
->pim_dr_priority
323 != PIM_DEFAULT_DR_PRIORITY
) {
324 vty_out(vty
, " ip pim drpriority %u\n",
325 pim_ifp
->pim_dr_priority
);
329 /* IF ip pim hello */
330 if (pim_ifp
->pim_hello_period
331 != PIM_DEFAULT_HELLO_PERIOD
) {
332 vty_out(vty
, " ip pim hello %d",
333 pim_ifp
->pim_hello_period
);
334 if (pim_ifp
->pim_default_holdtime
!= -1)
336 pim_ifp
->pim_default_holdtime
);
342 if (PIM_INADDR_ISNOT_ANY(
343 pim_ifp
->update_source
)) {
344 char src_str
[INET_ADDRSTRLEN
];
345 pim_inet4_dump("<src?>",
346 pim_ifp
->update_source
,
349 vty_out(vty
, " ip pim use-source %s\n",
355 if (PIM_IF_TEST_IGMP(pim_ifp
->options
)) {
356 vty_out(vty
, " ip igmp\n");
360 /* ip igmp version */
361 if (pim_ifp
->igmp_version
362 != IGMP_DEFAULT_VERSION
) {
363 vty_out(vty
, " ip igmp version %d\n",
364 pim_ifp
->igmp_version
);
368 /* IF ip igmp query-max-response-time */
369 if (pim_ifp
->igmp_query_max_response_time_dsec
370 != IGMP_QUERY_MAX_RESPONSE_TIME_DSEC
) {
372 " ip igmp query-max-response-time %d\n",
373 pim_ifp
->igmp_query_max_response_time_dsec
);
377 /* IF ip igmp query-interval */
378 if (pim_ifp
->igmp_default_query_interval
379 != IGMP_GENERAL_QUERY_INTERVAL
) {
381 " ip igmp query-interval %d\n",
382 pim_ifp
->igmp_default_query_interval
);
386 /* IF ip igmp last-member_query-count */
387 if (pim_ifp
->igmp_last_member_query_count
388 != IGMP_DEFAULT_ROBUSTNESS_VARIABLE
) {
390 " ip igmp last-member-query-count %d\n",
391 pim_ifp
->igmp_last_member_query_count
);
395 /* IF ip igmp last-member_query-interval */
396 if (pim_ifp
->igmp_specific_query_max_response_time_dsec
397 != IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC
) {
399 " ip igmp last-member-query-interval %d\n",
400 pim_ifp
->igmp_specific_query_max_response_time_dsec
);
404 /* IF ip igmp join */
405 if (pim_ifp
->igmp_join_list
) {
406 struct listnode
*node
;
407 struct igmp_join
*ij
;
408 for (ALL_LIST_ELEMENTS_RO(
409 pim_ifp
->igmp_join_list
,
411 char group_str
[INET_ADDRSTRLEN
];
419 if (ij
->source_addr
.s_addr
== INADDR_ANY
) {
421 " ip igmp join %s\n",
429 " ip igmp join %s %s\n",
430 group_str
, source_str
);
436 if (pim_ifp
->activeactive
)
437 vty_out(vty
, " ip pim active-active\n");
440 if (pim_ifp
->boundary_oil_plist
) {
442 " ip multicast boundary oil %s\n",
443 pim_ifp
->boundary_oil_plist
);
448 pim_static_write_mroute(pim
, vty
, ifp
);
449 pim_bsm_write_config(vty
, ifp
);
451 pim_bfd_write_config(vty
, ifp
);
454 vty_endframe(vty
, "!\n");