blob: 8c8fa528f3f8a9fb42dcaf3f8858017439b47632 [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
2273 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2274 {
2275 for (ri = rn->info; ri; ri = ri->next)
2276 if (ri->peer == peer)
2277 {
hasso93406d82005-02-02 14:40:33 +00002278 /* graceful restart STALE flag set. */
2279 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2280 && peer->nsf[afi][safi]
2281 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
2282 && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)
2283 && ! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
2284 {
2285 SET_FLAG (ri->flags, BGP_INFO_STALE);
2286 peer->pcount[afi][safi]--;
2287 }
2288 else
2289 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002290 break;
2291 }
2292 for (ain = rn->adj_in; ain; ain = ain->next)
2293 if (ain->peer == peer)
2294 {
2295 bgp_adj_in_remove (rn, ain);
2296 bgp_unlock_node (rn);
2297 break;
2298 }
2299 for (aout = rn->adj_out; aout; aout = aout->next)
2300 if (aout->peer == peer)
2301 {
2302 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2303 bgp_unlock_node (rn);
2304 break;
2305 }
2306 }
2307}
2308
2309void
2310bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi)
2311{
2312 struct bgp_node *rn;
2313 struct bgp_table *table;
paulfee0f4c2004-09-13 05:12:46 +00002314 struct peer *rsclient;
2315 struct listnode *nn;
paul718e3742002-12-13 20:15:29 +00002316
paul718e3742002-12-13 20:15:29 +00002317 if (safi != SAFI_MPLS_VPN)
paulfee0f4c2004-09-13 05:12:46 +00002318 bgp_clear_route_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002319 else
2320 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2321 rn = bgp_route_next (rn))
2322 if ((table = rn->info) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002323 bgp_clear_route_table (peer, afi, safi, table, NULL);
2324
2325 LIST_LOOP (peer->bgp->rsclient, rsclient, nn)
2326 {
2327 if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2328 bgp_clear_route_table (peer, afi, safi, NULL, rsclient);
2329 }
paul718e3742002-12-13 20:15:29 +00002330}
2331
2332void
2333bgp_clear_route_all (struct peer *peer)
2334{
2335 afi_t afi;
2336 safi_t safi;
2337
2338 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2339 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2340 bgp_clear_route (peer, afi, safi);
2341}
2342
2343void
2344bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
2345{
2346 struct bgp_table *table;
2347 struct bgp_node *rn;
2348 struct bgp_adj_in *ain;
2349
2350 table = peer->bgp->rib[afi][safi];
2351
2352 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2353 for (ain = rn->adj_in; ain ; ain = ain->next)
2354 if (ain->peer == peer)
2355 {
2356 bgp_adj_in_remove (rn, ain);
2357 bgp_unlock_node (rn);
2358 break;
2359 }
2360}
hasso93406d82005-02-02 14:40:33 +00002361
2362void
2363bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
2364{
2365 struct bgp_node *rn;
2366 struct bgp_info *ri;
2367 struct bgp_table *table;
2368
2369 table = peer->bgp->rib[afi][safi];
2370
2371 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2372 {
2373 for (ri = rn->info; ri; ri = ri->next)
2374 if (ri->peer == peer)
2375 {
2376 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2377 bgp_rib_remove (rn, ri, peer, afi, safi);
2378 break;
2379 }
2380 }
2381}
paul718e3742002-12-13 20:15:29 +00002382
2383/* Delete all kernel routes. */
2384void
paul545acaf2004-04-20 15:13:15 +00002385bgp_cleanup_routes ()
paul718e3742002-12-13 20:15:29 +00002386{
2387 struct bgp *bgp;
2388 struct listnode *nn;
2389 struct bgp_node *rn;
2390 struct bgp_table *table;
2391 struct bgp_info *ri;
2392
2393 LIST_LOOP (bm->bgp, bgp, nn)
2394 {
2395 table = bgp->rib[AFI_IP][SAFI_UNICAST];
2396
2397 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2398 for (ri = rn->info; ri; ri = ri->next)
2399 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
2400 && ri->type == ZEBRA_ROUTE_BGP
2401 && ri->sub_type == BGP_ROUTE_NORMAL)
2402 bgp_zebra_withdraw (&rn->p, ri);
2403
2404 table = bgp->rib[AFI_IP6][SAFI_UNICAST];
2405
2406 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2407 for (ri = rn->info; ri; ri = ri->next)
2408 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
2409 && ri->type == ZEBRA_ROUTE_BGP
2410 && ri->sub_type == BGP_ROUTE_NORMAL)
2411 bgp_zebra_withdraw (&rn->p, ri);
2412 }
2413}
2414
2415void
2416bgp_reset ()
2417{
2418 vty_reset ();
2419 bgp_zclient_reset ();
2420 access_list_reset ();
2421 prefix_list_reset ();
2422}
2423
2424/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2425 value. */
2426int
2427bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
2428{
2429 u_char *pnt;
2430 u_char *lim;
2431 struct prefix p;
2432 int psize;
2433 int ret;
2434
2435 /* Check peer status. */
2436 if (peer->status != Established)
2437 return 0;
2438
2439 pnt = packet->nlri;
2440 lim = pnt + packet->length;
2441
2442 for (; pnt < lim; pnt += psize)
2443 {
2444 /* Clear prefix structure. */
2445 memset (&p, 0, sizeof (struct prefix));
2446
2447 /* Fetch prefix length. */
2448 p.prefixlen = *pnt++;
2449 p.family = afi2family (packet->afi);
2450
2451 /* Already checked in nlri_sanity_check(). We do double check
2452 here. */
2453 if ((packet->afi == AFI_IP && p.prefixlen > 32)
2454 || (packet->afi == AFI_IP6 && p.prefixlen > 128))
2455 return -1;
2456
2457 /* Packet size overflow check. */
2458 psize = PSIZE (p.prefixlen);
2459
2460 /* When packet overflow occur return immediately. */
2461 if (pnt + psize > lim)
2462 return -1;
2463
2464 /* Fetch prefix from NLRI packet. */
2465 memcpy (&p.u.prefix, pnt, psize);
2466
2467 /* Check address. */
2468 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
2469 {
2470 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
2471 {
paulf5ba3872004-07-09 12:11:31 +00002472 /*
2473 * From draft-ietf-idr-bgp4-22, Section 6.3:
2474 * If a BGP router receives an UPDATE message with a
2475 * semantically incorrect NLRI field, in which a prefix is
2476 * semantically incorrect (eg. an unexpected multicast IP
2477 * address), it should ignore the prefix.
2478 */
paul718e3742002-12-13 20:15:29 +00002479 zlog (peer->log, LOG_ERR,
2480 "IPv4 unicast NLRI is multicast address %s",
2481 inet_ntoa (p.u.prefix4));
paulf5ba3872004-07-09 12:11:31 +00002482
paul718e3742002-12-13 20:15:29 +00002483 return -1;
2484 }
2485 }
2486
2487#ifdef HAVE_IPV6
2488 /* Check address. */
2489 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
2490 {
2491 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
2492 {
2493 char buf[BUFSIZ];
2494
2495 zlog (peer->log, LOG_WARNING,
2496 "IPv6 link-local NLRI received %s ignore this NLRI",
2497 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
2498
2499 continue;
2500 }
2501 }
2502#endif /* HAVE_IPV6 */
2503
2504 /* Normal process. */
2505 if (attr)
2506 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
2507 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
2508 else
2509 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
2510 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
2511
2512 /* Address family configuration mismatch or maximum-prefix count
2513 overflow. */
2514 if (ret < 0)
2515 return -1;
2516 }
2517
2518 /* Packet length consistency check. */
2519 if (pnt != lim)
2520 return -1;
2521
2522 return 0;
2523}
2524
2525/* NLRI encode syntax check routine. */
2526int
2527bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt,
2528 bgp_size_t length)
2529{
2530 u_char *end;
2531 u_char prefixlen;
2532 int psize;
2533
2534 end = pnt + length;
2535
2536 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
2537 syntactic validity. If the field is syntactically incorrect,
2538 then the Error Subcode is set to Invalid Network Field. */
2539
2540 while (pnt < end)
2541 {
2542 prefixlen = *pnt++;
2543
2544 /* Prefix length check. */
2545 if ((afi == AFI_IP && prefixlen > 32)
2546 || (afi == AFI_IP6 && prefixlen > 128))
2547 {
2548 plog_err (peer->log,
2549 "%s [Error] Update packet error (wrong prefix length %d)",
2550 peer->host, prefixlen);
2551 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
2552 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
2553 return -1;
2554 }
2555
2556 /* Packet size overflow check. */
2557 psize = PSIZE (prefixlen);
2558
2559 if (pnt + psize > end)
2560 {
2561 plog_err (peer->log,
2562 "%s [Error] Update packet error"
2563 " (prefix data overflow prefix size is %d)",
2564 peer->host, psize);
2565 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
2566 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
2567 return -1;
2568 }
2569
2570 pnt += psize;
2571 }
2572
2573 /* Packet length consistency check. */
2574 if (pnt != end)
2575 {
2576 plog_err (peer->log,
2577 "%s [Error] Update packet error"
2578 " (prefix length mismatch with total length)",
2579 peer->host);
2580 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
2581 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
2582 return -1;
2583 }
2584 return 0;
2585}
2586
2587struct bgp_static *
2588bgp_static_new ()
2589{
2590 struct bgp_static *new;
2591 new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
2592 memset (new, 0, sizeof (struct bgp_static));
2593 return new;
2594}
2595
2596void
2597bgp_static_free (struct bgp_static *bgp_static)
2598{
2599 if (bgp_static->rmap.name)
2600 free (bgp_static->rmap.name);
2601 XFREE (MTYPE_BGP_STATIC, bgp_static);
2602}
2603
2604void
paulfee0f4c2004-09-13 05:12:46 +00002605bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
2606 struct prefix *p, afi_t afi, safi_t safi)
2607{
2608 struct bgp_node *rn;
2609 struct bgp_info *ri;
2610
2611 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
2612
2613 /* Check selected route and self inserted route. */
2614 for (ri = rn->info; ri; ri = ri->next)
2615 if (ri->peer == bgp->peer_self
2616 && ri->type == ZEBRA_ROUTE_BGP
2617 && ri->sub_type == BGP_ROUTE_STATIC)
2618 break;
2619
2620 /* Withdraw static BGP route from routing table. */
2621 if (ri)
2622 {
2623 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
2624 bgp_process (bgp, rn, afi, safi);
2625 bgp_info_delete (rn, ri);
2626 bgp_info_free (ri);
2627 bgp_unlock_node (rn);
2628 }
2629
2630 /* Unlock bgp_node_lookup. */
2631 bgp_unlock_node (rn);
2632}
2633
2634void
2635bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
2636 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
2637{
2638 struct bgp_node *rn;
2639 struct bgp_info *ri;
2640 struct bgp_info *new;
2641 struct bgp_info info;
2642 struct attr new_attr;
2643 struct attr *attr_new;
2644 struct attr attr;
2645 struct bgp *bgp;
2646 int ret;
2647 char buf[SU_ADDRSTRLEN];
2648
2649 bgp = rsclient->bgp;
2650
2651 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
2652
2653 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2654 if (bgp_static)
2655 {
2656 attr.nexthop = bgp_static->igpnexthop;
2657 attr.med = bgp_static->igpmetric;
2658 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
2659 }
2660
2661 new_attr = attr;
2662
2663 /* Apply network route-map for export to this rsclient. */
2664 if (bgp_static->rmap.name)
2665 {
2666 info.peer = rsclient;
2667 info.attr = &new_attr;
2668
2669 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
2670 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
2671
2672 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
2673
2674 rsclient->rmap_type = 0;
2675
2676 if (ret == RMAP_DENYMATCH)
2677 {
2678 /* Free uninterned attribute. */
2679 bgp_attr_flush (&new_attr);
2680
2681 /* Unintern original. */
2682 aspath_unintern (attr.aspath);
2683 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
2684
2685 return;
2686 }
2687 attr_new = bgp_attr_intern (&new_attr);
2688 }
2689 else
2690 attr_new = bgp_attr_intern (&attr);
2691
2692 new_attr = *attr_new;
2693
2694 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
2695
2696 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY)
2697{
2698 /* This BGP update is filtered. Log the reason then update BGP entry. */
2699 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002700 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002701 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
2702 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2703 p->prefixlen, rsclient->host);
2704
2705 bgp->peer_self->rmap_type = 0;
2706
2707 bgp_attr_unintern (attr_new);
2708 aspath_unintern (attr.aspath);
2709
2710 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
2711
2712 return;
2713 }
2714
2715 bgp->peer_self->rmap_type = 0;
2716
2717 bgp_attr_unintern (attr_new);
2718 attr_new = bgp_attr_intern (&new_attr);
2719
2720 for (ri = rn->info; ri; ri = ri->next)
2721 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
2722 && ri->sub_type == BGP_ROUTE_STATIC)
2723 break;
2724
2725 if (ri)
2726 {
2727 if (attrhash_cmp (ri->attr, attr_new))
2728 {
2729 bgp_unlock_node (rn);
2730 bgp_attr_unintern (attr_new);
2731 aspath_unintern (attr.aspath);
2732 return;
2733 }
2734 else
2735 {
2736 /* The attribute is changed. */
2737 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
2738
2739 /* Rewrite BGP route information. */
2740 bgp_attr_unintern (ri->attr);
2741 ri->attr = attr_new;
2742 ri->uptime = time (NULL);
2743
2744 /* Process change. */
2745 bgp_process (bgp, rn, afi, safi);
2746 bgp_unlock_node (rn);
2747 aspath_unintern (attr.aspath);
2748 return;
2749 }
2750}
2751
2752 /* Make new BGP info. */
2753 new = bgp_info_new ();
2754 new->type = ZEBRA_ROUTE_BGP;
2755 new->sub_type = BGP_ROUTE_STATIC;
2756 new->peer = bgp->peer_self;
2757 SET_FLAG (new->flags, BGP_INFO_VALID);
2758 new->attr = attr_new;
2759 new->uptime = time (NULL);
2760
2761 /* Register new BGP information. */
2762 bgp_info_add (rn, new);
2763
2764 /* Process change. */
2765 bgp_process (bgp, rn, afi, safi);
2766
2767 /* Unintern original. */
2768 aspath_unintern (attr.aspath);
2769}
2770
2771void
2772bgp_static_update_main (struct bgp *bgp, struct prefix *p,
paul718e3742002-12-13 20:15:29 +00002773 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
2774{
2775 struct bgp_node *rn;
2776 struct bgp_info *ri;
2777 struct bgp_info *new;
2778 struct bgp_info info;
2779 struct attr attr;
paul286e1e72003-08-08 00:24:31 +00002780 struct attr attr_tmp;
paul718e3742002-12-13 20:15:29 +00002781 struct attr *attr_new;
2782 int ret;
2783
paulfee0f4c2004-09-13 05:12:46 +00002784 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00002785
2786 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2787 if (bgp_static)
2788 {
2789 attr.nexthop = bgp_static->igpnexthop;
2790 attr.med = bgp_static->igpmetric;
2791 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
2792 }
2793
2794 /* Apply route-map. */
2795 if (bgp_static->rmap.name)
2796 {
paul286e1e72003-08-08 00:24:31 +00002797 attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00002798 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00002799 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00002800
paulfee0f4c2004-09-13 05:12:46 +00002801 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
2802
paul718e3742002-12-13 20:15:29 +00002803 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00002804
paulfee0f4c2004-09-13 05:12:46 +00002805 bgp->peer_self->rmap_type = 0;
2806
paul718e3742002-12-13 20:15:29 +00002807 if (ret == RMAP_DENYMATCH)
2808 {
2809 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00002810 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00002811
2812 /* Unintern original. */
2813 aspath_unintern (attr.aspath);
2814 bgp_static_withdraw (bgp, p, afi, safi);
2815 return;
2816 }
paul286e1e72003-08-08 00:24:31 +00002817 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00002818 }
paul286e1e72003-08-08 00:24:31 +00002819 else
2820 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00002821
2822 for (ri = rn->info; ri; ri = ri->next)
2823 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
2824 && ri->sub_type == BGP_ROUTE_STATIC)
2825 break;
2826
2827 if (ri)
2828 {
2829 if (attrhash_cmp (ri->attr, attr_new))
2830 {
2831 bgp_unlock_node (rn);
2832 bgp_attr_unintern (attr_new);
2833 aspath_unintern (attr.aspath);
2834 return;
2835 }
2836 else
2837 {
2838 /* The attribute is changed. */
2839 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
2840
2841 /* Rewrite BGP route information. */
2842 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2843 bgp_attr_unintern (ri->attr);
2844 ri->attr = attr_new;
2845 ri->uptime = time (NULL);
2846
2847 /* Process change. */
2848 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2849 bgp_process (bgp, rn, afi, safi);
2850 bgp_unlock_node (rn);
2851 aspath_unintern (attr.aspath);
2852 return;
2853 }
2854 }
2855
2856 /* Make new BGP info. */
2857 new = bgp_info_new ();
2858 new->type = ZEBRA_ROUTE_BGP;
2859 new->sub_type = BGP_ROUTE_STATIC;
2860 new->peer = bgp->peer_self;
2861 SET_FLAG (new->flags, BGP_INFO_VALID);
2862 new->attr = attr_new;
2863 new->uptime = time (NULL);
2864
2865 /* Aggregate address increment. */
2866 bgp_aggregate_increment (bgp, p, new, afi, safi);
2867
2868 /* Register new BGP information. */
2869 bgp_info_add (rn, new);
2870
2871 /* Process change. */
2872 bgp_process (bgp, rn, afi, safi);
2873
2874 /* Unintern original. */
2875 aspath_unintern (attr.aspath);
2876}
2877
2878void
paulfee0f4c2004-09-13 05:12:46 +00002879bgp_static_update (struct bgp *bgp, struct prefix *p,
2880 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
2881{
2882 struct peer *rsclient;
2883 struct listnode *nn;
2884
2885 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
2886
2887 LIST_LOOP(bgp->rsclient, rsclient, nn)
2888 {
2889 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
2890 }
2891}
2892
2893void
paul718e3742002-12-13 20:15:29 +00002894bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi,
2895 u_char safi, struct prefix_rd *prd, u_char *tag)
2896{
2897 struct bgp_node *rn;
2898 struct bgp_info *new;
2899
paulfee0f4c2004-09-13 05:12:46 +00002900 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00002901
2902 /* Make new BGP info. */
2903 new = bgp_info_new ();
2904 new->type = ZEBRA_ROUTE_BGP;
2905 new->sub_type = BGP_ROUTE_STATIC;
2906 new->peer = bgp->peer_self;
2907 new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP);
2908 SET_FLAG (new->flags, BGP_INFO_VALID);
2909 new->uptime = time (NULL);
2910 memcpy (new->tag, tag, 3);
2911
2912 /* Aggregate address increment. */
2913 bgp_aggregate_increment (bgp, p, (struct bgp_info *) new, afi, safi);
2914
2915 /* Register new BGP information. */
2916 bgp_info_add (rn, (struct bgp_info *) new);
2917
2918 /* Process change. */
2919 bgp_process (bgp, rn, afi, safi);
2920}
2921
2922void
2923bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
2924 safi_t safi)
2925{
2926 struct bgp_node *rn;
2927 struct bgp_info *ri;
2928
paulfee0f4c2004-09-13 05:12:46 +00002929 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00002930
2931 /* Check selected route and self inserted route. */
2932 for (ri = rn->info; ri; ri = ri->next)
2933 if (ri->peer == bgp->peer_self
2934 && ri->type == ZEBRA_ROUTE_BGP
2935 && ri->sub_type == BGP_ROUTE_STATIC)
2936 break;
2937
2938 /* Withdraw static BGP route from routing table. */
2939 if (ri)
2940 {
2941 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2942 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
2943 bgp_process (bgp, rn, afi, safi);
2944 bgp_info_delete (rn, ri);
2945 bgp_info_free (ri);
2946 bgp_unlock_node (rn);
2947 }
2948
2949 /* Unlock bgp_node_lookup. */
2950 bgp_unlock_node (rn);
2951}
2952
2953void
paulfee0f4c2004-09-13 05:12:46 +00002954bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2955{
2956 struct bgp_static *bgp_static;
2957 struct bgp *bgp;
2958 struct bgp_node *rn;
2959 struct prefix *p;
2960
2961 bgp = rsclient->bgp;
2962
2963 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
2964 if ((bgp_static = rn->info) != NULL)
2965 {
2966 p = &rn->p;
2967
2968 bgp_static_update_rsclient (rsclient, p, bgp_static,
2969 afi, safi);
2970 }
2971}
2972
2973void
paul718e3742002-12-13 20:15:29 +00002974bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi,
2975 u_char safi, struct prefix_rd *prd, u_char *tag)
2976{
2977 struct bgp_node *rn;
2978 struct bgp_info *ri;
2979
paulfee0f4c2004-09-13 05:12:46 +00002980 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00002981
2982 /* Check selected route and self inserted route. */
2983 for (ri = rn->info; ri; ri = ri->next)
2984 if (ri->peer == bgp->peer_self
2985 && ri->type == ZEBRA_ROUTE_BGP
2986 && ri->sub_type == BGP_ROUTE_STATIC)
2987 break;
2988
2989 /* Withdraw static BGP route from routing table. */
2990 if (ri)
2991 {
2992 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2993 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
2994 bgp_process (bgp, rn, afi, safi);
2995 bgp_info_delete (rn, ri);
2996 bgp_info_free (ri);
2997 bgp_unlock_node (rn);
2998 }
2999
3000 /* Unlock bgp_node_lookup. */
3001 bgp_unlock_node (rn);
3002}
3003
3004/* Configure static BGP network. When user don't run zebra, static
3005 route should be installed as valid. */
3006int
paulfd79ac92004-10-13 05:06:08 +00003007bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
3008 u_int16_t afi, u_char safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003009{
3010 int ret;
3011 struct prefix p;
3012 struct bgp_static *bgp_static;
3013 struct bgp_node *rn;
3014 int need_update = 0;
3015
3016 /* Convert IP prefix string to struct prefix. */
3017 ret = str2prefix (ip_str, &p);
3018 if (! ret)
3019 {
3020 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3021 return CMD_WARNING;
3022 }
3023#ifdef HAVE_IPV6
3024 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3025 {
3026 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3027 VTY_NEWLINE);
3028 return CMD_WARNING;
3029 }
3030#endif /* HAVE_IPV6 */
3031
3032 apply_mask (&p);
3033
3034 /* Set BGP static route configuration. */
3035 rn = bgp_node_get (bgp->route[afi][safi], &p);
3036
3037 if (rn->info)
3038 {
3039 /* Configuration change. */
3040 bgp_static = rn->info;
3041
3042 /* Check previous routes are installed into BGP. */
3043 if (! bgp_static->backdoor && bgp_static->valid)
3044 need_update = 1;
3045
3046 bgp_static->backdoor = backdoor;
3047 if (rmap)
3048 {
3049 if (bgp_static->rmap.name)
3050 free (bgp_static->rmap.name);
3051 bgp_static->rmap.name = strdup (rmap);
3052 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3053 }
3054 else
3055 {
3056 if (bgp_static->rmap.name)
3057 free (bgp_static->rmap.name);
3058 bgp_static->rmap.name = NULL;
3059 bgp_static->rmap.map = NULL;
3060 bgp_static->valid = 0;
3061 }
3062 bgp_unlock_node (rn);
3063 }
3064 else
3065 {
3066 /* New configuration. */
3067 bgp_static = bgp_static_new ();
3068 bgp_static->backdoor = backdoor;
3069 bgp_static->valid = 0;
3070 bgp_static->igpmetric = 0;
3071 bgp_static->igpnexthop.s_addr = 0;
3072 if (rmap)
3073 {
3074 if (bgp_static->rmap.name)
3075 free (bgp_static->rmap.name);
3076 bgp_static->rmap.name = strdup (rmap);
3077 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3078 }
3079 rn->info = bgp_static;
3080 }
3081
3082 /* If BGP scan is not enabled, we should install this route here. */
3083 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3084 {
3085 bgp_static->valid = 1;
3086
3087 if (need_update)
3088 bgp_static_withdraw (bgp, &p, afi, safi);
3089
3090 if (! bgp_static->backdoor)
3091 bgp_static_update (bgp, &p, bgp_static, afi, safi);
3092 }
3093
3094 return CMD_SUCCESS;
3095}
3096
3097/* Configure static BGP network. */
3098int
paulfd79ac92004-10-13 05:06:08 +00003099bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
paul718e3742002-12-13 20:15:29 +00003100 u_int16_t afi, u_char safi)
3101{
3102 int ret;
3103 struct prefix p;
3104 struct bgp_static *bgp_static;
3105 struct bgp_node *rn;
3106
3107 /* Convert IP prefix string to struct prefix. */
3108 ret = str2prefix (ip_str, &p);
3109 if (! ret)
3110 {
3111 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3112 return CMD_WARNING;
3113 }
3114#ifdef HAVE_IPV6
3115 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3116 {
3117 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3118 VTY_NEWLINE);
3119 return CMD_WARNING;
3120 }
3121#endif /* HAVE_IPV6 */
3122
3123 apply_mask (&p);
3124
3125 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
3126 if (! rn)
3127 {
3128 vty_out (vty, "%% Can't find specified static route configuration.%s",
3129 VTY_NEWLINE);
3130 return CMD_WARNING;
3131 }
3132
3133 bgp_static = rn->info;
3134
3135 /* Update BGP RIB. */
3136 if (! bgp_static->backdoor)
3137 bgp_static_withdraw (bgp, &p, afi, safi);
3138
3139 /* Clear configuration. */
3140 bgp_static_free (bgp_static);
3141 rn->info = NULL;
3142 bgp_unlock_node (rn);
3143 bgp_unlock_node (rn);
3144
3145 return CMD_SUCCESS;
3146}
3147
3148/* Called from bgp_delete(). Delete all static routes from the BGP
3149 instance. */
3150void
3151bgp_static_delete (struct bgp *bgp)
3152{
3153 afi_t afi;
3154 safi_t safi;
3155 struct bgp_node *rn;
3156 struct bgp_node *rm;
3157 struct bgp_table *table;
3158 struct bgp_static *bgp_static;
3159
3160 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3161 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
3162 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3163 if (rn->info != NULL)
3164 {
3165 if (safi == SAFI_MPLS_VPN)
3166 {
3167 table = rn->info;
3168
3169 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
3170 {
3171 bgp_static = rn->info;
3172 bgp_static_withdraw_vpnv4 (bgp, &rm->p,
3173 AFI_IP, SAFI_MPLS_VPN,
3174 (struct prefix_rd *)&rn->p,
3175 bgp_static->tag);
3176 bgp_static_free (bgp_static);
3177 rn->info = NULL;
3178 bgp_unlock_node (rn);
3179 }
3180 }
3181 else
3182 {
3183 bgp_static = rn->info;
3184 bgp_static_withdraw (bgp, &rn->p, afi, safi);
3185 bgp_static_free (bgp_static);
3186 rn->info = NULL;
3187 bgp_unlock_node (rn);
3188 }
3189 }
3190}
3191
3192int
paulfd79ac92004-10-13 05:06:08 +00003193bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str,
3194 const char *tag_str)
paul718e3742002-12-13 20:15:29 +00003195{
3196 int ret;
3197 struct prefix p;
3198 struct prefix_rd prd;
3199 struct bgp *bgp;
3200 struct bgp_node *prn;
3201 struct bgp_node *rn;
3202 struct bgp_table *table;
3203 struct bgp_static *bgp_static;
3204 u_char tag[3];
3205
3206 bgp = vty->index;
3207
3208 ret = str2prefix (ip_str, &p);
3209 if (! ret)
3210 {
3211 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3212 return CMD_WARNING;
3213 }
3214 apply_mask (&p);
3215
3216 ret = str2prefix_rd (rd_str, &prd);
3217 if (! ret)
3218 {
3219 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
3220 return CMD_WARNING;
3221 }
3222
3223 ret = str2tag (tag_str, tag);
3224 if (! ret)
3225 {
3226 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
3227 return CMD_WARNING;
3228 }
3229
3230 prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN],
3231 (struct prefix *)&prd);
3232 if (prn->info == NULL)
3233 prn->info = bgp_table_init ();
3234 else
3235 bgp_unlock_node (prn);
3236 table = prn->info;
3237
3238 rn = bgp_node_get (table, &p);
3239
3240 if (rn->info)
3241 {
3242 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
3243 bgp_unlock_node (rn);
3244 }
3245 else
3246 {
3247 /* New configuration. */
3248 bgp_static = bgp_static_new ();
3249 bgp_static->valid = 1;
3250 memcpy (bgp_static->tag, tag, 3);
3251 rn->info = bgp_static;
3252
3253 bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag);
3254 }
3255
3256 return CMD_SUCCESS;
3257}
3258
3259/* Configure static BGP network. */
3260int
paulfd79ac92004-10-13 05:06:08 +00003261bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str,
3262 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00003263{
3264 int ret;
3265 struct bgp *bgp;
3266 struct prefix p;
3267 struct prefix_rd prd;
3268 struct bgp_node *prn;
3269 struct bgp_node *rn;
3270 struct bgp_table *table;
3271 struct bgp_static *bgp_static;
3272 u_char tag[3];
3273
3274 bgp = vty->index;
3275
3276 /* Convert IP prefix string to struct prefix. */
3277 ret = str2prefix (ip_str, &p);
3278 if (! ret)
3279 {
3280 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3281 return CMD_WARNING;
3282 }
3283 apply_mask (&p);
3284
3285 ret = str2prefix_rd (rd_str, &prd);
3286 if (! ret)
3287 {
3288 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
3289 return CMD_WARNING;
3290 }
3291
3292 ret = str2tag (tag_str, tag);
3293 if (! ret)
3294 {
3295 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
3296 return CMD_WARNING;
3297 }
3298
3299 prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN],
3300 (struct prefix *)&prd);
3301 if (prn->info == NULL)
3302 prn->info = bgp_table_init ();
3303 else
3304 bgp_unlock_node (prn);
3305 table = prn->info;
3306
3307 rn = bgp_node_lookup (table, &p);
3308
3309 if (rn)
3310 {
3311 bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag);
3312
3313 bgp_static = rn->info;
3314 bgp_static_free (bgp_static);
3315 rn->info = NULL;
3316 bgp_unlock_node (rn);
3317 bgp_unlock_node (rn);
3318 }
3319 else
3320 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
3321
3322 return CMD_SUCCESS;
3323}
3324
3325DEFUN (bgp_network,
3326 bgp_network_cmd,
3327 "network A.B.C.D/M",
3328 "Specify a network to announce via BGP\n"
3329 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3330{
3331 return bgp_static_set (vty, vty->index, argv[0],
3332 AFI_IP, bgp_node_safi (vty), NULL, 0);
3333}
3334
3335DEFUN (bgp_network_route_map,
3336 bgp_network_route_map_cmd,
3337 "network A.B.C.D/M route-map WORD",
3338 "Specify a network to announce via BGP\n"
3339 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3340 "Route-map to modify the attributes\n"
3341 "Name of the route map\n")
3342{
3343 return bgp_static_set (vty, vty->index, argv[0],
3344 AFI_IP, bgp_node_safi (vty), argv[1], 0);
3345}
3346
3347DEFUN (bgp_network_backdoor,
3348 bgp_network_backdoor_cmd,
3349 "network A.B.C.D/M backdoor",
3350 "Specify a network to announce via BGP\n"
3351 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3352 "Specify a BGP backdoor route\n")
3353{
3354 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
3355}
3356
3357DEFUN (bgp_network_mask,
3358 bgp_network_mask_cmd,
3359 "network A.B.C.D mask A.B.C.D",
3360 "Specify a network to announce via BGP\n"
3361 "Network number\n"
3362 "Network mask\n"
3363 "Network mask\n")
3364{
3365 int ret;
3366 char prefix_str[BUFSIZ];
3367
3368 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3369 if (! ret)
3370 {
3371 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3372 return CMD_WARNING;
3373 }
3374
3375 return bgp_static_set (vty, vty->index, prefix_str,
3376 AFI_IP, bgp_node_safi (vty), NULL, 0);
3377}
3378
3379DEFUN (bgp_network_mask_route_map,
3380 bgp_network_mask_route_map_cmd,
3381 "network A.B.C.D mask A.B.C.D route-map WORD",
3382 "Specify a network to announce via BGP\n"
3383 "Network number\n"
3384 "Network mask\n"
3385 "Network mask\n"
3386 "Route-map to modify the attributes\n"
3387 "Name of the route map\n")
3388{
3389 int ret;
3390 char prefix_str[BUFSIZ];
3391
3392 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3393 if (! ret)
3394 {
3395 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3396 return CMD_WARNING;
3397 }
3398
3399 return bgp_static_set (vty, vty->index, prefix_str,
3400 AFI_IP, bgp_node_safi (vty), argv[2], 0);
3401}
3402
3403DEFUN (bgp_network_mask_backdoor,
3404 bgp_network_mask_backdoor_cmd,
3405 "network A.B.C.D mask A.B.C.D backdoor",
3406 "Specify a network to announce via BGP\n"
3407 "Network number\n"
3408 "Network mask\n"
3409 "Network mask\n"
3410 "Specify a BGP backdoor route\n")
3411{
3412 int ret;
3413 char prefix_str[BUFSIZ];
3414
3415 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3416 if (! ret)
3417 {
3418 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3419 return CMD_WARNING;
3420 }
3421
3422 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1);
3423}
3424
3425DEFUN (bgp_network_mask_natural,
3426 bgp_network_mask_natural_cmd,
3427 "network A.B.C.D",
3428 "Specify a network to announce via BGP\n"
3429 "Network number\n")
3430{
3431 int ret;
3432 char prefix_str[BUFSIZ];
3433
3434 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3435 if (! ret)
3436 {
3437 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3438 return CMD_WARNING;
3439 }
3440
3441 return bgp_static_set (vty, vty->index, prefix_str,
3442 AFI_IP, bgp_node_safi (vty), NULL, 0);
3443}
3444
3445DEFUN (bgp_network_mask_natural_route_map,
3446 bgp_network_mask_natural_route_map_cmd,
3447 "network A.B.C.D route-map WORD",
3448 "Specify a network to announce via BGP\n"
3449 "Network number\n"
3450 "Route-map to modify the attributes\n"
3451 "Name of the route map\n")
3452{
3453 int ret;
3454 char prefix_str[BUFSIZ];
3455
3456 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3457 if (! ret)
3458 {
3459 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3460 return CMD_WARNING;
3461 }
3462
3463 return bgp_static_set (vty, vty->index, prefix_str,
3464 AFI_IP, bgp_node_safi (vty), argv[1], 0);
3465}
3466
3467DEFUN (bgp_network_mask_natural_backdoor,
3468 bgp_network_mask_natural_backdoor_cmd,
3469 "network A.B.C.D backdoor",
3470 "Specify a network to announce via BGP\n"
3471 "Network number\n"
3472 "Specify a BGP backdoor route\n")
3473{
3474 int ret;
3475 char prefix_str[BUFSIZ];
3476
3477 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3478 if (! ret)
3479 {
3480 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3481 return CMD_WARNING;
3482 }
3483
3484 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1);
3485}
3486
3487DEFUN (no_bgp_network,
3488 no_bgp_network_cmd,
3489 "no network A.B.C.D/M",
3490 NO_STR
3491 "Specify a network to announce via BGP\n"
3492 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3493{
3494 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
3495 bgp_node_safi (vty));
3496}
3497
3498ALIAS (no_bgp_network,
3499 no_bgp_network_route_map_cmd,
3500 "no network A.B.C.D/M route-map WORD",
3501 NO_STR
3502 "Specify a network to announce via BGP\n"
3503 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3504 "Route-map to modify the attributes\n"
3505 "Name of the route map\n")
3506
3507ALIAS (no_bgp_network,
3508 no_bgp_network_backdoor_cmd,
3509 "no network A.B.C.D/M backdoor",
3510 NO_STR
3511 "Specify a network to announce via BGP\n"
3512 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3513 "Specify a BGP backdoor route\n")
3514
3515DEFUN (no_bgp_network_mask,
3516 no_bgp_network_mask_cmd,
3517 "no network A.B.C.D mask A.B.C.D",
3518 NO_STR
3519 "Specify a network to announce via BGP\n"
3520 "Network number\n"
3521 "Network mask\n"
3522 "Network mask\n")
3523{
3524 int ret;
3525 char prefix_str[BUFSIZ];
3526
3527 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3528 if (! ret)
3529 {
3530 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3531 return CMD_WARNING;
3532 }
3533
3534 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
3535 bgp_node_safi (vty));
3536}
3537
3538ALIAS (no_bgp_network_mask,
3539 no_bgp_network_mask_route_map_cmd,
3540 "no network A.B.C.D mask A.B.C.D route-map WORD",
3541 NO_STR
3542 "Specify a network to announce via BGP\n"
3543 "Network number\n"
3544 "Network mask\n"
3545 "Network mask\n"
3546 "Route-map to modify the attributes\n"
3547 "Name of the route map\n")
3548
3549ALIAS (no_bgp_network_mask,
3550 no_bgp_network_mask_backdoor_cmd,
3551 "no network A.B.C.D mask A.B.C.D backdoor",
3552 NO_STR
3553 "Specify a network to announce via BGP\n"
3554 "Network number\n"
3555 "Network mask\n"
3556 "Network mask\n"
3557 "Specify a BGP backdoor route\n")
3558
3559DEFUN (no_bgp_network_mask_natural,
3560 no_bgp_network_mask_natural_cmd,
3561 "no network A.B.C.D",
3562 NO_STR
3563 "Specify a network to announce via BGP\n"
3564 "Network number\n")
3565{
3566 int ret;
3567 char prefix_str[BUFSIZ];
3568
3569 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3570 if (! ret)
3571 {
3572 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3573 return CMD_WARNING;
3574 }
3575
3576 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
3577 bgp_node_safi (vty));
3578}
3579
3580ALIAS (no_bgp_network_mask_natural,
3581 no_bgp_network_mask_natural_route_map_cmd,
3582 "no network A.B.C.D route-map WORD",
3583 NO_STR
3584 "Specify a network to announce via BGP\n"
3585 "Network number\n"
3586 "Route-map to modify the attributes\n"
3587 "Name of the route map\n")
3588
3589ALIAS (no_bgp_network_mask_natural,
3590 no_bgp_network_mask_natural_backdoor_cmd,
3591 "no network A.B.C.D backdoor",
3592 NO_STR
3593 "Specify a network to announce via BGP\n"
3594 "Network number\n"
3595 "Specify a BGP backdoor route\n")
3596
3597#ifdef HAVE_IPV6
3598DEFUN (ipv6_bgp_network,
3599 ipv6_bgp_network_cmd,
3600 "network X:X::X:X/M",
3601 "Specify a network to announce via BGP\n"
3602 "IPv6 prefix <network>/<length>\n")
3603{
3604 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
3605}
3606
3607DEFUN (ipv6_bgp_network_route_map,
3608 ipv6_bgp_network_route_map_cmd,
3609 "network X:X::X:X/M route-map WORD",
3610 "Specify a network to announce via BGP\n"
3611 "IPv6 prefix <network>/<length>\n"
3612 "Route-map to modify the attributes\n"
3613 "Name of the route map\n")
3614{
3615 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
3616 bgp_node_safi (vty), argv[1], 0);
3617}
3618
3619DEFUN (no_ipv6_bgp_network,
3620 no_ipv6_bgp_network_cmd,
3621 "no network X:X::X:X/M",
3622 NO_STR
3623 "Specify a network to announce via BGP\n"
3624 "IPv6 prefix <network>/<length>\n")
3625{
3626 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST);
3627}
3628
3629ALIAS (no_ipv6_bgp_network,
3630 no_ipv6_bgp_network_route_map_cmd,
3631 "no network X:X::X:X/M route-map WORD",
3632 NO_STR
3633 "Specify a network to announce via BGP\n"
3634 "IPv6 prefix <network>/<length>\n"
3635 "Route-map to modify the attributes\n"
3636 "Name of the route map\n")
3637
3638ALIAS (ipv6_bgp_network,
3639 old_ipv6_bgp_network_cmd,
3640 "ipv6 bgp network X:X::X:X/M",
3641 IPV6_STR
3642 BGP_STR
3643 "Specify a network to announce via BGP\n"
3644 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
3645
3646ALIAS (no_ipv6_bgp_network,
3647 old_no_ipv6_bgp_network_cmd,
3648 "no ipv6 bgp network X:X::X:X/M",
3649 NO_STR
3650 IPV6_STR
3651 BGP_STR
3652 "Specify a network to announce via BGP\n"
3653 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
3654#endif /* HAVE_IPV6 */
3655
3656/* Aggreagete address:
3657
3658 advertise-map Set condition to advertise attribute
3659 as-set Generate AS set path information
3660 attribute-map Set attributes of aggregate
3661 route-map Set parameters of aggregate
3662 summary-only Filter more specific routes from updates
3663 suppress-map Conditionally filter more specific routes from updates
3664 <cr>
3665 */
3666struct bgp_aggregate
3667{
3668 /* Summary-only flag. */
3669 u_char summary_only;
3670
3671 /* AS set generation. */
3672 u_char as_set;
3673
3674 /* Route-map for aggregated route. */
3675 struct route_map *map;
3676
3677 /* Suppress-count. */
3678 unsigned long count;
3679
3680 /* SAFI configuration. */
3681 safi_t safi;
3682};
3683
3684struct bgp_aggregate *
3685bgp_aggregate_new ()
3686{
3687 struct bgp_aggregate *new;
3688 new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
3689 memset (new, 0, sizeof (struct bgp_aggregate));
3690 return new;
3691}
3692
3693void
3694bgp_aggregate_free (struct bgp_aggregate *aggregate)
3695{
3696 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
3697}
3698
3699void
3700bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
3701 afi_t afi, safi_t safi, struct bgp_info *del,
3702 struct bgp_aggregate *aggregate)
3703{
3704 struct bgp_table *table;
3705 struct bgp_node *top;
3706 struct bgp_node *rn;
3707 u_char origin;
3708 struct aspath *aspath = NULL;
3709 struct aspath *asmerge = NULL;
3710 struct community *community = NULL;
3711 struct community *commerge = NULL;
3712 struct in_addr nexthop;
3713 u_int32_t med = 0;
3714 struct bgp_info *ri;
3715 struct bgp_info *new;
3716 int first = 1;
3717 unsigned long match = 0;
3718
3719 /* Record adding route's nexthop and med. */
3720 if (rinew)
3721 {
3722 nexthop = rinew->attr->nexthop;
3723 med = rinew->attr->med;
3724 }
3725
3726 /* ORIGIN attribute: If at least one route among routes that are
3727 aggregated has ORIGIN with the value INCOMPLETE, then the
3728 aggregated route must have the ORIGIN attribute with the value
3729 INCOMPLETE. Otherwise, if at least one route among routes that
3730 are aggregated has ORIGIN with the value EGP, then the aggregated
3731 route must have the origin attribute with the value EGP. In all
3732 other case the value of the ORIGIN attribute of the aggregated
3733 route is INTERNAL. */
3734 origin = BGP_ORIGIN_IGP;
3735
3736 table = bgp->rib[afi][safi];
3737
3738 top = bgp_node_get (table, p);
3739 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
3740 if (rn->p.prefixlen > p->prefixlen)
3741 {
3742 match = 0;
3743
3744 for (ri = rn->info; ri; ri = ri->next)
3745 {
3746 if (BGP_INFO_HOLDDOWN (ri))
3747 continue;
3748
3749 if (del && ri == del)
3750 continue;
3751
3752 if (! rinew && first)
3753 {
3754 nexthop = ri->attr->nexthop;
3755 med = ri->attr->med;
3756 first = 0;
3757 }
3758
3759#ifdef AGGREGATE_NEXTHOP_CHECK
3760 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
3761 || ri->attr->med != med)
3762 {
3763 if (aspath)
3764 aspath_free (aspath);
3765 if (community)
3766 community_free (community);
3767 bgp_unlock_node (rn);
3768 bgp_unlock_node (top);
3769 return;
3770 }
3771#endif /* AGGREGATE_NEXTHOP_CHECK */
3772
3773 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
3774 {
3775 if (aggregate->summary_only)
3776 {
3777 ri->suppress++;
3778 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
3779 match++;
3780 }
3781
3782 aggregate->count++;
3783
3784 if (aggregate->as_set)
3785 {
3786 if (origin < ri->attr->origin)
3787 origin = ri->attr->origin;
3788
3789 if (aspath)
3790 {
3791 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
3792 aspath_free (aspath);
3793 aspath = asmerge;
3794 }
3795 else
3796 aspath = aspath_dup (ri->attr->aspath);
3797
3798 if (ri->attr->community)
3799 {
3800 if (community)
3801 {
3802 commerge = community_merge (community,
3803 ri->attr->community);
3804 community = community_uniq_sort (commerge);
3805 community_free (commerge);
3806 }
3807 else
3808 community = community_dup (ri->attr->community);
3809 }
3810 }
3811 }
3812 }
3813 if (match)
3814 bgp_process (bgp, rn, afi, safi);
3815 }
3816 bgp_unlock_node (top);
3817
3818 if (rinew)
3819 {
3820 aggregate->count++;
3821
3822 if (aggregate->summary_only)
3823 rinew->suppress++;
3824
3825 if (aggregate->as_set)
3826 {
3827 if (origin < rinew->attr->origin)
3828 origin = rinew->attr->origin;
3829
3830 if (aspath)
3831 {
3832 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
3833 aspath_free (aspath);
3834 aspath = asmerge;
3835 }
3836 else
3837 aspath = aspath_dup (rinew->attr->aspath);
3838
3839 if (rinew->attr->community)
3840 {
3841 if (community)
3842 {
3843 commerge = community_merge (community,
3844 rinew->attr->community);
3845 community = community_uniq_sort (commerge);
3846 community_free (commerge);
3847 }
3848 else
3849 community = community_dup (rinew->attr->community);
3850 }
3851 }
3852 }
3853
3854 if (aggregate->count > 0)
3855 {
3856 rn = bgp_node_get (table, p);
3857 new = bgp_info_new ();
3858 new->type = ZEBRA_ROUTE_BGP;
3859 new->sub_type = BGP_ROUTE_AGGREGATE;
3860 new->peer = bgp->peer_self;
3861 SET_FLAG (new->flags, BGP_INFO_VALID);
3862 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
3863 new->uptime = time (NULL);
3864
3865 bgp_info_add (rn, new);
3866 bgp_process (bgp, rn, afi, safi);
3867 }
3868 else
3869 {
3870 if (aspath)
3871 aspath_free (aspath);
3872 if (community)
3873 community_free (community);
3874 }
3875}
3876
3877void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
3878 struct bgp_aggregate *);
3879
3880void
3881bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
3882 struct bgp_info *ri, afi_t afi, safi_t safi)
3883{
3884 struct bgp_node *child;
3885 struct bgp_node *rn;
3886 struct bgp_aggregate *aggregate;
3887
3888 /* MPLS-VPN aggregation is not yet supported. */
3889 if (safi == SAFI_MPLS_VPN)
3890 return;
3891
3892 if (p->prefixlen == 0)
3893 return;
3894
3895 if (BGP_INFO_HOLDDOWN (ri))
3896 return;
3897
3898 child = bgp_node_get (bgp->aggregate[afi][safi], p);
3899
3900 /* Aggregate address configuration check. */
3901 for (rn = child; rn; rn = rn->parent)
3902 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
3903 {
3904 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00003905 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00003906 }
3907 bgp_unlock_node (child);
3908}
3909
3910void
3911bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
3912 struct bgp_info *del, afi_t afi, safi_t safi)
3913{
3914 struct bgp_node *child;
3915 struct bgp_node *rn;
3916 struct bgp_aggregate *aggregate;
3917
3918 /* MPLS-VPN aggregation is not yet supported. */
3919 if (safi == SAFI_MPLS_VPN)
3920 return;
3921
3922 if (p->prefixlen == 0)
3923 return;
3924
3925 child = bgp_node_get (bgp->aggregate[afi][safi], p);
3926
3927 /* Aggregate address configuration check. */
3928 for (rn = child; rn; rn = rn->parent)
3929 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
3930 {
3931 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00003932 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00003933 }
3934 bgp_unlock_node (child);
3935}
3936
3937void
3938bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
3939 struct bgp_aggregate *aggregate)
3940{
3941 struct bgp_table *table;
3942 struct bgp_node *top;
3943 struct bgp_node *rn;
3944 struct bgp_info *new;
3945 struct bgp_info *ri;
3946 unsigned long match;
3947 u_char origin = BGP_ORIGIN_IGP;
3948 struct aspath *aspath = NULL;
3949 struct aspath *asmerge = NULL;
3950 struct community *community = NULL;
3951 struct community *commerge = NULL;
3952
3953 table = bgp->rib[afi][safi];
3954
3955 /* Sanity check. */
3956 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
3957 return;
3958 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
3959 return;
3960
3961 /* If routes exists below this node, generate aggregate routes. */
3962 top = bgp_node_get (table, p);
3963 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
3964 if (rn->p.prefixlen > p->prefixlen)
3965 {
3966 match = 0;
3967
3968 for (ri = rn->info; ri; ri = ri->next)
3969 {
3970 if (BGP_INFO_HOLDDOWN (ri))
3971 continue;
3972
3973 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
3974 {
3975 /* summary-only aggregate route suppress aggregated
3976 route announcement. */
3977 if (aggregate->summary_only)
3978 {
3979 ri->suppress++;
3980 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
3981 match++;
3982 }
3983 /* as-set aggregate route generate origin, as path,
3984 community aggregation. */
3985 if (aggregate->as_set)
3986 {
3987 if (origin < ri->attr->origin)
3988 origin = ri->attr->origin;
3989
3990 if (aspath)
3991 {
3992 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
3993 aspath_free (aspath);
3994 aspath = asmerge;
3995 }
3996 else
3997 aspath = aspath_dup (ri->attr->aspath);
3998
3999 if (ri->attr->community)
4000 {
4001 if (community)
4002 {
4003 commerge = community_merge (community,
4004 ri->attr->community);
4005 community = community_uniq_sort (commerge);
4006 community_free (commerge);
4007 }
4008 else
4009 community = community_dup (ri->attr->community);
4010 }
4011 }
4012 aggregate->count++;
4013 }
4014 }
4015
4016 /* If this node is suppressed, process the change. */
4017 if (match)
4018 bgp_process (bgp, rn, afi, safi);
4019 }
4020 bgp_unlock_node (top);
4021
4022 /* Add aggregate route to BGP table. */
4023 if (aggregate->count)
4024 {
4025 rn = bgp_node_get (table, p);
4026
4027 new = bgp_info_new ();
4028 new->type = ZEBRA_ROUTE_BGP;
4029 new->sub_type = BGP_ROUTE_AGGREGATE;
4030 new->peer = bgp->peer_self;
4031 SET_FLAG (new->flags, BGP_INFO_VALID);
4032 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
4033 new->uptime = time (NULL);
4034
4035 bgp_info_add (rn, new);
4036
4037 /* Process change. */
4038 bgp_process (bgp, rn, afi, safi);
4039 }
4040}
4041
4042void
4043bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
4044 safi_t safi, struct bgp_aggregate *aggregate)
4045{
4046 struct bgp_table *table;
4047 struct bgp_node *top;
4048 struct bgp_node *rn;
4049 struct bgp_info *ri;
4050 unsigned long match;
4051
4052 table = bgp->rib[afi][safi];
4053
4054 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
4055 return;
4056 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
4057 return;
4058
4059 /* If routes exists below this node, generate aggregate routes. */
4060 top = bgp_node_get (table, p);
4061 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4062 if (rn->p.prefixlen > p->prefixlen)
4063 {
4064 match = 0;
4065
4066 for (ri = rn->info; ri; ri = ri->next)
4067 {
4068 if (BGP_INFO_HOLDDOWN (ri))
4069 continue;
4070
4071 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4072 {
4073 if (aggregate->summary_only)
4074 {
4075 ri->suppress--;
4076
4077 if (ri->suppress == 0)
4078 {
4079 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
4080 match++;
4081 }
4082 }
4083 aggregate->count--;
4084 }
4085 }
4086
4087 /* If this node is suppressed, process the change. */
4088 if (match)
4089 bgp_process (bgp, rn, afi, safi);
4090 }
4091 bgp_unlock_node (top);
4092
4093 /* Delete aggregate route from BGP table. */
4094 rn = bgp_node_get (table, p);
4095
4096 for (ri = rn->info; ri; ri = ri->next)
4097 if (ri->peer == bgp->peer_self
4098 && ri->type == ZEBRA_ROUTE_BGP
4099 && ri->sub_type == BGP_ROUTE_AGGREGATE)
4100 break;
4101
4102 /* Withdraw static BGP route from routing table. */
4103 if (ri)
4104 {
4105 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
4106 bgp_process (bgp, rn, afi, safi);
4107 bgp_info_delete (rn, ri);
4108 bgp_info_free (ri);
4109 bgp_unlock_node (rn);
4110 }
4111
4112 /* Unlock bgp_node_lookup. */
4113 bgp_unlock_node (rn);
4114}
4115
4116/* Aggregate route attribute. */
4117#define AGGREGATE_SUMMARY_ONLY 1
4118#define AGGREGATE_AS_SET 1
4119
4120int
paulfd79ac92004-10-13 05:06:08 +00004121bgp_aggregate_set (struct vty *vty, const char *prefix_str,
4122 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00004123 u_char summary_only, u_char as_set)
4124{
4125 int ret;
4126 struct prefix p;
4127 struct bgp_node *rn;
4128 struct bgp *bgp;
4129 struct bgp_aggregate *aggregate;
4130
4131 /* Convert string to prefix structure. */
4132 ret = str2prefix (prefix_str, &p);
4133 if (!ret)
4134 {
4135 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
4136 return CMD_WARNING;
4137 }
4138 apply_mask (&p);
4139
4140 /* Get BGP structure. */
4141 bgp = vty->index;
4142
4143 /* Old configuration check. */
4144 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
4145
4146 if (rn->info)
4147 {
4148 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
4149 bgp_unlock_node (rn);
4150 return CMD_WARNING;
4151 }
4152
4153 /* Make aggregate address structure. */
4154 aggregate = bgp_aggregate_new ();
4155 aggregate->summary_only = summary_only;
4156 aggregate->as_set = as_set;
4157 aggregate->safi = safi;
4158 rn->info = aggregate;
4159
4160 /* Aggregate address insert into BGP routing table. */
4161 if (safi & SAFI_UNICAST)
4162 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
4163 if (safi & SAFI_MULTICAST)
4164 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
4165
4166 return CMD_SUCCESS;
4167}
4168
4169int
paulfd79ac92004-10-13 05:06:08 +00004170bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
4171 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004172{
4173 int ret;
4174 struct prefix p;
4175 struct bgp_node *rn;
4176 struct bgp *bgp;
4177 struct bgp_aggregate *aggregate;
4178
4179 /* Convert string to prefix structure. */
4180 ret = str2prefix (prefix_str, &p);
4181 if (!ret)
4182 {
4183 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
4184 return CMD_WARNING;
4185 }
4186 apply_mask (&p);
4187
4188 /* Get BGP structure. */
4189 bgp = vty->index;
4190
4191 /* Old configuration check. */
4192 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
4193 if (! rn)
4194 {
4195 vty_out (vty, "%% There is no aggregate-address configuration.%s",
4196 VTY_NEWLINE);
4197 return CMD_WARNING;
4198 }
4199
4200 aggregate = rn->info;
4201 if (aggregate->safi & SAFI_UNICAST)
4202 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
4203 if (aggregate->safi & SAFI_MULTICAST)
4204 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
4205
4206 /* Unlock aggregate address configuration. */
4207 rn->info = NULL;
4208 bgp_aggregate_free (aggregate);
4209 bgp_unlock_node (rn);
4210 bgp_unlock_node (rn);
4211
4212 return CMD_SUCCESS;
4213}
4214
4215DEFUN (aggregate_address,
4216 aggregate_address_cmd,
4217 "aggregate-address A.B.C.D/M",
4218 "Configure BGP aggregate entries\n"
4219 "Aggregate prefix\n")
4220{
4221 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
4222}
4223
4224DEFUN (aggregate_address_mask,
4225 aggregate_address_mask_cmd,
4226 "aggregate-address A.B.C.D A.B.C.D",
4227 "Configure BGP aggregate entries\n"
4228 "Aggregate address\n"
4229 "Aggregate mask\n")
4230{
4231 int ret;
4232 char prefix_str[BUFSIZ];
4233
4234 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4235
4236 if (! ret)
4237 {
4238 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4239 return CMD_WARNING;
4240 }
4241
4242 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4243 0, 0);
4244}
4245
4246DEFUN (aggregate_address_summary_only,
4247 aggregate_address_summary_only_cmd,
4248 "aggregate-address A.B.C.D/M summary-only",
4249 "Configure BGP aggregate entries\n"
4250 "Aggregate prefix\n"
4251 "Filter more specific routes from updates\n")
4252{
4253 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
4254 AGGREGATE_SUMMARY_ONLY, 0);
4255}
4256
4257DEFUN (aggregate_address_mask_summary_only,
4258 aggregate_address_mask_summary_only_cmd,
4259 "aggregate-address A.B.C.D A.B.C.D summary-only",
4260 "Configure BGP aggregate entries\n"
4261 "Aggregate address\n"
4262 "Aggregate mask\n"
4263 "Filter more specific routes from updates\n")
4264{
4265 int ret;
4266 char prefix_str[BUFSIZ];
4267
4268 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4269
4270 if (! ret)
4271 {
4272 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4273 return CMD_WARNING;
4274 }
4275
4276 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4277 AGGREGATE_SUMMARY_ONLY, 0);
4278}
4279
4280DEFUN (aggregate_address_as_set,
4281 aggregate_address_as_set_cmd,
4282 "aggregate-address A.B.C.D/M as-set",
4283 "Configure BGP aggregate entries\n"
4284 "Aggregate prefix\n"
4285 "Generate AS set path information\n")
4286{
4287 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
4288 0, AGGREGATE_AS_SET);
4289}
4290
4291DEFUN (aggregate_address_mask_as_set,
4292 aggregate_address_mask_as_set_cmd,
4293 "aggregate-address A.B.C.D A.B.C.D as-set",
4294 "Configure BGP aggregate entries\n"
4295 "Aggregate address\n"
4296 "Aggregate mask\n"
4297 "Generate AS set path information\n")
4298{
4299 int ret;
4300 char prefix_str[BUFSIZ];
4301
4302 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4303
4304 if (! ret)
4305 {
4306 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4307 return CMD_WARNING;
4308 }
4309
4310 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4311 0, AGGREGATE_AS_SET);
4312}
4313
4314
4315DEFUN (aggregate_address_as_set_summary,
4316 aggregate_address_as_set_summary_cmd,
4317 "aggregate-address A.B.C.D/M as-set summary-only",
4318 "Configure BGP aggregate entries\n"
4319 "Aggregate prefix\n"
4320 "Generate AS set path information\n"
4321 "Filter more specific routes from updates\n")
4322{
4323 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
4324 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
4325}
4326
4327ALIAS (aggregate_address_as_set_summary,
4328 aggregate_address_summary_as_set_cmd,
4329 "aggregate-address A.B.C.D/M summary-only as-set",
4330 "Configure BGP aggregate entries\n"
4331 "Aggregate prefix\n"
4332 "Filter more specific routes from updates\n"
4333 "Generate AS set path information\n")
4334
4335DEFUN (aggregate_address_mask_as_set_summary,
4336 aggregate_address_mask_as_set_summary_cmd,
4337 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4338 "Configure BGP aggregate entries\n"
4339 "Aggregate address\n"
4340 "Aggregate mask\n"
4341 "Generate AS set path information\n"
4342 "Filter more specific routes from updates\n")
4343{
4344 int ret;
4345 char prefix_str[BUFSIZ];
4346
4347 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4348
4349 if (! ret)
4350 {
4351 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4352 return CMD_WARNING;
4353 }
4354
4355 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4356 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
4357}
4358
4359ALIAS (aggregate_address_mask_as_set_summary,
4360 aggregate_address_mask_summary_as_set_cmd,
4361 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4362 "Configure BGP aggregate entries\n"
4363 "Aggregate address\n"
4364 "Aggregate mask\n"
4365 "Filter more specific routes from updates\n"
4366 "Generate AS set path information\n")
4367
4368DEFUN (no_aggregate_address,
4369 no_aggregate_address_cmd,
4370 "no aggregate-address A.B.C.D/M",
4371 NO_STR
4372 "Configure BGP aggregate entries\n"
4373 "Aggregate prefix\n")
4374{
4375 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
4376}
4377
4378ALIAS (no_aggregate_address,
4379 no_aggregate_address_summary_only_cmd,
4380 "no aggregate-address A.B.C.D/M summary-only",
4381 NO_STR
4382 "Configure BGP aggregate entries\n"
4383 "Aggregate prefix\n"
4384 "Filter more specific routes from updates\n")
4385
4386ALIAS (no_aggregate_address,
4387 no_aggregate_address_as_set_cmd,
4388 "no aggregate-address A.B.C.D/M as-set",
4389 NO_STR
4390 "Configure BGP aggregate entries\n"
4391 "Aggregate prefix\n"
4392 "Generate AS set path information\n")
4393
4394ALIAS (no_aggregate_address,
4395 no_aggregate_address_as_set_summary_cmd,
4396 "no aggregate-address A.B.C.D/M as-set summary-only",
4397 NO_STR
4398 "Configure BGP aggregate entries\n"
4399 "Aggregate prefix\n"
4400 "Generate AS set path information\n"
4401 "Filter more specific routes from updates\n")
4402
4403ALIAS (no_aggregate_address,
4404 no_aggregate_address_summary_as_set_cmd,
4405 "no aggregate-address A.B.C.D/M summary-only as-set",
4406 NO_STR
4407 "Configure BGP aggregate entries\n"
4408 "Aggregate prefix\n"
4409 "Filter more specific routes from updates\n"
4410 "Generate AS set path information\n")
4411
4412DEFUN (no_aggregate_address_mask,
4413 no_aggregate_address_mask_cmd,
4414 "no aggregate-address A.B.C.D A.B.C.D",
4415 NO_STR
4416 "Configure BGP aggregate entries\n"
4417 "Aggregate address\n"
4418 "Aggregate mask\n")
4419{
4420 int ret;
4421 char prefix_str[BUFSIZ];
4422
4423 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4424
4425 if (! ret)
4426 {
4427 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4428 return CMD_WARNING;
4429 }
4430
4431 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
4432}
4433
4434ALIAS (no_aggregate_address_mask,
4435 no_aggregate_address_mask_summary_only_cmd,
4436 "no aggregate-address A.B.C.D A.B.C.D summary-only",
4437 NO_STR
4438 "Configure BGP aggregate entries\n"
4439 "Aggregate address\n"
4440 "Aggregate mask\n"
4441 "Filter more specific routes from updates\n")
4442
4443ALIAS (no_aggregate_address_mask,
4444 no_aggregate_address_mask_as_set_cmd,
4445 "no aggregate-address A.B.C.D A.B.C.D as-set",
4446 NO_STR
4447 "Configure BGP aggregate entries\n"
4448 "Aggregate address\n"
4449 "Aggregate mask\n"
4450 "Generate AS set path information\n")
4451
4452ALIAS (no_aggregate_address_mask,
4453 no_aggregate_address_mask_as_set_summary_cmd,
4454 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4455 NO_STR
4456 "Configure BGP aggregate entries\n"
4457 "Aggregate address\n"
4458 "Aggregate mask\n"
4459 "Generate AS set path information\n"
4460 "Filter more specific routes from updates\n")
4461
4462ALIAS (no_aggregate_address_mask,
4463 no_aggregate_address_mask_summary_as_set_cmd,
4464 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4465 NO_STR
4466 "Configure BGP aggregate entries\n"
4467 "Aggregate address\n"
4468 "Aggregate mask\n"
4469 "Filter more specific routes from updates\n"
4470 "Generate AS set path information\n")
4471
4472#ifdef HAVE_IPV6
4473DEFUN (ipv6_aggregate_address,
4474 ipv6_aggregate_address_cmd,
4475 "aggregate-address X:X::X:X/M",
4476 "Configure BGP aggregate entries\n"
4477 "Aggregate prefix\n")
4478{
4479 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
4480}
4481
4482DEFUN (ipv6_aggregate_address_summary_only,
4483 ipv6_aggregate_address_summary_only_cmd,
4484 "aggregate-address X:X::X:X/M summary-only",
4485 "Configure BGP aggregate entries\n"
4486 "Aggregate prefix\n"
4487 "Filter more specific routes from updates\n")
4488{
4489 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
4490 AGGREGATE_SUMMARY_ONLY, 0);
4491}
4492
4493DEFUN (no_ipv6_aggregate_address,
4494 no_ipv6_aggregate_address_cmd,
4495 "no aggregate-address X:X::X:X/M",
4496 NO_STR
4497 "Configure BGP aggregate entries\n"
4498 "Aggregate prefix\n")
4499{
4500 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
4501}
4502
4503DEFUN (no_ipv6_aggregate_address_summary_only,
4504 no_ipv6_aggregate_address_summary_only_cmd,
4505 "no aggregate-address X:X::X:X/M summary-only",
4506 NO_STR
4507 "Configure BGP aggregate entries\n"
4508 "Aggregate prefix\n"
4509 "Filter more specific routes from updates\n")
4510{
4511 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
4512}
4513
4514ALIAS (ipv6_aggregate_address,
4515 old_ipv6_aggregate_address_cmd,
4516 "ipv6 bgp aggregate-address X:X::X:X/M",
4517 IPV6_STR
4518 BGP_STR
4519 "Configure BGP aggregate entries\n"
4520 "Aggregate prefix\n")
4521
4522ALIAS (ipv6_aggregate_address_summary_only,
4523 old_ipv6_aggregate_address_summary_only_cmd,
4524 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4525 IPV6_STR
4526 BGP_STR
4527 "Configure BGP aggregate entries\n"
4528 "Aggregate prefix\n"
4529 "Filter more specific routes from updates\n")
4530
4531ALIAS (no_ipv6_aggregate_address,
4532 old_no_ipv6_aggregate_address_cmd,
4533 "no ipv6 bgp aggregate-address X:X::X:X/M",
4534 NO_STR
4535 IPV6_STR
4536 BGP_STR
4537 "Configure BGP aggregate entries\n"
4538 "Aggregate prefix\n")
4539
4540ALIAS (no_ipv6_aggregate_address_summary_only,
4541 old_no_ipv6_aggregate_address_summary_only_cmd,
4542 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4543 NO_STR
4544 IPV6_STR
4545 BGP_STR
4546 "Configure BGP aggregate entries\n"
4547 "Aggregate prefix\n"
4548 "Filter more specific routes from updates\n")
4549#endif /* HAVE_IPV6 */
4550
4551/* Redistribute route treatment. */
4552void
4553bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop,
4554 u_int32_t metric, u_char type)
4555{
4556 struct bgp *bgp;
4557 struct listnode *nn;
4558 struct bgp_info *new;
4559 struct bgp_info *bi;
4560 struct bgp_info info;
4561 struct bgp_node *bn;
4562 struct attr attr;
4563 struct attr attr_new;
4564 struct attr *new_attr;
4565 afi_t afi;
4566 int ret;
4567
4568 /* Make default attribute. */
4569 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
4570 if (nexthop)
4571 attr.nexthop = *nexthop;
4572
4573 attr.med = metric;
4574 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
4575
4576 LIST_LOOP (bm->bgp, bgp, nn)
4577 {
4578 afi = family2afi (p->family);
4579
4580 if (bgp->redist[afi][type])
4581 {
4582 /* Copy attribute for modification. */
4583 attr_new = attr;
4584
4585 if (bgp->redist_metric_flag[afi][type])
4586 attr_new.med = bgp->redist_metric[afi][type];
4587
4588 /* Apply route-map. */
4589 if (bgp->rmap[afi][type].map)
4590 {
4591 info.peer = bgp->peer_self;
4592 info.attr = &attr_new;
4593
paulfee0f4c2004-09-13 05:12:46 +00004594 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
4595
paul718e3742002-12-13 20:15:29 +00004596 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
4597 &info);
paulfee0f4c2004-09-13 05:12:46 +00004598
4599 bgp->peer_self->rmap_type = 0;
4600
paul718e3742002-12-13 20:15:29 +00004601 if (ret == RMAP_DENYMATCH)
4602 {
4603 /* Free uninterned attribute. */
4604 bgp_attr_flush (&attr_new);
4605
4606 /* Unintern original. */
4607 aspath_unintern (attr.aspath);
4608 bgp_redistribute_delete (p, type);
4609 return;
4610 }
4611 }
4612
paulfee0f4c2004-09-13 05:12:46 +00004613 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00004614 new_attr = bgp_attr_intern (&attr_new);
4615
4616 for (bi = bn->info; bi; bi = bi->next)
4617 if (bi->peer == bgp->peer_self
4618 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
4619 break;
4620
4621 if (bi)
4622 {
4623 if (attrhash_cmp (bi->attr, new_attr))
4624 {
4625 bgp_attr_unintern (new_attr);
4626 aspath_unintern (attr.aspath);
4627 bgp_unlock_node (bn);
4628 return;
4629 }
4630 else
4631 {
4632 /* The attribute is changed. */
4633 SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED);
4634
4635 /* Rewrite BGP route information. */
4636 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
4637 bgp_attr_unintern (bi->attr);
4638 bi->attr = new_attr;
4639 bi->uptime = time (NULL);
4640
4641 /* Process change. */
4642 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
4643 bgp_process (bgp, bn, afi, SAFI_UNICAST);
4644 bgp_unlock_node (bn);
4645 aspath_unintern (attr.aspath);
4646 return;
4647 }
4648 }
4649
4650 new = bgp_info_new ();
4651 new->type = type;
4652 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
4653 new->peer = bgp->peer_self;
4654 SET_FLAG (new->flags, BGP_INFO_VALID);
4655 new->attr = new_attr;
4656 new->uptime = time (NULL);
4657
4658 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
4659 bgp_info_add (bn, new);
4660 bgp_process (bgp, bn, afi, SAFI_UNICAST);
4661 }
4662 }
4663
4664 /* Unintern original. */
4665 aspath_unintern (attr.aspath);
4666}
4667
4668void
4669bgp_redistribute_delete (struct prefix *p, u_char type)
4670{
4671 struct bgp *bgp;
4672 struct listnode *nn;
4673 afi_t afi;
4674 struct bgp_node *rn;
4675 struct bgp_info *ri;
4676
4677 LIST_LOOP (bm->bgp, bgp, nn)
4678 {
4679 afi = family2afi (p->family);
4680
4681 if (bgp->redist[afi][type])
4682 {
paulfee0f4c2004-09-13 05:12:46 +00004683 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00004684
4685 for (ri = rn->info; ri; ri = ri->next)
4686 if (ri->peer == bgp->peer_self
4687 && ri->type == type)
4688 break;
4689
4690 if (ri)
4691 {
4692 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
4693 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
4694 bgp_process (bgp, rn, afi, SAFI_UNICAST);
4695 bgp_info_delete (rn, ri);
4696 bgp_info_free (ri);
4697 bgp_unlock_node (rn);
4698 }
4699 bgp_unlock_node (rn);
4700 }
4701 }
4702}
4703
4704/* Withdraw specified route type's route. */
4705void
4706bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
4707{
4708 struct bgp_node *rn;
4709 struct bgp_info *ri;
4710 struct bgp_table *table;
4711
4712 table = bgp->rib[afi][SAFI_UNICAST];
4713
4714 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
4715 {
4716 for (ri = rn->info; ri; ri = ri->next)
4717 if (ri->peer == bgp->peer_self
4718 && ri->type == type)
4719 break;
4720
4721 if (ri)
4722 {
4723 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
4724 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
4725 bgp_process (bgp, rn, afi, SAFI_UNICAST);
4726 bgp_info_delete (rn, ri);
4727 bgp_info_free (ri);
4728 bgp_unlock_node (rn);
4729 }
4730 }
4731}
4732
4733/* Static function to display route. */
4734void
4735route_vty_out_route (struct prefix *p, struct vty *vty)
4736{
4737 int len;
4738 u_int32_t destination;
4739 char buf[BUFSIZ];
4740
4741 if (p->family == AF_INET)
4742 {
4743 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
4744 destination = ntohl (p->u.prefix4.s_addr);
4745
4746 if ((IN_CLASSC (destination) && p->prefixlen == 24)
4747 || (IN_CLASSB (destination) && p->prefixlen == 16)
4748 || (IN_CLASSA (destination) && p->prefixlen == 8)
4749 || p->u.prefix4.s_addr == 0)
4750 {
4751 /* When mask is natural, mask is not displayed. */
4752 }
4753 else
4754 len += vty_out (vty, "/%d", p->prefixlen);
4755 }
4756 else
4757 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
4758 p->prefixlen);
4759
4760 len = 17 - len;
4761 if (len < 1)
4762 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
4763 else
4764 vty_out (vty, "%*s", len, " ");
4765}
4766
paul718e3742002-12-13 20:15:29 +00004767enum bgp_display_type
4768{
4769 normal_list,
4770};
4771
4772/* called from terminal list command */
ajs5a646652004-11-05 01:25:55 +00004773void
paul718e3742002-12-13 20:15:29 +00004774route_vty_out (struct vty *vty, struct prefix *p,
4775 struct bgp_info *binfo, int display, safi_t safi)
4776{
4777 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00004778
4779 /* Route status display. */
hasso93406d82005-02-02 14:40:33 +00004780 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
4781 vty_out (vty, "S");
4782 else if (binfo->suppress)
paul718e3742002-12-13 20:15:29 +00004783 vty_out (vty, "s");
4784 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4785 vty_out (vty, "*");
4786 else
4787 vty_out (vty, " ");
4788
4789 /* Selected */
4790 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4791 vty_out (vty, "h");
4792 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4793 vty_out (vty, "d");
4794 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
4795 vty_out (vty, ">");
4796 else
4797 vty_out (vty, " ");
4798
4799 /* Internal route. */
4800 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
4801 vty_out (vty, "i");
4802 else
4803 vty_out (vty, " ");
4804
4805 /* print prefix and mask */
4806 if (! display)
4807 route_vty_out_route (p, vty);
4808 else
4809 vty_out (vty, "%*s", 17, " ");
4810
4811 /* Print attribute */
4812 attr = binfo->attr;
4813 if (attr)
4814 {
4815 if (p->family == AF_INET)
4816 {
4817 if (safi == SAFI_MPLS_VPN)
4818 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
4819 else
4820 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
4821 }
4822#ifdef HAVE_IPV6
4823 else if (p->family == AF_INET6)
4824 {
4825 int len;
4826 char buf[BUFSIZ];
4827
4828 len = vty_out (vty, "%s",
4829 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
4830 len = 16 - len;
4831 if (len < 1)
4832 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
4833 else
4834 vty_out (vty, "%*s", len, " ");
4835 }
4836#endif /* HAVE_IPV6 */
4837
4838 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
4839 vty_out (vty, "%10d", attr->med);
4840 else
4841 vty_out (vty, " ");
4842
4843 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
4844 vty_out (vty, "%7d", attr->local_pref);
4845 else
4846 vty_out (vty, " ");
4847
4848 vty_out (vty, "%7u ",attr->weight);
4849
4850 /* Print aspath */
4851 if (attr->aspath)
4852 aspath_print_vty (vty, attr->aspath);
4853
4854 /* Print origin */
4855 if (strlen (attr->aspath->str) == 0)
4856 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
4857 else
4858 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
4859 }
4860 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004861}
4862
4863/* called from terminal list command */
4864void
4865route_vty_out_tmp (struct vty *vty, struct prefix *p,
4866 struct attr *attr, safi_t safi)
4867{
4868 /* Route status display. */
4869 vty_out (vty, "*");
4870 vty_out (vty, ">");
4871 vty_out (vty, " ");
4872
4873 /* print prefix and mask */
4874 route_vty_out_route (p, vty);
4875
4876 /* Print attribute */
4877 if (attr)
4878 {
4879 if (p->family == AF_INET)
4880 {
4881 if (safi == SAFI_MPLS_VPN)
4882 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
4883 else
4884 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
4885 }
4886#ifdef HAVE_IPV6
4887 else if (p->family == AF_INET6)
4888 {
4889 int len;
4890 char buf[BUFSIZ];
4891
4892 len = vty_out (vty, "%s",
4893 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
4894 len = 16 - len;
4895 if (len < 1)
4896 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
4897 else
4898 vty_out (vty, "%*s", len, " ");
4899 }
4900#endif /* HAVE_IPV6 */
4901
4902 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
4903 vty_out (vty, "%10d", attr->med);
4904 else
4905 vty_out (vty, " ");
4906
4907 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
4908 vty_out (vty, "%7d", attr->local_pref);
4909 else
4910 vty_out (vty, " ");
4911
4912 vty_out (vty, "%7d ",attr->weight);
4913
4914 /* Print aspath */
4915 if (attr->aspath)
4916 aspath_print_vty (vty, attr->aspath);
4917
4918 /* Print origin */
4919 if (strlen (attr->aspath->str) == 0)
4920 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
4921 else
4922 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
4923 }
4924
4925 vty_out (vty, "%s", VTY_NEWLINE);
4926}
4927
ajs5a646652004-11-05 01:25:55 +00004928void
paul718e3742002-12-13 20:15:29 +00004929route_vty_out_tag (struct vty *vty, struct prefix *p,
4930 struct bgp_info *binfo, int display, safi_t safi)
4931{
4932 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00004933 u_int32_t label = 0;
4934
paul718e3742002-12-13 20:15:29 +00004935 /* Route status display. */
4936 if (binfo->suppress)
4937 vty_out (vty, "s");
4938 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4939 vty_out (vty, "*");
4940 else
4941 vty_out (vty, " ");
4942
4943 /* Selected */
4944 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4945 vty_out (vty, "h");
4946 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4947 vty_out (vty, "d");
4948 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
4949 vty_out (vty, ">");
4950 else
4951 vty_out (vty, " ");
4952
4953 /* Internal route. */
4954 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
4955 vty_out (vty, "i");
4956 else
4957 vty_out (vty, " ");
4958
4959 /* print prefix and mask */
4960 if (! display)
4961 route_vty_out_route (p, vty);
4962 else
4963 vty_out (vty, "%*s", 17, " ");
4964
4965 /* Print attribute */
4966 attr = binfo->attr;
4967 if (attr)
4968 {
4969 if (p->family == AF_INET)
4970 {
4971 if (safi == SAFI_MPLS_VPN)
4972 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
4973 else
4974 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
4975 }
4976#ifdef HAVE_IPV6
4977 else if (p->family == AF_INET6)
4978 {
4979 char buf[BUFSIZ];
4980 char buf1[BUFSIZ];
4981 if (attr->mp_nexthop_len == 16)
4982 vty_out (vty, "%s",
4983 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
4984 else if (attr->mp_nexthop_len == 32)
4985 vty_out (vty, "%s(%s)",
4986 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ),
4987 inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ));
4988
4989 }
4990#endif /* HAVE_IPV6 */
4991 }
4992
4993 label = decode_label (binfo->tag);
4994
4995 vty_out (vty, "notag/%d", label);
4996
4997 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004998}
4999
5000/* dampening route */
ajs5a646652004-11-05 01:25:55 +00005001static void
paul718e3742002-12-13 20:15:29 +00005002damp_route_vty_out (struct vty *vty, struct prefix *p,
5003 struct bgp_info *binfo, int display, safi_t safi)
5004{
5005 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00005006 int len;
5007
paul718e3742002-12-13 20:15:29 +00005008 /* Route status display. */
5009 if (binfo->suppress)
5010 vty_out (vty, "s");
5011 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5012 vty_out (vty, "*");
5013 else
5014 vty_out (vty, " ");
5015
5016 /* Selected */
5017 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5018 vty_out (vty, "h");
5019 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5020 vty_out (vty, "d");
5021 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5022 vty_out (vty, ">");
5023 else
5024 vty_out (vty, " ");
5025
5026 vty_out (vty, " ");
5027
5028 /* print prefix and mask */
5029 if (! display)
5030 route_vty_out_route (p, vty);
5031 else
5032 vty_out (vty, "%*s", 17, " ");
5033
5034 len = vty_out (vty, "%s", binfo->peer->host);
5035 len = 17 - len;
5036 if (len < 1)
5037 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
5038 else
5039 vty_out (vty, "%*s", len, " ");
5040
5041 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
5042
5043 /* Print attribute */
5044 attr = binfo->attr;
5045 if (attr)
5046 {
5047 /* Print aspath */
5048 if (attr->aspath)
5049 aspath_print_vty (vty, attr->aspath);
5050
5051 /* Print origin */
5052 if (strlen (attr->aspath->str) == 0)
5053 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
5054 else
5055 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
5056 }
5057 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005058}
5059
5060#define BGP_UPTIME_LEN 25
5061
5062/* flap route */
ajs5a646652004-11-05 01:25:55 +00005063static void
paul718e3742002-12-13 20:15:29 +00005064flap_route_vty_out (struct vty *vty, struct prefix *p,
5065 struct bgp_info *binfo, int display, safi_t safi)
5066{
5067 struct attr *attr;
5068 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00005069 char timebuf[BGP_UPTIME_LEN];
5070 int len;
5071
paul718e3742002-12-13 20:15:29 +00005072 bdi = binfo->damp_info;
5073
5074 /* Route status display. */
5075 if (binfo->suppress)
5076 vty_out (vty, "s");
5077 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5078 vty_out (vty, "*");
5079 else
5080 vty_out (vty, " ");
5081
5082 /* Selected */
5083 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5084 vty_out (vty, "h");
5085 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5086 vty_out (vty, "d");
5087 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5088 vty_out (vty, ">");
5089 else
5090 vty_out (vty, " ");
5091
5092 vty_out (vty, " ");
5093
5094 /* print prefix and mask */
5095 if (! display)
5096 route_vty_out_route (p, vty);
5097 else
5098 vty_out (vty, "%*s", 17, " ");
5099
5100 len = vty_out (vty, "%s", binfo->peer->host);
5101 len = 16 - len;
5102 if (len < 1)
5103 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
5104 else
5105 vty_out (vty, "%*s", len, " ");
5106
5107 len = vty_out (vty, "%d", bdi->flap);
5108 len = 5 - len;
5109 if (len < 1)
5110 vty_out (vty, " ");
5111 else
5112 vty_out (vty, "%*s ", len, " ");
5113
5114 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
5115 timebuf, BGP_UPTIME_LEN));
5116
5117 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
5118 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5119 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
5120 else
5121 vty_out (vty, "%*s ", 8, " ");
5122
5123 /* Print attribute */
5124 attr = binfo->attr;
5125 if (attr)
5126 {
5127 /* Print aspath */
5128 if (attr->aspath)
5129 aspath_print_vty (vty, attr->aspath);
5130
5131 /* Print origin */
5132 if (strlen (attr->aspath->str) == 0)
5133 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
5134 else
5135 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
5136 }
5137 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005138}
5139
5140void
5141route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
5142 struct bgp_info *binfo, afi_t afi, safi_t safi)
5143{
5144 char buf[INET6_ADDRSTRLEN];
5145 char buf1[BUFSIZ];
5146 struct attr *attr;
5147 int sockunion_vty_out (struct vty *, union sockunion *);
5148
5149 attr = binfo->attr;
5150
5151 if (attr)
5152 {
5153 /* Line1 display AS-path, Aggregator */
5154 if (attr->aspath)
5155 {
5156 vty_out (vty, " ");
5157 if (attr->aspath->length == 0)
5158 vty_out (vty, "Local");
5159 else
5160 aspath_print_vty (vty, attr->aspath);
5161 }
5162
hasso93406d82005-02-02 14:40:33 +00005163 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
5164 vty_out (vty, ", (stale)");
5165 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
5166 vty_out (vty, ", (aggregated by %d %s)", attr->aggregator_as,
5167 inet_ntoa (attr->aggregator_addr));
5168 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
5169 vty_out (vty, ", (Received from a RR-client)");
5170 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
5171 vty_out (vty, ", (Received from a RS-client)");
5172 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5173 vty_out (vty, ", (history entry)");
5174 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5175 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00005176 vty_out (vty, "%s", VTY_NEWLINE);
5177
5178 /* Line2 display Next-hop, Neighbor, Router-id */
5179 if (p->family == AF_INET)
5180 {
5181 vty_out (vty, " %s", safi == SAFI_MPLS_VPN ?
5182 inet_ntoa (attr->mp_nexthop_global_in) :
5183 inet_ntoa (attr->nexthop));
5184 }
5185#ifdef HAVE_IPV6
5186 else
5187 {
5188 vty_out (vty, " %s",
5189 inet_ntop (AF_INET6, &attr->mp_nexthop_global,
5190 buf, INET6_ADDRSTRLEN));
5191 }
5192#endif /* HAVE_IPV6 */
5193
5194 if (binfo->peer == bgp->peer_self)
5195 {
5196 vty_out (vty, " from %s ",
5197 p->family == AF_INET ? "0.0.0.0" : "::");
5198 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
5199 }
5200 else
5201 {
5202 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
5203 vty_out (vty, " (inaccessible)");
5204 else if (binfo->igpmetric)
5205 vty_out (vty, " (metric %d)", binfo->igpmetric);
pauleb821182004-05-01 08:44:08 +00005206 vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN));
paul718e3742002-12-13 20:15:29 +00005207 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
5208 vty_out (vty, " (%s)", inet_ntoa (attr->originator_id));
5209 else
5210 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
5211 }
5212 vty_out (vty, "%s", VTY_NEWLINE);
5213
5214#ifdef HAVE_IPV6
5215 /* display nexthop local */
5216 if (attr->mp_nexthop_len == 32)
5217 {
5218 vty_out (vty, " (%s)%s",
5219 inet_ntop (AF_INET6, &attr->mp_nexthop_local,
5220 buf, INET6_ADDRSTRLEN),
5221 VTY_NEWLINE);
5222 }
5223#endif /* HAVE_IPV6 */
5224
5225 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5226 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
5227
5228 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
5229 vty_out (vty, ", metric %d", attr->med);
5230
5231 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
5232 vty_out (vty, ", localpref %d", attr->local_pref);
5233 else
5234 vty_out (vty, ", localpref %d", bgp->default_local_pref);
5235
5236 if (attr->weight != 0)
5237 vty_out (vty, ", weight %d", attr->weight);
5238
5239 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5240 vty_out (vty, ", valid");
5241
5242 if (binfo->peer != bgp->peer_self)
5243 {
5244 if (binfo->peer->as == binfo->peer->local_as)
5245 vty_out (vty, ", internal");
5246 else
5247 vty_out (vty, ", %s",
5248 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
5249 }
5250 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
5251 vty_out (vty, ", aggregated, local");
5252 else if (binfo->type != ZEBRA_ROUTE_BGP)
5253 vty_out (vty, ", sourced");
5254 else
5255 vty_out (vty, ", sourced, local");
5256
5257 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
5258 vty_out (vty, ", atomic-aggregate");
5259
5260 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5261 vty_out (vty, ", best");
5262
5263 vty_out (vty, "%s", VTY_NEWLINE);
5264
5265 /* Line 4 display Community */
5266 if (attr->community)
5267 vty_out (vty, " Community: %s%s", attr->community->str,
5268 VTY_NEWLINE);
5269
5270 /* Line 5 display Extended-community */
5271 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
5272 vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str,
5273 VTY_NEWLINE);
5274
5275 /* Line 6 display Originator, Cluster-id */
5276 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
5277 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
5278 {
5279 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
5280 vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id));
5281
5282 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
5283 {
5284 int i;
5285 vty_out (vty, ", Cluster list: ");
5286 for (i = 0; i < attr->cluster->length / 4; i++)
5287 vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i]));
5288 }
5289 vty_out (vty, "%s", VTY_NEWLINE);
5290 }
5291
5292 if (binfo->damp_info)
5293 bgp_damp_info_vty (vty, binfo);
5294
5295 /* Line 7 display Uptime */
5296 vty_out (vty, " Last update: %s", ctime (&binfo->uptime));
5297 }
5298 vty_out (vty, "%s", VTY_NEWLINE);
5299}
5300
hasso93406d82005-02-02 14:40:33 +00005301#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale%s"
5302#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00005303#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
5304#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
5305#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
5306
5307enum bgp_show_type
5308{
5309 bgp_show_type_normal,
5310 bgp_show_type_regexp,
5311 bgp_show_type_prefix_list,
5312 bgp_show_type_filter_list,
5313 bgp_show_type_route_map,
5314 bgp_show_type_neighbor,
5315 bgp_show_type_cidr_only,
5316 bgp_show_type_prefix_longer,
5317 bgp_show_type_community_all,
5318 bgp_show_type_community,
5319 bgp_show_type_community_exact,
5320 bgp_show_type_community_list,
5321 bgp_show_type_community_list_exact,
5322 bgp_show_type_flap_statistics,
5323 bgp_show_type_flap_address,
5324 bgp_show_type_flap_prefix,
5325 bgp_show_type_flap_cidr_only,
5326 bgp_show_type_flap_regexp,
5327 bgp_show_type_flap_filter_list,
5328 bgp_show_type_flap_prefix_list,
5329 bgp_show_type_flap_prefix_longer,
5330 bgp_show_type_flap_route_map,
5331 bgp_show_type_flap_neighbor,
5332 bgp_show_type_dampend_paths,
5333 bgp_show_type_damp_neighbor
5334};
5335
ajs5a646652004-11-05 01:25:55 +00005336static int
paulfee0f4c2004-09-13 05:12:46 +00005337bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00005338 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00005339{
paul718e3742002-12-13 20:15:29 +00005340 struct bgp_info *ri;
5341 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00005342 int header = 1;
paul718e3742002-12-13 20:15:29 +00005343 int display;
ajs5a646652004-11-05 01:25:55 +00005344 unsigned long output_count;
paul718e3742002-12-13 20:15:29 +00005345
5346 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00005347 output_count = 0;
paul718e3742002-12-13 20:15:29 +00005348
paul718e3742002-12-13 20:15:29 +00005349 /* Start processing of routes. */
5350 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5351 if (rn->info != NULL)
5352 {
5353 display = 0;
5354
5355 for (ri = rn->info; ri; ri = ri->next)
5356 {
ajs5a646652004-11-05 01:25:55 +00005357 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00005358 || type == bgp_show_type_flap_address
5359 || type == bgp_show_type_flap_prefix
5360 || type == bgp_show_type_flap_cidr_only
5361 || type == bgp_show_type_flap_regexp
5362 || type == bgp_show_type_flap_filter_list
5363 || type == bgp_show_type_flap_prefix_list
5364 || type == bgp_show_type_flap_prefix_longer
5365 || type == bgp_show_type_flap_route_map
5366 || type == bgp_show_type_flap_neighbor
5367 || type == bgp_show_type_dampend_paths
5368 || type == bgp_show_type_damp_neighbor)
5369 {
5370 if (! ri->damp_info)
5371 continue;
5372 }
5373 if (type == bgp_show_type_regexp
5374 || type == bgp_show_type_flap_regexp)
5375 {
ajs5a646652004-11-05 01:25:55 +00005376 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00005377
5378 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
5379 continue;
5380 }
5381 if (type == bgp_show_type_prefix_list
5382 || type == bgp_show_type_flap_prefix_list)
5383 {
ajs5a646652004-11-05 01:25:55 +00005384 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00005385
5386 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
5387 continue;
5388 }
5389 if (type == bgp_show_type_filter_list
5390 || type == bgp_show_type_flap_filter_list)
5391 {
ajs5a646652004-11-05 01:25:55 +00005392 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00005393
5394 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
5395 continue;
5396 }
5397 if (type == bgp_show_type_route_map
5398 || type == bgp_show_type_flap_route_map)
5399 {
ajs5a646652004-11-05 01:25:55 +00005400 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00005401 struct bgp_info binfo;
5402 struct attr dummy_attr;
5403 int ret;
5404
5405 dummy_attr = *ri->attr;
5406 binfo.peer = ri->peer;
5407 binfo.attr = &dummy_attr;
5408
5409 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
5410
5411 if (ret == RMAP_DENYMATCH)
5412 continue;
5413 }
5414 if (type == bgp_show_type_neighbor
5415 || type == bgp_show_type_flap_neighbor
5416 || type == bgp_show_type_damp_neighbor)
5417 {
ajs5a646652004-11-05 01:25:55 +00005418 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00005419
5420 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
5421 continue;
5422 }
5423 if (type == bgp_show_type_cidr_only
5424 || type == bgp_show_type_flap_cidr_only)
5425 {
5426 u_int32_t destination;
5427
5428 destination = ntohl (rn->p.u.prefix4.s_addr);
5429 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
5430 continue;
5431 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
5432 continue;
5433 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
5434 continue;
5435 }
5436 if (type == bgp_show_type_prefix_longer
5437 || type == bgp_show_type_flap_prefix_longer)
5438 {
ajs5a646652004-11-05 01:25:55 +00005439 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00005440
5441 if (! prefix_match (p, &rn->p))
5442 continue;
5443 }
5444 if (type == bgp_show_type_community_all)
5445 {
5446 if (! ri->attr->community)
5447 continue;
5448 }
5449 if (type == bgp_show_type_community)
5450 {
ajs5a646652004-11-05 01:25:55 +00005451 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00005452
5453 if (! ri->attr->community ||
5454 ! community_match (ri->attr->community, com))
5455 continue;
5456 }
5457 if (type == bgp_show_type_community_exact)
5458 {
ajs5a646652004-11-05 01:25:55 +00005459 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00005460
5461 if (! ri->attr->community ||
5462 ! community_cmp (ri->attr->community, com))
5463 continue;
5464 }
5465 if (type == bgp_show_type_community_list)
5466 {
ajs5a646652004-11-05 01:25:55 +00005467 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00005468
5469 if (! community_list_match (ri->attr->community, list))
5470 continue;
5471 }
5472 if (type == bgp_show_type_community_list_exact)
5473 {
ajs5a646652004-11-05 01:25:55 +00005474 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00005475
5476 if (! community_list_exact_match (ri->attr->community, list))
5477 continue;
5478 }
5479 if (type == bgp_show_type_flap_address
5480 || type == bgp_show_type_flap_prefix)
5481 {
ajs5a646652004-11-05 01:25:55 +00005482 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00005483
5484 if (! prefix_match (&rn->p, p))
5485 continue;
5486
5487 if (type == bgp_show_type_flap_prefix)
5488 if (p->prefixlen != rn->p.prefixlen)
5489 continue;
5490 }
5491 if (type == bgp_show_type_dampend_paths
5492 || type == bgp_show_type_damp_neighbor)
5493 {
5494 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
5495 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
5496 continue;
5497 }
5498
5499 if (header)
5500 {
hasso93406d82005-02-02 14:40:33 +00005501 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
5502 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
5503 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005504 if (type == bgp_show_type_dampend_paths
5505 || type == bgp_show_type_damp_neighbor)
5506 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
5507 else if (type == bgp_show_type_flap_statistics
5508 || type == bgp_show_type_flap_address
5509 || type == bgp_show_type_flap_prefix
5510 || type == bgp_show_type_flap_cidr_only
5511 || type == bgp_show_type_flap_regexp
5512 || type == bgp_show_type_flap_filter_list
5513 || type == bgp_show_type_flap_prefix_list
5514 || type == bgp_show_type_flap_prefix_longer
5515 || type == bgp_show_type_flap_route_map
5516 || type == bgp_show_type_flap_neighbor)
5517 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
5518 else
5519 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005520 header = 0;
5521 }
5522
5523 if (type == bgp_show_type_dampend_paths
5524 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00005525 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005526 else if (type == bgp_show_type_flap_statistics
5527 || type == bgp_show_type_flap_address
5528 || type == bgp_show_type_flap_prefix
5529 || type == bgp_show_type_flap_cidr_only
5530 || type == bgp_show_type_flap_regexp
5531 || type == bgp_show_type_flap_filter_list
5532 || type == bgp_show_type_flap_prefix_list
5533 || type == bgp_show_type_flap_prefix_longer
5534 || type == bgp_show_type_flap_route_map
5535 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00005536 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005537 else
ajs5a646652004-11-05 01:25:55 +00005538 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005539 display++;
5540 }
5541 if (display)
ajs5a646652004-11-05 01:25:55 +00005542 output_count++;
paul718e3742002-12-13 20:15:29 +00005543 }
5544
5545 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00005546 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00005547 {
5548 if (type == bgp_show_type_normal)
5549 vty_out (vty, "No BGP network exists%s", VTY_NEWLINE);
5550 }
5551 else
5552 vty_out (vty, "%sTotal number of prefixes %ld%s",
ajs5a646652004-11-05 01:25:55 +00005553 VTY_NEWLINE, output_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005554
5555 return CMD_SUCCESS;
5556}
5557
ajs5a646652004-11-05 01:25:55 +00005558static int
paulfee0f4c2004-09-13 05:12:46 +00005559bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00005560 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00005561{
5562 struct bgp_table *table;
5563
5564 if (bgp == NULL) {
5565 bgp = bgp_get_default ();
5566 }
5567
5568 if (bgp == NULL)
5569 {
5570 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
5571 return CMD_WARNING;
5572 }
5573
5574
5575 table = bgp->rib[afi][safi];
5576
ajs5a646652004-11-05 01:25:55 +00005577 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00005578}
5579
paul718e3742002-12-13 20:15:29 +00005580/* Header of detailed BGP route information */
5581void
5582route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
5583 struct bgp_node *rn,
5584 struct prefix_rd *prd, afi_t afi, safi_t safi)
5585{
5586 struct bgp_info *ri;
5587 struct prefix *p;
5588 struct peer *peer;
5589 struct listnode *nn;
5590 char buf1[INET6_ADDRSTRLEN];
5591 char buf2[INET6_ADDRSTRLEN];
5592 int count = 0;
5593 int best = 0;
5594 int suppress = 0;
5595 int no_export = 0;
5596 int no_advertise = 0;
5597 int local_as = 0;
5598 int first = 0;
5599
5600 p = &rn->p;
5601 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
5602 (safi == SAFI_MPLS_VPN ?
5603 prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
5604 safi == SAFI_MPLS_VPN ? ":" : "",
5605 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
5606 p->prefixlen, VTY_NEWLINE);
5607
5608 for (ri = rn->info; ri; ri = ri->next)
5609 {
5610 count++;
5611 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
5612 {
5613 best = count;
5614 if (ri->suppress)
5615 suppress = 1;
5616 if (ri->attr->community != NULL)
5617 {
5618 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
5619 no_advertise = 1;
5620 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
5621 no_export = 1;
5622 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
5623 local_as = 1;
5624 }
5625 }
5626 }
5627
5628 vty_out (vty, "Paths: (%d available", count);
5629 if (best)
5630 {
5631 vty_out (vty, ", best #%d", best);
5632 if (safi == SAFI_UNICAST)
5633 vty_out (vty, ", table Default-IP-Routing-Table");
5634 }
5635 else
5636 vty_out (vty, ", no best path");
5637 if (no_advertise)
5638 vty_out (vty, ", not advertised to any peer");
5639 else if (no_export)
5640 vty_out (vty, ", not advertised to EBGP peer");
5641 else if (local_as)
5642 vty_out (vty, ", not advertised outside local AS");
5643 if (suppress)
5644 vty_out (vty, ", Advertisements suppressed by an aggregate.");
5645 vty_out (vty, ")%s", VTY_NEWLINE);
5646
5647 /* advertised peer */
5648 LIST_LOOP (bgp->peer, peer, nn)
5649 {
5650 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
5651 {
5652 if (! first)
5653 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
5654 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
5655 first = 1;
5656 }
5657 }
5658 if (! first)
5659 vty_out (vty, " Not advertised to any peer");
5660 vty_out (vty, "%s", VTY_NEWLINE);
5661}
5662
5663/* Display specified route of BGP table. */
5664int
paulfee0f4c2004-09-13 05:12:46 +00005665bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00005666 struct bgp_table *rib, const char *ip_str,
5667 afi_t afi, safi_t safi, struct prefix_rd *prd,
5668 int prefix_check)
paul718e3742002-12-13 20:15:29 +00005669{
5670 int ret;
5671 int header;
5672 int display = 0;
5673 struct prefix match;
5674 struct bgp_node *rn;
5675 struct bgp_node *rm;
5676 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00005677 struct bgp_table *table;
5678
paul718e3742002-12-13 20:15:29 +00005679 /* Check IP address argument. */
5680 ret = str2prefix (ip_str, &match);
5681 if (! ret)
5682 {
5683 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
5684 return CMD_WARNING;
5685 }
5686
5687 match.family = afi2family (afi);
5688
5689 if (safi == SAFI_MPLS_VPN)
5690 {
paulfee0f4c2004-09-13 05:12:46 +00005691 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00005692 {
5693 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
5694 continue;
5695
5696 if ((table = rn->info) != NULL)
5697 {
5698 header = 1;
5699
5700 if ((rm = bgp_node_match (table, &match)) != NULL)
5701 {
5702 if (prefix_check && rm->p.prefixlen != match.prefixlen)
5703 continue;
5704
5705 for (ri = rm->info; ri; ri = ri->next)
5706 {
5707 if (header)
5708 {
5709 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
5710 AFI_IP, SAFI_MPLS_VPN);
5711
5712 header = 0;
5713 }
5714 display++;
5715 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN);
5716 }
5717 }
5718 }
5719 }
5720 }
5721 else
5722 {
5723 header = 1;
5724
paulfee0f4c2004-09-13 05:12:46 +00005725 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00005726 {
5727 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
5728 {
5729 for (ri = rn->info; ri; ri = ri->next)
5730 {
5731 if (header)
5732 {
5733 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
5734 header = 0;
5735 }
5736 display++;
5737 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
5738 }
5739 }
5740 }
5741 }
5742
5743 if (! display)
5744 {
5745 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
5746 return CMD_WARNING;
5747 }
5748
5749 return CMD_SUCCESS;
5750}
5751
paulfee0f4c2004-09-13 05:12:46 +00005752/* Display specified route of Main RIB */
5753int
paulfd79ac92004-10-13 05:06:08 +00005754bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00005755 afi_t afi, safi_t safi, struct prefix_rd *prd,
5756 int prefix_check)
5757{
5758 struct bgp *bgp;
5759
5760 /* BGP structure lookup. */
5761 if (view_name)
5762 {
5763 bgp = bgp_lookup_by_name (view_name);
5764 if (bgp == NULL)
5765 {
5766 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
5767 return CMD_WARNING;
5768 }
5769 }
5770 else
5771 {
5772 bgp = bgp_get_default ();
5773 if (bgp == NULL)
5774 {
5775 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
5776 return CMD_WARNING;
5777 }
5778 }
5779
5780 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
5781 afi, safi, prd, prefix_check);
5782}
5783
paul718e3742002-12-13 20:15:29 +00005784/* BGP route print out function. */
5785DEFUN (show_ip_bgp,
5786 show_ip_bgp_cmd,
5787 "show ip bgp",
5788 SHOW_STR
5789 IP_STR
5790 BGP_STR)
5791{
ajs5a646652004-11-05 01:25:55 +00005792 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00005793}
5794
5795DEFUN (show_ip_bgp_ipv4,
5796 show_ip_bgp_ipv4_cmd,
5797 "show ip bgp ipv4 (unicast|multicast)",
5798 SHOW_STR
5799 IP_STR
5800 BGP_STR
5801 "Address family\n"
5802 "Address Family modifier\n"
5803 "Address Family modifier\n")
5804{
5805 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00005806 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
5807 NULL);
paul718e3742002-12-13 20:15:29 +00005808
ajs5a646652004-11-05 01:25:55 +00005809 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00005810}
5811
5812DEFUN (show_ip_bgp_route,
5813 show_ip_bgp_route_cmd,
5814 "show ip bgp A.B.C.D",
5815 SHOW_STR
5816 IP_STR
5817 BGP_STR
5818 "Network in the BGP routing table to display\n")
5819{
5820 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
5821}
5822
5823DEFUN (show_ip_bgp_ipv4_route,
5824 show_ip_bgp_ipv4_route_cmd,
5825 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
5826 SHOW_STR
5827 IP_STR
5828 BGP_STR
5829 "Address family\n"
5830 "Address Family modifier\n"
5831 "Address Family modifier\n"
5832 "Network in the BGP routing table to display\n")
5833{
5834 if (strncmp (argv[0], "m", 1) == 0)
5835 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
5836
5837 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
5838}
5839
5840DEFUN (show_ip_bgp_vpnv4_all_route,
5841 show_ip_bgp_vpnv4_all_route_cmd,
5842 "show ip bgp vpnv4 all A.B.C.D",
5843 SHOW_STR
5844 IP_STR
5845 BGP_STR
5846 "Display VPNv4 NLRI specific information\n"
5847 "Display information about all VPNv4 NLRIs\n"
5848 "Network in the BGP routing table to display\n")
5849{
5850 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
5851}
5852
5853DEFUN (show_ip_bgp_vpnv4_rd_route,
5854 show_ip_bgp_vpnv4_rd_route_cmd,
5855 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
5856 SHOW_STR
5857 IP_STR
5858 BGP_STR
5859 "Display VPNv4 NLRI specific information\n"
5860 "Display information for a route distinguisher\n"
5861 "VPN Route Distinguisher\n"
5862 "Network in the BGP routing table to display\n")
5863{
5864 int ret;
5865 struct prefix_rd prd;
5866
5867 ret = str2prefix_rd (argv[0], &prd);
5868 if (! ret)
5869 {
5870 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
5871 return CMD_WARNING;
5872 }
5873 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
5874}
5875
5876DEFUN (show_ip_bgp_prefix,
5877 show_ip_bgp_prefix_cmd,
5878 "show ip bgp A.B.C.D/M",
5879 SHOW_STR
5880 IP_STR
5881 BGP_STR
5882 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5883{
5884 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
5885}
5886
5887DEFUN (show_ip_bgp_ipv4_prefix,
5888 show_ip_bgp_ipv4_prefix_cmd,
5889 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
5890 SHOW_STR
5891 IP_STR
5892 BGP_STR
5893 "Address family\n"
5894 "Address Family modifier\n"
5895 "Address Family modifier\n"
5896 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5897{
5898 if (strncmp (argv[0], "m", 1) == 0)
5899 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
5900
5901 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
5902}
5903
5904DEFUN (show_ip_bgp_vpnv4_all_prefix,
5905 show_ip_bgp_vpnv4_all_prefix_cmd,
5906 "show ip bgp vpnv4 all A.B.C.D/M",
5907 SHOW_STR
5908 IP_STR
5909 BGP_STR
5910 "Display VPNv4 NLRI specific information\n"
5911 "Display information about all VPNv4 NLRIs\n"
5912 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5913{
5914 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
5915}
5916
5917DEFUN (show_ip_bgp_vpnv4_rd_prefix,
5918 show_ip_bgp_vpnv4_rd_prefix_cmd,
5919 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
5920 SHOW_STR
5921 IP_STR
5922 BGP_STR
5923 "Display VPNv4 NLRI specific information\n"
5924 "Display information for a route distinguisher\n"
5925 "VPN Route Distinguisher\n"
5926 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5927{
5928 int ret;
5929 struct prefix_rd prd;
5930
5931 ret = str2prefix_rd (argv[0], &prd);
5932 if (! ret)
5933 {
5934 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
5935 return CMD_WARNING;
5936 }
5937 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
5938}
5939
5940DEFUN (show_ip_bgp_view,
5941 show_ip_bgp_view_cmd,
5942 "show ip bgp view WORD",
5943 SHOW_STR
5944 IP_STR
5945 BGP_STR
5946 "BGP view\n"
5947 "BGP view name\n")
5948{
paulbb46e942003-10-24 19:02:03 +00005949 struct bgp *bgp;
5950
5951 /* BGP structure lookup. */
5952 bgp = bgp_lookup_by_name (argv[0]);
5953 if (bgp == NULL)
5954 {
5955 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
5956 return CMD_WARNING;
5957 }
5958
ajs5a646652004-11-05 01:25:55 +00005959 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00005960}
5961
5962DEFUN (show_ip_bgp_view_route,
5963 show_ip_bgp_view_route_cmd,
5964 "show ip bgp view WORD A.B.C.D",
5965 SHOW_STR
5966 IP_STR
5967 BGP_STR
5968 "BGP view\n"
5969 "BGP view name\n"
5970 "Network in the BGP routing table to display\n")
5971{
5972 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
5973}
5974
5975DEFUN (show_ip_bgp_view_prefix,
5976 show_ip_bgp_view_prefix_cmd,
5977 "show ip bgp view WORD A.B.C.D/M",
5978 SHOW_STR
5979 IP_STR
5980 BGP_STR
5981 "BGP view\n"
5982 "BGP view name\n"
5983 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5984{
5985 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
5986}
5987
5988#ifdef HAVE_IPV6
5989DEFUN (show_bgp,
5990 show_bgp_cmd,
5991 "show bgp",
5992 SHOW_STR
5993 BGP_STR)
5994{
ajs5a646652004-11-05 01:25:55 +00005995 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
5996 NULL);
paul718e3742002-12-13 20:15:29 +00005997}
5998
5999ALIAS (show_bgp,
6000 show_bgp_ipv6_cmd,
6001 "show bgp ipv6",
6002 SHOW_STR
6003 BGP_STR
6004 "Address family\n")
6005
6006/* old command */
6007DEFUN (show_ipv6_bgp,
6008 show_ipv6_bgp_cmd,
6009 "show ipv6 bgp",
6010 SHOW_STR
6011 IP_STR
6012 BGP_STR)
6013{
ajs5a646652004-11-05 01:25:55 +00006014 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
6015 NULL);
paul718e3742002-12-13 20:15:29 +00006016}
6017
6018DEFUN (show_bgp_route,
6019 show_bgp_route_cmd,
6020 "show bgp X:X::X:X",
6021 SHOW_STR
6022 BGP_STR
6023 "Network in the BGP routing table to display\n")
6024{
6025 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
6026}
6027
6028ALIAS (show_bgp_route,
6029 show_bgp_ipv6_route_cmd,
6030 "show bgp ipv6 X:X::X:X",
6031 SHOW_STR
6032 BGP_STR
6033 "Address family\n"
6034 "Network in the BGP routing table to display\n")
6035
6036/* old command */
6037DEFUN (show_ipv6_bgp_route,
6038 show_ipv6_bgp_route_cmd,
6039 "show ipv6 bgp X:X::X:X",
6040 SHOW_STR
6041 IP_STR
6042 BGP_STR
6043 "Network in the BGP routing table to display\n")
6044{
6045 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
6046}
6047
6048DEFUN (show_bgp_prefix,
6049 show_bgp_prefix_cmd,
6050 "show bgp X:X::X:X/M",
6051 SHOW_STR
6052 BGP_STR
6053 "IPv6 prefix <network>/<length>\n")
6054{
6055 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
6056}
6057
6058ALIAS (show_bgp_prefix,
6059 show_bgp_ipv6_prefix_cmd,
6060 "show bgp ipv6 X:X::X:X/M",
6061 SHOW_STR
6062 BGP_STR
6063 "Address family\n"
6064 "IPv6 prefix <network>/<length>\n")
6065
6066/* old command */
6067DEFUN (show_ipv6_bgp_prefix,
6068 show_ipv6_bgp_prefix_cmd,
6069 "show ipv6 bgp X:X::X:X/M",
6070 SHOW_STR
6071 IP_STR
6072 BGP_STR
6073 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6074{
6075 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
6076}
6077
paulbb46e942003-10-24 19:02:03 +00006078DEFUN (show_bgp_view,
6079 show_bgp_view_cmd,
6080 "show bgp view WORD",
6081 SHOW_STR
6082 BGP_STR
6083 "BGP view\n"
6084 "View name\n")
6085{
6086 struct bgp *bgp;
6087
6088 /* BGP structure lookup. */
6089 bgp = bgp_lookup_by_name (argv[0]);
6090 if (bgp == NULL)
6091 {
6092 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
6093 return CMD_WARNING;
6094 }
6095
ajs5a646652004-11-05 01:25:55 +00006096 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00006097}
6098
6099ALIAS (show_bgp_view,
6100 show_bgp_view_ipv6_cmd,
6101 "show bgp view WORD ipv6",
6102 SHOW_STR
6103 BGP_STR
6104 "BGP view\n"
6105 "View name\n"
6106 "Address family\n")
6107
6108DEFUN (show_bgp_view_route,
6109 show_bgp_view_route_cmd,
6110 "show bgp view WORD X:X::X:X",
6111 SHOW_STR
6112 BGP_STR
6113 "BGP view\n"
6114 "View name\n"
6115 "Network in the BGP routing table to display\n")
6116{
6117 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
6118}
6119
6120ALIAS (show_bgp_view_route,
6121 show_bgp_view_ipv6_route_cmd,
6122 "show bgp view WORD ipv6 X:X::X:X",
6123 SHOW_STR
6124 BGP_STR
6125 "BGP view\n"
6126 "View name\n"
6127 "Address family\n"
6128 "Network in the BGP routing table to display\n")
6129
6130DEFUN (show_bgp_view_prefix,
6131 show_bgp_view_prefix_cmd,
6132 "show bgp view WORD X:X::X:X/M",
6133 SHOW_STR
6134 BGP_STR
6135 "BGP view\n"
6136 "View name\n"
6137 "IPv6 prefix <network>/<length>\n")
6138{
6139 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
6140}
6141
6142ALIAS (show_bgp_view_prefix,
6143 show_bgp_view_ipv6_prefix_cmd,
6144 "show bgp view WORD ipv6 X:X::X:X/M",
6145 SHOW_STR
6146 BGP_STR
6147 "BGP view\n"
6148 "View name\n"
6149 "Address family\n"
6150 "IPv6 prefix <network>/<length>\n")
6151
paul718e3742002-12-13 20:15:29 +00006152/* old command */
6153DEFUN (show_ipv6_mbgp,
6154 show_ipv6_mbgp_cmd,
6155 "show ipv6 mbgp",
6156 SHOW_STR
6157 IP_STR
6158 MBGP_STR)
6159{
ajs5a646652004-11-05 01:25:55 +00006160 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
6161 NULL);
paul718e3742002-12-13 20:15:29 +00006162}
6163
6164/* old command */
6165DEFUN (show_ipv6_mbgp_route,
6166 show_ipv6_mbgp_route_cmd,
6167 "show ipv6 mbgp X:X::X:X",
6168 SHOW_STR
6169 IP_STR
6170 MBGP_STR
6171 "Network in the MBGP routing table to display\n")
6172{
6173 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
6174}
6175
6176/* old command */
6177DEFUN (show_ipv6_mbgp_prefix,
6178 show_ipv6_mbgp_prefix_cmd,
6179 "show ipv6 mbgp X:X::X:X/M",
6180 SHOW_STR
6181 IP_STR
6182 MBGP_STR
6183 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6184{
6185 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
6186}
6187#endif
6188
paul718e3742002-12-13 20:15:29 +00006189
6190int
paulfd79ac92004-10-13 05:06:08 +00006191bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006192 safi_t safi, enum bgp_show_type type)
6193{
6194 int i;
6195 struct buffer *b;
6196 char *regstr;
6197 int first;
6198 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00006199 int rc;
paul718e3742002-12-13 20:15:29 +00006200
6201 first = 0;
6202 b = buffer_new (1024);
6203 for (i = 0; i < argc; i++)
6204 {
6205 if (first)
6206 buffer_putc (b, ' ');
6207 else
6208 {
6209 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
6210 continue;
6211 first = 1;
6212 }
6213
6214 buffer_putstr (b, argv[i]);
6215 }
6216 buffer_putc (b, '\0');
6217
6218 regstr = buffer_getstr (b);
6219 buffer_free (b);
6220
6221 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00006222 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00006223 if (! regex)
6224 {
6225 vty_out (vty, "Can't compile regexp %s%s", argv[0],
6226 VTY_NEWLINE);
6227 return CMD_WARNING;
6228 }
6229
ajs5a646652004-11-05 01:25:55 +00006230 rc = bgp_show (vty, NULL, afi, safi, type, regex);
6231 bgp_regex_free (regex);
6232 return rc;
paul718e3742002-12-13 20:15:29 +00006233}
6234
6235DEFUN (show_ip_bgp_regexp,
6236 show_ip_bgp_regexp_cmd,
6237 "show ip bgp regexp .LINE",
6238 SHOW_STR
6239 IP_STR
6240 BGP_STR
6241 "Display routes matching the AS path regular expression\n"
6242 "A regular-expression to match the BGP AS paths\n")
6243{
6244 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
6245 bgp_show_type_regexp);
6246}
6247
6248DEFUN (show_ip_bgp_flap_regexp,
6249 show_ip_bgp_flap_regexp_cmd,
6250 "show ip bgp flap-statistics regexp .LINE",
6251 SHOW_STR
6252 IP_STR
6253 BGP_STR
6254 "Display flap statistics of routes\n"
6255 "Display routes matching the AS path regular expression\n"
6256 "A regular-expression to match the BGP AS paths\n")
6257{
6258 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
6259 bgp_show_type_flap_regexp);
6260}
6261
6262DEFUN (show_ip_bgp_ipv4_regexp,
6263 show_ip_bgp_ipv4_regexp_cmd,
6264 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
6265 SHOW_STR
6266 IP_STR
6267 BGP_STR
6268 "Address family\n"
6269 "Address Family modifier\n"
6270 "Address Family modifier\n"
6271 "Display routes matching the AS path regular expression\n"
6272 "A regular-expression to match the BGP AS paths\n")
6273{
6274 if (strncmp (argv[0], "m", 1) == 0)
6275 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
6276 bgp_show_type_regexp);
6277
6278 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
6279 bgp_show_type_regexp);
6280}
6281
6282#ifdef HAVE_IPV6
6283DEFUN (show_bgp_regexp,
6284 show_bgp_regexp_cmd,
6285 "show bgp regexp .LINE",
6286 SHOW_STR
6287 BGP_STR
6288 "Display routes matching the AS path regular expression\n"
6289 "A regular-expression to match the BGP AS paths\n")
6290{
6291 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
6292 bgp_show_type_regexp);
6293}
6294
6295ALIAS (show_bgp_regexp,
6296 show_bgp_ipv6_regexp_cmd,
6297 "show bgp ipv6 regexp .LINE",
6298 SHOW_STR
6299 BGP_STR
6300 "Address family\n"
6301 "Display routes matching the AS path regular expression\n"
6302 "A regular-expression to match the BGP AS paths\n")
6303
6304/* old command */
6305DEFUN (show_ipv6_bgp_regexp,
6306 show_ipv6_bgp_regexp_cmd,
6307 "show ipv6 bgp regexp .LINE",
6308 SHOW_STR
6309 IP_STR
6310 BGP_STR
6311 "Display routes matching the AS path regular expression\n"
6312 "A regular-expression to match the BGP AS paths\n")
6313{
6314 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
6315 bgp_show_type_regexp);
6316}
6317
6318/* old command */
6319DEFUN (show_ipv6_mbgp_regexp,
6320 show_ipv6_mbgp_regexp_cmd,
6321 "show ipv6 mbgp regexp .LINE",
6322 SHOW_STR
6323 IP_STR
6324 BGP_STR
6325 "Display routes matching the AS path regular expression\n"
6326 "A regular-expression to match the MBGP AS paths\n")
6327{
6328 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
6329 bgp_show_type_regexp);
6330}
6331#endif /* HAVE_IPV6 */
6332
6333int
paulfd79ac92004-10-13 05:06:08 +00006334bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006335 safi_t safi, enum bgp_show_type type)
6336{
6337 struct prefix_list *plist;
6338
6339 plist = prefix_list_lookup (afi, prefix_list_str);
6340 if (plist == NULL)
6341 {
6342 vty_out (vty, "%% %s is not a valid prefix-list name%s",
6343 prefix_list_str, VTY_NEWLINE);
6344 return CMD_WARNING;
6345 }
6346
ajs5a646652004-11-05 01:25:55 +00006347 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00006348}
6349
6350DEFUN (show_ip_bgp_prefix_list,
6351 show_ip_bgp_prefix_list_cmd,
6352 "show ip bgp prefix-list WORD",
6353 SHOW_STR
6354 IP_STR
6355 BGP_STR
6356 "Display routes conforming to the prefix-list\n"
6357 "IP prefix-list name\n")
6358{
6359 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6360 bgp_show_type_prefix_list);
6361}
6362
6363DEFUN (show_ip_bgp_flap_prefix_list,
6364 show_ip_bgp_flap_prefix_list_cmd,
6365 "show ip bgp flap-statistics prefix-list WORD",
6366 SHOW_STR
6367 IP_STR
6368 BGP_STR
6369 "Display flap statistics of routes\n"
6370 "Display routes conforming to the prefix-list\n"
6371 "IP prefix-list name\n")
6372{
6373 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6374 bgp_show_type_flap_prefix_list);
6375}
6376
6377DEFUN (show_ip_bgp_ipv4_prefix_list,
6378 show_ip_bgp_ipv4_prefix_list_cmd,
6379 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
6380 SHOW_STR
6381 IP_STR
6382 BGP_STR
6383 "Address family\n"
6384 "Address Family modifier\n"
6385 "Address Family modifier\n"
6386 "Display routes conforming to the prefix-list\n"
6387 "IP prefix-list name\n")
6388{
6389 if (strncmp (argv[0], "m", 1) == 0)
6390 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
6391 bgp_show_type_prefix_list);
6392
6393 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
6394 bgp_show_type_prefix_list);
6395}
6396
6397#ifdef HAVE_IPV6
6398DEFUN (show_bgp_prefix_list,
6399 show_bgp_prefix_list_cmd,
6400 "show bgp prefix-list WORD",
6401 SHOW_STR
6402 BGP_STR
6403 "Display routes conforming to the prefix-list\n"
6404 "IPv6 prefix-list name\n")
6405{
6406 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6407 bgp_show_type_prefix_list);
6408}
6409
6410ALIAS (show_bgp_prefix_list,
6411 show_bgp_ipv6_prefix_list_cmd,
6412 "show bgp ipv6 prefix-list WORD",
6413 SHOW_STR
6414 BGP_STR
6415 "Address family\n"
6416 "Display routes conforming to the prefix-list\n"
6417 "IPv6 prefix-list name\n")
6418
6419/* old command */
6420DEFUN (show_ipv6_bgp_prefix_list,
6421 show_ipv6_bgp_prefix_list_cmd,
6422 "show ipv6 bgp prefix-list WORD",
6423 SHOW_STR
6424 IPV6_STR
6425 BGP_STR
6426 "Display routes matching the prefix-list\n"
6427 "IPv6 prefix-list name\n")
6428{
6429 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6430 bgp_show_type_prefix_list);
6431}
6432
6433/* old command */
6434DEFUN (show_ipv6_mbgp_prefix_list,
6435 show_ipv6_mbgp_prefix_list_cmd,
6436 "show ipv6 mbgp prefix-list WORD",
6437 SHOW_STR
6438 IPV6_STR
6439 MBGP_STR
6440 "Display routes matching the prefix-list\n"
6441 "IPv6 prefix-list name\n")
6442{
6443 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
6444 bgp_show_type_prefix_list);
6445}
6446#endif /* HAVE_IPV6 */
6447
6448int
paulfd79ac92004-10-13 05:06:08 +00006449bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006450 safi_t safi, enum bgp_show_type type)
6451{
6452 struct as_list *as_list;
6453
6454 as_list = as_list_lookup (filter);
6455 if (as_list == NULL)
6456 {
6457 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
6458 return CMD_WARNING;
6459 }
6460
ajs5a646652004-11-05 01:25:55 +00006461 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00006462}
6463
6464DEFUN (show_ip_bgp_filter_list,
6465 show_ip_bgp_filter_list_cmd,
6466 "show ip bgp filter-list WORD",
6467 SHOW_STR
6468 IP_STR
6469 BGP_STR
6470 "Display routes conforming to the filter-list\n"
6471 "Regular expression access list name\n")
6472{
6473 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6474 bgp_show_type_filter_list);
6475}
6476
6477DEFUN (show_ip_bgp_flap_filter_list,
6478 show_ip_bgp_flap_filter_list_cmd,
6479 "show ip bgp flap-statistics filter-list WORD",
6480 SHOW_STR
6481 IP_STR
6482 BGP_STR
6483 "Display flap statistics of routes\n"
6484 "Display routes conforming to the filter-list\n"
6485 "Regular expression access list name\n")
6486{
6487 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6488 bgp_show_type_flap_filter_list);
6489}
6490
6491DEFUN (show_ip_bgp_ipv4_filter_list,
6492 show_ip_bgp_ipv4_filter_list_cmd,
6493 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
6494 SHOW_STR
6495 IP_STR
6496 BGP_STR
6497 "Address family\n"
6498 "Address Family modifier\n"
6499 "Address Family modifier\n"
6500 "Display routes conforming to the filter-list\n"
6501 "Regular expression access list name\n")
6502{
6503 if (strncmp (argv[0], "m", 1) == 0)
6504 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
6505 bgp_show_type_filter_list);
6506
6507 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
6508 bgp_show_type_filter_list);
6509}
6510
6511#ifdef HAVE_IPV6
6512DEFUN (show_bgp_filter_list,
6513 show_bgp_filter_list_cmd,
6514 "show bgp filter-list WORD",
6515 SHOW_STR
6516 BGP_STR
6517 "Display routes conforming to the filter-list\n"
6518 "Regular expression access list name\n")
6519{
6520 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6521 bgp_show_type_filter_list);
6522}
6523
6524ALIAS (show_bgp_filter_list,
6525 show_bgp_ipv6_filter_list_cmd,
6526 "show bgp ipv6 filter-list WORD",
6527 SHOW_STR
6528 BGP_STR
6529 "Address family\n"
6530 "Display routes conforming to the filter-list\n"
6531 "Regular expression access list name\n")
6532
6533/* old command */
6534DEFUN (show_ipv6_bgp_filter_list,
6535 show_ipv6_bgp_filter_list_cmd,
6536 "show ipv6 bgp filter-list WORD",
6537 SHOW_STR
6538 IPV6_STR
6539 BGP_STR
6540 "Display routes conforming to the filter-list\n"
6541 "Regular expression access list name\n")
6542{
6543 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6544 bgp_show_type_filter_list);
6545}
6546
6547/* old command */
6548DEFUN (show_ipv6_mbgp_filter_list,
6549 show_ipv6_mbgp_filter_list_cmd,
6550 "show ipv6 mbgp filter-list WORD",
6551 SHOW_STR
6552 IPV6_STR
6553 MBGP_STR
6554 "Display routes conforming to the filter-list\n"
6555 "Regular expression access list name\n")
6556{
6557 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
6558 bgp_show_type_filter_list);
6559}
6560#endif /* HAVE_IPV6 */
6561
6562int
paulfd79ac92004-10-13 05:06:08 +00006563bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006564 safi_t safi, enum bgp_show_type type)
6565{
6566 struct route_map *rmap;
6567
6568 rmap = route_map_lookup_by_name (rmap_str);
6569 if (! rmap)
6570 {
6571 vty_out (vty, "%% %s is not a valid route-map name%s",
6572 rmap_str, VTY_NEWLINE);
6573 return CMD_WARNING;
6574 }
6575
ajs5a646652004-11-05 01:25:55 +00006576 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00006577}
6578
6579DEFUN (show_ip_bgp_route_map,
6580 show_ip_bgp_route_map_cmd,
6581 "show ip bgp route-map WORD",
6582 SHOW_STR
6583 IP_STR
6584 BGP_STR
6585 "Display routes matching the route-map\n"
6586 "A route-map to match on\n")
6587{
6588 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
6589 bgp_show_type_route_map);
6590}
6591
6592DEFUN (show_ip_bgp_flap_route_map,
6593 show_ip_bgp_flap_route_map_cmd,
6594 "show ip bgp flap-statistics route-map WORD",
6595 SHOW_STR
6596 IP_STR
6597 BGP_STR
6598 "Display flap statistics of routes\n"
6599 "Display routes matching the route-map\n"
6600 "A route-map to match on\n")
6601{
6602 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
6603 bgp_show_type_flap_route_map);
6604}
6605
6606DEFUN (show_ip_bgp_ipv4_route_map,
6607 show_ip_bgp_ipv4_route_map_cmd,
6608 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
6609 SHOW_STR
6610 IP_STR
6611 BGP_STR
6612 "Address family\n"
6613 "Address Family modifier\n"
6614 "Address Family modifier\n"
6615 "Display routes matching the route-map\n"
6616 "A route-map to match on\n")
6617{
6618 if (strncmp (argv[0], "m", 1) == 0)
6619 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
6620 bgp_show_type_route_map);
6621
6622 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
6623 bgp_show_type_route_map);
6624}
6625
6626DEFUN (show_bgp_route_map,
6627 show_bgp_route_map_cmd,
6628 "show bgp route-map WORD",
6629 SHOW_STR
6630 BGP_STR
6631 "Display routes matching the route-map\n"
6632 "A route-map to match on\n")
6633{
6634 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6635 bgp_show_type_route_map);
6636}
6637
6638ALIAS (show_bgp_route_map,
6639 show_bgp_ipv6_route_map_cmd,
6640 "show bgp ipv6 route-map WORD",
6641 SHOW_STR
6642 BGP_STR
6643 "Address family\n"
6644 "Display routes matching the route-map\n"
6645 "A route-map to match on\n")
6646
6647DEFUN (show_ip_bgp_cidr_only,
6648 show_ip_bgp_cidr_only_cmd,
6649 "show ip bgp cidr-only",
6650 SHOW_STR
6651 IP_STR
6652 BGP_STR
6653 "Display only routes with non-natural netmasks\n")
6654{
6655 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006656 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006657}
6658
6659DEFUN (show_ip_bgp_flap_cidr_only,
6660 show_ip_bgp_flap_cidr_only_cmd,
6661 "show ip bgp flap-statistics cidr-only",
6662 SHOW_STR
6663 IP_STR
6664 BGP_STR
6665 "Display flap statistics of routes\n"
6666 "Display only routes with non-natural netmasks\n")
6667{
6668 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006669 bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006670}
6671
6672DEFUN (show_ip_bgp_ipv4_cidr_only,
6673 show_ip_bgp_ipv4_cidr_only_cmd,
6674 "show ip bgp ipv4 (unicast|multicast) cidr-only",
6675 SHOW_STR
6676 IP_STR
6677 BGP_STR
6678 "Address family\n"
6679 "Address Family modifier\n"
6680 "Address Family modifier\n"
6681 "Display only routes with non-natural netmasks\n")
6682{
6683 if (strncmp (argv[0], "m", 1) == 0)
6684 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00006685 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006686
6687 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006688 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006689}
6690
6691DEFUN (show_ip_bgp_community_all,
6692 show_ip_bgp_community_all_cmd,
6693 "show ip bgp community",
6694 SHOW_STR
6695 IP_STR
6696 BGP_STR
6697 "Display routes matching the communities\n")
6698{
6699 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006700 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006701}
6702
6703DEFUN (show_ip_bgp_ipv4_community_all,
6704 show_ip_bgp_ipv4_community_all_cmd,
6705 "show ip bgp ipv4 (unicast|multicast) community",
6706 SHOW_STR
6707 IP_STR
6708 BGP_STR
6709 "Address family\n"
6710 "Address Family modifier\n"
6711 "Address Family modifier\n"
6712 "Display routes matching the communities\n")
6713{
6714 if (strncmp (argv[0], "m", 1) == 0)
6715 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00006716 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006717
6718 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006719 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006720}
6721
6722#ifdef HAVE_IPV6
6723DEFUN (show_bgp_community_all,
6724 show_bgp_community_all_cmd,
6725 "show bgp community",
6726 SHOW_STR
6727 BGP_STR
6728 "Display routes matching the communities\n")
6729{
6730 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006731 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006732}
6733
6734ALIAS (show_bgp_community_all,
6735 show_bgp_ipv6_community_all_cmd,
6736 "show bgp ipv6 community",
6737 SHOW_STR
6738 BGP_STR
6739 "Address family\n"
6740 "Display routes matching the communities\n")
6741
6742/* old command */
6743DEFUN (show_ipv6_bgp_community_all,
6744 show_ipv6_bgp_community_all_cmd,
6745 "show ipv6 bgp community",
6746 SHOW_STR
6747 IPV6_STR
6748 BGP_STR
6749 "Display routes matching the communities\n")
6750{
6751 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006752 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006753}
6754
6755/* old command */
6756DEFUN (show_ipv6_mbgp_community_all,
6757 show_ipv6_mbgp_community_all_cmd,
6758 "show ipv6 mbgp community",
6759 SHOW_STR
6760 IPV6_STR
6761 MBGP_STR
6762 "Display routes matching the communities\n")
6763{
6764 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00006765 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006766}
6767#endif /* HAVE_IPV6 */
6768
6769int
paulfd79ac92004-10-13 05:06:08 +00006770bgp_show_community (struct vty *vty, int argc, const char **argv, int exact,
6771 u_int16_t afi, u_char safi)
paul718e3742002-12-13 20:15:29 +00006772{
6773 struct community *com;
6774 struct buffer *b;
6775 int i;
6776 char *str;
6777 int first = 0;
6778
6779 b = buffer_new (1024);
6780 for (i = 0; i < argc; i++)
6781 {
6782 if (first)
6783 buffer_putc (b, ' ');
6784 else
6785 {
6786 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
6787 continue;
6788 first = 1;
6789 }
6790
6791 buffer_putstr (b, argv[i]);
6792 }
6793 buffer_putc (b, '\0');
6794
6795 str = buffer_getstr (b);
6796 buffer_free (b);
6797
6798 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00006799 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00006800 if (! com)
6801 {
6802 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
6803 return CMD_WARNING;
6804 }
6805
ajs5a646652004-11-05 01:25:55 +00006806 return bgp_show (vty, NULL, afi, safi,
6807 (exact ? bgp_show_type_community_exact :
6808 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00006809}
6810
6811DEFUN (show_ip_bgp_community,
6812 show_ip_bgp_community_cmd,
6813 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
6814 SHOW_STR
6815 IP_STR
6816 BGP_STR
6817 "Display routes matching the communities\n"
6818 "community number\n"
6819 "Do not send outside local AS (well-known community)\n"
6820 "Do not advertise to any peer (well-known community)\n"
6821 "Do not export to next AS (well-known community)\n")
6822{
6823 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST);
6824}
6825
6826ALIAS (show_ip_bgp_community,
6827 show_ip_bgp_community2_cmd,
6828 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6829 SHOW_STR
6830 IP_STR
6831 BGP_STR
6832 "Display routes matching the communities\n"
6833 "community number\n"
6834 "Do not send outside local AS (well-known community)\n"
6835 "Do not advertise to any peer (well-known community)\n"
6836 "Do not export to next AS (well-known community)\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
6842ALIAS (show_ip_bgp_community,
6843 show_ip_bgp_community3_cmd,
6844 "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)",
6845 SHOW_STR
6846 IP_STR
6847 BGP_STR
6848 "Display routes matching the communities\n"
6849 "community number\n"
6850 "Do not send outside local AS (well-known community)\n"
6851 "Do not advertise to any peer (well-known community)\n"
6852 "Do not export to next AS (well-known community)\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
6862ALIAS (show_ip_bgp_community,
6863 show_ip_bgp_community4_cmd,
6864 "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)",
6865 SHOW_STR
6866 IP_STR
6867 BGP_STR
6868 "Display routes matching the communities\n"
6869 "community number\n"
6870 "Do not send outside local AS (well-known community)\n"
6871 "Do not advertise to any peer (well-known community)\n"
6872 "Do not export to next AS (well-known community)\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
6886DEFUN (show_ip_bgp_ipv4_community,
6887 show_ip_bgp_ipv4_community_cmd,
6888 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
6889 SHOW_STR
6890 IP_STR
6891 BGP_STR
6892 "Address family\n"
6893 "Address Family modifier\n"
6894 "Address Family modifier\n"
6895 "Display routes matching the communities\n"
6896 "community number\n"
6897 "Do not send outside local AS (well-known community)\n"
6898 "Do not advertise to any peer (well-known community)\n"
6899 "Do not export to next AS (well-known community)\n")
6900{
6901 if (strncmp (argv[0], "m", 1) == 0)
6902 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
6903
6904 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST);
6905}
6906
6907ALIAS (show_ip_bgp_ipv4_community,
6908 show_ip_bgp_ipv4_community2_cmd,
6909 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6910 SHOW_STR
6911 IP_STR
6912 BGP_STR
6913 "Address family\n"
6914 "Address Family modifier\n"
6915 "Address Family modifier\n"
6916 "Display routes matching the communities\n"
6917 "community number\n"
6918 "Do not send outside local AS (well-known community)\n"
6919 "Do not advertise to any peer (well-known community)\n"
6920 "Do not export to next AS (well-known community)\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
6926ALIAS (show_ip_bgp_ipv4_community,
6927 show_ip_bgp_ipv4_community3_cmd,
6928 "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)",
6929 SHOW_STR
6930 IP_STR
6931 BGP_STR
6932 "Address family\n"
6933 "Address Family modifier\n"
6934 "Address Family modifier\n"
6935 "Display routes matching the communities\n"
6936 "community number\n"
6937 "Do not send outside local AS (well-known community)\n"
6938 "Do not advertise to any peer (well-known community)\n"
6939 "Do not export to next AS (well-known community)\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
6949ALIAS (show_ip_bgp_ipv4_community,
6950 show_ip_bgp_ipv4_community4_cmd,
6951 "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)",
6952 SHOW_STR
6953 IP_STR
6954 BGP_STR
6955 "Address family\n"
6956 "Address Family modifier\n"
6957 "Address Family modifier\n"
6958 "Display routes matching the communities\n"
6959 "community number\n"
6960 "Do not send outside local AS (well-known community)\n"
6961 "Do not advertise to any peer (well-known community)\n"
6962 "Do not export to next AS (well-known community)\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
6976DEFUN (show_ip_bgp_community_exact,
6977 show_ip_bgp_community_exact_cmd,
6978 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6979 SHOW_STR
6980 IP_STR
6981 BGP_STR
6982 "Display routes matching the communities\n"
6983 "community number\n"
6984 "Do not send outside local AS (well-known community)\n"
6985 "Do not advertise to any peer (well-known community)\n"
6986 "Do not export to next AS (well-known community)\n"
6987 "Exact match of the communities")
6988{
6989 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST);
6990}
6991
6992ALIAS (show_ip_bgp_community_exact,
6993 show_ip_bgp_community2_exact_cmd,
6994 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6995 SHOW_STR
6996 IP_STR
6997 BGP_STR
6998 "Display routes matching the communities\n"
6999 "community number\n"
7000 "Do not send outside local AS (well-known community)\n"
7001 "Do not advertise to any peer (well-known community)\n"
7002 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7008
7009ALIAS (show_ip_bgp_community_exact,
7010 show_ip_bgp_community3_exact_cmd,
7011 "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",
7012 SHOW_STR
7013 IP_STR
7014 BGP_STR
7015 "Display routes matching the communities\n"
7016 "community number\n"
7017 "Do not send outside local AS (well-known community)\n"
7018 "Do not advertise to any peer (well-known community)\n"
7019 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7029
7030ALIAS (show_ip_bgp_community_exact,
7031 show_ip_bgp_community4_exact_cmd,
7032 "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",
7033 SHOW_STR
7034 IP_STR
7035 BGP_STR
7036 "Display routes matching the communities\n"
7037 "community number\n"
7038 "Do not send outside local AS (well-known community)\n"
7039 "Do not advertise to any peer (well-known community)\n"
7040 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7054
7055DEFUN (show_ip_bgp_ipv4_community_exact,
7056 show_ip_bgp_ipv4_community_exact_cmd,
7057 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7058 SHOW_STR
7059 IP_STR
7060 BGP_STR
7061 "Address family\n"
7062 "Address Family modifier\n"
7063 "Address Family modifier\n"
7064 "Display routes matching the communities\n"
7065 "community number\n"
7066 "Do not send outside local AS (well-known community)\n"
7067 "Do not advertise to any peer (well-known community)\n"
7068 "Do not export to next AS (well-known community)\n"
7069 "Exact match of the communities")
7070{
7071 if (strncmp (argv[0], "m", 1) == 0)
7072 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
7073
7074 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST);
7075}
7076
7077ALIAS (show_ip_bgp_ipv4_community_exact,
7078 show_ip_bgp_ipv4_community2_exact_cmd,
7079 "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",
7080 SHOW_STR
7081 IP_STR
7082 BGP_STR
7083 "Address family\n"
7084 "Address Family modifier\n"
7085 "Address Family modifier\n"
7086 "Display routes matching the communities\n"
7087 "community number\n"
7088 "Do not send outside local AS (well-known community)\n"
7089 "Do not advertise to any peer (well-known community)\n"
7090 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7096
7097ALIAS (show_ip_bgp_ipv4_community_exact,
7098 show_ip_bgp_ipv4_community3_exact_cmd,
7099 "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",
7100 SHOW_STR
7101 IP_STR
7102 BGP_STR
7103 "Address family\n"
7104 "Address Family modifier\n"
7105 "Address Family modifier\n"
7106 "Display routes matching the communities\n"
7107 "community number\n"
7108 "Do not send outside local AS (well-known community)\n"
7109 "Do not advertise to any peer (well-known community)\n"
7110 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7120
7121ALIAS (show_ip_bgp_ipv4_community_exact,
7122 show_ip_bgp_ipv4_community4_exact_cmd,
7123 "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",
7124 SHOW_STR
7125 IP_STR
7126 BGP_STR
7127 "Address family\n"
7128 "Address Family modifier\n"
7129 "Address Family modifier\n"
7130 "Display routes matching the communities\n"
7131 "community number\n"
7132 "Do not send outside local AS (well-known community)\n"
7133 "Do not advertise to any peer (well-known community)\n"
7134 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7148
7149#ifdef HAVE_IPV6
7150DEFUN (show_bgp_community,
7151 show_bgp_community_cmd,
7152 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
7153 SHOW_STR
7154 BGP_STR
7155 "Display routes matching the communities\n"
7156 "community number\n"
7157 "Do not send outside local AS (well-known community)\n"
7158 "Do not advertise to any peer (well-known community)\n"
7159 "Do not export to next AS (well-known community)\n")
7160{
7161 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
7162}
7163
7164ALIAS (show_bgp_community,
7165 show_bgp_ipv6_community_cmd,
7166 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
7167 SHOW_STR
7168 BGP_STR
7169 "Address family\n"
7170 "Display routes matching the communities\n"
7171 "community number\n"
7172 "Do not send outside local AS (well-known community)\n"
7173 "Do not advertise to any peer (well-known community)\n"
7174 "Do not export to next AS (well-known community)\n")
7175
7176ALIAS (show_bgp_community,
7177 show_bgp_community2_cmd,
7178 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7179 SHOW_STR
7180 BGP_STR
7181 "Display routes matching the communities\n"
7182 "community number\n"
7183 "Do not send outside local AS (well-known community)\n"
7184 "Do not advertise to any peer (well-known community)\n"
7185 "Do not export to next AS (well-known community)\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
7191ALIAS (show_bgp_community,
7192 show_bgp_ipv6_community2_cmd,
7193 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7194 SHOW_STR
7195 BGP_STR
7196 "Address family\n"
7197 "Display routes matching the communities\n"
7198 "community number\n"
7199 "Do not send outside local AS (well-known community)\n"
7200 "Do not advertise to any peer (well-known community)\n"
7201 "Do not export to next AS (well-known community)\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
7207ALIAS (show_bgp_community,
7208 show_bgp_community3_cmd,
7209 "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)",
7210 SHOW_STR
7211 BGP_STR
7212 "Display routes matching the communities\n"
7213 "community number\n"
7214 "Do not send outside local AS (well-known community)\n"
7215 "Do not advertise to any peer (well-known community)\n"
7216 "Do not export to next AS (well-known community)\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
7226ALIAS (show_bgp_community,
7227 show_bgp_ipv6_community3_cmd,
7228 "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)",
7229 SHOW_STR
7230 BGP_STR
7231 "Address family\n"
7232 "Display routes matching the communities\n"
7233 "community number\n"
7234 "Do not send outside local AS (well-known community)\n"
7235 "Do not advertise to any peer (well-known community)\n"
7236 "Do not export to next AS (well-known community)\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
7246ALIAS (show_bgp_community,
7247 show_bgp_community4_cmd,
7248 "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)",
7249 SHOW_STR
7250 BGP_STR
7251 "Display routes matching the communities\n"
7252 "community number\n"
7253 "Do not send outside local AS (well-known community)\n"
7254 "Do not advertise to any peer (well-known community)\n"
7255 "Do not export to next AS (well-known community)\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
7269ALIAS (show_bgp_community,
7270 show_bgp_ipv6_community4_cmd,
7271 "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)",
7272 SHOW_STR
7273 BGP_STR
7274 "Address family\n"
7275 "Display routes matching the communities\n"
7276 "community number\n"
7277 "Do not send outside local AS (well-known community)\n"
7278 "Do not advertise to any peer (well-known community)\n"
7279 "Do not export to next AS (well-known community)\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
7293/* old command */
7294DEFUN (show_ipv6_bgp_community,
7295 show_ipv6_bgp_community_cmd,
7296 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
7297 SHOW_STR
7298 IPV6_STR
7299 BGP_STR
7300 "Display routes matching the communities\n"
7301 "community number\n"
7302 "Do not send outside local AS (well-known community)\n"
7303 "Do not advertise to any peer (well-known community)\n"
7304 "Do not export to next AS (well-known community)\n")
7305{
7306 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
7307}
7308
7309/* old command */
7310ALIAS (show_ipv6_bgp_community,
7311 show_ipv6_bgp_community2_cmd,
7312 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7313 SHOW_STR
7314 IPV6_STR
7315 BGP_STR
7316 "Display routes matching the communities\n"
7317 "community number\n"
7318 "Do not send outside local AS (well-known community)\n"
7319 "Do not advertise to any peer (well-known community)\n"
7320 "Do not export to next AS (well-known community)\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
7326/* old command */
7327ALIAS (show_ipv6_bgp_community,
7328 show_ipv6_bgp_community3_cmd,
7329 "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)",
7330 SHOW_STR
7331 IPV6_STR
7332 BGP_STR
7333 "Display routes matching the communities\n"
7334 "community number\n"
7335 "Do not send outside local AS (well-known community)\n"
7336 "Do not advertise to any peer (well-known community)\n"
7337 "Do not export to next AS (well-known community)\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
7347/* old command */
7348ALIAS (show_ipv6_bgp_community,
7349 show_ipv6_bgp_community4_cmd,
7350 "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)",
7351 SHOW_STR
7352 IPV6_STR
7353 BGP_STR
7354 "Display routes matching the communities\n"
7355 "community number\n"
7356 "Do not send outside local AS (well-known community)\n"
7357 "Do not advertise to any peer (well-known community)\n"
7358 "Do not export to next AS (well-known community)\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
7372DEFUN (show_bgp_community_exact,
7373 show_bgp_community_exact_cmd,
7374 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7375 SHOW_STR
7376 BGP_STR
7377 "Display routes matching the communities\n"
7378 "community number\n"
7379 "Do not send outside local AS (well-known community)\n"
7380 "Do not advertise to any peer (well-known community)\n"
7381 "Do not export to next AS (well-known community)\n"
7382 "Exact match of the communities")
7383{
7384 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
7385}
7386
7387ALIAS (show_bgp_community_exact,
7388 show_bgp_ipv6_community_exact_cmd,
7389 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7390 SHOW_STR
7391 BGP_STR
7392 "Address family\n"
7393 "Display routes matching the communities\n"
7394 "community number\n"
7395 "Do not send outside local AS (well-known community)\n"
7396 "Do not advertise to any peer (well-known community)\n"
7397 "Do not export to next AS (well-known community)\n"
7398 "Exact match of the communities")
7399
7400ALIAS (show_bgp_community_exact,
7401 show_bgp_community2_exact_cmd,
7402 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7403 SHOW_STR
7404 BGP_STR
7405 "Display routes matching the communities\n"
7406 "community number\n"
7407 "Do not send outside local AS (well-known community)\n"
7408 "Do not advertise to any peer (well-known community)\n"
7409 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7415
7416ALIAS (show_bgp_community_exact,
7417 show_bgp_ipv6_community2_exact_cmd,
7418 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7419 SHOW_STR
7420 BGP_STR
7421 "Address family\n"
7422 "Display routes matching the communities\n"
7423 "community number\n"
7424 "Do not send outside local AS (well-known community)\n"
7425 "Do not advertise to any peer (well-known community)\n"
7426 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7432
7433ALIAS (show_bgp_community_exact,
7434 show_bgp_community3_exact_cmd,
7435 "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",
7436 SHOW_STR
7437 BGP_STR
7438 "Display routes matching the communities\n"
7439 "community number\n"
7440 "Do not send outside local AS (well-known community)\n"
7441 "Do not advertise to any peer (well-known community)\n"
7442 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7452
7453ALIAS (show_bgp_community_exact,
7454 show_bgp_ipv6_community3_exact_cmd,
7455 "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",
7456 SHOW_STR
7457 BGP_STR
7458 "Address family\n"
7459 "Display routes matching the communities\n"
7460 "community number\n"
7461 "Do not send outside local AS (well-known community)\n"
7462 "Do not advertise to any peer (well-known community)\n"
7463 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7473
7474ALIAS (show_bgp_community_exact,
7475 show_bgp_community4_exact_cmd,
7476 "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",
7477 SHOW_STR
7478 BGP_STR
7479 "Display routes matching the communities\n"
7480 "community number\n"
7481 "Do not send outside local AS (well-known community)\n"
7482 "Do not advertise to any peer (well-known community)\n"
7483 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7497
7498ALIAS (show_bgp_community_exact,
7499 show_bgp_ipv6_community4_exact_cmd,
7500 "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",
7501 SHOW_STR
7502 BGP_STR
7503 "Address family\n"
7504 "Display routes matching the communities\n"
7505 "community number\n"
7506 "Do not send outside local AS (well-known community)\n"
7507 "Do not advertise to any peer (well-known community)\n"
7508 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7522
7523/* old command */
7524DEFUN (show_ipv6_bgp_community_exact,
7525 show_ipv6_bgp_community_exact_cmd,
7526 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7527 SHOW_STR
7528 IPV6_STR
7529 BGP_STR
7530 "Display routes matching the communities\n"
7531 "community number\n"
7532 "Do not send outside local AS (well-known community)\n"
7533 "Do not advertise to any peer (well-known community)\n"
7534 "Do not export to next AS (well-known community)\n"
7535 "Exact match of the communities")
7536{
7537 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
7538}
7539
7540/* old command */
7541ALIAS (show_ipv6_bgp_community_exact,
7542 show_ipv6_bgp_community2_exact_cmd,
7543 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7544 SHOW_STR
7545 IPV6_STR
7546 BGP_STR
7547 "Display routes matching the communities\n"
7548 "community number\n"
7549 "Do not send outside local AS (well-known community)\n"
7550 "Do not advertise to any peer (well-known community)\n"
7551 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7557
7558/* old command */
7559ALIAS (show_ipv6_bgp_community_exact,
7560 show_ipv6_bgp_community3_exact_cmd,
7561 "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",
7562 SHOW_STR
7563 IPV6_STR
7564 BGP_STR
7565 "Display routes matching the communities\n"
7566 "community number\n"
7567 "Do not send outside local AS (well-known community)\n"
7568 "Do not advertise to any peer (well-known community)\n"
7569 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7579
7580/* old command */
7581ALIAS (show_ipv6_bgp_community_exact,
7582 show_ipv6_bgp_community4_exact_cmd,
7583 "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",
7584 SHOW_STR
7585 IPV6_STR
7586 BGP_STR
7587 "Display routes matching the communities\n"
7588 "community number\n"
7589 "Do not send outside local AS (well-known community)\n"
7590 "Do not advertise to any peer (well-known community)\n"
7591 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7605
7606/* old command */
7607DEFUN (show_ipv6_mbgp_community,
7608 show_ipv6_mbgp_community_cmd,
7609 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
7610 SHOW_STR
7611 IPV6_STR
7612 MBGP_STR
7613 "Display routes matching the communities\n"
7614 "community number\n"
7615 "Do not send outside local AS (well-known community)\n"
7616 "Do not advertise to any peer (well-known community)\n"
7617 "Do not export to next AS (well-known community)\n")
7618{
7619 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
7620}
7621
7622/* old command */
7623ALIAS (show_ipv6_mbgp_community,
7624 show_ipv6_mbgp_community2_cmd,
7625 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7626 SHOW_STR
7627 IPV6_STR
7628 MBGP_STR
7629 "Display routes matching the communities\n"
7630 "community number\n"
7631 "Do not send outside local AS (well-known community)\n"
7632 "Do not advertise to any peer (well-known community)\n"
7633 "Do not export to next AS (well-known community)\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
7639/* old command */
7640ALIAS (show_ipv6_mbgp_community,
7641 show_ipv6_mbgp_community3_cmd,
7642 "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)",
7643 SHOW_STR
7644 IPV6_STR
7645 MBGP_STR
7646 "Display routes matching the communities\n"
7647 "community number\n"
7648 "Do not send outside local AS (well-known community)\n"
7649 "Do not advertise to any peer (well-known community)\n"
7650 "Do not export to next AS (well-known community)\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
7660/* old command */
7661ALIAS (show_ipv6_mbgp_community,
7662 show_ipv6_mbgp_community4_cmd,
7663 "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)",
7664 SHOW_STR
7665 IPV6_STR
7666 MBGP_STR
7667 "Display routes matching the communities\n"
7668 "community number\n"
7669 "Do not send outside local AS (well-known community)\n"
7670 "Do not advertise to any peer (well-known community)\n"
7671 "Do not export to next AS (well-known community)\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
7685/* old command */
7686DEFUN (show_ipv6_mbgp_community_exact,
7687 show_ipv6_mbgp_community_exact_cmd,
7688 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7689 SHOW_STR
7690 IPV6_STR
7691 MBGP_STR
7692 "Display routes matching the communities\n"
7693 "community number\n"
7694 "Do not send outside local AS (well-known community)\n"
7695 "Do not advertise to any peer (well-known community)\n"
7696 "Do not export to next AS (well-known community)\n"
7697 "Exact match of the communities")
7698{
7699 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
7700}
7701
7702/* old command */
7703ALIAS (show_ipv6_mbgp_community_exact,
7704 show_ipv6_mbgp_community2_exact_cmd,
7705 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7706 SHOW_STR
7707 IPV6_STR
7708 MBGP_STR
7709 "Display routes matching the communities\n"
7710 "community number\n"
7711 "Do not send outside local AS (well-known community)\n"
7712 "Do not advertise to any peer (well-known community)\n"
7713 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7719
7720/* old command */
7721ALIAS (show_ipv6_mbgp_community_exact,
7722 show_ipv6_mbgp_community3_exact_cmd,
7723 "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",
7724 SHOW_STR
7725 IPV6_STR
7726 MBGP_STR
7727 "Display routes matching the communities\n"
7728 "community number\n"
7729 "Do not send outside local AS (well-known community)\n"
7730 "Do not advertise to any peer (well-known community)\n"
7731 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7741
7742/* old command */
7743ALIAS (show_ipv6_mbgp_community_exact,
7744 show_ipv6_mbgp_community4_exact_cmd,
7745 "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",
7746 SHOW_STR
7747 IPV6_STR
7748 MBGP_STR
7749 "Display routes matching the communities\n"
7750 "community number\n"
7751 "Do not send outside local AS (well-known community)\n"
7752 "Do not advertise to any peer (well-known community)\n"
7753 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
7767#endif /* HAVE_IPV6 */
7768
7769int
paulfd79ac92004-10-13 05:06:08 +00007770bgp_show_community_list (struct vty *vty, const char *com, int exact,
paul718e3742002-12-13 20:15:29 +00007771 u_int16_t afi, u_char safi)
7772{
7773 struct community_list *list;
7774
hassofee6e4e2005-02-02 16:29:31 +00007775 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +00007776 if (list == NULL)
7777 {
7778 vty_out (vty, "%% %s is not a valid community-list name%s", com,
7779 VTY_NEWLINE);
7780 return CMD_WARNING;
7781 }
7782
ajs5a646652004-11-05 01:25:55 +00007783 return bgp_show (vty, NULL, afi, safi,
7784 (exact ? bgp_show_type_community_list_exact :
7785 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +00007786}
7787
7788DEFUN (show_ip_bgp_community_list,
7789 show_ip_bgp_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007790 "show ip bgp community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007791 SHOW_STR
7792 IP_STR
7793 BGP_STR
7794 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007795 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007796 "community-list name\n")
7797{
7798 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
7799}
7800
7801DEFUN (show_ip_bgp_ipv4_community_list,
7802 show_ip_bgp_ipv4_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007803 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007804 SHOW_STR
7805 IP_STR
7806 BGP_STR
7807 "Address family\n"
7808 "Address Family modifier\n"
7809 "Address Family modifier\n"
7810 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007811 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007812 "community-list name\n")
7813{
7814 if (strncmp (argv[0], "m", 1) == 0)
7815 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
7816
7817 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
7818}
7819
7820DEFUN (show_ip_bgp_community_list_exact,
7821 show_ip_bgp_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007822 "show ip bgp community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007823 SHOW_STR
7824 IP_STR
7825 BGP_STR
7826 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007827 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007828 "community-list name\n"
7829 "Exact match of the communities\n")
7830{
7831 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
7832}
7833
7834DEFUN (show_ip_bgp_ipv4_community_list_exact,
7835 show_ip_bgp_ipv4_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007836 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007837 SHOW_STR
7838 IP_STR
7839 BGP_STR
7840 "Address family\n"
7841 "Address Family modifier\n"
7842 "Address Family modifier\n"
7843 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007844 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007845 "community-list name\n"
7846 "Exact match of the communities\n")
7847{
7848 if (strncmp (argv[0], "m", 1) == 0)
7849 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
7850
7851 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
7852}
7853
7854#ifdef HAVE_IPV6
7855DEFUN (show_bgp_community_list,
7856 show_bgp_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007857 "show bgp community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007858 SHOW_STR
7859 BGP_STR
7860 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007861 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007862 "community-list name\n")
7863{
7864 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
7865}
7866
7867ALIAS (show_bgp_community_list,
7868 show_bgp_ipv6_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007869 "show bgp ipv6 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007870 SHOW_STR
7871 BGP_STR
7872 "Address family\n"
7873 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007874 "community-list number\n"
7875 "community-list name\n");
paul718e3742002-12-13 20:15:29 +00007876
7877/* old command */
7878DEFUN (show_ipv6_bgp_community_list,
7879 show_ipv6_bgp_community_list_cmd,
7880 "show ipv6 bgp community-list WORD",
7881 SHOW_STR
7882 IPV6_STR
7883 BGP_STR
7884 "Display routes matching the community-list\n"
7885 "community-list name\n")
7886{
7887 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
7888}
7889
7890/* old command */
7891DEFUN (show_ipv6_mbgp_community_list,
7892 show_ipv6_mbgp_community_list_cmd,
7893 "show ipv6 mbgp community-list WORD",
7894 SHOW_STR
7895 IPV6_STR
7896 MBGP_STR
7897 "Display routes matching the community-list\n"
7898 "community-list name\n")
7899{
7900 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
7901}
7902
7903DEFUN (show_bgp_community_list_exact,
7904 show_bgp_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007905 "show bgp community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007906 SHOW_STR
7907 BGP_STR
7908 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007909 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007910 "community-list name\n"
7911 "Exact match of the communities\n")
7912{
7913 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
7914}
7915
7916ALIAS (show_bgp_community_list_exact,
7917 show_bgp_ipv6_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007918 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007919 SHOW_STR
7920 BGP_STR
7921 "Address family\n"
7922 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007923 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007924 "community-list name\n"
7925 "Exact match of the communities\n")
7926
7927/* old command */
7928DEFUN (show_ipv6_bgp_community_list_exact,
7929 show_ipv6_bgp_community_list_exact_cmd,
7930 "show ipv6 bgp community-list WORD exact-match",
7931 SHOW_STR
7932 IPV6_STR
7933 BGP_STR
7934 "Display routes matching the community-list\n"
7935 "community-list name\n"
7936 "Exact match of the communities\n")
7937{
7938 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
7939}
7940
7941/* old command */
7942DEFUN (show_ipv6_mbgp_community_list_exact,
7943 show_ipv6_mbgp_community_list_exact_cmd,
7944 "show ipv6 mbgp community-list WORD exact-match",
7945 SHOW_STR
7946 IPV6_STR
7947 MBGP_STR
7948 "Display routes matching the community-list\n"
7949 "community-list name\n"
7950 "Exact match of the communities\n")
7951{
7952 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
7953}
7954#endif /* HAVE_IPV6 */
7955
paul718e3742002-12-13 20:15:29 +00007956int
paulfd79ac92004-10-13 05:06:08 +00007957bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +00007958 safi_t safi, enum bgp_show_type type)
7959{
7960 int ret;
7961 struct prefix *p;
7962
7963 p = prefix_new();
7964
7965 ret = str2prefix (prefix, p);
7966 if (! ret)
7967 {
7968 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
7969 return CMD_WARNING;
7970 }
7971
ajs5a646652004-11-05 01:25:55 +00007972 ret = bgp_show (vty, NULL, afi, safi, type, p);
7973 prefix_free(p);
7974 return ret;
paul718e3742002-12-13 20:15:29 +00007975}
7976
7977DEFUN (show_ip_bgp_prefix_longer,
7978 show_ip_bgp_prefix_longer_cmd,
7979 "show ip bgp A.B.C.D/M longer-prefixes",
7980 SHOW_STR
7981 IP_STR
7982 BGP_STR
7983 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7984 "Display route and more specific routes\n")
7985{
7986 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
7987 bgp_show_type_prefix_longer);
7988}
7989
7990DEFUN (show_ip_bgp_flap_prefix_longer,
7991 show_ip_bgp_flap_prefix_longer_cmd,
7992 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
7993 SHOW_STR
7994 IP_STR
7995 BGP_STR
7996 "Display flap statistics of routes\n"
7997 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7998 "Display route and more specific routes\n")
7999{
8000 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
8001 bgp_show_type_flap_prefix_longer);
8002}
8003
8004DEFUN (show_ip_bgp_ipv4_prefix_longer,
8005 show_ip_bgp_ipv4_prefix_longer_cmd,
8006 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8007 SHOW_STR
8008 IP_STR
8009 BGP_STR
8010 "Address family\n"
8011 "Address Family modifier\n"
8012 "Address Family modifier\n"
8013 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8014 "Display route and more specific routes\n")
8015{
8016 if (strncmp (argv[0], "m", 1) == 0)
8017 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8018 bgp_show_type_prefix_longer);
8019
8020 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
8021 bgp_show_type_prefix_longer);
8022}
8023
8024DEFUN (show_ip_bgp_flap_address,
8025 show_ip_bgp_flap_address_cmd,
8026 "show ip bgp flap-statistics A.B.C.D",
8027 SHOW_STR
8028 IP_STR
8029 BGP_STR
8030 "Display flap statistics of routes\n"
8031 "Network in the BGP routing table to display\n")
8032{
8033 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
8034 bgp_show_type_flap_address);
8035}
8036
8037DEFUN (show_ip_bgp_flap_prefix,
8038 show_ip_bgp_flap_prefix_cmd,
8039 "show ip bgp flap-statistics A.B.C.D/M",
8040 SHOW_STR
8041 IP_STR
8042 BGP_STR
8043 "Display flap statistics of routes\n"
8044 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8045{
8046 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
8047 bgp_show_type_flap_prefix);
8048}
8049#ifdef HAVE_IPV6
8050DEFUN (show_bgp_prefix_longer,
8051 show_bgp_prefix_longer_cmd,
8052 "show bgp X:X::X:X/M longer-prefixes",
8053 SHOW_STR
8054 BGP_STR
8055 "IPv6 prefix <network>/<length>\n"
8056 "Display route and more specific routes\n")
8057{
8058 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8059 bgp_show_type_prefix_longer);
8060}
8061
8062ALIAS (show_bgp_prefix_longer,
8063 show_bgp_ipv6_prefix_longer_cmd,
8064 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8065 SHOW_STR
8066 BGP_STR
8067 "Address family\n"
8068 "IPv6 prefix <network>/<length>\n"
8069 "Display route and more specific routes\n")
8070
8071/* old command */
8072DEFUN (show_ipv6_bgp_prefix_longer,
8073 show_ipv6_bgp_prefix_longer_cmd,
8074 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8075 SHOW_STR
8076 IPV6_STR
8077 BGP_STR
8078 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8079 "Display route and more specific routes\n")
8080{
8081 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8082 bgp_show_type_prefix_longer);
8083}
8084
8085/* old command */
8086DEFUN (show_ipv6_mbgp_prefix_longer,
8087 show_ipv6_mbgp_prefix_longer_cmd,
8088 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8089 SHOW_STR
8090 IPV6_STR
8091 MBGP_STR
8092 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8093 "Display route and more specific routes\n")
8094{
8095 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8096 bgp_show_type_prefix_longer);
8097}
8098#endif /* HAVE_IPV6 */
paulbb46e942003-10-24 19:02:03 +00008099
8100struct peer *
paulfd79ac92004-10-13 05:06:08 +00008101peer_lookup_in_view (struct vty *vty, const char *view_name,
8102 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +00008103{
8104 int ret;
8105 struct bgp *bgp;
8106 struct peer *peer;
8107 union sockunion su;
8108
8109 /* BGP structure lookup. */
8110 if (view_name)
8111 {
8112 bgp = bgp_lookup_by_name (view_name);
8113 if (! bgp)
8114 {
8115 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
8116 return NULL;
8117 }
8118 }
paul5228ad22004-06-04 17:58:18 +00008119 else
paulbb46e942003-10-24 19:02:03 +00008120 {
8121 bgp = bgp_get_default ();
8122 if (! bgp)
8123 {
8124 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
8125 return NULL;
8126 }
8127 }
8128
8129 /* Get peer sockunion. */
8130 ret = str2sockunion (ip_str, &su);
8131 if (ret < 0)
8132 {
8133 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
8134 return NULL;
8135 }
8136
8137 /* Peer structure lookup. */
8138 peer = peer_lookup (bgp, &su);
8139 if (! peer)
8140 {
8141 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
8142 return NULL;
8143 }
8144
8145 return peer;
8146}
8147
paul718e3742002-12-13 20:15:29 +00008148void
8149show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
8150 int in)
8151{
8152 struct bgp_table *table;
8153 struct bgp_adj_in *ain;
8154 struct bgp_adj_out *adj;
8155 unsigned long output_count;
8156 struct bgp_node *rn;
8157 int header1 = 1;
8158 struct bgp *bgp;
8159 int header2 = 1;
8160
paulbb46e942003-10-24 19:02:03 +00008161 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +00008162
8163 if (! bgp)
8164 return;
8165
8166 table = bgp->rib[afi][safi];
8167
8168 output_count = 0;
8169
8170 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
8171 PEER_STATUS_DEFAULT_ORIGINATE))
8172 {
8173 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 +00008174 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
8175 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008176
8177 vty_out (vty, "Originating default network 0.0.0.0%s%s",
8178 VTY_NEWLINE, VTY_NEWLINE);
8179 header1 = 0;
8180 }
8181
8182 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
8183 if (in)
8184 {
8185 for (ain = rn->adj_in; ain; ain = ain->next)
8186 if (ain->peer == peer)
8187 {
8188 if (header1)
8189 {
8190 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 +00008191 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
8192 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008193 header1 = 0;
8194 }
8195 if (header2)
8196 {
8197 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
8198 header2 = 0;
8199 }
8200 if (ain->attr)
8201 {
8202 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
8203 output_count++;
8204 }
8205 }
8206 }
8207 else
8208 {
8209 for (adj = rn->adj_out; adj; adj = adj->next)
8210 if (adj->peer == peer)
8211 {
8212 if (header1)
8213 {
8214 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 +00008215 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
8216 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008217 header1 = 0;
8218 }
8219 if (header2)
8220 {
8221 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
8222 header2 = 0;
8223 }
8224 if (adj->attr)
8225 {
8226 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
8227 output_count++;
8228 }
8229 }
8230 }
8231
8232 if (output_count != 0)
8233 vty_out (vty, "%sTotal number of prefixes %ld%s",
8234 VTY_NEWLINE, output_count, VTY_NEWLINE);
8235}
8236
8237int
paulbb46e942003-10-24 19:02:03 +00008238peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
8239{
paul718e3742002-12-13 20:15:29 +00008240 if (! peer || ! peer->afc[afi][safi])
8241 {
8242 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
8243 return CMD_WARNING;
8244 }
8245
8246 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
8247 {
8248 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
8249 VTY_NEWLINE);
8250 return CMD_WARNING;
8251 }
8252
8253 show_adj_route (vty, peer, afi, safi, in);
8254
8255 return CMD_SUCCESS;
8256}
8257
8258DEFUN (show_ip_bgp_neighbor_advertised_route,
8259 show_ip_bgp_neighbor_advertised_route_cmd,
8260 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8261 SHOW_STR
8262 IP_STR
8263 BGP_STR
8264 "Detailed information on TCP and BGP neighbor connections\n"
8265 "Neighbor to display information about\n"
8266 "Neighbor to display information about\n"
8267 "Display the routes advertised to a BGP neighbor\n")
8268{
paulbb46e942003-10-24 19:02:03 +00008269 struct peer *peer;
8270
8271 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8272 if (! peer)
8273 return CMD_WARNING;
8274
8275 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
paul718e3742002-12-13 20:15:29 +00008276}
8277
8278DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
8279 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
8280 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8281 SHOW_STR
8282 IP_STR
8283 BGP_STR
8284 "Address family\n"
8285 "Address Family modifier\n"
8286 "Address Family modifier\n"
8287 "Detailed information on TCP and BGP neighbor connections\n"
8288 "Neighbor to display information about\n"
8289 "Neighbor to display information about\n"
8290 "Display the routes advertised to a BGP neighbor\n")
8291{
paulbb46e942003-10-24 19:02:03 +00008292 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00008293
paulbb46e942003-10-24 19:02:03 +00008294 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8295 if (! peer)
8296 return CMD_WARNING;
8297
8298 if (strncmp (argv[0], "m", 1) == 0)
8299 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
8300
8301 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
paul718e3742002-12-13 20:15:29 +00008302}
8303
8304#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00008305DEFUN (show_bgp_view_neighbor_advertised_route,
8306 show_bgp_view_neighbor_advertised_route_cmd,
8307 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8308 SHOW_STR
8309 BGP_STR
8310 "BGP view\n"
8311 "View name\n"
8312 "Detailed information on TCP and BGP neighbor connections\n"
8313 "Neighbor to display information about\n"
8314 "Neighbor to display information about\n"
8315 "Display the routes advertised to a BGP neighbor\n")
8316{
8317 struct peer *peer;
8318
8319 if (argc == 2)
8320 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8321 else
8322 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8323
8324 if (! peer)
8325 return CMD_WARNING;
8326
8327 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
8328}
8329
8330ALIAS (show_bgp_view_neighbor_advertised_route,
8331 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
8332 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8333 SHOW_STR
8334 BGP_STR
8335 "BGP view\n"
8336 "View name\n"
8337 "Address family\n"
8338 "Detailed information on TCP and BGP neighbor connections\n"
8339 "Neighbor to display information about\n"
8340 "Neighbor to display information about\n"
8341 "Display the routes advertised to a BGP neighbor\n")
8342
8343DEFUN (show_bgp_view_neighbor_received_routes,
8344 show_bgp_view_neighbor_received_routes_cmd,
8345 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
8346 SHOW_STR
8347 BGP_STR
8348 "BGP view\n"
8349 "View name\n"
8350 "Detailed information on TCP and BGP neighbor connections\n"
8351 "Neighbor to display information about\n"
8352 "Neighbor to display information about\n"
8353 "Display the received routes from neighbor\n")
8354{
8355 struct peer *peer;
8356
8357 if (argc == 2)
8358 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8359 else
8360 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8361
8362 if (! peer)
8363 return CMD_WARNING;
8364
8365 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
8366}
8367
8368ALIAS (show_bgp_view_neighbor_received_routes,
8369 show_bgp_view_ipv6_neighbor_received_routes_cmd,
8370 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
8371 SHOW_STR
8372 BGP_STR
8373 "BGP view\n"
8374 "View name\n"
8375 "Address family\n"
8376 "Detailed information on TCP and BGP neighbor connections\n"
8377 "Neighbor to display information about\n"
8378 "Neighbor to display information about\n"
8379 "Display the received routes from neighbor\n")
8380
8381ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00008382 show_bgp_neighbor_advertised_route_cmd,
8383 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8384 SHOW_STR
8385 BGP_STR
8386 "Detailed information on TCP and BGP neighbor connections\n"
8387 "Neighbor to display information about\n"
8388 "Neighbor to display information about\n"
8389 "Display the routes advertised to a BGP neighbor\n")
paulbb46e942003-10-24 19:02:03 +00008390
8391ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00008392 show_bgp_ipv6_neighbor_advertised_route_cmd,
8393 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8394 SHOW_STR
8395 BGP_STR
8396 "Address family\n"
8397 "Detailed information on TCP and BGP neighbor connections\n"
8398 "Neighbor to display information about\n"
8399 "Neighbor to display information about\n"
8400 "Display the routes advertised to a BGP neighbor\n")
8401
8402/* old command */
paulbb46e942003-10-24 19:02:03 +00008403ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00008404 ipv6_bgp_neighbor_advertised_route_cmd,
8405 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8406 SHOW_STR
8407 IPV6_STR
8408 BGP_STR
8409 "Detailed information on TCP and BGP neighbor connections\n"
8410 "Neighbor to display information about\n"
8411 "Neighbor to display information about\n"
8412 "Display the routes advertised to a BGP neighbor\n")
paulbb46e942003-10-24 19:02:03 +00008413
paul718e3742002-12-13 20:15:29 +00008414/* old command */
8415DEFUN (ipv6_mbgp_neighbor_advertised_route,
8416 ipv6_mbgp_neighbor_advertised_route_cmd,
8417 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8418 SHOW_STR
8419 IPV6_STR
8420 MBGP_STR
8421 "Detailed information on TCP and BGP neighbor connections\n"
8422 "Neighbor to display information about\n"
8423 "Neighbor to display information about\n"
8424 "Display the routes advertised to a BGP neighbor\n")
8425{
paulbb46e942003-10-24 19:02:03 +00008426 struct peer *peer;
8427
8428 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8429 if (! peer)
8430 return CMD_WARNING;
8431
8432 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
paul718e3742002-12-13 20:15:29 +00008433}
8434#endif /* HAVE_IPV6 */
8435
8436DEFUN (show_ip_bgp_neighbor_received_routes,
8437 show_ip_bgp_neighbor_received_routes_cmd,
8438 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8439 SHOW_STR
8440 IP_STR
8441 BGP_STR
8442 "Detailed information on TCP and BGP neighbor connections\n"
8443 "Neighbor to display information about\n"
8444 "Neighbor to display information about\n"
8445 "Display the received routes from neighbor\n")
8446{
paulbb46e942003-10-24 19:02:03 +00008447 struct peer *peer;
8448
8449 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8450 if (! peer)
8451 return CMD_WARNING;
8452
8453 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
paul718e3742002-12-13 20:15:29 +00008454}
8455
8456DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
8457 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
8458 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
8459 SHOW_STR
8460 IP_STR
8461 BGP_STR
8462 "Address family\n"
8463 "Address Family modifier\n"
8464 "Address Family modifier\n"
8465 "Detailed information on TCP and BGP neighbor connections\n"
8466 "Neighbor to display information about\n"
8467 "Neighbor to display information about\n"
8468 "Display the received routes from neighbor\n")
8469{
paulbb46e942003-10-24 19:02:03 +00008470 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00008471
paulbb46e942003-10-24 19:02:03 +00008472 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8473 if (! peer)
8474 return CMD_WARNING;
8475
8476 if (strncmp (argv[0], "m", 1) == 0)
8477 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
8478
8479 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
paul718e3742002-12-13 20:15:29 +00008480}
8481
8482DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
8483 show_ip_bgp_neighbor_received_prefix_filter_cmd,
8484 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8485 SHOW_STR
8486 IP_STR
8487 BGP_STR
8488 "Detailed information on TCP and BGP neighbor connections\n"
8489 "Neighbor to display information about\n"
8490 "Neighbor to display information about\n"
8491 "Display information received from a BGP neighbor\n"
8492 "Display the prefixlist filter\n")
8493{
8494 char name[BUFSIZ];
8495 union sockunion *su;
8496 struct peer *peer;
8497 int count;
8498
8499 su = sockunion_str2su (argv[0]);
8500 if (su == NULL)
8501 return CMD_WARNING;
8502
8503 peer = peer_lookup (NULL, su);
8504 if (! peer)
8505 return CMD_WARNING;
8506
8507 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
8508 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
8509 if (count)
8510 {
8511 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
8512 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
8513 }
8514
8515 return CMD_SUCCESS;
8516}
8517
8518DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
8519 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
8520 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8521 SHOW_STR
8522 IP_STR
8523 BGP_STR
8524 "Address family\n"
8525 "Address Family modifier\n"
8526 "Address Family modifier\n"
8527 "Detailed information on TCP and BGP neighbor connections\n"
8528 "Neighbor to display information about\n"
8529 "Neighbor to display information about\n"
8530 "Display information received from a BGP neighbor\n"
8531 "Display the prefixlist filter\n")
8532{
8533 char name[BUFSIZ];
8534 union sockunion *su;
8535 struct peer *peer;
8536 int count;
8537
8538 su = sockunion_str2su (argv[1]);
8539 if (su == NULL)
8540 return CMD_WARNING;
8541
8542 peer = peer_lookup (NULL, su);
8543 if (! peer)
8544 return CMD_WARNING;
8545
8546 if (strncmp (argv[0], "m", 1) == 0)
8547 {
8548 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
8549 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
8550 if (count)
8551 {
8552 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
8553 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
8554 }
8555 }
8556 else
8557 {
8558 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
8559 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
8560 if (count)
8561 {
8562 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
8563 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
8564 }
8565 }
8566
8567 return CMD_SUCCESS;
8568}
8569
8570
8571#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00008572ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00008573 show_bgp_neighbor_received_routes_cmd,
8574 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8575 SHOW_STR
8576 BGP_STR
8577 "Detailed information on TCP and BGP neighbor connections\n"
8578 "Neighbor to display information about\n"
8579 "Neighbor to display information about\n"
8580 "Display the received routes from neighbor\n")
paul718e3742002-12-13 20:15:29 +00008581
paulbb46e942003-10-24 19:02:03 +00008582ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00008583 show_bgp_ipv6_neighbor_received_routes_cmd,
8584 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
8585 SHOW_STR
8586 BGP_STR
8587 "Address family\n"
8588 "Detailed information on TCP and BGP neighbor connections\n"
8589 "Neighbor to display information about\n"
8590 "Neighbor to display information about\n"
8591 "Display the received routes from neighbor\n")
8592
8593DEFUN (show_bgp_neighbor_received_prefix_filter,
8594 show_bgp_neighbor_received_prefix_filter_cmd,
8595 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8596 SHOW_STR
8597 BGP_STR
8598 "Detailed information on TCP and BGP neighbor connections\n"
8599 "Neighbor to display information about\n"
8600 "Neighbor to display information about\n"
8601 "Display information received from a BGP neighbor\n"
8602 "Display the prefixlist filter\n")
8603{
8604 char name[BUFSIZ];
8605 union sockunion *su;
8606 struct peer *peer;
8607 int count;
8608
8609 su = sockunion_str2su (argv[0]);
8610 if (su == NULL)
8611 return CMD_WARNING;
8612
8613 peer = peer_lookup (NULL, su);
8614 if (! peer)
8615 return CMD_WARNING;
8616
8617 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
8618 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
8619 if (count)
8620 {
8621 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
8622 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
8623 }
8624
8625 return CMD_SUCCESS;
8626}
8627
8628ALIAS (show_bgp_neighbor_received_prefix_filter,
8629 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
8630 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8631 SHOW_STR
8632 BGP_STR
8633 "Address family\n"
8634 "Detailed information on TCP and BGP neighbor connections\n"
8635 "Neighbor to display information about\n"
8636 "Neighbor to display information about\n"
8637 "Display information received from a BGP neighbor\n"
8638 "Display the prefixlist filter\n")
8639
8640/* old command */
paulbb46e942003-10-24 19:02:03 +00008641ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00008642 ipv6_bgp_neighbor_received_routes_cmd,
8643 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8644 SHOW_STR
8645 IPV6_STR
8646 BGP_STR
8647 "Detailed information on TCP and BGP neighbor connections\n"
8648 "Neighbor to display information about\n"
8649 "Neighbor to display information about\n"
8650 "Display the received routes from neighbor\n")
paul718e3742002-12-13 20:15:29 +00008651
8652/* old command */
8653DEFUN (ipv6_mbgp_neighbor_received_routes,
8654 ipv6_mbgp_neighbor_received_routes_cmd,
8655 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8656 SHOW_STR
8657 IPV6_STR
8658 MBGP_STR
8659 "Detailed information on TCP and BGP neighbor connections\n"
8660 "Neighbor to display information about\n"
8661 "Neighbor to display information about\n"
8662 "Display the received routes from neighbor\n")
8663{
paulbb46e942003-10-24 19:02:03 +00008664 struct peer *peer;
8665
8666 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8667 if (! peer)
8668 return CMD_WARNING;
8669
8670 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
paul718e3742002-12-13 20:15:29 +00008671}
paulbb46e942003-10-24 19:02:03 +00008672
8673DEFUN (show_bgp_view_neighbor_received_prefix_filter,
8674 show_bgp_view_neighbor_received_prefix_filter_cmd,
8675 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8676 SHOW_STR
8677 BGP_STR
8678 "BGP view\n"
8679 "View name\n"
8680 "Detailed information on TCP and BGP neighbor connections\n"
8681 "Neighbor to display information about\n"
8682 "Neighbor to display information about\n"
8683 "Display information received from a BGP neighbor\n"
8684 "Display the prefixlist filter\n")
8685{
8686 char name[BUFSIZ];
8687 union sockunion *su;
8688 struct peer *peer;
8689 struct bgp *bgp;
8690 int count;
8691
8692 /* BGP structure lookup. */
8693 bgp = bgp_lookup_by_name (argv[0]);
8694 if (bgp == NULL)
8695 {
8696 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8697 return CMD_WARNING;
8698 }
8699
8700 su = sockunion_str2su (argv[1]);
8701 if (su == NULL)
8702 return CMD_WARNING;
8703
8704 peer = peer_lookup (bgp, su);
8705 if (! peer)
8706 return CMD_WARNING;
8707
8708 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
8709 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
8710 if (count)
8711 {
8712 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
8713 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
8714 }
8715
8716 return CMD_SUCCESS;
8717}
8718
8719ALIAS (show_bgp_view_neighbor_received_prefix_filter,
8720 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
8721 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8722 SHOW_STR
8723 BGP_STR
8724 "BGP view\n"
8725 "View name\n"
8726 "Address family\n"
8727 "Detailed information on TCP and BGP neighbor connections\n"
8728 "Neighbor to display information about\n"
8729 "Neighbor to display information about\n"
8730 "Display information received from a BGP neighbor\n"
8731 "Display the prefixlist filter\n")
paul718e3742002-12-13 20:15:29 +00008732#endif /* HAVE_IPV6 */
8733
paul718e3742002-12-13 20:15:29 +00008734int
paulbb46e942003-10-24 19:02:03 +00008735bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008736 safi_t safi, enum bgp_show_type type)
8737{
paul718e3742002-12-13 20:15:29 +00008738 if (! peer || ! peer->afc[afi][safi])
8739 {
8740 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008741 return CMD_WARNING;
8742 }
8743
ajs5a646652004-11-05 01:25:55 +00008744 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +00008745}
8746
8747DEFUN (show_ip_bgp_neighbor_routes,
8748 show_ip_bgp_neighbor_routes_cmd,
8749 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
8750 SHOW_STR
8751 IP_STR
8752 BGP_STR
8753 "Detailed information on TCP and BGP neighbor connections\n"
8754 "Neighbor to display information about\n"
8755 "Neighbor to display information about\n"
8756 "Display routes learned from neighbor\n")
8757{
paulbb46e942003-10-24 19:02:03 +00008758 struct peer *peer;
8759
8760 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8761 if (! peer)
8762 return CMD_WARNING;
8763
8764 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008765 bgp_show_type_neighbor);
8766}
8767
8768DEFUN (show_ip_bgp_neighbor_flap,
8769 show_ip_bgp_neighbor_flap_cmd,
8770 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
8771 SHOW_STR
8772 IP_STR
8773 BGP_STR
8774 "Detailed information on TCP and BGP neighbor connections\n"
8775 "Neighbor to display information about\n"
8776 "Neighbor to display information about\n"
8777 "Display flap statistics of the routes learned from neighbor\n")
8778{
paulbb46e942003-10-24 19:02:03 +00008779 struct peer *peer;
8780
8781 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8782 if (! peer)
8783 return CMD_WARNING;
8784
8785 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008786 bgp_show_type_flap_neighbor);
8787}
8788
8789DEFUN (show_ip_bgp_neighbor_damp,
8790 show_ip_bgp_neighbor_damp_cmd,
8791 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
8792 SHOW_STR
8793 IP_STR
8794 BGP_STR
8795 "Detailed information on TCP and BGP neighbor connections\n"
8796 "Neighbor to display information about\n"
8797 "Neighbor to display information about\n"
8798 "Display the dampened routes received from neighbor\n")
8799{
paulbb46e942003-10-24 19:02:03 +00008800 struct peer *peer;
8801
8802 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8803 if (! peer)
8804 return CMD_WARNING;
8805
8806 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008807 bgp_show_type_damp_neighbor);
8808}
8809
8810DEFUN (show_ip_bgp_ipv4_neighbor_routes,
8811 show_ip_bgp_ipv4_neighbor_routes_cmd,
8812 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
8813 SHOW_STR
8814 IP_STR
8815 BGP_STR
8816 "Address family\n"
8817 "Address Family modifier\n"
8818 "Address Family modifier\n"
8819 "Detailed information on TCP and BGP neighbor connections\n"
8820 "Neighbor to display information about\n"
8821 "Neighbor to display information about\n"
8822 "Display routes learned from neighbor\n")
8823{
paulbb46e942003-10-24 19:02:03 +00008824 struct peer *peer;
8825
8826 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8827 if (! peer)
8828 return CMD_WARNING;
8829
paul718e3742002-12-13 20:15:29 +00008830 if (strncmp (argv[0], "m", 1) == 0)
paulbb46e942003-10-24 19:02:03 +00008831 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
paul718e3742002-12-13 20:15:29 +00008832 bgp_show_type_neighbor);
8833
paulbb46e942003-10-24 19:02:03 +00008834 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008835 bgp_show_type_neighbor);
8836}
paulbb46e942003-10-24 19:02:03 +00008837
paulfee0f4c2004-09-13 05:12:46 +00008838DEFUN (show_ip_bgp_view_rsclient,
8839 show_ip_bgp_view_rsclient_cmd,
8840 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
8841 SHOW_STR
8842 IP_STR
8843 BGP_STR
8844 "BGP view\n"
8845 "BGP view name\n"
8846 "Information about Route Server Client\n"
8847 NEIGHBOR_ADDR_STR)
8848{
8849 struct bgp_table *table;
8850 struct peer *peer;
8851
8852 if (argc == 2)
8853 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8854 else
8855 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8856
8857 if (! peer)
8858 return CMD_WARNING;
8859
8860 if (! peer->afc[AFI_IP][SAFI_UNICAST])
8861 {
8862 vty_out (vty, "%% Activate the neighbor for the address family first%s",
8863 VTY_NEWLINE);
8864 return CMD_WARNING;
8865 }
8866
8867 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
8868 PEER_FLAG_RSERVER_CLIENT))
8869 {
8870 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
8871 VTY_NEWLINE);
8872 return CMD_WARNING;
8873 }
8874
8875 table = peer->rib[AFI_IP][SAFI_UNICAST];
8876
ajs5a646652004-11-05 01:25:55 +00008877 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +00008878}
8879
8880ALIAS (show_ip_bgp_view_rsclient,
8881 show_ip_bgp_rsclient_cmd,
8882 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
8883 SHOW_STR
8884 IP_STR
8885 BGP_STR
8886 "Information about Route Server Client\n"
8887 NEIGHBOR_ADDR_STR)
8888
8889DEFUN (show_ip_bgp_view_rsclient_route,
8890 show_ip_bgp_view_rsclient_route_cmd,
8891 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
8892 SHOW_STR
8893 IP_STR
8894 BGP_STR
8895 "BGP view\n"
8896 "BGP view name\n"
8897 "Information about Route Server Client\n"
8898 NEIGHBOR_ADDR_STR
8899 "Network in the BGP routing table to display\n")
8900{
8901 struct bgp *bgp;
8902 struct peer *peer;
8903
8904 /* BGP structure lookup. */
8905 if (argc == 3)
8906 {
8907 bgp = bgp_lookup_by_name (argv[0]);
8908 if (bgp == NULL)
8909 {
8910 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8911 return CMD_WARNING;
8912 }
8913 }
8914 else
8915 {
8916 bgp = bgp_get_default ();
8917 if (bgp == NULL)
8918 {
8919 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
8920 return CMD_WARNING;
8921 }
8922 }
8923
8924 if (argc == 3)
8925 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8926 else
8927 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8928
8929 if (! peer)
8930 return CMD_WARNING;
8931
8932 if (! peer->afc[AFI_IP][SAFI_UNICAST])
8933 {
8934 vty_out (vty, "%% Activate the neighbor for the address family first%s",
8935 VTY_NEWLINE);
8936 return CMD_WARNING;
8937}
8938
8939 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
8940 PEER_FLAG_RSERVER_CLIENT))
8941 {
8942 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
8943 VTY_NEWLINE);
8944 return CMD_WARNING;
8945 }
8946
8947 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
8948 (argc == 3) ? argv[2] : argv[1],
8949 AFI_IP, SAFI_UNICAST, NULL, 0);
8950}
8951
8952ALIAS (show_ip_bgp_view_rsclient_route,
8953 show_ip_bgp_rsclient_route_cmd,
8954 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
8955 SHOW_STR
8956 IP_STR
8957 BGP_STR
8958 "Information about Route Server Client\n"
8959 NEIGHBOR_ADDR_STR
8960 "Network in the BGP routing table to display\n")
8961
8962DEFUN (show_ip_bgp_view_rsclient_prefix,
8963 show_ip_bgp_view_rsclient_prefix_cmd,
8964 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
8965 SHOW_STR
8966 IP_STR
8967 BGP_STR
8968 "BGP view\n"
8969 "BGP view name\n"
8970 "Information about Route Server Client\n"
8971 NEIGHBOR_ADDR_STR
8972 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8973{
8974 struct bgp *bgp;
8975 struct peer *peer;
8976
8977 /* BGP structure lookup. */
8978 if (argc == 3)
8979 {
8980 bgp = bgp_lookup_by_name (argv[0]);
8981 if (bgp == NULL)
8982 {
8983 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8984 return CMD_WARNING;
8985 }
8986 }
8987 else
8988 {
8989 bgp = bgp_get_default ();
8990 if (bgp == NULL)
8991 {
8992 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
8993 return CMD_WARNING;
8994 }
8995 }
8996
8997 if (argc == 3)
8998 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8999 else
9000 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9001
9002 if (! peer)
9003 return CMD_WARNING;
9004
9005 if (! peer->afc[AFI_IP][SAFI_UNICAST])
9006 {
9007 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9008 VTY_NEWLINE);
9009 return CMD_WARNING;
9010}
9011
9012 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
9013 PEER_FLAG_RSERVER_CLIENT))
9014{
9015 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9016 VTY_NEWLINE);
9017 return CMD_WARNING;
9018 }
9019
9020 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
9021 (argc == 3) ? argv[2] : argv[1],
9022 AFI_IP, SAFI_UNICAST, NULL, 1);
9023}
9024
9025ALIAS (show_ip_bgp_view_rsclient_prefix,
9026 show_ip_bgp_rsclient_prefix_cmd,
9027 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
9028 SHOW_STR
9029 IP_STR
9030 BGP_STR
9031 "Information about Route Server Client\n"
9032 NEIGHBOR_ADDR_STR
9033 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9034
9035
paul718e3742002-12-13 20:15:29 +00009036#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00009037DEFUN (show_bgp_view_neighbor_routes,
9038 show_bgp_view_neighbor_routes_cmd,
9039 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
9040 SHOW_STR
9041 BGP_STR
9042 "BGP view\n"
9043 "BGP view name\n"
9044 "Detailed information on TCP and BGP neighbor connections\n"
9045 "Neighbor to display information about\n"
9046 "Neighbor to display information about\n"
9047 "Display routes learned from neighbor\n")
9048{
9049 struct peer *peer;
9050
9051 if (argc == 2)
9052 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9053 else
9054 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9055
9056 if (! peer)
9057 return CMD_WARNING;
9058
9059 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
9060 bgp_show_type_neighbor);
9061}
9062
9063ALIAS (show_bgp_view_neighbor_routes,
9064 show_bgp_view_ipv6_neighbor_routes_cmd,
9065 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
9066 SHOW_STR
9067 BGP_STR
9068 "BGP view\n"
9069 "BGP view name\n"
9070 "Address family\n"
9071 "Detailed information on TCP and BGP neighbor connections\n"
9072 "Neighbor to display information about\n"
9073 "Neighbor to display information about\n"
9074 "Display routes learned from neighbor\n")
9075
9076DEFUN (show_bgp_view_neighbor_damp,
9077 show_bgp_view_neighbor_damp_cmd,
9078 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9079 SHOW_STR
9080 BGP_STR
9081 "BGP view\n"
9082 "BGP view name\n"
9083 "Detailed information on TCP and BGP neighbor connections\n"
9084 "Neighbor to display information about\n"
9085 "Neighbor to display information about\n"
9086 "Display the dampened routes received from neighbor\n")
9087{
9088 struct peer *peer;
9089
9090 if (argc == 2)
9091 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9092 else
9093 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9094
9095 if (! peer)
9096 return CMD_WARNING;
9097
9098 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
9099 bgp_show_type_damp_neighbor);
9100}
9101
9102ALIAS (show_bgp_view_neighbor_damp,
9103 show_bgp_view_ipv6_neighbor_damp_cmd,
9104 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9105 SHOW_STR
9106 BGP_STR
9107 "BGP view\n"
9108 "BGP view name\n"
9109 "Address family\n"
9110 "Detailed information on TCP and BGP neighbor connections\n"
9111 "Neighbor to display information about\n"
9112 "Neighbor to display information about\n"
9113 "Display the dampened routes received from neighbor\n")
9114
9115DEFUN (show_bgp_view_neighbor_flap,
9116 show_bgp_view_neighbor_flap_cmd,
9117 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9118 SHOW_STR
9119 BGP_STR
9120 "BGP view\n"
9121 "BGP view name\n"
9122 "Detailed information on TCP and BGP neighbor connections\n"
9123 "Neighbor to display information about\n"
9124 "Neighbor to display information about\n"
9125 "Display flap statistics of the routes learned from neighbor\n")
9126{
9127 struct peer *peer;
9128
9129 if (argc == 2)
9130 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9131 else
9132 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9133
9134 if (! peer)
9135 return CMD_WARNING;
9136
9137 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
9138 bgp_show_type_flap_neighbor);
9139}
9140
9141ALIAS (show_bgp_view_neighbor_flap,
9142 show_bgp_view_ipv6_neighbor_flap_cmd,
9143 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9144 SHOW_STR
9145 BGP_STR
9146 "BGP view\n"
9147 "BGP view name\n"
9148 "Address family\n"
9149 "Detailed information on TCP and BGP neighbor connections\n"
9150 "Neighbor to display information about\n"
9151 "Neighbor to display information about\n"
9152 "Display flap statistics of the routes learned from neighbor\n")
9153
9154ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00009155 show_bgp_neighbor_routes_cmd,
9156 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
9157 SHOW_STR
9158 BGP_STR
9159 "Detailed information on TCP and BGP neighbor connections\n"
9160 "Neighbor to display information about\n"
9161 "Neighbor to display information about\n"
9162 "Display routes learned from neighbor\n")
paul718e3742002-12-13 20:15:29 +00009163
paulbb46e942003-10-24 19:02:03 +00009164
9165ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00009166 show_bgp_ipv6_neighbor_routes_cmd,
9167 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
9168 SHOW_STR
9169 BGP_STR
9170 "Address family\n"
9171 "Detailed information on TCP and BGP neighbor connections\n"
9172 "Neighbor to display information about\n"
9173 "Neighbor to display information about\n"
9174 "Display routes learned from neighbor\n")
9175
9176/* old command */
paulbb46e942003-10-24 19:02:03 +00009177ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00009178 ipv6_bgp_neighbor_routes_cmd,
9179 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
9180 SHOW_STR
9181 IPV6_STR
9182 BGP_STR
9183 "Detailed information on TCP and BGP neighbor connections\n"
9184 "Neighbor to display information about\n"
9185 "Neighbor to display information about\n"
9186 "Display routes learned from neighbor\n")
paul718e3742002-12-13 20:15:29 +00009187
9188/* old command */
9189DEFUN (ipv6_mbgp_neighbor_routes,
9190 ipv6_mbgp_neighbor_routes_cmd,
9191 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
9192 SHOW_STR
9193 IPV6_STR
9194 MBGP_STR
9195 "Detailed information on TCP and BGP neighbor connections\n"
9196 "Neighbor to display information about\n"
9197 "Neighbor to display information about\n"
9198 "Display routes learned from neighbor\n")
9199{
paulbb46e942003-10-24 19:02:03 +00009200 struct peer *peer;
9201
9202 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9203 if (! peer)
9204 return CMD_WARNING;
9205
9206 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
paul718e3742002-12-13 20:15:29 +00009207 bgp_show_type_neighbor);
9208}
paulbb46e942003-10-24 19:02:03 +00009209
9210ALIAS (show_bgp_view_neighbor_flap,
9211 show_bgp_neighbor_flap_cmd,
9212 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9213 SHOW_STR
9214 BGP_STR
9215 "Detailed information on TCP and BGP neighbor connections\n"
9216 "Neighbor to display information about\n"
9217 "Neighbor to display information about\n"
9218 "Display flap statistics of the routes learned from neighbor\n")
9219
9220ALIAS (show_bgp_view_neighbor_flap,
9221 show_bgp_ipv6_neighbor_flap_cmd,
9222 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9223 SHOW_STR
9224 BGP_STR
9225 "Address family\n"
9226 "Detailed information on TCP and BGP neighbor connections\n"
9227 "Neighbor to display information about\n"
9228 "Neighbor to display information about\n"
9229 "Display flap statistics of the routes learned from neighbor\n")
9230
9231ALIAS (show_bgp_view_neighbor_damp,
9232 show_bgp_neighbor_damp_cmd,
9233 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9234 SHOW_STR
9235 BGP_STR
9236 "Detailed information on TCP and BGP neighbor connections\n"
9237 "Neighbor to display information about\n"
9238 "Neighbor to display information about\n"
9239 "Display the dampened routes received from neighbor\n")
9240
9241ALIAS (show_bgp_view_neighbor_damp,
9242 show_bgp_ipv6_neighbor_damp_cmd,
9243 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9244 SHOW_STR
9245 BGP_STR
9246 "Address family\n"
9247 "Detailed information on TCP and BGP neighbor connections\n"
9248 "Neighbor to display information about\n"
9249 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +00009250 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +00009251
9252DEFUN (show_bgp_view_rsclient,
9253 show_bgp_view_rsclient_cmd,
9254 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
9255 SHOW_STR
9256 BGP_STR
9257 "BGP view\n"
9258 "BGP view name\n"
9259 "Information about Route Server Client\n"
9260 NEIGHBOR_ADDR_STR)
9261{
9262 struct bgp_table *table;
9263 struct peer *peer;
9264
9265 if (argc == 2)
9266 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9267 else
9268 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9269
9270 if (! peer)
9271 return CMD_WARNING;
9272
9273 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
9274 {
9275 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9276 VTY_NEWLINE);
9277 return CMD_WARNING;
9278 }
9279
9280 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
9281 PEER_FLAG_RSERVER_CLIENT))
9282 {
9283 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9284 VTY_NEWLINE);
9285 return CMD_WARNING;
9286 }
9287
9288 table = peer->rib[AFI_IP6][SAFI_UNICAST];
9289
ajs5a646652004-11-05 01:25:55 +00009290 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +00009291}
9292
9293ALIAS (show_bgp_view_rsclient,
9294 show_bgp_rsclient_cmd,
9295 "show bgp rsclient (A.B.C.D|X:X::X:X)",
9296 SHOW_STR
9297 BGP_STR
9298 "Information about Route Server Client\n"
9299 NEIGHBOR_ADDR_STR)
9300
9301DEFUN (show_bgp_view_rsclient_route,
9302 show_bgp_view_rsclient_route_cmd,
9303 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
9304 SHOW_STR
9305 BGP_STR
9306 "BGP view\n"
9307 "BGP view name\n"
9308 "Information about Route Server Client\n"
9309 NEIGHBOR_ADDR_STR
9310 "Network in the BGP routing table to display\n")
9311{
9312 struct bgp *bgp;
9313 struct peer *peer;
9314
9315 /* BGP structure lookup. */
9316 if (argc == 3)
9317 {
9318 bgp = bgp_lookup_by_name (argv[0]);
9319 if (bgp == NULL)
9320 {
9321 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
9322 return CMD_WARNING;
9323 }
9324 }
9325 else
9326 {
9327 bgp = bgp_get_default ();
9328 if (bgp == NULL)
9329 {
9330 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9331 return CMD_WARNING;
9332 }
9333 }
9334
9335 if (argc == 3)
9336 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9337 else
9338 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9339
9340 if (! peer)
9341 return CMD_WARNING;
9342
9343 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
9344 {
9345 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9346 VTY_NEWLINE);
9347 return CMD_WARNING;
9348 }
9349
9350 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
9351 PEER_FLAG_RSERVER_CLIENT))
9352 {
9353 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9354 VTY_NEWLINE);
9355 return CMD_WARNING;
9356 }
9357
9358 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
9359 (argc == 3) ? argv[2] : argv[1],
9360 AFI_IP6, SAFI_UNICAST, NULL, 0);
9361}
9362
9363ALIAS (show_bgp_view_rsclient_route,
9364 show_bgp_rsclient_route_cmd,
9365 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
9366 SHOW_STR
9367 BGP_STR
9368 "Information about Route Server Client\n"
9369 NEIGHBOR_ADDR_STR
9370 "Network in the BGP routing table to display\n")
9371
9372DEFUN (show_bgp_view_rsclient_prefix,
9373 show_bgp_view_rsclient_prefix_cmd,
9374 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
9375 SHOW_STR
9376 BGP_STR
9377 "BGP view\n"
9378 "BGP view name\n"
9379 "Information about Route Server Client\n"
9380 NEIGHBOR_ADDR_STR
9381 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
9382{
9383 struct bgp *bgp;
9384 struct peer *peer;
9385
9386 /* BGP structure lookup. */
9387 if (argc == 3)
9388 {
9389 bgp = bgp_lookup_by_name (argv[0]);
9390 if (bgp == NULL)
9391 {
9392 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
9393 return CMD_WARNING;
9394 }
9395 }
9396 else
9397 {
9398 bgp = bgp_get_default ();
9399 if (bgp == NULL)
9400 {
9401 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9402 return CMD_WARNING;
9403 }
9404 }
9405
9406 if (argc == 3)
9407 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9408 else
9409 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9410
9411 if (! peer)
9412 return CMD_WARNING;
9413
9414 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
9415 {
9416 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9417 VTY_NEWLINE);
9418 return CMD_WARNING;
9419 }
9420
9421 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
9422 PEER_FLAG_RSERVER_CLIENT))
9423 {
9424 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9425 VTY_NEWLINE);
9426 return CMD_WARNING;
9427 }
9428
9429 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
9430 (argc == 3) ? argv[2] : argv[1],
9431 AFI_IP6, SAFI_UNICAST, NULL, 1);
9432}
9433
9434ALIAS (show_bgp_view_rsclient_prefix,
9435 show_bgp_rsclient_prefix_cmd,
9436 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
9437 SHOW_STR
9438 BGP_STR
9439 "Information about Route Server Client\n"
9440 NEIGHBOR_ADDR_STR
9441 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
9442
paul718e3742002-12-13 20:15:29 +00009443#endif /* HAVE_IPV6 */
9444
9445struct bgp_table *bgp_distance_table;
9446
9447struct bgp_distance
9448{
9449 /* Distance value for the IP source prefix. */
9450 u_char distance;
9451
9452 /* Name of the access-list to be matched. */
9453 char *access_list;
9454};
9455
9456struct bgp_distance *
9457bgp_distance_new ()
9458{
9459 struct bgp_distance *new;
9460 new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
9461 memset (new, 0, sizeof (struct bgp_distance));
9462 return new;
9463}
9464
9465void
9466bgp_distance_free (struct bgp_distance *bdistance)
9467{
9468 XFREE (MTYPE_BGP_DISTANCE, bdistance);
9469}
9470
9471int
paulfd79ac92004-10-13 05:06:08 +00009472bgp_distance_set (struct vty *vty, const char *distance_str,
9473 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +00009474{
9475 int ret;
9476 struct prefix_ipv4 p;
9477 u_char distance;
9478 struct bgp_node *rn;
9479 struct bgp_distance *bdistance;
9480
9481 ret = str2prefix_ipv4 (ip_str, &p);
9482 if (ret == 0)
9483 {
9484 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
9485 return CMD_WARNING;
9486 }
9487
9488 distance = atoi (distance_str);
9489
9490 /* Get BGP distance node. */
9491 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
9492 if (rn->info)
9493 {
9494 bdistance = rn->info;
9495 bgp_unlock_node (rn);
9496 }
9497 else
9498 {
9499 bdistance = bgp_distance_new ();
9500 rn->info = bdistance;
9501 }
9502
9503 /* Set distance value. */
9504 bdistance->distance = distance;
9505
9506 /* Reset access-list configuration. */
9507 if (bdistance->access_list)
9508 {
9509 free (bdistance->access_list);
9510 bdistance->access_list = NULL;
9511 }
9512 if (access_list_str)
9513 bdistance->access_list = strdup (access_list_str);
9514
9515 return CMD_SUCCESS;
9516}
9517
9518int
paulfd79ac92004-10-13 05:06:08 +00009519bgp_distance_unset (struct vty *vty, const char *distance_str,
9520 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +00009521{
9522 int ret;
9523 struct prefix_ipv4 p;
9524 u_char distance;
9525 struct bgp_node *rn;
9526 struct bgp_distance *bdistance;
9527
9528 ret = str2prefix_ipv4 (ip_str, &p);
9529 if (ret == 0)
9530 {
9531 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
9532 return CMD_WARNING;
9533 }
9534
9535 distance = atoi (distance_str);
9536
9537 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
9538 if (! rn)
9539 {
9540 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
9541 return CMD_WARNING;
9542 }
9543
9544 bdistance = rn->info;
9545
9546 if (bdistance->access_list)
9547 free (bdistance->access_list);
9548 bgp_distance_free (bdistance);
9549
9550 rn->info = NULL;
9551 bgp_unlock_node (rn);
9552 bgp_unlock_node (rn);
9553
9554 return CMD_SUCCESS;
9555}
9556
9557void
9558bgp_distance_reset ()
9559{
9560 struct bgp_node *rn;
9561 struct bgp_distance *bdistance;
9562
9563 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
9564 if ((bdistance = rn->info) != NULL)
9565 {
9566 if (bdistance->access_list)
9567 free (bdistance->access_list);
9568 bgp_distance_free (bdistance);
9569 rn->info = NULL;
9570 bgp_unlock_node (rn);
9571 }
9572}
9573
9574/* Apply BGP information to distance method. */
9575u_char
9576bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
9577{
9578 struct bgp_node *rn;
9579 struct prefix_ipv4 q;
9580 struct peer *peer;
9581 struct bgp_distance *bdistance;
9582 struct access_list *alist;
9583 struct bgp_static *bgp_static;
9584
9585 if (! bgp)
9586 return 0;
9587
9588 if (p->family != AF_INET)
9589 return 0;
9590
9591 peer = rinfo->peer;
9592
9593 if (peer->su.sa.sa_family != AF_INET)
9594 return 0;
9595
9596 memset (&q, 0, sizeof (struct prefix_ipv4));
9597 q.family = AF_INET;
9598 q.prefix = peer->su.sin.sin_addr;
9599 q.prefixlen = IPV4_MAX_BITLEN;
9600
9601 /* Check source address. */
9602 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
9603 if (rn)
9604 {
9605 bdistance = rn->info;
9606 bgp_unlock_node (rn);
9607
9608 if (bdistance->access_list)
9609 {
9610 alist = access_list_lookup (AFI_IP, bdistance->access_list);
9611 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
9612 return bdistance->distance;
9613 }
9614 else
9615 return bdistance->distance;
9616 }
9617
9618 /* Backdoor check. */
9619 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
9620 if (rn)
9621 {
9622 bgp_static = rn->info;
9623 bgp_unlock_node (rn);
9624
9625 if (bgp_static->backdoor)
9626 {
9627 if (bgp->distance_local)
9628 return bgp->distance_local;
9629 else
9630 return ZEBRA_IBGP_DISTANCE_DEFAULT;
9631 }
9632 }
9633
9634 if (peer_sort (peer) == BGP_PEER_EBGP)
9635 {
9636 if (bgp->distance_ebgp)
9637 return bgp->distance_ebgp;
9638 return ZEBRA_EBGP_DISTANCE_DEFAULT;
9639 }
9640 else
9641 {
9642 if (bgp->distance_ibgp)
9643 return bgp->distance_ibgp;
9644 return ZEBRA_IBGP_DISTANCE_DEFAULT;
9645 }
9646}
9647
9648DEFUN (bgp_distance,
9649 bgp_distance_cmd,
9650 "distance bgp <1-255> <1-255> <1-255>",
9651 "Define an administrative distance\n"
9652 "BGP distance\n"
9653 "Distance for routes external to the AS\n"
9654 "Distance for routes internal to the AS\n"
9655 "Distance for local routes\n")
9656{
9657 struct bgp *bgp;
9658
9659 bgp = vty->index;
9660
9661 bgp->distance_ebgp = atoi (argv[0]);
9662 bgp->distance_ibgp = atoi (argv[1]);
9663 bgp->distance_local = atoi (argv[2]);
9664 return CMD_SUCCESS;
9665}
9666
9667DEFUN (no_bgp_distance,
9668 no_bgp_distance_cmd,
9669 "no distance bgp <1-255> <1-255> <1-255>",
9670 NO_STR
9671 "Define an administrative distance\n"
9672 "BGP distance\n"
9673 "Distance for routes external to the AS\n"
9674 "Distance for routes internal to the AS\n"
9675 "Distance for local routes\n")
9676{
9677 struct bgp *bgp;
9678
9679 bgp = vty->index;
9680
9681 bgp->distance_ebgp= 0;
9682 bgp->distance_ibgp = 0;
9683 bgp->distance_local = 0;
9684 return CMD_SUCCESS;
9685}
9686
9687ALIAS (no_bgp_distance,
9688 no_bgp_distance2_cmd,
9689 "no distance bgp",
9690 NO_STR
9691 "Define an administrative distance\n"
9692 "BGP distance\n")
9693
9694DEFUN (bgp_distance_source,
9695 bgp_distance_source_cmd,
9696 "distance <1-255> A.B.C.D/M",
9697 "Define an administrative distance\n"
9698 "Administrative distance\n"
9699 "IP source prefix\n")
9700{
9701 bgp_distance_set (vty, argv[0], argv[1], NULL);
9702 return CMD_SUCCESS;
9703}
9704
9705DEFUN (no_bgp_distance_source,
9706 no_bgp_distance_source_cmd,
9707 "no distance <1-255> A.B.C.D/M",
9708 NO_STR
9709 "Define an administrative distance\n"
9710 "Administrative distance\n"
9711 "IP source prefix\n")
9712{
9713 bgp_distance_unset (vty, argv[0], argv[1], NULL);
9714 return CMD_SUCCESS;
9715}
9716
9717DEFUN (bgp_distance_source_access_list,
9718 bgp_distance_source_access_list_cmd,
9719 "distance <1-255> A.B.C.D/M WORD",
9720 "Define an administrative distance\n"
9721 "Administrative distance\n"
9722 "IP source prefix\n"
9723 "Access list name\n")
9724{
9725 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
9726 return CMD_SUCCESS;
9727}
9728
9729DEFUN (no_bgp_distance_source_access_list,
9730 no_bgp_distance_source_access_list_cmd,
9731 "no distance <1-255> A.B.C.D/M WORD",
9732 NO_STR
9733 "Define an administrative distance\n"
9734 "Administrative distance\n"
9735 "IP source prefix\n"
9736 "Access list name\n")
9737{
9738 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
9739 return CMD_SUCCESS;
9740}
9741
9742DEFUN (bgp_damp_set,
9743 bgp_damp_set_cmd,
9744 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
9745 "BGP Specific commands\n"
9746 "Enable route-flap dampening\n"
9747 "Half-life time for the penalty\n"
9748 "Value to start reusing a route\n"
9749 "Value to start suppressing a route\n"
9750 "Maximum duration to suppress a stable route\n")
9751{
9752 struct bgp *bgp;
9753 int half = DEFAULT_HALF_LIFE * 60;
9754 int reuse = DEFAULT_REUSE;
9755 int suppress = DEFAULT_SUPPRESS;
9756 int max = 4 * half;
9757
9758 if (argc == 4)
9759 {
9760 half = atoi (argv[0]) * 60;
9761 reuse = atoi (argv[1]);
9762 suppress = atoi (argv[2]);
9763 max = atoi (argv[3]) * 60;
9764 }
9765 else if (argc == 1)
9766 {
9767 half = atoi (argv[0]) * 60;
9768 max = 4 * half;
9769 }
9770
9771 bgp = vty->index;
9772 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
9773 half, reuse, suppress, max);
9774}
9775
9776ALIAS (bgp_damp_set,
9777 bgp_damp_set2_cmd,
9778 "bgp dampening <1-45>",
9779 "BGP Specific commands\n"
9780 "Enable route-flap dampening\n"
9781 "Half-life time for the penalty\n")
9782
9783ALIAS (bgp_damp_set,
9784 bgp_damp_set3_cmd,
9785 "bgp dampening",
9786 "BGP Specific commands\n"
9787 "Enable route-flap dampening\n")
9788
9789DEFUN (bgp_damp_unset,
9790 bgp_damp_unset_cmd,
9791 "no bgp dampening",
9792 NO_STR
9793 "BGP Specific commands\n"
9794 "Enable route-flap dampening\n")
9795{
9796 struct bgp *bgp;
9797
9798 bgp = vty->index;
9799 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
9800}
9801
9802ALIAS (bgp_damp_unset,
9803 bgp_damp_unset2_cmd,
9804 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
9805 NO_STR
9806 "BGP Specific commands\n"
9807 "Enable route-flap dampening\n"
9808 "Half-life time for the penalty\n"
9809 "Value to start reusing a route\n"
9810 "Value to start suppressing a route\n"
9811 "Maximum duration to suppress a stable route\n")
9812
9813DEFUN (show_ip_bgp_dampened_paths,
9814 show_ip_bgp_dampened_paths_cmd,
9815 "show ip bgp dampened-paths",
9816 SHOW_STR
9817 IP_STR
9818 BGP_STR
9819 "Display paths suppressed due to dampening\n")
9820{
ajs5a646652004-11-05 01:25:55 +00009821 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
9822 NULL);
paul718e3742002-12-13 20:15:29 +00009823}
9824
9825DEFUN (show_ip_bgp_flap_statistics,
9826 show_ip_bgp_flap_statistics_cmd,
9827 "show ip bgp flap-statistics",
9828 SHOW_STR
9829 IP_STR
9830 BGP_STR
9831 "Display flap statistics of routes\n")
9832{
ajs5a646652004-11-05 01:25:55 +00009833 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9834 bgp_show_type_flap_statistics, NULL);
paul718e3742002-12-13 20:15:29 +00009835}
9836
9837/* Display specified route of BGP table. */
9838int
paulfd79ac92004-10-13 05:06:08 +00009839bgp_clear_damp_route (struct vty *vty, const char *view_name,
9840 const char *ip_str, afi_t afi, safi_t safi,
9841 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +00009842{
9843 int ret;
9844 struct prefix match;
9845 struct bgp_node *rn;
9846 struct bgp_node *rm;
9847 struct bgp_info *ri;
9848 struct bgp_info *ri_temp;
9849 struct bgp *bgp;
9850 struct bgp_table *table;
9851
9852 /* BGP structure lookup. */
9853 if (view_name)
9854 {
9855 bgp = bgp_lookup_by_name (view_name);
9856 if (bgp == NULL)
9857 {
9858 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9859 return CMD_WARNING;
9860 }
9861 }
9862 else
9863 {
9864 bgp = bgp_get_default ();
9865 if (bgp == NULL)
9866 {
9867 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
9868 return CMD_WARNING;
9869 }
9870 }
9871
9872 /* Check IP address argument. */
9873 ret = str2prefix (ip_str, &match);
9874 if (! ret)
9875 {
9876 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
9877 return CMD_WARNING;
9878 }
9879
9880 match.family = afi2family (afi);
9881
9882 if (safi == SAFI_MPLS_VPN)
9883 {
9884 for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn))
9885 {
9886 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
9887 continue;
9888
9889 if ((table = rn->info) != NULL)
9890 if ((rm = bgp_node_match (table, &match)) != NULL)
9891 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
9892 {
9893 ri = rm->info;
9894 while (ri)
9895 {
9896 if (ri->damp_info)
9897 {
9898 ri_temp = ri->next;
9899 bgp_damp_info_free (ri->damp_info, 1);
9900 ri = ri_temp;
9901 }
9902 else
9903 ri = ri->next;
9904 }
9905 }
9906 }
9907 }
9908 else
9909 {
9910 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
9911 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
9912 {
9913 ri = rn->info;
9914 while (ri)
9915 {
9916 if (ri->damp_info)
9917 {
9918 ri_temp = ri->next;
9919 bgp_damp_info_free (ri->damp_info, 1);
9920 ri = ri_temp;
9921 }
9922 else
9923 ri = ri->next;
9924 }
9925 }
9926 }
9927
9928 return CMD_SUCCESS;
9929}
9930
9931DEFUN (clear_ip_bgp_dampening,
9932 clear_ip_bgp_dampening_cmd,
9933 "clear ip bgp dampening",
9934 CLEAR_STR
9935 IP_STR
9936 BGP_STR
9937 "Clear route flap dampening information\n")
9938{
9939 bgp_damp_info_clean ();
9940 return CMD_SUCCESS;
9941}
9942
9943DEFUN (clear_ip_bgp_dampening_prefix,
9944 clear_ip_bgp_dampening_prefix_cmd,
9945 "clear ip bgp dampening A.B.C.D/M",
9946 CLEAR_STR
9947 IP_STR
9948 BGP_STR
9949 "Clear route flap dampening information\n"
9950 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9951{
9952 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
9953 SAFI_UNICAST, NULL, 1);
9954}
9955
9956DEFUN (clear_ip_bgp_dampening_address,
9957 clear_ip_bgp_dampening_address_cmd,
9958 "clear ip bgp dampening A.B.C.D",
9959 CLEAR_STR
9960 IP_STR
9961 BGP_STR
9962 "Clear route flap dampening information\n"
9963 "Network to clear damping information\n")
9964{
9965 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
9966 SAFI_UNICAST, NULL, 0);
9967}
9968
9969DEFUN (clear_ip_bgp_dampening_address_mask,
9970 clear_ip_bgp_dampening_address_mask_cmd,
9971 "clear ip bgp dampening A.B.C.D A.B.C.D",
9972 CLEAR_STR
9973 IP_STR
9974 BGP_STR
9975 "Clear route flap dampening information\n"
9976 "Network to clear damping information\n"
9977 "Network mask\n")
9978{
9979 int ret;
9980 char prefix_str[BUFSIZ];
9981
9982 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
9983 if (! ret)
9984 {
9985 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
9986 return CMD_WARNING;
9987 }
9988
9989 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
9990 SAFI_UNICAST, NULL, 0);
9991}
9992
9993int
9994bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
9995 afi_t afi, safi_t safi, int *write)
9996{
9997 struct bgp_node *prn;
9998 struct bgp_node *rn;
9999 struct bgp_table *table;
10000 struct prefix *p;
10001 struct prefix_rd *prd;
10002 struct bgp_static *bgp_static;
10003 u_int32_t label;
10004 char buf[SU_ADDRSTRLEN];
10005 char rdbuf[RD_ADDRSTRLEN];
10006
10007 /* Network configuration. */
10008 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
10009 if ((table = prn->info) != NULL)
10010 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
10011 if ((bgp_static = rn->info) != NULL)
10012 {
10013 p = &rn->p;
10014 prd = (struct prefix_rd *) &prn->p;
10015
10016 /* "address-family" display. */
10017 bgp_config_write_family_header (vty, afi, safi, write);
10018
10019 /* "network" configuration display. */
10020 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
10021 label = decode_label (bgp_static->tag);
10022
10023 vty_out (vty, " network %s/%d rd %s tag %d",
10024 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10025 p->prefixlen,
10026 rdbuf, label);
10027 vty_out (vty, "%s", VTY_NEWLINE);
10028 }
10029 return 0;
10030}
10031
10032/* Configuration of static route announcement and aggregate
10033 information. */
10034int
10035bgp_config_write_network (struct vty *vty, struct bgp *bgp,
10036 afi_t afi, safi_t safi, int *write)
10037{
10038 struct bgp_node *rn;
10039 struct prefix *p;
10040 struct bgp_static *bgp_static;
10041 struct bgp_aggregate *bgp_aggregate;
10042 char buf[SU_ADDRSTRLEN];
10043
10044 if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
10045 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
10046
10047 /* Network configuration. */
10048 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
10049 if ((bgp_static = rn->info) != NULL)
10050 {
10051 p = &rn->p;
10052
10053 /* "address-family" display. */
10054 bgp_config_write_family_header (vty, afi, safi, write);
10055
10056 /* "network" configuration display. */
10057 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
10058 {
10059 u_int32_t destination;
10060 struct in_addr netmask;
10061
10062 destination = ntohl (p->u.prefix4.s_addr);
10063 masklen2ip (p->prefixlen, &netmask);
10064 vty_out (vty, " network %s",
10065 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
10066
10067 if ((IN_CLASSC (destination) && p->prefixlen == 24)
10068 || (IN_CLASSB (destination) && p->prefixlen == 16)
10069 || (IN_CLASSA (destination) && p->prefixlen == 8)
10070 || p->u.prefix4.s_addr == 0)
10071 {
10072 /* Natural mask is not display. */
10073 }
10074 else
10075 vty_out (vty, " mask %s", inet_ntoa (netmask));
10076 }
10077 else
10078 {
10079 vty_out (vty, " network %s/%d",
10080 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10081 p->prefixlen);
10082 }
10083
10084 if (bgp_static->rmap.name)
10085 vty_out (vty, " route-map %s", bgp_static->rmap.name);
10086 else if (bgp_static->backdoor)
10087 vty_out (vty, " backdoor");
10088
10089 vty_out (vty, "%s", VTY_NEWLINE);
10090 }
10091
10092 /* Aggregate-address configuration. */
10093 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
10094 if ((bgp_aggregate = rn->info) != NULL)
10095 {
10096 p = &rn->p;
10097
10098 /* "address-family" display. */
10099 bgp_config_write_family_header (vty, afi, safi, write);
10100
10101 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
10102 {
10103 struct in_addr netmask;
10104
10105 masklen2ip (p->prefixlen, &netmask);
10106 vty_out (vty, " aggregate-address %s %s",
10107 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10108 inet_ntoa (netmask));
10109 }
10110 else
10111 {
10112 vty_out (vty, " aggregate-address %s/%d",
10113 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10114 p->prefixlen);
10115 }
10116
10117 if (bgp_aggregate->as_set)
10118 vty_out (vty, " as-set");
10119
10120 if (bgp_aggregate->summary_only)
10121 vty_out (vty, " summary-only");
10122
10123 vty_out (vty, "%s", VTY_NEWLINE);
10124 }
10125
10126 return 0;
10127}
10128
10129int
10130bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
10131{
10132 struct bgp_node *rn;
10133 struct bgp_distance *bdistance;
10134
10135 /* Distance configuration. */
10136 if (bgp->distance_ebgp
10137 && bgp->distance_ibgp
10138 && bgp->distance_local
10139 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
10140 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
10141 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
10142 vty_out (vty, " distance bgp %d %d %d%s",
10143 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
10144 VTY_NEWLINE);
10145
10146 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
10147 if ((bdistance = rn->info) != NULL)
10148 {
10149 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
10150 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
10151 bdistance->access_list ? bdistance->access_list : "",
10152 VTY_NEWLINE);
10153 }
10154
10155 return 0;
10156}
10157
10158/* Allocate routing table structure and install commands. */
10159void
10160bgp_route_init ()
10161{
10162 /* Init BGP distance table. */
10163 bgp_distance_table = bgp_table_init ();
10164
10165 /* IPv4 BGP commands. */
10166 install_element (BGP_NODE, &bgp_network_cmd);
10167 install_element (BGP_NODE, &bgp_network_mask_cmd);
10168 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
10169 install_element (BGP_NODE, &bgp_network_route_map_cmd);
10170 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
10171 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
10172 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
10173 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
10174 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
10175 install_element (BGP_NODE, &no_bgp_network_cmd);
10176 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
10177 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
10178 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
10179 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
10180 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
10181 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
10182 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
10183 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
10184
10185 install_element (BGP_NODE, &aggregate_address_cmd);
10186 install_element (BGP_NODE, &aggregate_address_mask_cmd);
10187 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
10188 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
10189 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
10190 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
10191 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
10192 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
10193 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
10194 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
10195 install_element (BGP_NODE, &no_aggregate_address_cmd);
10196 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
10197 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
10198 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
10199 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
10200 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
10201 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
10202 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
10203 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
10204 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
10205
10206 /* IPv4 unicast configuration. */
10207 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
10208 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
10209 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
10210 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
10211 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
10212 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
10213 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
10214 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
10215 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
10216 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
10217 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
10218 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
10219 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
10220 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
10221 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
10222 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
10223 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
10224 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
10225 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
10226 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
10227 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
10228 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
10229 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
10230 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
10231 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
10232 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
10233 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
10234 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
10235 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
10236 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
10237 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
10238 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
10239
10240 /* IPv4 multicast configuration. */
10241 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
10242 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
10243 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
10244 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
10245 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
10246 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
10247 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
10248 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
10249 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
10250 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
10251 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
10252 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
10253 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
10254 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
10255 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
10256 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
10257 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
10258 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
10259 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
10260 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
10261 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
10262 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
10263 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
10264 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
10265 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
10266 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
10267 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
10268 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
10269 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
10270 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
10271 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
10272 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
10273
10274 install_element (VIEW_NODE, &show_ip_bgp_cmd);
10275 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
10276 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
10277 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
10278 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
10279 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
10280 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
10281 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
10282 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
10283 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
10284 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
10285 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
10286 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
10287 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
10288 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
10289 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
10290 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
10291 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
10292 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
10293 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
10294 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
10295 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
10296 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
10297 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
10298 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
10299 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
10300 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
10301 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
10302 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
10303 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
10304 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
10305 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
10306 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
10307 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
10308 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
10309 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
10310 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
10311 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
10312 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
10313 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
10314 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
10315 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
10316 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
10317 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
10318 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
10319 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
10320 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
10321 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
10322 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
10323 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
10324 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
10325 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
10326 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
10327 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
10328 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
10329 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
10330 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
10331 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
10332 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
10333 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
10334 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
10335 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
10336 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
10337 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
10338 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
10339 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
10340 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010341 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
10342 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
10343 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
10344 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
10345 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
10346 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010347
10348 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
10349 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
10350 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
10351 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
10352 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
10353 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
10354 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
10355 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
10356 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
10357 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
10358 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
10359 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
10360 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
10361 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
10362 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
10363 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
10364 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
10365 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
10366 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
10367 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
10368 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
10369 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
10370 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
10371 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
10372 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
10373 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
10374 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
10375 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
10376 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
10377 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
10378 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
10379 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
10380 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
10381 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
10382 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
10383 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
10384 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
10385 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
10386 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
10387 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
10388 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
10389 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
10390 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
10391 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
10392 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
10393 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
10394 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
10395 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
10396 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
10397 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
10398 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
10399 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
10400 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
10401 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
10402 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
10403 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
10404 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
10405 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
10406 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
10407 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
10408 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
10409 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
10410 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
10411 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
10412 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
10413 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
10414 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010415 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
10416 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
10417 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
10418 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
10419 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
10420 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010421
10422 /* BGP dampening clear commands */
10423 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
10424 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
10425 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
10426 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
10427
10428#ifdef HAVE_IPV6
10429 /* New config IPv6 BGP commands. */
10430 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
10431 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
10432 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
10433 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
10434
10435 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
10436 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
10437 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
10438 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
10439
10440 /* Old config IPv6 BGP commands. */
10441 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
10442 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
10443
10444 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
10445 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
10446 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
10447 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
10448
10449 install_element (VIEW_NODE, &show_bgp_cmd);
10450 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
10451 install_element (VIEW_NODE, &show_bgp_route_cmd);
10452 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
10453 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
10454 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
10455 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
10456 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
10457 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
10458 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
10459 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
10460 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
10461 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
10462 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
10463 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
10464 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
10465 install_element (VIEW_NODE, &show_bgp_community_cmd);
10466 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
10467 install_element (VIEW_NODE, &show_bgp_community2_cmd);
10468 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
10469 install_element (VIEW_NODE, &show_bgp_community3_cmd);
10470 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
10471 install_element (VIEW_NODE, &show_bgp_community4_cmd);
10472 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
10473 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
10474 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
10475 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
10476 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
10477 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
10478 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
10479 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
10480 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
10481 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
10482 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
10483 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
10484 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
10485 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
10486 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
10487 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
10488 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
10489 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
10490 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
10491 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
10492 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
10493 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
10494 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000010495 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
10496 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
10497 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
10498 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010499 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
10500 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
10501 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000010502 install_element (VIEW_NODE, &show_bgp_view_cmd);
10503 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
10504 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
10505 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
10506 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
10507 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
10508 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
10509 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
10510 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
10511 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
10512 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
10513 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
10514 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
10515 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
10516 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
10517 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
10518 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
10519 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010520 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
10521 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
10522 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010523
10524 install_element (ENABLE_NODE, &show_bgp_cmd);
10525 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
10526 install_element (ENABLE_NODE, &show_bgp_route_cmd);
10527 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
10528 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
10529 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
10530 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
10531 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
10532 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
10533 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
10534 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
10535 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
10536 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
10537 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
10538 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
10539 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
10540 install_element (ENABLE_NODE, &show_bgp_community_cmd);
10541 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
10542 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
10543 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
10544 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
10545 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
10546 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
10547 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
10548 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
10549 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
10550 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
10551 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
10552 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
10553 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
10554 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
10555 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
10556 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
10557 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
10558 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
10559 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
10560 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
10561 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
10562 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
10563 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
10564 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
10565 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
10566 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
10567 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
10568 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
10569 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000010570 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
10571 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
10572 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
10573 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010574 install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
10575 install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
10576 install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000010577 install_element (ENABLE_NODE, &show_bgp_view_cmd);
10578 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
10579 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
10580 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
10581 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
10582 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
10583 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
10584 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
10585 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
10586 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
10587 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
10588 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
10589 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
10590 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
10591 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
10592 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
10593 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
10594 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010595 install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
10596 install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
10597 install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010598
10599 /* old command */
10600 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
10601 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
10602 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
10603 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
10604 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
10605 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
10606 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
10607 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
10608 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
10609 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
10610 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
10611 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
10612 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
10613 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
10614 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
10615 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
10616 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
10617 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
10618 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
10619 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
10620 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
10621 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
10622 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
10623 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
10624 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
10625 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
10626 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
10627 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
10628 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
10629 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
10630 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
10631 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
10632 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
10633 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
10634 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
10635 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
paulbb46e942003-10-24 19:02:03 +000010636
paul718e3742002-12-13 20:15:29 +000010637 /* old command */
10638 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
10639 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
10640 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
10641 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
10642 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
10643 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
10644 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
10645 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
10646 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
10647 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
10648 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
10649 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
10650 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
10651 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
10652 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
10653 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
10654 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
10655 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
10656 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
10657 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
10658 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
10659 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
10660 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
10661 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
10662 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
10663 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
10664 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
10665 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
10666 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
10667 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
10668 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
10669 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
10670 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
10671 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
10672 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
10673 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
10674
10675 /* old command */
10676 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
10677 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
10678 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
10679 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
10680
10681 /* old command */
10682 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
10683 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
10684 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
10685 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
10686
10687 /* old command */
10688 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
10689 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
10690 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
10691 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
10692#endif /* HAVE_IPV6 */
10693
10694 install_element (BGP_NODE, &bgp_distance_cmd);
10695 install_element (BGP_NODE, &no_bgp_distance_cmd);
10696 install_element (BGP_NODE, &no_bgp_distance2_cmd);
10697 install_element (BGP_NODE, &bgp_distance_source_cmd);
10698 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
10699 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
10700 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
10701
10702 install_element (BGP_NODE, &bgp_damp_set_cmd);
10703 install_element (BGP_NODE, &bgp_damp_set2_cmd);
10704 install_element (BGP_NODE, &bgp_damp_set3_cmd);
10705 install_element (BGP_NODE, &bgp_damp_unset_cmd);
10706 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
10707 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
10708 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
10709 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
10710 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
10711 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
10712}