blob: 9009638db9017714b11b454d3ea0e5f44e1b9a57 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
23#include "prefix.h"
24#include "linklist.h"
25#include "memory.h"
26#include "command.h"
27#include "stream.h"
28#include "filter.h"
29#include "str.h"
30#include "log.h"
31#include "routemap.h"
32#include "buffer.h"
33#include "sockunion.h"
34#include "plist.h"
35#include "thread.h"
36
37#include "bgpd/bgpd.h"
38#include "bgpd/bgp_table.h"
39#include "bgpd/bgp_route.h"
40#include "bgpd/bgp_attr.h"
41#include "bgpd/bgp_debug.h"
42#include "bgpd/bgp_aspath.h"
43#include "bgpd/bgp_regex.h"
44#include "bgpd/bgp_community.h"
45#include "bgpd/bgp_ecommunity.h"
46#include "bgpd/bgp_clist.h"
47#include "bgpd/bgp_packet.h"
48#include "bgpd/bgp_filter.h"
49#include "bgpd/bgp_fsm.h"
50#include "bgpd/bgp_mplsvpn.h"
51#include "bgpd/bgp_nexthop.h"
52#include "bgpd/bgp_damp.h"
53#include "bgpd/bgp_advertise.h"
54#include "bgpd/bgp_zebra.h"
hasso0a486e52005-02-01 20:57:17 +000055#include "bgpd/bgp_vty.h"
paul718e3742002-12-13 20:15:29 +000056
57/* Extern from bgp_dump.c */
58extern char *bgp_origin_str[];
59extern char *bgp_origin_long_str[];
60
61struct bgp_node *
paulfee0f4c2004-09-13 05:12:46 +000062bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
paul718e3742002-12-13 20:15:29 +000063 struct prefix_rd *prd)
64{
65 struct bgp_node *rn;
66 struct bgp_node *prn = NULL;
paul718e3742002-12-13 20:15:29 +000067
68 if (safi == SAFI_MPLS_VPN)
69 {
paulfee0f4c2004-09-13 05:12:46 +000070 prn = bgp_node_get (table, (struct prefix *) prd);
paul718e3742002-12-13 20:15:29 +000071
72 if (prn->info == NULL)
73 prn->info = bgp_table_init ();
74 else
75 bgp_unlock_node (prn);
76 table = prn->info;
77 }
paul718e3742002-12-13 20:15:29 +000078
79 rn = bgp_node_get (table, p);
80
81 if (safi == SAFI_MPLS_VPN)
82 rn->prn = prn;
83
84 return rn;
85}
86
87/* Allocate new bgp info structure. */
88struct bgp_info *
89bgp_info_new ()
90{
91 struct bgp_info *new;
92
93 new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
94 memset (new, 0, sizeof (struct bgp_info));
95
96 return new;
97}
98
99/* Free bgp route information. */
100void
101bgp_info_free (struct bgp_info *binfo)
102{
103 if (binfo->attr)
104 bgp_attr_unintern (binfo->attr);
105
106 if (binfo->damp_info)
107 bgp_damp_info_free (binfo->damp_info, 0);
108
109 XFREE (MTYPE_BGP_ROUTE, binfo);
110}
111
112void
113bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
114{
115 struct bgp_info *top;
116
117 top = rn->info;
118
119 ri->next = rn->info;
120 ri->prev = NULL;
121 if (top)
122 top->prev = ri;
123 rn->info = ri;
124}
125
126void
127bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
128{
129 if (ri->next)
130 ri->next->prev = ri->prev;
131 if (ri->prev)
132 ri->prev->next = ri->next;
133 else
134 rn->info = ri->next;
135}
136
137/* Get MED value. If MED value is missing and "bgp bestpath
138 missing-as-worst" is specified, treat it as the worst value. */
139u_int32_t
140bgp_med_value (struct attr *attr, struct bgp *bgp)
141{
142 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
143 return attr->med;
144 else
145 {
146 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
paul3b424972003-10-13 09:47:32 +0000147 return BGP_MED_MAX;
paul718e3742002-12-13 20:15:29 +0000148 else
149 return 0;
150 }
151}
152
153/* Compare two bgp route entity. br is preferable then return 1. */
154int
155bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist)
156{
157 u_int32_t new_pref;
158 u_int32_t exist_pref;
159 u_int32_t new_med;
160 u_int32_t exist_med;
161 struct in_addr new_id;
162 struct in_addr exist_id;
163 int new_cluster;
164 int exist_cluster;
165 int internal_as_route = 0;
166 int confed_as_route = 0;
167 int ret;
168
169 /* 0. Null check. */
170 if (new == NULL)
171 return 0;
172 if (exist == NULL)
173 return 1;
174
175 /* 1. Weight check. */
176 if (new->attr->weight > exist->attr->weight)
177 return 1;
178 if (new->attr->weight < exist->attr->weight)
179 return 0;
180
181 /* 2. Local preference check. */
182 if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
183 new_pref = new->attr->local_pref;
184 else
185 new_pref = bgp->default_local_pref;
186
187 if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
188 exist_pref = exist->attr->local_pref;
189 else
190 exist_pref = bgp->default_local_pref;
191
192 if (new_pref > exist_pref)
193 return 1;
194 if (new_pref < exist_pref)
195 return 0;
196
197 /* 3. Local route check. */
198 if (new->sub_type == BGP_ROUTE_STATIC)
199 return 1;
200 if (exist->sub_type == BGP_ROUTE_STATIC)
201 return 0;
202
203 if (new->sub_type == BGP_ROUTE_REDISTRIBUTE)
204 return 1;
205 if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE)
206 return 0;
207
208 if (new->sub_type == BGP_ROUTE_AGGREGATE)
209 return 1;
210 if (exist->sub_type == BGP_ROUTE_AGGREGATE)
211 return 0;
212
213 /* 4. AS path length check. */
214 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
215 {
216 if (new->attr->aspath->count < exist->attr->aspath->count)
217 return 1;
218 if (new->attr->aspath->count > exist->attr->aspath->count)
219 return 0;
220 }
221
222 /* 5. Origin check. */
223 if (new->attr->origin < exist->attr->origin)
224 return 1;
225 if (new->attr->origin > exist->attr->origin)
226 return 0;
227
228 /* 6. MED check. */
229 internal_as_route = (new->attr->aspath->length == 0
230 && exist->attr->aspath->length == 0);
231 confed_as_route = (new->attr->aspath->length > 0
232 && exist->attr->aspath->length > 0
233 && new->attr->aspath->count == 0
234 && exist->attr->aspath->count == 0);
235
236 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
237 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
238 && confed_as_route)
239 || aspath_cmp_left (new->attr->aspath, exist->attr->aspath)
240 || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath)
241 || internal_as_route)
242 {
243 new_med = bgp_med_value (new->attr, bgp);
244 exist_med = bgp_med_value (exist->attr, bgp);
245
246 if (new_med < exist_med)
247 return 1;
248 if (new_med > exist_med)
249 return 0;
250 }
251
252 /* 7. Peer type check. */
253 if (peer_sort (new->peer) == BGP_PEER_EBGP
254 && peer_sort (exist->peer) == BGP_PEER_IBGP)
255 return 1;
256 if (peer_sort (new->peer) == BGP_PEER_EBGP
257 && peer_sort (exist->peer) == BGP_PEER_CONFED)
258 return 1;
259 if (peer_sort (new->peer) == BGP_PEER_IBGP
260 && peer_sort (exist->peer) == BGP_PEER_EBGP)
261 return 0;
262 if (peer_sort (new->peer) == BGP_PEER_CONFED
263 && peer_sort (exist->peer) == BGP_PEER_EBGP)
264 return 0;
265
266 /* 8. IGP metric check. */
267 if (new->igpmetric < exist->igpmetric)
268 return 1;
269 if (new->igpmetric > exist->igpmetric)
270 return 0;
271
272 /* 9. Maximum path check. */
273
274 /* 10. If both paths are external, prefer the path that was received
275 first (the oldest one). This step minimizes route-flap, since a
276 newer path won't displace an older one, even if it was the
277 preferred route based on the additional decision criteria below. */
278 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
279 && peer_sort (new->peer) == BGP_PEER_EBGP
280 && peer_sort (exist->peer) == BGP_PEER_EBGP)
281 {
282 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
283 return 1;
284 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
285 return 0;
286 }
287
288 /* 11. Rourter-ID comparision. */
289 if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
290 new_id.s_addr = new->attr->originator_id.s_addr;
291 else
292 new_id.s_addr = new->peer->remote_id.s_addr;
293 if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
294 exist_id.s_addr = exist->attr->originator_id.s_addr;
295 else
296 exist_id.s_addr = exist->peer->remote_id.s_addr;
297
298 if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
299 return 1;
300 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
301 return 0;
302
303 /* 12. Cluster length comparision. */
304 if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
305 new_cluster = new->attr->cluster->length;
306 else
307 new_cluster = 0;
308 if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
309 exist_cluster = exist->attr->cluster->length;
310 else
311 exist_cluster = 0;
312
313 if (new_cluster < exist_cluster)
314 return 1;
315 if (new_cluster > exist_cluster)
316 return 0;
317
318 /* 13. Neighbor address comparision. */
319 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
320
321 if (ret == 1)
322 return 0;
323 if (ret == -1)
324 return 1;
325
326 return 1;
327}
328
329enum filter_type
330bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
331 afi_t afi, safi_t safi)
332{
333 struct bgp_filter *filter;
334
335 filter = &peer->filter[afi][safi];
336
337 if (DISTRIBUTE_IN_NAME (filter))
338 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
339 return FILTER_DENY;
340
341 if (PREFIX_LIST_IN_NAME (filter))
342 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
343 return FILTER_DENY;
344
345 if (FILTER_LIST_IN_NAME (filter))
346 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
347 return FILTER_DENY;
348
349 return FILTER_PERMIT;
350}
351
352enum filter_type
353bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
354 afi_t afi, safi_t safi)
355{
356 struct bgp_filter *filter;
357
358 filter = &peer->filter[afi][safi];
359
360 if (DISTRIBUTE_OUT_NAME (filter))
361 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
362 return FILTER_DENY;
363
364 if (PREFIX_LIST_OUT_NAME (filter))
365 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
366 return FILTER_DENY;
367
368 if (FILTER_LIST_OUT_NAME (filter))
369 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
370 return FILTER_DENY;
371
372 return FILTER_PERMIT;
373}
374
375/* If community attribute includes no_export then return 1. */
376int
377bgp_community_filter (struct peer *peer, struct attr *attr)
378{
379 if (attr->community)
380 {
381 /* NO_ADVERTISE check. */
382 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
383 return 1;
384
385 /* NO_EXPORT check. */
386 if (peer_sort (peer) == BGP_PEER_EBGP &&
387 community_include (attr->community, COMMUNITY_NO_EXPORT))
388 return 1;
389
390 /* NO_EXPORT_SUBCONFED check. */
391 if (peer_sort (peer) == BGP_PEER_EBGP
392 || peer_sort (peer) == BGP_PEER_CONFED)
393 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
394 return 1;
395 }
396 return 0;
397}
398
399/* Route reflection loop check. */
400static int
401bgp_cluster_filter (struct peer *peer, struct attr *attr)
402{
403 struct in_addr cluster_id;
404
405 if (attr->cluster)
406 {
407 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
408 cluster_id = peer->bgp->cluster_id;
409 else
410 cluster_id = peer->bgp->router_id;
411
412 if (cluster_loop_check (attr->cluster, cluster_id))
413 return 1;
414 }
415 return 0;
416}
417
418int
419bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
420 afi_t afi, safi_t safi)
421{
422 struct bgp_filter *filter;
423 struct bgp_info info;
424 route_map_result_t ret;
425
426 filter = &peer->filter[afi][safi];
427
428 /* Apply default weight value. */
429 attr->weight = peer->weight;
430
431 /* Route map apply. */
432 if (ROUTE_MAP_IN_NAME (filter))
433 {
434 /* Duplicate current value to new strucutre for modification. */
435 info.peer = peer;
436 info.attr = attr;
437
paulac41b2a2003-08-12 05:32:27 +0000438 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
439
paul718e3742002-12-13 20:15:29 +0000440 /* Apply BGP route map to the attribute. */
441 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
paulac41b2a2003-08-12 05:32:27 +0000442
443 peer->rmap_type = 0;
444
paul718e3742002-12-13 20:15:29 +0000445 if (ret == RMAP_DENYMATCH)
446 {
447 /* Free newly generated AS path and community by route-map. */
448 bgp_attr_flush (attr);
449 return RMAP_DENY;
450 }
451 }
452 return RMAP_PERMIT;
453}
454
455int
paulfee0f4c2004-09-13 05:12:46 +0000456bgp_export_modifier (struct peer *rsclient, struct peer *peer,
457 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
458{
459 struct bgp_filter *filter;
460 struct bgp_info info;
461 route_map_result_t ret;
462
463 filter = &peer->filter[afi][safi];
464
465 /* Route map apply. */
466 if (ROUTE_MAP_EXPORT_NAME (filter))
467 {
468 /* Duplicate current value to new strucutre for modification. */
469 info.peer = rsclient;
470 info.attr = attr;
471
472 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
473
474 /* Apply BGP route map to the attribute. */
475 ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
476
477 rsclient->rmap_type = 0;
478
479 if (ret == RMAP_DENYMATCH)
480 {
481 /* Free newly generated AS path and community by route-map. */
482 bgp_attr_flush (attr);
483 return RMAP_DENY;
484 }
485 }
486 return RMAP_PERMIT;
487}
488
489int
490bgp_import_modifier (struct peer *rsclient, struct peer *peer,
491 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
492{
493 struct bgp_filter *filter;
494 struct bgp_info info;
495 route_map_result_t ret;
496
497 filter = &rsclient->filter[afi][safi];
498
499 /* Apply default weight value. */
500 attr->weight = peer->weight;
501
502 /* Route map apply. */
503 if (ROUTE_MAP_IMPORT_NAME (filter))
504 {
505 /* Duplicate current value to new strucutre for modification. */
506 info.peer = peer;
507 info.attr = attr;
508
509 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
510
511 /* Apply BGP route map to the attribute. */
512 ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
513
514 peer->rmap_type = 0;
515
516 if (ret == RMAP_DENYMATCH)
517 {
518 /* Free newly generated AS path and community by route-map. */
519 bgp_attr_flush (attr);
520 return RMAP_DENY;
521 }
522 }
523 return RMAP_PERMIT;
524}
525
526int
paul718e3742002-12-13 20:15:29 +0000527bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
528 struct attr *attr, afi_t afi, safi_t safi)
529{
530 int ret;
531 char buf[SU_ADDRSTRLEN];
532 struct bgp_filter *filter;
533 struct bgp_info info;
534 struct peer *from;
535 struct bgp *bgp;
536 struct attr dummy_attr;
537 int transparent;
538 int reflect;
539
540 from = ri->peer;
541 filter = &peer->filter[afi][safi];
542 bgp = peer->bgp;
543
544#ifdef DISABLE_BGP_ANNOUNCE
545 return 0;
546#endif
547
paulfee0f4c2004-09-13 05:12:46 +0000548 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
549 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
550 return 0;
551
paul718e3742002-12-13 20:15:29 +0000552 /* Do not send back route to sender. */
553 if (from == peer)
554 return 0;
555
paul35be31b2004-05-01 18:17:04 +0000556 /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */
557 if (p->family == AF_INET
558 && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop))
559 return 0;
560#ifdef HAVE_IPV6
561 if (p->family == AF_INET6
562 && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop))
563 return 0;
564#endif
565
paul718e3742002-12-13 20:15:29 +0000566 /* Aggregate-address suppress check. */
567 if (ri->suppress)
568 if (! UNSUPPRESS_MAP_NAME (filter))
569 return 0;
570
571 /* Default route check. */
572 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
573 {
574 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
575 return 0;
576#ifdef HAVE_IPV6
577 else if (p->family == AF_INET6 && p->prefixlen == 0)
578 return 0;
579#endif /* HAVE_IPV6 */
580 }
581
paul286e1e72003-08-08 00:24:31 +0000582 /* Transparency check. */
583 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
584 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
585 transparent = 1;
586 else
587 transparent = 0;
588
paul718e3742002-12-13 20:15:29 +0000589 /* If community is not disabled check the no-export and local. */
paul286e1e72003-08-08 00:24:31 +0000590 if (! transparent && bgp_community_filter (peer, ri->attr))
paul718e3742002-12-13 20:15:29 +0000591 return 0;
592
593 /* If the attribute has originator-id and it is same as remote
594 peer's id. */
595 if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
596 {
597 if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->originator_id))
598 {
599 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000600 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000601 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
602 peer->host,
603 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
604 p->prefixlen);
605 return 0;
606 }
607 }
608
609 /* ORF prefix-list filter check */
610 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
611 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
612 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
613 if (peer->orf_plist[afi][safi])
614 {
615 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
616 return 0;
617 }
618
619 /* Output filter check. */
620 if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY)
621 {
622 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000623 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000624 "%s [Update:SEND] %s/%d is filtered",
625 peer->host,
626 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
627 p->prefixlen);
628 return 0;
629 }
630
631#ifdef BGP_SEND_ASPATH_CHECK
632 /* AS path loop check. */
633 if (aspath_loop_check (ri->attr->aspath, peer->as))
634 {
635 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000636 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000637 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
638 peer->host, peer->as);
639 return 0;
640 }
641#endif /* BGP_SEND_ASPATH_CHECK */
642
643 /* If we're a CONFED we need to loop check the CONFED ID too */
644 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
645 {
646 if (aspath_loop_check(ri->attr->aspath, bgp->confed_id))
647 {
648 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000649 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000650 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
651 peer->host,
652 bgp->confed_id);
653 return 0;
654 }
655 }
656
657 /* Route-Reflect check. */
658 if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP)
659 reflect = 1;
660 else
661 reflect = 0;
662
663 /* IBGP reflection check. */
664 if (reflect)
665 {
666 /* A route from a Client peer. */
667 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
668 {
669 /* Reflect to all the Non-Client peers and also to the
670 Client peers other than the originator. Originator check
671 is already done. So there is noting to do. */
672 /* no bgp client-to-client reflection check. */
673 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
674 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
675 return 0;
676 }
677 else
678 {
679 /* A route from a Non-client peer. Reflect to all other
680 clients. */
681 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
682 return 0;
683 }
684 }
685
686 /* For modify attribute, copy it to temporary structure. */
687 *attr = *ri->attr;
688
689 /* If local-preference is not set. */
690 if ((peer_sort (peer) == BGP_PEER_IBGP
691 || peer_sort (peer) == BGP_PEER_CONFED)
692 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
693 {
694 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
695 attr->local_pref = bgp->default_local_pref;
696 }
697
paul718e3742002-12-13 20:15:29 +0000698 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
699 if (peer_sort (peer) == BGP_PEER_EBGP
700 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
701 {
702 if (ri->peer != bgp->peer_self && ! transparent
703 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
704 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
705 }
706
707 /* next-hop-set */
708 if (transparent || reflect
709 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
710 && ((p->family == AF_INET && attr->nexthop.s_addr)
paul286e1e72003-08-08 00:24:31 +0000711#ifdef HAVE_IPV6
paulfee0f4c2004-09-13 05:12:46 +0000712 || (p->family == AF_INET6 &&
713 ! IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global))
paul286e1e72003-08-08 00:24:31 +0000714#endif /* HAVE_IPV6 */
715 )))
paul718e3742002-12-13 20:15:29 +0000716 {
717 /* NEXT-HOP Unchanged. */
718 }
719 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
720 || (p->family == AF_INET && attr->nexthop.s_addr == 0)
721#ifdef HAVE_IPV6
paulfee0f4c2004-09-13 05:12:46 +0000722 || (p->family == AF_INET6 &&
723 IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global))
paul718e3742002-12-13 20:15:29 +0000724#endif /* HAVE_IPV6 */
725 || (peer_sort (peer) == BGP_PEER_EBGP
726 && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0))
727 {
728 /* Set IPv4 nexthop. */
729 if (p->family == AF_INET)
730 {
731 if (safi == SAFI_MPLS_VPN)
732 memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
733 else
734 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
735 }
736#ifdef HAVE_IPV6
737 /* Set IPv6 nexthop. */
738 if (p->family == AF_INET6)
739 {
740 /* IPv6 global nexthop must be included. */
741 memcpy (&attr->mp_nexthop_global, &peer->nexthop.v6_global,
742 IPV6_MAX_BYTELEN);
743 attr->mp_nexthop_len = 16;
744 }
745#endif /* HAVE_IPV6 */
746 }
747
748#ifdef HAVE_IPV6
749 if (p->family == AF_INET6)
750 {
paulfee0f4c2004-09-13 05:12:46 +0000751 /* Left nexthop_local unchanged if so configured. */
752 if ( CHECK_FLAG (peer->af_flags[afi][safi],
753 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
754 {
755 if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) )
756 attr->mp_nexthop_len=32;
757 else
758 attr->mp_nexthop_len=16;
759 }
760
761 /* Default nexthop_local treatment for non-RS-Clients */
762 else
763 {
paul718e3742002-12-13 20:15:29 +0000764 /* Link-local address should not be transit to different peer. */
765 attr->mp_nexthop_len = 16;
766
767 /* Set link-local address for shared network peer. */
768 if (peer->shared_network
769 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
770 {
771 memcpy (&attr->mp_nexthop_local, &peer->nexthop.v6_local,
772 IPV6_MAX_BYTELEN);
773 attr->mp_nexthop_len = 32;
774 }
775
776 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
777 address.*/
778 if (reflect)
779 attr->mp_nexthop_len = 16;
780
781 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
782 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
783 attr->mp_nexthop_len = 16;
784 }
paulfee0f4c2004-09-13 05:12:46 +0000785
786 }
paul718e3742002-12-13 20:15:29 +0000787#endif /* HAVE_IPV6 */
788
789 /* If this is EBGP peer and remove-private-AS is set. */
790 if (peer_sort (peer) == BGP_PEER_EBGP
791 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
792 && aspath_private_as_check (attr->aspath))
793 attr->aspath = aspath_empty_get ();
794
795 /* Route map & unsuppress-map apply. */
796 if (ROUTE_MAP_OUT_NAME (filter)
797 || ri->suppress)
798 {
799 info.peer = peer;
800 info.attr = attr;
801
802 /* The route reflector is not allowed to modify the attributes
803 of the reflected IBGP routes. */
804 if (peer_sort (from) == BGP_PEER_IBGP
805 && peer_sort (peer) == BGP_PEER_IBGP)
806 {
807 dummy_attr = *attr;
808 info.attr = &dummy_attr;
809 }
paulac41b2a2003-08-12 05:32:27 +0000810
811 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
812
paul718e3742002-12-13 20:15:29 +0000813 if (ri->suppress)
814 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
815 else
816 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
817
paulac41b2a2003-08-12 05:32:27 +0000818 peer->rmap_type = 0;
819
paul718e3742002-12-13 20:15:29 +0000820 if (ret == RMAP_DENYMATCH)
821 {
822 bgp_attr_flush (attr);
823 return 0;
824 }
825 }
826 return 1;
827}
828
829int
paulfee0f4c2004-09-13 05:12:46 +0000830bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
831 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +0000832{
paulfee0f4c2004-09-13 05:12:46 +0000833 int ret;
834 char buf[SU_ADDRSTRLEN];
835 struct bgp_filter *filter;
836 struct bgp_info info;
837 struct peer *from;
838 struct bgp *bgp;
839
840 from = ri->peer;
841 filter = &rsclient->filter[afi][safi];
842 bgp = rsclient->bgp;
843
844#ifdef DISABLE_BGP_ANNOUNCE
845 return 0;
846#endif
847
848 /* Do not send back route to sender. */
849 if (from == rsclient)
850 return 0;
851
852 /* Aggregate-address suppress check. */
853 if (ri->suppress)
854 if (! UNSUPPRESS_MAP_NAME (filter))
855 return 0;
856
857 /* Default route check. */
858 if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
859 PEER_STATUS_DEFAULT_ORIGINATE))
860 {
861 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
862 return 0;
863#ifdef HAVE_IPV6
864 else if (p->family == AF_INET6 && p->prefixlen == 0)
865 return 0;
866#endif /* HAVE_IPV6 */
867 }
868
869 /* If the attribute has originator-id and it is same as remote
870 peer's id. */
871 if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
872 {
873 if (IPV4_ADDR_SAME (&rsclient->remote_id, &ri->attr->originator_id))
874 {
875 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000876 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +0000877 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
878 rsclient->host,
879 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
880 p->prefixlen);
881 return 0;
882 }
883 }
884
885 /* ORF prefix-list filter check */
886 if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
887 && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
888 || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
889 if (rsclient->orf_plist[afi][safi])
890 {
891 if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
892 return 0;
893 }
894
895 /* Output filter check. */
896 if (bgp_output_filter (rsclient, p, ri->attr, afi, safi) == FILTER_DENY)
897 {
898 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000899 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +0000900 "%s [Update:SEND] %s/%d is filtered",
901 rsclient->host,
902 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
903 p->prefixlen);
904 return 0;
905 }
906
907#ifdef BGP_SEND_ASPATH_CHECK
908 /* AS path loop check. */
909 if (aspath_loop_check (ri->attr->aspath, rsclient->as))
910 {
911 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000912 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +0000913 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
914 rsclient->host, rsclient->as);
915 return 0;
916 }
917#endif /* BGP_SEND_ASPATH_CHECK */
918
919 /* For modify attribute, copy it to temporary structure. */
920 *attr = *ri->attr;
921
922 /* next-hop-set */
923 if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
924#ifdef HAVE_IPV6
925 || (p->family == AF_INET6 &&
926 IN6_IS_ADDR_UNSPECIFIED(&attr->mp_nexthop_global))
927#endif /* HAVE_IPV6 */
928 )
929 {
930 /* Set IPv4 nexthop. */
931 if (p->family == AF_INET)
932 {
933 if (safi == SAFI_MPLS_VPN)
934 memcpy (&attr->mp_nexthop_global_in, &rsclient->nexthop.v4,
935 IPV4_MAX_BYTELEN);
936 else
937 memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
938 }
939#ifdef HAVE_IPV6
940 /* Set IPv6 nexthop. */
941 if (p->family == AF_INET6)
942 {
943 /* IPv6 global nexthop must be included. */
944 memcpy (&attr->mp_nexthop_global, &rsclient->nexthop.v6_global,
945
946 IPV6_MAX_BYTELEN);
947 attr->mp_nexthop_len = 16;
948 }
949#endif /* HAVE_IPV6 */
950 }
951
952#ifdef HAVE_IPV6
953 if (p->family == AF_INET6)
954 {
955 /* Left nexthop_local unchanged if so configured. */
956 if ( CHECK_FLAG (rsclient->af_flags[afi][safi],
957 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
958 {
959 if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) )
960 attr->mp_nexthop_len=32;
961 else
962 attr->mp_nexthop_len=16;
963 }
964
965 /* Default nexthop_local treatment for RS-Clients */
966 else
967 {
968 /* Announcer and RS-Client are both in the same network */
969 if (rsclient->shared_network && from->shared_network &&
970 (rsclient->ifindex == from->ifindex))
971 {
972 if ( IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local) )
973 attr->mp_nexthop_len=32;
974 else
975 attr->mp_nexthop_len=16;
976 }
977
978 /* Set link-local address for shared network peer. */
979 else if (rsclient->shared_network
980 && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
981 {
982 memcpy (&attr->mp_nexthop_local, &rsclient->nexthop.v6_local,
983 IPV6_MAX_BYTELEN);
984 attr->mp_nexthop_len = 32;
985 }
986
987 else
988 attr->mp_nexthop_len = 16;
989 }
990
991 }
992#endif /* HAVE_IPV6 */
993
994
995 /* If this is EBGP peer and remove-private-AS is set. */
996 if (peer_sort (rsclient) == BGP_PEER_EBGP
997 && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
998 && aspath_private_as_check (attr->aspath))
999 attr->aspath = aspath_empty_get ();
1000
1001 /* Route map & unsuppress-map apply. */
1002 if (ROUTE_MAP_OUT_NAME (filter) || ri->suppress)
1003 {
1004 info.peer = rsclient;
1005 info.attr = attr;
1006
1007 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
1008
1009 if (ri->suppress)
1010 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1011 else
1012 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1013
1014 rsclient->rmap_type = 0;
1015
1016 if (ret == RMAP_DENYMATCH)
1017 {
1018 bgp_attr_flush (attr);
1019 return 0;
1020 }
1021 }
1022
1023 return 1;
1024}
1025
1026struct bgp_info_pair
1027{
1028 struct bgp_info *old;
1029 struct bgp_info *new;
1030};
1031
1032void
1033bgp_best_selection (struct bgp *bgp, struct bgp_node *rn, struct bgp_info_pair *result)
1034{
paul718e3742002-12-13 20:15:29 +00001035 struct bgp_info *new_select;
1036 struct bgp_info *old_select;
paulfee0f4c2004-09-13 05:12:46 +00001037 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00001038 struct bgp_info *ri1;
1039 struct bgp_info *ri2;
1040
paul718e3742002-12-13 20:15:29 +00001041 /* bgp deterministic-med */
1042 new_select = NULL;
1043 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1044 for (ri1 = rn->info; ri1; ri1 = ri1->next)
1045 {
1046 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
1047 continue;
1048 if (BGP_INFO_HOLDDOWN (ri1))
1049 continue;
1050
1051 new_select = ri1;
1052 if (ri1->next)
1053 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
1054 {
1055 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
1056 continue;
1057 if (BGP_INFO_HOLDDOWN (ri2))
1058 continue;
1059
1060 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
1061 || aspath_cmp_left_confed (ri1->attr->aspath,
1062 ri2->attr->aspath))
1063 {
1064 if (bgp_info_cmp (bgp, ri2, new_select))
1065 {
1066 UNSET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED);
1067 new_select = ri2;
1068 }
1069
1070 SET_FLAG (ri2->flags, BGP_INFO_DMED_CHECK);
1071 }
1072 }
1073 SET_FLAG (new_select->flags, BGP_INFO_DMED_CHECK);
1074 SET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED);
1075 }
1076
1077 /* Check old selected route and new selected route. */
1078 old_select = NULL;
1079 new_select = NULL;
1080 for (ri = rn->info; ri; ri = ri->next)
1081 {
1082 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
1083 old_select = ri;
1084
1085 if (BGP_INFO_HOLDDOWN (ri))
1086 continue;
1087
1088 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
1089 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
1090 {
1091 UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK);
1092 continue;
1093 }
1094 UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK);
1095 UNSET_FLAG (ri->flags, BGP_INFO_DMED_SELECTED);
1096
1097 if (bgp_info_cmp (bgp, ri, new_select))
1098 new_select = ri;
1099 }
1100
paulfee0f4c2004-09-13 05:12:46 +00001101 result->old = old_select;
1102 result->new = new_select;
1103
1104 return;
1105}
1106
1107int
1108bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
1109 struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi)
1110 {
1111 struct prefix *p;
1112
1113 p = &rn->p;
1114
1115 /* Announce route to Established peer. */
1116 if (peer->status != Established)
1117 return 0;
1118
1119 /* Address family configuration check. */
1120 if (! peer->afc_nego[afi][safi])
1121 return 0;
1122
1123 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1124 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1125 PEER_STATUS_ORF_WAIT_REFRESH))
1126 return 0;
1127
1128 switch (rn->table->type)
1129 {
1130 case BGP_TABLE_MAIN:
1131 /* Announcement to peer->conf. If the route is filtered,
1132 withdraw it. */
1133 if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi))
1134 bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected);
1135 else
1136 bgp_adj_out_unset (rn, peer, p, afi, safi);
1137 break;
1138 case BGP_TABLE_RSCLIENT:
1139 /* Announcement to peer->conf. If the route is filtered,
1140 withdraw it. */
1141 if (selected && bgp_announce_check_rsclient
1142 (selected, peer, p, attr, afi, safi))
1143 bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected);
1144 else
1145 bgp_adj_out_unset (rn, peer, p, afi, safi);
1146 break;
1147 }
1148 return 0;
1149 }
1150
1151int
1152bgp_process_rsclient (struct bgp *bgp, struct peer *rsclient,
1153 struct bgp_node *rn, afi_t afi, safi_t safi)
1154{
1155 struct prefix *p;
1156 struct bgp_info *new_select;
1157 struct bgp_info *old_select;
1158 struct bgp_info_pair old_and_new;
1159 struct attr attr;
1160 struct peer_group *group;
1161 struct listnode *nn;
1162
1163 p = &rn->p;
1164
1165 /* Best path selection. */
1166 bgp_best_selection (bgp, rn, &old_and_new);
1167 new_select = old_and_new.new;
1168 old_select = old_and_new.old;
1169
1170 if (CHECK_FLAG(rsclient->sflags, PEER_STATUS_GROUP))
1171 {
1172 group = rsclient->group;
1173 LIST_LOOP(group->peer, rsclient, nn)
1174 {
1175 /* Nothing to do. */
1176 if (old_select && old_select == new_select)
1177 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1178 continue;
hasso338b3422005-02-23 14:27:24 +00001179
1180 if (old_select)
1181 UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED);
1182 if (new_select)
1183 {
1184 SET_FLAG (new_select->flags, BGP_INFO_SELECTED);
1185 UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED);
1186 }
paulfee0f4c2004-09-13 05:12:46 +00001187
1188 bgp_process_announce_selected (rsclient, new_select, rn, &attr,
1189 afi, safi);
1190 }
1191 return 0;
1192 }
1193
1194 bgp_process_announce_selected (rsclient, new_select, rn, &attr, afi, safi);
1195
1196 return 0;
1197}
1198
1199int
1200bgp_process_main (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1201 {
1202 struct prefix *p;
1203 struct bgp_info *new_select;
1204 struct bgp_info *old_select;
1205 struct bgp_info_pair old_and_new;
1206 struct listnode *nn;
1207 struct peer *peer;
1208 struct attr attr;
1209
1210 p = &rn->p;
1211
1212 /* Best path selection. */
1213 bgp_best_selection (bgp, rn, &old_and_new);
1214 old_select = old_and_new.old;
1215 new_select = old_and_new.new;
1216
1217 /* Nothing to do. */
1218 if (old_select && old_select == new_select)
1219 {
1220 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1221 {
1222 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED))
1223 bgp_zebra_announce (p, old_select, bgp);
1224 return 0;
1225 }
1226 }
paul718e3742002-12-13 20:15:29 +00001227
hasso338b3422005-02-23 14:27:24 +00001228 if (old_select)
1229 UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED);
1230 if (new_select)
1231 {
1232 SET_FLAG (new_select->flags, BGP_INFO_SELECTED);
1233 UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED);
1234 }
1235
1236
paul718e3742002-12-13 20:15:29 +00001237 /* Check each BGP peer. */
1238 LIST_LOOP (bgp->peer, peer, nn)
1239 {
paulfee0f4c2004-09-13 05:12:46 +00001240 bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi);
paul718e3742002-12-13 20:15:29 +00001241 }
1242
1243 /* FIB update. */
1244 if (safi == SAFI_UNICAST && ! bgp->name &&
1245 ! bgp_option_check (BGP_OPT_NO_FIB))
1246 {
1247 if (new_select
1248 && new_select->type == ZEBRA_ROUTE_BGP
1249 && new_select->sub_type == BGP_ROUTE_NORMAL)
1250 bgp_zebra_announce (p, new_select, bgp);
1251 else
1252 {
1253 /* Withdraw the route from the kernel. */
1254 if (old_select
1255 && old_select->type == ZEBRA_ROUTE_BGP
1256 && old_select->sub_type == BGP_ROUTE_NORMAL)
1257 bgp_zebra_withdraw (p, old_select);
1258 }
1259 }
1260 return 0;
1261}
1262
1263int
paulfee0f4c2004-09-13 05:12:46 +00001264bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1265{
1266 switch (rn->table->type)
1267 {
1268 case BGP_TABLE_MAIN:
1269 return bgp_process_main (bgp, rn, afi, safi);
1270 case BGP_TABLE_RSCLIENT:
1271 return bgp_process_rsclient (bgp, (struct peer *) rn->table->owner,
1272 rn, afi, safi);
1273 }
1274 return 0;
1275}
hasso0a486e52005-02-01 20:57:17 +00001276
1277int
1278bgp_maximum_prefix_restart_timer (struct thread *thread)
1279{
1280 struct peer *peer;
1281
1282 peer = THREAD_ARG (thread);
1283 peer->t_pmax_restart = NULL;
1284
1285 if (BGP_DEBUG (events, EVENTS))
1286 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1287 peer->host);
1288
1289 peer_clear (peer);
1290
1291 return 0;
1292}
1293
paulfee0f4c2004-09-13 05:12:46 +00001294int
paul5228ad22004-06-04 17:58:18 +00001295bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1296 safi_t safi, int always)
paul718e3742002-12-13 20:15:29 +00001297{
hassoe0701b72004-05-20 09:19:34 +00001298 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1299 return 0;
1300
1301 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +00001302 {
hassoe0701b72004-05-20 09:19:34 +00001303 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1304 && ! always)
1305 return 0;
paul718e3742002-12-13 20:15:29 +00001306
hassoe0701b72004-05-20 09:19:34 +00001307 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001308 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1309 "limit %ld", afi_safi_print (afi, safi), peer->host,
1310 peer->pcount[afi][safi], peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001311 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
paul718e3742002-12-13 20:15:29 +00001312
hassoe0701b72004-05-20 09:19:34 +00001313 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1314 return 0;
paul718e3742002-12-13 20:15:29 +00001315
hassoe0701b72004-05-20 09:19:34 +00001316 {
paul5228ad22004-06-04 17:58:18 +00001317 u_int8_t ndata[7];
hassoe0701b72004-05-20 09:19:34 +00001318
1319 if (safi == SAFI_MPLS_VPN)
1320 safi = BGP_SAFI_VPNV4;
paul5228ad22004-06-04 17:58:18 +00001321
1322 ndata[0] = (afi >> 8);
1323 ndata[1] = afi;
1324 ndata[2] = safi;
1325 ndata[3] = (peer->pmax[afi][safi] >> 24);
1326 ndata[4] = (peer->pmax[afi][safi] >> 16);
1327 ndata[5] = (peer->pmax[afi][safi] >> 8);
1328 ndata[6] = (peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001329
1330 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1331 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1332 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1333 }
hasso0a486e52005-02-01 20:57:17 +00001334
1335 /* restart timer start */
1336 if (peer->pmax_restart[afi][safi])
1337 {
1338 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1339
1340 if (BGP_DEBUG (events, EVENTS))
1341 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1342 peer->host, peer->v_pmax_restart);
1343
1344 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1345 peer->v_pmax_restart);
1346 }
1347
hassoe0701b72004-05-20 09:19:34 +00001348 return 1;
paul718e3742002-12-13 20:15:29 +00001349 }
hassoe0701b72004-05-20 09:19:34 +00001350 else
1351 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1352
1353 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1354 {
1355 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1356 && ! always)
1357 return 0;
1358
1359 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001360 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1361 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1362 peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001363 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1364 }
1365 else
1366 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
paul718e3742002-12-13 20:15:29 +00001367 return 0;
1368}
1369
1370void
1371bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1372 afi_t afi, safi_t safi)
1373{
1374 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1375 {
paulfee0f4c2004-09-13 05:12:46 +00001376 /* Ignore 'pcount' for RS-client tables */
1377 if ( rn->table->type == BGP_TABLE_MAIN)
1378 {
paul718e3742002-12-13 20:15:29 +00001379 peer->pcount[afi][safi]--;
1380 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001381 }
paul718e3742002-12-13 20:15:29 +00001382 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
1383 bgp_process (peer->bgp, rn, afi, safi);
1384 }
1385 bgp_info_delete (rn, ri);
1386 bgp_info_free (ri);
1387 bgp_unlock_node (rn);
1388}
1389
1390void
1391bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1392 afi_t afi, safi_t safi, int force)
1393{
1394 int valid;
1395 int status = BGP_DAMP_NONE;
1396
paulfee0f4c2004-09-13 05:12:46 +00001397 /* Ignore 'pcount' for RS-client tables */
1398 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) &&
1399 rn->table->type == BGP_TABLE_MAIN)
paul718e3742002-12-13 20:15:29 +00001400 {
hasso93406d82005-02-02 14:40:33 +00001401 if (! CHECK_FLAG (ri->flags, BGP_INFO_STALE))
1402 peer->pcount[afi][safi]--;
paul718e3742002-12-13 20:15:29 +00001403 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1404 }
1405
1406 if (! force)
1407 {
1408 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1409 && peer_sort (peer) == BGP_PEER_EBGP)
1410 status = bgp_damp_withdraw (ri, rn, afi, safi, 0);
1411
1412 if (status == BGP_DAMP_SUPPRESSED)
1413 return;
1414 }
1415
1416 valid = CHECK_FLAG (ri->flags, BGP_INFO_VALID);
1417 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
1418 bgp_process (peer->bgp, rn, afi, safi);
1419
1420 if (valid)
1421 SET_FLAG (ri->flags, BGP_INFO_VALID);
1422
1423 if (status != BGP_DAMP_USED)
1424 {
1425 bgp_info_delete (rn, ri);
1426 bgp_info_free (ri);
1427 bgp_unlock_node (rn);
1428 }
1429}
1430
paulfee0f4c2004-09-13 05:12:46 +00001431void
1432bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1433 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1434 int sub_type, struct prefix_rd *prd, u_char *tag)
1435{
1436 struct bgp_node *rn;
1437 struct bgp *bgp;
1438 struct attr new_attr;
1439 struct attr *attr_new;
1440 struct attr *attr_new2;
1441 struct bgp_info *ri;
1442 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001443 const char *reason;
paulfee0f4c2004-09-13 05:12:46 +00001444 char buf[SU_ADDRSTRLEN];
1445
1446 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1447 if (peer == rsclient)
1448 return;
1449
1450 bgp = peer->bgp;
1451 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1452
1453 /* Check previously received route. */
1454 for (ri = rn->info; ri; ri = ri->next)
1455 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1456 break;
1457
1458 /* AS path loop check. */
1459 if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi])
1460 {
1461 reason = "as-path contains our own AS;";
1462 goto filtered;
1463 }
1464
1465 /* Route reflector originator ID check. */
1466 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
1467 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->originator_id))
1468 {
1469 reason = "originator is us;";
1470 goto filtered;
1471 }
1472
1473 new_attr = *attr;
1474
1475 /* Apply export policy. */
1476 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1477 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1478 {
1479 reason = "export-policy;";
1480 goto filtered;
1481 }
1482
1483 attr_new2 = bgp_attr_intern (&new_attr);
1484
1485 /* Apply import policy. */
1486 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1487 {
1488 bgp_attr_unintern (attr_new2);
1489
1490 reason = "import-policy;";
1491 goto filtered;
1492 }
1493
1494 attr_new = bgp_attr_intern (&new_attr);
1495 bgp_attr_unintern (attr_new2);
1496
1497 /* IPv4 unicast next hop check. */
1498 if (afi == AFI_IP && safi == SAFI_UNICAST)
1499 {
1500 /* Next hop must not be 0.0.0.0 nor Class E address. */
1501 if (new_attr.nexthop.s_addr == 0
1502 || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000)
1503 {
1504 bgp_attr_unintern (attr_new);
1505
1506 reason = "martian next-hop;";
1507 goto filtered;
1508 }
1509 }
1510
1511 /* If the update is implicit withdraw. */
1512 if (ri)
1513 {
1514 ri->uptime = time (NULL);
1515
1516 /* Same attribute comes in. */
1517 if (attrhash_cmp (ri->attr, attr_new))
1518 {
1519
1520 UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1521
1522 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001523 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001524 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1525 peer->host,
1526 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1527 p->prefixlen, rsclient->host);
1528
1529 bgp_unlock_node (rn);
1530 bgp_attr_unintern (attr_new);
1531
1532 return;
1533 }
1534
1535 /* Received Logging. */
1536 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001537 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00001538 peer->host,
1539 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1540 p->prefixlen, rsclient->host);
1541
1542 /* The attribute is changed. */
1543 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1544
1545 /* Update to new attribute. */
1546 bgp_attr_unintern (ri->attr);
1547 ri->attr = attr_new;
1548
1549 /* Update MPLS tag. */
1550 if (safi == SAFI_MPLS_VPN)
1551 memcpy (ri->tag, tag, 3);
1552
1553 SET_FLAG (ri->flags, BGP_INFO_VALID);
1554
1555 /* Process change. */
1556 bgp_process (bgp, rn, afi, safi);
1557 bgp_unlock_node (rn);
1558
1559 return;
1560 }
1561
1562 /* Received Logging. */
1563 if (BGP_DEBUG (update, UPDATE_IN))
1564 {
ajsd2c1f162004-12-08 21:10:20 +00001565 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00001566 peer->host,
1567 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1568 p->prefixlen, rsclient->host);
1569 }
1570
1571 /* Make new BGP info. */
1572 new = bgp_info_new ();
1573 new->type = type;
1574 new->sub_type = sub_type;
1575 new->peer = peer;
1576 new->attr = attr_new;
1577 new->uptime = time (NULL);
1578
1579 /* Update MPLS tag. */
1580 if (safi == SAFI_MPLS_VPN)
1581 memcpy (new->tag, tag, 3);
1582
1583 SET_FLAG (new->flags, BGP_INFO_VALID);
1584
1585 /* Register new BGP information. */
1586 bgp_info_add (rn, new);
1587
1588 /* Process change. */
1589 bgp_process (bgp, rn, afi, safi);
1590
1591 return;
1592
1593 filtered:
1594
1595 /* This BGP update is filtered. Log the reason then update BGP entry. */
1596 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001597 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001598 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1599 peer->host,
1600 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1601 p->prefixlen, rsclient->host, reason);
1602
1603 if (ri)
1604 bgp_rib_withdraw (rn, ri, peer, afi, safi, 1);
1605
1606 bgp_unlock_node (rn);
1607
1608 return;
1609}
1610
1611void
1612bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1613 struct peer *peer, struct prefix *p, int type, int sub_type,
1614 struct prefix_rd *prd, u_char *tag)
1615 {
1616 struct bgp_node *rn;
1617 struct bgp_info *ri;
1618 char buf[SU_ADDRSTRLEN];
1619
1620 if (rsclient == peer)
1621 return;
1622
1623 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1624
1625 /* Lookup withdrawn route. */
1626 for (ri = rn->info; ri; ri = ri->next)
1627 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1628 break;
1629
1630 /* Withdraw specified route from routing table. */
1631 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1632 bgp_rib_withdraw (rn, ri, peer, afi, safi, 0);
1633 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001634 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001635 "%s Can't find the route %s/%d", peer->host,
1636 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1637 p->prefixlen);
1638
1639 /* Unlock bgp_node_get() lock. */
1640 bgp_unlock_node (rn);
1641 }
1642
paul718e3742002-12-13 20:15:29 +00001643int
paulfee0f4c2004-09-13 05:12:46 +00001644bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
paul718e3742002-12-13 20:15:29 +00001645 afi_t afi, safi_t safi, int type, int sub_type,
1646 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
1647{
1648 int ret;
1649 int aspath_loop_count = 0;
1650 struct bgp_node *rn;
1651 struct bgp *bgp;
1652 struct attr new_attr;
1653 struct attr *attr_new;
1654 struct bgp_info *ri;
1655 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001656 const char *reason;
paul718e3742002-12-13 20:15:29 +00001657 char buf[SU_ADDRSTRLEN];
1658
1659 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00001660 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00001661
1662 /* When peer's soft reconfiguration enabled. Record input packet in
1663 Adj-RIBs-In. */
1664 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
1665 && peer != bgp->peer_self && ! soft_reconfig)
1666 bgp_adj_in_set (rn, peer, attr);
1667
1668 /* Check previously received route. */
1669 for (ri = rn->info; ri; ri = ri->next)
1670 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1671 break;
1672
1673 /* AS path local-as loop check. */
1674 if (peer->change_local_as)
1675 {
1676 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
1677 aspath_loop_count = 1;
1678
1679 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
1680 {
1681 reason = "as-path contains our own AS;";
1682 goto filtered;
1683 }
1684 }
1685
1686 /* AS path loop check. */
1687 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
1688 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
1689 && aspath_loop_check(attr->aspath, bgp->confed_id)
1690 > peer->allowas_in[afi][safi]))
1691 {
1692 reason = "as-path contains our own AS;";
1693 goto filtered;
1694 }
1695
1696 /* Route reflector originator ID check. */
1697 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
1698 && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id))
1699 {
1700 reason = "originator is us;";
1701 goto filtered;
1702 }
1703
1704 /* Route reflector cluster ID check. */
1705 if (bgp_cluster_filter (peer, attr))
1706 {
1707 reason = "reflected from the same cluster;";
1708 goto filtered;
1709 }
1710
1711 /* Apply incoming filter. */
1712 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
1713 {
1714 reason = "filter;";
1715 goto filtered;
1716 }
1717
1718 /* Apply incoming route-map. */
1719 new_attr = *attr;
1720
1721 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
1722 {
1723 reason = "route-map;";
1724 goto filtered;
1725 }
1726
1727 /* IPv4 unicast next hop check. */
1728 if (afi == AFI_IP && safi == SAFI_UNICAST)
1729 {
1730 /* If the peer is EBGP and nexthop is not on connected route,
1731 discard it. */
1732 if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1
1733 && ! bgp_nexthop_check_ebgp (afi, &new_attr)
hasso6ffd2072005-02-02 14:50:11 +00001734 && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
paul718e3742002-12-13 20:15:29 +00001735 {
1736 reason = "non-connected next-hop;";
1737 goto filtered;
1738 }
1739
1740 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
1741 must not be my own address. */
1742 if (bgp_nexthop_self (afi, &new_attr)
1743 || new_attr.nexthop.s_addr == 0
1744 || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000)
1745 {
1746 reason = "martian next-hop;";
1747 goto filtered;
1748 }
1749 }
1750
1751 attr_new = bgp_attr_intern (&new_attr);
1752
1753 /* If the update is implicit withdraw. */
1754 if (ri)
1755 {
1756 ri->uptime = time (NULL);
1757
1758 /* Same attribute comes in. */
1759 if (attrhash_cmp (ri->attr, attr_new))
1760 {
1761 UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1762
1763 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1764 && peer_sort (peer) == BGP_PEER_EBGP
1765 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1766 {
1767 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001768 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00001769 peer->host,
1770 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1771 p->prefixlen);
1772
1773 peer->pcount[afi][safi]++;
1774 ret = bgp_damp_update (ri, rn, afi, safi);
1775 if (ret != BGP_DAMP_SUPPRESSED)
1776 {
1777 bgp_aggregate_increment (bgp, p, ri, afi, safi);
1778 bgp_process (bgp, rn, afi, safi);
1779 }
1780 }
1781 else
1782 {
1783 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001784 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00001785 "%s rcvd %s/%d...duplicate ignored",
1786 peer->host,
1787 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1788 p->prefixlen);
hasso93406d82005-02-02 14:40:33 +00001789
1790 /* graceful restart STALE flag unset. */
1791 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
1792 {
1793 UNSET_FLAG (ri->flags, BGP_INFO_STALE);
1794 peer->pcount[afi][safi]++;
1795 }
paul718e3742002-12-13 20:15:29 +00001796 }
1797
1798 bgp_unlock_node (rn);
1799 bgp_attr_unintern (attr_new);
1800 return 0;
1801 }
1802
1803 /* Received Logging. */
1804 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001805 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00001806 peer->host,
1807 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1808 p->prefixlen);
1809
hasso93406d82005-02-02 14:40:33 +00001810 /* graceful restart STALE flag unset. */
1811 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
1812 {
1813 UNSET_FLAG (ri->flags, BGP_INFO_STALE);
1814 peer->pcount[afi][safi]++;
1815 }
1816
paul718e3742002-12-13 20:15:29 +00001817 /* The attribute is changed. */
1818 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1819
1820 /* Update bgp route dampening information. */
1821 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1822 && peer_sort (peer) == BGP_PEER_EBGP)
1823 {
1824 /* This is implicit withdraw so we should update dampening
1825 information. */
1826 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1827 bgp_damp_withdraw (ri, rn, afi, safi, 1);
1828 else
1829 peer->pcount[afi][safi]++;
1830 }
1831
1832 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
1833
1834 /* Update to new attribute. */
1835 bgp_attr_unintern (ri->attr);
1836 ri->attr = attr_new;
1837
1838 /* Update MPLS tag. */
1839 if (safi == SAFI_MPLS_VPN)
1840 memcpy (ri->tag, tag, 3);
1841
1842 /* Update bgp route dampening information. */
1843 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1844 && peer_sort (peer) == BGP_PEER_EBGP)
1845 {
1846 /* Now we do normal update dampening. */
1847 ret = bgp_damp_update (ri, rn, afi, safi);
1848 if (ret == BGP_DAMP_SUPPRESSED)
1849 {
1850 bgp_unlock_node (rn);
1851 return 0;
1852 }
1853 }
1854
1855 /* Nexthop reachability check. */
1856 if ((afi == AFI_IP || afi == AFI_IP6)
1857 && safi == SAFI_UNICAST
1858 && (peer_sort (peer) == BGP_PEER_IBGP
1859 || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00001860 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00001861 {
1862 if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
1863 SET_FLAG (ri->flags, BGP_INFO_VALID);
1864 else
1865 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
1866 }
1867 else
1868 SET_FLAG (ri->flags, BGP_INFO_VALID);
1869
1870 /* Process change. */
1871 bgp_aggregate_increment (bgp, p, ri, afi, safi);
1872
1873 bgp_process (bgp, rn, afi, safi);
1874 bgp_unlock_node (rn);
1875 return 0;
1876 }
1877
1878 /* Received Logging. */
1879 if (BGP_DEBUG (update, UPDATE_IN))
1880 {
ajsd2c1f162004-12-08 21:10:20 +00001881 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00001882 peer->host,
1883 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1884 p->prefixlen);
1885 }
1886
1887 /* Increment prefix counter */
1888 peer->pcount[afi][safi]++;
1889
1890 /* Make new BGP info. */
1891 new = bgp_info_new ();
1892 new->type = type;
1893 new->sub_type = sub_type;
1894 new->peer = peer;
1895 new->attr = attr_new;
1896 new->uptime = time (NULL);
1897
1898 /* Update MPLS tag. */
1899 if (safi == SAFI_MPLS_VPN)
1900 memcpy (new->tag, tag, 3);
1901
1902 /* Nexthop reachability check. */
1903 if ((afi == AFI_IP || afi == AFI_IP6)
1904 && safi == SAFI_UNICAST
1905 && (peer_sort (peer) == BGP_PEER_IBGP
1906 || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00001907 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00001908 {
1909 if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
1910 SET_FLAG (new->flags, BGP_INFO_VALID);
1911 else
1912 UNSET_FLAG (new->flags, BGP_INFO_VALID);
1913 }
1914 else
1915 SET_FLAG (new->flags, BGP_INFO_VALID);
1916
1917 /* Aggregate address increment. */
1918 bgp_aggregate_increment (bgp, p, new, afi, safi);
1919
1920 /* Register new BGP information. */
1921 bgp_info_add (rn, new);
1922
1923 /* If maximum prefix count is configured and current prefix
1924 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00001925 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
1926 return -1;
paul718e3742002-12-13 20:15:29 +00001927
1928 /* Process change. */
1929 bgp_process (bgp, rn, afi, safi);
1930
1931 return 0;
1932
1933 /* This BGP update is filtered. Log the reason then update BGP
1934 entry. */
1935 filtered:
1936 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001937 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00001938 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
1939 peer->host,
1940 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1941 p->prefixlen, reason);
1942
1943 if (ri)
1944 bgp_rib_withdraw (rn, ri, peer, afi, safi, 1);
1945
1946 bgp_unlock_node (rn);
1947
1948 return 0;
1949}
1950
1951int
paulfee0f4c2004-09-13 05:12:46 +00001952bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
1953 afi_t afi, safi_t safi, int type, int sub_type,
1954 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
1955{
1956 struct peer *rsclient;
1957 struct listnode *nn;
1958 struct bgp *bgp;
1959 int ret;
1960
1961 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
1962 soft_reconfig);
1963
1964 bgp = peer->bgp;
1965
1966 /* Process the update for each RS-client. */
1967 LIST_LOOP(bgp->rsclient, rsclient, nn)
1968 {
1969 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
1970 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
1971 sub_type, prd, tag);
1972 }
1973
1974 return ret;
1975}
1976
1977int
paul718e3742002-12-13 20:15:29 +00001978bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
1979 int afi, int safi, int type, int sub_type, struct prefix_rd *prd,
1980 u_char *tag)
1981{
1982 struct bgp *bgp;
1983 char buf[SU_ADDRSTRLEN];
1984 struct bgp_node *rn;
1985 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00001986 struct peer *rsclient;
1987 struct listnode *nn;
paul718e3742002-12-13 20:15:29 +00001988
1989 bgp = peer->bgp;
1990
paulfee0f4c2004-09-13 05:12:46 +00001991 /* Process the withdraw for each RS-client. */
1992 LIST_LOOP (bgp->rsclient, rsclient, nn)
1993 {
1994 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
1995 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
1996 }
1997
paul718e3742002-12-13 20:15:29 +00001998 /* Logging. */
1999 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002000 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00002001 peer->host,
2002 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2003 p->prefixlen);
2004
2005 /* Lookup node. */
paulfee0f4c2004-09-13 05:12:46 +00002006 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00002007
2008 /* If peer is soft reconfiguration enabled. Record input packet for
2009 further calculation. */
2010 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2011 && peer != bgp->peer_self)
2012 bgp_adj_in_unset (rn, peer);
2013
2014 /* Lookup withdrawn route. */
2015 for (ri = rn->info; ri; ri = ri->next)
2016 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2017 break;
2018
2019 /* Withdraw specified route from routing table. */
2020 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2021 bgp_rib_withdraw (rn, ri, peer, afi, safi, 0);
2022 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002023 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002024 "%s Can't find the route %s/%d", peer->host,
2025 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2026 p->prefixlen);
2027
2028 /* Unlock bgp_node_get() lock. */
2029 bgp_unlock_node (rn);
2030
2031 return 0;
2032}
2033
2034void
2035bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2036{
2037 struct bgp *bgp;
2038 struct attr attr;
2039 struct aspath *aspath;
2040 struct prefix p;
2041 struct bgp_info binfo;
2042 struct peer *from;
2043 int ret = RMAP_DENYMATCH;
2044
2045 bgp = peer->bgp;
2046 from = bgp->peer_self;
2047
2048 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2049 aspath = attr.aspath;
2050 attr.local_pref = bgp->default_local_pref;
2051 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2052
2053 if (afi == AFI_IP)
2054 str2prefix ("0.0.0.0/0", &p);
2055#ifdef HAVE_IPV6
2056 else if (afi == AFI_IP6)
2057 {
2058 str2prefix ("::/0", &p);
2059
2060 /* IPv6 global nexthop must be included. */
2061 memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global,
2062 IPV6_MAX_BYTELEN);
2063 attr.mp_nexthop_len = 16;
2064
2065 /* If the peer is on shared nextwork and we have link-local
2066 nexthop set it. */
2067 if (peer->shared_network
2068 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2069 {
2070 memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local,
2071 IPV6_MAX_BYTELEN);
2072 attr.mp_nexthop_len = 32;
2073 }
2074 }
2075#endif /* HAVE_IPV6 */
2076 else
2077 return;
2078
2079 if (peer->default_rmap[afi][safi].name)
2080 {
2081 binfo.peer = bgp->peer_self;
2082 binfo.attr = &attr;
2083
paulfee0f4c2004-09-13 05:12:46 +00002084 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
2085
paul718e3742002-12-13 20:15:29 +00002086 ret = route_map_apply (peer->default_rmap[afi][safi].map, &p,
2087 RMAP_BGP, &binfo);
2088
paulfee0f4c2004-09-13 05:12:46 +00002089 bgp->peer_self->rmap_type = 0;
2090
paul718e3742002-12-13 20:15:29 +00002091 if (ret == RMAP_DENYMATCH)
2092 {
2093 bgp_attr_flush (&attr);
2094 withdraw = 1;
2095 }
2096 }
2097
2098 if (withdraw)
2099 {
2100 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2101 bgp_default_withdraw_send (peer, afi, safi);
2102 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2103 }
2104 else
2105 {
2106 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2107 bgp_default_update_send (peer, &attr, afi, safi, from);
2108 }
2109
2110 aspath_unintern (aspath);
2111}
2112
2113static void
2114bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002115 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002116{
2117 struct bgp_node *rn;
2118 struct bgp_info *ri;
2119 struct attr attr;
2120
2121 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002122 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002123
2124 if (safi != SAFI_MPLS_VPN
2125 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2126 bgp_default_originate (peer, afi, safi, 0);
2127
2128 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2129 for (ri = rn->info; ri; ri = ri->next)
2130 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2131 {
paulfee0f4c2004-09-13 05:12:46 +00002132 if ( (rsclient) ?
2133 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2134 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002135 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2136 else
2137 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2138 }
2139}
2140
2141void
2142bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2143{
2144 struct bgp_node *rn;
2145 struct bgp_table *table;
2146
2147 if (peer->status != Established)
2148 return;
2149
2150 if (! peer->afc_nego[afi][safi])
2151 return;
2152
2153 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2154 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2155 return;
2156
2157 if (safi != SAFI_MPLS_VPN)
paulfee0f4c2004-09-13 05:12:46 +00002158 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002159 else
2160 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2161 rn = bgp_route_next(rn))
2162 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002163 bgp_announce_table (peer, afi, safi, table, 0);
2164
2165 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2166 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002167}
2168
2169void
2170bgp_announce_route_all (struct peer *peer)
2171{
2172 afi_t afi;
2173 safi_t safi;
2174
2175 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2176 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2177 bgp_announce_route (peer, afi, safi);
2178}
2179
2180static void
paulfee0f4c2004-09-13 05:12:46 +00002181bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
2182 safi_t safi, struct bgp_table *table)
2183{
2184 struct bgp_node *rn;
2185 struct bgp_adj_in *ain;
2186
2187 if (! table)
2188 table = rsclient->bgp->rib[afi][safi];
2189
2190 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2191 for (ain = rn->adj_in; ain; ain = ain->next)
2192 {
2193 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
2194 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
2195 }
2196}
2197
2198void
2199bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2200{
2201 struct bgp_table *table;
2202 struct bgp_node *rn;
2203
2204 if (safi != SAFI_MPLS_VPN)
2205 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL);
2206
2207 else
2208 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2209 rn = bgp_route_next (rn))
2210 if ((table = rn->info) != NULL)
2211 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table);
2212}
2213
2214static void
paul718e3742002-12-13 20:15:29 +00002215bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
2216 struct bgp_table *table)
2217{
2218 int ret;
2219 struct bgp_node *rn;
2220 struct bgp_adj_in *ain;
2221
2222 if (! table)
2223 table = peer->bgp->rib[afi][safi];
2224
2225 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2226 for (ain = rn->adj_in; ain; ain = ain->next)
2227 {
2228 if (ain->peer == peer)
2229 {
2230 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2231 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
2232 NULL, NULL, 1);
2233 if (ret < 0)
2234 {
2235 bgp_unlock_node (rn);
2236 return;
2237 }
2238 continue;
2239 }
2240 }
2241}
2242
2243void
2244bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2245{
2246 struct bgp_node *rn;
2247 struct bgp_table *table;
2248
2249 if (peer->status != Established)
2250 return;
2251
2252 if (safi != SAFI_MPLS_VPN)
2253 bgp_soft_reconfig_table (peer, afi, safi, NULL);
2254 else
2255 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2256 rn = bgp_route_next (rn))
2257 if ((table = rn->info) != NULL)
2258 bgp_soft_reconfig_table (peer, afi, safi, table);
2259}
2260
2261static void
2262bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002263 struct bgp_table *table, struct peer *rsclient)
paul718e3742002-12-13 20:15:29 +00002264{
2265 struct bgp_node *rn;
2266 struct bgp_adj_in *ain;
2267 struct bgp_adj_out *aout;
2268 struct bgp_info *ri;
2269
2270 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002271 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002272
hasso6cf159b2005-03-21 10:28:14 +00002273 /* If still no table => afi/safi isn't configured at all or smth. */
2274 if (! table)
2275 return;
2276
paul718e3742002-12-13 20:15:29 +00002277 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2278 {
2279 for (ri = rn->info; ri; ri = ri->next)
2280 if (ri->peer == peer)
2281 {
hasso93406d82005-02-02 14:40:33 +00002282 /* graceful restart STALE flag set. */
2283 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2284 && peer->nsf[afi][safi]
2285 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
2286 && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)
2287 && ! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
2288 {
2289 SET_FLAG (ri->flags, BGP_INFO_STALE);
2290 peer->pcount[afi][safi]--;
2291 }
2292 else
2293 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002294 break;
2295 }
2296 for (ain = rn->adj_in; ain; ain = ain->next)
2297 if (ain->peer == peer)
2298 {
2299 bgp_adj_in_remove (rn, ain);
2300 bgp_unlock_node (rn);
2301 break;
2302 }
2303 for (aout = rn->adj_out; aout; aout = aout->next)
2304 if (aout->peer == peer)
2305 {
2306 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2307 bgp_unlock_node (rn);
2308 break;
2309 }
2310 }
2311}
2312
2313void
2314bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi)
2315{
2316 struct bgp_node *rn;
2317 struct bgp_table *table;
paulfee0f4c2004-09-13 05:12:46 +00002318 struct peer *rsclient;
2319 struct listnode *nn;
paul718e3742002-12-13 20:15:29 +00002320
paul718e3742002-12-13 20:15:29 +00002321 if (safi != SAFI_MPLS_VPN)
paulfee0f4c2004-09-13 05:12:46 +00002322 bgp_clear_route_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002323 else
2324 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2325 rn = bgp_route_next (rn))
2326 if ((table = rn->info) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002327 bgp_clear_route_table (peer, afi, safi, table, NULL);
2328
2329 LIST_LOOP (peer->bgp->rsclient, rsclient, nn)
2330 {
2331 if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2332 bgp_clear_route_table (peer, afi, safi, NULL, rsclient);
2333 }
paul718e3742002-12-13 20:15:29 +00002334}
2335
2336void
2337bgp_clear_route_all (struct peer *peer)
2338{
2339 afi_t afi;
2340 safi_t safi;
2341
2342 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2343 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2344 bgp_clear_route (peer, afi, safi);
2345}
2346
2347void
2348bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
2349{
2350 struct bgp_table *table;
2351 struct bgp_node *rn;
2352 struct bgp_adj_in *ain;
2353
2354 table = peer->bgp->rib[afi][safi];
2355
2356 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2357 for (ain = rn->adj_in; ain ; ain = ain->next)
2358 if (ain->peer == peer)
2359 {
2360 bgp_adj_in_remove (rn, ain);
2361 bgp_unlock_node (rn);
2362 break;
2363 }
2364}
hasso93406d82005-02-02 14:40:33 +00002365
2366void
2367bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
2368{
2369 struct bgp_node *rn;
2370 struct bgp_info *ri;
2371 struct bgp_table *table;
2372
2373 table = peer->bgp->rib[afi][safi];
2374
2375 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2376 {
2377 for (ri = rn->info; ri; ri = ri->next)
2378 if (ri->peer == peer)
2379 {
2380 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2381 bgp_rib_remove (rn, ri, peer, afi, safi);
2382 break;
2383 }
2384 }
2385}
paul718e3742002-12-13 20:15:29 +00002386
2387/* Delete all kernel routes. */
2388void
paul545acaf2004-04-20 15:13:15 +00002389bgp_cleanup_routes ()
paul718e3742002-12-13 20:15:29 +00002390{
2391 struct bgp *bgp;
2392 struct listnode *nn;
2393 struct bgp_node *rn;
2394 struct bgp_table *table;
2395 struct bgp_info *ri;
2396
2397 LIST_LOOP (bm->bgp, bgp, nn)
2398 {
2399 table = bgp->rib[AFI_IP][SAFI_UNICAST];
2400
2401 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2402 for (ri = rn->info; ri; ri = ri->next)
2403 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
2404 && ri->type == ZEBRA_ROUTE_BGP
2405 && ri->sub_type == BGP_ROUTE_NORMAL)
2406 bgp_zebra_withdraw (&rn->p, ri);
2407
2408 table = bgp->rib[AFI_IP6][SAFI_UNICAST];
2409
2410 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2411 for (ri = rn->info; ri; ri = ri->next)
2412 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
2413 && ri->type == ZEBRA_ROUTE_BGP
2414 && ri->sub_type == BGP_ROUTE_NORMAL)
2415 bgp_zebra_withdraw (&rn->p, ri);
2416 }
2417}
2418
2419void
2420bgp_reset ()
2421{
2422 vty_reset ();
2423 bgp_zclient_reset ();
2424 access_list_reset ();
2425 prefix_list_reset ();
2426}
2427
2428/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2429 value. */
2430int
2431bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
2432{
2433 u_char *pnt;
2434 u_char *lim;
2435 struct prefix p;
2436 int psize;
2437 int ret;
2438
2439 /* Check peer status. */
2440 if (peer->status != Established)
2441 return 0;
2442
2443 pnt = packet->nlri;
2444 lim = pnt + packet->length;
2445
2446 for (; pnt < lim; pnt += psize)
2447 {
2448 /* Clear prefix structure. */
2449 memset (&p, 0, sizeof (struct prefix));
2450
2451 /* Fetch prefix length. */
2452 p.prefixlen = *pnt++;
2453 p.family = afi2family (packet->afi);
2454
2455 /* Already checked in nlri_sanity_check(). We do double check
2456 here. */
2457 if ((packet->afi == AFI_IP && p.prefixlen > 32)
2458 || (packet->afi == AFI_IP6 && p.prefixlen > 128))
2459 return -1;
2460
2461 /* Packet size overflow check. */
2462 psize = PSIZE (p.prefixlen);
2463
2464 /* When packet overflow occur return immediately. */
2465 if (pnt + psize > lim)
2466 return -1;
2467
2468 /* Fetch prefix from NLRI packet. */
2469 memcpy (&p.u.prefix, pnt, psize);
2470
2471 /* Check address. */
2472 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
2473 {
2474 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
2475 {
paulf5ba3872004-07-09 12:11:31 +00002476 /*
2477 * From draft-ietf-idr-bgp4-22, Section 6.3:
2478 * If a BGP router receives an UPDATE message with a
2479 * semantically incorrect NLRI field, in which a prefix is
2480 * semantically incorrect (eg. an unexpected multicast IP
2481 * address), it should ignore the prefix.
2482 */
paul718e3742002-12-13 20:15:29 +00002483 zlog (peer->log, LOG_ERR,
2484 "IPv4 unicast NLRI is multicast address %s",
2485 inet_ntoa (p.u.prefix4));
paulf5ba3872004-07-09 12:11:31 +00002486
paul718e3742002-12-13 20:15:29 +00002487 return -1;
2488 }
2489 }
2490
2491#ifdef HAVE_IPV6
2492 /* Check address. */
2493 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
2494 {
2495 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
2496 {
2497 char buf[BUFSIZ];
2498
2499 zlog (peer->log, LOG_WARNING,
2500 "IPv6 link-local NLRI received %s ignore this NLRI",
2501 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
2502
2503 continue;
2504 }
2505 }
2506#endif /* HAVE_IPV6 */
2507
2508 /* Normal process. */
2509 if (attr)
2510 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
2511 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
2512 else
2513 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
2514 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
2515
2516 /* Address family configuration mismatch or maximum-prefix count
2517 overflow. */
2518 if (ret < 0)
2519 return -1;
2520 }
2521
2522 /* Packet length consistency check. */
2523 if (pnt != lim)
2524 return -1;
2525
2526 return 0;
2527}
2528
2529/* NLRI encode syntax check routine. */
2530int
2531bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt,
2532 bgp_size_t length)
2533{
2534 u_char *end;
2535 u_char prefixlen;
2536 int psize;
2537
2538 end = pnt + length;
2539
2540 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
2541 syntactic validity. If the field is syntactically incorrect,
2542 then the Error Subcode is set to Invalid Network Field. */
2543
2544 while (pnt < end)
2545 {
2546 prefixlen = *pnt++;
2547
2548 /* Prefix length check. */
2549 if ((afi == AFI_IP && prefixlen > 32)
2550 || (afi == AFI_IP6 && prefixlen > 128))
2551 {
2552 plog_err (peer->log,
2553 "%s [Error] Update packet error (wrong prefix length %d)",
2554 peer->host, prefixlen);
2555 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
2556 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
2557 return -1;
2558 }
2559
2560 /* Packet size overflow check. */
2561 psize = PSIZE (prefixlen);
2562
2563 if (pnt + psize > end)
2564 {
2565 plog_err (peer->log,
2566 "%s [Error] Update packet error"
2567 " (prefix data overflow prefix size is %d)",
2568 peer->host, psize);
2569 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
2570 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
2571 return -1;
2572 }
2573
2574 pnt += psize;
2575 }
2576
2577 /* Packet length consistency check. */
2578 if (pnt != end)
2579 {
2580 plog_err (peer->log,
2581 "%s [Error] Update packet error"
2582 " (prefix length mismatch with total length)",
2583 peer->host);
2584 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
2585 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
2586 return -1;
2587 }
2588 return 0;
2589}
2590
2591struct bgp_static *
2592bgp_static_new ()
2593{
2594 struct bgp_static *new;
2595 new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
2596 memset (new, 0, sizeof (struct bgp_static));
2597 return new;
2598}
2599
2600void
2601bgp_static_free (struct bgp_static *bgp_static)
2602{
2603 if (bgp_static->rmap.name)
2604 free (bgp_static->rmap.name);
2605 XFREE (MTYPE_BGP_STATIC, bgp_static);
2606}
2607
2608void
paulfee0f4c2004-09-13 05:12:46 +00002609bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
2610 struct prefix *p, afi_t afi, safi_t safi)
2611{
2612 struct bgp_node *rn;
2613 struct bgp_info *ri;
2614
2615 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
2616
2617 /* Check selected route and self inserted route. */
2618 for (ri = rn->info; ri; ri = ri->next)
2619 if (ri->peer == bgp->peer_self
2620 && ri->type == ZEBRA_ROUTE_BGP
2621 && ri->sub_type == BGP_ROUTE_STATIC)
2622 break;
2623
2624 /* Withdraw static BGP route from routing table. */
2625 if (ri)
2626 {
2627 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
2628 bgp_process (bgp, rn, afi, safi);
2629 bgp_info_delete (rn, ri);
2630 bgp_info_free (ri);
2631 bgp_unlock_node (rn);
2632 }
2633
2634 /* Unlock bgp_node_lookup. */
2635 bgp_unlock_node (rn);
2636}
2637
2638void
2639bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
2640 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
2641{
2642 struct bgp_node *rn;
2643 struct bgp_info *ri;
2644 struct bgp_info *new;
2645 struct bgp_info info;
2646 struct attr new_attr;
2647 struct attr *attr_new;
2648 struct attr attr;
2649 struct bgp *bgp;
2650 int ret;
2651 char buf[SU_ADDRSTRLEN];
2652
2653 bgp = rsclient->bgp;
2654
2655 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
2656
2657 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2658 if (bgp_static)
2659 {
2660 attr.nexthop = bgp_static->igpnexthop;
2661 attr.med = bgp_static->igpmetric;
2662 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
2663 }
2664
2665 new_attr = attr;
2666
2667 /* Apply network route-map for export to this rsclient. */
2668 if (bgp_static->rmap.name)
2669 {
2670 info.peer = rsclient;
2671 info.attr = &new_attr;
2672
2673 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
2674 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
2675
2676 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
2677
2678 rsclient->rmap_type = 0;
2679
2680 if (ret == RMAP_DENYMATCH)
2681 {
2682 /* Free uninterned attribute. */
2683 bgp_attr_flush (&new_attr);
2684
2685 /* Unintern original. */
2686 aspath_unintern (attr.aspath);
2687 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
2688
2689 return;
2690 }
2691 attr_new = bgp_attr_intern (&new_attr);
2692 }
2693 else
2694 attr_new = bgp_attr_intern (&attr);
2695
2696 new_attr = *attr_new;
2697
2698 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
2699
2700 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY)
2701{
2702 /* This BGP update is filtered. Log the reason then update BGP entry. */
2703 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002704 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002705 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
2706 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2707 p->prefixlen, rsclient->host);
2708
2709 bgp->peer_self->rmap_type = 0;
2710
2711 bgp_attr_unintern (attr_new);
2712 aspath_unintern (attr.aspath);
2713
2714 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
2715
2716 return;
2717 }
2718
2719 bgp->peer_self->rmap_type = 0;
2720
2721 bgp_attr_unintern (attr_new);
2722 attr_new = bgp_attr_intern (&new_attr);
2723
2724 for (ri = rn->info; ri; ri = ri->next)
2725 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
2726 && ri->sub_type == BGP_ROUTE_STATIC)
2727 break;
2728
2729 if (ri)
2730 {
2731 if (attrhash_cmp (ri->attr, attr_new))
2732 {
2733 bgp_unlock_node (rn);
2734 bgp_attr_unintern (attr_new);
2735 aspath_unintern (attr.aspath);
2736 return;
2737 }
2738 else
2739 {
2740 /* The attribute is changed. */
2741 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
2742
2743 /* Rewrite BGP route information. */
2744 bgp_attr_unintern (ri->attr);
2745 ri->attr = attr_new;
2746 ri->uptime = time (NULL);
2747
2748 /* Process change. */
2749 bgp_process (bgp, rn, afi, safi);
2750 bgp_unlock_node (rn);
2751 aspath_unintern (attr.aspath);
2752 return;
2753 }
2754}
2755
2756 /* Make new BGP info. */
2757 new = bgp_info_new ();
2758 new->type = ZEBRA_ROUTE_BGP;
2759 new->sub_type = BGP_ROUTE_STATIC;
2760 new->peer = bgp->peer_self;
2761 SET_FLAG (new->flags, BGP_INFO_VALID);
2762 new->attr = attr_new;
2763 new->uptime = time (NULL);
2764
2765 /* Register new BGP information. */
2766 bgp_info_add (rn, new);
2767
2768 /* Process change. */
2769 bgp_process (bgp, rn, afi, safi);
2770
2771 /* Unintern original. */
2772 aspath_unintern (attr.aspath);
2773}
2774
2775void
2776bgp_static_update_main (struct bgp *bgp, struct prefix *p,
paul718e3742002-12-13 20:15:29 +00002777 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
2778{
2779 struct bgp_node *rn;
2780 struct bgp_info *ri;
2781 struct bgp_info *new;
2782 struct bgp_info info;
2783 struct attr attr;
paul286e1e72003-08-08 00:24:31 +00002784 struct attr attr_tmp;
paul718e3742002-12-13 20:15:29 +00002785 struct attr *attr_new;
2786 int ret;
2787
paulfee0f4c2004-09-13 05:12:46 +00002788 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00002789
2790 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2791 if (bgp_static)
2792 {
2793 attr.nexthop = bgp_static->igpnexthop;
2794 attr.med = bgp_static->igpmetric;
2795 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
2796 }
2797
2798 /* Apply route-map. */
2799 if (bgp_static->rmap.name)
2800 {
paul286e1e72003-08-08 00:24:31 +00002801 attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00002802 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00002803 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00002804
paulfee0f4c2004-09-13 05:12:46 +00002805 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
2806
paul718e3742002-12-13 20:15:29 +00002807 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00002808
paulfee0f4c2004-09-13 05:12:46 +00002809 bgp->peer_self->rmap_type = 0;
2810
paul718e3742002-12-13 20:15:29 +00002811 if (ret == RMAP_DENYMATCH)
2812 {
2813 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00002814 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00002815
2816 /* Unintern original. */
2817 aspath_unintern (attr.aspath);
2818 bgp_static_withdraw (bgp, p, afi, safi);
2819 return;
2820 }
paul286e1e72003-08-08 00:24:31 +00002821 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00002822 }
paul286e1e72003-08-08 00:24:31 +00002823 else
2824 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00002825
2826 for (ri = rn->info; ri; ri = ri->next)
2827 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
2828 && ri->sub_type == BGP_ROUTE_STATIC)
2829 break;
2830
2831 if (ri)
2832 {
2833 if (attrhash_cmp (ri->attr, attr_new))
2834 {
2835 bgp_unlock_node (rn);
2836 bgp_attr_unintern (attr_new);
2837 aspath_unintern (attr.aspath);
2838 return;
2839 }
2840 else
2841 {
2842 /* The attribute is changed. */
2843 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
2844
2845 /* Rewrite BGP route information. */
2846 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2847 bgp_attr_unintern (ri->attr);
2848 ri->attr = attr_new;
2849 ri->uptime = time (NULL);
2850
2851 /* Process change. */
2852 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2853 bgp_process (bgp, rn, afi, safi);
2854 bgp_unlock_node (rn);
2855 aspath_unintern (attr.aspath);
2856 return;
2857 }
2858 }
2859
2860 /* Make new BGP info. */
2861 new = bgp_info_new ();
2862 new->type = ZEBRA_ROUTE_BGP;
2863 new->sub_type = BGP_ROUTE_STATIC;
2864 new->peer = bgp->peer_self;
2865 SET_FLAG (new->flags, BGP_INFO_VALID);
2866 new->attr = attr_new;
2867 new->uptime = time (NULL);
2868
2869 /* Aggregate address increment. */
2870 bgp_aggregate_increment (bgp, p, new, afi, safi);
2871
2872 /* Register new BGP information. */
2873 bgp_info_add (rn, new);
2874
2875 /* Process change. */
2876 bgp_process (bgp, rn, afi, safi);
2877
2878 /* Unintern original. */
2879 aspath_unintern (attr.aspath);
2880}
2881
2882void
paulfee0f4c2004-09-13 05:12:46 +00002883bgp_static_update (struct bgp *bgp, struct prefix *p,
2884 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
2885{
2886 struct peer *rsclient;
2887 struct listnode *nn;
2888
2889 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
2890
2891 LIST_LOOP(bgp->rsclient, rsclient, nn)
2892 {
2893 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
2894 }
2895}
2896
2897void
paul718e3742002-12-13 20:15:29 +00002898bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi,
2899 u_char safi, struct prefix_rd *prd, u_char *tag)
2900{
2901 struct bgp_node *rn;
2902 struct bgp_info *new;
2903
paulfee0f4c2004-09-13 05:12:46 +00002904 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00002905
2906 /* Make new BGP info. */
2907 new = bgp_info_new ();
2908 new->type = ZEBRA_ROUTE_BGP;
2909 new->sub_type = BGP_ROUTE_STATIC;
2910 new->peer = bgp->peer_self;
2911 new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP);
2912 SET_FLAG (new->flags, BGP_INFO_VALID);
2913 new->uptime = time (NULL);
2914 memcpy (new->tag, tag, 3);
2915
2916 /* Aggregate address increment. */
2917 bgp_aggregate_increment (bgp, p, (struct bgp_info *) new, afi, safi);
2918
2919 /* Register new BGP information. */
2920 bgp_info_add (rn, (struct bgp_info *) new);
2921
2922 /* Process change. */
2923 bgp_process (bgp, rn, afi, safi);
2924}
2925
2926void
2927bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
2928 safi_t safi)
2929{
2930 struct bgp_node *rn;
2931 struct bgp_info *ri;
2932
paulfee0f4c2004-09-13 05:12:46 +00002933 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00002934
2935 /* Check selected route and self inserted route. */
2936 for (ri = rn->info; ri; ri = ri->next)
2937 if (ri->peer == bgp->peer_self
2938 && ri->type == ZEBRA_ROUTE_BGP
2939 && ri->sub_type == BGP_ROUTE_STATIC)
2940 break;
2941
2942 /* Withdraw static BGP route from routing table. */
2943 if (ri)
2944 {
2945 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2946 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
2947 bgp_process (bgp, rn, afi, safi);
2948 bgp_info_delete (rn, ri);
2949 bgp_info_free (ri);
2950 bgp_unlock_node (rn);
2951 }
2952
2953 /* Unlock bgp_node_lookup. */
2954 bgp_unlock_node (rn);
2955}
2956
2957void
paulfee0f4c2004-09-13 05:12:46 +00002958bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2959{
2960 struct bgp_static *bgp_static;
2961 struct bgp *bgp;
2962 struct bgp_node *rn;
2963 struct prefix *p;
2964
2965 bgp = rsclient->bgp;
2966
2967 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
2968 if ((bgp_static = rn->info) != NULL)
2969 {
2970 p = &rn->p;
2971
2972 bgp_static_update_rsclient (rsclient, p, bgp_static,
2973 afi, safi);
2974 }
2975}
2976
2977void
paul718e3742002-12-13 20:15:29 +00002978bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi,
2979 u_char safi, struct prefix_rd *prd, u_char *tag)
2980{
2981 struct bgp_node *rn;
2982 struct bgp_info *ri;
2983
paulfee0f4c2004-09-13 05:12:46 +00002984 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00002985
2986 /* Check selected route and self inserted route. */
2987 for (ri = rn->info; ri; ri = ri->next)
2988 if (ri->peer == bgp->peer_self
2989 && ri->type == ZEBRA_ROUTE_BGP
2990 && ri->sub_type == BGP_ROUTE_STATIC)
2991 break;
2992
2993 /* Withdraw static BGP route from routing table. */
2994 if (ri)
2995 {
2996 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2997 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
2998 bgp_process (bgp, rn, afi, safi);
2999 bgp_info_delete (rn, ri);
3000 bgp_info_free (ri);
3001 bgp_unlock_node (rn);
3002 }
3003
3004 /* Unlock bgp_node_lookup. */
3005 bgp_unlock_node (rn);
3006}
3007
3008/* Configure static BGP network. When user don't run zebra, static
3009 route should be installed as valid. */
3010int
paulfd79ac92004-10-13 05:06:08 +00003011bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
3012 u_int16_t afi, u_char safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003013{
3014 int ret;
3015 struct prefix p;
3016 struct bgp_static *bgp_static;
3017 struct bgp_node *rn;
3018 int need_update = 0;
3019
3020 /* Convert IP prefix string to struct prefix. */
3021 ret = str2prefix (ip_str, &p);
3022 if (! ret)
3023 {
3024 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3025 return CMD_WARNING;
3026 }
3027#ifdef HAVE_IPV6
3028 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3029 {
3030 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3031 VTY_NEWLINE);
3032 return CMD_WARNING;
3033 }
3034#endif /* HAVE_IPV6 */
3035
3036 apply_mask (&p);
3037
3038 /* Set BGP static route configuration. */
3039 rn = bgp_node_get (bgp->route[afi][safi], &p);
3040
3041 if (rn->info)
3042 {
3043 /* Configuration change. */
3044 bgp_static = rn->info;
3045
3046 /* Check previous routes are installed into BGP. */
3047 if (! bgp_static->backdoor && bgp_static->valid)
3048 need_update = 1;
3049
3050 bgp_static->backdoor = backdoor;
3051 if (rmap)
3052 {
3053 if (bgp_static->rmap.name)
3054 free (bgp_static->rmap.name);
3055 bgp_static->rmap.name = strdup (rmap);
3056 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3057 }
3058 else
3059 {
3060 if (bgp_static->rmap.name)
3061 free (bgp_static->rmap.name);
3062 bgp_static->rmap.name = NULL;
3063 bgp_static->rmap.map = NULL;
3064 bgp_static->valid = 0;
3065 }
3066 bgp_unlock_node (rn);
3067 }
3068 else
3069 {
3070 /* New configuration. */
3071 bgp_static = bgp_static_new ();
3072 bgp_static->backdoor = backdoor;
3073 bgp_static->valid = 0;
3074 bgp_static->igpmetric = 0;
3075 bgp_static->igpnexthop.s_addr = 0;
3076 if (rmap)
3077 {
3078 if (bgp_static->rmap.name)
3079 free (bgp_static->rmap.name);
3080 bgp_static->rmap.name = strdup (rmap);
3081 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3082 }
3083 rn->info = bgp_static;
3084 }
3085
3086 /* If BGP scan is not enabled, we should install this route here. */
3087 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3088 {
3089 bgp_static->valid = 1;
3090
3091 if (need_update)
3092 bgp_static_withdraw (bgp, &p, afi, safi);
3093
3094 if (! bgp_static->backdoor)
3095 bgp_static_update (bgp, &p, bgp_static, afi, safi);
3096 }
3097
3098 return CMD_SUCCESS;
3099}
3100
3101/* Configure static BGP network. */
3102int
paulfd79ac92004-10-13 05:06:08 +00003103bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
paul718e3742002-12-13 20:15:29 +00003104 u_int16_t afi, u_char safi)
3105{
3106 int ret;
3107 struct prefix p;
3108 struct bgp_static *bgp_static;
3109 struct bgp_node *rn;
3110
3111 /* Convert IP prefix string to struct prefix. */
3112 ret = str2prefix (ip_str, &p);
3113 if (! ret)
3114 {
3115 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3116 return CMD_WARNING;
3117 }
3118#ifdef HAVE_IPV6
3119 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3120 {
3121 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3122 VTY_NEWLINE);
3123 return CMD_WARNING;
3124 }
3125#endif /* HAVE_IPV6 */
3126
3127 apply_mask (&p);
3128
3129 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
3130 if (! rn)
3131 {
3132 vty_out (vty, "%% Can't find specified static route configuration.%s",
3133 VTY_NEWLINE);
3134 return CMD_WARNING;
3135 }
3136
3137 bgp_static = rn->info;
3138
3139 /* Update BGP RIB. */
3140 if (! bgp_static->backdoor)
3141 bgp_static_withdraw (bgp, &p, afi, safi);
3142
3143 /* Clear configuration. */
3144 bgp_static_free (bgp_static);
3145 rn->info = NULL;
3146 bgp_unlock_node (rn);
3147 bgp_unlock_node (rn);
3148
3149 return CMD_SUCCESS;
3150}
3151
3152/* Called from bgp_delete(). Delete all static routes from the BGP
3153 instance. */
3154void
3155bgp_static_delete (struct bgp *bgp)
3156{
3157 afi_t afi;
3158 safi_t safi;
3159 struct bgp_node *rn;
3160 struct bgp_node *rm;
3161 struct bgp_table *table;
3162 struct bgp_static *bgp_static;
3163
3164 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3165 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
3166 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3167 if (rn->info != NULL)
3168 {
3169 if (safi == SAFI_MPLS_VPN)
3170 {
3171 table = rn->info;
3172
3173 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
3174 {
3175 bgp_static = rn->info;
3176 bgp_static_withdraw_vpnv4 (bgp, &rm->p,
3177 AFI_IP, SAFI_MPLS_VPN,
3178 (struct prefix_rd *)&rn->p,
3179 bgp_static->tag);
3180 bgp_static_free (bgp_static);
3181 rn->info = NULL;
3182 bgp_unlock_node (rn);
3183 }
3184 }
3185 else
3186 {
3187 bgp_static = rn->info;
3188 bgp_static_withdraw (bgp, &rn->p, afi, safi);
3189 bgp_static_free (bgp_static);
3190 rn->info = NULL;
3191 bgp_unlock_node (rn);
3192 }
3193 }
3194}
3195
3196int
paulfd79ac92004-10-13 05:06:08 +00003197bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str,
3198 const char *tag_str)
paul718e3742002-12-13 20:15:29 +00003199{
3200 int ret;
3201 struct prefix p;
3202 struct prefix_rd prd;
3203 struct bgp *bgp;
3204 struct bgp_node *prn;
3205 struct bgp_node *rn;
3206 struct bgp_table *table;
3207 struct bgp_static *bgp_static;
3208 u_char tag[3];
3209
3210 bgp = vty->index;
3211
3212 ret = str2prefix (ip_str, &p);
3213 if (! ret)
3214 {
3215 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3216 return CMD_WARNING;
3217 }
3218 apply_mask (&p);
3219
3220 ret = str2prefix_rd (rd_str, &prd);
3221 if (! ret)
3222 {
3223 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
3224 return CMD_WARNING;
3225 }
3226
3227 ret = str2tag (tag_str, tag);
3228 if (! ret)
3229 {
3230 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
3231 return CMD_WARNING;
3232 }
3233
3234 prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN],
3235 (struct prefix *)&prd);
3236 if (prn->info == NULL)
3237 prn->info = bgp_table_init ();
3238 else
3239 bgp_unlock_node (prn);
3240 table = prn->info;
3241
3242 rn = bgp_node_get (table, &p);
3243
3244 if (rn->info)
3245 {
3246 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
3247 bgp_unlock_node (rn);
3248 }
3249 else
3250 {
3251 /* New configuration. */
3252 bgp_static = bgp_static_new ();
3253 bgp_static->valid = 1;
3254 memcpy (bgp_static->tag, tag, 3);
3255 rn->info = bgp_static;
3256
3257 bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag);
3258 }
3259
3260 return CMD_SUCCESS;
3261}
3262
3263/* Configure static BGP network. */
3264int
paulfd79ac92004-10-13 05:06:08 +00003265bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str,
3266 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00003267{
3268 int ret;
3269 struct bgp *bgp;
3270 struct prefix p;
3271 struct prefix_rd prd;
3272 struct bgp_node *prn;
3273 struct bgp_node *rn;
3274 struct bgp_table *table;
3275 struct bgp_static *bgp_static;
3276 u_char tag[3];
3277
3278 bgp = vty->index;
3279
3280 /* Convert IP prefix string to struct prefix. */
3281 ret = str2prefix (ip_str, &p);
3282 if (! ret)
3283 {
3284 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3285 return CMD_WARNING;
3286 }
3287 apply_mask (&p);
3288
3289 ret = str2prefix_rd (rd_str, &prd);
3290 if (! ret)
3291 {
3292 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
3293 return CMD_WARNING;
3294 }
3295
3296 ret = str2tag (tag_str, tag);
3297 if (! ret)
3298 {
3299 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
3300 return CMD_WARNING;
3301 }
3302
3303 prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN],
3304 (struct prefix *)&prd);
3305 if (prn->info == NULL)
3306 prn->info = bgp_table_init ();
3307 else
3308 bgp_unlock_node (prn);
3309 table = prn->info;
3310
3311 rn = bgp_node_lookup (table, &p);
3312
3313 if (rn)
3314 {
3315 bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag);
3316
3317 bgp_static = rn->info;
3318 bgp_static_free (bgp_static);
3319 rn->info = NULL;
3320 bgp_unlock_node (rn);
3321 bgp_unlock_node (rn);
3322 }
3323 else
3324 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
3325
3326 return CMD_SUCCESS;
3327}
3328
3329DEFUN (bgp_network,
3330 bgp_network_cmd,
3331 "network A.B.C.D/M",
3332 "Specify a network to announce via BGP\n"
3333 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3334{
3335 return bgp_static_set (vty, vty->index, argv[0],
3336 AFI_IP, bgp_node_safi (vty), NULL, 0);
3337}
3338
3339DEFUN (bgp_network_route_map,
3340 bgp_network_route_map_cmd,
3341 "network A.B.C.D/M route-map WORD",
3342 "Specify a network to announce via BGP\n"
3343 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3344 "Route-map to modify the attributes\n"
3345 "Name of the route map\n")
3346{
3347 return bgp_static_set (vty, vty->index, argv[0],
3348 AFI_IP, bgp_node_safi (vty), argv[1], 0);
3349}
3350
3351DEFUN (bgp_network_backdoor,
3352 bgp_network_backdoor_cmd,
3353 "network A.B.C.D/M backdoor",
3354 "Specify a network to announce via BGP\n"
3355 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3356 "Specify a BGP backdoor route\n")
3357{
3358 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
3359}
3360
3361DEFUN (bgp_network_mask,
3362 bgp_network_mask_cmd,
3363 "network A.B.C.D mask A.B.C.D",
3364 "Specify a network to announce via BGP\n"
3365 "Network number\n"
3366 "Network mask\n"
3367 "Network mask\n")
3368{
3369 int ret;
3370 char prefix_str[BUFSIZ];
3371
3372 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3373 if (! ret)
3374 {
3375 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3376 return CMD_WARNING;
3377 }
3378
3379 return bgp_static_set (vty, vty->index, prefix_str,
3380 AFI_IP, bgp_node_safi (vty), NULL, 0);
3381}
3382
3383DEFUN (bgp_network_mask_route_map,
3384 bgp_network_mask_route_map_cmd,
3385 "network A.B.C.D mask A.B.C.D route-map WORD",
3386 "Specify a network to announce via BGP\n"
3387 "Network number\n"
3388 "Network mask\n"
3389 "Network mask\n"
3390 "Route-map to modify the attributes\n"
3391 "Name of the route map\n")
3392{
3393 int ret;
3394 char prefix_str[BUFSIZ];
3395
3396 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3397 if (! ret)
3398 {
3399 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3400 return CMD_WARNING;
3401 }
3402
3403 return bgp_static_set (vty, vty->index, prefix_str,
3404 AFI_IP, bgp_node_safi (vty), argv[2], 0);
3405}
3406
3407DEFUN (bgp_network_mask_backdoor,
3408 bgp_network_mask_backdoor_cmd,
3409 "network A.B.C.D mask A.B.C.D backdoor",
3410 "Specify a network to announce via BGP\n"
3411 "Network number\n"
3412 "Network mask\n"
3413 "Network mask\n"
3414 "Specify a BGP backdoor route\n")
3415{
3416 int ret;
3417 char prefix_str[BUFSIZ];
3418
3419 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3420 if (! ret)
3421 {
3422 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3423 return CMD_WARNING;
3424 }
3425
3426 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1);
3427}
3428
3429DEFUN (bgp_network_mask_natural,
3430 bgp_network_mask_natural_cmd,
3431 "network A.B.C.D",
3432 "Specify a network to announce via BGP\n"
3433 "Network number\n")
3434{
3435 int ret;
3436 char prefix_str[BUFSIZ];
3437
3438 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3439 if (! ret)
3440 {
3441 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3442 return CMD_WARNING;
3443 }
3444
3445 return bgp_static_set (vty, vty->index, prefix_str,
3446 AFI_IP, bgp_node_safi (vty), NULL, 0);
3447}
3448
3449DEFUN (bgp_network_mask_natural_route_map,
3450 bgp_network_mask_natural_route_map_cmd,
3451 "network A.B.C.D route-map WORD",
3452 "Specify a network to announce via BGP\n"
3453 "Network number\n"
3454 "Route-map to modify the attributes\n"
3455 "Name of the route map\n")
3456{
3457 int ret;
3458 char prefix_str[BUFSIZ];
3459
3460 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3461 if (! ret)
3462 {
3463 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3464 return CMD_WARNING;
3465 }
3466
3467 return bgp_static_set (vty, vty->index, prefix_str,
3468 AFI_IP, bgp_node_safi (vty), argv[1], 0);
3469}
3470
3471DEFUN (bgp_network_mask_natural_backdoor,
3472 bgp_network_mask_natural_backdoor_cmd,
3473 "network A.B.C.D backdoor",
3474 "Specify a network to announce via BGP\n"
3475 "Network number\n"
3476 "Specify a BGP backdoor route\n")
3477{
3478 int ret;
3479 char prefix_str[BUFSIZ];
3480
3481 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3482 if (! ret)
3483 {
3484 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3485 return CMD_WARNING;
3486 }
3487
3488 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1);
3489}
3490
3491DEFUN (no_bgp_network,
3492 no_bgp_network_cmd,
3493 "no network A.B.C.D/M",
3494 NO_STR
3495 "Specify a network to announce via BGP\n"
3496 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3497{
3498 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
3499 bgp_node_safi (vty));
3500}
3501
3502ALIAS (no_bgp_network,
3503 no_bgp_network_route_map_cmd,
3504 "no network A.B.C.D/M route-map WORD",
3505 NO_STR
3506 "Specify a network to announce via BGP\n"
3507 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3508 "Route-map to modify the attributes\n"
3509 "Name of the route map\n")
3510
3511ALIAS (no_bgp_network,
3512 no_bgp_network_backdoor_cmd,
3513 "no network A.B.C.D/M backdoor",
3514 NO_STR
3515 "Specify a network to announce via BGP\n"
3516 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3517 "Specify a BGP backdoor route\n")
3518
3519DEFUN (no_bgp_network_mask,
3520 no_bgp_network_mask_cmd,
3521 "no network A.B.C.D mask A.B.C.D",
3522 NO_STR
3523 "Specify a network to announce via BGP\n"
3524 "Network number\n"
3525 "Network mask\n"
3526 "Network mask\n")
3527{
3528 int ret;
3529 char prefix_str[BUFSIZ];
3530
3531 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3532 if (! ret)
3533 {
3534 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3535 return CMD_WARNING;
3536 }
3537
3538 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
3539 bgp_node_safi (vty));
3540}
3541
3542ALIAS (no_bgp_network_mask,
3543 no_bgp_network_mask_route_map_cmd,
3544 "no network A.B.C.D mask A.B.C.D route-map WORD",
3545 NO_STR
3546 "Specify a network to announce via BGP\n"
3547 "Network number\n"
3548 "Network mask\n"
3549 "Network mask\n"
3550 "Route-map to modify the attributes\n"
3551 "Name of the route map\n")
3552
3553ALIAS (no_bgp_network_mask,
3554 no_bgp_network_mask_backdoor_cmd,
3555 "no network A.B.C.D mask A.B.C.D backdoor",
3556 NO_STR
3557 "Specify a network to announce via BGP\n"
3558 "Network number\n"
3559 "Network mask\n"
3560 "Network mask\n"
3561 "Specify a BGP backdoor route\n")
3562
3563DEFUN (no_bgp_network_mask_natural,
3564 no_bgp_network_mask_natural_cmd,
3565 "no network A.B.C.D",
3566 NO_STR
3567 "Specify a network to announce via BGP\n"
3568 "Network number\n")
3569{
3570 int ret;
3571 char prefix_str[BUFSIZ];
3572
3573 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3574 if (! ret)
3575 {
3576 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3577 return CMD_WARNING;
3578 }
3579
3580 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
3581 bgp_node_safi (vty));
3582}
3583
3584ALIAS (no_bgp_network_mask_natural,
3585 no_bgp_network_mask_natural_route_map_cmd,
3586 "no network A.B.C.D route-map WORD",
3587 NO_STR
3588 "Specify a network to announce via BGP\n"
3589 "Network number\n"
3590 "Route-map to modify the attributes\n"
3591 "Name of the route map\n")
3592
3593ALIAS (no_bgp_network_mask_natural,
3594 no_bgp_network_mask_natural_backdoor_cmd,
3595 "no network A.B.C.D backdoor",
3596 NO_STR
3597 "Specify a network to announce via BGP\n"
3598 "Network number\n"
3599 "Specify a BGP backdoor route\n")
3600
3601#ifdef HAVE_IPV6
3602DEFUN (ipv6_bgp_network,
3603 ipv6_bgp_network_cmd,
3604 "network X:X::X:X/M",
3605 "Specify a network to announce via BGP\n"
3606 "IPv6 prefix <network>/<length>\n")
3607{
3608 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
3609}
3610
3611DEFUN (ipv6_bgp_network_route_map,
3612 ipv6_bgp_network_route_map_cmd,
3613 "network X:X::X:X/M route-map WORD",
3614 "Specify a network to announce via BGP\n"
3615 "IPv6 prefix <network>/<length>\n"
3616 "Route-map to modify the attributes\n"
3617 "Name of the route map\n")
3618{
3619 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
3620 bgp_node_safi (vty), argv[1], 0);
3621}
3622
3623DEFUN (no_ipv6_bgp_network,
3624 no_ipv6_bgp_network_cmd,
3625 "no network X:X::X:X/M",
3626 NO_STR
3627 "Specify a network to announce via BGP\n"
3628 "IPv6 prefix <network>/<length>\n")
3629{
3630 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST);
3631}
3632
3633ALIAS (no_ipv6_bgp_network,
3634 no_ipv6_bgp_network_route_map_cmd,
3635 "no network X:X::X:X/M route-map WORD",
3636 NO_STR
3637 "Specify a network to announce via BGP\n"
3638 "IPv6 prefix <network>/<length>\n"
3639 "Route-map to modify the attributes\n"
3640 "Name of the route map\n")
3641
3642ALIAS (ipv6_bgp_network,
3643 old_ipv6_bgp_network_cmd,
3644 "ipv6 bgp network X:X::X:X/M",
3645 IPV6_STR
3646 BGP_STR
3647 "Specify a network to announce via BGP\n"
3648 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
3649
3650ALIAS (no_ipv6_bgp_network,
3651 old_no_ipv6_bgp_network_cmd,
3652 "no ipv6 bgp network X:X::X:X/M",
3653 NO_STR
3654 IPV6_STR
3655 BGP_STR
3656 "Specify a network to announce via BGP\n"
3657 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
3658#endif /* HAVE_IPV6 */
3659
3660/* Aggreagete address:
3661
3662 advertise-map Set condition to advertise attribute
3663 as-set Generate AS set path information
3664 attribute-map Set attributes of aggregate
3665 route-map Set parameters of aggregate
3666 summary-only Filter more specific routes from updates
3667 suppress-map Conditionally filter more specific routes from updates
3668 <cr>
3669 */
3670struct bgp_aggregate
3671{
3672 /* Summary-only flag. */
3673 u_char summary_only;
3674
3675 /* AS set generation. */
3676 u_char as_set;
3677
3678 /* Route-map for aggregated route. */
3679 struct route_map *map;
3680
3681 /* Suppress-count. */
3682 unsigned long count;
3683
3684 /* SAFI configuration. */
3685 safi_t safi;
3686};
3687
3688struct bgp_aggregate *
3689bgp_aggregate_new ()
3690{
3691 struct bgp_aggregate *new;
3692 new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
3693 memset (new, 0, sizeof (struct bgp_aggregate));
3694 return new;
3695}
3696
3697void
3698bgp_aggregate_free (struct bgp_aggregate *aggregate)
3699{
3700 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
3701}
3702
3703void
3704bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
3705 afi_t afi, safi_t safi, struct bgp_info *del,
3706 struct bgp_aggregate *aggregate)
3707{
3708 struct bgp_table *table;
3709 struct bgp_node *top;
3710 struct bgp_node *rn;
3711 u_char origin;
3712 struct aspath *aspath = NULL;
3713 struct aspath *asmerge = NULL;
3714 struct community *community = NULL;
3715 struct community *commerge = NULL;
3716 struct in_addr nexthop;
3717 u_int32_t med = 0;
3718 struct bgp_info *ri;
3719 struct bgp_info *new;
3720 int first = 1;
3721 unsigned long match = 0;
3722
3723 /* Record adding route's nexthop and med. */
3724 if (rinew)
3725 {
3726 nexthop = rinew->attr->nexthop;
3727 med = rinew->attr->med;
3728 }
3729
3730 /* ORIGIN attribute: If at least one route among routes that are
3731 aggregated has ORIGIN with the value INCOMPLETE, then the
3732 aggregated route must have the ORIGIN attribute with the value
3733 INCOMPLETE. Otherwise, if at least one route among routes that
3734 are aggregated has ORIGIN with the value EGP, then the aggregated
3735 route must have the origin attribute with the value EGP. In all
3736 other case the value of the ORIGIN attribute of the aggregated
3737 route is INTERNAL. */
3738 origin = BGP_ORIGIN_IGP;
3739
3740 table = bgp->rib[afi][safi];
3741
3742 top = bgp_node_get (table, p);
3743 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
3744 if (rn->p.prefixlen > p->prefixlen)
3745 {
3746 match = 0;
3747
3748 for (ri = rn->info; ri; ri = ri->next)
3749 {
3750 if (BGP_INFO_HOLDDOWN (ri))
3751 continue;
3752
3753 if (del && ri == del)
3754 continue;
3755
3756 if (! rinew && first)
3757 {
3758 nexthop = ri->attr->nexthop;
3759 med = ri->attr->med;
3760 first = 0;
3761 }
3762
3763#ifdef AGGREGATE_NEXTHOP_CHECK
3764 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
3765 || ri->attr->med != med)
3766 {
3767 if (aspath)
3768 aspath_free (aspath);
3769 if (community)
3770 community_free (community);
3771 bgp_unlock_node (rn);
3772 bgp_unlock_node (top);
3773 return;
3774 }
3775#endif /* AGGREGATE_NEXTHOP_CHECK */
3776
3777 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
3778 {
3779 if (aggregate->summary_only)
3780 {
3781 ri->suppress++;
3782 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
3783 match++;
3784 }
3785
3786 aggregate->count++;
3787
3788 if (aggregate->as_set)
3789 {
3790 if (origin < ri->attr->origin)
3791 origin = ri->attr->origin;
3792
3793 if (aspath)
3794 {
3795 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
3796 aspath_free (aspath);
3797 aspath = asmerge;
3798 }
3799 else
3800 aspath = aspath_dup (ri->attr->aspath);
3801
3802 if (ri->attr->community)
3803 {
3804 if (community)
3805 {
3806 commerge = community_merge (community,
3807 ri->attr->community);
3808 community = community_uniq_sort (commerge);
3809 community_free (commerge);
3810 }
3811 else
3812 community = community_dup (ri->attr->community);
3813 }
3814 }
3815 }
3816 }
3817 if (match)
3818 bgp_process (bgp, rn, afi, safi);
3819 }
3820 bgp_unlock_node (top);
3821
3822 if (rinew)
3823 {
3824 aggregate->count++;
3825
3826 if (aggregate->summary_only)
3827 rinew->suppress++;
3828
3829 if (aggregate->as_set)
3830 {
3831 if (origin < rinew->attr->origin)
3832 origin = rinew->attr->origin;
3833
3834 if (aspath)
3835 {
3836 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
3837 aspath_free (aspath);
3838 aspath = asmerge;
3839 }
3840 else
3841 aspath = aspath_dup (rinew->attr->aspath);
3842
3843 if (rinew->attr->community)
3844 {
3845 if (community)
3846 {
3847 commerge = community_merge (community,
3848 rinew->attr->community);
3849 community = community_uniq_sort (commerge);
3850 community_free (commerge);
3851 }
3852 else
3853 community = community_dup (rinew->attr->community);
3854 }
3855 }
3856 }
3857
3858 if (aggregate->count > 0)
3859 {
3860 rn = bgp_node_get (table, p);
3861 new = bgp_info_new ();
3862 new->type = ZEBRA_ROUTE_BGP;
3863 new->sub_type = BGP_ROUTE_AGGREGATE;
3864 new->peer = bgp->peer_self;
3865 SET_FLAG (new->flags, BGP_INFO_VALID);
3866 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
3867 new->uptime = time (NULL);
3868
3869 bgp_info_add (rn, new);
3870 bgp_process (bgp, rn, afi, safi);
3871 }
3872 else
3873 {
3874 if (aspath)
3875 aspath_free (aspath);
3876 if (community)
3877 community_free (community);
3878 }
3879}
3880
3881void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
3882 struct bgp_aggregate *);
3883
3884void
3885bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
3886 struct bgp_info *ri, afi_t afi, safi_t safi)
3887{
3888 struct bgp_node *child;
3889 struct bgp_node *rn;
3890 struct bgp_aggregate *aggregate;
3891
3892 /* MPLS-VPN aggregation is not yet supported. */
3893 if (safi == SAFI_MPLS_VPN)
3894 return;
3895
3896 if (p->prefixlen == 0)
3897 return;
3898
3899 if (BGP_INFO_HOLDDOWN (ri))
3900 return;
3901
3902 child = bgp_node_get (bgp->aggregate[afi][safi], p);
3903
3904 /* Aggregate address configuration check. */
3905 for (rn = child; rn; rn = rn->parent)
3906 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
3907 {
3908 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00003909 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00003910 }
3911 bgp_unlock_node (child);
3912}
3913
3914void
3915bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
3916 struct bgp_info *del, afi_t afi, safi_t safi)
3917{
3918 struct bgp_node *child;
3919 struct bgp_node *rn;
3920 struct bgp_aggregate *aggregate;
3921
3922 /* MPLS-VPN aggregation is not yet supported. */
3923 if (safi == SAFI_MPLS_VPN)
3924 return;
3925
3926 if (p->prefixlen == 0)
3927 return;
3928
3929 child = bgp_node_get (bgp->aggregate[afi][safi], p);
3930
3931 /* Aggregate address configuration check. */
3932 for (rn = child; rn; rn = rn->parent)
3933 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
3934 {
3935 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00003936 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00003937 }
3938 bgp_unlock_node (child);
3939}
3940
3941void
3942bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
3943 struct bgp_aggregate *aggregate)
3944{
3945 struct bgp_table *table;
3946 struct bgp_node *top;
3947 struct bgp_node *rn;
3948 struct bgp_info *new;
3949 struct bgp_info *ri;
3950 unsigned long match;
3951 u_char origin = BGP_ORIGIN_IGP;
3952 struct aspath *aspath = NULL;
3953 struct aspath *asmerge = NULL;
3954 struct community *community = NULL;
3955 struct community *commerge = NULL;
3956
3957 table = bgp->rib[afi][safi];
3958
3959 /* Sanity check. */
3960 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
3961 return;
3962 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
3963 return;
3964
3965 /* If routes exists below this node, generate aggregate routes. */
3966 top = bgp_node_get (table, p);
3967 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
3968 if (rn->p.prefixlen > p->prefixlen)
3969 {
3970 match = 0;
3971
3972 for (ri = rn->info; ri; ri = ri->next)
3973 {
3974 if (BGP_INFO_HOLDDOWN (ri))
3975 continue;
3976
3977 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
3978 {
3979 /* summary-only aggregate route suppress aggregated
3980 route announcement. */
3981 if (aggregate->summary_only)
3982 {
3983 ri->suppress++;
3984 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
3985 match++;
3986 }
3987 /* as-set aggregate route generate origin, as path,
3988 community aggregation. */
3989 if (aggregate->as_set)
3990 {
3991 if (origin < ri->attr->origin)
3992 origin = ri->attr->origin;
3993
3994 if (aspath)
3995 {
3996 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
3997 aspath_free (aspath);
3998 aspath = asmerge;
3999 }
4000 else
4001 aspath = aspath_dup (ri->attr->aspath);
4002
4003 if (ri->attr->community)
4004 {
4005 if (community)
4006 {
4007 commerge = community_merge (community,
4008 ri->attr->community);
4009 community = community_uniq_sort (commerge);
4010 community_free (commerge);
4011 }
4012 else
4013 community = community_dup (ri->attr->community);
4014 }
4015 }
4016 aggregate->count++;
4017 }
4018 }
4019
4020 /* If this node is suppressed, process the change. */
4021 if (match)
4022 bgp_process (bgp, rn, afi, safi);
4023 }
4024 bgp_unlock_node (top);
4025
4026 /* Add aggregate route to BGP table. */
4027 if (aggregate->count)
4028 {
4029 rn = bgp_node_get (table, p);
4030
4031 new = bgp_info_new ();
4032 new->type = ZEBRA_ROUTE_BGP;
4033 new->sub_type = BGP_ROUTE_AGGREGATE;
4034 new->peer = bgp->peer_self;
4035 SET_FLAG (new->flags, BGP_INFO_VALID);
4036 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
4037 new->uptime = time (NULL);
4038
4039 bgp_info_add (rn, new);
4040
4041 /* Process change. */
4042 bgp_process (bgp, rn, afi, safi);
4043 }
4044}
4045
4046void
4047bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
4048 safi_t safi, struct bgp_aggregate *aggregate)
4049{
4050 struct bgp_table *table;
4051 struct bgp_node *top;
4052 struct bgp_node *rn;
4053 struct bgp_info *ri;
4054 unsigned long match;
4055
4056 table = bgp->rib[afi][safi];
4057
4058 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
4059 return;
4060 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
4061 return;
4062
4063 /* If routes exists below this node, generate aggregate routes. */
4064 top = bgp_node_get (table, p);
4065 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4066 if (rn->p.prefixlen > p->prefixlen)
4067 {
4068 match = 0;
4069
4070 for (ri = rn->info; ri; ri = ri->next)
4071 {
4072 if (BGP_INFO_HOLDDOWN (ri))
4073 continue;
4074
4075 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4076 {
4077 if (aggregate->summary_only)
4078 {
4079 ri->suppress--;
4080
4081 if (ri->suppress == 0)
4082 {
4083 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
4084 match++;
4085 }
4086 }
4087 aggregate->count--;
4088 }
4089 }
4090
4091 /* If this node is suppressed, process the change. */
4092 if (match)
4093 bgp_process (bgp, rn, afi, safi);
4094 }
4095 bgp_unlock_node (top);
4096
4097 /* Delete aggregate route from BGP table. */
4098 rn = bgp_node_get (table, p);
4099
4100 for (ri = rn->info; ri; ri = ri->next)
4101 if (ri->peer == bgp->peer_self
4102 && ri->type == ZEBRA_ROUTE_BGP
4103 && ri->sub_type == BGP_ROUTE_AGGREGATE)
4104 break;
4105
4106 /* Withdraw static BGP route from routing table. */
4107 if (ri)
4108 {
4109 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
4110 bgp_process (bgp, rn, afi, safi);
4111 bgp_info_delete (rn, ri);
4112 bgp_info_free (ri);
4113 bgp_unlock_node (rn);
4114 }
4115
4116 /* Unlock bgp_node_lookup. */
4117 bgp_unlock_node (rn);
4118}
4119
4120/* Aggregate route attribute. */
4121#define AGGREGATE_SUMMARY_ONLY 1
4122#define AGGREGATE_AS_SET 1
4123
4124int
paulfd79ac92004-10-13 05:06:08 +00004125bgp_aggregate_set (struct vty *vty, const char *prefix_str,
4126 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00004127 u_char summary_only, u_char as_set)
4128{
4129 int ret;
4130 struct prefix p;
4131 struct bgp_node *rn;
4132 struct bgp *bgp;
4133 struct bgp_aggregate *aggregate;
4134
4135 /* Convert string to prefix structure. */
4136 ret = str2prefix (prefix_str, &p);
4137 if (!ret)
4138 {
4139 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
4140 return CMD_WARNING;
4141 }
4142 apply_mask (&p);
4143
4144 /* Get BGP structure. */
4145 bgp = vty->index;
4146
4147 /* Old configuration check. */
4148 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
4149
4150 if (rn->info)
4151 {
4152 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
4153 bgp_unlock_node (rn);
4154 return CMD_WARNING;
4155 }
4156
4157 /* Make aggregate address structure. */
4158 aggregate = bgp_aggregate_new ();
4159 aggregate->summary_only = summary_only;
4160 aggregate->as_set = as_set;
4161 aggregate->safi = safi;
4162 rn->info = aggregate;
4163
4164 /* Aggregate address insert into BGP routing table. */
4165 if (safi & SAFI_UNICAST)
4166 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
4167 if (safi & SAFI_MULTICAST)
4168 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
4169
4170 return CMD_SUCCESS;
4171}
4172
4173int
paulfd79ac92004-10-13 05:06:08 +00004174bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
4175 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004176{
4177 int ret;
4178 struct prefix p;
4179 struct bgp_node *rn;
4180 struct bgp *bgp;
4181 struct bgp_aggregate *aggregate;
4182
4183 /* Convert string to prefix structure. */
4184 ret = str2prefix (prefix_str, &p);
4185 if (!ret)
4186 {
4187 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
4188 return CMD_WARNING;
4189 }
4190 apply_mask (&p);
4191
4192 /* Get BGP structure. */
4193 bgp = vty->index;
4194
4195 /* Old configuration check. */
4196 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
4197 if (! rn)
4198 {
4199 vty_out (vty, "%% There is no aggregate-address configuration.%s",
4200 VTY_NEWLINE);
4201 return CMD_WARNING;
4202 }
4203
4204 aggregate = rn->info;
4205 if (aggregate->safi & SAFI_UNICAST)
4206 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
4207 if (aggregate->safi & SAFI_MULTICAST)
4208 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
4209
4210 /* Unlock aggregate address configuration. */
4211 rn->info = NULL;
4212 bgp_aggregate_free (aggregate);
4213 bgp_unlock_node (rn);
4214 bgp_unlock_node (rn);
4215
4216 return CMD_SUCCESS;
4217}
4218
4219DEFUN (aggregate_address,
4220 aggregate_address_cmd,
4221 "aggregate-address A.B.C.D/M",
4222 "Configure BGP aggregate entries\n"
4223 "Aggregate prefix\n")
4224{
4225 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
4226}
4227
4228DEFUN (aggregate_address_mask,
4229 aggregate_address_mask_cmd,
4230 "aggregate-address A.B.C.D A.B.C.D",
4231 "Configure BGP aggregate entries\n"
4232 "Aggregate address\n"
4233 "Aggregate mask\n")
4234{
4235 int ret;
4236 char prefix_str[BUFSIZ];
4237
4238 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4239
4240 if (! ret)
4241 {
4242 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4243 return CMD_WARNING;
4244 }
4245
4246 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4247 0, 0);
4248}
4249
4250DEFUN (aggregate_address_summary_only,
4251 aggregate_address_summary_only_cmd,
4252 "aggregate-address A.B.C.D/M summary-only",
4253 "Configure BGP aggregate entries\n"
4254 "Aggregate prefix\n"
4255 "Filter more specific routes from updates\n")
4256{
4257 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
4258 AGGREGATE_SUMMARY_ONLY, 0);
4259}
4260
4261DEFUN (aggregate_address_mask_summary_only,
4262 aggregate_address_mask_summary_only_cmd,
4263 "aggregate-address A.B.C.D A.B.C.D summary-only",
4264 "Configure BGP aggregate entries\n"
4265 "Aggregate address\n"
4266 "Aggregate mask\n"
4267 "Filter more specific routes from updates\n")
4268{
4269 int ret;
4270 char prefix_str[BUFSIZ];
4271
4272 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4273
4274 if (! ret)
4275 {
4276 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4277 return CMD_WARNING;
4278 }
4279
4280 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4281 AGGREGATE_SUMMARY_ONLY, 0);
4282}
4283
4284DEFUN (aggregate_address_as_set,
4285 aggregate_address_as_set_cmd,
4286 "aggregate-address A.B.C.D/M as-set",
4287 "Configure BGP aggregate entries\n"
4288 "Aggregate prefix\n"
4289 "Generate AS set path information\n")
4290{
4291 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
4292 0, AGGREGATE_AS_SET);
4293}
4294
4295DEFUN (aggregate_address_mask_as_set,
4296 aggregate_address_mask_as_set_cmd,
4297 "aggregate-address A.B.C.D A.B.C.D as-set",
4298 "Configure BGP aggregate entries\n"
4299 "Aggregate address\n"
4300 "Aggregate mask\n"
4301 "Generate AS set path information\n")
4302{
4303 int ret;
4304 char prefix_str[BUFSIZ];
4305
4306 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4307
4308 if (! ret)
4309 {
4310 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4311 return CMD_WARNING;
4312 }
4313
4314 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4315 0, AGGREGATE_AS_SET);
4316}
4317
4318
4319DEFUN (aggregate_address_as_set_summary,
4320 aggregate_address_as_set_summary_cmd,
4321 "aggregate-address A.B.C.D/M as-set summary-only",
4322 "Configure BGP aggregate entries\n"
4323 "Aggregate prefix\n"
4324 "Generate AS set path information\n"
4325 "Filter more specific routes from updates\n")
4326{
4327 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
4328 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
4329}
4330
4331ALIAS (aggregate_address_as_set_summary,
4332 aggregate_address_summary_as_set_cmd,
4333 "aggregate-address A.B.C.D/M summary-only as-set",
4334 "Configure BGP aggregate entries\n"
4335 "Aggregate prefix\n"
4336 "Filter more specific routes from updates\n"
4337 "Generate AS set path information\n")
4338
4339DEFUN (aggregate_address_mask_as_set_summary,
4340 aggregate_address_mask_as_set_summary_cmd,
4341 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4342 "Configure BGP aggregate entries\n"
4343 "Aggregate address\n"
4344 "Aggregate mask\n"
4345 "Generate AS set path information\n"
4346 "Filter more specific routes from updates\n")
4347{
4348 int ret;
4349 char prefix_str[BUFSIZ];
4350
4351 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4352
4353 if (! ret)
4354 {
4355 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4356 return CMD_WARNING;
4357 }
4358
4359 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4360 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
4361}
4362
4363ALIAS (aggregate_address_mask_as_set_summary,
4364 aggregate_address_mask_summary_as_set_cmd,
4365 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4366 "Configure BGP aggregate entries\n"
4367 "Aggregate address\n"
4368 "Aggregate mask\n"
4369 "Filter more specific routes from updates\n"
4370 "Generate AS set path information\n")
4371
4372DEFUN (no_aggregate_address,
4373 no_aggregate_address_cmd,
4374 "no aggregate-address A.B.C.D/M",
4375 NO_STR
4376 "Configure BGP aggregate entries\n"
4377 "Aggregate prefix\n")
4378{
4379 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
4380}
4381
4382ALIAS (no_aggregate_address,
4383 no_aggregate_address_summary_only_cmd,
4384 "no aggregate-address A.B.C.D/M summary-only",
4385 NO_STR
4386 "Configure BGP aggregate entries\n"
4387 "Aggregate prefix\n"
4388 "Filter more specific routes from updates\n")
4389
4390ALIAS (no_aggregate_address,
4391 no_aggregate_address_as_set_cmd,
4392 "no aggregate-address A.B.C.D/M as-set",
4393 NO_STR
4394 "Configure BGP aggregate entries\n"
4395 "Aggregate prefix\n"
4396 "Generate AS set path information\n")
4397
4398ALIAS (no_aggregate_address,
4399 no_aggregate_address_as_set_summary_cmd,
4400 "no aggregate-address A.B.C.D/M as-set summary-only",
4401 NO_STR
4402 "Configure BGP aggregate entries\n"
4403 "Aggregate prefix\n"
4404 "Generate AS set path information\n"
4405 "Filter more specific routes from updates\n")
4406
4407ALIAS (no_aggregate_address,
4408 no_aggregate_address_summary_as_set_cmd,
4409 "no aggregate-address A.B.C.D/M summary-only as-set",
4410 NO_STR
4411 "Configure BGP aggregate entries\n"
4412 "Aggregate prefix\n"
4413 "Filter more specific routes from updates\n"
4414 "Generate AS set path information\n")
4415
4416DEFUN (no_aggregate_address_mask,
4417 no_aggregate_address_mask_cmd,
4418 "no aggregate-address A.B.C.D A.B.C.D",
4419 NO_STR
4420 "Configure BGP aggregate entries\n"
4421 "Aggregate address\n"
4422 "Aggregate mask\n")
4423{
4424 int ret;
4425 char prefix_str[BUFSIZ];
4426
4427 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4428
4429 if (! ret)
4430 {
4431 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4432 return CMD_WARNING;
4433 }
4434
4435 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
4436}
4437
4438ALIAS (no_aggregate_address_mask,
4439 no_aggregate_address_mask_summary_only_cmd,
4440 "no aggregate-address A.B.C.D A.B.C.D summary-only",
4441 NO_STR
4442 "Configure BGP aggregate entries\n"
4443 "Aggregate address\n"
4444 "Aggregate mask\n"
4445 "Filter more specific routes from updates\n")
4446
4447ALIAS (no_aggregate_address_mask,
4448 no_aggregate_address_mask_as_set_cmd,
4449 "no aggregate-address A.B.C.D A.B.C.D as-set",
4450 NO_STR
4451 "Configure BGP aggregate entries\n"
4452 "Aggregate address\n"
4453 "Aggregate mask\n"
4454 "Generate AS set path information\n")
4455
4456ALIAS (no_aggregate_address_mask,
4457 no_aggregate_address_mask_as_set_summary_cmd,
4458 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4459 NO_STR
4460 "Configure BGP aggregate entries\n"
4461 "Aggregate address\n"
4462 "Aggregate mask\n"
4463 "Generate AS set path information\n"
4464 "Filter more specific routes from updates\n")
4465
4466ALIAS (no_aggregate_address_mask,
4467 no_aggregate_address_mask_summary_as_set_cmd,
4468 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4469 NO_STR
4470 "Configure BGP aggregate entries\n"
4471 "Aggregate address\n"
4472 "Aggregate mask\n"
4473 "Filter more specific routes from updates\n"
4474 "Generate AS set path information\n")
4475
4476#ifdef HAVE_IPV6
4477DEFUN (ipv6_aggregate_address,
4478 ipv6_aggregate_address_cmd,
4479 "aggregate-address X:X::X:X/M",
4480 "Configure BGP aggregate entries\n"
4481 "Aggregate prefix\n")
4482{
4483 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
4484}
4485
4486DEFUN (ipv6_aggregate_address_summary_only,
4487 ipv6_aggregate_address_summary_only_cmd,
4488 "aggregate-address X:X::X:X/M summary-only",
4489 "Configure BGP aggregate entries\n"
4490 "Aggregate prefix\n"
4491 "Filter more specific routes from updates\n")
4492{
4493 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
4494 AGGREGATE_SUMMARY_ONLY, 0);
4495}
4496
4497DEFUN (no_ipv6_aggregate_address,
4498 no_ipv6_aggregate_address_cmd,
4499 "no aggregate-address X:X::X:X/M",
4500 NO_STR
4501 "Configure BGP aggregate entries\n"
4502 "Aggregate prefix\n")
4503{
4504 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
4505}
4506
4507DEFUN (no_ipv6_aggregate_address_summary_only,
4508 no_ipv6_aggregate_address_summary_only_cmd,
4509 "no aggregate-address X:X::X:X/M summary-only",
4510 NO_STR
4511 "Configure BGP aggregate entries\n"
4512 "Aggregate prefix\n"
4513 "Filter more specific routes from updates\n")
4514{
4515 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
4516}
4517
4518ALIAS (ipv6_aggregate_address,
4519 old_ipv6_aggregate_address_cmd,
4520 "ipv6 bgp aggregate-address X:X::X:X/M",
4521 IPV6_STR
4522 BGP_STR
4523 "Configure BGP aggregate entries\n"
4524 "Aggregate prefix\n")
4525
4526ALIAS (ipv6_aggregate_address_summary_only,
4527 old_ipv6_aggregate_address_summary_only_cmd,
4528 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4529 IPV6_STR
4530 BGP_STR
4531 "Configure BGP aggregate entries\n"
4532 "Aggregate prefix\n"
4533 "Filter more specific routes from updates\n")
4534
4535ALIAS (no_ipv6_aggregate_address,
4536 old_no_ipv6_aggregate_address_cmd,
4537 "no ipv6 bgp aggregate-address X:X::X:X/M",
4538 NO_STR
4539 IPV6_STR
4540 BGP_STR
4541 "Configure BGP aggregate entries\n"
4542 "Aggregate prefix\n")
4543
4544ALIAS (no_ipv6_aggregate_address_summary_only,
4545 old_no_ipv6_aggregate_address_summary_only_cmd,
4546 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4547 NO_STR
4548 IPV6_STR
4549 BGP_STR
4550 "Configure BGP aggregate entries\n"
4551 "Aggregate prefix\n"
4552 "Filter more specific routes from updates\n")
4553#endif /* HAVE_IPV6 */
4554
4555/* Redistribute route treatment. */
4556void
4557bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop,
4558 u_int32_t metric, u_char type)
4559{
4560 struct bgp *bgp;
4561 struct listnode *nn;
4562 struct bgp_info *new;
4563 struct bgp_info *bi;
4564 struct bgp_info info;
4565 struct bgp_node *bn;
4566 struct attr attr;
4567 struct attr attr_new;
4568 struct attr *new_attr;
4569 afi_t afi;
4570 int ret;
4571
4572 /* Make default attribute. */
4573 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
4574 if (nexthop)
4575 attr.nexthop = *nexthop;
4576
4577 attr.med = metric;
4578 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
4579
4580 LIST_LOOP (bm->bgp, bgp, nn)
4581 {
4582 afi = family2afi (p->family);
4583
4584 if (bgp->redist[afi][type])
4585 {
4586 /* Copy attribute for modification. */
4587 attr_new = attr;
4588
4589 if (bgp->redist_metric_flag[afi][type])
4590 attr_new.med = bgp->redist_metric[afi][type];
4591
4592 /* Apply route-map. */
4593 if (bgp->rmap[afi][type].map)
4594 {
4595 info.peer = bgp->peer_self;
4596 info.attr = &attr_new;
4597
paulfee0f4c2004-09-13 05:12:46 +00004598 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
4599
paul718e3742002-12-13 20:15:29 +00004600 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
4601 &info);
paulfee0f4c2004-09-13 05:12:46 +00004602
4603 bgp->peer_self->rmap_type = 0;
4604
paul718e3742002-12-13 20:15:29 +00004605 if (ret == RMAP_DENYMATCH)
4606 {
4607 /* Free uninterned attribute. */
4608 bgp_attr_flush (&attr_new);
4609
4610 /* Unintern original. */
4611 aspath_unintern (attr.aspath);
4612 bgp_redistribute_delete (p, type);
4613 return;
4614 }
4615 }
4616
paulfee0f4c2004-09-13 05:12:46 +00004617 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00004618 new_attr = bgp_attr_intern (&attr_new);
4619
4620 for (bi = bn->info; bi; bi = bi->next)
4621 if (bi->peer == bgp->peer_self
4622 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
4623 break;
4624
4625 if (bi)
4626 {
4627 if (attrhash_cmp (bi->attr, new_attr))
4628 {
4629 bgp_attr_unintern (new_attr);
4630 aspath_unintern (attr.aspath);
4631 bgp_unlock_node (bn);
4632 return;
4633 }
4634 else
4635 {
4636 /* The attribute is changed. */
4637 SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED);
4638
4639 /* Rewrite BGP route information. */
4640 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
4641 bgp_attr_unintern (bi->attr);
4642 bi->attr = new_attr;
4643 bi->uptime = time (NULL);
4644
4645 /* Process change. */
4646 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
4647 bgp_process (bgp, bn, afi, SAFI_UNICAST);
4648 bgp_unlock_node (bn);
4649 aspath_unintern (attr.aspath);
4650 return;
4651 }
4652 }
4653
4654 new = bgp_info_new ();
4655 new->type = type;
4656 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
4657 new->peer = bgp->peer_self;
4658 SET_FLAG (new->flags, BGP_INFO_VALID);
4659 new->attr = new_attr;
4660 new->uptime = time (NULL);
4661
4662 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
4663 bgp_info_add (bn, new);
4664 bgp_process (bgp, bn, afi, SAFI_UNICAST);
4665 }
4666 }
4667
4668 /* Unintern original. */
4669 aspath_unintern (attr.aspath);
4670}
4671
4672void
4673bgp_redistribute_delete (struct prefix *p, u_char type)
4674{
4675 struct bgp *bgp;
4676 struct listnode *nn;
4677 afi_t afi;
4678 struct bgp_node *rn;
4679 struct bgp_info *ri;
4680
4681 LIST_LOOP (bm->bgp, bgp, nn)
4682 {
4683 afi = family2afi (p->family);
4684
4685 if (bgp->redist[afi][type])
4686 {
paulfee0f4c2004-09-13 05:12:46 +00004687 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00004688
4689 for (ri = rn->info; ri; ri = ri->next)
4690 if (ri->peer == bgp->peer_self
4691 && ri->type == type)
4692 break;
4693
4694 if (ri)
4695 {
4696 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
4697 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
4698 bgp_process (bgp, rn, afi, SAFI_UNICAST);
4699 bgp_info_delete (rn, ri);
4700 bgp_info_free (ri);
4701 bgp_unlock_node (rn);
4702 }
4703 bgp_unlock_node (rn);
4704 }
4705 }
4706}
4707
4708/* Withdraw specified route type's route. */
4709void
4710bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
4711{
4712 struct bgp_node *rn;
4713 struct bgp_info *ri;
4714 struct bgp_table *table;
4715
4716 table = bgp->rib[afi][SAFI_UNICAST];
4717
4718 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
4719 {
4720 for (ri = rn->info; ri; ri = ri->next)
4721 if (ri->peer == bgp->peer_self
4722 && ri->type == type)
4723 break;
4724
4725 if (ri)
4726 {
4727 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
4728 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
4729 bgp_process (bgp, rn, afi, SAFI_UNICAST);
4730 bgp_info_delete (rn, ri);
4731 bgp_info_free (ri);
4732 bgp_unlock_node (rn);
4733 }
4734 }
4735}
4736
4737/* Static function to display route. */
4738void
4739route_vty_out_route (struct prefix *p, struct vty *vty)
4740{
4741 int len;
4742 u_int32_t destination;
4743 char buf[BUFSIZ];
4744
4745 if (p->family == AF_INET)
4746 {
4747 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
4748 destination = ntohl (p->u.prefix4.s_addr);
4749
4750 if ((IN_CLASSC (destination) && p->prefixlen == 24)
4751 || (IN_CLASSB (destination) && p->prefixlen == 16)
4752 || (IN_CLASSA (destination) && p->prefixlen == 8)
4753 || p->u.prefix4.s_addr == 0)
4754 {
4755 /* When mask is natural, mask is not displayed. */
4756 }
4757 else
4758 len += vty_out (vty, "/%d", p->prefixlen);
4759 }
4760 else
4761 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
4762 p->prefixlen);
4763
4764 len = 17 - len;
4765 if (len < 1)
4766 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
4767 else
4768 vty_out (vty, "%*s", len, " ");
4769}
4770
paul718e3742002-12-13 20:15:29 +00004771enum bgp_display_type
4772{
4773 normal_list,
4774};
4775
4776/* called from terminal list command */
ajs5a646652004-11-05 01:25:55 +00004777void
paul718e3742002-12-13 20:15:29 +00004778route_vty_out (struct vty *vty, struct prefix *p,
4779 struct bgp_info *binfo, int display, safi_t safi)
4780{
4781 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00004782
4783 /* Route status display. */
hasso93406d82005-02-02 14:40:33 +00004784 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
4785 vty_out (vty, "S");
4786 else if (binfo->suppress)
paul718e3742002-12-13 20:15:29 +00004787 vty_out (vty, "s");
4788 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4789 vty_out (vty, "*");
4790 else
4791 vty_out (vty, " ");
4792
4793 /* Selected */
4794 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4795 vty_out (vty, "h");
4796 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4797 vty_out (vty, "d");
4798 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
4799 vty_out (vty, ">");
4800 else
4801 vty_out (vty, " ");
4802
4803 /* Internal route. */
4804 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
4805 vty_out (vty, "i");
4806 else
4807 vty_out (vty, " ");
4808
4809 /* print prefix and mask */
4810 if (! display)
4811 route_vty_out_route (p, vty);
4812 else
4813 vty_out (vty, "%*s", 17, " ");
4814
4815 /* Print attribute */
4816 attr = binfo->attr;
4817 if (attr)
4818 {
4819 if (p->family == AF_INET)
4820 {
4821 if (safi == SAFI_MPLS_VPN)
4822 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
4823 else
4824 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
4825 }
4826#ifdef HAVE_IPV6
4827 else if (p->family == AF_INET6)
4828 {
4829 int len;
4830 char buf[BUFSIZ];
4831
4832 len = vty_out (vty, "%s",
4833 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
4834 len = 16 - len;
4835 if (len < 1)
4836 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
4837 else
4838 vty_out (vty, "%*s", len, " ");
4839 }
4840#endif /* HAVE_IPV6 */
4841
4842 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
4843 vty_out (vty, "%10d", attr->med);
4844 else
4845 vty_out (vty, " ");
4846
4847 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
4848 vty_out (vty, "%7d", attr->local_pref);
4849 else
4850 vty_out (vty, " ");
4851
4852 vty_out (vty, "%7u ",attr->weight);
4853
4854 /* Print aspath */
4855 if (attr->aspath)
4856 aspath_print_vty (vty, attr->aspath);
4857
4858 /* Print origin */
4859 if (strlen (attr->aspath->str) == 0)
4860 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
4861 else
4862 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
4863 }
4864 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004865}
4866
4867/* called from terminal list command */
4868void
4869route_vty_out_tmp (struct vty *vty, struct prefix *p,
4870 struct attr *attr, safi_t safi)
4871{
4872 /* Route status display. */
4873 vty_out (vty, "*");
4874 vty_out (vty, ">");
4875 vty_out (vty, " ");
4876
4877 /* print prefix and mask */
4878 route_vty_out_route (p, vty);
4879
4880 /* Print attribute */
4881 if (attr)
4882 {
4883 if (p->family == AF_INET)
4884 {
4885 if (safi == SAFI_MPLS_VPN)
4886 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
4887 else
4888 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
4889 }
4890#ifdef HAVE_IPV6
4891 else if (p->family == AF_INET6)
4892 {
4893 int len;
4894 char buf[BUFSIZ];
4895
4896 len = vty_out (vty, "%s",
4897 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
4898 len = 16 - len;
4899 if (len < 1)
4900 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
4901 else
4902 vty_out (vty, "%*s", len, " ");
4903 }
4904#endif /* HAVE_IPV6 */
4905
4906 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
4907 vty_out (vty, "%10d", attr->med);
4908 else
4909 vty_out (vty, " ");
4910
4911 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
4912 vty_out (vty, "%7d", attr->local_pref);
4913 else
4914 vty_out (vty, " ");
4915
4916 vty_out (vty, "%7d ",attr->weight);
4917
4918 /* Print aspath */
4919 if (attr->aspath)
4920 aspath_print_vty (vty, attr->aspath);
4921
4922 /* Print origin */
4923 if (strlen (attr->aspath->str) == 0)
4924 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
4925 else
4926 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
4927 }
4928
4929 vty_out (vty, "%s", VTY_NEWLINE);
4930}
4931
ajs5a646652004-11-05 01:25:55 +00004932void
paul718e3742002-12-13 20:15:29 +00004933route_vty_out_tag (struct vty *vty, struct prefix *p,
4934 struct bgp_info *binfo, int display, safi_t safi)
4935{
4936 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00004937 u_int32_t label = 0;
4938
paul718e3742002-12-13 20:15:29 +00004939 /* Route status display. */
4940 if (binfo->suppress)
4941 vty_out (vty, "s");
4942 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4943 vty_out (vty, "*");
4944 else
4945 vty_out (vty, " ");
4946
4947 /* Selected */
4948 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4949 vty_out (vty, "h");
4950 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4951 vty_out (vty, "d");
4952 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
4953 vty_out (vty, ">");
4954 else
4955 vty_out (vty, " ");
4956
4957 /* Internal route. */
4958 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
4959 vty_out (vty, "i");
4960 else
4961 vty_out (vty, " ");
4962
4963 /* print prefix and mask */
4964 if (! display)
4965 route_vty_out_route (p, vty);
4966 else
4967 vty_out (vty, "%*s", 17, " ");
4968
4969 /* Print attribute */
4970 attr = binfo->attr;
4971 if (attr)
4972 {
4973 if (p->family == AF_INET)
4974 {
4975 if (safi == SAFI_MPLS_VPN)
4976 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
4977 else
4978 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
4979 }
4980#ifdef HAVE_IPV6
4981 else if (p->family == AF_INET6)
4982 {
4983 char buf[BUFSIZ];
4984 char buf1[BUFSIZ];
4985 if (attr->mp_nexthop_len == 16)
4986 vty_out (vty, "%s",
4987 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
4988 else if (attr->mp_nexthop_len == 32)
4989 vty_out (vty, "%s(%s)",
4990 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ),
4991 inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ));
4992
4993 }
4994#endif /* HAVE_IPV6 */
4995 }
4996
4997 label = decode_label (binfo->tag);
4998
4999 vty_out (vty, "notag/%d", label);
5000
5001 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005002}
5003
5004/* dampening route */
ajs5a646652004-11-05 01:25:55 +00005005static void
paul718e3742002-12-13 20:15:29 +00005006damp_route_vty_out (struct vty *vty, struct prefix *p,
5007 struct bgp_info *binfo, int display, safi_t safi)
5008{
5009 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00005010 int len;
5011
paul718e3742002-12-13 20:15:29 +00005012 /* Route status display. */
5013 if (binfo->suppress)
5014 vty_out (vty, "s");
5015 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5016 vty_out (vty, "*");
5017 else
5018 vty_out (vty, " ");
5019
5020 /* Selected */
5021 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5022 vty_out (vty, "h");
5023 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5024 vty_out (vty, "d");
5025 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5026 vty_out (vty, ">");
5027 else
5028 vty_out (vty, " ");
5029
5030 vty_out (vty, " ");
5031
5032 /* print prefix and mask */
5033 if (! display)
5034 route_vty_out_route (p, vty);
5035 else
5036 vty_out (vty, "%*s", 17, " ");
5037
5038 len = vty_out (vty, "%s", binfo->peer->host);
5039 len = 17 - len;
5040 if (len < 1)
5041 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
5042 else
5043 vty_out (vty, "%*s", len, " ");
5044
5045 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
5046
5047 /* Print attribute */
5048 attr = binfo->attr;
5049 if (attr)
5050 {
5051 /* Print aspath */
5052 if (attr->aspath)
5053 aspath_print_vty (vty, attr->aspath);
5054
5055 /* Print origin */
5056 if (strlen (attr->aspath->str) == 0)
5057 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
5058 else
5059 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
5060 }
5061 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005062}
5063
5064#define BGP_UPTIME_LEN 25
5065
5066/* flap route */
ajs5a646652004-11-05 01:25:55 +00005067static void
paul718e3742002-12-13 20:15:29 +00005068flap_route_vty_out (struct vty *vty, struct prefix *p,
5069 struct bgp_info *binfo, int display, safi_t safi)
5070{
5071 struct attr *attr;
5072 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00005073 char timebuf[BGP_UPTIME_LEN];
5074 int len;
5075
paul718e3742002-12-13 20:15:29 +00005076 bdi = binfo->damp_info;
5077
5078 /* Route status display. */
5079 if (binfo->suppress)
5080 vty_out (vty, "s");
5081 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5082 vty_out (vty, "*");
5083 else
5084 vty_out (vty, " ");
5085
5086 /* Selected */
5087 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5088 vty_out (vty, "h");
5089 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5090 vty_out (vty, "d");
5091 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5092 vty_out (vty, ">");
5093 else
5094 vty_out (vty, " ");
5095
5096 vty_out (vty, " ");
5097
5098 /* print prefix and mask */
5099 if (! display)
5100 route_vty_out_route (p, vty);
5101 else
5102 vty_out (vty, "%*s", 17, " ");
5103
5104 len = vty_out (vty, "%s", binfo->peer->host);
5105 len = 16 - len;
5106 if (len < 1)
5107 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
5108 else
5109 vty_out (vty, "%*s", len, " ");
5110
5111 len = vty_out (vty, "%d", bdi->flap);
5112 len = 5 - len;
5113 if (len < 1)
5114 vty_out (vty, " ");
5115 else
5116 vty_out (vty, "%*s ", len, " ");
5117
5118 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
5119 timebuf, BGP_UPTIME_LEN));
5120
5121 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
5122 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5123 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
5124 else
5125 vty_out (vty, "%*s ", 8, " ");
5126
5127 /* Print attribute */
5128 attr = binfo->attr;
5129 if (attr)
5130 {
5131 /* Print aspath */
5132 if (attr->aspath)
5133 aspath_print_vty (vty, attr->aspath);
5134
5135 /* Print origin */
5136 if (strlen (attr->aspath->str) == 0)
5137 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
5138 else
5139 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
5140 }
5141 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005142}
5143
5144void
5145route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
5146 struct bgp_info *binfo, afi_t afi, safi_t safi)
5147{
5148 char buf[INET6_ADDRSTRLEN];
5149 char buf1[BUFSIZ];
5150 struct attr *attr;
5151 int sockunion_vty_out (struct vty *, union sockunion *);
5152
5153 attr = binfo->attr;
5154
5155 if (attr)
5156 {
5157 /* Line1 display AS-path, Aggregator */
5158 if (attr->aspath)
5159 {
5160 vty_out (vty, " ");
5161 if (attr->aspath->length == 0)
5162 vty_out (vty, "Local");
5163 else
5164 aspath_print_vty (vty, attr->aspath);
5165 }
5166
hasso93406d82005-02-02 14:40:33 +00005167 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
5168 vty_out (vty, ", (stale)");
5169 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
5170 vty_out (vty, ", (aggregated by %d %s)", attr->aggregator_as,
5171 inet_ntoa (attr->aggregator_addr));
5172 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
5173 vty_out (vty, ", (Received from a RR-client)");
5174 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
5175 vty_out (vty, ", (Received from a RS-client)");
5176 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5177 vty_out (vty, ", (history entry)");
5178 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5179 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00005180 vty_out (vty, "%s", VTY_NEWLINE);
5181
5182 /* Line2 display Next-hop, Neighbor, Router-id */
5183 if (p->family == AF_INET)
5184 {
5185 vty_out (vty, " %s", safi == SAFI_MPLS_VPN ?
5186 inet_ntoa (attr->mp_nexthop_global_in) :
5187 inet_ntoa (attr->nexthop));
5188 }
5189#ifdef HAVE_IPV6
5190 else
5191 {
5192 vty_out (vty, " %s",
5193 inet_ntop (AF_INET6, &attr->mp_nexthop_global,
5194 buf, INET6_ADDRSTRLEN));
5195 }
5196#endif /* HAVE_IPV6 */
5197
5198 if (binfo->peer == bgp->peer_self)
5199 {
5200 vty_out (vty, " from %s ",
5201 p->family == AF_INET ? "0.0.0.0" : "::");
5202 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
5203 }
5204 else
5205 {
5206 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
5207 vty_out (vty, " (inaccessible)");
5208 else if (binfo->igpmetric)
5209 vty_out (vty, " (metric %d)", binfo->igpmetric);
pauleb821182004-05-01 08:44:08 +00005210 vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN));
paul718e3742002-12-13 20:15:29 +00005211 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
5212 vty_out (vty, " (%s)", inet_ntoa (attr->originator_id));
5213 else
5214 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
5215 }
5216 vty_out (vty, "%s", VTY_NEWLINE);
5217
5218#ifdef HAVE_IPV6
5219 /* display nexthop local */
5220 if (attr->mp_nexthop_len == 32)
5221 {
5222 vty_out (vty, " (%s)%s",
5223 inet_ntop (AF_INET6, &attr->mp_nexthop_local,
5224 buf, INET6_ADDRSTRLEN),
5225 VTY_NEWLINE);
5226 }
5227#endif /* HAVE_IPV6 */
5228
5229 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5230 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
5231
5232 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
5233 vty_out (vty, ", metric %d", attr->med);
5234
5235 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
5236 vty_out (vty, ", localpref %d", attr->local_pref);
5237 else
5238 vty_out (vty, ", localpref %d", bgp->default_local_pref);
5239
5240 if (attr->weight != 0)
5241 vty_out (vty, ", weight %d", attr->weight);
5242
5243 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5244 vty_out (vty, ", valid");
5245
5246 if (binfo->peer != bgp->peer_self)
5247 {
5248 if (binfo->peer->as == binfo->peer->local_as)
5249 vty_out (vty, ", internal");
5250 else
5251 vty_out (vty, ", %s",
5252 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
5253 }
5254 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
5255 vty_out (vty, ", aggregated, local");
5256 else if (binfo->type != ZEBRA_ROUTE_BGP)
5257 vty_out (vty, ", sourced");
5258 else
5259 vty_out (vty, ", sourced, local");
5260
5261 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
5262 vty_out (vty, ", atomic-aggregate");
5263
5264 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5265 vty_out (vty, ", best");
5266
5267 vty_out (vty, "%s", VTY_NEWLINE);
5268
5269 /* Line 4 display Community */
5270 if (attr->community)
5271 vty_out (vty, " Community: %s%s", attr->community->str,
5272 VTY_NEWLINE);
5273
5274 /* Line 5 display Extended-community */
5275 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
5276 vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str,
5277 VTY_NEWLINE);
5278
5279 /* Line 6 display Originator, Cluster-id */
5280 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
5281 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
5282 {
5283 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
5284 vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id));
5285
5286 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
5287 {
5288 int i;
5289 vty_out (vty, ", Cluster list: ");
5290 for (i = 0; i < attr->cluster->length / 4; i++)
5291 vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i]));
5292 }
5293 vty_out (vty, "%s", VTY_NEWLINE);
5294 }
5295
5296 if (binfo->damp_info)
5297 bgp_damp_info_vty (vty, binfo);
5298
5299 /* Line 7 display Uptime */
5300 vty_out (vty, " Last update: %s", ctime (&binfo->uptime));
5301 }
5302 vty_out (vty, "%s", VTY_NEWLINE);
5303}
5304
hasso93406d82005-02-02 14:40:33 +00005305#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale%s"
5306#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00005307#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
5308#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
5309#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
5310
5311enum bgp_show_type
5312{
5313 bgp_show_type_normal,
5314 bgp_show_type_regexp,
5315 bgp_show_type_prefix_list,
5316 bgp_show_type_filter_list,
5317 bgp_show_type_route_map,
5318 bgp_show_type_neighbor,
5319 bgp_show_type_cidr_only,
5320 bgp_show_type_prefix_longer,
5321 bgp_show_type_community_all,
5322 bgp_show_type_community,
5323 bgp_show_type_community_exact,
5324 bgp_show_type_community_list,
5325 bgp_show_type_community_list_exact,
5326 bgp_show_type_flap_statistics,
5327 bgp_show_type_flap_address,
5328 bgp_show_type_flap_prefix,
5329 bgp_show_type_flap_cidr_only,
5330 bgp_show_type_flap_regexp,
5331 bgp_show_type_flap_filter_list,
5332 bgp_show_type_flap_prefix_list,
5333 bgp_show_type_flap_prefix_longer,
5334 bgp_show_type_flap_route_map,
5335 bgp_show_type_flap_neighbor,
5336 bgp_show_type_dampend_paths,
5337 bgp_show_type_damp_neighbor
5338};
5339
ajs5a646652004-11-05 01:25:55 +00005340static int
paulfee0f4c2004-09-13 05:12:46 +00005341bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00005342 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00005343{
paul718e3742002-12-13 20:15:29 +00005344 struct bgp_info *ri;
5345 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00005346 int header = 1;
paul718e3742002-12-13 20:15:29 +00005347 int display;
ajs5a646652004-11-05 01:25:55 +00005348 unsigned long output_count;
paul718e3742002-12-13 20:15:29 +00005349
5350 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00005351 output_count = 0;
paul718e3742002-12-13 20:15:29 +00005352
paul718e3742002-12-13 20:15:29 +00005353 /* Start processing of routes. */
5354 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5355 if (rn->info != NULL)
5356 {
5357 display = 0;
5358
5359 for (ri = rn->info; ri; ri = ri->next)
5360 {
ajs5a646652004-11-05 01:25:55 +00005361 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00005362 || type == bgp_show_type_flap_address
5363 || type == bgp_show_type_flap_prefix
5364 || type == bgp_show_type_flap_cidr_only
5365 || type == bgp_show_type_flap_regexp
5366 || type == bgp_show_type_flap_filter_list
5367 || type == bgp_show_type_flap_prefix_list
5368 || type == bgp_show_type_flap_prefix_longer
5369 || type == bgp_show_type_flap_route_map
5370 || type == bgp_show_type_flap_neighbor
5371 || type == bgp_show_type_dampend_paths
5372 || type == bgp_show_type_damp_neighbor)
5373 {
5374 if (! ri->damp_info)
5375 continue;
5376 }
5377 if (type == bgp_show_type_regexp
5378 || type == bgp_show_type_flap_regexp)
5379 {
ajs5a646652004-11-05 01:25:55 +00005380 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00005381
5382 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
5383 continue;
5384 }
5385 if (type == bgp_show_type_prefix_list
5386 || type == bgp_show_type_flap_prefix_list)
5387 {
ajs5a646652004-11-05 01:25:55 +00005388 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00005389
5390 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
5391 continue;
5392 }
5393 if (type == bgp_show_type_filter_list
5394 || type == bgp_show_type_flap_filter_list)
5395 {
ajs5a646652004-11-05 01:25:55 +00005396 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00005397
5398 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
5399 continue;
5400 }
5401 if (type == bgp_show_type_route_map
5402 || type == bgp_show_type_flap_route_map)
5403 {
ajs5a646652004-11-05 01:25:55 +00005404 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00005405 struct bgp_info binfo;
5406 struct attr dummy_attr;
5407 int ret;
5408
5409 dummy_attr = *ri->attr;
5410 binfo.peer = ri->peer;
5411 binfo.attr = &dummy_attr;
5412
5413 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
5414
5415 if (ret == RMAP_DENYMATCH)
5416 continue;
5417 }
5418 if (type == bgp_show_type_neighbor
5419 || type == bgp_show_type_flap_neighbor
5420 || type == bgp_show_type_damp_neighbor)
5421 {
ajs5a646652004-11-05 01:25:55 +00005422 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00005423
5424 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
5425 continue;
5426 }
5427 if (type == bgp_show_type_cidr_only
5428 || type == bgp_show_type_flap_cidr_only)
5429 {
5430 u_int32_t destination;
5431
5432 destination = ntohl (rn->p.u.prefix4.s_addr);
5433 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
5434 continue;
5435 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
5436 continue;
5437 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
5438 continue;
5439 }
5440 if (type == bgp_show_type_prefix_longer
5441 || type == bgp_show_type_flap_prefix_longer)
5442 {
ajs5a646652004-11-05 01:25:55 +00005443 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00005444
5445 if (! prefix_match (p, &rn->p))
5446 continue;
5447 }
5448 if (type == bgp_show_type_community_all)
5449 {
5450 if (! ri->attr->community)
5451 continue;
5452 }
5453 if (type == bgp_show_type_community)
5454 {
ajs5a646652004-11-05 01:25:55 +00005455 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00005456
5457 if (! ri->attr->community ||
5458 ! community_match (ri->attr->community, com))
5459 continue;
5460 }
5461 if (type == bgp_show_type_community_exact)
5462 {
ajs5a646652004-11-05 01:25:55 +00005463 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00005464
5465 if (! ri->attr->community ||
5466 ! community_cmp (ri->attr->community, com))
5467 continue;
5468 }
5469 if (type == bgp_show_type_community_list)
5470 {
ajs5a646652004-11-05 01:25:55 +00005471 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00005472
5473 if (! community_list_match (ri->attr->community, list))
5474 continue;
5475 }
5476 if (type == bgp_show_type_community_list_exact)
5477 {
ajs5a646652004-11-05 01:25:55 +00005478 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00005479
5480 if (! community_list_exact_match (ri->attr->community, list))
5481 continue;
5482 }
5483 if (type == bgp_show_type_flap_address
5484 || type == bgp_show_type_flap_prefix)
5485 {
ajs5a646652004-11-05 01:25:55 +00005486 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00005487
5488 if (! prefix_match (&rn->p, p))
5489 continue;
5490
5491 if (type == bgp_show_type_flap_prefix)
5492 if (p->prefixlen != rn->p.prefixlen)
5493 continue;
5494 }
5495 if (type == bgp_show_type_dampend_paths
5496 || type == bgp_show_type_damp_neighbor)
5497 {
5498 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
5499 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
5500 continue;
5501 }
5502
5503 if (header)
5504 {
hasso93406d82005-02-02 14:40:33 +00005505 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
5506 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
5507 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005508 if (type == bgp_show_type_dampend_paths
5509 || type == bgp_show_type_damp_neighbor)
5510 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
5511 else if (type == bgp_show_type_flap_statistics
5512 || type == bgp_show_type_flap_address
5513 || type == bgp_show_type_flap_prefix
5514 || type == bgp_show_type_flap_cidr_only
5515 || type == bgp_show_type_flap_regexp
5516 || type == bgp_show_type_flap_filter_list
5517 || type == bgp_show_type_flap_prefix_list
5518 || type == bgp_show_type_flap_prefix_longer
5519 || type == bgp_show_type_flap_route_map
5520 || type == bgp_show_type_flap_neighbor)
5521 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
5522 else
5523 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005524 header = 0;
5525 }
5526
5527 if (type == bgp_show_type_dampend_paths
5528 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00005529 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005530 else if (type == bgp_show_type_flap_statistics
5531 || type == bgp_show_type_flap_address
5532 || type == bgp_show_type_flap_prefix
5533 || type == bgp_show_type_flap_cidr_only
5534 || type == bgp_show_type_flap_regexp
5535 || type == bgp_show_type_flap_filter_list
5536 || type == bgp_show_type_flap_prefix_list
5537 || type == bgp_show_type_flap_prefix_longer
5538 || type == bgp_show_type_flap_route_map
5539 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00005540 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005541 else
ajs5a646652004-11-05 01:25:55 +00005542 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005543 display++;
5544 }
5545 if (display)
ajs5a646652004-11-05 01:25:55 +00005546 output_count++;
paul718e3742002-12-13 20:15:29 +00005547 }
5548
5549 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00005550 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00005551 {
5552 if (type == bgp_show_type_normal)
5553 vty_out (vty, "No BGP network exists%s", VTY_NEWLINE);
5554 }
5555 else
5556 vty_out (vty, "%sTotal number of prefixes %ld%s",
ajs5a646652004-11-05 01:25:55 +00005557 VTY_NEWLINE, output_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005558
5559 return CMD_SUCCESS;
5560}
5561
ajs5a646652004-11-05 01:25:55 +00005562static int
paulfee0f4c2004-09-13 05:12:46 +00005563bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00005564 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00005565{
5566 struct bgp_table *table;
5567
5568 if (bgp == NULL) {
5569 bgp = bgp_get_default ();
5570 }
5571
5572 if (bgp == NULL)
5573 {
5574 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
5575 return CMD_WARNING;
5576 }
5577
5578
5579 table = bgp->rib[afi][safi];
5580
ajs5a646652004-11-05 01:25:55 +00005581 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00005582}
5583
paul718e3742002-12-13 20:15:29 +00005584/* Header of detailed BGP route information */
5585void
5586route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
5587 struct bgp_node *rn,
5588 struct prefix_rd *prd, afi_t afi, safi_t safi)
5589{
5590 struct bgp_info *ri;
5591 struct prefix *p;
5592 struct peer *peer;
5593 struct listnode *nn;
5594 char buf1[INET6_ADDRSTRLEN];
5595 char buf2[INET6_ADDRSTRLEN];
5596 int count = 0;
5597 int best = 0;
5598 int suppress = 0;
5599 int no_export = 0;
5600 int no_advertise = 0;
5601 int local_as = 0;
5602 int first = 0;
5603
5604 p = &rn->p;
5605 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
5606 (safi == SAFI_MPLS_VPN ?
5607 prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
5608 safi == SAFI_MPLS_VPN ? ":" : "",
5609 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
5610 p->prefixlen, VTY_NEWLINE);
5611
5612 for (ri = rn->info; ri; ri = ri->next)
5613 {
5614 count++;
5615 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
5616 {
5617 best = count;
5618 if (ri->suppress)
5619 suppress = 1;
5620 if (ri->attr->community != NULL)
5621 {
5622 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
5623 no_advertise = 1;
5624 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
5625 no_export = 1;
5626 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
5627 local_as = 1;
5628 }
5629 }
5630 }
5631
5632 vty_out (vty, "Paths: (%d available", count);
5633 if (best)
5634 {
5635 vty_out (vty, ", best #%d", best);
5636 if (safi == SAFI_UNICAST)
5637 vty_out (vty, ", table Default-IP-Routing-Table");
5638 }
5639 else
5640 vty_out (vty, ", no best path");
5641 if (no_advertise)
5642 vty_out (vty, ", not advertised to any peer");
5643 else if (no_export)
5644 vty_out (vty, ", not advertised to EBGP peer");
5645 else if (local_as)
5646 vty_out (vty, ", not advertised outside local AS");
5647 if (suppress)
5648 vty_out (vty, ", Advertisements suppressed by an aggregate.");
5649 vty_out (vty, ")%s", VTY_NEWLINE);
5650
5651 /* advertised peer */
5652 LIST_LOOP (bgp->peer, peer, nn)
5653 {
5654 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
5655 {
5656 if (! first)
5657 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
5658 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
5659 first = 1;
5660 }
5661 }
5662 if (! first)
5663 vty_out (vty, " Not advertised to any peer");
5664 vty_out (vty, "%s", VTY_NEWLINE);
5665}
5666
5667/* Display specified route of BGP table. */
5668int
paulfee0f4c2004-09-13 05:12:46 +00005669bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00005670 struct bgp_table *rib, const char *ip_str,
5671 afi_t afi, safi_t safi, struct prefix_rd *prd,
5672 int prefix_check)
paul718e3742002-12-13 20:15:29 +00005673{
5674 int ret;
5675 int header;
5676 int display = 0;
5677 struct prefix match;
5678 struct bgp_node *rn;
5679 struct bgp_node *rm;
5680 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00005681 struct bgp_table *table;
5682
paul718e3742002-12-13 20:15:29 +00005683 /* Check IP address argument. */
5684 ret = str2prefix (ip_str, &match);
5685 if (! ret)
5686 {
5687 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
5688 return CMD_WARNING;
5689 }
5690
5691 match.family = afi2family (afi);
5692
5693 if (safi == SAFI_MPLS_VPN)
5694 {
paulfee0f4c2004-09-13 05:12:46 +00005695 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00005696 {
5697 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
5698 continue;
5699
5700 if ((table = rn->info) != NULL)
5701 {
5702 header = 1;
5703
5704 if ((rm = bgp_node_match (table, &match)) != NULL)
5705 {
5706 if (prefix_check && rm->p.prefixlen != match.prefixlen)
5707 continue;
5708
5709 for (ri = rm->info; ri; ri = ri->next)
5710 {
5711 if (header)
5712 {
5713 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
5714 AFI_IP, SAFI_MPLS_VPN);
5715
5716 header = 0;
5717 }
5718 display++;
5719 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN);
5720 }
5721 }
5722 }
5723 }
5724 }
5725 else
5726 {
5727 header = 1;
5728
paulfee0f4c2004-09-13 05:12:46 +00005729 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00005730 {
5731 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
5732 {
5733 for (ri = rn->info; ri; ri = ri->next)
5734 {
5735 if (header)
5736 {
5737 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
5738 header = 0;
5739 }
5740 display++;
5741 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
5742 }
5743 }
5744 }
5745 }
5746
5747 if (! display)
5748 {
5749 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
5750 return CMD_WARNING;
5751 }
5752
5753 return CMD_SUCCESS;
5754}
5755
paulfee0f4c2004-09-13 05:12:46 +00005756/* Display specified route of Main RIB */
5757int
paulfd79ac92004-10-13 05:06:08 +00005758bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00005759 afi_t afi, safi_t safi, struct prefix_rd *prd,
5760 int prefix_check)
5761{
5762 struct bgp *bgp;
5763
5764 /* BGP structure lookup. */
5765 if (view_name)
5766 {
5767 bgp = bgp_lookup_by_name (view_name);
5768 if (bgp == NULL)
5769 {
5770 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
5771 return CMD_WARNING;
5772 }
5773 }
5774 else
5775 {
5776 bgp = bgp_get_default ();
5777 if (bgp == NULL)
5778 {
5779 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
5780 return CMD_WARNING;
5781 }
5782 }
5783
5784 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
5785 afi, safi, prd, prefix_check);
5786}
5787
paul718e3742002-12-13 20:15:29 +00005788/* BGP route print out function. */
5789DEFUN (show_ip_bgp,
5790 show_ip_bgp_cmd,
5791 "show ip bgp",
5792 SHOW_STR
5793 IP_STR
5794 BGP_STR)
5795{
ajs5a646652004-11-05 01:25:55 +00005796 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00005797}
5798
5799DEFUN (show_ip_bgp_ipv4,
5800 show_ip_bgp_ipv4_cmd,
5801 "show ip bgp ipv4 (unicast|multicast)",
5802 SHOW_STR
5803 IP_STR
5804 BGP_STR
5805 "Address family\n"
5806 "Address Family modifier\n"
5807 "Address Family modifier\n")
5808{
5809 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00005810 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
5811 NULL);
paul718e3742002-12-13 20:15:29 +00005812
ajs5a646652004-11-05 01:25:55 +00005813 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00005814}
5815
5816DEFUN (show_ip_bgp_route,
5817 show_ip_bgp_route_cmd,
5818 "show ip bgp A.B.C.D",
5819 SHOW_STR
5820 IP_STR
5821 BGP_STR
5822 "Network in the BGP routing table to display\n")
5823{
5824 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
5825}
5826
5827DEFUN (show_ip_bgp_ipv4_route,
5828 show_ip_bgp_ipv4_route_cmd,
5829 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
5830 SHOW_STR
5831 IP_STR
5832 BGP_STR
5833 "Address family\n"
5834 "Address Family modifier\n"
5835 "Address Family modifier\n"
5836 "Network in the BGP routing table to display\n")
5837{
5838 if (strncmp (argv[0], "m", 1) == 0)
5839 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
5840
5841 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
5842}
5843
5844DEFUN (show_ip_bgp_vpnv4_all_route,
5845 show_ip_bgp_vpnv4_all_route_cmd,
5846 "show ip bgp vpnv4 all A.B.C.D",
5847 SHOW_STR
5848 IP_STR
5849 BGP_STR
5850 "Display VPNv4 NLRI specific information\n"
5851 "Display information about all VPNv4 NLRIs\n"
5852 "Network in the BGP routing table to display\n")
5853{
5854 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
5855}
5856
5857DEFUN (show_ip_bgp_vpnv4_rd_route,
5858 show_ip_bgp_vpnv4_rd_route_cmd,
5859 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
5860 SHOW_STR
5861 IP_STR
5862 BGP_STR
5863 "Display VPNv4 NLRI specific information\n"
5864 "Display information for a route distinguisher\n"
5865 "VPN Route Distinguisher\n"
5866 "Network in the BGP routing table to display\n")
5867{
5868 int ret;
5869 struct prefix_rd prd;
5870
5871 ret = str2prefix_rd (argv[0], &prd);
5872 if (! ret)
5873 {
5874 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
5875 return CMD_WARNING;
5876 }
5877 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
5878}
5879
5880DEFUN (show_ip_bgp_prefix,
5881 show_ip_bgp_prefix_cmd,
5882 "show ip bgp A.B.C.D/M",
5883 SHOW_STR
5884 IP_STR
5885 BGP_STR
5886 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5887{
5888 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
5889}
5890
5891DEFUN (show_ip_bgp_ipv4_prefix,
5892 show_ip_bgp_ipv4_prefix_cmd,
5893 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
5894 SHOW_STR
5895 IP_STR
5896 BGP_STR
5897 "Address family\n"
5898 "Address Family modifier\n"
5899 "Address Family modifier\n"
5900 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5901{
5902 if (strncmp (argv[0], "m", 1) == 0)
5903 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
5904
5905 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
5906}
5907
5908DEFUN (show_ip_bgp_vpnv4_all_prefix,
5909 show_ip_bgp_vpnv4_all_prefix_cmd,
5910 "show ip bgp vpnv4 all A.B.C.D/M",
5911 SHOW_STR
5912 IP_STR
5913 BGP_STR
5914 "Display VPNv4 NLRI specific information\n"
5915 "Display information about all VPNv4 NLRIs\n"
5916 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5917{
5918 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
5919}
5920
5921DEFUN (show_ip_bgp_vpnv4_rd_prefix,
5922 show_ip_bgp_vpnv4_rd_prefix_cmd,
5923 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
5924 SHOW_STR
5925 IP_STR
5926 BGP_STR
5927 "Display VPNv4 NLRI specific information\n"
5928 "Display information for a route distinguisher\n"
5929 "VPN Route Distinguisher\n"
5930 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5931{
5932 int ret;
5933 struct prefix_rd prd;
5934
5935 ret = str2prefix_rd (argv[0], &prd);
5936 if (! ret)
5937 {
5938 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
5939 return CMD_WARNING;
5940 }
5941 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
5942}
5943
5944DEFUN (show_ip_bgp_view,
5945 show_ip_bgp_view_cmd,
5946 "show ip bgp view WORD",
5947 SHOW_STR
5948 IP_STR
5949 BGP_STR
5950 "BGP view\n"
5951 "BGP view name\n")
5952{
paulbb46e942003-10-24 19:02:03 +00005953 struct bgp *bgp;
5954
5955 /* BGP structure lookup. */
5956 bgp = bgp_lookup_by_name (argv[0]);
5957 if (bgp == NULL)
5958 {
5959 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
5960 return CMD_WARNING;
5961 }
5962
ajs5a646652004-11-05 01:25:55 +00005963 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00005964}
5965
5966DEFUN (show_ip_bgp_view_route,
5967 show_ip_bgp_view_route_cmd,
5968 "show ip bgp view WORD A.B.C.D",
5969 SHOW_STR
5970 IP_STR
5971 BGP_STR
5972 "BGP view\n"
5973 "BGP view name\n"
5974 "Network in the BGP routing table to display\n")
5975{
5976 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
5977}
5978
5979DEFUN (show_ip_bgp_view_prefix,
5980 show_ip_bgp_view_prefix_cmd,
5981 "show ip bgp view WORD A.B.C.D/M",
5982 SHOW_STR
5983 IP_STR
5984 BGP_STR
5985 "BGP view\n"
5986 "BGP view name\n"
5987 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5988{
5989 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
5990}
5991
5992#ifdef HAVE_IPV6
5993DEFUN (show_bgp,
5994 show_bgp_cmd,
5995 "show bgp",
5996 SHOW_STR
5997 BGP_STR)
5998{
ajs5a646652004-11-05 01:25:55 +00005999 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
6000 NULL);
paul718e3742002-12-13 20:15:29 +00006001}
6002
6003ALIAS (show_bgp,
6004 show_bgp_ipv6_cmd,
6005 "show bgp ipv6",
6006 SHOW_STR
6007 BGP_STR
6008 "Address family\n")
6009
6010/* old command */
6011DEFUN (show_ipv6_bgp,
6012 show_ipv6_bgp_cmd,
6013 "show ipv6 bgp",
6014 SHOW_STR
6015 IP_STR
6016 BGP_STR)
6017{
ajs5a646652004-11-05 01:25:55 +00006018 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
6019 NULL);
paul718e3742002-12-13 20:15:29 +00006020}
6021
6022DEFUN (show_bgp_route,
6023 show_bgp_route_cmd,
6024 "show bgp X:X::X:X",
6025 SHOW_STR
6026 BGP_STR
6027 "Network in the BGP routing table to display\n")
6028{
6029 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
6030}
6031
6032ALIAS (show_bgp_route,
6033 show_bgp_ipv6_route_cmd,
6034 "show bgp ipv6 X:X::X:X",
6035 SHOW_STR
6036 BGP_STR
6037 "Address family\n"
6038 "Network in the BGP routing table to display\n")
6039
6040/* old command */
6041DEFUN (show_ipv6_bgp_route,
6042 show_ipv6_bgp_route_cmd,
6043 "show ipv6 bgp X:X::X:X",
6044 SHOW_STR
6045 IP_STR
6046 BGP_STR
6047 "Network in the BGP routing table to display\n")
6048{
6049 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
6050}
6051
6052DEFUN (show_bgp_prefix,
6053 show_bgp_prefix_cmd,
6054 "show bgp X:X::X:X/M",
6055 SHOW_STR
6056 BGP_STR
6057 "IPv6 prefix <network>/<length>\n")
6058{
6059 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
6060}
6061
6062ALIAS (show_bgp_prefix,
6063 show_bgp_ipv6_prefix_cmd,
6064 "show bgp ipv6 X:X::X:X/M",
6065 SHOW_STR
6066 BGP_STR
6067 "Address family\n"
6068 "IPv6 prefix <network>/<length>\n")
6069
6070/* old command */
6071DEFUN (show_ipv6_bgp_prefix,
6072 show_ipv6_bgp_prefix_cmd,
6073 "show ipv6 bgp X:X::X:X/M",
6074 SHOW_STR
6075 IP_STR
6076 BGP_STR
6077 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6078{
6079 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
6080}
6081
paulbb46e942003-10-24 19:02:03 +00006082DEFUN (show_bgp_view,
6083 show_bgp_view_cmd,
6084 "show bgp view WORD",
6085 SHOW_STR
6086 BGP_STR
6087 "BGP view\n"
6088 "View name\n")
6089{
6090 struct bgp *bgp;
6091
6092 /* BGP structure lookup. */
6093 bgp = bgp_lookup_by_name (argv[0]);
6094 if (bgp == NULL)
6095 {
6096 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
6097 return CMD_WARNING;
6098 }
6099
ajs5a646652004-11-05 01:25:55 +00006100 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00006101}
6102
6103ALIAS (show_bgp_view,
6104 show_bgp_view_ipv6_cmd,
6105 "show bgp view WORD ipv6",
6106 SHOW_STR
6107 BGP_STR
6108 "BGP view\n"
6109 "View name\n"
6110 "Address family\n")
6111
6112DEFUN (show_bgp_view_route,
6113 show_bgp_view_route_cmd,
6114 "show bgp view WORD X:X::X:X",
6115 SHOW_STR
6116 BGP_STR
6117 "BGP view\n"
6118 "View name\n"
6119 "Network in the BGP routing table to display\n")
6120{
6121 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
6122}
6123
6124ALIAS (show_bgp_view_route,
6125 show_bgp_view_ipv6_route_cmd,
6126 "show bgp view WORD ipv6 X:X::X:X",
6127 SHOW_STR
6128 BGP_STR
6129 "BGP view\n"
6130 "View name\n"
6131 "Address family\n"
6132 "Network in the BGP routing table to display\n")
6133
6134DEFUN (show_bgp_view_prefix,
6135 show_bgp_view_prefix_cmd,
6136 "show bgp view WORD X:X::X:X/M",
6137 SHOW_STR
6138 BGP_STR
6139 "BGP view\n"
6140 "View name\n"
6141 "IPv6 prefix <network>/<length>\n")
6142{
6143 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
6144}
6145
6146ALIAS (show_bgp_view_prefix,
6147 show_bgp_view_ipv6_prefix_cmd,
6148 "show bgp view WORD ipv6 X:X::X:X/M",
6149 SHOW_STR
6150 BGP_STR
6151 "BGP view\n"
6152 "View name\n"
6153 "Address family\n"
6154 "IPv6 prefix <network>/<length>\n")
6155
paul718e3742002-12-13 20:15:29 +00006156/* old command */
6157DEFUN (show_ipv6_mbgp,
6158 show_ipv6_mbgp_cmd,
6159 "show ipv6 mbgp",
6160 SHOW_STR
6161 IP_STR
6162 MBGP_STR)
6163{
ajs5a646652004-11-05 01:25:55 +00006164 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
6165 NULL);
paul718e3742002-12-13 20:15:29 +00006166}
6167
6168/* old command */
6169DEFUN (show_ipv6_mbgp_route,
6170 show_ipv6_mbgp_route_cmd,
6171 "show ipv6 mbgp X:X::X:X",
6172 SHOW_STR
6173 IP_STR
6174 MBGP_STR
6175 "Network in the MBGP routing table to display\n")
6176{
6177 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
6178}
6179
6180/* old command */
6181DEFUN (show_ipv6_mbgp_prefix,
6182 show_ipv6_mbgp_prefix_cmd,
6183 "show ipv6 mbgp X:X::X:X/M",
6184 SHOW_STR
6185 IP_STR
6186 MBGP_STR
6187 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6188{
6189 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
6190}
6191#endif
6192
paul718e3742002-12-13 20:15:29 +00006193
6194int
paulfd79ac92004-10-13 05:06:08 +00006195bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006196 safi_t safi, enum bgp_show_type type)
6197{
6198 int i;
6199 struct buffer *b;
6200 char *regstr;
6201 int first;
6202 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00006203 int rc;
paul718e3742002-12-13 20:15:29 +00006204
6205 first = 0;
6206 b = buffer_new (1024);
6207 for (i = 0; i < argc; i++)
6208 {
6209 if (first)
6210 buffer_putc (b, ' ');
6211 else
6212 {
6213 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
6214 continue;
6215 first = 1;
6216 }
6217
6218 buffer_putstr (b, argv[i]);
6219 }
6220 buffer_putc (b, '\0');
6221
6222 regstr = buffer_getstr (b);
6223 buffer_free (b);
6224
6225 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00006226 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00006227 if (! regex)
6228 {
6229 vty_out (vty, "Can't compile regexp %s%s", argv[0],
6230 VTY_NEWLINE);
6231 return CMD_WARNING;
6232 }
6233
ajs5a646652004-11-05 01:25:55 +00006234 rc = bgp_show (vty, NULL, afi, safi, type, regex);
6235 bgp_regex_free (regex);
6236 return rc;
paul718e3742002-12-13 20:15:29 +00006237}
6238
6239DEFUN (show_ip_bgp_regexp,
6240 show_ip_bgp_regexp_cmd,
6241 "show ip bgp regexp .LINE",
6242 SHOW_STR
6243 IP_STR
6244 BGP_STR
6245 "Display routes matching the AS path regular expression\n"
6246 "A regular-expression to match the BGP AS paths\n")
6247{
6248 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
6249 bgp_show_type_regexp);
6250}
6251
6252DEFUN (show_ip_bgp_flap_regexp,
6253 show_ip_bgp_flap_regexp_cmd,
6254 "show ip bgp flap-statistics regexp .LINE",
6255 SHOW_STR
6256 IP_STR
6257 BGP_STR
6258 "Display flap statistics of routes\n"
6259 "Display routes matching the AS path regular expression\n"
6260 "A regular-expression to match the BGP AS paths\n")
6261{
6262 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
6263 bgp_show_type_flap_regexp);
6264}
6265
6266DEFUN (show_ip_bgp_ipv4_regexp,
6267 show_ip_bgp_ipv4_regexp_cmd,
6268 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
6269 SHOW_STR
6270 IP_STR
6271 BGP_STR
6272 "Address family\n"
6273 "Address Family modifier\n"
6274 "Address Family modifier\n"
6275 "Display routes matching the AS path regular expression\n"
6276 "A regular-expression to match the BGP AS paths\n")
6277{
6278 if (strncmp (argv[0], "m", 1) == 0)
6279 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
6280 bgp_show_type_regexp);
6281
6282 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
6283 bgp_show_type_regexp);
6284}
6285
6286#ifdef HAVE_IPV6
6287DEFUN (show_bgp_regexp,
6288 show_bgp_regexp_cmd,
6289 "show bgp regexp .LINE",
6290 SHOW_STR
6291 BGP_STR
6292 "Display routes matching the AS path regular expression\n"
6293 "A regular-expression to match the BGP AS paths\n")
6294{
6295 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
6296 bgp_show_type_regexp);
6297}
6298
6299ALIAS (show_bgp_regexp,
6300 show_bgp_ipv6_regexp_cmd,
6301 "show bgp ipv6 regexp .LINE",
6302 SHOW_STR
6303 BGP_STR
6304 "Address family\n"
6305 "Display routes matching the AS path regular expression\n"
6306 "A regular-expression to match the BGP AS paths\n")
6307
6308/* old command */
6309DEFUN (show_ipv6_bgp_regexp,
6310 show_ipv6_bgp_regexp_cmd,
6311 "show ipv6 bgp regexp .LINE",
6312 SHOW_STR
6313 IP_STR
6314 BGP_STR
6315 "Display routes matching the AS path regular expression\n"
6316 "A regular-expression to match the BGP AS paths\n")
6317{
6318 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
6319 bgp_show_type_regexp);
6320}
6321
6322/* old command */
6323DEFUN (show_ipv6_mbgp_regexp,
6324 show_ipv6_mbgp_regexp_cmd,
6325 "show ipv6 mbgp regexp .LINE",
6326 SHOW_STR
6327 IP_STR
6328 BGP_STR
6329 "Display routes matching the AS path regular expression\n"
6330 "A regular-expression to match the MBGP AS paths\n")
6331{
6332 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
6333 bgp_show_type_regexp);
6334}
6335#endif /* HAVE_IPV6 */
6336
6337int
paulfd79ac92004-10-13 05:06:08 +00006338bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006339 safi_t safi, enum bgp_show_type type)
6340{
6341 struct prefix_list *plist;
6342
6343 plist = prefix_list_lookup (afi, prefix_list_str);
6344 if (plist == NULL)
6345 {
6346 vty_out (vty, "%% %s is not a valid prefix-list name%s",
6347 prefix_list_str, VTY_NEWLINE);
6348 return CMD_WARNING;
6349 }
6350
ajs5a646652004-11-05 01:25:55 +00006351 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00006352}
6353
6354DEFUN (show_ip_bgp_prefix_list,
6355 show_ip_bgp_prefix_list_cmd,
6356 "show ip bgp prefix-list WORD",
6357 SHOW_STR
6358 IP_STR
6359 BGP_STR
6360 "Display routes conforming to the prefix-list\n"
6361 "IP prefix-list name\n")
6362{
6363 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6364 bgp_show_type_prefix_list);
6365}
6366
6367DEFUN (show_ip_bgp_flap_prefix_list,
6368 show_ip_bgp_flap_prefix_list_cmd,
6369 "show ip bgp flap-statistics prefix-list WORD",
6370 SHOW_STR
6371 IP_STR
6372 BGP_STR
6373 "Display flap statistics of routes\n"
6374 "Display routes conforming to the prefix-list\n"
6375 "IP prefix-list name\n")
6376{
6377 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6378 bgp_show_type_flap_prefix_list);
6379}
6380
6381DEFUN (show_ip_bgp_ipv4_prefix_list,
6382 show_ip_bgp_ipv4_prefix_list_cmd,
6383 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
6384 SHOW_STR
6385 IP_STR
6386 BGP_STR
6387 "Address family\n"
6388 "Address Family modifier\n"
6389 "Address Family modifier\n"
6390 "Display routes conforming to the prefix-list\n"
6391 "IP prefix-list name\n")
6392{
6393 if (strncmp (argv[0], "m", 1) == 0)
6394 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
6395 bgp_show_type_prefix_list);
6396
6397 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
6398 bgp_show_type_prefix_list);
6399}
6400
6401#ifdef HAVE_IPV6
6402DEFUN (show_bgp_prefix_list,
6403 show_bgp_prefix_list_cmd,
6404 "show bgp prefix-list WORD",
6405 SHOW_STR
6406 BGP_STR
6407 "Display routes conforming to the prefix-list\n"
6408 "IPv6 prefix-list name\n")
6409{
6410 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6411 bgp_show_type_prefix_list);
6412}
6413
6414ALIAS (show_bgp_prefix_list,
6415 show_bgp_ipv6_prefix_list_cmd,
6416 "show bgp ipv6 prefix-list WORD",
6417 SHOW_STR
6418 BGP_STR
6419 "Address family\n"
6420 "Display routes conforming to the prefix-list\n"
6421 "IPv6 prefix-list name\n")
6422
6423/* old command */
6424DEFUN (show_ipv6_bgp_prefix_list,
6425 show_ipv6_bgp_prefix_list_cmd,
6426 "show ipv6 bgp prefix-list WORD",
6427 SHOW_STR
6428 IPV6_STR
6429 BGP_STR
6430 "Display routes matching the prefix-list\n"
6431 "IPv6 prefix-list name\n")
6432{
6433 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6434 bgp_show_type_prefix_list);
6435}
6436
6437/* old command */
6438DEFUN (show_ipv6_mbgp_prefix_list,
6439 show_ipv6_mbgp_prefix_list_cmd,
6440 "show ipv6 mbgp prefix-list WORD",
6441 SHOW_STR
6442 IPV6_STR
6443 MBGP_STR
6444 "Display routes matching the prefix-list\n"
6445 "IPv6 prefix-list name\n")
6446{
6447 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
6448 bgp_show_type_prefix_list);
6449}
6450#endif /* HAVE_IPV6 */
6451
6452int
paulfd79ac92004-10-13 05:06:08 +00006453bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006454 safi_t safi, enum bgp_show_type type)
6455{
6456 struct as_list *as_list;
6457
6458 as_list = as_list_lookup (filter);
6459 if (as_list == NULL)
6460 {
6461 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
6462 return CMD_WARNING;
6463 }
6464
ajs5a646652004-11-05 01:25:55 +00006465 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00006466}
6467
6468DEFUN (show_ip_bgp_filter_list,
6469 show_ip_bgp_filter_list_cmd,
6470 "show ip bgp filter-list WORD",
6471 SHOW_STR
6472 IP_STR
6473 BGP_STR
6474 "Display routes conforming to the filter-list\n"
6475 "Regular expression access list name\n")
6476{
6477 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6478 bgp_show_type_filter_list);
6479}
6480
6481DEFUN (show_ip_bgp_flap_filter_list,
6482 show_ip_bgp_flap_filter_list_cmd,
6483 "show ip bgp flap-statistics filter-list WORD",
6484 SHOW_STR
6485 IP_STR
6486 BGP_STR
6487 "Display flap statistics of routes\n"
6488 "Display routes conforming to the filter-list\n"
6489 "Regular expression access list name\n")
6490{
6491 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6492 bgp_show_type_flap_filter_list);
6493}
6494
6495DEFUN (show_ip_bgp_ipv4_filter_list,
6496 show_ip_bgp_ipv4_filter_list_cmd,
6497 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
6498 SHOW_STR
6499 IP_STR
6500 BGP_STR
6501 "Address family\n"
6502 "Address Family modifier\n"
6503 "Address Family modifier\n"
6504 "Display routes conforming to the filter-list\n"
6505 "Regular expression access list name\n")
6506{
6507 if (strncmp (argv[0], "m", 1) == 0)
6508 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
6509 bgp_show_type_filter_list);
6510
6511 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
6512 bgp_show_type_filter_list);
6513}
6514
6515#ifdef HAVE_IPV6
6516DEFUN (show_bgp_filter_list,
6517 show_bgp_filter_list_cmd,
6518 "show bgp filter-list WORD",
6519 SHOW_STR
6520 BGP_STR
6521 "Display routes conforming to the filter-list\n"
6522 "Regular expression access list name\n")
6523{
6524 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6525 bgp_show_type_filter_list);
6526}
6527
6528ALIAS (show_bgp_filter_list,
6529 show_bgp_ipv6_filter_list_cmd,
6530 "show bgp ipv6 filter-list WORD",
6531 SHOW_STR
6532 BGP_STR
6533 "Address family\n"
6534 "Display routes conforming to the filter-list\n"
6535 "Regular expression access list name\n")
6536
6537/* old command */
6538DEFUN (show_ipv6_bgp_filter_list,
6539 show_ipv6_bgp_filter_list_cmd,
6540 "show ipv6 bgp filter-list WORD",
6541 SHOW_STR
6542 IPV6_STR
6543 BGP_STR
6544 "Display routes conforming to the filter-list\n"
6545 "Regular expression access list name\n")
6546{
6547 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6548 bgp_show_type_filter_list);
6549}
6550
6551/* old command */
6552DEFUN (show_ipv6_mbgp_filter_list,
6553 show_ipv6_mbgp_filter_list_cmd,
6554 "show ipv6 mbgp filter-list WORD",
6555 SHOW_STR
6556 IPV6_STR
6557 MBGP_STR
6558 "Display routes conforming to the filter-list\n"
6559 "Regular expression access list name\n")
6560{
6561 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
6562 bgp_show_type_filter_list);
6563}
6564#endif /* HAVE_IPV6 */
6565
6566int
paulfd79ac92004-10-13 05:06:08 +00006567bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006568 safi_t safi, enum bgp_show_type type)
6569{
6570 struct route_map *rmap;
6571
6572 rmap = route_map_lookup_by_name (rmap_str);
6573 if (! rmap)
6574 {
6575 vty_out (vty, "%% %s is not a valid route-map name%s",
6576 rmap_str, VTY_NEWLINE);
6577 return CMD_WARNING;
6578 }
6579
ajs5a646652004-11-05 01:25:55 +00006580 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00006581}
6582
6583DEFUN (show_ip_bgp_route_map,
6584 show_ip_bgp_route_map_cmd,
6585 "show ip bgp route-map WORD",
6586 SHOW_STR
6587 IP_STR
6588 BGP_STR
6589 "Display routes matching the route-map\n"
6590 "A route-map to match on\n")
6591{
6592 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
6593 bgp_show_type_route_map);
6594}
6595
6596DEFUN (show_ip_bgp_flap_route_map,
6597 show_ip_bgp_flap_route_map_cmd,
6598 "show ip bgp flap-statistics route-map WORD",
6599 SHOW_STR
6600 IP_STR
6601 BGP_STR
6602 "Display flap statistics of routes\n"
6603 "Display routes matching the route-map\n"
6604 "A route-map to match on\n")
6605{
6606 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
6607 bgp_show_type_flap_route_map);
6608}
6609
6610DEFUN (show_ip_bgp_ipv4_route_map,
6611 show_ip_bgp_ipv4_route_map_cmd,
6612 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
6613 SHOW_STR
6614 IP_STR
6615 BGP_STR
6616 "Address family\n"
6617 "Address Family modifier\n"
6618 "Address Family modifier\n"
6619 "Display routes matching the route-map\n"
6620 "A route-map to match on\n")
6621{
6622 if (strncmp (argv[0], "m", 1) == 0)
6623 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
6624 bgp_show_type_route_map);
6625
6626 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
6627 bgp_show_type_route_map);
6628}
6629
6630DEFUN (show_bgp_route_map,
6631 show_bgp_route_map_cmd,
6632 "show bgp route-map WORD",
6633 SHOW_STR
6634 BGP_STR
6635 "Display routes matching the route-map\n"
6636 "A route-map to match on\n")
6637{
6638 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6639 bgp_show_type_route_map);
6640}
6641
6642ALIAS (show_bgp_route_map,
6643 show_bgp_ipv6_route_map_cmd,
6644 "show bgp ipv6 route-map WORD",
6645 SHOW_STR
6646 BGP_STR
6647 "Address family\n"
6648 "Display routes matching the route-map\n"
6649 "A route-map to match on\n")
6650
6651DEFUN (show_ip_bgp_cidr_only,
6652 show_ip_bgp_cidr_only_cmd,
6653 "show ip bgp cidr-only",
6654 SHOW_STR
6655 IP_STR
6656 BGP_STR
6657 "Display only routes with non-natural netmasks\n")
6658{
6659 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006660 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006661}
6662
6663DEFUN (show_ip_bgp_flap_cidr_only,
6664 show_ip_bgp_flap_cidr_only_cmd,
6665 "show ip bgp flap-statistics cidr-only",
6666 SHOW_STR
6667 IP_STR
6668 BGP_STR
6669 "Display flap statistics of routes\n"
6670 "Display only routes with non-natural netmasks\n")
6671{
6672 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006673 bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006674}
6675
6676DEFUN (show_ip_bgp_ipv4_cidr_only,
6677 show_ip_bgp_ipv4_cidr_only_cmd,
6678 "show ip bgp ipv4 (unicast|multicast) cidr-only",
6679 SHOW_STR
6680 IP_STR
6681 BGP_STR
6682 "Address family\n"
6683 "Address Family modifier\n"
6684 "Address Family modifier\n"
6685 "Display only routes with non-natural netmasks\n")
6686{
6687 if (strncmp (argv[0], "m", 1) == 0)
6688 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00006689 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006690
6691 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006692 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006693}
6694
6695DEFUN (show_ip_bgp_community_all,
6696 show_ip_bgp_community_all_cmd,
6697 "show ip bgp community",
6698 SHOW_STR
6699 IP_STR
6700 BGP_STR
6701 "Display routes matching the communities\n")
6702{
6703 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006704 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006705}
6706
6707DEFUN (show_ip_bgp_ipv4_community_all,
6708 show_ip_bgp_ipv4_community_all_cmd,
6709 "show ip bgp ipv4 (unicast|multicast) community",
6710 SHOW_STR
6711 IP_STR
6712 BGP_STR
6713 "Address family\n"
6714 "Address Family modifier\n"
6715 "Address Family modifier\n"
6716 "Display routes matching the communities\n")
6717{
6718 if (strncmp (argv[0], "m", 1) == 0)
6719 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00006720 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006721
6722 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006723 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006724}
6725
6726#ifdef HAVE_IPV6
6727DEFUN (show_bgp_community_all,
6728 show_bgp_community_all_cmd,
6729 "show bgp community",
6730 SHOW_STR
6731 BGP_STR
6732 "Display routes matching the communities\n")
6733{
6734 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006735 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006736}
6737
6738ALIAS (show_bgp_community_all,
6739 show_bgp_ipv6_community_all_cmd,
6740 "show bgp ipv6 community",
6741 SHOW_STR
6742 BGP_STR
6743 "Address family\n"
6744 "Display routes matching the communities\n")
6745
6746/* old command */
6747DEFUN (show_ipv6_bgp_community_all,
6748 show_ipv6_bgp_community_all_cmd,
6749 "show ipv6 bgp community",
6750 SHOW_STR
6751 IPV6_STR
6752 BGP_STR
6753 "Display routes matching the communities\n")
6754{
6755 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006756 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006757}
6758
6759/* old command */
6760DEFUN (show_ipv6_mbgp_community_all,
6761 show_ipv6_mbgp_community_all_cmd,
6762 "show ipv6 mbgp community",
6763 SHOW_STR
6764 IPV6_STR
6765 MBGP_STR
6766 "Display routes matching the communities\n")
6767{
6768 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00006769 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006770}
6771#endif /* HAVE_IPV6 */
6772
6773int
paulfd79ac92004-10-13 05:06:08 +00006774bgp_show_community (struct vty *vty, int argc, const char **argv, int exact,
6775 u_int16_t afi, u_char safi)
paul718e3742002-12-13 20:15:29 +00006776{
6777 struct community *com;
6778 struct buffer *b;
6779 int i;
6780 char *str;
6781 int first = 0;
6782
6783 b = buffer_new (1024);
6784 for (i = 0; i < argc; i++)
6785 {
6786 if (first)
6787 buffer_putc (b, ' ');
6788 else
6789 {
6790 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
6791 continue;
6792 first = 1;
6793 }
6794
6795 buffer_putstr (b, argv[i]);
6796 }
6797 buffer_putc (b, '\0');
6798
6799 str = buffer_getstr (b);
6800 buffer_free (b);
6801
6802 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00006803 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00006804 if (! com)
6805 {
6806 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
6807 return CMD_WARNING;
6808 }
6809
ajs5a646652004-11-05 01:25:55 +00006810 return bgp_show (vty, NULL, afi, safi,
6811 (exact ? bgp_show_type_community_exact :
6812 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00006813}
6814
6815DEFUN (show_ip_bgp_community,
6816 show_ip_bgp_community_cmd,
6817 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
6818 SHOW_STR
6819 IP_STR
6820 BGP_STR
6821 "Display routes matching the communities\n"
6822 "community number\n"
6823 "Do not send outside local AS (well-known community)\n"
6824 "Do not advertise to any peer (well-known community)\n"
6825 "Do not export to next AS (well-known community)\n")
6826{
6827 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST);
6828}
6829
6830ALIAS (show_ip_bgp_community,
6831 show_ip_bgp_community2_cmd,
6832 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6833 SHOW_STR
6834 IP_STR
6835 BGP_STR
6836 "Display routes matching the communities\n"
6837 "community number\n"
6838 "Do not send outside local AS (well-known community)\n"
6839 "Do not advertise to any peer (well-known community)\n"
6840 "Do not export to next AS (well-known community)\n"
6841 "community number\n"
6842 "Do not send outside local AS (well-known community)\n"
6843 "Do not advertise to any peer (well-known community)\n"
6844 "Do not export to next AS (well-known community)\n")
6845
6846ALIAS (show_ip_bgp_community,
6847 show_ip_bgp_community3_cmd,
6848 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6849 SHOW_STR
6850 IP_STR
6851 BGP_STR
6852 "Display routes matching the communities\n"
6853 "community number\n"
6854 "Do not send outside local AS (well-known community)\n"
6855 "Do not advertise to any peer (well-known community)\n"
6856 "Do not export to next AS (well-known community)\n"
6857 "community number\n"
6858 "Do not send outside local AS (well-known community)\n"
6859 "Do not advertise to any peer (well-known community)\n"
6860 "Do not export to next AS (well-known community)\n"
6861 "community number\n"
6862 "Do not send outside local AS (well-known community)\n"
6863 "Do not advertise to any peer (well-known community)\n"
6864 "Do not export to next AS (well-known community)\n")
6865
6866ALIAS (show_ip_bgp_community,
6867 show_ip_bgp_community4_cmd,
6868 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6869 SHOW_STR
6870 IP_STR
6871 BGP_STR
6872 "Display routes matching the communities\n"
6873 "community number\n"
6874 "Do not send outside local AS (well-known community)\n"
6875 "Do not advertise to any peer (well-known community)\n"
6876 "Do not export to next AS (well-known community)\n"
6877 "community number\n"
6878 "Do not send outside local AS (well-known community)\n"
6879 "Do not advertise to any peer (well-known community)\n"
6880 "Do not export to next AS (well-known community)\n"
6881 "community number\n"
6882 "Do not send outside local AS (well-known community)\n"
6883 "Do not advertise to any peer (well-known community)\n"
6884 "Do not export to next AS (well-known community)\n"
6885 "community number\n"
6886 "Do not send outside local AS (well-known community)\n"
6887 "Do not advertise to any peer (well-known community)\n"
6888 "Do not export to next AS (well-known community)\n")
6889
6890DEFUN (show_ip_bgp_ipv4_community,
6891 show_ip_bgp_ipv4_community_cmd,
6892 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
6893 SHOW_STR
6894 IP_STR
6895 BGP_STR
6896 "Address family\n"
6897 "Address Family modifier\n"
6898 "Address Family modifier\n"
6899 "Display routes matching the communities\n"
6900 "community number\n"
6901 "Do not send outside local AS (well-known community)\n"
6902 "Do not advertise to any peer (well-known community)\n"
6903 "Do not export to next AS (well-known community)\n")
6904{
6905 if (strncmp (argv[0], "m", 1) == 0)
6906 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
6907
6908 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST);
6909}
6910
6911ALIAS (show_ip_bgp_ipv4_community,
6912 show_ip_bgp_ipv4_community2_cmd,
6913 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6914 SHOW_STR
6915 IP_STR
6916 BGP_STR
6917 "Address family\n"
6918 "Address Family modifier\n"
6919 "Address Family modifier\n"
6920 "Display routes matching the communities\n"
6921 "community number\n"
6922 "Do not send outside local AS (well-known community)\n"
6923 "Do not advertise to any peer (well-known community)\n"
6924 "Do not export to next AS (well-known community)\n"
6925 "community number\n"
6926 "Do not send outside local AS (well-known community)\n"
6927 "Do not advertise to any peer (well-known community)\n"
6928 "Do not export to next AS (well-known community)\n")
6929
6930ALIAS (show_ip_bgp_ipv4_community,
6931 show_ip_bgp_ipv4_community3_cmd,
6932 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6933 SHOW_STR
6934 IP_STR
6935 BGP_STR
6936 "Address family\n"
6937 "Address Family modifier\n"
6938 "Address Family modifier\n"
6939 "Display routes matching the communities\n"
6940 "community number\n"
6941 "Do not send outside local AS (well-known community)\n"
6942 "Do not advertise to any peer (well-known community)\n"
6943 "Do not export to next AS (well-known community)\n"
6944 "community number\n"
6945 "Do not send outside local AS (well-known community)\n"
6946 "Do not advertise to any peer (well-known community)\n"
6947 "Do not export to next AS (well-known community)\n"
6948 "community number\n"
6949 "Do not send outside local AS (well-known community)\n"
6950 "Do not advertise to any peer (well-known community)\n"
6951 "Do not export to next AS (well-known community)\n")
6952
6953ALIAS (show_ip_bgp_ipv4_community,
6954 show_ip_bgp_ipv4_community4_cmd,
6955 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6956 SHOW_STR
6957 IP_STR
6958 BGP_STR
6959 "Address family\n"
6960 "Address Family modifier\n"
6961 "Address Family modifier\n"
6962 "Display routes matching the communities\n"
6963 "community number\n"
6964 "Do not send outside local AS (well-known community)\n"
6965 "Do not advertise to any peer (well-known community)\n"
6966 "Do not export to next AS (well-known community)\n"
6967 "community number\n"
6968 "Do not send outside local AS (well-known community)\n"
6969 "Do not advertise to any peer (well-known community)\n"
6970 "Do not export to next AS (well-known community)\n"
6971 "community number\n"
6972 "Do not send outside local AS (well-known community)\n"
6973 "Do not advertise to any peer (well-known community)\n"
6974 "Do not export to next AS (well-known community)\n"
6975 "community number\n"
6976 "Do not send outside local AS (well-known community)\n"
6977 "Do not advertise to any peer (well-known community)\n"
6978 "Do not export to next AS (well-known community)\n")
6979
6980DEFUN (show_ip_bgp_community_exact,
6981 show_ip_bgp_community_exact_cmd,
6982 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6983 SHOW_STR
6984 IP_STR
6985 BGP_STR
6986 "Display routes matching the communities\n"
6987 "community number\n"
6988 "Do not send outside local AS (well-known community)\n"
6989 "Do not advertise to any peer (well-known community)\n"
6990 "Do not export to next AS (well-known community)\n"
6991 "Exact match of the communities")
6992{
6993 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST);
6994}
6995
6996ALIAS (show_ip_bgp_community_exact,
6997 show_ip_bgp_community2_exact_cmd,
6998 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6999 SHOW_STR
7000 IP_STR
7001 BGP_STR
7002 "Display routes matching the communities\n"
7003 "community number\n"
7004 "Do not send outside local AS (well-known community)\n"
7005 "Do not advertise to any peer (well-known community)\n"
7006 "Do not export to next AS (well-known community)\n"
7007 "community number\n"
7008 "Do not send outside local AS (well-known community)\n"
7009 "Do not advertise to any peer (well-known community)\n"
7010 "Do not export to next AS (well-known community)\n"
7011 "Exact match of the communities")
7012
7013ALIAS (show_ip_bgp_community_exact,
7014 show_ip_bgp_community3_exact_cmd,
7015 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7016 SHOW_STR
7017 IP_STR
7018 BGP_STR
7019 "Display routes matching the communities\n"
7020 "community number\n"
7021 "Do not send outside local AS (well-known community)\n"
7022 "Do not advertise to any peer (well-known community)\n"
7023 "Do not export to next AS (well-known community)\n"
7024 "community number\n"
7025 "Do not send outside local AS (well-known community)\n"
7026 "Do not advertise to any peer (well-known community)\n"
7027 "Do not export to next AS (well-known community)\n"
7028 "community number\n"
7029 "Do not send outside local AS (well-known community)\n"
7030 "Do not advertise to any peer (well-known community)\n"
7031 "Do not export to next AS (well-known community)\n"
7032 "Exact match of the communities")
7033
7034ALIAS (show_ip_bgp_community_exact,
7035 show_ip_bgp_community4_exact_cmd,
7036 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7037 SHOW_STR
7038 IP_STR
7039 BGP_STR
7040 "Display routes matching the communities\n"
7041 "community number\n"
7042 "Do not send outside local AS (well-known community)\n"
7043 "Do not advertise to any peer (well-known community)\n"
7044 "Do not export to next AS (well-known community)\n"
7045 "community number\n"
7046 "Do not send outside local AS (well-known community)\n"
7047 "Do not advertise to any peer (well-known community)\n"
7048 "Do not export to next AS (well-known community)\n"
7049 "community number\n"
7050 "Do not send outside local AS (well-known community)\n"
7051 "Do not advertise to any peer (well-known community)\n"
7052 "Do not export to next AS (well-known community)\n"
7053 "community number\n"
7054 "Do not send outside local AS (well-known community)\n"
7055 "Do not advertise to any peer (well-known community)\n"
7056 "Do not export to next AS (well-known community)\n"
7057 "Exact match of the communities")
7058
7059DEFUN (show_ip_bgp_ipv4_community_exact,
7060 show_ip_bgp_ipv4_community_exact_cmd,
7061 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7062 SHOW_STR
7063 IP_STR
7064 BGP_STR
7065 "Address family\n"
7066 "Address Family modifier\n"
7067 "Address Family modifier\n"
7068 "Display routes matching the communities\n"
7069 "community number\n"
7070 "Do not send outside local AS (well-known community)\n"
7071 "Do not advertise to any peer (well-known community)\n"
7072 "Do not export to next AS (well-known community)\n"
7073 "Exact match of the communities")
7074{
7075 if (strncmp (argv[0], "m", 1) == 0)
7076 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
7077
7078 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST);
7079}
7080
7081ALIAS (show_ip_bgp_ipv4_community_exact,
7082 show_ip_bgp_ipv4_community2_exact_cmd,
7083 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7084 SHOW_STR
7085 IP_STR
7086 BGP_STR
7087 "Address family\n"
7088 "Address Family modifier\n"
7089 "Address Family modifier\n"
7090 "Display routes matching the communities\n"
7091 "community number\n"
7092 "Do not send outside local AS (well-known community)\n"
7093 "Do not advertise to any peer (well-known community)\n"
7094 "Do not export to next AS (well-known community)\n"
7095 "community number\n"
7096 "Do not send outside local AS (well-known community)\n"
7097 "Do not advertise to any peer (well-known community)\n"
7098 "Do not export to next AS (well-known community)\n"
7099 "Exact match of the communities")
7100
7101ALIAS (show_ip_bgp_ipv4_community_exact,
7102 show_ip_bgp_ipv4_community3_exact_cmd,
7103 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7104 SHOW_STR
7105 IP_STR
7106 BGP_STR
7107 "Address family\n"
7108 "Address Family modifier\n"
7109 "Address Family modifier\n"
7110 "Display routes matching the communities\n"
7111 "community number\n"
7112 "Do not send outside local AS (well-known community)\n"
7113 "Do not advertise to any peer (well-known community)\n"
7114 "Do not export to next AS (well-known community)\n"
7115 "community number\n"
7116 "Do not send outside local AS (well-known community)\n"
7117 "Do not advertise to any peer (well-known community)\n"
7118 "Do not export to next AS (well-known community)\n"
7119 "community number\n"
7120 "Do not send outside local AS (well-known community)\n"
7121 "Do not advertise to any peer (well-known community)\n"
7122 "Do not export to next AS (well-known community)\n"
7123 "Exact match of the communities")
7124
7125ALIAS (show_ip_bgp_ipv4_community_exact,
7126 show_ip_bgp_ipv4_community4_exact_cmd,
7127 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7128 SHOW_STR
7129 IP_STR
7130 BGP_STR
7131 "Address family\n"
7132 "Address Family modifier\n"
7133 "Address Family modifier\n"
7134 "Display routes matching the communities\n"
7135 "community number\n"
7136 "Do not send outside local AS (well-known community)\n"
7137 "Do not advertise to any peer (well-known community)\n"
7138 "Do not export to next AS (well-known community)\n"
7139 "community number\n"
7140 "Do not send outside local AS (well-known community)\n"
7141 "Do not advertise to any peer (well-known community)\n"
7142 "Do not export to next AS (well-known community)\n"
7143 "community number\n"
7144 "Do not send outside local AS (well-known community)\n"
7145 "Do not advertise to any peer (well-known community)\n"
7146 "Do not export to next AS (well-known community)\n"
7147 "community number\n"
7148 "Do not send outside local AS (well-known community)\n"
7149 "Do not advertise to any peer (well-known community)\n"
7150 "Do not export to next AS (well-known community)\n"
7151 "Exact match of the communities")
7152
7153#ifdef HAVE_IPV6
7154DEFUN (show_bgp_community,
7155 show_bgp_community_cmd,
7156 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
7157 SHOW_STR
7158 BGP_STR
7159 "Display routes matching the communities\n"
7160 "community number\n"
7161 "Do not send outside local AS (well-known community)\n"
7162 "Do not advertise to any peer (well-known community)\n"
7163 "Do not export to next AS (well-known community)\n")
7164{
7165 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
7166}
7167
7168ALIAS (show_bgp_community,
7169 show_bgp_ipv6_community_cmd,
7170 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
7171 SHOW_STR
7172 BGP_STR
7173 "Address family\n"
7174 "Display routes matching the communities\n"
7175 "community number\n"
7176 "Do not send outside local AS (well-known community)\n"
7177 "Do not advertise to any peer (well-known community)\n"
7178 "Do not export to next AS (well-known community)\n")
7179
7180ALIAS (show_bgp_community,
7181 show_bgp_community2_cmd,
7182 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7183 SHOW_STR
7184 BGP_STR
7185 "Display routes matching the communities\n"
7186 "community number\n"
7187 "Do not send outside local AS (well-known community)\n"
7188 "Do not advertise to any peer (well-known community)\n"
7189 "Do not export to next AS (well-known community)\n"
7190 "community number\n"
7191 "Do not send outside local AS (well-known community)\n"
7192 "Do not advertise to any peer (well-known community)\n"
7193 "Do not export to next AS (well-known community)\n")
7194
7195ALIAS (show_bgp_community,
7196 show_bgp_ipv6_community2_cmd,
7197 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7198 SHOW_STR
7199 BGP_STR
7200 "Address family\n"
7201 "Display routes matching the communities\n"
7202 "community number\n"
7203 "Do not send outside local AS (well-known community)\n"
7204 "Do not advertise to any peer (well-known community)\n"
7205 "Do not export to next AS (well-known community)\n"
7206 "community number\n"
7207 "Do not send outside local AS (well-known community)\n"
7208 "Do not advertise to any peer (well-known community)\n"
7209 "Do not export to next AS (well-known community)\n")
7210
7211ALIAS (show_bgp_community,
7212 show_bgp_community3_cmd,
7213 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7214 SHOW_STR
7215 BGP_STR
7216 "Display routes matching the communities\n"
7217 "community number\n"
7218 "Do not send outside local AS (well-known community)\n"
7219 "Do not advertise to any peer (well-known community)\n"
7220 "Do not export to next AS (well-known community)\n"
7221 "community number\n"
7222 "Do not send outside local AS (well-known community)\n"
7223 "Do not advertise to any peer (well-known community)\n"
7224 "Do not export to next AS (well-known community)\n"
7225 "community number\n"
7226 "Do not send outside local AS (well-known community)\n"
7227 "Do not advertise to any peer (well-known community)\n"
7228 "Do not export to next AS (well-known community)\n")
7229
7230ALIAS (show_bgp_community,
7231 show_bgp_ipv6_community3_cmd,
7232 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7233 SHOW_STR
7234 BGP_STR
7235 "Address family\n"
7236 "Display routes matching the communities\n"
7237 "community number\n"
7238 "Do not send outside local AS (well-known community)\n"
7239 "Do not advertise to any peer (well-known community)\n"
7240 "Do not export to next AS (well-known community)\n"
7241 "community number\n"
7242 "Do not send outside local AS (well-known community)\n"
7243 "Do not advertise to any peer (well-known community)\n"
7244 "Do not export to next AS (well-known community)\n"
7245 "community number\n"
7246 "Do not send outside local AS (well-known community)\n"
7247 "Do not advertise to any peer (well-known community)\n"
7248 "Do not export to next AS (well-known community)\n")
7249
7250ALIAS (show_bgp_community,
7251 show_bgp_community4_cmd,
7252 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7253 SHOW_STR
7254 BGP_STR
7255 "Display routes matching the communities\n"
7256 "community number\n"
7257 "Do not send outside local AS (well-known community)\n"
7258 "Do not advertise to any peer (well-known community)\n"
7259 "Do not export to next AS (well-known community)\n"
7260 "community number\n"
7261 "Do not send outside local AS (well-known community)\n"
7262 "Do not advertise to any peer (well-known community)\n"
7263 "Do not export to next AS (well-known community)\n"
7264 "community number\n"
7265 "Do not send outside local AS (well-known community)\n"
7266 "Do not advertise to any peer (well-known community)\n"
7267 "Do not export to next AS (well-known community)\n"
7268 "community number\n"
7269 "Do not send outside local AS (well-known community)\n"
7270 "Do not advertise to any peer (well-known community)\n"
7271 "Do not export to next AS (well-known community)\n")
7272
7273ALIAS (show_bgp_community,
7274 show_bgp_ipv6_community4_cmd,
7275 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7276 SHOW_STR
7277 BGP_STR
7278 "Address family\n"
7279 "Display routes matching the communities\n"
7280 "community number\n"
7281 "Do not send outside local AS (well-known community)\n"
7282 "Do not advertise to any peer (well-known community)\n"
7283 "Do not export to next AS (well-known community)\n"
7284 "community number\n"
7285 "Do not send outside local AS (well-known community)\n"
7286 "Do not advertise to any peer (well-known community)\n"
7287 "Do not export to next AS (well-known community)\n"
7288 "community number\n"
7289 "Do not send outside local AS (well-known community)\n"
7290 "Do not advertise to any peer (well-known community)\n"
7291 "Do not export to next AS (well-known community)\n"
7292 "community number\n"
7293 "Do not send outside local AS (well-known community)\n"
7294 "Do not advertise to any peer (well-known community)\n"
7295 "Do not export to next AS (well-known community)\n")
7296
7297/* old command */
7298DEFUN (show_ipv6_bgp_community,
7299 show_ipv6_bgp_community_cmd,
7300 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
7301 SHOW_STR
7302 IPV6_STR
7303 BGP_STR
7304 "Display routes matching the communities\n"
7305 "community number\n"
7306 "Do not send outside local AS (well-known community)\n"
7307 "Do not advertise to any peer (well-known community)\n"
7308 "Do not export to next AS (well-known community)\n")
7309{
7310 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
7311}
7312
7313/* old command */
7314ALIAS (show_ipv6_bgp_community,
7315 show_ipv6_bgp_community2_cmd,
7316 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7317 SHOW_STR
7318 IPV6_STR
7319 BGP_STR
7320 "Display routes matching the communities\n"
7321 "community number\n"
7322 "Do not send outside local AS (well-known community)\n"
7323 "Do not advertise to any peer (well-known community)\n"
7324 "Do not export to next AS (well-known community)\n"
7325 "community number\n"
7326 "Do not send outside local AS (well-known community)\n"
7327 "Do not advertise to any peer (well-known community)\n"
7328 "Do not export to next AS (well-known community)\n")
7329
7330/* old command */
7331ALIAS (show_ipv6_bgp_community,
7332 show_ipv6_bgp_community3_cmd,
7333 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7334 SHOW_STR
7335 IPV6_STR
7336 BGP_STR
7337 "Display routes matching the communities\n"
7338 "community number\n"
7339 "Do not send outside local AS (well-known community)\n"
7340 "Do not advertise to any peer (well-known community)\n"
7341 "Do not export to next AS (well-known community)\n"
7342 "community number\n"
7343 "Do not send outside local AS (well-known community)\n"
7344 "Do not advertise to any peer (well-known community)\n"
7345 "Do not export to next AS (well-known community)\n"
7346 "community number\n"
7347 "Do not send outside local AS (well-known community)\n"
7348 "Do not advertise to any peer (well-known community)\n"
7349 "Do not export to next AS (well-known community)\n")
7350
7351/* old command */
7352ALIAS (show_ipv6_bgp_community,
7353 show_ipv6_bgp_community4_cmd,
7354 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7355 SHOW_STR
7356 IPV6_STR
7357 BGP_STR
7358 "Display routes matching the communities\n"
7359 "community number\n"
7360 "Do not send outside local AS (well-known community)\n"
7361 "Do not advertise to any peer (well-known community)\n"
7362 "Do not export to next AS (well-known community)\n"
7363 "community number\n"
7364 "Do not send outside local AS (well-known community)\n"
7365 "Do not advertise to any peer (well-known community)\n"
7366 "Do not export to next AS (well-known community)\n"
7367 "community number\n"
7368 "Do not send outside local AS (well-known community)\n"
7369 "Do not advertise to any peer (well-known community)\n"
7370 "Do not export to next AS (well-known community)\n"
7371 "community number\n"
7372 "Do not send outside local AS (well-known community)\n"
7373 "Do not advertise to any peer (well-known community)\n"
7374 "Do not export to next AS (well-known community)\n")
7375
7376DEFUN (show_bgp_community_exact,
7377 show_bgp_community_exact_cmd,
7378 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7379 SHOW_STR
7380 BGP_STR
7381 "Display routes matching the communities\n"
7382 "community number\n"
7383 "Do not send outside local AS (well-known community)\n"
7384 "Do not advertise to any peer (well-known community)\n"
7385 "Do not export to next AS (well-known community)\n"
7386 "Exact match of the communities")
7387{
7388 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
7389}
7390
7391ALIAS (show_bgp_community_exact,
7392 show_bgp_ipv6_community_exact_cmd,
7393 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7394 SHOW_STR
7395 BGP_STR
7396 "Address family\n"
7397 "Display routes matching the communities\n"
7398 "community number\n"
7399 "Do not send outside local AS (well-known community)\n"
7400 "Do not advertise to any peer (well-known community)\n"
7401 "Do not export to next AS (well-known community)\n"
7402 "Exact match of the communities")
7403
7404ALIAS (show_bgp_community_exact,
7405 show_bgp_community2_exact_cmd,
7406 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7407 SHOW_STR
7408 BGP_STR
7409 "Display routes matching the communities\n"
7410 "community number\n"
7411 "Do not send outside local AS (well-known community)\n"
7412 "Do not advertise to any peer (well-known community)\n"
7413 "Do not export to next AS (well-known community)\n"
7414 "community number\n"
7415 "Do not send outside local AS (well-known community)\n"
7416 "Do not advertise to any peer (well-known community)\n"
7417 "Do not export to next AS (well-known community)\n"
7418 "Exact match of the communities")
7419
7420ALIAS (show_bgp_community_exact,
7421 show_bgp_ipv6_community2_exact_cmd,
7422 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7423 SHOW_STR
7424 BGP_STR
7425 "Address family\n"
7426 "Display routes matching the communities\n"
7427 "community number\n"
7428 "Do not send outside local AS (well-known community)\n"
7429 "Do not advertise to any peer (well-known community)\n"
7430 "Do not export to next AS (well-known community)\n"
7431 "community number\n"
7432 "Do not send outside local AS (well-known community)\n"
7433 "Do not advertise to any peer (well-known community)\n"
7434 "Do not export to next AS (well-known community)\n"
7435 "Exact match of the communities")
7436
7437ALIAS (show_bgp_community_exact,
7438 show_bgp_community3_exact_cmd,
7439 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7440 SHOW_STR
7441 BGP_STR
7442 "Display routes matching the communities\n"
7443 "community number\n"
7444 "Do not send outside local AS (well-known community)\n"
7445 "Do not advertise to any peer (well-known community)\n"
7446 "Do not export to next AS (well-known community)\n"
7447 "community number\n"
7448 "Do not send outside local AS (well-known community)\n"
7449 "Do not advertise to any peer (well-known community)\n"
7450 "Do not export to next AS (well-known community)\n"
7451 "community number\n"
7452 "Do not send outside local AS (well-known community)\n"
7453 "Do not advertise to any peer (well-known community)\n"
7454 "Do not export to next AS (well-known community)\n"
7455 "Exact match of the communities")
7456
7457ALIAS (show_bgp_community_exact,
7458 show_bgp_ipv6_community3_exact_cmd,
7459 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7460 SHOW_STR
7461 BGP_STR
7462 "Address family\n"
7463 "Display routes matching the communities\n"
7464 "community number\n"
7465 "Do not send outside local AS (well-known community)\n"
7466 "Do not advertise to any peer (well-known community)\n"
7467 "Do not export to next AS (well-known community)\n"
7468 "community number\n"
7469 "Do not send outside local AS (well-known community)\n"
7470 "Do not advertise to any peer (well-known community)\n"
7471 "Do not export to next AS (well-known community)\n"
7472 "community number\n"
7473 "Do not send outside local AS (well-known community)\n"
7474 "Do not advertise to any peer (well-known community)\n"
7475 "Do not export to next AS (well-known community)\n"
7476 "Exact match of the communities")
7477
7478ALIAS (show_bgp_community_exact,
7479 show_bgp_community4_exact_cmd,
7480 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7481 SHOW_STR
7482 BGP_STR
7483 "Display routes matching the communities\n"
7484 "community number\n"
7485 "Do not send outside local AS (well-known community)\n"
7486 "Do not advertise to any peer (well-known community)\n"
7487 "Do not export to next AS (well-known community)\n"
7488 "community number\n"
7489 "Do not send outside local AS (well-known community)\n"
7490 "Do not advertise to any peer (well-known community)\n"
7491 "Do not export to next AS (well-known community)\n"
7492 "community number\n"
7493 "Do not send outside local AS (well-known community)\n"
7494 "Do not advertise to any peer (well-known community)\n"
7495 "Do not export to next AS (well-known community)\n"
7496 "community number\n"
7497 "Do not send outside local AS (well-known community)\n"
7498 "Do not advertise to any peer (well-known community)\n"
7499 "Do not export to next AS (well-known community)\n"
7500 "Exact match of the communities")
7501
7502ALIAS (show_bgp_community_exact,
7503 show_bgp_ipv6_community4_exact_cmd,
7504 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7505 SHOW_STR
7506 BGP_STR
7507 "Address family\n"
7508 "Display routes matching the communities\n"
7509 "community number\n"
7510 "Do not send outside local AS (well-known community)\n"
7511 "Do not advertise to any peer (well-known community)\n"
7512 "Do not export to next AS (well-known community)\n"
7513 "community number\n"
7514 "Do not send outside local AS (well-known community)\n"
7515 "Do not advertise to any peer (well-known community)\n"
7516 "Do not export to next AS (well-known community)\n"
7517 "community number\n"
7518 "Do not send outside local AS (well-known community)\n"
7519 "Do not advertise to any peer (well-known community)\n"
7520 "Do not export to next AS (well-known community)\n"
7521 "community number\n"
7522 "Do not send outside local AS (well-known community)\n"
7523 "Do not advertise to any peer (well-known community)\n"
7524 "Do not export to next AS (well-known community)\n"
7525 "Exact match of the communities")
7526
7527/* old command */
7528DEFUN (show_ipv6_bgp_community_exact,
7529 show_ipv6_bgp_community_exact_cmd,
7530 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7531 SHOW_STR
7532 IPV6_STR
7533 BGP_STR
7534 "Display routes matching the communities\n"
7535 "community number\n"
7536 "Do not send outside local AS (well-known community)\n"
7537 "Do not advertise to any peer (well-known community)\n"
7538 "Do not export to next AS (well-known community)\n"
7539 "Exact match of the communities")
7540{
7541 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
7542}
7543
7544/* old command */
7545ALIAS (show_ipv6_bgp_community_exact,
7546 show_ipv6_bgp_community2_exact_cmd,
7547 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7548 SHOW_STR
7549 IPV6_STR
7550 BGP_STR
7551 "Display routes matching the communities\n"
7552 "community number\n"
7553 "Do not send outside local AS (well-known community)\n"
7554 "Do not advertise to any peer (well-known community)\n"
7555 "Do not export to next AS (well-known community)\n"
7556 "community number\n"
7557 "Do not send outside local AS (well-known community)\n"
7558 "Do not advertise to any peer (well-known community)\n"
7559 "Do not export to next AS (well-known community)\n"
7560 "Exact match of the communities")
7561
7562/* old command */
7563ALIAS (show_ipv6_bgp_community_exact,
7564 show_ipv6_bgp_community3_exact_cmd,
7565 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7566 SHOW_STR
7567 IPV6_STR
7568 BGP_STR
7569 "Display routes matching the communities\n"
7570 "community number\n"
7571 "Do not send outside local AS (well-known community)\n"
7572 "Do not advertise to any peer (well-known community)\n"
7573 "Do not export to next AS (well-known community)\n"
7574 "community number\n"
7575 "Do not send outside local AS (well-known community)\n"
7576 "Do not advertise to any peer (well-known community)\n"
7577 "Do not export to next AS (well-known community)\n"
7578 "community number\n"
7579 "Do not send outside local AS (well-known community)\n"
7580 "Do not advertise to any peer (well-known community)\n"
7581 "Do not export to next AS (well-known community)\n"
7582 "Exact match of the communities")
7583
7584/* old command */
7585ALIAS (show_ipv6_bgp_community_exact,
7586 show_ipv6_bgp_community4_exact_cmd,
7587 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7588 SHOW_STR
7589 IPV6_STR
7590 BGP_STR
7591 "Display routes matching the communities\n"
7592 "community number\n"
7593 "Do not send outside local AS (well-known community)\n"
7594 "Do not advertise to any peer (well-known community)\n"
7595 "Do not export to next AS (well-known community)\n"
7596 "community number\n"
7597 "Do not send outside local AS (well-known community)\n"
7598 "Do not advertise to any peer (well-known community)\n"
7599 "Do not export to next AS (well-known community)\n"
7600 "community number\n"
7601 "Do not send outside local AS (well-known community)\n"
7602 "Do not advertise to any peer (well-known community)\n"
7603 "Do not export to next AS (well-known community)\n"
7604 "community number\n"
7605 "Do not send outside local AS (well-known community)\n"
7606 "Do not advertise to any peer (well-known community)\n"
7607 "Do not export to next AS (well-known community)\n"
7608 "Exact match of the communities")
7609
7610/* old command */
7611DEFUN (show_ipv6_mbgp_community,
7612 show_ipv6_mbgp_community_cmd,
7613 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
7614 SHOW_STR
7615 IPV6_STR
7616 MBGP_STR
7617 "Display routes matching the communities\n"
7618 "community number\n"
7619 "Do not send outside local AS (well-known community)\n"
7620 "Do not advertise to any peer (well-known community)\n"
7621 "Do not export to next AS (well-known community)\n")
7622{
7623 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
7624}
7625
7626/* old command */
7627ALIAS (show_ipv6_mbgp_community,
7628 show_ipv6_mbgp_community2_cmd,
7629 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7630 SHOW_STR
7631 IPV6_STR
7632 MBGP_STR
7633 "Display routes matching the communities\n"
7634 "community number\n"
7635 "Do not send outside local AS (well-known community)\n"
7636 "Do not advertise to any peer (well-known community)\n"
7637 "Do not export to next AS (well-known community)\n"
7638 "community number\n"
7639 "Do not send outside local AS (well-known community)\n"
7640 "Do not advertise to any peer (well-known community)\n"
7641 "Do not export to next AS (well-known community)\n")
7642
7643/* old command */
7644ALIAS (show_ipv6_mbgp_community,
7645 show_ipv6_mbgp_community3_cmd,
7646 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7647 SHOW_STR
7648 IPV6_STR
7649 MBGP_STR
7650 "Display routes matching the communities\n"
7651 "community number\n"
7652 "Do not send outside local AS (well-known community)\n"
7653 "Do not advertise to any peer (well-known community)\n"
7654 "Do not export to next AS (well-known community)\n"
7655 "community number\n"
7656 "Do not send outside local AS (well-known community)\n"
7657 "Do not advertise to any peer (well-known community)\n"
7658 "Do not export to next AS (well-known community)\n"
7659 "community number\n"
7660 "Do not send outside local AS (well-known community)\n"
7661 "Do not advertise to any peer (well-known community)\n"
7662 "Do not export to next AS (well-known community)\n")
7663
7664/* old command */
7665ALIAS (show_ipv6_mbgp_community,
7666 show_ipv6_mbgp_community4_cmd,
7667 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7668 SHOW_STR
7669 IPV6_STR
7670 MBGP_STR
7671 "Display routes matching the communities\n"
7672 "community number\n"
7673 "Do not send outside local AS (well-known community)\n"
7674 "Do not advertise to any peer (well-known community)\n"
7675 "Do not export to next AS (well-known community)\n"
7676 "community number\n"
7677 "Do not send outside local AS (well-known community)\n"
7678 "Do not advertise to any peer (well-known community)\n"
7679 "Do not export to next AS (well-known community)\n"
7680 "community number\n"
7681 "Do not send outside local AS (well-known community)\n"
7682 "Do not advertise to any peer (well-known community)\n"
7683 "Do not export to next AS (well-known community)\n"
7684 "community number\n"
7685 "Do not send outside local AS (well-known community)\n"
7686 "Do not advertise to any peer (well-known community)\n"
7687 "Do not export to next AS (well-known community)\n")
7688
7689/* old command */
7690DEFUN (show_ipv6_mbgp_community_exact,
7691 show_ipv6_mbgp_community_exact_cmd,
7692 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7693 SHOW_STR
7694 IPV6_STR
7695 MBGP_STR
7696 "Display routes matching the communities\n"
7697 "community number\n"
7698 "Do not send outside local AS (well-known community)\n"
7699 "Do not advertise to any peer (well-known community)\n"
7700 "Do not export to next AS (well-known community)\n"
7701 "Exact match of the communities")
7702{
7703 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
7704}
7705
7706/* old command */
7707ALIAS (show_ipv6_mbgp_community_exact,
7708 show_ipv6_mbgp_community2_exact_cmd,
7709 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7710 SHOW_STR
7711 IPV6_STR
7712 MBGP_STR
7713 "Display routes matching the communities\n"
7714 "community number\n"
7715 "Do not send outside local AS (well-known community)\n"
7716 "Do not advertise to any peer (well-known community)\n"
7717 "Do not export to next AS (well-known community)\n"
7718 "community number\n"
7719 "Do not send outside local AS (well-known community)\n"
7720 "Do not advertise to any peer (well-known community)\n"
7721 "Do not export to next AS (well-known community)\n"
7722 "Exact match of the communities")
7723
7724/* old command */
7725ALIAS (show_ipv6_mbgp_community_exact,
7726 show_ipv6_mbgp_community3_exact_cmd,
7727 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7728 SHOW_STR
7729 IPV6_STR
7730 MBGP_STR
7731 "Display routes matching the communities\n"
7732 "community number\n"
7733 "Do not send outside local AS (well-known community)\n"
7734 "Do not advertise to any peer (well-known community)\n"
7735 "Do not export to next AS (well-known community)\n"
7736 "community number\n"
7737 "Do not send outside local AS (well-known community)\n"
7738 "Do not advertise to any peer (well-known community)\n"
7739 "Do not export to next AS (well-known community)\n"
7740 "community number\n"
7741 "Do not send outside local AS (well-known community)\n"
7742 "Do not advertise to any peer (well-known community)\n"
7743 "Do not export to next AS (well-known community)\n"
7744 "Exact match of the communities")
7745
7746/* old command */
7747ALIAS (show_ipv6_mbgp_community_exact,
7748 show_ipv6_mbgp_community4_exact_cmd,
7749 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7750 SHOW_STR
7751 IPV6_STR
7752 MBGP_STR
7753 "Display routes matching the communities\n"
7754 "community number\n"
7755 "Do not send outside local AS (well-known community)\n"
7756 "Do not advertise to any peer (well-known community)\n"
7757 "Do not export to next AS (well-known community)\n"
7758 "community number\n"
7759 "Do not send outside local AS (well-known community)\n"
7760 "Do not advertise to any peer (well-known community)\n"
7761 "Do not export to next AS (well-known community)\n"
7762 "community number\n"
7763 "Do not send outside local AS (well-known community)\n"
7764 "Do not advertise to any peer (well-known community)\n"
7765 "Do not export to next AS (well-known community)\n"
7766 "community number\n"
7767 "Do not send outside local AS (well-known community)\n"
7768 "Do not advertise to any peer (well-known community)\n"
7769 "Do not export to next AS (well-known community)\n"
7770 "Exact match of the communities")
7771#endif /* HAVE_IPV6 */
7772
7773int
paulfd79ac92004-10-13 05:06:08 +00007774bgp_show_community_list (struct vty *vty, const char *com, int exact,
paul718e3742002-12-13 20:15:29 +00007775 u_int16_t afi, u_char safi)
7776{
7777 struct community_list *list;
7778
hassofee6e4e2005-02-02 16:29:31 +00007779 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +00007780 if (list == NULL)
7781 {
7782 vty_out (vty, "%% %s is not a valid community-list name%s", com,
7783 VTY_NEWLINE);
7784 return CMD_WARNING;
7785 }
7786
ajs5a646652004-11-05 01:25:55 +00007787 return bgp_show (vty, NULL, afi, safi,
7788 (exact ? bgp_show_type_community_list_exact :
7789 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +00007790}
7791
7792DEFUN (show_ip_bgp_community_list,
7793 show_ip_bgp_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007794 "show ip bgp community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007795 SHOW_STR
7796 IP_STR
7797 BGP_STR
7798 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007799 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007800 "community-list name\n")
7801{
7802 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
7803}
7804
7805DEFUN (show_ip_bgp_ipv4_community_list,
7806 show_ip_bgp_ipv4_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007807 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007808 SHOW_STR
7809 IP_STR
7810 BGP_STR
7811 "Address family\n"
7812 "Address Family modifier\n"
7813 "Address Family modifier\n"
7814 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007815 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007816 "community-list name\n")
7817{
7818 if (strncmp (argv[0], "m", 1) == 0)
7819 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
7820
7821 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
7822}
7823
7824DEFUN (show_ip_bgp_community_list_exact,
7825 show_ip_bgp_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007826 "show ip bgp community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007827 SHOW_STR
7828 IP_STR
7829 BGP_STR
7830 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007831 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007832 "community-list name\n"
7833 "Exact match of the communities\n")
7834{
7835 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
7836}
7837
7838DEFUN (show_ip_bgp_ipv4_community_list_exact,
7839 show_ip_bgp_ipv4_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007840 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007841 SHOW_STR
7842 IP_STR
7843 BGP_STR
7844 "Address family\n"
7845 "Address Family modifier\n"
7846 "Address Family modifier\n"
7847 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007848 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007849 "community-list name\n"
7850 "Exact match of the communities\n")
7851{
7852 if (strncmp (argv[0], "m", 1) == 0)
7853 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
7854
7855 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
7856}
7857
7858#ifdef HAVE_IPV6
7859DEFUN (show_bgp_community_list,
7860 show_bgp_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007861 "show bgp community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007862 SHOW_STR
7863 BGP_STR
7864 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007865 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007866 "community-list name\n")
7867{
7868 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
7869}
7870
7871ALIAS (show_bgp_community_list,
7872 show_bgp_ipv6_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007873 "show bgp ipv6 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007874 SHOW_STR
7875 BGP_STR
7876 "Address family\n"
7877 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007878 "community-list number\n"
7879 "community-list name\n");
paul718e3742002-12-13 20:15:29 +00007880
7881/* old command */
7882DEFUN (show_ipv6_bgp_community_list,
7883 show_ipv6_bgp_community_list_cmd,
7884 "show ipv6 bgp community-list WORD",
7885 SHOW_STR
7886 IPV6_STR
7887 BGP_STR
7888 "Display routes matching the community-list\n"
7889 "community-list name\n")
7890{
7891 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
7892}
7893
7894/* old command */
7895DEFUN (show_ipv6_mbgp_community_list,
7896 show_ipv6_mbgp_community_list_cmd,
7897 "show ipv6 mbgp community-list WORD",
7898 SHOW_STR
7899 IPV6_STR
7900 MBGP_STR
7901 "Display routes matching the community-list\n"
7902 "community-list name\n")
7903{
7904 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
7905}
7906
7907DEFUN (show_bgp_community_list_exact,
7908 show_bgp_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007909 "show bgp community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007910 SHOW_STR
7911 BGP_STR
7912 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007913 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007914 "community-list name\n"
7915 "Exact match of the communities\n")
7916{
7917 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
7918}
7919
7920ALIAS (show_bgp_community_list_exact,
7921 show_bgp_ipv6_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007922 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007923 SHOW_STR
7924 BGP_STR
7925 "Address family\n"
7926 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007927 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007928 "community-list name\n"
7929 "Exact match of the communities\n")
7930
7931/* old command */
7932DEFUN (show_ipv6_bgp_community_list_exact,
7933 show_ipv6_bgp_community_list_exact_cmd,
7934 "show ipv6 bgp community-list WORD exact-match",
7935 SHOW_STR
7936 IPV6_STR
7937 BGP_STR
7938 "Display routes matching the community-list\n"
7939 "community-list name\n"
7940 "Exact match of the communities\n")
7941{
7942 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
7943}
7944
7945/* old command */
7946DEFUN (show_ipv6_mbgp_community_list_exact,
7947 show_ipv6_mbgp_community_list_exact_cmd,
7948 "show ipv6 mbgp community-list WORD exact-match",
7949 SHOW_STR
7950 IPV6_STR
7951 MBGP_STR
7952 "Display routes matching the community-list\n"
7953 "community-list name\n"
7954 "Exact match of the communities\n")
7955{
7956 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
7957}
7958#endif /* HAVE_IPV6 */
7959
paul718e3742002-12-13 20:15:29 +00007960int
paulfd79ac92004-10-13 05:06:08 +00007961bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +00007962 safi_t safi, enum bgp_show_type type)
7963{
7964 int ret;
7965 struct prefix *p;
7966
7967 p = prefix_new();
7968
7969 ret = str2prefix (prefix, p);
7970 if (! ret)
7971 {
7972 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
7973 return CMD_WARNING;
7974 }
7975
ajs5a646652004-11-05 01:25:55 +00007976 ret = bgp_show (vty, NULL, afi, safi, type, p);
7977 prefix_free(p);
7978 return ret;
paul718e3742002-12-13 20:15:29 +00007979}
7980
7981DEFUN (show_ip_bgp_prefix_longer,
7982 show_ip_bgp_prefix_longer_cmd,
7983 "show ip bgp A.B.C.D/M longer-prefixes",
7984 SHOW_STR
7985 IP_STR
7986 BGP_STR
7987 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7988 "Display route and more specific routes\n")
7989{
7990 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
7991 bgp_show_type_prefix_longer);
7992}
7993
7994DEFUN (show_ip_bgp_flap_prefix_longer,
7995 show_ip_bgp_flap_prefix_longer_cmd,
7996 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
7997 SHOW_STR
7998 IP_STR
7999 BGP_STR
8000 "Display flap statistics of routes\n"
8001 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8002 "Display route and more specific routes\n")
8003{
8004 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
8005 bgp_show_type_flap_prefix_longer);
8006}
8007
8008DEFUN (show_ip_bgp_ipv4_prefix_longer,
8009 show_ip_bgp_ipv4_prefix_longer_cmd,
8010 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8011 SHOW_STR
8012 IP_STR
8013 BGP_STR
8014 "Address family\n"
8015 "Address Family modifier\n"
8016 "Address Family modifier\n"
8017 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8018 "Display route and more specific routes\n")
8019{
8020 if (strncmp (argv[0], "m", 1) == 0)
8021 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8022 bgp_show_type_prefix_longer);
8023
8024 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
8025 bgp_show_type_prefix_longer);
8026}
8027
8028DEFUN (show_ip_bgp_flap_address,
8029 show_ip_bgp_flap_address_cmd,
8030 "show ip bgp flap-statistics A.B.C.D",
8031 SHOW_STR
8032 IP_STR
8033 BGP_STR
8034 "Display flap statistics of routes\n"
8035 "Network in the BGP routing table to display\n")
8036{
8037 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
8038 bgp_show_type_flap_address);
8039}
8040
8041DEFUN (show_ip_bgp_flap_prefix,
8042 show_ip_bgp_flap_prefix_cmd,
8043 "show ip bgp flap-statistics A.B.C.D/M",
8044 SHOW_STR
8045 IP_STR
8046 BGP_STR
8047 "Display flap statistics of routes\n"
8048 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8049{
8050 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
8051 bgp_show_type_flap_prefix);
8052}
8053#ifdef HAVE_IPV6
8054DEFUN (show_bgp_prefix_longer,
8055 show_bgp_prefix_longer_cmd,
8056 "show bgp X:X::X:X/M longer-prefixes",
8057 SHOW_STR
8058 BGP_STR
8059 "IPv6 prefix <network>/<length>\n"
8060 "Display route and more specific routes\n")
8061{
8062 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8063 bgp_show_type_prefix_longer);
8064}
8065
8066ALIAS (show_bgp_prefix_longer,
8067 show_bgp_ipv6_prefix_longer_cmd,
8068 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8069 SHOW_STR
8070 BGP_STR
8071 "Address family\n"
8072 "IPv6 prefix <network>/<length>\n"
8073 "Display route and more specific routes\n")
8074
8075/* old command */
8076DEFUN (show_ipv6_bgp_prefix_longer,
8077 show_ipv6_bgp_prefix_longer_cmd,
8078 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8079 SHOW_STR
8080 IPV6_STR
8081 BGP_STR
8082 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8083 "Display route and more specific routes\n")
8084{
8085 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8086 bgp_show_type_prefix_longer);
8087}
8088
8089/* old command */
8090DEFUN (show_ipv6_mbgp_prefix_longer,
8091 show_ipv6_mbgp_prefix_longer_cmd,
8092 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8093 SHOW_STR
8094 IPV6_STR
8095 MBGP_STR
8096 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8097 "Display route and more specific routes\n")
8098{
8099 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8100 bgp_show_type_prefix_longer);
8101}
8102#endif /* HAVE_IPV6 */
paulbb46e942003-10-24 19:02:03 +00008103
8104struct peer *
paulfd79ac92004-10-13 05:06:08 +00008105peer_lookup_in_view (struct vty *vty, const char *view_name,
8106 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +00008107{
8108 int ret;
8109 struct bgp *bgp;
8110 struct peer *peer;
8111 union sockunion su;
8112
8113 /* BGP structure lookup. */
8114 if (view_name)
8115 {
8116 bgp = bgp_lookup_by_name (view_name);
8117 if (! bgp)
8118 {
8119 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
8120 return NULL;
8121 }
8122 }
paul5228ad22004-06-04 17:58:18 +00008123 else
paulbb46e942003-10-24 19:02:03 +00008124 {
8125 bgp = bgp_get_default ();
8126 if (! bgp)
8127 {
8128 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
8129 return NULL;
8130 }
8131 }
8132
8133 /* Get peer sockunion. */
8134 ret = str2sockunion (ip_str, &su);
8135 if (ret < 0)
8136 {
8137 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
8138 return NULL;
8139 }
8140
8141 /* Peer structure lookup. */
8142 peer = peer_lookup (bgp, &su);
8143 if (! peer)
8144 {
8145 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
8146 return NULL;
8147 }
8148
8149 return peer;
8150}
8151
paul718e3742002-12-13 20:15:29 +00008152void
8153show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
8154 int in)
8155{
8156 struct bgp_table *table;
8157 struct bgp_adj_in *ain;
8158 struct bgp_adj_out *adj;
8159 unsigned long output_count;
8160 struct bgp_node *rn;
8161 int header1 = 1;
8162 struct bgp *bgp;
8163 int header2 = 1;
8164
paulbb46e942003-10-24 19:02:03 +00008165 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +00008166
8167 if (! bgp)
8168 return;
8169
8170 table = bgp->rib[afi][safi];
8171
8172 output_count = 0;
8173
8174 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
8175 PEER_STATUS_DEFAULT_ORIGINATE))
8176 {
8177 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00008178 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
8179 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008180
8181 vty_out (vty, "Originating default network 0.0.0.0%s%s",
8182 VTY_NEWLINE, VTY_NEWLINE);
8183 header1 = 0;
8184 }
8185
8186 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
8187 if (in)
8188 {
8189 for (ain = rn->adj_in; ain; ain = ain->next)
8190 if (ain->peer == peer)
8191 {
8192 if (header1)
8193 {
8194 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00008195 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
8196 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008197 header1 = 0;
8198 }
8199 if (header2)
8200 {
8201 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
8202 header2 = 0;
8203 }
8204 if (ain->attr)
8205 {
8206 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
8207 output_count++;
8208 }
8209 }
8210 }
8211 else
8212 {
8213 for (adj = rn->adj_out; adj; adj = adj->next)
8214 if (adj->peer == peer)
8215 {
8216 if (header1)
8217 {
8218 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +00008219 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
8220 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008221 header1 = 0;
8222 }
8223 if (header2)
8224 {
8225 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
8226 header2 = 0;
8227 }
8228 if (adj->attr)
8229 {
8230 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
8231 output_count++;
8232 }
8233 }
8234 }
8235
8236 if (output_count != 0)
8237 vty_out (vty, "%sTotal number of prefixes %ld%s",
8238 VTY_NEWLINE, output_count, VTY_NEWLINE);
8239}
8240
8241int
paulbb46e942003-10-24 19:02:03 +00008242peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
8243{
paul718e3742002-12-13 20:15:29 +00008244 if (! peer || ! peer->afc[afi][safi])
8245 {
8246 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
8247 return CMD_WARNING;
8248 }
8249
8250 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
8251 {
8252 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
8253 VTY_NEWLINE);
8254 return CMD_WARNING;
8255 }
8256
8257 show_adj_route (vty, peer, afi, safi, in);
8258
8259 return CMD_SUCCESS;
8260}
8261
8262DEFUN (show_ip_bgp_neighbor_advertised_route,
8263 show_ip_bgp_neighbor_advertised_route_cmd,
8264 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8265 SHOW_STR
8266 IP_STR
8267 BGP_STR
8268 "Detailed information on TCP and BGP neighbor connections\n"
8269 "Neighbor to display information about\n"
8270 "Neighbor to display information about\n"
8271 "Display the routes advertised to a BGP neighbor\n")
8272{
paulbb46e942003-10-24 19:02:03 +00008273 struct peer *peer;
8274
8275 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8276 if (! peer)
8277 return CMD_WARNING;
8278
8279 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
paul718e3742002-12-13 20:15:29 +00008280}
8281
8282DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
8283 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
8284 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8285 SHOW_STR
8286 IP_STR
8287 BGP_STR
8288 "Address family\n"
8289 "Address Family modifier\n"
8290 "Address Family modifier\n"
8291 "Detailed information on TCP and BGP neighbor connections\n"
8292 "Neighbor to display information about\n"
8293 "Neighbor to display information about\n"
8294 "Display the routes advertised to a BGP neighbor\n")
8295{
paulbb46e942003-10-24 19:02:03 +00008296 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00008297
paulbb46e942003-10-24 19:02:03 +00008298 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8299 if (! peer)
8300 return CMD_WARNING;
8301
8302 if (strncmp (argv[0], "m", 1) == 0)
8303 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
8304
8305 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
paul718e3742002-12-13 20:15:29 +00008306}
8307
8308#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00008309DEFUN (show_bgp_view_neighbor_advertised_route,
8310 show_bgp_view_neighbor_advertised_route_cmd,
8311 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8312 SHOW_STR
8313 BGP_STR
8314 "BGP view\n"
8315 "View name\n"
8316 "Detailed information on TCP and BGP neighbor connections\n"
8317 "Neighbor to display information about\n"
8318 "Neighbor to display information about\n"
8319 "Display the routes advertised to a BGP neighbor\n")
8320{
8321 struct peer *peer;
8322
8323 if (argc == 2)
8324 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8325 else
8326 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8327
8328 if (! peer)
8329 return CMD_WARNING;
8330
8331 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
8332}
8333
8334ALIAS (show_bgp_view_neighbor_advertised_route,
8335 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
8336 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8337 SHOW_STR
8338 BGP_STR
8339 "BGP view\n"
8340 "View name\n"
8341 "Address family\n"
8342 "Detailed information on TCP and BGP neighbor connections\n"
8343 "Neighbor to display information about\n"
8344 "Neighbor to display information about\n"
8345 "Display the routes advertised to a BGP neighbor\n")
8346
8347DEFUN (show_bgp_view_neighbor_received_routes,
8348 show_bgp_view_neighbor_received_routes_cmd,
8349 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
8350 SHOW_STR
8351 BGP_STR
8352 "BGP view\n"
8353 "View name\n"
8354 "Detailed information on TCP and BGP neighbor connections\n"
8355 "Neighbor to display information about\n"
8356 "Neighbor to display information about\n"
8357 "Display the received routes from neighbor\n")
8358{
8359 struct peer *peer;
8360
8361 if (argc == 2)
8362 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8363 else
8364 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8365
8366 if (! peer)
8367 return CMD_WARNING;
8368
8369 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
8370}
8371
8372ALIAS (show_bgp_view_neighbor_received_routes,
8373 show_bgp_view_ipv6_neighbor_received_routes_cmd,
8374 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
8375 SHOW_STR
8376 BGP_STR
8377 "BGP view\n"
8378 "View name\n"
8379 "Address family\n"
8380 "Detailed information on TCP and BGP neighbor connections\n"
8381 "Neighbor to display information about\n"
8382 "Neighbor to display information about\n"
8383 "Display the received routes from neighbor\n")
8384
8385ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00008386 show_bgp_neighbor_advertised_route_cmd,
8387 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8388 SHOW_STR
8389 BGP_STR
8390 "Detailed information on TCP and BGP neighbor connections\n"
8391 "Neighbor to display information about\n"
8392 "Neighbor to display information about\n"
8393 "Display the routes advertised to a BGP neighbor\n")
paulbb46e942003-10-24 19:02:03 +00008394
8395ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00008396 show_bgp_ipv6_neighbor_advertised_route_cmd,
8397 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8398 SHOW_STR
8399 BGP_STR
8400 "Address family\n"
8401 "Detailed information on TCP and BGP neighbor connections\n"
8402 "Neighbor to display information about\n"
8403 "Neighbor to display information about\n"
8404 "Display the routes advertised to a BGP neighbor\n")
8405
8406/* old command */
paulbb46e942003-10-24 19:02:03 +00008407ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00008408 ipv6_bgp_neighbor_advertised_route_cmd,
8409 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8410 SHOW_STR
8411 IPV6_STR
8412 BGP_STR
8413 "Detailed information on TCP and BGP neighbor connections\n"
8414 "Neighbor to display information about\n"
8415 "Neighbor to display information about\n"
8416 "Display the routes advertised to a BGP neighbor\n")
paulbb46e942003-10-24 19:02:03 +00008417
paul718e3742002-12-13 20:15:29 +00008418/* old command */
8419DEFUN (ipv6_mbgp_neighbor_advertised_route,
8420 ipv6_mbgp_neighbor_advertised_route_cmd,
8421 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8422 SHOW_STR
8423 IPV6_STR
8424 MBGP_STR
8425 "Detailed information on TCP and BGP neighbor connections\n"
8426 "Neighbor to display information about\n"
8427 "Neighbor to display information about\n"
8428 "Display the routes advertised to a BGP neighbor\n")
8429{
paulbb46e942003-10-24 19:02:03 +00008430 struct peer *peer;
8431
8432 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8433 if (! peer)
8434 return CMD_WARNING;
8435
8436 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
paul718e3742002-12-13 20:15:29 +00008437}
8438#endif /* HAVE_IPV6 */
8439
8440DEFUN (show_ip_bgp_neighbor_received_routes,
8441 show_ip_bgp_neighbor_received_routes_cmd,
8442 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8443 SHOW_STR
8444 IP_STR
8445 BGP_STR
8446 "Detailed information on TCP and BGP neighbor connections\n"
8447 "Neighbor to display information about\n"
8448 "Neighbor to display information about\n"
8449 "Display the received routes from neighbor\n")
8450{
paulbb46e942003-10-24 19:02:03 +00008451 struct peer *peer;
8452
8453 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8454 if (! peer)
8455 return CMD_WARNING;
8456
8457 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
paul718e3742002-12-13 20:15:29 +00008458}
8459
8460DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
8461 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
8462 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
8463 SHOW_STR
8464 IP_STR
8465 BGP_STR
8466 "Address family\n"
8467 "Address Family modifier\n"
8468 "Address Family modifier\n"
8469 "Detailed information on TCP and BGP neighbor connections\n"
8470 "Neighbor to display information about\n"
8471 "Neighbor to display information about\n"
8472 "Display the received routes from neighbor\n")
8473{
paulbb46e942003-10-24 19:02:03 +00008474 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00008475
paulbb46e942003-10-24 19:02:03 +00008476 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8477 if (! peer)
8478 return CMD_WARNING;
8479
8480 if (strncmp (argv[0], "m", 1) == 0)
8481 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
8482
8483 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
paul718e3742002-12-13 20:15:29 +00008484}
8485
8486DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
8487 show_ip_bgp_neighbor_received_prefix_filter_cmd,
8488 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8489 SHOW_STR
8490 IP_STR
8491 BGP_STR
8492 "Detailed information on TCP and BGP neighbor connections\n"
8493 "Neighbor to display information about\n"
8494 "Neighbor to display information about\n"
8495 "Display information received from a BGP neighbor\n"
8496 "Display the prefixlist filter\n")
8497{
8498 char name[BUFSIZ];
8499 union sockunion *su;
8500 struct peer *peer;
8501 int count;
8502
8503 su = sockunion_str2su (argv[0]);
8504 if (su == NULL)
8505 return CMD_WARNING;
8506
8507 peer = peer_lookup (NULL, su);
8508 if (! peer)
8509 return CMD_WARNING;
8510
8511 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
8512 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
8513 if (count)
8514 {
8515 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
8516 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
8517 }
8518
8519 return CMD_SUCCESS;
8520}
8521
8522DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
8523 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
8524 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8525 SHOW_STR
8526 IP_STR
8527 BGP_STR
8528 "Address family\n"
8529 "Address Family modifier\n"
8530 "Address Family modifier\n"
8531 "Detailed information on TCP and BGP neighbor connections\n"
8532 "Neighbor to display information about\n"
8533 "Neighbor to display information about\n"
8534 "Display information received from a BGP neighbor\n"
8535 "Display the prefixlist filter\n")
8536{
8537 char name[BUFSIZ];
8538 union sockunion *su;
8539 struct peer *peer;
8540 int count;
8541
8542 su = sockunion_str2su (argv[1]);
8543 if (su == NULL)
8544 return CMD_WARNING;
8545
8546 peer = peer_lookup (NULL, su);
8547 if (! peer)
8548 return CMD_WARNING;
8549
8550 if (strncmp (argv[0], "m", 1) == 0)
8551 {
8552 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
8553 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
8554 if (count)
8555 {
8556 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
8557 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
8558 }
8559 }
8560 else
8561 {
8562 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
8563 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
8564 if (count)
8565 {
8566 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
8567 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
8568 }
8569 }
8570
8571 return CMD_SUCCESS;
8572}
8573
8574
8575#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00008576ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00008577 show_bgp_neighbor_received_routes_cmd,
8578 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8579 SHOW_STR
8580 BGP_STR
8581 "Detailed information on TCP and BGP neighbor connections\n"
8582 "Neighbor to display information about\n"
8583 "Neighbor to display information about\n"
8584 "Display the received routes from neighbor\n")
paul718e3742002-12-13 20:15:29 +00008585
paulbb46e942003-10-24 19:02:03 +00008586ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00008587 show_bgp_ipv6_neighbor_received_routes_cmd,
8588 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
8589 SHOW_STR
8590 BGP_STR
8591 "Address family\n"
8592 "Detailed information on TCP and BGP neighbor connections\n"
8593 "Neighbor to display information about\n"
8594 "Neighbor to display information about\n"
8595 "Display the received routes from neighbor\n")
8596
8597DEFUN (show_bgp_neighbor_received_prefix_filter,
8598 show_bgp_neighbor_received_prefix_filter_cmd,
8599 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8600 SHOW_STR
8601 BGP_STR
8602 "Detailed information on TCP and BGP neighbor connections\n"
8603 "Neighbor to display information about\n"
8604 "Neighbor to display information about\n"
8605 "Display information received from a BGP neighbor\n"
8606 "Display the prefixlist filter\n")
8607{
8608 char name[BUFSIZ];
8609 union sockunion *su;
8610 struct peer *peer;
8611 int count;
8612
8613 su = sockunion_str2su (argv[0]);
8614 if (su == NULL)
8615 return CMD_WARNING;
8616
8617 peer = peer_lookup (NULL, su);
8618 if (! peer)
8619 return CMD_WARNING;
8620
8621 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
8622 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
8623 if (count)
8624 {
8625 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
8626 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
8627 }
8628
8629 return CMD_SUCCESS;
8630}
8631
8632ALIAS (show_bgp_neighbor_received_prefix_filter,
8633 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
8634 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8635 SHOW_STR
8636 BGP_STR
8637 "Address family\n"
8638 "Detailed information on TCP and BGP neighbor connections\n"
8639 "Neighbor to display information about\n"
8640 "Neighbor to display information about\n"
8641 "Display information received from a BGP neighbor\n"
8642 "Display the prefixlist filter\n")
8643
8644/* old command */
paulbb46e942003-10-24 19:02:03 +00008645ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00008646 ipv6_bgp_neighbor_received_routes_cmd,
8647 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8648 SHOW_STR
8649 IPV6_STR
8650 BGP_STR
8651 "Detailed information on TCP and BGP neighbor connections\n"
8652 "Neighbor to display information about\n"
8653 "Neighbor to display information about\n"
8654 "Display the received routes from neighbor\n")
paul718e3742002-12-13 20:15:29 +00008655
8656/* old command */
8657DEFUN (ipv6_mbgp_neighbor_received_routes,
8658 ipv6_mbgp_neighbor_received_routes_cmd,
8659 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8660 SHOW_STR
8661 IPV6_STR
8662 MBGP_STR
8663 "Detailed information on TCP and BGP neighbor connections\n"
8664 "Neighbor to display information about\n"
8665 "Neighbor to display information about\n"
8666 "Display the received routes from neighbor\n")
8667{
paulbb46e942003-10-24 19:02:03 +00008668 struct peer *peer;
8669
8670 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8671 if (! peer)
8672 return CMD_WARNING;
8673
8674 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
paul718e3742002-12-13 20:15:29 +00008675}
paulbb46e942003-10-24 19:02:03 +00008676
8677DEFUN (show_bgp_view_neighbor_received_prefix_filter,
8678 show_bgp_view_neighbor_received_prefix_filter_cmd,
8679 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8680 SHOW_STR
8681 BGP_STR
8682 "BGP view\n"
8683 "View name\n"
8684 "Detailed information on TCP and BGP neighbor connections\n"
8685 "Neighbor to display information about\n"
8686 "Neighbor to display information about\n"
8687 "Display information received from a BGP neighbor\n"
8688 "Display the prefixlist filter\n")
8689{
8690 char name[BUFSIZ];
8691 union sockunion *su;
8692 struct peer *peer;
8693 struct bgp *bgp;
8694 int count;
8695
8696 /* BGP structure lookup. */
8697 bgp = bgp_lookup_by_name (argv[0]);
8698 if (bgp == NULL)
8699 {
8700 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8701 return CMD_WARNING;
8702 }
8703
8704 su = sockunion_str2su (argv[1]);
8705 if (su == NULL)
8706 return CMD_WARNING;
8707
8708 peer = peer_lookup (bgp, su);
8709 if (! peer)
8710 return CMD_WARNING;
8711
8712 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
8713 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
8714 if (count)
8715 {
8716 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
8717 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
8718 }
8719
8720 return CMD_SUCCESS;
8721}
8722
8723ALIAS (show_bgp_view_neighbor_received_prefix_filter,
8724 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
8725 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8726 SHOW_STR
8727 BGP_STR
8728 "BGP view\n"
8729 "View name\n"
8730 "Address family\n"
8731 "Detailed information on TCP and BGP neighbor connections\n"
8732 "Neighbor to display information about\n"
8733 "Neighbor to display information about\n"
8734 "Display information received from a BGP neighbor\n"
8735 "Display the prefixlist filter\n")
paul718e3742002-12-13 20:15:29 +00008736#endif /* HAVE_IPV6 */
8737
paul718e3742002-12-13 20:15:29 +00008738int
paulbb46e942003-10-24 19:02:03 +00008739bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008740 safi_t safi, enum bgp_show_type type)
8741{
paul718e3742002-12-13 20:15:29 +00008742 if (! peer || ! peer->afc[afi][safi])
8743 {
8744 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008745 return CMD_WARNING;
8746 }
8747
ajs5a646652004-11-05 01:25:55 +00008748 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +00008749}
8750
8751DEFUN (show_ip_bgp_neighbor_routes,
8752 show_ip_bgp_neighbor_routes_cmd,
8753 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
8754 SHOW_STR
8755 IP_STR
8756 BGP_STR
8757 "Detailed information on TCP and BGP neighbor connections\n"
8758 "Neighbor to display information about\n"
8759 "Neighbor to display information about\n"
8760 "Display routes learned from neighbor\n")
8761{
paulbb46e942003-10-24 19:02:03 +00008762 struct peer *peer;
8763
8764 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8765 if (! peer)
8766 return CMD_WARNING;
8767
8768 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008769 bgp_show_type_neighbor);
8770}
8771
8772DEFUN (show_ip_bgp_neighbor_flap,
8773 show_ip_bgp_neighbor_flap_cmd,
8774 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
8775 SHOW_STR
8776 IP_STR
8777 BGP_STR
8778 "Detailed information on TCP and BGP neighbor connections\n"
8779 "Neighbor to display information about\n"
8780 "Neighbor to display information about\n"
8781 "Display flap statistics of the routes learned from neighbor\n")
8782{
paulbb46e942003-10-24 19:02:03 +00008783 struct peer *peer;
8784
8785 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8786 if (! peer)
8787 return CMD_WARNING;
8788
8789 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008790 bgp_show_type_flap_neighbor);
8791}
8792
8793DEFUN (show_ip_bgp_neighbor_damp,
8794 show_ip_bgp_neighbor_damp_cmd,
8795 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
8796 SHOW_STR
8797 IP_STR
8798 BGP_STR
8799 "Detailed information on TCP and BGP neighbor connections\n"
8800 "Neighbor to display information about\n"
8801 "Neighbor to display information about\n"
8802 "Display the dampened routes received from neighbor\n")
8803{
paulbb46e942003-10-24 19:02:03 +00008804 struct peer *peer;
8805
8806 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8807 if (! peer)
8808 return CMD_WARNING;
8809
8810 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008811 bgp_show_type_damp_neighbor);
8812}
8813
8814DEFUN (show_ip_bgp_ipv4_neighbor_routes,
8815 show_ip_bgp_ipv4_neighbor_routes_cmd,
8816 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
8817 SHOW_STR
8818 IP_STR
8819 BGP_STR
8820 "Address family\n"
8821 "Address Family modifier\n"
8822 "Address Family modifier\n"
8823 "Detailed information on TCP and BGP neighbor connections\n"
8824 "Neighbor to display information about\n"
8825 "Neighbor to display information about\n"
8826 "Display routes learned from neighbor\n")
8827{
paulbb46e942003-10-24 19:02:03 +00008828 struct peer *peer;
8829
8830 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8831 if (! peer)
8832 return CMD_WARNING;
8833
paul718e3742002-12-13 20:15:29 +00008834 if (strncmp (argv[0], "m", 1) == 0)
paulbb46e942003-10-24 19:02:03 +00008835 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
paul718e3742002-12-13 20:15:29 +00008836 bgp_show_type_neighbor);
8837
paulbb46e942003-10-24 19:02:03 +00008838 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008839 bgp_show_type_neighbor);
8840}
paulbb46e942003-10-24 19:02:03 +00008841
paulfee0f4c2004-09-13 05:12:46 +00008842DEFUN (show_ip_bgp_view_rsclient,
8843 show_ip_bgp_view_rsclient_cmd,
8844 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
8845 SHOW_STR
8846 IP_STR
8847 BGP_STR
8848 "BGP view\n"
8849 "BGP view name\n"
8850 "Information about Route Server Client\n"
8851 NEIGHBOR_ADDR_STR)
8852{
8853 struct bgp_table *table;
8854 struct peer *peer;
8855
8856 if (argc == 2)
8857 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8858 else
8859 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8860
8861 if (! peer)
8862 return CMD_WARNING;
8863
8864 if (! peer->afc[AFI_IP][SAFI_UNICAST])
8865 {
8866 vty_out (vty, "%% Activate the neighbor for the address family first%s",
8867 VTY_NEWLINE);
8868 return CMD_WARNING;
8869 }
8870
8871 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
8872 PEER_FLAG_RSERVER_CLIENT))
8873 {
8874 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
8875 VTY_NEWLINE);
8876 return CMD_WARNING;
8877 }
8878
8879 table = peer->rib[AFI_IP][SAFI_UNICAST];
8880
ajs5a646652004-11-05 01:25:55 +00008881 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +00008882}
8883
8884ALIAS (show_ip_bgp_view_rsclient,
8885 show_ip_bgp_rsclient_cmd,
8886 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
8887 SHOW_STR
8888 IP_STR
8889 BGP_STR
8890 "Information about Route Server Client\n"
8891 NEIGHBOR_ADDR_STR)
8892
8893DEFUN (show_ip_bgp_view_rsclient_route,
8894 show_ip_bgp_view_rsclient_route_cmd,
8895 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
8896 SHOW_STR
8897 IP_STR
8898 BGP_STR
8899 "BGP view\n"
8900 "BGP view name\n"
8901 "Information about Route Server Client\n"
8902 NEIGHBOR_ADDR_STR
8903 "Network in the BGP routing table to display\n")
8904{
8905 struct bgp *bgp;
8906 struct peer *peer;
8907
8908 /* BGP structure lookup. */
8909 if (argc == 3)
8910 {
8911 bgp = bgp_lookup_by_name (argv[0]);
8912 if (bgp == NULL)
8913 {
8914 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8915 return CMD_WARNING;
8916 }
8917 }
8918 else
8919 {
8920 bgp = bgp_get_default ();
8921 if (bgp == NULL)
8922 {
8923 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
8924 return CMD_WARNING;
8925 }
8926 }
8927
8928 if (argc == 3)
8929 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8930 else
8931 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8932
8933 if (! peer)
8934 return CMD_WARNING;
8935
8936 if (! peer->afc[AFI_IP][SAFI_UNICAST])
8937 {
8938 vty_out (vty, "%% Activate the neighbor for the address family first%s",
8939 VTY_NEWLINE);
8940 return CMD_WARNING;
8941}
8942
8943 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
8944 PEER_FLAG_RSERVER_CLIENT))
8945 {
8946 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
8947 VTY_NEWLINE);
8948 return CMD_WARNING;
8949 }
8950
8951 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
8952 (argc == 3) ? argv[2] : argv[1],
8953 AFI_IP, SAFI_UNICAST, NULL, 0);
8954}
8955
8956ALIAS (show_ip_bgp_view_rsclient_route,
8957 show_ip_bgp_rsclient_route_cmd,
8958 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
8959 SHOW_STR
8960 IP_STR
8961 BGP_STR
8962 "Information about Route Server Client\n"
8963 NEIGHBOR_ADDR_STR
8964 "Network in the BGP routing table to display\n")
8965
8966DEFUN (show_ip_bgp_view_rsclient_prefix,
8967 show_ip_bgp_view_rsclient_prefix_cmd,
8968 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
8969 SHOW_STR
8970 IP_STR
8971 BGP_STR
8972 "BGP view\n"
8973 "BGP view name\n"
8974 "Information about Route Server Client\n"
8975 NEIGHBOR_ADDR_STR
8976 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8977{
8978 struct bgp *bgp;
8979 struct peer *peer;
8980
8981 /* BGP structure lookup. */
8982 if (argc == 3)
8983 {
8984 bgp = bgp_lookup_by_name (argv[0]);
8985 if (bgp == NULL)
8986 {
8987 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8988 return CMD_WARNING;
8989 }
8990 }
8991 else
8992 {
8993 bgp = bgp_get_default ();
8994 if (bgp == NULL)
8995 {
8996 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
8997 return CMD_WARNING;
8998 }
8999 }
9000
9001 if (argc == 3)
9002 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9003 else
9004 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9005
9006 if (! peer)
9007 return CMD_WARNING;
9008
9009 if (! peer->afc[AFI_IP][SAFI_UNICAST])
9010 {
9011 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9012 VTY_NEWLINE);
9013 return CMD_WARNING;
9014}
9015
9016 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
9017 PEER_FLAG_RSERVER_CLIENT))
9018{
9019 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9020 VTY_NEWLINE);
9021 return CMD_WARNING;
9022 }
9023
9024 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
9025 (argc == 3) ? argv[2] : argv[1],
9026 AFI_IP, SAFI_UNICAST, NULL, 1);
9027}
9028
9029ALIAS (show_ip_bgp_view_rsclient_prefix,
9030 show_ip_bgp_rsclient_prefix_cmd,
9031 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
9032 SHOW_STR
9033 IP_STR
9034 BGP_STR
9035 "Information about Route Server Client\n"
9036 NEIGHBOR_ADDR_STR
9037 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9038
9039
paul718e3742002-12-13 20:15:29 +00009040#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00009041DEFUN (show_bgp_view_neighbor_routes,
9042 show_bgp_view_neighbor_routes_cmd,
9043 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
9044 SHOW_STR
9045 BGP_STR
9046 "BGP view\n"
9047 "BGP view name\n"
9048 "Detailed information on TCP and BGP neighbor connections\n"
9049 "Neighbor to display information about\n"
9050 "Neighbor to display information about\n"
9051 "Display routes learned from neighbor\n")
9052{
9053 struct peer *peer;
9054
9055 if (argc == 2)
9056 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9057 else
9058 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9059
9060 if (! peer)
9061 return CMD_WARNING;
9062
9063 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
9064 bgp_show_type_neighbor);
9065}
9066
9067ALIAS (show_bgp_view_neighbor_routes,
9068 show_bgp_view_ipv6_neighbor_routes_cmd,
9069 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
9070 SHOW_STR
9071 BGP_STR
9072 "BGP view\n"
9073 "BGP view name\n"
9074 "Address family\n"
9075 "Detailed information on TCP and BGP neighbor connections\n"
9076 "Neighbor to display information about\n"
9077 "Neighbor to display information about\n"
9078 "Display routes learned from neighbor\n")
9079
9080DEFUN (show_bgp_view_neighbor_damp,
9081 show_bgp_view_neighbor_damp_cmd,
9082 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9083 SHOW_STR
9084 BGP_STR
9085 "BGP view\n"
9086 "BGP view name\n"
9087 "Detailed information on TCP and BGP neighbor connections\n"
9088 "Neighbor to display information about\n"
9089 "Neighbor to display information about\n"
9090 "Display the dampened routes received from neighbor\n")
9091{
9092 struct peer *peer;
9093
9094 if (argc == 2)
9095 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9096 else
9097 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9098
9099 if (! peer)
9100 return CMD_WARNING;
9101
9102 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
9103 bgp_show_type_damp_neighbor);
9104}
9105
9106ALIAS (show_bgp_view_neighbor_damp,
9107 show_bgp_view_ipv6_neighbor_damp_cmd,
9108 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9109 SHOW_STR
9110 BGP_STR
9111 "BGP view\n"
9112 "BGP view name\n"
9113 "Address family\n"
9114 "Detailed information on TCP and BGP neighbor connections\n"
9115 "Neighbor to display information about\n"
9116 "Neighbor to display information about\n"
9117 "Display the dampened routes received from neighbor\n")
9118
9119DEFUN (show_bgp_view_neighbor_flap,
9120 show_bgp_view_neighbor_flap_cmd,
9121 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9122 SHOW_STR
9123 BGP_STR
9124 "BGP view\n"
9125 "BGP view name\n"
9126 "Detailed information on TCP and BGP neighbor connections\n"
9127 "Neighbor to display information about\n"
9128 "Neighbor to display information about\n"
9129 "Display flap statistics of the routes learned from neighbor\n")
9130{
9131 struct peer *peer;
9132
9133 if (argc == 2)
9134 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9135 else
9136 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9137
9138 if (! peer)
9139 return CMD_WARNING;
9140
9141 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
9142 bgp_show_type_flap_neighbor);
9143}
9144
9145ALIAS (show_bgp_view_neighbor_flap,
9146 show_bgp_view_ipv6_neighbor_flap_cmd,
9147 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9148 SHOW_STR
9149 BGP_STR
9150 "BGP view\n"
9151 "BGP view name\n"
9152 "Address family\n"
9153 "Detailed information on TCP and BGP neighbor connections\n"
9154 "Neighbor to display information about\n"
9155 "Neighbor to display information about\n"
9156 "Display flap statistics of the routes learned from neighbor\n")
9157
9158ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00009159 show_bgp_neighbor_routes_cmd,
9160 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
9161 SHOW_STR
9162 BGP_STR
9163 "Detailed information on TCP and BGP neighbor connections\n"
9164 "Neighbor to display information about\n"
9165 "Neighbor to display information about\n"
9166 "Display routes learned from neighbor\n")
paul718e3742002-12-13 20:15:29 +00009167
paulbb46e942003-10-24 19:02:03 +00009168
9169ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00009170 show_bgp_ipv6_neighbor_routes_cmd,
9171 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
9172 SHOW_STR
9173 BGP_STR
9174 "Address family\n"
9175 "Detailed information on TCP and BGP neighbor connections\n"
9176 "Neighbor to display information about\n"
9177 "Neighbor to display information about\n"
9178 "Display routes learned from neighbor\n")
9179
9180/* old command */
paulbb46e942003-10-24 19:02:03 +00009181ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00009182 ipv6_bgp_neighbor_routes_cmd,
9183 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
9184 SHOW_STR
9185 IPV6_STR
9186 BGP_STR
9187 "Detailed information on TCP and BGP neighbor connections\n"
9188 "Neighbor to display information about\n"
9189 "Neighbor to display information about\n"
9190 "Display routes learned from neighbor\n")
paul718e3742002-12-13 20:15:29 +00009191
9192/* old command */
9193DEFUN (ipv6_mbgp_neighbor_routes,
9194 ipv6_mbgp_neighbor_routes_cmd,
9195 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
9196 SHOW_STR
9197 IPV6_STR
9198 MBGP_STR
9199 "Detailed information on TCP and BGP neighbor connections\n"
9200 "Neighbor to display information about\n"
9201 "Neighbor to display information about\n"
9202 "Display routes learned from neighbor\n")
9203{
paulbb46e942003-10-24 19:02:03 +00009204 struct peer *peer;
9205
9206 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9207 if (! peer)
9208 return CMD_WARNING;
9209
9210 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
paul718e3742002-12-13 20:15:29 +00009211 bgp_show_type_neighbor);
9212}
paulbb46e942003-10-24 19:02:03 +00009213
9214ALIAS (show_bgp_view_neighbor_flap,
9215 show_bgp_neighbor_flap_cmd,
9216 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9217 SHOW_STR
9218 BGP_STR
9219 "Detailed information on TCP and BGP neighbor connections\n"
9220 "Neighbor to display information about\n"
9221 "Neighbor to display information about\n"
9222 "Display flap statistics of the routes learned from neighbor\n")
9223
9224ALIAS (show_bgp_view_neighbor_flap,
9225 show_bgp_ipv6_neighbor_flap_cmd,
9226 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9227 SHOW_STR
9228 BGP_STR
9229 "Address family\n"
9230 "Detailed information on TCP and BGP neighbor connections\n"
9231 "Neighbor to display information about\n"
9232 "Neighbor to display information about\n"
9233 "Display flap statistics of the routes learned from neighbor\n")
9234
9235ALIAS (show_bgp_view_neighbor_damp,
9236 show_bgp_neighbor_damp_cmd,
9237 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9238 SHOW_STR
9239 BGP_STR
9240 "Detailed information on TCP and BGP neighbor connections\n"
9241 "Neighbor to display information about\n"
9242 "Neighbor to display information about\n"
9243 "Display the dampened routes received from neighbor\n")
9244
9245ALIAS (show_bgp_view_neighbor_damp,
9246 show_bgp_ipv6_neighbor_damp_cmd,
9247 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9248 SHOW_STR
9249 BGP_STR
9250 "Address family\n"
9251 "Detailed information on TCP and BGP neighbor connections\n"
9252 "Neighbor to display information about\n"
9253 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +00009254 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +00009255
9256DEFUN (show_bgp_view_rsclient,
9257 show_bgp_view_rsclient_cmd,
9258 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
9259 SHOW_STR
9260 BGP_STR
9261 "BGP view\n"
9262 "BGP view name\n"
9263 "Information about Route Server Client\n"
9264 NEIGHBOR_ADDR_STR)
9265{
9266 struct bgp_table *table;
9267 struct peer *peer;
9268
9269 if (argc == 2)
9270 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9271 else
9272 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9273
9274 if (! peer)
9275 return CMD_WARNING;
9276
9277 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
9278 {
9279 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9280 VTY_NEWLINE);
9281 return CMD_WARNING;
9282 }
9283
9284 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
9285 PEER_FLAG_RSERVER_CLIENT))
9286 {
9287 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9288 VTY_NEWLINE);
9289 return CMD_WARNING;
9290 }
9291
9292 table = peer->rib[AFI_IP6][SAFI_UNICAST];
9293
ajs5a646652004-11-05 01:25:55 +00009294 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +00009295}
9296
9297ALIAS (show_bgp_view_rsclient,
9298 show_bgp_rsclient_cmd,
9299 "show bgp rsclient (A.B.C.D|X:X::X:X)",
9300 SHOW_STR
9301 BGP_STR
9302 "Information about Route Server Client\n"
9303 NEIGHBOR_ADDR_STR)
9304
9305DEFUN (show_bgp_view_rsclient_route,
9306 show_bgp_view_rsclient_route_cmd,
9307 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
9308 SHOW_STR
9309 BGP_STR
9310 "BGP view\n"
9311 "BGP view name\n"
9312 "Information about Route Server Client\n"
9313 NEIGHBOR_ADDR_STR
9314 "Network in the BGP routing table to display\n")
9315{
9316 struct bgp *bgp;
9317 struct peer *peer;
9318
9319 /* BGP structure lookup. */
9320 if (argc == 3)
9321 {
9322 bgp = bgp_lookup_by_name (argv[0]);
9323 if (bgp == NULL)
9324 {
9325 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
9326 return CMD_WARNING;
9327 }
9328 }
9329 else
9330 {
9331 bgp = bgp_get_default ();
9332 if (bgp == NULL)
9333 {
9334 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9335 return CMD_WARNING;
9336 }
9337 }
9338
9339 if (argc == 3)
9340 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9341 else
9342 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9343
9344 if (! peer)
9345 return CMD_WARNING;
9346
9347 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
9348 {
9349 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9350 VTY_NEWLINE);
9351 return CMD_WARNING;
9352 }
9353
9354 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
9355 PEER_FLAG_RSERVER_CLIENT))
9356 {
9357 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9358 VTY_NEWLINE);
9359 return CMD_WARNING;
9360 }
9361
9362 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
9363 (argc == 3) ? argv[2] : argv[1],
9364 AFI_IP6, SAFI_UNICAST, NULL, 0);
9365}
9366
9367ALIAS (show_bgp_view_rsclient_route,
9368 show_bgp_rsclient_route_cmd,
9369 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
9370 SHOW_STR
9371 BGP_STR
9372 "Information about Route Server Client\n"
9373 NEIGHBOR_ADDR_STR
9374 "Network in the BGP routing table to display\n")
9375
9376DEFUN (show_bgp_view_rsclient_prefix,
9377 show_bgp_view_rsclient_prefix_cmd,
9378 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
9379 SHOW_STR
9380 BGP_STR
9381 "BGP view\n"
9382 "BGP view name\n"
9383 "Information about Route Server Client\n"
9384 NEIGHBOR_ADDR_STR
9385 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
9386{
9387 struct bgp *bgp;
9388 struct peer *peer;
9389
9390 /* BGP structure lookup. */
9391 if (argc == 3)
9392 {
9393 bgp = bgp_lookup_by_name (argv[0]);
9394 if (bgp == NULL)
9395 {
9396 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
9397 return CMD_WARNING;
9398 }
9399 }
9400 else
9401 {
9402 bgp = bgp_get_default ();
9403 if (bgp == NULL)
9404 {
9405 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9406 return CMD_WARNING;
9407 }
9408 }
9409
9410 if (argc == 3)
9411 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9412 else
9413 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9414
9415 if (! peer)
9416 return CMD_WARNING;
9417
9418 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
9419 {
9420 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9421 VTY_NEWLINE);
9422 return CMD_WARNING;
9423 }
9424
9425 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
9426 PEER_FLAG_RSERVER_CLIENT))
9427 {
9428 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9429 VTY_NEWLINE);
9430 return CMD_WARNING;
9431 }
9432
9433 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
9434 (argc == 3) ? argv[2] : argv[1],
9435 AFI_IP6, SAFI_UNICAST, NULL, 1);
9436}
9437
9438ALIAS (show_bgp_view_rsclient_prefix,
9439 show_bgp_rsclient_prefix_cmd,
9440 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
9441 SHOW_STR
9442 BGP_STR
9443 "Information about Route Server Client\n"
9444 NEIGHBOR_ADDR_STR
9445 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
9446
paul718e3742002-12-13 20:15:29 +00009447#endif /* HAVE_IPV6 */
9448
9449struct bgp_table *bgp_distance_table;
9450
9451struct bgp_distance
9452{
9453 /* Distance value for the IP source prefix. */
9454 u_char distance;
9455
9456 /* Name of the access-list to be matched. */
9457 char *access_list;
9458};
9459
9460struct bgp_distance *
9461bgp_distance_new ()
9462{
9463 struct bgp_distance *new;
9464 new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
9465 memset (new, 0, sizeof (struct bgp_distance));
9466 return new;
9467}
9468
9469void
9470bgp_distance_free (struct bgp_distance *bdistance)
9471{
9472 XFREE (MTYPE_BGP_DISTANCE, bdistance);
9473}
9474
9475int
paulfd79ac92004-10-13 05:06:08 +00009476bgp_distance_set (struct vty *vty, const char *distance_str,
9477 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +00009478{
9479 int ret;
9480 struct prefix_ipv4 p;
9481 u_char distance;
9482 struct bgp_node *rn;
9483 struct bgp_distance *bdistance;
9484
9485 ret = str2prefix_ipv4 (ip_str, &p);
9486 if (ret == 0)
9487 {
9488 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
9489 return CMD_WARNING;
9490 }
9491
9492 distance = atoi (distance_str);
9493
9494 /* Get BGP distance node. */
9495 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
9496 if (rn->info)
9497 {
9498 bdistance = rn->info;
9499 bgp_unlock_node (rn);
9500 }
9501 else
9502 {
9503 bdistance = bgp_distance_new ();
9504 rn->info = bdistance;
9505 }
9506
9507 /* Set distance value. */
9508 bdistance->distance = distance;
9509
9510 /* Reset access-list configuration. */
9511 if (bdistance->access_list)
9512 {
9513 free (bdistance->access_list);
9514 bdistance->access_list = NULL;
9515 }
9516 if (access_list_str)
9517 bdistance->access_list = strdup (access_list_str);
9518
9519 return CMD_SUCCESS;
9520}
9521
9522int
paulfd79ac92004-10-13 05:06:08 +00009523bgp_distance_unset (struct vty *vty, const char *distance_str,
9524 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +00009525{
9526 int ret;
9527 struct prefix_ipv4 p;
9528 u_char distance;
9529 struct bgp_node *rn;
9530 struct bgp_distance *bdistance;
9531
9532 ret = str2prefix_ipv4 (ip_str, &p);
9533 if (ret == 0)
9534 {
9535 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
9536 return CMD_WARNING;
9537 }
9538
9539 distance = atoi (distance_str);
9540
9541 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
9542 if (! rn)
9543 {
9544 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
9545 return CMD_WARNING;
9546 }
9547
9548 bdistance = rn->info;
9549
9550 if (bdistance->access_list)
9551 free (bdistance->access_list);
9552 bgp_distance_free (bdistance);
9553
9554 rn->info = NULL;
9555 bgp_unlock_node (rn);
9556 bgp_unlock_node (rn);
9557
9558 return CMD_SUCCESS;
9559}
9560
9561void
9562bgp_distance_reset ()
9563{
9564 struct bgp_node *rn;
9565 struct bgp_distance *bdistance;
9566
9567 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
9568 if ((bdistance = rn->info) != NULL)
9569 {
9570 if (bdistance->access_list)
9571 free (bdistance->access_list);
9572 bgp_distance_free (bdistance);
9573 rn->info = NULL;
9574 bgp_unlock_node (rn);
9575 }
9576}
9577
9578/* Apply BGP information to distance method. */
9579u_char
9580bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
9581{
9582 struct bgp_node *rn;
9583 struct prefix_ipv4 q;
9584 struct peer *peer;
9585 struct bgp_distance *bdistance;
9586 struct access_list *alist;
9587 struct bgp_static *bgp_static;
9588
9589 if (! bgp)
9590 return 0;
9591
9592 if (p->family != AF_INET)
9593 return 0;
9594
9595 peer = rinfo->peer;
9596
9597 if (peer->su.sa.sa_family != AF_INET)
9598 return 0;
9599
9600 memset (&q, 0, sizeof (struct prefix_ipv4));
9601 q.family = AF_INET;
9602 q.prefix = peer->su.sin.sin_addr;
9603 q.prefixlen = IPV4_MAX_BITLEN;
9604
9605 /* Check source address. */
9606 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
9607 if (rn)
9608 {
9609 bdistance = rn->info;
9610 bgp_unlock_node (rn);
9611
9612 if (bdistance->access_list)
9613 {
9614 alist = access_list_lookup (AFI_IP, bdistance->access_list);
9615 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
9616 return bdistance->distance;
9617 }
9618 else
9619 return bdistance->distance;
9620 }
9621
9622 /* Backdoor check. */
9623 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
9624 if (rn)
9625 {
9626 bgp_static = rn->info;
9627 bgp_unlock_node (rn);
9628
9629 if (bgp_static->backdoor)
9630 {
9631 if (bgp->distance_local)
9632 return bgp->distance_local;
9633 else
9634 return ZEBRA_IBGP_DISTANCE_DEFAULT;
9635 }
9636 }
9637
9638 if (peer_sort (peer) == BGP_PEER_EBGP)
9639 {
9640 if (bgp->distance_ebgp)
9641 return bgp->distance_ebgp;
9642 return ZEBRA_EBGP_DISTANCE_DEFAULT;
9643 }
9644 else
9645 {
9646 if (bgp->distance_ibgp)
9647 return bgp->distance_ibgp;
9648 return ZEBRA_IBGP_DISTANCE_DEFAULT;
9649 }
9650}
9651
9652DEFUN (bgp_distance,
9653 bgp_distance_cmd,
9654 "distance bgp <1-255> <1-255> <1-255>",
9655 "Define an administrative distance\n"
9656 "BGP distance\n"
9657 "Distance for routes external to the AS\n"
9658 "Distance for routes internal to the AS\n"
9659 "Distance for local routes\n")
9660{
9661 struct bgp *bgp;
9662
9663 bgp = vty->index;
9664
9665 bgp->distance_ebgp = atoi (argv[0]);
9666 bgp->distance_ibgp = atoi (argv[1]);
9667 bgp->distance_local = atoi (argv[2]);
9668 return CMD_SUCCESS;
9669}
9670
9671DEFUN (no_bgp_distance,
9672 no_bgp_distance_cmd,
9673 "no distance bgp <1-255> <1-255> <1-255>",
9674 NO_STR
9675 "Define an administrative distance\n"
9676 "BGP distance\n"
9677 "Distance for routes external to the AS\n"
9678 "Distance for routes internal to the AS\n"
9679 "Distance for local routes\n")
9680{
9681 struct bgp *bgp;
9682
9683 bgp = vty->index;
9684
9685 bgp->distance_ebgp= 0;
9686 bgp->distance_ibgp = 0;
9687 bgp->distance_local = 0;
9688 return CMD_SUCCESS;
9689}
9690
9691ALIAS (no_bgp_distance,
9692 no_bgp_distance2_cmd,
9693 "no distance bgp",
9694 NO_STR
9695 "Define an administrative distance\n"
9696 "BGP distance\n")
9697
9698DEFUN (bgp_distance_source,
9699 bgp_distance_source_cmd,
9700 "distance <1-255> A.B.C.D/M",
9701 "Define an administrative distance\n"
9702 "Administrative distance\n"
9703 "IP source prefix\n")
9704{
9705 bgp_distance_set (vty, argv[0], argv[1], NULL);
9706 return CMD_SUCCESS;
9707}
9708
9709DEFUN (no_bgp_distance_source,
9710 no_bgp_distance_source_cmd,
9711 "no distance <1-255> A.B.C.D/M",
9712 NO_STR
9713 "Define an administrative distance\n"
9714 "Administrative distance\n"
9715 "IP source prefix\n")
9716{
9717 bgp_distance_unset (vty, argv[0], argv[1], NULL);
9718 return CMD_SUCCESS;
9719}
9720
9721DEFUN (bgp_distance_source_access_list,
9722 bgp_distance_source_access_list_cmd,
9723 "distance <1-255> A.B.C.D/M WORD",
9724 "Define an administrative distance\n"
9725 "Administrative distance\n"
9726 "IP source prefix\n"
9727 "Access list name\n")
9728{
9729 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
9730 return CMD_SUCCESS;
9731}
9732
9733DEFUN (no_bgp_distance_source_access_list,
9734 no_bgp_distance_source_access_list_cmd,
9735 "no distance <1-255> A.B.C.D/M WORD",
9736 NO_STR
9737 "Define an administrative distance\n"
9738 "Administrative distance\n"
9739 "IP source prefix\n"
9740 "Access list name\n")
9741{
9742 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
9743 return CMD_SUCCESS;
9744}
9745
9746DEFUN (bgp_damp_set,
9747 bgp_damp_set_cmd,
9748 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
9749 "BGP Specific commands\n"
9750 "Enable route-flap dampening\n"
9751 "Half-life time for the penalty\n"
9752 "Value to start reusing a route\n"
9753 "Value to start suppressing a route\n"
9754 "Maximum duration to suppress a stable route\n")
9755{
9756 struct bgp *bgp;
9757 int half = DEFAULT_HALF_LIFE * 60;
9758 int reuse = DEFAULT_REUSE;
9759 int suppress = DEFAULT_SUPPRESS;
9760 int max = 4 * half;
9761
9762 if (argc == 4)
9763 {
9764 half = atoi (argv[0]) * 60;
9765 reuse = atoi (argv[1]);
9766 suppress = atoi (argv[2]);
9767 max = atoi (argv[3]) * 60;
9768 }
9769 else if (argc == 1)
9770 {
9771 half = atoi (argv[0]) * 60;
9772 max = 4 * half;
9773 }
9774
9775 bgp = vty->index;
9776 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
9777 half, reuse, suppress, max);
9778}
9779
9780ALIAS (bgp_damp_set,
9781 bgp_damp_set2_cmd,
9782 "bgp dampening <1-45>",
9783 "BGP Specific commands\n"
9784 "Enable route-flap dampening\n"
9785 "Half-life time for the penalty\n")
9786
9787ALIAS (bgp_damp_set,
9788 bgp_damp_set3_cmd,
9789 "bgp dampening",
9790 "BGP Specific commands\n"
9791 "Enable route-flap dampening\n")
9792
9793DEFUN (bgp_damp_unset,
9794 bgp_damp_unset_cmd,
9795 "no bgp dampening",
9796 NO_STR
9797 "BGP Specific commands\n"
9798 "Enable route-flap dampening\n")
9799{
9800 struct bgp *bgp;
9801
9802 bgp = vty->index;
9803 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
9804}
9805
9806ALIAS (bgp_damp_unset,
9807 bgp_damp_unset2_cmd,
9808 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
9809 NO_STR
9810 "BGP Specific commands\n"
9811 "Enable route-flap dampening\n"
9812 "Half-life time for the penalty\n"
9813 "Value to start reusing a route\n"
9814 "Value to start suppressing a route\n"
9815 "Maximum duration to suppress a stable route\n")
9816
9817DEFUN (show_ip_bgp_dampened_paths,
9818 show_ip_bgp_dampened_paths_cmd,
9819 "show ip bgp dampened-paths",
9820 SHOW_STR
9821 IP_STR
9822 BGP_STR
9823 "Display paths suppressed due to dampening\n")
9824{
ajs5a646652004-11-05 01:25:55 +00009825 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
9826 NULL);
paul718e3742002-12-13 20:15:29 +00009827}
9828
9829DEFUN (show_ip_bgp_flap_statistics,
9830 show_ip_bgp_flap_statistics_cmd,
9831 "show ip bgp flap-statistics",
9832 SHOW_STR
9833 IP_STR
9834 BGP_STR
9835 "Display flap statistics of routes\n")
9836{
ajs5a646652004-11-05 01:25:55 +00009837 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9838 bgp_show_type_flap_statistics, NULL);
paul718e3742002-12-13 20:15:29 +00009839}
9840
9841/* Display specified route of BGP table. */
9842int
paulfd79ac92004-10-13 05:06:08 +00009843bgp_clear_damp_route (struct vty *vty, const char *view_name,
9844 const char *ip_str, afi_t afi, safi_t safi,
9845 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +00009846{
9847 int ret;
9848 struct prefix match;
9849 struct bgp_node *rn;
9850 struct bgp_node *rm;
9851 struct bgp_info *ri;
9852 struct bgp_info *ri_temp;
9853 struct bgp *bgp;
9854 struct bgp_table *table;
9855
9856 /* BGP structure lookup. */
9857 if (view_name)
9858 {
9859 bgp = bgp_lookup_by_name (view_name);
9860 if (bgp == NULL)
9861 {
9862 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9863 return CMD_WARNING;
9864 }
9865 }
9866 else
9867 {
9868 bgp = bgp_get_default ();
9869 if (bgp == NULL)
9870 {
9871 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
9872 return CMD_WARNING;
9873 }
9874 }
9875
9876 /* Check IP address argument. */
9877 ret = str2prefix (ip_str, &match);
9878 if (! ret)
9879 {
9880 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
9881 return CMD_WARNING;
9882 }
9883
9884 match.family = afi2family (afi);
9885
9886 if (safi == SAFI_MPLS_VPN)
9887 {
9888 for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn))
9889 {
9890 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
9891 continue;
9892
9893 if ((table = rn->info) != NULL)
9894 if ((rm = bgp_node_match (table, &match)) != NULL)
9895 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
9896 {
9897 ri = rm->info;
9898 while (ri)
9899 {
9900 if (ri->damp_info)
9901 {
9902 ri_temp = ri->next;
9903 bgp_damp_info_free (ri->damp_info, 1);
9904 ri = ri_temp;
9905 }
9906 else
9907 ri = ri->next;
9908 }
9909 }
9910 }
9911 }
9912 else
9913 {
9914 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
9915 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
9916 {
9917 ri = rn->info;
9918 while (ri)
9919 {
9920 if (ri->damp_info)
9921 {
9922 ri_temp = ri->next;
9923 bgp_damp_info_free (ri->damp_info, 1);
9924 ri = ri_temp;
9925 }
9926 else
9927 ri = ri->next;
9928 }
9929 }
9930 }
9931
9932 return CMD_SUCCESS;
9933}
9934
9935DEFUN (clear_ip_bgp_dampening,
9936 clear_ip_bgp_dampening_cmd,
9937 "clear ip bgp dampening",
9938 CLEAR_STR
9939 IP_STR
9940 BGP_STR
9941 "Clear route flap dampening information\n")
9942{
9943 bgp_damp_info_clean ();
9944 return CMD_SUCCESS;
9945}
9946
9947DEFUN (clear_ip_bgp_dampening_prefix,
9948 clear_ip_bgp_dampening_prefix_cmd,
9949 "clear ip bgp dampening A.B.C.D/M",
9950 CLEAR_STR
9951 IP_STR
9952 BGP_STR
9953 "Clear route flap dampening information\n"
9954 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9955{
9956 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
9957 SAFI_UNICAST, NULL, 1);
9958}
9959
9960DEFUN (clear_ip_bgp_dampening_address,
9961 clear_ip_bgp_dampening_address_cmd,
9962 "clear ip bgp dampening A.B.C.D",
9963 CLEAR_STR
9964 IP_STR
9965 BGP_STR
9966 "Clear route flap dampening information\n"
9967 "Network to clear damping information\n")
9968{
9969 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
9970 SAFI_UNICAST, NULL, 0);
9971}
9972
9973DEFUN (clear_ip_bgp_dampening_address_mask,
9974 clear_ip_bgp_dampening_address_mask_cmd,
9975 "clear ip bgp dampening A.B.C.D A.B.C.D",
9976 CLEAR_STR
9977 IP_STR
9978 BGP_STR
9979 "Clear route flap dampening information\n"
9980 "Network to clear damping information\n"
9981 "Network mask\n")
9982{
9983 int ret;
9984 char prefix_str[BUFSIZ];
9985
9986 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
9987 if (! ret)
9988 {
9989 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
9990 return CMD_WARNING;
9991 }
9992
9993 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
9994 SAFI_UNICAST, NULL, 0);
9995}
9996
9997int
9998bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
9999 afi_t afi, safi_t safi, int *write)
10000{
10001 struct bgp_node *prn;
10002 struct bgp_node *rn;
10003 struct bgp_table *table;
10004 struct prefix *p;
10005 struct prefix_rd *prd;
10006 struct bgp_static *bgp_static;
10007 u_int32_t label;
10008 char buf[SU_ADDRSTRLEN];
10009 char rdbuf[RD_ADDRSTRLEN];
10010
10011 /* Network configuration. */
10012 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
10013 if ((table = prn->info) != NULL)
10014 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
10015 if ((bgp_static = rn->info) != NULL)
10016 {
10017 p = &rn->p;
10018 prd = (struct prefix_rd *) &prn->p;
10019
10020 /* "address-family" display. */
10021 bgp_config_write_family_header (vty, afi, safi, write);
10022
10023 /* "network" configuration display. */
10024 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
10025 label = decode_label (bgp_static->tag);
10026
10027 vty_out (vty, " network %s/%d rd %s tag %d",
10028 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10029 p->prefixlen,
10030 rdbuf, label);
10031 vty_out (vty, "%s", VTY_NEWLINE);
10032 }
10033 return 0;
10034}
10035
10036/* Configuration of static route announcement and aggregate
10037 information. */
10038int
10039bgp_config_write_network (struct vty *vty, struct bgp *bgp,
10040 afi_t afi, safi_t safi, int *write)
10041{
10042 struct bgp_node *rn;
10043 struct prefix *p;
10044 struct bgp_static *bgp_static;
10045 struct bgp_aggregate *bgp_aggregate;
10046 char buf[SU_ADDRSTRLEN];
10047
10048 if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
10049 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
10050
10051 /* Network configuration. */
10052 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
10053 if ((bgp_static = rn->info) != NULL)
10054 {
10055 p = &rn->p;
10056
10057 /* "address-family" display. */
10058 bgp_config_write_family_header (vty, afi, safi, write);
10059
10060 /* "network" configuration display. */
10061 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
10062 {
10063 u_int32_t destination;
10064 struct in_addr netmask;
10065
10066 destination = ntohl (p->u.prefix4.s_addr);
10067 masklen2ip (p->prefixlen, &netmask);
10068 vty_out (vty, " network %s",
10069 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
10070
10071 if ((IN_CLASSC (destination) && p->prefixlen == 24)
10072 || (IN_CLASSB (destination) && p->prefixlen == 16)
10073 || (IN_CLASSA (destination) && p->prefixlen == 8)
10074 || p->u.prefix4.s_addr == 0)
10075 {
10076 /* Natural mask is not display. */
10077 }
10078 else
10079 vty_out (vty, " mask %s", inet_ntoa (netmask));
10080 }
10081 else
10082 {
10083 vty_out (vty, " network %s/%d",
10084 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10085 p->prefixlen);
10086 }
10087
10088 if (bgp_static->rmap.name)
10089 vty_out (vty, " route-map %s", bgp_static->rmap.name);
10090 else if (bgp_static->backdoor)
10091 vty_out (vty, " backdoor");
10092
10093 vty_out (vty, "%s", VTY_NEWLINE);
10094 }
10095
10096 /* Aggregate-address configuration. */
10097 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
10098 if ((bgp_aggregate = rn->info) != NULL)
10099 {
10100 p = &rn->p;
10101
10102 /* "address-family" display. */
10103 bgp_config_write_family_header (vty, afi, safi, write);
10104
10105 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
10106 {
10107 struct in_addr netmask;
10108
10109 masklen2ip (p->prefixlen, &netmask);
10110 vty_out (vty, " aggregate-address %s %s",
10111 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10112 inet_ntoa (netmask));
10113 }
10114 else
10115 {
10116 vty_out (vty, " aggregate-address %s/%d",
10117 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10118 p->prefixlen);
10119 }
10120
10121 if (bgp_aggregate->as_set)
10122 vty_out (vty, " as-set");
10123
10124 if (bgp_aggregate->summary_only)
10125 vty_out (vty, " summary-only");
10126
10127 vty_out (vty, "%s", VTY_NEWLINE);
10128 }
10129
10130 return 0;
10131}
10132
10133int
10134bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
10135{
10136 struct bgp_node *rn;
10137 struct bgp_distance *bdistance;
10138
10139 /* Distance configuration. */
10140 if (bgp->distance_ebgp
10141 && bgp->distance_ibgp
10142 && bgp->distance_local
10143 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
10144 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
10145 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
10146 vty_out (vty, " distance bgp %d %d %d%s",
10147 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
10148 VTY_NEWLINE);
10149
10150 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
10151 if ((bdistance = rn->info) != NULL)
10152 {
10153 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
10154 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
10155 bdistance->access_list ? bdistance->access_list : "",
10156 VTY_NEWLINE);
10157 }
10158
10159 return 0;
10160}
10161
10162/* Allocate routing table structure and install commands. */
10163void
10164bgp_route_init ()
10165{
10166 /* Init BGP distance table. */
10167 bgp_distance_table = bgp_table_init ();
10168
10169 /* IPv4 BGP commands. */
10170 install_element (BGP_NODE, &bgp_network_cmd);
10171 install_element (BGP_NODE, &bgp_network_mask_cmd);
10172 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
10173 install_element (BGP_NODE, &bgp_network_route_map_cmd);
10174 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
10175 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
10176 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
10177 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
10178 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
10179 install_element (BGP_NODE, &no_bgp_network_cmd);
10180 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
10181 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
10182 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
10183 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
10184 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
10185 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
10186 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
10187 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
10188
10189 install_element (BGP_NODE, &aggregate_address_cmd);
10190 install_element (BGP_NODE, &aggregate_address_mask_cmd);
10191 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
10192 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
10193 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
10194 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
10195 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
10196 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
10197 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
10198 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
10199 install_element (BGP_NODE, &no_aggregate_address_cmd);
10200 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
10201 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
10202 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
10203 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
10204 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
10205 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
10206 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
10207 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
10208 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
10209
10210 /* IPv4 unicast configuration. */
10211 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
10212 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
10213 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
10214 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
10215 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
10216 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
10217 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
10218 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
10219 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
10220 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
10221 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
10222 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
10223 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
10224 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
10225 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
10226 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
10227 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
10228 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
10229 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
10230 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
10231 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
10232 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
10233 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
10234 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
10235 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
10236 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
10237 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
10238 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
10239 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
10240 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
10241 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
10242 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
10243
10244 /* IPv4 multicast configuration. */
10245 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
10246 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
10247 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
10248 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
10249 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
10250 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
10251 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
10252 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
10253 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
10254 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
10255 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
10256 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
10257 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
10258 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
10259 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
10260 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
10261 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
10262 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
10263 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
10264 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
10265 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
10266 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
10267 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
10268 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
10269 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
10270 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
10271 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
10272 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
10273 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
10274 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
10275 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
10276 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
10277
10278 install_element (VIEW_NODE, &show_ip_bgp_cmd);
10279 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
10280 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
10281 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
10282 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
10283 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
10284 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
10285 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
10286 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
10287 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
10288 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
10289 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
10290 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
10291 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
10292 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
10293 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
10294 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
10295 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
10296 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
10297 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
10298 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
10299 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
10300 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
10301 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
10302 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
10303 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
10304 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
10305 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
10306 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
10307 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
10308 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
10309 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
10310 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
10311 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
10312 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
10313 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
10314 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
10315 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
10316 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
10317 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
10318 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
10319 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
10320 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
10321 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
10322 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
10323 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
10324 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
10325 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
10326 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
10327 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
10328 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
10329 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
10330 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
10331 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
10332 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
10333 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
10334 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
10335 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
10336 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
10337 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
10338 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
10339 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
10340 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
10341 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
10342 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
10343 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
10344 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010345 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
10346 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
10347 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
10348 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
10349 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
10350 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010351
10352 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
10353 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
10354 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
10355 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
10356 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
10357 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
10358 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
10359 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
10360 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
10361 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
10362 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
10363 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
10364 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
10365 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
10366 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
10367 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
10368 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
10369 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
10370 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
10371 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
10372 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
10373 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
10374 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
10375 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
10376 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
10377 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
10378 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
10379 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
10380 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
10381 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
10382 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
10383 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
10384 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
10385 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
10386 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
10387 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
10388 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
10389 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
10390 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
10391 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
10392 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
10393 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
10394 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
10395 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
10396 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
10397 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
10398 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
10399 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
10400 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
10401 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
10402 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
10403 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
10404 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
10405 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
10406 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
10407 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
10408 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
10409 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
10410 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
10411 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
10412 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
10413 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
10414 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
10415 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
10416 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
10417 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
10418 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010419 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
10420 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
10421 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
10422 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
10423 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
10424 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010425
10426 /* BGP dampening clear commands */
10427 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
10428 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
10429 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
10430 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
10431
10432#ifdef HAVE_IPV6
10433 /* New config IPv6 BGP commands. */
10434 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
10435 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
10436 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
10437 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
10438
10439 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
10440 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
10441 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
10442 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
10443
10444 /* Old config IPv6 BGP commands. */
10445 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
10446 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
10447
10448 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
10449 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
10450 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
10451 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
10452
10453 install_element (VIEW_NODE, &show_bgp_cmd);
10454 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
10455 install_element (VIEW_NODE, &show_bgp_route_cmd);
10456 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
10457 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
10458 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
10459 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
10460 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
10461 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
10462 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
10463 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
10464 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
10465 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
10466 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
10467 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
10468 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
10469 install_element (VIEW_NODE, &show_bgp_community_cmd);
10470 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
10471 install_element (VIEW_NODE, &show_bgp_community2_cmd);
10472 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
10473 install_element (VIEW_NODE, &show_bgp_community3_cmd);
10474 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
10475 install_element (VIEW_NODE, &show_bgp_community4_cmd);
10476 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
10477 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
10478 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
10479 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
10480 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
10481 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
10482 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
10483 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
10484 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
10485 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
10486 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
10487 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
10488 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
10489 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
10490 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
10491 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
10492 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
10493 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
10494 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
10495 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
10496 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
10497 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
10498 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000010499 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
10500 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
10501 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
10502 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010503 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
10504 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
10505 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000010506 install_element (VIEW_NODE, &show_bgp_view_cmd);
10507 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
10508 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
10509 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
10510 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
10511 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
10512 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
10513 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
10514 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
10515 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
10516 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
10517 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
10518 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
10519 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
10520 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
10521 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
10522 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
10523 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010524 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
10525 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
10526 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010527
10528 install_element (ENABLE_NODE, &show_bgp_cmd);
10529 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
10530 install_element (ENABLE_NODE, &show_bgp_route_cmd);
10531 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
10532 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
10533 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
10534 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
10535 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
10536 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
10537 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
10538 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
10539 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
10540 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
10541 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
10542 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
10543 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
10544 install_element (ENABLE_NODE, &show_bgp_community_cmd);
10545 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
10546 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
10547 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
10548 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
10549 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
10550 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
10551 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
10552 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
10553 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
10554 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
10555 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
10556 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
10557 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
10558 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
10559 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
10560 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
10561 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
10562 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
10563 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
10564 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
10565 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
10566 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
10567 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
10568 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
10569 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
10570 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
10571 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
10572 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
10573 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000010574 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
10575 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
10576 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
10577 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010578 install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
10579 install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
10580 install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000010581 install_element (ENABLE_NODE, &show_bgp_view_cmd);
10582 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
10583 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
10584 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
10585 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
10586 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
10587 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
10588 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
10589 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
10590 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
10591 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
10592 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
10593 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
10594 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
10595 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
10596 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
10597 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
10598 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010599 install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
10600 install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
10601 install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010602
10603 /* old command */
10604 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
10605 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
10606 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
10607 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
10608 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
10609 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
10610 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
10611 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
10612 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
10613 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
10614 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
10615 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
10616 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
10617 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
10618 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
10619 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
10620 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
10621 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
10622 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
10623 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
10624 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
10625 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
10626 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
10627 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
10628 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
10629 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
10630 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
10631 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
10632 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
10633 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
10634 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
10635 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
10636 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
10637 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
10638 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
10639 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
paulbb46e942003-10-24 19:02:03 +000010640
paul718e3742002-12-13 20:15:29 +000010641 /* old command */
10642 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
10643 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
10644 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
10645 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
10646 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
10647 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
10648 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
10649 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
10650 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
10651 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
10652 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
10653 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
10654 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
10655 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
10656 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
10657 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
10658 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
10659 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
10660 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
10661 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
10662 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
10663 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
10664 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
10665 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
10666 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
10667 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
10668 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
10669 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
10670 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
10671 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
10672 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
10673 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
10674 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
10675 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
10676 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
10677 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
10678
10679 /* old command */
10680 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
10681 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
10682 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
10683 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
10684
10685 /* old command */
10686 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
10687 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
10688 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
10689 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
10690
10691 /* old command */
10692 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
10693 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
10694 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
10695 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
10696#endif /* HAVE_IPV6 */
10697
10698 install_element (BGP_NODE, &bgp_distance_cmd);
10699 install_element (BGP_NODE, &no_bgp_distance_cmd);
10700 install_element (BGP_NODE, &no_bgp_distance2_cmd);
10701 install_element (BGP_NODE, &bgp_distance_source_cmd);
10702 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
10703 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
10704 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
10705
10706 install_element (BGP_NODE, &bgp_damp_set_cmd);
10707 install_element (BGP_NODE, &bgp_damp_set2_cmd);
10708 install_element (BGP_NODE, &bgp_damp_set3_cmd);
10709 install_element (BGP_NODE, &bgp_damp_unset_cmd);
10710 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
10711 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
10712 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
10713 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
10714 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
10715 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
10716}