]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP nexthop scan |
2 | Copyright (C) 2000 Kunihiro Ishiguro | |
3 | ||
4 | This file is part of GNU Zebra. | |
5 | ||
6 | GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU General Public License as published by the | |
8 | Free Software Foundation; either version 2, or (at your option) any | |
9 | later version. | |
10 | ||
11 | GNU Zebra is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU Zebra; see the file COPYING. If not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | 02111-1307, USA. */ | |
20 | ||
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
24 | #include "thread.h" | |
25 | #include "prefix.h" | |
26 | #include "zclient.h" | |
27 | #include "stream.h" | |
28 | #include "network.h" | |
29 | #include "log.h" | |
30 | #include "memory.h" | |
10f9bf3f JBD |
31 | #include "hash.h" |
32 | #include "jhash.h" | |
fb018d25 | 33 | #include "nexthop.h" |
3f9c7369 | 34 | #include "queue.h" |
718e3744 | 35 | |
36 | #include "bgpd/bgpd.h" | |
37 | #include "bgpd/bgp_table.h" | |
38 | #include "bgpd/bgp_route.h" | |
39 | #include "bgpd/bgp_attr.h" | |
40 | #include "bgpd/bgp_nexthop.h" | |
fb018d25 | 41 | #include "bgpd/bgp_nht.h" |
718e3744 | 42 | #include "bgpd/bgp_debug.h" |
43 | #include "bgpd/bgp_damp.h" | |
8ffedcea | 44 | #include "bgpd/bgp_fsm.h" |
8386ac43 | 45 | #include "bgpd/bgp_vty.h" |
718e3744 | 46 | #include "zebra/rib.h" |
47 | #include "zebra/zserv.h" /* For ZEBRA_SERV_PATH. */ | |
48 | ||
fb018d25 | 49 | |
718e3744 | 50 | |
fb018d25 DS |
51 | char * |
52 | bnc_str (struct bgp_nexthop_cache *bnc, char *buf, int size) | |
53 | { | |
54 | prefix2str(&(bnc->node->p), buf, size); | |
55 | return buf; | |
56 | } | |
57 | ||
fb018d25 | 58 | void |
718e3744 | 59 | bnc_nexthop_free (struct bgp_nexthop_cache *bnc) |
60 | { | |
61 | struct nexthop *nexthop; | |
62 | struct nexthop *next = NULL; | |
63 | ||
64 | for (nexthop = bnc->nexthop; nexthop; nexthop = next) | |
65 | { | |
66 | next = nexthop->next; | |
67 | XFREE (MTYPE_NEXTHOP, nexthop); | |
68 | } | |
69 | } | |
70 | ||
fb018d25 | 71 | struct bgp_nexthop_cache * |
ffd0c037 | 72 | bnc_new (void) |
718e3744 | 73 | { |
fb018d25 DS |
74 | struct bgp_nexthop_cache *bnc; |
75 | ||
76 | bnc = XCALLOC (MTYPE_BGP_NEXTHOP_CACHE, sizeof (struct bgp_nexthop_cache)); | |
77 | LIST_INIT(&(bnc->paths)); | |
78 | return bnc; | |
718e3744 | 79 | } |
80 | ||
fb018d25 | 81 | void |
718e3744 | 82 | bnc_free (struct bgp_nexthop_cache *bnc) |
83 | { | |
84 | bnc_nexthop_free (bnc); | |
85 | XFREE (MTYPE_BGP_NEXTHOP_CACHE, bnc); | |
86 | } | |
6b0655a2 | 87 | |
718e3744 | 88 | /* Reset and free all BGP nexthop cache. */ |
94f2b392 | 89 | static void |
718e3744 | 90 | bgp_nexthop_cache_reset (struct bgp_table *table) |
91 | { | |
92 | struct bgp_node *rn; | |
93 | struct bgp_nexthop_cache *bnc; | |
94 | ||
95 | for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) | |
96 | if ((bnc = rn->info) != NULL) | |
97 | { | |
98 | bnc_free (bnc); | |
99 | rn->info = NULL; | |
100 | bgp_unlock_node (rn); | |
101 | } | |
102 | } | |
103 | ||
10f9bf3f JBD |
104 | /* BGP own address structure */ |
105 | struct bgp_addr | |
106 | { | |
107 | struct in_addr addr; | |
108 | int refcnt; | |
109 | }; | |
110 | ||
10f9bf3f JBD |
111 | static void * |
112 | bgp_address_hash_alloc (void *p) | |
113 | { | |
ffd0c037 | 114 | const struct in_addr *val = (const struct in_addr *)p; |
10f9bf3f JBD |
115 | struct bgp_addr *addr; |
116 | ||
117 | addr = XMALLOC (MTYPE_BGP_ADDR, sizeof (struct bgp_addr)); | |
118 | addr->refcnt = 0; | |
119 | addr->addr.s_addr = val->s_addr; | |
120 | ||
121 | return addr; | |
122 | } | |
123 | ||
124 | static unsigned int | |
125 | bgp_address_hash_key_make (void *p) | |
126 | { | |
127 | const struct bgp_addr *addr = p; | |
128 | ||
129 | return jhash_1word(addr->addr.s_addr, 0); | |
130 | } | |
131 | ||
132 | static int | |
133 | bgp_address_hash_cmp (const void *p1, const void *p2) | |
134 | { | |
135 | const struct bgp_addr *addr1 = p1; | |
136 | const struct bgp_addr *addr2 = p2; | |
137 | ||
138 | return addr1->addr.s_addr == addr2->addr.s_addr; | |
139 | } | |
140 | ||
141 | void | |
6aeb9e78 | 142 | bgp_address_init (struct bgp *bgp) |
10f9bf3f | 143 | { |
6aeb9e78 | 144 | bgp->address_hash = hash_create (bgp_address_hash_key_make, |
10f9bf3f JBD |
145 | bgp_address_hash_cmp); |
146 | } | |
147 | ||
148 | static void | |
6aeb9e78 | 149 | bgp_address_add (struct bgp *bgp, struct prefix *p) |
10f9bf3f JBD |
150 | { |
151 | struct bgp_addr tmp; | |
152 | struct bgp_addr *addr; | |
153 | ||
154 | tmp.addr = p->u.prefix4; | |
155 | ||
6aeb9e78 | 156 | addr = hash_get (bgp->address_hash, &tmp, bgp_address_hash_alloc); |
5ce10e92 DS |
157 | if (!addr) |
158 | return; | |
159 | ||
10f9bf3f JBD |
160 | addr->refcnt++; |
161 | } | |
162 | ||
163 | static void | |
6aeb9e78 | 164 | bgp_address_del (struct bgp *bgp, struct prefix *p) |
10f9bf3f JBD |
165 | { |
166 | struct bgp_addr tmp; | |
167 | struct bgp_addr *addr; | |
168 | ||
169 | tmp.addr = p->u.prefix4; | |
170 | ||
6aeb9e78 | 171 | addr = hash_lookup (bgp->address_hash, &tmp); |
9e47abd8 RG |
172 | /* may have been deleted earlier by bgp_interface_down() */ |
173 | if (addr == NULL) | |
174 | return; | |
175 | ||
10f9bf3f JBD |
176 | addr->refcnt--; |
177 | ||
178 | if (addr->refcnt == 0) | |
179 | { | |
6aeb9e78 | 180 | hash_release (bgp->address_hash, addr); |
10f9bf3f JBD |
181 | XFREE (MTYPE_BGP_ADDR, addr); |
182 | } | |
183 | } | |
184 | ||
6b0655a2 | 185 | |
5932020b | 186 | struct bgp_connected_ref |
718e3744 | 187 | { |
188 | unsigned int refcnt; | |
189 | }; | |
190 | ||
191 | void | |
6aeb9e78 | 192 | bgp_connected_add (struct bgp *bgp, struct connected *ifc) |
718e3744 | 193 | { |
194 | struct prefix p; | |
195 | struct prefix *addr; | |
718e3744 | 196 | struct bgp_node *rn; |
5932020b | 197 | struct bgp_connected_ref *bc; |
6aeb9e78 | 198 | struct listnode *node, *nnode; |
8ffedcea | 199 | struct peer *peer; |
718e3744 | 200 | |
718e3744 | 201 | addr = ifc->address; |
718e3744 | 202 | |
4608cb43 | 203 | p = *(CONNECTED_PREFIX(ifc)); |
718e3744 | 204 | if (addr->family == AF_INET) |
205 | { | |
718e3744 | 206 | apply_mask_ipv4 ((struct prefix_ipv4 *) &p); |
207 | ||
208 | if (prefix_ipv4_any ((struct prefix_ipv4 *) &p)) | |
209 | return; | |
210 | ||
6aeb9e78 | 211 | bgp_address_add (bgp, addr); |
10f9bf3f | 212 | |
6aeb9e78 | 213 | rn = bgp_node_get (bgp->connected_table[AFI_IP], (struct prefix *) &p); |
718e3744 | 214 | if (rn->info) |
215 | { | |
216 | bc = rn->info; | |
217 | bc->refcnt++; | |
218 | } | |
219 | else | |
220 | { | |
6c88b44d | 221 | bc = XCALLOC (MTYPE_BGP_CONN, sizeof (struct bgp_connected_ref)); |
718e3744 | 222 | bc->refcnt = 1; |
223 | rn->info = bc; | |
224 | } | |
8ffedcea | 225 | |
6aeb9e78 DS |
226 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
227 | { | |
228 | if (peer->conf_if && (strcmp (peer->conf_if, ifc->ifp->name) == 0) && | |
229 | !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
230 | { | |
231 | if (peer_active(peer)) | |
232 | BGP_EVENT_ADD (peer, BGP_Stop); | |
233 | BGP_EVENT_ADD (peer, BGP_Start); | |
234 | } | |
235 | } | |
718e3744 | 236 | } |
237 | #ifdef HAVE_IPV6 | |
e4529636 | 238 | else if (addr->family == AF_INET6) |
718e3744 | 239 | { |
718e3744 | 240 | apply_mask_ipv6 ((struct prefix_ipv6 *) &p); |
241 | ||
242 | if (IN6_IS_ADDR_UNSPECIFIED (&p.u.prefix6)) | |
243 | return; | |
244 | ||
245 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
246 | return; | |
247 | ||
6aeb9e78 | 248 | rn = bgp_node_get (bgp->connected_table[AFI_IP6], (struct prefix *) &p); |
718e3744 | 249 | if (rn->info) |
250 | { | |
251 | bc = rn->info; | |
252 | bc->refcnt++; | |
253 | } | |
254 | else | |
255 | { | |
6c88b44d | 256 | bc = XCALLOC (MTYPE_BGP_CONN, sizeof (struct bgp_connected_ref)); |
718e3744 | 257 | bc->refcnt = 1; |
258 | rn->info = bc; | |
259 | } | |
260 | } | |
261 | #endif /* HAVE_IPV6 */ | |
262 | } | |
263 | ||
264 | void | |
6aeb9e78 | 265 | bgp_connected_delete (struct bgp *bgp, struct connected *ifc) |
718e3744 | 266 | { |
267 | struct prefix p; | |
268 | struct prefix *addr; | |
718e3744 | 269 | struct bgp_node *rn; |
5932020b | 270 | struct bgp_connected_ref *bc; |
718e3744 | 271 | |
718e3744 | 272 | addr = ifc->address; |
718e3744 | 273 | |
4608cb43 | 274 | p = *(CONNECTED_PREFIX(ifc)); |
718e3744 | 275 | if (addr->family == AF_INET) |
276 | { | |
718e3744 | 277 | apply_mask_ipv4 ((struct prefix_ipv4 *) &p); |
278 | ||
279 | if (prefix_ipv4_any ((struct prefix_ipv4 *) &p)) | |
280 | return; | |
281 | ||
6aeb9e78 | 282 | bgp_address_del (bgp, addr); |
10f9bf3f | 283 | |
6aeb9e78 | 284 | rn = bgp_node_lookup (bgp->connected_table[AFI_IP], &p); |
718e3744 | 285 | if (! rn) |
286 | return; | |
287 | ||
288 | bc = rn->info; | |
289 | bc->refcnt--; | |
290 | if (bc->refcnt == 0) | |
291 | { | |
6c88b44d | 292 | XFREE (MTYPE_BGP_CONN, bc); |
718e3744 | 293 | rn->info = NULL; |
294 | } | |
295 | bgp_unlock_node (rn); | |
296 | bgp_unlock_node (rn); | |
297 | } | |
298 | #ifdef HAVE_IPV6 | |
299 | else if (addr->family == AF_INET6) | |
300 | { | |
718e3744 | 301 | apply_mask_ipv6 ((struct prefix_ipv6 *) &p); |
302 | ||
303 | if (IN6_IS_ADDR_UNSPECIFIED (&p.u.prefix6)) | |
304 | return; | |
305 | ||
306 | if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) | |
307 | return; | |
308 | ||
6aeb9e78 | 309 | rn = bgp_node_lookup (bgp->connected_table[AFI_IP6], (struct prefix *) &p); |
718e3744 | 310 | if (! rn) |
311 | return; | |
312 | ||
313 | bc = rn->info; | |
314 | bc->refcnt--; | |
315 | if (bc->refcnt == 0) | |
316 | { | |
6c88b44d | 317 | XFREE (MTYPE_BGP_CONN, bc); |
718e3744 | 318 | rn->info = NULL; |
319 | } | |
320 | bgp_unlock_node (rn); | |
321 | bgp_unlock_node (rn); | |
322 | } | |
323 | #endif /* HAVE_IPV6 */ | |
324 | } | |
325 | ||
326 | int | |
6aeb9e78 | 327 | bgp_nexthop_self (struct bgp *bgp, struct attr *attr) |
718e3744 | 328 | { |
10f9bf3f | 329 | struct bgp_addr tmp, *addr; |
718e3744 | 330 | |
10f9bf3f JBD |
331 | tmp.addr = attr->nexthop; |
332 | ||
6aeb9e78 | 333 | addr = hash_lookup (bgp->address_hash, &tmp); |
10f9bf3f JBD |
334 | if (addr) |
335 | return 1; | |
718e3744 | 336 | |
718e3744 | 337 | return 0; |
338 | } | |
6b0655a2 | 339 | |
718e3744 | 340 | int |
fc9a856f | 341 | bgp_multiaccess_check_v4 (struct in_addr nexthop, struct peer *peer) |
718e3744 | 342 | { |
343 | struct bgp_node *rn1; | |
344 | struct bgp_node *rn2; | |
fc9a856f | 345 | struct prefix p; |
718e3744 | 346 | int ret; |
347 | ||
fc9a856f DS |
348 | p.family = AF_INET; |
349 | p.prefixlen = IPV4_MAX_BITLEN; | |
350 | p.u.prefix4 = nexthop; | |
718e3744 | 351 | |
6aeb9e78 | 352 | rn1 = bgp_node_match (peer->bgp->connected_table[AFI_IP], &p); |
fc9a856f | 353 | if (!rn1) |
718e3744 | 354 | return 0; |
718e3744 | 355 | |
fc9a856f DS |
356 | p.family = AF_INET; |
357 | p.prefixlen = IPV4_MAX_BITLEN; | |
358 | p.u.prefix4 = peer->su.sin.sin_addr; | |
718e3744 | 359 | |
6aeb9e78 | 360 | rn2 = bgp_node_match (peer->bgp->connected_table[AFI_IP], &p); |
fc9a856f | 361 | if (!rn2) |
718e3744 | 362 | { |
fc9a856f DS |
363 | bgp_unlock_node(rn1); |
364 | return 0; | |
718e3744 | 365 | } |
366 | ||
fc9a856f | 367 | ret = (rn1 == rn2) ? 1 : 0; |
718e3744 | 368 | |
fc9a856f DS |
369 | bgp_unlock_node(rn1); |
370 | bgp_unlock_node(rn2); | |
718e3744 | 371 | |
fc9a856f | 372 | return (ret); |
718e3744 | 373 | } |
374 | ||
f186de26 | 375 | static void |
376 | bgp_show_nexthops (struct vty *vty, struct bgp *bgp, int detail) | |
fb018d25 DS |
377 | { |
378 | struct bgp_node *rn; | |
379 | struct bgp_nexthop_cache *bnc; | |
da11a696 | 380 | char buf[PREFIX2STR_BUFFER]; |
77217fd4 | 381 | struct nexthop *nexthop; |
fb018d25 | 382 | time_t tbuf; |
da11a696 | 383 | afi_t afi; |
fb018d25 DS |
384 | |
385 | vty_out (vty, "Current BGP nexthop cache:%s", VTY_NEWLINE); | |
da11a696 DS |
386 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
387 | { | |
6aeb9e78 | 388 | for (rn = bgp_table_top (bgp->nexthop_cache_table[afi]); rn; rn = bgp_route_next (rn)) |
fb018d25 | 389 | { |
da11a696 DS |
390 | if ((bnc = rn->info) != NULL) |
391 | { | |
392 | if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_VALID)) | |
77217fd4 | 393 | { |
da11a696 DS |
394 | vty_out (vty, " %s valid [IGP metric %d], #paths %d%s", |
395 | inet_ntop (rn->p.family, &rn->p.u.prefix, buf, sizeof (buf)), | |
396 | bnc->metric, bnc->path_count, VTY_NEWLINE); | |
397 | if (detail) | |
398 | for (nexthop = bnc->nexthop; nexthop; nexthop = nexthop->next) | |
399 | switch (nexthop->type) | |
400 | { | |
401 | case NEXTHOP_TYPE_IPV6: | |
402 | vty_out (vty, " gate %s%s", | |
403 | inet_ntop (AF_INET6, &nexthop->gate.ipv6, | |
404 | buf, sizeof (buf)), VTY_NEWLINE); | |
405 | break; | |
406 | case NEXTHOP_TYPE_IPV6_IFINDEX: | |
407 | vty_out(vty, " gate %s, if %s%s", | |
408 | inet_ntop(AF_INET6, &nexthop->gate.ipv6, buf, | |
409 | sizeof (buf)), | |
410 | ifindex2ifname(nexthop->ifindex), | |
411 | VTY_NEWLINE); | |
412 | break; | |
413 | case NEXTHOP_TYPE_IPV4: | |
414 | vty_out (vty, " gate %s%s", | |
415 | inet_ntop (AF_INET, &nexthop->gate.ipv4, buf, | |
416 | sizeof (buf)), VTY_NEWLINE); | |
417 | break; | |
418 | case NEXTHOP_TYPE_IFINDEX: | |
419 | vty_out (vty, " if %s%s", | |
420 | ifindex2ifname(nexthop->ifindex), VTY_NEWLINE); | |
421 | break; | |
422 | case NEXTHOP_TYPE_IPV4_IFINDEX: | |
423 | vty_out (vty, " gate %s, if %s%s", | |
424 | inet_ntop(AF_INET, &nexthop->gate.ipv4, buf, | |
425 | sizeof (buf)), | |
426 | ifindex2ifname(nexthop->ifindex), VTY_NEWLINE); | |
427 | break; | |
428 | default: | |
429 | vty_out (vty, " invalid nexthop type %u%s", | |
430 | nexthop->type, VTY_NEWLINE); | |
431 | } | |
432 | } | |
433 | else | |
434 | { | |
435 | vty_out (vty, " %s invalid%s", | |
436 | inet_ntop (rn->p.family, &rn->p.u.prefix, | |
437 | buf, sizeof (buf)), VTY_NEWLINE); | |
438 | if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)) | |
439 | vty_out (vty, " Must be Connected%s", VTY_NEWLINE); | |
77217fd4 | 440 | } |
fb018d25 | 441 | #ifdef HAVE_CLOCK_MONOTONIC |
da11a696 DS |
442 | tbuf = time(NULL) - (bgp_clock() - bnc->last_update); |
443 | vty_out (vty, " Last update: %s", ctime(&tbuf)); | |
fb018d25 | 444 | #else |
da11a696 | 445 | vty_out (vty, " Last update: %s", ctime(&bnc->uptime)); |
fb018d25 | 446 | #endif /* HAVE_CLOCK_MONOTONIC */ |
da11a696 DS |
447 | vty_out(vty, "%s", VTY_NEWLINE); |
448 | } | |
fb018d25 | 449 | } |
da11a696 | 450 | } |
f186de26 | 451 | } |
452 | ||
453 | static int | |
454 | show_ip_bgp_nexthop_table (struct vty *vty, const char *name, int detail) | |
455 | { | |
456 | struct bgp *bgp; | |
457 | ||
458 | if (name) | |
459 | bgp = bgp_lookup_by_name (name); | |
460 | else | |
461 | bgp = bgp_get_default (); | |
462 | if (!bgp) | |
463 | { | |
464 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
465 | return CMD_WARNING; | |
466 | } | |
467 | ||
468 | bgp_show_nexthops (vty, bgp, detail); | |
469 | ||
fb018d25 DS |
470 | return CMD_SUCCESS; |
471 | } | |
472 | ||
f186de26 | 473 | static void |
474 | bgp_show_all_instances_nexthops_vty (struct vty *vty) | |
475 | { | |
476 | struct listnode *node, *nnode; | |
477 | struct bgp *bgp; | |
478 | ||
479 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
480 | { | |
481 | vty_out (vty, "%sInstance %s:%s", | |
482 | VTY_NEWLINE, | |
483 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
484 | VTY_NEWLINE); | |
485 | bgp_show_nexthops (vty, bgp, 0); | |
486 | } | |
487 | } | |
488 | ||
fb018d25 DS |
489 | DEFUN (show_ip_bgp_nexthop, |
490 | show_ip_bgp_nexthop_cmd, | |
491 | "show ip bgp nexthop", | |
492 | SHOW_STR | |
493 | IP_STR | |
494 | BGP_STR | |
495 | "BGP nexthop table\n") | |
496 | { | |
6aeb9e78 | 497 | return show_ip_bgp_nexthop_table (vty, NULL, 0); |
fb018d25 DS |
498 | } |
499 | ||
500 | DEFUN (show_ip_bgp_nexthop_detail, | |
501 | show_ip_bgp_nexthop_detail_cmd, | |
502 | "show ip bgp nexthop detail", | |
503 | SHOW_STR | |
504 | IP_STR | |
505 | BGP_STR | |
506 | "BGP nexthop table\n") | |
507 | { | |
6aeb9e78 | 508 | return show_ip_bgp_nexthop_table (vty, NULL, 1); |
fb018d25 DS |
509 | } |
510 | ||
8386ac43 | 511 | DEFUN (show_ip_bgp_instance_nexthop, |
512 | show_ip_bgp_instance_nexthop_cmd, | |
513 | "show ip bgp " BGP_INSTANCE_CMD " nexthop", | |
50ef26d4 | 514 | SHOW_STR |
515 | IP_STR | |
516 | BGP_STR | |
8386ac43 | 517 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 518 | "BGP nexthop table\n") |
519 | { | |
520 | return show_ip_bgp_nexthop_table (vty, argv[1], 0); | |
521 | } | |
522 | ||
f186de26 | 523 | DEFUN (show_ip_bgp_instance_all_nexthop, |
524 | show_ip_bgp_instance_all_nexthop_cmd, | |
525 | "show ip bgp " BGP_INSTANCE_ALL_CMD " nexthop", | |
526 | SHOW_STR | |
527 | IP_STR | |
528 | BGP_STR | |
529 | BGP_INSTANCE_ALL_HELP_STR | |
530 | "BGP nexthop table\n") | |
531 | { | |
532 | bgp_show_all_instances_nexthops_vty (vty); | |
533 | return CMD_SUCCESS; | |
534 | } | |
535 | ||
8386ac43 | 536 | DEFUN (show_ip_bgp_instance_nexthop_detail, |
537 | show_ip_bgp_instance_nexthop_detail_cmd, | |
538 | "show ip bgp " BGP_INSTANCE_CMD " nexthop detail", | |
50ef26d4 | 539 | SHOW_STR |
540 | IP_STR | |
541 | BGP_STR | |
8386ac43 | 542 | BGP_INSTANCE_HELP_STR |
50ef26d4 | 543 | "BGP nexthop table\n") |
544 | { | |
545 | return show_ip_bgp_nexthop_table (vty, argv[1], 1); | |
546 | } | |
547 | ||
718e3744 | 548 | void |
6aeb9e78 | 549 | bgp_scan_init (struct bgp *bgp) |
718e3744 | 550 | { |
6aeb9e78 DS |
551 | bgp->nexthop_cache_table[AFI_IP] = bgp_table_init (AFI_IP, SAFI_UNICAST); |
552 | bgp->connected_table[AFI_IP] = bgp_table_init (AFI_IP, SAFI_UNICAST); | |
553 | bgp->import_check_table[AFI_IP] = bgp_table_init (AFI_IP, SAFI_UNICAST); | |
718e3744 | 554 | |
555 | #ifdef HAVE_IPV6 | |
6aeb9e78 DS |
556 | bgp->nexthop_cache_table[AFI_IP6] = bgp_table_init (AFI_IP6, SAFI_UNICAST); |
557 | bgp->connected_table[AFI_IP6] = bgp_table_init (AFI_IP6, SAFI_UNICAST); | |
558 | bgp->import_check_table[AFI_IP6] = bgp_table_init (AFI_IP6, SAFI_UNICAST); | |
718e3744 | 559 | #endif /* HAVE_IPV6 */ |
560 | ||
fc9a856f DS |
561 | } |
562 | ||
563 | void | |
ffd0c037 | 564 | bgp_scan_vty_init (void) |
fc9a856f DS |
565 | { |
566 | install_element (ENABLE_NODE, &show_ip_bgp_nexthop_cmd); | |
fb018d25 DS |
567 | install_element (VIEW_NODE, &show_ip_bgp_nexthop_cmd); |
568 | install_element (VIEW_NODE, &show_ip_bgp_nexthop_detail_cmd); | |
fb018d25 | 569 | install_element (ENABLE_NODE, &show_ip_bgp_nexthop_detail_cmd); |
8386ac43 | 570 | install_element (ENABLE_NODE, &show_ip_bgp_instance_nexthop_cmd); |
f186de26 | 571 | install_element (ENABLE_NODE, &show_ip_bgp_instance_all_nexthop_cmd); |
8386ac43 | 572 | install_element (VIEW_NODE, &show_ip_bgp_instance_nexthop_cmd); |
f186de26 | 573 | install_element (VIEW_NODE, &show_ip_bgp_instance_all_nexthop_cmd); |
8386ac43 | 574 | install_element (VIEW_NODE, &show_ip_bgp_instance_nexthop_detail_cmd); |
575 | install_element (ENABLE_NODE, &show_ip_bgp_instance_nexthop_detail_cmd); | |
718e3744 | 576 | } |
228da428 CC |
577 | |
578 | void | |
6aeb9e78 | 579 | bgp_scan_finish (struct bgp *bgp) |
228da428 | 580 | { |
6c88b44d | 581 | /* Only the current one needs to be reset. */ |
6aeb9e78 | 582 | bgp_nexthop_cache_reset (bgp->nexthop_cache_table[AFI_IP]); |
6c88b44d | 583 | |
6aeb9e78 DS |
584 | bgp_table_unlock (bgp->nexthop_cache_table[AFI_IP]); |
585 | bgp->nexthop_cache_table[AFI_IP] = NULL; | |
228da428 | 586 | |
6aeb9e78 DS |
587 | bgp_table_unlock (bgp->connected_table[AFI_IP]); |
588 | bgp->connected_table[AFI_IP] = NULL; | |
228da428 | 589 | |
6aeb9e78 DS |
590 | bgp_table_unlock (bgp->import_check_table[AFI_IP]); |
591 | bgp->import_check_table[AFI_IP] = NULL; | |
078430f6 | 592 | |
228da428 | 593 | #ifdef HAVE_IPV6 |
6c88b44d | 594 | /* Only the current one needs to be reset. */ |
6aeb9e78 | 595 | bgp_nexthop_cache_reset (bgp->nexthop_cache_table[AFI_IP6]); |
6c88b44d | 596 | |
6aeb9e78 DS |
597 | bgp_table_unlock (bgp->nexthop_cache_table[AFI_IP6]); |
598 | bgp->nexthop_cache_table[AFI_IP6] = NULL; | |
228da428 | 599 | |
6aeb9e78 DS |
600 | bgp_table_unlock (bgp->connected_table[AFI_IP6]); |
601 | bgp->connected_table[AFI_IP6] = NULL; | |
078430f6 | 602 | |
6aeb9e78 DS |
603 | bgp_table_unlock (bgp->import_check_table[AFI_IP6]); |
604 | bgp->import_check_table[AFI_IP6] = NULL; | |
228da428 CC |
605 | #endif /* HAVE_IPV6 */ |
606 | } |