]>
Commit | Line | Data |
---|---|---|
12e41d03 DL |
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 | |
16 | along with this program; see the file COPYING; if not, write to the | |
17 | Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, | |
18 | MA 02110-1301 USA | |
19 | ||
20 | $QuaggaId: $Format:%an, %ai, %h$ $ | |
21 | */ | |
22 | ||
12e41d03 DL |
23 | #include <zebra.h> |
24 | ||
7a2fbbf0 DL |
25 | #include <sys/ioctl.h> |
26 | ||
12e41d03 DL |
27 | #include "command.h" |
28 | #include "if.h" | |
29 | #include "prefix.h" | |
30 | #include "zclient.h" | |
31 | ||
32 | #include "pimd.h" | |
9867746a | 33 | #include "pim_mroute.h" |
12e41d03 DL |
34 | #include "pim_cmd.h" |
35 | #include "pim_iface.h" | |
36 | #include "pim_vty.h" | |
37 | #include "pim_mroute.h" | |
38 | #include "pim_str.h" | |
39 | #include "pim_igmp.h" | |
40 | #include "pim_igmpv3.h" | |
41 | #include "pim_sock.h" | |
42 | #include "pim_time.h" | |
43 | #include "pim_util.h" | |
44 | #include "pim_oil.h" | |
45 | #include "pim_neighbor.h" | |
46 | #include "pim_pim.h" | |
47 | #include "pim_ifchannel.h" | |
48 | #include "pim_hello.h" | |
49 | #include "pim_msg.h" | |
50 | #include "pim_upstream.h" | |
51 | #include "pim_rpf.h" | |
52 | #include "pim_macro.h" | |
53 | #include "pim_ssmpingd.h" | |
54 | #include "pim_zebra.h" | |
6250610a | 55 | #include "pim_static.h" |
a920d6e7 | 56 | #include "pim_rp.h" |
12e41d03 DL |
57 | |
58 | static struct cmd_node pim_global_node = { | |
59 | PIM_NODE, | |
60 | "", | |
61 | 1 /* vtysh ? yes */ | |
62 | }; | |
63 | ||
64 | static struct cmd_node interface_node = { | |
65 | INTERFACE_NODE, | |
66 | "%s(config-if)# ", | |
67 | 1 /* vtysh ? yes */ | |
68 | }; | |
69 | ||
70 | static void pim_if_membership_clear(struct interface *ifp) | |
71 | { | |
72 | struct pim_interface *pim_ifp; | |
73 | ||
74 | pim_ifp = ifp->info; | |
75 | zassert(pim_ifp); | |
76 | ||
77 | if (PIM_IF_TEST_PIM(pim_ifp->options) && | |
78 | PIM_IF_TEST_IGMP(pim_ifp->options)) { | |
79 | return; | |
80 | } | |
81 | ||
82 | pim_ifchannel_membership_clear(ifp); | |
83 | } | |
84 | ||
85 | /* | |
86 | When PIM is disabled on interface, IGMPv3 local membership | |
87 | information is not injected into PIM interface state. | |
88 | ||
89 | The function pim_if_membership_refresh() fetches all IGMPv3 local | |
90 | membership information into PIM. It is intented to be called | |
91 | whenever PIM is enabled on the interface in order to collect missed | |
92 | local membership information. | |
93 | */ | |
94 | static void pim_if_membership_refresh(struct interface *ifp) | |
95 | { | |
96 | struct pim_interface *pim_ifp; | |
97 | struct listnode *sock_node; | |
98 | struct igmp_sock *igmp; | |
99 | ||
100 | pim_ifp = ifp->info; | |
101 | zassert(pim_ifp); | |
102 | ||
103 | if (!PIM_IF_TEST_PIM(pim_ifp->options)) | |
104 | return; | |
105 | if (!PIM_IF_TEST_IGMP(pim_ifp->options)) | |
106 | return; | |
107 | ||
108 | /* | |
109 | First clear off membership from all PIM (S,G) entries on the | |
110 | interface | |
111 | */ | |
112 | ||
113 | pim_ifchannel_membership_clear(ifp); | |
114 | ||
115 | /* | |
116 | Then restore PIM (S,G) membership from all IGMPv3 (S,G) entries on | |
117 | the interface | |
118 | */ | |
119 | ||
120 | /* scan igmp sockets */ | |
121 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
122 | struct listnode *grpnode; | |
123 | struct igmp_group *grp; | |
124 | ||
125 | /* scan igmp groups */ | |
126 | for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) { | |
127 | struct listnode *srcnode; | |
128 | struct igmp_source *src; | |
129 | ||
130 | /* scan group sources */ | |
131 | for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) { | |
132 | ||
133 | if (IGMP_SOURCE_TEST_FORWARDING(src->source_flags)) { | |
134 | pim_ifchannel_local_membership_add(ifp, | |
135 | src->source_addr, | |
136 | grp->group_addr); | |
137 | } | |
138 | ||
139 | } /* scan group sources */ | |
140 | } /* scan igmp groups */ | |
141 | } /* scan igmp sockets */ | |
142 | ||
143 | /* | |
144 | Finally delete every PIM (S,G) entry lacking all state info | |
145 | */ | |
146 | ||
147 | pim_ifchannel_delete_on_noinfo(ifp); | |
148 | ||
149 | } | |
150 | ||
151 | static void pim_show_assert(struct vty *vty) | |
152 | { | |
153 | struct listnode *ifnode; | |
154 | struct interface *ifp; | |
155 | time_t now; | |
156 | ||
157 | now = pim_time_monotonic_sec(); | |
158 | ||
159 | vty_out(vty, | |
160 | "Interface Address Source Group State Winner Uptime Timer%s", | |
161 | VTY_NEWLINE); | |
162 | ||
469351b3 | 163 | for (ALL_LIST_ELEMENTS_RO(vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
164 | struct pim_interface *pim_ifp; |
165 | struct in_addr ifaddr; | |
166 | struct listnode *ch_node; | |
167 | struct pim_ifchannel *ch; | |
168 | ||
169 | pim_ifp = ifp->info; | |
170 | ||
171 | if (!pim_ifp) | |
172 | continue; | |
173 | ||
174 | ifaddr = pim_ifp->primary_address; | |
175 | ||
176 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) { | |
177 | char ch_src_str[100]; | |
178 | char ch_grp_str[100]; | |
179 | char winner_str[100]; | |
180 | char uptime[10]; | |
181 | char timer[10]; | |
182 | ||
183 | pim_inet4_dump("<ch_src?>", ch->source_addr, | |
184 | ch_src_str, sizeof(ch_src_str)); | |
185 | pim_inet4_dump("<ch_grp?>", ch->group_addr, | |
186 | ch_grp_str, sizeof(ch_grp_str)); | |
187 | pim_inet4_dump("<assrt_win?>", ch->ifassert_winner, | |
188 | winner_str, sizeof(winner_str)); | |
189 | ||
190 | pim_time_uptime(uptime, sizeof(uptime), now - ch->ifassert_creation); | |
191 | pim_time_timer_to_mmss(timer, sizeof(timer), | |
192 | ch->t_ifassert_timer); | |
193 | ||
194 | vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %-15s %-8s %-5s%s", | |
195 | ifp->name, | |
196 | inet_ntoa(ifaddr), | |
197 | ch_src_str, | |
198 | ch_grp_str, | |
199 | pim_ifchannel_ifassert_name(ch->ifassert_state), | |
200 | winner_str, | |
201 | uptime, | |
202 | timer, | |
203 | VTY_NEWLINE); | |
204 | } /* scan interface channels */ | |
205 | } /* scan interfaces */ | |
206 | } | |
207 | ||
208 | static void pim_show_assert_internal(struct vty *vty) | |
209 | { | |
210 | struct listnode *ifnode; | |
211 | struct interface *ifp; | |
212 | ||
213 | vty_out(vty, | |
214 | "CA: CouldAssert%s" | |
215 | "ECA: Evaluate CouldAssert%s" | |
216 | "ATD: AssertTrackingDesired%s" | |
217 | "eATD: Evaluate AssertTrackingDesired%s%s", | |
218 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
219 | ||
220 | vty_out(vty, | |
221 | "Interface Address Source Group CA eCA ATD eATD%s", | |
222 | VTY_NEWLINE); | |
223 | ||
469351b3 | 224 | for (ALL_LIST_ELEMENTS_RO(vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
225 | struct pim_interface *pim_ifp; |
226 | struct in_addr ifaddr; | |
227 | struct listnode *ch_node; | |
228 | struct pim_ifchannel *ch; | |
229 | ||
230 | pim_ifp = ifp->info; | |
231 | ||
232 | if (!pim_ifp) | |
233 | continue; | |
234 | ||
235 | ifaddr = pim_ifp->primary_address; | |
236 | ||
237 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) { | |
238 | char ch_src_str[100]; | |
239 | char ch_grp_str[100]; | |
240 | ||
241 | pim_inet4_dump("<ch_src?>", ch->source_addr, | |
242 | ch_src_str, sizeof(ch_src_str)); | |
243 | pim_inet4_dump("<ch_grp?>", ch->group_addr, | |
244 | ch_grp_str, sizeof(ch_grp_str)); | |
245 | vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-3s %-3s %-4s%s", | |
246 | ifp->name, | |
247 | inet_ntoa(ifaddr), | |
248 | ch_src_str, | |
249 | ch_grp_str, | |
250 | PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags) ? "yes" : "no", | |
251 | pim_macro_ch_could_assert_eval(ch) ? "yes" : "no", | |
252 | PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) ? "yes" : "no", | |
253 | pim_macro_assert_tracking_desired_eval(ch) ? "yes" : "no", | |
254 | VTY_NEWLINE); | |
255 | } /* scan interface channels */ | |
256 | } /* scan interfaces */ | |
257 | } | |
258 | ||
259 | static void pim_show_assert_metric(struct vty *vty) | |
260 | { | |
261 | struct listnode *ifnode; | |
262 | struct interface *ifp; | |
263 | ||
264 | vty_out(vty, | |
265 | "Interface Address Source Group RPT Pref Metric Address %s", | |
266 | VTY_NEWLINE); | |
267 | ||
469351b3 | 268 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
269 | struct pim_interface *pim_ifp; |
270 | struct in_addr ifaddr; | |
271 | struct listnode *ch_node; | |
272 | struct pim_ifchannel *ch; | |
273 | ||
274 | pim_ifp = ifp->info; | |
275 | ||
276 | if (!pim_ifp) | |
277 | continue; | |
278 | ||
279 | ifaddr = pim_ifp->primary_address; | |
280 | ||
281 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) { | |
282 | char ch_src_str[100]; | |
283 | char ch_grp_str[100]; | |
284 | char addr_str[100]; | |
285 | struct pim_assert_metric am; | |
286 | ||
287 | am = pim_macro_spt_assert_metric(&ch->upstream->rpf, pim_ifp->primary_address); | |
288 | ||
289 | pim_inet4_dump("<ch_src?>", ch->source_addr, | |
290 | ch_src_str, sizeof(ch_src_str)); | |
291 | pim_inet4_dump("<ch_grp?>", ch->group_addr, | |
292 | ch_grp_str, sizeof(ch_grp_str)); | |
293 | pim_inet4_dump("<addr?>", am.ip_address, | |
294 | addr_str, sizeof(addr_str)); | |
295 | ||
296 | vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %4u %6u %-15s%s", | |
297 | ifp->name, | |
298 | inet_ntoa(ifaddr), | |
299 | ch_src_str, | |
300 | ch_grp_str, | |
301 | am.rpt_bit_flag ? "yes" : "no", | |
302 | am.metric_preference, | |
303 | am.route_metric, | |
304 | addr_str, | |
305 | VTY_NEWLINE); | |
306 | } /* scan interface channels */ | |
307 | } /* scan interfaces */ | |
308 | } | |
309 | ||
310 | static void pim_show_assert_winner_metric(struct vty *vty) | |
311 | { | |
312 | struct listnode *ifnode; | |
313 | struct interface *ifp; | |
314 | ||
315 | vty_out(vty, | |
316 | "Interface Address Source Group RPT Pref Metric Address %s", | |
317 | VTY_NEWLINE); | |
318 | ||
469351b3 | 319 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
320 | struct pim_interface *pim_ifp; |
321 | struct in_addr ifaddr; | |
322 | struct listnode *ch_node; | |
323 | struct pim_ifchannel *ch; | |
324 | ||
325 | pim_ifp = ifp->info; | |
326 | ||
327 | if (!pim_ifp) | |
328 | continue; | |
329 | ||
330 | ifaddr = pim_ifp->primary_address; | |
331 | ||
332 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) { | |
333 | char ch_src_str[100]; | |
334 | char ch_grp_str[100]; | |
335 | char addr_str[100]; | |
336 | struct pim_assert_metric *am; | |
337 | char pref_str[5]; | |
338 | char metr_str[7]; | |
339 | ||
340 | am = &ch->ifassert_winner_metric; | |
341 | ||
342 | pim_inet4_dump("<ch_src?>", ch->source_addr, | |
343 | ch_src_str, sizeof(ch_src_str)); | |
344 | pim_inet4_dump("<ch_grp?>", ch->group_addr, | |
345 | ch_grp_str, sizeof(ch_grp_str)); | |
346 | pim_inet4_dump("<addr?>", am->ip_address, | |
347 | addr_str, sizeof(addr_str)); | |
348 | ||
349 | if (am->metric_preference == PIM_ASSERT_METRIC_PREFERENCE_MAX) | |
350 | snprintf(pref_str, sizeof(pref_str), "INFI"); | |
351 | else | |
352 | snprintf(pref_str, sizeof(pref_str), "%4u", am->metric_preference); | |
353 | ||
354 | if (am->route_metric == PIM_ASSERT_ROUTE_METRIC_MAX) | |
355 | snprintf(metr_str, sizeof(metr_str), "INFI"); | |
356 | else | |
357 | snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric); | |
358 | ||
359 | vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-4s %-6s %-15s%s", | |
360 | ifp->name, | |
361 | inet_ntoa(ifaddr), | |
362 | ch_src_str, | |
363 | ch_grp_str, | |
364 | am->rpt_bit_flag ? "yes" : "no", | |
365 | pref_str, | |
366 | metr_str, | |
367 | addr_str, | |
368 | VTY_NEWLINE); | |
369 | } /* scan interface channels */ | |
370 | } /* scan interfaces */ | |
371 | } | |
372 | ||
373 | static void pim_show_membership(struct vty *vty) | |
374 | { | |
375 | struct listnode *ifnode; | |
376 | struct interface *ifp; | |
377 | ||
378 | vty_out(vty, | |
379 | "Interface Address Source Group Membership%s", | |
380 | VTY_NEWLINE); | |
381 | ||
469351b3 | 382 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
383 | struct pim_interface *pim_ifp; |
384 | struct in_addr ifaddr; | |
385 | struct listnode *ch_node; | |
386 | struct pim_ifchannel *ch; | |
387 | ||
388 | pim_ifp = ifp->info; | |
389 | ||
390 | if (!pim_ifp) | |
391 | continue; | |
392 | ||
393 | ifaddr = pim_ifp->primary_address; | |
394 | ||
395 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) { | |
396 | char ch_src_str[100]; | |
397 | char ch_grp_str[100]; | |
398 | ||
399 | pim_inet4_dump("<ch_src?>", ch->source_addr, | |
400 | ch_src_str, sizeof(ch_src_str)); | |
401 | pim_inet4_dump("<ch_grp?>", ch->group_addr, | |
402 | ch_grp_str, sizeof(ch_grp_str)); | |
403 | ||
404 | vty_out(vty, "%-9s %-15s %-15s %-15s %-10s%s", | |
405 | ifp->name, | |
406 | inet_ntoa(ifaddr), | |
407 | ch_src_str, | |
408 | ch_grp_str, | |
409 | ch->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO ? | |
410 | "NOINFO" : "INCLUDE", | |
411 | VTY_NEWLINE); | |
412 | } /* scan interface channels */ | |
413 | } /* scan interfaces */ | |
414 | ||
415 | } | |
416 | ||
417 | static void igmp_show_interfaces(struct vty *vty) | |
418 | { | |
419 | struct listnode *node; | |
420 | struct interface *ifp; | |
421 | time_t now; | |
422 | ||
423 | now = pim_time_monotonic_sec(); | |
424 | ||
425 | vty_out(vty, | |
426 | "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s", | |
427 | VTY_NEWLINE); | |
428 | ||
469351b3 | 429 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
430 | struct pim_interface *pim_ifp; |
431 | struct listnode *sock_node; | |
432 | struct igmp_sock *igmp; | |
433 | ||
434 | pim_ifp = ifp->info; | |
435 | ||
436 | if (!pim_ifp) | |
437 | continue; | |
438 | ||
439 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
440 | char uptime[10]; | |
441 | int mloop; | |
442 | ||
443 | pim_time_uptime(uptime, sizeof(uptime), now - igmp->sock_creation); | |
444 | ||
445 | mloop = pim_socket_mcastloop_get(igmp->fd); | |
446 | ||
447 | vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s", | |
448 | ifp->name, | |
449 | inet_ntoa(igmp->ifaddr), | |
450 | ifp->ifindex, | |
451 | igmp->fd, | |
452 | uptime, | |
453 | if_is_multicast(ifp) ? "yes" : "no", | |
454 | if_is_broadcast(ifp) ? "yes" : "no", | |
455 | (mloop < 0) ? "?" : (mloop ? "yes" : "no"), | |
456 | (ifp->flags & IFF_ALLMULTI) ? "yes" : "no", | |
457 | (ifp->flags & IFF_PROMISC) ? "yes" : "no", | |
458 | PIM_IF_IS_DELETED(ifp) ? "yes" : "no", | |
459 | VTY_NEWLINE); | |
460 | } | |
461 | } | |
462 | } | |
463 | ||
464 | static void igmp_show_interface_join(struct vty *vty) | |
465 | { | |
466 | struct listnode *node; | |
467 | struct interface *ifp; | |
468 | time_t now; | |
469 | ||
470 | now = pim_time_monotonic_sec(); | |
471 | ||
472 | vty_out(vty, | |
473 | "Interface Address Source Group Socket Uptime %s", | |
474 | VTY_NEWLINE); | |
475 | ||
469351b3 | 476 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
477 | struct pim_interface *pim_ifp; |
478 | struct listnode *join_node; | |
479 | struct igmp_join *ij; | |
480 | struct in_addr pri_addr; | |
481 | char pri_addr_str[100]; | |
482 | ||
483 | pim_ifp = ifp->info; | |
484 | ||
485 | if (!pim_ifp) | |
486 | continue; | |
487 | ||
488 | if (!pim_ifp->igmp_join_list) | |
489 | continue; | |
490 | ||
491 | pri_addr = pim_find_primary_addr(ifp); | |
492 | pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str)); | |
493 | ||
494 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, join_node, ij)) { | |
495 | char group_str[100]; | |
496 | char source_str[100]; | |
497 | char uptime[10]; | |
498 | ||
499 | pim_time_uptime(uptime, sizeof(uptime), now - ij->sock_creation); | |
500 | pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str)); | |
501 | pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str)); | |
502 | ||
503 | vty_out(vty, "%-9s %-15s %-15s %-15s %6d %8s%s", | |
504 | ifp->name, | |
505 | pri_addr_str, | |
506 | source_str, | |
507 | group_str, | |
508 | ij->sock_fd, | |
509 | uptime, | |
510 | VTY_NEWLINE); | |
511 | } /* for (pim_ifp->igmp_join_list) */ | |
512 | ||
513 | } /* for (iflist) */ | |
514 | ||
515 | } | |
516 | ||
517 | static void show_interface_address(struct vty *vty) | |
518 | { | |
519 | struct listnode *ifpnode; | |
520 | struct interface *ifp; | |
521 | ||
522 | vty_out(vty, | |
523 | "Interface Primary Secondary %s", | |
524 | VTY_NEWLINE); | |
525 | ||
469351b3 | 526 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifpnode, ifp)) { |
12e41d03 DL |
527 | struct listnode *ifcnode; |
528 | struct connected *ifc; | |
529 | struct in_addr pri_addr; | |
530 | char pri_addr_str[100]; | |
531 | ||
532 | pri_addr = pim_find_primary_addr(ifp); | |
533 | ||
534 | pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str)); | |
535 | ||
536 | for (ALL_LIST_ELEMENTS_RO(ifp->connected, ifcnode, ifc)) { | |
537 | char sec_addr_str[100]; | |
538 | struct prefix *p = ifc->address; | |
539 | ||
540 | if (p->family != AF_INET) | |
541 | continue; | |
542 | ||
543 | if (p->u.prefix4.s_addr == pri_addr.s_addr) { | |
544 | sec_addr_str[0] = '\0'; | |
545 | } | |
546 | else { | |
547 | pim_inet4_dump("<sec?>", p->u.prefix4, sec_addr_str, sizeof(sec_addr_str)); | |
548 | } | |
549 | ||
550 | vty_out(vty, "%-9s %-15s %-15s%s", | |
551 | ifp->name, | |
552 | pri_addr_str, | |
553 | sec_addr_str, | |
554 | VTY_NEWLINE); | |
555 | } | |
556 | } | |
557 | } | |
558 | ||
559 | static void pim_show_dr(struct vty *vty) | |
560 | { | |
561 | struct listnode *node; | |
562 | struct interface *ifp; | |
563 | time_t now; | |
564 | ||
565 | now = pim_time_monotonic_sec(); | |
566 | ||
567 | vty_out(vty, | |
dedccda6 DS |
568 | "NonPri: Number of neighbors missing DR Priority hello option%s" |
569 | "DrPri: Designated Router Priority sent%s%s", | |
570 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
12e41d03 | 571 | |
dedccda6 | 572 | vty_out(vty, "Interface Address DR Uptime Elections Changes NonPri DrPri%s", VTY_NEWLINE); |
12e41d03 | 573 | |
469351b3 | 574 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
575 | struct pim_interface *pim_ifp; |
576 | struct in_addr ifaddr; | |
577 | char dr_str[100]; | |
578 | char dr_uptime[10]; | |
579 | ||
580 | pim_ifp = ifp->info; | |
581 | ||
582 | if (!pim_ifp) | |
583 | continue; | |
584 | ||
585 | if (pim_ifp->pim_sock_fd < 0) | |
586 | continue; | |
587 | ||
588 | ifaddr = pim_ifp->primary_address; | |
589 | ||
590 | pim_time_uptime_begin(dr_uptime, sizeof(dr_uptime), | |
591 | now, pim_ifp->pim_dr_election_last); | |
592 | ||
593 | pim_inet4_dump("<dr?>", pim_ifp->pim_dr_addr, | |
594 | dr_str, sizeof(dr_str)); | |
595 | ||
dedccda6 | 596 | vty_out(vty, "%-9s %-15s %-15s %8s %9d %7d %6d %10d%s", |
12e41d03 DL |
597 | ifp->name, |
598 | inet_ntoa(ifaddr), | |
599 | dr_str, | |
600 | dr_uptime, | |
601 | pim_ifp->pim_dr_election_count, | |
602 | pim_ifp->pim_dr_election_changes, | |
603 | pim_ifp->pim_dr_num_nondrpri_neighbors, | |
dedccda6 | 604 | pim_ifp->pim_dr_priority, |
12e41d03 DL |
605 | VTY_NEWLINE); |
606 | } | |
607 | } | |
608 | ||
609 | static void pim_show_hello(struct vty *vty) | |
610 | { | |
611 | struct listnode *node; | |
612 | struct interface *ifp; | |
613 | time_t now; | |
614 | ||
615 | now = pim_time_monotonic_sec(); | |
616 | ||
617 | vty_out(vty, "Interface Address Period Timer StatStart Recv Rfail Send Sfail%s", VTY_NEWLINE); | |
618 | ||
469351b3 | 619 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
620 | struct pim_interface *pim_ifp; |
621 | struct in_addr ifaddr; | |
622 | char hello_period[10]; | |
623 | char hello_timer[10]; | |
624 | char stat_uptime[10]; | |
625 | ||
626 | pim_ifp = ifp->info; | |
627 | ||
628 | if (!pim_ifp) | |
629 | continue; | |
630 | ||
631 | if (pim_ifp->pim_sock_fd < 0) | |
632 | continue; | |
633 | ||
634 | ifaddr = pim_ifp->primary_address; | |
635 | ||
636 | pim_time_timer_to_mmss(hello_timer, sizeof(hello_timer), pim_ifp->t_pim_hello_timer); | |
637 | pim_time_mmss(hello_period, sizeof(hello_period), pim_ifp->pim_hello_period); | |
638 | pim_time_uptime(stat_uptime, sizeof(stat_uptime), now - pim_ifp->pim_ifstat_start); | |
639 | ||
640 | vty_out(vty, "%-9s %-15s %6s %5s %9s %4u %5u %4u %5u%s", | |
641 | ifp->name, | |
642 | inet_ntoa(ifaddr), | |
643 | hello_period, | |
644 | hello_timer, | |
645 | stat_uptime, | |
646 | pim_ifp->pim_ifstat_hello_recv, | |
647 | pim_ifp->pim_ifstat_hello_recvfail, | |
648 | pim_ifp->pim_ifstat_hello_sent, | |
649 | pim_ifp->pim_ifstat_hello_sendfail, | |
650 | VTY_NEWLINE); | |
651 | } | |
652 | } | |
653 | ||
654 | static void pim_show_interfaces(struct vty *vty) | |
655 | { | |
656 | struct listnode *node; | |
657 | struct interface *ifp; | |
658 | time_t now; | |
659 | ||
660 | now = pim_time_monotonic_sec(); | |
661 | ||
662 | vty_out(vty, "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s", VTY_NEWLINE); | |
663 | ||
469351b3 | 664 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
665 | struct pim_interface *pim_ifp; |
666 | struct in_addr ifaddr; | |
667 | char uptime[10]; | |
668 | int mloop; | |
669 | ||
670 | pim_ifp = ifp->info; | |
671 | ||
672 | if (!pim_ifp) | |
673 | continue; | |
674 | ||
675 | if (pim_ifp->pim_sock_fd < 0) | |
676 | continue; | |
677 | ||
678 | ifaddr = pim_ifp->primary_address; | |
679 | ||
680 | pim_time_uptime(uptime, sizeof(uptime), now - pim_ifp->pim_sock_creation); | |
681 | ||
682 | mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd); | |
683 | ||
684 | vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s", | |
685 | ifp->name, | |
686 | inet_ntoa(ifaddr), | |
687 | ifp->ifindex, | |
688 | pim_ifp->pim_sock_fd, | |
689 | uptime, | |
690 | if_is_multicast(ifp) ? "yes" : "no", | |
691 | if_is_broadcast(ifp) ? "yes" : "no", | |
692 | (mloop < 0) ? "?" : (mloop ? "yes" : "no"), | |
693 | (ifp->flags & IFF_ALLMULTI) ? "yes" : "no", | |
694 | (ifp->flags & IFF_PROMISC) ? "yes" : "no", | |
695 | PIM_IF_IS_DELETED(ifp) ? "yes" : "no", | |
696 | VTY_NEWLINE); | |
697 | } | |
698 | } | |
699 | ||
700 | static void pim_show_join(struct vty *vty) | |
701 | { | |
702 | struct listnode *ifnode; | |
703 | struct interface *ifp; | |
704 | time_t now; | |
705 | ||
706 | now = pim_time_monotonic_sec(); | |
707 | ||
708 | vty_out(vty, | |
709 | "Interface Address Source Group State Uptime Expire Prune%s", | |
710 | VTY_NEWLINE); | |
711 | ||
469351b3 | 712 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
713 | struct pim_interface *pim_ifp; |
714 | struct in_addr ifaddr; | |
715 | struct listnode *ch_node; | |
716 | struct pim_ifchannel *ch; | |
717 | ||
718 | pim_ifp = ifp->info; | |
719 | ||
720 | if (!pim_ifp) | |
721 | continue; | |
722 | ||
723 | ifaddr = pim_ifp->primary_address; | |
724 | ||
725 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) { | |
726 | char ch_src_str[100]; | |
727 | char ch_grp_str[100]; | |
728 | char uptime[10]; | |
729 | char expire[10]; | |
730 | char prune[10]; | |
731 | ||
732 | pim_inet4_dump("<ch_src?>", ch->source_addr, | |
733 | ch_src_str, sizeof(ch_src_str)); | |
734 | pim_inet4_dump("<ch_grp?>", ch->group_addr, | |
735 | ch_grp_str, sizeof(ch_grp_str)); | |
736 | ||
737 | pim_time_uptime_begin(uptime, sizeof(uptime), now, ch->ifjoin_creation); | |
738 | pim_time_timer_to_mmss(expire, sizeof(expire), | |
739 | ch->t_ifjoin_expiry_timer); | |
740 | pim_time_timer_to_mmss(prune, sizeof(prune), | |
741 | ch->t_ifjoin_prune_pending_timer); | |
742 | ||
743 | vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s%s", | |
744 | ifp->name, | |
745 | inet_ntoa(ifaddr), | |
746 | ch_src_str, | |
747 | ch_grp_str, | |
748 | pim_ifchannel_ifjoin_name(ch->ifjoin_state), | |
749 | uptime, | |
750 | expire, | |
751 | prune, | |
752 | VTY_NEWLINE); | |
753 | } /* scan interface channels */ | |
754 | } /* scan interfaces */ | |
755 | ||
756 | } | |
757 | ||
758 | static void pim_show_neighbors(struct vty *vty) | |
759 | { | |
760 | struct listnode *node; | |
761 | struct interface *ifp; | |
762 | time_t now; | |
763 | ||
764 | now = pim_time_monotonic_sec(); | |
765 | ||
766 | vty_out(vty, | |
767 | "Recv flags: H=holdtime L=lan_prune_delay P=dr_priority G=generation_id A=address_list%s" | |
768 | " T=can_disable_join_suppression%s%s", | |
769 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
770 | ||
771 | vty_out(vty, "Interface Address Neighbor Uptime Timer Holdt DrPri GenId Recv %s", VTY_NEWLINE); | |
772 | ||
469351b3 | 773 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
774 | struct pim_interface *pim_ifp; |
775 | struct in_addr ifaddr; | |
776 | struct listnode *neighnode; | |
777 | struct pim_neighbor *neigh; | |
778 | ||
779 | pim_ifp = ifp->info; | |
780 | ||
781 | if (!pim_ifp) | |
782 | continue; | |
783 | ||
784 | if (pim_ifp->pim_sock_fd < 0) | |
785 | continue; | |
786 | ||
787 | ifaddr = pim_ifp->primary_address; | |
788 | ||
789 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) { | |
790 | char uptime[10]; | |
791 | char holdtime[10]; | |
792 | char expire[10]; | |
793 | char neigh_src_str[100]; | |
794 | char recv[7]; | |
795 | ||
796 | pim_inet4_dump("<src?>", neigh->source_addr, | |
797 | neigh_src_str, sizeof(neigh_src_str)); | |
798 | pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation); | |
799 | pim_time_mmss(holdtime, sizeof(holdtime), neigh->holdtime); | |
800 | pim_time_timer_to_mmss(expire, sizeof(expire), neigh->t_expire_timer); | |
801 | ||
802 | recv[0] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_HOLDTIME) ? 'H' : ' '; | |
803 | recv[1] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? 'L' : ' '; | |
804 | recv[2] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_DR_PRIORITY) ? 'P' : ' '; | |
805 | recv[3] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_GENERATION_ID) ? 'G' : ' '; | |
806 | recv[4] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_ADDRESS_LIST) ? 'A' : ' '; | |
807 | recv[5] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION) ? 'T' : ' '; | |
808 | recv[6] = '\0'; | |
809 | ||
810 | vty_out(vty, "%-9s %-15s %-15s %8s %5s %5s %5u %08x %6s%s", | |
811 | ifp->name, | |
812 | inet_ntoa(ifaddr), | |
813 | neigh_src_str, | |
814 | uptime, | |
815 | expire, | |
816 | holdtime, | |
817 | neigh->dr_priority, | |
818 | neigh->generation_id, | |
819 | recv, | |
820 | VTY_NEWLINE); | |
821 | } | |
822 | ||
823 | ||
824 | } | |
825 | } | |
826 | ||
827 | static void pim_show_lan_prune_delay(struct vty *vty) | |
828 | { | |
829 | struct listnode *node; | |
830 | struct interface *ifp; | |
831 | ||
832 | vty_out(vty, | |
833 | "PrDly=propagation_delay (msec) OvInt=override_interval (msec)%s" | |
834 | "HiDly=highest_propagation_delay (msec) HiInt=highest_override_interval (msec)%s" | |
835 | "NoDly=number_of_non_lan_delay_neighbors%s" | |
836 | "T=t_bit LPD=lan_prune_delay_hello_option%s%s", | |
837 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
838 | ||
839 | vty_out(vty, "Interface Address PrDly OvInt NoDly HiDly HiInt T | Neighbor LPD PrDly OvInt T%s", VTY_NEWLINE); | |
840 | ||
469351b3 | 841 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
842 | struct pim_interface *pim_ifp; |
843 | struct in_addr ifaddr; | |
844 | struct listnode *neighnode; | |
845 | struct pim_neighbor *neigh; | |
846 | ||
847 | pim_ifp = ifp->info; | |
848 | ||
849 | if (!pim_ifp) | |
850 | continue; | |
851 | ||
852 | if (pim_ifp->pim_sock_fd < 0) | |
853 | continue; | |
854 | ||
855 | ifaddr = pim_ifp->primary_address; | |
856 | ||
857 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) { | |
858 | char neigh_src_str[100]; | |
859 | ||
860 | pim_inet4_dump("<src?>", neigh->source_addr, | |
861 | neigh_src_str, sizeof(neigh_src_str)); | |
862 | ||
863 | vty_out(vty, "%-9s %-15s %5u %5u %5u %5u %5u %1u | %-15s %-3s %5u %5u %1u%s", | |
864 | ifp->name, | |
865 | inet_ntoa(ifaddr), | |
866 | pim_ifp->pim_propagation_delay_msec, | |
867 | pim_ifp->pim_override_interval_msec, | |
868 | pim_ifp->pim_number_of_nonlandelay_neighbors, | |
869 | pim_ifp->pim_neighbors_highest_propagation_delay_msec, | |
870 | pim_ifp->pim_neighbors_highest_override_interval_msec, | |
871 | PIM_FORCE_BOOLEAN(PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(pim_ifp->options)), | |
872 | neigh_src_str, | |
873 | PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? "yes" : "no", | |
874 | neigh->propagation_delay_msec, | |
875 | neigh->override_interval_msec, | |
876 | PIM_FORCE_BOOLEAN(PIM_OPTION_IS_SET(neigh->hello_options, | |
877 | PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION)), | |
878 | VTY_NEWLINE); | |
879 | } | |
880 | ||
881 | } | |
882 | } | |
883 | ||
884 | static void pim_show_jp_override_interval(struct vty *vty) | |
885 | { | |
886 | struct listnode *node; | |
887 | struct interface *ifp; | |
888 | ||
889 | vty_out(vty, | |
890 | "EffPDelay=effective_propagation_delay (msec)%s" | |
891 | "EffOvrInt=override_interval (msec)%s" | |
892 | "JPOvrInt=jp_override_interval (msec)%s%s", | |
893 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
894 | ||
895 | vty_out(vty, "Interface Address LAN_Delay EffPDelay EffOvrInt JPOvrInt%s", VTY_NEWLINE); | |
896 | ||
469351b3 | 897 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
898 | struct pim_interface *pim_ifp; |
899 | struct in_addr ifaddr; | |
900 | ||
901 | pim_ifp = ifp->info; | |
902 | ||
903 | if (!pim_ifp) | |
904 | continue; | |
905 | ||
906 | if (pim_ifp->pim_sock_fd < 0) | |
907 | continue; | |
908 | ||
909 | ifaddr = pim_ifp->primary_address; | |
910 | ||
911 | vty_out(vty, "%-9s %-15s %-9s %9u %9u %8u%s", | |
912 | ifp->name, | |
913 | inet_ntoa(ifaddr), | |
914 | pim_if_lan_delay_enabled(ifp) ? "enabled" : "disabled", | |
915 | pim_if_effective_propagation_delay_msec(ifp), | |
916 | pim_if_effective_override_interval_msec(ifp), | |
917 | pim_if_jp_override_interval_msec(ifp), | |
918 | VTY_NEWLINE); | |
919 | } | |
920 | } | |
921 | ||
922 | static void pim_show_neighbors_secondary(struct vty *vty) | |
923 | { | |
924 | struct listnode *node; | |
925 | struct interface *ifp; | |
926 | ||
927 | vty_out(vty, "Interface Address Neighbor Secondary %s", VTY_NEWLINE); | |
928 | ||
469351b3 | 929 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
930 | struct pim_interface *pim_ifp; |
931 | struct in_addr ifaddr; | |
932 | struct listnode *neighnode; | |
933 | struct pim_neighbor *neigh; | |
934 | ||
935 | pim_ifp = ifp->info; | |
936 | ||
937 | if (!pim_ifp) | |
938 | continue; | |
939 | ||
940 | if (pim_ifp->pim_sock_fd < 0) | |
941 | continue; | |
942 | ||
943 | ifaddr = pim_ifp->primary_address; | |
944 | ||
945 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) { | |
946 | char neigh_src_str[100]; | |
947 | struct listnode *prefix_node; | |
948 | struct prefix *p; | |
949 | ||
950 | if (!neigh->prefix_list) | |
951 | continue; | |
952 | ||
953 | pim_inet4_dump("<src?>", neigh->source_addr, | |
954 | neigh_src_str, sizeof(neigh_src_str)); | |
955 | ||
956 | for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) { | |
957 | char neigh_sec_str[100]; | |
958 | ||
959 | if (p->family != AF_INET) | |
960 | continue; | |
961 | ||
962 | pim_inet4_dump("<src?>", p->u.prefix4, | |
963 | neigh_sec_str, sizeof(neigh_sec_str)); | |
964 | ||
965 | vty_out(vty, "%-9s %-15s %-15s %-15s%s", | |
966 | ifp->name, | |
967 | inet_ntoa(ifaddr), | |
968 | neigh_src_str, | |
969 | neigh_sec_str, | |
970 | VTY_NEWLINE); | |
971 | } | |
972 | } | |
973 | } | |
974 | } | |
975 | ||
976 | static void pim_show_upstream(struct vty *vty) | |
977 | { | |
978 | struct listnode *upnode; | |
979 | struct pim_upstream *up; | |
980 | time_t now; | |
981 | ||
982 | now = pim_time_monotonic_sec(); | |
983 | ||
2e948c78 | 984 | vty_out(vty, "Iif Source Group State Uptime JoinTimer RefCnt%s", VTY_NEWLINE); |
12e41d03 DL |
985 | |
986 | for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) { | |
987 | char src_str[100]; | |
988 | char grp_str[100]; | |
989 | char uptime[10]; | |
990 | char join_timer[10]; | |
991 | ||
992 | pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str)); | |
993 | pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str)); | |
994 | pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition); | |
995 | pim_time_timer_to_hhmmss(join_timer, sizeof(join_timer), up->t_join_timer); | |
996 | ||
2e948c78 DS |
997 | vty_out(vty, "%-10s%-15s %-15s %-5s %-8s %-9s %6d%s", |
998 | up->rpf.source_nexthop.interface->name, | |
12e41d03 DL |
999 | src_str, |
1000 | grp_str, | |
1001 | up->join_state == PIM_UPSTREAM_JOINED ? "Jnd" : "NtJnd", | |
1002 | uptime, | |
1003 | join_timer, | |
1004 | up->ref_count, | |
1005 | VTY_NEWLINE); | |
1006 | } | |
1007 | } | |
1008 | ||
1009 | static void pim_show_join_desired(struct vty *vty) | |
1010 | { | |
1011 | struct listnode *ifnode; | |
1012 | struct listnode *chnode; | |
1013 | struct interface *ifp; | |
1014 | struct pim_interface *pim_ifp; | |
1015 | struct pim_ifchannel *ch; | |
1016 | char src_str[100]; | |
1017 | char grp_str[100]; | |
1018 | ||
1019 | vty_out(vty, | |
1020 | "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD%s", | |
1021 | VTY_NEWLINE); | |
1022 | ||
1023 | /* scan all interfaces */ | |
469351b3 | 1024 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
1025 | pim_ifp = ifp->info; |
1026 | if (!pim_ifp) | |
1027 | continue; | |
1028 | ||
1029 | /* scan per-interface (S,G) state */ | |
1030 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, chnode, ch)) { | |
1031 | struct pim_upstream *up = ch->upstream; | |
1032 | ||
1033 | pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str)); | |
1034 | pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str)); | |
1035 | ||
1036 | vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s%s", | |
1037 | ifp->name, | |
1038 | src_str, | |
1039 | grp_str, | |
1040 | pim_macro_ch_lost_assert(ch) ? "yes" : "no", | |
1041 | pim_macro_chisin_joins(ch) ? "yes" : "no", | |
1042 | pim_macro_chisin_pim_include(ch) ? "yes" : "no", | |
1043 | PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) ? "yes" : "no", | |
1044 | pim_upstream_evaluate_join_desired(up) ? "yes" : "no", | |
1045 | VTY_NEWLINE); | |
1046 | } | |
1047 | } | |
1048 | } | |
1049 | ||
1050 | static void pim_show_upstream_rpf(struct vty *vty) | |
1051 | { | |
1052 | struct listnode *upnode; | |
1053 | struct pim_upstream *up; | |
1054 | ||
1055 | vty_out(vty, | |
1056 | "Source Group RpfIface RibNextHop RpfAddress %s", | |
1057 | VTY_NEWLINE); | |
1058 | ||
1059 | for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) { | |
1060 | char src_str[100]; | |
1061 | char grp_str[100]; | |
1062 | char rpf_nexthop_str[100]; | |
1063 | char rpf_addr_str[100]; | |
1064 | struct pim_rpf *rpf; | |
1065 | const char *rpf_ifname; | |
1066 | ||
1067 | rpf = &up->rpf; | |
1068 | ||
1069 | pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str)); | |
1070 | pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str)); | |
1071 | pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rpf_nexthop_str, sizeof(rpf_nexthop_str)); | |
1072 | pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str)); | |
1073 | ||
1074 | rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>"; | |
1075 | ||
1076 | vty_out(vty, "%-15s %-15s %-8s %-15s %-15s%s", | |
1077 | src_str, | |
1078 | grp_str, | |
1079 | rpf_ifname, | |
1080 | rpf_nexthop_str, | |
1081 | rpf_addr_str, | |
1082 | VTY_NEWLINE); | |
1083 | } | |
1084 | } | |
1085 | ||
1086 | static void show_rpf_refresh_stats(struct vty *vty, time_t now) | |
1087 | { | |
1088 | char refresh_uptime[10]; | |
1089 | ||
1090 | pim_time_uptime_begin(refresh_uptime, sizeof(refresh_uptime), now, qpim_rpf_cache_refresh_last); | |
1091 | ||
1092 | vty_out(vty, | |
1093 | "RPF Cache Refresh Delay: %ld msecs%s" | |
1094 | "RPF Cache Refresh Timer: %ld msecs%s" | |
1095 | "RPF Cache Refresh Requests: %lld%s" | |
1096 | "RPF Cache Refresh Events: %lld%s" | |
1097 | "RPF Cache Refresh Last: %s%s", | |
1098 | qpim_rpf_cache_refresh_delay_msec, VTY_NEWLINE, | |
1099 | pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTY_NEWLINE, | |
1100 | (long long)qpim_rpf_cache_refresh_requests, VTY_NEWLINE, | |
1101 | (long long)qpim_rpf_cache_refresh_events, VTY_NEWLINE, | |
1102 | refresh_uptime, VTY_NEWLINE); | |
1103 | } | |
1104 | ||
1105 | static void show_scan_oil_stats(struct vty *vty, time_t now) | |
1106 | { | |
1107 | char uptime_scan_oil[10]; | |
1108 | char uptime_mroute_add[10]; | |
1109 | char uptime_mroute_del[10]; | |
1110 | ||
1111 | pim_time_uptime_begin(uptime_scan_oil, sizeof(uptime_scan_oil), now, qpim_scan_oil_last); | |
1112 | pim_time_uptime_begin(uptime_mroute_add, sizeof(uptime_mroute_add), now, qpim_mroute_add_last); | |
1113 | pim_time_uptime_begin(uptime_mroute_del, sizeof(uptime_mroute_del), now, qpim_mroute_del_last); | |
1114 | ||
1115 | vty_out(vty, | |
1116 | "Scan OIL - Last: %s Events: %lld%s" | |
1117 | "MFC Add - Last: %s Events: %lld%s" | |
1118 | "MFC Del - Last: %s Events: %lld%s", | |
1119 | uptime_scan_oil, (long long) qpim_scan_oil_events, VTY_NEWLINE, | |
1120 | uptime_mroute_add, (long long) qpim_mroute_add_events, VTY_NEWLINE, | |
1121 | uptime_mroute_del, (long long) qpim_mroute_del_events, VTY_NEWLINE); | |
1122 | } | |
1123 | ||
1124 | static void pim_show_rpf(struct vty *vty) | |
1125 | { | |
1126 | struct listnode *up_node; | |
1127 | struct pim_upstream *up; | |
1128 | time_t now = pim_time_monotonic_sec(); | |
1129 | ||
1130 | show_rpf_refresh_stats(vty, now); | |
1131 | ||
1132 | vty_out(vty, "%s", VTY_NEWLINE); | |
1133 | ||
1134 | vty_out(vty, | |
1135 | "Source Group RpfIface RpfAddress RibNextHop Metric Pref%s", | |
1136 | VTY_NEWLINE); | |
1137 | ||
1138 | for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, up_node, up)) { | |
1139 | char src_str[100]; | |
1140 | char grp_str[100]; | |
1141 | char rpf_addr_str[100]; | |
1142 | char rib_nexthop_str[100]; | |
1143 | const char *rpf_ifname; | |
1144 | struct pim_rpf *rpf = &up->rpf; | |
1145 | ||
1146 | pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str)); | |
1147 | pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str)); | |
1148 | pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str)); | |
1149 | pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rib_nexthop_str, sizeof(rib_nexthop_str)); | |
1150 | ||
1151 | rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>"; | |
1152 | ||
1153 | vty_out(vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d%s", | |
1154 | src_str, | |
1155 | grp_str, | |
1156 | rpf_ifname, | |
1157 | rpf_addr_str, | |
1158 | rib_nexthop_str, | |
1159 | rpf->source_nexthop.mrib_route_metric, | |
1160 | rpf->source_nexthop.mrib_metric_preference, | |
1161 | VTY_NEWLINE); | |
1162 | } | |
1163 | } | |
1164 | ||
1165 | static void igmp_show_querier(struct vty *vty) | |
1166 | { | |
1167 | struct listnode *node; | |
1168 | struct interface *ifp; | |
1169 | ||
1170 | vty_out(vty, "Interface Address Querier StartCount Query-Timer Other-Timer%s", VTY_NEWLINE); | |
1171 | ||
469351b3 | 1172 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
1173 | struct pim_interface *pim_ifp = ifp->info; |
1174 | struct listnode *sock_node; | |
1175 | struct igmp_sock *igmp; | |
1176 | ||
1177 | if (!pim_ifp) | |
1178 | continue; | |
1179 | ||
1180 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
1181 | char query_hhmmss[10]; | |
1182 | char other_hhmmss[10]; | |
1183 | ||
1184 | pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer); | |
1185 | pim_time_timer_to_hhmmss(other_hhmmss, sizeof(other_hhmmss), igmp->t_other_querier_timer); | |
1186 | ||
1187 | vty_out(vty, "%-9s %-15s %-7s %10d %11s %11s%s", | |
1188 | ifp->name, | |
1189 | inet_ntoa(igmp->ifaddr), | |
1190 | igmp->t_igmp_query_timer ? "THIS" : "OTHER", | |
1191 | igmp->startup_query_count, | |
1192 | query_hhmmss, | |
1193 | other_hhmmss, | |
1194 | VTY_NEWLINE); | |
1195 | } | |
1196 | } | |
1197 | } | |
1198 | ||
1199 | static void igmp_show_groups(struct vty *vty) | |
1200 | { | |
1201 | struct listnode *ifnode; | |
1202 | struct interface *ifp; | |
1203 | time_t now; | |
1204 | ||
1205 | now = pim_time_monotonic_sec(); | |
1206 | ||
1207 | vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE); | |
1208 | ||
1209 | /* scan interfaces */ | |
469351b3 | 1210 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
1211 | struct pim_interface *pim_ifp = ifp->info; |
1212 | struct listnode *sock_node; | |
1213 | struct igmp_sock *igmp; | |
1214 | ||
1215 | if (!pim_ifp) | |
1216 | continue; | |
1217 | ||
1218 | /* scan igmp sockets */ | |
1219 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
1220 | char ifaddr_str[100]; | |
1221 | struct listnode *grpnode; | |
1222 | struct igmp_group *grp; | |
1223 | ||
1224 | pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str)); | |
1225 | ||
1226 | /* scan igmp groups */ | |
1227 | for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) { | |
1228 | char group_str[100]; | |
1229 | char hhmmss[10]; | |
1230 | char uptime[10]; | |
1231 | ||
1232 | pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str)); | |
1233 | pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer); | |
1234 | pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation); | |
1235 | ||
1236 | vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s", | |
1237 | ifp->name, | |
1238 | ifaddr_str, | |
1239 | group_str, | |
1240 | grp->group_filtermode_isexcl ? "EXCL" : "INCL", | |
1241 | hhmmss, | |
1242 | grp->group_source_list ? listcount(grp->group_source_list) : 0, | |
1243 | igmp_group_compat_mode(igmp, grp), | |
1244 | uptime, | |
1245 | VTY_NEWLINE); | |
1246 | ||
1247 | } /* scan igmp groups */ | |
1248 | } /* scan igmp sockets */ | |
1249 | } /* scan interfaces */ | |
1250 | } | |
1251 | ||
1252 | static void igmp_show_group_retransmission(struct vty *vty) | |
1253 | { | |
1254 | struct listnode *ifnode; | |
1255 | struct interface *ifp; | |
1256 | ||
1257 | vty_out(vty, "Interface Address Group RetTimer Counter RetSrcs%s", VTY_NEWLINE); | |
1258 | ||
1259 | /* scan interfaces */ | |
469351b3 | 1260 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
1261 | struct pim_interface *pim_ifp = ifp->info; |
1262 | struct listnode *sock_node; | |
1263 | struct igmp_sock *igmp; | |
1264 | ||
1265 | if (!pim_ifp) | |
1266 | continue; | |
1267 | ||
1268 | /* scan igmp sockets */ | |
1269 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
1270 | char ifaddr_str[100]; | |
1271 | struct listnode *grpnode; | |
1272 | struct igmp_group *grp; | |
1273 | ||
1274 | pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str)); | |
1275 | ||
1276 | /* scan igmp groups */ | |
1277 | for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) { | |
1278 | char group_str[100]; | |
1279 | char grp_retr_mmss[10]; | |
1280 | struct listnode *src_node; | |
1281 | struct igmp_source *src; | |
1282 | int grp_retr_sources = 0; | |
1283 | ||
1284 | pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str)); | |
1285 | pim_time_timer_to_mmss(grp_retr_mmss, sizeof(grp_retr_mmss), grp->t_group_query_retransmit_timer); | |
1286 | ||
1287 | ||
1288 | /* count group sources with retransmission state */ | |
1289 | for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) { | |
1290 | if (src->source_query_retransmit_count > 0) { | |
1291 | ++grp_retr_sources; | |
1292 | } | |
1293 | } | |
1294 | ||
1295 | vty_out(vty, "%-9s %-15s %-15s %-8s %7d %7d%s", | |
1296 | ifp->name, | |
1297 | ifaddr_str, | |
1298 | group_str, | |
1299 | grp_retr_mmss, | |
1300 | grp->group_specific_query_retransmit_count, | |
1301 | grp_retr_sources, | |
1302 | VTY_NEWLINE); | |
1303 | ||
1304 | } /* scan igmp groups */ | |
1305 | } /* scan igmp sockets */ | |
1306 | } /* scan interfaces */ | |
1307 | } | |
1308 | ||
1309 | static void igmp_show_parameters(struct vty *vty) | |
1310 | { | |
1311 | struct listnode *ifnode; | |
1312 | struct interface *ifp; | |
1313 | ||
1314 | vty_out(vty, | |
1315 | "QRV: Robustness Variable SQI: Startup Query Interval%s" | |
1316 | "QQI: Query Interval OQPI: Other Querier Present Interval%s" | |
1317 | "QRI: Query Response Interval LMQT: Last Member Query Time%s" | |
1318 | "GMI: Group Membership Interval OHPI: Older Host Present Interval%s%s", | |
1319 | VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE); | |
1320 | ||
1321 | vty_out(vty, | |
1322 | "Interface Address QRV QQI QRI GMI SQI OQPI LMQT OHPI %s", | |
1323 | VTY_NEWLINE); | |
1324 | ||
1325 | /* scan interfaces */ | |
469351b3 | 1326 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
1327 | struct pim_interface *pim_ifp = ifp->info; |
1328 | struct listnode *sock_node; | |
1329 | struct igmp_sock *igmp; | |
1330 | ||
1331 | if (!pim_ifp) | |
1332 | continue; | |
1333 | ||
1334 | /* scan igmp sockets */ | |
1335 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
1336 | char ifaddr_str[100]; | |
1337 | long gmi_dsec; /* Group Membership Interval */ | |
1338 | long oqpi_dsec; /* Other Querier Present Interval */ | |
1339 | int sqi; | |
1340 | long lmqt_dsec; | |
1341 | long ohpi_dsec; | |
1342 | long qri_dsec; | |
1343 | ||
1344 | pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str)); | |
1345 | ||
1346 | gmi_dsec = PIM_IGMP_GMI_MSEC(igmp->querier_robustness_variable, | |
1347 | igmp->querier_query_interval, | |
1348 | pim_ifp->igmp_query_max_response_time_dsec) / 100; | |
1349 | ||
1350 | sqi = PIM_IGMP_SQI(pim_ifp->igmp_default_query_interval); | |
1351 | ||
1352 | oqpi_dsec = PIM_IGMP_OQPI_MSEC(igmp->querier_robustness_variable, | |
1353 | igmp->querier_query_interval, | |
1354 | pim_ifp->igmp_query_max_response_time_dsec) / 100; | |
1355 | ||
1356 | lmqt_dsec = PIM_IGMP_LMQT_MSEC(pim_ifp->igmp_query_max_response_time_dsec, | |
1357 | igmp->querier_robustness_variable) / 100; | |
1358 | ||
1359 | ohpi_dsec = PIM_IGMP_OHPI_DSEC(igmp->querier_robustness_variable, | |
1360 | igmp->querier_query_interval, | |
1361 | pim_ifp->igmp_query_max_response_time_dsec); | |
1362 | ||
1363 | qri_dsec = pim_ifp->igmp_query_max_response_time_dsec; | |
1364 | ||
1365 | vty_out(vty, | |
1366 | "%-9s %-15s %3d %3d %3ld.%ld %3ld.%ld %3d %3ld.%ld %3ld.%ld %3ld.%ld%s", | |
1367 | ifp->name, | |
1368 | ifaddr_str, | |
1369 | igmp->querier_robustness_variable, | |
1370 | igmp->querier_query_interval, | |
1371 | qri_dsec / 10, qri_dsec % 10, | |
1372 | gmi_dsec / 10, gmi_dsec % 10, | |
1373 | sqi, | |
1374 | oqpi_dsec / 10, oqpi_dsec % 10, | |
1375 | lmqt_dsec / 10, lmqt_dsec % 10, | |
1376 | ohpi_dsec / 10, ohpi_dsec % 10, | |
1377 | VTY_NEWLINE); | |
1378 | ||
1379 | } /* scan igmp sockets */ | |
1380 | } /* scan interfaces */ | |
1381 | } | |
1382 | ||
1383 | static void igmp_show_sources(struct vty *vty) | |
1384 | { | |
1385 | struct listnode *ifnode; | |
1386 | struct interface *ifp; | |
1387 | time_t now; | |
1388 | ||
1389 | now = pim_time_monotonic_sec(); | |
1390 | ||
1391 | vty_out(vty, "Interface Address Group Source Timer Fwd Uptime %s", VTY_NEWLINE); | |
1392 | ||
1393 | /* scan interfaces */ | |
469351b3 | 1394 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
1395 | struct pim_interface *pim_ifp = ifp->info; |
1396 | struct listnode *sock_node; | |
1397 | struct igmp_sock *igmp; | |
1398 | ||
1399 | if (!pim_ifp) | |
1400 | continue; | |
1401 | ||
1402 | /* scan igmp sockets */ | |
1403 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
1404 | char ifaddr_str[100]; | |
1405 | struct listnode *grpnode; | |
1406 | struct igmp_group *grp; | |
1407 | ||
1408 | pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str)); | |
1409 | ||
1410 | /* scan igmp groups */ | |
1411 | for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) { | |
1412 | char group_str[100]; | |
1413 | struct listnode *srcnode; | |
1414 | struct igmp_source *src; | |
1415 | ||
1416 | pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str)); | |
1417 | ||
1418 | /* scan group sources */ | |
1419 | for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) { | |
1420 | char source_str[100]; | |
1421 | char mmss[10]; | |
1422 | char uptime[10]; | |
1423 | ||
1424 | pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str)); | |
1425 | ||
1426 | pim_time_timer_to_mmss(mmss, sizeof(mmss), src->t_source_timer); | |
1427 | ||
1428 | pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation); | |
1429 | ||
1430 | vty_out(vty, "%-9s %-15s %-15s %-15s %5s %3s %8s%s", | |
1431 | ifp->name, | |
1432 | ifaddr_str, | |
1433 | group_str, | |
1434 | source_str, | |
1435 | mmss, | |
1436 | IGMP_SOURCE_TEST_FORWARDING(src->source_flags) ? "Y" : "N", | |
1437 | uptime, | |
1438 | VTY_NEWLINE); | |
1439 | ||
1440 | } /* scan group sources */ | |
1441 | } /* scan igmp groups */ | |
1442 | } /* scan igmp sockets */ | |
1443 | } /* scan interfaces */ | |
1444 | } | |
1445 | ||
1446 | static void igmp_show_source_retransmission(struct vty *vty) | |
1447 | { | |
1448 | struct listnode *ifnode; | |
1449 | struct interface *ifp; | |
1450 | ||
1451 | vty_out(vty, "Interface Address Group Source Counter%s", VTY_NEWLINE); | |
1452 | ||
1453 | /* scan interfaces */ | |
469351b3 | 1454 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
1455 | struct pim_interface *pim_ifp = ifp->info; |
1456 | struct listnode *sock_node; | |
1457 | struct igmp_sock *igmp; | |
1458 | ||
1459 | if (!pim_ifp) | |
1460 | continue; | |
1461 | ||
1462 | /* scan igmp sockets */ | |
1463 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
1464 | char ifaddr_str[100]; | |
1465 | struct listnode *grpnode; | |
1466 | struct igmp_group *grp; | |
1467 | ||
1468 | pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str)); | |
1469 | ||
1470 | /* scan igmp groups */ | |
1471 | for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) { | |
1472 | char group_str[100]; | |
1473 | struct listnode *srcnode; | |
1474 | struct igmp_source *src; | |
1475 | ||
1476 | pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str)); | |
1477 | ||
1478 | /* scan group sources */ | |
1479 | for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) { | |
1480 | char source_str[100]; | |
1481 | ||
1482 | pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str)); | |
1483 | ||
1484 | vty_out(vty, "%-9s %-15s %-15s %-15s %7d%s", | |
1485 | ifp->name, | |
1486 | ifaddr_str, | |
1487 | group_str, | |
1488 | source_str, | |
1489 | src->source_query_retransmit_count, | |
1490 | VTY_NEWLINE); | |
1491 | ||
1492 | } /* scan group sources */ | |
1493 | } /* scan igmp groups */ | |
1494 | } /* scan igmp sockets */ | |
1495 | } /* scan interfaces */ | |
1496 | } | |
1497 | ||
1498 | static void clear_igmp_interfaces() | |
1499 | { | |
1500 | struct listnode *ifnode; | |
1501 | struct listnode *ifnextnode; | |
1502 | struct interface *ifp; | |
1503 | ||
469351b3 | 1504 | for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) { |
12e41d03 DL |
1505 | pim_if_addr_del_all_igmp(ifp); |
1506 | } | |
1507 | ||
469351b3 | 1508 | for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) { |
12e41d03 DL |
1509 | pim_if_addr_add_all(ifp); |
1510 | } | |
1511 | } | |
1512 | ||
1513 | static void clear_pim_interfaces() | |
1514 | { | |
1515 | struct listnode *ifnode; | |
1516 | struct listnode *ifnextnode; | |
1517 | struct interface *ifp; | |
1518 | ||
469351b3 | 1519 | for (ALL_LIST_ELEMENTS (vrf_iflist (VRF_DEFAULT), ifnode, ifnextnode, ifp)) { |
12e41d03 DL |
1520 | if (ifp->info) { |
1521 | pim_neighbor_delete_all(ifp, "interface cleared"); | |
1522 | } | |
1523 | } | |
1524 | } | |
1525 | ||
1526 | static void clear_interfaces() | |
1527 | { | |
1528 | clear_igmp_interfaces(); | |
1529 | clear_pim_interfaces(); | |
1530 | } | |
1531 | ||
1532 | DEFUN (pim_interface, | |
1533 | pim_interface_cmd, | |
1534 | "interface IFNAME", | |
1535 | "Select an interface to configure\n" | |
1536 | "Interface's name\n") | |
1537 | { | |
1538 | struct interface *ifp; | |
1539 | const char *ifname = argv[0]; | |
1540 | size_t sl; | |
1541 | ||
1542 | sl = strlen(ifname); | |
1543 | if (sl > INTERFACE_NAMSIZ) { | |
1544 | vty_out(vty, "%% Interface name %s is invalid: length exceeds " | |
1545 | "%d characters%s", | |
1546 | ifname, INTERFACE_NAMSIZ, VTY_NEWLINE); | |
1547 | return CMD_WARNING; | |
1548 | } | |
1549 | ||
1550 | ifp = if_lookup_by_name_len(ifname, sl); | |
1551 | if (!ifp) { | |
1552 | vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE); | |
1553 | ||
1554 | /* Returning here would prevent pimd from booting when there are | |
1555 | interface commands in pimd.conf, since all interfaces are | |
1556 | unknown at pimd boot time (the zebra daemon has not been | |
1557 | contacted for interface discovery). */ | |
1558 | ||
1559 | ifp = if_get_by_name_len(ifname, sl); | |
1560 | if (!ifp) { | |
1561 | vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE); | |
1562 | return CMD_WARNING; | |
1563 | } | |
1564 | } | |
1565 | ||
1566 | vty->index = ifp; | |
1567 | vty->node = INTERFACE_NODE; | |
1568 | ||
1569 | return CMD_SUCCESS; | |
1570 | } | |
1571 | ||
1572 | DEFUN (clear_ip_interfaces, | |
1573 | clear_ip_interfaces_cmd, | |
1574 | "clear ip interfaces", | |
1575 | CLEAR_STR | |
1576 | IP_STR | |
1577 | "Reset interfaces\n") | |
1578 | { | |
1579 | clear_interfaces(); | |
1580 | ||
1581 | return CMD_SUCCESS; | |
1582 | } | |
1583 | ||
1584 | DEFUN (clear_ip_igmp_interfaces, | |
1585 | clear_ip_igmp_interfaces_cmd, | |
1586 | "clear ip igmp interfaces", | |
1587 | CLEAR_STR | |
1588 | IP_STR | |
1589 | CLEAR_IP_IGMP_STR | |
1590 | "Reset IGMP interfaces\n") | |
1591 | { | |
1592 | clear_igmp_interfaces(); | |
1593 | ||
1594 | return CMD_SUCCESS; | |
1595 | } | |
1596 | ||
1597 | static void mroute_add_all() | |
1598 | { | |
1599 | struct listnode *node; | |
1600 | struct channel_oil *c_oil; | |
1601 | ||
1602 | for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) { | |
c171d6d8 | 1603 | if (pim_mroute_add(c_oil)) { |
12e41d03 DL |
1604 | /* just log warning */ |
1605 | char source_str[100]; | |
1606 | char group_str[100]; | |
1607 | pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str)); | |
1608 | pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str)); | |
1609 | zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC", | |
1610 | __FILE__, __PRETTY_FUNCTION__, | |
1611 | source_str, group_str); | |
1612 | } | |
1613 | } | |
1614 | } | |
1615 | ||
1616 | static void mroute_del_all() | |
1617 | { | |
1618 | struct listnode *node; | |
1619 | struct channel_oil *c_oil; | |
1620 | ||
1621 | for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) { | |
c171d6d8 | 1622 | if (pim_mroute_del(c_oil)) { |
12e41d03 DL |
1623 | /* just log warning */ |
1624 | char source_str[100]; | |
1625 | char group_str[100]; | |
1626 | pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str)); | |
1627 | pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str)); | |
1628 | zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC", | |
1629 | __FILE__, __PRETTY_FUNCTION__, | |
1630 | source_str, group_str); | |
1631 | } | |
1632 | } | |
1633 | } | |
1634 | ||
6250610a JAG |
1635 | static void static_mroute_add_all() |
1636 | { | |
1637 | struct listnode *node; | |
1638 | struct static_route *s_route; | |
1639 | ||
1640 | for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) { | |
c171d6d8 | 1641 | if (pim_mroute_add(&s_route->c_oil)) { |
6250610a JAG |
1642 | /* just log warning */ |
1643 | char source_str[100]; | |
1644 | char group_str[100]; | |
9867746a DS |
1645 | pim_inet4_dump("<source?>", s_route->c_oil.oil.mfcc_origin, source_str, sizeof(source_str)); |
1646 | pim_inet4_dump("<group?>", s_route->c_oil.oil.mfcc_mcastgrp, group_str, sizeof(group_str)); | |
6250610a JAG |
1647 | zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC", |
1648 | __FILE__, __PRETTY_FUNCTION__, | |
1649 | source_str, group_str); | |
1650 | } | |
1651 | } | |
1652 | } | |
1653 | ||
1654 | static void static_mroute_del_all() | |
1655 | { | |
1656 | struct listnode *node; | |
1657 | struct static_route *s_route; | |
1658 | ||
1659 | for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) { | |
c171d6d8 | 1660 | if (pim_mroute_del(&s_route->c_oil)) { |
6250610a JAG |
1661 | /* just log warning */ |
1662 | char source_str[100]; | |
1663 | char group_str[100]; | |
9867746a DS |
1664 | pim_inet4_dump("<source?>", s_route->c_oil.oil.mfcc_origin, source_str, sizeof(source_str)); |
1665 | pim_inet4_dump("<group?>", s_route->c_oil.oil.mfcc_mcastgrp, group_str, sizeof(group_str)); | |
6250610a JAG |
1666 | zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC", |
1667 | __FILE__, __PRETTY_FUNCTION__, | |
1668 | source_str, group_str); | |
1669 | } | |
1670 | } | |
1671 | } | |
1672 | ||
12e41d03 DL |
1673 | DEFUN (clear_ip_mroute, |
1674 | clear_ip_mroute_cmd, | |
1675 | "clear ip mroute", | |
1676 | CLEAR_STR | |
1677 | IP_STR | |
1678 | "Reset multicast routes\n") | |
1679 | { | |
1680 | mroute_del_all(); | |
1681 | mroute_add_all(); | |
1682 | ||
1683 | return CMD_SUCCESS; | |
1684 | } | |
1685 | ||
1686 | DEFUN (clear_ip_pim_interfaces, | |
1687 | clear_ip_pim_interfaces_cmd, | |
1688 | "clear ip pim interfaces", | |
1689 | CLEAR_STR | |
1690 | IP_STR | |
1691 | CLEAR_IP_PIM_STR | |
1692 | "Reset PIM interfaces\n") | |
1693 | { | |
1694 | clear_pim_interfaces(); | |
1695 | ||
1696 | return CMD_SUCCESS; | |
1697 | } | |
1698 | ||
1699 | DEFUN (clear_ip_pim_oil, | |
1700 | clear_ip_pim_oil_cmd, | |
1701 | "clear ip pim oil", | |
1702 | CLEAR_STR | |
1703 | IP_STR | |
1704 | CLEAR_IP_PIM_STR | |
1705 | "Rescan PIM OIL (output interface list)\n") | |
1706 | { | |
1707 | pim_scan_oil(); | |
1708 | ||
1709 | return CMD_SUCCESS; | |
1710 | } | |
1711 | ||
1712 | DEFUN (show_ip_igmp_interface, | |
1713 | show_ip_igmp_interface_cmd, | |
1714 | "show ip igmp interface", | |
1715 | SHOW_STR | |
1716 | IP_STR | |
1717 | IGMP_STR | |
1718 | "IGMP interface information\n") | |
1719 | { | |
1720 | igmp_show_interfaces(vty); | |
1721 | ||
1722 | return CMD_SUCCESS; | |
1723 | } | |
1724 | ||
1725 | DEFUN (show_ip_igmp_join, | |
1726 | show_ip_igmp_join_cmd, | |
1727 | "show ip igmp join", | |
1728 | SHOW_STR | |
1729 | IP_STR | |
1730 | IGMP_STR | |
1731 | "IGMP static join information\n") | |
1732 | { | |
1733 | igmp_show_interface_join(vty); | |
1734 | ||
1735 | return CMD_SUCCESS; | |
1736 | } | |
1737 | ||
1738 | DEFUN (show_ip_igmp_groups, | |
1739 | show_ip_igmp_groups_cmd, | |
1740 | "show ip igmp groups", | |
1741 | SHOW_STR | |
1742 | IP_STR | |
1743 | IGMP_STR | |
1744 | IGMP_GROUP_STR) | |
1745 | { | |
1746 | igmp_show_groups(vty); | |
1747 | ||
1748 | return CMD_SUCCESS; | |
1749 | } | |
1750 | ||
1751 | DEFUN (show_ip_igmp_groups_retransmissions, | |
1752 | show_ip_igmp_groups_retransmissions_cmd, | |
1753 | "show ip igmp groups retransmissions", | |
1754 | SHOW_STR | |
1755 | IP_STR | |
1756 | IGMP_STR | |
1757 | IGMP_GROUP_STR | |
1758 | "IGMP group retransmissions\n") | |
1759 | { | |
1760 | igmp_show_group_retransmission(vty); | |
1761 | ||
1762 | return CMD_SUCCESS; | |
1763 | } | |
1764 | ||
1765 | DEFUN (show_ip_igmp_parameters, | |
1766 | show_ip_igmp_parameters_cmd, | |
1767 | "show ip igmp parameters", | |
1768 | SHOW_STR | |
1769 | IP_STR | |
1770 | IGMP_STR | |
1771 | "IGMP parameters information\n") | |
1772 | { | |
1773 | igmp_show_parameters(vty); | |
1774 | ||
1775 | return CMD_SUCCESS; | |
1776 | } | |
1777 | ||
1778 | DEFUN (show_ip_igmp_sources, | |
1779 | show_ip_igmp_sources_cmd, | |
1780 | "show ip igmp sources", | |
1781 | SHOW_STR | |
1782 | IP_STR | |
1783 | IGMP_STR | |
1784 | IGMP_SOURCE_STR) | |
1785 | { | |
1786 | igmp_show_sources(vty); | |
1787 | ||
1788 | return CMD_SUCCESS; | |
1789 | } | |
1790 | ||
1791 | DEFUN (show_ip_igmp_sources_retransmissions, | |
1792 | show_ip_igmp_sources_retransmissions_cmd, | |
1793 | "show ip igmp sources retransmissions", | |
1794 | SHOW_STR | |
1795 | IP_STR | |
1796 | IGMP_STR | |
1797 | IGMP_SOURCE_STR | |
1798 | "IGMP source retransmissions\n") | |
1799 | { | |
1800 | igmp_show_source_retransmission(vty); | |
1801 | ||
1802 | return CMD_SUCCESS; | |
1803 | } | |
1804 | ||
1805 | DEFUN (show_ip_igmp_querier, | |
1806 | show_ip_igmp_querier_cmd, | |
1807 | "show ip igmp querier", | |
1808 | SHOW_STR | |
1809 | IP_STR | |
1810 | IGMP_STR | |
1811 | "IGMP querier information\n") | |
1812 | { | |
1813 | igmp_show_querier(vty); | |
1814 | ||
1815 | return CMD_SUCCESS; | |
1816 | } | |
1817 | ||
1818 | DEFUN (show_ip_pim_address, | |
1819 | show_ip_pim_address_cmd, | |
1820 | "show ip pim address", | |
1821 | SHOW_STR | |
1822 | IP_STR | |
1823 | PIM_STR | |
1824 | "PIM interface address\n") | |
1825 | { | |
1826 | show_interface_address(vty); | |
1827 | ||
1828 | return CMD_SUCCESS; | |
1829 | } | |
1830 | ||
1831 | DEFUN (show_ip_pim_assert, | |
1832 | show_ip_pim_assert_cmd, | |
1833 | "show ip pim assert", | |
1834 | SHOW_STR | |
1835 | IP_STR | |
1836 | PIM_STR | |
1837 | "PIM interface assert\n") | |
1838 | { | |
1839 | pim_show_assert(vty); | |
1840 | ||
1841 | return CMD_SUCCESS; | |
1842 | } | |
1843 | ||
1844 | DEFUN (show_ip_pim_assert_internal, | |
1845 | show_ip_pim_assert_internal_cmd, | |
1846 | "show ip pim assert-internal", | |
1847 | SHOW_STR | |
1848 | IP_STR | |
1849 | PIM_STR | |
1850 | "PIM interface internal assert state\n") | |
1851 | { | |
1852 | pim_show_assert_internal(vty); | |
1853 | ||
1854 | return CMD_SUCCESS; | |
1855 | } | |
1856 | ||
1857 | DEFUN (show_ip_pim_assert_metric, | |
1858 | show_ip_pim_assert_metric_cmd, | |
1859 | "show ip pim assert-metric", | |
1860 | SHOW_STR | |
1861 | IP_STR | |
1862 | PIM_STR | |
1863 | "PIM interface assert metric\n") | |
1864 | { | |
1865 | pim_show_assert_metric(vty); | |
1866 | ||
1867 | return CMD_SUCCESS; | |
1868 | } | |
1869 | ||
1870 | DEFUN (show_ip_pim_assert_winner_metric, | |
1871 | show_ip_pim_assert_winner_metric_cmd, | |
1872 | "show ip pim assert-winner-metric", | |
1873 | SHOW_STR | |
1874 | IP_STR | |
1875 | PIM_STR | |
1876 | "PIM interface assert winner metric\n") | |
1877 | { | |
1878 | pim_show_assert_winner_metric(vty); | |
1879 | ||
1880 | return CMD_SUCCESS; | |
1881 | } | |
1882 | ||
1883 | DEFUN (show_ip_pim_dr, | |
1884 | show_ip_pim_dr_cmd, | |
1885 | "show ip pim designated-router", | |
1886 | SHOW_STR | |
1887 | IP_STR | |
1888 | PIM_STR | |
1889 | "PIM interface designated router\n") | |
1890 | { | |
1891 | pim_show_dr(vty); | |
1892 | ||
1893 | return CMD_SUCCESS; | |
1894 | } | |
1895 | ||
1896 | DEFUN (show_ip_pim_hello, | |
1897 | show_ip_pim_hello_cmd, | |
1898 | "show ip pim hello", | |
1899 | SHOW_STR | |
1900 | IP_STR | |
1901 | PIM_STR | |
1902 | "PIM interface hello information\n") | |
1903 | { | |
1904 | pim_show_hello(vty); | |
1905 | ||
1906 | return CMD_SUCCESS; | |
1907 | } | |
1908 | ||
1909 | DEFUN (show_ip_pim_interface, | |
1910 | show_ip_pim_interface_cmd, | |
1911 | "show ip pim interface", | |
1912 | SHOW_STR | |
1913 | IP_STR | |
1914 | PIM_STR | |
1915 | "PIM interface information\n") | |
1916 | { | |
1917 | pim_show_interfaces(vty); | |
1918 | ||
1919 | return CMD_SUCCESS; | |
1920 | } | |
1921 | ||
1922 | DEFUN (show_ip_pim_join, | |
1923 | show_ip_pim_join_cmd, | |
1924 | "show ip pim join", | |
1925 | SHOW_STR | |
1926 | IP_STR | |
1927 | PIM_STR | |
1928 | "PIM interface join information\n") | |
1929 | { | |
1930 | pim_show_join(vty); | |
1931 | ||
1932 | return CMD_SUCCESS; | |
1933 | } | |
1934 | ||
1935 | DEFUN (show_ip_pim_lan_prune_delay, | |
1936 | show_ip_pim_lan_prune_delay_cmd, | |
1937 | "show ip pim lan-prune-delay", | |
1938 | SHOW_STR | |
1939 | IP_STR | |
1940 | PIM_STR | |
1941 | "PIM neighbors LAN prune delay parameters\n") | |
1942 | { | |
1943 | pim_show_lan_prune_delay(vty); | |
1944 | ||
1945 | return CMD_SUCCESS; | |
1946 | } | |
1947 | ||
1948 | DEFUN (show_ip_pim_local_membership, | |
1949 | show_ip_pim_local_membership_cmd, | |
1950 | "show ip pim local-membership", | |
1951 | SHOW_STR | |
1952 | IP_STR | |
1953 | PIM_STR | |
1954 | "PIM interface local-membership\n") | |
1955 | { | |
1956 | pim_show_membership(vty); | |
1957 | ||
1958 | return CMD_SUCCESS; | |
1959 | } | |
1960 | ||
1961 | DEFUN (show_ip_pim_jp_override_interval, | |
1962 | show_ip_pim_jp_override_interval_cmd, | |
1963 | "show ip pim jp-override-interval", | |
1964 | SHOW_STR | |
1965 | IP_STR | |
1966 | PIM_STR | |
1967 | "PIM interface J/P override interval\n") | |
1968 | { | |
1969 | pim_show_jp_override_interval(vty); | |
1970 | ||
1971 | return CMD_SUCCESS; | |
1972 | } | |
1973 | ||
1974 | DEFUN (show_ip_pim_neighbor, | |
1975 | show_ip_pim_neighbor_cmd, | |
1976 | "show ip pim neighbor", | |
1977 | SHOW_STR | |
1978 | IP_STR | |
1979 | PIM_STR | |
1980 | "PIM neighbor information\n") | |
1981 | { | |
1982 | pim_show_neighbors(vty); | |
1983 | ||
1984 | return CMD_SUCCESS; | |
1985 | } | |
1986 | ||
1987 | DEFUN (show_ip_pim_secondary, | |
1988 | show_ip_pim_secondary_cmd, | |
1989 | "show ip pim secondary", | |
1990 | SHOW_STR | |
1991 | IP_STR | |
1992 | PIM_STR | |
1993 | "PIM neighbor addresses\n") | |
1994 | { | |
1995 | pim_show_neighbors_secondary(vty); | |
1996 | ||
1997 | return CMD_SUCCESS; | |
1998 | } | |
1999 | ||
2000 | DEFUN (show_ip_pim_upstream, | |
2001 | show_ip_pim_upstream_cmd, | |
2002 | "show ip pim upstream", | |
2003 | SHOW_STR | |
2004 | IP_STR | |
2005 | PIM_STR | |
2006 | "PIM upstream information\n") | |
2007 | { | |
2008 | pim_show_upstream(vty); | |
2009 | ||
2010 | return CMD_SUCCESS; | |
2011 | } | |
2012 | ||
2013 | DEFUN (show_ip_pim_upstream_join_desired, | |
2014 | show_ip_pim_upstream_join_desired_cmd, | |
2015 | "show ip pim upstream-join-desired", | |
2016 | SHOW_STR | |
2017 | IP_STR | |
2018 | PIM_STR | |
2019 | "PIM upstream join-desired\n") | |
2020 | { | |
2021 | pim_show_join_desired(vty); | |
2022 | ||
2023 | return CMD_SUCCESS; | |
2024 | } | |
2025 | ||
2026 | DEFUN (show_ip_pim_upstream_rpf, | |
2027 | show_ip_pim_upstream_rpf_cmd, | |
2028 | "show ip pim upstream-rpf", | |
2029 | SHOW_STR | |
2030 | IP_STR | |
2031 | PIM_STR | |
2032 | "PIM upstream source rpf\n") | |
2033 | { | |
2034 | pim_show_upstream_rpf(vty); | |
2035 | ||
2036 | return CMD_SUCCESS; | |
2037 | } | |
2038 | ||
2039 | DEFUN (show_ip_pim_rpf, | |
2040 | show_ip_pim_rpf_cmd, | |
2041 | "show ip pim rpf", | |
2042 | SHOW_STR | |
2043 | IP_STR | |
2044 | PIM_STR | |
2045 | "PIM cached source rpf information\n") | |
2046 | { | |
2047 | pim_show_rpf(vty); | |
2048 | ||
2049 | return CMD_SUCCESS; | |
2050 | } | |
2051 | ||
2052 | static void show_multicast_interfaces(struct vty *vty) | |
2053 | { | |
2054 | struct listnode *node; | |
2055 | struct interface *ifp; | |
2056 | ||
2057 | vty_out(vty, "%s", VTY_NEWLINE); | |
2058 | ||
2059 | vty_out(vty, "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut%s", | |
2060 | VTY_NEWLINE); | |
2061 | ||
469351b3 | 2062 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) { |
12e41d03 DL |
2063 | struct pim_interface *pim_ifp; |
2064 | struct in_addr ifaddr; | |
2065 | struct sioc_vif_req vreq; | |
2066 | ||
2067 | pim_ifp = ifp->info; | |
2068 | ||
2069 | if (!pim_ifp) | |
2070 | continue; | |
2071 | ||
2072 | memset(&vreq, 0, sizeof(vreq)); | |
2073 | vreq.vifi = pim_ifp->mroute_vif_index; | |
2074 | ||
2075 | if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) { | |
6c44fe22 DS |
2076 | zlog_warn("ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s%s", |
2077 | (unsigned long)SIOCGETVIFCNT, | |
2078 | ifp->name, | |
2079 | pim_ifp->mroute_vif_index, | |
2080 | errno, | |
2081 | safe_strerror(errno), | |
2082 | VTY_NEWLINE); | |
12e41d03 DL |
2083 | } |
2084 | ||
2085 | ifaddr = pim_ifp->primary_address; | |
2086 | ||
2087 | vty_out(vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu%s", | |
2088 | ifp->name, | |
2089 | inet_ntoa(ifaddr), | |
2090 | ifp->ifindex, | |
2091 | pim_ifp->mroute_vif_index, | |
2092 | vreq.icount, | |
2093 | vreq.ocount, | |
2094 | vreq.ibytes, | |
2095 | vreq.obytes, | |
2096 | VTY_NEWLINE); | |
2097 | } | |
2098 | } | |
2099 | ||
2100 | DEFUN (show_ip_multicast, | |
2101 | show_ip_multicast_cmd, | |
2102 | "show ip multicast", | |
2103 | SHOW_STR | |
2104 | IP_STR | |
2105 | "Multicast global information\n") | |
2106 | { | |
2107 | time_t now = pim_time_monotonic_sec(); | |
2108 | ||
2109 | if (PIM_MROUTE_IS_ENABLED) { | |
2110 | char uptime[10]; | |
2111 | ||
2112 | vty_out(vty, "Mroute socket descriptor: %d%s", | |
2113 | qpim_mroute_socket_fd, | |
2114 | VTY_NEWLINE); | |
2115 | ||
2116 | pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation); | |
2117 | vty_out(vty, "Mroute socket uptime: %s%s", | |
2118 | uptime, | |
2119 | VTY_NEWLINE); | |
2120 | } | |
2121 | else { | |
2122 | vty_out(vty, "Multicast disabled%s", | |
2123 | VTY_NEWLINE); | |
2124 | } | |
2125 | ||
2126 | vty_out(vty, "%s", VTY_NEWLINE); | |
2127 | vty_out(vty, "Zclient update socket: "); | |
2128 | if (qpim_zclient_update) { | |
2129 | vty_out(vty, "%d failures=%d%s", qpim_zclient_update->sock, | |
2130 | qpim_zclient_update->fail, VTY_NEWLINE); | |
2131 | } | |
2132 | else { | |
2133 | vty_out(vty, "<null zclient>%s", VTY_NEWLINE); | |
2134 | } | |
2135 | vty_out(vty, "Zclient lookup socket: "); | |
2136 | if (qpim_zclient_lookup) { | |
2137 | vty_out(vty, "%d failures=%d%s", qpim_zclient_lookup->sock, | |
2138 | qpim_zclient_lookup->fail, VTY_NEWLINE); | |
2139 | } | |
2140 | else { | |
2141 | vty_out(vty, "<null zclient>%s", VTY_NEWLINE); | |
2142 | } | |
2143 | ||
2144 | vty_out(vty, "%s", VTY_NEWLINE); | |
2145 | vty_out(vty, "Current highest VifIndex: %d%s", | |
2146 | qpim_mroute_oif_highest_vif_index, | |
2147 | VTY_NEWLINE); | |
2148 | vty_out(vty, "Maximum highest VifIndex: %d%s", | |
1865a44a | 2149 | PIM_MAX_USABLE_VIFS, |
12e41d03 DL |
2150 | VTY_NEWLINE); |
2151 | ||
2152 | vty_out(vty, "%s", VTY_NEWLINE); | |
2153 | vty_out(vty, "Upstream Join Timer: %d secs%s", | |
2154 | qpim_t_periodic, | |
2155 | VTY_NEWLINE); | |
2156 | vty_out(vty, "Join/Prune Holdtime: %d secs%s", | |
2157 | PIM_JP_HOLDTIME, | |
2158 | VTY_NEWLINE); | |
2159 | ||
2160 | vty_out(vty, "%s", VTY_NEWLINE); | |
2161 | ||
2162 | show_rpf_refresh_stats(vty, now); | |
2163 | ||
2164 | vty_out(vty, "%s", VTY_NEWLINE); | |
2165 | ||
2166 | show_scan_oil_stats(vty, now); | |
2167 | ||
2168 | show_multicast_interfaces(vty); | |
2169 | ||
2170 | return CMD_SUCCESS; | |
2171 | } | |
2172 | ||
2173 | static void show_mroute(struct vty *vty) | |
2174 | { | |
2175 | struct listnode *node; | |
2176 | struct channel_oil *c_oil; | |
6250610a | 2177 | struct static_route *s_route; |
12e41d03 DL |
2178 | time_t now; |
2179 | ||
0fba6e63 | 2180 | vty_out(vty, "Proto: I=IGMP P=PIM S=STATIC O=SOURCE%s%s", VTY_NEWLINE, VTY_NEWLINE); |
12e41d03 DL |
2181 | |
2182 | vty_out(vty, "Source Group Proto Input iVifI Output oVifI TTL Uptime %s", | |
2183 | VTY_NEWLINE); | |
2184 | ||
2185 | now = pim_time_monotonic_sec(); | |
2186 | ||
6250610a | 2187 | /* print list of PIM and IGMP routes */ |
12e41d03 DL |
2188 | for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) { |
2189 | char group_str[100]; | |
2190 | char source_str[100]; | |
2191 | int oif_vif_index; | |
2192 | ||
58302dc7 DS |
2193 | if (!c_oil->installed) |
2194 | continue; | |
2195 | ||
12e41d03 DL |
2196 | pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str)); |
2197 | pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str)); | |
2198 | ||
2199 | for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) { | |
2200 | struct interface *ifp_in; | |
2201 | struct interface *ifp_out; | |
2202 | char oif_uptime[10]; | |
2203 | int ttl; | |
2204 | char proto[5]; | |
2205 | ||
2206 | ttl = c_oil->oil.mfcc_ttls[oif_vif_index]; | |
2207 | if (ttl < 1) | |
2208 | continue; | |
2209 | ||
2210 | ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent); | |
2211 | ifp_out = pim_if_find_by_vif_index(oif_vif_index); | |
2212 | ||
2213 | pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]); | |
2214 | ||
2215 | proto[0] = '\0'; | |
2216 | if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) { | |
2217 | strcat(proto, "P"); | |
2218 | } | |
2219 | if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP) { | |
2220 | strcat(proto, "I"); | |
2221 | } | |
0fba6e63 DS |
2222 | if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_SOURCE) { |
2223 | strcat(proto, "O"); | |
2224 | } | |
12e41d03 DL |
2225 | |
2226 | vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s", | |
2227 | source_str, | |
2228 | group_str, | |
2229 | proto, | |
2230 | ifp_in ? ifp_in->name : "<iif?>", | |
2231 | c_oil->oil.mfcc_parent, | |
2232 | ifp_out ? ifp_out->name : "<oif?>", | |
2233 | oif_vif_index, | |
2234 | ttl, | |
2235 | oif_uptime, | |
2236 | VTY_NEWLINE); | |
2237 | } | |
2238 | } | |
6250610a JAG |
2239 | |
2240 | /* Print list of static routes */ | |
2241 | for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) { | |
2242 | char group_str[100]; | |
2243 | char source_str[100]; | |
2244 | int oif_vif_index; | |
2245 | ||
58302dc7 DS |
2246 | if (!s_route->c_oil.installed) |
2247 | continue; | |
2248 | ||
6250610a JAG |
2249 | pim_inet4_dump("<group?>", s_route->group, group_str, sizeof(group_str)); |
2250 | pim_inet4_dump("<source?>", s_route->source, source_str, sizeof(source_str)); | |
2251 | ||
2252 | for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) { | |
2253 | struct interface *ifp_in; | |
2254 | struct interface *ifp_out; | |
2255 | char oif_uptime[10]; | |
2256 | int ttl; | |
2257 | char proto[5]; | |
2258 | ||
2259 | ttl = s_route->oif_ttls[oif_vif_index]; | |
2260 | if (ttl < 1) | |
2261 | continue; | |
2262 | ||
2263 | ifp_in = pim_if_find_by_vif_index(s_route->iif); | |
2264 | ifp_out = pim_if_find_by_vif_index(oif_vif_index); | |
2265 | ||
9867746a | 2266 | pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - s_route->c_oil.oif_creation[oif_vif_index]); |
6250610a JAG |
2267 | |
2268 | proto[0] = '\0'; | |
2269 | strcat(proto, "S"); | |
2270 | ||
2271 | vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s", | |
2272 | source_str, | |
2273 | group_str, | |
2274 | proto, | |
2275 | ifp_in ? ifp_in->name : "<iif?>", | |
2276 | s_route->iif, | |
2277 | ifp_out ? ifp_out->name : "<oif?>", | |
2278 | oif_vif_index, | |
2279 | ttl, | |
2280 | oif_uptime, | |
2281 | VTY_NEWLINE); | |
2282 | } | |
2283 | } | |
12e41d03 DL |
2284 | } |
2285 | ||
2286 | DEFUN (show_ip_mroute, | |
2287 | show_ip_mroute_cmd, | |
2288 | "show ip mroute", | |
2289 | SHOW_STR | |
2290 | IP_STR | |
2291 | MROUTE_STR) | |
2292 | { | |
2293 | show_mroute(vty); | |
2294 | return CMD_SUCCESS; | |
2295 | } | |
2296 | ||
2297 | static void show_mroute_count(struct vty *vty) | |
2298 | { | |
2299 | struct listnode *node; | |
2300 | struct channel_oil *c_oil; | |
6250610a | 2301 | struct static_route *s_route; |
12e41d03 DL |
2302 | |
2303 | vty_out(vty, "%s", VTY_NEWLINE); | |
2304 | ||
2305 | vty_out(vty, "Source Group Packets Bytes WrongIf %s", | |
2306 | VTY_NEWLINE); | |
2307 | ||
6250610a | 2308 | /* Print PIM and IGMP route counts */ |
12e41d03 DL |
2309 | for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) { |
2310 | char group_str[100]; | |
2311 | char source_str[100]; | |
2312 | struct sioc_sg_req sgreq; | |
2313 | ||
58302dc7 DS |
2314 | if (!c_oil->installed) |
2315 | continue; | |
2316 | ||
12e41d03 DL |
2317 | memset(&sgreq, 0, sizeof(sgreq)); |
2318 | sgreq.src = c_oil->oil.mfcc_origin; | |
2319 | sgreq.grp = c_oil->oil.mfcc_mcastgrp; | |
2320 | ||
2321 | pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str)); | |
2322 | pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str)); | |
2323 | ||
2324 | if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) { | |
2325 | int e = errno; | |
2326 | vty_out(vty, | |
1cb17fc7 DL |
2327 | "ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=(%s,%s): errno=%d: %s%s", |
2328 | (unsigned long)SIOCGETSGCNT, | |
12e41d03 DL |
2329 | source_str, |
2330 | group_str, | |
2331 | e, | |
2332 | safe_strerror(e), | |
2333 | VTY_NEWLINE); | |
2334 | continue; | |
2335 | } | |
2336 | ||
2337 | vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s", | |
2338 | source_str, | |
2339 | group_str, | |
2340 | sgreq.pktcnt, | |
2341 | sgreq.bytecnt, | |
2342 | sgreq.wrong_if, | |
2343 | VTY_NEWLINE); | |
6250610a JAG |
2344 | } |
2345 | ||
2346 | /* Print static route counts */ | |
2347 | for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) { | |
2348 | char group_str[100]; | |
2349 | char source_str[100]; | |
2350 | struct sioc_sg_req sgreq; | |
2351 | ||
58302dc7 DS |
2352 | if (!s_route->c_oil.installed) |
2353 | continue; | |
2354 | ||
6250610a | 2355 | memset(&sgreq, 0, sizeof(sgreq)); |
9867746a DS |
2356 | sgreq.src = s_route->c_oil.oil.mfcc_origin; |
2357 | sgreq.grp = s_route->c_oil.oil.mfcc_mcastgrp; | |
6250610a | 2358 | |
9867746a DS |
2359 | pim_inet4_dump("<group?>", s_route->c_oil.oil.mfcc_mcastgrp, group_str, sizeof(group_str)); |
2360 | pim_inet4_dump("<source?>", s_route->c_oil.oil.mfcc_origin, source_str, sizeof(source_str)); | |
6250610a JAG |
2361 | |
2362 | if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) { | |
2363 | int e = errno; | |
2364 | vty_out(vty, | |
02e51cad PJ |
2365 | "ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=(%s,%s): errno=%d: %s%s", |
2366 | /* note that typeof ioctl defs can vary across platforms, from | |
2367 | * int, to unsigned int, to long unsigned int | |
2368 | */ | |
2369 | (unsigned long)SIOCGETSGCNT, | |
6250610a JAG |
2370 | source_str, |
2371 | group_str, | |
2372 | e, | |
2373 | safe_strerror(e), | |
2374 | VTY_NEWLINE); | |
2375 | continue; | |
2376 | } | |
12e41d03 | 2377 | |
6250610a JAG |
2378 | vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s", |
2379 | source_str, | |
2380 | group_str, | |
2381 | sgreq.pktcnt, | |
2382 | sgreq.bytecnt, | |
2383 | sgreq.wrong_if, | |
2384 | VTY_NEWLINE); | |
12e41d03 DL |
2385 | } |
2386 | } | |
2387 | ||
2388 | DEFUN (show_ip_mroute_count, | |
2389 | show_ip_mroute_count_cmd, | |
2390 | "show ip mroute count", | |
2391 | SHOW_STR | |
2392 | IP_STR | |
2393 | MROUTE_STR | |
2394 | "Route and packet count data\n") | |
2395 | { | |
2396 | show_mroute_count(vty); | |
2397 | return CMD_SUCCESS; | |
2398 | } | |
2399 | ||
2400 | DEFUN (show_ip_rib, | |
2401 | show_ip_rib_cmd, | |
2402 | "show ip rib A.B.C.D", | |
2403 | SHOW_STR | |
2404 | IP_STR | |
2405 | RIB_STR | |
2406 | "Unicast address\n") | |
2407 | { | |
2408 | struct in_addr addr; | |
2409 | const char *addr_str; | |
2410 | struct pim_nexthop nexthop; | |
2411 | char nexthop_addr_str[100]; | |
2412 | int result; | |
2413 | ||
2414 | addr_str = argv[0]; | |
2415 | result = inet_pton(AF_INET, addr_str, &addr); | |
2416 | if (result <= 0) { | |
2417 | vty_out(vty, "Bad unicast address %s: errno=%d: %s%s", | |
2418 | addr_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
2419 | return CMD_WARNING; | |
2420 | } | |
2421 | ||
651d0f71 | 2422 | if (pim_nexthop_lookup(&nexthop, addr, NULL)) { |
12e41d03 DL |
2423 | vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s", |
2424 | addr_str, VTY_NEWLINE); | |
2425 | return CMD_WARNING; | |
2426 | } | |
2427 | ||
2428 | vty_out(vty, "Address NextHop Interface Metric Preference%s", | |
2429 | VTY_NEWLINE); | |
2430 | ||
2431 | pim_inet4_dump("<nexthop?>", nexthop.mrib_nexthop_addr, | |
2432 | nexthop_addr_str, sizeof(nexthop_addr_str)); | |
2433 | ||
2434 | vty_out(vty, "%-15s %-15s %-9s %6d %10d%s", | |
2435 | addr_str, | |
2436 | nexthop_addr_str, | |
2437 | nexthop.interface ? nexthop.interface->name : "<ifname?>", | |
2438 | nexthop.mrib_route_metric, | |
2439 | nexthop.mrib_metric_preference, | |
2440 | VTY_NEWLINE); | |
2441 | ||
2442 | return CMD_SUCCESS; | |
2443 | } | |
2444 | ||
2445 | static void show_ssmpingd(struct vty *vty) | |
2446 | { | |
2447 | struct listnode *node; | |
2448 | struct ssmpingd_sock *ss; | |
2449 | time_t now; | |
2450 | ||
2451 | vty_out(vty, "Source Socket Address Port Uptime Requests%s", | |
2452 | VTY_NEWLINE); | |
2453 | ||
2454 | if (!qpim_ssmpingd_list) | |
2455 | return; | |
2456 | ||
2457 | now = pim_time_monotonic_sec(); | |
2458 | ||
2459 | for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) { | |
2460 | char source_str[100]; | |
2461 | char ss_uptime[10]; | |
2462 | struct sockaddr_in bind_addr; | |
2463 | socklen_t len = sizeof(bind_addr); | |
2464 | char bind_addr_str[100]; | |
2465 | ||
2466 | pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str)); | |
2467 | ||
2468 | if (pim_socket_getsockname(ss->sock_fd, (struct sockaddr *) &bind_addr, &len)) { | |
2469 | vty_out(vty, "%% Failure reading socket name for ssmpingd source %s on fd=%d%s", | |
2470 | source_str, ss->sock_fd, VTY_NEWLINE); | |
2471 | } | |
2472 | ||
2473 | pim_inet4_dump("<addr?>", bind_addr.sin_addr, bind_addr_str, sizeof(bind_addr_str)); | |
2474 | pim_time_uptime(ss_uptime, sizeof(ss_uptime), now - ss->creation); | |
2475 | ||
2476 | vty_out(vty, "%-15s %6d %-15s %5d %8s %8lld%s", | |
2477 | source_str, | |
2478 | ss->sock_fd, | |
2479 | bind_addr_str, | |
2480 | ntohs(bind_addr.sin_port), | |
2481 | ss_uptime, | |
2482 | (long long)ss->requests, | |
2483 | VTY_NEWLINE); | |
2484 | } | |
2485 | } | |
2486 | ||
2487 | DEFUN (show_ip_ssmpingd, | |
2488 | show_ip_ssmpingd_cmd, | |
2489 | "show ip ssmpingd", | |
2490 | SHOW_STR | |
2491 | IP_STR | |
2492 | SHOW_SSMPINGD_STR) | |
2493 | { | |
2494 | show_ssmpingd(vty); | |
2495 | return CMD_SUCCESS; | |
2496 | } | |
2497 | ||
981d6c7a DS |
2498 | DEFUN (ip_pim_rp, |
2499 | ip_pim_rp_cmd, | |
2500 | "ip pim rp A.B.C.D", | |
2501 | IP_STR | |
2502 | "pim multicast routing" | |
2503 | "Rendevous Point" | |
2504 | "ip address of RP") | |
2505 | { | |
2506 | int result; | |
2507 | ||
c8ae3ce8 | 2508 | result = inet_pton(AF_INET, argv[0], &qpim_rp.rpf_addr.s_addr); |
981d6c7a DS |
2509 | if (result <= 0) { |
2510 | vty_out(vty, "%% Bad RP address specified: %s", argv[0]); | |
2511 | return CMD_WARNING; | |
2512 | } | |
2513 | ||
651d0f71 | 2514 | if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr, NULL) != 0) { |
c8ae3ce8 DS |
2515 | vty_out(vty, "%% No Path to RP address specified: %s", argv[0]); |
2516 | return CMD_WARNING; | |
2517 | } | |
2518 | ||
981d6c7a DS |
2519 | return CMD_SUCCESS; |
2520 | } | |
2521 | ||
2522 | DEFUN (no_ip_pim_rp, | |
2523 | no_ip_pim_rp_cmd, | |
2524 | "no ip pim rp {A.B.C.D}", | |
2525 | NO_STR | |
2526 | IP_STR | |
2527 | "pim multicast routing" | |
2528 | "Rendevous Point" | |
2529 | "ip address of RP") | |
2530 | { | |
c8ae3ce8 | 2531 | qpim_rp.rpf_addr.s_addr = INADDR_NONE; |
981d6c7a DS |
2532 | |
2533 | return CMD_SUCCESS; | |
2534 | } | |
2535 | ||
12e41d03 DL |
2536 | DEFUN (ip_multicast_routing, |
2537 | ip_multicast_routing_cmd, | |
2538 | PIM_CMD_IP_MULTICAST_ROUTING, | |
2539 | IP_STR | |
2540 | "Enable IP multicast forwarding\n") | |
2541 | { | |
2542 | pim_mroute_socket_enable(); | |
2543 | pim_if_add_vif_all(); | |
2544 | mroute_add_all(); | |
6250610a | 2545 | static_mroute_add_all(); |
12e41d03 DL |
2546 | return CMD_SUCCESS; |
2547 | } | |
2548 | ||
2549 | DEFUN (no_ip_multicast_routing, | |
2550 | no_ip_multicast_routing_cmd, | |
2551 | PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING, | |
2552 | NO_STR | |
2553 | IP_STR | |
2554 | "Global IP configuration subcommands\n" | |
2555 | "Enable IP multicast forwarding\n") | |
2556 | { | |
2557 | mroute_del_all(); | |
6250610a | 2558 | static_mroute_del_all(); |
12e41d03 DL |
2559 | pim_if_del_vif_all(); |
2560 | pim_mroute_socket_disable(); | |
2561 | return CMD_SUCCESS; | |
2562 | } | |
2563 | ||
2564 | DEFUN (ip_ssmpingd, | |
2565 | ip_ssmpingd_cmd, | |
2566 | "ip ssmpingd [A.B.C.D]", | |
2567 | IP_STR | |
2568 | CONF_SSMPINGD_STR | |
2569 | "Source address\n") | |
2570 | { | |
2571 | int result; | |
2572 | struct in_addr source_addr; | |
2573 | const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0"; | |
2574 | ||
2575 | result = inet_pton(AF_INET, source_str, &source_addr); | |
2576 | if (result <= 0) { | |
2577 | vty_out(vty, "%% Bad source address %s: errno=%d: %s%s", | |
2578 | source_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
2579 | return CMD_WARNING; | |
2580 | } | |
2581 | ||
2582 | result = pim_ssmpingd_start(source_addr); | |
2583 | if (result) { | |
2584 | vty_out(vty, "%% Failure starting ssmpingd for source %s: %d%s", | |
2585 | source_str, result, VTY_NEWLINE); | |
2586 | return CMD_WARNING; | |
2587 | } | |
2588 | ||
2589 | return CMD_SUCCESS; | |
2590 | } | |
2591 | ||
2592 | DEFUN (no_ip_ssmpingd, | |
2593 | no_ip_ssmpingd_cmd, | |
2594 | "no ip ssmpingd [A.B.C.D]", | |
2595 | NO_STR | |
2596 | IP_STR | |
2597 | CONF_SSMPINGD_STR | |
2598 | "Source address\n") | |
2599 | { | |
2600 | int result; | |
2601 | struct in_addr source_addr; | |
2602 | const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0"; | |
2603 | ||
2604 | result = inet_pton(AF_INET, source_str, &source_addr); | |
2605 | if (result <= 0) { | |
2606 | vty_out(vty, "%% Bad source address %s: errno=%d: %s%s", | |
2607 | source_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
2608 | return CMD_WARNING; | |
2609 | } | |
2610 | ||
2611 | result = pim_ssmpingd_stop(source_addr); | |
2612 | if (result) { | |
2613 | vty_out(vty, "%% Failure stopping ssmpingd for source %s: %d%s", | |
2614 | source_str, result, VTY_NEWLINE); | |
2615 | return CMD_WARNING; | |
2616 | } | |
2617 | ||
2618 | return CMD_SUCCESS; | |
2619 | } | |
2620 | ||
2621 | DEFUN (interface_ip_igmp, | |
2622 | interface_ip_igmp_cmd, | |
2623 | "ip igmp", | |
2624 | IP_STR | |
2625 | IFACE_IGMP_STR) | |
2626 | { | |
2627 | struct interface *ifp; | |
2628 | struct pim_interface *pim_ifp; | |
2629 | ||
2630 | ifp = vty->index; | |
2631 | pim_ifp = ifp->info; | |
2632 | ||
2633 | if (!pim_ifp) { | |
2634 | pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */); | |
2635 | if (!pim_ifp) { | |
2636 | vty_out(vty, "Could not enable IGMP on interface %s%s", | |
2637 | ifp->name, VTY_NEWLINE); | |
2638 | return CMD_WARNING; | |
2639 | } | |
2640 | } | |
2641 | else { | |
2642 | PIM_IF_DO_IGMP(pim_ifp->options); | |
2643 | } | |
2644 | ||
2645 | pim_if_addr_add_all(ifp); | |
2646 | pim_if_membership_refresh(ifp); | |
2647 | ||
2648 | return CMD_SUCCESS; | |
2649 | } | |
2650 | ||
2651 | DEFUN (interface_no_ip_igmp, | |
2652 | interface_no_ip_igmp_cmd, | |
2653 | "no ip igmp", | |
2654 | NO_STR | |
2655 | IP_STR | |
2656 | IFACE_IGMP_STR) | |
2657 | { | |
2658 | struct interface *ifp; | |
2659 | struct pim_interface *pim_ifp; | |
2660 | ||
2661 | ifp = vty->index; | |
2662 | pim_ifp = ifp->info; | |
2663 | if (!pim_ifp) | |
2664 | return CMD_SUCCESS; | |
2665 | ||
2666 | PIM_IF_DONT_IGMP(pim_ifp->options); | |
2667 | ||
2668 | pim_if_membership_clear(ifp); | |
2669 | ||
2670 | pim_if_addr_del_all_igmp(ifp); | |
2671 | ||
2672 | if (!PIM_IF_TEST_PIM(pim_ifp->options)) { | |
2673 | pim_if_delete(ifp); | |
2674 | } | |
2675 | ||
2676 | return CMD_SUCCESS; | |
2677 | } | |
2678 | ||
2679 | DEFUN (interface_ip_igmp_join, | |
2680 | interface_ip_igmp_join_cmd, | |
2681 | "ip igmp join A.B.C.D A.B.C.D", | |
2682 | IP_STR | |
2683 | IFACE_IGMP_STR | |
2684 | "IGMP join multicast group\n" | |
2685 | "Multicast group address\n" | |
2686 | "Source address\n") | |
2687 | { | |
2688 | struct interface *ifp; | |
2689 | const char *group_str; | |
2690 | const char *source_str; | |
2691 | struct in_addr group_addr; | |
2692 | struct in_addr source_addr; | |
2693 | int result; | |
2694 | ||
2695 | ifp = vty->index; | |
2696 | ||
2697 | /* Group address */ | |
2698 | group_str = argv[0]; | |
2699 | result = inet_pton(AF_INET, group_str, &group_addr); | |
2700 | if (result <= 0) { | |
2701 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
2702 | group_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
2703 | return CMD_WARNING; | |
2704 | } | |
2705 | ||
2706 | /* Source address */ | |
2707 | source_str = argv[1]; | |
2708 | result = inet_pton(AF_INET, source_str, &source_addr); | |
2709 | if (result <= 0) { | |
2710 | vty_out(vty, "Bad source address %s: errno=%d: %s%s", | |
2711 | source_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
2712 | return CMD_WARNING; | |
2713 | } | |
2714 | ||
2715 | result = pim_if_igmp_join_add(ifp, group_addr, source_addr); | |
2716 | if (result) { | |
2717 | vty_out(vty, "%% Failure joining IGMP group %s source %s on interface %s: %d%s", | |
2718 | group_str, source_str, ifp->name, result, VTY_NEWLINE); | |
2719 | return CMD_WARNING; | |
2720 | } | |
2721 | ||
2722 | return CMD_SUCCESS; | |
2723 | } | |
2724 | ||
2725 | DEFUN (interface_no_ip_igmp_join, | |
2726 | interface_no_ip_igmp_join_cmd, | |
2727 | "no ip igmp join A.B.C.D A.B.C.D", | |
2728 | NO_STR | |
2729 | IP_STR | |
2730 | IFACE_IGMP_STR | |
2731 | "IGMP join multicast group\n" | |
2732 | "Multicast group address\n" | |
2733 | "Source address\n") | |
2734 | { | |
2735 | struct interface *ifp; | |
2736 | const char *group_str; | |
2737 | const char *source_str; | |
2738 | struct in_addr group_addr; | |
2739 | struct in_addr source_addr; | |
2740 | int result; | |
2741 | ||
2742 | ifp = vty->index; | |
2743 | ||
2744 | /* Group address */ | |
2745 | group_str = argv[0]; | |
2746 | result = inet_pton(AF_INET, group_str, &group_addr); | |
2747 | if (result <= 0) { | |
2748 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
2749 | group_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
2750 | return CMD_WARNING; | |
2751 | } | |
2752 | ||
2753 | /* Source address */ | |
2754 | source_str = argv[1]; | |
2755 | result = inet_pton(AF_INET, source_str, &source_addr); | |
2756 | if (result <= 0) { | |
2757 | vty_out(vty, "Bad source address %s: errno=%d: %s%s", | |
2758 | source_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
2759 | return CMD_WARNING; | |
2760 | } | |
2761 | ||
2762 | result = pim_if_igmp_join_del(ifp, group_addr, source_addr); | |
2763 | if (result) { | |
2764 | vty_out(vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d%s", | |
2765 | group_str, source_str, ifp->name, result, VTY_NEWLINE); | |
2766 | return CMD_WARNING; | |
2767 | } | |
2768 | ||
2769 | return CMD_SUCCESS; | |
2770 | } | |
2771 | ||
2772 | /* | |
2773 | CLI reconfiguration affects the interface level (struct pim_interface). | |
2774 | This function propagates the reconfiguration to every active socket | |
2775 | for that interface. | |
2776 | */ | |
2777 | static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp) | |
2778 | { | |
2779 | struct interface *ifp; | |
2780 | struct pim_interface *pim_ifp; | |
2781 | ||
2782 | zassert(igmp); | |
2783 | ||
2784 | /* other querier present? */ | |
2785 | ||
2786 | if (igmp->t_other_querier_timer) | |
2787 | return; | |
2788 | ||
2789 | /* this is the querier */ | |
2790 | ||
2791 | zassert(igmp->interface); | |
2792 | zassert(igmp->interface->info); | |
2793 | ||
2794 | ifp = igmp->interface; | |
2795 | pim_ifp = ifp->info; | |
2796 | ||
2797 | if (PIM_DEBUG_IGMP_TRACE) { | |
2798 | char ifaddr_str[100]; | |
2799 | pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str)); | |
2800 | zlog_debug("%s: Querier %s on %s reconfig query_interval=%d", | |
2801 | __PRETTY_FUNCTION__, | |
2802 | ifaddr_str, | |
2803 | ifp->name, | |
2804 | pim_ifp->igmp_default_query_interval); | |
2805 | } | |
2806 | ||
2807 | /* | |
2808 | igmp_startup_mode_on() will reset QQI: | |
2809 | ||
2810 | igmp->querier_query_interval = pim_ifp->igmp_default_query_interval; | |
2811 | */ | |
2812 | igmp_startup_mode_on(igmp); | |
2813 | } | |
2814 | ||
2815 | static void igmp_sock_query_reschedule(struct igmp_sock *igmp) | |
2816 | { | |
2817 | if (igmp->t_igmp_query_timer) { | |
2818 | /* other querier present */ | |
2819 | zassert(igmp->t_igmp_query_timer); | |
2820 | zassert(!igmp->t_other_querier_timer); | |
2821 | ||
2822 | pim_igmp_general_query_off(igmp); | |
2823 | pim_igmp_general_query_on(igmp); | |
2824 | ||
2825 | zassert(igmp->t_igmp_query_timer); | |
2826 | zassert(!igmp->t_other_querier_timer); | |
2827 | } | |
2828 | else { | |
2829 | /* this is the querier */ | |
2830 | ||
2831 | zassert(!igmp->t_igmp_query_timer); | |
2832 | zassert(igmp->t_other_querier_timer); | |
2833 | ||
2834 | pim_igmp_other_querier_timer_off(igmp); | |
2835 | pim_igmp_other_querier_timer_on(igmp); | |
2836 | ||
2837 | zassert(!igmp->t_igmp_query_timer); | |
2838 | zassert(igmp->t_other_querier_timer); | |
2839 | } | |
2840 | } | |
2841 | ||
2842 | static void change_query_interval(struct pim_interface *pim_ifp, | |
2843 | int query_interval) | |
2844 | { | |
2845 | struct listnode *sock_node; | |
2846 | struct igmp_sock *igmp; | |
2847 | ||
2848 | pim_ifp->igmp_default_query_interval = query_interval; | |
2849 | ||
2850 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
2851 | igmp_sock_query_interval_reconfig(igmp); | |
2852 | igmp_sock_query_reschedule(igmp); | |
2853 | } | |
2854 | } | |
2855 | ||
2856 | static void change_query_max_response_time(struct pim_interface *pim_ifp, | |
2857 | int query_max_response_time_dsec) | |
2858 | { | |
2859 | struct listnode *sock_node; | |
2860 | struct igmp_sock *igmp; | |
2861 | ||
2862 | pim_ifp->igmp_query_max_response_time_dsec = query_max_response_time_dsec; | |
2863 | ||
2864 | /* | |
2865 | Below we modify socket/group/source timers in order to quickly | |
2866 | reflect the change. Otherwise, those timers would eventually catch | |
2867 | up. | |
2868 | */ | |
2869 | ||
2870 | /* scan all sockets */ | |
2871 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) { | |
2872 | struct listnode *grp_node; | |
2873 | struct igmp_group *grp; | |
2874 | ||
2875 | /* reschedule socket general query */ | |
2876 | igmp_sock_query_reschedule(igmp); | |
2877 | ||
2878 | /* scan socket groups */ | |
2879 | for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grp_node, grp)) { | |
2880 | struct listnode *src_node; | |
2881 | struct igmp_source *src; | |
2882 | ||
2883 | /* reset group timers for groups in EXCLUDE mode */ | |
2884 | if (grp->group_filtermode_isexcl) { | |
2885 | igmp_group_reset_gmi(grp); | |
2886 | } | |
2887 | ||
2888 | /* scan group sources */ | |
2889 | for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) { | |
2890 | ||
2891 | /* reset source timers for sources with running timers */ | |
2892 | if (src->t_source_timer) { | |
2893 | igmp_source_reset_gmi(igmp, grp, src); | |
2894 | } | |
2895 | } | |
2896 | } | |
2897 | } | |
2898 | } | |
2899 | ||
2900 | #define IGMP_QUERY_INTERVAL_MIN (1) | |
2901 | #define IGMP_QUERY_INTERVAL_MAX (1800) | |
2902 | ||
2903 | DEFUN (interface_ip_igmp_query_interval, | |
2904 | interface_ip_igmp_query_interval_cmd, | |
2905 | PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>", | |
2906 | IP_STR | |
2907 | IFACE_IGMP_STR | |
2908 | IFACE_IGMP_QUERY_INTERVAL_STR | |
2909 | "Query interval in seconds\n") | |
2910 | { | |
2911 | struct interface *ifp; | |
2912 | struct pim_interface *pim_ifp; | |
2913 | int query_interval; | |
2914 | int query_interval_dsec; | |
2915 | ||
2916 | ifp = vty->index; | |
2917 | pim_ifp = ifp->info; | |
2918 | ||
2919 | if (!pim_ifp) { | |
2920 | vty_out(vty, | |
2921 | "IGMP not enabled on interface %s. Please enable IGMP first.%s", | |
2922 | ifp->name, | |
2923 | VTY_NEWLINE); | |
2924 | return CMD_WARNING; | |
2925 | } | |
2926 | ||
2927 | query_interval = atoi(argv[0]); | |
2928 | query_interval_dsec = 10 * query_interval; | |
2929 | ||
2930 | /* | |
2931 | It seems we don't need to check bounds since command.c does it | |
2932 | already, but we verify them anyway for extra safety. | |
2933 | */ | |
2934 | if (query_interval < IGMP_QUERY_INTERVAL_MIN) { | |
2935 | vty_out(vty, "General query interval %d lower than minimum %d%s", | |
2936 | query_interval, | |
2937 | IGMP_QUERY_INTERVAL_MIN, | |
2938 | VTY_NEWLINE); | |
2939 | return CMD_WARNING; | |
2940 | } | |
2941 | if (query_interval > IGMP_QUERY_INTERVAL_MAX) { | |
2942 | vty_out(vty, "General query interval %d higher than maximum %d%s", | |
2943 | query_interval, | |
2944 | IGMP_QUERY_INTERVAL_MAX, | |
2945 | VTY_NEWLINE); | |
2946 | return CMD_WARNING; | |
2947 | } | |
2948 | ||
2949 | if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) { | |
2950 | vty_out(vty, | |
2951 | "Can't set general query interval %d dsec <= query max response time %d dsec.%s", | |
2952 | query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec, | |
2953 | VTY_NEWLINE); | |
2954 | return CMD_WARNING; | |
2955 | } | |
2956 | ||
2957 | change_query_interval(pim_ifp, query_interval); | |
2958 | ||
2959 | return CMD_SUCCESS; | |
2960 | } | |
2961 | ||
2962 | DEFUN (interface_no_ip_igmp_query_interval, | |
2963 | interface_no_ip_igmp_query_interval_cmd, | |
2964 | PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL, | |
2965 | NO_STR | |
2966 | IP_STR | |
2967 | IFACE_IGMP_STR | |
2968 | IFACE_IGMP_QUERY_INTERVAL_STR) | |
2969 | { | |
2970 | struct interface *ifp; | |
2971 | struct pim_interface *pim_ifp; | |
2972 | int default_query_interval_dsec; | |
2973 | ||
2974 | ifp = vty->index; | |
2975 | pim_ifp = ifp->info; | |
2976 | ||
2977 | if (!pim_ifp) | |
2978 | return CMD_SUCCESS; | |
2979 | ||
2980 | default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10; | |
2981 | ||
2982 | if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) { | |
2983 | vty_out(vty, | |
2984 | "Can't set default general query interval %d dsec <= query max response time %d dsec.%s", | |
2985 | default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec, | |
2986 | VTY_NEWLINE); | |
2987 | return CMD_WARNING; | |
2988 | } | |
2989 | ||
2990 | change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL); | |
2991 | ||
2992 | return CMD_SUCCESS; | |
2993 | } | |
2994 | ||
2995 | #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN (1) | |
2996 | #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX (25) | |
2997 | ||
2998 | DEFUN (interface_ip_igmp_query_max_response_time, | |
2999 | interface_ip_igmp_query_max_response_time_cmd, | |
3000 | PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>", | |
3001 | IP_STR | |
3002 | IFACE_IGMP_STR | |
3003 | IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR | |
3004 | "Query response value in seconds\n") | |
3005 | { | |
3006 | struct interface *ifp; | |
3007 | struct pim_interface *pim_ifp; | |
3008 | int query_max_response_time; | |
3009 | ||
3010 | ifp = vty->index; | |
3011 | pim_ifp = ifp->info; | |
3012 | ||
3013 | if (!pim_ifp) { | |
3014 | vty_out(vty, | |
3015 | "IGMP not enabled on interface %s. Please enable IGMP first.%s", | |
3016 | ifp->name, | |
3017 | VTY_NEWLINE); | |
3018 | return CMD_WARNING; | |
3019 | } | |
3020 | ||
3021 | query_max_response_time = atoi(argv[0]); | |
3022 | ||
3023 | /* | |
3024 | It seems we don't need to check bounds since command.c does it | |
3025 | already, but we verify them anyway for extra safety. | |
3026 | */ | |
3027 | if (query_max_response_time < IGMP_QUERY_MAX_RESPONSE_TIME_MIN) { | |
3028 | vty_out(vty, "Query max response time %d sec lower than minimum %d sec%s", | |
3029 | query_max_response_time, | |
3030 | IGMP_QUERY_MAX_RESPONSE_TIME_MIN, | |
3031 | VTY_NEWLINE); | |
3032 | return CMD_WARNING; | |
3033 | } | |
3034 | if (query_max_response_time > IGMP_QUERY_MAX_RESPONSE_TIME_MAX) { | |
3035 | vty_out(vty, "Query max response time %d sec higher than maximum %d sec%s", | |
3036 | query_max_response_time, | |
3037 | IGMP_QUERY_MAX_RESPONSE_TIME_MAX, | |
3038 | VTY_NEWLINE); | |
3039 | return CMD_WARNING; | |
3040 | } | |
3041 | ||
3042 | if (query_max_response_time >= pim_ifp->igmp_default_query_interval) { | |
3043 | vty_out(vty, | |
3044 | "Can't set query max response time %d sec >= general query interval %d sec%s", | |
3045 | query_max_response_time, pim_ifp->igmp_default_query_interval, | |
3046 | VTY_NEWLINE); | |
3047 | return CMD_WARNING; | |
3048 | } | |
3049 | ||
3050 | change_query_max_response_time(pim_ifp, 10 * query_max_response_time); | |
3051 | ||
3052 | return CMD_SUCCESS; | |
3053 | } | |
3054 | ||
3055 | DEFUN (interface_no_ip_igmp_query_max_response_time, | |
3056 | interface_no_ip_igmp_query_max_response_time_cmd, | |
3057 | PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME, | |
3058 | NO_STR | |
3059 | IP_STR | |
3060 | IFACE_IGMP_STR | |
3061 | IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR) | |
3062 | { | |
3063 | struct interface *ifp; | |
3064 | struct pim_interface *pim_ifp; | |
3065 | int default_query_interval_dsec; | |
3066 | ||
3067 | ifp = vty->index; | |
3068 | pim_ifp = ifp->info; | |
3069 | ||
3070 | if (!pim_ifp) | |
3071 | return CMD_SUCCESS; | |
3072 | ||
3073 | default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval; | |
3074 | ||
3075 | if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) { | |
3076 | vty_out(vty, | |
3077 | "Can't set default query max response time %d dsec >= general query interval %d dsec.%s", | |
3078 | IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec, | |
3079 | VTY_NEWLINE); | |
3080 | return CMD_WARNING; | |
3081 | } | |
3082 | ||
3083 | change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC); | |
3084 | ||
3085 | return CMD_SUCCESS; | |
3086 | } | |
3087 | ||
3088 | #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10) | |
3089 | #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250) | |
3090 | ||
3091 | DEFUN (interface_ip_igmp_query_max_response_time_dsec, | |
3092 | interface_ip_igmp_query_max_response_time_dsec_cmd, | |
3093 | PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>", | |
3094 | IP_STR | |
3095 | IFACE_IGMP_STR | |
3096 | IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR | |
3097 | "Query response value in deciseconds\n") | |
3098 | { | |
3099 | struct interface *ifp; | |
3100 | struct pim_interface *pim_ifp; | |
3101 | int query_max_response_time_dsec; | |
3102 | int default_query_interval_dsec; | |
3103 | ||
3104 | ifp = vty->index; | |
3105 | pim_ifp = ifp->info; | |
3106 | ||
3107 | if (!pim_ifp) { | |
3108 | vty_out(vty, | |
3109 | "IGMP not enabled on interface %s. Please enable IGMP first.%s", | |
3110 | ifp->name, | |
3111 | VTY_NEWLINE); | |
3112 | return CMD_WARNING; | |
3113 | } | |
3114 | ||
3115 | query_max_response_time_dsec = atoi(argv[0]); | |
3116 | ||
3117 | /* | |
3118 | It seems we don't need to check bounds since command.c does it | |
3119 | already, but we verify them anyway for extra safety. | |
3120 | */ | |
3121 | if (query_max_response_time_dsec < IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC) { | |
3122 | vty_out(vty, "Query max response time %d dsec lower than minimum %d dsec%s", | |
3123 | query_max_response_time_dsec, | |
3124 | IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC, | |
3125 | VTY_NEWLINE); | |
3126 | return CMD_WARNING; | |
3127 | } | |
3128 | if (query_max_response_time_dsec > IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC) { | |
3129 | vty_out(vty, "Query max response time %d dsec higher than maximum %d dsec%s", | |
3130 | query_max_response_time_dsec, | |
3131 | IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC, | |
3132 | VTY_NEWLINE); | |
3133 | return CMD_WARNING; | |
3134 | } | |
3135 | ||
3136 | default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval; | |
3137 | ||
3138 | if (query_max_response_time_dsec >= default_query_interval_dsec) { | |
3139 | vty_out(vty, | |
3140 | "Can't set query max response time %d dsec >= general query interval %d dsec%s", | |
3141 | query_max_response_time_dsec, default_query_interval_dsec, | |
3142 | VTY_NEWLINE); | |
3143 | return CMD_WARNING; | |
3144 | } | |
3145 | ||
3146 | change_query_max_response_time(pim_ifp, query_max_response_time_dsec); | |
3147 | ||
3148 | return CMD_SUCCESS; | |
3149 | } | |
3150 | ||
3151 | DEFUN (interface_no_ip_igmp_query_max_response_time_dsec, | |
3152 | interface_no_ip_igmp_query_max_response_time_dsec_cmd, | |
3153 | PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, | |
3154 | NO_STR | |
3155 | IP_STR | |
3156 | IFACE_IGMP_STR | |
3157 | IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR) | |
3158 | { | |
3159 | struct interface *ifp; | |
3160 | struct pim_interface *pim_ifp; | |
3161 | int default_query_interval_dsec; | |
3162 | ||
3163 | ifp = vty->index; | |
3164 | pim_ifp = ifp->info; | |
3165 | ||
3166 | if (!pim_ifp) | |
3167 | return CMD_SUCCESS; | |
3168 | ||
3169 | default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval; | |
3170 | ||
3171 | if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) { | |
3172 | vty_out(vty, | |
3173 | "Can't set default query max response time %d dsec >= general query interval %d dsec.%s", | |
3174 | IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec, | |
3175 | VTY_NEWLINE); | |
3176 | return CMD_WARNING; | |
3177 | } | |
3178 | ||
3179 | change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC); | |
3180 | ||
3181 | return CMD_SUCCESS; | |
3182 | } | |
3183 | ||
dedccda6 DS |
3184 | DEFUN (interface_ip_pim_drprio, |
3185 | interface_ip_pim_drprio_cmd, | |
3186 | "ip pim drpriority <1-4294967295>", | |
3187 | IP_STR | |
3188 | PIM_STR | |
3189 | "Set the Designated Router Election Priority\n" | |
3190 | "Value of the new DR Priority\n") | |
3191 | { | |
3192 | struct interface *ifp; | |
3193 | struct pim_interface *pim_ifp; | |
3194 | uint32_t old_dr_prio; | |
3195 | ||
3196 | ifp = vty->index; | |
3197 | pim_ifp = ifp->info; | |
3198 | ||
3199 | if (!pim_ifp) { | |
3200 | vty_out(vty, "Please enable PIM on interface, first%s", VTY_NEWLINE); | |
3201 | return CMD_WARNING; | |
3202 | } | |
3203 | ||
3204 | old_dr_prio = pim_ifp->pim_dr_priority; | |
3205 | ||
3206 | pim_ifp->pim_dr_priority = strtol(argv[0], NULL, 10); | |
3207 | ||
3208 | if (old_dr_prio != pim_ifp->pim_dr_priority) { | |
3209 | if (pim_if_dr_election(ifp)) | |
3210 | pim_hello_restart_now(ifp); | |
3211 | } | |
3212 | ||
3213 | return CMD_SUCCESS; | |
3214 | } | |
3215 | ||
3216 | DEFUN (interface_no_ip_pim_drprio, | |
3217 | interface_no_ip_pim_drprio_cmd, | |
3218 | "no ip pim drpriority {<1-4294967295>}", | |
3219 | IP_STR | |
3220 | PIM_STR | |
3221 | "Revert the Designated Router Priority to default\n" | |
3222 | "Old Value of the Priority\n") | |
3223 | { | |
3224 | struct interface *ifp; | |
3225 | struct pim_interface *pim_ifp; | |
3226 | ||
3227 | ifp = vty->index; | |
3228 | pim_ifp = ifp->info; | |
3229 | ||
3230 | if (!pim_ifp) { | |
7960fa8f | 3231 | vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE); |
dedccda6 DS |
3232 | return CMD_WARNING; |
3233 | } | |
3234 | ||
3235 | if (pim_ifp->pim_dr_priority != PIM_DEFAULT_DR_PRIORITY) { | |
3236 | pim_ifp->pim_dr_priority = PIM_DEFAULT_DR_PRIORITY; | |
3237 | if (pim_if_dr_election(ifp)) | |
3238 | pim_hello_restart_now(ifp); | |
3239 | } | |
3240 | ||
3241 | return CMD_SUCCESS; | |
3242 | } | |
3243 | ||
981d6c7a DS |
3244 | static int |
3245 | pim_cmd_interface_add (struct interface *ifp, enum pim_interface_type itype) | |
12e41d03 | 3246 | { |
981d6c7a | 3247 | struct pim_interface *pim_ifp = ifp->info; |
a920d6e7 | 3248 | struct in_addr null = { .s_addr = 0 }; |
12e41d03 DL |
3249 | |
3250 | if (!pim_ifp) { | |
3251 | pim_ifp = pim_if_new(ifp, 0 /* igmp=false */, 1 /* pim=true */); | |
3252 | if (!pim_ifp) { | |
981d6c7a | 3253 | return 0; |
12e41d03 DL |
3254 | } |
3255 | } | |
3256 | else { | |
3257 | PIM_IF_DO_PIM(pim_ifp->options); | |
3258 | } | |
3259 | ||
981d6c7a | 3260 | pim_ifp->itype = itype; |
12e41d03 DL |
3261 | pim_if_addr_add_all(ifp); |
3262 | pim_if_membership_refresh(ifp); | |
3263 | ||
a920d6e7 | 3264 | pim_rp_check_rp (null, pim_ifp->primary_address); |
981d6c7a DS |
3265 | return 1; |
3266 | } | |
3267 | ||
3268 | ||
3269 | DEFUN (interface_ip_pim_ssm, | |
3270 | interface_ip_pim_ssm_cmd, | |
3271 | "ip pim ssm", | |
3272 | IP_STR | |
3273 | PIM_STR | |
3274 | IFACE_PIM_STR) | |
3275 | { | |
3276 | struct interface *ifp; | |
3277 | ||
3278 | ifp = vty->index; | |
3279 | ||
3280 | if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SSM)) { | |
3281 | vty_out(vty, "Could not enable PIM SSM on interface%s", VTY_NEWLINE); | |
3282 | return CMD_WARNING; | |
3283 | } | |
3284 | ||
12e41d03 DL |
3285 | return CMD_SUCCESS; |
3286 | } | |
3287 | ||
981d6c7a DS |
3288 | DEFUN (interface_ip_pim_sm, |
3289 | interface_ip_pim_sm_cmd, | |
3290 | "ip pim sm", | |
12e41d03 DL |
3291 | IP_STR |
3292 | PIM_STR | |
8371bd60 | 3293 | IFACE_PIM_SM_STR) |
12e41d03 DL |
3294 | { |
3295 | struct interface *ifp; | |
12e41d03 DL |
3296 | |
3297 | ifp = vty->index; | |
981d6c7a DS |
3298 | if (!pim_cmd_interface_add(ifp, PIM_INTERFACE_SM)) { |
3299 | vty_out(vty, "Could not enable PIM SM on interface%s", VTY_NEWLINE); | |
3300 | return CMD_WARNING; | |
3301 | } | |
3302 | ||
c992c9a0 DS |
3303 | pim_if_create_pimreg(); |
3304 | ||
981d6c7a DS |
3305 | return CMD_SUCCESS; |
3306 | } | |
3307 | ||
3308 | static int | |
3309 | pim_cmd_interface_delete (struct interface *ifp) | |
3310 | { | |
3311 | struct pim_interface *pim_ifp = ifp->info; | |
3312 | ||
12e41d03 | 3313 | if (!pim_ifp) |
981d6c7a | 3314 | return 1; |
12e41d03 DL |
3315 | |
3316 | PIM_IF_DONT_PIM(pim_ifp->options); | |
3317 | ||
3318 | pim_if_membership_clear(ifp); | |
3319 | ||
3320 | /* | |
3321 | pim_if_addr_del_all() removes all sockets from | |
3322 | pim_ifp->igmp_socket_list. | |
3323 | */ | |
3324 | pim_if_addr_del_all(ifp); | |
3325 | ||
3326 | /* | |
3327 | pim_sock_delete() removes all neighbors from | |
3328 | pim_ifp->pim_neighbor_list. | |
3329 | */ | |
3330 | pim_sock_delete(ifp, "pim unconfigured on interface"); | |
3331 | ||
3332 | if (!PIM_IF_TEST_IGMP(pim_ifp->options)) { | |
3333 | pim_if_delete(ifp); | |
3334 | } | |
3335 | ||
981d6c7a DS |
3336 | return 1; |
3337 | } | |
3338 | ||
3339 | DEFUN (interface_no_ip_pim_ssm, | |
3340 | interface_no_ip_pim_ssm_cmd, | |
3341 | "no ip pim ssm", | |
3342 | NO_STR | |
3343 | IP_STR | |
3344 | PIM_STR | |
3345 | IFACE_PIM_STR) | |
3346 | { | |
3347 | struct interface *ifp; | |
3348 | ||
3349 | ifp = vty->index; | |
3350 | if (!pim_cmd_interface_delete(ifp)) { | |
3351 | vty_out(vty, "Unable to delete interface information%s", VTY_NEWLINE); | |
3352 | return CMD_WARNING; | |
3353 | } | |
3354 | ||
3355 | return CMD_SUCCESS; | |
3356 | } | |
3357 | ||
3358 | DEFUN (interface_no_ip_pim_sm, | |
3359 | interface_no_ip_pim_sm_cmd, | |
3360 | "no ip pim sm", | |
3361 | NO_STR | |
3362 | IP_STR | |
3363 | PIM_STR | |
8371bd60 | 3364 | IFACE_PIM_SM_STR) |
981d6c7a DS |
3365 | { |
3366 | struct interface *ifp; | |
3367 | ||
3368 | ifp = vty->index; | |
3369 | if (!pim_cmd_interface_delete(ifp)) { | |
3370 | vty_out(vty, "Unable to delete interface information%s", VTY_NEWLINE); | |
3371 | return CMD_WARNING; | |
3372 | } | |
3373 | ||
12e41d03 DL |
3374 | return CMD_SUCCESS; |
3375 | } | |
3376 | ||
6250610a JAG |
3377 | DEFUN (interface_ip_mroute, |
3378 | interface_ip_mroute_cmd, | |
3379 | "ip mroute INTERFACE A.B.C.D", | |
3380 | IP_STR | |
3381 | "Add multicast route\n" | |
3382 | "Outgoing interface name\n" | |
3383 | "Group address\n") | |
3384 | { | |
3385 | struct interface *iif; | |
3386 | struct interface *oif; | |
3387 | const char *oifname; | |
3388 | const char *grp_str; | |
3389 | struct in_addr grp_addr; | |
3390 | struct in_addr src_addr; | |
3391 | int result; | |
3392 | ||
3393 | iif = vty->index; | |
3394 | ||
3395 | oifname = argv[0]; | |
3396 | oif = if_lookup_by_name(oifname); | |
3397 | if (!oif) { | |
3398 | vty_out(vty, "No such interface name %s%s", | |
3399 | oifname, VTY_NEWLINE); | |
3400 | return CMD_WARNING; | |
3401 | } | |
3402 | ||
3403 | grp_str = argv[1]; | |
3404 | result = inet_pton(AF_INET, grp_str, &grp_addr); | |
3405 | if (result <= 0) { | |
3406 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
3407 | grp_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
3408 | return CMD_WARNING; | |
3409 | } | |
3410 | ||
3411 | src_addr.s_addr = INADDR_ANY; | |
3412 | ||
3413 | if (pim_static_add(iif, oif, grp_addr, src_addr)) { | |
3414 | vty_out(vty, "Failed to add route%s", VTY_NEWLINE); | |
3415 | return CMD_WARNING; | |
3416 | } | |
3417 | ||
3418 | return CMD_SUCCESS; | |
3419 | } | |
3420 | ||
3421 | DEFUN (interface_ip_mroute_source, | |
3422 | interface_ip_mroute_source_cmd, | |
3423 | "ip mroute INTERFACE A.B.C.D A.B.C.D", | |
3424 | IP_STR | |
3425 | "Add multicast route\n" | |
3426 | "Outgoing interface name\n" | |
3427 | "Group address\n" | |
3428 | "Source address\n") | |
3429 | { | |
3430 | struct interface *iif; | |
3431 | struct interface *oif; | |
3432 | const char *oifname; | |
3433 | const char *grp_str; | |
3434 | struct in_addr grp_addr; | |
3435 | const char *src_str; | |
3436 | struct in_addr src_addr; | |
3437 | int result; | |
3438 | ||
3439 | iif = vty->index; | |
3440 | ||
3441 | oifname = argv[0]; | |
3442 | oif = if_lookup_by_name(oifname); | |
3443 | if (!oif) { | |
3444 | vty_out(vty, "No such interface name %s%s", | |
3445 | oifname, VTY_NEWLINE); | |
3446 | return CMD_WARNING; | |
3447 | } | |
3448 | ||
3449 | grp_str = argv[1]; | |
3450 | result = inet_pton(AF_INET, grp_str, &grp_addr); | |
3451 | if (result <= 0) { | |
3452 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
3453 | grp_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
3454 | return CMD_WARNING; | |
3455 | } | |
3456 | ||
3457 | src_str = argv[2]; | |
3458 | result = inet_pton(AF_INET, src_str, &src_addr); | |
3459 | if (result <= 0) { | |
3460 | vty_out(vty, "Bad source address %s: errno=%d: %s%s", | |
3461 | src_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
3462 | return CMD_WARNING; | |
3463 | } | |
3464 | ||
3465 | if (pim_static_add(iif, oif, grp_addr, src_addr)) { | |
3466 | vty_out(vty, "Failed to add route%s", VTY_NEWLINE); | |
3467 | return CMD_WARNING; | |
3468 | } | |
3469 | ||
3470 | return CMD_SUCCESS; | |
3471 | } | |
3472 | ||
3473 | DEFUN (interface_no_ip_mroute, | |
3474 | interface_no_ip_mroute_cmd, | |
3475 | "no ip mroute INTERFACE A.B.C.D", | |
3476 | NO_STR | |
3477 | IP_STR | |
3478 | "Add multicast route\n" | |
3479 | "Outgoing interface name\n" | |
3480 | "Group Address\n") | |
3481 | { | |
3482 | struct interface *iif; | |
3483 | struct interface *oif; | |
3484 | const char *oifname; | |
3485 | const char *grp_str; | |
3486 | struct in_addr grp_addr; | |
3487 | struct in_addr src_addr; | |
3488 | int result; | |
3489 | ||
3490 | iif = vty->index; | |
3491 | ||
3492 | oifname = argv[0]; | |
3493 | oif = if_lookup_by_name(oifname); | |
3494 | if (!oif) { | |
3495 | vty_out(vty, "No such interface name %s%s", | |
3496 | oifname, VTY_NEWLINE); | |
3497 | return CMD_WARNING; | |
3498 | } | |
3499 | ||
3500 | grp_str = argv[1]; | |
3501 | result = inet_pton(AF_INET, grp_str, &grp_addr); | |
3502 | if (result <= 0) { | |
3503 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
3504 | grp_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
3505 | return CMD_WARNING; | |
3506 | } | |
3507 | ||
3508 | src_addr.s_addr = INADDR_ANY; | |
3509 | ||
3510 | if (pim_static_del(iif, oif, grp_addr, src_addr)) { | |
3511 | vty_out(vty, "Failed to remove route%s", VTY_NEWLINE); | |
3512 | return CMD_WARNING; | |
3513 | } | |
3514 | ||
3515 | return CMD_SUCCESS; | |
3516 | } | |
3517 | ||
3518 | DEFUN (interface_no_ip_mroute_source, | |
3519 | interface_no_ip_mroute_source_cmd, | |
3520 | "no ip mroute INTERFACE A.B.C.D A.B.C.D", | |
3521 | NO_STR | |
3522 | IP_STR | |
3523 | "Add multicast route\n" | |
3524 | "Outgoing interface name\n" | |
3525 | "Group Address\n" | |
3526 | "Source Address\n") | |
3527 | { | |
3528 | struct interface *iif; | |
3529 | struct interface *oif; | |
3530 | const char *oifname; | |
3531 | const char *grp_str; | |
3532 | struct in_addr grp_addr; | |
3533 | const char *src_str; | |
3534 | struct in_addr src_addr; | |
3535 | int result; | |
3536 | ||
3537 | iif = vty->index; | |
3538 | ||
3539 | oifname = argv[0]; | |
3540 | oif = if_lookup_by_name(oifname); | |
3541 | if (!oif) { | |
3542 | vty_out(vty, "No such interface name %s%s", | |
3543 | oifname, VTY_NEWLINE); | |
3544 | return CMD_WARNING; | |
3545 | } | |
3546 | ||
3547 | grp_str = argv[1]; | |
3548 | result = inet_pton(AF_INET, grp_str, &grp_addr); | |
3549 | if (result <= 0) { | |
3550 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
3551 | grp_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
3552 | return CMD_WARNING; | |
3553 | } | |
3554 | ||
3555 | src_str = argv[2]; | |
3556 | result = inet_pton(AF_INET, src_str, &src_addr); | |
3557 | if (result <= 0) { | |
3558 | vty_out(vty, "Bad source address %s: errno=%d: %s%s", | |
3559 | src_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
3560 | return CMD_WARNING; | |
3561 | } | |
3562 | ||
3563 | if (pim_static_del(iif, oif, grp_addr, src_addr)) { | |
3564 | vty_out(vty, "Failed to remove route%s", VTY_NEWLINE); | |
3565 | return CMD_WARNING; | |
3566 | } | |
3567 | ||
3568 | return CMD_SUCCESS; | |
3569 | } | |
3570 | ||
7960fa8f DS |
3571 | DEFUN (interface_ip_pim_hello, |
3572 | interface_ip_pim_hello_cmd, | |
3573 | "ip pim hello <1-180>", | |
3574 | IP_STR | |
3575 | PIM_STR | |
3576 | IFACE_PIM_HELLO_STR | |
3577 | IFACE_PIM_HELLO_TIME_STR) | |
3578 | { | |
3579 | struct interface *ifp; | |
3580 | struct pim_interface *pim_ifp; | |
3581 | ||
3582 | ifp = vty->index; | |
3583 | pim_ifp = ifp->info; | |
3584 | ||
3585 | if (!pim_ifp) { | |
3586 | vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE); | |
3587 | return CMD_WARNING; | |
3588 | } | |
3589 | ||
3590 | pim_ifp->pim_hello_period = strtol(argv[0], NULL, 10); | |
3591 | ||
3592 | if (argc == 2) | |
3593 | pim_ifp->pim_default_holdtime = strtol(argv[1], NULL, 10); | |
3594 | ||
3595 | return CMD_SUCCESS; | |
3596 | } | |
3597 | ||
3598 | ALIAS (interface_ip_pim_hello, | |
3599 | interface_ip_pim_hello_hold_cmd, | |
3600 | "ip pim hello <1-180> <1-180>", | |
3601 | IP_STR | |
3602 | PIM_STR | |
3603 | IFACE_PIM_HELLO_STR | |
3604 | IFACE_PIM_HELLO_TIME_STR | |
3605 | IFACE_PIM_HELLO_HOLD_STR) | |
3606 | ||
3607 | ||
3608 | DEFUN (interface_no_ip_pim_hello, | |
3609 | interface_no_ip_pim_hello_cmd, | |
3610 | "no ip pim hello {<1-180> <1-180>}", | |
3611 | NO_STR | |
3612 | IP_STR | |
3613 | PIM_STR | |
3614 | IFACE_PIM_HELLO_STR | |
3615 | IFACE_PIM_HELLO_TIME_STR | |
3616 | IFACE_PIM_HELLO_HOLD_STR) | |
3617 | { | |
3618 | struct interface *ifp; | |
3619 | struct pim_interface *pim_ifp; | |
3620 | ||
3621 | ifp = vty->index; | |
3622 | pim_ifp = ifp->info; | |
3623 | ||
3624 | if (!pim_ifp) { | |
3625 | vty_out(vty, "Pim not enabled on this interface%s", VTY_NEWLINE); | |
3626 | return CMD_WARNING; | |
3627 | } | |
3628 | ||
3629 | pim_ifp->pim_hello_period = PIM_DEFAULT_HELLO_PERIOD; | |
3630 | pim_ifp->pim_default_holdtime = -1; | |
3631 | ||
3632 | return CMD_SUCCESS; | |
3633 | } | |
3634 | ||
12e41d03 DL |
3635 | DEFUN (debug_igmp, |
3636 | debug_igmp_cmd, | |
3637 | "debug igmp", | |
3638 | DEBUG_STR | |
3639 | DEBUG_IGMP_STR) | |
3640 | { | |
3641 | PIM_DO_DEBUG_IGMP_EVENTS; | |
3642 | PIM_DO_DEBUG_IGMP_PACKETS; | |
3643 | PIM_DO_DEBUG_IGMP_TRACE; | |
3644 | return CMD_SUCCESS; | |
3645 | } | |
3646 | ||
3647 | DEFUN (no_debug_igmp, | |
3648 | no_debug_igmp_cmd, | |
3649 | "no debug igmp", | |
3650 | NO_STR | |
3651 | DEBUG_STR | |
3652 | DEBUG_IGMP_STR) | |
3653 | { | |
3654 | PIM_DONT_DEBUG_IGMP_EVENTS; | |
3655 | PIM_DONT_DEBUG_IGMP_PACKETS; | |
3656 | PIM_DONT_DEBUG_IGMP_TRACE; | |
3657 | return CMD_SUCCESS; | |
3658 | } | |
3659 | ||
3660 | ALIAS (no_debug_igmp, | |
3661 | undebug_igmp_cmd, | |
3662 | "undebug igmp", | |
3663 | UNDEBUG_STR | |
3664 | DEBUG_IGMP_STR) | |
3665 | ||
3666 | DEFUN (debug_igmp_events, | |
3667 | debug_igmp_events_cmd, | |
3668 | "debug igmp events", | |
3669 | DEBUG_STR | |
3670 | DEBUG_IGMP_STR | |
3671 | DEBUG_IGMP_EVENTS_STR) | |
3672 | { | |
3673 | PIM_DO_DEBUG_IGMP_EVENTS; | |
3674 | return CMD_SUCCESS; | |
3675 | } | |
3676 | ||
3677 | DEFUN (no_debug_igmp_events, | |
3678 | no_debug_igmp_events_cmd, | |
3679 | "no debug igmp events", | |
3680 | NO_STR | |
3681 | DEBUG_STR | |
3682 | DEBUG_IGMP_STR | |
3683 | DEBUG_IGMP_EVENTS_STR) | |
3684 | { | |
3685 | PIM_DONT_DEBUG_IGMP_EVENTS; | |
3686 | return CMD_SUCCESS; | |
3687 | } | |
3688 | ||
3689 | ALIAS (no_debug_igmp_events, | |
3690 | undebug_igmp_events_cmd, | |
3691 | "undebug igmp events", | |
3692 | UNDEBUG_STR | |
3693 | DEBUG_IGMP_STR | |
3694 | DEBUG_IGMP_EVENTS_STR) | |
3695 | ||
3696 | DEFUN (debug_igmp_packets, | |
3697 | debug_igmp_packets_cmd, | |
3698 | "debug igmp packets", | |
3699 | DEBUG_STR | |
3700 | DEBUG_IGMP_STR | |
3701 | DEBUG_IGMP_PACKETS_STR) | |
3702 | { | |
3703 | PIM_DO_DEBUG_IGMP_PACKETS; | |
3704 | return CMD_SUCCESS; | |
3705 | } | |
3706 | ||
3707 | DEFUN (no_debug_igmp_packets, | |
3708 | no_debug_igmp_packets_cmd, | |
3709 | "no debug igmp packets", | |
3710 | NO_STR | |
3711 | DEBUG_STR | |
3712 | DEBUG_IGMP_STR | |
3713 | DEBUG_IGMP_PACKETS_STR) | |
3714 | { | |
3715 | PIM_DONT_DEBUG_IGMP_PACKETS; | |
3716 | return CMD_SUCCESS; | |
3717 | } | |
3718 | ||
3719 | ALIAS (no_debug_igmp_packets, | |
3720 | undebug_igmp_packets_cmd, | |
3721 | "undebug igmp packets", | |
3722 | UNDEBUG_STR | |
3723 | DEBUG_IGMP_STR | |
3724 | DEBUG_IGMP_PACKETS_STR) | |
3725 | ||
3726 | DEFUN (debug_igmp_trace, | |
3727 | debug_igmp_trace_cmd, | |
3728 | "debug igmp trace", | |
3729 | DEBUG_STR | |
3730 | DEBUG_IGMP_STR | |
3731 | DEBUG_IGMP_TRACE_STR) | |
3732 | { | |
3733 | PIM_DO_DEBUG_IGMP_TRACE; | |
3734 | return CMD_SUCCESS; | |
3735 | } | |
3736 | ||
3737 | DEFUN (no_debug_igmp_trace, | |
3738 | no_debug_igmp_trace_cmd, | |
3739 | "no debug igmp trace", | |
3740 | NO_STR | |
3741 | DEBUG_STR | |
3742 | DEBUG_IGMP_STR | |
3743 | DEBUG_IGMP_TRACE_STR) | |
3744 | { | |
3745 | PIM_DONT_DEBUG_IGMP_TRACE; | |
3746 | return CMD_SUCCESS; | |
3747 | } | |
3748 | ||
3749 | ALIAS (no_debug_igmp_trace, | |
3750 | undebug_igmp_trace_cmd, | |
3751 | "undebug igmp trace", | |
3752 | UNDEBUG_STR | |
3753 | DEBUG_IGMP_STR | |
3754 | DEBUG_IGMP_TRACE_STR) | |
3755 | ||
3756 | DEFUN (debug_mroute, | |
3757 | debug_mroute_cmd, | |
3758 | "debug mroute", | |
3759 | DEBUG_STR | |
3760 | DEBUG_MROUTE_STR) | |
3761 | { | |
3762 | PIM_DO_DEBUG_MROUTE; | |
3763 | return CMD_SUCCESS; | |
3764 | } | |
3765 | ||
3766 | DEFUN (no_debug_mroute, | |
3767 | no_debug_mroute_cmd, | |
3768 | "no debug mroute", | |
3769 | NO_STR | |
3770 | DEBUG_STR | |
3771 | DEBUG_MROUTE_STR) | |
3772 | { | |
3773 | PIM_DONT_DEBUG_MROUTE; | |
3774 | return CMD_SUCCESS; | |
3775 | } | |
3776 | ||
3777 | ALIAS (no_debug_mroute, | |
3778 | undebug_mroute_cmd, | |
3779 | "undebug mroute", | |
3780 | UNDEBUG_STR | |
3781 | DEBUG_MROUTE_STR) | |
3782 | ||
6250610a JAG |
3783 | DEFUN (debug_static, |
3784 | debug_static_cmd, | |
3785 | "debug static", | |
3786 | DEBUG_STR | |
3787 | DEBUG_STATIC_STR) | |
3788 | { | |
3789 | PIM_DO_DEBUG_STATIC; | |
3790 | return CMD_SUCCESS; | |
3791 | } | |
3792 | ||
3793 | DEFUN (no_debug_static, | |
3794 | no_debug_static_cmd, | |
3795 | "no debug static", | |
3796 | NO_STR | |
3797 | DEBUG_STR | |
3798 | DEBUG_STATIC_STR) | |
3799 | { | |
3800 | PIM_DONT_DEBUG_STATIC; | |
3801 | return CMD_SUCCESS; | |
3802 | } | |
3803 | ||
3804 | ALIAS (no_debug_static, | |
3805 | undebug_static_cmd, | |
3806 | "undebug static", | |
3807 | UNDEBUG_STR | |
3808 | DEBUG_STATIC_STR) | |
3809 | ||
12e41d03 DL |
3810 | DEFUN (debug_pim, |
3811 | debug_pim_cmd, | |
3812 | "debug pim", | |
3813 | DEBUG_STR | |
3814 | DEBUG_PIM_STR) | |
3815 | { | |
3816 | PIM_DO_DEBUG_PIM_EVENTS; | |
3817 | PIM_DO_DEBUG_PIM_PACKETS; | |
3818 | PIM_DO_DEBUG_PIM_TRACE; | |
3819 | return CMD_SUCCESS; | |
3820 | } | |
3821 | ||
3822 | DEFUN (no_debug_pim, | |
3823 | no_debug_pim_cmd, | |
3824 | "no debug pim", | |
3825 | NO_STR | |
3826 | DEBUG_STR | |
3827 | DEBUG_PIM_STR) | |
3828 | { | |
3829 | PIM_DONT_DEBUG_PIM_EVENTS; | |
3830 | PIM_DONT_DEBUG_PIM_PACKETS; | |
3831 | PIM_DONT_DEBUG_PIM_TRACE; | |
3832 | ||
3833 | PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND; | |
3834 | PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV; | |
3835 | ||
3836 | return CMD_SUCCESS; | |
3837 | } | |
3838 | ||
3839 | ALIAS (no_debug_pim, | |
3840 | undebug_pim_cmd, | |
3841 | "undebug pim", | |
3842 | UNDEBUG_STR | |
3843 | DEBUG_PIM_STR) | |
3844 | ||
3845 | DEFUN (debug_pim_events, | |
3846 | debug_pim_events_cmd, | |
3847 | "debug pim events", | |
3848 | DEBUG_STR | |
3849 | DEBUG_PIM_STR | |
3850 | DEBUG_PIM_EVENTS_STR) | |
3851 | { | |
3852 | PIM_DO_DEBUG_PIM_EVENTS; | |
3853 | return CMD_SUCCESS; | |
3854 | } | |
3855 | ||
3856 | DEFUN (no_debug_pim_events, | |
3857 | no_debug_pim_events_cmd, | |
3858 | "no debug pim events", | |
3859 | NO_STR | |
3860 | DEBUG_STR | |
3861 | DEBUG_PIM_STR | |
3862 | DEBUG_PIM_EVENTS_STR) | |
3863 | { | |
3864 | PIM_DONT_DEBUG_PIM_EVENTS; | |
3865 | return CMD_SUCCESS; | |
3866 | } | |
3867 | ||
3868 | ALIAS (no_debug_pim_events, | |
3869 | undebug_pim_events_cmd, | |
3870 | "undebug pim events", | |
3871 | UNDEBUG_STR | |
3872 | DEBUG_PIM_STR | |
3873 | DEBUG_PIM_EVENTS_STR) | |
3874 | ||
3875 | DEFUN (debug_pim_packets, | |
3876 | debug_pim_packets_cmd, | |
3877 | "debug pim packets", | |
3878 | DEBUG_STR | |
3879 | DEBUG_PIM_STR | |
3880 | DEBUG_PIM_PACKETS_STR) | |
3881 | { | |
3882 | PIM_DO_DEBUG_PIM_PACKETS; | |
3883 | vty_out (vty, "PIM Packet debugging is on %s", VTY_NEWLINE); | |
3884 | return CMD_SUCCESS; | |
3885 | } | |
3886 | ||
3887 | DEFUN (debug_pim_packets_filter, | |
3888 | debug_pim_packets_filter_cmd, | |
3889 | "debug pim packets (hello|joins)", | |
3890 | DEBUG_STR | |
3891 | DEBUG_PIM_STR | |
3892 | DEBUG_PIM_PACKETS_STR | |
3893 | DEBUG_PIM_HELLO_PACKETS_STR | |
3894 | DEBUG_PIM_J_P_PACKETS_STR) | |
3895 | { | |
3896 | if (strncmp(argv[0],"h",1) == 0) | |
3897 | { | |
3898 | PIM_DO_DEBUG_PIM_HELLO; | |
3899 | vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE); | |
3900 | } | |
3901 | else if (strncmp(argv[0],"j",1) == 0) | |
3902 | { | |
3903 | PIM_DO_DEBUG_PIM_J_P; | |
3904 | vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE); | |
3905 | } | |
3906 | return CMD_SUCCESS; | |
3907 | } | |
3908 | ||
3909 | DEFUN (no_debug_pim_packets, | |
3910 | no_debug_pim_packets_cmd, | |
3911 | "no debug pim packets", | |
3912 | NO_STR | |
3913 | DEBUG_STR | |
3914 | DEBUG_PIM_STR | |
3915 | DEBUG_PIM_PACKETS_STR | |
3916 | DEBUG_PIM_HELLO_PACKETS_STR | |
3917 | DEBUG_PIM_J_P_PACKETS_STR) | |
3918 | { | |
3919 | PIM_DONT_DEBUG_PIM_PACKETS; | |
3920 | vty_out (vty, "PIM Packet debugging is off %s", VTY_NEWLINE); | |
3921 | return CMD_SUCCESS; | |
3922 | } | |
3923 | ||
3924 | DEFUN (no_debug_pim_packets_filter, | |
3925 | no_debug_pim_packets_filter_cmd, | |
3926 | "no debug pim packets (hello|joins)", | |
3927 | NO_STR | |
3928 | DEBUG_STR | |
3929 | DEBUG_PIM_STR | |
3930 | DEBUG_PIM_PACKETS_STR | |
3931 | DEBUG_PIM_HELLO_PACKETS_STR | |
3932 | DEBUG_PIM_J_P_PACKETS_STR) | |
3933 | { | |
3934 | if (strncmp(argv[0],"h",1) == 0) | |
3935 | { | |
3936 | PIM_DONT_DEBUG_PIM_HELLO; | |
3937 | vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE); | |
3938 | } | |
3939 | else if (strncmp(argv[0],"j",1) == 0) | |
3940 | { | |
3941 | PIM_DONT_DEBUG_PIM_J_P; | |
3942 | vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE); | |
3943 | } | |
3944 | return CMD_SUCCESS; | |
3945 | } | |
3946 | ||
3947 | ALIAS (no_debug_pim_packets, | |
3948 | undebug_pim_packets_cmd, | |
3949 | "undebug pim packets", | |
3950 | UNDEBUG_STR | |
3951 | DEBUG_PIM_STR | |
3952 | DEBUG_PIM_PACKETS_STR) | |
3953 | ||
3954 | DEFUN (debug_pim_packetdump_send, | |
3955 | debug_pim_packetdump_send_cmd, | |
3956 | "debug pim packet-dump send", | |
3957 | DEBUG_STR | |
3958 | DEBUG_PIM_STR | |
3959 | DEBUG_PIM_PACKETDUMP_STR | |
3960 | DEBUG_PIM_PACKETDUMP_SEND_STR) | |
3961 | { | |
3962 | PIM_DO_DEBUG_PIM_PACKETDUMP_SEND; | |
3963 | return CMD_SUCCESS; | |
3964 | } | |
3965 | ||
3966 | DEFUN (no_debug_pim_packetdump_send, | |
3967 | no_debug_pim_packetdump_send_cmd, | |
3968 | "no debug pim packet-dump send", | |
3969 | NO_STR | |
3970 | DEBUG_STR | |
3971 | DEBUG_PIM_STR | |
3972 | DEBUG_PIM_PACKETDUMP_STR | |
3973 | DEBUG_PIM_PACKETDUMP_SEND_STR) | |
3974 | { | |
3975 | PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND; | |
3976 | return CMD_SUCCESS; | |
3977 | } | |
3978 | ||
3979 | ALIAS (no_debug_pim_packetdump_send, | |
3980 | undebug_pim_packetdump_send_cmd, | |
3981 | "undebug pim packet-dump send", | |
3982 | UNDEBUG_STR | |
3983 | DEBUG_PIM_STR | |
3984 | DEBUG_PIM_PACKETDUMP_STR | |
3985 | DEBUG_PIM_PACKETDUMP_SEND_STR) | |
3986 | ||
3987 | DEFUN (debug_pim_packetdump_recv, | |
3988 | debug_pim_packetdump_recv_cmd, | |
3989 | "debug pim packet-dump receive", | |
3990 | DEBUG_STR | |
3991 | DEBUG_PIM_STR | |
3992 | DEBUG_PIM_PACKETDUMP_STR | |
3993 | DEBUG_PIM_PACKETDUMP_RECV_STR) | |
3994 | { | |
3995 | PIM_DO_DEBUG_PIM_PACKETDUMP_RECV; | |
3996 | return CMD_SUCCESS; | |
3997 | } | |
3998 | ||
3999 | DEFUN (no_debug_pim_packetdump_recv, | |
4000 | no_debug_pim_packetdump_recv_cmd, | |
4001 | "no debug pim packet-dump receive", | |
4002 | NO_STR | |
4003 | DEBUG_STR | |
4004 | DEBUG_PIM_STR | |
4005 | DEBUG_PIM_PACKETDUMP_STR | |
4006 | DEBUG_PIM_PACKETDUMP_RECV_STR) | |
4007 | { | |
4008 | PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV; | |
4009 | return CMD_SUCCESS; | |
4010 | } | |
4011 | ||
4012 | ALIAS (no_debug_pim_packetdump_recv, | |
4013 | undebug_pim_packetdump_recv_cmd, | |
4014 | "undebug pim packet-dump receive", | |
4015 | UNDEBUG_STR | |
4016 | DEBUG_PIM_STR | |
4017 | DEBUG_PIM_PACKETDUMP_STR | |
4018 | DEBUG_PIM_PACKETDUMP_RECV_STR) | |
4019 | ||
4020 | DEFUN (debug_pim_trace, | |
4021 | debug_pim_trace_cmd, | |
4022 | "debug pim trace", | |
4023 | DEBUG_STR | |
4024 | DEBUG_PIM_STR | |
4025 | DEBUG_PIM_TRACE_STR) | |
4026 | { | |
4027 | PIM_DO_DEBUG_PIM_TRACE; | |
4028 | return CMD_SUCCESS; | |
4029 | } | |
4030 | ||
4031 | DEFUN (no_debug_pim_trace, | |
4032 | no_debug_pim_trace_cmd, | |
4033 | "no debug pim trace", | |
4034 | NO_STR | |
4035 | DEBUG_STR | |
4036 | DEBUG_PIM_STR | |
4037 | DEBUG_PIM_TRACE_STR) | |
4038 | { | |
4039 | PIM_DONT_DEBUG_PIM_TRACE; | |
4040 | return CMD_SUCCESS; | |
4041 | } | |
4042 | ||
4043 | ALIAS (no_debug_pim_trace, | |
4044 | undebug_pim_trace_cmd, | |
4045 | "undebug pim trace", | |
4046 | UNDEBUG_STR | |
4047 | DEBUG_PIM_STR | |
4048 | DEBUG_PIM_TRACE_STR) | |
4049 | ||
4050 | DEFUN (debug_ssmpingd, | |
4051 | debug_ssmpingd_cmd, | |
4052 | "debug ssmpingd", | |
4053 | DEBUG_STR | |
4054 | DEBUG_PIM_STR | |
4055 | DEBUG_SSMPINGD_STR) | |
4056 | { | |
4057 | PIM_DO_DEBUG_SSMPINGD; | |
4058 | return CMD_SUCCESS; | |
4059 | } | |
4060 | ||
4061 | DEFUN (no_debug_ssmpingd, | |
4062 | no_debug_ssmpingd_cmd, | |
4063 | "no debug ssmpingd", | |
4064 | NO_STR | |
4065 | DEBUG_STR | |
4066 | DEBUG_PIM_STR | |
4067 | DEBUG_SSMPINGD_STR) | |
4068 | { | |
4069 | PIM_DONT_DEBUG_SSMPINGD; | |
4070 | return CMD_SUCCESS; | |
4071 | } | |
4072 | ||
4073 | ALIAS (no_debug_ssmpingd, | |
4074 | undebug_ssmpingd_cmd, | |
4075 | "undebug ssmpingd", | |
4076 | UNDEBUG_STR | |
4077 | DEBUG_PIM_STR | |
4078 | DEBUG_SSMPINGD_STR) | |
4079 | ||
4080 | DEFUN (debug_pim_zebra, | |
4081 | debug_pim_zebra_cmd, | |
4082 | "debug pim zebra", | |
4083 | DEBUG_STR | |
4084 | DEBUG_PIM_STR | |
4085 | DEBUG_PIM_ZEBRA_STR) | |
4086 | { | |
4087 | PIM_DO_DEBUG_ZEBRA; | |
4088 | return CMD_SUCCESS; | |
4089 | } | |
4090 | ||
4091 | DEFUN (no_debug_pim_zebra, | |
4092 | no_debug_pim_zebra_cmd, | |
4093 | "no debug pim zebra", | |
4094 | NO_STR | |
4095 | DEBUG_STR | |
4096 | DEBUG_PIM_STR | |
4097 | DEBUG_PIM_ZEBRA_STR) | |
4098 | { | |
4099 | PIM_DONT_DEBUG_ZEBRA; | |
4100 | return CMD_SUCCESS; | |
4101 | } | |
4102 | ||
4103 | ALIAS (no_debug_pim_zebra, | |
4104 | undebug_pim_zebra_cmd, | |
4105 | "undebug pim zebra", | |
4106 | UNDEBUG_STR | |
4107 | DEBUG_PIM_STR | |
4108 | DEBUG_PIM_ZEBRA_STR) | |
4109 | ||
7a1d58ce DS |
4110 | DEFUN (show_debugging_pim, |
4111 | show_debugging_pim_cmd, | |
4112 | "show debugging pim", | |
12e41d03 | 4113 | SHOW_STR |
7a1d58ce DS |
4114 | DEBUG_STR |
4115 | PIM_STR) | |
12e41d03 DL |
4116 | { |
4117 | pim_debug_config_write(vty); | |
4118 | return CMD_SUCCESS; | |
4119 | } | |
4120 | ||
4121 | static struct igmp_sock *find_igmp_sock_by_fd(int fd) | |
4122 | { | |
4123 | struct listnode *ifnode; | |
4124 | struct interface *ifp; | |
4125 | ||
4126 | /* scan all interfaces */ | |
469351b3 | 4127 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) { |
12e41d03 DL |
4128 | struct pim_interface *pim_ifp; |
4129 | struct igmp_sock *igmp; | |
4130 | ||
4131 | if (!ifp->info) | |
4132 | continue; | |
4133 | ||
4134 | pim_ifp = ifp->info; | |
4135 | ||
4136 | /* lookup igmp socket under current interface */ | |
4137 | igmp = igmp_sock_lookup_by_fd(pim_ifp->igmp_socket_list, fd); | |
4138 | if (igmp) | |
4139 | return igmp; | |
4140 | } | |
4141 | ||
4142 | return 0; | |
4143 | } | |
4144 | ||
4145 | DEFUN (test_igmp_receive_report, | |
4146 | test_igmp_receive_report_cmd, | |
4147 | "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE", | |
4148 | "Test\n" | |
4149 | "Test IGMP protocol\n" | |
4150 | "Test IGMP message\n" | |
4151 | "Test IGMP report\n" | |
4152 | "Socket\n" | |
4153 | "IGMP group address\n" | |
4154 | "Record type\n" | |
4155 | "Sources\n") | |
4156 | { | |
4157 | char buf[1000]; | |
4158 | char *igmp_msg; | |
4159 | struct ip *ip_hdr; | |
4160 | size_t ip_hlen; /* ip header length in bytes */ | |
4161 | int ip_msg_len; | |
4162 | int igmp_msg_len; | |
4163 | const char *socket; | |
4164 | int socket_fd; | |
4165 | const char *grp_str; | |
4166 | struct in_addr grp_addr; | |
4167 | const char *record_type_str; | |
4168 | int record_type; | |
4169 | const char *src_str; | |
4170 | int result; | |
4171 | struct igmp_sock *igmp; | |
4172 | char *group_record; | |
4173 | int num_sources; | |
4174 | struct in_addr *sources; | |
4175 | struct in_addr *src_addr; | |
4176 | int argi; | |
4177 | ||
4178 | socket = argv[0]; | |
4179 | socket_fd = atoi(socket); | |
4180 | igmp = find_igmp_sock_by_fd(socket_fd); | |
4181 | if (!igmp) { | |
4182 | vty_out(vty, "Could not find IGMP socket %s: fd=%d%s", | |
4183 | socket, socket_fd, VTY_NEWLINE); | |
4184 | return CMD_WARNING; | |
4185 | } | |
4186 | ||
4187 | grp_str = argv[1]; | |
4188 | result = inet_pton(AF_INET, grp_str, &grp_addr); | |
4189 | if (result <= 0) { | |
4190 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
4191 | grp_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4192 | return CMD_WARNING; | |
4193 | } | |
4194 | ||
4195 | record_type_str = argv[2]; | |
4196 | record_type = atoi(record_type_str); | |
4197 | ||
4198 | /* | |
4199 | Tweak IP header | |
4200 | */ | |
4201 | ip_hdr = (struct ip *) buf; | |
4202 | ip_hdr->ip_p = PIM_IP_PROTO_IGMP; | |
4203 | ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */ | |
4204 | ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */ | |
4205 | ip_hdr->ip_src = igmp->ifaddr; | |
4206 | ip_hdr->ip_dst = igmp->ifaddr; | |
4207 | ||
4208 | /* | |
4209 | Build IGMP v3 report message | |
4210 | */ | |
4211 | igmp_msg = buf + ip_hlen; | |
4212 | group_record = igmp_msg + IGMP_V3_REPORT_GROUPPRECORD_OFFSET; | |
4213 | *igmp_msg = PIM_IGMP_V3_MEMBERSHIP_REPORT; /* type */ | |
4214 | *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0; /* for computing checksum */ | |
4215 | *(uint16_t *) (igmp_msg + IGMP_V3_REPORT_NUMGROUPS_OFFSET) = htons(1); /* one group record */ | |
4216 | *(uint8_t *) (group_record + IGMP_V3_GROUP_RECORD_TYPE_OFFSET) = record_type; | |
4217 | memcpy(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET, &grp_addr, sizeof(struct in_addr)); | |
4218 | ||
4219 | /* Scan LINE sources */ | |
4220 | sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET); | |
4221 | src_addr = sources; | |
4222 | for (argi = 3; argi < argc; ++argi,++src_addr) { | |
4223 | src_str = argv[argi]; | |
4224 | result = inet_pton(AF_INET, src_str, src_addr); | |
4225 | if (result <= 0) { | |
4226 | vty_out(vty, "Bad source address %s: errno=%d: %s%s", | |
4227 | src_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4228 | return CMD_WARNING; | |
4229 | } | |
4230 | } | |
4231 | num_sources = src_addr - sources; | |
4232 | ||
4233 | *(uint16_t *)(group_record + IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET) = htons(num_sources); | |
4234 | ||
4235 | igmp_msg_len = IGMP_V3_MSG_MIN_SIZE + (num_sources << 4); /* v3 report for one single group record */ | |
4236 | ||
4237 | /* compute checksum */ | |
4238 | *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = in_cksum(igmp_msg, igmp_msg_len); | |
4239 | ||
4240 | /* "receive" message */ | |
4241 | ||
4242 | ip_msg_len = ip_hlen + igmp_msg_len; | |
4243 | result = pim_igmp_packet(igmp, buf, ip_msg_len); | |
4244 | if (result) { | |
4245 | vty_out(vty, "pim_igmp_packet(len=%d) returned: %d%s", | |
4246 | ip_msg_len, result, VTY_NEWLINE); | |
4247 | return CMD_WARNING; | |
4248 | } | |
4249 | ||
4250 | return CMD_SUCCESS; | |
4251 | } | |
4252 | ||
4253 | static int hexval(uint8_t ch) | |
4254 | { | |
4255 | return isdigit(ch) ? (ch - '0') : (10 + tolower(ch) - 'a'); | |
4256 | } | |
4257 | ||
4258 | DEFUN (test_pim_receive_dump, | |
4259 | test_pim_receive_dump_cmd, | |
4260 | "test pim receive dump INTERFACE A.B.C.D .LINE", | |
4261 | "Test\n" | |
4262 | "Test PIM protocol\n" | |
4263 | "Test PIM message reception\n" | |
4264 | "Test PIM packet dump reception from neighbor\n" | |
4265 | "Interface\n" | |
4266 | "Neighbor address\n" | |
4267 | "Packet dump\n") | |
4268 | { | |
4269 | uint8_t buf[1000]; | |
4270 | uint8_t *pim_msg; | |
4271 | struct ip *ip_hdr; | |
4272 | size_t ip_hlen; /* ip header length in bytes */ | |
4273 | int ip_msg_len; | |
4274 | int pim_msg_size; | |
4275 | const char *neigh_str; | |
4276 | struct in_addr neigh_addr; | |
4277 | const char *ifname; | |
4278 | struct interface *ifp; | |
4279 | int argi; | |
4280 | int result; | |
4281 | ||
4282 | /* Find interface */ | |
4283 | ifname = argv[0]; | |
4284 | ifp = if_lookup_by_name(ifname); | |
4285 | if (!ifp) { | |
4286 | vty_out(vty, "No such interface name %s%s", | |
4287 | ifname, VTY_NEWLINE); | |
4288 | return CMD_WARNING; | |
4289 | } | |
4290 | ||
4291 | /* Neighbor address */ | |
4292 | neigh_str = argv[1]; | |
4293 | result = inet_pton(AF_INET, neigh_str, &neigh_addr); | |
4294 | if (result <= 0) { | |
4295 | vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", | |
4296 | neigh_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4297 | return CMD_WARNING; | |
4298 | } | |
4299 | ||
4300 | /* | |
4301 | Tweak IP header | |
4302 | */ | |
4303 | ip_hdr = (struct ip *) buf; | |
4304 | ip_hdr->ip_p = PIM_IP_PROTO_PIM; | |
4305 | ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */ | |
4306 | ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */ | |
4307 | ip_hdr->ip_src = neigh_addr; | |
4308 | ip_hdr->ip_dst = qpim_all_pim_routers_addr; | |
4309 | ||
4310 | /* | |
4311 | Build PIM hello message | |
4312 | */ | |
4313 | pim_msg = buf + ip_hlen; | |
4314 | pim_msg_size = 0; | |
4315 | ||
4316 | /* Scan LINE dump into buffer */ | |
4317 | for (argi = 2; argi < argc; ++argi) { | |
4318 | const char *str = argv[argi]; | |
4319 | int str_len = strlen(str); | |
4320 | int str_last = str_len - 1; | |
4321 | int i; | |
4322 | ||
4323 | if (str_len % 2) { | |
4324 | vty_out(vty, "%% Uneven hex array arg %d=%s%s", | |
4325 | argi, str, VTY_NEWLINE); | |
4326 | return CMD_WARNING; | |
4327 | } | |
4328 | ||
4329 | for (i = 0; i < str_last; i += 2) { | |
4330 | uint8_t octet; | |
4331 | int left; | |
4332 | uint8_t h1 = str[i]; | |
4333 | uint8_t h2 = str[i + 1]; | |
4334 | ||
4335 | if (!isxdigit(h1) || !isxdigit(h2)) { | |
4336 | vty_out(vty, "%% Non-hex octet %c%c at hex array arg %d=%s%s", | |
4337 | h1, h2, argi, str, VTY_NEWLINE); | |
4338 | return CMD_WARNING; | |
4339 | } | |
4340 | octet = (hexval(h1) << 4) + hexval(h2); | |
4341 | ||
4342 | left = sizeof(buf) - ip_hlen - pim_msg_size; | |
4343 | if (left < 1) { | |
4344 | vty_out(vty, "%% Overflow buf_size=%zu buf_left=%d at hex array arg %d=%s octet %02x%s", | |
4345 | sizeof(buf), left, argi, str, octet, VTY_NEWLINE); | |
4346 | return CMD_WARNING; | |
4347 | } | |
4348 | ||
4349 | pim_msg[pim_msg_size++] = octet; | |
4350 | } | |
4351 | } | |
4352 | ||
4353 | ip_msg_len = ip_hlen + pim_msg_size; | |
4354 | ||
4355 | vty_out(vty, "Receiving: buf_size=%zu ip_msg_size=%d pim_msg_size=%d%s", | |
4356 | sizeof(buf), ip_msg_len, pim_msg_size, VTY_NEWLINE); | |
4357 | ||
4358 | /* "receive" message */ | |
4359 | ||
4360 | result = pim_pim_packet(ifp, buf, ip_msg_len); | |
4361 | if (result) { | |
4362 | vty_out(vty, "%% pim_pim_packet(len=%d) returned failure: %d%s", | |
4363 | ip_msg_len, result, VTY_NEWLINE); | |
4364 | return CMD_WARNING; | |
4365 | } | |
4366 | ||
4367 | return CMD_SUCCESS; | |
4368 | } | |
4369 | ||
4370 | DEFUN (test_pim_receive_hello, | |
4371 | test_pim_receive_hello_cmd, | |
4372 | "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]", | |
4373 | "Test\n" | |
4374 | "Test PIM protocol\n" | |
4375 | "Test PIM message reception\n" | |
4376 | "Test PIM hello reception from neighbor\n" | |
4377 | "Interface\n" | |
4378 | "Neighbor address\n" | |
4379 | "Neighbor holdtime\n" | |
4380 | "Neighbor DR priority\n" | |
4381 | "Neighbor generation ID\n" | |
4382 | "Neighbor propagation delay (msec)\n" | |
4383 | "Neighbor override interval (msec)\n" | |
4384 | "Neighbor LAN prune delay T-bit\n" | |
4385 | "Neighbor secondary addresses\n") | |
4386 | { | |
4387 | uint8_t buf[1000]; | |
4388 | uint8_t *pim_msg; | |
4389 | struct ip *ip_hdr; | |
4390 | size_t ip_hlen; /* ip header length in bytes */ | |
4391 | int ip_msg_len; | |
4392 | int pim_tlv_size; | |
4393 | int pim_msg_size; | |
4394 | const char *neigh_str; | |
4395 | struct in_addr neigh_addr; | |
4396 | const char *ifname; | |
4397 | struct interface *ifp; | |
4398 | uint16_t neigh_holdtime; | |
4399 | uint16_t neigh_propagation_delay; | |
4400 | uint16_t neigh_override_interval; | |
4401 | int neigh_can_disable_join_suppression; | |
4402 | uint32_t neigh_dr_priority; | |
4403 | uint32_t neigh_generation_id; | |
4404 | int argi; | |
4405 | int result; | |
4406 | ||
4407 | /* Find interface */ | |
4408 | ifname = argv[0]; | |
4409 | ifp = if_lookup_by_name(ifname); | |
4410 | if (!ifp) { | |
4411 | vty_out(vty, "No such interface name %s%s", | |
4412 | ifname, VTY_NEWLINE); | |
4413 | return CMD_WARNING; | |
4414 | } | |
4415 | ||
4416 | /* Neighbor address */ | |
4417 | neigh_str = argv[1]; | |
4418 | result = inet_pton(AF_INET, neigh_str, &neigh_addr); | |
4419 | if (result <= 0) { | |
4420 | vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", | |
4421 | neigh_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4422 | return CMD_WARNING; | |
4423 | } | |
4424 | ||
4425 | neigh_holdtime = atoi(argv[2]); | |
4426 | neigh_dr_priority = atoi(argv[3]); | |
4427 | neigh_generation_id = atoi(argv[4]); | |
4428 | neigh_propagation_delay = atoi(argv[5]); | |
4429 | neigh_override_interval = atoi(argv[6]); | |
4430 | neigh_can_disable_join_suppression = atoi(argv[7]); | |
4431 | ||
4432 | /* | |
4433 | Tweak IP header | |
4434 | */ | |
4435 | ip_hdr = (struct ip *) buf; | |
4436 | ip_hdr->ip_p = PIM_IP_PROTO_PIM; | |
4437 | ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */ | |
4438 | ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */ | |
4439 | ip_hdr->ip_src = neigh_addr; | |
4440 | ip_hdr->ip_dst = qpim_all_pim_routers_addr; | |
4441 | ||
4442 | /* | |
4443 | Build PIM hello message | |
4444 | */ | |
4445 | pim_msg = buf + ip_hlen; | |
4446 | ||
4447 | /* Scan LINE addresses */ | |
4448 | for (argi = 8; argi < argc; ++argi) { | |
4449 | const char *sec_str = argv[argi]; | |
4450 | struct in_addr sec_addr; | |
4451 | result = inet_pton(AF_INET, sec_str, &sec_addr); | |
4452 | if (result <= 0) { | |
4453 | vty_out(vty, "Bad neighbor secondary address %s: errno=%d: %s%s", | |
4454 | sec_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4455 | return CMD_WARNING; | |
4456 | } | |
4457 | ||
4458 | vty_out(vty, | |
4459 | "FIXME WRITEME consider neighbor secondary address %s%s", | |
4460 | sec_str, VTY_NEWLINE); | |
4461 | } | |
4462 | ||
4463 | pim_tlv_size = pim_hello_build_tlv(ifp->name, | |
4464 | pim_msg + PIM_PIM_MIN_LEN, | |
4465 | sizeof(buf) - ip_hlen - PIM_PIM_MIN_LEN, | |
4466 | neigh_holdtime, | |
4467 | neigh_dr_priority, | |
4468 | neigh_generation_id, | |
4469 | neigh_propagation_delay, | |
4470 | neigh_override_interval, | |
4471 | neigh_can_disable_join_suppression, | |
4472 | 0 /* FIXME secondary address list */); | |
4473 | if (pim_tlv_size < 0) { | |
4474 | vty_out(vty, "pim_hello_build_tlv() returned failure: %d%s", | |
4475 | pim_tlv_size, VTY_NEWLINE); | |
4476 | return CMD_WARNING; | |
4477 | } | |
4478 | ||
4479 | pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN; | |
4480 | ||
4481 | pim_msg_build_header(pim_msg, pim_msg_size, | |
4482 | PIM_MSG_TYPE_HELLO); | |
4483 | ||
4484 | /* "receive" message */ | |
4485 | ||
4486 | ip_msg_len = ip_hlen + pim_msg_size; | |
4487 | result = pim_pim_packet(ifp, buf, ip_msg_len); | |
4488 | if (result) { | |
4489 | vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s", | |
4490 | ip_msg_len, result, VTY_NEWLINE); | |
4491 | return CMD_WARNING; | |
4492 | } | |
4493 | ||
4494 | return CMD_SUCCESS; | |
4495 | } | |
4496 | ||
4497 | DEFUN (test_pim_receive_assert, | |
4498 | test_pim_receive_assert_cmd, | |
4499 | "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>", | |
4500 | "Test\n" | |
4501 | "Test PIM protocol\n" | |
4502 | "Test PIM message reception\n" | |
4503 | "Test reception of PIM assert\n" | |
4504 | "Interface\n" | |
4505 | "Neighbor address\n" | |
4506 | "Assert multicast group address\n" | |
4507 | "Assert unicast source address\n" | |
4508 | "Assert metric preference\n" | |
4509 | "Assert route metric\n" | |
4510 | "Assert RPT bit flag\n") | |
4511 | { | |
4512 | uint8_t buf[1000]; | |
4513 | uint8_t *buf_pastend = buf + sizeof(buf); | |
4514 | uint8_t *pim_msg; | |
4515 | struct ip *ip_hdr; | |
4516 | size_t ip_hlen; /* ip header length in bytes */ | |
4517 | int ip_msg_len; | |
4518 | int pim_msg_size; | |
4519 | const char *neigh_str; | |
4520 | struct in_addr neigh_addr; | |
4521 | const char *group_str; | |
4522 | struct in_addr group_addr; | |
4523 | const char *source_str; | |
4524 | struct in_addr source_addr; | |
4525 | const char *ifname; | |
4526 | struct interface *ifp; | |
4527 | uint32_t assert_metric_preference; | |
4528 | uint32_t assert_route_metric; | |
4529 | uint32_t assert_rpt_bit_flag; | |
4530 | int remain; | |
4531 | int result; | |
4532 | ||
4533 | /* Find interface */ | |
4534 | ifname = argv[0]; | |
4535 | ifp = if_lookup_by_name(ifname); | |
4536 | if (!ifp) { | |
4537 | vty_out(vty, "No such interface name %s%s", | |
4538 | ifname, VTY_NEWLINE); | |
4539 | return CMD_WARNING; | |
4540 | } | |
4541 | ||
4542 | /* Neighbor address */ | |
4543 | neigh_str = argv[1]; | |
4544 | result = inet_pton(AF_INET, neigh_str, &neigh_addr); | |
4545 | if (result <= 0) { | |
4546 | vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s", | |
4547 | neigh_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4548 | return CMD_WARNING; | |
4549 | } | |
4550 | ||
4551 | /* Group address */ | |
4552 | group_str = argv[2]; | |
4553 | result = inet_pton(AF_INET, group_str, &group_addr); | |
4554 | if (result <= 0) { | |
4555 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
4556 | group_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4557 | return CMD_WARNING; | |
4558 | } | |
4559 | ||
4560 | /* Source address */ | |
4561 | source_str = argv[3]; | |
4562 | result = inet_pton(AF_INET, source_str, &source_addr); | |
4563 | if (result <= 0) { | |
4564 | vty_out(vty, "Bad source address %s: errno=%d: %s%s", | |
4565 | source_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4566 | return CMD_WARNING; | |
4567 | } | |
4568 | ||
4569 | assert_metric_preference = atoi(argv[4]); | |
4570 | assert_route_metric = atoi(argv[5]); | |
4571 | assert_rpt_bit_flag = atoi(argv[6]); | |
4572 | ||
4573 | remain = buf_pastend - buf; | |
4574 | if (remain < (int) sizeof(struct ip)) { | |
4575 | vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%zu%s", | |
4576 | remain, sizeof(struct ip), VTY_NEWLINE); | |
4577 | return CMD_WARNING; | |
4578 | } | |
4579 | ||
4580 | /* | |
4581 | Tweak IP header | |
4582 | */ | |
4583 | ip_hdr = (struct ip *) buf; | |
4584 | ip_hdr->ip_p = PIM_IP_PROTO_PIM; | |
4585 | ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */ | |
4586 | ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */ | |
4587 | ip_hdr->ip_src = neigh_addr; | |
4588 | ip_hdr->ip_dst = qpim_all_pim_routers_addr; | |
4589 | ||
4590 | /* | |
4591 | Build PIM assert message | |
4592 | */ | |
4593 | pim_msg = buf + ip_hlen; /* skip ip header */ | |
4594 | ||
4595 | pim_msg_size = pim_assert_build_msg(pim_msg, buf_pastend - pim_msg, ifp, | |
4596 | group_addr, source_addr, | |
4597 | assert_metric_preference, | |
4598 | assert_route_metric, | |
4599 | assert_rpt_bit_flag); | |
4600 | if (pim_msg_size < 0) { | |
4601 | vty_out(vty, "Failure building PIM assert message: size=%d%s", | |
4602 | pim_msg_size, VTY_NEWLINE); | |
4603 | return CMD_WARNING; | |
4604 | } | |
4605 | ||
4606 | /* "receive" message */ | |
4607 | ||
4608 | ip_msg_len = ip_hlen + pim_msg_size; | |
4609 | result = pim_pim_packet(ifp, buf, ip_msg_len); | |
4610 | if (result) { | |
4611 | vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s", | |
4612 | ip_msg_len, result, VTY_NEWLINE); | |
4613 | return CMD_WARNING; | |
4614 | } | |
4615 | ||
4616 | return CMD_SUCCESS; | |
4617 | } | |
4618 | ||
4619 | static int recv_joinprune(struct vty *vty, | |
4620 | const char *argv[], | |
4621 | int src_is_join) | |
4622 | { | |
4623 | uint8_t buf[1000]; | |
4624 | const uint8_t *buf_pastend = buf + sizeof(buf); | |
4625 | uint8_t *pim_msg; | |
4626 | uint8_t *pim_msg_curr; | |
4627 | int pim_msg_size; | |
4628 | struct ip *ip_hdr; | |
4629 | size_t ip_hlen; /* ip header length in bytes */ | |
4630 | int ip_msg_len; | |
4631 | uint16_t neigh_holdtime; | |
4632 | const char *neigh_dst_str; | |
4633 | struct in_addr neigh_dst_addr; | |
4634 | const char *neigh_src_str; | |
4635 | struct in_addr neigh_src_addr; | |
4636 | const char *group_str; | |
4637 | struct in_addr group_addr; | |
4638 | const char *source_str; | |
4639 | struct in_addr source_addr; | |
4640 | const char *ifname; | |
4641 | struct interface *ifp; | |
4642 | int result; | |
4643 | int remain; | |
4644 | uint16_t num_joined; | |
4645 | uint16_t num_pruned; | |
4646 | ||
4647 | /* Find interface */ | |
4648 | ifname = argv[0]; | |
4649 | ifp = if_lookup_by_name(ifname); | |
4650 | if (!ifp) { | |
4651 | vty_out(vty, "No such interface name %s%s", | |
4652 | ifname, VTY_NEWLINE); | |
4653 | return CMD_WARNING; | |
4654 | } | |
4655 | ||
4656 | neigh_holdtime = atoi(argv[1]); | |
4657 | ||
4658 | /* Neighbor destination address */ | |
4659 | neigh_dst_str = argv[2]; | |
4660 | result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr); | |
4661 | if (result <= 0) { | |
4662 | vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s", | |
4663 | neigh_dst_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4664 | return CMD_WARNING; | |
4665 | } | |
4666 | ||
4667 | /* Neighbor source address */ | |
4668 | neigh_src_str = argv[3]; | |
4669 | result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr); | |
4670 | if (result <= 0) { | |
4671 | vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s", | |
4672 | neigh_src_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4673 | return CMD_WARNING; | |
4674 | } | |
4675 | ||
4676 | /* Multicast group address */ | |
4677 | group_str = argv[4]; | |
4678 | result = inet_pton(AF_INET, group_str, &group_addr); | |
4679 | if (result <= 0) { | |
4680 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
4681 | group_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4682 | return CMD_WARNING; | |
4683 | } | |
4684 | ||
4685 | /* Multicast source address */ | |
4686 | source_str = argv[5]; | |
4687 | result = inet_pton(AF_INET, source_str, &source_addr); | |
4688 | if (result <= 0) { | |
4689 | vty_out(vty, "Bad source address %s: errno=%d: %s%s", | |
4690 | source_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4691 | return CMD_WARNING; | |
4692 | } | |
4693 | ||
4694 | /* | |
4695 | Tweak IP header | |
4696 | */ | |
4697 | ip_hdr = (struct ip *) buf; | |
4698 | ip_hdr->ip_p = PIM_IP_PROTO_PIM; | |
4699 | ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */ | |
4700 | ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */ | |
4701 | ip_hdr->ip_src = neigh_src_addr; | |
4702 | ip_hdr->ip_dst = qpim_all_pim_routers_addr; | |
4703 | ||
4704 | /* | |
4705 | Build PIM message | |
4706 | */ | |
4707 | pim_msg = buf + ip_hlen; | |
4708 | ||
4709 | /* skip room for pim header */ | |
4710 | pim_msg_curr = pim_msg + PIM_MSG_HEADER_LEN; | |
4711 | ||
4712 | remain = buf_pastend - pim_msg_curr; | |
4713 | pim_msg_curr = pim_msg_addr_encode_ipv4_ucast(pim_msg_curr, | |
4714 | remain, | |
4715 | neigh_dst_addr); | |
4716 | if (!pim_msg_curr) { | |
4717 | vty_out(vty, "Failure encoding destination address %s: space left=%d%s", | |
4718 | neigh_dst_str, remain, VTY_NEWLINE); | |
4719 | return CMD_WARNING; | |
4720 | } | |
4721 | ||
4722 | remain = buf_pastend - pim_msg_curr; | |
4723 | if (remain < 4) { | |
4724 | vty_out(vty, "Group will not fit: space left=%d%s", | |
4725 | remain, VTY_NEWLINE); | |
4726 | return CMD_WARNING; | |
4727 | } | |
4728 | ||
4729 | *pim_msg_curr = 0; /* reserved */ | |
4730 | ++pim_msg_curr; | |
4731 | *pim_msg_curr = 1; /* number of groups */ | |
4732 | ++pim_msg_curr; | |
4733 | *((uint16_t *) pim_msg_curr) = htons(neigh_holdtime); | |
4734 | ++pim_msg_curr; | |
4735 | ++pim_msg_curr; | |
4736 | ||
4737 | remain = buf_pastend - pim_msg_curr; | |
4738 | pim_msg_curr = pim_msg_addr_encode_ipv4_group(pim_msg_curr, | |
4739 | remain, | |
4740 | group_addr); | |
4741 | if (!pim_msg_curr) { | |
4742 | vty_out(vty, "Failure encoding group address %s: space left=%d%s", | |
4743 | group_str, remain, VTY_NEWLINE); | |
4744 | return CMD_WARNING; | |
4745 | } | |
4746 | ||
4747 | remain = buf_pastend - pim_msg_curr; | |
4748 | if (remain < 4) { | |
4749 | vty_out(vty, "Sources will not fit: space left=%d%s", | |
4750 | remain, VTY_NEWLINE); | |
4751 | return CMD_WARNING; | |
4752 | } | |
4753 | ||
4754 | if (src_is_join) { | |
4755 | num_joined = 1; | |
4756 | num_pruned = 0; | |
4757 | } | |
4758 | else { | |
4759 | num_joined = 0; | |
4760 | num_pruned = 1; | |
4761 | } | |
4762 | ||
4763 | /* number of joined sources */ | |
4764 | *((uint16_t *) pim_msg_curr) = htons(num_joined); | |
4765 | ++pim_msg_curr; | |
4766 | ++pim_msg_curr; | |
4767 | ||
4768 | /* number of pruned sources */ | |
4769 | *((uint16_t *) pim_msg_curr) = htons(num_pruned); | |
4770 | ++pim_msg_curr; | |
4771 | ++pim_msg_curr; | |
4772 | ||
4773 | remain = buf_pastend - pim_msg_curr; | |
4774 | pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr, | |
4775 | remain, | |
4776 | source_addr); | |
4777 | if (!pim_msg_curr) { | |
4778 | vty_out(vty, "Failure encoding source address %s: space left=%d%s", | |
4779 | source_str, remain, VTY_NEWLINE); | |
4780 | return CMD_WARNING; | |
4781 | } | |
4782 | ||
4783 | /* Add PIM header */ | |
4784 | ||
4785 | pim_msg_size = pim_msg_curr - pim_msg; | |
4786 | ||
4787 | pim_msg_build_header(pim_msg, pim_msg_size, | |
4788 | PIM_MSG_TYPE_JOIN_PRUNE); | |
4789 | ||
4790 | /* | |
4791 | "Receive" message | |
4792 | */ | |
4793 | ||
4794 | ip_msg_len = ip_hlen + pim_msg_size; | |
4795 | result = pim_pim_packet(ifp, buf, ip_msg_len); | |
4796 | if (result) { | |
4797 | vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s", | |
4798 | ip_msg_len, result, VTY_NEWLINE); | |
4799 | return CMD_WARNING; | |
4800 | } | |
4801 | ||
4802 | return CMD_SUCCESS; | |
4803 | } | |
4804 | ||
4805 | DEFUN (test_pim_receive_join, | |
4806 | test_pim_receive_join_cmd, | |
4807 | "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", | |
4808 | "Test\n" | |
4809 | "Test PIM protocol\n" | |
4810 | "Test PIM message reception\n" | |
4811 | "Test PIM join reception from neighbor\n" | |
4812 | "Interface\n" | |
4813 | "Neighbor holdtime\n" | |
4814 | "Upstream neighbor unicast destination address\n" | |
4815 | "Downstream neighbor unicast source address\n" | |
4816 | "Multicast group address\n" | |
4817 | "Unicast source address\n") | |
4818 | { | |
4819 | return recv_joinprune(vty, argv, 1 /* src_is_join=true */); | |
4820 | } | |
4821 | ||
4822 | DEFUN (test_pim_receive_prune, | |
4823 | test_pim_receive_prune_cmd, | |
4824 | "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D", | |
4825 | "Test\n" | |
4826 | "Test PIM protocol\n" | |
4827 | "Test PIM message reception\n" | |
4828 | "Test PIM prune reception from neighbor\n" | |
4829 | "Interface\n" | |
4830 | "Neighbor holdtime\n" | |
4831 | "Upstream neighbor unicast destination address\n" | |
4832 | "Downstream neighbor unicast source address\n" | |
4833 | "Multicast group address\n" | |
4834 | "Unicast source address\n") | |
4835 | { | |
4836 | return recv_joinprune(vty, argv, 0 /* src_is_join=false */); | |
4837 | } | |
4838 | ||
4839 | DEFUN (test_pim_receive_upcall, | |
4840 | test_pim_receive_upcall_cmd, | |
4841 | "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D", | |
4842 | "Test\n" | |
4843 | "Test PIM protocol\n" | |
4844 | "Test PIM message reception\n" | |
4845 | "Test reception of kernel upcall\n" | |
4846 | "NOCACHE kernel upcall\n" | |
4847 | "WRONGVIF kernel upcall\n" | |
4848 | "WHOLEPKT kernel upcall\n" | |
4849 | "Input interface vif index\n" | |
4850 | "Multicast group address\n" | |
4851 | "Multicast source address\n") | |
4852 | { | |
4853 | struct igmpmsg msg; | |
4854 | const char *upcall_type; | |
4855 | const char *group_str; | |
4856 | const char *source_str; | |
4857 | int result; | |
4858 | ||
4859 | upcall_type = argv[0]; | |
4860 | ||
4861 | if (upcall_type[0] == 'n') | |
4862 | msg.im_msgtype = IGMPMSG_NOCACHE; | |
4863 | else if (upcall_type[1] == 'r') | |
4864 | msg.im_msgtype = IGMPMSG_WRONGVIF; | |
4865 | else if (upcall_type[1] == 'h') | |
4866 | msg.im_msgtype = IGMPMSG_WHOLEPKT; | |
4867 | else { | |
4868 | vty_out(vty, "Unknown kernel upcall type: %s%s", | |
4869 | upcall_type, VTY_NEWLINE); | |
4870 | return CMD_WARNING; | |
4871 | } | |
4872 | ||
4873 | msg.im_vif = atoi(argv[1]); | |
4874 | ||
4875 | /* Group address */ | |
4876 | group_str = argv[2]; | |
4877 | result = inet_pton(AF_INET, group_str, &msg.im_dst); | |
4878 | if (result <= 0) { | |
4879 | vty_out(vty, "Bad group address %s: errno=%d: %s%s", | |
4880 | group_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4881 | return CMD_WARNING; | |
4882 | } | |
4883 | ||
4884 | /* Source address */ | |
4885 | source_str = argv[3]; | |
4886 | result = inet_pton(AF_INET, source_str, &msg.im_src); | |
4887 | if (result <= 0) { | |
4888 | vty_out(vty, "Bad source address %s: errno=%d: %s%s", | |
4889 | source_str, errno, safe_strerror(errno), VTY_NEWLINE); | |
4890 | return CMD_WARNING; | |
4891 | } | |
4892 | ||
4893 | msg.im_mbz = 0; /* Must be zero */ | |
4894 | ||
4895 | result = pim_mroute_msg(-1, (char *) &msg, sizeof(msg)); | |
4896 | if (result) { | |
4897 | vty_out(vty, "pim_mroute_msg(len=%zu) returned failure: %d%s", | |
4898 | sizeof(msg), result, VTY_NEWLINE); | |
4899 | return CMD_WARNING; | |
4900 | } | |
4901 | ||
4902 | return CMD_SUCCESS; | |
4903 | } | |
4904 | ||
4905 | void pim_cmd_init() | |
4906 | { | |
4907 | install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */ | |
4908 | install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */ | |
4909 | ||
4910 | install_element (CONFIG_NODE, &ip_multicast_routing_cmd); | |
4911 | install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd); | |
981d6c7a DS |
4912 | install_element (CONFIG_NODE, &ip_pim_rp_cmd); |
4913 | install_element (CONFIG_NODE, &no_ip_pim_rp_cmd); | |
12e41d03 DL |
4914 | install_element (CONFIG_NODE, &ip_ssmpingd_cmd); |
4915 | install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd); | |
4916 | #if 0 | |
4917 | install_element (CONFIG_NODE, &interface_cmd); /* from if.h */ | |
4918 | #else | |
4919 | install_element (CONFIG_NODE, &pim_interface_cmd); | |
4920 | #endif | |
4921 | install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */ | |
4922 | ||
4923 | install_default (INTERFACE_NODE); | |
4924 | install_element (INTERFACE_NODE, &interface_ip_igmp_cmd); | |
4925 | install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd); | |
4926 | install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd); | |
4927 | install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd); | |
4928 | install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd); | |
4929 | install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd); | |
4930 | install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd); | |
4931 | install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd); | |
4932 | install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd); | |
4933 | install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd); | |
4934 | install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd); | |
dedccda6 | 4935 | install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd); |
981d6c7a | 4936 | install_element (INTERFACE_NODE, &interface_ip_pim_sm_cmd); |
8371bd60 | 4937 | install_element (INTERFACE_NODE, &interface_no_ip_pim_sm_cmd); |
dedccda6 DS |
4938 | install_element (INTERFACE_NODE, &interface_ip_pim_drprio_cmd); |
4939 | install_element (INTERFACE_NODE, &interface_no_ip_pim_drprio_cmd); | |
7960fa8f DS |
4940 | install_element (INTERFACE_NODE, &interface_ip_pim_hello_cmd); |
4941 | install_element (INTERFACE_NODE, &interface_ip_pim_hello_hold_cmd); | |
4942 | install_element (INTERFACE_NODE, &interface_no_ip_pim_hello_cmd); | |
12e41d03 | 4943 | |
6250610a JAG |
4944 | // Static mroutes NEB |
4945 | install_element (INTERFACE_NODE, &interface_ip_mroute_cmd); | |
4946 | install_element (INTERFACE_NODE, &interface_ip_mroute_source_cmd); | |
4947 | install_element (INTERFACE_NODE, &interface_no_ip_mroute_cmd); | |
4948 | install_element (INTERFACE_NODE, &interface_no_ip_mroute_source_cmd); | |
4949 | ||
12e41d03 DL |
4950 | install_element (VIEW_NODE, &show_ip_igmp_interface_cmd); |
4951 | install_element (VIEW_NODE, &show_ip_igmp_join_cmd); | |
4952 | install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd); | |
4953 | install_element (VIEW_NODE, &show_ip_igmp_groups_cmd); | |
4954 | install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd); | |
4955 | install_element (VIEW_NODE, &show_ip_igmp_sources_cmd); | |
4956 | install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd); | |
4957 | install_element (VIEW_NODE, &show_ip_igmp_querier_cmd); | |
4958 | install_element (VIEW_NODE, &show_ip_pim_assert_cmd); | |
4959 | install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd); | |
4960 | install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd); | |
4961 | install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd); | |
4962 | install_element (VIEW_NODE, &show_ip_pim_dr_cmd); | |
4963 | install_element (VIEW_NODE, &show_ip_pim_hello_cmd); | |
4964 | install_element (VIEW_NODE, &show_ip_pim_interface_cmd); | |
4965 | install_element (VIEW_NODE, &show_ip_pim_join_cmd); | |
4966 | install_element (VIEW_NODE, &show_ip_pim_jp_override_interval_cmd); | |
4967 | install_element (VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd); | |
4968 | install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd); | |
4969 | install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd); | |
4970 | install_element (VIEW_NODE, &show_ip_pim_rpf_cmd); | |
4971 | install_element (VIEW_NODE, &show_ip_pim_secondary_cmd); | |
4972 | install_element (VIEW_NODE, &show_ip_pim_upstream_cmd); | |
4973 | install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd); | |
4974 | install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd); | |
4975 | install_element (VIEW_NODE, &show_ip_multicast_cmd); | |
4976 | install_element (VIEW_NODE, &show_ip_mroute_cmd); | |
4977 | install_element (VIEW_NODE, &show_ip_mroute_count_cmd); | |
4978 | install_element (VIEW_NODE, &show_ip_rib_cmd); | |
4979 | install_element (VIEW_NODE, &show_ip_ssmpingd_cmd); | |
7a1d58ce | 4980 | install_element (VIEW_NODE, &show_debugging_pim_cmd); |
12e41d03 DL |
4981 | |
4982 | install_element (ENABLE_NODE, &clear_ip_interfaces_cmd); | |
4983 | install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd); | |
4984 | install_element (ENABLE_NODE, &clear_ip_mroute_cmd); | |
4985 | install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd); | |
4986 | install_element (ENABLE_NODE, &clear_ip_pim_oil_cmd); | |
4987 | ||
4988 | install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd); | |
4989 | install_element (ENABLE_NODE, &show_ip_igmp_join_cmd); | |
4990 | install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd); | |
4991 | install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd); | |
4992 | install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd); | |
4993 | install_element (ENABLE_NODE, &show_ip_igmp_sources_cmd); | |
4994 | install_element (ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd); | |
4995 | install_element (ENABLE_NODE, &show_ip_igmp_querier_cmd); | |
4996 | install_element (ENABLE_NODE, &show_ip_pim_address_cmd); | |
4997 | install_element (ENABLE_NODE, &show_ip_pim_assert_cmd); | |
4998 | install_element (ENABLE_NODE, &show_ip_pim_assert_internal_cmd); | |
4999 | install_element (ENABLE_NODE, &show_ip_pim_assert_metric_cmd); | |
5000 | install_element (ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd); | |
5001 | install_element (ENABLE_NODE, &show_ip_pim_dr_cmd); | |
5002 | install_element (ENABLE_NODE, &show_ip_pim_hello_cmd); | |
5003 | install_element (ENABLE_NODE, &show_ip_pim_interface_cmd); | |
5004 | install_element (ENABLE_NODE, &show_ip_pim_join_cmd); | |
5005 | install_element (ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd); | |
5006 | install_element (ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd); | |
5007 | install_element (ENABLE_NODE, &show_ip_pim_local_membership_cmd); | |
5008 | install_element (ENABLE_NODE, &show_ip_pim_neighbor_cmd); | |
5009 | install_element (ENABLE_NODE, &show_ip_pim_rpf_cmd); | |
5010 | install_element (ENABLE_NODE, &show_ip_pim_secondary_cmd); | |
5011 | install_element (ENABLE_NODE, &show_ip_pim_upstream_cmd); | |
5012 | install_element (ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd); | |
5013 | install_element (ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd); | |
5014 | install_element (ENABLE_NODE, &show_ip_multicast_cmd); | |
5015 | install_element (ENABLE_NODE, &show_ip_mroute_cmd); | |
5016 | install_element (ENABLE_NODE, &show_ip_mroute_count_cmd); | |
5017 | install_element (ENABLE_NODE, &show_ip_rib_cmd); | |
5018 | install_element (ENABLE_NODE, &show_ip_ssmpingd_cmd); | |
7a1d58ce | 5019 | install_element (ENABLE_NODE, &show_debugging_pim_cmd); |
12e41d03 DL |
5020 | |
5021 | install_element (ENABLE_NODE, &test_igmp_receive_report_cmd); | |
5022 | install_element (ENABLE_NODE, &test_pim_receive_assert_cmd); | |
5023 | install_element (ENABLE_NODE, &test_pim_receive_dump_cmd); | |
5024 | install_element (ENABLE_NODE, &test_pim_receive_hello_cmd); | |
5025 | install_element (ENABLE_NODE, &test_pim_receive_join_cmd); | |
5026 | install_element (ENABLE_NODE, &test_pim_receive_prune_cmd); | |
5027 | install_element (ENABLE_NODE, &test_pim_receive_upcall_cmd); | |
5028 | ||
5029 | install_element (ENABLE_NODE, &debug_igmp_cmd); | |
5030 | install_element (ENABLE_NODE, &no_debug_igmp_cmd); | |
5031 | install_element (ENABLE_NODE, &undebug_igmp_cmd); | |
5032 | install_element (ENABLE_NODE, &debug_igmp_events_cmd); | |
5033 | install_element (ENABLE_NODE, &no_debug_igmp_events_cmd); | |
5034 | install_element (ENABLE_NODE, &undebug_igmp_events_cmd); | |
5035 | install_element (ENABLE_NODE, &debug_igmp_packets_cmd); | |
5036 | install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd); | |
5037 | install_element (ENABLE_NODE, &undebug_igmp_packets_cmd); | |
5038 | install_element (ENABLE_NODE, &debug_igmp_trace_cmd); | |
5039 | install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd); | |
5040 | install_element (ENABLE_NODE, &undebug_igmp_trace_cmd); | |
5041 | install_element (ENABLE_NODE, &debug_mroute_cmd); | |
5042 | install_element (ENABLE_NODE, &no_debug_mroute_cmd); | |
6250610a JAG |
5043 | install_element (ENABLE_NODE, &debug_static_cmd); |
5044 | install_element (ENABLE_NODE, &no_debug_static_cmd); | |
12e41d03 DL |
5045 | install_element (ENABLE_NODE, &debug_pim_cmd); |
5046 | install_element (ENABLE_NODE, &no_debug_pim_cmd); | |
5047 | install_element (ENABLE_NODE, &undebug_pim_cmd); | |
5048 | install_element (ENABLE_NODE, &debug_pim_events_cmd); | |
5049 | install_element (ENABLE_NODE, &no_debug_pim_events_cmd); | |
5050 | install_element (ENABLE_NODE, &undebug_pim_events_cmd); | |
5051 | install_element (ENABLE_NODE, &debug_pim_packets_cmd); | |
5052 | install_element (ENABLE_NODE, &debug_pim_packets_filter_cmd); | |
5053 | install_element (ENABLE_NODE, &no_debug_pim_packets_cmd); | |
5054 | install_element (ENABLE_NODE, &no_debug_pim_packets_filter_cmd); | |
5055 | install_element (ENABLE_NODE, &undebug_pim_packets_cmd); | |
5056 | install_element (ENABLE_NODE, &debug_pim_packetdump_send_cmd); | |
5057 | install_element (ENABLE_NODE, &no_debug_pim_packetdump_send_cmd); | |
5058 | install_element (ENABLE_NODE, &undebug_pim_packetdump_send_cmd); | |
5059 | install_element (ENABLE_NODE, &debug_pim_packetdump_recv_cmd); | |
5060 | install_element (ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd); | |
5061 | install_element (ENABLE_NODE, &undebug_pim_packetdump_recv_cmd); | |
5062 | install_element (ENABLE_NODE, &debug_pim_trace_cmd); | |
5063 | install_element (ENABLE_NODE, &no_debug_pim_trace_cmd); | |
5064 | install_element (ENABLE_NODE, &undebug_pim_trace_cmd); | |
5065 | install_element (ENABLE_NODE, &debug_ssmpingd_cmd); | |
5066 | install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd); | |
5067 | install_element (ENABLE_NODE, &undebug_ssmpingd_cmd); | |
5068 | install_element (ENABLE_NODE, &debug_pim_zebra_cmd); | |
5069 | install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd); | |
5070 | install_element (ENABLE_NODE, &undebug_pim_zebra_cmd); | |
5071 | ||
5072 | install_element (CONFIG_NODE, &debug_igmp_cmd); | |
5073 | install_element (CONFIG_NODE, &no_debug_igmp_cmd); | |
5074 | install_element (CONFIG_NODE, &undebug_igmp_cmd); | |
5075 | install_element (CONFIG_NODE, &debug_igmp_events_cmd); | |
5076 | install_element (CONFIG_NODE, &no_debug_igmp_events_cmd); | |
5077 | install_element (CONFIG_NODE, &undebug_igmp_events_cmd); | |
5078 | install_element (CONFIG_NODE, &debug_igmp_packets_cmd); | |
5079 | install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd); | |
5080 | install_element (CONFIG_NODE, &undebug_igmp_packets_cmd); | |
5081 | install_element (CONFIG_NODE, &debug_igmp_trace_cmd); | |
5082 | install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd); | |
5083 | install_element (CONFIG_NODE, &undebug_igmp_trace_cmd); | |
5084 | install_element (CONFIG_NODE, &debug_mroute_cmd); | |
5085 | install_element (CONFIG_NODE, &no_debug_mroute_cmd); | |
6250610a JAG |
5086 | install_element (CONFIG_NODE, &debug_static_cmd); |
5087 | install_element (CONFIG_NODE, &no_debug_static_cmd); | |
12e41d03 DL |
5088 | install_element (CONFIG_NODE, &debug_pim_cmd); |
5089 | install_element (CONFIG_NODE, &no_debug_pim_cmd); | |
5090 | install_element (CONFIG_NODE, &undebug_pim_cmd); | |
5091 | install_element (CONFIG_NODE, &debug_pim_events_cmd); | |
5092 | install_element (CONFIG_NODE, &no_debug_pim_events_cmd); | |
5093 | install_element (CONFIG_NODE, &undebug_pim_events_cmd); | |
5094 | install_element (CONFIG_NODE, &debug_pim_packets_cmd); | |
5095 | install_element (CONFIG_NODE, &debug_pim_packets_filter_cmd); | |
5096 | install_element (CONFIG_NODE, &no_debug_pim_packets_cmd); | |
5097 | install_element (CONFIG_NODE, &no_debug_pim_packets_filter_cmd); | |
5098 | install_element (CONFIG_NODE, &undebug_pim_packets_cmd); | |
5099 | install_element (CONFIG_NODE, &debug_pim_trace_cmd); | |
5100 | install_element (CONFIG_NODE, &no_debug_pim_trace_cmd); | |
5101 | install_element (CONFIG_NODE, &undebug_pim_trace_cmd); | |
5102 | install_element (CONFIG_NODE, &debug_ssmpingd_cmd); | |
5103 | install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd); | |
5104 | install_element (CONFIG_NODE, &undebug_ssmpingd_cmd); | |
5105 | install_element (CONFIG_NODE, &debug_pim_zebra_cmd); | |
5106 | install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd); | |
5107 | install_element (CONFIG_NODE, &undebug_pim_zebra_cmd); | |
5108 | } |