]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
7f57883e DS |
2 | /* |
3 | * EIGRP VTY Interface. | |
4 | * Copyright (C) 2013-2016 | |
5 | * Authors: | |
6 | * Donnie Savage | |
7 | * Jan Janovic | |
8 | * Matej Perina | |
9 | * Peter Orsag | |
10 | * Peter Paluch | |
11 | * Frantisek Gazo | |
12 | * Tomas Hvorkovy | |
13 | * Martin Kontsek | |
14 | * Lukas Koribsky | |
7f57883e DS |
15 | */ |
16 | ||
17 | #include <zebra.h> | |
18 | ||
19 | #include "memory.h" | |
24a58196 | 20 | #include "frrevent.h" |
7f57883e DS |
21 | #include "prefix.h" |
22 | #include "table.h" | |
23 | #include "vty.h" | |
24 | #include "command.h" | |
25 | #include "plist.h" | |
26 | #include "log.h" | |
27 | #include "zclient.h" | |
28 | #include "keychain.h" | |
29 | #include "linklist.h" | |
30 | #include "distribute.h" | |
31 | ||
32 | #include "eigrpd/eigrp_structs.h" | |
33 | #include "eigrpd/eigrpd.h" | |
34 | #include "eigrpd/eigrp_interface.h" | |
35 | #include "eigrpd/eigrp_neighbor.h" | |
36 | #include "eigrpd/eigrp_packet.h" | |
37 | #include "eigrpd/eigrp_zebra.h" | |
38 | #include "eigrpd/eigrp_vty.h" | |
39 | #include "eigrpd/eigrp_network.h" | |
40 | #include "eigrpd/eigrp_dump.h" | |
41 | #include "eigrpd/eigrp_const.h" | |
42 | ||
085fc344 | 43 | #include "eigrpd/eigrp_vty_clippy.c" |
085fc344 | 44 | |
dc4accdd DS |
45 | static void eigrp_vty_display_prefix_entry(struct vty *vty, struct eigrp *eigrp, |
46 | struct eigrp_prefix_descriptor *pe, | |
b0534a89 DS |
47 | bool all) |
48 | { | |
49 | bool first = true; | |
dc4accdd | 50 | struct eigrp_route_descriptor *te; |
b0534a89 DS |
51 | struct listnode *node; |
52 | ||
53 | for (ALL_LIST_ELEMENTS_RO(pe->entries, node, te)) { | |
54 | if (all | |
dc4accdd DS |
55 | || (((te->flags & EIGRP_ROUTE_DESCRIPTOR_SUCCESSOR_FLAG) |
56 | == EIGRP_ROUTE_DESCRIPTOR_SUCCESSOR_FLAG) | |
57 | || ((te->flags & EIGRP_ROUTE_DESCRIPTOR_FSUCCESSOR_FLAG) | |
58 | == EIGRP_ROUTE_DESCRIPTOR_FSUCCESSOR_FLAG))) { | |
59 | show_ip_eigrp_route_descriptor(vty, eigrp, te, &first); | |
b0534a89 DS |
60 | first = false; |
61 | } | |
62 | } | |
63 | } | |
64 | ||
cae06ae0 DS |
65 | static struct eigrp *eigrp_vty_get_eigrp(struct vty *vty, const char *vrf_name) |
66 | { | |
67 | struct vrf *vrf; | |
68 | ||
69 | if (vrf_name) | |
70 | vrf = vrf_lookup_by_name(vrf_name); | |
71 | else | |
72 | vrf = vrf_lookup_by_id(VRF_DEFAULT); | |
73 | ||
74 | if (!vrf) { | |
75 | vty_out(vty, "VRF %s specified does not exist", | |
76 | vrf_name ? vrf_name : VRF_DEFAULT_NAME); | |
77 | return NULL; | |
78 | } | |
79 | ||
80 | return eigrp_lookup(vrf->vrf_id); | |
81 | } | |
82 | ||
10b3a325 DS |
83 | static void eigrp_topology_helper(struct vty *vty, struct eigrp *eigrp, |
84 | const char *all) | |
85 | { | |
dc4accdd | 86 | struct eigrp_prefix_descriptor *tn; |
10b3a325 DS |
87 | struct route_node *rn; |
88 | ||
89 | show_ip_eigrp_topology_header(vty, eigrp); | |
90 | ||
91 | for (rn = route_top(eigrp->topology_table); rn; rn = route_next(rn)) { | |
92 | if (!rn->info) | |
93 | continue; | |
94 | ||
95 | tn = rn->info; | |
96 | eigrp_vty_display_prefix_entry(vty, eigrp, tn, | |
97 | all ? true : false); | |
98 | } | |
99 | } | |
100 | ||
13133652 DS |
101 | DEFPY (show_ip_eigrp_topology_all, |
102 | show_ip_eigrp_topology_all_cmd, | |
cae06ae0 | 103 | "show ip eigrp [vrf NAME] topology [all-links$all]", |
7f57883e DS |
104 | SHOW_STR |
105 | IP_STR | |
106 | "IP-EIGRP show commands\n" | |
cae06ae0 | 107 | VRF_CMD_HELP_STR |
7f57883e DS |
108 | "IP-EIGRP topology\n" |
109 | "Show all links in topology table\n") | |
110 | { | |
d62a17ae | 111 | struct eigrp *eigrp; |
d62a17ae | 112 | |
10b3a325 DS |
113 | if (vrf && strncmp(vrf, "all", sizeof("all")) == 0) { |
114 | struct vrf *v; | |
d62a17ae | 115 | |
10b3a325 DS |
116 | RB_FOREACH (v, vrf_name_head, &vrfs_by_name) { |
117 | eigrp = eigrp_lookup(v->vrf_id); | |
118 | if (!eigrp) | |
119 | continue; | |
d62a17ae | 120 | |
10b3a325 | 121 | vty_out(vty, "VRF %s:\n", v->name); |
9ca66cc7 | 122 | |
10b3a325 DS |
123 | eigrp_topology_helper(vty, eigrp, all); |
124 | } | |
125 | } else { | |
126 | eigrp = eigrp_vty_get_eigrp(vty, vrf); | |
127 | if (eigrp == NULL) { | |
128 | vty_out(vty, " EIGRP Routing Process not enabled\n"); | |
129 | return CMD_SUCCESS; | |
130 | } | |
131 | ||
132 | eigrp_topology_helper(vty, eigrp, all); | |
d62a17ae | 133 | } |
134 | ||
135 | return CMD_SUCCESS; | |
7f57883e DS |
136 | } |
137 | ||
13133652 DS |
138 | DEFPY (show_ip_eigrp_topology, |
139 | show_ip_eigrp_topology_cmd, | |
cae06ae0 | 140 | "show ip eigrp [vrf NAME] topology <A.B.C.D$address|A.B.C.D/M$prefix>", |
13133652 DS |
141 | SHOW_STR |
142 | IP_STR | |
143 | "IP-EIGRP show commands\n" | |
cae06ae0 | 144 | VRF_CMD_HELP_STR |
13133652 DS |
145 | "IP-EIGRP topology\n" |
146 | "For a specific address\n" | |
147 | "For a specific prefix\n") | |
148 | { | |
149 | struct eigrp *eigrp; | |
dc4accdd | 150 | struct eigrp_prefix_descriptor *tn; |
13133652 DS |
151 | struct route_node *rn; |
152 | struct prefix cmp; | |
153 | ||
10b3a325 DS |
154 | if (vrf && strncmp(vrf, "all", sizeof("all")) == 0) { |
155 | vty_out(vty, "Specifying vrf `all` for a particular address/prefix makes no sense\n"); | |
156 | return CMD_SUCCESS; | |
157 | } | |
158 | ||
cae06ae0 | 159 | eigrp = eigrp_vty_get_eigrp(vty, vrf); |
13133652 DS |
160 | if (eigrp == NULL) { |
161 | vty_out(vty, " EIGRP Routing Process not enabled\n"); | |
162 | return CMD_SUCCESS; | |
163 | } | |
164 | ||
165 | show_ip_eigrp_topology_header(vty, eigrp); | |
166 | ||
167 | if (address_str) | |
168 | prefix_str = address_str; | |
169 | ||
170 | if (str2prefix(prefix_str, &cmp) < 0) { | |
171 | vty_out(vty, "%% Malformed address\n"); | |
172 | return CMD_WARNING; | |
173 | } | |
174 | ||
175 | rn = route_node_match(eigrp->topology_table, &cmp); | |
176 | if (!rn) { | |
177 | vty_out(vty, "%% Network not in table\n"); | |
178 | return CMD_WARNING; | |
179 | } | |
180 | ||
181 | if (!rn->info) { | |
182 | vty_out(vty, "%% Network not in table\n"); | |
183 | route_unlock_node(rn); | |
184 | return CMD_WARNING; | |
185 | } | |
186 | ||
187 | tn = rn->info; | |
188 | eigrp_vty_display_prefix_entry(vty, eigrp, tn, argc == 5); | |
189 | ||
051da24e | 190 | route_unlock_node(rn); |
13133652 DS |
191 | return CMD_SUCCESS; |
192 | } | |
7f57883e | 193 | |
b1d26a40 DS |
194 | static void eigrp_interface_helper(struct vty *vty, struct eigrp *eigrp, |
195 | const char *ifname, const char *detail) | |
196 | { | |
197 | struct eigrp_interface *ei; | |
198 | struct listnode *node; | |
199 | ||
200 | if (!ifname) | |
201 | show_ip_eigrp_interface_header(vty, eigrp); | |
202 | ||
203 | for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) { | |
204 | if (!ifname || strcmp(ei->ifp->name, ifname) == 0) { | |
205 | show_ip_eigrp_interface_sub(vty, eigrp, ei); | |
206 | if (detail) | |
207 | show_ip_eigrp_interface_detail(vty, eigrp, ei); | |
208 | } | |
209 | } | |
210 | } | |
211 | ||
cae06ae0 | 212 | DEFPY (show_ip_eigrp_interfaces, |
7f57883e | 213 | show_ip_eigrp_interfaces_cmd, |
cae06ae0 | 214 | "show ip eigrp [vrf NAME] interfaces [IFNAME] [detail]$detail", |
7f57883e DS |
215 | SHOW_STR |
216 | IP_STR | |
217 | "IP-EIGRP show commands\n" | |
cae06ae0 | 218 | VRF_CMD_HELP_STR |
dbc56a10 DS |
219 | "IP-EIGRP interfaces\n" |
220 | "Interface name to look at\n" | |
221 | "Detailed information\n") | |
7f57883e | 222 | { |
d62a17ae | 223 | struct eigrp *eigrp; |
d62a17ae | 224 | |
b1d26a40 | 225 | if (vrf && strncmp(vrf, "all", sizeof("all")) == 0) { |
6fd04fda | 226 | struct vrf *v; |
d62a17ae | 227 | |
6fd04fda DS |
228 | RB_FOREACH (v, vrf_name_head, &vrfs_by_name) { |
229 | eigrp = eigrp_lookup(v->vrf_id); | |
b1d26a40 DS |
230 | if (!eigrp) |
231 | continue; | |
d62a17ae | 232 | |
6fd04fda | 233 | vty_out(vty, "VRF %s:\n", v->name); |
b1d26a40 DS |
234 | |
235 | eigrp_interface_helper(vty, eigrp, ifname, detail); | |
236 | } | |
237 | } else { | |
238 | eigrp = eigrp_vty_get_eigrp(vty, vrf); | |
239 | if (eigrp == NULL) { | |
240 | vty_out(vty, "EIGRP Routing Process not enabled\n"); | |
241 | return CMD_SUCCESS; | |
d62a17ae | 242 | } |
b1d26a40 DS |
243 | |
244 | eigrp_interface_helper(vty, eigrp, ifname, detail); | |
d62a17ae | 245 | } |
246 | ||
b1d26a40 | 247 | |
d62a17ae | 248 | return CMD_SUCCESS; |
7f57883e DS |
249 | } |
250 | ||
fb41c4f3 DS |
251 | static void eigrp_neighbors_helper(struct vty *vty, struct eigrp *eigrp, |
252 | const char *ifname, const char *detail) | |
253 | { | |
254 | struct eigrp_interface *ei; | |
255 | struct listnode *node, *node2, *nnode2; | |
256 | struct eigrp_neighbor *nbr; | |
257 | ||
258 | show_ip_eigrp_neighbor_header(vty, eigrp); | |
259 | ||
260 | for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) { | |
261 | if (!ifname || strcmp(ei->ifp->name, ifname) == 0) { | |
262 | for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) { | |
263 | if (detail || (nbr->state == EIGRP_NEIGHBOR_UP)) | |
264 | show_ip_eigrp_neighbor_sub(vty, nbr, | |
265 | !!detail); | |
266 | } | |
267 | } | |
268 | } | |
269 | } | |
270 | ||
cae06ae0 | 271 | DEFPY (show_ip_eigrp_neighbors, |
7f57883e | 272 | show_ip_eigrp_neighbors_cmd, |
cae06ae0 | 273 | "show ip eigrp [vrf NAME] neighbors [IFNAME] [detail]$detail", |
7f57883e DS |
274 | SHOW_STR |
275 | IP_STR | |
276 | "IP-EIGRP show commands\n" | |
cae06ae0 | 277 | VRF_CMD_HELP_STR |
dbc56a10 DS |
278 | "IP-EIGRP neighbors\n" |
279 | "Interface to show on\n" | |
280 | "Detailed Information\n") | |
7f57883e | 281 | { |
d62a17ae | 282 | struct eigrp *eigrp; |
d62a17ae | 283 | |
fb41c4f3 DS |
284 | if (vrf && strncmp(vrf, "all", sizeof("all")) == 0) { |
285 | struct vrf *vrf; | |
d62a17ae | 286 | |
fb41c4f3 DS |
287 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { |
288 | eigrp = eigrp_lookup(vrf->vrf_id); | |
289 | if (!eigrp) | |
290 | continue; | |
d62a17ae | 291 | |
fb41c4f3 DS |
292 | vty_out(vty, "VRF %s:\n", vrf->name); |
293 | ||
294 | eigrp_neighbors_helper(vty, eigrp, ifname, detail); | |
295 | } | |
296 | } else { | |
297 | eigrp = eigrp_vty_get_eigrp(vty, vrf); | |
298 | if (eigrp == NULL) { | |
299 | vty_out(vty, " EIGRP Routing Process not enabled\n"); | |
300 | return CMD_SUCCESS; | |
d62a17ae | 301 | } |
fb41c4f3 DS |
302 | |
303 | eigrp_neighbors_helper(vty, eigrp, ifname, detail); | |
d62a17ae | 304 | } |
305 | ||
306 | return CMD_SUCCESS; | |
7f57883e DS |
307 | } |
308 | ||
7f57883e DS |
309 | /* |
310 | * Execute hard restart for all neighbors | |
311 | */ | |
cae06ae0 | 312 | DEFPY (clear_ip_eigrp_neighbors, |
7f57883e | 313 | clear_ip_eigrp_neighbors_cmd, |
cae06ae0 | 314 | "clear ip eigrp [vrf NAME] neighbors", |
7f57883e DS |
315 | CLEAR_STR |
316 | IP_STR | |
317 | "Clear IP-EIGRP\n" | |
cae06ae0 | 318 | VRF_CMD_HELP_STR |
7f57883e DS |
319 | "Clear IP-EIGRP neighbors\n") |
320 | { | |
d62a17ae | 321 | struct eigrp *eigrp; |
322 | struct eigrp_interface *ei; | |
323 | struct listnode *node, *node2, *nnode2; | |
324 | struct eigrp_neighbor *nbr; | |
325 | ||
326 | /* Check if eigrp process is enabled */ | |
cae06ae0 | 327 | eigrp = eigrp_vty_get_eigrp(vty, vrf); |
d62a17ae | 328 | if (eigrp == NULL) { |
329 | vty_out(vty, " EIGRP Routing Process not enabled\n"); | |
330 | return CMD_SUCCESS; | |
331 | } | |
332 | ||
333 | /* iterate over all eigrp interfaces */ | |
334 | for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) { | |
335 | /* send Goodbye Hello */ | |
336 | eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL); | |
337 | ||
338 | /* iterate over all neighbors on eigrp interface */ | |
339 | for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) { | |
340 | if (nbr->state != EIGRP_NEIGHBOR_DOWN) { | |
341 | zlog_debug( | |
37b4b3cc DS |
342 | "Neighbor %pI4 (%s) is down: manually cleared", |
343 | &nbr->src, | |
d62a17ae | 344 | ifindex2ifname(nbr->ei->ifp->ifindex, |
daa64bdf | 345 | eigrp->vrf_id)); |
d62a17ae | 346 | vty_time_print(vty, 0); |
347 | vty_out(vty, | |
37b4b3cc DS |
348 | "Neighbor %pI4 (%s) is down: manually cleared\n", |
349 | &nbr->src, | |
d62a17ae | 350 | ifindex2ifname(nbr->ei->ifp->ifindex, |
daa64bdf | 351 | eigrp->vrf_id)); |
d62a17ae | 352 | |
353 | /* set neighbor to DOWN */ | |
354 | nbr->state = EIGRP_NEIGHBOR_DOWN; | |
355 | /* delete neighbor */ | |
356 | eigrp_nbr_delete(nbr); | |
357 | } | |
358 | } | |
359 | } | |
360 | ||
361 | return CMD_SUCCESS; | |
7f57883e DS |
362 | } |
363 | ||
364 | /* | |
365 | * Execute hard restart for all neighbors on interface | |
366 | */ | |
cae06ae0 | 367 | DEFPY (clear_ip_eigrp_neighbors_int, |
7f57883e | 368 | clear_ip_eigrp_neighbors_int_cmd, |
cae06ae0 | 369 | "clear ip eigrp [vrf NAME] neighbors IFNAME", |
7f57883e DS |
370 | CLEAR_STR |
371 | IP_STR | |
372 | "Clear IP-EIGRP\n" | |
cae06ae0 | 373 | VRF_CMD_HELP_STR |
7f57883e DS |
374 | "Clear IP-EIGRP neighbors\n" |
375 | "Interface's name\n") | |
376 | { | |
d62a17ae | 377 | struct eigrp *eigrp; |
378 | struct eigrp_interface *ei; | |
379 | struct listnode *node2, *nnode2; | |
380 | struct eigrp_neighbor *nbr; | |
d62a17ae | 381 | |
382 | /* Check if eigrp process is enabled */ | |
cae06ae0 | 383 | eigrp = eigrp_vty_get_eigrp(vty, vrf); |
d62a17ae | 384 | if (eigrp == NULL) { |
385 | vty_out(vty, " EIGRP Routing Process not enabled\n"); | |
386 | return CMD_SUCCESS; | |
387 | } | |
388 | ||
389 | /* lookup interface by specified name */ | |
cae06ae0 | 390 | ei = eigrp_if_lookup_by_name(eigrp, ifname); |
d62a17ae | 391 | if (ei == NULL) { |
cae06ae0 | 392 | vty_out(vty, " Interface (%s) doesn't exist\n", ifname); |
d62a17ae | 393 | return CMD_WARNING; |
394 | } | |
395 | ||
396 | /* send Goodbye Hello */ | |
397 | eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL); | |
398 | ||
399 | /* iterate over all neighbors on eigrp interface */ | |
400 | for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) { | |
401 | if (nbr->state != EIGRP_NEIGHBOR_DOWN) { | |
37b4b3cc DS |
402 | zlog_debug( |
403 | "Neighbor %pI4 (%s) is down: manually cleared", | |
404 | &nbr->src, | |
405 | ifindex2ifname(nbr->ei->ifp->ifindex, | |
406 | eigrp->vrf_id)); | |
d62a17ae | 407 | vty_time_print(vty, 0); |
408 | vty_out(vty, | |
37b4b3cc DS |
409 | "Neighbor %pI4 (%s) is down: manually cleared\n", |
410 | &nbr->src, | |
d62a17ae | 411 | ifindex2ifname(nbr->ei->ifp->ifindex, |
daa64bdf | 412 | eigrp->vrf_id)); |
d62a17ae | 413 | |
414 | /* set neighbor to DOWN */ | |
415 | nbr->state = EIGRP_NEIGHBOR_DOWN; | |
416 | /* delete neighbor */ | |
417 | eigrp_nbr_delete(nbr); | |
418 | } | |
419 | } | |
420 | ||
421 | return CMD_SUCCESS; | |
7f57883e DS |
422 | } |
423 | ||
424 | /* | |
425 | * Execute hard restart for neighbor specified by IP | |
426 | */ | |
cae06ae0 | 427 | DEFPY (clear_ip_eigrp_neighbors_IP, |
7f57883e | 428 | clear_ip_eigrp_neighbors_IP_cmd, |
cae06ae0 | 429 | "clear ip eigrp [vrf NAME] neighbors A.B.C.D$nbr_addr", |
7f57883e DS |
430 | CLEAR_STR |
431 | IP_STR | |
432 | "Clear IP-EIGRP\n" | |
cae06ae0 | 433 | VRF_CMD_HELP_STR |
7f57883e DS |
434 | "Clear IP-EIGRP neighbors\n" |
435 | "IP-EIGRP neighbor address\n") | |
436 | { | |
d62a17ae | 437 | struct eigrp *eigrp; |
438 | struct eigrp_neighbor *nbr; | |
d62a17ae | 439 | |
440 | /* Check if eigrp process is enabled */ | |
cae06ae0 | 441 | eigrp = eigrp_vty_get_eigrp(vty, vrf); |
d62a17ae | 442 | if (eigrp == NULL) { |
443 | vty_out(vty, " EIGRP Routing Process not enabled\n"); | |
444 | return CMD_SUCCESS; | |
445 | } | |
446 | ||
447 | /* lookup neighbor in whole process */ | |
448 | nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr); | |
449 | ||
450 | /* if neighbor doesn't exists, notify user and exit */ | |
451 | if (nbr == NULL) { | |
452 | vty_out(vty, "Neighbor with entered address doesn't exists.\n"); | |
453 | return CMD_WARNING; | |
454 | } | |
455 | ||
456 | /* execute hard reset on neighbor */ | |
457 | eigrp_nbr_hard_restart(nbr, vty); | |
458 | ||
459 | return CMD_SUCCESS; | |
7f57883e DS |
460 | } |
461 | ||
462 | /* | |
463 | * Execute graceful restart for all neighbors | |
464 | */ | |
cae06ae0 | 465 | DEFPY (clear_ip_eigrp_neighbors_soft, |
7f57883e | 466 | clear_ip_eigrp_neighbors_soft_cmd, |
cae06ae0 | 467 | "clear ip eigrp [vrf NAME] neighbors soft", |
7f57883e DS |
468 | CLEAR_STR |
469 | IP_STR | |
470 | "Clear IP-EIGRP\n" | |
cae06ae0 | 471 | VRF_CMD_HELP_STR |
7f57883e DS |
472 | "Clear IP-EIGRP neighbors\n" |
473 | "Resync with peers without adjacency reset\n") | |
474 | { | |
d62a17ae | 475 | struct eigrp *eigrp; |
7f57883e | 476 | |
d62a17ae | 477 | /* Check if eigrp process is enabled */ |
cae06ae0 | 478 | eigrp = eigrp_vty_get_eigrp(vty, vrf); |
d62a17ae | 479 | if (eigrp == NULL) { |
480 | vty_out(vty, " EIGRP Routing Process not enabled\n"); | |
481 | return CMD_SUCCESS; | |
482 | } | |
7f57883e | 483 | |
d62a17ae | 484 | /* execute graceful restart on all neighbors */ |
485 | eigrp_update_send_process_GR(eigrp, EIGRP_GR_MANUAL, vty); | |
7f57883e | 486 | |
d62a17ae | 487 | return CMD_SUCCESS; |
7f57883e DS |
488 | } |
489 | ||
490 | /* | |
491 | * Execute graceful restart for all neighbors on interface | |
492 | */ | |
cae06ae0 | 493 | DEFPY (clear_ip_eigrp_neighbors_int_soft, |
7f57883e | 494 | clear_ip_eigrp_neighbors_int_soft_cmd, |
cae06ae0 | 495 | "clear ip eigrp [vrf NAME] neighbors IFNAME soft", |
7f57883e DS |
496 | CLEAR_STR |
497 | IP_STR | |
498 | "Clear IP-EIGRP\n" | |
cae06ae0 | 499 | VRF_CMD_HELP_STR |
7f57883e DS |
500 | "Clear IP-EIGRP neighbors\n" |
501 | "Interface's name\n" | |
502 | "Resync with peer without adjacency reset\n") | |
503 | { | |
d62a17ae | 504 | struct eigrp *eigrp; |
505 | struct eigrp_interface *ei; | |
506 | ||
507 | /* Check if eigrp process is enabled */ | |
cae06ae0 | 508 | eigrp = eigrp_vty_get_eigrp(vty, vrf); |
d62a17ae | 509 | if (eigrp == NULL) { |
510 | vty_out(vty, " EIGRP Routing Process not enabled\n"); | |
511 | return CMD_SUCCESS; | |
512 | } | |
513 | ||
514 | /* lookup interface by specified name */ | |
cae06ae0 | 515 | ei = eigrp_if_lookup_by_name(eigrp, ifname); |
d62a17ae | 516 | if (ei == NULL) { |
517 | vty_out(vty, " Interface (%s) doesn't exist\n", argv[4]->arg); | |
518 | return CMD_WARNING; | |
519 | } | |
520 | ||
521 | /* execute graceful restart for all neighbors on interface */ | |
522 | eigrp_update_send_interface_GR(ei, EIGRP_GR_MANUAL, vty); | |
523 | return CMD_SUCCESS; | |
7f57883e DS |
524 | } |
525 | ||
526 | /* | |
527 | * Execute graceful restart for neighbor specified by IP | |
528 | */ | |
cae06ae0 | 529 | DEFPY (clear_ip_eigrp_neighbors_IP_soft, |
7f57883e | 530 | clear_ip_eigrp_neighbors_IP_soft_cmd, |
cae06ae0 | 531 | "clear ip eigrp [vrf NAME] neighbors A.B.C.D$nbr_addr soft", |
7f57883e DS |
532 | CLEAR_STR |
533 | IP_STR | |
534 | "Clear IP-EIGRP\n" | |
cae06ae0 | 535 | VRF_CMD_HELP_STR |
7f57883e DS |
536 | "Clear IP-EIGRP neighbors\n" |
537 | "IP-EIGRP neighbor address\n" | |
538 | "Resync with peer without adjacency reset\n") | |
539 | { | |
d62a17ae | 540 | struct eigrp *eigrp; |
541 | struct eigrp_neighbor *nbr; | |
d62a17ae | 542 | |
d62a17ae | 543 | |
544 | /* Check if eigrp process is enabled */ | |
cae06ae0 | 545 | eigrp = eigrp_vty_get_eigrp(vty, vrf); |
d62a17ae | 546 | if (eigrp == NULL) { |
547 | vty_out(vty, " EIGRP Routing Process not enabled\n"); | |
548 | return CMD_SUCCESS; | |
549 | } | |
550 | ||
551 | /* lookup neighbor in whole process */ | |
552 | nbr = eigrp_nbr_lookup_by_addr_process(eigrp, nbr_addr); | |
553 | ||
554 | /* if neighbor doesn't exists, notify user and exit */ | |
555 | if (nbr == NULL) { | |
556 | vty_out(vty, "Neighbor with entered address doesn't exists.\n"); | |
557 | return CMD_WARNING; | |
558 | } | |
559 | ||
560 | /* execute graceful restart on neighbor */ | |
561 | eigrp_update_send_GR(nbr, EIGRP_GR_MANUAL, vty); | |
562 | ||
563 | return CMD_SUCCESS; | |
7f57883e DS |
564 | } |
565 | ||
d62a17ae | 566 | void eigrp_vty_show_init(void) |
7f57883e | 567 | { |
d62a17ae | 568 | install_element(VIEW_NODE, &show_ip_eigrp_interfaces_cmd); |
7f57883e | 569 | |
d62a17ae | 570 | install_element(VIEW_NODE, &show_ip_eigrp_neighbors_cmd); |
7f57883e | 571 | |
d62a17ae | 572 | install_element(VIEW_NODE, &show_ip_eigrp_topology_cmd); |
13133652 | 573 | install_element(VIEW_NODE, &show_ip_eigrp_topology_all_cmd); |
7f57883e DS |
574 | } |
575 | ||
7f57883e | 576 | /* Install EIGRP related vty commands. */ |
d62a17ae | 577 | void eigrp_vty_init(void) |
7f57883e | 578 | { |
d62a17ae | 579 | /* commands for manual hard restart */ |
580 | install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_cmd); | |
581 | install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_cmd); | |
582 | install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_cmd); | |
583 | /* commands for manual graceful restart */ | |
584 | install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_soft_cmd); | |
585 | install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_int_soft_cmd); | |
586 | install_element(ENABLE_NODE, &clear_ip_eigrp_neighbors_IP_soft_cmd); | |
7f57883e | 587 | } |