blob: 156120b8458098af494031b00714b2581cc96196 [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
hasso6d694292005-01-24 09:29:42 +00001101 if ( (! old_select) || old_select != new_select
1102 || CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
paul718e3742002-12-13 20:15:29 +00001103 {
paul718e3742002-12-13 20:15:29 +00001104 if (old_select)
1105 UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED);
1106 if (new_select)
1107 {
1108 SET_FLAG (new_select->flags, BGP_INFO_SELECTED);
1109 UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED);
1110 }
paulfee0f4c2004-09-13 05:12:46 +00001111 }
1112
1113 result->old = old_select;
1114 result->new = new_select;
1115
1116 return;
1117}
1118
1119int
1120bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
1121 struct bgp_node *rn, struct attr *attr, afi_t afi, safi_t safi)
1122 {
1123 struct prefix *p;
1124
1125 p = &rn->p;
1126
1127 /* Announce route to Established peer. */
1128 if (peer->status != Established)
1129 return 0;
1130
1131 /* Address family configuration check. */
1132 if (! peer->afc_nego[afi][safi])
1133 return 0;
1134
1135 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1136 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1137 PEER_STATUS_ORF_WAIT_REFRESH))
1138 return 0;
1139
1140 switch (rn->table->type)
1141 {
1142 case BGP_TABLE_MAIN:
1143 /* Announcement to peer->conf. If the route is filtered,
1144 withdraw it. */
1145 if (selected && bgp_announce_check (selected, peer, p, attr, afi, safi))
1146 bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected);
1147 else
1148 bgp_adj_out_unset (rn, peer, p, afi, safi);
1149 break;
1150 case BGP_TABLE_RSCLIENT:
1151 /* Announcement to peer->conf. If the route is filtered,
1152 withdraw it. */
1153 if (selected && bgp_announce_check_rsclient
1154 (selected, peer, p, attr, afi, safi))
1155 bgp_adj_out_set (rn, peer, p, attr, afi, safi, selected);
1156 else
1157 bgp_adj_out_unset (rn, peer, p, afi, safi);
1158 break;
1159 }
1160 return 0;
1161 }
1162
1163int
1164bgp_process_rsclient (struct bgp *bgp, struct peer *rsclient,
1165 struct bgp_node *rn, afi_t afi, safi_t safi)
1166{
1167 struct prefix *p;
1168 struct bgp_info *new_select;
1169 struct bgp_info *old_select;
1170 struct bgp_info_pair old_and_new;
1171 struct attr attr;
1172 struct peer_group *group;
1173 struct listnode *nn;
1174
1175 p = &rn->p;
1176
1177 /* Best path selection. */
1178 bgp_best_selection (bgp, rn, &old_and_new);
1179 new_select = old_and_new.new;
1180 old_select = old_and_new.old;
1181
1182 if (CHECK_FLAG(rsclient->sflags, PEER_STATUS_GROUP))
1183 {
1184 group = rsclient->group;
1185 LIST_LOOP(group->peer, rsclient, nn)
1186 {
1187 /* Nothing to do. */
1188 if (old_select && old_select == new_select)
1189 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1190 continue;
1191
1192 bgp_process_announce_selected (rsclient, new_select, rn, &attr,
1193 afi, safi);
1194 }
1195 return 0;
1196 }
1197
1198 bgp_process_announce_selected (rsclient, new_select, rn, &attr, afi, safi);
1199
1200 return 0;
1201}
1202
1203int
1204bgp_process_main (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1205 {
1206 struct prefix *p;
1207 struct bgp_info *new_select;
1208 struct bgp_info *old_select;
1209 struct bgp_info_pair old_and_new;
1210 struct listnode *nn;
1211 struct peer *peer;
1212 struct attr attr;
1213
1214 p = &rn->p;
1215
1216 /* Best path selection. */
1217 bgp_best_selection (bgp, rn, &old_and_new);
1218 old_select = old_and_new.old;
1219 new_select = old_and_new.new;
1220
1221 /* Nothing to do. */
1222 if (old_select && old_select == new_select)
1223 {
1224 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1225 {
1226 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED))
1227 bgp_zebra_announce (p, old_select, bgp);
1228 return 0;
1229 }
1230 }
paul718e3742002-12-13 20:15:29 +00001231
1232 /* Check each BGP peer. */
1233 LIST_LOOP (bgp->peer, peer, nn)
1234 {
paulfee0f4c2004-09-13 05:12:46 +00001235 bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi);
paul718e3742002-12-13 20:15:29 +00001236 }
1237
1238 /* FIB update. */
1239 if (safi == SAFI_UNICAST && ! bgp->name &&
1240 ! bgp_option_check (BGP_OPT_NO_FIB))
1241 {
1242 if (new_select
1243 && new_select->type == ZEBRA_ROUTE_BGP
1244 && new_select->sub_type == BGP_ROUTE_NORMAL)
1245 bgp_zebra_announce (p, new_select, bgp);
1246 else
1247 {
1248 /* Withdraw the route from the kernel. */
1249 if (old_select
1250 && old_select->type == ZEBRA_ROUTE_BGP
1251 && old_select->sub_type == BGP_ROUTE_NORMAL)
1252 bgp_zebra_withdraw (p, old_select);
1253 }
1254 }
1255 return 0;
1256}
1257
1258int
paulfee0f4c2004-09-13 05:12:46 +00001259bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1260{
1261 switch (rn->table->type)
1262 {
1263 case BGP_TABLE_MAIN:
1264 return bgp_process_main (bgp, rn, afi, safi);
1265 case BGP_TABLE_RSCLIENT:
1266 return bgp_process_rsclient (bgp, (struct peer *) rn->table->owner,
1267 rn, afi, safi);
1268 }
1269 return 0;
1270}
hasso0a486e52005-02-01 20:57:17 +00001271
1272int
1273bgp_maximum_prefix_restart_timer (struct thread *thread)
1274{
1275 struct peer *peer;
1276
1277 peer = THREAD_ARG (thread);
1278 peer->t_pmax_restart = NULL;
1279
1280 if (BGP_DEBUG (events, EVENTS))
1281 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1282 peer->host);
1283
1284 peer_clear (peer);
1285
1286 return 0;
1287}
1288
paulfee0f4c2004-09-13 05:12:46 +00001289int
paul5228ad22004-06-04 17:58:18 +00001290bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1291 safi_t safi, int always)
paul718e3742002-12-13 20:15:29 +00001292{
hassoe0701b72004-05-20 09:19:34 +00001293 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1294 return 0;
1295
1296 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +00001297 {
hassoe0701b72004-05-20 09:19:34 +00001298 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1299 && ! always)
1300 return 0;
paul718e3742002-12-13 20:15:29 +00001301
hassoe0701b72004-05-20 09:19:34 +00001302 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001303 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1304 "limit %ld", afi_safi_print (afi, safi), peer->host,
1305 peer->pcount[afi][safi], peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001306 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
paul718e3742002-12-13 20:15:29 +00001307
hassoe0701b72004-05-20 09:19:34 +00001308 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1309 return 0;
paul718e3742002-12-13 20:15:29 +00001310
hassoe0701b72004-05-20 09:19:34 +00001311 {
paul5228ad22004-06-04 17:58:18 +00001312 u_int8_t ndata[7];
hassoe0701b72004-05-20 09:19:34 +00001313
1314 if (safi == SAFI_MPLS_VPN)
1315 safi = BGP_SAFI_VPNV4;
paul5228ad22004-06-04 17:58:18 +00001316
1317 ndata[0] = (afi >> 8);
1318 ndata[1] = afi;
1319 ndata[2] = safi;
1320 ndata[3] = (peer->pmax[afi][safi] >> 24);
1321 ndata[4] = (peer->pmax[afi][safi] >> 16);
1322 ndata[5] = (peer->pmax[afi][safi] >> 8);
1323 ndata[6] = (peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001324
1325 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1326 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1327 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1328 }
hasso0a486e52005-02-01 20:57:17 +00001329
1330 /* restart timer start */
1331 if (peer->pmax_restart[afi][safi])
1332 {
1333 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1334
1335 if (BGP_DEBUG (events, EVENTS))
1336 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1337 peer->host, peer->v_pmax_restart);
1338
1339 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1340 peer->v_pmax_restart);
1341 }
1342
hassoe0701b72004-05-20 09:19:34 +00001343 return 1;
paul718e3742002-12-13 20:15:29 +00001344 }
hassoe0701b72004-05-20 09:19:34 +00001345 else
1346 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1347
1348 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1349 {
1350 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1351 && ! always)
1352 return 0;
1353
1354 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001355 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1356 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1357 peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001358 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1359 }
1360 else
1361 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
paul718e3742002-12-13 20:15:29 +00001362 return 0;
1363}
1364
1365void
1366bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1367 afi_t afi, safi_t safi)
1368{
1369 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1370 {
paulfee0f4c2004-09-13 05:12:46 +00001371 /* Ignore 'pcount' for RS-client tables */
1372 if ( rn->table->type == BGP_TABLE_MAIN)
1373 {
paul718e3742002-12-13 20:15:29 +00001374 peer->pcount[afi][safi]--;
1375 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001376 }
paul718e3742002-12-13 20:15:29 +00001377 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
1378 bgp_process (peer->bgp, rn, afi, safi);
1379 }
1380 bgp_info_delete (rn, ri);
1381 bgp_info_free (ri);
1382 bgp_unlock_node (rn);
1383}
1384
1385void
1386bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1387 afi_t afi, safi_t safi, int force)
1388{
1389 int valid;
1390 int status = BGP_DAMP_NONE;
1391
paulfee0f4c2004-09-13 05:12:46 +00001392 /* Ignore 'pcount' for RS-client tables */
1393 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY) &&
1394 rn->table->type == BGP_TABLE_MAIN)
paul718e3742002-12-13 20:15:29 +00001395 {
hasso93406d82005-02-02 14:40:33 +00001396 if (! CHECK_FLAG (ri->flags, BGP_INFO_STALE))
1397 peer->pcount[afi][safi]--;
paul718e3742002-12-13 20:15:29 +00001398 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1399 }
1400
1401 if (! force)
1402 {
1403 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1404 && peer_sort (peer) == BGP_PEER_EBGP)
1405 status = bgp_damp_withdraw (ri, rn, afi, safi, 0);
1406
1407 if (status == BGP_DAMP_SUPPRESSED)
1408 return;
1409 }
1410
1411 valid = CHECK_FLAG (ri->flags, BGP_INFO_VALID);
1412 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
1413 bgp_process (peer->bgp, rn, afi, safi);
1414
1415 if (valid)
1416 SET_FLAG (ri->flags, BGP_INFO_VALID);
1417
1418 if (status != BGP_DAMP_USED)
1419 {
1420 bgp_info_delete (rn, ri);
1421 bgp_info_free (ri);
1422 bgp_unlock_node (rn);
1423 }
1424}
1425
paulfee0f4c2004-09-13 05:12:46 +00001426void
1427bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1428 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1429 int sub_type, struct prefix_rd *prd, u_char *tag)
1430{
1431 struct bgp_node *rn;
1432 struct bgp *bgp;
1433 struct attr new_attr;
1434 struct attr *attr_new;
1435 struct attr *attr_new2;
1436 struct bgp_info *ri;
1437 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001438 const char *reason;
paulfee0f4c2004-09-13 05:12:46 +00001439 char buf[SU_ADDRSTRLEN];
1440
1441 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1442 if (peer == rsclient)
1443 return;
1444
1445 bgp = peer->bgp;
1446 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1447
1448 /* Check previously received route. */
1449 for (ri = rn->info; ri; ri = ri->next)
1450 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1451 break;
1452
1453 /* AS path loop check. */
1454 if (aspath_loop_check (attr->aspath, rsclient->as) > peer->allowas_in[afi][safi])
1455 {
1456 reason = "as-path contains our own AS;";
1457 goto filtered;
1458 }
1459
1460 /* Route reflector originator ID check. */
1461 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
1462 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->originator_id))
1463 {
1464 reason = "originator is us;";
1465 goto filtered;
1466 }
1467
1468 new_attr = *attr;
1469
1470 /* Apply export policy. */
1471 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1472 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1473 {
1474 reason = "export-policy;";
1475 goto filtered;
1476 }
1477
1478 attr_new2 = bgp_attr_intern (&new_attr);
1479
1480 /* Apply import policy. */
1481 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1482 {
1483 bgp_attr_unintern (attr_new2);
1484
1485 reason = "import-policy;";
1486 goto filtered;
1487 }
1488
1489 attr_new = bgp_attr_intern (&new_attr);
1490 bgp_attr_unintern (attr_new2);
1491
1492 /* IPv4 unicast next hop check. */
1493 if (afi == AFI_IP && safi == SAFI_UNICAST)
1494 {
1495 /* Next hop must not be 0.0.0.0 nor Class E address. */
1496 if (new_attr.nexthop.s_addr == 0
1497 || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000)
1498 {
1499 bgp_attr_unintern (attr_new);
1500
1501 reason = "martian next-hop;";
1502 goto filtered;
1503 }
1504 }
1505
1506 /* If the update is implicit withdraw. */
1507 if (ri)
1508 {
1509 ri->uptime = time (NULL);
1510
1511 /* Same attribute comes in. */
1512 if (attrhash_cmp (ri->attr, attr_new))
1513 {
1514
1515 UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1516
1517 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001518 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001519 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1520 peer->host,
1521 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1522 p->prefixlen, rsclient->host);
1523
1524 bgp_unlock_node (rn);
1525 bgp_attr_unintern (attr_new);
1526
1527 return;
1528 }
1529
1530 /* Received Logging. */
1531 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001532 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00001533 peer->host,
1534 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1535 p->prefixlen, rsclient->host);
1536
1537 /* The attribute is changed. */
1538 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1539
1540 /* Update to new attribute. */
1541 bgp_attr_unintern (ri->attr);
1542 ri->attr = attr_new;
1543
1544 /* Update MPLS tag. */
1545 if (safi == SAFI_MPLS_VPN)
1546 memcpy (ri->tag, tag, 3);
1547
1548 SET_FLAG (ri->flags, BGP_INFO_VALID);
1549
1550 /* Process change. */
1551 bgp_process (bgp, rn, afi, safi);
1552 bgp_unlock_node (rn);
1553
1554 return;
1555 }
1556
1557 /* Received Logging. */
1558 if (BGP_DEBUG (update, UPDATE_IN))
1559 {
ajsd2c1f162004-12-08 21:10:20 +00001560 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00001561 peer->host,
1562 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1563 p->prefixlen, rsclient->host);
1564 }
1565
1566 /* Make new BGP info. */
1567 new = bgp_info_new ();
1568 new->type = type;
1569 new->sub_type = sub_type;
1570 new->peer = peer;
1571 new->attr = attr_new;
1572 new->uptime = time (NULL);
1573
1574 /* Update MPLS tag. */
1575 if (safi == SAFI_MPLS_VPN)
1576 memcpy (new->tag, tag, 3);
1577
1578 SET_FLAG (new->flags, BGP_INFO_VALID);
1579
1580 /* Register new BGP information. */
1581 bgp_info_add (rn, new);
1582
1583 /* Process change. */
1584 bgp_process (bgp, rn, afi, safi);
1585
1586 return;
1587
1588 filtered:
1589
1590 /* This BGP update is filtered. Log the reason then update BGP entry. */
1591 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001592 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001593 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1594 peer->host,
1595 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1596 p->prefixlen, rsclient->host, reason);
1597
1598 if (ri)
1599 bgp_rib_withdraw (rn, ri, peer, afi, safi, 1);
1600
1601 bgp_unlock_node (rn);
1602
1603 return;
1604}
1605
1606void
1607bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1608 struct peer *peer, struct prefix *p, int type, int sub_type,
1609 struct prefix_rd *prd, u_char *tag)
1610 {
1611 struct bgp_node *rn;
1612 struct bgp_info *ri;
1613 char buf[SU_ADDRSTRLEN];
1614
1615 if (rsclient == peer)
1616 return;
1617
1618 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1619
1620 /* Lookup withdrawn route. */
1621 for (ri = rn->info; ri; ri = ri->next)
1622 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1623 break;
1624
1625 /* Withdraw specified route from routing table. */
1626 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1627 bgp_rib_withdraw (rn, ri, peer, afi, safi, 0);
1628 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001629 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001630 "%s Can't find the route %s/%d", peer->host,
1631 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1632 p->prefixlen);
1633
1634 /* Unlock bgp_node_get() lock. */
1635 bgp_unlock_node (rn);
1636 }
1637
paul718e3742002-12-13 20:15:29 +00001638int
paulfee0f4c2004-09-13 05:12:46 +00001639bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
paul718e3742002-12-13 20:15:29 +00001640 afi_t afi, safi_t safi, int type, int sub_type,
1641 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
1642{
1643 int ret;
1644 int aspath_loop_count = 0;
1645 struct bgp_node *rn;
1646 struct bgp *bgp;
1647 struct attr new_attr;
1648 struct attr *attr_new;
1649 struct bgp_info *ri;
1650 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001651 const char *reason;
paul718e3742002-12-13 20:15:29 +00001652 char buf[SU_ADDRSTRLEN];
1653
1654 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00001655 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00001656
1657 /* When peer's soft reconfiguration enabled. Record input packet in
1658 Adj-RIBs-In. */
1659 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
1660 && peer != bgp->peer_self && ! soft_reconfig)
1661 bgp_adj_in_set (rn, peer, attr);
1662
1663 /* Check previously received route. */
1664 for (ri = rn->info; ri; ri = ri->next)
1665 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1666 break;
1667
1668 /* AS path local-as loop check. */
1669 if (peer->change_local_as)
1670 {
1671 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
1672 aspath_loop_count = 1;
1673
1674 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
1675 {
1676 reason = "as-path contains our own AS;";
1677 goto filtered;
1678 }
1679 }
1680
1681 /* AS path loop check. */
1682 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
1683 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
1684 && aspath_loop_check(attr->aspath, bgp->confed_id)
1685 > peer->allowas_in[afi][safi]))
1686 {
1687 reason = "as-path contains our own AS;";
1688 goto filtered;
1689 }
1690
1691 /* Route reflector originator ID check. */
1692 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
1693 && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id))
1694 {
1695 reason = "originator is us;";
1696 goto filtered;
1697 }
1698
1699 /* Route reflector cluster ID check. */
1700 if (bgp_cluster_filter (peer, attr))
1701 {
1702 reason = "reflected from the same cluster;";
1703 goto filtered;
1704 }
1705
1706 /* Apply incoming filter. */
1707 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
1708 {
1709 reason = "filter;";
1710 goto filtered;
1711 }
1712
1713 /* Apply incoming route-map. */
1714 new_attr = *attr;
1715
1716 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
1717 {
1718 reason = "route-map;";
1719 goto filtered;
1720 }
1721
1722 /* IPv4 unicast next hop check. */
1723 if (afi == AFI_IP && safi == SAFI_UNICAST)
1724 {
1725 /* If the peer is EBGP and nexthop is not on connected route,
1726 discard it. */
1727 if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1
1728 && ! bgp_nexthop_check_ebgp (afi, &new_attr)
hasso6ffd2072005-02-02 14:50:11 +00001729 && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
paul718e3742002-12-13 20:15:29 +00001730 {
1731 reason = "non-connected next-hop;";
1732 goto filtered;
1733 }
1734
1735 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
1736 must not be my own address. */
1737 if (bgp_nexthop_self (afi, &new_attr)
1738 || new_attr.nexthop.s_addr == 0
1739 || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000)
1740 {
1741 reason = "martian next-hop;";
1742 goto filtered;
1743 }
1744 }
1745
1746 attr_new = bgp_attr_intern (&new_attr);
1747
1748 /* If the update is implicit withdraw. */
1749 if (ri)
1750 {
1751 ri->uptime = time (NULL);
1752
1753 /* Same attribute comes in. */
1754 if (attrhash_cmp (ri->attr, attr_new))
1755 {
1756 UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1757
1758 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1759 && peer_sort (peer) == BGP_PEER_EBGP
1760 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1761 {
1762 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001763 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00001764 peer->host,
1765 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1766 p->prefixlen);
1767
1768 peer->pcount[afi][safi]++;
1769 ret = bgp_damp_update (ri, rn, afi, safi);
1770 if (ret != BGP_DAMP_SUPPRESSED)
1771 {
1772 bgp_aggregate_increment (bgp, p, ri, afi, safi);
1773 bgp_process (bgp, rn, afi, safi);
1774 }
1775 }
1776 else
1777 {
1778 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001779 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00001780 "%s rcvd %s/%d...duplicate ignored",
1781 peer->host,
1782 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1783 p->prefixlen);
hasso93406d82005-02-02 14:40:33 +00001784
1785 /* graceful restart STALE flag unset. */
1786 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
1787 {
1788 UNSET_FLAG (ri->flags, BGP_INFO_STALE);
1789 peer->pcount[afi][safi]++;
1790 }
paul718e3742002-12-13 20:15:29 +00001791 }
1792
1793 bgp_unlock_node (rn);
1794 bgp_attr_unintern (attr_new);
1795 return 0;
1796 }
1797
1798 /* Received Logging. */
1799 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001800 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00001801 peer->host,
1802 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1803 p->prefixlen);
1804
hasso93406d82005-02-02 14:40:33 +00001805 /* graceful restart STALE flag unset. */
1806 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
1807 {
1808 UNSET_FLAG (ri->flags, BGP_INFO_STALE);
1809 peer->pcount[afi][safi]++;
1810 }
1811
paul718e3742002-12-13 20:15:29 +00001812 /* The attribute is changed. */
1813 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1814
1815 /* Update bgp route dampening information. */
1816 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1817 && peer_sort (peer) == BGP_PEER_EBGP)
1818 {
1819 /* This is implicit withdraw so we should update dampening
1820 information. */
1821 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1822 bgp_damp_withdraw (ri, rn, afi, safi, 1);
1823 else
1824 peer->pcount[afi][safi]++;
1825 }
1826
1827 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
1828
1829 /* Update to new attribute. */
1830 bgp_attr_unintern (ri->attr);
1831 ri->attr = attr_new;
1832
1833 /* Update MPLS tag. */
1834 if (safi == SAFI_MPLS_VPN)
1835 memcpy (ri->tag, tag, 3);
1836
1837 /* Update bgp route dampening information. */
1838 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1839 && peer_sort (peer) == BGP_PEER_EBGP)
1840 {
1841 /* Now we do normal update dampening. */
1842 ret = bgp_damp_update (ri, rn, afi, safi);
1843 if (ret == BGP_DAMP_SUPPRESSED)
1844 {
1845 bgp_unlock_node (rn);
1846 return 0;
1847 }
1848 }
1849
1850 /* Nexthop reachability check. */
1851 if ((afi == AFI_IP || afi == AFI_IP6)
1852 && safi == SAFI_UNICAST
1853 && (peer_sort (peer) == BGP_PEER_IBGP
1854 || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00001855 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00001856 {
1857 if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
1858 SET_FLAG (ri->flags, BGP_INFO_VALID);
1859 else
1860 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
1861 }
1862 else
1863 SET_FLAG (ri->flags, BGP_INFO_VALID);
1864
1865 /* Process change. */
1866 bgp_aggregate_increment (bgp, p, ri, afi, safi);
1867
1868 bgp_process (bgp, rn, afi, safi);
1869 bgp_unlock_node (rn);
1870 return 0;
1871 }
1872
1873 /* Received Logging. */
1874 if (BGP_DEBUG (update, UPDATE_IN))
1875 {
ajsd2c1f162004-12-08 21:10:20 +00001876 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00001877 peer->host,
1878 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1879 p->prefixlen);
1880 }
1881
1882 /* Increment prefix counter */
1883 peer->pcount[afi][safi]++;
1884
1885 /* Make new BGP info. */
1886 new = bgp_info_new ();
1887 new->type = type;
1888 new->sub_type = sub_type;
1889 new->peer = peer;
1890 new->attr = attr_new;
1891 new->uptime = time (NULL);
1892
1893 /* Update MPLS tag. */
1894 if (safi == SAFI_MPLS_VPN)
1895 memcpy (new->tag, tag, 3);
1896
1897 /* Nexthop reachability check. */
1898 if ((afi == AFI_IP || afi == AFI_IP6)
1899 && safi == SAFI_UNICAST
1900 && (peer_sort (peer) == BGP_PEER_IBGP
1901 || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00001902 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00001903 {
1904 if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
1905 SET_FLAG (new->flags, BGP_INFO_VALID);
1906 else
1907 UNSET_FLAG (new->flags, BGP_INFO_VALID);
1908 }
1909 else
1910 SET_FLAG (new->flags, BGP_INFO_VALID);
1911
1912 /* Aggregate address increment. */
1913 bgp_aggregate_increment (bgp, p, new, afi, safi);
1914
1915 /* Register new BGP information. */
1916 bgp_info_add (rn, new);
1917
1918 /* If maximum prefix count is configured and current prefix
1919 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00001920 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
1921 return -1;
paul718e3742002-12-13 20:15:29 +00001922
1923 /* Process change. */
1924 bgp_process (bgp, rn, afi, safi);
1925
1926 return 0;
1927
1928 /* This BGP update is filtered. Log the reason then update BGP
1929 entry. */
1930 filtered:
1931 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001932 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00001933 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
1934 peer->host,
1935 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1936 p->prefixlen, reason);
1937
1938 if (ri)
1939 bgp_rib_withdraw (rn, ri, peer, afi, safi, 1);
1940
1941 bgp_unlock_node (rn);
1942
1943 return 0;
1944}
1945
1946int
paulfee0f4c2004-09-13 05:12:46 +00001947bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
1948 afi_t afi, safi_t safi, int type, int sub_type,
1949 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
1950{
1951 struct peer *rsclient;
1952 struct listnode *nn;
1953 struct bgp *bgp;
1954 int ret;
1955
1956 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
1957 soft_reconfig);
1958
1959 bgp = peer->bgp;
1960
1961 /* Process the update for each RS-client. */
1962 LIST_LOOP(bgp->rsclient, rsclient, nn)
1963 {
1964 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
1965 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
1966 sub_type, prd, tag);
1967 }
1968
1969 return ret;
1970}
1971
1972int
paul718e3742002-12-13 20:15:29 +00001973bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
1974 int afi, int safi, int type, int sub_type, struct prefix_rd *prd,
1975 u_char *tag)
1976{
1977 struct bgp *bgp;
1978 char buf[SU_ADDRSTRLEN];
1979 struct bgp_node *rn;
1980 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00001981 struct peer *rsclient;
1982 struct listnode *nn;
paul718e3742002-12-13 20:15:29 +00001983
1984 bgp = peer->bgp;
1985
paulfee0f4c2004-09-13 05:12:46 +00001986 /* Process the withdraw for each RS-client. */
1987 LIST_LOOP (bgp->rsclient, rsclient, nn)
1988 {
1989 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
1990 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
1991 }
1992
paul718e3742002-12-13 20:15:29 +00001993 /* Logging. */
1994 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001995 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00001996 peer->host,
1997 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1998 p->prefixlen);
1999
2000 /* Lookup node. */
paulfee0f4c2004-09-13 05:12:46 +00002001 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00002002
2003 /* If peer is soft reconfiguration enabled. Record input packet for
2004 further calculation. */
2005 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2006 && peer != bgp->peer_self)
2007 bgp_adj_in_unset (rn, peer);
2008
2009 /* Lookup withdrawn route. */
2010 for (ri = rn->info; ri; ri = ri->next)
2011 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2012 break;
2013
2014 /* Withdraw specified route from routing table. */
2015 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2016 bgp_rib_withdraw (rn, ri, peer, afi, safi, 0);
2017 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002018 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002019 "%s Can't find the route %s/%d", peer->host,
2020 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2021 p->prefixlen);
2022
2023 /* Unlock bgp_node_get() lock. */
2024 bgp_unlock_node (rn);
2025
2026 return 0;
2027}
2028
2029void
2030bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2031{
2032 struct bgp *bgp;
2033 struct attr attr;
2034 struct aspath *aspath;
2035 struct prefix p;
2036 struct bgp_info binfo;
2037 struct peer *from;
2038 int ret = RMAP_DENYMATCH;
2039
2040 bgp = peer->bgp;
2041 from = bgp->peer_self;
2042
2043 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2044 aspath = attr.aspath;
2045 attr.local_pref = bgp->default_local_pref;
2046 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2047
2048 if (afi == AFI_IP)
2049 str2prefix ("0.0.0.0/0", &p);
2050#ifdef HAVE_IPV6
2051 else if (afi == AFI_IP6)
2052 {
2053 str2prefix ("::/0", &p);
2054
2055 /* IPv6 global nexthop must be included. */
2056 memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global,
2057 IPV6_MAX_BYTELEN);
2058 attr.mp_nexthop_len = 16;
2059
2060 /* If the peer is on shared nextwork and we have link-local
2061 nexthop set it. */
2062 if (peer->shared_network
2063 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2064 {
2065 memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local,
2066 IPV6_MAX_BYTELEN);
2067 attr.mp_nexthop_len = 32;
2068 }
2069 }
2070#endif /* HAVE_IPV6 */
2071 else
2072 return;
2073
2074 if (peer->default_rmap[afi][safi].name)
2075 {
2076 binfo.peer = bgp->peer_self;
2077 binfo.attr = &attr;
2078
paulfee0f4c2004-09-13 05:12:46 +00002079 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
2080
paul718e3742002-12-13 20:15:29 +00002081 ret = route_map_apply (peer->default_rmap[afi][safi].map, &p,
2082 RMAP_BGP, &binfo);
2083
paulfee0f4c2004-09-13 05:12:46 +00002084 bgp->peer_self->rmap_type = 0;
2085
paul718e3742002-12-13 20:15:29 +00002086 if (ret == RMAP_DENYMATCH)
2087 {
2088 bgp_attr_flush (&attr);
2089 withdraw = 1;
2090 }
2091 }
2092
2093 if (withdraw)
2094 {
2095 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2096 bgp_default_withdraw_send (peer, afi, safi);
2097 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2098 }
2099 else
2100 {
2101 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2102 bgp_default_update_send (peer, &attr, afi, safi, from);
2103 }
2104
2105 aspath_unintern (aspath);
2106}
2107
2108static void
2109bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002110 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002111{
2112 struct bgp_node *rn;
2113 struct bgp_info *ri;
2114 struct attr attr;
2115
2116 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002117 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002118
2119 if (safi != SAFI_MPLS_VPN
2120 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2121 bgp_default_originate (peer, afi, safi, 0);
2122
2123 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2124 for (ri = rn->info; ri; ri = ri->next)
2125 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2126 {
paulfee0f4c2004-09-13 05:12:46 +00002127 if ( (rsclient) ?
2128 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2129 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002130 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2131 else
2132 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2133 }
2134}
2135
2136void
2137bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2138{
2139 struct bgp_node *rn;
2140 struct bgp_table *table;
2141
2142 if (peer->status != Established)
2143 return;
2144
2145 if (! peer->afc_nego[afi][safi])
2146 return;
2147
2148 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2149 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2150 return;
2151
2152 if (safi != SAFI_MPLS_VPN)
paulfee0f4c2004-09-13 05:12:46 +00002153 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002154 else
2155 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2156 rn = bgp_route_next(rn))
2157 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002158 bgp_announce_table (peer, afi, safi, table, 0);
2159
2160 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2161 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002162}
2163
2164void
2165bgp_announce_route_all (struct peer *peer)
2166{
2167 afi_t afi;
2168 safi_t safi;
2169
2170 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2171 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2172 bgp_announce_route (peer, afi, safi);
2173}
2174
2175static void
paulfee0f4c2004-09-13 05:12:46 +00002176bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
2177 safi_t safi, struct bgp_table *table)
2178{
2179 struct bgp_node *rn;
2180 struct bgp_adj_in *ain;
2181
2182 if (! table)
2183 table = rsclient->bgp->rib[afi][safi];
2184
2185 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2186 for (ain = rn->adj_in; ain; ain = ain->next)
2187 {
2188 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
2189 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
2190 }
2191}
2192
2193void
2194bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2195{
2196 struct bgp_table *table;
2197 struct bgp_node *rn;
2198
2199 if (safi != SAFI_MPLS_VPN)
2200 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL);
2201
2202 else
2203 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2204 rn = bgp_route_next (rn))
2205 if ((table = rn->info) != NULL)
2206 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table);
2207}
2208
2209static void
paul718e3742002-12-13 20:15:29 +00002210bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
2211 struct bgp_table *table)
2212{
2213 int ret;
2214 struct bgp_node *rn;
2215 struct bgp_adj_in *ain;
2216
2217 if (! table)
2218 table = peer->bgp->rib[afi][safi];
2219
2220 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2221 for (ain = rn->adj_in; ain; ain = ain->next)
2222 {
2223 if (ain->peer == peer)
2224 {
2225 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2226 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
2227 NULL, NULL, 1);
2228 if (ret < 0)
2229 {
2230 bgp_unlock_node (rn);
2231 return;
2232 }
2233 continue;
2234 }
2235 }
2236}
2237
2238void
2239bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2240{
2241 struct bgp_node *rn;
2242 struct bgp_table *table;
2243
2244 if (peer->status != Established)
2245 return;
2246
2247 if (safi != SAFI_MPLS_VPN)
2248 bgp_soft_reconfig_table (peer, afi, safi, NULL);
2249 else
2250 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2251 rn = bgp_route_next (rn))
2252 if ((table = rn->info) != NULL)
2253 bgp_soft_reconfig_table (peer, afi, safi, table);
2254}
2255
2256static void
2257bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002258 struct bgp_table *table, struct peer *rsclient)
paul718e3742002-12-13 20:15:29 +00002259{
2260 struct bgp_node *rn;
2261 struct bgp_adj_in *ain;
2262 struct bgp_adj_out *aout;
2263 struct bgp_info *ri;
2264
2265 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002266 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002267
2268 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2269 {
2270 for (ri = rn->info; ri; ri = ri->next)
2271 if (ri->peer == peer)
2272 {
hasso93406d82005-02-02 14:40:33 +00002273 /* graceful restart STALE flag set. */
2274 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2275 && peer->nsf[afi][safi]
2276 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
2277 && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY)
2278 && ! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
2279 {
2280 SET_FLAG (ri->flags, BGP_INFO_STALE);
2281 peer->pcount[afi][safi]--;
2282 }
2283 else
2284 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002285 break;
2286 }
2287 for (ain = rn->adj_in; ain; ain = ain->next)
2288 if (ain->peer == peer)
2289 {
2290 bgp_adj_in_remove (rn, ain);
2291 bgp_unlock_node (rn);
2292 break;
2293 }
2294 for (aout = rn->adj_out; aout; aout = aout->next)
2295 if (aout->peer == peer)
2296 {
2297 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2298 bgp_unlock_node (rn);
2299 break;
2300 }
2301 }
2302}
2303
2304void
2305bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi)
2306{
2307 struct bgp_node *rn;
2308 struct bgp_table *table;
paulfee0f4c2004-09-13 05:12:46 +00002309 struct peer *rsclient;
2310 struct listnode *nn;
paul718e3742002-12-13 20:15:29 +00002311
paul718e3742002-12-13 20:15:29 +00002312 if (safi != SAFI_MPLS_VPN)
paulfee0f4c2004-09-13 05:12:46 +00002313 bgp_clear_route_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002314 else
2315 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2316 rn = bgp_route_next (rn))
2317 if ((table = rn->info) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002318 bgp_clear_route_table (peer, afi, safi, table, NULL);
2319
2320 LIST_LOOP (peer->bgp->rsclient, rsclient, nn)
2321 {
2322 if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2323 bgp_clear_route_table (peer, afi, safi, NULL, rsclient);
2324 }
paul718e3742002-12-13 20:15:29 +00002325}
2326
2327void
2328bgp_clear_route_all (struct peer *peer)
2329{
2330 afi_t afi;
2331 safi_t safi;
2332
2333 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2334 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2335 bgp_clear_route (peer, afi, safi);
2336}
2337
2338void
2339bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
2340{
2341 struct bgp_table *table;
2342 struct bgp_node *rn;
2343 struct bgp_adj_in *ain;
2344
2345 table = peer->bgp->rib[afi][safi];
2346
2347 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2348 for (ain = rn->adj_in; ain ; ain = ain->next)
2349 if (ain->peer == peer)
2350 {
2351 bgp_adj_in_remove (rn, ain);
2352 bgp_unlock_node (rn);
2353 break;
2354 }
2355}
hasso93406d82005-02-02 14:40:33 +00002356
2357void
2358bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
2359{
2360 struct bgp_node *rn;
2361 struct bgp_info *ri;
2362 struct bgp_table *table;
2363
2364 table = peer->bgp->rib[afi][safi];
2365
2366 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2367 {
2368 for (ri = rn->info; ri; ri = ri->next)
2369 if (ri->peer == peer)
2370 {
2371 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2372 bgp_rib_remove (rn, ri, peer, afi, safi);
2373 break;
2374 }
2375 }
2376}
paul718e3742002-12-13 20:15:29 +00002377
2378/* Delete all kernel routes. */
2379void
paul545acaf2004-04-20 15:13:15 +00002380bgp_cleanup_routes ()
paul718e3742002-12-13 20:15:29 +00002381{
2382 struct bgp *bgp;
2383 struct listnode *nn;
2384 struct bgp_node *rn;
2385 struct bgp_table *table;
2386 struct bgp_info *ri;
2387
2388 LIST_LOOP (bm->bgp, bgp, nn)
2389 {
2390 table = bgp->rib[AFI_IP][SAFI_UNICAST];
2391
2392 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2393 for (ri = rn->info; ri; ri = ri->next)
2394 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
2395 && ri->type == ZEBRA_ROUTE_BGP
2396 && ri->sub_type == BGP_ROUTE_NORMAL)
2397 bgp_zebra_withdraw (&rn->p, ri);
2398
2399 table = bgp->rib[AFI_IP6][SAFI_UNICAST];
2400
2401 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2402 for (ri = rn->info; ri; ri = ri->next)
2403 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
2404 && ri->type == ZEBRA_ROUTE_BGP
2405 && ri->sub_type == BGP_ROUTE_NORMAL)
2406 bgp_zebra_withdraw (&rn->p, ri);
2407 }
2408}
2409
2410void
2411bgp_reset ()
2412{
2413 vty_reset ();
2414 bgp_zclient_reset ();
2415 access_list_reset ();
2416 prefix_list_reset ();
2417}
2418
2419/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2420 value. */
2421int
2422bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
2423{
2424 u_char *pnt;
2425 u_char *lim;
2426 struct prefix p;
2427 int psize;
2428 int ret;
2429
2430 /* Check peer status. */
2431 if (peer->status != Established)
2432 return 0;
2433
2434 pnt = packet->nlri;
2435 lim = pnt + packet->length;
2436
2437 for (; pnt < lim; pnt += psize)
2438 {
2439 /* Clear prefix structure. */
2440 memset (&p, 0, sizeof (struct prefix));
2441
2442 /* Fetch prefix length. */
2443 p.prefixlen = *pnt++;
2444 p.family = afi2family (packet->afi);
2445
2446 /* Already checked in nlri_sanity_check(). We do double check
2447 here. */
2448 if ((packet->afi == AFI_IP && p.prefixlen > 32)
2449 || (packet->afi == AFI_IP6 && p.prefixlen > 128))
2450 return -1;
2451
2452 /* Packet size overflow check. */
2453 psize = PSIZE (p.prefixlen);
2454
2455 /* When packet overflow occur return immediately. */
2456 if (pnt + psize > lim)
2457 return -1;
2458
2459 /* Fetch prefix from NLRI packet. */
2460 memcpy (&p.u.prefix, pnt, psize);
2461
2462 /* Check address. */
2463 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
2464 {
2465 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
2466 {
paulf5ba3872004-07-09 12:11:31 +00002467 /*
2468 * From draft-ietf-idr-bgp4-22, Section 6.3:
2469 * If a BGP router receives an UPDATE message with a
2470 * semantically incorrect NLRI field, in which a prefix is
2471 * semantically incorrect (eg. an unexpected multicast IP
2472 * address), it should ignore the prefix.
2473 */
paul718e3742002-12-13 20:15:29 +00002474 zlog (peer->log, LOG_ERR,
2475 "IPv4 unicast NLRI is multicast address %s",
2476 inet_ntoa (p.u.prefix4));
paulf5ba3872004-07-09 12:11:31 +00002477
paul718e3742002-12-13 20:15:29 +00002478 return -1;
2479 }
2480 }
2481
2482#ifdef HAVE_IPV6
2483 /* Check address. */
2484 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
2485 {
2486 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
2487 {
2488 char buf[BUFSIZ];
2489
2490 zlog (peer->log, LOG_WARNING,
2491 "IPv6 link-local NLRI received %s ignore this NLRI",
2492 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
2493
2494 continue;
2495 }
2496 }
2497#endif /* HAVE_IPV6 */
2498
2499 /* Normal process. */
2500 if (attr)
2501 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
2502 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
2503 else
2504 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
2505 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
2506
2507 /* Address family configuration mismatch or maximum-prefix count
2508 overflow. */
2509 if (ret < 0)
2510 return -1;
2511 }
2512
2513 /* Packet length consistency check. */
2514 if (pnt != lim)
2515 return -1;
2516
2517 return 0;
2518}
2519
2520/* NLRI encode syntax check routine. */
2521int
2522bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt,
2523 bgp_size_t length)
2524{
2525 u_char *end;
2526 u_char prefixlen;
2527 int psize;
2528
2529 end = pnt + length;
2530
2531 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
2532 syntactic validity. If the field is syntactically incorrect,
2533 then the Error Subcode is set to Invalid Network Field. */
2534
2535 while (pnt < end)
2536 {
2537 prefixlen = *pnt++;
2538
2539 /* Prefix length check. */
2540 if ((afi == AFI_IP && prefixlen > 32)
2541 || (afi == AFI_IP6 && prefixlen > 128))
2542 {
2543 plog_err (peer->log,
2544 "%s [Error] Update packet error (wrong prefix length %d)",
2545 peer->host, prefixlen);
2546 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
2547 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
2548 return -1;
2549 }
2550
2551 /* Packet size overflow check. */
2552 psize = PSIZE (prefixlen);
2553
2554 if (pnt + psize > end)
2555 {
2556 plog_err (peer->log,
2557 "%s [Error] Update packet error"
2558 " (prefix data overflow prefix size is %d)",
2559 peer->host, psize);
2560 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
2561 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
2562 return -1;
2563 }
2564
2565 pnt += psize;
2566 }
2567
2568 /* Packet length consistency check. */
2569 if (pnt != end)
2570 {
2571 plog_err (peer->log,
2572 "%s [Error] Update packet error"
2573 " (prefix length mismatch with total length)",
2574 peer->host);
2575 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
2576 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
2577 return -1;
2578 }
2579 return 0;
2580}
2581
2582struct bgp_static *
2583bgp_static_new ()
2584{
2585 struct bgp_static *new;
2586 new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
2587 memset (new, 0, sizeof (struct bgp_static));
2588 return new;
2589}
2590
2591void
2592bgp_static_free (struct bgp_static *bgp_static)
2593{
2594 if (bgp_static->rmap.name)
2595 free (bgp_static->rmap.name);
2596 XFREE (MTYPE_BGP_STATIC, bgp_static);
2597}
2598
2599void
paulfee0f4c2004-09-13 05:12:46 +00002600bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
2601 struct prefix *p, afi_t afi, safi_t safi)
2602{
2603 struct bgp_node *rn;
2604 struct bgp_info *ri;
2605
2606 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
2607
2608 /* Check selected route and self inserted route. */
2609 for (ri = rn->info; ri; ri = ri->next)
2610 if (ri->peer == bgp->peer_self
2611 && ri->type == ZEBRA_ROUTE_BGP
2612 && ri->sub_type == BGP_ROUTE_STATIC)
2613 break;
2614
2615 /* Withdraw static BGP route from routing table. */
2616 if (ri)
2617 {
2618 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
2619 bgp_process (bgp, rn, afi, safi);
2620 bgp_info_delete (rn, ri);
2621 bgp_info_free (ri);
2622 bgp_unlock_node (rn);
2623 }
2624
2625 /* Unlock bgp_node_lookup. */
2626 bgp_unlock_node (rn);
2627}
2628
2629void
2630bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
2631 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
2632{
2633 struct bgp_node *rn;
2634 struct bgp_info *ri;
2635 struct bgp_info *new;
2636 struct bgp_info info;
2637 struct attr new_attr;
2638 struct attr *attr_new;
2639 struct attr attr;
2640 struct bgp *bgp;
2641 int ret;
2642 char buf[SU_ADDRSTRLEN];
2643
2644 bgp = rsclient->bgp;
2645
2646 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
2647
2648 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2649 if (bgp_static)
2650 {
2651 attr.nexthop = bgp_static->igpnexthop;
2652 attr.med = bgp_static->igpmetric;
2653 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
2654 }
2655
2656 new_attr = attr;
2657
2658 /* Apply network route-map for export to this rsclient. */
2659 if (bgp_static->rmap.name)
2660 {
2661 info.peer = rsclient;
2662 info.attr = &new_attr;
2663
2664 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
2665 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
2666
2667 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
2668
2669 rsclient->rmap_type = 0;
2670
2671 if (ret == RMAP_DENYMATCH)
2672 {
2673 /* Free uninterned attribute. */
2674 bgp_attr_flush (&new_attr);
2675
2676 /* Unintern original. */
2677 aspath_unintern (attr.aspath);
2678 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
2679
2680 return;
2681 }
2682 attr_new = bgp_attr_intern (&new_attr);
2683 }
2684 else
2685 attr_new = bgp_attr_intern (&attr);
2686
2687 new_attr = *attr_new;
2688
2689 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
2690
2691 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi) == RMAP_DENY)
2692{
2693 /* This BGP update is filtered. Log the reason then update BGP entry. */
2694 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002695 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002696 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
2697 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2698 p->prefixlen, rsclient->host);
2699
2700 bgp->peer_self->rmap_type = 0;
2701
2702 bgp_attr_unintern (attr_new);
2703 aspath_unintern (attr.aspath);
2704
2705 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
2706
2707 return;
2708 }
2709
2710 bgp->peer_self->rmap_type = 0;
2711
2712 bgp_attr_unintern (attr_new);
2713 attr_new = bgp_attr_intern (&new_attr);
2714
2715 for (ri = rn->info; ri; ri = ri->next)
2716 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
2717 && ri->sub_type == BGP_ROUTE_STATIC)
2718 break;
2719
2720 if (ri)
2721 {
2722 if (attrhash_cmp (ri->attr, attr_new))
2723 {
2724 bgp_unlock_node (rn);
2725 bgp_attr_unintern (attr_new);
2726 aspath_unintern (attr.aspath);
2727 return;
2728 }
2729 else
2730 {
2731 /* The attribute is changed. */
2732 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
2733
2734 /* Rewrite BGP route information. */
2735 bgp_attr_unintern (ri->attr);
2736 ri->attr = attr_new;
2737 ri->uptime = time (NULL);
2738
2739 /* Process change. */
2740 bgp_process (bgp, rn, afi, safi);
2741 bgp_unlock_node (rn);
2742 aspath_unintern (attr.aspath);
2743 return;
2744 }
2745}
2746
2747 /* Make new BGP info. */
2748 new = bgp_info_new ();
2749 new->type = ZEBRA_ROUTE_BGP;
2750 new->sub_type = BGP_ROUTE_STATIC;
2751 new->peer = bgp->peer_self;
2752 SET_FLAG (new->flags, BGP_INFO_VALID);
2753 new->attr = attr_new;
2754 new->uptime = time (NULL);
2755
2756 /* Register new BGP information. */
2757 bgp_info_add (rn, new);
2758
2759 /* Process change. */
2760 bgp_process (bgp, rn, afi, safi);
2761
2762 /* Unintern original. */
2763 aspath_unintern (attr.aspath);
2764}
2765
2766void
2767bgp_static_update_main (struct bgp *bgp, struct prefix *p,
paul718e3742002-12-13 20:15:29 +00002768 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
2769{
2770 struct bgp_node *rn;
2771 struct bgp_info *ri;
2772 struct bgp_info *new;
2773 struct bgp_info info;
2774 struct attr attr;
paul286e1e72003-08-08 00:24:31 +00002775 struct attr attr_tmp;
paul718e3742002-12-13 20:15:29 +00002776 struct attr *attr_new;
2777 int ret;
2778
paulfee0f4c2004-09-13 05:12:46 +00002779 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00002780
2781 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2782 if (bgp_static)
2783 {
2784 attr.nexthop = bgp_static->igpnexthop;
2785 attr.med = bgp_static->igpmetric;
2786 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
2787 }
2788
2789 /* Apply route-map. */
2790 if (bgp_static->rmap.name)
2791 {
paul286e1e72003-08-08 00:24:31 +00002792 attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00002793 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00002794 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00002795
paulfee0f4c2004-09-13 05:12:46 +00002796 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
2797
paul718e3742002-12-13 20:15:29 +00002798 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00002799
paulfee0f4c2004-09-13 05:12:46 +00002800 bgp->peer_self->rmap_type = 0;
2801
paul718e3742002-12-13 20:15:29 +00002802 if (ret == RMAP_DENYMATCH)
2803 {
2804 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00002805 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00002806
2807 /* Unintern original. */
2808 aspath_unintern (attr.aspath);
2809 bgp_static_withdraw (bgp, p, afi, safi);
2810 return;
2811 }
paul286e1e72003-08-08 00:24:31 +00002812 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00002813 }
paul286e1e72003-08-08 00:24:31 +00002814 else
2815 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00002816
2817 for (ri = rn->info; ri; ri = ri->next)
2818 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
2819 && ri->sub_type == BGP_ROUTE_STATIC)
2820 break;
2821
2822 if (ri)
2823 {
2824 if (attrhash_cmp (ri->attr, attr_new))
2825 {
2826 bgp_unlock_node (rn);
2827 bgp_attr_unintern (attr_new);
2828 aspath_unintern (attr.aspath);
2829 return;
2830 }
2831 else
2832 {
2833 /* The attribute is changed. */
2834 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
2835
2836 /* Rewrite BGP route information. */
2837 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2838 bgp_attr_unintern (ri->attr);
2839 ri->attr = attr_new;
2840 ri->uptime = time (NULL);
2841
2842 /* Process change. */
2843 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2844 bgp_process (bgp, rn, afi, safi);
2845 bgp_unlock_node (rn);
2846 aspath_unintern (attr.aspath);
2847 return;
2848 }
2849 }
2850
2851 /* Make new BGP info. */
2852 new = bgp_info_new ();
2853 new->type = ZEBRA_ROUTE_BGP;
2854 new->sub_type = BGP_ROUTE_STATIC;
2855 new->peer = bgp->peer_self;
2856 SET_FLAG (new->flags, BGP_INFO_VALID);
2857 new->attr = attr_new;
2858 new->uptime = time (NULL);
2859
2860 /* Aggregate address increment. */
2861 bgp_aggregate_increment (bgp, p, new, afi, safi);
2862
2863 /* Register new BGP information. */
2864 bgp_info_add (rn, new);
2865
2866 /* Process change. */
2867 bgp_process (bgp, rn, afi, safi);
2868
2869 /* Unintern original. */
2870 aspath_unintern (attr.aspath);
2871}
2872
2873void
paulfee0f4c2004-09-13 05:12:46 +00002874bgp_static_update (struct bgp *bgp, struct prefix *p,
2875 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
2876{
2877 struct peer *rsclient;
2878 struct listnode *nn;
2879
2880 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
2881
2882 LIST_LOOP(bgp->rsclient, rsclient, nn)
2883 {
2884 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
2885 }
2886}
2887
2888void
paul718e3742002-12-13 20:15:29 +00002889bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi,
2890 u_char safi, struct prefix_rd *prd, u_char *tag)
2891{
2892 struct bgp_node *rn;
2893 struct bgp_info *new;
2894
paulfee0f4c2004-09-13 05:12:46 +00002895 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00002896
2897 /* Make new BGP info. */
2898 new = bgp_info_new ();
2899 new->type = ZEBRA_ROUTE_BGP;
2900 new->sub_type = BGP_ROUTE_STATIC;
2901 new->peer = bgp->peer_self;
2902 new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP);
2903 SET_FLAG (new->flags, BGP_INFO_VALID);
2904 new->uptime = time (NULL);
2905 memcpy (new->tag, tag, 3);
2906
2907 /* Aggregate address increment. */
2908 bgp_aggregate_increment (bgp, p, (struct bgp_info *) new, afi, safi);
2909
2910 /* Register new BGP information. */
2911 bgp_info_add (rn, (struct bgp_info *) new);
2912
2913 /* Process change. */
2914 bgp_process (bgp, rn, afi, safi);
2915}
2916
2917void
2918bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
2919 safi_t safi)
2920{
2921 struct bgp_node *rn;
2922 struct bgp_info *ri;
2923
paulfee0f4c2004-09-13 05:12:46 +00002924 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00002925
2926 /* Check selected route and self inserted route. */
2927 for (ri = rn->info; ri; ri = ri->next)
2928 if (ri->peer == bgp->peer_self
2929 && ri->type == ZEBRA_ROUTE_BGP
2930 && ri->sub_type == BGP_ROUTE_STATIC)
2931 break;
2932
2933 /* Withdraw static BGP route from routing table. */
2934 if (ri)
2935 {
2936 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2937 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
2938 bgp_process (bgp, rn, afi, safi);
2939 bgp_info_delete (rn, ri);
2940 bgp_info_free (ri);
2941 bgp_unlock_node (rn);
2942 }
2943
2944 /* Unlock bgp_node_lookup. */
2945 bgp_unlock_node (rn);
2946}
2947
2948void
paulfee0f4c2004-09-13 05:12:46 +00002949bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2950{
2951 struct bgp_static *bgp_static;
2952 struct bgp *bgp;
2953 struct bgp_node *rn;
2954 struct prefix *p;
2955
2956 bgp = rsclient->bgp;
2957
2958 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
2959 if ((bgp_static = rn->info) != NULL)
2960 {
2961 p = &rn->p;
2962
2963 bgp_static_update_rsclient (rsclient, p, bgp_static,
2964 afi, safi);
2965 }
2966}
2967
2968void
paul718e3742002-12-13 20:15:29 +00002969bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi,
2970 u_char safi, struct prefix_rd *prd, u_char *tag)
2971{
2972 struct bgp_node *rn;
2973 struct bgp_info *ri;
2974
paulfee0f4c2004-09-13 05:12:46 +00002975 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00002976
2977 /* Check selected route and self inserted route. */
2978 for (ri = rn->info; ri; ri = ri->next)
2979 if (ri->peer == bgp->peer_self
2980 && ri->type == ZEBRA_ROUTE_BGP
2981 && ri->sub_type == BGP_ROUTE_STATIC)
2982 break;
2983
2984 /* Withdraw static BGP route from routing table. */
2985 if (ri)
2986 {
2987 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2988 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
2989 bgp_process (bgp, rn, afi, safi);
2990 bgp_info_delete (rn, ri);
2991 bgp_info_free (ri);
2992 bgp_unlock_node (rn);
2993 }
2994
2995 /* Unlock bgp_node_lookup. */
2996 bgp_unlock_node (rn);
2997}
2998
2999/* Configure static BGP network. When user don't run zebra, static
3000 route should be installed as valid. */
3001int
paulfd79ac92004-10-13 05:06:08 +00003002bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
3003 u_int16_t afi, u_char safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003004{
3005 int ret;
3006 struct prefix p;
3007 struct bgp_static *bgp_static;
3008 struct bgp_node *rn;
3009 int need_update = 0;
3010
3011 /* Convert IP prefix string to struct prefix. */
3012 ret = str2prefix (ip_str, &p);
3013 if (! ret)
3014 {
3015 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3016 return CMD_WARNING;
3017 }
3018#ifdef HAVE_IPV6
3019 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3020 {
3021 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3022 VTY_NEWLINE);
3023 return CMD_WARNING;
3024 }
3025#endif /* HAVE_IPV6 */
3026
3027 apply_mask (&p);
3028
3029 /* Set BGP static route configuration. */
3030 rn = bgp_node_get (bgp->route[afi][safi], &p);
3031
3032 if (rn->info)
3033 {
3034 /* Configuration change. */
3035 bgp_static = rn->info;
3036
3037 /* Check previous routes are installed into BGP. */
3038 if (! bgp_static->backdoor && bgp_static->valid)
3039 need_update = 1;
3040
3041 bgp_static->backdoor = backdoor;
3042 if (rmap)
3043 {
3044 if (bgp_static->rmap.name)
3045 free (bgp_static->rmap.name);
3046 bgp_static->rmap.name = strdup (rmap);
3047 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3048 }
3049 else
3050 {
3051 if (bgp_static->rmap.name)
3052 free (bgp_static->rmap.name);
3053 bgp_static->rmap.name = NULL;
3054 bgp_static->rmap.map = NULL;
3055 bgp_static->valid = 0;
3056 }
3057 bgp_unlock_node (rn);
3058 }
3059 else
3060 {
3061 /* New configuration. */
3062 bgp_static = bgp_static_new ();
3063 bgp_static->backdoor = backdoor;
3064 bgp_static->valid = 0;
3065 bgp_static->igpmetric = 0;
3066 bgp_static->igpnexthop.s_addr = 0;
3067 if (rmap)
3068 {
3069 if (bgp_static->rmap.name)
3070 free (bgp_static->rmap.name);
3071 bgp_static->rmap.name = strdup (rmap);
3072 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3073 }
3074 rn->info = bgp_static;
3075 }
3076
3077 /* If BGP scan is not enabled, we should install this route here. */
3078 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3079 {
3080 bgp_static->valid = 1;
3081
3082 if (need_update)
3083 bgp_static_withdraw (bgp, &p, afi, safi);
3084
3085 if (! bgp_static->backdoor)
3086 bgp_static_update (bgp, &p, bgp_static, afi, safi);
3087 }
3088
3089 return CMD_SUCCESS;
3090}
3091
3092/* Configure static BGP network. */
3093int
paulfd79ac92004-10-13 05:06:08 +00003094bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
paul718e3742002-12-13 20:15:29 +00003095 u_int16_t afi, u_char safi)
3096{
3097 int ret;
3098 struct prefix p;
3099 struct bgp_static *bgp_static;
3100 struct bgp_node *rn;
3101
3102 /* Convert IP prefix string to struct prefix. */
3103 ret = str2prefix (ip_str, &p);
3104 if (! ret)
3105 {
3106 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3107 return CMD_WARNING;
3108 }
3109#ifdef HAVE_IPV6
3110 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3111 {
3112 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3113 VTY_NEWLINE);
3114 return CMD_WARNING;
3115 }
3116#endif /* HAVE_IPV6 */
3117
3118 apply_mask (&p);
3119
3120 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
3121 if (! rn)
3122 {
3123 vty_out (vty, "%% Can't find specified static route configuration.%s",
3124 VTY_NEWLINE);
3125 return CMD_WARNING;
3126 }
3127
3128 bgp_static = rn->info;
3129
3130 /* Update BGP RIB. */
3131 if (! bgp_static->backdoor)
3132 bgp_static_withdraw (bgp, &p, afi, safi);
3133
3134 /* Clear configuration. */
3135 bgp_static_free (bgp_static);
3136 rn->info = NULL;
3137 bgp_unlock_node (rn);
3138 bgp_unlock_node (rn);
3139
3140 return CMD_SUCCESS;
3141}
3142
3143/* Called from bgp_delete(). Delete all static routes from the BGP
3144 instance. */
3145void
3146bgp_static_delete (struct bgp *bgp)
3147{
3148 afi_t afi;
3149 safi_t safi;
3150 struct bgp_node *rn;
3151 struct bgp_node *rm;
3152 struct bgp_table *table;
3153 struct bgp_static *bgp_static;
3154
3155 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3156 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
3157 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3158 if (rn->info != NULL)
3159 {
3160 if (safi == SAFI_MPLS_VPN)
3161 {
3162 table = rn->info;
3163
3164 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
3165 {
3166 bgp_static = rn->info;
3167 bgp_static_withdraw_vpnv4 (bgp, &rm->p,
3168 AFI_IP, SAFI_MPLS_VPN,
3169 (struct prefix_rd *)&rn->p,
3170 bgp_static->tag);
3171 bgp_static_free (bgp_static);
3172 rn->info = NULL;
3173 bgp_unlock_node (rn);
3174 }
3175 }
3176 else
3177 {
3178 bgp_static = rn->info;
3179 bgp_static_withdraw (bgp, &rn->p, afi, safi);
3180 bgp_static_free (bgp_static);
3181 rn->info = NULL;
3182 bgp_unlock_node (rn);
3183 }
3184 }
3185}
3186
3187int
paulfd79ac92004-10-13 05:06:08 +00003188bgp_static_set_vpnv4 (struct vty *vty, const char *ip_str, const char *rd_str,
3189 const char *tag_str)
paul718e3742002-12-13 20:15:29 +00003190{
3191 int ret;
3192 struct prefix p;
3193 struct prefix_rd prd;
3194 struct bgp *bgp;
3195 struct bgp_node *prn;
3196 struct bgp_node *rn;
3197 struct bgp_table *table;
3198 struct bgp_static *bgp_static;
3199 u_char tag[3];
3200
3201 bgp = vty->index;
3202
3203 ret = str2prefix (ip_str, &p);
3204 if (! ret)
3205 {
3206 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3207 return CMD_WARNING;
3208 }
3209 apply_mask (&p);
3210
3211 ret = str2prefix_rd (rd_str, &prd);
3212 if (! ret)
3213 {
3214 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
3215 return CMD_WARNING;
3216 }
3217
3218 ret = str2tag (tag_str, tag);
3219 if (! ret)
3220 {
3221 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
3222 return CMD_WARNING;
3223 }
3224
3225 prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN],
3226 (struct prefix *)&prd);
3227 if (prn->info == NULL)
3228 prn->info = bgp_table_init ();
3229 else
3230 bgp_unlock_node (prn);
3231 table = prn->info;
3232
3233 rn = bgp_node_get (table, &p);
3234
3235 if (rn->info)
3236 {
3237 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
3238 bgp_unlock_node (rn);
3239 }
3240 else
3241 {
3242 /* New configuration. */
3243 bgp_static = bgp_static_new ();
3244 bgp_static->valid = 1;
3245 memcpy (bgp_static->tag, tag, 3);
3246 rn->info = bgp_static;
3247
3248 bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag);
3249 }
3250
3251 return CMD_SUCCESS;
3252}
3253
3254/* Configure static BGP network. */
3255int
paulfd79ac92004-10-13 05:06:08 +00003256bgp_static_unset_vpnv4 (struct vty *vty, const char *ip_str,
3257 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00003258{
3259 int ret;
3260 struct bgp *bgp;
3261 struct prefix p;
3262 struct prefix_rd prd;
3263 struct bgp_node *prn;
3264 struct bgp_node *rn;
3265 struct bgp_table *table;
3266 struct bgp_static *bgp_static;
3267 u_char tag[3];
3268
3269 bgp = vty->index;
3270
3271 /* Convert IP prefix string to struct prefix. */
3272 ret = str2prefix (ip_str, &p);
3273 if (! ret)
3274 {
3275 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3276 return CMD_WARNING;
3277 }
3278 apply_mask (&p);
3279
3280 ret = str2prefix_rd (rd_str, &prd);
3281 if (! ret)
3282 {
3283 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
3284 return CMD_WARNING;
3285 }
3286
3287 ret = str2tag (tag_str, tag);
3288 if (! ret)
3289 {
3290 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
3291 return CMD_WARNING;
3292 }
3293
3294 prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN],
3295 (struct prefix *)&prd);
3296 if (prn->info == NULL)
3297 prn->info = bgp_table_init ();
3298 else
3299 bgp_unlock_node (prn);
3300 table = prn->info;
3301
3302 rn = bgp_node_lookup (table, &p);
3303
3304 if (rn)
3305 {
3306 bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag);
3307
3308 bgp_static = rn->info;
3309 bgp_static_free (bgp_static);
3310 rn->info = NULL;
3311 bgp_unlock_node (rn);
3312 bgp_unlock_node (rn);
3313 }
3314 else
3315 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
3316
3317 return CMD_SUCCESS;
3318}
3319
3320DEFUN (bgp_network,
3321 bgp_network_cmd,
3322 "network A.B.C.D/M",
3323 "Specify a network to announce via BGP\n"
3324 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3325{
3326 return bgp_static_set (vty, vty->index, argv[0],
3327 AFI_IP, bgp_node_safi (vty), NULL, 0);
3328}
3329
3330DEFUN (bgp_network_route_map,
3331 bgp_network_route_map_cmd,
3332 "network A.B.C.D/M route-map WORD",
3333 "Specify a network to announce via BGP\n"
3334 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3335 "Route-map to modify the attributes\n"
3336 "Name of the route map\n")
3337{
3338 return bgp_static_set (vty, vty->index, argv[0],
3339 AFI_IP, bgp_node_safi (vty), argv[1], 0);
3340}
3341
3342DEFUN (bgp_network_backdoor,
3343 bgp_network_backdoor_cmd,
3344 "network A.B.C.D/M backdoor",
3345 "Specify a network to announce via BGP\n"
3346 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3347 "Specify a BGP backdoor route\n")
3348{
3349 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
3350}
3351
3352DEFUN (bgp_network_mask,
3353 bgp_network_mask_cmd,
3354 "network A.B.C.D mask A.B.C.D",
3355 "Specify a network to announce via BGP\n"
3356 "Network number\n"
3357 "Network mask\n"
3358 "Network mask\n")
3359{
3360 int ret;
3361 char prefix_str[BUFSIZ];
3362
3363 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3364 if (! ret)
3365 {
3366 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3367 return CMD_WARNING;
3368 }
3369
3370 return bgp_static_set (vty, vty->index, prefix_str,
3371 AFI_IP, bgp_node_safi (vty), NULL, 0);
3372}
3373
3374DEFUN (bgp_network_mask_route_map,
3375 bgp_network_mask_route_map_cmd,
3376 "network A.B.C.D mask A.B.C.D route-map WORD",
3377 "Specify a network to announce via BGP\n"
3378 "Network number\n"
3379 "Network mask\n"
3380 "Network mask\n"
3381 "Route-map to modify the attributes\n"
3382 "Name of the route map\n")
3383{
3384 int ret;
3385 char prefix_str[BUFSIZ];
3386
3387 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3388 if (! ret)
3389 {
3390 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3391 return CMD_WARNING;
3392 }
3393
3394 return bgp_static_set (vty, vty->index, prefix_str,
3395 AFI_IP, bgp_node_safi (vty), argv[2], 0);
3396}
3397
3398DEFUN (bgp_network_mask_backdoor,
3399 bgp_network_mask_backdoor_cmd,
3400 "network A.B.C.D mask A.B.C.D backdoor",
3401 "Specify a network to announce via BGP\n"
3402 "Network number\n"
3403 "Network mask\n"
3404 "Network mask\n"
3405 "Specify a BGP backdoor route\n")
3406{
3407 int ret;
3408 char prefix_str[BUFSIZ];
3409
3410 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3411 if (! ret)
3412 {
3413 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3414 return CMD_WARNING;
3415 }
3416
3417 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1);
3418}
3419
3420DEFUN (bgp_network_mask_natural,
3421 bgp_network_mask_natural_cmd,
3422 "network A.B.C.D",
3423 "Specify a network to announce via BGP\n"
3424 "Network number\n")
3425{
3426 int ret;
3427 char prefix_str[BUFSIZ];
3428
3429 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3430 if (! ret)
3431 {
3432 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3433 return CMD_WARNING;
3434 }
3435
3436 return bgp_static_set (vty, vty->index, prefix_str,
3437 AFI_IP, bgp_node_safi (vty), NULL, 0);
3438}
3439
3440DEFUN (bgp_network_mask_natural_route_map,
3441 bgp_network_mask_natural_route_map_cmd,
3442 "network A.B.C.D route-map WORD",
3443 "Specify a network to announce via BGP\n"
3444 "Network number\n"
3445 "Route-map to modify the attributes\n"
3446 "Name of the route map\n")
3447{
3448 int ret;
3449 char prefix_str[BUFSIZ];
3450
3451 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3452 if (! ret)
3453 {
3454 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3455 return CMD_WARNING;
3456 }
3457
3458 return bgp_static_set (vty, vty->index, prefix_str,
3459 AFI_IP, bgp_node_safi (vty), argv[1], 0);
3460}
3461
3462DEFUN (bgp_network_mask_natural_backdoor,
3463 bgp_network_mask_natural_backdoor_cmd,
3464 "network A.B.C.D backdoor",
3465 "Specify a network to announce via BGP\n"
3466 "Network number\n"
3467 "Specify a BGP backdoor route\n")
3468{
3469 int ret;
3470 char prefix_str[BUFSIZ];
3471
3472 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3473 if (! ret)
3474 {
3475 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3476 return CMD_WARNING;
3477 }
3478
3479 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1);
3480}
3481
3482DEFUN (no_bgp_network,
3483 no_bgp_network_cmd,
3484 "no network A.B.C.D/M",
3485 NO_STR
3486 "Specify a network to announce via BGP\n"
3487 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3488{
3489 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
3490 bgp_node_safi (vty));
3491}
3492
3493ALIAS (no_bgp_network,
3494 no_bgp_network_route_map_cmd,
3495 "no network A.B.C.D/M route-map WORD",
3496 NO_STR
3497 "Specify a network to announce via BGP\n"
3498 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3499 "Route-map to modify the attributes\n"
3500 "Name of the route map\n")
3501
3502ALIAS (no_bgp_network,
3503 no_bgp_network_backdoor_cmd,
3504 "no network A.B.C.D/M backdoor",
3505 NO_STR
3506 "Specify a network to announce via BGP\n"
3507 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3508 "Specify a BGP backdoor route\n")
3509
3510DEFUN (no_bgp_network_mask,
3511 no_bgp_network_mask_cmd,
3512 "no network A.B.C.D mask A.B.C.D",
3513 NO_STR
3514 "Specify a network to announce via BGP\n"
3515 "Network number\n"
3516 "Network mask\n"
3517 "Network mask\n")
3518{
3519 int ret;
3520 char prefix_str[BUFSIZ];
3521
3522 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3523 if (! ret)
3524 {
3525 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3526 return CMD_WARNING;
3527 }
3528
3529 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
3530 bgp_node_safi (vty));
3531}
3532
3533ALIAS (no_bgp_network_mask,
3534 no_bgp_network_mask_route_map_cmd,
3535 "no network A.B.C.D mask A.B.C.D route-map WORD",
3536 NO_STR
3537 "Specify a network to announce via BGP\n"
3538 "Network number\n"
3539 "Network mask\n"
3540 "Network mask\n"
3541 "Route-map to modify the attributes\n"
3542 "Name of the route map\n")
3543
3544ALIAS (no_bgp_network_mask,
3545 no_bgp_network_mask_backdoor_cmd,
3546 "no network A.B.C.D mask A.B.C.D backdoor",
3547 NO_STR
3548 "Specify a network to announce via BGP\n"
3549 "Network number\n"
3550 "Network mask\n"
3551 "Network mask\n"
3552 "Specify a BGP backdoor route\n")
3553
3554DEFUN (no_bgp_network_mask_natural,
3555 no_bgp_network_mask_natural_cmd,
3556 "no network A.B.C.D",
3557 NO_STR
3558 "Specify a network to announce via BGP\n"
3559 "Network number\n")
3560{
3561 int ret;
3562 char prefix_str[BUFSIZ];
3563
3564 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
3565 if (! ret)
3566 {
3567 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3568 return CMD_WARNING;
3569 }
3570
3571 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
3572 bgp_node_safi (vty));
3573}
3574
3575ALIAS (no_bgp_network_mask_natural,
3576 no_bgp_network_mask_natural_route_map_cmd,
3577 "no network A.B.C.D route-map WORD",
3578 NO_STR
3579 "Specify a network to announce via BGP\n"
3580 "Network number\n"
3581 "Route-map to modify the attributes\n"
3582 "Name of the route map\n")
3583
3584ALIAS (no_bgp_network_mask_natural,
3585 no_bgp_network_mask_natural_backdoor_cmd,
3586 "no network A.B.C.D backdoor",
3587 NO_STR
3588 "Specify a network to announce via BGP\n"
3589 "Network number\n"
3590 "Specify a BGP backdoor route\n")
3591
3592#ifdef HAVE_IPV6
3593DEFUN (ipv6_bgp_network,
3594 ipv6_bgp_network_cmd,
3595 "network X:X::X:X/M",
3596 "Specify a network to announce via BGP\n"
3597 "IPv6 prefix <network>/<length>\n")
3598{
3599 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
3600}
3601
3602DEFUN (ipv6_bgp_network_route_map,
3603 ipv6_bgp_network_route_map_cmd,
3604 "network X:X::X:X/M route-map WORD",
3605 "Specify a network to announce via BGP\n"
3606 "IPv6 prefix <network>/<length>\n"
3607 "Route-map to modify the attributes\n"
3608 "Name of the route map\n")
3609{
3610 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
3611 bgp_node_safi (vty), argv[1], 0);
3612}
3613
3614DEFUN (no_ipv6_bgp_network,
3615 no_ipv6_bgp_network_cmd,
3616 "no network X:X::X:X/M",
3617 NO_STR
3618 "Specify a network to announce via BGP\n"
3619 "IPv6 prefix <network>/<length>\n")
3620{
3621 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST);
3622}
3623
3624ALIAS (no_ipv6_bgp_network,
3625 no_ipv6_bgp_network_route_map_cmd,
3626 "no network X:X::X:X/M route-map WORD",
3627 NO_STR
3628 "Specify a network to announce via BGP\n"
3629 "IPv6 prefix <network>/<length>\n"
3630 "Route-map to modify the attributes\n"
3631 "Name of the route map\n")
3632
3633ALIAS (ipv6_bgp_network,
3634 old_ipv6_bgp_network_cmd,
3635 "ipv6 bgp network X:X::X:X/M",
3636 IPV6_STR
3637 BGP_STR
3638 "Specify a network to announce via BGP\n"
3639 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
3640
3641ALIAS (no_ipv6_bgp_network,
3642 old_no_ipv6_bgp_network_cmd,
3643 "no ipv6 bgp network X:X::X:X/M",
3644 NO_STR
3645 IPV6_STR
3646 BGP_STR
3647 "Specify a network to announce via BGP\n"
3648 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
3649#endif /* HAVE_IPV6 */
3650
3651/* Aggreagete address:
3652
3653 advertise-map Set condition to advertise attribute
3654 as-set Generate AS set path information
3655 attribute-map Set attributes of aggregate
3656 route-map Set parameters of aggregate
3657 summary-only Filter more specific routes from updates
3658 suppress-map Conditionally filter more specific routes from updates
3659 <cr>
3660 */
3661struct bgp_aggregate
3662{
3663 /* Summary-only flag. */
3664 u_char summary_only;
3665
3666 /* AS set generation. */
3667 u_char as_set;
3668
3669 /* Route-map for aggregated route. */
3670 struct route_map *map;
3671
3672 /* Suppress-count. */
3673 unsigned long count;
3674
3675 /* SAFI configuration. */
3676 safi_t safi;
3677};
3678
3679struct bgp_aggregate *
3680bgp_aggregate_new ()
3681{
3682 struct bgp_aggregate *new;
3683 new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
3684 memset (new, 0, sizeof (struct bgp_aggregate));
3685 return new;
3686}
3687
3688void
3689bgp_aggregate_free (struct bgp_aggregate *aggregate)
3690{
3691 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
3692}
3693
3694void
3695bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
3696 afi_t afi, safi_t safi, struct bgp_info *del,
3697 struct bgp_aggregate *aggregate)
3698{
3699 struct bgp_table *table;
3700 struct bgp_node *top;
3701 struct bgp_node *rn;
3702 u_char origin;
3703 struct aspath *aspath = NULL;
3704 struct aspath *asmerge = NULL;
3705 struct community *community = NULL;
3706 struct community *commerge = NULL;
3707 struct in_addr nexthop;
3708 u_int32_t med = 0;
3709 struct bgp_info *ri;
3710 struct bgp_info *new;
3711 int first = 1;
3712 unsigned long match = 0;
3713
3714 /* Record adding route's nexthop and med. */
3715 if (rinew)
3716 {
3717 nexthop = rinew->attr->nexthop;
3718 med = rinew->attr->med;
3719 }
3720
3721 /* ORIGIN attribute: If at least one route among routes that are
3722 aggregated has ORIGIN with the value INCOMPLETE, then the
3723 aggregated route must have the ORIGIN attribute with the value
3724 INCOMPLETE. Otherwise, if at least one route among routes that
3725 are aggregated has ORIGIN with the value EGP, then the aggregated
3726 route must have the origin attribute with the value EGP. In all
3727 other case the value of the ORIGIN attribute of the aggregated
3728 route is INTERNAL. */
3729 origin = BGP_ORIGIN_IGP;
3730
3731 table = bgp->rib[afi][safi];
3732
3733 top = bgp_node_get (table, p);
3734 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
3735 if (rn->p.prefixlen > p->prefixlen)
3736 {
3737 match = 0;
3738
3739 for (ri = rn->info; ri; ri = ri->next)
3740 {
3741 if (BGP_INFO_HOLDDOWN (ri))
3742 continue;
3743
3744 if (del && ri == del)
3745 continue;
3746
3747 if (! rinew && first)
3748 {
3749 nexthop = ri->attr->nexthop;
3750 med = ri->attr->med;
3751 first = 0;
3752 }
3753
3754#ifdef AGGREGATE_NEXTHOP_CHECK
3755 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
3756 || ri->attr->med != med)
3757 {
3758 if (aspath)
3759 aspath_free (aspath);
3760 if (community)
3761 community_free (community);
3762 bgp_unlock_node (rn);
3763 bgp_unlock_node (top);
3764 return;
3765 }
3766#endif /* AGGREGATE_NEXTHOP_CHECK */
3767
3768 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
3769 {
3770 if (aggregate->summary_only)
3771 {
3772 ri->suppress++;
3773 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
3774 match++;
3775 }
3776
3777 aggregate->count++;
3778
3779 if (aggregate->as_set)
3780 {
3781 if (origin < ri->attr->origin)
3782 origin = ri->attr->origin;
3783
3784 if (aspath)
3785 {
3786 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
3787 aspath_free (aspath);
3788 aspath = asmerge;
3789 }
3790 else
3791 aspath = aspath_dup (ri->attr->aspath);
3792
3793 if (ri->attr->community)
3794 {
3795 if (community)
3796 {
3797 commerge = community_merge (community,
3798 ri->attr->community);
3799 community = community_uniq_sort (commerge);
3800 community_free (commerge);
3801 }
3802 else
3803 community = community_dup (ri->attr->community);
3804 }
3805 }
3806 }
3807 }
3808 if (match)
3809 bgp_process (bgp, rn, afi, safi);
3810 }
3811 bgp_unlock_node (top);
3812
3813 if (rinew)
3814 {
3815 aggregate->count++;
3816
3817 if (aggregate->summary_only)
3818 rinew->suppress++;
3819
3820 if (aggregate->as_set)
3821 {
3822 if (origin < rinew->attr->origin)
3823 origin = rinew->attr->origin;
3824
3825 if (aspath)
3826 {
3827 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
3828 aspath_free (aspath);
3829 aspath = asmerge;
3830 }
3831 else
3832 aspath = aspath_dup (rinew->attr->aspath);
3833
3834 if (rinew->attr->community)
3835 {
3836 if (community)
3837 {
3838 commerge = community_merge (community,
3839 rinew->attr->community);
3840 community = community_uniq_sort (commerge);
3841 community_free (commerge);
3842 }
3843 else
3844 community = community_dup (rinew->attr->community);
3845 }
3846 }
3847 }
3848
3849 if (aggregate->count > 0)
3850 {
3851 rn = bgp_node_get (table, p);
3852 new = bgp_info_new ();
3853 new->type = ZEBRA_ROUTE_BGP;
3854 new->sub_type = BGP_ROUTE_AGGREGATE;
3855 new->peer = bgp->peer_self;
3856 SET_FLAG (new->flags, BGP_INFO_VALID);
3857 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
3858 new->uptime = time (NULL);
3859
3860 bgp_info_add (rn, new);
3861 bgp_process (bgp, rn, afi, safi);
3862 }
3863 else
3864 {
3865 if (aspath)
3866 aspath_free (aspath);
3867 if (community)
3868 community_free (community);
3869 }
3870}
3871
3872void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
3873 struct bgp_aggregate *);
3874
3875void
3876bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
3877 struct bgp_info *ri, afi_t afi, safi_t safi)
3878{
3879 struct bgp_node *child;
3880 struct bgp_node *rn;
3881 struct bgp_aggregate *aggregate;
3882
3883 /* MPLS-VPN aggregation is not yet supported. */
3884 if (safi == SAFI_MPLS_VPN)
3885 return;
3886
3887 if (p->prefixlen == 0)
3888 return;
3889
3890 if (BGP_INFO_HOLDDOWN (ri))
3891 return;
3892
3893 child = bgp_node_get (bgp->aggregate[afi][safi], p);
3894
3895 /* Aggregate address configuration check. */
3896 for (rn = child; rn; rn = rn->parent)
3897 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
3898 {
3899 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00003900 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00003901 }
3902 bgp_unlock_node (child);
3903}
3904
3905void
3906bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
3907 struct bgp_info *del, afi_t afi, safi_t safi)
3908{
3909 struct bgp_node *child;
3910 struct bgp_node *rn;
3911 struct bgp_aggregate *aggregate;
3912
3913 /* MPLS-VPN aggregation is not yet supported. */
3914 if (safi == SAFI_MPLS_VPN)
3915 return;
3916
3917 if (p->prefixlen == 0)
3918 return;
3919
3920 child = bgp_node_get (bgp->aggregate[afi][safi], p);
3921
3922 /* Aggregate address configuration check. */
3923 for (rn = child; rn; rn = rn->parent)
3924 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
3925 {
3926 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00003927 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00003928 }
3929 bgp_unlock_node (child);
3930}
3931
3932void
3933bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
3934 struct bgp_aggregate *aggregate)
3935{
3936 struct bgp_table *table;
3937 struct bgp_node *top;
3938 struct bgp_node *rn;
3939 struct bgp_info *new;
3940 struct bgp_info *ri;
3941 unsigned long match;
3942 u_char origin = BGP_ORIGIN_IGP;
3943 struct aspath *aspath = NULL;
3944 struct aspath *asmerge = NULL;
3945 struct community *community = NULL;
3946 struct community *commerge = NULL;
3947
3948 table = bgp->rib[afi][safi];
3949
3950 /* Sanity check. */
3951 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
3952 return;
3953 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
3954 return;
3955
3956 /* If routes exists below this node, generate aggregate routes. */
3957 top = bgp_node_get (table, p);
3958 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
3959 if (rn->p.prefixlen > p->prefixlen)
3960 {
3961 match = 0;
3962
3963 for (ri = rn->info; ri; ri = ri->next)
3964 {
3965 if (BGP_INFO_HOLDDOWN (ri))
3966 continue;
3967
3968 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
3969 {
3970 /* summary-only aggregate route suppress aggregated
3971 route announcement. */
3972 if (aggregate->summary_only)
3973 {
3974 ri->suppress++;
3975 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
3976 match++;
3977 }
3978 /* as-set aggregate route generate origin, as path,
3979 community aggregation. */
3980 if (aggregate->as_set)
3981 {
3982 if (origin < ri->attr->origin)
3983 origin = ri->attr->origin;
3984
3985 if (aspath)
3986 {
3987 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
3988 aspath_free (aspath);
3989 aspath = asmerge;
3990 }
3991 else
3992 aspath = aspath_dup (ri->attr->aspath);
3993
3994 if (ri->attr->community)
3995 {
3996 if (community)
3997 {
3998 commerge = community_merge (community,
3999 ri->attr->community);
4000 community = community_uniq_sort (commerge);
4001 community_free (commerge);
4002 }
4003 else
4004 community = community_dup (ri->attr->community);
4005 }
4006 }
4007 aggregate->count++;
4008 }
4009 }
4010
4011 /* If this node is suppressed, process the change. */
4012 if (match)
4013 bgp_process (bgp, rn, afi, safi);
4014 }
4015 bgp_unlock_node (top);
4016
4017 /* Add aggregate route to BGP table. */
4018 if (aggregate->count)
4019 {
4020 rn = bgp_node_get (table, p);
4021
4022 new = bgp_info_new ();
4023 new->type = ZEBRA_ROUTE_BGP;
4024 new->sub_type = BGP_ROUTE_AGGREGATE;
4025 new->peer = bgp->peer_self;
4026 SET_FLAG (new->flags, BGP_INFO_VALID);
4027 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
4028 new->uptime = time (NULL);
4029
4030 bgp_info_add (rn, new);
4031
4032 /* Process change. */
4033 bgp_process (bgp, rn, afi, safi);
4034 }
4035}
4036
4037void
4038bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
4039 safi_t safi, struct bgp_aggregate *aggregate)
4040{
4041 struct bgp_table *table;
4042 struct bgp_node *top;
4043 struct bgp_node *rn;
4044 struct bgp_info *ri;
4045 unsigned long match;
4046
4047 table = bgp->rib[afi][safi];
4048
4049 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
4050 return;
4051 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
4052 return;
4053
4054 /* If routes exists below this node, generate aggregate routes. */
4055 top = bgp_node_get (table, p);
4056 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4057 if (rn->p.prefixlen > p->prefixlen)
4058 {
4059 match = 0;
4060
4061 for (ri = rn->info; ri; ri = ri->next)
4062 {
4063 if (BGP_INFO_HOLDDOWN (ri))
4064 continue;
4065
4066 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4067 {
4068 if (aggregate->summary_only)
4069 {
4070 ri->suppress--;
4071
4072 if (ri->suppress == 0)
4073 {
4074 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
4075 match++;
4076 }
4077 }
4078 aggregate->count--;
4079 }
4080 }
4081
4082 /* If this node is suppressed, process the change. */
4083 if (match)
4084 bgp_process (bgp, rn, afi, safi);
4085 }
4086 bgp_unlock_node (top);
4087
4088 /* Delete aggregate route from BGP table. */
4089 rn = bgp_node_get (table, p);
4090
4091 for (ri = rn->info; ri; ri = ri->next)
4092 if (ri->peer == bgp->peer_self
4093 && ri->type == ZEBRA_ROUTE_BGP
4094 && ri->sub_type == BGP_ROUTE_AGGREGATE)
4095 break;
4096
4097 /* Withdraw static BGP route from routing table. */
4098 if (ri)
4099 {
4100 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
4101 bgp_process (bgp, rn, afi, safi);
4102 bgp_info_delete (rn, ri);
4103 bgp_info_free (ri);
4104 bgp_unlock_node (rn);
4105 }
4106
4107 /* Unlock bgp_node_lookup. */
4108 bgp_unlock_node (rn);
4109}
4110
4111/* Aggregate route attribute. */
4112#define AGGREGATE_SUMMARY_ONLY 1
4113#define AGGREGATE_AS_SET 1
4114
4115int
paulfd79ac92004-10-13 05:06:08 +00004116bgp_aggregate_set (struct vty *vty, const char *prefix_str,
4117 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00004118 u_char summary_only, u_char as_set)
4119{
4120 int ret;
4121 struct prefix p;
4122 struct bgp_node *rn;
4123 struct bgp *bgp;
4124 struct bgp_aggregate *aggregate;
4125
4126 /* Convert string to prefix structure. */
4127 ret = str2prefix (prefix_str, &p);
4128 if (!ret)
4129 {
4130 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
4131 return CMD_WARNING;
4132 }
4133 apply_mask (&p);
4134
4135 /* Get BGP structure. */
4136 bgp = vty->index;
4137
4138 /* Old configuration check. */
4139 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
4140
4141 if (rn->info)
4142 {
4143 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
4144 bgp_unlock_node (rn);
4145 return CMD_WARNING;
4146 }
4147
4148 /* Make aggregate address structure. */
4149 aggregate = bgp_aggregate_new ();
4150 aggregate->summary_only = summary_only;
4151 aggregate->as_set = as_set;
4152 aggregate->safi = safi;
4153 rn->info = aggregate;
4154
4155 /* Aggregate address insert into BGP routing table. */
4156 if (safi & SAFI_UNICAST)
4157 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
4158 if (safi & SAFI_MULTICAST)
4159 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
4160
4161 return CMD_SUCCESS;
4162}
4163
4164int
paulfd79ac92004-10-13 05:06:08 +00004165bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
4166 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004167{
4168 int ret;
4169 struct prefix p;
4170 struct bgp_node *rn;
4171 struct bgp *bgp;
4172 struct bgp_aggregate *aggregate;
4173
4174 /* Convert string to prefix structure. */
4175 ret = str2prefix (prefix_str, &p);
4176 if (!ret)
4177 {
4178 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
4179 return CMD_WARNING;
4180 }
4181 apply_mask (&p);
4182
4183 /* Get BGP structure. */
4184 bgp = vty->index;
4185
4186 /* Old configuration check. */
4187 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
4188 if (! rn)
4189 {
4190 vty_out (vty, "%% There is no aggregate-address configuration.%s",
4191 VTY_NEWLINE);
4192 return CMD_WARNING;
4193 }
4194
4195 aggregate = rn->info;
4196 if (aggregate->safi & SAFI_UNICAST)
4197 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
4198 if (aggregate->safi & SAFI_MULTICAST)
4199 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
4200
4201 /* Unlock aggregate address configuration. */
4202 rn->info = NULL;
4203 bgp_aggregate_free (aggregate);
4204 bgp_unlock_node (rn);
4205 bgp_unlock_node (rn);
4206
4207 return CMD_SUCCESS;
4208}
4209
4210DEFUN (aggregate_address,
4211 aggregate_address_cmd,
4212 "aggregate-address A.B.C.D/M",
4213 "Configure BGP aggregate entries\n"
4214 "Aggregate prefix\n")
4215{
4216 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
4217}
4218
4219DEFUN (aggregate_address_mask,
4220 aggregate_address_mask_cmd,
4221 "aggregate-address A.B.C.D A.B.C.D",
4222 "Configure BGP aggregate entries\n"
4223 "Aggregate address\n"
4224 "Aggregate mask\n")
4225{
4226 int ret;
4227 char prefix_str[BUFSIZ];
4228
4229 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4230
4231 if (! ret)
4232 {
4233 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4234 return CMD_WARNING;
4235 }
4236
4237 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4238 0, 0);
4239}
4240
4241DEFUN (aggregate_address_summary_only,
4242 aggregate_address_summary_only_cmd,
4243 "aggregate-address A.B.C.D/M summary-only",
4244 "Configure BGP aggregate entries\n"
4245 "Aggregate prefix\n"
4246 "Filter more specific routes from updates\n")
4247{
4248 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
4249 AGGREGATE_SUMMARY_ONLY, 0);
4250}
4251
4252DEFUN (aggregate_address_mask_summary_only,
4253 aggregate_address_mask_summary_only_cmd,
4254 "aggregate-address A.B.C.D A.B.C.D summary-only",
4255 "Configure BGP aggregate entries\n"
4256 "Aggregate address\n"
4257 "Aggregate mask\n"
4258 "Filter more specific routes from updates\n")
4259{
4260 int ret;
4261 char prefix_str[BUFSIZ];
4262
4263 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4264
4265 if (! ret)
4266 {
4267 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4268 return CMD_WARNING;
4269 }
4270
4271 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4272 AGGREGATE_SUMMARY_ONLY, 0);
4273}
4274
4275DEFUN (aggregate_address_as_set,
4276 aggregate_address_as_set_cmd,
4277 "aggregate-address A.B.C.D/M as-set",
4278 "Configure BGP aggregate entries\n"
4279 "Aggregate prefix\n"
4280 "Generate AS set path information\n")
4281{
4282 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
4283 0, AGGREGATE_AS_SET);
4284}
4285
4286DEFUN (aggregate_address_mask_as_set,
4287 aggregate_address_mask_as_set_cmd,
4288 "aggregate-address A.B.C.D A.B.C.D as-set",
4289 "Configure BGP aggregate entries\n"
4290 "Aggregate address\n"
4291 "Aggregate mask\n"
4292 "Generate AS set path information\n")
4293{
4294 int ret;
4295 char prefix_str[BUFSIZ];
4296
4297 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4298
4299 if (! ret)
4300 {
4301 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4302 return CMD_WARNING;
4303 }
4304
4305 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4306 0, AGGREGATE_AS_SET);
4307}
4308
4309
4310DEFUN (aggregate_address_as_set_summary,
4311 aggregate_address_as_set_summary_cmd,
4312 "aggregate-address A.B.C.D/M as-set summary-only",
4313 "Configure BGP aggregate entries\n"
4314 "Aggregate prefix\n"
4315 "Generate AS set path information\n"
4316 "Filter more specific routes from updates\n")
4317{
4318 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
4319 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
4320}
4321
4322ALIAS (aggregate_address_as_set_summary,
4323 aggregate_address_summary_as_set_cmd,
4324 "aggregate-address A.B.C.D/M summary-only as-set",
4325 "Configure BGP aggregate entries\n"
4326 "Aggregate prefix\n"
4327 "Filter more specific routes from updates\n"
4328 "Generate AS set path information\n")
4329
4330DEFUN (aggregate_address_mask_as_set_summary,
4331 aggregate_address_mask_as_set_summary_cmd,
4332 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4333 "Configure BGP aggregate entries\n"
4334 "Aggregate address\n"
4335 "Aggregate mask\n"
4336 "Generate AS set path information\n"
4337 "Filter more specific routes from updates\n")
4338{
4339 int ret;
4340 char prefix_str[BUFSIZ];
4341
4342 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4343
4344 if (! ret)
4345 {
4346 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4347 return CMD_WARNING;
4348 }
4349
4350 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
4351 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
4352}
4353
4354ALIAS (aggregate_address_mask_as_set_summary,
4355 aggregate_address_mask_summary_as_set_cmd,
4356 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4357 "Configure BGP aggregate entries\n"
4358 "Aggregate address\n"
4359 "Aggregate mask\n"
4360 "Filter more specific routes from updates\n"
4361 "Generate AS set path information\n")
4362
4363DEFUN (no_aggregate_address,
4364 no_aggregate_address_cmd,
4365 "no aggregate-address A.B.C.D/M",
4366 NO_STR
4367 "Configure BGP aggregate entries\n"
4368 "Aggregate prefix\n")
4369{
4370 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
4371}
4372
4373ALIAS (no_aggregate_address,
4374 no_aggregate_address_summary_only_cmd,
4375 "no aggregate-address A.B.C.D/M summary-only",
4376 NO_STR
4377 "Configure BGP aggregate entries\n"
4378 "Aggregate prefix\n"
4379 "Filter more specific routes from updates\n")
4380
4381ALIAS (no_aggregate_address,
4382 no_aggregate_address_as_set_cmd,
4383 "no aggregate-address A.B.C.D/M as-set",
4384 NO_STR
4385 "Configure BGP aggregate entries\n"
4386 "Aggregate prefix\n"
4387 "Generate AS set path information\n")
4388
4389ALIAS (no_aggregate_address,
4390 no_aggregate_address_as_set_summary_cmd,
4391 "no aggregate-address A.B.C.D/M as-set summary-only",
4392 NO_STR
4393 "Configure BGP aggregate entries\n"
4394 "Aggregate prefix\n"
4395 "Generate AS set path information\n"
4396 "Filter more specific routes from updates\n")
4397
4398ALIAS (no_aggregate_address,
4399 no_aggregate_address_summary_as_set_cmd,
4400 "no aggregate-address A.B.C.D/M summary-only as-set",
4401 NO_STR
4402 "Configure BGP aggregate entries\n"
4403 "Aggregate prefix\n"
4404 "Filter more specific routes from updates\n"
4405 "Generate AS set path information\n")
4406
4407DEFUN (no_aggregate_address_mask,
4408 no_aggregate_address_mask_cmd,
4409 "no aggregate-address A.B.C.D A.B.C.D",
4410 NO_STR
4411 "Configure BGP aggregate entries\n"
4412 "Aggregate address\n"
4413 "Aggregate mask\n")
4414{
4415 int ret;
4416 char prefix_str[BUFSIZ];
4417
4418 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4419
4420 if (! ret)
4421 {
4422 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4423 return CMD_WARNING;
4424 }
4425
4426 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
4427}
4428
4429ALIAS (no_aggregate_address_mask,
4430 no_aggregate_address_mask_summary_only_cmd,
4431 "no aggregate-address A.B.C.D A.B.C.D summary-only",
4432 NO_STR
4433 "Configure BGP aggregate entries\n"
4434 "Aggregate address\n"
4435 "Aggregate mask\n"
4436 "Filter more specific routes from updates\n")
4437
4438ALIAS (no_aggregate_address_mask,
4439 no_aggregate_address_mask_as_set_cmd,
4440 "no aggregate-address A.B.C.D A.B.C.D as-set",
4441 NO_STR
4442 "Configure BGP aggregate entries\n"
4443 "Aggregate address\n"
4444 "Aggregate mask\n"
4445 "Generate AS set path information\n")
4446
4447ALIAS (no_aggregate_address_mask,
4448 no_aggregate_address_mask_as_set_summary_cmd,
4449 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4450 NO_STR
4451 "Configure BGP aggregate entries\n"
4452 "Aggregate address\n"
4453 "Aggregate mask\n"
4454 "Generate AS set path information\n"
4455 "Filter more specific routes from updates\n")
4456
4457ALIAS (no_aggregate_address_mask,
4458 no_aggregate_address_mask_summary_as_set_cmd,
4459 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4460 NO_STR
4461 "Configure BGP aggregate entries\n"
4462 "Aggregate address\n"
4463 "Aggregate mask\n"
4464 "Filter more specific routes from updates\n"
4465 "Generate AS set path information\n")
4466
4467#ifdef HAVE_IPV6
4468DEFUN (ipv6_aggregate_address,
4469 ipv6_aggregate_address_cmd,
4470 "aggregate-address X:X::X:X/M",
4471 "Configure BGP aggregate entries\n"
4472 "Aggregate prefix\n")
4473{
4474 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
4475}
4476
4477DEFUN (ipv6_aggregate_address_summary_only,
4478 ipv6_aggregate_address_summary_only_cmd,
4479 "aggregate-address X:X::X:X/M summary-only",
4480 "Configure BGP aggregate entries\n"
4481 "Aggregate prefix\n"
4482 "Filter more specific routes from updates\n")
4483{
4484 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
4485 AGGREGATE_SUMMARY_ONLY, 0);
4486}
4487
4488DEFUN (no_ipv6_aggregate_address,
4489 no_ipv6_aggregate_address_cmd,
4490 "no aggregate-address X:X::X:X/M",
4491 NO_STR
4492 "Configure BGP aggregate entries\n"
4493 "Aggregate prefix\n")
4494{
4495 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
4496}
4497
4498DEFUN (no_ipv6_aggregate_address_summary_only,
4499 no_ipv6_aggregate_address_summary_only_cmd,
4500 "no aggregate-address X:X::X:X/M summary-only",
4501 NO_STR
4502 "Configure BGP aggregate entries\n"
4503 "Aggregate prefix\n"
4504 "Filter more specific routes from updates\n")
4505{
4506 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
4507}
4508
4509ALIAS (ipv6_aggregate_address,
4510 old_ipv6_aggregate_address_cmd,
4511 "ipv6 bgp aggregate-address X:X::X:X/M",
4512 IPV6_STR
4513 BGP_STR
4514 "Configure BGP aggregate entries\n"
4515 "Aggregate prefix\n")
4516
4517ALIAS (ipv6_aggregate_address_summary_only,
4518 old_ipv6_aggregate_address_summary_only_cmd,
4519 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4520 IPV6_STR
4521 BGP_STR
4522 "Configure BGP aggregate entries\n"
4523 "Aggregate prefix\n"
4524 "Filter more specific routes from updates\n")
4525
4526ALIAS (no_ipv6_aggregate_address,
4527 old_no_ipv6_aggregate_address_cmd,
4528 "no ipv6 bgp aggregate-address X:X::X:X/M",
4529 NO_STR
4530 IPV6_STR
4531 BGP_STR
4532 "Configure BGP aggregate entries\n"
4533 "Aggregate prefix\n")
4534
4535ALIAS (no_ipv6_aggregate_address_summary_only,
4536 old_no_ipv6_aggregate_address_summary_only_cmd,
4537 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
4538 NO_STR
4539 IPV6_STR
4540 BGP_STR
4541 "Configure BGP aggregate entries\n"
4542 "Aggregate prefix\n"
4543 "Filter more specific routes from updates\n")
4544#endif /* HAVE_IPV6 */
4545
4546/* Redistribute route treatment. */
4547void
4548bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop,
4549 u_int32_t metric, u_char type)
4550{
4551 struct bgp *bgp;
4552 struct listnode *nn;
4553 struct bgp_info *new;
4554 struct bgp_info *bi;
4555 struct bgp_info info;
4556 struct bgp_node *bn;
4557 struct attr attr;
4558 struct attr attr_new;
4559 struct attr *new_attr;
4560 afi_t afi;
4561 int ret;
4562
4563 /* Make default attribute. */
4564 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
4565 if (nexthop)
4566 attr.nexthop = *nexthop;
4567
4568 attr.med = metric;
4569 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
4570
4571 LIST_LOOP (bm->bgp, bgp, nn)
4572 {
4573 afi = family2afi (p->family);
4574
4575 if (bgp->redist[afi][type])
4576 {
4577 /* Copy attribute for modification. */
4578 attr_new = attr;
4579
4580 if (bgp->redist_metric_flag[afi][type])
4581 attr_new.med = bgp->redist_metric[afi][type];
4582
4583 /* Apply route-map. */
4584 if (bgp->rmap[afi][type].map)
4585 {
4586 info.peer = bgp->peer_self;
4587 info.attr = &attr_new;
4588
paulfee0f4c2004-09-13 05:12:46 +00004589 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
4590
paul718e3742002-12-13 20:15:29 +00004591 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
4592 &info);
paulfee0f4c2004-09-13 05:12:46 +00004593
4594 bgp->peer_self->rmap_type = 0;
4595
paul718e3742002-12-13 20:15:29 +00004596 if (ret == RMAP_DENYMATCH)
4597 {
4598 /* Free uninterned attribute. */
4599 bgp_attr_flush (&attr_new);
4600
4601 /* Unintern original. */
4602 aspath_unintern (attr.aspath);
4603 bgp_redistribute_delete (p, type);
4604 return;
4605 }
4606 }
4607
paulfee0f4c2004-09-13 05:12:46 +00004608 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00004609 new_attr = bgp_attr_intern (&attr_new);
4610
4611 for (bi = bn->info; bi; bi = bi->next)
4612 if (bi->peer == bgp->peer_self
4613 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
4614 break;
4615
4616 if (bi)
4617 {
4618 if (attrhash_cmp (bi->attr, new_attr))
4619 {
4620 bgp_attr_unintern (new_attr);
4621 aspath_unintern (attr.aspath);
4622 bgp_unlock_node (bn);
4623 return;
4624 }
4625 else
4626 {
4627 /* The attribute is changed. */
4628 SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED);
4629
4630 /* Rewrite BGP route information. */
4631 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
4632 bgp_attr_unintern (bi->attr);
4633 bi->attr = new_attr;
4634 bi->uptime = time (NULL);
4635
4636 /* Process change. */
4637 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
4638 bgp_process (bgp, bn, afi, SAFI_UNICAST);
4639 bgp_unlock_node (bn);
4640 aspath_unintern (attr.aspath);
4641 return;
4642 }
4643 }
4644
4645 new = bgp_info_new ();
4646 new->type = type;
4647 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
4648 new->peer = bgp->peer_self;
4649 SET_FLAG (new->flags, BGP_INFO_VALID);
4650 new->attr = new_attr;
4651 new->uptime = time (NULL);
4652
4653 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
4654 bgp_info_add (bn, new);
4655 bgp_process (bgp, bn, afi, SAFI_UNICAST);
4656 }
4657 }
4658
4659 /* Unintern original. */
4660 aspath_unintern (attr.aspath);
4661}
4662
4663void
4664bgp_redistribute_delete (struct prefix *p, u_char type)
4665{
4666 struct bgp *bgp;
4667 struct listnode *nn;
4668 afi_t afi;
4669 struct bgp_node *rn;
4670 struct bgp_info *ri;
4671
4672 LIST_LOOP (bm->bgp, bgp, nn)
4673 {
4674 afi = family2afi (p->family);
4675
4676 if (bgp->redist[afi][type])
4677 {
paulfee0f4c2004-09-13 05:12:46 +00004678 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00004679
4680 for (ri = rn->info; ri; ri = ri->next)
4681 if (ri->peer == bgp->peer_self
4682 && ri->type == type)
4683 break;
4684
4685 if (ri)
4686 {
4687 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
4688 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
4689 bgp_process (bgp, rn, afi, SAFI_UNICAST);
4690 bgp_info_delete (rn, ri);
4691 bgp_info_free (ri);
4692 bgp_unlock_node (rn);
4693 }
4694 bgp_unlock_node (rn);
4695 }
4696 }
4697}
4698
4699/* Withdraw specified route type's route. */
4700void
4701bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
4702{
4703 struct bgp_node *rn;
4704 struct bgp_info *ri;
4705 struct bgp_table *table;
4706
4707 table = bgp->rib[afi][SAFI_UNICAST];
4708
4709 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
4710 {
4711 for (ri = rn->info; ri; ri = ri->next)
4712 if (ri->peer == bgp->peer_self
4713 && ri->type == type)
4714 break;
4715
4716 if (ri)
4717 {
4718 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
4719 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
4720 bgp_process (bgp, rn, afi, SAFI_UNICAST);
4721 bgp_info_delete (rn, ri);
4722 bgp_info_free (ri);
4723 bgp_unlock_node (rn);
4724 }
4725 }
4726}
4727
4728/* Static function to display route. */
4729void
4730route_vty_out_route (struct prefix *p, struct vty *vty)
4731{
4732 int len;
4733 u_int32_t destination;
4734 char buf[BUFSIZ];
4735
4736 if (p->family == AF_INET)
4737 {
4738 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
4739 destination = ntohl (p->u.prefix4.s_addr);
4740
4741 if ((IN_CLASSC (destination) && p->prefixlen == 24)
4742 || (IN_CLASSB (destination) && p->prefixlen == 16)
4743 || (IN_CLASSA (destination) && p->prefixlen == 8)
4744 || p->u.prefix4.s_addr == 0)
4745 {
4746 /* When mask is natural, mask is not displayed. */
4747 }
4748 else
4749 len += vty_out (vty, "/%d", p->prefixlen);
4750 }
4751 else
4752 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
4753 p->prefixlen);
4754
4755 len = 17 - len;
4756 if (len < 1)
4757 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
4758 else
4759 vty_out (vty, "%*s", len, " ");
4760}
4761
paul718e3742002-12-13 20:15:29 +00004762enum bgp_display_type
4763{
4764 normal_list,
4765};
4766
4767/* called from terminal list command */
ajs5a646652004-11-05 01:25:55 +00004768void
paul718e3742002-12-13 20:15:29 +00004769route_vty_out (struct vty *vty, struct prefix *p,
4770 struct bgp_info *binfo, int display, safi_t safi)
4771{
4772 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00004773
4774 /* Route status display. */
hasso93406d82005-02-02 14:40:33 +00004775 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
4776 vty_out (vty, "S");
4777 else if (binfo->suppress)
paul718e3742002-12-13 20:15:29 +00004778 vty_out (vty, "s");
4779 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4780 vty_out (vty, "*");
4781 else
4782 vty_out (vty, " ");
4783
4784 /* Selected */
4785 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4786 vty_out (vty, "h");
4787 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4788 vty_out (vty, "d");
4789 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
4790 vty_out (vty, ">");
4791 else
4792 vty_out (vty, " ");
4793
4794 /* Internal route. */
4795 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
4796 vty_out (vty, "i");
4797 else
4798 vty_out (vty, " ");
4799
4800 /* print prefix and mask */
4801 if (! display)
4802 route_vty_out_route (p, vty);
4803 else
4804 vty_out (vty, "%*s", 17, " ");
4805
4806 /* Print attribute */
4807 attr = binfo->attr;
4808 if (attr)
4809 {
4810 if (p->family == AF_INET)
4811 {
4812 if (safi == SAFI_MPLS_VPN)
4813 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
4814 else
4815 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
4816 }
4817#ifdef HAVE_IPV6
4818 else if (p->family == AF_INET6)
4819 {
4820 int len;
4821 char buf[BUFSIZ];
4822
4823 len = vty_out (vty, "%s",
4824 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
4825 len = 16 - len;
4826 if (len < 1)
4827 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
4828 else
4829 vty_out (vty, "%*s", len, " ");
4830 }
4831#endif /* HAVE_IPV6 */
4832
4833 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
4834 vty_out (vty, "%10d", attr->med);
4835 else
4836 vty_out (vty, " ");
4837
4838 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
4839 vty_out (vty, "%7d", attr->local_pref);
4840 else
4841 vty_out (vty, " ");
4842
4843 vty_out (vty, "%7u ",attr->weight);
4844
4845 /* Print aspath */
4846 if (attr->aspath)
4847 aspath_print_vty (vty, attr->aspath);
4848
4849 /* Print origin */
4850 if (strlen (attr->aspath->str) == 0)
4851 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
4852 else
4853 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
4854 }
4855 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004856}
4857
4858/* called from terminal list command */
4859void
4860route_vty_out_tmp (struct vty *vty, struct prefix *p,
4861 struct attr *attr, safi_t safi)
4862{
4863 /* Route status display. */
4864 vty_out (vty, "*");
4865 vty_out (vty, ">");
4866 vty_out (vty, " ");
4867
4868 /* print prefix and mask */
4869 route_vty_out_route (p, vty);
4870
4871 /* Print attribute */
4872 if (attr)
4873 {
4874 if (p->family == AF_INET)
4875 {
4876 if (safi == SAFI_MPLS_VPN)
4877 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
4878 else
4879 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
4880 }
4881#ifdef HAVE_IPV6
4882 else if (p->family == AF_INET6)
4883 {
4884 int len;
4885 char buf[BUFSIZ];
4886
4887 len = vty_out (vty, "%s",
4888 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
4889 len = 16 - len;
4890 if (len < 1)
4891 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
4892 else
4893 vty_out (vty, "%*s", len, " ");
4894 }
4895#endif /* HAVE_IPV6 */
4896
4897 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
4898 vty_out (vty, "%10d", attr->med);
4899 else
4900 vty_out (vty, " ");
4901
4902 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
4903 vty_out (vty, "%7d", attr->local_pref);
4904 else
4905 vty_out (vty, " ");
4906
4907 vty_out (vty, "%7d ",attr->weight);
4908
4909 /* Print aspath */
4910 if (attr->aspath)
4911 aspath_print_vty (vty, attr->aspath);
4912
4913 /* Print origin */
4914 if (strlen (attr->aspath->str) == 0)
4915 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
4916 else
4917 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
4918 }
4919
4920 vty_out (vty, "%s", VTY_NEWLINE);
4921}
4922
ajs5a646652004-11-05 01:25:55 +00004923void
paul718e3742002-12-13 20:15:29 +00004924route_vty_out_tag (struct vty *vty, struct prefix *p,
4925 struct bgp_info *binfo, int display, safi_t safi)
4926{
4927 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00004928 u_int32_t label = 0;
4929
paul718e3742002-12-13 20:15:29 +00004930 /* Route status display. */
4931 if (binfo->suppress)
4932 vty_out (vty, "s");
4933 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4934 vty_out (vty, "*");
4935 else
4936 vty_out (vty, " ");
4937
4938 /* Selected */
4939 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4940 vty_out (vty, "h");
4941 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4942 vty_out (vty, "d");
4943 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
4944 vty_out (vty, ">");
4945 else
4946 vty_out (vty, " ");
4947
4948 /* Internal route. */
4949 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
4950 vty_out (vty, "i");
4951 else
4952 vty_out (vty, " ");
4953
4954 /* print prefix and mask */
4955 if (! display)
4956 route_vty_out_route (p, vty);
4957 else
4958 vty_out (vty, "%*s", 17, " ");
4959
4960 /* Print attribute */
4961 attr = binfo->attr;
4962 if (attr)
4963 {
4964 if (p->family == AF_INET)
4965 {
4966 if (safi == SAFI_MPLS_VPN)
4967 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
4968 else
4969 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
4970 }
4971#ifdef HAVE_IPV6
4972 else if (p->family == AF_INET6)
4973 {
4974 char buf[BUFSIZ];
4975 char buf1[BUFSIZ];
4976 if (attr->mp_nexthop_len == 16)
4977 vty_out (vty, "%s",
4978 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
4979 else if (attr->mp_nexthop_len == 32)
4980 vty_out (vty, "%s(%s)",
4981 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ),
4982 inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ));
4983
4984 }
4985#endif /* HAVE_IPV6 */
4986 }
4987
4988 label = decode_label (binfo->tag);
4989
4990 vty_out (vty, "notag/%d", label);
4991
4992 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00004993}
4994
4995/* dampening route */
ajs5a646652004-11-05 01:25:55 +00004996static void
paul718e3742002-12-13 20:15:29 +00004997damp_route_vty_out (struct vty *vty, struct prefix *p,
4998 struct bgp_info *binfo, int display, safi_t safi)
4999{
5000 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00005001 int len;
5002
paul718e3742002-12-13 20:15:29 +00005003 /* Route status display. */
5004 if (binfo->suppress)
5005 vty_out (vty, "s");
5006 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5007 vty_out (vty, "*");
5008 else
5009 vty_out (vty, " ");
5010
5011 /* Selected */
5012 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5013 vty_out (vty, "h");
5014 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5015 vty_out (vty, "d");
5016 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5017 vty_out (vty, ">");
5018 else
5019 vty_out (vty, " ");
5020
5021 vty_out (vty, " ");
5022
5023 /* print prefix and mask */
5024 if (! display)
5025 route_vty_out_route (p, vty);
5026 else
5027 vty_out (vty, "%*s", 17, " ");
5028
5029 len = vty_out (vty, "%s", binfo->peer->host);
5030 len = 17 - len;
5031 if (len < 1)
5032 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
5033 else
5034 vty_out (vty, "%*s", len, " ");
5035
5036 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
5037
5038 /* Print attribute */
5039 attr = binfo->attr;
5040 if (attr)
5041 {
5042 /* Print aspath */
5043 if (attr->aspath)
5044 aspath_print_vty (vty, attr->aspath);
5045
5046 /* Print origin */
5047 if (strlen (attr->aspath->str) == 0)
5048 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
5049 else
5050 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
5051 }
5052 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005053}
5054
5055#define BGP_UPTIME_LEN 25
5056
5057/* flap route */
ajs5a646652004-11-05 01:25:55 +00005058static void
paul718e3742002-12-13 20:15:29 +00005059flap_route_vty_out (struct vty *vty, struct prefix *p,
5060 struct bgp_info *binfo, int display, safi_t safi)
5061{
5062 struct attr *attr;
5063 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00005064 char timebuf[BGP_UPTIME_LEN];
5065 int len;
5066
paul718e3742002-12-13 20:15:29 +00005067 bdi = binfo->damp_info;
5068
5069 /* Route status display. */
5070 if (binfo->suppress)
5071 vty_out (vty, "s");
5072 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5073 vty_out (vty, "*");
5074 else
5075 vty_out (vty, " ");
5076
5077 /* Selected */
5078 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5079 vty_out (vty, "h");
5080 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5081 vty_out (vty, "d");
5082 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5083 vty_out (vty, ">");
5084 else
5085 vty_out (vty, " ");
5086
5087 vty_out (vty, " ");
5088
5089 /* print prefix and mask */
5090 if (! display)
5091 route_vty_out_route (p, vty);
5092 else
5093 vty_out (vty, "%*s", 17, " ");
5094
5095 len = vty_out (vty, "%s", binfo->peer->host);
5096 len = 16 - len;
5097 if (len < 1)
5098 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
5099 else
5100 vty_out (vty, "%*s", len, " ");
5101
5102 len = vty_out (vty, "%d", bdi->flap);
5103 len = 5 - len;
5104 if (len < 1)
5105 vty_out (vty, " ");
5106 else
5107 vty_out (vty, "%*s ", len, " ");
5108
5109 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
5110 timebuf, BGP_UPTIME_LEN));
5111
5112 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
5113 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5114 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
5115 else
5116 vty_out (vty, "%*s ", 8, " ");
5117
5118 /* Print attribute */
5119 attr = binfo->attr;
5120 if (attr)
5121 {
5122 /* Print aspath */
5123 if (attr->aspath)
5124 aspath_print_vty (vty, attr->aspath);
5125
5126 /* Print origin */
5127 if (strlen (attr->aspath->str) == 0)
5128 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
5129 else
5130 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
5131 }
5132 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005133}
5134
5135void
5136route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
5137 struct bgp_info *binfo, afi_t afi, safi_t safi)
5138{
5139 char buf[INET6_ADDRSTRLEN];
5140 char buf1[BUFSIZ];
5141 struct attr *attr;
5142 int sockunion_vty_out (struct vty *, union sockunion *);
5143
5144 attr = binfo->attr;
5145
5146 if (attr)
5147 {
5148 /* Line1 display AS-path, Aggregator */
5149 if (attr->aspath)
5150 {
5151 vty_out (vty, " ");
5152 if (attr->aspath->length == 0)
5153 vty_out (vty, "Local");
5154 else
5155 aspath_print_vty (vty, attr->aspath);
5156 }
5157
hasso93406d82005-02-02 14:40:33 +00005158 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
5159 vty_out (vty, ", (stale)");
5160 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
5161 vty_out (vty, ", (aggregated by %d %s)", attr->aggregator_as,
5162 inet_ntoa (attr->aggregator_addr));
5163 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
5164 vty_out (vty, ", (Received from a RR-client)");
5165 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
5166 vty_out (vty, ", (Received from a RS-client)");
5167 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5168 vty_out (vty, ", (history entry)");
5169 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5170 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00005171 vty_out (vty, "%s", VTY_NEWLINE);
5172
5173 /* Line2 display Next-hop, Neighbor, Router-id */
5174 if (p->family == AF_INET)
5175 {
5176 vty_out (vty, " %s", safi == SAFI_MPLS_VPN ?
5177 inet_ntoa (attr->mp_nexthop_global_in) :
5178 inet_ntoa (attr->nexthop));
5179 }
5180#ifdef HAVE_IPV6
5181 else
5182 {
5183 vty_out (vty, " %s",
5184 inet_ntop (AF_INET6, &attr->mp_nexthop_global,
5185 buf, INET6_ADDRSTRLEN));
5186 }
5187#endif /* HAVE_IPV6 */
5188
5189 if (binfo->peer == bgp->peer_self)
5190 {
5191 vty_out (vty, " from %s ",
5192 p->family == AF_INET ? "0.0.0.0" : "::");
5193 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
5194 }
5195 else
5196 {
5197 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
5198 vty_out (vty, " (inaccessible)");
5199 else if (binfo->igpmetric)
5200 vty_out (vty, " (metric %d)", binfo->igpmetric);
pauleb821182004-05-01 08:44:08 +00005201 vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN));
paul718e3742002-12-13 20:15:29 +00005202 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
5203 vty_out (vty, " (%s)", inet_ntoa (attr->originator_id));
5204 else
5205 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
5206 }
5207 vty_out (vty, "%s", VTY_NEWLINE);
5208
5209#ifdef HAVE_IPV6
5210 /* display nexthop local */
5211 if (attr->mp_nexthop_len == 32)
5212 {
5213 vty_out (vty, " (%s)%s",
5214 inet_ntop (AF_INET6, &attr->mp_nexthop_local,
5215 buf, INET6_ADDRSTRLEN),
5216 VTY_NEWLINE);
5217 }
5218#endif /* HAVE_IPV6 */
5219
5220 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5221 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
5222
5223 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
5224 vty_out (vty, ", metric %d", attr->med);
5225
5226 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
5227 vty_out (vty, ", localpref %d", attr->local_pref);
5228 else
5229 vty_out (vty, ", localpref %d", bgp->default_local_pref);
5230
5231 if (attr->weight != 0)
5232 vty_out (vty, ", weight %d", attr->weight);
5233
5234 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5235 vty_out (vty, ", valid");
5236
5237 if (binfo->peer != bgp->peer_self)
5238 {
5239 if (binfo->peer->as == binfo->peer->local_as)
5240 vty_out (vty, ", internal");
5241 else
5242 vty_out (vty, ", %s",
5243 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
5244 }
5245 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
5246 vty_out (vty, ", aggregated, local");
5247 else if (binfo->type != ZEBRA_ROUTE_BGP)
5248 vty_out (vty, ", sourced");
5249 else
5250 vty_out (vty, ", sourced, local");
5251
5252 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
5253 vty_out (vty, ", atomic-aggregate");
5254
5255 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5256 vty_out (vty, ", best");
5257
5258 vty_out (vty, "%s", VTY_NEWLINE);
5259
5260 /* Line 4 display Community */
5261 if (attr->community)
5262 vty_out (vty, " Community: %s%s", attr->community->str,
5263 VTY_NEWLINE);
5264
5265 /* Line 5 display Extended-community */
5266 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
5267 vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str,
5268 VTY_NEWLINE);
5269
5270 /* Line 6 display Originator, Cluster-id */
5271 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
5272 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
5273 {
5274 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
5275 vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id));
5276
5277 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
5278 {
5279 int i;
5280 vty_out (vty, ", Cluster list: ");
5281 for (i = 0; i < attr->cluster->length / 4; i++)
5282 vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i]));
5283 }
5284 vty_out (vty, "%s", VTY_NEWLINE);
5285 }
5286
5287 if (binfo->damp_info)
5288 bgp_damp_info_vty (vty, binfo);
5289
5290 /* Line 7 display Uptime */
5291 vty_out (vty, " Last update: %s", ctime (&binfo->uptime));
5292 }
5293 vty_out (vty, "%s", VTY_NEWLINE);
5294}
5295
hasso93406d82005-02-02 14:40:33 +00005296#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,%s r RIB-failure, S Stale%s"
5297#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00005298#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
5299#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
5300#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
5301
5302enum bgp_show_type
5303{
5304 bgp_show_type_normal,
5305 bgp_show_type_regexp,
5306 bgp_show_type_prefix_list,
5307 bgp_show_type_filter_list,
5308 bgp_show_type_route_map,
5309 bgp_show_type_neighbor,
5310 bgp_show_type_cidr_only,
5311 bgp_show_type_prefix_longer,
5312 bgp_show_type_community_all,
5313 bgp_show_type_community,
5314 bgp_show_type_community_exact,
5315 bgp_show_type_community_list,
5316 bgp_show_type_community_list_exact,
5317 bgp_show_type_flap_statistics,
5318 bgp_show_type_flap_address,
5319 bgp_show_type_flap_prefix,
5320 bgp_show_type_flap_cidr_only,
5321 bgp_show_type_flap_regexp,
5322 bgp_show_type_flap_filter_list,
5323 bgp_show_type_flap_prefix_list,
5324 bgp_show_type_flap_prefix_longer,
5325 bgp_show_type_flap_route_map,
5326 bgp_show_type_flap_neighbor,
5327 bgp_show_type_dampend_paths,
5328 bgp_show_type_damp_neighbor
5329};
5330
ajs5a646652004-11-05 01:25:55 +00005331static int
paulfee0f4c2004-09-13 05:12:46 +00005332bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00005333 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00005334{
paul718e3742002-12-13 20:15:29 +00005335 struct bgp_info *ri;
5336 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00005337 int header = 1;
paul718e3742002-12-13 20:15:29 +00005338 int display;
ajs5a646652004-11-05 01:25:55 +00005339 unsigned long output_count;
paul718e3742002-12-13 20:15:29 +00005340
5341 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00005342 output_count = 0;
paul718e3742002-12-13 20:15:29 +00005343
paul718e3742002-12-13 20:15:29 +00005344 /* Start processing of routes. */
5345 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5346 if (rn->info != NULL)
5347 {
5348 display = 0;
5349
5350 for (ri = rn->info; ri; ri = ri->next)
5351 {
ajs5a646652004-11-05 01:25:55 +00005352 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00005353 || type == bgp_show_type_flap_address
5354 || type == bgp_show_type_flap_prefix
5355 || type == bgp_show_type_flap_cidr_only
5356 || type == bgp_show_type_flap_regexp
5357 || type == bgp_show_type_flap_filter_list
5358 || type == bgp_show_type_flap_prefix_list
5359 || type == bgp_show_type_flap_prefix_longer
5360 || type == bgp_show_type_flap_route_map
5361 || type == bgp_show_type_flap_neighbor
5362 || type == bgp_show_type_dampend_paths
5363 || type == bgp_show_type_damp_neighbor)
5364 {
5365 if (! ri->damp_info)
5366 continue;
5367 }
5368 if (type == bgp_show_type_regexp
5369 || type == bgp_show_type_flap_regexp)
5370 {
ajs5a646652004-11-05 01:25:55 +00005371 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00005372
5373 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
5374 continue;
5375 }
5376 if (type == bgp_show_type_prefix_list
5377 || type == bgp_show_type_flap_prefix_list)
5378 {
ajs5a646652004-11-05 01:25:55 +00005379 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00005380
5381 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
5382 continue;
5383 }
5384 if (type == bgp_show_type_filter_list
5385 || type == bgp_show_type_flap_filter_list)
5386 {
ajs5a646652004-11-05 01:25:55 +00005387 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00005388
5389 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
5390 continue;
5391 }
5392 if (type == bgp_show_type_route_map
5393 || type == bgp_show_type_flap_route_map)
5394 {
ajs5a646652004-11-05 01:25:55 +00005395 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00005396 struct bgp_info binfo;
5397 struct attr dummy_attr;
5398 int ret;
5399
5400 dummy_attr = *ri->attr;
5401 binfo.peer = ri->peer;
5402 binfo.attr = &dummy_attr;
5403
5404 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
5405
5406 if (ret == RMAP_DENYMATCH)
5407 continue;
5408 }
5409 if (type == bgp_show_type_neighbor
5410 || type == bgp_show_type_flap_neighbor
5411 || type == bgp_show_type_damp_neighbor)
5412 {
ajs5a646652004-11-05 01:25:55 +00005413 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00005414
5415 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
5416 continue;
5417 }
5418 if (type == bgp_show_type_cidr_only
5419 || type == bgp_show_type_flap_cidr_only)
5420 {
5421 u_int32_t destination;
5422
5423 destination = ntohl (rn->p.u.prefix4.s_addr);
5424 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
5425 continue;
5426 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
5427 continue;
5428 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
5429 continue;
5430 }
5431 if (type == bgp_show_type_prefix_longer
5432 || type == bgp_show_type_flap_prefix_longer)
5433 {
ajs5a646652004-11-05 01:25:55 +00005434 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00005435
5436 if (! prefix_match (p, &rn->p))
5437 continue;
5438 }
5439 if (type == bgp_show_type_community_all)
5440 {
5441 if (! ri->attr->community)
5442 continue;
5443 }
5444 if (type == bgp_show_type_community)
5445 {
ajs5a646652004-11-05 01:25:55 +00005446 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00005447
5448 if (! ri->attr->community ||
5449 ! community_match (ri->attr->community, com))
5450 continue;
5451 }
5452 if (type == bgp_show_type_community_exact)
5453 {
ajs5a646652004-11-05 01:25:55 +00005454 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00005455
5456 if (! ri->attr->community ||
5457 ! community_cmp (ri->attr->community, com))
5458 continue;
5459 }
5460 if (type == bgp_show_type_community_list)
5461 {
ajs5a646652004-11-05 01:25:55 +00005462 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00005463
5464 if (! community_list_match (ri->attr->community, list))
5465 continue;
5466 }
5467 if (type == bgp_show_type_community_list_exact)
5468 {
ajs5a646652004-11-05 01:25:55 +00005469 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00005470
5471 if (! community_list_exact_match (ri->attr->community, list))
5472 continue;
5473 }
5474 if (type == bgp_show_type_flap_address
5475 || type == bgp_show_type_flap_prefix)
5476 {
ajs5a646652004-11-05 01:25:55 +00005477 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00005478
5479 if (! prefix_match (&rn->p, p))
5480 continue;
5481
5482 if (type == bgp_show_type_flap_prefix)
5483 if (p->prefixlen != rn->p.prefixlen)
5484 continue;
5485 }
5486 if (type == bgp_show_type_dampend_paths
5487 || type == bgp_show_type_damp_neighbor)
5488 {
5489 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
5490 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
5491 continue;
5492 }
5493
5494 if (header)
5495 {
hasso93406d82005-02-02 14:40:33 +00005496 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
5497 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
5498 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005499 if (type == bgp_show_type_dampend_paths
5500 || type == bgp_show_type_damp_neighbor)
5501 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
5502 else if (type == bgp_show_type_flap_statistics
5503 || type == bgp_show_type_flap_address
5504 || type == bgp_show_type_flap_prefix
5505 || type == bgp_show_type_flap_cidr_only
5506 || type == bgp_show_type_flap_regexp
5507 || type == bgp_show_type_flap_filter_list
5508 || type == bgp_show_type_flap_prefix_list
5509 || type == bgp_show_type_flap_prefix_longer
5510 || type == bgp_show_type_flap_route_map
5511 || type == bgp_show_type_flap_neighbor)
5512 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
5513 else
5514 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005515 header = 0;
5516 }
5517
5518 if (type == bgp_show_type_dampend_paths
5519 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00005520 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005521 else if (type == bgp_show_type_flap_statistics
5522 || type == bgp_show_type_flap_address
5523 || type == bgp_show_type_flap_prefix
5524 || type == bgp_show_type_flap_cidr_only
5525 || type == bgp_show_type_flap_regexp
5526 || type == bgp_show_type_flap_filter_list
5527 || type == bgp_show_type_flap_prefix_list
5528 || type == bgp_show_type_flap_prefix_longer
5529 || type == bgp_show_type_flap_route_map
5530 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00005531 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005532 else
ajs5a646652004-11-05 01:25:55 +00005533 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005534 display++;
5535 }
5536 if (display)
ajs5a646652004-11-05 01:25:55 +00005537 output_count++;
paul718e3742002-12-13 20:15:29 +00005538 }
5539
5540 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00005541 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00005542 {
5543 if (type == bgp_show_type_normal)
5544 vty_out (vty, "No BGP network exists%s", VTY_NEWLINE);
5545 }
5546 else
5547 vty_out (vty, "%sTotal number of prefixes %ld%s",
ajs5a646652004-11-05 01:25:55 +00005548 VTY_NEWLINE, output_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005549
5550 return CMD_SUCCESS;
5551}
5552
ajs5a646652004-11-05 01:25:55 +00005553static int
paulfee0f4c2004-09-13 05:12:46 +00005554bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00005555 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00005556{
5557 struct bgp_table *table;
5558
5559 if (bgp == NULL) {
5560 bgp = bgp_get_default ();
5561 }
5562
5563 if (bgp == NULL)
5564 {
5565 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
5566 return CMD_WARNING;
5567 }
5568
5569
5570 table = bgp->rib[afi][safi];
5571
ajs5a646652004-11-05 01:25:55 +00005572 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00005573}
5574
paul718e3742002-12-13 20:15:29 +00005575/* Header of detailed BGP route information */
5576void
5577route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
5578 struct bgp_node *rn,
5579 struct prefix_rd *prd, afi_t afi, safi_t safi)
5580{
5581 struct bgp_info *ri;
5582 struct prefix *p;
5583 struct peer *peer;
5584 struct listnode *nn;
5585 char buf1[INET6_ADDRSTRLEN];
5586 char buf2[INET6_ADDRSTRLEN];
5587 int count = 0;
5588 int best = 0;
5589 int suppress = 0;
5590 int no_export = 0;
5591 int no_advertise = 0;
5592 int local_as = 0;
5593 int first = 0;
5594
5595 p = &rn->p;
5596 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
5597 (safi == SAFI_MPLS_VPN ?
5598 prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
5599 safi == SAFI_MPLS_VPN ? ":" : "",
5600 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
5601 p->prefixlen, VTY_NEWLINE);
5602
5603 for (ri = rn->info; ri; ri = ri->next)
5604 {
5605 count++;
5606 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
5607 {
5608 best = count;
5609 if (ri->suppress)
5610 suppress = 1;
5611 if (ri->attr->community != NULL)
5612 {
5613 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
5614 no_advertise = 1;
5615 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
5616 no_export = 1;
5617 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
5618 local_as = 1;
5619 }
5620 }
5621 }
5622
5623 vty_out (vty, "Paths: (%d available", count);
5624 if (best)
5625 {
5626 vty_out (vty, ", best #%d", best);
5627 if (safi == SAFI_UNICAST)
5628 vty_out (vty, ", table Default-IP-Routing-Table");
5629 }
5630 else
5631 vty_out (vty, ", no best path");
5632 if (no_advertise)
5633 vty_out (vty, ", not advertised to any peer");
5634 else if (no_export)
5635 vty_out (vty, ", not advertised to EBGP peer");
5636 else if (local_as)
5637 vty_out (vty, ", not advertised outside local AS");
5638 if (suppress)
5639 vty_out (vty, ", Advertisements suppressed by an aggregate.");
5640 vty_out (vty, ")%s", VTY_NEWLINE);
5641
5642 /* advertised peer */
5643 LIST_LOOP (bgp->peer, peer, nn)
5644 {
5645 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
5646 {
5647 if (! first)
5648 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
5649 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
5650 first = 1;
5651 }
5652 }
5653 if (! first)
5654 vty_out (vty, " Not advertised to any peer");
5655 vty_out (vty, "%s", VTY_NEWLINE);
5656}
5657
5658/* Display specified route of BGP table. */
5659int
paulfee0f4c2004-09-13 05:12:46 +00005660bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00005661 struct bgp_table *rib, const char *ip_str,
5662 afi_t afi, safi_t safi, struct prefix_rd *prd,
5663 int prefix_check)
paul718e3742002-12-13 20:15:29 +00005664{
5665 int ret;
5666 int header;
5667 int display = 0;
5668 struct prefix match;
5669 struct bgp_node *rn;
5670 struct bgp_node *rm;
5671 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00005672 struct bgp_table *table;
5673
paul718e3742002-12-13 20:15:29 +00005674 /* Check IP address argument. */
5675 ret = str2prefix (ip_str, &match);
5676 if (! ret)
5677 {
5678 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
5679 return CMD_WARNING;
5680 }
5681
5682 match.family = afi2family (afi);
5683
5684 if (safi == SAFI_MPLS_VPN)
5685 {
paulfee0f4c2004-09-13 05:12:46 +00005686 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00005687 {
5688 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
5689 continue;
5690
5691 if ((table = rn->info) != NULL)
5692 {
5693 header = 1;
5694
5695 if ((rm = bgp_node_match (table, &match)) != NULL)
5696 {
5697 if (prefix_check && rm->p.prefixlen != match.prefixlen)
5698 continue;
5699
5700 for (ri = rm->info; ri; ri = ri->next)
5701 {
5702 if (header)
5703 {
5704 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
5705 AFI_IP, SAFI_MPLS_VPN);
5706
5707 header = 0;
5708 }
5709 display++;
5710 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN);
5711 }
5712 }
5713 }
5714 }
5715 }
5716 else
5717 {
5718 header = 1;
5719
paulfee0f4c2004-09-13 05:12:46 +00005720 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00005721 {
5722 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
5723 {
5724 for (ri = rn->info; ri; ri = ri->next)
5725 {
5726 if (header)
5727 {
5728 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
5729 header = 0;
5730 }
5731 display++;
5732 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
5733 }
5734 }
5735 }
5736 }
5737
5738 if (! display)
5739 {
5740 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
5741 return CMD_WARNING;
5742 }
5743
5744 return CMD_SUCCESS;
5745}
5746
paulfee0f4c2004-09-13 05:12:46 +00005747/* Display specified route of Main RIB */
5748int
paulfd79ac92004-10-13 05:06:08 +00005749bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00005750 afi_t afi, safi_t safi, struct prefix_rd *prd,
5751 int prefix_check)
5752{
5753 struct bgp *bgp;
5754
5755 /* BGP structure lookup. */
5756 if (view_name)
5757 {
5758 bgp = bgp_lookup_by_name (view_name);
5759 if (bgp == NULL)
5760 {
5761 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
5762 return CMD_WARNING;
5763 }
5764 }
5765 else
5766 {
5767 bgp = bgp_get_default ();
5768 if (bgp == NULL)
5769 {
5770 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
5771 return CMD_WARNING;
5772 }
5773 }
5774
5775 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
5776 afi, safi, prd, prefix_check);
5777}
5778
paul718e3742002-12-13 20:15:29 +00005779/* BGP route print out function. */
5780DEFUN (show_ip_bgp,
5781 show_ip_bgp_cmd,
5782 "show ip bgp",
5783 SHOW_STR
5784 IP_STR
5785 BGP_STR)
5786{
ajs5a646652004-11-05 01:25:55 +00005787 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00005788}
5789
5790DEFUN (show_ip_bgp_ipv4,
5791 show_ip_bgp_ipv4_cmd,
5792 "show ip bgp ipv4 (unicast|multicast)",
5793 SHOW_STR
5794 IP_STR
5795 BGP_STR
5796 "Address family\n"
5797 "Address Family modifier\n"
5798 "Address Family modifier\n")
5799{
5800 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00005801 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
5802 NULL);
paul718e3742002-12-13 20:15:29 +00005803
ajs5a646652004-11-05 01:25:55 +00005804 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00005805}
5806
5807DEFUN (show_ip_bgp_route,
5808 show_ip_bgp_route_cmd,
5809 "show ip bgp A.B.C.D",
5810 SHOW_STR
5811 IP_STR
5812 BGP_STR
5813 "Network in the BGP routing table to display\n")
5814{
5815 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
5816}
5817
5818DEFUN (show_ip_bgp_ipv4_route,
5819 show_ip_bgp_ipv4_route_cmd,
5820 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
5821 SHOW_STR
5822 IP_STR
5823 BGP_STR
5824 "Address family\n"
5825 "Address Family modifier\n"
5826 "Address Family modifier\n"
5827 "Network in the BGP routing table to display\n")
5828{
5829 if (strncmp (argv[0], "m", 1) == 0)
5830 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
5831
5832 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
5833}
5834
5835DEFUN (show_ip_bgp_vpnv4_all_route,
5836 show_ip_bgp_vpnv4_all_route_cmd,
5837 "show ip bgp vpnv4 all A.B.C.D",
5838 SHOW_STR
5839 IP_STR
5840 BGP_STR
5841 "Display VPNv4 NLRI specific information\n"
5842 "Display information about all VPNv4 NLRIs\n"
5843 "Network in the BGP routing table to display\n")
5844{
5845 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
5846}
5847
5848DEFUN (show_ip_bgp_vpnv4_rd_route,
5849 show_ip_bgp_vpnv4_rd_route_cmd,
5850 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
5851 SHOW_STR
5852 IP_STR
5853 BGP_STR
5854 "Display VPNv4 NLRI specific information\n"
5855 "Display information for a route distinguisher\n"
5856 "VPN Route Distinguisher\n"
5857 "Network in the BGP routing table to display\n")
5858{
5859 int ret;
5860 struct prefix_rd prd;
5861
5862 ret = str2prefix_rd (argv[0], &prd);
5863 if (! ret)
5864 {
5865 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
5866 return CMD_WARNING;
5867 }
5868 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
5869}
5870
5871DEFUN (show_ip_bgp_prefix,
5872 show_ip_bgp_prefix_cmd,
5873 "show ip bgp A.B.C.D/M",
5874 SHOW_STR
5875 IP_STR
5876 BGP_STR
5877 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5878{
5879 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
5880}
5881
5882DEFUN (show_ip_bgp_ipv4_prefix,
5883 show_ip_bgp_ipv4_prefix_cmd,
5884 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
5885 SHOW_STR
5886 IP_STR
5887 BGP_STR
5888 "Address family\n"
5889 "Address Family modifier\n"
5890 "Address Family modifier\n"
5891 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5892{
5893 if (strncmp (argv[0], "m", 1) == 0)
5894 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
5895
5896 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
5897}
5898
5899DEFUN (show_ip_bgp_vpnv4_all_prefix,
5900 show_ip_bgp_vpnv4_all_prefix_cmd,
5901 "show ip bgp vpnv4 all A.B.C.D/M",
5902 SHOW_STR
5903 IP_STR
5904 BGP_STR
5905 "Display VPNv4 NLRI specific information\n"
5906 "Display information about all VPNv4 NLRIs\n"
5907 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5908{
5909 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
5910}
5911
5912DEFUN (show_ip_bgp_vpnv4_rd_prefix,
5913 show_ip_bgp_vpnv4_rd_prefix_cmd,
5914 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
5915 SHOW_STR
5916 IP_STR
5917 BGP_STR
5918 "Display VPNv4 NLRI specific information\n"
5919 "Display information for a route distinguisher\n"
5920 "VPN Route Distinguisher\n"
5921 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5922{
5923 int ret;
5924 struct prefix_rd prd;
5925
5926 ret = str2prefix_rd (argv[0], &prd);
5927 if (! ret)
5928 {
5929 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
5930 return CMD_WARNING;
5931 }
5932 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
5933}
5934
5935DEFUN (show_ip_bgp_view,
5936 show_ip_bgp_view_cmd,
5937 "show ip bgp view WORD",
5938 SHOW_STR
5939 IP_STR
5940 BGP_STR
5941 "BGP view\n"
5942 "BGP view name\n")
5943{
paulbb46e942003-10-24 19:02:03 +00005944 struct bgp *bgp;
5945
5946 /* BGP structure lookup. */
5947 bgp = bgp_lookup_by_name (argv[0]);
5948 if (bgp == NULL)
5949 {
5950 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
5951 return CMD_WARNING;
5952 }
5953
ajs5a646652004-11-05 01:25:55 +00005954 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00005955}
5956
5957DEFUN (show_ip_bgp_view_route,
5958 show_ip_bgp_view_route_cmd,
5959 "show ip bgp view WORD A.B.C.D",
5960 SHOW_STR
5961 IP_STR
5962 BGP_STR
5963 "BGP view\n"
5964 "BGP view name\n"
5965 "Network in the BGP routing table to display\n")
5966{
5967 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
5968}
5969
5970DEFUN (show_ip_bgp_view_prefix,
5971 show_ip_bgp_view_prefix_cmd,
5972 "show ip bgp view WORD A.B.C.D/M",
5973 SHOW_STR
5974 IP_STR
5975 BGP_STR
5976 "BGP view\n"
5977 "BGP view name\n"
5978 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5979{
5980 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
5981}
5982
5983#ifdef HAVE_IPV6
5984DEFUN (show_bgp,
5985 show_bgp_cmd,
5986 "show bgp",
5987 SHOW_STR
5988 BGP_STR)
5989{
ajs5a646652004-11-05 01:25:55 +00005990 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
5991 NULL);
paul718e3742002-12-13 20:15:29 +00005992}
5993
5994ALIAS (show_bgp,
5995 show_bgp_ipv6_cmd,
5996 "show bgp ipv6",
5997 SHOW_STR
5998 BGP_STR
5999 "Address family\n")
6000
6001/* old command */
6002DEFUN (show_ipv6_bgp,
6003 show_ipv6_bgp_cmd,
6004 "show ipv6 bgp",
6005 SHOW_STR
6006 IP_STR
6007 BGP_STR)
6008{
ajs5a646652004-11-05 01:25:55 +00006009 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
6010 NULL);
paul718e3742002-12-13 20:15:29 +00006011}
6012
6013DEFUN (show_bgp_route,
6014 show_bgp_route_cmd,
6015 "show bgp X:X::X:X",
6016 SHOW_STR
6017 BGP_STR
6018 "Network in the BGP routing table to display\n")
6019{
6020 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
6021}
6022
6023ALIAS (show_bgp_route,
6024 show_bgp_ipv6_route_cmd,
6025 "show bgp ipv6 X:X::X:X",
6026 SHOW_STR
6027 BGP_STR
6028 "Address family\n"
6029 "Network in the BGP routing table to display\n")
6030
6031/* old command */
6032DEFUN (show_ipv6_bgp_route,
6033 show_ipv6_bgp_route_cmd,
6034 "show ipv6 bgp X:X::X:X",
6035 SHOW_STR
6036 IP_STR
6037 BGP_STR
6038 "Network in the BGP routing table to display\n")
6039{
6040 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
6041}
6042
6043DEFUN (show_bgp_prefix,
6044 show_bgp_prefix_cmd,
6045 "show bgp X:X::X:X/M",
6046 SHOW_STR
6047 BGP_STR
6048 "IPv6 prefix <network>/<length>\n")
6049{
6050 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
6051}
6052
6053ALIAS (show_bgp_prefix,
6054 show_bgp_ipv6_prefix_cmd,
6055 "show bgp ipv6 X:X::X:X/M",
6056 SHOW_STR
6057 BGP_STR
6058 "Address family\n"
6059 "IPv6 prefix <network>/<length>\n")
6060
6061/* old command */
6062DEFUN (show_ipv6_bgp_prefix,
6063 show_ipv6_bgp_prefix_cmd,
6064 "show ipv6 bgp X:X::X:X/M",
6065 SHOW_STR
6066 IP_STR
6067 BGP_STR
6068 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6069{
6070 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
6071}
6072
paulbb46e942003-10-24 19:02:03 +00006073DEFUN (show_bgp_view,
6074 show_bgp_view_cmd,
6075 "show bgp view WORD",
6076 SHOW_STR
6077 BGP_STR
6078 "BGP view\n"
6079 "View name\n")
6080{
6081 struct bgp *bgp;
6082
6083 /* BGP structure lookup. */
6084 bgp = bgp_lookup_by_name (argv[0]);
6085 if (bgp == NULL)
6086 {
6087 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
6088 return CMD_WARNING;
6089 }
6090
ajs5a646652004-11-05 01:25:55 +00006091 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00006092}
6093
6094ALIAS (show_bgp_view,
6095 show_bgp_view_ipv6_cmd,
6096 "show bgp view WORD ipv6",
6097 SHOW_STR
6098 BGP_STR
6099 "BGP view\n"
6100 "View name\n"
6101 "Address family\n")
6102
6103DEFUN (show_bgp_view_route,
6104 show_bgp_view_route_cmd,
6105 "show bgp view WORD X:X::X:X",
6106 SHOW_STR
6107 BGP_STR
6108 "BGP view\n"
6109 "View name\n"
6110 "Network in the BGP routing table to display\n")
6111{
6112 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
6113}
6114
6115ALIAS (show_bgp_view_route,
6116 show_bgp_view_ipv6_route_cmd,
6117 "show bgp view WORD ipv6 X:X::X:X",
6118 SHOW_STR
6119 BGP_STR
6120 "BGP view\n"
6121 "View name\n"
6122 "Address family\n"
6123 "Network in the BGP routing table to display\n")
6124
6125DEFUN (show_bgp_view_prefix,
6126 show_bgp_view_prefix_cmd,
6127 "show bgp view WORD X:X::X:X/M",
6128 SHOW_STR
6129 BGP_STR
6130 "BGP view\n"
6131 "View name\n"
6132 "IPv6 prefix <network>/<length>\n")
6133{
6134 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
6135}
6136
6137ALIAS (show_bgp_view_prefix,
6138 show_bgp_view_ipv6_prefix_cmd,
6139 "show bgp view WORD ipv6 X:X::X:X/M",
6140 SHOW_STR
6141 BGP_STR
6142 "BGP view\n"
6143 "View name\n"
6144 "Address family\n"
6145 "IPv6 prefix <network>/<length>\n")
6146
paul718e3742002-12-13 20:15:29 +00006147/* old command */
6148DEFUN (show_ipv6_mbgp,
6149 show_ipv6_mbgp_cmd,
6150 "show ipv6 mbgp",
6151 SHOW_STR
6152 IP_STR
6153 MBGP_STR)
6154{
ajs5a646652004-11-05 01:25:55 +00006155 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
6156 NULL);
paul718e3742002-12-13 20:15:29 +00006157}
6158
6159/* old command */
6160DEFUN (show_ipv6_mbgp_route,
6161 show_ipv6_mbgp_route_cmd,
6162 "show ipv6 mbgp X:X::X:X",
6163 SHOW_STR
6164 IP_STR
6165 MBGP_STR
6166 "Network in the MBGP routing table to display\n")
6167{
6168 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
6169}
6170
6171/* old command */
6172DEFUN (show_ipv6_mbgp_prefix,
6173 show_ipv6_mbgp_prefix_cmd,
6174 "show ipv6 mbgp X:X::X:X/M",
6175 SHOW_STR
6176 IP_STR
6177 MBGP_STR
6178 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6179{
6180 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
6181}
6182#endif
6183
paul718e3742002-12-13 20:15:29 +00006184
6185int
paulfd79ac92004-10-13 05:06:08 +00006186bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006187 safi_t safi, enum bgp_show_type type)
6188{
6189 int i;
6190 struct buffer *b;
6191 char *regstr;
6192 int first;
6193 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00006194 int rc;
paul718e3742002-12-13 20:15:29 +00006195
6196 first = 0;
6197 b = buffer_new (1024);
6198 for (i = 0; i < argc; i++)
6199 {
6200 if (first)
6201 buffer_putc (b, ' ');
6202 else
6203 {
6204 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
6205 continue;
6206 first = 1;
6207 }
6208
6209 buffer_putstr (b, argv[i]);
6210 }
6211 buffer_putc (b, '\0');
6212
6213 regstr = buffer_getstr (b);
6214 buffer_free (b);
6215
6216 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00006217 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00006218 if (! regex)
6219 {
6220 vty_out (vty, "Can't compile regexp %s%s", argv[0],
6221 VTY_NEWLINE);
6222 return CMD_WARNING;
6223 }
6224
ajs5a646652004-11-05 01:25:55 +00006225 rc = bgp_show (vty, NULL, afi, safi, type, regex);
6226 bgp_regex_free (regex);
6227 return rc;
paul718e3742002-12-13 20:15:29 +00006228}
6229
6230DEFUN (show_ip_bgp_regexp,
6231 show_ip_bgp_regexp_cmd,
6232 "show ip bgp regexp .LINE",
6233 SHOW_STR
6234 IP_STR
6235 BGP_STR
6236 "Display routes matching the AS path regular expression\n"
6237 "A regular-expression to match the BGP AS paths\n")
6238{
6239 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
6240 bgp_show_type_regexp);
6241}
6242
6243DEFUN (show_ip_bgp_flap_regexp,
6244 show_ip_bgp_flap_regexp_cmd,
6245 "show ip bgp flap-statistics regexp .LINE",
6246 SHOW_STR
6247 IP_STR
6248 BGP_STR
6249 "Display flap statistics of routes\n"
6250 "Display routes matching the AS path regular expression\n"
6251 "A regular-expression to match the BGP AS paths\n")
6252{
6253 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
6254 bgp_show_type_flap_regexp);
6255}
6256
6257DEFUN (show_ip_bgp_ipv4_regexp,
6258 show_ip_bgp_ipv4_regexp_cmd,
6259 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
6260 SHOW_STR
6261 IP_STR
6262 BGP_STR
6263 "Address family\n"
6264 "Address Family modifier\n"
6265 "Address Family modifier\n"
6266 "Display routes matching the AS path regular expression\n"
6267 "A regular-expression to match the BGP AS paths\n")
6268{
6269 if (strncmp (argv[0], "m", 1) == 0)
6270 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
6271 bgp_show_type_regexp);
6272
6273 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
6274 bgp_show_type_regexp);
6275}
6276
6277#ifdef HAVE_IPV6
6278DEFUN (show_bgp_regexp,
6279 show_bgp_regexp_cmd,
6280 "show bgp regexp .LINE",
6281 SHOW_STR
6282 BGP_STR
6283 "Display routes matching the AS path regular expression\n"
6284 "A regular-expression to match the BGP AS paths\n")
6285{
6286 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
6287 bgp_show_type_regexp);
6288}
6289
6290ALIAS (show_bgp_regexp,
6291 show_bgp_ipv6_regexp_cmd,
6292 "show bgp ipv6 regexp .LINE",
6293 SHOW_STR
6294 BGP_STR
6295 "Address family\n"
6296 "Display routes matching the AS path regular expression\n"
6297 "A regular-expression to match the BGP AS paths\n")
6298
6299/* old command */
6300DEFUN (show_ipv6_bgp_regexp,
6301 show_ipv6_bgp_regexp_cmd,
6302 "show ipv6 bgp regexp .LINE",
6303 SHOW_STR
6304 IP_STR
6305 BGP_STR
6306 "Display routes matching the AS path regular expression\n"
6307 "A regular-expression to match the BGP AS paths\n")
6308{
6309 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
6310 bgp_show_type_regexp);
6311}
6312
6313/* old command */
6314DEFUN (show_ipv6_mbgp_regexp,
6315 show_ipv6_mbgp_regexp_cmd,
6316 "show ipv6 mbgp regexp .LINE",
6317 SHOW_STR
6318 IP_STR
6319 BGP_STR
6320 "Display routes matching the AS path regular expression\n"
6321 "A regular-expression to match the MBGP AS paths\n")
6322{
6323 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
6324 bgp_show_type_regexp);
6325}
6326#endif /* HAVE_IPV6 */
6327
6328int
paulfd79ac92004-10-13 05:06:08 +00006329bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006330 safi_t safi, enum bgp_show_type type)
6331{
6332 struct prefix_list *plist;
6333
6334 plist = prefix_list_lookup (afi, prefix_list_str);
6335 if (plist == NULL)
6336 {
6337 vty_out (vty, "%% %s is not a valid prefix-list name%s",
6338 prefix_list_str, VTY_NEWLINE);
6339 return CMD_WARNING;
6340 }
6341
ajs5a646652004-11-05 01:25:55 +00006342 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00006343}
6344
6345DEFUN (show_ip_bgp_prefix_list,
6346 show_ip_bgp_prefix_list_cmd,
6347 "show ip bgp prefix-list WORD",
6348 SHOW_STR
6349 IP_STR
6350 BGP_STR
6351 "Display routes conforming to the prefix-list\n"
6352 "IP prefix-list name\n")
6353{
6354 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6355 bgp_show_type_prefix_list);
6356}
6357
6358DEFUN (show_ip_bgp_flap_prefix_list,
6359 show_ip_bgp_flap_prefix_list_cmd,
6360 "show ip bgp flap-statistics prefix-list WORD",
6361 SHOW_STR
6362 IP_STR
6363 BGP_STR
6364 "Display flap statistics of routes\n"
6365 "Display routes conforming to the prefix-list\n"
6366 "IP prefix-list name\n")
6367{
6368 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6369 bgp_show_type_flap_prefix_list);
6370}
6371
6372DEFUN (show_ip_bgp_ipv4_prefix_list,
6373 show_ip_bgp_ipv4_prefix_list_cmd,
6374 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
6375 SHOW_STR
6376 IP_STR
6377 BGP_STR
6378 "Address family\n"
6379 "Address Family modifier\n"
6380 "Address Family modifier\n"
6381 "Display routes conforming to the prefix-list\n"
6382 "IP prefix-list name\n")
6383{
6384 if (strncmp (argv[0], "m", 1) == 0)
6385 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
6386 bgp_show_type_prefix_list);
6387
6388 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
6389 bgp_show_type_prefix_list);
6390}
6391
6392#ifdef HAVE_IPV6
6393DEFUN (show_bgp_prefix_list,
6394 show_bgp_prefix_list_cmd,
6395 "show bgp prefix-list WORD",
6396 SHOW_STR
6397 BGP_STR
6398 "Display routes conforming to the prefix-list\n"
6399 "IPv6 prefix-list name\n")
6400{
6401 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6402 bgp_show_type_prefix_list);
6403}
6404
6405ALIAS (show_bgp_prefix_list,
6406 show_bgp_ipv6_prefix_list_cmd,
6407 "show bgp ipv6 prefix-list WORD",
6408 SHOW_STR
6409 BGP_STR
6410 "Address family\n"
6411 "Display routes conforming to the prefix-list\n"
6412 "IPv6 prefix-list name\n")
6413
6414/* old command */
6415DEFUN (show_ipv6_bgp_prefix_list,
6416 show_ipv6_bgp_prefix_list_cmd,
6417 "show ipv6 bgp prefix-list WORD",
6418 SHOW_STR
6419 IPV6_STR
6420 BGP_STR
6421 "Display routes matching the prefix-list\n"
6422 "IPv6 prefix-list name\n")
6423{
6424 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6425 bgp_show_type_prefix_list);
6426}
6427
6428/* old command */
6429DEFUN (show_ipv6_mbgp_prefix_list,
6430 show_ipv6_mbgp_prefix_list_cmd,
6431 "show ipv6 mbgp prefix-list WORD",
6432 SHOW_STR
6433 IPV6_STR
6434 MBGP_STR
6435 "Display routes matching the prefix-list\n"
6436 "IPv6 prefix-list name\n")
6437{
6438 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
6439 bgp_show_type_prefix_list);
6440}
6441#endif /* HAVE_IPV6 */
6442
6443int
paulfd79ac92004-10-13 05:06:08 +00006444bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006445 safi_t safi, enum bgp_show_type type)
6446{
6447 struct as_list *as_list;
6448
6449 as_list = as_list_lookup (filter);
6450 if (as_list == NULL)
6451 {
6452 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
6453 return CMD_WARNING;
6454 }
6455
ajs5a646652004-11-05 01:25:55 +00006456 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00006457}
6458
6459DEFUN (show_ip_bgp_filter_list,
6460 show_ip_bgp_filter_list_cmd,
6461 "show ip bgp filter-list WORD",
6462 SHOW_STR
6463 IP_STR
6464 BGP_STR
6465 "Display routes conforming to the filter-list\n"
6466 "Regular expression access list name\n")
6467{
6468 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6469 bgp_show_type_filter_list);
6470}
6471
6472DEFUN (show_ip_bgp_flap_filter_list,
6473 show_ip_bgp_flap_filter_list_cmd,
6474 "show ip bgp flap-statistics filter-list WORD",
6475 SHOW_STR
6476 IP_STR
6477 BGP_STR
6478 "Display flap statistics of routes\n"
6479 "Display routes conforming to the filter-list\n"
6480 "Regular expression access list name\n")
6481{
6482 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
6483 bgp_show_type_flap_filter_list);
6484}
6485
6486DEFUN (show_ip_bgp_ipv4_filter_list,
6487 show_ip_bgp_ipv4_filter_list_cmd,
6488 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
6489 SHOW_STR
6490 IP_STR
6491 BGP_STR
6492 "Address family\n"
6493 "Address Family modifier\n"
6494 "Address Family modifier\n"
6495 "Display routes conforming to the filter-list\n"
6496 "Regular expression access list name\n")
6497{
6498 if (strncmp (argv[0], "m", 1) == 0)
6499 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
6500 bgp_show_type_filter_list);
6501
6502 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
6503 bgp_show_type_filter_list);
6504}
6505
6506#ifdef HAVE_IPV6
6507DEFUN (show_bgp_filter_list,
6508 show_bgp_filter_list_cmd,
6509 "show bgp filter-list WORD",
6510 SHOW_STR
6511 BGP_STR
6512 "Display routes conforming to the filter-list\n"
6513 "Regular expression access list name\n")
6514{
6515 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6516 bgp_show_type_filter_list);
6517}
6518
6519ALIAS (show_bgp_filter_list,
6520 show_bgp_ipv6_filter_list_cmd,
6521 "show bgp ipv6 filter-list WORD",
6522 SHOW_STR
6523 BGP_STR
6524 "Address family\n"
6525 "Display routes conforming to the filter-list\n"
6526 "Regular expression access list name\n")
6527
6528/* old command */
6529DEFUN (show_ipv6_bgp_filter_list,
6530 show_ipv6_bgp_filter_list_cmd,
6531 "show ipv6 bgp filter-list WORD",
6532 SHOW_STR
6533 IPV6_STR
6534 BGP_STR
6535 "Display routes conforming to the filter-list\n"
6536 "Regular expression access list name\n")
6537{
6538 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6539 bgp_show_type_filter_list);
6540}
6541
6542/* old command */
6543DEFUN (show_ipv6_mbgp_filter_list,
6544 show_ipv6_mbgp_filter_list_cmd,
6545 "show ipv6 mbgp filter-list WORD",
6546 SHOW_STR
6547 IPV6_STR
6548 MBGP_STR
6549 "Display routes conforming to the filter-list\n"
6550 "Regular expression access list name\n")
6551{
6552 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
6553 bgp_show_type_filter_list);
6554}
6555#endif /* HAVE_IPV6 */
6556
6557int
paulfd79ac92004-10-13 05:06:08 +00006558bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00006559 safi_t safi, enum bgp_show_type type)
6560{
6561 struct route_map *rmap;
6562
6563 rmap = route_map_lookup_by_name (rmap_str);
6564 if (! rmap)
6565 {
6566 vty_out (vty, "%% %s is not a valid route-map name%s",
6567 rmap_str, VTY_NEWLINE);
6568 return CMD_WARNING;
6569 }
6570
ajs5a646652004-11-05 01:25:55 +00006571 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00006572}
6573
6574DEFUN (show_ip_bgp_route_map,
6575 show_ip_bgp_route_map_cmd,
6576 "show ip bgp route-map WORD",
6577 SHOW_STR
6578 IP_STR
6579 BGP_STR
6580 "Display routes matching the route-map\n"
6581 "A route-map to match on\n")
6582{
6583 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
6584 bgp_show_type_route_map);
6585}
6586
6587DEFUN (show_ip_bgp_flap_route_map,
6588 show_ip_bgp_flap_route_map_cmd,
6589 "show ip bgp flap-statistics route-map WORD",
6590 SHOW_STR
6591 IP_STR
6592 BGP_STR
6593 "Display flap statistics of routes\n"
6594 "Display routes matching the route-map\n"
6595 "A route-map to match on\n")
6596{
6597 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
6598 bgp_show_type_flap_route_map);
6599}
6600
6601DEFUN (show_ip_bgp_ipv4_route_map,
6602 show_ip_bgp_ipv4_route_map_cmd,
6603 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
6604 SHOW_STR
6605 IP_STR
6606 BGP_STR
6607 "Address family\n"
6608 "Address Family modifier\n"
6609 "Address Family modifier\n"
6610 "Display routes matching the route-map\n"
6611 "A route-map to match on\n")
6612{
6613 if (strncmp (argv[0], "m", 1) == 0)
6614 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
6615 bgp_show_type_route_map);
6616
6617 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
6618 bgp_show_type_route_map);
6619}
6620
6621DEFUN (show_bgp_route_map,
6622 show_bgp_route_map_cmd,
6623 "show bgp route-map WORD",
6624 SHOW_STR
6625 BGP_STR
6626 "Display routes matching the route-map\n"
6627 "A route-map to match on\n")
6628{
6629 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
6630 bgp_show_type_route_map);
6631}
6632
6633ALIAS (show_bgp_route_map,
6634 show_bgp_ipv6_route_map_cmd,
6635 "show bgp ipv6 route-map WORD",
6636 SHOW_STR
6637 BGP_STR
6638 "Address family\n"
6639 "Display routes matching the route-map\n"
6640 "A route-map to match on\n")
6641
6642DEFUN (show_ip_bgp_cidr_only,
6643 show_ip_bgp_cidr_only_cmd,
6644 "show ip bgp cidr-only",
6645 SHOW_STR
6646 IP_STR
6647 BGP_STR
6648 "Display only routes with non-natural netmasks\n")
6649{
6650 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006651 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006652}
6653
6654DEFUN (show_ip_bgp_flap_cidr_only,
6655 show_ip_bgp_flap_cidr_only_cmd,
6656 "show ip bgp flap-statistics cidr-only",
6657 SHOW_STR
6658 IP_STR
6659 BGP_STR
6660 "Display flap statistics of routes\n"
6661 "Display only routes with non-natural netmasks\n")
6662{
6663 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006664 bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006665}
6666
6667DEFUN (show_ip_bgp_ipv4_cidr_only,
6668 show_ip_bgp_ipv4_cidr_only_cmd,
6669 "show ip bgp ipv4 (unicast|multicast) cidr-only",
6670 SHOW_STR
6671 IP_STR
6672 BGP_STR
6673 "Address family\n"
6674 "Address Family modifier\n"
6675 "Address Family modifier\n"
6676 "Display only routes with non-natural netmasks\n")
6677{
6678 if (strncmp (argv[0], "m", 1) == 0)
6679 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00006680 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006681
6682 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006683 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00006684}
6685
6686DEFUN (show_ip_bgp_community_all,
6687 show_ip_bgp_community_all_cmd,
6688 "show ip bgp community",
6689 SHOW_STR
6690 IP_STR
6691 BGP_STR
6692 "Display routes matching the communities\n")
6693{
6694 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006695 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006696}
6697
6698DEFUN (show_ip_bgp_ipv4_community_all,
6699 show_ip_bgp_ipv4_community_all_cmd,
6700 "show ip bgp ipv4 (unicast|multicast) community",
6701 SHOW_STR
6702 IP_STR
6703 BGP_STR
6704 "Address family\n"
6705 "Address Family modifier\n"
6706 "Address Family modifier\n"
6707 "Display routes matching the communities\n")
6708{
6709 if (strncmp (argv[0], "m", 1) == 0)
6710 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00006711 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006712
6713 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006714 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006715}
6716
6717#ifdef HAVE_IPV6
6718DEFUN (show_bgp_community_all,
6719 show_bgp_community_all_cmd,
6720 "show bgp community",
6721 SHOW_STR
6722 BGP_STR
6723 "Display routes matching the communities\n")
6724{
6725 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006726 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006727}
6728
6729ALIAS (show_bgp_community_all,
6730 show_bgp_ipv6_community_all_cmd,
6731 "show bgp ipv6 community",
6732 SHOW_STR
6733 BGP_STR
6734 "Address family\n"
6735 "Display routes matching the communities\n")
6736
6737/* old command */
6738DEFUN (show_ipv6_bgp_community_all,
6739 show_ipv6_bgp_community_all_cmd,
6740 "show ipv6 bgp community",
6741 SHOW_STR
6742 IPV6_STR
6743 BGP_STR
6744 "Display routes matching the communities\n")
6745{
6746 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00006747 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006748}
6749
6750/* old command */
6751DEFUN (show_ipv6_mbgp_community_all,
6752 show_ipv6_mbgp_community_all_cmd,
6753 "show ipv6 mbgp community",
6754 SHOW_STR
6755 IPV6_STR
6756 MBGP_STR
6757 "Display routes matching the communities\n")
6758{
6759 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00006760 bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00006761}
6762#endif /* HAVE_IPV6 */
6763
6764int
paulfd79ac92004-10-13 05:06:08 +00006765bgp_show_community (struct vty *vty, int argc, const char **argv, int exact,
6766 u_int16_t afi, u_char safi)
paul718e3742002-12-13 20:15:29 +00006767{
6768 struct community *com;
6769 struct buffer *b;
6770 int i;
6771 char *str;
6772 int first = 0;
6773
6774 b = buffer_new (1024);
6775 for (i = 0; i < argc; i++)
6776 {
6777 if (first)
6778 buffer_putc (b, ' ');
6779 else
6780 {
6781 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
6782 continue;
6783 first = 1;
6784 }
6785
6786 buffer_putstr (b, argv[i]);
6787 }
6788 buffer_putc (b, '\0');
6789
6790 str = buffer_getstr (b);
6791 buffer_free (b);
6792
6793 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00006794 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00006795 if (! com)
6796 {
6797 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
6798 return CMD_WARNING;
6799 }
6800
ajs5a646652004-11-05 01:25:55 +00006801 return bgp_show (vty, NULL, afi, safi,
6802 (exact ? bgp_show_type_community_exact :
6803 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00006804}
6805
6806DEFUN (show_ip_bgp_community,
6807 show_ip_bgp_community_cmd,
6808 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
6809 SHOW_STR
6810 IP_STR
6811 BGP_STR
6812 "Display routes matching the communities\n"
6813 "community number\n"
6814 "Do not send outside local AS (well-known community)\n"
6815 "Do not advertise to any peer (well-known community)\n"
6816 "Do not export to next AS (well-known community)\n")
6817{
6818 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST);
6819}
6820
6821ALIAS (show_ip_bgp_community,
6822 show_ip_bgp_community2_cmd,
6823 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6824 SHOW_STR
6825 IP_STR
6826 BGP_STR
6827 "Display routes matching the communities\n"
6828 "community number\n"
6829 "Do not send outside local AS (well-known community)\n"
6830 "Do not advertise to any peer (well-known community)\n"
6831 "Do not export to next AS (well-known community)\n"
6832 "community number\n"
6833 "Do not send outside local AS (well-known community)\n"
6834 "Do not advertise to any peer (well-known community)\n"
6835 "Do not export to next AS (well-known community)\n")
6836
6837ALIAS (show_ip_bgp_community,
6838 show_ip_bgp_community3_cmd,
6839 "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)",
6840 SHOW_STR
6841 IP_STR
6842 BGP_STR
6843 "Display routes matching the communities\n"
6844 "community number\n"
6845 "Do not send outside local AS (well-known community)\n"
6846 "Do not advertise to any peer (well-known community)\n"
6847 "Do not export to next AS (well-known community)\n"
6848 "community number\n"
6849 "Do not send outside local AS (well-known community)\n"
6850 "Do not advertise to any peer (well-known community)\n"
6851 "Do not export to next AS (well-known community)\n"
6852 "community number\n"
6853 "Do not send outside local AS (well-known community)\n"
6854 "Do not advertise to any peer (well-known community)\n"
6855 "Do not export to next AS (well-known community)\n")
6856
6857ALIAS (show_ip_bgp_community,
6858 show_ip_bgp_community4_cmd,
6859 "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)",
6860 SHOW_STR
6861 IP_STR
6862 BGP_STR
6863 "Display routes matching the communities\n"
6864 "community number\n"
6865 "Do not send outside local AS (well-known community)\n"
6866 "Do not advertise to any peer (well-known community)\n"
6867 "Do not export to next AS (well-known community)\n"
6868 "community number\n"
6869 "Do not send outside local AS (well-known community)\n"
6870 "Do not advertise to any peer (well-known community)\n"
6871 "Do not export to next AS (well-known community)\n"
6872 "community number\n"
6873 "Do not send outside local AS (well-known community)\n"
6874 "Do not advertise to any peer (well-known community)\n"
6875 "Do not export to next AS (well-known community)\n"
6876 "community number\n"
6877 "Do not send outside local AS (well-known community)\n"
6878 "Do not advertise to any peer (well-known community)\n"
6879 "Do not export to next AS (well-known community)\n")
6880
6881DEFUN (show_ip_bgp_ipv4_community,
6882 show_ip_bgp_ipv4_community_cmd,
6883 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
6884 SHOW_STR
6885 IP_STR
6886 BGP_STR
6887 "Address family\n"
6888 "Address Family modifier\n"
6889 "Address Family modifier\n"
6890 "Display routes matching the communities\n"
6891 "community number\n"
6892 "Do not send outside local AS (well-known community)\n"
6893 "Do not advertise to any peer (well-known community)\n"
6894 "Do not export to next AS (well-known community)\n")
6895{
6896 if (strncmp (argv[0], "m", 1) == 0)
6897 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
6898
6899 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST);
6900}
6901
6902ALIAS (show_ip_bgp_ipv4_community,
6903 show_ip_bgp_ipv4_community2_cmd,
6904 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6905 SHOW_STR
6906 IP_STR
6907 BGP_STR
6908 "Address family\n"
6909 "Address Family modifier\n"
6910 "Address Family modifier\n"
6911 "Display routes matching the communities\n"
6912 "community number\n"
6913 "Do not send outside local AS (well-known community)\n"
6914 "Do not advertise to any peer (well-known community)\n"
6915 "Do not export to next AS (well-known community)\n"
6916 "community number\n"
6917 "Do not send outside local AS (well-known community)\n"
6918 "Do not advertise to any peer (well-known community)\n"
6919 "Do not export to next AS (well-known community)\n")
6920
6921ALIAS (show_ip_bgp_ipv4_community,
6922 show_ip_bgp_ipv4_community3_cmd,
6923 "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)",
6924 SHOW_STR
6925 IP_STR
6926 BGP_STR
6927 "Address family\n"
6928 "Address Family modifier\n"
6929 "Address Family modifier\n"
6930 "Display routes matching the communities\n"
6931 "community number\n"
6932 "Do not send outside local AS (well-known community)\n"
6933 "Do not advertise to any peer (well-known community)\n"
6934 "Do not export to next AS (well-known community)\n"
6935 "community number\n"
6936 "Do not send outside local AS (well-known community)\n"
6937 "Do not advertise to any peer (well-known community)\n"
6938 "Do not export to next AS (well-known community)\n"
6939 "community number\n"
6940 "Do not send outside local AS (well-known community)\n"
6941 "Do not advertise to any peer (well-known community)\n"
6942 "Do not export to next AS (well-known community)\n")
6943
6944ALIAS (show_ip_bgp_ipv4_community,
6945 show_ip_bgp_ipv4_community4_cmd,
6946 "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)",
6947 SHOW_STR
6948 IP_STR
6949 BGP_STR
6950 "Address family\n"
6951 "Address Family modifier\n"
6952 "Address Family modifier\n"
6953 "Display routes matching the communities\n"
6954 "community number\n"
6955 "Do not send outside local AS (well-known community)\n"
6956 "Do not advertise to any peer (well-known community)\n"
6957 "Do not export to next AS (well-known community)\n"
6958 "community number\n"
6959 "Do not send outside local AS (well-known community)\n"
6960 "Do not advertise to any peer (well-known community)\n"
6961 "Do not export to next AS (well-known community)\n"
6962 "community number\n"
6963 "Do not send outside local AS (well-known community)\n"
6964 "Do not advertise to any peer (well-known community)\n"
6965 "Do not export to next AS (well-known community)\n"
6966 "community number\n"
6967 "Do not send outside local AS (well-known community)\n"
6968 "Do not advertise to any peer (well-known community)\n"
6969 "Do not export to next AS (well-known community)\n")
6970
6971DEFUN (show_ip_bgp_community_exact,
6972 show_ip_bgp_community_exact_cmd,
6973 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6974 SHOW_STR
6975 IP_STR
6976 BGP_STR
6977 "Display routes matching the communities\n"
6978 "community number\n"
6979 "Do not send outside local AS (well-known community)\n"
6980 "Do not advertise to any peer (well-known community)\n"
6981 "Do not export to next AS (well-known community)\n"
6982 "Exact match of the communities")
6983{
6984 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST);
6985}
6986
6987ALIAS (show_ip_bgp_community_exact,
6988 show_ip_bgp_community2_exact_cmd,
6989 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6990 SHOW_STR
6991 IP_STR
6992 BGP_STR
6993 "Display routes matching the communities\n"
6994 "community number\n"
6995 "Do not send outside local AS (well-known community)\n"
6996 "Do not advertise to any peer (well-known community)\n"
6997 "Do not export to next AS (well-known community)\n"
6998 "community number\n"
6999 "Do not send outside local AS (well-known community)\n"
7000 "Do not advertise to any peer (well-known community)\n"
7001 "Do not export to next AS (well-known community)\n"
7002 "Exact match of the communities")
7003
7004ALIAS (show_ip_bgp_community_exact,
7005 show_ip_bgp_community3_exact_cmd,
7006 "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",
7007 SHOW_STR
7008 IP_STR
7009 BGP_STR
7010 "Display routes matching the communities\n"
7011 "community number\n"
7012 "Do not send outside local AS (well-known community)\n"
7013 "Do not advertise to any peer (well-known community)\n"
7014 "Do not export to next AS (well-known community)\n"
7015 "community number\n"
7016 "Do not send outside local AS (well-known community)\n"
7017 "Do not advertise to any peer (well-known community)\n"
7018 "Do not export to next AS (well-known community)\n"
7019 "community number\n"
7020 "Do not send outside local AS (well-known community)\n"
7021 "Do not advertise to any peer (well-known community)\n"
7022 "Do not export to next AS (well-known community)\n"
7023 "Exact match of the communities")
7024
7025ALIAS (show_ip_bgp_community_exact,
7026 show_ip_bgp_community4_exact_cmd,
7027 "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",
7028 SHOW_STR
7029 IP_STR
7030 BGP_STR
7031 "Display routes matching the communities\n"
7032 "community number\n"
7033 "Do not send outside local AS (well-known community)\n"
7034 "Do not advertise to any peer (well-known community)\n"
7035 "Do not export to next AS (well-known community)\n"
7036 "community number\n"
7037 "Do not send outside local AS (well-known community)\n"
7038 "Do not advertise to any peer (well-known community)\n"
7039 "Do not export to next AS (well-known community)\n"
7040 "community number\n"
7041 "Do not send outside local AS (well-known community)\n"
7042 "Do not advertise to any peer (well-known community)\n"
7043 "Do not export to next AS (well-known community)\n"
7044 "community number\n"
7045 "Do not send outside local AS (well-known community)\n"
7046 "Do not advertise to any peer (well-known community)\n"
7047 "Do not export to next AS (well-known community)\n"
7048 "Exact match of the communities")
7049
7050DEFUN (show_ip_bgp_ipv4_community_exact,
7051 show_ip_bgp_ipv4_community_exact_cmd,
7052 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7053 SHOW_STR
7054 IP_STR
7055 BGP_STR
7056 "Address family\n"
7057 "Address Family modifier\n"
7058 "Address Family modifier\n"
7059 "Display routes matching the communities\n"
7060 "community number\n"
7061 "Do not send outside local AS (well-known community)\n"
7062 "Do not advertise to any peer (well-known community)\n"
7063 "Do not export to next AS (well-known community)\n"
7064 "Exact match of the communities")
7065{
7066 if (strncmp (argv[0], "m", 1) == 0)
7067 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
7068
7069 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST);
7070}
7071
7072ALIAS (show_ip_bgp_ipv4_community_exact,
7073 show_ip_bgp_ipv4_community2_exact_cmd,
7074 "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",
7075 SHOW_STR
7076 IP_STR
7077 BGP_STR
7078 "Address family\n"
7079 "Address Family modifier\n"
7080 "Address Family modifier\n"
7081 "Display routes matching the communities\n"
7082 "community number\n"
7083 "Do not send outside local AS (well-known community)\n"
7084 "Do not advertise to any peer (well-known community)\n"
7085 "Do not export to next AS (well-known community)\n"
7086 "community number\n"
7087 "Do not send outside local AS (well-known community)\n"
7088 "Do not advertise to any peer (well-known community)\n"
7089 "Do not export to next AS (well-known community)\n"
7090 "Exact match of the communities")
7091
7092ALIAS (show_ip_bgp_ipv4_community_exact,
7093 show_ip_bgp_ipv4_community3_exact_cmd,
7094 "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",
7095 SHOW_STR
7096 IP_STR
7097 BGP_STR
7098 "Address family\n"
7099 "Address Family modifier\n"
7100 "Address Family modifier\n"
7101 "Display routes matching the communities\n"
7102 "community number\n"
7103 "Do not send outside local AS (well-known community)\n"
7104 "Do not advertise to any peer (well-known community)\n"
7105 "Do not export to next AS (well-known community)\n"
7106 "community number\n"
7107 "Do not send outside local AS (well-known community)\n"
7108 "Do not advertise to any peer (well-known community)\n"
7109 "Do not export to next AS (well-known community)\n"
7110 "community number\n"
7111 "Do not send outside local AS (well-known community)\n"
7112 "Do not advertise to any peer (well-known community)\n"
7113 "Do not export to next AS (well-known community)\n"
7114 "Exact match of the communities")
7115
7116ALIAS (show_ip_bgp_ipv4_community_exact,
7117 show_ip_bgp_ipv4_community4_exact_cmd,
7118 "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",
7119 SHOW_STR
7120 IP_STR
7121 BGP_STR
7122 "Address family\n"
7123 "Address Family modifier\n"
7124 "Address Family modifier\n"
7125 "Display routes matching the communities\n"
7126 "community number\n"
7127 "Do not send outside local AS (well-known community)\n"
7128 "Do not advertise to any peer (well-known community)\n"
7129 "Do not export to next AS (well-known community)\n"
7130 "community number\n"
7131 "Do not send outside local AS (well-known community)\n"
7132 "Do not advertise to any peer (well-known community)\n"
7133 "Do not export to next AS (well-known community)\n"
7134 "community number\n"
7135 "Do not send outside local AS (well-known community)\n"
7136 "Do not advertise to any peer (well-known community)\n"
7137 "Do not export to next AS (well-known community)\n"
7138 "community number\n"
7139 "Do not send outside local AS (well-known community)\n"
7140 "Do not advertise to any peer (well-known community)\n"
7141 "Do not export to next AS (well-known community)\n"
7142 "Exact match of the communities")
7143
7144#ifdef HAVE_IPV6
7145DEFUN (show_bgp_community,
7146 show_bgp_community_cmd,
7147 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
7148 SHOW_STR
7149 BGP_STR
7150 "Display routes matching the communities\n"
7151 "community number\n"
7152 "Do not send outside local AS (well-known community)\n"
7153 "Do not advertise to any peer (well-known community)\n"
7154 "Do not export to next AS (well-known community)\n")
7155{
7156 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
7157}
7158
7159ALIAS (show_bgp_community,
7160 show_bgp_ipv6_community_cmd,
7161 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
7162 SHOW_STR
7163 BGP_STR
7164 "Address family\n"
7165 "Display routes matching the communities\n"
7166 "community number\n"
7167 "Do not send outside local AS (well-known community)\n"
7168 "Do not advertise to any peer (well-known community)\n"
7169 "Do not export to next AS (well-known community)\n")
7170
7171ALIAS (show_bgp_community,
7172 show_bgp_community2_cmd,
7173 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7174 SHOW_STR
7175 BGP_STR
7176 "Display routes matching the communities\n"
7177 "community number\n"
7178 "Do not send outside local AS (well-known community)\n"
7179 "Do not advertise to any peer (well-known community)\n"
7180 "Do not export to next AS (well-known community)\n"
7181 "community number\n"
7182 "Do not send outside local AS (well-known community)\n"
7183 "Do not advertise to any peer (well-known community)\n"
7184 "Do not export to next AS (well-known community)\n")
7185
7186ALIAS (show_bgp_community,
7187 show_bgp_ipv6_community2_cmd,
7188 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7189 SHOW_STR
7190 BGP_STR
7191 "Address family\n"
7192 "Display routes matching the communities\n"
7193 "community number\n"
7194 "Do not send outside local AS (well-known community)\n"
7195 "Do not advertise to any peer (well-known community)\n"
7196 "Do not export to next AS (well-known community)\n"
7197 "community number\n"
7198 "Do not send outside local AS (well-known community)\n"
7199 "Do not advertise to any peer (well-known community)\n"
7200 "Do not export to next AS (well-known community)\n")
7201
7202ALIAS (show_bgp_community,
7203 show_bgp_community3_cmd,
7204 "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)",
7205 SHOW_STR
7206 BGP_STR
7207 "Display routes matching the communities\n"
7208 "community number\n"
7209 "Do not send outside local AS (well-known community)\n"
7210 "Do not advertise to any peer (well-known community)\n"
7211 "Do not export to next AS (well-known community)\n"
7212 "community number\n"
7213 "Do not send outside local AS (well-known community)\n"
7214 "Do not advertise to any peer (well-known community)\n"
7215 "Do not export to next AS (well-known community)\n"
7216 "community number\n"
7217 "Do not send outside local AS (well-known community)\n"
7218 "Do not advertise to any peer (well-known community)\n"
7219 "Do not export to next AS (well-known community)\n")
7220
7221ALIAS (show_bgp_community,
7222 show_bgp_ipv6_community3_cmd,
7223 "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)",
7224 SHOW_STR
7225 BGP_STR
7226 "Address family\n"
7227 "Display routes matching the communities\n"
7228 "community number\n"
7229 "Do not send outside local AS (well-known community)\n"
7230 "Do not advertise to any peer (well-known community)\n"
7231 "Do not export to next AS (well-known community)\n"
7232 "community number\n"
7233 "Do not send outside local AS (well-known community)\n"
7234 "Do not advertise to any peer (well-known community)\n"
7235 "Do not export to next AS (well-known community)\n"
7236 "community number\n"
7237 "Do not send outside local AS (well-known community)\n"
7238 "Do not advertise to any peer (well-known community)\n"
7239 "Do not export to next AS (well-known community)\n")
7240
7241ALIAS (show_bgp_community,
7242 show_bgp_community4_cmd,
7243 "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)",
7244 SHOW_STR
7245 BGP_STR
7246 "Display routes matching the communities\n"
7247 "community number\n"
7248 "Do not send outside local AS (well-known community)\n"
7249 "Do not advertise to any peer (well-known community)\n"
7250 "Do not export to next AS (well-known community)\n"
7251 "community number\n"
7252 "Do not send outside local AS (well-known community)\n"
7253 "Do not advertise to any peer (well-known community)\n"
7254 "Do not export to next AS (well-known community)\n"
7255 "community number\n"
7256 "Do not send outside local AS (well-known community)\n"
7257 "Do not advertise to any peer (well-known community)\n"
7258 "Do not export to next AS (well-known community)\n"
7259 "community number\n"
7260 "Do not send outside local AS (well-known community)\n"
7261 "Do not advertise to any peer (well-known community)\n"
7262 "Do not export to next AS (well-known community)\n")
7263
7264ALIAS (show_bgp_community,
7265 show_bgp_ipv6_community4_cmd,
7266 "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)",
7267 SHOW_STR
7268 BGP_STR
7269 "Address family\n"
7270 "Display routes matching the communities\n"
7271 "community number\n"
7272 "Do not send outside local AS (well-known community)\n"
7273 "Do not advertise to any peer (well-known community)\n"
7274 "Do not export to next AS (well-known community)\n"
7275 "community number\n"
7276 "Do not send outside local AS (well-known community)\n"
7277 "Do not advertise to any peer (well-known community)\n"
7278 "Do not export to next AS (well-known community)\n"
7279 "community number\n"
7280 "Do not send outside local AS (well-known community)\n"
7281 "Do not advertise to any peer (well-known community)\n"
7282 "Do not export to next AS (well-known community)\n"
7283 "community number\n"
7284 "Do not send outside local AS (well-known community)\n"
7285 "Do not advertise to any peer (well-known community)\n"
7286 "Do not export to next AS (well-known community)\n")
7287
7288/* old command */
7289DEFUN (show_ipv6_bgp_community,
7290 show_ipv6_bgp_community_cmd,
7291 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
7292 SHOW_STR
7293 IPV6_STR
7294 BGP_STR
7295 "Display routes matching the communities\n"
7296 "community number\n"
7297 "Do not send outside local AS (well-known community)\n"
7298 "Do not advertise to any peer (well-known community)\n"
7299 "Do not export to next AS (well-known community)\n")
7300{
7301 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
7302}
7303
7304/* old command */
7305ALIAS (show_ipv6_bgp_community,
7306 show_ipv6_bgp_community2_cmd,
7307 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7308 SHOW_STR
7309 IPV6_STR
7310 BGP_STR
7311 "Display routes matching the communities\n"
7312 "community number\n"
7313 "Do not send outside local AS (well-known community)\n"
7314 "Do not advertise to any peer (well-known community)\n"
7315 "Do not export to next AS (well-known community)\n"
7316 "community number\n"
7317 "Do not send outside local AS (well-known community)\n"
7318 "Do not advertise to any peer (well-known community)\n"
7319 "Do not export to next AS (well-known community)\n")
7320
7321/* old command */
7322ALIAS (show_ipv6_bgp_community,
7323 show_ipv6_bgp_community3_cmd,
7324 "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)",
7325 SHOW_STR
7326 IPV6_STR
7327 BGP_STR
7328 "Display routes matching the communities\n"
7329 "community number\n"
7330 "Do not send outside local AS (well-known community)\n"
7331 "Do not advertise to any peer (well-known community)\n"
7332 "Do not export to next AS (well-known community)\n"
7333 "community number\n"
7334 "Do not send outside local AS (well-known community)\n"
7335 "Do not advertise to any peer (well-known community)\n"
7336 "Do not export to next AS (well-known community)\n"
7337 "community number\n"
7338 "Do not send outside local AS (well-known community)\n"
7339 "Do not advertise to any peer (well-known community)\n"
7340 "Do not export to next AS (well-known community)\n")
7341
7342/* old command */
7343ALIAS (show_ipv6_bgp_community,
7344 show_ipv6_bgp_community4_cmd,
7345 "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)",
7346 SHOW_STR
7347 IPV6_STR
7348 BGP_STR
7349 "Display routes matching the communities\n"
7350 "community number\n"
7351 "Do not send outside local AS (well-known community)\n"
7352 "Do not advertise to any peer (well-known community)\n"
7353 "Do not export to next AS (well-known community)\n"
7354 "community number\n"
7355 "Do not send outside local AS (well-known community)\n"
7356 "Do not advertise to any peer (well-known community)\n"
7357 "Do not export to next AS (well-known community)\n"
7358 "community number\n"
7359 "Do not send outside local AS (well-known community)\n"
7360 "Do not advertise to any peer (well-known community)\n"
7361 "Do not export to next AS (well-known community)\n"
7362 "community number\n"
7363 "Do not send outside local AS (well-known community)\n"
7364 "Do not advertise to any peer (well-known community)\n"
7365 "Do not export to next AS (well-known community)\n")
7366
7367DEFUN (show_bgp_community_exact,
7368 show_bgp_community_exact_cmd,
7369 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7370 SHOW_STR
7371 BGP_STR
7372 "Display routes matching the communities\n"
7373 "community number\n"
7374 "Do not send outside local AS (well-known community)\n"
7375 "Do not advertise to any peer (well-known community)\n"
7376 "Do not export to next AS (well-known community)\n"
7377 "Exact match of the communities")
7378{
7379 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
7380}
7381
7382ALIAS (show_bgp_community_exact,
7383 show_bgp_ipv6_community_exact_cmd,
7384 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7385 SHOW_STR
7386 BGP_STR
7387 "Address family\n"
7388 "Display routes matching the communities\n"
7389 "community number\n"
7390 "Do not send outside local AS (well-known community)\n"
7391 "Do not advertise to any peer (well-known community)\n"
7392 "Do not export to next AS (well-known community)\n"
7393 "Exact match of the communities")
7394
7395ALIAS (show_bgp_community_exact,
7396 show_bgp_community2_exact_cmd,
7397 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7398 SHOW_STR
7399 BGP_STR
7400 "Display routes matching the communities\n"
7401 "community number\n"
7402 "Do not send outside local AS (well-known community)\n"
7403 "Do not advertise to any peer (well-known community)\n"
7404 "Do not export to next AS (well-known community)\n"
7405 "community number\n"
7406 "Do not send outside local AS (well-known community)\n"
7407 "Do not advertise to any peer (well-known community)\n"
7408 "Do not export to next AS (well-known community)\n"
7409 "Exact match of the communities")
7410
7411ALIAS (show_bgp_community_exact,
7412 show_bgp_ipv6_community2_exact_cmd,
7413 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7414 SHOW_STR
7415 BGP_STR
7416 "Address family\n"
7417 "Display routes matching the communities\n"
7418 "community number\n"
7419 "Do not send outside local AS (well-known community)\n"
7420 "Do not advertise to any peer (well-known community)\n"
7421 "Do not export to next AS (well-known community)\n"
7422 "community number\n"
7423 "Do not send outside local AS (well-known community)\n"
7424 "Do not advertise to any peer (well-known community)\n"
7425 "Do not export to next AS (well-known community)\n"
7426 "Exact match of the communities")
7427
7428ALIAS (show_bgp_community_exact,
7429 show_bgp_community3_exact_cmd,
7430 "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",
7431 SHOW_STR
7432 BGP_STR
7433 "Display routes matching the communities\n"
7434 "community number\n"
7435 "Do not send outside local AS (well-known community)\n"
7436 "Do not advertise to any peer (well-known community)\n"
7437 "Do not export to next AS (well-known community)\n"
7438 "community number\n"
7439 "Do not send outside local AS (well-known community)\n"
7440 "Do not advertise to any peer (well-known community)\n"
7441 "Do not export to next AS (well-known community)\n"
7442 "community number\n"
7443 "Do not send outside local AS (well-known community)\n"
7444 "Do not advertise to any peer (well-known community)\n"
7445 "Do not export to next AS (well-known community)\n"
7446 "Exact match of the communities")
7447
7448ALIAS (show_bgp_community_exact,
7449 show_bgp_ipv6_community3_exact_cmd,
7450 "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",
7451 SHOW_STR
7452 BGP_STR
7453 "Address family\n"
7454 "Display routes matching the communities\n"
7455 "community number\n"
7456 "Do not send outside local AS (well-known community)\n"
7457 "Do not advertise to any peer (well-known community)\n"
7458 "Do not export to next AS (well-known community)\n"
7459 "community number\n"
7460 "Do not send outside local AS (well-known community)\n"
7461 "Do not advertise to any peer (well-known community)\n"
7462 "Do not export to next AS (well-known community)\n"
7463 "community number\n"
7464 "Do not send outside local AS (well-known community)\n"
7465 "Do not advertise to any peer (well-known community)\n"
7466 "Do not export to next AS (well-known community)\n"
7467 "Exact match of the communities")
7468
7469ALIAS (show_bgp_community_exact,
7470 show_bgp_community4_exact_cmd,
7471 "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",
7472 SHOW_STR
7473 BGP_STR
7474 "Display routes matching the communities\n"
7475 "community number\n"
7476 "Do not send outside local AS (well-known community)\n"
7477 "Do not advertise to any peer (well-known community)\n"
7478 "Do not export to next AS (well-known community)\n"
7479 "community number\n"
7480 "Do not send outside local AS (well-known community)\n"
7481 "Do not advertise to any peer (well-known community)\n"
7482 "Do not export to next AS (well-known community)\n"
7483 "community number\n"
7484 "Do not send outside local AS (well-known community)\n"
7485 "Do not advertise to any peer (well-known community)\n"
7486 "Do not export to next AS (well-known community)\n"
7487 "community number\n"
7488 "Do not send outside local AS (well-known community)\n"
7489 "Do not advertise to any peer (well-known community)\n"
7490 "Do not export to next AS (well-known community)\n"
7491 "Exact match of the communities")
7492
7493ALIAS (show_bgp_community_exact,
7494 show_bgp_ipv6_community4_exact_cmd,
7495 "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",
7496 SHOW_STR
7497 BGP_STR
7498 "Address family\n"
7499 "Display routes matching the communities\n"
7500 "community number\n"
7501 "Do not send outside local AS (well-known community)\n"
7502 "Do not advertise to any peer (well-known community)\n"
7503 "Do not export to next AS (well-known community)\n"
7504 "community number\n"
7505 "Do not send outside local AS (well-known community)\n"
7506 "Do not advertise to any peer (well-known community)\n"
7507 "Do not export to next AS (well-known community)\n"
7508 "community number\n"
7509 "Do not send outside local AS (well-known community)\n"
7510 "Do not advertise to any peer (well-known community)\n"
7511 "Do not export to next AS (well-known community)\n"
7512 "community number\n"
7513 "Do not send outside local AS (well-known community)\n"
7514 "Do not advertise to any peer (well-known community)\n"
7515 "Do not export to next AS (well-known community)\n"
7516 "Exact match of the communities")
7517
7518/* old command */
7519DEFUN (show_ipv6_bgp_community_exact,
7520 show_ipv6_bgp_community_exact_cmd,
7521 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7522 SHOW_STR
7523 IPV6_STR
7524 BGP_STR
7525 "Display routes matching the communities\n"
7526 "community number\n"
7527 "Do not send outside local AS (well-known community)\n"
7528 "Do not advertise to any peer (well-known community)\n"
7529 "Do not export to next AS (well-known community)\n"
7530 "Exact match of the communities")
7531{
7532 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
7533}
7534
7535/* old command */
7536ALIAS (show_ipv6_bgp_community_exact,
7537 show_ipv6_bgp_community2_exact_cmd,
7538 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7539 SHOW_STR
7540 IPV6_STR
7541 BGP_STR
7542 "Display routes matching the communities\n"
7543 "community number\n"
7544 "Do not send outside local AS (well-known community)\n"
7545 "Do not advertise to any peer (well-known community)\n"
7546 "Do not export to next AS (well-known community)\n"
7547 "community number\n"
7548 "Do not send outside local AS (well-known community)\n"
7549 "Do not advertise to any peer (well-known community)\n"
7550 "Do not export to next AS (well-known community)\n"
7551 "Exact match of the communities")
7552
7553/* old command */
7554ALIAS (show_ipv6_bgp_community_exact,
7555 show_ipv6_bgp_community3_exact_cmd,
7556 "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",
7557 SHOW_STR
7558 IPV6_STR
7559 BGP_STR
7560 "Display routes matching the communities\n"
7561 "community number\n"
7562 "Do not send outside local AS (well-known community)\n"
7563 "Do not advertise to any peer (well-known community)\n"
7564 "Do not export to next AS (well-known community)\n"
7565 "community number\n"
7566 "Do not send outside local AS (well-known community)\n"
7567 "Do not advertise to any peer (well-known community)\n"
7568 "Do not export to next AS (well-known community)\n"
7569 "community number\n"
7570 "Do not send outside local AS (well-known community)\n"
7571 "Do not advertise to any peer (well-known community)\n"
7572 "Do not export to next AS (well-known community)\n"
7573 "Exact match of the communities")
7574
7575/* old command */
7576ALIAS (show_ipv6_bgp_community_exact,
7577 show_ipv6_bgp_community4_exact_cmd,
7578 "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",
7579 SHOW_STR
7580 IPV6_STR
7581 BGP_STR
7582 "Display routes matching the communities\n"
7583 "community number\n"
7584 "Do not send outside local AS (well-known community)\n"
7585 "Do not advertise to any peer (well-known community)\n"
7586 "Do not export to next AS (well-known community)\n"
7587 "community number\n"
7588 "Do not send outside local AS (well-known community)\n"
7589 "Do not advertise to any peer (well-known community)\n"
7590 "Do not export to next AS (well-known community)\n"
7591 "community number\n"
7592 "Do not send outside local AS (well-known community)\n"
7593 "Do not advertise to any peer (well-known community)\n"
7594 "Do not export to next AS (well-known community)\n"
7595 "community number\n"
7596 "Do not send outside local AS (well-known community)\n"
7597 "Do not advertise to any peer (well-known community)\n"
7598 "Do not export to next AS (well-known community)\n"
7599 "Exact match of the communities")
7600
7601/* old command */
7602DEFUN (show_ipv6_mbgp_community,
7603 show_ipv6_mbgp_community_cmd,
7604 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
7605 SHOW_STR
7606 IPV6_STR
7607 MBGP_STR
7608 "Display routes matching the communities\n"
7609 "community number\n"
7610 "Do not send outside local AS (well-known community)\n"
7611 "Do not advertise to any peer (well-known community)\n"
7612 "Do not export to next AS (well-known community)\n")
7613{
7614 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
7615}
7616
7617/* old command */
7618ALIAS (show_ipv6_mbgp_community,
7619 show_ipv6_mbgp_community2_cmd,
7620 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7621 SHOW_STR
7622 IPV6_STR
7623 MBGP_STR
7624 "Display routes matching the communities\n"
7625 "community number\n"
7626 "Do not send outside local AS (well-known community)\n"
7627 "Do not advertise to any peer (well-known community)\n"
7628 "Do not export to next AS (well-known community)\n"
7629 "community number\n"
7630 "Do not send outside local AS (well-known community)\n"
7631 "Do not advertise to any peer (well-known community)\n"
7632 "Do not export to next AS (well-known community)\n")
7633
7634/* old command */
7635ALIAS (show_ipv6_mbgp_community,
7636 show_ipv6_mbgp_community3_cmd,
7637 "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)",
7638 SHOW_STR
7639 IPV6_STR
7640 MBGP_STR
7641 "Display routes matching the communities\n"
7642 "community number\n"
7643 "Do not send outside local AS (well-known community)\n"
7644 "Do not advertise to any peer (well-known community)\n"
7645 "Do not export to next AS (well-known community)\n"
7646 "community number\n"
7647 "Do not send outside local AS (well-known community)\n"
7648 "Do not advertise to any peer (well-known community)\n"
7649 "Do not export to next AS (well-known community)\n"
7650 "community number\n"
7651 "Do not send outside local AS (well-known community)\n"
7652 "Do not advertise to any peer (well-known community)\n"
7653 "Do not export to next AS (well-known community)\n")
7654
7655/* old command */
7656ALIAS (show_ipv6_mbgp_community,
7657 show_ipv6_mbgp_community4_cmd,
7658 "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)",
7659 SHOW_STR
7660 IPV6_STR
7661 MBGP_STR
7662 "Display routes matching the communities\n"
7663 "community number\n"
7664 "Do not send outside local AS (well-known community)\n"
7665 "Do not advertise to any peer (well-known community)\n"
7666 "Do not export to next AS (well-known community)\n"
7667 "community number\n"
7668 "Do not send outside local AS (well-known community)\n"
7669 "Do not advertise to any peer (well-known community)\n"
7670 "Do not export to next AS (well-known community)\n"
7671 "community number\n"
7672 "Do not send outside local AS (well-known community)\n"
7673 "Do not advertise to any peer (well-known community)\n"
7674 "Do not export to next AS (well-known community)\n"
7675 "community number\n"
7676 "Do not send outside local AS (well-known community)\n"
7677 "Do not advertise to any peer (well-known community)\n"
7678 "Do not export to next AS (well-known community)\n")
7679
7680/* old command */
7681DEFUN (show_ipv6_mbgp_community_exact,
7682 show_ipv6_mbgp_community_exact_cmd,
7683 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7684 SHOW_STR
7685 IPV6_STR
7686 MBGP_STR
7687 "Display routes matching the communities\n"
7688 "community number\n"
7689 "Do not send outside local AS (well-known community)\n"
7690 "Do not advertise to any peer (well-known community)\n"
7691 "Do not export to next AS (well-known community)\n"
7692 "Exact match of the communities")
7693{
7694 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
7695}
7696
7697/* old command */
7698ALIAS (show_ipv6_mbgp_community_exact,
7699 show_ipv6_mbgp_community2_exact_cmd,
7700 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7701 SHOW_STR
7702 IPV6_STR
7703 MBGP_STR
7704 "Display routes matching the communities\n"
7705 "community number\n"
7706 "Do not send outside local AS (well-known community)\n"
7707 "Do not advertise to any peer (well-known community)\n"
7708 "Do not export to next AS (well-known community)\n"
7709 "community number\n"
7710 "Do not send outside local AS (well-known community)\n"
7711 "Do not advertise to any peer (well-known community)\n"
7712 "Do not export to next AS (well-known community)\n"
7713 "Exact match of the communities")
7714
7715/* old command */
7716ALIAS (show_ipv6_mbgp_community_exact,
7717 show_ipv6_mbgp_community3_exact_cmd,
7718 "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",
7719 SHOW_STR
7720 IPV6_STR
7721 MBGP_STR
7722 "Display routes matching the communities\n"
7723 "community number\n"
7724 "Do not send outside local AS (well-known community)\n"
7725 "Do not advertise to any peer (well-known community)\n"
7726 "Do not export to next AS (well-known community)\n"
7727 "community number\n"
7728 "Do not send outside local AS (well-known community)\n"
7729 "Do not advertise to any peer (well-known community)\n"
7730 "Do not export to next AS (well-known community)\n"
7731 "community number\n"
7732 "Do not send outside local AS (well-known community)\n"
7733 "Do not advertise to any peer (well-known community)\n"
7734 "Do not export to next AS (well-known community)\n"
7735 "Exact match of the communities")
7736
7737/* old command */
7738ALIAS (show_ipv6_mbgp_community_exact,
7739 show_ipv6_mbgp_community4_exact_cmd,
7740 "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",
7741 SHOW_STR
7742 IPV6_STR
7743 MBGP_STR
7744 "Display routes matching the communities\n"
7745 "community number\n"
7746 "Do not send outside local AS (well-known community)\n"
7747 "Do not advertise to any peer (well-known community)\n"
7748 "Do not export to next AS (well-known community)\n"
7749 "community number\n"
7750 "Do not send outside local AS (well-known community)\n"
7751 "Do not advertise to any peer (well-known community)\n"
7752 "Do not export to next AS (well-known community)\n"
7753 "community number\n"
7754 "Do not send outside local AS (well-known community)\n"
7755 "Do not advertise to any peer (well-known community)\n"
7756 "Do not export to next AS (well-known community)\n"
7757 "community number\n"
7758 "Do not send outside local AS (well-known community)\n"
7759 "Do not advertise to any peer (well-known community)\n"
7760 "Do not export to next AS (well-known community)\n"
7761 "Exact match of the communities")
7762#endif /* HAVE_IPV6 */
7763
7764int
paulfd79ac92004-10-13 05:06:08 +00007765bgp_show_community_list (struct vty *vty, const char *com, int exact,
paul718e3742002-12-13 20:15:29 +00007766 u_int16_t afi, u_char safi)
7767{
7768 struct community_list *list;
7769
hassofee6e4e2005-02-02 16:29:31 +00007770 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +00007771 if (list == NULL)
7772 {
7773 vty_out (vty, "%% %s is not a valid community-list name%s", com,
7774 VTY_NEWLINE);
7775 return CMD_WARNING;
7776 }
7777
ajs5a646652004-11-05 01:25:55 +00007778 return bgp_show (vty, NULL, afi, safi,
7779 (exact ? bgp_show_type_community_list_exact :
7780 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +00007781}
7782
7783DEFUN (show_ip_bgp_community_list,
7784 show_ip_bgp_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007785 "show ip bgp community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007786 SHOW_STR
7787 IP_STR
7788 BGP_STR
7789 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007790 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007791 "community-list name\n")
7792{
7793 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
7794}
7795
7796DEFUN (show_ip_bgp_ipv4_community_list,
7797 show_ip_bgp_ipv4_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007798 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007799 SHOW_STR
7800 IP_STR
7801 BGP_STR
7802 "Address family\n"
7803 "Address Family modifier\n"
7804 "Address Family modifier\n"
7805 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007806 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007807 "community-list name\n")
7808{
7809 if (strncmp (argv[0], "m", 1) == 0)
7810 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
7811
7812 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
7813}
7814
7815DEFUN (show_ip_bgp_community_list_exact,
7816 show_ip_bgp_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007817 "show ip bgp community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007818 SHOW_STR
7819 IP_STR
7820 BGP_STR
7821 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007822 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007823 "community-list name\n"
7824 "Exact match of the communities\n")
7825{
7826 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
7827}
7828
7829DEFUN (show_ip_bgp_ipv4_community_list_exact,
7830 show_ip_bgp_ipv4_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007831 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007832 SHOW_STR
7833 IP_STR
7834 BGP_STR
7835 "Address family\n"
7836 "Address Family modifier\n"
7837 "Address Family modifier\n"
7838 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007839 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007840 "community-list name\n"
7841 "Exact match of the communities\n")
7842{
7843 if (strncmp (argv[0], "m", 1) == 0)
7844 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
7845
7846 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
7847}
7848
7849#ifdef HAVE_IPV6
7850DEFUN (show_bgp_community_list,
7851 show_bgp_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007852 "show bgp community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007853 SHOW_STR
7854 BGP_STR
7855 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007856 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007857 "community-list name\n")
7858{
7859 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
7860}
7861
7862ALIAS (show_bgp_community_list,
7863 show_bgp_ipv6_community_list_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007864 "show bgp ipv6 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +00007865 SHOW_STR
7866 BGP_STR
7867 "Address family\n"
7868 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007869 "community-list number\n"
7870 "community-list name\n");
paul718e3742002-12-13 20:15:29 +00007871
7872/* old command */
7873DEFUN (show_ipv6_bgp_community_list,
7874 show_ipv6_bgp_community_list_cmd,
7875 "show ipv6 bgp community-list WORD",
7876 SHOW_STR
7877 IPV6_STR
7878 BGP_STR
7879 "Display routes matching the community-list\n"
7880 "community-list name\n")
7881{
7882 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
7883}
7884
7885/* old command */
7886DEFUN (show_ipv6_mbgp_community_list,
7887 show_ipv6_mbgp_community_list_cmd,
7888 "show ipv6 mbgp community-list WORD",
7889 SHOW_STR
7890 IPV6_STR
7891 MBGP_STR
7892 "Display routes matching the community-list\n"
7893 "community-list name\n")
7894{
7895 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
7896}
7897
7898DEFUN (show_bgp_community_list_exact,
7899 show_bgp_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007900 "show bgp community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007901 SHOW_STR
7902 BGP_STR
7903 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007904 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007905 "community-list name\n"
7906 "Exact match of the communities\n")
7907{
7908 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
7909}
7910
7911ALIAS (show_bgp_community_list_exact,
7912 show_bgp_ipv6_community_list_exact_cmd,
hassofee6e4e2005-02-02 16:29:31 +00007913 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +00007914 SHOW_STR
7915 BGP_STR
7916 "Address family\n"
7917 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +00007918 "community-list number\n"
paul718e3742002-12-13 20:15:29 +00007919 "community-list name\n"
7920 "Exact match of the communities\n")
7921
7922/* old command */
7923DEFUN (show_ipv6_bgp_community_list_exact,
7924 show_ipv6_bgp_community_list_exact_cmd,
7925 "show ipv6 bgp community-list WORD exact-match",
7926 SHOW_STR
7927 IPV6_STR
7928 BGP_STR
7929 "Display routes matching the community-list\n"
7930 "community-list name\n"
7931 "Exact match of the communities\n")
7932{
7933 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
7934}
7935
7936/* old command */
7937DEFUN (show_ipv6_mbgp_community_list_exact,
7938 show_ipv6_mbgp_community_list_exact_cmd,
7939 "show ipv6 mbgp community-list WORD exact-match",
7940 SHOW_STR
7941 IPV6_STR
7942 MBGP_STR
7943 "Display routes matching the community-list\n"
7944 "community-list name\n"
7945 "Exact match of the communities\n")
7946{
7947 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
7948}
7949#endif /* HAVE_IPV6 */
7950
paul718e3742002-12-13 20:15:29 +00007951int
paulfd79ac92004-10-13 05:06:08 +00007952bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +00007953 safi_t safi, enum bgp_show_type type)
7954{
7955 int ret;
7956 struct prefix *p;
7957
7958 p = prefix_new();
7959
7960 ret = str2prefix (prefix, p);
7961 if (! ret)
7962 {
7963 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
7964 return CMD_WARNING;
7965 }
7966
ajs5a646652004-11-05 01:25:55 +00007967 ret = bgp_show (vty, NULL, afi, safi, type, p);
7968 prefix_free(p);
7969 return ret;
paul718e3742002-12-13 20:15:29 +00007970}
7971
7972DEFUN (show_ip_bgp_prefix_longer,
7973 show_ip_bgp_prefix_longer_cmd,
7974 "show ip bgp A.B.C.D/M longer-prefixes",
7975 SHOW_STR
7976 IP_STR
7977 BGP_STR
7978 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7979 "Display route and more specific routes\n")
7980{
7981 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
7982 bgp_show_type_prefix_longer);
7983}
7984
7985DEFUN (show_ip_bgp_flap_prefix_longer,
7986 show_ip_bgp_flap_prefix_longer_cmd,
7987 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
7988 SHOW_STR
7989 IP_STR
7990 BGP_STR
7991 "Display flap statistics of routes\n"
7992 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7993 "Display route and more specific routes\n")
7994{
7995 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
7996 bgp_show_type_flap_prefix_longer);
7997}
7998
7999DEFUN (show_ip_bgp_ipv4_prefix_longer,
8000 show_ip_bgp_ipv4_prefix_longer_cmd,
8001 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8002 SHOW_STR
8003 IP_STR
8004 BGP_STR
8005 "Address family\n"
8006 "Address Family modifier\n"
8007 "Address Family modifier\n"
8008 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8009 "Display route and more specific routes\n")
8010{
8011 if (strncmp (argv[0], "m", 1) == 0)
8012 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8013 bgp_show_type_prefix_longer);
8014
8015 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
8016 bgp_show_type_prefix_longer);
8017}
8018
8019DEFUN (show_ip_bgp_flap_address,
8020 show_ip_bgp_flap_address_cmd,
8021 "show ip bgp flap-statistics A.B.C.D",
8022 SHOW_STR
8023 IP_STR
8024 BGP_STR
8025 "Display flap statistics of routes\n"
8026 "Network in the BGP routing table to display\n")
8027{
8028 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
8029 bgp_show_type_flap_address);
8030}
8031
8032DEFUN (show_ip_bgp_flap_prefix,
8033 show_ip_bgp_flap_prefix_cmd,
8034 "show ip bgp flap-statistics A.B.C.D/M",
8035 SHOW_STR
8036 IP_STR
8037 BGP_STR
8038 "Display flap statistics of routes\n"
8039 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8040{
8041 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
8042 bgp_show_type_flap_prefix);
8043}
8044#ifdef HAVE_IPV6
8045DEFUN (show_bgp_prefix_longer,
8046 show_bgp_prefix_longer_cmd,
8047 "show bgp X:X::X:X/M longer-prefixes",
8048 SHOW_STR
8049 BGP_STR
8050 "IPv6 prefix <network>/<length>\n"
8051 "Display route and more specific routes\n")
8052{
8053 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8054 bgp_show_type_prefix_longer);
8055}
8056
8057ALIAS (show_bgp_prefix_longer,
8058 show_bgp_ipv6_prefix_longer_cmd,
8059 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8060 SHOW_STR
8061 BGP_STR
8062 "Address family\n"
8063 "IPv6 prefix <network>/<length>\n"
8064 "Display route and more specific routes\n")
8065
8066/* old command */
8067DEFUN (show_ipv6_bgp_prefix_longer,
8068 show_ipv6_bgp_prefix_longer_cmd,
8069 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8070 SHOW_STR
8071 IPV6_STR
8072 BGP_STR
8073 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8074 "Display route and more specific routes\n")
8075{
8076 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8077 bgp_show_type_prefix_longer);
8078}
8079
8080/* old command */
8081DEFUN (show_ipv6_mbgp_prefix_longer,
8082 show_ipv6_mbgp_prefix_longer_cmd,
8083 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8084 SHOW_STR
8085 IPV6_STR
8086 MBGP_STR
8087 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8088 "Display route and more specific routes\n")
8089{
8090 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8091 bgp_show_type_prefix_longer);
8092}
8093#endif /* HAVE_IPV6 */
paulbb46e942003-10-24 19:02:03 +00008094
8095struct peer *
paulfd79ac92004-10-13 05:06:08 +00008096peer_lookup_in_view (struct vty *vty, const char *view_name,
8097 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +00008098{
8099 int ret;
8100 struct bgp *bgp;
8101 struct peer *peer;
8102 union sockunion su;
8103
8104 /* BGP structure lookup. */
8105 if (view_name)
8106 {
8107 bgp = bgp_lookup_by_name (view_name);
8108 if (! bgp)
8109 {
8110 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
8111 return NULL;
8112 }
8113 }
paul5228ad22004-06-04 17:58:18 +00008114 else
paulbb46e942003-10-24 19:02:03 +00008115 {
8116 bgp = bgp_get_default ();
8117 if (! bgp)
8118 {
8119 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
8120 return NULL;
8121 }
8122 }
8123
8124 /* Get peer sockunion. */
8125 ret = str2sockunion (ip_str, &su);
8126 if (ret < 0)
8127 {
8128 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
8129 return NULL;
8130 }
8131
8132 /* Peer structure lookup. */
8133 peer = peer_lookup (bgp, &su);
8134 if (! peer)
8135 {
8136 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
8137 return NULL;
8138 }
8139
8140 return peer;
8141}
8142
paul718e3742002-12-13 20:15:29 +00008143void
8144show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
8145 int in)
8146{
8147 struct bgp_table *table;
8148 struct bgp_adj_in *ain;
8149 struct bgp_adj_out *adj;
8150 unsigned long output_count;
8151 struct bgp_node *rn;
8152 int header1 = 1;
8153 struct bgp *bgp;
8154 int header2 = 1;
8155
paulbb46e942003-10-24 19:02:03 +00008156 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +00008157
8158 if (! bgp)
8159 return;
8160
8161 table = bgp->rib[afi][safi];
8162
8163 output_count = 0;
8164
8165 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
8166 PEER_STATUS_DEFAULT_ORIGINATE))
8167 {
8168 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 +00008169 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
8170 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008171
8172 vty_out (vty, "Originating default network 0.0.0.0%s%s",
8173 VTY_NEWLINE, VTY_NEWLINE);
8174 header1 = 0;
8175 }
8176
8177 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
8178 if (in)
8179 {
8180 for (ain = rn->adj_in; ain; ain = ain->next)
8181 if (ain->peer == peer)
8182 {
8183 if (header1)
8184 {
8185 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 +00008186 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
8187 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008188 header1 = 0;
8189 }
8190 if (header2)
8191 {
8192 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
8193 header2 = 0;
8194 }
8195 if (ain->attr)
8196 {
8197 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
8198 output_count++;
8199 }
8200 }
8201 }
8202 else
8203 {
8204 for (adj = rn->adj_out; adj; adj = adj->next)
8205 if (adj->peer == peer)
8206 {
8207 if (header1)
8208 {
8209 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 +00008210 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
8211 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008212 header1 = 0;
8213 }
8214 if (header2)
8215 {
8216 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
8217 header2 = 0;
8218 }
8219 if (adj->attr)
8220 {
8221 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
8222 output_count++;
8223 }
8224 }
8225 }
8226
8227 if (output_count != 0)
8228 vty_out (vty, "%sTotal number of prefixes %ld%s",
8229 VTY_NEWLINE, output_count, VTY_NEWLINE);
8230}
8231
8232int
paulbb46e942003-10-24 19:02:03 +00008233peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
8234{
paul718e3742002-12-13 20:15:29 +00008235 if (! peer || ! peer->afc[afi][safi])
8236 {
8237 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
8238 return CMD_WARNING;
8239 }
8240
8241 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
8242 {
8243 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
8244 VTY_NEWLINE);
8245 return CMD_WARNING;
8246 }
8247
8248 show_adj_route (vty, peer, afi, safi, in);
8249
8250 return CMD_SUCCESS;
8251}
8252
8253DEFUN (show_ip_bgp_neighbor_advertised_route,
8254 show_ip_bgp_neighbor_advertised_route_cmd,
8255 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8256 SHOW_STR
8257 IP_STR
8258 BGP_STR
8259 "Detailed information on TCP and BGP neighbor connections\n"
8260 "Neighbor to display information about\n"
8261 "Neighbor to display information about\n"
8262 "Display the routes advertised to a BGP neighbor\n")
8263{
paulbb46e942003-10-24 19:02:03 +00008264 struct peer *peer;
8265
8266 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8267 if (! peer)
8268 return CMD_WARNING;
8269
8270 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
paul718e3742002-12-13 20:15:29 +00008271}
8272
8273DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
8274 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
8275 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8276 SHOW_STR
8277 IP_STR
8278 BGP_STR
8279 "Address family\n"
8280 "Address Family modifier\n"
8281 "Address Family modifier\n"
8282 "Detailed information on TCP and BGP neighbor connections\n"
8283 "Neighbor to display information about\n"
8284 "Neighbor to display information about\n"
8285 "Display the routes advertised to a BGP neighbor\n")
8286{
paulbb46e942003-10-24 19:02:03 +00008287 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00008288
paulbb46e942003-10-24 19:02:03 +00008289 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8290 if (! peer)
8291 return CMD_WARNING;
8292
8293 if (strncmp (argv[0], "m", 1) == 0)
8294 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
8295
8296 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
paul718e3742002-12-13 20:15:29 +00008297}
8298
8299#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00008300DEFUN (show_bgp_view_neighbor_advertised_route,
8301 show_bgp_view_neighbor_advertised_route_cmd,
8302 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8303 SHOW_STR
8304 BGP_STR
8305 "BGP view\n"
8306 "View name\n"
8307 "Detailed information on TCP and BGP neighbor connections\n"
8308 "Neighbor to display information about\n"
8309 "Neighbor to display information about\n"
8310 "Display the routes advertised to a BGP neighbor\n")
8311{
8312 struct peer *peer;
8313
8314 if (argc == 2)
8315 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8316 else
8317 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8318
8319 if (! peer)
8320 return CMD_WARNING;
8321
8322 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
8323}
8324
8325ALIAS (show_bgp_view_neighbor_advertised_route,
8326 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
8327 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8328 SHOW_STR
8329 BGP_STR
8330 "BGP view\n"
8331 "View name\n"
8332 "Address family\n"
8333 "Detailed information on TCP and BGP neighbor connections\n"
8334 "Neighbor to display information about\n"
8335 "Neighbor to display information about\n"
8336 "Display the routes advertised to a BGP neighbor\n")
8337
8338DEFUN (show_bgp_view_neighbor_received_routes,
8339 show_bgp_view_neighbor_received_routes_cmd,
8340 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
8341 SHOW_STR
8342 BGP_STR
8343 "BGP view\n"
8344 "View name\n"
8345 "Detailed information on TCP and BGP neighbor connections\n"
8346 "Neighbor to display information about\n"
8347 "Neighbor to display information about\n"
8348 "Display the received routes from neighbor\n")
8349{
8350 struct peer *peer;
8351
8352 if (argc == 2)
8353 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8354 else
8355 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8356
8357 if (! peer)
8358 return CMD_WARNING;
8359
8360 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
8361}
8362
8363ALIAS (show_bgp_view_neighbor_received_routes,
8364 show_bgp_view_ipv6_neighbor_received_routes_cmd,
8365 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
8366 SHOW_STR
8367 BGP_STR
8368 "BGP view\n"
8369 "View name\n"
8370 "Address family\n"
8371 "Detailed information on TCP and BGP neighbor connections\n"
8372 "Neighbor to display information about\n"
8373 "Neighbor to display information about\n"
8374 "Display the received routes from neighbor\n")
8375
8376ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00008377 show_bgp_neighbor_advertised_route_cmd,
8378 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8379 SHOW_STR
8380 BGP_STR
8381 "Detailed information on TCP and BGP neighbor connections\n"
8382 "Neighbor to display information about\n"
8383 "Neighbor to display information about\n"
8384 "Display the routes advertised to a BGP neighbor\n")
paulbb46e942003-10-24 19:02:03 +00008385
8386ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00008387 show_bgp_ipv6_neighbor_advertised_route_cmd,
8388 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8389 SHOW_STR
8390 BGP_STR
8391 "Address family\n"
8392 "Detailed information on TCP and BGP neighbor connections\n"
8393 "Neighbor to display information about\n"
8394 "Neighbor to display information about\n"
8395 "Display the routes advertised to a BGP neighbor\n")
8396
8397/* old command */
paulbb46e942003-10-24 19:02:03 +00008398ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00008399 ipv6_bgp_neighbor_advertised_route_cmd,
8400 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8401 SHOW_STR
8402 IPV6_STR
8403 BGP_STR
8404 "Detailed information on TCP and BGP neighbor connections\n"
8405 "Neighbor to display information about\n"
8406 "Neighbor to display information about\n"
8407 "Display the routes advertised to a BGP neighbor\n")
paulbb46e942003-10-24 19:02:03 +00008408
paul718e3742002-12-13 20:15:29 +00008409/* old command */
8410DEFUN (ipv6_mbgp_neighbor_advertised_route,
8411 ipv6_mbgp_neighbor_advertised_route_cmd,
8412 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
8413 SHOW_STR
8414 IPV6_STR
8415 MBGP_STR
8416 "Detailed information on TCP and BGP neighbor connections\n"
8417 "Neighbor to display information about\n"
8418 "Neighbor to display information about\n"
8419 "Display the routes advertised to a BGP neighbor\n")
8420{
paulbb46e942003-10-24 19:02:03 +00008421 struct peer *peer;
8422
8423 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8424 if (! peer)
8425 return CMD_WARNING;
8426
8427 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
paul718e3742002-12-13 20:15:29 +00008428}
8429#endif /* HAVE_IPV6 */
8430
8431DEFUN (show_ip_bgp_neighbor_received_routes,
8432 show_ip_bgp_neighbor_received_routes_cmd,
8433 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8434 SHOW_STR
8435 IP_STR
8436 BGP_STR
8437 "Detailed information on TCP and BGP neighbor connections\n"
8438 "Neighbor to display information about\n"
8439 "Neighbor to display information about\n"
8440 "Display the received routes from neighbor\n")
8441{
paulbb46e942003-10-24 19:02:03 +00008442 struct peer *peer;
8443
8444 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8445 if (! peer)
8446 return CMD_WARNING;
8447
8448 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
paul718e3742002-12-13 20:15:29 +00008449}
8450
8451DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
8452 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
8453 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
8454 SHOW_STR
8455 IP_STR
8456 BGP_STR
8457 "Address family\n"
8458 "Address Family modifier\n"
8459 "Address Family modifier\n"
8460 "Detailed information on TCP and BGP neighbor connections\n"
8461 "Neighbor to display information about\n"
8462 "Neighbor to display information about\n"
8463 "Display the received routes from neighbor\n")
8464{
paulbb46e942003-10-24 19:02:03 +00008465 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00008466
paulbb46e942003-10-24 19:02:03 +00008467 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8468 if (! peer)
8469 return CMD_WARNING;
8470
8471 if (strncmp (argv[0], "m", 1) == 0)
8472 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
8473
8474 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
paul718e3742002-12-13 20:15:29 +00008475}
8476
8477DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
8478 show_ip_bgp_neighbor_received_prefix_filter_cmd,
8479 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8480 SHOW_STR
8481 IP_STR
8482 BGP_STR
8483 "Detailed information on TCP and BGP neighbor connections\n"
8484 "Neighbor to display information about\n"
8485 "Neighbor to display information about\n"
8486 "Display information received from a BGP neighbor\n"
8487 "Display the prefixlist filter\n")
8488{
8489 char name[BUFSIZ];
8490 union sockunion *su;
8491 struct peer *peer;
8492 int count;
8493
8494 su = sockunion_str2su (argv[0]);
8495 if (su == NULL)
8496 return CMD_WARNING;
8497
8498 peer = peer_lookup (NULL, su);
8499 if (! peer)
8500 return CMD_WARNING;
8501
8502 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
8503 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
8504 if (count)
8505 {
8506 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
8507 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
8508 }
8509
8510 return CMD_SUCCESS;
8511}
8512
8513DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
8514 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
8515 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8516 SHOW_STR
8517 IP_STR
8518 BGP_STR
8519 "Address family\n"
8520 "Address Family modifier\n"
8521 "Address Family modifier\n"
8522 "Detailed information on TCP and BGP neighbor connections\n"
8523 "Neighbor to display information about\n"
8524 "Neighbor to display information about\n"
8525 "Display information received from a BGP neighbor\n"
8526 "Display the prefixlist filter\n")
8527{
8528 char name[BUFSIZ];
8529 union sockunion *su;
8530 struct peer *peer;
8531 int count;
8532
8533 su = sockunion_str2su (argv[1]);
8534 if (su == NULL)
8535 return CMD_WARNING;
8536
8537 peer = peer_lookup (NULL, su);
8538 if (! peer)
8539 return CMD_WARNING;
8540
8541 if (strncmp (argv[0], "m", 1) == 0)
8542 {
8543 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
8544 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
8545 if (count)
8546 {
8547 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
8548 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
8549 }
8550 }
8551 else
8552 {
8553 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
8554 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
8555 if (count)
8556 {
8557 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
8558 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
8559 }
8560 }
8561
8562 return CMD_SUCCESS;
8563}
8564
8565
8566#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00008567ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00008568 show_bgp_neighbor_received_routes_cmd,
8569 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8570 SHOW_STR
8571 BGP_STR
8572 "Detailed information on TCP and BGP neighbor connections\n"
8573 "Neighbor to display information about\n"
8574 "Neighbor to display information about\n"
8575 "Display the received routes from neighbor\n")
paul718e3742002-12-13 20:15:29 +00008576
paulbb46e942003-10-24 19:02:03 +00008577ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00008578 show_bgp_ipv6_neighbor_received_routes_cmd,
8579 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
8580 SHOW_STR
8581 BGP_STR
8582 "Address family\n"
8583 "Detailed information on TCP and BGP neighbor connections\n"
8584 "Neighbor to display information about\n"
8585 "Neighbor to display information about\n"
8586 "Display the received routes from neighbor\n")
8587
8588DEFUN (show_bgp_neighbor_received_prefix_filter,
8589 show_bgp_neighbor_received_prefix_filter_cmd,
8590 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8591 SHOW_STR
8592 BGP_STR
8593 "Detailed information on TCP and BGP neighbor connections\n"
8594 "Neighbor to display information about\n"
8595 "Neighbor to display information about\n"
8596 "Display information received from a BGP neighbor\n"
8597 "Display the prefixlist filter\n")
8598{
8599 char name[BUFSIZ];
8600 union sockunion *su;
8601 struct peer *peer;
8602 int count;
8603
8604 su = sockunion_str2su (argv[0]);
8605 if (su == NULL)
8606 return CMD_WARNING;
8607
8608 peer = peer_lookup (NULL, su);
8609 if (! peer)
8610 return CMD_WARNING;
8611
8612 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
8613 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
8614 if (count)
8615 {
8616 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
8617 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
8618 }
8619
8620 return CMD_SUCCESS;
8621}
8622
8623ALIAS (show_bgp_neighbor_received_prefix_filter,
8624 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
8625 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8626 SHOW_STR
8627 BGP_STR
8628 "Address family\n"
8629 "Detailed information on TCP and BGP neighbor connections\n"
8630 "Neighbor to display information about\n"
8631 "Neighbor to display information about\n"
8632 "Display information received from a BGP neighbor\n"
8633 "Display the prefixlist filter\n")
8634
8635/* old command */
paulbb46e942003-10-24 19:02:03 +00008636ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00008637 ipv6_bgp_neighbor_received_routes_cmd,
8638 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8639 SHOW_STR
8640 IPV6_STR
8641 BGP_STR
8642 "Detailed information on TCP and BGP neighbor connections\n"
8643 "Neighbor to display information about\n"
8644 "Neighbor to display information about\n"
8645 "Display the received routes from neighbor\n")
paul718e3742002-12-13 20:15:29 +00008646
8647/* old command */
8648DEFUN (ipv6_mbgp_neighbor_received_routes,
8649 ipv6_mbgp_neighbor_received_routes_cmd,
8650 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
8651 SHOW_STR
8652 IPV6_STR
8653 MBGP_STR
8654 "Detailed information on TCP and BGP neighbor connections\n"
8655 "Neighbor to display information about\n"
8656 "Neighbor to display information about\n"
8657 "Display the received routes from neighbor\n")
8658{
paulbb46e942003-10-24 19:02:03 +00008659 struct peer *peer;
8660
8661 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8662 if (! peer)
8663 return CMD_WARNING;
8664
8665 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
paul718e3742002-12-13 20:15:29 +00008666}
paulbb46e942003-10-24 19:02:03 +00008667
8668DEFUN (show_bgp_view_neighbor_received_prefix_filter,
8669 show_bgp_view_neighbor_received_prefix_filter_cmd,
8670 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8671 SHOW_STR
8672 BGP_STR
8673 "BGP view\n"
8674 "View name\n"
8675 "Detailed information on TCP and BGP neighbor connections\n"
8676 "Neighbor to display information about\n"
8677 "Neighbor to display information about\n"
8678 "Display information received from a BGP neighbor\n"
8679 "Display the prefixlist filter\n")
8680{
8681 char name[BUFSIZ];
8682 union sockunion *su;
8683 struct peer *peer;
8684 struct bgp *bgp;
8685 int count;
8686
8687 /* BGP structure lookup. */
8688 bgp = bgp_lookup_by_name (argv[0]);
8689 if (bgp == NULL)
8690 {
8691 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8692 return CMD_WARNING;
8693 }
8694
8695 su = sockunion_str2su (argv[1]);
8696 if (su == NULL)
8697 return CMD_WARNING;
8698
8699 peer = peer_lookup (bgp, su);
8700 if (! peer)
8701 return CMD_WARNING;
8702
8703 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
8704 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
8705 if (count)
8706 {
8707 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
8708 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
8709 }
8710
8711 return CMD_SUCCESS;
8712}
8713
8714ALIAS (show_bgp_view_neighbor_received_prefix_filter,
8715 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
8716 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
8717 SHOW_STR
8718 BGP_STR
8719 "BGP view\n"
8720 "View name\n"
8721 "Address family\n"
8722 "Detailed information on TCP and BGP neighbor connections\n"
8723 "Neighbor to display information about\n"
8724 "Neighbor to display information about\n"
8725 "Display information received from a BGP neighbor\n"
8726 "Display the prefixlist filter\n")
paul718e3742002-12-13 20:15:29 +00008727#endif /* HAVE_IPV6 */
8728
paul718e3742002-12-13 20:15:29 +00008729int
paulbb46e942003-10-24 19:02:03 +00008730bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008731 safi_t safi, enum bgp_show_type type)
8732{
paul718e3742002-12-13 20:15:29 +00008733 if (! peer || ! peer->afc[afi][safi])
8734 {
8735 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008736 return CMD_WARNING;
8737 }
8738
ajs5a646652004-11-05 01:25:55 +00008739 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +00008740}
8741
8742DEFUN (show_ip_bgp_neighbor_routes,
8743 show_ip_bgp_neighbor_routes_cmd,
8744 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
8745 SHOW_STR
8746 IP_STR
8747 BGP_STR
8748 "Detailed information on TCP and BGP neighbor connections\n"
8749 "Neighbor to display information about\n"
8750 "Neighbor to display information about\n"
8751 "Display routes learned from neighbor\n")
8752{
paulbb46e942003-10-24 19:02:03 +00008753 struct peer *peer;
8754
8755 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8756 if (! peer)
8757 return CMD_WARNING;
8758
8759 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008760 bgp_show_type_neighbor);
8761}
8762
8763DEFUN (show_ip_bgp_neighbor_flap,
8764 show_ip_bgp_neighbor_flap_cmd,
8765 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
8766 SHOW_STR
8767 IP_STR
8768 BGP_STR
8769 "Detailed information on TCP and BGP neighbor connections\n"
8770 "Neighbor to display information about\n"
8771 "Neighbor to display information about\n"
8772 "Display flap statistics of the routes learned from neighbor\n")
8773{
paulbb46e942003-10-24 19:02:03 +00008774 struct peer *peer;
8775
8776 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8777 if (! peer)
8778 return CMD_WARNING;
8779
8780 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008781 bgp_show_type_flap_neighbor);
8782}
8783
8784DEFUN (show_ip_bgp_neighbor_damp,
8785 show_ip_bgp_neighbor_damp_cmd,
8786 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
8787 SHOW_STR
8788 IP_STR
8789 BGP_STR
8790 "Detailed information on TCP and BGP neighbor connections\n"
8791 "Neighbor to display information about\n"
8792 "Neighbor to display information about\n"
8793 "Display the dampened routes received from neighbor\n")
8794{
paulbb46e942003-10-24 19:02:03 +00008795 struct peer *peer;
8796
8797 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8798 if (! peer)
8799 return CMD_WARNING;
8800
8801 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008802 bgp_show_type_damp_neighbor);
8803}
8804
8805DEFUN (show_ip_bgp_ipv4_neighbor_routes,
8806 show_ip_bgp_ipv4_neighbor_routes_cmd,
8807 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
8808 SHOW_STR
8809 IP_STR
8810 BGP_STR
8811 "Address family\n"
8812 "Address Family modifier\n"
8813 "Address Family modifier\n"
8814 "Detailed information on TCP and BGP neighbor connections\n"
8815 "Neighbor to display information about\n"
8816 "Neighbor to display information about\n"
8817 "Display routes learned from neighbor\n")
8818{
paulbb46e942003-10-24 19:02:03 +00008819 struct peer *peer;
8820
8821 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8822 if (! peer)
8823 return CMD_WARNING;
8824
paul718e3742002-12-13 20:15:29 +00008825 if (strncmp (argv[0], "m", 1) == 0)
paulbb46e942003-10-24 19:02:03 +00008826 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
paul718e3742002-12-13 20:15:29 +00008827 bgp_show_type_neighbor);
8828
paulbb46e942003-10-24 19:02:03 +00008829 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008830 bgp_show_type_neighbor);
8831}
paulbb46e942003-10-24 19:02:03 +00008832
paulfee0f4c2004-09-13 05:12:46 +00008833DEFUN (show_ip_bgp_view_rsclient,
8834 show_ip_bgp_view_rsclient_cmd,
8835 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
8836 SHOW_STR
8837 IP_STR
8838 BGP_STR
8839 "BGP view\n"
8840 "BGP view name\n"
8841 "Information about Route Server Client\n"
8842 NEIGHBOR_ADDR_STR)
8843{
8844 struct bgp_table *table;
8845 struct peer *peer;
8846
8847 if (argc == 2)
8848 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8849 else
8850 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8851
8852 if (! peer)
8853 return CMD_WARNING;
8854
8855 if (! peer->afc[AFI_IP][SAFI_UNICAST])
8856 {
8857 vty_out (vty, "%% Activate the neighbor for the address family first%s",
8858 VTY_NEWLINE);
8859 return CMD_WARNING;
8860 }
8861
8862 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
8863 PEER_FLAG_RSERVER_CLIENT))
8864 {
8865 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
8866 VTY_NEWLINE);
8867 return CMD_WARNING;
8868 }
8869
8870 table = peer->rib[AFI_IP][SAFI_UNICAST];
8871
ajs5a646652004-11-05 01:25:55 +00008872 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +00008873}
8874
8875ALIAS (show_ip_bgp_view_rsclient,
8876 show_ip_bgp_rsclient_cmd,
8877 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
8878 SHOW_STR
8879 IP_STR
8880 BGP_STR
8881 "Information about Route Server Client\n"
8882 NEIGHBOR_ADDR_STR)
8883
8884DEFUN (show_ip_bgp_view_rsclient_route,
8885 show_ip_bgp_view_rsclient_route_cmd,
8886 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
8887 SHOW_STR
8888 IP_STR
8889 BGP_STR
8890 "BGP view\n"
8891 "BGP view name\n"
8892 "Information about Route Server Client\n"
8893 NEIGHBOR_ADDR_STR
8894 "Network in the BGP routing table to display\n")
8895{
8896 struct bgp *bgp;
8897 struct peer *peer;
8898
8899 /* BGP structure lookup. */
8900 if (argc == 3)
8901 {
8902 bgp = bgp_lookup_by_name (argv[0]);
8903 if (bgp == NULL)
8904 {
8905 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8906 return CMD_WARNING;
8907 }
8908 }
8909 else
8910 {
8911 bgp = bgp_get_default ();
8912 if (bgp == NULL)
8913 {
8914 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
8915 return CMD_WARNING;
8916 }
8917 }
8918
8919 if (argc == 3)
8920 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8921 else
8922 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8923
8924 if (! peer)
8925 return CMD_WARNING;
8926
8927 if (! peer->afc[AFI_IP][SAFI_UNICAST])
8928 {
8929 vty_out (vty, "%% Activate the neighbor for the address family first%s",
8930 VTY_NEWLINE);
8931 return CMD_WARNING;
8932}
8933
8934 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
8935 PEER_FLAG_RSERVER_CLIENT))
8936 {
8937 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
8938 VTY_NEWLINE);
8939 return CMD_WARNING;
8940 }
8941
8942 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
8943 (argc == 3) ? argv[2] : argv[1],
8944 AFI_IP, SAFI_UNICAST, NULL, 0);
8945}
8946
8947ALIAS (show_ip_bgp_view_rsclient_route,
8948 show_ip_bgp_rsclient_route_cmd,
8949 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
8950 SHOW_STR
8951 IP_STR
8952 BGP_STR
8953 "Information about Route Server Client\n"
8954 NEIGHBOR_ADDR_STR
8955 "Network in the BGP routing table to display\n")
8956
8957DEFUN (show_ip_bgp_view_rsclient_prefix,
8958 show_ip_bgp_view_rsclient_prefix_cmd,
8959 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
8960 SHOW_STR
8961 IP_STR
8962 BGP_STR
8963 "BGP view\n"
8964 "BGP view name\n"
8965 "Information about Route Server Client\n"
8966 NEIGHBOR_ADDR_STR
8967 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8968{
8969 struct bgp *bgp;
8970 struct peer *peer;
8971
8972 /* BGP structure lookup. */
8973 if (argc == 3)
8974 {
8975 bgp = bgp_lookup_by_name (argv[0]);
8976 if (bgp == NULL)
8977 {
8978 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
8979 return CMD_WARNING;
8980 }
8981 }
8982 else
8983 {
8984 bgp = bgp_get_default ();
8985 if (bgp == NULL)
8986 {
8987 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
8988 return CMD_WARNING;
8989 }
8990 }
8991
8992 if (argc == 3)
8993 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8994 else
8995 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8996
8997 if (! peer)
8998 return CMD_WARNING;
8999
9000 if (! peer->afc[AFI_IP][SAFI_UNICAST])
9001 {
9002 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9003 VTY_NEWLINE);
9004 return CMD_WARNING;
9005}
9006
9007 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
9008 PEER_FLAG_RSERVER_CLIENT))
9009{
9010 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9011 VTY_NEWLINE);
9012 return CMD_WARNING;
9013 }
9014
9015 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
9016 (argc == 3) ? argv[2] : argv[1],
9017 AFI_IP, SAFI_UNICAST, NULL, 1);
9018}
9019
9020ALIAS (show_ip_bgp_view_rsclient_prefix,
9021 show_ip_bgp_rsclient_prefix_cmd,
9022 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
9023 SHOW_STR
9024 IP_STR
9025 BGP_STR
9026 "Information about Route Server Client\n"
9027 NEIGHBOR_ADDR_STR
9028 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9029
9030
paul718e3742002-12-13 20:15:29 +00009031#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00009032DEFUN (show_bgp_view_neighbor_routes,
9033 show_bgp_view_neighbor_routes_cmd,
9034 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
9035 SHOW_STR
9036 BGP_STR
9037 "BGP view\n"
9038 "BGP view name\n"
9039 "Detailed information on TCP and BGP neighbor connections\n"
9040 "Neighbor to display information about\n"
9041 "Neighbor to display information about\n"
9042 "Display routes learned from neighbor\n")
9043{
9044 struct peer *peer;
9045
9046 if (argc == 2)
9047 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9048 else
9049 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9050
9051 if (! peer)
9052 return CMD_WARNING;
9053
9054 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
9055 bgp_show_type_neighbor);
9056}
9057
9058ALIAS (show_bgp_view_neighbor_routes,
9059 show_bgp_view_ipv6_neighbor_routes_cmd,
9060 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
9061 SHOW_STR
9062 BGP_STR
9063 "BGP view\n"
9064 "BGP view name\n"
9065 "Address family\n"
9066 "Detailed information on TCP and BGP neighbor connections\n"
9067 "Neighbor to display information about\n"
9068 "Neighbor to display information about\n"
9069 "Display routes learned from neighbor\n")
9070
9071DEFUN (show_bgp_view_neighbor_damp,
9072 show_bgp_view_neighbor_damp_cmd,
9073 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9074 SHOW_STR
9075 BGP_STR
9076 "BGP view\n"
9077 "BGP view name\n"
9078 "Detailed information on TCP and BGP neighbor connections\n"
9079 "Neighbor to display information about\n"
9080 "Neighbor to display information about\n"
9081 "Display the dampened routes received from neighbor\n")
9082{
9083 struct peer *peer;
9084
9085 if (argc == 2)
9086 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9087 else
9088 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9089
9090 if (! peer)
9091 return CMD_WARNING;
9092
9093 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
9094 bgp_show_type_damp_neighbor);
9095}
9096
9097ALIAS (show_bgp_view_neighbor_damp,
9098 show_bgp_view_ipv6_neighbor_damp_cmd,
9099 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9100 SHOW_STR
9101 BGP_STR
9102 "BGP view\n"
9103 "BGP view name\n"
9104 "Address family\n"
9105 "Detailed information on TCP and BGP neighbor connections\n"
9106 "Neighbor to display information about\n"
9107 "Neighbor to display information about\n"
9108 "Display the dampened routes received from neighbor\n")
9109
9110DEFUN (show_bgp_view_neighbor_flap,
9111 show_bgp_view_neighbor_flap_cmd,
9112 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9113 SHOW_STR
9114 BGP_STR
9115 "BGP view\n"
9116 "BGP view name\n"
9117 "Detailed information on TCP and BGP neighbor connections\n"
9118 "Neighbor to display information about\n"
9119 "Neighbor to display information about\n"
9120 "Display flap statistics of the routes learned from neighbor\n")
9121{
9122 struct peer *peer;
9123
9124 if (argc == 2)
9125 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9126 else
9127 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9128
9129 if (! peer)
9130 return CMD_WARNING;
9131
9132 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
9133 bgp_show_type_flap_neighbor);
9134}
9135
9136ALIAS (show_bgp_view_neighbor_flap,
9137 show_bgp_view_ipv6_neighbor_flap_cmd,
9138 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9139 SHOW_STR
9140 BGP_STR
9141 "BGP view\n"
9142 "BGP view name\n"
9143 "Address family\n"
9144 "Detailed information on TCP and BGP neighbor connections\n"
9145 "Neighbor to display information about\n"
9146 "Neighbor to display information about\n"
9147 "Display flap statistics of the routes learned from neighbor\n")
9148
9149ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00009150 show_bgp_neighbor_routes_cmd,
9151 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
9152 SHOW_STR
9153 BGP_STR
9154 "Detailed information on TCP and BGP neighbor connections\n"
9155 "Neighbor to display information about\n"
9156 "Neighbor to display information about\n"
9157 "Display routes learned from neighbor\n")
paul718e3742002-12-13 20:15:29 +00009158
paulbb46e942003-10-24 19:02:03 +00009159
9160ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00009161 show_bgp_ipv6_neighbor_routes_cmd,
9162 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
9163 SHOW_STR
9164 BGP_STR
9165 "Address family\n"
9166 "Detailed information on TCP and BGP neighbor connections\n"
9167 "Neighbor to display information about\n"
9168 "Neighbor to display information about\n"
9169 "Display routes learned from neighbor\n")
9170
9171/* old command */
paulbb46e942003-10-24 19:02:03 +00009172ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00009173 ipv6_bgp_neighbor_routes_cmd,
9174 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
9175 SHOW_STR
9176 IPV6_STR
9177 BGP_STR
9178 "Detailed information on TCP and BGP neighbor connections\n"
9179 "Neighbor to display information about\n"
9180 "Neighbor to display information about\n"
9181 "Display routes learned from neighbor\n")
paul718e3742002-12-13 20:15:29 +00009182
9183/* old command */
9184DEFUN (ipv6_mbgp_neighbor_routes,
9185 ipv6_mbgp_neighbor_routes_cmd,
9186 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
9187 SHOW_STR
9188 IPV6_STR
9189 MBGP_STR
9190 "Detailed information on TCP and BGP neighbor connections\n"
9191 "Neighbor to display information about\n"
9192 "Neighbor to display information about\n"
9193 "Display routes learned from neighbor\n")
9194{
paulbb46e942003-10-24 19:02:03 +00009195 struct peer *peer;
9196
9197 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9198 if (! peer)
9199 return CMD_WARNING;
9200
9201 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
paul718e3742002-12-13 20:15:29 +00009202 bgp_show_type_neighbor);
9203}
paulbb46e942003-10-24 19:02:03 +00009204
9205ALIAS (show_bgp_view_neighbor_flap,
9206 show_bgp_neighbor_flap_cmd,
9207 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9208 SHOW_STR
9209 BGP_STR
9210 "Detailed information on TCP and BGP neighbor connections\n"
9211 "Neighbor to display information about\n"
9212 "Neighbor to display information about\n"
9213 "Display flap statistics of the routes learned from neighbor\n")
9214
9215ALIAS (show_bgp_view_neighbor_flap,
9216 show_bgp_ipv6_neighbor_flap_cmd,
9217 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9218 SHOW_STR
9219 BGP_STR
9220 "Address family\n"
9221 "Detailed information on TCP and BGP neighbor connections\n"
9222 "Neighbor to display information about\n"
9223 "Neighbor to display information about\n"
9224 "Display flap statistics of the routes learned from neighbor\n")
9225
9226ALIAS (show_bgp_view_neighbor_damp,
9227 show_bgp_neighbor_damp_cmd,
9228 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9229 SHOW_STR
9230 BGP_STR
9231 "Detailed information on TCP and BGP neighbor connections\n"
9232 "Neighbor to display information about\n"
9233 "Neighbor to display information about\n"
9234 "Display the dampened routes received from neighbor\n")
9235
9236ALIAS (show_bgp_view_neighbor_damp,
9237 show_bgp_ipv6_neighbor_damp_cmd,
9238 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9239 SHOW_STR
9240 BGP_STR
9241 "Address family\n"
9242 "Detailed information on TCP and BGP neighbor connections\n"
9243 "Neighbor to display information about\n"
9244 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +00009245 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +00009246
9247DEFUN (show_bgp_view_rsclient,
9248 show_bgp_view_rsclient_cmd,
9249 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
9250 SHOW_STR
9251 BGP_STR
9252 "BGP view\n"
9253 "BGP view name\n"
9254 "Information about Route Server Client\n"
9255 NEIGHBOR_ADDR_STR)
9256{
9257 struct bgp_table *table;
9258 struct peer *peer;
9259
9260 if (argc == 2)
9261 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9262 else
9263 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9264
9265 if (! peer)
9266 return CMD_WARNING;
9267
9268 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
9269 {
9270 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9271 VTY_NEWLINE);
9272 return CMD_WARNING;
9273 }
9274
9275 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
9276 PEER_FLAG_RSERVER_CLIENT))
9277 {
9278 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9279 VTY_NEWLINE);
9280 return CMD_WARNING;
9281 }
9282
9283 table = peer->rib[AFI_IP6][SAFI_UNICAST];
9284
ajs5a646652004-11-05 01:25:55 +00009285 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +00009286}
9287
9288ALIAS (show_bgp_view_rsclient,
9289 show_bgp_rsclient_cmd,
9290 "show bgp rsclient (A.B.C.D|X:X::X:X)",
9291 SHOW_STR
9292 BGP_STR
9293 "Information about Route Server Client\n"
9294 NEIGHBOR_ADDR_STR)
9295
9296DEFUN (show_bgp_view_rsclient_route,
9297 show_bgp_view_rsclient_route_cmd,
9298 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
9299 SHOW_STR
9300 BGP_STR
9301 "BGP view\n"
9302 "BGP view name\n"
9303 "Information about Route Server Client\n"
9304 NEIGHBOR_ADDR_STR
9305 "Network in the BGP routing table to display\n")
9306{
9307 struct bgp *bgp;
9308 struct peer *peer;
9309
9310 /* BGP structure lookup. */
9311 if (argc == 3)
9312 {
9313 bgp = bgp_lookup_by_name (argv[0]);
9314 if (bgp == NULL)
9315 {
9316 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
9317 return CMD_WARNING;
9318 }
9319 }
9320 else
9321 {
9322 bgp = bgp_get_default ();
9323 if (bgp == NULL)
9324 {
9325 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9326 return CMD_WARNING;
9327 }
9328 }
9329
9330 if (argc == 3)
9331 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9332 else
9333 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9334
9335 if (! peer)
9336 return CMD_WARNING;
9337
9338 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
9339 {
9340 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9341 VTY_NEWLINE);
9342 return CMD_WARNING;
9343 }
9344
9345 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
9346 PEER_FLAG_RSERVER_CLIENT))
9347 {
9348 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9349 VTY_NEWLINE);
9350 return CMD_WARNING;
9351 }
9352
9353 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
9354 (argc == 3) ? argv[2] : argv[1],
9355 AFI_IP6, SAFI_UNICAST, NULL, 0);
9356}
9357
9358ALIAS (show_bgp_view_rsclient_route,
9359 show_bgp_rsclient_route_cmd,
9360 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
9361 SHOW_STR
9362 BGP_STR
9363 "Information about Route Server Client\n"
9364 NEIGHBOR_ADDR_STR
9365 "Network in the BGP routing table to display\n")
9366
9367DEFUN (show_bgp_view_rsclient_prefix,
9368 show_bgp_view_rsclient_prefix_cmd,
9369 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
9370 SHOW_STR
9371 BGP_STR
9372 "BGP view\n"
9373 "BGP view name\n"
9374 "Information about Route Server Client\n"
9375 NEIGHBOR_ADDR_STR
9376 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
9377{
9378 struct bgp *bgp;
9379 struct peer *peer;
9380
9381 /* BGP structure lookup. */
9382 if (argc == 3)
9383 {
9384 bgp = bgp_lookup_by_name (argv[0]);
9385 if (bgp == NULL)
9386 {
9387 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
9388 return CMD_WARNING;
9389 }
9390 }
9391 else
9392 {
9393 bgp = bgp_get_default ();
9394 if (bgp == NULL)
9395 {
9396 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9397 return CMD_WARNING;
9398 }
9399 }
9400
9401 if (argc == 3)
9402 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
9403 else
9404 peer = peer_lookup_in_view (vty, NULL, argv[0]);
9405
9406 if (! peer)
9407 return CMD_WARNING;
9408
9409 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
9410 {
9411 vty_out (vty, "%% Activate the neighbor for the address family first%s",
9412 VTY_NEWLINE);
9413 return CMD_WARNING;
9414 }
9415
9416 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
9417 PEER_FLAG_RSERVER_CLIENT))
9418 {
9419 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
9420 VTY_NEWLINE);
9421 return CMD_WARNING;
9422 }
9423
9424 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
9425 (argc == 3) ? argv[2] : argv[1],
9426 AFI_IP6, SAFI_UNICAST, NULL, 1);
9427}
9428
9429ALIAS (show_bgp_view_rsclient_prefix,
9430 show_bgp_rsclient_prefix_cmd,
9431 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
9432 SHOW_STR
9433 BGP_STR
9434 "Information about Route Server Client\n"
9435 NEIGHBOR_ADDR_STR
9436 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
9437
paul718e3742002-12-13 20:15:29 +00009438#endif /* HAVE_IPV6 */
9439
9440struct bgp_table *bgp_distance_table;
9441
9442struct bgp_distance
9443{
9444 /* Distance value for the IP source prefix. */
9445 u_char distance;
9446
9447 /* Name of the access-list to be matched. */
9448 char *access_list;
9449};
9450
9451struct bgp_distance *
9452bgp_distance_new ()
9453{
9454 struct bgp_distance *new;
9455 new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
9456 memset (new, 0, sizeof (struct bgp_distance));
9457 return new;
9458}
9459
9460void
9461bgp_distance_free (struct bgp_distance *bdistance)
9462{
9463 XFREE (MTYPE_BGP_DISTANCE, bdistance);
9464}
9465
9466int
paulfd79ac92004-10-13 05:06:08 +00009467bgp_distance_set (struct vty *vty, const char *distance_str,
9468 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +00009469{
9470 int ret;
9471 struct prefix_ipv4 p;
9472 u_char distance;
9473 struct bgp_node *rn;
9474 struct bgp_distance *bdistance;
9475
9476 ret = str2prefix_ipv4 (ip_str, &p);
9477 if (ret == 0)
9478 {
9479 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
9480 return CMD_WARNING;
9481 }
9482
9483 distance = atoi (distance_str);
9484
9485 /* Get BGP distance node. */
9486 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
9487 if (rn->info)
9488 {
9489 bdistance = rn->info;
9490 bgp_unlock_node (rn);
9491 }
9492 else
9493 {
9494 bdistance = bgp_distance_new ();
9495 rn->info = bdistance;
9496 }
9497
9498 /* Set distance value. */
9499 bdistance->distance = distance;
9500
9501 /* Reset access-list configuration. */
9502 if (bdistance->access_list)
9503 {
9504 free (bdistance->access_list);
9505 bdistance->access_list = NULL;
9506 }
9507 if (access_list_str)
9508 bdistance->access_list = strdup (access_list_str);
9509
9510 return CMD_SUCCESS;
9511}
9512
9513int
paulfd79ac92004-10-13 05:06:08 +00009514bgp_distance_unset (struct vty *vty, const char *distance_str,
9515 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +00009516{
9517 int ret;
9518 struct prefix_ipv4 p;
9519 u_char distance;
9520 struct bgp_node *rn;
9521 struct bgp_distance *bdistance;
9522
9523 ret = str2prefix_ipv4 (ip_str, &p);
9524 if (ret == 0)
9525 {
9526 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
9527 return CMD_WARNING;
9528 }
9529
9530 distance = atoi (distance_str);
9531
9532 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
9533 if (! rn)
9534 {
9535 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
9536 return CMD_WARNING;
9537 }
9538
9539 bdistance = rn->info;
9540
9541 if (bdistance->access_list)
9542 free (bdistance->access_list);
9543 bgp_distance_free (bdistance);
9544
9545 rn->info = NULL;
9546 bgp_unlock_node (rn);
9547 bgp_unlock_node (rn);
9548
9549 return CMD_SUCCESS;
9550}
9551
9552void
9553bgp_distance_reset ()
9554{
9555 struct bgp_node *rn;
9556 struct bgp_distance *bdistance;
9557
9558 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
9559 if ((bdistance = rn->info) != NULL)
9560 {
9561 if (bdistance->access_list)
9562 free (bdistance->access_list);
9563 bgp_distance_free (bdistance);
9564 rn->info = NULL;
9565 bgp_unlock_node (rn);
9566 }
9567}
9568
9569/* Apply BGP information to distance method. */
9570u_char
9571bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
9572{
9573 struct bgp_node *rn;
9574 struct prefix_ipv4 q;
9575 struct peer *peer;
9576 struct bgp_distance *bdistance;
9577 struct access_list *alist;
9578 struct bgp_static *bgp_static;
9579
9580 if (! bgp)
9581 return 0;
9582
9583 if (p->family != AF_INET)
9584 return 0;
9585
9586 peer = rinfo->peer;
9587
9588 if (peer->su.sa.sa_family != AF_INET)
9589 return 0;
9590
9591 memset (&q, 0, sizeof (struct prefix_ipv4));
9592 q.family = AF_INET;
9593 q.prefix = peer->su.sin.sin_addr;
9594 q.prefixlen = IPV4_MAX_BITLEN;
9595
9596 /* Check source address. */
9597 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
9598 if (rn)
9599 {
9600 bdistance = rn->info;
9601 bgp_unlock_node (rn);
9602
9603 if (bdistance->access_list)
9604 {
9605 alist = access_list_lookup (AFI_IP, bdistance->access_list);
9606 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
9607 return bdistance->distance;
9608 }
9609 else
9610 return bdistance->distance;
9611 }
9612
9613 /* Backdoor check. */
9614 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
9615 if (rn)
9616 {
9617 bgp_static = rn->info;
9618 bgp_unlock_node (rn);
9619
9620 if (bgp_static->backdoor)
9621 {
9622 if (bgp->distance_local)
9623 return bgp->distance_local;
9624 else
9625 return ZEBRA_IBGP_DISTANCE_DEFAULT;
9626 }
9627 }
9628
9629 if (peer_sort (peer) == BGP_PEER_EBGP)
9630 {
9631 if (bgp->distance_ebgp)
9632 return bgp->distance_ebgp;
9633 return ZEBRA_EBGP_DISTANCE_DEFAULT;
9634 }
9635 else
9636 {
9637 if (bgp->distance_ibgp)
9638 return bgp->distance_ibgp;
9639 return ZEBRA_IBGP_DISTANCE_DEFAULT;
9640 }
9641}
9642
9643DEFUN (bgp_distance,
9644 bgp_distance_cmd,
9645 "distance bgp <1-255> <1-255> <1-255>",
9646 "Define an administrative distance\n"
9647 "BGP distance\n"
9648 "Distance for routes external to the AS\n"
9649 "Distance for routes internal to the AS\n"
9650 "Distance for local routes\n")
9651{
9652 struct bgp *bgp;
9653
9654 bgp = vty->index;
9655
9656 bgp->distance_ebgp = atoi (argv[0]);
9657 bgp->distance_ibgp = atoi (argv[1]);
9658 bgp->distance_local = atoi (argv[2]);
9659 return CMD_SUCCESS;
9660}
9661
9662DEFUN (no_bgp_distance,
9663 no_bgp_distance_cmd,
9664 "no distance bgp <1-255> <1-255> <1-255>",
9665 NO_STR
9666 "Define an administrative distance\n"
9667 "BGP distance\n"
9668 "Distance for routes external to the AS\n"
9669 "Distance for routes internal to the AS\n"
9670 "Distance for local routes\n")
9671{
9672 struct bgp *bgp;
9673
9674 bgp = vty->index;
9675
9676 bgp->distance_ebgp= 0;
9677 bgp->distance_ibgp = 0;
9678 bgp->distance_local = 0;
9679 return CMD_SUCCESS;
9680}
9681
9682ALIAS (no_bgp_distance,
9683 no_bgp_distance2_cmd,
9684 "no distance bgp",
9685 NO_STR
9686 "Define an administrative distance\n"
9687 "BGP distance\n")
9688
9689DEFUN (bgp_distance_source,
9690 bgp_distance_source_cmd,
9691 "distance <1-255> A.B.C.D/M",
9692 "Define an administrative distance\n"
9693 "Administrative distance\n"
9694 "IP source prefix\n")
9695{
9696 bgp_distance_set (vty, argv[0], argv[1], NULL);
9697 return CMD_SUCCESS;
9698}
9699
9700DEFUN (no_bgp_distance_source,
9701 no_bgp_distance_source_cmd,
9702 "no distance <1-255> A.B.C.D/M",
9703 NO_STR
9704 "Define an administrative distance\n"
9705 "Administrative distance\n"
9706 "IP source prefix\n")
9707{
9708 bgp_distance_unset (vty, argv[0], argv[1], NULL);
9709 return CMD_SUCCESS;
9710}
9711
9712DEFUN (bgp_distance_source_access_list,
9713 bgp_distance_source_access_list_cmd,
9714 "distance <1-255> A.B.C.D/M WORD",
9715 "Define an administrative distance\n"
9716 "Administrative distance\n"
9717 "IP source prefix\n"
9718 "Access list name\n")
9719{
9720 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
9721 return CMD_SUCCESS;
9722}
9723
9724DEFUN (no_bgp_distance_source_access_list,
9725 no_bgp_distance_source_access_list_cmd,
9726 "no distance <1-255> A.B.C.D/M WORD",
9727 NO_STR
9728 "Define an administrative distance\n"
9729 "Administrative distance\n"
9730 "IP source prefix\n"
9731 "Access list name\n")
9732{
9733 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
9734 return CMD_SUCCESS;
9735}
9736
9737DEFUN (bgp_damp_set,
9738 bgp_damp_set_cmd,
9739 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
9740 "BGP Specific commands\n"
9741 "Enable route-flap dampening\n"
9742 "Half-life time for the penalty\n"
9743 "Value to start reusing a route\n"
9744 "Value to start suppressing a route\n"
9745 "Maximum duration to suppress a stable route\n")
9746{
9747 struct bgp *bgp;
9748 int half = DEFAULT_HALF_LIFE * 60;
9749 int reuse = DEFAULT_REUSE;
9750 int suppress = DEFAULT_SUPPRESS;
9751 int max = 4 * half;
9752
9753 if (argc == 4)
9754 {
9755 half = atoi (argv[0]) * 60;
9756 reuse = atoi (argv[1]);
9757 suppress = atoi (argv[2]);
9758 max = atoi (argv[3]) * 60;
9759 }
9760 else if (argc == 1)
9761 {
9762 half = atoi (argv[0]) * 60;
9763 max = 4 * half;
9764 }
9765
9766 bgp = vty->index;
9767 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
9768 half, reuse, suppress, max);
9769}
9770
9771ALIAS (bgp_damp_set,
9772 bgp_damp_set2_cmd,
9773 "bgp dampening <1-45>",
9774 "BGP Specific commands\n"
9775 "Enable route-flap dampening\n"
9776 "Half-life time for the penalty\n")
9777
9778ALIAS (bgp_damp_set,
9779 bgp_damp_set3_cmd,
9780 "bgp dampening",
9781 "BGP Specific commands\n"
9782 "Enable route-flap dampening\n")
9783
9784DEFUN (bgp_damp_unset,
9785 bgp_damp_unset_cmd,
9786 "no bgp dampening",
9787 NO_STR
9788 "BGP Specific commands\n"
9789 "Enable route-flap dampening\n")
9790{
9791 struct bgp *bgp;
9792
9793 bgp = vty->index;
9794 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
9795}
9796
9797ALIAS (bgp_damp_unset,
9798 bgp_damp_unset2_cmd,
9799 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
9800 NO_STR
9801 "BGP Specific commands\n"
9802 "Enable route-flap dampening\n"
9803 "Half-life time for the penalty\n"
9804 "Value to start reusing a route\n"
9805 "Value to start suppressing a route\n"
9806 "Maximum duration to suppress a stable route\n")
9807
9808DEFUN (show_ip_bgp_dampened_paths,
9809 show_ip_bgp_dampened_paths_cmd,
9810 "show ip bgp dampened-paths",
9811 SHOW_STR
9812 IP_STR
9813 BGP_STR
9814 "Display paths suppressed due to dampening\n")
9815{
ajs5a646652004-11-05 01:25:55 +00009816 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
9817 NULL);
paul718e3742002-12-13 20:15:29 +00009818}
9819
9820DEFUN (show_ip_bgp_flap_statistics,
9821 show_ip_bgp_flap_statistics_cmd,
9822 "show ip bgp flap-statistics",
9823 SHOW_STR
9824 IP_STR
9825 BGP_STR
9826 "Display flap statistics of routes\n")
9827{
ajs5a646652004-11-05 01:25:55 +00009828 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
9829 bgp_show_type_flap_statistics, NULL);
paul718e3742002-12-13 20:15:29 +00009830}
9831
9832/* Display specified route of BGP table. */
9833int
paulfd79ac92004-10-13 05:06:08 +00009834bgp_clear_damp_route (struct vty *vty, const char *view_name,
9835 const char *ip_str, afi_t afi, safi_t safi,
9836 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +00009837{
9838 int ret;
9839 struct prefix match;
9840 struct bgp_node *rn;
9841 struct bgp_node *rm;
9842 struct bgp_info *ri;
9843 struct bgp_info *ri_temp;
9844 struct bgp *bgp;
9845 struct bgp_table *table;
9846
9847 /* BGP structure lookup. */
9848 if (view_name)
9849 {
9850 bgp = bgp_lookup_by_name (view_name);
9851 if (bgp == NULL)
9852 {
9853 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9854 return CMD_WARNING;
9855 }
9856 }
9857 else
9858 {
9859 bgp = bgp_get_default ();
9860 if (bgp == NULL)
9861 {
9862 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
9863 return CMD_WARNING;
9864 }
9865 }
9866
9867 /* Check IP address argument. */
9868 ret = str2prefix (ip_str, &match);
9869 if (! ret)
9870 {
9871 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
9872 return CMD_WARNING;
9873 }
9874
9875 match.family = afi2family (afi);
9876
9877 if (safi == SAFI_MPLS_VPN)
9878 {
9879 for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn))
9880 {
9881 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
9882 continue;
9883
9884 if ((table = rn->info) != NULL)
9885 if ((rm = bgp_node_match (table, &match)) != NULL)
9886 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
9887 {
9888 ri = rm->info;
9889 while (ri)
9890 {
9891 if (ri->damp_info)
9892 {
9893 ri_temp = ri->next;
9894 bgp_damp_info_free (ri->damp_info, 1);
9895 ri = ri_temp;
9896 }
9897 else
9898 ri = ri->next;
9899 }
9900 }
9901 }
9902 }
9903 else
9904 {
9905 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
9906 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
9907 {
9908 ri = rn->info;
9909 while (ri)
9910 {
9911 if (ri->damp_info)
9912 {
9913 ri_temp = ri->next;
9914 bgp_damp_info_free (ri->damp_info, 1);
9915 ri = ri_temp;
9916 }
9917 else
9918 ri = ri->next;
9919 }
9920 }
9921 }
9922
9923 return CMD_SUCCESS;
9924}
9925
9926DEFUN (clear_ip_bgp_dampening,
9927 clear_ip_bgp_dampening_cmd,
9928 "clear ip bgp dampening",
9929 CLEAR_STR
9930 IP_STR
9931 BGP_STR
9932 "Clear route flap dampening information\n")
9933{
9934 bgp_damp_info_clean ();
9935 return CMD_SUCCESS;
9936}
9937
9938DEFUN (clear_ip_bgp_dampening_prefix,
9939 clear_ip_bgp_dampening_prefix_cmd,
9940 "clear ip bgp dampening A.B.C.D/M",
9941 CLEAR_STR
9942 IP_STR
9943 BGP_STR
9944 "Clear route flap dampening information\n"
9945 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
9946{
9947 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
9948 SAFI_UNICAST, NULL, 1);
9949}
9950
9951DEFUN (clear_ip_bgp_dampening_address,
9952 clear_ip_bgp_dampening_address_cmd,
9953 "clear ip bgp dampening A.B.C.D",
9954 CLEAR_STR
9955 IP_STR
9956 BGP_STR
9957 "Clear route flap dampening information\n"
9958 "Network to clear damping information\n")
9959{
9960 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
9961 SAFI_UNICAST, NULL, 0);
9962}
9963
9964DEFUN (clear_ip_bgp_dampening_address_mask,
9965 clear_ip_bgp_dampening_address_mask_cmd,
9966 "clear ip bgp dampening A.B.C.D A.B.C.D",
9967 CLEAR_STR
9968 IP_STR
9969 BGP_STR
9970 "Clear route flap dampening information\n"
9971 "Network to clear damping information\n"
9972 "Network mask\n")
9973{
9974 int ret;
9975 char prefix_str[BUFSIZ];
9976
9977 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
9978 if (! ret)
9979 {
9980 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
9981 return CMD_WARNING;
9982 }
9983
9984 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
9985 SAFI_UNICAST, NULL, 0);
9986}
9987
9988int
9989bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
9990 afi_t afi, safi_t safi, int *write)
9991{
9992 struct bgp_node *prn;
9993 struct bgp_node *rn;
9994 struct bgp_table *table;
9995 struct prefix *p;
9996 struct prefix_rd *prd;
9997 struct bgp_static *bgp_static;
9998 u_int32_t label;
9999 char buf[SU_ADDRSTRLEN];
10000 char rdbuf[RD_ADDRSTRLEN];
10001
10002 /* Network configuration. */
10003 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
10004 if ((table = prn->info) != NULL)
10005 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
10006 if ((bgp_static = rn->info) != NULL)
10007 {
10008 p = &rn->p;
10009 prd = (struct prefix_rd *) &prn->p;
10010
10011 /* "address-family" display. */
10012 bgp_config_write_family_header (vty, afi, safi, write);
10013
10014 /* "network" configuration display. */
10015 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
10016 label = decode_label (bgp_static->tag);
10017
10018 vty_out (vty, " network %s/%d rd %s tag %d",
10019 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10020 p->prefixlen,
10021 rdbuf, label);
10022 vty_out (vty, "%s", VTY_NEWLINE);
10023 }
10024 return 0;
10025}
10026
10027/* Configuration of static route announcement and aggregate
10028 information. */
10029int
10030bgp_config_write_network (struct vty *vty, struct bgp *bgp,
10031 afi_t afi, safi_t safi, int *write)
10032{
10033 struct bgp_node *rn;
10034 struct prefix *p;
10035 struct bgp_static *bgp_static;
10036 struct bgp_aggregate *bgp_aggregate;
10037 char buf[SU_ADDRSTRLEN];
10038
10039 if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
10040 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
10041
10042 /* Network configuration. */
10043 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
10044 if ((bgp_static = rn->info) != NULL)
10045 {
10046 p = &rn->p;
10047
10048 /* "address-family" display. */
10049 bgp_config_write_family_header (vty, afi, safi, write);
10050
10051 /* "network" configuration display. */
10052 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
10053 {
10054 u_int32_t destination;
10055 struct in_addr netmask;
10056
10057 destination = ntohl (p->u.prefix4.s_addr);
10058 masklen2ip (p->prefixlen, &netmask);
10059 vty_out (vty, " network %s",
10060 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
10061
10062 if ((IN_CLASSC (destination) && p->prefixlen == 24)
10063 || (IN_CLASSB (destination) && p->prefixlen == 16)
10064 || (IN_CLASSA (destination) && p->prefixlen == 8)
10065 || p->u.prefix4.s_addr == 0)
10066 {
10067 /* Natural mask is not display. */
10068 }
10069 else
10070 vty_out (vty, " mask %s", inet_ntoa (netmask));
10071 }
10072 else
10073 {
10074 vty_out (vty, " network %s/%d",
10075 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10076 p->prefixlen);
10077 }
10078
10079 if (bgp_static->rmap.name)
10080 vty_out (vty, " route-map %s", bgp_static->rmap.name);
10081 else if (bgp_static->backdoor)
10082 vty_out (vty, " backdoor");
10083
10084 vty_out (vty, "%s", VTY_NEWLINE);
10085 }
10086
10087 /* Aggregate-address configuration. */
10088 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
10089 if ((bgp_aggregate = rn->info) != NULL)
10090 {
10091 p = &rn->p;
10092
10093 /* "address-family" display. */
10094 bgp_config_write_family_header (vty, afi, safi, write);
10095
10096 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
10097 {
10098 struct in_addr netmask;
10099
10100 masklen2ip (p->prefixlen, &netmask);
10101 vty_out (vty, " aggregate-address %s %s",
10102 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10103 inet_ntoa (netmask));
10104 }
10105 else
10106 {
10107 vty_out (vty, " aggregate-address %s/%d",
10108 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
10109 p->prefixlen);
10110 }
10111
10112 if (bgp_aggregate->as_set)
10113 vty_out (vty, " as-set");
10114
10115 if (bgp_aggregate->summary_only)
10116 vty_out (vty, " summary-only");
10117
10118 vty_out (vty, "%s", VTY_NEWLINE);
10119 }
10120
10121 return 0;
10122}
10123
10124int
10125bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
10126{
10127 struct bgp_node *rn;
10128 struct bgp_distance *bdistance;
10129
10130 /* Distance configuration. */
10131 if (bgp->distance_ebgp
10132 && bgp->distance_ibgp
10133 && bgp->distance_local
10134 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
10135 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
10136 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
10137 vty_out (vty, " distance bgp %d %d %d%s",
10138 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
10139 VTY_NEWLINE);
10140
10141 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
10142 if ((bdistance = rn->info) != NULL)
10143 {
10144 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
10145 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
10146 bdistance->access_list ? bdistance->access_list : "",
10147 VTY_NEWLINE);
10148 }
10149
10150 return 0;
10151}
10152
10153/* Allocate routing table structure and install commands. */
10154void
10155bgp_route_init ()
10156{
10157 /* Init BGP distance table. */
10158 bgp_distance_table = bgp_table_init ();
10159
10160 /* IPv4 BGP commands. */
10161 install_element (BGP_NODE, &bgp_network_cmd);
10162 install_element (BGP_NODE, &bgp_network_mask_cmd);
10163 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
10164 install_element (BGP_NODE, &bgp_network_route_map_cmd);
10165 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
10166 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
10167 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
10168 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
10169 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
10170 install_element (BGP_NODE, &no_bgp_network_cmd);
10171 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
10172 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
10173 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
10174 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
10175 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
10176 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
10177 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
10178 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
10179
10180 install_element (BGP_NODE, &aggregate_address_cmd);
10181 install_element (BGP_NODE, &aggregate_address_mask_cmd);
10182 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
10183 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
10184 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
10185 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
10186 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
10187 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
10188 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
10189 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
10190 install_element (BGP_NODE, &no_aggregate_address_cmd);
10191 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
10192 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
10193 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
10194 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
10195 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
10196 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
10197 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
10198 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
10199 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
10200
10201 /* IPv4 unicast configuration. */
10202 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
10203 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
10204 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
10205 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
10206 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
10207 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
10208 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
10209 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
10210 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
10211 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
10212 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
10213 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
10214 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
10215 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
10216 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
10217 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
10218 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
10219 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
10220 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
10221 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
10222 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
10223 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
10224 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
10225 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
10226 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
10227 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
10228 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
10229 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
10230 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
10231 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
10232 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
10233 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
10234
10235 /* IPv4 multicast configuration. */
10236 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
10237 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
10238 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
10239 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
10240 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
10241 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
10242 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
10243 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
10244 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
10245 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
10246 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
10247 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
10248 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
10249 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
10250 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
10251 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
10252 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
10253 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
10254 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
10255 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
10256 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
10257 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
10258 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
10259 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
10260 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
10261 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
10262 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
10263 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
10264 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
10265 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
10266 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
10267 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
10268
10269 install_element (VIEW_NODE, &show_ip_bgp_cmd);
10270 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
10271 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
10272 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
10273 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
10274 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
10275 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
10276 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
10277 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
10278 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
10279 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
10280 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
10281 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
10282 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
10283 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
10284 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
10285 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
10286 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
10287 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
10288 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
10289 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
10290 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
10291 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
10292 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
10293 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
10294 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
10295 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
10296 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
10297 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
10298 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
10299 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
10300 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
10301 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
10302 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
10303 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
10304 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
10305 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
10306 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
10307 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
10308 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
10309 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
10310 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
10311 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
10312 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
10313 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
10314 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
10315 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
10316 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
10317 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
10318 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
10319 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
10320 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
10321 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
10322 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
10323 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
10324 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
10325 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
10326 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
10327 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
10328 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
10329 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
10330 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
10331 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
10332 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
10333 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
10334 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
10335 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010336 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
10337 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
10338 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
10339 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
10340 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
10341 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010342
10343 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
10344 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
10345 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
10346 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
10347 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
10348 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
10349 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
10350 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
10351 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
10352 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
10353 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
10354 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
10355 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
10356 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
10357 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
10358 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
10359 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
10360 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
10361 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
10362 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
10363 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
10364 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
10365 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
10366 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
10367 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
10368 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
10369 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
10370 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
10371 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
10372 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
10373 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
10374 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
10375 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
10376 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
10377 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
10378 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
10379 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
10380 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
10381 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
10382 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
10383 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
10384 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
10385 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
10386 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
10387 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
10388 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
10389 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
10390 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
10391 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
10392 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
10393 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
10394 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
10395 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
10396 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
10397 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
10398 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
10399 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
10400 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
10401 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
10402 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
10403 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
10404 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
10405 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
10406 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
10407 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
10408 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
10409 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010410 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
10411 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
10412 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
10413 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
10414 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
10415 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010416
10417 /* BGP dampening clear commands */
10418 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
10419 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
10420 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
10421 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
10422
10423#ifdef HAVE_IPV6
10424 /* New config IPv6 BGP commands. */
10425 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
10426 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
10427 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
10428 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
10429
10430 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
10431 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
10432 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
10433 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
10434
10435 /* Old config IPv6 BGP commands. */
10436 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
10437 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
10438
10439 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
10440 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
10441 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
10442 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
10443
10444 install_element (VIEW_NODE, &show_bgp_cmd);
10445 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
10446 install_element (VIEW_NODE, &show_bgp_route_cmd);
10447 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
10448 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
10449 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
10450 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
10451 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
10452 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
10453 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
10454 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
10455 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
10456 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
10457 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
10458 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
10459 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
10460 install_element (VIEW_NODE, &show_bgp_community_cmd);
10461 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
10462 install_element (VIEW_NODE, &show_bgp_community2_cmd);
10463 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
10464 install_element (VIEW_NODE, &show_bgp_community3_cmd);
10465 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
10466 install_element (VIEW_NODE, &show_bgp_community4_cmd);
10467 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
10468 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
10469 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
10470 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
10471 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
10472 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
10473 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
10474 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
10475 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
10476 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
10477 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
10478 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
10479 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
10480 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
10481 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
10482 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
10483 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
10484 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
10485 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
10486 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
10487 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
10488 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
10489 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000010490 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
10491 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
10492 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
10493 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010494 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
10495 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
10496 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000010497 install_element (VIEW_NODE, &show_bgp_view_cmd);
10498 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
10499 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
10500 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
10501 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
10502 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
10503 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
10504 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
10505 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
10506 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
10507 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
10508 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
10509 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
10510 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
10511 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
10512 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
10513 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
10514 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010515 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
10516 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
10517 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010518
10519 install_element (ENABLE_NODE, &show_bgp_cmd);
10520 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
10521 install_element (ENABLE_NODE, &show_bgp_route_cmd);
10522 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
10523 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
10524 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
10525 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
10526 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
10527 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
10528 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
10529 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
10530 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
10531 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
10532 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
10533 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
10534 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
10535 install_element (ENABLE_NODE, &show_bgp_community_cmd);
10536 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
10537 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
10538 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
10539 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
10540 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
10541 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
10542 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
10543 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
10544 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
10545 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
10546 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
10547 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
10548 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
10549 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
10550 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
10551 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
10552 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
10553 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
10554 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
10555 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
10556 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
10557 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
10558 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
10559 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
10560 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
10561 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
10562 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
10563 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
10564 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000010565 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
10566 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
10567 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
10568 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010569 install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
10570 install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
10571 install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000010572 install_element (ENABLE_NODE, &show_bgp_view_cmd);
10573 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
10574 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
10575 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
10576 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
10577 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
10578 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
10579 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
10580 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
10581 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
10582 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
10583 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
10584 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
10585 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
10586 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
10587 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
10588 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
10589 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
paulfee0f4c2004-09-13 05:12:46 +000010590 install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
10591 install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
10592 install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000010593
10594 /* old command */
10595 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
10596 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
10597 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
10598 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
10599 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
10600 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
10601 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
10602 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
10603 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
10604 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
10605 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
10606 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
10607 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
10608 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
10609 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
10610 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
10611 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
10612 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
10613 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
10614 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
10615 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
10616 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
10617 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
10618 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
10619 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
10620 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
10621 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
10622 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
10623 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
10624 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
10625 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
10626 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
10627 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
10628 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
10629 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
10630 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
paulbb46e942003-10-24 19:02:03 +000010631
paul718e3742002-12-13 20:15:29 +000010632 /* old command */
10633 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
10634 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
10635 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
10636 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
10637 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
10638 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
10639 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
10640 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
10641 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
10642 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
10643 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
10644 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
10645 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
10646 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
10647 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
10648 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
10649 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
10650 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
10651 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
10652 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
10653 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
10654 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
10655 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
10656 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
10657 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
10658 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
10659 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
10660 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
10661 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
10662 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
10663 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
10664 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
10665 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
10666 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
10667 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
10668 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
10669
10670 /* old command */
10671 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
10672 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
10673 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
10674 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
10675
10676 /* old command */
10677 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
10678 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
10679 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
10680 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
10681
10682 /* old command */
10683 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
10684 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
10685 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
10686 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
10687#endif /* HAVE_IPV6 */
10688
10689 install_element (BGP_NODE, &bgp_distance_cmd);
10690 install_element (BGP_NODE, &no_bgp_distance_cmd);
10691 install_element (BGP_NODE, &no_bgp_distance2_cmd);
10692 install_element (BGP_NODE, &bgp_distance_source_cmd);
10693 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
10694 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
10695 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
10696
10697 install_element (BGP_NODE, &bgp_damp_set_cmd);
10698 install_element (BGP_NODE, &bgp_damp_set2_cmd);
10699 install_element (BGP_NODE, &bgp_damp_set3_cmd);
10700 install_element (BGP_NODE, &bgp_damp_unset_cmd);
10701 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
10702 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
10703 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
10704 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
10705 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
10706 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
10707}