blob: 97636effe44a40813038a8e7b229c6f60b3d08a3 [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"
55
56/* Extern from bgp_dump.c */
57extern char *bgp_origin_str[];
58extern char *bgp_origin_long_str[];
59
60struct bgp_node *
61bgp_afi_node_get (struct bgp *bgp, afi_t afi, safi_t safi, struct prefix *p,
62 struct prefix_rd *prd)
63{
64 struct bgp_node *rn;
65 struct bgp_node *prn = NULL;
66 struct bgp_table *table;
67
68 if (safi == SAFI_MPLS_VPN)
69 {
70 prn = bgp_node_get (bgp->rib[afi][safi], (struct prefix *) prd);
71
72 if (prn->info == NULL)
73 prn->info = bgp_table_init ();
74 else
75 bgp_unlock_node (prn);
76 table = prn->info;
77 }
78 else
79 table = bgp->rib[afi][safi];
80
81 rn = bgp_node_get (table, p);
82
83 if (safi == SAFI_MPLS_VPN)
84 rn->prn = prn;
85
86 return rn;
87}
88
89/* Allocate new bgp info structure. */
90struct bgp_info *
91bgp_info_new ()
92{
93 struct bgp_info *new;
94
95 new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
96 memset (new, 0, sizeof (struct bgp_info));
97
98 return new;
99}
100
101/* Free bgp route information. */
102void
103bgp_info_free (struct bgp_info *binfo)
104{
105 if (binfo->attr)
106 bgp_attr_unintern (binfo->attr);
107
108 if (binfo->damp_info)
109 bgp_damp_info_free (binfo->damp_info, 0);
110
111 XFREE (MTYPE_BGP_ROUTE, binfo);
112}
113
114void
115bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
116{
117 struct bgp_info *top;
118
119 top = rn->info;
120
121 ri->next = rn->info;
122 ri->prev = NULL;
123 if (top)
124 top->prev = ri;
125 rn->info = ri;
126}
127
128void
129bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
130{
131 if (ri->next)
132 ri->next->prev = ri->prev;
133 if (ri->prev)
134 ri->prev->next = ri->next;
135 else
136 rn->info = ri->next;
137}
138
139/* Get MED value. If MED value is missing and "bgp bestpath
140 missing-as-worst" is specified, treat it as the worst value. */
141u_int32_t
142bgp_med_value (struct attr *attr, struct bgp *bgp)
143{
144 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
145 return attr->med;
146 else
147 {
148 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
paul3b424972003-10-13 09:47:32 +0000149 return BGP_MED_MAX;
paul718e3742002-12-13 20:15:29 +0000150 else
151 return 0;
152 }
153}
154
155/* Compare two bgp route entity. br is preferable then return 1. */
156int
157bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist)
158{
159 u_int32_t new_pref;
160 u_int32_t exist_pref;
161 u_int32_t new_med;
162 u_int32_t exist_med;
163 struct in_addr new_id;
164 struct in_addr exist_id;
165 int new_cluster;
166 int exist_cluster;
167 int internal_as_route = 0;
168 int confed_as_route = 0;
169 int ret;
170
171 /* 0. Null check. */
172 if (new == NULL)
173 return 0;
174 if (exist == NULL)
175 return 1;
176
177 /* 1. Weight check. */
178 if (new->attr->weight > exist->attr->weight)
179 return 1;
180 if (new->attr->weight < exist->attr->weight)
181 return 0;
182
183 /* 2. Local preference check. */
184 if (new->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
185 new_pref = new->attr->local_pref;
186 else
187 new_pref = bgp->default_local_pref;
188
189 if (exist->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
190 exist_pref = exist->attr->local_pref;
191 else
192 exist_pref = bgp->default_local_pref;
193
194 if (new_pref > exist_pref)
195 return 1;
196 if (new_pref < exist_pref)
197 return 0;
198
199 /* 3. Local route check. */
200 if (new->sub_type == BGP_ROUTE_STATIC)
201 return 1;
202 if (exist->sub_type == BGP_ROUTE_STATIC)
203 return 0;
204
205 if (new->sub_type == BGP_ROUTE_REDISTRIBUTE)
206 return 1;
207 if (exist->sub_type == BGP_ROUTE_REDISTRIBUTE)
208 return 0;
209
210 if (new->sub_type == BGP_ROUTE_AGGREGATE)
211 return 1;
212 if (exist->sub_type == BGP_ROUTE_AGGREGATE)
213 return 0;
214
215 /* 4. AS path length check. */
216 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
217 {
218 if (new->attr->aspath->count < exist->attr->aspath->count)
219 return 1;
220 if (new->attr->aspath->count > exist->attr->aspath->count)
221 return 0;
222 }
223
224 /* 5. Origin check. */
225 if (new->attr->origin < exist->attr->origin)
226 return 1;
227 if (new->attr->origin > exist->attr->origin)
228 return 0;
229
230 /* 6. MED check. */
231 internal_as_route = (new->attr->aspath->length == 0
232 && exist->attr->aspath->length == 0);
233 confed_as_route = (new->attr->aspath->length > 0
234 && exist->attr->aspath->length > 0
235 && new->attr->aspath->count == 0
236 && exist->attr->aspath->count == 0);
237
238 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
239 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
240 && confed_as_route)
241 || aspath_cmp_left (new->attr->aspath, exist->attr->aspath)
242 || aspath_cmp_left_confed (new->attr->aspath, exist->attr->aspath)
243 || internal_as_route)
244 {
245 new_med = bgp_med_value (new->attr, bgp);
246 exist_med = bgp_med_value (exist->attr, bgp);
247
248 if (new_med < exist_med)
249 return 1;
250 if (new_med > exist_med)
251 return 0;
252 }
253
254 /* 7. Peer type check. */
255 if (peer_sort (new->peer) == BGP_PEER_EBGP
256 && peer_sort (exist->peer) == BGP_PEER_IBGP)
257 return 1;
258 if (peer_sort (new->peer) == BGP_PEER_EBGP
259 && peer_sort (exist->peer) == BGP_PEER_CONFED)
260 return 1;
261 if (peer_sort (new->peer) == BGP_PEER_IBGP
262 && peer_sort (exist->peer) == BGP_PEER_EBGP)
263 return 0;
264 if (peer_sort (new->peer) == BGP_PEER_CONFED
265 && peer_sort (exist->peer) == BGP_PEER_EBGP)
266 return 0;
267
268 /* 8. IGP metric check. */
269 if (new->igpmetric < exist->igpmetric)
270 return 1;
271 if (new->igpmetric > exist->igpmetric)
272 return 0;
273
274 /* 9. Maximum path check. */
275
276 /* 10. If both paths are external, prefer the path that was received
277 first (the oldest one). This step minimizes route-flap, since a
278 newer path won't displace an older one, even if it was the
279 preferred route based on the additional decision criteria below. */
280 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
281 && peer_sort (new->peer) == BGP_PEER_EBGP
282 && peer_sort (exist->peer) == BGP_PEER_EBGP)
283 {
284 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
285 return 1;
286 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
287 return 0;
288 }
289
290 /* 11. Rourter-ID comparision. */
291 if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
292 new_id.s_addr = new->attr->originator_id.s_addr;
293 else
294 new_id.s_addr = new->peer->remote_id.s_addr;
295 if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
296 exist_id.s_addr = exist->attr->originator_id.s_addr;
297 else
298 exist_id.s_addr = exist->peer->remote_id.s_addr;
299
300 if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
301 return 1;
302 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
303 return 0;
304
305 /* 12. Cluster length comparision. */
306 if (new->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
307 new_cluster = new->attr->cluster->length;
308 else
309 new_cluster = 0;
310 if (exist->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
311 exist_cluster = exist->attr->cluster->length;
312 else
313 exist_cluster = 0;
314
315 if (new_cluster < exist_cluster)
316 return 1;
317 if (new_cluster > exist_cluster)
318 return 0;
319
320 /* 13. Neighbor address comparision. */
321 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
322
323 if (ret == 1)
324 return 0;
325 if (ret == -1)
326 return 1;
327
328 return 1;
329}
330
331enum filter_type
332bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
333 afi_t afi, safi_t safi)
334{
335 struct bgp_filter *filter;
336
337 filter = &peer->filter[afi][safi];
338
339 if (DISTRIBUTE_IN_NAME (filter))
340 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
341 return FILTER_DENY;
342
343 if (PREFIX_LIST_IN_NAME (filter))
344 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
345 return FILTER_DENY;
346
347 if (FILTER_LIST_IN_NAME (filter))
348 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
349 return FILTER_DENY;
350
351 return FILTER_PERMIT;
352}
353
354enum filter_type
355bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
356 afi_t afi, safi_t safi)
357{
358 struct bgp_filter *filter;
359
360 filter = &peer->filter[afi][safi];
361
362 if (DISTRIBUTE_OUT_NAME (filter))
363 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
364 return FILTER_DENY;
365
366 if (PREFIX_LIST_OUT_NAME (filter))
367 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
368 return FILTER_DENY;
369
370 if (FILTER_LIST_OUT_NAME (filter))
371 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
372 return FILTER_DENY;
373
374 return FILTER_PERMIT;
375}
376
377/* If community attribute includes no_export then return 1. */
378int
379bgp_community_filter (struct peer *peer, struct attr *attr)
380{
381 if (attr->community)
382 {
383 /* NO_ADVERTISE check. */
384 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
385 return 1;
386
387 /* NO_EXPORT check. */
388 if (peer_sort (peer) == BGP_PEER_EBGP &&
389 community_include (attr->community, COMMUNITY_NO_EXPORT))
390 return 1;
391
392 /* NO_EXPORT_SUBCONFED check. */
393 if (peer_sort (peer) == BGP_PEER_EBGP
394 || peer_sort (peer) == BGP_PEER_CONFED)
395 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
396 return 1;
397 }
398 return 0;
399}
400
401/* Route reflection loop check. */
402static int
403bgp_cluster_filter (struct peer *peer, struct attr *attr)
404{
405 struct in_addr cluster_id;
406
407 if (attr->cluster)
408 {
409 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
410 cluster_id = peer->bgp->cluster_id;
411 else
412 cluster_id = peer->bgp->router_id;
413
414 if (cluster_loop_check (attr->cluster, cluster_id))
415 return 1;
416 }
417 return 0;
418}
419
420int
421bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
422 afi_t afi, safi_t safi)
423{
424 struct bgp_filter *filter;
425 struct bgp_info info;
426 route_map_result_t ret;
427
428 filter = &peer->filter[afi][safi];
429
430 /* Apply default weight value. */
431 attr->weight = peer->weight;
432
433 /* Route map apply. */
434 if (ROUTE_MAP_IN_NAME (filter))
435 {
436 /* Duplicate current value to new strucutre for modification. */
437 info.peer = peer;
438 info.attr = attr;
439
paulac41b2a2003-08-12 05:32:27 +0000440 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
441
paul718e3742002-12-13 20:15:29 +0000442 /* Apply BGP route map to the attribute. */
443 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
paulac41b2a2003-08-12 05:32:27 +0000444
445 peer->rmap_type = 0;
446
paul718e3742002-12-13 20:15:29 +0000447 if (ret == RMAP_DENYMATCH)
448 {
449 /* Free newly generated AS path and community by route-map. */
450 bgp_attr_flush (attr);
451 return RMAP_DENY;
452 }
453 }
454 return RMAP_PERMIT;
455}
456
457int
458bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
459 struct attr *attr, afi_t afi, safi_t safi)
460{
461 int ret;
462 char buf[SU_ADDRSTRLEN];
463 struct bgp_filter *filter;
464 struct bgp_info info;
465 struct peer *from;
466 struct bgp *bgp;
467 struct attr dummy_attr;
468 int transparent;
469 int reflect;
470
471 from = ri->peer;
472 filter = &peer->filter[afi][safi];
473 bgp = peer->bgp;
474
475#ifdef DISABLE_BGP_ANNOUNCE
476 return 0;
477#endif
478
479 /* Do not send back route to sender. */
480 if (from == peer)
481 return 0;
482
paul35be31b2004-05-01 18:17:04 +0000483 /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */
484 if (p->family == AF_INET
485 && IPV4_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop))
486 return 0;
487#ifdef HAVE_IPV6
488 if (p->family == AF_INET6
489 && IPV6_ADDR_SAME(&peer->remote_id, &ri->attr->nexthop))
490 return 0;
491#endif
492
paul718e3742002-12-13 20:15:29 +0000493 /* Aggregate-address suppress check. */
494 if (ri->suppress)
495 if (! UNSUPPRESS_MAP_NAME (filter))
496 return 0;
497
498 /* Default route check. */
499 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
500 {
501 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
502 return 0;
503#ifdef HAVE_IPV6
504 else if (p->family == AF_INET6 && p->prefixlen == 0)
505 return 0;
506#endif /* HAVE_IPV6 */
507 }
508
paul286e1e72003-08-08 00:24:31 +0000509 /* Transparency check. */
510 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
511 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
512 transparent = 1;
513 else
514 transparent = 0;
515
paul718e3742002-12-13 20:15:29 +0000516 /* If community is not disabled check the no-export and local. */
paul286e1e72003-08-08 00:24:31 +0000517 if (! transparent && bgp_community_filter (peer, ri->attr))
paul718e3742002-12-13 20:15:29 +0000518 return 0;
519
520 /* If the attribute has originator-id and it is same as remote
521 peer's id. */
522 if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
523 {
524 if (IPV4_ADDR_SAME (&peer->remote_id, &ri->attr->originator_id))
525 {
526 if (BGP_DEBUG (filter, FILTER))
527 zlog (peer->log, LOG_INFO,
528 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
529 peer->host,
530 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
531 p->prefixlen);
532 return 0;
533 }
534 }
535
536 /* ORF prefix-list filter check */
537 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
538 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
539 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
540 if (peer->orf_plist[afi][safi])
541 {
542 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
543 return 0;
544 }
545
546 /* Output filter check. */
547 if (bgp_output_filter (peer, p, ri->attr, afi, safi) == FILTER_DENY)
548 {
549 if (BGP_DEBUG (filter, FILTER))
550 zlog (peer->log, LOG_INFO,
551 "%s [Update:SEND] %s/%d is filtered",
552 peer->host,
553 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
554 p->prefixlen);
555 return 0;
556 }
557
558#ifdef BGP_SEND_ASPATH_CHECK
559 /* AS path loop check. */
560 if (aspath_loop_check (ri->attr->aspath, peer->as))
561 {
562 if (BGP_DEBUG (filter, FILTER))
563 zlog (peer->log, LOG_INFO,
564 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
565 peer->host, peer->as);
566 return 0;
567 }
568#endif /* BGP_SEND_ASPATH_CHECK */
569
570 /* If we're a CONFED we need to loop check the CONFED ID too */
571 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
572 {
573 if (aspath_loop_check(ri->attr->aspath, bgp->confed_id))
574 {
575 if (BGP_DEBUG (filter, FILTER))
576 zlog (peer->log, LOG_INFO,
577 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
578 peer->host,
579 bgp->confed_id);
580 return 0;
581 }
582 }
583
584 /* Route-Reflect check. */
585 if (peer_sort (from) == BGP_PEER_IBGP && peer_sort (peer) == BGP_PEER_IBGP)
586 reflect = 1;
587 else
588 reflect = 0;
589
590 /* IBGP reflection check. */
591 if (reflect)
592 {
593 /* A route from a Client peer. */
594 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
595 {
596 /* Reflect to all the Non-Client peers and also to the
597 Client peers other than the originator. Originator check
598 is already done. So there is noting to do. */
599 /* no bgp client-to-client reflection check. */
600 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
601 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
602 return 0;
603 }
604 else
605 {
606 /* A route from a Non-client peer. Reflect to all other
607 clients. */
608 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
609 return 0;
610 }
611 }
612
613 /* For modify attribute, copy it to temporary structure. */
614 *attr = *ri->attr;
615
616 /* If local-preference is not set. */
617 if ((peer_sort (peer) == BGP_PEER_IBGP
618 || peer_sort (peer) == BGP_PEER_CONFED)
619 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
620 {
621 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
622 attr->local_pref = bgp->default_local_pref;
623 }
624
paul718e3742002-12-13 20:15:29 +0000625 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
626 if (peer_sort (peer) == BGP_PEER_EBGP
627 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
628 {
629 if (ri->peer != bgp->peer_self && ! transparent
630 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
631 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
632 }
633
634 /* next-hop-set */
635 if (transparent || reflect
636 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
637 && ((p->family == AF_INET && attr->nexthop.s_addr)
paul286e1e72003-08-08 00:24:31 +0000638#ifdef HAVE_IPV6
639 || (p->family == AF_INET6 && ri->peer != bgp->peer_self)
640#endif /* HAVE_IPV6 */
641 )))
paul718e3742002-12-13 20:15:29 +0000642 {
643 /* NEXT-HOP Unchanged. */
644 }
645 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
646 || (p->family == AF_INET && attr->nexthop.s_addr == 0)
647#ifdef HAVE_IPV6
648 || (p->family == AF_INET6 && ri->peer == bgp->peer_self)
649#endif /* HAVE_IPV6 */
650 || (peer_sort (peer) == BGP_PEER_EBGP
651 && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0))
652 {
653 /* Set IPv4 nexthop. */
654 if (p->family == AF_INET)
655 {
656 if (safi == SAFI_MPLS_VPN)
657 memcpy (&attr->mp_nexthop_global_in, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
658 else
659 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
660 }
661#ifdef HAVE_IPV6
662 /* Set IPv6 nexthop. */
663 if (p->family == AF_INET6)
664 {
665 /* IPv6 global nexthop must be included. */
666 memcpy (&attr->mp_nexthop_global, &peer->nexthop.v6_global,
667 IPV6_MAX_BYTELEN);
668 attr->mp_nexthop_len = 16;
669 }
670#endif /* HAVE_IPV6 */
671 }
672
673#ifdef HAVE_IPV6
674 if (p->family == AF_INET6)
675 {
676 /* Link-local address should not be transit to different peer. */
677 attr->mp_nexthop_len = 16;
678
679 /* Set link-local address for shared network peer. */
680 if (peer->shared_network
681 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
682 {
683 memcpy (&attr->mp_nexthop_local, &peer->nexthop.v6_local,
684 IPV6_MAX_BYTELEN);
685 attr->mp_nexthop_len = 32;
686 }
687
688 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
689 address.*/
690 if (reflect)
691 attr->mp_nexthop_len = 16;
692
693 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
694 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
695 attr->mp_nexthop_len = 16;
696 }
697#endif /* HAVE_IPV6 */
698
699 /* If this is EBGP peer and remove-private-AS is set. */
700 if (peer_sort (peer) == BGP_PEER_EBGP
701 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
702 && aspath_private_as_check (attr->aspath))
703 attr->aspath = aspath_empty_get ();
704
705 /* Route map & unsuppress-map apply. */
706 if (ROUTE_MAP_OUT_NAME (filter)
707 || ri->suppress)
708 {
709 info.peer = peer;
710 info.attr = attr;
711
712 /* The route reflector is not allowed to modify the attributes
713 of the reflected IBGP routes. */
714 if (peer_sort (from) == BGP_PEER_IBGP
715 && peer_sort (peer) == BGP_PEER_IBGP)
716 {
717 dummy_attr = *attr;
718 info.attr = &dummy_attr;
719 }
paulac41b2a2003-08-12 05:32:27 +0000720
721 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
722
paul718e3742002-12-13 20:15:29 +0000723 if (ri->suppress)
724 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
725 else
726 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
727
paulac41b2a2003-08-12 05:32:27 +0000728 peer->rmap_type = 0;
729
paul718e3742002-12-13 20:15:29 +0000730 if (ret == RMAP_DENYMATCH)
731 {
732 bgp_attr_flush (attr);
733 return 0;
734 }
735 }
736 return 1;
737}
738
739int
740bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
741{
742 struct prefix *p;
743 struct bgp_info *ri;
744 struct bgp_info *new_select;
745 struct bgp_info *old_select;
746 struct listnode *nn;
747 struct peer *peer;
748 struct attr attr;
749 struct bgp_info *ri1;
750 struct bgp_info *ri2;
751
752 p = &rn->p;
753
754 /* bgp deterministic-med */
755 new_select = NULL;
756 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
757 for (ri1 = rn->info; ri1; ri1 = ri1->next)
758 {
759 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
760 continue;
761 if (BGP_INFO_HOLDDOWN (ri1))
762 continue;
763
764 new_select = ri1;
765 if (ri1->next)
766 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
767 {
768 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
769 continue;
770 if (BGP_INFO_HOLDDOWN (ri2))
771 continue;
772
773 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
774 || aspath_cmp_left_confed (ri1->attr->aspath,
775 ri2->attr->aspath))
776 {
777 if (bgp_info_cmp (bgp, ri2, new_select))
778 {
779 UNSET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED);
780 new_select = ri2;
781 }
782
783 SET_FLAG (ri2->flags, BGP_INFO_DMED_CHECK);
784 }
785 }
786 SET_FLAG (new_select->flags, BGP_INFO_DMED_CHECK);
787 SET_FLAG (new_select->flags, BGP_INFO_DMED_SELECTED);
788 }
789
790 /* Check old selected route and new selected route. */
791 old_select = NULL;
792 new_select = NULL;
793 for (ri = rn->info; ri; ri = ri->next)
794 {
795 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
796 old_select = ri;
797
798 if (BGP_INFO_HOLDDOWN (ri))
799 continue;
800
801 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
802 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
803 {
804 UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK);
805 continue;
806 }
807 UNSET_FLAG (ri->flags, BGP_INFO_DMED_CHECK);
808 UNSET_FLAG (ri->flags, BGP_INFO_DMED_SELECTED);
809
810 if (bgp_info_cmp (bgp, ri, new_select))
811 new_select = ri;
812 }
813
814 /* Nothing to do. */
815 if (old_select && old_select == new_select)
816 {
817 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
818 {
819 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED))
820 bgp_zebra_announce (p, old_select, bgp);
821 return 0;
822 }
823 }
824
825 if (old_select)
826 UNSET_FLAG (old_select->flags, BGP_INFO_SELECTED);
827 if (new_select)
828 {
829 SET_FLAG (new_select->flags, BGP_INFO_SELECTED);
830 UNSET_FLAG (new_select->flags, BGP_INFO_ATTR_CHANGED);
831 }
832
833 /* Check each BGP peer. */
834 LIST_LOOP (bgp->peer, peer, nn)
835 {
836 /* Announce route to Established peer. */
837 if (peer->status != Established)
838 continue;
839
840 /* Address family configuration check. */
841 if (! peer->afc_nego[afi][safi])
842 continue;
843
844 /* First update is deferred until ORF or ROUTE-REFRESH is received */
845 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
846 continue;
847
848 /* Announcement to peer->conf. If the route is filtered,
849 withdraw it. */
850 if (new_select
851 && bgp_announce_check (new_select, peer, p, &attr, afi, safi))
852 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, new_select);
853 else
854 bgp_adj_out_unset (rn, peer, p, afi, safi);
855 }
856
857 /* FIB update. */
858 if (safi == SAFI_UNICAST && ! bgp->name &&
859 ! bgp_option_check (BGP_OPT_NO_FIB))
860 {
861 if (new_select
862 && new_select->type == ZEBRA_ROUTE_BGP
863 && new_select->sub_type == BGP_ROUTE_NORMAL)
864 bgp_zebra_announce (p, new_select, bgp);
865 else
866 {
867 /* Withdraw the route from the kernel. */
868 if (old_select
869 && old_select->type == ZEBRA_ROUTE_BGP
870 && old_select->sub_type == BGP_ROUTE_NORMAL)
871 bgp_zebra_withdraw (p, old_select);
872 }
873 }
874 return 0;
875}
876
877int
878bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, safi_t safi)
879{
paulc22854b2003-08-27 07:07:02 +0000880 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
paul718e3742002-12-13 20:15:29 +0000881 {
paul50d649a2003-08-27 12:25:49 +0000882 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +0000883 {
paulc22854b2003-08-27 07:07:02 +0000884 zlog (peer->log, LOG_INFO,
885 "MAXPFXEXCEED: No. of prefix received from %s (afi %d): %ld exceed limit %ld", peer->host, afi, peer->pcount[afi][safi], peer->pmax[afi][safi]);
886 if (! CHECK_FLAG (peer->af_flags[afi][safi],
887 PEER_FLAG_MAX_PREFIX_WARNING))
888 {
889 char ndata[7];
paul718e3742002-12-13 20:15:29 +0000890
paulc22854b2003-08-27 07:07:02 +0000891 ndata[0] = (u_char)(afi >> 8);
892 ndata[1] = (u_char) afi;
893 ndata[3] = (u_char)(peer->pmax[afi][safi] >> 24);
894 ndata[4] = (u_char)(peer->pmax[afi][safi] >> 16);
895 ndata[5] = (u_char)(peer->pmax[afi][safi] >> 8);
896 ndata[6] = (u_char)(peer->pmax[afi][safi]);
paul718e3742002-12-13 20:15:29 +0000897
paulc22854b2003-08-27 07:07:02 +0000898 if (safi == SAFI_MPLS_VPN)
899 safi = BGP_SAFI_VPNV4;
900 ndata[2] = (u_char) safi;
paul718e3742002-12-13 20:15:29 +0000901
paulc22854b2003-08-27 07:07:02 +0000902 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
903 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
904 BGP_NOTIFY_CEASE_MAX_PREFIX,
905 ndata, 7);
906 return 1;
907 }
paul718e3742002-12-13 20:15:29 +0000908 }
909 }
910 return 0;
911}
912
913void
914bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
915 afi_t afi, safi_t safi)
916{
917 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
918 {
919 peer->pcount[afi][safi]--;
920 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
921 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
922 bgp_process (peer->bgp, rn, afi, safi);
923 }
924 bgp_info_delete (rn, ri);
925 bgp_info_free (ri);
926 bgp_unlock_node (rn);
927}
928
929void
930bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
931 afi_t afi, safi_t safi, int force)
932{
933 int valid;
934 int status = BGP_DAMP_NONE;
935
936 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
937 {
938 peer->pcount[afi][safi]--;
939 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
940 }
941
942 if (! force)
943 {
944 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
945 && peer_sort (peer) == BGP_PEER_EBGP)
946 status = bgp_damp_withdraw (ri, rn, afi, safi, 0);
947
948 if (status == BGP_DAMP_SUPPRESSED)
949 return;
950 }
951
952 valid = CHECK_FLAG (ri->flags, BGP_INFO_VALID);
953 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
954 bgp_process (peer->bgp, rn, afi, safi);
955
956 if (valid)
957 SET_FLAG (ri->flags, BGP_INFO_VALID);
958
959 if (status != BGP_DAMP_USED)
960 {
961 bgp_info_delete (rn, ri);
962 bgp_info_free (ri);
963 bgp_unlock_node (rn);
964 }
965}
966
967int
968bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
969 afi_t afi, safi_t safi, int type, int sub_type,
970 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
971{
972 int ret;
973 int aspath_loop_count = 0;
974 struct bgp_node *rn;
975 struct bgp *bgp;
976 struct attr new_attr;
977 struct attr *attr_new;
978 struct bgp_info *ri;
979 struct bgp_info *new;
980 char *reason;
981 char buf[SU_ADDRSTRLEN];
982
983 bgp = peer->bgp;
984 rn = bgp_afi_node_get (bgp, afi, safi, p, prd);
985
986 /* When peer's soft reconfiguration enabled. Record input packet in
987 Adj-RIBs-In. */
988 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
989 && peer != bgp->peer_self && ! soft_reconfig)
990 bgp_adj_in_set (rn, peer, attr);
991
992 /* Check previously received route. */
993 for (ri = rn->info; ri; ri = ri->next)
994 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
995 break;
996
997 /* AS path local-as loop check. */
998 if (peer->change_local_as)
999 {
1000 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
1001 aspath_loop_count = 1;
1002
1003 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
1004 {
1005 reason = "as-path contains our own AS;";
1006 goto filtered;
1007 }
1008 }
1009
1010 /* AS path loop check. */
1011 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
1012 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
1013 && aspath_loop_check(attr->aspath, bgp->confed_id)
1014 > peer->allowas_in[afi][safi]))
1015 {
1016 reason = "as-path contains our own AS;";
1017 goto filtered;
1018 }
1019
1020 /* Route reflector originator ID check. */
1021 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
1022 && IPV4_ADDR_SAME (&bgp->router_id, &attr->originator_id))
1023 {
1024 reason = "originator is us;";
1025 goto filtered;
1026 }
1027
1028 /* Route reflector cluster ID check. */
1029 if (bgp_cluster_filter (peer, attr))
1030 {
1031 reason = "reflected from the same cluster;";
1032 goto filtered;
1033 }
1034
1035 /* Apply incoming filter. */
1036 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
1037 {
1038 reason = "filter;";
1039 goto filtered;
1040 }
1041
1042 /* Apply incoming route-map. */
1043 new_attr = *attr;
1044
1045 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
1046 {
1047 reason = "route-map;";
1048 goto filtered;
1049 }
1050
1051 /* IPv4 unicast next hop check. */
1052 if (afi == AFI_IP && safi == SAFI_UNICAST)
1053 {
1054 /* If the peer is EBGP and nexthop is not on connected route,
1055 discard it. */
1056 if (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl == 1
1057 && ! bgp_nexthop_check_ebgp (afi, &new_attr)
1058 && ! CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP))
1059 {
1060 reason = "non-connected next-hop;";
1061 goto filtered;
1062 }
1063
1064 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
1065 must not be my own address. */
1066 if (bgp_nexthop_self (afi, &new_attr)
1067 || new_attr.nexthop.s_addr == 0
1068 || ntohl (new_attr.nexthop.s_addr) >= 0xe0000000)
1069 {
1070 reason = "martian next-hop;";
1071 goto filtered;
1072 }
1073 }
1074
1075 attr_new = bgp_attr_intern (&new_attr);
1076
1077 /* If the update is implicit withdraw. */
1078 if (ri)
1079 {
1080 ri->uptime = time (NULL);
1081
1082 /* Same attribute comes in. */
1083 if (attrhash_cmp (ri->attr, attr_new))
1084 {
1085 UNSET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1086
1087 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1088 && peer_sort (peer) == BGP_PEER_EBGP
1089 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1090 {
1091 if (BGP_DEBUG (update, UPDATE_IN))
1092 zlog (peer->log, LOG_INFO, "%s rcvd %s/%d",
1093 peer->host,
1094 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1095 p->prefixlen);
1096
1097 peer->pcount[afi][safi]++;
1098 ret = bgp_damp_update (ri, rn, afi, safi);
1099 if (ret != BGP_DAMP_SUPPRESSED)
1100 {
1101 bgp_aggregate_increment (bgp, p, ri, afi, safi);
1102 bgp_process (bgp, rn, afi, safi);
1103 }
1104 }
1105 else
1106 {
1107 if (BGP_DEBUG (update, UPDATE_IN))
1108 zlog (peer->log, LOG_INFO,
1109 "%s rcvd %s/%d...duplicate ignored",
1110 peer->host,
1111 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1112 p->prefixlen);
1113 }
1114
1115 bgp_unlock_node (rn);
1116 bgp_attr_unintern (attr_new);
1117 return 0;
1118 }
1119
1120 /* Received Logging. */
1121 if (BGP_DEBUG (update, UPDATE_IN))
1122 zlog (peer->log, LOG_INFO, "%s rcvd %s/%d",
1123 peer->host,
1124 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1125 p->prefixlen);
1126
1127 /* The attribute is changed. */
1128 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1129
1130 /* Update bgp route dampening information. */
1131 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1132 && peer_sort (peer) == BGP_PEER_EBGP)
1133 {
1134 /* This is implicit withdraw so we should update dampening
1135 information. */
1136 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1137 bgp_damp_withdraw (ri, rn, afi, safi, 1);
1138 else
1139 peer->pcount[afi][safi]++;
1140 }
1141
1142 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
1143
1144 /* Update to new attribute. */
1145 bgp_attr_unintern (ri->attr);
1146 ri->attr = attr_new;
1147
1148 /* Update MPLS tag. */
1149 if (safi == SAFI_MPLS_VPN)
1150 memcpy (ri->tag, tag, 3);
1151
1152 /* Update bgp route dampening information. */
1153 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
1154 && peer_sort (peer) == BGP_PEER_EBGP)
1155 {
1156 /* Now we do normal update dampening. */
1157 ret = bgp_damp_update (ri, rn, afi, safi);
1158 if (ret == BGP_DAMP_SUPPRESSED)
1159 {
1160 bgp_unlock_node (rn);
1161 return 0;
1162 }
1163 }
1164
1165 /* Nexthop reachability check. */
1166 if ((afi == AFI_IP || afi == AFI_IP6)
1167 && safi == SAFI_UNICAST
1168 && (peer_sort (peer) == BGP_PEER_IBGP
1169 || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1)
1170 || CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP)))
1171 {
1172 if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
1173 SET_FLAG (ri->flags, BGP_INFO_VALID);
1174 else
1175 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
1176 }
1177 else
1178 SET_FLAG (ri->flags, BGP_INFO_VALID);
1179
1180 /* Process change. */
1181 bgp_aggregate_increment (bgp, p, ri, afi, safi);
1182
1183 bgp_process (bgp, rn, afi, safi);
1184 bgp_unlock_node (rn);
1185 return 0;
1186 }
1187
1188 /* Received Logging. */
1189 if (BGP_DEBUG (update, UPDATE_IN))
1190 {
1191 zlog (peer->log, LOG_INFO, "%s rcvd %s/%d",
1192 peer->host,
1193 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1194 p->prefixlen);
1195 }
1196
1197 /* Increment prefix counter */
1198 peer->pcount[afi][safi]++;
1199
1200 /* Make new BGP info. */
1201 new = bgp_info_new ();
1202 new->type = type;
1203 new->sub_type = sub_type;
1204 new->peer = peer;
1205 new->attr = attr_new;
1206 new->uptime = time (NULL);
1207
1208 /* Update MPLS tag. */
1209 if (safi == SAFI_MPLS_VPN)
1210 memcpy (new->tag, tag, 3);
1211
1212 /* Nexthop reachability check. */
1213 if ((afi == AFI_IP || afi == AFI_IP6)
1214 && safi == SAFI_UNICAST
1215 && (peer_sort (peer) == BGP_PEER_IBGP
1216 || (peer_sort (peer) == BGP_PEER_EBGP && peer->ttl != 1)
1217 || CHECK_FLAG (peer->flags, PEER_FLAG_ENFORCE_MULTIHOP)))
1218 {
1219 if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
1220 SET_FLAG (new->flags, BGP_INFO_VALID);
1221 else
1222 UNSET_FLAG (new->flags, BGP_INFO_VALID);
1223 }
1224 else
1225 SET_FLAG (new->flags, BGP_INFO_VALID);
1226
1227 /* Aggregate address increment. */
1228 bgp_aggregate_increment (bgp, p, new, afi, safi);
1229
1230 /* Register new BGP information. */
1231 bgp_info_add (rn, new);
1232
1233 /* If maximum prefix count is configured and current prefix
1234 count exeed it. */
1235 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1236 if (bgp_maximum_prefix_overflow (peer, afi, safi))
1237 return -1;
1238
1239 /* Process change. */
1240 bgp_process (bgp, rn, afi, safi);
1241
1242 return 0;
1243
1244 /* This BGP update is filtered. Log the reason then update BGP
1245 entry. */
1246 filtered:
1247 if (BGP_DEBUG (update, UPDATE_IN))
1248 zlog (peer->log, LOG_INFO,
1249 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
1250 peer->host,
1251 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1252 p->prefixlen, reason);
1253
1254 if (ri)
1255 bgp_rib_withdraw (rn, ri, peer, afi, safi, 1);
1256
1257 bgp_unlock_node (rn);
1258
1259 return 0;
1260}
1261
1262int
1263bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
1264 int afi, int safi, int type, int sub_type, struct prefix_rd *prd,
1265 u_char *tag)
1266{
1267 struct bgp *bgp;
1268 char buf[SU_ADDRSTRLEN];
1269 struct bgp_node *rn;
1270 struct bgp_info *ri;
1271
1272 bgp = peer->bgp;
1273
1274 /* Logging. */
1275 if (BGP_DEBUG (update, UPDATE_IN))
1276 zlog (peer->log, LOG_INFO, "%s rcvd UPDATE about %s/%d -- withdrawn",
1277 peer->host,
1278 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1279 p->prefixlen);
1280
1281 /* Lookup node. */
1282 rn = bgp_afi_node_get (bgp, afi, safi, p, prd);
1283
1284 /* If peer is soft reconfiguration enabled. Record input packet for
1285 further calculation. */
1286 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
1287 && peer != bgp->peer_self)
1288 bgp_adj_in_unset (rn, peer);
1289
1290 /* Lookup withdrawn route. */
1291 for (ri = rn->info; ri; ri = ri->next)
1292 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1293 break;
1294
1295 /* Withdraw specified route from routing table. */
1296 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1297 bgp_rib_withdraw (rn, ri, peer, afi, safi, 0);
1298 else if (BGP_DEBUG (update, UPDATE_IN))
1299 zlog (peer->log, LOG_INFO,
1300 "%s Can't find the route %s/%d", peer->host,
1301 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1302 p->prefixlen);
1303
1304 /* Unlock bgp_node_get() lock. */
1305 bgp_unlock_node (rn);
1306
1307 return 0;
1308}
1309
1310void
1311bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
1312{
1313 struct bgp *bgp;
1314 struct attr attr;
1315 struct aspath *aspath;
1316 struct prefix p;
1317 struct bgp_info binfo;
1318 struct peer *from;
1319 int ret = RMAP_DENYMATCH;
1320
1321 bgp = peer->bgp;
1322 from = bgp->peer_self;
1323
1324 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
1325 aspath = attr.aspath;
1326 attr.local_pref = bgp->default_local_pref;
1327 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
1328
1329 if (afi == AFI_IP)
1330 str2prefix ("0.0.0.0/0", &p);
1331#ifdef HAVE_IPV6
1332 else if (afi == AFI_IP6)
1333 {
1334 str2prefix ("::/0", &p);
1335
1336 /* IPv6 global nexthop must be included. */
1337 memcpy (&attr.mp_nexthop_global, &peer->nexthop.v6_global,
1338 IPV6_MAX_BYTELEN);
1339 attr.mp_nexthop_len = 16;
1340
1341 /* If the peer is on shared nextwork and we have link-local
1342 nexthop set it. */
1343 if (peer->shared_network
1344 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
1345 {
1346 memcpy (&attr.mp_nexthop_local, &peer->nexthop.v6_local,
1347 IPV6_MAX_BYTELEN);
1348 attr.mp_nexthop_len = 32;
1349 }
1350 }
1351#endif /* HAVE_IPV6 */
1352 else
1353 return;
1354
1355 if (peer->default_rmap[afi][safi].name)
1356 {
1357 binfo.peer = bgp->peer_self;
1358 binfo.attr = &attr;
1359
1360 ret = route_map_apply (peer->default_rmap[afi][safi].map, &p,
1361 RMAP_BGP, &binfo);
1362
1363 if (ret == RMAP_DENYMATCH)
1364 {
1365 bgp_attr_flush (&attr);
1366 withdraw = 1;
1367 }
1368 }
1369
1370 if (withdraw)
1371 {
1372 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
1373 bgp_default_withdraw_send (peer, afi, safi);
1374 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
1375 }
1376 else
1377 {
1378 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
1379 bgp_default_update_send (peer, &attr, afi, safi, from);
1380 }
1381
1382 aspath_unintern (aspath);
1383}
1384
1385static void
1386bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
1387 struct bgp_table *table)
1388{
1389 struct bgp_node *rn;
1390 struct bgp_info *ri;
1391 struct attr attr;
1392
1393 if (! table)
1394 table = peer->bgp->rib[afi][safi];
1395
1396 if (safi != SAFI_MPLS_VPN
1397 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
1398 bgp_default_originate (peer, afi, safi, 0);
1399
1400 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
1401 for (ri = rn->info; ri; ri = ri->next)
1402 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
1403 {
1404 if (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi))
1405 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
1406 else
1407 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
1408 }
1409}
1410
1411void
1412bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
1413{
1414 struct bgp_node *rn;
1415 struct bgp_table *table;
1416
1417 if (peer->status != Established)
1418 return;
1419
1420 if (! peer->afc_nego[afi][safi])
1421 return;
1422
1423 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1424 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
1425 return;
1426
1427 if (safi != SAFI_MPLS_VPN)
1428 bgp_announce_table (peer, afi, safi, NULL);
1429 else
1430 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
1431 rn = bgp_route_next(rn))
1432 if ((table = (rn->info)) != NULL)
1433 bgp_announce_table (peer, afi, safi, table);
1434}
1435
1436void
1437bgp_announce_route_all (struct peer *peer)
1438{
1439 afi_t afi;
1440 safi_t safi;
1441
1442 for (afi = AFI_IP; afi < AFI_MAX; afi++)
1443 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
1444 bgp_announce_route (peer, afi, safi);
1445}
1446
1447static void
1448bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
1449 struct bgp_table *table)
1450{
1451 int ret;
1452 struct bgp_node *rn;
1453 struct bgp_adj_in *ain;
1454
1455 if (! table)
1456 table = peer->bgp->rib[afi][safi];
1457
1458 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
1459 for (ain = rn->adj_in; ain; ain = ain->next)
1460 {
1461 if (ain->peer == peer)
1462 {
1463 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
1464 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
1465 NULL, NULL, 1);
1466 if (ret < 0)
1467 {
1468 bgp_unlock_node (rn);
1469 return;
1470 }
1471 continue;
1472 }
1473 }
1474}
1475
1476void
1477bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
1478{
1479 struct bgp_node *rn;
1480 struct bgp_table *table;
1481
1482 if (peer->status != Established)
1483 return;
1484
1485 if (safi != SAFI_MPLS_VPN)
1486 bgp_soft_reconfig_table (peer, afi, safi, NULL);
1487 else
1488 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
1489 rn = bgp_route_next (rn))
1490 if ((table = rn->info) != NULL)
1491 bgp_soft_reconfig_table (peer, afi, safi, table);
1492}
1493
1494static void
1495bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
1496 struct bgp_table *table)
1497{
1498 struct bgp_node *rn;
1499 struct bgp_adj_in *ain;
1500 struct bgp_adj_out *aout;
1501 struct bgp_info *ri;
1502
1503 if (! table)
1504 table = peer->bgp->rib[afi][safi];
1505
1506 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
1507 {
1508 for (ri = rn->info; ri; ri = ri->next)
1509 if (ri->peer == peer)
1510 {
1511 bgp_rib_remove (rn, ri, peer, afi, safi);
1512 break;
1513 }
1514 for (ain = rn->adj_in; ain; ain = ain->next)
1515 if (ain->peer == peer)
1516 {
1517 bgp_adj_in_remove (rn, ain);
1518 bgp_unlock_node (rn);
1519 break;
1520 }
1521 for (aout = rn->adj_out; aout; aout = aout->next)
1522 if (aout->peer == peer)
1523 {
1524 bgp_adj_out_remove (rn, aout, peer, afi, safi);
1525 bgp_unlock_node (rn);
1526 break;
1527 }
1528 }
1529}
1530
1531void
1532bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi)
1533{
1534 struct bgp_node *rn;
1535 struct bgp_table *table;
1536
1537 if (! peer->afc[afi][safi])
1538 return;
1539
1540 if (safi != SAFI_MPLS_VPN)
1541 bgp_clear_route_table (peer, afi, safi, NULL);
1542 else
1543 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
1544 rn = bgp_route_next (rn))
1545 if ((table = rn->info) != NULL)
1546 bgp_clear_route_table (peer, afi, safi, table);
1547}
1548
1549void
1550bgp_clear_route_all (struct peer *peer)
1551{
1552 afi_t afi;
1553 safi_t safi;
1554
1555 for (afi = AFI_IP; afi < AFI_MAX; afi++)
1556 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
1557 bgp_clear_route (peer, afi, safi);
1558}
1559
1560void
1561bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
1562{
1563 struct bgp_table *table;
1564 struct bgp_node *rn;
1565 struct bgp_adj_in *ain;
1566
1567 table = peer->bgp->rib[afi][safi];
1568
1569 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
1570 for (ain = rn->adj_in; ain ; ain = ain->next)
1571 if (ain->peer == peer)
1572 {
1573 bgp_adj_in_remove (rn, ain);
1574 bgp_unlock_node (rn);
1575 break;
1576 }
1577}
1578
1579/* Delete all kernel routes. */
1580void
paul545acaf2004-04-20 15:13:15 +00001581bgp_cleanup_routes ()
paul718e3742002-12-13 20:15:29 +00001582{
1583 struct bgp *bgp;
1584 struct listnode *nn;
1585 struct bgp_node *rn;
1586 struct bgp_table *table;
1587 struct bgp_info *ri;
1588
1589 LIST_LOOP (bm->bgp, bgp, nn)
1590 {
1591 table = bgp->rib[AFI_IP][SAFI_UNICAST];
1592
1593 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
1594 for (ri = rn->info; ri; ri = ri->next)
1595 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
1596 && ri->type == ZEBRA_ROUTE_BGP
1597 && ri->sub_type == BGP_ROUTE_NORMAL)
1598 bgp_zebra_withdraw (&rn->p, ri);
1599
1600 table = bgp->rib[AFI_IP6][SAFI_UNICAST];
1601
1602 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
1603 for (ri = rn->info; ri; ri = ri->next)
1604 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
1605 && ri->type == ZEBRA_ROUTE_BGP
1606 && ri->sub_type == BGP_ROUTE_NORMAL)
1607 bgp_zebra_withdraw (&rn->p, ri);
1608 }
1609}
1610
1611void
1612bgp_reset ()
1613{
1614 vty_reset ();
1615 bgp_zclient_reset ();
1616 access_list_reset ();
1617 prefix_list_reset ();
1618}
1619
1620/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
1621 value. */
1622int
1623bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
1624{
1625 u_char *pnt;
1626 u_char *lim;
1627 struct prefix p;
1628 int psize;
1629 int ret;
1630
1631 /* Check peer status. */
1632 if (peer->status != Established)
1633 return 0;
1634
1635 pnt = packet->nlri;
1636 lim = pnt + packet->length;
1637
1638 for (; pnt < lim; pnt += psize)
1639 {
1640 /* Clear prefix structure. */
1641 memset (&p, 0, sizeof (struct prefix));
1642
1643 /* Fetch prefix length. */
1644 p.prefixlen = *pnt++;
1645 p.family = afi2family (packet->afi);
1646
1647 /* Already checked in nlri_sanity_check(). We do double check
1648 here. */
1649 if ((packet->afi == AFI_IP && p.prefixlen > 32)
1650 || (packet->afi == AFI_IP6 && p.prefixlen > 128))
1651 return -1;
1652
1653 /* Packet size overflow check. */
1654 psize = PSIZE (p.prefixlen);
1655
1656 /* When packet overflow occur return immediately. */
1657 if (pnt + psize > lim)
1658 return -1;
1659
1660 /* Fetch prefix from NLRI packet. */
1661 memcpy (&p.u.prefix, pnt, psize);
1662
1663 /* Check address. */
1664 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
1665 {
1666 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
1667 {
1668 zlog (peer->log, LOG_ERR,
1669 "IPv4 unicast NLRI is multicast address %s",
1670 inet_ntoa (p.u.prefix4));
1671 bgp_notify_send (peer,
1672 BGP_NOTIFY_UPDATE_ERR,
1673 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
1674 return -1;
1675 }
1676 }
1677
1678#ifdef HAVE_IPV6
1679 /* Check address. */
1680 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
1681 {
1682 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
1683 {
1684 char buf[BUFSIZ];
1685
1686 zlog (peer->log, LOG_WARNING,
1687 "IPv6 link-local NLRI received %s ignore this NLRI",
1688 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
1689
1690 continue;
1691 }
1692 }
1693#endif /* HAVE_IPV6 */
1694
1695 /* Normal process. */
1696 if (attr)
1697 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
1698 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
1699 else
1700 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
1701 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
1702
1703 /* Address family configuration mismatch or maximum-prefix count
1704 overflow. */
1705 if (ret < 0)
1706 return -1;
1707 }
1708
1709 /* Packet length consistency check. */
1710 if (pnt != lim)
1711 return -1;
1712
1713 return 0;
1714}
1715
1716/* NLRI encode syntax check routine. */
1717int
1718bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt,
1719 bgp_size_t length)
1720{
1721 u_char *end;
1722 u_char prefixlen;
1723 int psize;
1724
1725 end = pnt + length;
1726
1727 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
1728 syntactic validity. If the field is syntactically incorrect,
1729 then the Error Subcode is set to Invalid Network Field. */
1730
1731 while (pnt < end)
1732 {
1733 prefixlen = *pnt++;
1734
1735 /* Prefix length check. */
1736 if ((afi == AFI_IP && prefixlen > 32)
1737 || (afi == AFI_IP6 && prefixlen > 128))
1738 {
1739 plog_err (peer->log,
1740 "%s [Error] Update packet error (wrong prefix length %d)",
1741 peer->host, prefixlen);
1742 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
1743 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
1744 return -1;
1745 }
1746
1747 /* Packet size overflow check. */
1748 psize = PSIZE (prefixlen);
1749
1750 if (pnt + psize > end)
1751 {
1752 plog_err (peer->log,
1753 "%s [Error] Update packet error"
1754 " (prefix data overflow prefix size is %d)",
1755 peer->host, psize);
1756 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
1757 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
1758 return -1;
1759 }
1760
1761 pnt += psize;
1762 }
1763
1764 /* Packet length consistency check. */
1765 if (pnt != end)
1766 {
1767 plog_err (peer->log,
1768 "%s [Error] Update packet error"
1769 " (prefix length mismatch with total length)",
1770 peer->host);
1771 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
1772 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
1773 return -1;
1774 }
1775 return 0;
1776}
1777
1778struct bgp_static *
1779bgp_static_new ()
1780{
1781 struct bgp_static *new;
1782 new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
1783 memset (new, 0, sizeof (struct bgp_static));
1784 return new;
1785}
1786
1787void
1788bgp_static_free (struct bgp_static *bgp_static)
1789{
1790 if (bgp_static->rmap.name)
1791 free (bgp_static->rmap.name);
1792 XFREE (MTYPE_BGP_STATIC, bgp_static);
1793}
1794
1795void
1796bgp_static_update (struct bgp *bgp, struct prefix *p,
1797 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
1798{
1799 struct bgp_node *rn;
1800 struct bgp_info *ri;
1801 struct bgp_info *new;
1802 struct bgp_info info;
1803 struct attr attr;
paul286e1e72003-08-08 00:24:31 +00001804 struct attr attr_tmp;
paul718e3742002-12-13 20:15:29 +00001805 struct attr *attr_new;
1806 int ret;
1807
1808 rn = bgp_afi_node_get (bgp, afi, safi, p, NULL);
1809
1810 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
1811 if (bgp_static)
1812 {
1813 attr.nexthop = bgp_static->igpnexthop;
1814 attr.med = bgp_static->igpmetric;
1815 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
1816 }
1817
1818 /* Apply route-map. */
1819 if (bgp_static->rmap.name)
1820 {
paul286e1e72003-08-08 00:24:31 +00001821 attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00001822 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00001823 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00001824
1825 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00001826
paul718e3742002-12-13 20:15:29 +00001827 if (ret == RMAP_DENYMATCH)
1828 {
1829 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00001830 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00001831
1832 /* Unintern original. */
1833 aspath_unintern (attr.aspath);
1834 bgp_static_withdraw (bgp, p, afi, safi);
1835 return;
1836 }
paul286e1e72003-08-08 00:24:31 +00001837 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00001838 }
paul286e1e72003-08-08 00:24:31 +00001839 else
1840 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00001841
1842 for (ri = rn->info; ri; ri = ri->next)
1843 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
1844 && ri->sub_type == BGP_ROUTE_STATIC)
1845 break;
1846
1847 if (ri)
1848 {
1849 if (attrhash_cmp (ri->attr, attr_new))
1850 {
1851 bgp_unlock_node (rn);
1852 bgp_attr_unintern (attr_new);
1853 aspath_unintern (attr.aspath);
1854 return;
1855 }
1856 else
1857 {
1858 /* The attribute is changed. */
1859 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
1860
1861 /* Rewrite BGP route information. */
1862 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
1863 bgp_attr_unintern (ri->attr);
1864 ri->attr = attr_new;
1865 ri->uptime = time (NULL);
1866
1867 /* Process change. */
1868 bgp_aggregate_increment (bgp, p, ri, afi, safi);
1869 bgp_process (bgp, rn, afi, safi);
1870 bgp_unlock_node (rn);
1871 aspath_unintern (attr.aspath);
1872 return;
1873 }
1874 }
1875
1876 /* Make new BGP info. */
1877 new = bgp_info_new ();
1878 new->type = ZEBRA_ROUTE_BGP;
1879 new->sub_type = BGP_ROUTE_STATIC;
1880 new->peer = bgp->peer_self;
1881 SET_FLAG (new->flags, BGP_INFO_VALID);
1882 new->attr = attr_new;
1883 new->uptime = time (NULL);
1884
1885 /* Aggregate address increment. */
1886 bgp_aggregate_increment (bgp, p, new, afi, safi);
1887
1888 /* Register new BGP information. */
1889 bgp_info_add (rn, new);
1890
1891 /* Process change. */
1892 bgp_process (bgp, rn, afi, safi);
1893
1894 /* Unintern original. */
1895 aspath_unintern (attr.aspath);
1896}
1897
1898void
1899bgp_static_update_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi,
1900 u_char safi, struct prefix_rd *prd, u_char *tag)
1901{
1902 struct bgp_node *rn;
1903 struct bgp_info *new;
1904
1905 rn = bgp_afi_node_get (bgp, afi, safi, p, prd);
1906
1907 /* Make new BGP info. */
1908 new = bgp_info_new ();
1909 new->type = ZEBRA_ROUTE_BGP;
1910 new->sub_type = BGP_ROUTE_STATIC;
1911 new->peer = bgp->peer_self;
1912 new->attr = bgp_attr_default_intern (BGP_ORIGIN_IGP);
1913 SET_FLAG (new->flags, BGP_INFO_VALID);
1914 new->uptime = time (NULL);
1915 memcpy (new->tag, tag, 3);
1916
1917 /* Aggregate address increment. */
1918 bgp_aggregate_increment (bgp, p, (struct bgp_info *) new, afi, safi);
1919
1920 /* Register new BGP information. */
1921 bgp_info_add (rn, (struct bgp_info *) new);
1922
1923 /* Process change. */
1924 bgp_process (bgp, rn, afi, safi);
1925}
1926
1927void
1928bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
1929 safi_t safi)
1930{
1931 struct bgp_node *rn;
1932 struct bgp_info *ri;
1933
1934 rn = bgp_afi_node_get (bgp, afi, safi, p, NULL);
1935
1936 /* Check selected route and self inserted route. */
1937 for (ri = rn->info; ri; ri = ri->next)
1938 if (ri->peer == bgp->peer_self
1939 && ri->type == ZEBRA_ROUTE_BGP
1940 && ri->sub_type == BGP_ROUTE_STATIC)
1941 break;
1942
1943 /* Withdraw static BGP route from routing table. */
1944 if (ri)
1945 {
1946 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
1947 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
1948 bgp_process (bgp, rn, afi, safi);
1949 bgp_info_delete (rn, ri);
1950 bgp_info_free (ri);
1951 bgp_unlock_node (rn);
1952 }
1953
1954 /* Unlock bgp_node_lookup. */
1955 bgp_unlock_node (rn);
1956}
1957
1958void
1959bgp_static_withdraw_vpnv4 (struct bgp *bgp, struct prefix *p, u_int16_t afi,
1960 u_char safi, struct prefix_rd *prd, u_char *tag)
1961{
1962 struct bgp_node *rn;
1963 struct bgp_info *ri;
1964
1965 rn = bgp_afi_node_get (bgp, afi, safi, p, prd);
1966
1967 /* Check selected route and self inserted route. */
1968 for (ri = rn->info; ri; ri = ri->next)
1969 if (ri->peer == bgp->peer_self
1970 && ri->type == ZEBRA_ROUTE_BGP
1971 && ri->sub_type == BGP_ROUTE_STATIC)
1972 break;
1973
1974 /* Withdraw static BGP route from routing table. */
1975 if (ri)
1976 {
1977 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
1978 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
1979 bgp_process (bgp, rn, afi, safi);
1980 bgp_info_delete (rn, ri);
1981 bgp_info_free (ri);
1982 bgp_unlock_node (rn);
1983 }
1984
1985 /* Unlock bgp_node_lookup. */
1986 bgp_unlock_node (rn);
1987}
1988
1989/* Configure static BGP network. When user don't run zebra, static
1990 route should be installed as valid. */
1991int
1992bgp_static_set (struct vty *vty, struct bgp *bgp, char *ip_str, u_int16_t afi,
1993 u_char safi, char *rmap, int backdoor)
1994{
1995 int ret;
1996 struct prefix p;
1997 struct bgp_static *bgp_static;
1998 struct bgp_node *rn;
1999 int need_update = 0;
2000
2001 /* Convert IP prefix string to struct prefix. */
2002 ret = str2prefix (ip_str, &p);
2003 if (! ret)
2004 {
2005 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
2006 return CMD_WARNING;
2007 }
2008#ifdef HAVE_IPV6
2009 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
2010 {
2011 vty_out (vty, "%% Malformed prefix (link-local address)%s",
2012 VTY_NEWLINE);
2013 return CMD_WARNING;
2014 }
2015#endif /* HAVE_IPV6 */
2016
2017 apply_mask (&p);
2018
2019 /* Set BGP static route configuration. */
2020 rn = bgp_node_get (bgp->route[afi][safi], &p);
2021
2022 if (rn->info)
2023 {
2024 /* Configuration change. */
2025 bgp_static = rn->info;
2026
2027 /* Check previous routes are installed into BGP. */
2028 if (! bgp_static->backdoor && bgp_static->valid)
2029 need_update = 1;
2030
2031 bgp_static->backdoor = backdoor;
2032 if (rmap)
2033 {
2034 if (bgp_static->rmap.name)
2035 free (bgp_static->rmap.name);
2036 bgp_static->rmap.name = strdup (rmap);
2037 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
2038 }
2039 else
2040 {
2041 if (bgp_static->rmap.name)
2042 free (bgp_static->rmap.name);
2043 bgp_static->rmap.name = NULL;
2044 bgp_static->rmap.map = NULL;
2045 bgp_static->valid = 0;
2046 }
2047 bgp_unlock_node (rn);
2048 }
2049 else
2050 {
2051 /* New configuration. */
2052 bgp_static = bgp_static_new ();
2053 bgp_static->backdoor = backdoor;
2054 bgp_static->valid = 0;
2055 bgp_static->igpmetric = 0;
2056 bgp_static->igpnexthop.s_addr = 0;
2057 if (rmap)
2058 {
2059 if (bgp_static->rmap.name)
2060 free (bgp_static->rmap.name);
2061 bgp_static->rmap.name = strdup (rmap);
2062 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
2063 }
2064 rn->info = bgp_static;
2065 }
2066
2067 /* If BGP scan is not enabled, we should install this route here. */
2068 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
2069 {
2070 bgp_static->valid = 1;
2071
2072 if (need_update)
2073 bgp_static_withdraw (bgp, &p, afi, safi);
2074
2075 if (! bgp_static->backdoor)
2076 bgp_static_update (bgp, &p, bgp_static, afi, safi);
2077 }
2078
2079 return CMD_SUCCESS;
2080}
2081
2082/* Configure static BGP network. */
2083int
2084bgp_static_unset (struct vty *vty, struct bgp *bgp, char *ip_str,
2085 u_int16_t afi, u_char safi)
2086{
2087 int ret;
2088 struct prefix p;
2089 struct bgp_static *bgp_static;
2090 struct bgp_node *rn;
2091
2092 /* Convert IP prefix string to struct prefix. */
2093 ret = str2prefix (ip_str, &p);
2094 if (! ret)
2095 {
2096 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
2097 return CMD_WARNING;
2098 }
2099#ifdef HAVE_IPV6
2100 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
2101 {
2102 vty_out (vty, "%% Malformed prefix (link-local address)%s",
2103 VTY_NEWLINE);
2104 return CMD_WARNING;
2105 }
2106#endif /* HAVE_IPV6 */
2107
2108 apply_mask (&p);
2109
2110 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
2111 if (! rn)
2112 {
2113 vty_out (vty, "%% Can't find specified static route configuration.%s",
2114 VTY_NEWLINE);
2115 return CMD_WARNING;
2116 }
2117
2118 bgp_static = rn->info;
2119
2120 /* Update BGP RIB. */
2121 if (! bgp_static->backdoor)
2122 bgp_static_withdraw (bgp, &p, afi, safi);
2123
2124 /* Clear configuration. */
2125 bgp_static_free (bgp_static);
2126 rn->info = NULL;
2127 bgp_unlock_node (rn);
2128 bgp_unlock_node (rn);
2129
2130 return CMD_SUCCESS;
2131}
2132
2133/* Called from bgp_delete(). Delete all static routes from the BGP
2134 instance. */
2135void
2136bgp_static_delete (struct bgp *bgp)
2137{
2138 afi_t afi;
2139 safi_t safi;
2140 struct bgp_node *rn;
2141 struct bgp_node *rm;
2142 struct bgp_table *table;
2143 struct bgp_static *bgp_static;
2144
2145 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2146 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2147 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
2148 if (rn->info != NULL)
2149 {
2150 if (safi == SAFI_MPLS_VPN)
2151 {
2152 table = rn->info;
2153
2154 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
2155 {
2156 bgp_static = rn->info;
2157 bgp_static_withdraw_vpnv4 (bgp, &rm->p,
2158 AFI_IP, SAFI_MPLS_VPN,
2159 (struct prefix_rd *)&rn->p,
2160 bgp_static->tag);
2161 bgp_static_free (bgp_static);
2162 rn->info = NULL;
2163 bgp_unlock_node (rn);
2164 }
2165 }
2166 else
2167 {
2168 bgp_static = rn->info;
2169 bgp_static_withdraw (bgp, &rn->p, afi, safi);
2170 bgp_static_free (bgp_static);
2171 rn->info = NULL;
2172 bgp_unlock_node (rn);
2173 }
2174 }
2175}
2176
2177int
2178bgp_static_set_vpnv4 (struct vty *vty, char *ip_str, char *rd_str,
2179 char *tag_str)
2180{
2181 int ret;
2182 struct prefix p;
2183 struct prefix_rd prd;
2184 struct bgp *bgp;
2185 struct bgp_node *prn;
2186 struct bgp_node *rn;
2187 struct bgp_table *table;
2188 struct bgp_static *bgp_static;
2189 u_char tag[3];
2190
2191 bgp = vty->index;
2192
2193 ret = str2prefix (ip_str, &p);
2194 if (! ret)
2195 {
2196 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
2197 return CMD_WARNING;
2198 }
2199 apply_mask (&p);
2200
2201 ret = str2prefix_rd (rd_str, &prd);
2202 if (! ret)
2203 {
2204 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
2205 return CMD_WARNING;
2206 }
2207
2208 ret = str2tag (tag_str, tag);
2209 if (! ret)
2210 {
2211 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
2212 return CMD_WARNING;
2213 }
2214
2215 prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN],
2216 (struct prefix *)&prd);
2217 if (prn->info == NULL)
2218 prn->info = bgp_table_init ();
2219 else
2220 bgp_unlock_node (prn);
2221 table = prn->info;
2222
2223 rn = bgp_node_get (table, &p);
2224
2225 if (rn->info)
2226 {
2227 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
2228 bgp_unlock_node (rn);
2229 }
2230 else
2231 {
2232 /* New configuration. */
2233 bgp_static = bgp_static_new ();
2234 bgp_static->valid = 1;
2235 memcpy (bgp_static->tag, tag, 3);
2236 rn->info = bgp_static;
2237
2238 bgp_static_update_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag);
2239 }
2240
2241 return CMD_SUCCESS;
2242}
2243
2244/* Configure static BGP network. */
2245int
2246bgp_static_unset_vpnv4 (struct vty *vty, char *ip_str, char *rd_str,
2247 char *tag_str)
2248{
2249 int ret;
2250 struct bgp *bgp;
2251 struct prefix p;
2252 struct prefix_rd prd;
2253 struct bgp_node *prn;
2254 struct bgp_node *rn;
2255 struct bgp_table *table;
2256 struct bgp_static *bgp_static;
2257 u_char tag[3];
2258
2259 bgp = vty->index;
2260
2261 /* Convert IP prefix string to struct prefix. */
2262 ret = str2prefix (ip_str, &p);
2263 if (! ret)
2264 {
2265 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
2266 return CMD_WARNING;
2267 }
2268 apply_mask (&p);
2269
2270 ret = str2prefix_rd (rd_str, &prd);
2271 if (! ret)
2272 {
2273 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
2274 return CMD_WARNING;
2275 }
2276
2277 ret = str2tag (tag_str, tag);
2278 if (! ret)
2279 {
2280 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
2281 return CMD_WARNING;
2282 }
2283
2284 prn = bgp_node_get (bgp->route[AFI_IP][SAFI_MPLS_VPN],
2285 (struct prefix *)&prd);
2286 if (prn->info == NULL)
2287 prn->info = bgp_table_init ();
2288 else
2289 bgp_unlock_node (prn);
2290 table = prn->info;
2291
2292 rn = bgp_node_lookup (table, &p);
2293
2294 if (rn)
2295 {
2296 bgp_static_withdraw_vpnv4 (bgp, &p, AFI_IP, SAFI_MPLS_VPN, &prd, tag);
2297
2298 bgp_static = rn->info;
2299 bgp_static_free (bgp_static);
2300 rn->info = NULL;
2301 bgp_unlock_node (rn);
2302 bgp_unlock_node (rn);
2303 }
2304 else
2305 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
2306
2307 return CMD_SUCCESS;
2308}
2309
2310DEFUN (bgp_network,
2311 bgp_network_cmd,
2312 "network A.B.C.D/M",
2313 "Specify a network to announce via BGP\n"
2314 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2315{
2316 return bgp_static_set (vty, vty->index, argv[0],
2317 AFI_IP, bgp_node_safi (vty), NULL, 0);
2318}
2319
2320DEFUN (bgp_network_route_map,
2321 bgp_network_route_map_cmd,
2322 "network A.B.C.D/M route-map WORD",
2323 "Specify a network to announce via BGP\n"
2324 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2325 "Route-map to modify the attributes\n"
2326 "Name of the route map\n")
2327{
2328 return bgp_static_set (vty, vty->index, argv[0],
2329 AFI_IP, bgp_node_safi (vty), argv[1], 0);
2330}
2331
2332DEFUN (bgp_network_backdoor,
2333 bgp_network_backdoor_cmd,
2334 "network A.B.C.D/M backdoor",
2335 "Specify a network to announce via BGP\n"
2336 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2337 "Specify a BGP backdoor route\n")
2338{
2339 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
2340}
2341
2342DEFUN (bgp_network_mask,
2343 bgp_network_mask_cmd,
2344 "network A.B.C.D mask A.B.C.D",
2345 "Specify a network to announce via BGP\n"
2346 "Network number\n"
2347 "Network mask\n"
2348 "Network mask\n")
2349{
2350 int ret;
2351 char prefix_str[BUFSIZ];
2352
2353 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
2354 if (! ret)
2355 {
2356 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
2357 return CMD_WARNING;
2358 }
2359
2360 return bgp_static_set (vty, vty->index, prefix_str,
2361 AFI_IP, bgp_node_safi (vty), NULL, 0);
2362}
2363
2364DEFUN (bgp_network_mask_route_map,
2365 bgp_network_mask_route_map_cmd,
2366 "network A.B.C.D mask A.B.C.D route-map WORD",
2367 "Specify a network to announce via BGP\n"
2368 "Network number\n"
2369 "Network mask\n"
2370 "Network mask\n"
2371 "Route-map to modify the attributes\n"
2372 "Name of the route map\n")
2373{
2374 int ret;
2375 char prefix_str[BUFSIZ];
2376
2377 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
2378 if (! ret)
2379 {
2380 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
2381 return CMD_WARNING;
2382 }
2383
2384 return bgp_static_set (vty, vty->index, prefix_str,
2385 AFI_IP, bgp_node_safi (vty), argv[2], 0);
2386}
2387
2388DEFUN (bgp_network_mask_backdoor,
2389 bgp_network_mask_backdoor_cmd,
2390 "network A.B.C.D mask A.B.C.D backdoor",
2391 "Specify a network to announce via BGP\n"
2392 "Network number\n"
2393 "Network mask\n"
2394 "Network mask\n"
2395 "Specify a BGP backdoor route\n")
2396{
2397 int ret;
2398 char prefix_str[BUFSIZ];
2399
2400 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
2401 if (! ret)
2402 {
2403 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
2404 return CMD_WARNING;
2405 }
2406
2407 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1);
2408}
2409
2410DEFUN (bgp_network_mask_natural,
2411 bgp_network_mask_natural_cmd,
2412 "network A.B.C.D",
2413 "Specify a network to announce via BGP\n"
2414 "Network number\n")
2415{
2416 int ret;
2417 char prefix_str[BUFSIZ];
2418
2419 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
2420 if (! ret)
2421 {
2422 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
2423 return CMD_WARNING;
2424 }
2425
2426 return bgp_static_set (vty, vty->index, prefix_str,
2427 AFI_IP, bgp_node_safi (vty), NULL, 0);
2428}
2429
2430DEFUN (bgp_network_mask_natural_route_map,
2431 bgp_network_mask_natural_route_map_cmd,
2432 "network A.B.C.D route-map WORD",
2433 "Specify a network to announce via BGP\n"
2434 "Network number\n"
2435 "Route-map to modify the attributes\n"
2436 "Name of the route map\n")
2437{
2438 int ret;
2439 char prefix_str[BUFSIZ];
2440
2441 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
2442 if (! ret)
2443 {
2444 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
2445 return CMD_WARNING;
2446 }
2447
2448 return bgp_static_set (vty, vty->index, prefix_str,
2449 AFI_IP, bgp_node_safi (vty), argv[1], 0);
2450}
2451
2452DEFUN (bgp_network_mask_natural_backdoor,
2453 bgp_network_mask_natural_backdoor_cmd,
2454 "network A.B.C.D backdoor",
2455 "Specify a network to announce via BGP\n"
2456 "Network number\n"
2457 "Specify a BGP backdoor route\n")
2458{
2459 int ret;
2460 char prefix_str[BUFSIZ];
2461
2462 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
2463 if (! ret)
2464 {
2465 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
2466 return CMD_WARNING;
2467 }
2468
2469 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST, NULL, 1);
2470}
2471
2472DEFUN (no_bgp_network,
2473 no_bgp_network_cmd,
2474 "no network A.B.C.D/M",
2475 NO_STR
2476 "Specify a network to announce via BGP\n"
2477 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2478{
2479 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
2480 bgp_node_safi (vty));
2481}
2482
2483ALIAS (no_bgp_network,
2484 no_bgp_network_route_map_cmd,
2485 "no network A.B.C.D/M route-map WORD",
2486 NO_STR
2487 "Specify a network to announce via BGP\n"
2488 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2489 "Route-map to modify the attributes\n"
2490 "Name of the route map\n")
2491
2492ALIAS (no_bgp_network,
2493 no_bgp_network_backdoor_cmd,
2494 "no network A.B.C.D/M backdoor",
2495 NO_STR
2496 "Specify a network to announce via BGP\n"
2497 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2498 "Specify a BGP backdoor route\n")
2499
2500DEFUN (no_bgp_network_mask,
2501 no_bgp_network_mask_cmd,
2502 "no network A.B.C.D mask A.B.C.D",
2503 NO_STR
2504 "Specify a network to announce via BGP\n"
2505 "Network number\n"
2506 "Network mask\n"
2507 "Network mask\n")
2508{
2509 int ret;
2510 char prefix_str[BUFSIZ];
2511
2512 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
2513 if (! ret)
2514 {
2515 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
2516 return CMD_WARNING;
2517 }
2518
2519 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
2520 bgp_node_safi (vty));
2521}
2522
2523ALIAS (no_bgp_network_mask,
2524 no_bgp_network_mask_route_map_cmd,
2525 "no network A.B.C.D mask A.B.C.D route-map WORD",
2526 NO_STR
2527 "Specify a network to announce via BGP\n"
2528 "Network number\n"
2529 "Network mask\n"
2530 "Network mask\n"
2531 "Route-map to modify the attributes\n"
2532 "Name of the route map\n")
2533
2534ALIAS (no_bgp_network_mask,
2535 no_bgp_network_mask_backdoor_cmd,
2536 "no network A.B.C.D mask A.B.C.D backdoor",
2537 NO_STR
2538 "Specify a network to announce via BGP\n"
2539 "Network number\n"
2540 "Network mask\n"
2541 "Network mask\n"
2542 "Specify a BGP backdoor route\n")
2543
2544DEFUN (no_bgp_network_mask_natural,
2545 no_bgp_network_mask_natural_cmd,
2546 "no network A.B.C.D",
2547 NO_STR
2548 "Specify a network to announce via BGP\n"
2549 "Network number\n")
2550{
2551 int ret;
2552 char prefix_str[BUFSIZ];
2553
2554 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
2555 if (! ret)
2556 {
2557 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
2558 return CMD_WARNING;
2559 }
2560
2561 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
2562 bgp_node_safi (vty));
2563}
2564
2565ALIAS (no_bgp_network_mask_natural,
2566 no_bgp_network_mask_natural_route_map_cmd,
2567 "no network A.B.C.D route-map WORD",
2568 NO_STR
2569 "Specify a network to announce via BGP\n"
2570 "Network number\n"
2571 "Route-map to modify the attributes\n"
2572 "Name of the route map\n")
2573
2574ALIAS (no_bgp_network_mask_natural,
2575 no_bgp_network_mask_natural_backdoor_cmd,
2576 "no network A.B.C.D backdoor",
2577 NO_STR
2578 "Specify a network to announce via BGP\n"
2579 "Network number\n"
2580 "Specify a BGP backdoor route\n")
2581
2582#ifdef HAVE_IPV6
2583DEFUN (ipv6_bgp_network,
2584 ipv6_bgp_network_cmd,
2585 "network X:X::X:X/M",
2586 "Specify a network to announce via BGP\n"
2587 "IPv6 prefix <network>/<length>\n")
2588{
2589 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
2590}
2591
2592DEFUN (ipv6_bgp_network_route_map,
2593 ipv6_bgp_network_route_map_cmd,
2594 "network X:X::X:X/M route-map WORD",
2595 "Specify a network to announce via BGP\n"
2596 "IPv6 prefix <network>/<length>\n"
2597 "Route-map to modify the attributes\n"
2598 "Name of the route map\n")
2599{
2600 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
2601 bgp_node_safi (vty), argv[1], 0);
2602}
2603
2604DEFUN (no_ipv6_bgp_network,
2605 no_ipv6_bgp_network_cmd,
2606 "no network X:X::X:X/M",
2607 NO_STR
2608 "Specify a network to announce via BGP\n"
2609 "IPv6 prefix <network>/<length>\n")
2610{
2611 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, SAFI_UNICAST);
2612}
2613
2614ALIAS (no_ipv6_bgp_network,
2615 no_ipv6_bgp_network_route_map_cmd,
2616 "no network X:X::X:X/M route-map WORD",
2617 NO_STR
2618 "Specify a network to announce via BGP\n"
2619 "IPv6 prefix <network>/<length>\n"
2620 "Route-map to modify the attributes\n"
2621 "Name of the route map\n")
2622
2623ALIAS (ipv6_bgp_network,
2624 old_ipv6_bgp_network_cmd,
2625 "ipv6 bgp network X:X::X:X/M",
2626 IPV6_STR
2627 BGP_STR
2628 "Specify a network to announce via BGP\n"
2629 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2630
2631ALIAS (no_ipv6_bgp_network,
2632 old_no_ipv6_bgp_network_cmd,
2633 "no ipv6 bgp network X:X::X:X/M",
2634 NO_STR
2635 IPV6_STR
2636 BGP_STR
2637 "Specify a network to announce via BGP\n"
2638 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2639#endif /* HAVE_IPV6 */
2640
2641/* Aggreagete address:
2642
2643 advertise-map Set condition to advertise attribute
2644 as-set Generate AS set path information
2645 attribute-map Set attributes of aggregate
2646 route-map Set parameters of aggregate
2647 summary-only Filter more specific routes from updates
2648 suppress-map Conditionally filter more specific routes from updates
2649 <cr>
2650 */
2651struct bgp_aggregate
2652{
2653 /* Summary-only flag. */
2654 u_char summary_only;
2655
2656 /* AS set generation. */
2657 u_char as_set;
2658
2659 /* Route-map for aggregated route. */
2660 struct route_map *map;
2661
2662 /* Suppress-count. */
2663 unsigned long count;
2664
2665 /* SAFI configuration. */
2666 safi_t safi;
2667};
2668
2669struct bgp_aggregate *
2670bgp_aggregate_new ()
2671{
2672 struct bgp_aggregate *new;
2673 new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
2674 memset (new, 0, sizeof (struct bgp_aggregate));
2675 return new;
2676}
2677
2678void
2679bgp_aggregate_free (struct bgp_aggregate *aggregate)
2680{
2681 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
2682}
2683
2684void
2685bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
2686 afi_t afi, safi_t safi, struct bgp_info *del,
2687 struct bgp_aggregate *aggregate)
2688{
2689 struct bgp_table *table;
2690 struct bgp_node *top;
2691 struct bgp_node *rn;
2692 u_char origin;
2693 struct aspath *aspath = NULL;
2694 struct aspath *asmerge = NULL;
2695 struct community *community = NULL;
2696 struct community *commerge = NULL;
2697 struct in_addr nexthop;
2698 u_int32_t med = 0;
2699 struct bgp_info *ri;
2700 struct bgp_info *new;
2701 int first = 1;
2702 unsigned long match = 0;
2703
2704 /* Record adding route's nexthop and med. */
2705 if (rinew)
2706 {
2707 nexthop = rinew->attr->nexthop;
2708 med = rinew->attr->med;
2709 }
2710
2711 /* ORIGIN attribute: If at least one route among routes that are
2712 aggregated has ORIGIN with the value INCOMPLETE, then the
2713 aggregated route must have the ORIGIN attribute with the value
2714 INCOMPLETE. Otherwise, if at least one route among routes that
2715 are aggregated has ORIGIN with the value EGP, then the aggregated
2716 route must have the origin attribute with the value EGP. In all
2717 other case the value of the ORIGIN attribute of the aggregated
2718 route is INTERNAL. */
2719 origin = BGP_ORIGIN_IGP;
2720
2721 table = bgp->rib[afi][safi];
2722
2723 top = bgp_node_get (table, p);
2724 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
2725 if (rn->p.prefixlen > p->prefixlen)
2726 {
2727 match = 0;
2728
2729 for (ri = rn->info; ri; ri = ri->next)
2730 {
2731 if (BGP_INFO_HOLDDOWN (ri))
2732 continue;
2733
2734 if (del && ri == del)
2735 continue;
2736
2737 if (! rinew && first)
2738 {
2739 nexthop = ri->attr->nexthop;
2740 med = ri->attr->med;
2741 first = 0;
2742 }
2743
2744#ifdef AGGREGATE_NEXTHOP_CHECK
2745 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
2746 || ri->attr->med != med)
2747 {
2748 if (aspath)
2749 aspath_free (aspath);
2750 if (community)
2751 community_free (community);
2752 bgp_unlock_node (rn);
2753 bgp_unlock_node (top);
2754 return;
2755 }
2756#endif /* AGGREGATE_NEXTHOP_CHECK */
2757
2758 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
2759 {
2760 if (aggregate->summary_only)
2761 {
2762 ri->suppress++;
2763 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
2764 match++;
2765 }
2766
2767 aggregate->count++;
2768
2769 if (aggregate->as_set)
2770 {
2771 if (origin < ri->attr->origin)
2772 origin = ri->attr->origin;
2773
2774 if (aspath)
2775 {
2776 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
2777 aspath_free (aspath);
2778 aspath = asmerge;
2779 }
2780 else
2781 aspath = aspath_dup (ri->attr->aspath);
2782
2783 if (ri->attr->community)
2784 {
2785 if (community)
2786 {
2787 commerge = community_merge (community,
2788 ri->attr->community);
2789 community = community_uniq_sort (commerge);
2790 community_free (commerge);
2791 }
2792 else
2793 community = community_dup (ri->attr->community);
2794 }
2795 }
2796 }
2797 }
2798 if (match)
2799 bgp_process (bgp, rn, afi, safi);
2800 }
2801 bgp_unlock_node (top);
2802
2803 if (rinew)
2804 {
2805 aggregate->count++;
2806
2807 if (aggregate->summary_only)
2808 rinew->suppress++;
2809
2810 if (aggregate->as_set)
2811 {
2812 if (origin < rinew->attr->origin)
2813 origin = rinew->attr->origin;
2814
2815 if (aspath)
2816 {
2817 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
2818 aspath_free (aspath);
2819 aspath = asmerge;
2820 }
2821 else
2822 aspath = aspath_dup (rinew->attr->aspath);
2823
2824 if (rinew->attr->community)
2825 {
2826 if (community)
2827 {
2828 commerge = community_merge (community,
2829 rinew->attr->community);
2830 community = community_uniq_sort (commerge);
2831 community_free (commerge);
2832 }
2833 else
2834 community = community_dup (rinew->attr->community);
2835 }
2836 }
2837 }
2838
2839 if (aggregate->count > 0)
2840 {
2841 rn = bgp_node_get (table, p);
2842 new = bgp_info_new ();
2843 new->type = ZEBRA_ROUTE_BGP;
2844 new->sub_type = BGP_ROUTE_AGGREGATE;
2845 new->peer = bgp->peer_self;
2846 SET_FLAG (new->flags, BGP_INFO_VALID);
2847 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
2848 new->uptime = time (NULL);
2849
2850 bgp_info_add (rn, new);
2851 bgp_process (bgp, rn, afi, safi);
2852 }
2853 else
2854 {
2855 if (aspath)
2856 aspath_free (aspath);
2857 if (community)
2858 community_free (community);
2859 }
2860}
2861
2862void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
2863 struct bgp_aggregate *);
2864
2865void
2866bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
2867 struct bgp_info *ri, afi_t afi, safi_t safi)
2868{
2869 struct bgp_node *child;
2870 struct bgp_node *rn;
2871 struct bgp_aggregate *aggregate;
2872
2873 /* MPLS-VPN aggregation is not yet supported. */
2874 if (safi == SAFI_MPLS_VPN)
2875 return;
2876
2877 if (p->prefixlen == 0)
2878 return;
2879
2880 if (BGP_INFO_HOLDDOWN (ri))
2881 return;
2882
2883 child = bgp_node_get (bgp->aggregate[afi][safi], p);
2884
2885 /* Aggregate address configuration check. */
2886 for (rn = child; rn; rn = rn->parent)
2887 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
2888 {
2889 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00002890 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00002891 }
2892 bgp_unlock_node (child);
2893}
2894
2895void
2896bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
2897 struct bgp_info *del, afi_t afi, safi_t safi)
2898{
2899 struct bgp_node *child;
2900 struct bgp_node *rn;
2901 struct bgp_aggregate *aggregate;
2902
2903 /* MPLS-VPN aggregation is not yet supported. */
2904 if (safi == SAFI_MPLS_VPN)
2905 return;
2906
2907 if (p->prefixlen == 0)
2908 return;
2909
2910 child = bgp_node_get (bgp->aggregate[afi][safi], p);
2911
2912 /* Aggregate address configuration check. */
2913 for (rn = child; rn; rn = rn->parent)
2914 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
2915 {
2916 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00002917 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00002918 }
2919 bgp_unlock_node (child);
2920}
2921
2922void
2923bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
2924 struct bgp_aggregate *aggregate)
2925{
2926 struct bgp_table *table;
2927 struct bgp_node *top;
2928 struct bgp_node *rn;
2929 struct bgp_info *new;
2930 struct bgp_info *ri;
2931 unsigned long match;
2932 u_char origin = BGP_ORIGIN_IGP;
2933 struct aspath *aspath = NULL;
2934 struct aspath *asmerge = NULL;
2935 struct community *community = NULL;
2936 struct community *commerge = NULL;
2937
2938 table = bgp->rib[afi][safi];
2939
2940 /* Sanity check. */
2941 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
2942 return;
2943 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
2944 return;
2945
2946 /* If routes exists below this node, generate aggregate routes. */
2947 top = bgp_node_get (table, p);
2948 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
2949 if (rn->p.prefixlen > p->prefixlen)
2950 {
2951 match = 0;
2952
2953 for (ri = rn->info; ri; ri = ri->next)
2954 {
2955 if (BGP_INFO_HOLDDOWN (ri))
2956 continue;
2957
2958 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
2959 {
2960 /* summary-only aggregate route suppress aggregated
2961 route announcement. */
2962 if (aggregate->summary_only)
2963 {
2964 ri->suppress++;
2965 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
2966 match++;
2967 }
2968 /* as-set aggregate route generate origin, as path,
2969 community aggregation. */
2970 if (aggregate->as_set)
2971 {
2972 if (origin < ri->attr->origin)
2973 origin = ri->attr->origin;
2974
2975 if (aspath)
2976 {
2977 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
2978 aspath_free (aspath);
2979 aspath = asmerge;
2980 }
2981 else
2982 aspath = aspath_dup (ri->attr->aspath);
2983
2984 if (ri->attr->community)
2985 {
2986 if (community)
2987 {
2988 commerge = community_merge (community,
2989 ri->attr->community);
2990 community = community_uniq_sort (commerge);
2991 community_free (commerge);
2992 }
2993 else
2994 community = community_dup (ri->attr->community);
2995 }
2996 }
2997 aggregate->count++;
2998 }
2999 }
3000
3001 /* If this node is suppressed, process the change. */
3002 if (match)
3003 bgp_process (bgp, rn, afi, safi);
3004 }
3005 bgp_unlock_node (top);
3006
3007 /* Add aggregate route to BGP table. */
3008 if (aggregate->count)
3009 {
3010 rn = bgp_node_get (table, p);
3011
3012 new = bgp_info_new ();
3013 new->type = ZEBRA_ROUTE_BGP;
3014 new->sub_type = BGP_ROUTE_AGGREGATE;
3015 new->peer = bgp->peer_self;
3016 SET_FLAG (new->flags, BGP_INFO_VALID);
3017 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
3018 new->uptime = time (NULL);
3019
3020 bgp_info_add (rn, new);
3021
3022 /* Process change. */
3023 bgp_process (bgp, rn, afi, safi);
3024 }
3025}
3026
3027void
3028bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
3029 safi_t safi, struct bgp_aggregate *aggregate)
3030{
3031 struct bgp_table *table;
3032 struct bgp_node *top;
3033 struct bgp_node *rn;
3034 struct bgp_info *ri;
3035 unsigned long match;
3036
3037 table = bgp->rib[afi][safi];
3038
3039 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
3040 return;
3041 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
3042 return;
3043
3044 /* If routes exists below this node, generate aggregate routes. */
3045 top = bgp_node_get (table, p);
3046 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
3047 if (rn->p.prefixlen > p->prefixlen)
3048 {
3049 match = 0;
3050
3051 for (ri = rn->info; ri; ri = ri->next)
3052 {
3053 if (BGP_INFO_HOLDDOWN (ri))
3054 continue;
3055
3056 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
3057 {
3058 if (aggregate->summary_only)
3059 {
3060 ri->suppress--;
3061
3062 if (ri->suppress == 0)
3063 {
3064 SET_FLAG (ri->flags, BGP_INFO_ATTR_CHANGED);
3065 match++;
3066 }
3067 }
3068 aggregate->count--;
3069 }
3070 }
3071
3072 /* If this node is suppressed, process the change. */
3073 if (match)
3074 bgp_process (bgp, rn, afi, safi);
3075 }
3076 bgp_unlock_node (top);
3077
3078 /* Delete aggregate route from BGP table. */
3079 rn = bgp_node_get (table, p);
3080
3081 for (ri = rn->info; ri; ri = ri->next)
3082 if (ri->peer == bgp->peer_self
3083 && ri->type == ZEBRA_ROUTE_BGP
3084 && ri->sub_type == BGP_ROUTE_AGGREGATE)
3085 break;
3086
3087 /* Withdraw static BGP route from routing table. */
3088 if (ri)
3089 {
3090 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
3091 bgp_process (bgp, rn, afi, safi);
3092 bgp_info_delete (rn, ri);
3093 bgp_info_free (ri);
3094 bgp_unlock_node (rn);
3095 }
3096
3097 /* Unlock bgp_node_lookup. */
3098 bgp_unlock_node (rn);
3099}
3100
3101/* Aggregate route attribute. */
3102#define AGGREGATE_SUMMARY_ONLY 1
3103#define AGGREGATE_AS_SET 1
3104
3105int
3106bgp_aggregate_set (struct vty *vty, char *prefix_str, afi_t afi, safi_t safi,
3107 u_char summary_only, u_char as_set)
3108{
3109 int ret;
3110 struct prefix p;
3111 struct bgp_node *rn;
3112 struct bgp *bgp;
3113 struct bgp_aggregate *aggregate;
3114
3115 /* Convert string to prefix structure. */
3116 ret = str2prefix (prefix_str, &p);
3117 if (!ret)
3118 {
3119 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
3120 return CMD_WARNING;
3121 }
3122 apply_mask (&p);
3123
3124 /* Get BGP structure. */
3125 bgp = vty->index;
3126
3127 /* Old configuration check. */
3128 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
3129
3130 if (rn->info)
3131 {
3132 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
3133 bgp_unlock_node (rn);
3134 return CMD_WARNING;
3135 }
3136
3137 /* Make aggregate address structure. */
3138 aggregate = bgp_aggregate_new ();
3139 aggregate->summary_only = summary_only;
3140 aggregate->as_set = as_set;
3141 aggregate->safi = safi;
3142 rn->info = aggregate;
3143
3144 /* Aggregate address insert into BGP routing table. */
3145 if (safi & SAFI_UNICAST)
3146 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
3147 if (safi & SAFI_MULTICAST)
3148 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
3149
3150 return CMD_SUCCESS;
3151}
3152
3153int
3154bgp_aggregate_unset (struct vty *vty, char *prefix_str, afi_t afi, safi_t safi)
3155{
3156 int ret;
3157 struct prefix p;
3158 struct bgp_node *rn;
3159 struct bgp *bgp;
3160 struct bgp_aggregate *aggregate;
3161
3162 /* Convert string to prefix structure. */
3163 ret = str2prefix (prefix_str, &p);
3164 if (!ret)
3165 {
3166 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
3167 return CMD_WARNING;
3168 }
3169 apply_mask (&p);
3170
3171 /* Get BGP structure. */
3172 bgp = vty->index;
3173
3174 /* Old configuration check. */
3175 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
3176 if (! rn)
3177 {
3178 vty_out (vty, "%% There is no aggregate-address configuration.%s",
3179 VTY_NEWLINE);
3180 return CMD_WARNING;
3181 }
3182
3183 aggregate = rn->info;
3184 if (aggregate->safi & SAFI_UNICAST)
3185 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
3186 if (aggregate->safi & SAFI_MULTICAST)
3187 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
3188
3189 /* Unlock aggregate address configuration. */
3190 rn->info = NULL;
3191 bgp_aggregate_free (aggregate);
3192 bgp_unlock_node (rn);
3193 bgp_unlock_node (rn);
3194
3195 return CMD_SUCCESS;
3196}
3197
3198DEFUN (aggregate_address,
3199 aggregate_address_cmd,
3200 "aggregate-address A.B.C.D/M",
3201 "Configure BGP aggregate entries\n"
3202 "Aggregate prefix\n")
3203{
3204 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
3205}
3206
3207DEFUN (aggregate_address_mask,
3208 aggregate_address_mask_cmd,
3209 "aggregate-address A.B.C.D A.B.C.D",
3210 "Configure BGP aggregate entries\n"
3211 "Aggregate address\n"
3212 "Aggregate mask\n")
3213{
3214 int ret;
3215 char prefix_str[BUFSIZ];
3216
3217 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3218
3219 if (! ret)
3220 {
3221 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3222 return CMD_WARNING;
3223 }
3224
3225 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
3226 0, 0);
3227}
3228
3229DEFUN (aggregate_address_summary_only,
3230 aggregate_address_summary_only_cmd,
3231 "aggregate-address A.B.C.D/M summary-only",
3232 "Configure BGP aggregate entries\n"
3233 "Aggregate prefix\n"
3234 "Filter more specific routes from updates\n")
3235{
3236 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
3237 AGGREGATE_SUMMARY_ONLY, 0);
3238}
3239
3240DEFUN (aggregate_address_mask_summary_only,
3241 aggregate_address_mask_summary_only_cmd,
3242 "aggregate-address A.B.C.D A.B.C.D summary-only",
3243 "Configure BGP aggregate entries\n"
3244 "Aggregate address\n"
3245 "Aggregate mask\n"
3246 "Filter more specific routes from updates\n")
3247{
3248 int ret;
3249 char prefix_str[BUFSIZ];
3250
3251 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3252
3253 if (! ret)
3254 {
3255 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3256 return CMD_WARNING;
3257 }
3258
3259 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
3260 AGGREGATE_SUMMARY_ONLY, 0);
3261}
3262
3263DEFUN (aggregate_address_as_set,
3264 aggregate_address_as_set_cmd,
3265 "aggregate-address A.B.C.D/M as-set",
3266 "Configure BGP aggregate entries\n"
3267 "Aggregate prefix\n"
3268 "Generate AS set path information\n")
3269{
3270 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
3271 0, AGGREGATE_AS_SET);
3272}
3273
3274DEFUN (aggregate_address_mask_as_set,
3275 aggregate_address_mask_as_set_cmd,
3276 "aggregate-address A.B.C.D A.B.C.D as-set",
3277 "Configure BGP aggregate entries\n"
3278 "Aggregate address\n"
3279 "Aggregate mask\n"
3280 "Generate AS set path information\n")
3281{
3282 int ret;
3283 char prefix_str[BUFSIZ];
3284
3285 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3286
3287 if (! ret)
3288 {
3289 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3290 return CMD_WARNING;
3291 }
3292
3293 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
3294 0, AGGREGATE_AS_SET);
3295}
3296
3297
3298DEFUN (aggregate_address_as_set_summary,
3299 aggregate_address_as_set_summary_cmd,
3300 "aggregate-address A.B.C.D/M as-set summary-only",
3301 "Configure BGP aggregate entries\n"
3302 "Aggregate prefix\n"
3303 "Generate AS set path information\n"
3304 "Filter more specific routes from updates\n")
3305{
3306 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
3307 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
3308}
3309
3310ALIAS (aggregate_address_as_set_summary,
3311 aggregate_address_summary_as_set_cmd,
3312 "aggregate-address A.B.C.D/M summary-only as-set",
3313 "Configure BGP aggregate entries\n"
3314 "Aggregate prefix\n"
3315 "Filter more specific routes from updates\n"
3316 "Generate AS set path information\n")
3317
3318DEFUN (aggregate_address_mask_as_set_summary,
3319 aggregate_address_mask_as_set_summary_cmd,
3320 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
3321 "Configure BGP aggregate entries\n"
3322 "Aggregate address\n"
3323 "Aggregate mask\n"
3324 "Generate AS set path information\n"
3325 "Filter more specific routes from updates\n")
3326{
3327 int ret;
3328 char prefix_str[BUFSIZ];
3329
3330 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3331
3332 if (! ret)
3333 {
3334 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3335 return CMD_WARNING;
3336 }
3337
3338 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
3339 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
3340}
3341
3342ALIAS (aggregate_address_mask_as_set_summary,
3343 aggregate_address_mask_summary_as_set_cmd,
3344 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
3345 "Configure BGP aggregate entries\n"
3346 "Aggregate address\n"
3347 "Aggregate mask\n"
3348 "Filter more specific routes from updates\n"
3349 "Generate AS set path information\n")
3350
3351DEFUN (no_aggregate_address,
3352 no_aggregate_address_cmd,
3353 "no aggregate-address A.B.C.D/M",
3354 NO_STR
3355 "Configure BGP aggregate entries\n"
3356 "Aggregate prefix\n")
3357{
3358 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
3359}
3360
3361ALIAS (no_aggregate_address,
3362 no_aggregate_address_summary_only_cmd,
3363 "no aggregate-address A.B.C.D/M summary-only",
3364 NO_STR
3365 "Configure BGP aggregate entries\n"
3366 "Aggregate prefix\n"
3367 "Filter more specific routes from updates\n")
3368
3369ALIAS (no_aggregate_address,
3370 no_aggregate_address_as_set_cmd,
3371 "no aggregate-address A.B.C.D/M as-set",
3372 NO_STR
3373 "Configure BGP aggregate entries\n"
3374 "Aggregate prefix\n"
3375 "Generate AS set path information\n")
3376
3377ALIAS (no_aggregate_address,
3378 no_aggregate_address_as_set_summary_cmd,
3379 "no aggregate-address A.B.C.D/M as-set summary-only",
3380 NO_STR
3381 "Configure BGP aggregate entries\n"
3382 "Aggregate prefix\n"
3383 "Generate AS set path information\n"
3384 "Filter more specific routes from updates\n")
3385
3386ALIAS (no_aggregate_address,
3387 no_aggregate_address_summary_as_set_cmd,
3388 "no aggregate-address A.B.C.D/M summary-only as-set",
3389 NO_STR
3390 "Configure BGP aggregate entries\n"
3391 "Aggregate prefix\n"
3392 "Filter more specific routes from updates\n"
3393 "Generate AS set path information\n")
3394
3395DEFUN (no_aggregate_address_mask,
3396 no_aggregate_address_mask_cmd,
3397 "no aggregate-address A.B.C.D A.B.C.D",
3398 NO_STR
3399 "Configure BGP aggregate entries\n"
3400 "Aggregate address\n"
3401 "Aggregate mask\n")
3402{
3403 int ret;
3404 char prefix_str[BUFSIZ];
3405
3406 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
3407
3408 if (! ret)
3409 {
3410 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
3411 return CMD_WARNING;
3412 }
3413
3414 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
3415}
3416
3417ALIAS (no_aggregate_address_mask,
3418 no_aggregate_address_mask_summary_only_cmd,
3419 "no aggregate-address A.B.C.D A.B.C.D summary-only",
3420 NO_STR
3421 "Configure BGP aggregate entries\n"
3422 "Aggregate address\n"
3423 "Aggregate mask\n"
3424 "Filter more specific routes from updates\n")
3425
3426ALIAS (no_aggregate_address_mask,
3427 no_aggregate_address_mask_as_set_cmd,
3428 "no aggregate-address A.B.C.D A.B.C.D as-set",
3429 NO_STR
3430 "Configure BGP aggregate entries\n"
3431 "Aggregate address\n"
3432 "Aggregate mask\n"
3433 "Generate AS set path information\n")
3434
3435ALIAS (no_aggregate_address_mask,
3436 no_aggregate_address_mask_as_set_summary_cmd,
3437 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
3438 NO_STR
3439 "Configure BGP aggregate entries\n"
3440 "Aggregate address\n"
3441 "Aggregate mask\n"
3442 "Generate AS set path information\n"
3443 "Filter more specific routes from updates\n")
3444
3445ALIAS (no_aggregate_address_mask,
3446 no_aggregate_address_mask_summary_as_set_cmd,
3447 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
3448 NO_STR
3449 "Configure BGP aggregate entries\n"
3450 "Aggregate address\n"
3451 "Aggregate mask\n"
3452 "Filter more specific routes from updates\n"
3453 "Generate AS set path information\n")
3454
3455#ifdef HAVE_IPV6
3456DEFUN (ipv6_aggregate_address,
3457 ipv6_aggregate_address_cmd,
3458 "aggregate-address X:X::X:X/M",
3459 "Configure BGP aggregate entries\n"
3460 "Aggregate prefix\n")
3461{
3462 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
3463}
3464
3465DEFUN (ipv6_aggregate_address_summary_only,
3466 ipv6_aggregate_address_summary_only_cmd,
3467 "aggregate-address X:X::X:X/M summary-only",
3468 "Configure BGP aggregate entries\n"
3469 "Aggregate prefix\n"
3470 "Filter more specific routes from updates\n")
3471{
3472 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
3473 AGGREGATE_SUMMARY_ONLY, 0);
3474}
3475
3476DEFUN (no_ipv6_aggregate_address,
3477 no_ipv6_aggregate_address_cmd,
3478 "no aggregate-address X:X::X:X/M",
3479 NO_STR
3480 "Configure BGP aggregate entries\n"
3481 "Aggregate prefix\n")
3482{
3483 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
3484}
3485
3486DEFUN (no_ipv6_aggregate_address_summary_only,
3487 no_ipv6_aggregate_address_summary_only_cmd,
3488 "no aggregate-address X:X::X:X/M summary-only",
3489 NO_STR
3490 "Configure BGP aggregate entries\n"
3491 "Aggregate prefix\n"
3492 "Filter more specific routes from updates\n")
3493{
3494 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
3495}
3496
3497ALIAS (ipv6_aggregate_address,
3498 old_ipv6_aggregate_address_cmd,
3499 "ipv6 bgp aggregate-address X:X::X:X/M",
3500 IPV6_STR
3501 BGP_STR
3502 "Configure BGP aggregate entries\n"
3503 "Aggregate prefix\n")
3504
3505ALIAS (ipv6_aggregate_address_summary_only,
3506 old_ipv6_aggregate_address_summary_only_cmd,
3507 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
3508 IPV6_STR
3509 BGP_STR
3510 "Configure BGP aggregate entries\n"
3511 "Aggregate prefix\n"
3512 "Filter more specific routes from updates\n")
3513
3514ALIAS (no_ipv6_aggregate_address,
3515 old_no_ipv6_aggregate_address_cmd,
3516 "no ipv6 bgp aggregate-address X:X::X:X/M",
3517 NO_STR
3518 IPV6_STR
3519 BGP_STR
3520 "Configure BGP aggregate entries\n"
3521 "Aggregate prefix\n")
3522
3523ALIAS (no_ipv6_aggregate_address_summary_only,
3524 old_no_ipv6_aggregate_address_summary_only_cmd,
3525 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
3526 NO_STR
3527 IPV6_STR
3528 BGP_STR
3529 "Configure BGP aggregate entries\n"
3530 "Aggregate prefix\n"
3531 "Filter more specific routes from updates\n")
3532#endif /* HAVE_IPV6 */
3533
3534/* Redistribute route treatment. */
3535void
3536bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop,
3537 u_int32_t metric, u_char type)
3538{
3539 struct bgp *bgp;
3540 struct listnode *nn;
3541 struct bgp_info *new;
3542 struct bgp_info *bi;
3543 struct bgp_info info;
3544 struct bgp_node *bn;
3545 struct attr attr;
3546 struct attr attr_new;
3547 struct attr *new_attr;
3548 afi_t afi;
3549 int ret;
3550
3551 /* Make default attribute. */
3552 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
3553 if (nexthop)
3554 attr.nexthop = *nexthop;
3555
3556 attr.med = metric;
3557 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3558
3559 LIST_LOOP (bm->bgp, bgp, nn)
3560 {
3561 afi = family2afi (p->family);
3562
3563 if (bgp->redist[afi][type])
3564 {
3565 /* Copy attribute for modification. */
3566 attr_new = attr;
3567
3568 if (bgp->redist_metric_flag[afi][type])
3569 attr_new.med = bgp->redist_metric[afi][type];
3570
3571 /* Apply route-map. */
3572 if (bgp->rmap[afi][type].map)
3573 {
3574 info.peer = bgp->peer_self;
3575 info.attr = &attr_new;
3576
3577 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
3578 &info);
3579 if (ret == RMAP_DENYMATCH)
3580 {
3581 /* Free uninterned attribute. */
3582 bgp_attr_flush (&attr_new);
3583
3584 /* Unintern original. */
3585 aspath_unintern (attr.aspath);
3586 bgp_redistribute_delete (p, type);
3587 return;
3588 }
3589 }
3590
3591 bn = bgp_afi_node_get (bgp, afi, SAFI_UNICAST, p, NULL);
3592 new_attr = bgp_attr_intern (&attr_new);
3593
3594 for (bi = bn->info; bi; bi = bi->next)
3595 if (bi->peer == bgp->peer_self
3596 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
3597 break;
3598
3599 if (bi)
3600 {
3601 if (attrhash_cmp (bi->attr, new_attr))
3602 {
3603 bgp_attr_unintern (new_attr);
3604 aspath_unintern (attr.aspath);
3605 bgp_unlock_node (bn);
3606 return;
3607 }
3608 else
3609 {
3610 /* The attribute is changed. */
3611 SET_FLAG (bi->flags, BGP_INFO_ATTR_CHANGED);
3612
3613 /* Rewrite BGP route information. */
3614 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
3615 bgp_attr_unintern (bi->attr);
3616 bi->attr = new_attr;
3617 bi->uptime = time (NULL);
3618
3619 /* Process change. */
3620 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
3621 bgp_process (bgp, bn, afi, SAFI_UNICAST);
3622 bgp_unlock_node (bn);
3623 aspath_unintern (attr.aspath);
3624 return;
3625 }
3626 }
3627
3628 new = bgp_info_new ();
3629 new->type = type;
3630 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
3631 new->peer = bgp->peer_self;
3632 SET_FLAG (new->flags, BGP_INFO_VALID);
3633 new->attr = new_attr;
3634 new->uptime = time (NULL);
3635
3636 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
3637 bgp_info_add (bn, new);
3638 bgp_process (bgp, bn, afi, SAFI_UNICAST);
3639 }
3640 }
3641
3642 /* Unintern original. */
3643 aspath_unintern (attr.aspath);
3644}
3645
3646void
3647bgp_redistribute_delete (struct prefix *p, u_char type)
3648{
3649 struct bgp *bgp;
3650 struct listnode *nn;
3651 afi_t afi;
3652 struct bgp_node *rn;
3653 struct bgp_info *ri;
3654
3655 LIST_LOOP (bm->bgp, bgp, nn)
3656 {
3657 afi = family2afi (p->family);
3658
3659 if (bgp->redist[afi][type])
3660 {
3661 rn = bgp_afi_node_get (bgp, afi, SAFI_UNICAST, p, NULL);
3662
3663 for (ri = rn->info; ri; ri = ri->next)
3664 if (ri->peer == bgp->peer_self
3665 && ri->type == type)
3666 break;
3667
3668 if (ri)
3669 {
3670 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
3671 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
3672 bgp_process (bgp, rn, afi, SAFI_UNICAST);
3673 bgp_info_delete (rn, ri);
3674 bgp_info_free (ri);
3675 bgp_unlock_node (rn);
3676 }
3677 bgp_unlock_node (rn);
3678 }
3679 }
3680}
3681
3682/* Withdraw specified route type's route. */
3683void
3684bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
3685{
3686 struct bgp_node *rn;
3687 struct bgp_info *ri;
3688 struct bgp_table *table;
3689
3690 table = bgp->rib[afi][SAFI_UNICAST];
3691
3692 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3693 {
3694 for (ri = rn->info; ri; ri = ri->next)
3695 if (ri->peer == bgp->peer_self
3696 && ri->type == type)
3697 break;
3698
3699 if (ri)
3700 {
3701 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
3702 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
3703 bgp_process (bgp, rn, afi, SAFI_UNICAST);
3704 bgp_info_delete (rn, ri);
3705 bgp_info_free (ri);
3706 bgp_unlock_node (rn);
3707 }
3708 }
3709}
3710
3711/* Static function to display route. */
3712void
3713route_vty_out_route (struct prefix *p, struct vty *vty)
3714{
3715 int len;
3716 u_int32_t destination;
3717 char buf[BUFSIZ];
3718
3719 if (p->family == AF_INET)
3720 {
3721 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
3722 destination = ntohl (p->u.prefix4.s_addr);
3723
3724 if ((IN_CLASSC (destination) && p->prefixlen == 24)
3725 || (IN_CLASSB (destination) && p->prefixlen == 16)
3726 || (IN_CLASSA (destination) && p->prefixlen == 8)
3727 || p->u.prefix4.s_addr == 0)
3728 {
3729 /* When mask is natural, mask is not displayed. */
3730 }
3731 else
3732 len += vty_out (vty, "/%d", p->prefixlen);
3733 }
3734 else
3735 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
3736 p->prefixlen);
3737
3738 len = 17 - len;
3739 if (len < 1)
3740 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
3741 else
3742 vty_out (vty, "%*s", len, " ");
3743}
3744
3745/* Calculate line number of output data. */
3746int
3747vty_calc_line (struct vty *vty, unsigned long length)
3748{
3749 return vty->width ? (((vty->obuf->length - length) / vty->width) + 1) : 1;
3750}
3751
3752enum bgp_display_type
3753{
3754 normal_list,
3755};
3756
3757/* called from terminal list command */
3758int
3759route_vty_out (struct vty *vty, struct prefix *p,
3760 struct bgp_info *binfo, int display, safi_t safi)
3761{
3762 struct attr *attr;
3763 unsigned long length = 0;
3764
3765 length = vty->obuf->length;
3766
3767 /* Route status display. */
3768 if (binfo->suppress)
3769 vty_out (vty, "s");
3770 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
3771 vty_out (vty, "*");
3772 else
3773 vty_out (vty, " ");
3774
3775 /* Selected */
3776 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
3777 vty_out (vty, "h");
3778 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
3779 vty_out (vty, "d");
3780 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
3781 vty_out (vty, ">");
3782 else
3783 vty_out (vty, " ");
3784
3785 /* Internal route. */
3786 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
3787 vty_out (vty, "i");
3788 else
3789 vty_out (vty, " ");
3790
3791 /* print prefix and mask */
3792 if (! display)
3793 route_vty_out_route (p, vty);
3794 else
3795 vty_out (vty, "%*s", 17, " ");
3796
3797 /* Print attribute */
3798 attr = binfo->attr;
3799 if (attr)
3800 {
3801 if (p->family == AF_INET)
3802 {
3803 if (safi == SAFI_MPLS_VPN)
3804 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
3805 else
3806 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
3807 }
3808#ifdef HAVE_IPV6
3809 else if (p->family == AF_INET6)
3810 {
3811 int len;
3812 char buf[BUFSIZ];
3813
3814 len = vty_out (vty, "%s",
3815 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
3816 len = 16 - len;
3817 if (len < 1)
3818 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
3819 else
3820 vty_out (vty, "%*s", len, " ");
3821 }
3822#endif /* HAVE_IPV6 */
3823
3824 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
3825 vty_out (vty, "%10d", attr->med);
3826 else
3827 vty_out (vty, " ");
3828
3829 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
3830 vty_out (vty, "%7d", attr->local_pref);
3831 else
3832 vty_out (vty, " ");
3833
3834 vty_out (vty, "%7u ",attr->weight);
3835
3836 /* Print aspath */
3837 if (attr->aspath)
3838 aspath_print_vty (vty, attr->aspath);
3839
3840 /* Print origin */
3841 if (strlen (attr->aspath->str) == 0)
3842 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
3843 else
3844 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
3845 }
3846 vty_out (vty, "%s", VTY_NEWLINE);
3847
3848 return vty_calc_line (vty, length);
3849}
3850
3851/* called from terminal list command */
3852void
3853route_vty_out_tmp (struct vty *vty, struct prefix *p,
3854 struct attr *attr, safi_t safi)
3855{
3856 /* Route status display. */
3857 vty_out (vty, "*");
3858 vty_out (vty, ">");
3859 vty_out (vty, " ");
3860
3861 /* print prefix and mask */
3862 route_vty_out_route (p, vty);
3863
3864 /* Print attribute */
3865 if (attr)
3866 {
3867 if (p->family == AF_INET)
3868 {
3869 if (safi == SAFI_MPLS_VPN)
3870 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
3871 else
3872 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
3873 }
3874#ifdef HAVE_IPV6
3875 else if (p->family == AF_INET6)
3876 {
3877 int len;
3878 char buf[BUFSIZ];
3879
3880 len = vty_out (vty, "%s",
3881 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
3882 len = 16 - len;
3883 if (len < 1)
3884 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
3885 else
3886 vty_out (vty, "%*s", len, " ");
3887 }
3888#endif /* HAVE_IPV6 */
3889
3890 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
3891 vty_out (vty, "%10d", attr->med);
3892 else
3893 vty_out (vty, " ");
3894
3895 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
3896 vty_out (vty, "%7d", attr->local_pref);
3897 else
3898 vty_out (vty, " ");
3899
3900 vty_out (vty, "%7d ",attr->weight);
3901
3902 /* Print aspath */
3903 if (attr->aspath)
3904 aspath_print_vty (vty, attr->aspath);
3905
3906 /* Print origin */
3907 if (strlen (attr->aspath->str) == 0)
3908 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
3909 else
3910 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
3911 }
3912
3913 vty_out (vty, "%s", VTY_NEWLINE);
3914}
3915
3916int
3917route_vty_out_tag (struct vty *vty, struct prefix *p,
3918 struct bgp_info *binfo, int display, safi_t safi)
3919{
3920 struct attr *attr;
3921 unsigned long length = 0;
3922 u_int32_t label = 0;
3923
3924 length = vty->obuf->length;
3925
3926 /* Route status display. */
3927 if (binfo->suppress)
3928 vty_out (vty, "s");
3929 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
3930 vty_out (vty, "*");
3931 else
3932 vty_out (vty, " ");
3933
3934 /* Selected */
3935 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
3936 vty_out (vty, "h");
3937 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
3938 vty_out (vty, "d");
3939 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
3940 vty_out (vty, ">");
3941 else
3942 vty_out (vty, " ");
3943
3944 /* Internal route. */
3945 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
3946 vty_out (vty, "i");
3947 else
3948 vty_out (vty, " ");
3949
3950 /* print prefix and mask */
3951 if (! display)
3952 route_vty_out_route (p, vty);
3953 else
3954 vty_out (vty, "%*s", 17, " ");
3955
3956 /* Print attribute */
3957 attr = binfo->attr;
3958 if (attr)
3959 {
3960 if (p->family == AF_INET)
3961 {
3962 if (safi == SAFI_MPLS_VPN)
3963 vty_out (vty, "%-16s", inet_ntoa (attr->mp_nexthop_global_in));
3964 else
3965 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
3966 }
3967#ifdef HAVE_IPV6
3968 else if (p->family == AF_INET6)
3969 {
3970 char buf[BUFSIZ];
3971 char buf1[BUFSIZ];
3972 if (attr->mp_nexthop_len == 16)
3973 vty_out (vty, "%s",
3974 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ));
3975 else if (attr->mp_nexthop_len == 32)
3976 vty_out (vty, "%s(%s)",
3977 inet_ntop (AF_INET6, &attr->mp_nexthop_global, buf, BUFSIZ),
3978 inet_ntop (AF_INET6, &attr->mp_nexthop_local, buf1, BUFSIZ));
3979
3980 }
3981#endif /* HAVE_IPV6 */
3982 }
3983
3984 label = decode_label (binfo->tag);
3985
3986 vty_out (vty, "notag/%d", label);
3987
3988 vty_out (vty, "%s", VTY_NEWLINE);
3989
3990 return vty_calc_line (vty, length);
3991}
3992
3993/* dampening route */
3994int
3995damp_route_vty_out (struct vty *vty, struct prefix *p,
3996 struct bgp_info *binfo, int display, safi_t safi)
3997{
3998 struct attr *attr;
3999 unsigned long length = 0;
4000 int len;
4001
4002 length = vty->obuf->length;
4003
4004 /* Route status display. */
4005 if (binfo->suppress)
4006 vty_out (vty, "s");
4007 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4008 vty_out (vty, "*");
4009 else
4010 vty_out (vty, " ");
4011
4012 /* Selected */
4013 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4014 vty_out (vty, "h");
4015 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4016 vty_out (vty, "d");
4017 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
4018 vty_out (vty, ">");
4019 else
4020 vty_out (vty, " ");
4021
4022 vty_out (vty, " ");
4023
4024 /* print prefix and mask */
4025 if (! display)
4026 route_vty_out_route (p, vty);
4027 else
4028 vty_out (vty, "%*s", 17, " ");
4029
4030 len = vty_out (vty, "%s", binfo->peer->host);
4031 len = 17 - len;
4032 if (len < 1)
4033 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
4034 else
4035 vty_out (vty, "%*s", len, " ");
4036
4037 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
4038
4039 /* Print attribute */
4040 attr = binfo->attr;
4041 if (attr)
4042 {
4043 /* Print aspath */
4044 if (attr->aspath)
4045 aspath_print_vty (vty, attr->aspath);
4046
4047 /* Print origin */
4048 if (strlen (attr->aspath->str) == 0)
4049 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
4050 else
4051 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
4052 }
4053 vty_out (vty, "%s", VTY_NEWLINE);
4054
4055 return vty_calc_line (vty, length);
4056}
4057
4058#define BGP_UPTIME_LEN 25
4059
4060/* flap route */
4061int
4062flap_route_vty_out (struct vty *vty, struct prefix *p,
4063 struct bgp_info *binfo, int display, safi_t safi)
4064{
4065 struct attr *attr;
4066 struct bgp_damp_info *bdi;
4067 unsigned long length = 0;
4068 char timebuf[BGP_UPTIME_LEN];
4069 int len;
4070
4071 length = vty->obuf->length;
4072 bdi = binfo->damp_info;
4073
4074 /* Route status display. */
4075 if (binfo->suppress)
4076 vty_out (vty, "s");
4077 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4078 vty_out (vty, "*");
4079 else
4080 vty_out (vty, " ");
4081
4082 /* Selected */
4083 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4084 vty_out (vty, "h");
4085 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4086 vty_out (vty, "d");
4087 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
4088 vty_out (vty, ">");
4089 else
4090 vty_out (vty, " ");
4091
4092 vty_out (vty, " ");
4093
4094 /* print prefix and mask */
4095 if (! display)
4096 route_vty_out_route (p, vty);
4097 else
4098 vty_out (vty, "%*s", 17, " ");
4099
4100 len = vty_out (vty, "%s", binfo->peer->host);
4101 len = 16 - len;
4102 if (len < 1)
4103 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
4104 else
4105 vty_out (vty, "%*s", len, " ");
4106
4107 len = vty_out (vty, "%d", bdi->flap);
4108 len = 5 - len;
4109 if (len < 1)
4110 vty_out (vty, " ");
4111 else
4112 vty_out (vty, "%*s ", len, " ");
4113
4114 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
4115 timebuf, BGP_UPTIME_LEN));
4116
4117 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
4118 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4119 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo));
4120 else
4121 vty_out (vty, "%*s ", 8, " ");
4122
4123 /* Print attribute */
4124 attr = binfo->attr;
4125 if (attr)
4126 {
4127 /* Print aspath */
4128 if (attr->aspath)
4129 aspath_print_vty (vty, attr->aspath);
4130
4131 /* Print origin */
4132 if (strlen (attr->aspath->str) == 0)
4133 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
4134 else
4135 vty_out (vty, " %s", bgp_origin_str[attr->origin]);
4136 }
4137 vty_out (vty, "%s", VTY_NEWLINE);
4138
4139 return vty_calc_line (vty, length);
4140}
4141
4142void
4143route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
4144 struct bgp_info *binfo, afi_t afi, safi_t safi)
4145{
4146 char buf[INET6_ADDRSTRLEN];
4147 char buf1[BUFSIZ];
4148 struct attr *attr;
4149 int sockunion_vty_out (struct vty *, union sockunion *);
4150
4151 attr = binfo->attr;
4152
4153 if (attr)
4154 {
4155 /* Line1 display AS-path, Aggregator */
4156 if (attr->aspath)
4157 {
4158 vty_out (vty, " ");
4159 if (attr->aspath->length == 0)
4160 vty_out (vty, "Local");
4161 else
4162 aspath_print_vty (vty, attr->aspath);
4163 }
4164
4165 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)
4166 || CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)
4167 || CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
4168 || CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY)
4169 || CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4170 {
4171 vty_out (vty, ",");
4172
4173 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR))
4174 vty_out (vty, " (aggregated by %d %s)", attr->aggregator_as,
4175 inet_ntoa (attr->aggregator_addr));
4176 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
4177 vty_out (vty, " (Received from a RR-client)");
4178 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
4179 vty_out (vty, " (Received from a RS-client)");
4180 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4181 vty_out (vty, " (history entry)");
4182 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
4183 vty_out (vty, " (suppressed due to dampening)");
4184 }
4185 vty_out (vty, "%s", VTY_NEWLINE);
4186
4187 /* Line2 display Next-hop, Neighbor, Router-id */
4188 if (p->family == AF_INET)
4189 {
4190 vty_out (vty, " %s", safi == SAFI_MPLS_VPN ?
4191 inet_ntoa (attr->mp_nexthop_global_in) :
4192 inet_ntoa (attr->nexthop));
4193 }
4194#ifdef HAVE_IPV6
4195 else
4196 {
4197 vty_out (vty, " %s",
4198 inet_ntop (AF_INET6, &attr->mp_nexthop_global,
4199 buf, INET6_ADDRSTRLEN));
4200 }
4201#endif /* HAVE_IPV6 */
4202
4203 if (binfo->peer == bgp->peer_self)
4204 {
4205 vty_out (vty, " from %s ",
4206 p->family == AF_INET ? "0.0.0.0" : "::");
4207 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
4208 }
4209 else
4210 {
4211 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
4212 vty_out (vty, " (inaccessible)");
4213 else if (binfo->igpmetric)
4214 vty_out (vty, " (metric %d)", binfo->igpmetric);
pauleb821182004-05-01 08:44:08 +00004215 vty_out (vty, " from %s", sockunion2str (&binfo->peer->su, buf, SU_ADDRSTRLEN));
paul718e3742002-12-13 20:15:29 +00004216 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
4217 vty_out (vty, " (%s)", inet_ntoa (attr->originator_id));
4218 else
4219 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
4220 }
4221 vty_out (vty, "%s", VTY_NEWLINE);
4222
4223#ifdef HAVE_IPV6
4224 /* display nexthop local */
4225 if (attr->mp_nexthop_len == 32)
4226 {
4227 vty_out (vty, " (%s)%s",
4228 inet_ntop (AF_INET6, &attr->mp_nexthop_local,
4229 buf, INET6_ADDRSTRLEN),
4230 VTY_NEWLINE);
4231 }
4232#endif /* HAVE_IPV6 */
4233
4234 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
4235 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
4236
4237 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
4238 vty_out (vty, ", metric %d", attr->med);
4239
4240 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
4241 vty_out (vty, ", localpref %d", attr->local_pref);
4242 else
4243 vty_out (vty, ", localpref %d", bgp->default_local_pref);
4244
4245 if (attr->weight != 0)
4246 vty_out (vty, ", weight %d", attr->weight);
4247
4248 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
4249 vty_out (vty, ", valid");
4250
4251 if (binfo->peer != bgp->peer_self)
4252 {
4253 if (binfo->peer->as == binfo->peer->local_as)
4254 vty_out (vty, ", internal");
4255 else
4256 vty_out (vty, ", %s",
4257 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
4258 }
4259 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
4260 vty_out (vty, ", aggregated, local");
4261 else if (binfo->type != ZEBRA_ROUTE_BGP)
4262 vty_out (vty, ", sourced");
4263 else
4264 vty_out (vty, ", sourced, local");
4265
4266 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
4267 vty_out (vty, ", atomic-aggregate");
4268
4269 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
4270 vty_out (vty, ", best");
4271
4272 vty_out (vty, "%s", VTY_NEWLINE);
4273
4274 /* Line 4 display Community */
4275 if (attr->community)
4276 vty_out (vty, " Community: %s%s", attr->community->str,
4277 VTY_NEWLINE);
4278
4279 /* Line 5 display Extended-community */
4280 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
4281 vty_out (vty, " Extended Community: %s%s", attr->ecommunity->str,
4282 VTY_NEWLINE);
4283
4284 /* Line 6 display Originator, Cluster-id */
4285 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
4286 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
4287 {
4288 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
4289 vty_out (vty, " Originator: %s", inet_ntoa (attr->originator_id));
4290
4291 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
4292 {
4293 int i;
4294 vty_out (vty, ", Cluster list: ");
4295 for (i = 0; i < attr->cluster->length / 4; i++)
4296 vty_out (vty, "%s ", inet_ntoa (attr->cluster->list[i]));
4297 }
4298 vty_out (vty, "%s", VTY_NEWLINE);
4299 }
4300
4301 if (binfo->damp_info)
4302 bgp_damp_info_vty (vty, binfo);
4303
4304 /* Line 7 display Uptime */
4305 vty_out (vty, " Last update: %s", ctime (&binfo->uptime));
4306 }
4307 vty_out (vty, "%s", VTY_NEWLINE);
4308}
4309
4310#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
4311#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
4312#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
4313
4314enum bgp_show_type
4315{
4316 bgp_show_type_normal,
4317 bgp_show_type_regexp,
4318 bgp_show_type_prefix_list,
4319 bgp_show_type_filter_list,
4320 bgp_show_type_route_map,
4321 bgp_show_type_neighbor,
4322 bgp_show_type_cidr_only,
4323 bgp_show_type_prefix_longer,
4324 bgp_show_type_community_all,
4325 bgp_show_type_community,
4326 bgp_show_type_community_exact,
4327 bgp_show_type_community_list,
4328 bgp_show_type_community_list_exact,
4329 bgp_show_type_flap_statistics,
4330 bgp_show_type_flap_address,
4331 bgp_show_type_flap_prefix,
4332 bgp_show_type_flap_cidr_only,
4333 bgp_show_type_flap_regexp,
4334 bgp_show_type_flap_filter_list,
4335 bgp_show_type_flap_prefix_list,
4336 bgp_show_type_flap_prefix_longer,
4337 bgp_show_type_flap_route_map,
4338 bgp_show_type_flap_neighbor,
4339 bgp_show_type_dampend_paths,
4340 bgp_show_type_damp_neighbor
4341};
4342
4343int
4344bgp_show_callback (struct vty *vty, int unlock)
4345{
4346 struct bgp_node *rn;
4347 struct bgp_info *ri;
4348 int count;
4349 int limit;
4350 int display;
4351
4352 rn = vty->output_rn;
4353 count = 0;
4354 limit = ((vty->lines == 0)
4355 ? 10 : (vty->lines > 0
4356 ? vty->lines : vty->height - 2));
4357 limit = limit > 0 ? limit : 2;
4358
4359 /* Quit of display. */
4360 if (unlock && rn)
4361 {
4362 bgp_unlock_node (rn);
4363 if (vty->output_clean)
4364 (*vty->output_clean) (vty);
4365 vty->output_rn = NULL;
4366 vty->output_func = NULL;
4367 vty->output_clean = NULL;
4368 vty->output_arg = NULL;
4369 return 0;
4370 }
4371
4372 for (; rn; rn = bgp_route_next (rn))
4373 if (rn->info != NULL)
4374 {
4375 display = 0;
4376
4377 for (ri = rn->info; ri; ri = ri->next)
4378 {
4379 if (vty->output_type == bgp_show_type_flap_statistics
4380 || vty->output_type == bgp_show_type_flap_address
4381 || vty->output_type == bgp_show_type_flap_prefix
4382 || vty->output_type == bgp_show_type_flap_cidr_only
4383 || vty->output_type == bgp_show_type_flap_regexp
4384 || vty->output_type == bgp_show_type_flap_filter_list
4385 || vty->output_type == bgp_show_type_flap_prefix_list
4386 || vty->output_type == bgp_show_type_flap_prefix_longer
4387 || vty->output_type == bgp_show_type_flap_route_map
4388 || vty->output_type == bgp_show_type_flap_neighbor
4389 || vty->output_type == bgp_show_type_dampend_paths
4390 || vty->output_type == bgp_show_type_damp_neighbor)
4391 {
4392 if (! ri->damp_info)
4393 continue;
4394 }
4395 if (vty->output_type == bgp_show_type_regexp
4396 || vty->output_type == bgp_show_type_flap_regexp)
4397 {
4398 regex_t *regex = vty->output_arg;
4399
4400 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
4401 continue;
4402 }
4403 if (vty->output_type == bgp_show_type_prefix_list
4404 || vty->output_type == bgp_show_type_flap_prefix_list)
4405 {
4406 struct prefix_list *plist = vty->output_arg;
4407
4408 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
4409 continue;
4410 }
4411 if (vty->output_type == bgp_show_type_filter_list
4412 || vty->output_type == bgp_show_type_flap_filter_list)
4413 {
4414 struct as_list *as_list = vty->output_arg;
4415
4416 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
4417 continue;
4418 }
4419 if (vty->output_type == bgp_show_type_route_map
4420 || vty->output_type == bgp_show_type_flap_route_map)
4421 {
4422 struct route_map *rmap = vty->output_arg;
4423 struct bgp_info binfo;
4424 struct attr dummy_attr;
4425 int ret;
4426
4427 dummy_attr = *ri->attr;
4428 binfo.peer = ri->peer;
4429 binfo.attr = &dummy_attr;
4430
4431 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
4432
4433 if (ret == RMAP_DENYMATCH)
4434 continue;
4435 }
4436 if (vty->output_type == bgp_show_type_neighbor
4437 || vty->output_type == bgp_show_type_flap_neighbor
4438 || vty->output_type == bgp_show_type_damp_neighbor)
4439 {
4440 union sockunion *su = vty->output_arg;
4441
4442 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
4443 continue;
4444 }
4445 if (vty->output_type == bgp_show_type_cidr_only
4446 || vty->output_type == bgp_show_type_flap_cidr_only)
4447 {
4448 u_int32_t destination;
4449
4450 destination = ntohl (rn->p.u.prefix4.s_addr);
4451 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
4452 continue;
4453 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
4454 continue;
4455 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
4456 continue;
4457 }
4458 if (vty->output_type == bgp_show_type_prefix_longer
4459 || vty->output_type == bgp_show_type_flap_prefix_longer)
4460 {
4461 struct prefix *p = vty->output_arg;
4462
4463 if (! prefix_match (p, &rn->p))
4464 continue;
4465 }
4466 if (vty->output_type == bgp_show_type_community_all)
4467 {
4468 if (! ri->attr->community)
4469 continue;
4470 }
4471 if (vty->output_type == bgp_show_type_community)
4472 {
4473 struct community *com = vty->output_arg;
4474
4475 if (! ri->attr->community ||
4476 ! community_match (ri->attr->community, com))
4477 continue;
4478 }
4479 if (vty->output_type == bgp_show_type_community_exact)
4480 {
4481 struct community *com = vty->output_arg;
4482
4483 if (! ri->attr->community ||
4484 ! community_cmp (ri->attr->community, com))
4485 continue;
4486 }
4487 if (vty->output_type == bgp_show_type_community_list)
4488 {
4489 struct community_list *list = vty->output_arg;
4490
4491 if (! community_list_match (ri->attr->community, list))
4492 continue;
4493 }
4494 if (vty->output_type == bgp_show_type_community_list_exact)
4495 {
4496 struct community_list *list = vty->output_arg;
4497
4498 if (! community_list_exact_match (ri->attr->community, list))
4499 continue;
4500 }
4501 if (vty->output_type == bgp_show_type_flap_address
4502 || vty->output_type == bgp_show_type_flap_prefix)
4503 {
4504 struct prefix *p = vty->output_arg;
4505
4506 if (! prefix_match (&rn->p, p))
4507 continue;
4508
4509 if (vty->output_type == bgp_show_type_flap_prefix)
4510 if (p->prefixlen != rn->p.prefixlen)
4511 continue;
4512 }
4513 if (vty->output_type == bgp_show_type_dampend_paths
4514 || vty->output_type == bgp_show_type_damp_neighbor)
4515 {
4516 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
4517 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
4518 continue;
4519 }
4520
4521 if (vty->output_type == bgp_show_type_dampend_paths
4522 || vty->output_type == bgp_show_type_damp_neighbor)
4523 count += damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
4524 else if (vty->output_type == bgp_show_type_flap_statistics
4525 || vty->output_type == bgp_show_type_flap_address
4526 || vty->output_type == bgp_show_type_flap_prefix
4527 || vty->output_type == bgp_show_type_flap_cidr_only
4528 || vty->output_type == bgp_show_type_flap_regexp
4529 || vty->output_type == bgp_show_type_flap_filter_list
4530 || vty->output_type == bgp_show_type_flap_prefix_list
4531 || vty->output_type == bgp_show_type_flap_prefix_longer
4532 || vty->output_type == bgp_show_type_flap_route_map
4533 || vty->output_type == bgp_show_type_flap_neighbor)
4534 count += flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
4535 else
4536 count += route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
4537 display++;
4538 }
4539
4540 if (display)
4541 vty->output_count++;
4542
4543 /* Remember current pointer then suspend output. */
4544 if (count >= limit)
4545 {
4546 vty->status = VTY_CONTINUE;
4547 vty->output_rn = bgp_route_next (rn);;
4548 vty->output_func = bgp_show_callback;
4549 return 0;
4550 }
4551 }
4552
4553 /* Total line display. */
4554 if (vty->output_count)
4555 vty_out (vty, "%sTotal number of prefixes %ld%s",
4556 VTY_NEWLINE, vty->output_count, VTY_NEWLINE);
4557
4558 if (vty->output_clean)
4559 (*vty->output_clean) (vty);
4560
4561 vty->status = VTY_CONTINUE;
4562 vty->output_rn = NULL;
4563 vty->output_func = NULL;
4564 vty->output_clean = NULL;
4565 vty->output_arg = NULL;
4566
4567 return 0;
4568}
4569
4570int
paulbb46e942003-10-24 19:02:03 +00004571bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00004572 enum bgp_show_type type)
4573{
paul718e3742002-12-13 20:15:29 +00004574 struct bgp_info *ri;
4575 struct bgp_node *rn;
4576 struct bgp_table *table;
4577 int header = 1;
4578 int count;
4579 int limit;
4580 int display;
4581
4582 limit = ((vty->lines == 0)
4583 ? 10 : (vty->lines > 0
4584 ? vty->lines : vty->height - 2));
4585 limit = limit > 0 ? limit : 2;
4586
paulbb46e942003-10-24 19:02:03 +00004587 if (bgp == NULL) {
4588 bgp = bgp_get_default ();
4589 }
4590
4591 if (bgp == NULL)
paul718e3742002-12-13 20:15:29 +00004592 {
paulbb46e942003-10-24 19:02:03 +00004593 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
4594 return CMD_WARNING;
paul718e3742002-12-13 20:15:29 +00004595 }
4596
4597 count = 0;
4598
4599 /* This is first entry point, so reset total line. */
4600 vty->output_count = 0;
4601 vty->output_type = type;
4602
4603 table = bgp->rib[afi][safi];
4604
4605 /* Start processing of routes. */
4606 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
4607 if (rn->info != NULL)
4608 {
4609 display = 0;
4610
4611 for (ri = rn->info; ri; ri = ri->next)
4612 {
4613 if (vty->output_type == bgp_show_type_flap_statistics
4614 || type == bgp_show_type_flap_address
4615 || type == bgp_show_type_flap_prefix
4616 || type == bgp_show_type_flap_cidr_only
4617 || type == bgp_show_type_flap_regexp
4618 || type == bgp_show_type_flap_filter_list
4619 || type == bgp_show_type_flap_prefix_list
4620 || type == bgp_show_type_flap_prefix_longer
4621 || type == bgp_show_type_flap_route_map
4622 || type == bgp_show_type_flap_neighbor
4623 || type == bgp_show_type_dampend_paths
4624 || type == bgp_show_type_damp_neighbor)
4625 {
4626 if (! ri->damp_info)
4627 continue;
4628 }
4629 if (type == bgp_show_type_regexp
4630 || type == bgp_show_type_flap_regexp)
4631 {
4632 regex_t *regex = vty->output_arg;
4633
4634 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
4635 continue;
4636 }
4637 if (type == bgp_show_type_prefix_list
4638 || type == bgp_show_type_flap_prefix_list)
4639 {
4640 struct prefix_list *plist = vty->output_arg;
4641
4642 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
4643 continue;
4644 }
4645 if (type == bgp_show_type_filter_list
4646 || type == bgp_show_type_flap_filter_list)
4647 {
4648 struct as_list *as_list = vty->output_arg;
4649
4650 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
4651 continue;
4652 }
4653 if (type == bgp_show_type_route_map
4654 || type == bgp_show_type_flap_route_map)
4655 {
4656 struct route_map *rmap = vty->output_arg;
4657 struct bgp_info binfo;
4658 struct attr dummy_attr;
4659 int ret;
4660
4661 dummy_attr = *ri->attr;
4662 binfo.peer = ri->peer;
4663 binfo.attr = &dummy_attr;
4664
4665 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
4666
4667 if (ret == RMAP_DENYMATCH)
4668 continue;
4669 }
4670 if (type == bgp_show_type_neighbor
4671 || type == bgp_show_type_flap_neighbor
4672 || type == bgp_show_type_damp_neighbor)
4673 {
4674 union sockunion *su = vty->output_arg;
4675
4676 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
4677 continue;
4678 }
4679 if (type == bgp_show_type_cidr_only
4680 || type == bgp_show_type_flap_cidr_only)
4681 {
4682 u_int32_t destination;
4683
4684 destination = ntohl (rn->p.u.prefix4.s_addr);
4685 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
4686 continue;
4687 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
4688 continue;
4689 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
4690 continue;
4691 }
4692 if (type == bgp_show_type_prefix_longer
4693 || type == bgp_show_type_flap_prefix_longer)
4694 {
4695 struct prefix *p = vty->output_arg;
4696
4697 if (! prefix_match (p, &rn->p))
4698 continue;
4699 }
4700 if (type == bgp_show_type_community_all)
4701 {
4702 if (! ri->attr->community)
4703 continue;
4704 }
4705 if (type == bgp_show_type_community)
4706 {
4707 struct community *com = vty->output_arg;
4708
4709 if (! ri->attr->community ||
4710 ! community_match (ri->attr->community, com))
4711 continue;
4712 }
4713 if (type == bgp_show_type_community_exact)
4714 {
4715 struct community *com = vty->output_arg;
4716
4717 if (! ri->attr->community ||
4718 ! community_cmp (ri->attr->community, com))
4719 continue;
4720 }
4721 if (type == bgp_show_type_community_list)
4722 {
4723 struct community_list *list = vty->output_arg;
4724
4725 if (! community_list_match (ri->attr->community, list))
4726 continue;
4727 }
4728 if (type == bgp_show_type_community_list_exact)
4729 {
4730 struct community_list *list = vty->output_arg;
4731
4732 if (! community_list_exact_match (ri->attr->community, list))
4733 continue;
4734 }
4735 if (type == bgp_show_type_flap_address
4736 || type == bgp_show_type_flap_prefix)
4737 {
4738 struct prefix *p = vty->output_arg;
4739
4740 if (! prefix_match (&rn->p, p))
4741 continue;
4742
4743 if (type == bgp_show_type_flap_prefix)
4744 if (p->prefixlen != rn->p.prefixlen)
4745 continue;
4746 }
4747 if (type == bgp_show_type_dampend_paths
4748 || type == bgp_show_type_damp_neighbor)
4749 {
4750 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
4751 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
4752 continue;
4753 }
4754
4755 if (header)
4756 {
4757 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
4758 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE);
4759 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE);
4760 if (type == bgp_show_type_dampend_paths
4761 || type == bgp_show_type_damp_neighbor)
4762 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
4763 else if (type == bgp_show_type_flap_statistics
4764 || type == bgp_show_type_flap_address
4765 || type == bgp_show_type_flap_prefix
4766 || type == bgp_show_type_flap_cidr_only
4767 || type == bgp_show_type_flap_regexp
4768 || type == bgp_show_type_flap_filter_list
4769 || type == bgp_show_type_flap_prefix_list
4770 || type == bgp_show_type_flap_prefix_longer
4771 || type == bgp_show_type_flap_route_map
4772 || type == bgp_show_type_flap_neighbor)
4773 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
4774 else
4775 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
4776 count += 5;
4777 header = 0;
4778 }
4779
4780 if (type == bgp_show_type_dampend_paths
4781 || type == bgp_show_type_damp_neighbor)
4782 count += damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
4783 else if (type == bgp_show_type_flap_statistics
4784 || type == bgp_show_type_flap_address
4785 || type == bgp_show_type_flap_prefix
4786 || type == bgp_show_type_flap_cidr_only
4787 || type == bgp_show_type_flap_regexp
4788 || type == bgp_show_type_flap_filter_list
4789 || type == bgp_show_type_flap_prefix_list
4790 || type == bgp_show_type_flap_prefix_longer
4791 || type == bgp_show_type_flap_route_map
4792 || type == bgp_show_type_flap_neighbor)
4793 count += flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
4794 else
4795 count += route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
4796 display++;
4797 }
4798 if (display)
4799 vty->output_count++;
4800
4801 /* Remember current pointer then suspend output. */
4802 if (count >= limit && vty->type != VTY_SHELL_SERV)
4803 {
4804 vty->status = VTY_START;
4805 vty->output_rn = bgp_route_next (rn);
4806 vty->output_func = bgp_show_callback;
4807 vty->output_type = type;
4808
4809 return CMD_SUCCESS;
4810 }
4811 }
4812
4813 /* No route is displayed */
4814 if (vty->output_count == 0)
4815 {
4816 if (type == bgp_show_type_normal)
4817 vty_out (vty, "No BGP network exists%s", VTY_NEWLINE);
4818 }
4819 else
4820 vty_out (vty, "%sTotal number of prefixes %ld%s",
4821 VTY_NEWLINE, vty->output_count, VTY_NEWLINE);
4822
4823 /* Clean up allocated resources. */
4824 if (vty->output_clean)
4825 (*vty->output_clean) (vty);
4826
4827 vty->status = VTY_START;
4828 vty->output_rn = NULL;
4829 vty->output_func = NULL;
4830 vty->output_clean = NULL;
4831 vty->output_arg = NULL;
4832
4833 return CMD_SUCCESS;
4834}
4835
4836/* Header of detailed BGP route information */
4837void
4838route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
4839 struct bgp_node *rn,
4840 struct prefix_rd *prd, afi_t afi, safi_t safi)
4841{
4842 struct bgp_info *ri;
4843 struct prefix *p;
4844 struct peer *peer;
4845 struct listnode *nn;
4846 char buf1[INET6_ADDRSTRLEN];
4847 char buf2[INET6_ADDRSTRLEN];
4848 int count = 0;
4849 int best = 0;
4850 int suppress = 0;
4851 int no_export = 0;
4852 int no_advertise = 0;
4853 int local_as = 0;
4854 int first = 0;
4855
4856 p = &rn->p;
4857 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
4858 (safi == SAFI_MPLS_VPN ?
4859 prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
4860 safi == SAFI_MPLS_VPN ? ":" : "",
4861 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
4862 p->prefixlen, VTY_NEWLINE);
4863
4864 for (ri = rn->info; ri; ri = ri->next)
4865 {
4866 count++;
4867 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
4868 {
4869 best = count;
4870 if (ri->suppress)
4871 suppress = 1;
4872 if (ri->attr->community != NULL)
4873 {
4874 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
4875 no_advertise = 1;
4876 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
4877 no_export = 1;
4878 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
4879 local_as = 1;
4880 }
4881 }
4882 }
4883
4884 vty_out (vty, "Paths: (%d available", count);
4885 if (best)
4886 {
4887 vty_out (vty, ", best #%d", best);
4888 if (safi == SAFI_UNICAST)
4889 vty_out (vty, ", table Default-IP-Routing-Table");
4890 }
4891 else
4892 vty_out (vty, ", no best path");
4893 if (no_advertise)
4894 vty_out (vty, ", not advertised to any peer");
4895 else if (no_export)
4896 vty_out (vty, ", not advertised to EBGP peer");
4897 else if (local_as)
4898 vty_out (vty, ", not advertised outside local AS");
4899 if (suppress)
4900 vty_out (vty, ", Advertisements suppressed by an aggregate.");
4901 vty_out (vty, ")%s", VTY_NEWLINE);
4902
4903 /* advertised peer */
4904 LIST_LOOP (bgp->peer, peer, nn)
4905 {
4906 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
4907 {
4908 if (! first)
4909 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
4910 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
4911 first = 1;
4912 }
4913 }
4914 if (! first)
4915 vty_out (vty, " Not advertised to any peer");
4916 vty_out (vty, "%s", VTY_NEWLINE);
4917}
4918
4919/* Display specified route of BGP table. */
4920int
4921bgp_show_route (struct vty *vty, char *view_name, char *ip_str,
4922 afi_t afi, safi_t safi, struct prefix_rd *prd,
4923 int prefix_check)
4924{
4925 int ret;
4926 int header;
4927 int display = 0;
4928 struct prefix match;
4929 struct bgp_node *rn;
4930 struct bgp_node *rm;
4931 struct bgp_info *ri;
4932 struct bgp *bgp;
4933 struct bgp_table *table;
4934
4935 /* BGP structure lookup. */
4936 if (view_name)
4937 {
4938 bgp = bgp_lookup_by_name (view_name);
4939 if (bgp == NULL)
4940 {
4941 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
4942 return CMD_WARNING;
4943 }
4944 }
4945 else
4946 {
4947 bgp = bgp_get_default ();
4948 if (bgp == NULL)
4949 {
4950 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
4951 return CMD_WARNING;
4952 }
4953 }
4954
4955 /* Check IP address argument. */
4956 ret = str2prefix (ip_str, &match);
4957 if (! ret)
4958 {
4959 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
4960 return CMD_WARNING;
4961 }
4962
4963 match.family = afi2family (afi);
4964
4965 if (safi == SAFI_MPLS_VPN)
4966 {
4967 for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn))
4968 {
4969 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
4970 continue;
4971
4972 if ((table = rn->info) != NULL)
4973 {
4974 header = 1;
4975
4976 if ((rm = bgp_node_match (table, &match)) != NULL)
4977 {
4978 if (prefix_check && rm->p.prefixlen != match.prefixlen)
4979 continue;
4980
4981 for (ri = rm->info; ri; ri = ri->next)
4982 {
4983 if (header)
4984 {
4985 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
4986 AFI_IP, SAFI_MPLS_VPN);
4987
4988 header = 0;
4989 }
4990 display++;
4991 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, SAFI_MPLS_VPN);
4992 }
4993 }
4994 }
4995 }
4996 }
4997 else
4998 {
4999 header = 1;
5000
5001 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
5002 {
5003 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
5004 {
5005 for (ri = rn->info; ri; ri = ri->next)
5006 {
5007 if (header)
5008 {
5009 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
5010 header = 0;
5011 }
5012 display++;
5013 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
5014 }
5015 }
5016 }
5017 }
5018
5019 if (! display)
5020 {
5021 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
5022 return CMD_WARNING;
5023 }
5024
5025 return CMD_SUCCESS;
5026}
5027
5028/* BGP route print out function. */
5029DEFUN (show_ip_bgp,
5030 show_ip_bgp_cmd,
5031 "show ip bgp",
5032 SHOW_STR
5033 IP_STR
5034 BGP_STR)
5035{
5036 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal);
5037}
5038
5039DEFUN (show_ip_bgp_ipv4,
5040 show_ip_bgp_ipv4_cmd,
5041 "show ip bgp ipv4 (unicast|multicast)",
5042 SHOW_STR
5043 IP_STR
5044 BGP_STR
5045 "Address family\n"
5046 "Address Family modifier\n"
5047 "Address Family modifier\n")
5048{
5049 if (strncmp (argv[0], "m", 1) == 0)
5050 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal);
5051
5052 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal);
5053}
5054
5055DEFUN (show_ip_bgp_route,
5056 show_ip_bgp_route_cmd,
5057 "show ip bgp A.B.C.D",
5058 SHOW_STR
5059 IP_STR
5060 BGP_STR
5061 "Network in the BGP routing table to display\n")
5062{
5063 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
5064}
5065
5066DEFUN (show_ip_bgp_ipv4_route,
5067 show_ip_bgp_ipv4_route_cmd,
5068 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
5069 SHOW_STR
5070 IP_STR
5071 BGP_STR
5072 "Address family\n"
5073 "Address Family modifier\n"
5074 "Address Family modifier\n"
5075 "Network in the BGP routing table to display\n")
5076{
5077 if (strncmp (argv[0], "m", 1) == 0)
5078 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
5079
5080 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
5081}
5082
5083DEFUN (show_ip_bgp_vpnv4_all_route,
5084 show_ip_bgp_vpnv4_all_route_cmd,
5085 "show ip bgp vpnv4 all A.B.C.D",
5086 SHOW_STR
5087 IP_STR
5088 BGP_STR
5089 "Display VPNv4 NLRI specific information\n"
5090 "Display information about all VPNv4 NLRIs\n"
5091 "Network in the BGP routing table to display\n")
5092{
5093 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
5094}
5095
5096DEFUN (show_ip_bgp_vpnv4_rd_route,
5097 show_ip_bgp_vpnv4_rd_route_cmd,
5098 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
5099 SHOW_STR
5100 IP_STR
5101 BGP_STR
5102 "Display VPNv4 NLRI specific information\n"
5103 "Display information for a route distinguisher\n"
5104 "VPN Route Distinguisher\n"
5105 "Network in the BGP routing table to display\n")
5106{
5107 int ret;
5108 struct prefix_rd prd;
5109
5110 ret = str2prefix_rd (argv[0], &prd);
5111 if (! ret)
5112 {
5113 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
5114 return CMD_WARNING;
5115 }
5116 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
5117}
5118
5119DEFUN (show_ip_bgp_prefix,
5120 show_ip_bgp_prefix_cmd,
5121 "show ip bgp A.B.C.D/M",
5122 SHOW_STR
5123 IP_STR
5124 BGP_STR
5125 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5126{
5127 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
5128}
5129
5130DEFUN (show_ip_bgp_ipv4_prefix,
5131 show_ip_bgp_ipv4_prefix_cmd,
5132 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
5133 SHOW_STR
5134 IP_STR
5135 BGP_STR
5136 "Address family\n"
5137 "Address Family modifier\n"
5138 "Address Family modifier\n"
5139 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5140{
5141 if (strncmp (argv[0], "m", 1) == 0)
5142 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
5143
5144 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
5145}
5146
5147DEFUN (show_ip_bgp_vpnv4_all_prefix,
5148 show_ip_bgp_vpnv4_all_prefix_cmd,
5149 "show ip bgp vpnv4 all A.B.C.D/M",
5150 SHOW_STR
5151 IP_STR
5152 BGP_STR
5153 "Display VPNv4 NLRI specific information\n"
5154 "Display information about all VPNv4 NLRIs\n"
5155 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5156{
5157 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
5158}
5159
5160DEFUN (show_ip_bgp_vpnv4_rd_prefix,
5161 show_ip_bgp_vpnv4_rd_prefix_cmd,
5162 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
5163 SHOW_STR
5164 IP_STR
5165 BGP_STR
5166 "Display VPNv4 NLRI specific information\n"
5167 "Display information for a route distinguisher\n"
5168 "VPN Route Distinguisher\n"
5169 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5170{
5171 int ret;
5172 struct prefix_rd prd;
5173
5174 ret = str2prefix_rd (argv[0], &prd);
5175 if (! ret)
5176 {
5177 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
5178 return CMD_WARNING;
5179 }
5180 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
5181}
5182
5183DEFUN (show_ip_bgp_view,
5184 show_ip_bgp_view_cmd,
5185 "show ip bgp view WORD",
5186 SHOW_STR
5187 IP_STR
5188 BGP_STR
5189 "BGP view\n"
5190 "BGP view name\n")
5191{
paulbb46e942003-10-24 19:02:03 +00005192 struct bgp *bgp;
5193
5194 /* BGP structure lookup. */
5195 bgp = bgp_lookup_by_name (argv[0]);
5196 if (bgp == NULL)
5197 {
5198 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
5199 return CMD_WARNING;
5200 }
5201
5202 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal);
paul718e3742002-12-13 20:15:29 +00005203}
5204
5205DEFUN (show_ip_bgp_view_route,
5206 show_ip_bgp_view_route_cmd,
5207 "show ip bgp view WORD A.B.C.D",
5208 SHOW_STR
5209 IP_STR
5210 BGP_STR
5211 "BGP view\n"
5212 "BGP view name\n"
5213 "Network in the BGP routing table to display\n")
5214{
5215 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
5216}
5217
5218DEFUN (show_ip_bgp_view_prefix,
5219 show_ip_bgp_view_prefix_cmd,
5220 "show ip bgp view WORD A.B.C.D/M",
5221 SHOW_STR
5222 IP_STR
5223 BGP_STR
5224 "BGP view\n"
5225 "BGP view name\n"
5226 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
5227{
5228 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
5229}
5230
5231#ifdef HAVE_IPV6
5232DEFUN (show_bgp,
5233 show_bgp_cmd,
5234 "show bgp",
5235 SHOW_STR
5236 BGP_STR)
5237{
5238 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal);
5239}
5240
5241ALIAS (show_bgp,
5242 show_bgp_ipv6_cmd,
5243 "show bgp ipv6",
5244 SHOW_STR
5245 BGP_STR
5246 "Address family\n")
5247
5248/* old command */
5249DEFUN (show_ipv6_bgp,
5250 show_ipv6_bgp_cmd,
5251 "show ipv6 bgp",
5252 SHOW_STR
5253 IP_STR
5254 BGP_STR)
5255{
5256 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal);
5257}
5258
5259DEFUN (show_bgp_route,
5260 show_bgp_route_cmd,
5261 "show bgp X:X::X:X",
5262 SHOW_STR
5263 BGP_STR
5264 "Network in the BGP routing table to display\n")
5265{
5266 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
5267}
5268
5269ALIAS (show_bgp_route,
5270 show_bgp_ipv6_route_cmd,
5271 "show bgp ipv6 X:X::X:X",
5272 SHOW_STR
5273 BGP_STR
5274 "Address family\n"
5275 "Network in the BGP routing table to display\n")
5276
5277/* old command */
5278DEFUN (show_ipv6_bgp_route,
5279 show_ipv6_bgp_route_cmd,
5280 "show ipv6 bgp X:X::X:X",
5281 SHOW_STR
5282 IP_STR
5283 BGP_STR
5284 "Network in the BGP routing table to display\n")
5285{
5286 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
5287}
5288
5289DEFUN (show_bgp_prefix,
5290 show_bgp_prefix_cmd,
5291 "show bgp X:X::X:X/M",
5292 SHOW_STR
5293 BGP_STR
5294 "IPv6 prefix <network>/<length>\n")
5295{
5296 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
5297}
5298
5299ALIAS (show_bgp_prefix,
5300 show_bgp_ipv6_prefix_cmd,
5301 "show bgp ipv6 X:X::X:X/M",
5302 SHOW_STR
5303 BGP_STR
5304 "Address family\n"
5305 "IPv6 prefix <network>/<length>\n")
5306
5307/* old command */
5308DEFUN (show_ipv6_bgp_prefix,
5309 show_ipv6_bgp_prefix_cmd,
5310 "show ipv6 bgp X:X::X:X/M",
5311 SHOW_STR
5312 IP_STR
5313 BGP_STR
5314 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
5315{
5316 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
5317}
5318
paulbb46e942003-10-24 19:02:03 +00005319DEFUN (show_bgp_view,
5320 show_bgp_view_cmd,
5321 "show bgp view WORD",
5322 SHOW_STR
5323 BGP_STR
5324 "BGP view\n"
5325 "View name\n")
5326{
5327 struct bgp *bgp;
5328
5329 /* BGP structure lookup. */
5330 bgp = bgp_lookup_by_name (argv[0]);
5331 if (bgp == NULL)
5332 {
5333 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
5334 return CMD_WARNING;
5335 }
5336
5337 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal);
5338}
5339
5340ALIAS (show_bgp_view,
5341 show_bgp_view_ipv6_cmd,
5342 "show bgp view WORD ipv6",
5343 SHOW_STR
5344 BGP_STR
5345 "BGP view\n"
5346 "View name\n"
5347 "Address family\n")
5348
5349DEFUN (show_bgp_view_route,
5350 show_bgp_view_route_cmd,
5351 "show bgp view WORD X:X::X:X",
5352 SHOW_STR
5353 BGP_STR
5354 "BGP view\n"
5355 "View name\n"
5356 "Network in the BGP routing table to display\n")
5357{
5358 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
5359}
5360
5361ALIAS (show_bgp_view_route,
5362 show_bgp_view_ipv6_route_cmd,
5363 "show bgp view WORD ipv6 X:X::X:X",
5364 SHOW_STR
5365 BGP_STR
5366 "BGP view\n"
5367 "View name\n"
5368 "Address family\n"
5369 "Network in the BGP routing table to display\n")
5370
5371DEFUN (show_bgp_view_prefix,
5372 show_bgp_view_prefix_cmd,
5373 "show bgp view WORD X:X::X:X/M",
5374 SHOW_STR
5375 BGP_STR
5376 "BGP view\n"
5377 "View name\n"
5378 "IPv6 prefix <network>/<length>\n")
5379{
5380 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
5381}
5382
5383ALIAS (show_bgp_view_prefix,
5384 show_bgp_view_ipv6_prefix_cmd,
5385 "show bgp view WORD ipv6 X:X::X:X/M",
5386 SHOW_STR
5387 BGP_STR
5388 "BGP view\n"
5389 "View name\n"
5390 "Address family\n"
5391 "IPv6 prefix <network>/<length>\n")
5392
paul718e3742002-12-13 20:15:29 +00005393/* old command */
5394DEFUN (show_ipv6_mbgp,
5395 show_ipv6_mbgp_cmd,
5396 "show ipv6 mbgp",
5397 SHOW_STR
5398 IP_STR
5399 MBGP_STR)
5400{
5401 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal);
5402}
5403
5404/* old command */
5405DEFUN (show_ipv6_mbgp_route,
5406 show_ipv6_mbgp_route_cmd,
5407 "show ipv6 mbgp X:X::X:X",
5408 SHOW_STR
5409 IP_STR
5410 MBGP_STR
5411 "Network in the MBGP routing table to display\n")
5412{
5413 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
5414}
5415
5416/* old command */
5417DEFUN (show_ipv6_mbgp_prefix,
5418 show_ipv6_mbgp_prefix_cmd,
5419 "show ipv6 mbgp X:X::X:X/M",
5420 SHOW_STR
5421 IP_STR
5422 MBGP_STR
5423 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
5424{
5425 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
5426}
5427#endif
5428
5429void
5430bgp_show_regexp_clean (struct vty *vty)
5431{
5432 bgp_regex_free (vty->output_arg);
5433}
5434
5435int
5436bgp_show_regexp (struct vty *vty, int argc, char **argv, afi_t afi,
5437 safi_t safi, enum bgp_show_type type)
5438{
5439 int i;
5440 struct buffer *b;
5441 char *regstr;
5442 int first;
5443 regex_t *regex;
5444
5445 first = 0;
5446 b = buffer_new (1024);
5447 for (i = 0; i < argc; i++)
5448 {
5449 if (first)
5450 buffer_putc (b, ' ');
5451 else
5452 {
5453 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
5454 continue;
5455 first = 1;
5456 }
5457
5458 buffer_putstr (b, argv[i]);
5459 }
5460 buffer_putc (b, '\0');
5461
5462 regstr = buffer_getstr (b);
5463 buffer_free (b);
5464
5465 regex = bgp_regcomp (regstr);
5466 if (! regex)
5467 {
5468 vty_out (vty, "Can't compile regexp %s%s", argv[0],
5469 VTY_NEWLINE);
5470 return CMD_WARNING;
5471 }
5472
5473 vty->output_arg = regex;
5474 vty->output_clean = bgp_show_regexp_clean;
5475
5476 return bgp_show (vty, NULL, afi, safi, type);
5477}
5478
5479DEFUN (show_ip_bgp_regexp,
5480 show_ip_bgp_regexp_cmd,
5481 "show ip bgp regexp .LINE",
5482 SHOW_STR
5483 IP_STR
5484 BGP_STR
5485 "Display routes matching the AS path regular expression\n"
5486 "A regular-expression to match the BGP AS paths\n")
5487{
5488 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
5489 bgp_show_type_regexp);
5490}
5491
5492DEFUN (show_ip_bgp_flap_regexp,
5493 show_ip_bgp_flap_regexp_cmd,
5494 "show ip bgp flap-statistics regexp .LINE",
5495 SHOW_STR
5496 IP_STR
5497 BGP_STR
5498 "Display flap statistics of routes\n"
5499 "Display routes matching the AS path regular expression\n"
5500 "A regular-expression to match the BGP AS paths\n")
5501{
5502 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
5503 bgp_show_type_flap_regexp);
5504}
5505
5506DEFUN (show_ip_bgp_ipv4_regexp,
5507 show_ip_bgp_ipv4_regexp_cmd,
5508 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
5509 SHOW_STR
5510 IP_STR
5511 BGP_STR
5512 "Address family\n"
5513 "Address Family modifier\n"
5514 "Address Family modifier\n"
5515 "Display routes matching the AS path regular expression\n"
5516 "A regular-expression to match the BGP AS paths\n")
5517{
5518 if (strncmp (argv[0], "m", 1) == 0)
5519 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
5520 bgp_show_type_regexp);
5521
5522 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
5523 bgp_show_type_regexp);
5524}
5525
5526#ifdef HAVE_IPV6
5527DEFUN (show_bgp_regexp,
5528 show_bgp_regexp_cmd,
5529 "show bgp regexp .LINE",
5530 SHOW_STR
5531 BGP_STR
5532 "Display routes matching the AS path regular expression\n"
5533 "A regular-expression to match the BGP AS paths\n")
5534{
5535 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
5536 bgp_show_type_regexp);
5537}
5538
5539ALIAS (show_bgp_regexp,
5540 show_bgp_ipv6_regexp_cmd,
5541 "show bgp ipv6 regexp .LINE",
5542 SHOW_STR
5543 BGP_STR
5544 "Address family\n"
5545 "Display routes matching the AS path regular expression\n"
5546 "A regular-expression to match the BGP AS paths\n")
5547
5548/* old command */
5549DEFUN (show_ipv6_bgp_regexp,
5550 show_ipv6_bgp_regexp_cmd,
5551 "show ipv6 bgp regexp .LINE",
5552 SHOW_STR
5553 IP_STR
5554 BGP_STR
5555 "Display routes matching the AS path regular expression\n"
5556 "A regular-expression to match the BGP AS paths\n")
5557{
5558 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
5559 bgp_show_type_regexp);
5560}
5561
5562/* old command */
5563DEFUN (show_ipv6_mbgp_regexp,
5564 show_ipv6_mbgp_regexp_cmd,
5565 "show ipv6 mbgp regexp .LINE",
5566 SHOW_STR
5567 IP_STR
5568 BGP_STR
5569 "Display routes matching the AS path regular expression\n"
5570 "A regular-expression to match the MBGP AS paths\n")
5571{
5572 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
5573 bgp_show_type_regexp);
5574}
5575#endif /* HAVE_IPV6 */
5576
5577int
5578bgp_show_prefix_list (struct vty *vty, char *prefix_list_str, afi_t afi,
5579 safi_t safi, enum bgp_show_type type)
5580{
5581 struct prefix_list *plist;
5582
5583 plist = prefix_list_lookup (afi, prefix_list_str);
5584 if (plist == NULL)
5585 {
5586 vty_out (vty, "%% %s is not a valid prefix-list name%s",
5587 prefix_list_str, VTY_NEWLINE);
5588 return CMD_WARNING;
5589 }
5590
5591 vty->output_arg = plist;
5592
5593 return bgp_show (vty, NULL, afi, safi, type);
5594}
5595
5596DEFUN (show_ip_bgp_prefix_list,
5597 show_ip_bgp_prefix_list_cmd,
5598 "show ip bgp prefix-list WORD",
5599 SHOW_STR
5600 IP_STR
5601 BGP_STR
5602 "Display routes conforming to the prefix-list\n"
5603 "IP prefix-list name\n")
5604{
5605 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
5606 bgp_show_type_prefix_list);
5607}
5608
5609DEFUN (show_ip_bgp_flap_prefix_list,
5610 show_ip_bgp_flap_prefix_list_cmd,
5611 "show ip bgp flap-statistics prefix-list WORD",
5612 SHOW_STR
5613 IP_STR
5614 BGP_STR
5615 "Display flap statistics of routes\n"
5616 "Display routes conforming to the prefix-list\n"
5617 "IP prefix-list name\n")
5618{
5619 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
5620 bgp_show_type_flap_prefix_list);
5621}
5622
5623DEFUN (show_ip_bgp_ipv4_prefix_list,
5624 show_ip_bgp_ipv4_prefix_list_cmd,
5625 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
5626 SHOW_STR
5627 IP_STR
5628 BGP_STR
5629 "Address family\n"
5630 "Address Family modifier\n"
5631 "Address Family modifier\n"
5632 "Display routes conforming to the prefix-list\n"
5633 "IP prefix-list name\n")
5634{
5635 if (strncmp (argv[0], "m", 1) == 0)
5636 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
5637 bgp_show_type_prefix_list);
5638
5639 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
5640 bgp_show_type_prefix_list);
5641}
5642
5643#ifdef HAVE_IPV6
5644DEFUN (show_bgp_prefix_list,
5645 show_bgp_prefix_list_cmd,
5646 "show bgp prefix-list WORD",
5647 SHOW_STR
5648 BGP_STR
5649 "Display routes conforming to the prefix-list\n"
5650 "IPv6 prefix-list name\n")
5651{
5652 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5653 bgp_show_type_prefix_list);
5654}
5655
5656ALIAS (show_bgp_prefix_list,
5657 show_bgp_ipv6_prefix_list_cmd,
5658 "show bgp ipv6 prefix-list WORD",
5659 SHOW_STR
5660 BGP_STR
5661 "Address family\n"
5662 "Display routes conforming to the prefix-list\n"
5663 "IPv6 prefix-list name\n")
5664
5665/* old command */
5666DEFUN (show_ipv6_bgp_prefix_list,
5667 show_ipv6_bgp_prefix_list_cmd,
5668 "show ipv6 bgp prefix-list WORD",
5669 SHOW_STR
5670 IPV6_STR
5671 BGP_STR
5672 "Display routes matching the prefix-list\n"
5673 "IPv6 prefix-list name\n")
5674{
5675 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5676 bgp_show_type_prefix_list);
5677}
5678
5679/* old command */
5680DEFUN (show_ipv6_mbgp_prefix_list,
5681 show_ipv6_mbgp_prefix_list_cmd,
5682 "show ipv6 mbgp prefix-list WORD",
5683 SHOW_STR
5684 IPV6_STR
5685 MBGP_STR
5686 "Display routes matching the prefix-list\n"
5687 "IPv6 prefix-list name\n")
5688{
5689 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
5690 bgp_show_type_prefix_list);
5691}
5692#endif /* HAVE_IPV6 */
5693
5694int
5695bgp_show_filter_list (struct vty *vty, char *filter, afi_t afi,
5696 safi_t safi, enum bgp_show_type type)
5697{
5698 struct as_list *as_list;
5699
5700 as_list = as_list_lookup (filter);
5701 if (as_list == NULL)
5702 {
5703 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
5704 return CMD_WARNING;
5705 }
5706
5707 vty->output_arg = as_list;
5708
5709 return bgp_show (vty, NULL, afi, safi, type);
5710}
5711
5712DEFUN (show_ip_bgp_filter_list,
5713 show_ip_bgp_filter_list_cmd,
5714 "show ip bgp filter-list WORD",
5715 SHOW_STR
5716 IP_STR
5717 BGP_STR
5718 "Display routes conforming to the filter-list\n"
5719 "Regular expression access list name\n")
5720{
5721 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
5722 bgp_show_type_filter_list);
5723}
5724
5725DEFUN (show_ip_bgp_flap_filter_list,
5726 show_ip_bgp_flap_filter_list_cmd,
5727 "show ip bgp flap-statistics filter-list WORD",
5728 SHOW_STR
5729 IP_STR
5730 BGP_STR
5731 "Display flap statistics of routes\n"
5732 "Display routes conforming to the filter-list\n"
5733 "Regular expression access list name\n")
5734{
5735 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
5736 bgp_show_type_flap_filter_list);
5737}
5738
5739DEFUN (show_ip_bgp_ipv4_filter_list,
5740 show_ip_bgp_ipv4_filter_list_cmd,
5741 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
5742 SHOW_STR
5743 IP_STR
5744 BGP_STR
5745 "Address family\n"
5746 "Address Family modifier\n"
5747 "Address Family modifier\n"
5748 "Display routes conforming to the filter-list\n"
5749 "Regular expression access list name\n")
5750{
5751 if (strncmp (argv[0], "m", 1) == 0)
5752 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
5753 bgp_show_type_filter_list);
5754
5755 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
5756 bgp_show_type_filter_list);
5757}
5758
5759#ifdef HAVE_IPV6
5760DEFUN (show_bgp_filter_list,
5761 show_bgp_filter_list_cmd,
5762 "show bgp filter-list WORD",
5763 SHOW_STR
5764 BGP_STR
5765 "Display routes conforming to the filter-list\n"
5766 "Regular expression access list name\n")
5767{
5768 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5769 bgp_show_type_filter_list);
5770}
5771
5772ALIAS (show_bgp_filter_list,
5773 show_bgp_ipv6_filter_list_cmd,
5774 "show bgp ipv6 filter-list WORD",
5775 SHOW_STR
5776 BGP_STR
5777 "Address family\n"
5778 "Display routes conforming to the filter-list\n"
5779 "Regular expression access list name\n")
5780
5781/* old command */
5782DEFUN (show_ipv6_bgp_filter_list,
5783 show_ipv6_bgp_filter_list_cmd,
5784 "show ipv6 bgp filter-list WORD",
5785 SHOW_STR
5786 IPV6_STR
5787 BGP_STR
5788 "Display routes conforming to the filter-list\n"
5789 "Regular expression access list name\n")
5790{
5791 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5792 bgp_show_type_filter_list);
5793}
5794
5795/* old command */
5796DEFUN (show_ipv6_mbgp_filter_list,
5797 show_ipv6_mbgp_filter_list_cmd,
5798 "show ipv6 mbgp filter-list WORD",
5799 SHOW_STR
5800 IPV6_STR
5801 MBGP_STR
5802 "Display routes conforming to the filter-list\n"
5803 "Regular expression access list name\n")
5804{
5805 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
5806 bgp_show_type_filter_list);
5807}
5808#endif /* HAVE_IPV6 */
5809
5810int
5811bgp_show_route_map (struct vty *vty, char *rmap_str, afi_t afi,
5812 safi_t safi, enum bgp_show_type type)
5813{
5814 struct route_map *rmap;
5815
5816 rmap = route_map_lookup_by_name (rmap_str);
5817 if (! rmap)
5818 {
5819 vty_out (vty, "%% %s is not a valid route-map name%s",
5820 rmap_str, VTY_NEWLINE);
5821 return CMD_WARNING;
5822 }
5823
5824 vty->output_arg = rmap;
5825
5826 return bgp_show (vty, NULL, afi, safi, type);
5827}
5828
5829DEFUN (show_ip_bgp_route_map,
5830 show_ip_bgp_route_map_cmd,
5831 "show ip bgp route-map WORD",
5832 SHOW_STR
5833 IP_STR
5834 BGP_STR
5835 "Display routes matching the route-map\n"
5836 "A route-map to match on\n")
5837{
5838 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
5839 bgp_show_type_route_map);
5840}
5841
5842DEFUN (show_ip_bgp_flap_route_map,
5843 show_ip_bgp_flap_route_map_cmd,
5844 "show ip bgp flap-statistics route-map WORD",
5845 SHOW_STR
5846 IP_STR
5847 BGP_STR
5848 "Display flap statistics of routes\n"
5849 "Display routes matching the route-map\n"
5850 "A route-map to match on\n")
5851{
5852 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
5853 bgp_show_type_flap_route_map);
5854}
5855
5856DEFUN (show_ip_bgp_ipv4_route_map,
5857 show_ip_bgp_ipv4_route_map_cmd,
5858 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
5859 SHOW_STR
5860 IP_STR
5861 BGP_STR
5862 "Address family\n"
5863 "Address Family modifier\n"
5864 "Address Family modifier\n"
5865 "Display routes matching the route-map\n"
5866 "A route-map to match on\n")
5867{
5868 if (strncmp (argv[0], "m", 1) == 0)
5869 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
5870 bgp_show_type_route_map);
5871
5872 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
5873 bgp_show_type_route_map);
5874}
5875
5876DEFUN (show_bgp_route_map,
5877 show_bgp_route_map_cmd,
5878 "show bgp route-map WORD",
5879 SHOW_STR
5880 BGP_STR
5881 "Display routes matching the route-map\n"
5882 "A route-map to match on\n")
5883{
5884 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5885 bgp_show_type_route_map);
5886}
5887
5888ALIAS (show_bgp_route_map,
5889 show_bgp_ipv6_route_map_cmd,
5890 "show bgp ipv6 route-map WORD",
5891 SHOW_STR
5892 BGP_STR
5893 "Address family\n"
5894 "Display routes matching the route-map\n"
5895 "A route-map to match on\n")
5896
5897DEFUN (show_ip_bgp_cidr_only,
5898 show_ip_bgp_cidr_only_cmd,
5899 "show ip bgp cidr-only",
5900 SHOW_STR
5901 IP_STR
5902 BGP_STR
5903 "Display only routes with non-natural netmasks\n")
5904{
5905 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
5906 bgp_show_type_cidr_only);
5907}
5908
5909DEFUN (show_ip_bgp_flap_cidr_only,
5910 show_ip_bgp_flap_cidr_only_cmd,
5911 "show ip bgp flap-statistics cidr-only",
5912 SHOW_STR
5913 IP_STR
5914 BGP_STR
5915 "Display flap statistics of routes\n"
5916 "Display only routes with non-natural netmasks\n")
5917{
5918 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
5919 bgp_show_type_flap_cidr_only);
5920}
5921
5922DEFUN (show_ip_bgp_ipv4_cidr_only,
5923 show_ip_bgp_ipv4_cidr_only_cmd,
5924 "show ip bgp ipv4 (unicast|multicast) cidr-only",
5925 SHOW_STR
5926 IP_STR
5927 BGP_STR
5928 "Address family\n"
5929 "Address Family modifier\n"
5930 "Address Family modifier\n"
5931 "Display only routes with non-natural netmasks\n")
5932{
5933 if (strncmp (argv[0], "m", 1) == 0)
5934 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
5935 bgp_show_type_cidr_only);
5936
5937 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
5938 bgp_show_type_cidr_only);
5939}
5940
5941DEFUN (show_ip_bgp_community_all,
5942 show_ip_bgp_community_all_cmd,
5943 "show ip bgp community",
5944 SHOW_STR
5945 IP_STR
5946 BGP_STR
5947 "Display routes matching the communities\n")
5948{
5949 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
5950 bgp_show_type_community_all);
5951}
5952
5953DEFUN (show_ip_bgp_ipv4_community_all,
5954 show_ip_bgp_ipv4_community_all_cmd,
5955 "show ip bgp ipv4 (unicast|multicast) community",
5956 SHOW_STR
5957 IP_STR
5958 BGP_STR
5959 "Address family\n"
5960 "Address Family modifier\n"
5961 "Address Family modifier\n"
5962 "Display routes matching the communities\n")
5963{
5964 if (strncmp (argv[0], "m", 1) == 0)
5965 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
5966 bgp_show_type_community_all);
5967
5968 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
5969 bgp_show_type_community_all);
5970}
5971
5972#ifdef HAVE_IPV6
5973DEFUN (show_bgp_community_all,
5974 show_bgp_community_all_cmd,
5975 "show bgp community",
5976 SHOW_STR
5977 BGP_STR
5978 "Display routes matching the communities\n")
5979{
5980 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
5981 bgp_show_type_community_all);
5982}
5983
5984ALIAS (show_bgp_community_all,
5985 show_bgp_ipv6_community_all_cmd,
5986 "show bgp ipv6 community",
5987 SHOW_STR
5988 BGP_STR
5989 "Address family\n"
5990 "Display routes matching the communities\n")
5991
5992/* old command */
5993DEFUN (show_ipv6_bgp_community_all,
5994 show_ipv6_bgp_community_all_cmd,
5995 "show ipv6 bgp community",
5996 SHOW_STR
5997 IPV6_STR
5998 BGP_STR
5999 "Display routes matching the communities\n")
6000{
6001 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
6002 bgp_show_type_community_all);
6003}
6004
6005/* old command */
6006DEFUN (show_ipv6_mbgp_community_all,
6007 show_ipv6_mbgp_community_all_cmd,
6008 "show ipv6 mbgp community",
6009 SHOW_STR
6010 IPV6_STR
6011 MBGP_STR
6012 "Display routes matching the communities\n")
6013{
6014 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
6015 bgp_show_type_community_all);
6016}
6017#endif /* HAVE_IPV6 */
6018
6019int
6020bgp_show_community (struct vty *vty, int argc, char **argv, int exact,
6021 u_int16_t afi, u_char safi)
6022{
6023 struct community *com;
6024 struct buffer *b;
6025 int i;
6026 char *str;
6027 int first = 0;
6028
6029 b = buffer_new (1024);
6030 for (i = 0; i < argc; i++)
6031 {
6032 if (first)
6033 buffer_putc (b, ' ');
6034 else
6035 {
6036 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
6037 continue;
6038 first = 1;
6039 }
6040
6041 buffer_putstr (b, argv[i]);
6042 }
6043 buffer_putc (b, '\0');
6044
6045 str = buffer_getstr (b);
6046 buffer_free (b);
6047
6048 com = community_str2com (str);
6049 free (str);
6050 if (! com)
6051 {
6052 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
6053 return CMD_WARNING;
6054 }
6055
6056 vty->output_arg = com;
6057
6058 if (exact)
6059 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_exact);
6060
6061 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community);
6062}
6063
6064DEFUN (show_ip_bgp_community,
6065 show_ip_bgp_community_cmd,
6066 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
6067 SHOW_STR
6068 IP_STR
6069 BGP_STR
6070 "Display routes matching the communities\n"
6071 "community number\n"
6072 "Do not send outside local AS (well-known community)\n"
6073 "Do not advertise to any peer (well-known community)\n"
6074 "Do not export to next AS (well-known community)\n")
6075{
6076 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST);
6077}
6078
6079ALIAS (show_ip_bgp_community,
6080 show_ip_bgp_community2_cmd,
6081 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6082 SHOW_STR
6083 IP_STR
6084 BGP_STR
6085 "Display routes matching the communities\n"
6086 "community number\n"
6087 "Do not send outside local AS (well-known community)\n"
6088 "Do not advertise to any peer (well-known community)\n"
6089 "Do not export to next AS (well-known community)\n"
6090 "community number\n"
6091 "Do not send outside local AS (well-known community)\n"
6092 "Do not advertise to any peer (well-known community)\n"
6093 "Do not export to next AS (well-known community)\n")
6094
6095ALIAS (show_ip_bgp_community,
6096 show_ip_bgp_community3_cmd,
6097 "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)",
6098 SHOW_STR
6099 IP_STR
6100 BGP_STR
6101 "Display routes matching the communities\n"
6102 "community number\n"
6103 "Do not send outside local AS (well-known community)\n"
6104 "Do not advertise to any peer (well-known community)\n"
6105 "Do not export to next AS (well-known community)\n"
6106 "community number\n"
6107 "Do not send outside local AS (well-known community)\n"
6108 "Do not advertise to any peer (well-known community)\n"
6109 "Do not export to next AS (well-known community)\n"
6110 "community number\n"
6111 "Do not send outside local AS (well-known community)\n"
6112 "Do not advertise to any peer (well-known community)\n"
6113 "Do not export to next AS (well-known community)\n")
6114
6115ALIAS (show_ip_bgp_community,
6116 show_ip_bgp_community4_cmd,
6117 "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)",
6118 SHOW_STR
6119 IP_STR
6120 BGP_STR
6121 "Display routes matching the communities\n"
6122 "community number\n"
6123 "Do not send outside local AS (well-known community)\n"
6124 "Do not advertise to any peer (well-known community)\n"
6125 "Do not export to next AS (well-known community)\n"
6126 "community number\n"
6127 "Do not send outside local AS (well-known community)\n"
6128 "Do not advertise to any peer (well-known community)\n"
6129 "Do not export to next AS (well-known community)\n"
6130 "community number\n"
6131 "Do not send outside local AS (well-known community)\n"
6132 "Do not advertise to any peer (well-known community)\n"
6133 "Do not export to next AS (well-known community)\n"
6134 "community number\n"
6135 "Do not send outside local AS (well-known community)\n"
6136 "Do not advertise to any peer (well-known community)\n"
6137 "Do not export to next AS (well-known community)\n")
6138
6139DEFUN (show_ip_bgp_ipv4_community,
6140 show_ip_bgp_ipv4_community_cmd,
6141 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
6142 SHOW_STR
6143 IP_STR
6144 BGP_STR
6145 "Address family\n"
6146 "Address Family modifier\n"
6147 "Address Family modifier\n"
6148 "Display routes matching the communities\n"
6149 "community number\n"
6150 "Do not send outside local AS (well-known community)\n"
6151 "Do not advertise to any peer (well-known community)\n"
6152 "Do not export to next AS (well-known community)\n")
6153{
6154 if (strncmp (argv[0], "m", 1) == 0)
6155 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
6156
6157 return bgp_show_community (vty, argc, argv, 0, AFI_IP, SAFI_UNICAST);
6158}
6159
6160ALIAS (show_ip_bgp_ipv4_community,
6161 show_ip_bgp_ipv4_community2_cmd,
6162 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6163 SHOW_STR
6164 IP_STR
6165 BGP_STR
6166 "Address family\n"
6167 "Address Family modifier\n"
6168 "Address Family modifier\n"
6169 "Display routes matching the communities\n"
6170 "community number\n"
6171 "Do not send outside local AS (well-known community)\n"
6172 "Do not advertise to any peer (well-known community)\n"
6173 "Do not export to next AS (well-known community)\n"
6174 "community number\n"
6175 "Do not send outside local AS (well-known community)\n"
6176 "Do not advertise to any peer (well-known community)\n"
6177 "Do not export to next AS (well-known community)\n")
6178
6179ALIAS (show_ip_bgp_ipv4_community,
6180 show_ip_bgp_ipv4_community3_cmd,
6181 "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)",
6182 SHOW_STR
6183 IP_STR
6184 BGP_STR
6185 "Address family\n"
6186 "Address Family modifier\n"
6187 "Address Family modifier\n"
6188 "Display routes matching the communities\n"
6189 "community number\n"
6190 "Do not send outside local AS (well-known community)\n"
6191 "Do not advertise to any peer (well-known community)\n"
6192 "Do not export to next AS (well-known community)\n"
6193 "community number\n"
6194 "Do not send outside local AS (well-known community)\n"
6195 "Do not advertise to any peer (well-known community)\n"
6196 "Do not export to next AS (well-known community)\n"
6197 "community number\n"
6198 "Do not send outside local AS (well-known community)\n"
6199 "Do not advertise to any peer (well-known community)\n"
6200 "Do not export to next AS (well-known community)\n")
6201
6202ALIAS (show_ip_bgp_ipv4_community,
6203 show_ip_bgp_ipv4_community4_cmd,
6204 "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)",
6205 SHOW_STR
6206 IP_STR
6207 BGP_STR
6208 "Address family\n"
6209 "Address Family modifier\n"
6210 "Address Family modifier\n"
6211 "Display routes matching the communities\n"
6212 "community number\n"
6213 "Do not send outside local AS (well-known community)\n"
6214 "Do not advertise to any peer (well-known community)\n"
6215 "Do not export to next AS (well-known community)\n"
6216 "community number\n"
6217 "Do not send outside local AS (well-known community)\n"
6218 "Do not advertise to any peer (well-known community)\n"
6219 "Do not export to next AS (well-known community)\n"
6220 "community number\n"
6221 "Do not send outside local AS (well-known community)\n"
6222 "Do not advertise to any peer (well-known community)\n"
6223 "Do not export to next AS (well-known community)\n"
6224 "community number\n"
6225 "Do not send outside local AS (well-known community)\n"
6226 "Do not advertise to any peer (well-known community)\n"
6227 "Do not export to next AS (well-known community)\n")
6228
6229DEFUN (show_ip_bgp_community_exact,
6230 show_ip_bgp_community_exact_cmd,
6231 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6232 SHOW_STR
6233 IP_STR
6234 BGP_STR
6235 "Display routes matching the communities\n"
6236 "community number\n"
6237 "Do not send outside local AS (well-known community)\n"
6238 "Do not advertise to any peer (well-known community)\n"
6239 "Do not export to next AS (well-known community)\n"
6240 "Exact match of the communities")
6241{
6242 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST);
6243}
6244
6245ALIAS (show_ip_bgp_community_exact,
6246 show_ip_bgp_community2_exact_cmd,
6247 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6248 SHOW_STR
6249 IP_STR
6250 BGP_STR
6251 "Display routes matching the communities\n"
6252 "community number\n"
6253 "Do not send outside local AS (well-known community)\n"
6254 "Do not advertise to any peer (well-known community)\n"
6255 "Do not export to next AS (well-known community)\n"
6256 "community number\n"
6257 "Do not send outside local AS (well-known community)\n"
6258 "Do not advertise to any peer (well-known community)\n"
6259 "Do not export to next AS (well-known community)\n"
6260 "Exact match of the communities")
6261
6262ALIAS (show_ip_bgp_community_exact,
6263 show_ip_bgp_community3_exact_cmd,
6264 "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",
6265 SHOW_STR
6266 IP_STR
6267 BGP_STR
6268 "Display routes matching the communities\n"
6269 "community number\n"
6270 "Do not send outside local AS (well-known community)\n"
6271 "Do not advertise to any peer (well-known community)\n"
6272 "Do not export to next AS (well-known community)\n"
6273 "community number\n"
6274 "Do not send outside local AS (well-known community)\n"
6275 "Do not advertise to any peer (well-known community)\n"
6276 "Do not export to next AS (well-known community)\n"
6277 "community number\n"
6278 "Do not send outside local AS (well-known community)\n"
6279 "Do not advertise to any peer (well-known community)\n"
6280 "Do not export to next AS (well-known community)\n"
6281 "Exact match of the communities")
6282
6283ALIAS (show_ip_bgp_community_exact,
6284 show_ip_bgp_community4_exact_cmd,
6285 "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",
6286 SHOW_STR
6287 IP_STR
6288 BGP_STR
6289 "Display routes matching the communities\n"
6290 "community number\n"
6291 "Do not send outside local AS (well-known community)\n"
6292 "Do not advertise to any peer (well-known community)\n"
6293 "Do not export to next AS (well-known community)\n"
6294 "community number\n"
6295 "Do not send outside local AS (well-known community)\n"
6296 "Do not advertise to any peer (well-known community)\n"
6297 "Do not export to next AS (well-known community)\n"
6298 "community number\n"
6299 "Do not send outside local AS (well-known community)\n"
6300 "Do not advertise to any peer (well-known community)\n"
6301 "Do not export to next AS (well-known community)\n"
6302 "community number\n"
6303 "Do not send outside local AS (well-known community)\n"
6304 "Do not advertise to any peer (well-known community)\n"
6305 "Do not export to next AS (well-known community)\n"
6306 "Exact match of the communities")
6307
6308DEFUN (show_ip_bgp_ipv4_community_exact,
6309 show_ip_bgp_ipv4_community_exact_cmd,
6310 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6311 SHOW_STR
6312 IP_STR
6313 BGP_STR
6314 "Address family\n"
6315 "Address Family modifier\n"
6316 "Address Family modifier\n"
6317 "Display routes matching the communities\n"
6318 "community number\n"
6319 "Do not send outside local AS (well-known community)\n"
6320 "Do not advertise to any peer (well-known community)\n"
6321 "Do not export to next AS (well-known community)\n"
6322 "Exact match of the communities")
6323{
6324 if (strncmp (argv[0], "m", 1) == 0)
6325 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
6326
6327 return bgp_show_community (vty, argc, argv, 1, AFI_IP, SAFI_UNICAST);
6328}
6329
6330ALIAS (show_ip_bgp_ipv4_community_exact,
6331 show_ip_bgp_ipv4_community2_exact_cmd,
6332 "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",
6333 SHOW_STR
6334 IP_STR
6335 BGP_STR
6336 "Address family\n"
6337 "Address Family modifier\n"
6338 "Address Family modifier\n"
6339 "Display routes matching the communities\n"
6340 "community number\n"
6341 "Do not send outside local AS (well-known community)\n"
6342 "Do not advertise to any peer (well-known community)\n"
6343 "Do not export to next AS (well-known community)\n"
6344 "community number\n"
6345 "Do not send outside local AS (well-known community)\n"
6346 "Do not advertise to any peer (well-known community)\n"
6347 "Do not export to next AS (well-known community)\n"
6348 "Exact match of the communities")
6349
6350ALIAS (show_ip_bgp_ipv4_community_exact,
6351 show_ip_bgp_ipv4_community3_exact_cmd,
6352 "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",
6353 SHOW_STR
6354 IP_STR
6355 BGP_STR
6356 "Address family\n"
6357 "Address Family modifier\n"
6358 "Address Family modifier\n"
6359 "Display routes matching the communities\n"
6360 "community number\n"
6361 "Do not send outside local AS (well-known community)\n"
6362 "Do not advertise to any peer (well-known community)\n"
6363 "Do not export to next AS (well-known community)\n"
6364 "community number\n"
6365 "Do not send outside local AS (well-known community)\n"
6366 "Do not advertise to any peer (well-known community)\n"
6367 "Do not export to next AS (well-known community)\n"
6368 "community number\n"
6369 "Do not send outside local AS (well-known community)\n"
6370 "Do not advertise to any peer (well-known community)\n"
6371 "Do not export to next AS (well-known community)\n"
6372 "Exact match of the communities")
6373
6374ALIAS (show_ip_bgp_ipv4_community_exact,
6375 show_ip_bgp_ipv4_community4_exact_cmd,
6376 "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",
6377 SHOW_STR
6378 IP_STR
6379 BGP_STR
6380 "Address family\n"
6381 "Address Family modifier\n"
6382 "Address Family modifier\n"
6383 "Display routes matching the communities\n"
6384 "community number\n"
6385 "Do not send outside local AS (well-known community)\n"
6386 "Do not advertise to any peer (well-known community)\n"
6387 "Do not export to next AS (well-known community)\n"
6388 "community number\n"
6389 "Do not send outside local AS (well-known community)\n"
6390 "Do not advertise to any peer (well-known community)\n"
6391 "Do not export to next AS (well-known community)\n"
6392 "community number\n"
6393 "Do not send outside local AS (well-known community)\n"
6394 "Do not advertise to any peer (well-known community)\n"
6395 "Do not export to next AS (well-known community)\n"
6396 "community number\n"
6397 "Do not send outside local AS (well-known community)\n"
6398 "Do not advertise to any peer (well-known community)\n"
6399 "Do not export to next AS (well-known community)\n"
6400 "Exact match of the communities")
6401
6402#ifdef HAVE_IPV6
6403DEFUN (show_bgp_community,
6404 show_bgp_community_cmd,
6405 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
6406 SHOW_STR
6407 BGP_STR
6408 "Display routes matching the communities\n"
6409 "community number\n"
6410 "Do not send outside local AS (well-known community)\n"
6411 "Do not advertise to any peer (well-known community)\n"
6412 "Do not export to next AS (well-known community)\n")
6413{
6414 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
6415}
6416
6417ALIAS (show_bgp_community,
6418 show_bgp_ipv6_community_cmd,
6419 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
6420 SHOW_STR
6421 BGP_STR
6422 "Address family\n"
6423 "Display routes matching the communities\n"
6424 "community number\n"
6425 "Do not send outside local AS (well-known community)\n"
6426 "Do not advertise to any peer (well-known community)\n"
6427 "Do not export to next AS (well-known community)\n")
6428
6429ALIAS (show_bgp_community,
6430 show_bgp_community2_cmd,
6431 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6432 SHOW_STR
6433 BGP_STR
6434 "Display routes matching the communities\n"
6435 "community number\n"
6436 "Do not send outside local AS (well-known community)\n"
6437 "Do not advertise to any peer (well-known community)\n"
6438 "Do not export to next AS (well-known community)\n"
6439 "community number\n"
6440 "Do not send outside local AS (well-known community)\n"
6441 "Do not advertise to any peer (well-known community)\n"
6442 "Do not export to next AS (well-known community)\n")
6443
6444ALIAS (show_bgp_community,
6445 show_bgp_ipv6_community2_cmd,
6446 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6447 SHOW_STR
6448 BGP_STR
6449 "Address family\n"
6450 "Display routes matching the communities\n"
6451 "community number\n"
6452 "Do not send outside local AS (well-known community)\n"
6453 "Do not advertise to any peer (well-known community)\n"
6454 "Do not export to next AS (well-known community)\n"
6455 "community number\n"
6456 "Do not send outside local AS (well-known community)\n"
6457 "Do not advertise to any peer (well-known community)\n"
6458 "Do not export to next AS (well-known community)\n")
6459
6460ALIAS (show_bgp_community,
6461 show_bgp_community3_cmd,
6462 "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)",
6463 SHOW_STR
6464 BGP_STR
6465 "Display routes matching the communities\n"
6466 "community number\n"
6467 "Do not send outside local AS (well-known community)\n"
6468 "Do not advertise to any peer (well-known community)\n"
6469 "Do not export to next AS (well-known community)\n"
6470 "community number\n"
6471 "Do not send outside local AS (well-known community)\n"
6472 "Do not advertise to any peer (well-known community)\n"
6473 "Do not export to next AS (well-known community)\n"
6474 "community number\n"
6475 "Do not send outside local AS (well-known community)\n"
6476 "Do not advertise to any peer (well-known community)\n"
6477 "Do not export to next AS (well-known community)\n")
6478
6479ALIAS (show_bgp_community,
6480 show_bgp_ipv6_community3_cmd,
6481 "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)",
6482 SHOW_STR
6483 BGP_STR
6484 "Address family\n"
6485 "Display routes matching the communities\n"
6486 "community number\n"
6487 "Do not send outside local AS (well-known community)\n"
6488 "Do not advertise to any peer (well-known community)\n"
6489 "Do not export to next AS (well-known community)\n"
6490 "community number\n"
6491 "Do not send outside local AS (well-known community)\n"
6492 "Do not advertise to any peer (well-known community)\n"
6493 "Do not export to next AS (well-known community)\n"
6494 "community number\n"
6495 "Do not send outside local AS (well-known community)\n"
6496 "Do not advertise to any peer (well-known community)\n"
6497 "Do not export to next AS (well-known community)\n")
6498
6499ALIAS (show_bgp_community,
6500 show_bgp_community4_cmd,
6501 "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)",
6502 SHOW_STR
6503 BGP_STR
6504 "Display routes matching the communities\n"
6505 "community number\n"
6506 "Do not send outside local AS (well-known community)\n"
6507 "Do not advertise to any peer (well-known community)\n"
6508 "Do not export to next AS (well-known community)\n"
6509 "community number\n"
6510 "Do not send outside local AS (well-known community)\n"
6511 "Do not advertise to any peer (well-known community)\n"
6512 "Do not export to next AS (well-known community)\n"
6513 "community number\n"
6514 "Do not send outside local AS (well-known community)\n"
6515 "Do not advertise to any peer (well-known community)\n"
6516 "Do not export to next AS (well-known community)\n"
6517 "community number\n"
6518 "Do not send outside local AS (well-known community)\n"
6519 "Do not advertise to any peer (well-known community)\n"
6520 "Do not export to next AS (well-known community)\n")
6521
6522ALIAS (show_bgp_community,
6523 show_bgp_ipv6_community4_cmd,
6524 "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)",
6525 SHOW_STR
6526 BGP_STR
6527 "Address family\n"
6528 "Display routes matching the communities\n"
6529 "community number\n"
6530 "Do not send outside local AS (well-known community)\n"
6531 "Do not advertise to any peer (well-known community)\n"
6532 "Do not export to next AS (well-known community)\n"
6533 "community number\n"
6534 "Do not send outside local AS (well-known community)\n"
6535 "Do not advertise to any peer (well-known community)\n"
6536 "Do not export to next AS (well-known community)\n"
6537 "community number\n"
6538 "Do not send outside local AS (well-known community)\n"
6539 "Do not advertise to any peer (well-known community)\n"
6540 "Do not export to next AS (well-known community)\n"
6541 "community number\n"
6542 "Do not send outside local AS (well-known community)\n"
6543 "Do not advertise to any peer (well-known community)\n"
6544 "Do not export to next AS (well-known community)\n")
6545
6546/* old command */
6547DEFUN (show_ipv6_bgp_community,
6548 show_ipv6_bgp_community_cmd,
6549 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
6550 SHOW_STR
6551 IPV6_STR
6552 BGP_STR
6553 "Display routes matching the communities\n"
6554 "community number\n"
6555 "Do not send outside local AS (well-known community)\n"
6556 "Do not advertise to any peer (well-known community)\n"
6557 "Do not export to next AS (well-known community)\n")
6558{
6559 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
6560}
6561
6562/* old command */
6563ALIAS (show_ipv6_bgp_community,
6564 show_ipv6_bgp_community2_cmd,
6565 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6566 SHOW_STR
6567 IPV6_STR
6568 BGP_STR
6569 "Display routes matching the communities\n"
6570 "community number\n"
6571 "Do not send outside local AS (well-known community)\n"
6572 "Do not advertise to any peer (well-known community)\n"
6573 "Do not export to next AS (well-known community)\n"
6574 "community number\n"
6575 "Do not send outside local AS (well-known community)\n"
6576 "Do not advertise to any peer (well-known community)\n"
6577 "Do not export to next AS (well-known community)\n")
6578
6579/* old command */
6580ALIAS (show_ipv6_bgp_community,
6581 show_ipv6_bgp_community3_cmd,
6582 "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)",
6583 SHOW_STR
6584 IPV6_STR
6585 BGP_STR
6586 "Display routes matching the communities\n"
6587 "community number\n"
6588 "Do not send outside local AS (well-known community)\n"
6589 "Do not advertise to any peer (well-known community)\n"
6590 "Do not export to next AS (well-known community)\n"
6591 "community number\n"
6592 "Do not send outside local AS (well-known community)\n"
6593 "Do not advertise to any peer (well-known community)\n"
6594 "Do not export to next AS (well-known community)\n"
6595 "community number\n"
6596 "Do not send outside local AS (well-known community)\n"
6597 "Do not advertise to any peer (well-known community)\n"
6598 "Do not export to next AS (well-known community)\n")
6599
6600/* old command */
6601ALIAS (show_ipv6_bgp_community,
6602 show_ipv6_bgp_community4_cmd,
6603 "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)",
6604 SHOW_STR
6605 IPV6_STR
6606 BGP_STR
6607 "Display routes matching the communities\n"
6608 "community number\n"
6609 "Do not send outside local AS (well-known community)\n"
6610 "Do not advertise to any peer (well-known community)\n"
6611 "Do not export to next AS (well-known community)\n"
6612 "community number\n"
6613 "Do not send outside local AS (well-known community)\n"
6614 "Do not advertise to any peer (well-known community)\n"
6615 "Do not export to next AS (well-known community)\n"
6616 "community number\n"
6617 "Do not send outside local AS (well-known community)\n"
6618 "Do not advertise to any peer (well-known community)\n"
6619 "Do not export to next AS (well-known community)\n"
6620 "community number\n"
6621 "Do not send outside local AS (well-known community)\n"
6622 "Do not advertise to any peer (well-known community)\n"
6623 "Do not export to next AS (well-known community)\n")
6624
6625DEFUN (show_bgp_community_exact,
6626 show_bgp_community_exact_cmd,
6627 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6628 SHOW_STR
6629 BGP_STR
6630 "Display routes matching the communities\n"
6631 "community number\n"
6632 "Do not send outside local AS (well-known community)\n"
6633 "Do not advertise to any peer (well-known community)\n"
6634 "Do not export to next AS (well-known community)\n"
6635 "Exact match of the communities")
6636{
6637 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
6638}
6639
6640ALIAS (show_bgp_community_exact,
6641 show_bgp_ipv6_community_exact_cmd,
6642 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6643 SHOW_STR
6644 BGP_STR
6645 "Address family\n"
6646 "Display routes matching the communities\n"
6647 "community number\n"
6648 "Do not send outside local AS (well-known community)\n"
6649 "Do not advertise to any peer (well-known community)\n"
6650 "Do not export to next AS (well-known community)\n"
6651 "Exact match of the communities")
6652
6653ALIAS (show_bgp_community_exact,
6654 show_bgp_community2_exact_cmd,
6655 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6656 SHOW_STR
6657 BGP_STR
6658 "Display routes matching the communities\n"
6659 "community number\n"
6660 "Do not send outside local AS (well-known community)\n"
6661 "Do not advertise to any peer (well-known community)\n"
6662 "Do not export to next AS (well-known community)\n"
6663 "community number\n"
6664 "Do not send outside local AS (well-known community)\n"
6665 "Do not advertise to any peer (well-known community)\n"
6666 "Do not export to next AS (well-known community)\n"
6667 "Exact match of the communities")
6668
6669ALIAS (show_bgp_community_exact,
6670 show_bgp_ipv6_community2_exact_cmd,
6671 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6672 SHOW_STR
6673 BGP_STR
6674 "Address family\n"
6675 "Display routes matching the communities\n"
6676 "community number\n"
6677 "Do not send outside local AS (well-known community)\n"
6678 "Do not advertise to any peer (well-known community)\n"
6679 "Do not export to next AS (well-known community)\n"
6680 "community number\n"
6681 "Do not send outside local AS (well-known community)\n"
6682 "Do not advertise to any peer (well-known community)\n"
6683 "Do not export to next AS (well-known community)\n"
6684 "Exact match of the communities")
6685
6686ALIAS (show_bgp_community_exact,
6687 show_bgp_community3_exact_cmd,
6688 "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",
6689 SHOW_STR
6690 BGP_STR
6691 "Display routes matching the communities\n"
6692 "community number\n"
6693 "Do not send outside local AS (well-known community)\n"
6694 "Do not advertise to any peer (well-known community)\n"
6695 "Do not export to next AS (well-known community)\n"
6696 "community number\n"
6697 "Do not send outside local AS (well-known community)\n"
6698 "Do not advertise to any peer (well-known community)\n"
6699 "Do not export to next AS (well-known community)\n"
6700 "community number\n"
6701 "Do not send outside local AS (well-known community)\n"
6702 "Do not advertise to any peer (well-known community)\n"
6703 "Do not export to next AS (well-known community)\n"
6704 "Exact match of the communities")
6705
6706ALIAS (show_bgp_community_exact,
6707 show_bgp_ipv6_community3_exact_cmd,
6708 "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",
6709 SHOW_STR
6710 BGP_STR
6711 "Address family\n"
6712 "Display routes matching the communities\n"
6713 "community number\n"
6714 "Do not send outside local AS (well-known community)\n"
6715 "Do not advertise to any peer (well-known community)\n"
6716 "Do not export to next AS (well-known community)\n"
6717 "community number\n"
6718 "Do not send outside local AS (well-known community)\n"
6719 "Do not advertise to any peer (well-known community)\n"
6720 "Do not export to next AS (well-known community)\n"
6721 "community number\n"
6722 "Do not send outside local AS (well-known community)\n"
6723 "Do not advertise to any peer (well-known community)\n"
6724 "Do not export to next AS (well-known community)\n"
6725 "Exact match of the communities")
6726
6727ALIAS (show_bgp_community_exact,
6728 show_bgp_community4_exact_cmd,
6729 "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",
6730 SHOW_STR
6731 BGP_STR
6732 "Display routes matching the communities\n"
6733 "community number\n"
6734 "Do not send outside local AS (well-known community)\n"
6735 "Do not advertise to any peer (well-known community)\n"
6736 "Do not export to next AS (well-known community)\n"
6737 "community number\n"
6738 "Do not send outside local AS (well-known community)\n"
6739 "Do not advertise to any peer (well-known community)\n"
6740 "Do not export to next AS (well-known community)\n"
6741 "community number\n"
6742 "Do not send outside local AS (well-known community)\n"
6743 "Do not advertise to any peer (well-known community)\n"
6744 "Do not export to next AS (well-known community)\n"
6745 "community number\n"
6746 "Do not send outside local AS (well-known community)\n"
6747 "Do not advertise to any peer (well-known community)\n"
6748 "Do not export to next AS (well-known community)\n"
6749 "Exact match of the communities")
6750
6751ALIAS (show_bgp_community_exact,
6752 show_bgp_ipv6_community4_exact_cmd,
6753 "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",
6754 SHOW_STR
6755 BGP_STR
6756 "Address family\n"
6757 "Display routes matching the communities\n"
6758 "community number\n"
6759 "Do not send outside local AS (well-known community)\n"
6760 "Do not advertise to any peer (well-known community)\n"
6761 "Do not export to next AS (well-known community)\n"
6762 "community number\n"
6763 "Do not send outside local AS (well-known community)\n"
6764 "Do not advertise to any peer (well-known community)\n"
6765 "Do not export to next AS (well-known community)\n"
6766 "community number\n"
6767 "Do not send outside local AS (well-known community)\n"
6768 "Do not advertise to any peer (well-known community)\n"
6769 "Do not export to next AS (well-known community)\n"
6770 "community number\n"
6771 "Do not send outside local AS (well-known community)\n"
6772 "Do not advertise to any peer (well-known community)\n"
6773 "Do not export to next AS (well-known community)\n"
6774 "Exact match of the communities")
6775
6776/* old command */
6777DEFUN (show_ipv6_bgp_community_exact,
6778 show_ipv6_bgp_community_exact_cmd,
6779 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6780 SHOW_STR
6781 IPV6_STR
6782 BGP_STR
6783 "Display routes matching the communities\n"
6784 "community number\n"
6785 "Do not send outside local AS (well-known community)\n"
6786 "Do not advertise to any peer (well-known community)\n"
6787 "Do not export to next AS (well-known community)\n"
6788 "Exact match of the communities")
6789{
6790 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
6791}
6792
6793/* old command */
6794ALIAS (show_ipv6_bgp_community_exact,
6795 show_ipv6_bgp_community2_exact_cmd,
6796 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6797 SHOW_STR
6798 IPV6_STR
6799 BGP_STR
6800 "Display routes matching the communities\n"
6801 "community number\n"
6802 "Do not send outside local AS (well-known community)\n"
6803 "Do not advertise to any peer (well-known community)\n"
6804 "Do not export to next AS (well-known community)\n"
6805 "community number\n"
6806 "Do not send outside local AS (well-known community)\n"
6807 "Do not advertise to any peer (well-known community)\n"
6808 "Do not export to next AS (well-known community)\n"
6809 "Exact match of the communities")
6810
6811/* old command */
6812ALIAS (show_ipv6_bgp_community_exact,
6813 show_ipv6_bgp_community3_exact_cmd,
6814 "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",
6815 SHOW_STR
6816 IPV6_STR
6817 BGP_STR
6818 "Display routes matching the communities\n"
6819 "community number\n"
6820 "Do not send outside local AS (well-known community)\n"
6821 "Do not advertise to any peer (well-known community)\n"
6822 "Do not export to next AS (well-known community)\n"
6823 "community number\n"
6824 "Do not send outside local AS (well-known community)\n"
6825 "Do not advertise to any peer (well-known community)\n"
6826 "Do not export to next AS (well-known community)\n"
6827 "community number\n"
6828 "Do not send outside local AS (well-known community)\n"
6829 "Do not advertise to any peer (well-known community)\n"
6830 "Do not export to next AS (well-known community)\n"
6831 "Exact match of the communities")
6832
6833/* old command */
6834ALIAS (show_ipv6_bgp_community_exact,
6835 show_ipv6_bgp_community4_exact_cmd,
6836 "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",
6837 SHOW_STR
6838 IPV6_STR
6839 BGP_STR
6840 "Display routes matching the communities\n"
6841 "community number\n"
6842 "Do not send outside local AS (well-known community)\n"
6843 "Do not advertise to any peer (well-known community)\n"
6844 "Do not export to next AS (well-known community)\n"
6845 "community number\n"
6846 "Do not send outside local AS (well-known community)\n"
6847 "Do not advertise to any peer (well-known community)\n"
6848 "Do not export to next AS (well-known community)\n"
6849 "community number\n"
6850 "Do not send outside local AS (well-known community)\n"
6851 "Do not advertise to any peer (well-known community)\n"
6852 "Do not export to next AS (well-known community)\n"
6853 "community number\n"
6854 "Do not send outside local AS (well-known community)\n"
6855 "Do not advertise to any peer (well-known community)\n"
6856 "Do not export to next AS (well-known community)\n"
6857 "Exact match of the communities")
6858
6859/* old command */
6860DEFUN (show_ipv6_mbgp_community,
6861 show_ipv6_mbgp_community_cmd,
6862 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
6863 SHOW_STR
6864 IPV6_STR
6865 MBGP_STR
6866 "Display routes matching the communities\n"
6867 "community number\n"
6868 "Do not send outside local AS (well-known community)\n"
6869 "Do not advertise to any peer (well-known community)\n"
6870 "Do not export to next AS (well-known community)\n")
6871{
6872 return bgp_show_community (vty, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
6873}
6874
6875/* old command */
6876ALIAS (show_ipv6_mbgp_community,
6877 show_ipv6_mbgp_community2_cmd,
6878 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6879 SHOW_STR
6880 IPV6_STR
6881 MBGP_STR
6882 "Display routes matching the communities\n"
6883 "community number\n"
6884 "Do not send outside local AS (well-known community)\n"
6885 "Do not advertise to any peer (well-known community)\n"
6886 "Do not export to next AS (well-known community)\n"
6887 "community number\n"
6888 "Do not send outside local AS (well-known community)\n"
6889 "Do not advertise to any peer (well-known community)\n"
6890 "Do not export to next AS (well-known community)\n")
6891
6892/* old command */
6893ALIAS (show_ipv6_mbgp_community,
6894 show_ipv6_mbgp_community3_cmd,
6895 "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)",
6896 SHOW_STR
6897 IPV6_STR
6898 MBGP_STR
6899 "Display routes matching the communities\n"
6900 "community number\n"
6901 "Do not send outside local AS (well-known community)\n"
6902 "Do not advertise to any peer (well-known community)\n"
6903 "Do not export to next AS (well-known community)\n"
6904 "community number\n"
6905 "Do not send outside local AS (well-known community)\n"
6906 "Do not advertise to any peer (well-known community)\n"
6907 "Do not export to next AS (well-known community)\n"
6908 "community number\n"
6909 "Do not send outside local AS (well-known community)\n"
6910 "Do not advertise to any peer (well-known community)\n"
6911 "Do not export to next AS (well-known community)\n")
6912
6913/* old command */
6914ALIAS (show_ipv6_mbgp_community,
6915 show_ipv6_mbgp_community4_cmd,
6916 "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)",
6917 SHOW_STR
6918 IPV6_STR
6919 MBGP_STR
6920 "Display routes matching the communities\n"
6921 "community number\n"
6922 "Do not send outside local AS (well-known community)\n"
6923 "Do not advertise to any peer (well-known community)\n"
6924 "Do not export to next AS (well-known community)\n"
6925 "community number\n"
6926 "Do not send outside local AS (well-known community)\n"
6927 "Do not advertise to any peer (well-known community)\n"
6928 "Do not export to next AS (well-known community)\n"
6929 "community number\n"
6930 "Do not send outside local AS (well-known community)\n"
6931 "Do not advertise to any peer (well-known community)\n"
6932 "Do not export to next AS (well-known community)\n"
6933 "community number\n"
6934 "Do not send outside local AS (well-known community)\n"
6935 "Do not advertise to any peer (well-known community)\n"
6936 "Do not export to next AS (well-known community)\n")
6937
6938/* old command */
6939DEFUN (show_ipv6_mbgp_community_exact,
6940 show_ipv6_mbgp_community_exact_cmd,
6941 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6942 SHOW_STR
6943 IPV6_STR
6944 MBGP_STR
6945 "Display routes matching the communities\n"
6946 "community number\n"
6947 "Do not send outside local AS (well-known community)\n"
6948 "Do not advertise to any peer (well-known community)\n"
6949 "Do not export to next AS (well-known community)\n"
6950 "Exact match of the communities")
6951{
6952 return bgp_show_community (vty, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
6953}
6954
6955/* old command */
6956ALIAS (show_ipv6_mbgp_community_exact,
6957 show_ipv6_mbgp_community2_exact_cmd,
6958 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6959 SHOW_STR
6960 IPV6_STR
6961 MBGP_STR
6962 "Display routes matching the communities\n"
6963 "community number\n"
6964 "Do not send outside local AS (well-known community)\n"
6965 "Do not advertise to any peer (well-known community)\n"
6966 "Do not export to next AS (well-known community)\n"
6967 "community number\n"
6968 "Do not send outside local AS (well-known community)\n"
6969 "Do not advertise to any peer (well-known community)\n"
6970 "Do not export to next AS (well-known community)\n"
6971 "Exact match of the communities")
6972
6973/* old command */
6974ALIAS (show_ipv6_mbgp_community_exact,
6975 show_ipv6_mbgp_community3_exact_cmd,
6976 "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",
6977 SHOW_STR
6978 IPV6_STR
6979 MBGP_STR
6980 "Display routes matching the communities\n"
6981 "community number\n"
6982 "Do not send outside local AS (well-known community)\n"
6983 "Do not advertise to any peer (well-known community)\n"
6984 "Do not export to next AS (well-known community)\n"
6985 "community number\n"
6986 "Do not send outside local AS (well-known community)\n"
6987 "Do not advertise to any peer (well-known community)\n"
6988 "Do not export to next AS (well-known community)\n"
6989 "community number\n"
6990 "Do not send outside local AS (well-known community)\n"
6991 "Do not advertise to any peer (well-known community)\n"
6992 "Do not export to next AS (well-known community)\n"
6993 "Exact match of the communities")
6994
6995/* old command */
6996ALIAS (show_ipv6_mbgp_community_exact,
6997 show_ipv6_mbgp_community4_exact_cmd,
6998 "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",
6999 SHOW_STR
7000 IPV6_STR
7001 MBGP_STR
7002 "Display routes matching the communities\n"
7003 "community number\n"
7004 "Do not send outside local AS (well-known community)\n"
7005 "Do not advertise to any peer (well-known community)\n"
7006 "Do not export to next AS (well-known community)\n"
7007 "community number\n"
7008 "Do not send outside local AS (well-known community)\n"
7009 "Do not advertise to any peer (well-known community)\n"
7010 "Do not export to next AS (well-known community)\n"
7011 "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 "Exact match of the communities")
7020#endif /* HAVE_IPV6 */
7021
7022int
7023bgp_show_community_list (struct vty *vty, char *com, int exact,
7024 u_int16_t afi, u_char safi)
7025{
7026 struct community_list *list;
7027
7028 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_AUTO);
7029 if (list == NULL)
7030 {
7031 vty_out (vty, "%% %s is not a valid community-list name%s", com,
7032 VTY_NEWLINE);
7033 return CMD_WARNING;
7034 }
7035
7036 vty->output_arg = list;
7037
7038 if (exact)
7039 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_list_exact);
7040
7041 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_list);
7042}
7043
7044DEFUN (show_ip_bgp_community_list,
7045 show_ip_bgp_community_list_cmd,
7046 "show ip bgp community-list WORD",
7047 SHOW_STR
7048 IP_STR
7049 BGP_STR
7050 "Display routes matching the community-list\n"
7051 "community-list name\n")
7052{
7053 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
7054}
7055
7056DEFUN (show_ip_bgp_ipv4_community_list,
7057 show_ip_bgp_ipv4_community_list_cmd,
7058 "show ip bgp ipv4 (unicast|multicast) community-list WORD",
7059 SHOW_STR
7060 IP_STR
7061 BGP_STR
7062 "Address family\n"
7063 "Address Family modifier\n"
7064 "Address Family modifier\n"
7065 "Display routes matching the community-list\n"
7066 "community-list name\n")
7067{
7068 if (strncmp (argv[0], "m", 1) == 0)
7069 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
7070
7071 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
7072}
7073
7074DEFUN (show_ip_bgp_community_list_exact,
7075 show_ip_bgp_community_list_exact_cmd,
7076 "show ip bgp community-list WORD exact-match",
7077 SHOW_STR
7078 IP_STR
7079 BGP_STR
7080 "Display routes matching the community-list\n"
7081 "community-list name\n"
7082 "Exact match of the communities\n")
7083{
7084 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
7085}
7086
7087DEFUN (show_ip_bgp_ipv4_community_list_exact,
7088 show_ip_bgp_ipv4_community_list_exact_cmd,
7089 "show ip bgp ipv4 (unicast|multicast) community-list WORD exact-match",
7090 SHOW_STR
7091 IP_STR
7092 BGP_STR
7093 "Address family\n"
7094 "Address Family modifier\n"
7095 "Address Family modifier\n"
7096 "Display routes matching the community-list\n"
7097 "community-list name\n"
7098 "Exact match of the communities\n")
7099{
7100 if (strncmp (argv[0], "m", 1) == 0)
7101 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
7102
7103 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
7104}
7105
7106#ifdef HAVE_IPV6
7107DEFUN (show_bgp_community_list,
7108 show_bgp_community_list_cmd,
7109 "show bgp community-list WORD",
7110 SHOW_STR
7111 BGP_STR
7112 "Display routes matching the community-list\n"
7113 "community-list name\n")
7114{
7115 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
7116}
7117
7118ALIAS (show_bgp_community_list,
7119 show_bgp_ipv6_community_list_cmd,
7120 "show bgp ipv6 community-list WORD",
7121 SHOW_STR
7122 BGP_STR
7123 "Address family\n"
7124 "Display routes matching the community-list\n"
7125 "community-list name\n")
7126
7127/* old command */
7128DEFUN (show_ipv6_bgp_community_list,
7129 show_ipv6_bgp_community_list_cmd,
7130 "show ipv6 bgp community-list WORD",
7131 SHOW_STR
7132 IPV6_STR
7133 BGP_STR
7134 "Display routes matching the community-list\n"
7135 "community-list name\n")
7136{
7137 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
7138}
7139
7140/* old command */
7141DEFUN (show_ipv6_mbgp_community_list,
7142 show_ipv6_mbgp_community_list_cmd,
7143 "show ipv6 mbgp community-list WORD",
7144 SHOW_STR
7145 IPV6_STR
7146 MBGP_STR
7147 "Display routes matching the community-list\n"
7148 "community-list name\n")
7149{
7150 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
7151}
7152
7153DEFUN (show_bgp_community_list_exact,
7154 show_bgp_community_list_exact_cmd,
7155 "show bgp community-list WORD exact-match",
7156 SHOW_STR
7157 BGP_STR
7158 "Display routes matching the community-list\n"
7159 "community-list name\n"
7160 "Exact match of the communities\n")
7161{
7162 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
7163}
7164
7165ALIAS (show_bgp_community_list_exact,
7166 show_bgp_ipv6_community_list_exact_cmd,
7167 "show bgp ipv6 community-list WORD exact-match",
7168 SHOW_STR
7169 BGP_STR
7170 "Address family\n"
7171 "Display routes matching the community-list\n"
7172 "community-list name\n"
7173 "Exact match of the communities\n")
7174
7175/* old command */
7176DEFUN (show_ipv6_bgp_community_list_exact,
7177 show_ipv6_bgp_community_list_exact_cmd,
7178 "show ipv6 bgp community-list WORD exact-match",
7179 SHOW_STR
7180 IPV6_STR
7181 BGP_STR
7182 "Display routes matching the community-list\n"
7183 "community-list name\n"
7184 "Exact match of the communities\n")
7185{
7186 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
7187}
7188
7189/* old command */
7190DEFUN (show_ipv6_mbgp_community_list_exact,
7191 show_ipv6_mbgp_community_list_exact_cmd,
7192 "show ipv6 mbgp community-list WORD exact-match",
7193 SHOW_STR
7194 IPV6_STR
7195 MBGP_STR
7196 "Display routes matching the community-list\n"
7197 "community-list name\n"
7198 "Exact match of the communities\n")
7199{
7200 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
7201}
7202#endif /* HAVE_IPV6 */
7203
7204void
7205bgp_show_prefix_longer_clean (struct vty *vty)
7206{
7207 struct prefix *p;
7208
7209 p = vty->output_arg;
7210 prefix_free (p);
7211}
7212
7213int
7214bgp_show_prefix_longer (struct vty *vty, char *prefix, afi_t afi,
7215 safi_t safi, enum bgp_show_type type)
7216{
7217 int ret;
7218 struct prefix *p;
7219
7220 p = prefix_new();
7221
7222 ret = str2prefix (prefix, p);
7223 if (! ret)
7224 {
7225 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
7226 return CMD_WARNING;
7227 }
7228
7229 vty->output_arg = p;
7230 vty->output_clean = bgp_show_prefix_longer_clean;
7231
7232 return bgp_show (vty, NULL, afi, safi, type);
7233}
7234
7235DEFUN (show_ip_bgp_prefix_longer,
7236 show_ip_bgp_prefix_longer_cmd,
7237 "show ip bgp A.B.C.D/M longer-prefixes",
7238 SHOW_STR
7239 IP_STR
7240 BGP_STR
7241 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7242 "Display route and more specific routes\n")
7243{
7244 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
7245 bgp_show_type_prefix_longer);
7246}
7247
7248DEFUN (show_ip_bgp_flap_prefix_longer,
7249 show_ip_bgp_flap_prefix_longer_cmd,
7250 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
7251 SHOW_STR
7252 IP_STR
7253 BGP_STR
7254 "Display flap statistics of routes\n"
7255 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7256 "Display route and more specific routes\n")
7257{
7258 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
7259 bgp_show_type_flap_prefix_longer);
7260}
7261
7262DEFUN (show_ip_bgp_ipv4_prefix_longer,
7263 show_ip_bgp_ipv4_prefix_longer_cmd,
7264 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
7265 SHOW_STR
7266 IP_STR
7267 BGP_STR
7268 "Address family\n"
7269 "Address Family modifier\n"
7270 "Address Family modifier\n"
7271 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7272 "Display route and more specific routes\n")
7273{
7274 if (strncmp (argv[0], "m", 1) == 0)
7275 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
7276 bgp_show_type_prefix_longer);
7277
7278 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
7279 bgp_show_type_prefix_longer);
7280}
7281
7282DEFUN (show_ip_bgp_flap_address,
7283 show_ip_bgp_flap_address_cmd,
7284 "show ip bgp flap-statistics A.B.C.D",
7285 SHOW_STR
7286 IP_STR
7287 BGP_STR
7288 "Display flap statistics of routes\n"
7289 "Network in the BGP routing table to display\n")
7290{
7291 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
7292 bgp_show_type_flap_address);
7293}
7294
7295DEFUN (show_ip_bgp_flap_prefix,
7296 show_ip_bgp_flap_prefix_cmd,
7297 "show ip bgp flap-statistics A.B.C.D/M",
7298 SHOW_STR
7299 IP_STR
7300 BGP_STR
7301 "Display flap statistics of routes\n"
7302 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7303{
7304 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
7305 bgp_show_type_flap_prefix);
7306}
7307#ifdef HAVE_IPV6
7308DEFUN (show_bgp_prefix_longer,
7309 show_bgp_prefix_longer_cmd,
7310 "show bgp X:X::X:X/M longer-prefixes",
7311 SHOW_STR
7312 BGP_STR
7313 "IPv6 prefix <network>/<length>\n"
7314 "Display route and more specific routes\n")
7315{
7316 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
7317 bgp_show_type_prefix_longer);
7318}
7319
7320ALIAS (show_bgp_prefix_longer,
7321 show_bgp_ipv6_prefix_longer_cmd,
7322 "show bgp ipv6 X:X::X:X/M longer-prefixes",
7323 SHOW_STR
7324 BGP_STR
7325 "Address family\n"
7326 "IPv6 prefix <network>/<length>\n"
7327 "Display route and more specific routes\n")
7328
7329/* old command */
7330DEFUN (show_ipv6_bgp_prefix_longer,
7331 show_ipv6_bgp_prefix_longer_cmd,
7332 "show ipv6 bgp X:X::X:X/M longer-prefixes",
7333 SHOW_STR
7334 IPV6_STR
7335 BGP_STR
7336 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
7337 "Display route and more specific routes\n")
7338{
7339 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
7340 bgp_show_type_prefix_longer);
7341}
7342
7343/* old command */
7344DEFUN (show_ipv6_mbgp_prefix_longer,
7345 show_ipv6_mbgp_prefix_longer_cmd,
7346 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
7347 SHOW_STR
7348 IPV6_STR
7349 MBGP_STR
7350 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
7351 "Display route and more specific routes\n")
7352{
7353 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
7354 bgp_show_type_prefix_longer);
7355}
7356#endif /* HAVE_IPV6 */
paulbb46e942003-10-24 19:02:03 +00007357
7358struct peer *
7359peer_lookup_in_view (struct vty *vty, char *view_name, char *ip_str)
7360{
7361 int ret;
7362 struct bgp *bgp;
7363 struct peer *peer;
7364 union sockunion su;
7365
7366 /* BGP structure lookup. */
7367 if (view_name)
7368 {
7369 bgp = bgp_lookup_by_name (view_name);
7370 if (! bgp)
7371 {
7372 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
7373 return NULL;
7374 }
7375 }
7376 else // view_name==NULL
7377 {
7378 bgp = bgp_get_default ();
7379 if (! bgp)
7380 {
7381 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
7382 return NULL;
7383 }
7384 }
7385
7386 /* Get peer sockunion. */
7387 ret = str2sockunion (ip_str, &su);
7388 if (ret < 0)
7389 {
7390 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
7391 return NULL;
7392 }
7393
7394 /* Peer structure lookup. */
7395 peer = peer_lookup (bgp, &su);
7396 if (! peer)
7397 {
7398 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
7399 return NULL;
7400 }
7401
7402 return peer;
7403}
7404
paul718e3742002-12-13 20:15:29 +00007405void
7406show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
7407 int in)
7408{
7409 struct bgp_table *table;
7410 struct bgp_adj_in *ain;
7411 struct bgp_adj_out *adj;
7412 unsigned long output_count;
7413 struct bgp_node *rn;
7414 int header1 = 1;
7415 struct bgp *bgp;
7416 int header2 = 1;
7417
paulbb46e942003-10-24 19:02:03 +00007418 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +00007419
7420 if (! bgp)
7421 return;
7422
7423 table = bgp->rib[afi][safi];
7424
7425 output_count = 0;
7426
7427 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
7428 PEER_STATUS_DEFAULT_ORIGINATE))
7429 {
7430 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
7431 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE);
7432 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE);
7433
7434 vty_out (vty, "Originating default network 0.0.0.0%s%s",
7435 VTY_NEWLINE, VTY_NEWLINE);
7436 header1 = 0;
7437 }
7438
7439 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
7440 if (in)
7441 {
7442 for (ain = rn->adj_in; ain; ain = ain->next)
7443 if (ain->peer == peer)
7444 {
7445 if (header1)
7446 {
7447 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
7448 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE);
7449 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE);
7450 header1 = 0;
7451 }
7452 if (header2)
7453 {
7454 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
7455 header2 = 0;
7456 }
7457 if (ain->attr)
7458 {
7459 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
7460 output_count++;
7461 }
7462 }
7463 }
7464 else
7465 {
7466 for (adj = rn->adj_out; adj; adj = adj->next)
7467 if (adj->peer == peer)
7468 {
7469 if (header1)
7470 {
7471 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
7472 vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE);
7473 vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE, VTY_NEWLINE);
7474 header1 = 0;
7475 }
7476 if (header2)
7477 {
7478 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
7479 header2 = 0;
7480 }
7481 if (adj->attr)
7482 {
7483 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
7484 output_count++;
7485 }
7486 }
7487 }
7488
7489 if (output_count != 0)
7490 vty_out (vty, "%sTotal number of prefixes %ld%s",
7491 VTY_NEWLINE, output_count, VTY_NEWLINE);
7492}
7493
7494int
paulbb46e942003-10-24 19:02:03 +00007495peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
7496{
paul718e3742002-12-13 20:15:29 +00007497 if (! peer || ! peer->afc[afi][safi])
7498 {
7499 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
7500 return CMD_WARNING;
7501 }
7502
7503 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7504 {
7505 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
7506 VTY_NEWLINE);
7507 return CMD_WARNING;
7508 }
7509
7510 show_adj_route (vty, peer, afi, safi, in);
7511
7512 return CMD_SUCCESS;
7513}
7514
7515DEFUN (show_ip_bgp_neighbor_advertised_route,
7516 show_ip_bgp_neighbor_advertised_route_cmd,
7517 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
7518 SHOW_STR
7519 IP_STR
7520 BGP_STR
7521 "Detailed information on TCP and BGP neighbor connections\n"
7522 "Neighbor to display information about\n"
7523 "Neighbor to display information about\n"
7524 "Display the routes advertised to a BGP neighbor\n")
7525{
paulbb46e942003-10-24 19:02:03 +00007526 struct peer *peer;
7527
7528 peer = peer_lookup_in_view (vty, NULL, argv[0]);
7529 if (! peer)
7530 return CMD_WARNING;
7531
7532 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
paul718e3742002-12-13 20:15:29 +00007533}
7534
7535DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
7536 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
7537 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
7538 SHOW_STR
7539 IP_STR
7540 BGP_STR
7541 "Address family\n"
7542 "Address Family modifier\n"
7543 "Address Family modifier\n"
7544 "Detailed information on TCP and BGP neighbor connections\n"
7545 "Neighbor to display information about\n"
7546 "Neighbor to display information about\n"
7547 "Display the routes advertised to a BGP neighbor\n")
7548{
paulbb46e942003-10-24 19:02:03 +00007549 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00007550
paulbb46e942003-10-24 19:02:03 +00007551 peer = peer_lookup_in_view (vty, NULL, argv[1]);
7552 if (! peer)
7553 return CMD_WARNING;
7554
7555 if (strncmp (argv[0], "m", 1) == 0)
7556 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
7557
7558 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
paul718e3742002-12-13 20:15:29 +00007559}
7560
7561#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00007562DEFUN (show_bgp_view_neighbor_advertised_route,
7563 show_bgp_view_neighbor_advertised_route_cmd,
7564 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
7565 SHOW_STR
7566 BGP_STR
7567 "BGP view\n"
7568 "View name\n"
7569 "Detailed information on TCP and BGP neighbor connections\n"
7570 "Neighbor to display information about\n"
7571 "Neighbor to display information about\n"
7572 "Display the routes advertised to a BGP neighbor\n")
7573{
7574 struct peer *peer;
7575
7576 if (argc == 2)
7577 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
7578 else
7579 peer = peer_lookup_in_view (vty, NULL, argv[0]);
7580
7581 if (! peer)
7582 return CMD_WARNING;
7583
7584 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
7585}
7586
7587ALIAS (show_bgp_view_neighbor_advertised_route,
7588 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
7589 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
7590 SHOW_STR
7591 BGP_STR
7592 "BGP view\n"
7593 "View name\n"
7594 "Address family\n"
7595 "Detailed information on TCP and BGP neighbor connections\n"
7596 "Neighbor to display information about\n"
7597 "Neighbor to display information about\n"
7598 "Display the routes advertised to a BGP neighbor\n")
7599
7600DEFUN (show_bgp_view_neighbor_received_routes,
7601 show_bgp_view_neighbor_received_routes_cmd,
7602 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
7603 SHOW_STR
7604 BGP_STR
7605 "BGP view\n"
7606 "View name\n"
7607 "Detailed information on TCP and BGP neighbor connections\n"
7608 "Neighbor to display information about\n"
7609 "Neighbor to display information about\n"
7610 "Display the received routes from neighbor\n")
7611{
7612 struct peer *peer;
7613
7614 if (argc == 2)
7615 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
7616 else
7617 peer = peer_lookup_in_view (vty, NULL, argv[0]);
7618
7619 if (! peer)
7620 return CMD_WARNING;
7621
7622 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
7623}
7624
7625ALIAS (show_bgp_view_neighbor_received_routes,
7626 show_bgp_view_ipv6_neighbor_received_routes_cmd,
7627 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
7628 SHOW_STR
7629 BGP_STR
7630 "BGP view\n"
7631 "View name\n"
7632 "Address family\n"
7633 "Detailed information on TCP and BGP neighbor connections\n"
7634 "Neighbor to display information about\n"
7635 "Neighbor to display information about\n"
7636 "Display the received routes from neighbor\n")
7637
7638ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00007639 show_bgp_neighbor_advertised_route_cmd,
7640 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
7641 SHOW_STR
7642 BGP_STR
7643 "Detailed information on TCP and BGP neighbor connections\n"
7644 "Neighbor to display information about\n"
7645 "Neighbor to display information about\n"
7646 "Display the routes advertised to a BGP neighbor\n")
paulbb46e942003-10-24 19:02:03 +00007647
7648ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00007649 show_bgp_ipv6_neighbor_advertised_route_cmd,
7650 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
7651 SHOW_STR
7652 BGP_STR
7653 "Address family\n"
7654 "Detailed information on TCP and BGP neighbor connections\n"
7655 "Neighbor to display information about\n"
7656 "Neighbor to display information about\n"
7657 "Display the routes advertised to a BGP neighbor\n")
7658
7659/* old command */
paulbb46e942003-10-24 19:02:03 +00007660ALIAS (show_bgp_view_neighbor_advertised_route,
paul718e3742002-12-13 20:15:29 +00007661 ipv6_bgp_neighbor_advertised_route_cmd,
7662 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
7663 SHOW_STR
7664 IPV6_STR
7665 BGP_STR
7666 "Detailed information on TCP and BGP neighbor connections\n"
7667 "Neighbor to display information about\n"
7668 "Neighbor to display information about\n"
7669 "Display the routes advertised to a BGP neighbor\n")
paulbb46e942003-10-24 19:02:03 +00007670
paul718e3742002-12-13 20:15:29 +00007671/* old command */
7672DEFUN (ipv6_mbgp_neighbor_advertised_route,
7673 ipv6_mbgp_neighbor_advertised_route_cmd,
7674 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
7675 SHOW_STR
7676 IPV6_STR
7677 MBGP_STR
7678 "Detailed information on TCP and BGP neighbor connections\n"
7679 "Neighbor to display information about\n"
7680 "Neighbor to display information about\n"
7681 "Display the routes advertised to a BGP neighbor\n")
7682{
paulbb46e942003-10-24 19:02:03 +00007683 struct peer *peer;
7684
7685 peer = peer_lookup_in_view (vty, NULL, argv[0]);
7686 if (! peer)
7687 return CMD_WARNING;
7688
7689 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
paul718e3742002-12-13 20:15:29 +00007690}
7691#endif /* HAVE_IPV6 */
7692
7693DEFUN (show_ip_bgp_neighbor_received_routes,
7694 show_ip_bgp_neighbor_received_routes_cmd,
7695 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
7696 SHOW_STR
7697 IP_STR
7698 BGP_STR
7699 "Detailed information on TCP and BGP neighbor connections\n"
7700 "Neighbor to display information about\n"
7701 "Neighbor to display information about\n"
7702 "Display the received routes from neighbor\n")
7703{
paulbb46e942003-10-24 19:02:03 +00007704 struct peer *peer;
7705
7706 peer = peer_lookup_in_view (vty, NULL, argv[0]);
7707 if (! peer)
7708 return CMD_WARNING;
7709
7710 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
paul718e3742002-12-13 20:15:29 +00007711}
7712
7713DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
7714 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
7715 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
7716 SHOW_STR
7717 IP_STR
7718 BGP_STR
7719 "Address family\n"
7720 "Address Family modifier\n"
7721 "Address Family modifier\n"
7722 "Detailed information on TCP and BGP neighbor connections\n"
7723 "Neighbor to display information about\n"
7724 "Neighbor to display information about\n"
7725 "Display the received routes from neighbor\n")
7726{
paulbb46e942003-10-24 19:02:03 +00007727 struct peer *peer;
paul718e3742002-12-13 20:15:29 +00007728
paulbb46e942003-10-24 19:02:03 +00007729 peer = peer_lookup_in_view (vty, NULL, argv[1]);
7730 if (! peer)
7731 return CMD_WARNING;
7732
7733 if (strncmp (argv[0], "m", 1) == 0)
7734 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
7735
7736 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
paul718e3742002-12-13 20:15:29 +00007737}
7738
7739DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
7740 show_ip_bgp_neighbor_received_prefix_filter_cmd,
7741 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
7742 SHOW_STR
7743 IP_STR
7744 BGP_STR
7745 "Detailed information on TCP and BGP neighbor connections\n"
7746 "Neighbor to display information about\n"
7747 "Neighbor to display information about\n"
7748 "Display information received from a BGP neighbor\n"
7749 "Display the prefixlist filter\n")
7750{
7751 char name[BUFSIZ];
7752 union sockunion *su;
7753 struct peer *peer;
7754 int count;
7755
7756 su = sockunion_str2su (argv[0]);
7757 if (su == NULL)
7758 return CMD_WARNING;
7759
7760 peer = peer_lookup (NULL, su);
7761 if (! peer)
7762 return CMD_WARNING;
7763
7764 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
7765 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
7766 if (count)
7767 {
7768 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
7769 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
7770 }
7771
7772 return CMD_SUCCESS;
7773}
7774
7775DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
7776 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
7777 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
7778 SHOW_STR
7779 IP_STR
7780 BGP_STR
7781 "Address family\n"
7782 "Address Family modifier\n"
7783 "Address Family modifier\n"
7784 "Detailed information on TCP and BGP neighbor connections\n"
7785 "Neighbor to display information about\n"
7786 "Neighbor to display information about\n"
7787 "Display information received from a BGP neighbor\n"
7788 "Display the prefixlist filter\n")
7789{
7790 char name[BUFSIZ];
7791 union sockunion *su;
7792 struct peer *peer;
7793 int count;
7794
7795 su = sockunion_str2su (argv[1]);
7796 if (su == NULL)
7797 return CMD_WARNING;
7798
7799 peer = peer_lookup (NULL, su);
7800 if (! peer)
7801 return CMD_WARNING;
7802
7803 if (strncmp (argv[0], "m", 1) == 0)
7804 {
7805 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
7806 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
7807 if (count)
7808 {
7809 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
7810 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
7811 }
7812 }
7813 else
7814 {
7815 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
7816 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
7817 if (count)
7818 {
7819 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
7820 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
7821 }
7822 }
7823
7824 return CMD_SUCCESS;
7825}
7826
7827
7828#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00007829ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00007830 show_bgp_neighbor_received_routes_cmd,
7831 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
7832 SHOW_STR
7833 BGP_STR
7834 "Detailed information on TCP and BGP neighbor connections\n"
7835 "Neighbor to display information about\n"
7836 "Neighbor to display information about\n"
7837 "Display the received routes from neighbor\n")
paul718e3742002-12-13 20:15:29 +00007838
paulbb46e942003-10-24 19:02:03 +00007839ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00007840 show_bgp_ipv6_neighbor_received_routes_cmd,
7841 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
7842 SHOW_STR
7843 BGP_STR
7844 "Address family\n"
7845 "Detailed information on TCP and BGP neighbor connections\n"
7846 "Neighbor to display information about\n"
7847 "Neighbor to display information about\n"
7848 "Display the received routes from neighbor\n")
7849
7850DEFUN (show_bgp_neighbor_received_prefix_filter,
7851 show_bgp_neighbor_received_prefix_filter_cmd,
7852 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
7853 SHOW_STR
7854 BGP_STR
7855 "Detailed information on TCP and BGP neighbor connections\n"
7856 "Neighbor to display information about\n"
7857 "Neighbor to display information about\n"
7858 "Display information received from a BGP neighbor\n"
7859 "Display the prefixlist filter\n")
7860{
7861 char name[BUFSIZ];
7862 union sockunion *su;
7863 struct peer *peer;
7864 int count;
7865
7866 su = sockunion_str2su (argv[0]);
7867 if (su == NULL)
7868 return CMD_WARNING;
7869
7870 peer = peer_lookup (NULL, su);
7871 if (! peer)
7872 return CMD_WARNING;
7873
7874 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
7875 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
7876 if (count)
7877 {
7878 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
7879 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
7880 }
7881
7882 return CMD_SUCCESS;
7883}
7884
7885ALIAS (show_bgp_neighbor_received_prefix_filter,
7886 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
7887 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
7888 SHOW_STR
7889 BGP_STR
7890 "Address family\n"
7891 "Detailed information on TCP and BGP neighbor connections\n"
7892 "Neighbor to display information about\n"
7893 "Neighbor to display information about\n"
7894 "Display information received from a BGP neighbor\n"
7895 "Display the prefixlist filter\n")
7896
7897/* old command */
paulbb46e942003-10-24 19:02:03 +00007898ALIAS (show_bgp_view_neighbor_received_routes,
paul718e3742002-12-13 20:15:29 +00007899 ipv6_bgp_neighbor_received_routes_cmd,
7900 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
7901 SHOW_STR
7902 IPV6_STR
7903 BGP_STR
7904 "Detailed information on TCP and BGP neighbor connections\n"
7905 "Neighbor to display information about\n"
7906 "Neighbor to display information about\n"
7907 "Display the received routes from neighbor\n")
paul718e3742002-12-13 20:15:29 +00007908
7909/* old command */
7910DEFUN (ipv6_mbgp_neighbor_received_routes,
7911 ipv6_mbgp_neighbor_received_routes_cmd,
7912 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
7913 SHOW_STR
7914 IPV6_STR
7915 MBGP_STR
7916 "Detailed information on TCP and BGP neighbor connections\n"
7917 "Neighbor to display information about\n"
7918 "Neighbor to display information about\n"
7919 "Display the received routes from neighbor\n")
7920{
paulbb46e942003-10-24 19:02:03 +00007921 struct peer *peer;
7922
7923 peer = peer_lookup_in_view (vty, NULL, argv[0]);
7924 if (! peer)
7925 return CMD_WARNING;
7926
7927 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
paul718e3742002-12-13 20:15:29 +00007928}
paulbb46e942003-10-24 19:02:03 +00007929
7930DEFUN (show_bgp_view_neighbor_received_prefix_filter,
7931 show_bgp_view_neighbor_received_prefix_filter_cmd,
7932 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
7933 SHOW_STR
7934 BGP_STR
7935 "BGP view\n"
7936 "View name\n"
7937 "Detailed information on TCP and BGP neighbor connections\n"
7938 "Neighbor to display information about\n"
7939 "Neighbor to display information about\n"
7940 "Display information received from a BGP neighbor\n"
7941 "Display the prefixlist filter\n")
7942{
7943 char name[BUFSIZ];
7944 union sockunion *su;
7945 struct peer *peer;
7946 struct bgp *bgp;
7947 int count;
7948
7949 /* BGP structure lookup. */
7950 bgp = bgp_lookup_by_name (argv[0]);
7951 if (bgp == NULL)
7952 {
7953 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7954 return CMD_WARNING;
7955 }
7956
7957 su = sockunion_str2su (argv[1]);
7958 if (su == NULL)
7959 return CMD_WARNING;
7960
7961 peer = peer_lookup (bgp, su);
7962 if (! peer)
7963 return CMD_WARNING;
7964
7965 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
7966 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
7967 if (count)
7968 {
7969 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
7970 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
7971 }
7972
7973 return CMD_SUCCESS;
7974}
7975
7976ALIAS (show_bgp_view_neighbor_received_prefix_filter,
7977 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
7978 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
7979 SHOW_STR
7980 BGP_STR
7981 "BGP view\n"
7982 "View name\n"
7983 "Address family\n"
7984 "Detailed information on TCP and BGP neighbor connections\n"
7985 "Neighbor to display information about\n"
7986 "Neighbor to display information about\n"
7987 "Display information received from a BGP neighbor\n"
7988 "Display the prefixlist filter\n")
paul718e3742002-12-13 20:15:29 +00007989#endif /* HAVE_IPV6 */
7990
7991void
7992bgp_show_neighbor_route_clean (struct vty *vty)
7993{
7994 union sockunion *su;
7995
7996 su = vty->output_arg;
7997 XFREE (MTYPE_SOCKUNION, su);
7998}
7999
8000int
paulbb46e942003-10-24 19:02:03 +00008001bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008002 safi_t safi, enum bgp_show_type type)
8003{
paul718e3742002-12-13 20:15:29 +00008004 if (! peer || ! peer->afc[afi][safi])
8005 {
8006 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00008007 return CMD_WARNING;
8008 }
8009
paulbb46e942003-10-24 19:02:03 +00008010 vty->output_arg = sockunion_dup (&peer->su);
paul718e3742002-12-13 20:15:29 +00008011 vty->output_clean = bgp_show_neighbor_route_clean;
8012
paulbb46e942003-10-24 19:02:03 +00008013 return bgp_show (vty, peer->bgp, afi, safi, type);
paul718e3742002-12-13 20:15:29 +00008014}
8015
8016DEFUN (show_ip_bgp_neighbor_routes,
8017 show_ip_bgp_neighbor_routes_cmd,
8018 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
8019 SHOW_STR
8020 IP_STR
8021 BGP_STR
8022 "Detailed information on TCP and BGP neighbor connections\n"
8023 "Neighbor to display information about\n"
8024 "Neighbor to display information about\n"
8025 "Display routes learned from neighbor\n")
8026{
paulbb46e942003-10-24 19:02:03 +00008027 struct peer *peer;
8028
8029 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8030 if (! peer)
8031 return CMD_WARNING;
8032
8033 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008034 bgp_show_type_neighbor);
8035}
8036
8037DEFUN (show_ip_bgp_neighbor_flap,
8038 show_ip_bgp_neighbor_flap_cmd,
8039 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
8040 SHOW_STR
8041 IP_STR
8042 BGP_STR
8043 "Detailed information on TCP and BGP neighbor connections\n"
8044 "Neighbor to display information about\n"
8045 "Neighbor to display information about\n"
8046 "Display flap statistics of the routes learned from neighbor\n")
8047{
paulbb46e942003-10-24 19:02:03 +00008048 struct peer *peer;
8049
8050 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8051 if (! peer)
8052 return CMD_WARNING;
8053
8054 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008055 bgp_show_type_flap_neighbor);
8056}
8057
8058DEFUN (show_ip_bgp_neighbor_damp,
8059 show_ip_bgp_neighbor_damp_cmd,
8060 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
8061 SHOW_STR
8062 IP_STR
8063 BGP_STR
8064 "Detailed information on TCP and BGP neighbor connections\n"
8065 "Neighbor to display information about\n"
8066 "Neighbor to display information about\n"
8067 "Display the dampened routes received from neighbor\n")
8068{
paulbb46e942003-10-24 19:02:03 +00008069 struct peer *peer;
8070
8071 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8072 if (! peer)
8073 return CMD_WARNING;
8074
8075 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008076 bgp_show_type_damp_neighbor);
8077}
8078
8079DEFUN (show_ip_bgp_ipv4_neighbor_routes,
8080 show_ip_bgp_ipv4_neighbor_routes_cmd,
8081 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
8082 SHOW_STR
8083 IP_STR
8084 BGP_STR
8085 "Address family\n"
8086 "Address Family modifier\n"
8087 "Address Family modifier\n"
8088 "Detailed information on TCP and BGP neighbor connections\n"
8089 "Neighbor to display information about\n"
8090 "Neighbor to display information about\n"
8091 "Display routes learned from neighbor\n")
8092{
paulbb46e942003-10-24 19:02:03 +00008093 struct peer *peer;
8094
8095 peer = peer_lookup_in_view (vty, NULL, argv[1]);
8096 if (! peer)
8097 return CMD_WARNING;
8098
paul718e3742002-12-13 20:15:29 +00008099 if (strncmp (argv[0], "m", 1) == 0)
paulbb46e942003-10-24 19:02:03 +00008100 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
paul718e3742002-12-13 20:15:29 +00008101 bgp_show_type_neighbor);
8102
paulbb46e942003-10-24 19:02:03 +00008103 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
paul718e3742002-12-13 20:15:29 +00008104 bgp_show_type_neighbor);
8105}
paulbb46e942003-10-24 19:02:03 +00008106
paul718e3742002-12-13 20:15:29 +00008107#ifdef HAVE_IPV6
paulbb46e942003-10-24 19:02:03 +00008108DEFUN (show_bgp_view_neighbor_routes,
8109 show_bgp_view_neighbor_routes_cmd,
8110 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
8111 SHOW_STR
8112 BGP_STR
8113 "BGP view\n"
8114 "BGP view name\n"
8115 "Detailed information on TCP and BGP neighbor connections\n"
8116 "Neighbor to display information about\n"
8117 "Neighbor to display information about\n"
8118 "Display routes learned from neighbor\n")
8119{
8120 struct peer *peer;
8121
8122 if (argc == 2)
8123 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8124 else
8125 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8126
8127 if (! peer)
8128 return CMD_WARNING;
8129
8130 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
8131 bgp_show_type_neighbor);
8132}
8133
8134ALIAS (show_bgp_view_neighbor_routes,
8135 show_bgp_view_ipv6_neighbor_routes_cmd,
8136 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
8137 SHOW_STR
8138 BGP_STR
8139 "BGP view\n"
8140 "BGP view name\n"
8141 "Address family\n"
8142 "Detailed information on TCP and BGP neighbor connections\n"
8143 "Neighbor to display information about\n"
8144 "Neighbor to display information about\n"
8145 "Display routes learned from neighbor\n")
8146
8147DEFUN (show_bgp_view_neighbor_damp,
8148 show_bgp_view_neighbor_damp_cmd,
8149 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
8150 SHOW_STR
8151 BGP_STR
8152 "BGP view\n"
8153 "BGP view name\n"
8154 "Detailed information on TCP and BGP neighbor connections\n"
8155 "Neighbor to display information about\n"
8156 "Neighbor to display information about\n"
8157 "Display the dampened routes received from neighbor\n")
8158{
8159 struct peer *peer;
8160
8161 if (argc == 2)
8162 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8163 else
8164 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8165
8166 if (! peer)
8167 return CMD_WARNING;
8168
8169 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
8170 bgp_show_type_damp_neighbor);
8171}
8172
8173ALIAS (show_bgp_view_neighbor_damp,
8174 show_bgp_view_ipv6_neighbor_damp_cmd,
8175 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
8176 SHOW_STR
8177 BGP_STR
8178 "BGP view\n"
8179 "BGP view name\n"
8180 "Address family\n"
8181 "Detailed information on TCP and BGP neighbor connections\n"
8182 "Neighbor to display information about\n"
8183 "Neighbor to display information about\n"
8184 "Display the dampened routes received from neighbor\n")
8185
8186DEFUN (show_bgp_view_neighbor_flap,
8187 show_bgp_view_neighbor_flap_cmd,
8188 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
8189 SHOW_STR
8190 BGP_STR
8191 "BGP view\n"
8192 "BGP view name\n"
8193 "Detailed information on TCP and BGP neighbor connections\n"
8194 "Neighbor to display information about\n"
8195 "Neighbor to display information about\n"
8196 "Display flap statistics of the routes learned from neighbor\n")
8197{
8198 struct peer *peer;
8199
8200 if (argc == 2)
8201 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
8202 else
8203 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8204
8205 if (! peer)
8206 return CMD_WARNING;
8207
8208 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
8209 bgp_show_type_flap_neighbor);
8210}
8211
8212ALIAS (show_bgp_view_neighbor_flap,
8213 show_bgp_view_ipv6_neighbor_flap_cmd,
8214 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
8215 SHOW_STR
8216 BGP_STR
8217 "BGP view\n"
8218 "BGP view name\n"
8219 "Address family\n"
8220 "Detailed information on TCP and BGP neighbor connections\n"
8221 "Neighbor to display information about\n"
8222 "Neighbor to display information about\n"
8223 "Display flap statistics of the routes learned from neighbor\n")
8224
8225ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00008226 show_bgp_neighbor_routes_cmd,
8227 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
8228 SHOW_STR
8229 BGP_STR
8230 "Detailed information on TCP and BGP neighbor connections\n"
8231 "Neighbor to display information about\n"
8232 "Neighbor to display information about\n"
8233 "Display routes learned from neighbor\n")
paul718e3742002-12-13 20:15:29 +00008234
paulbb46e942003-10-24 19:02:03 +00008235
8236ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00008237 show_bgp_ipv6_neighbor_routes_cmd,
8238 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
8239 SHOW_STR
8240 BGP_STR
8241 "Address family\n"
8242 "Detailed information on TCP and BGP neighbor connections\n"
8243 "Neighbor to display information about\n"
8244 "Neighbor to display information about\n"
8245 "Display routes learned from neighbor\n")
8246
8247/* old command */
paulbb46e942003-10-24 19:02:03 +00008248ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +00008249 ipv6_bgp_neighbor_routes_cmd,
8250 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
8251 SHOW_STR
8252 IPV6_STR
8253 BGP_STR
8254 "Detailed information on TCP and BGP neighbor connections\n"
8255 "Neighbor to display information about\n"
8256 "Neighbor to display information about\n"
8257 "Display routes learned from neighbor\n")
paul718e3742002-12-13 20:15:29 +00008258
8259/* old command */
8260DEFUN (ipv6_mbgp_neighbor_routes,
8261 ipv6_mbgp_neighbor_routes_cmd,
8262 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
8263 SHOW_STR
8264 IPV6_STR
8265 MBGP_STR
8266 "Detailed information on TCP and BGP neighbor connections\n"
8267 "Neighbor to display information about\n"
8268 "Neighbor to display information about\n"
8269 "Display routes learned from neighbor\n")
8270{
paulbb46e942003-10-24 19:02:03 +00008271 struct peer *peer;
8272
8273 peer = peer_lookup_in_view (vty, NULL, argv[0]);
8274 if (! peer)
8275 return CMD_WARNING;
8276
8277 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
paul718e3742002-12-13 20:15:29 +00008278 bgp_show_type_neighbor);
8279}
paulbb46e942003-10-24 19:02:03 +00008280
8281ALIAS (show_bgp_view_neighbor_flap,
8282 show_bgp_neighbor_flap_cmd,
8283 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
8284 SHOW_STR
8285 BGP_STR
8286 "Detailed information on TCP and BGP neighbor connections\n"
8287 "Neighbor to display information about\n"
8288 "Neighbor to display information about\n"
8289 "Display flap statistics of the routes learned from neighbor\n")
8290
8291ALIAS (show_bgp_view_neighbor_flap,
8292 show_bgp_ipv6_neighbor_flap_cmd,
8293 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
8294 SHOW_STR
8295 BGP_STR
8296 "Address family\n"
8297 "Detailed information on TCP and BGP neighbor connections\n"
8298 "Neighbor to display information about\n"
8299 "Neighbor to display information about\n"
8300 "Display flap statistics of the routes learned from neighbor\n")
8301
8302ALIAS (show_bgp_view_neighbor_damp,
8303 show_bgp_neighbor_damp_cmd,
8304 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
8305 SHOW_STR
8306 BGP_STR
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 dampened routes received from neighbor\n")
8311
8312ALIAS (show_bgp_view_neighbor_damp,
8313 show_bgp_ipv6_neighbor_damp_cmd,
8314 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
8315 SHOW_STR
8316 BGP_STR
8317 "Address family\n"
8318 "Detailed information on TCP and BGP neighbor connections\n"
8319 "Neighbor to display information about\n"
8320 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +00008321 "Display the dampened routes received from neighbor\n")
paul718e3742002-12-13 20:15:29 +00008322#endif /* HAVE_IPV6 */
8323
8324struct bgp_table *bgp_distance_table;
8325
8326struct bgp_distance
8327{
8328 /* Distance value for the IP source prefix. */
8329 u_char distance;
8330
8331 /* Name of the access-list to be matched. */
8332 char *access_list;
8333};
8334
8335struct bgp_distance *
8336bgp_distance_new ()
8337{
8338 struct bgp_distance *new;
8339 new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
8340 memset (new, 0, sizeof (struct bgp_distance));
8341 return new;
8342}
8343
8344void
8345bgp_distance_free (struct bgp_distance *bdistance)
8346{
8347 XFREE (MTYPE_BGP_DISTANCE, bdistance);
8348}
8349
8350int
8351bgp_distance_set (struct vty *vty, char *distance_str, char *ip_str,
8352 char *access_list_str)
8353{
8354 int ret;
8355 struct prefix_ipv4 p;
8356 u_char distance;
8357 struct bgp_node *rn;
8358 struct bgp_distance *bdistance;
8359
8360 ret = str2prefix_ipv4 (ip_str, &p);
8361 if (ret == 0)
8362 {
8363 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
8364 return CMD_WARNING;
8365 }
8366
8367 distance = atoi (distance_str);
8368
8369 /* Get BGP distance node. */
8370 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
8371 if (rn->info)
8372 {
8373 bdistance = rn->info;
8374 bgp_unlock_node (rn);
8375 }
8376 else
8377 {
8378 bdistance = bgp_distance_new ();
8379 rn->info = bdistance;
8380 }
8381
8382 /* Set distance value. */
8383 bdistance->distance = distance;
8384
8385 /* Reset access-list configuration. */
8386 if (bdistance->access_list)
8387 {
8388 free (bdistance->access_list);
8389 bdistance->access_list = NULL;
8390 }
8391 if (access_list_str)
8392 bdistance->access_list = strdup (access_list_str);
8393
8394 return CMD_SUCCESS;
8395}
8396
8397int
8398bgp_distance_unset (struct vty *vty, char *distance_str, char *ip_str,
8399 char *access_list_str)
8400{
8401 int ret;
8402 struct prefix_ipv4 p;
8403 u_char distance;
8404 struct bgp_node *rn;
8405 struct bgp_distance *bdistance;
8406
8407 ret = str2prefix_ipv4 (ip_str, &p);
8408 if (ret == 0)
8409 {
8410 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
8411 return CMD_WARNING;
8412 }
8413
8414 distance = atoi (distance_str);
8415
8416 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
8417 if (! rn)
8418 {
8419 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
8420 return CMD_WARNING;
8421 }
8422
8423 bdistance = rn->info;
8424
8425 if (bdistance->access_list)
8426 free (bdistance->access_list);
8427 bgp_distance_free (bdistance);
8428
8429 rn->info = NULL;
8430 bgp_unlock_node (rn);
8431 bgp_unlock_node (rn);
8432
8433 return CMD_SUCCESS;
8434}
8435
8436void
8437bgp_distance_reset ()
8438{
8439 struct bgp_node *rn;
8440 struct bgp_distance *bdistance;
8441
8442 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
8443 if ((bdistance = rn->info) != NULL)
8444 {
8445 if (bdistance->access_list)
8446 free (bdistance->access_list);
8447 bgp_distance_free (bdistance);
8448 rn->info = NULL;
8449 bgp_unlock_node (rn);
8450 }
8451}
8452
8453/* Apply BGP information to distance method. */
8454u_char
8455bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
8456{
8457 struct bgp_node *rn;
8458 struct prefix_ipv4 q;
8459 struct peer *peer;
8460 struct bgp_distance *bdistance;
8461 struct access_list *alist;
8462 struct bgp_static *bgp_static;
8463
8464 if (! bgp)
8465 return 0;
8466
8467 if (p->family != AF_INET)
8468 return 0;
8469
8470 peer = rinfo->peer;
8471
8472 if (peer->su.sa.sa_family != AF_INET)
8473 return 0;
8474
8475 memset (&q, 0, sizeof (struct prefix_ipv4));
8476 q.family = AF_INET;
8477 q.prefix = peer->su.sin.sin_addr;
8478 q.prefixlen = IPV4_MAX_BITLEN;
8479
8480 /* Check source address. */
8481 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
8482 if (rn)
8483 {
8484 bdistance = rn->info;
8485 bgp_unlock_node (rn);
8486
8487 if (bdistance->access_list)
8488 {
8489 alist = access_list_lookup (AFI_IP, bdistance->access_list);
8490 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
8491 return bdistance->distance;
8492 }
8493 else
8494 return bdistance->distance;
8495 }
8496
8497 /* Backdoor check. */
8498 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
8499 if (rn)
8500 {
8501 bgp_static = rn->info;
8502 bgp_unlock_node (rn);
8503
8504 if (bgp_static->backdoor)
8505 {
8506 if (bgp->distance_local)
8507 return bgp->distance_local;
8508 else
8509 return ZEBRA_IBGP_DISTANCE_DEFAULT;
8510 }
8511 }
8512
8513 if (peer_sort (peer) == BGP_PEER_EBGP)
8514 {
8515 if (bgp->distance_ebgp)
8516 return bgp->distance_ebgp;
8517 return ZEBRA_EBGP_DISTANCE_DEFAULT;
8518 }
8519 else
8520 {
8521 if (bgp->distance_ibgp)
8522 return bgp->distance_ibgp;
8523 return ZEBRA_IBGP_DISTANCE_DEFAULT;
8524 }
8525}
8526
8527DEFUN (bgp_distance,
8528 bgp_distance_cmd,
8529 "distance bgp <1-255> <1-255> <1-255>",
8530 "Define an administrative distance\n"
8531 "BGP distance\n"
8532 "Distance for routes external to the AS\n"
8533 "Distance for routes internal to the AS\n"
8534 "Distance for local routes\n")
8535{
8536 struct bgp *bgp;
8537
8538 bgp = vty->index;
8539
8540 bgp->distance_ebgp = atoi (argv[0]);
8541 bgp->distance_ibgp = atoi (argv[1]);
8542 bgp->distance_local = atoi (argv[2]);
8543 return CMD_SUCCESS;
8544}
8545
8546DEFUN (no_bgp_distance,
8547 no_bgp_distance_cmd,
8548 "no distance bgp <1-255> <1-255> <1-255>",
8549 NO_STR
8550 "Define an administrative distance\n"
8551 "BGP distance\n"
8552 "Distance for routes external to the AS\n"
8553 "Distance for routes internal to the AS\n"
8554 "Distance for local routes\n")
8555{
8556 struct bgp *bgp;
8557
8558 bgp = vty->index;
8559
8560 bgp->distance_ebgp= 0;
8561 bgp->distance_ibgp = 0;
8562 bgp->distance_local = 0;
8563 return CMD_SUCCESS;
8564}
8565
8566ALIAS (no_bgp_distance,
8567 no_bgp_distance2_cmd,
8568 "no distance bgp",
8569 NO_STR
8570 "Define an administrative distance\n"
8571 "BGP distance\n")
8572
8573DEFUN (bgp_distance_source,
8574 bgp_distance_source_cmd,
8575 "distance <1-255> A.B.C.D/M",
8576 "Define an administrative distance\n"
8577 "Administrative distance\n"
8578 "IP source prefix\n")
8579{
8580 bgp_distance_set (vty, argv[0], argv[1], NULL);
8581 return CMD_SUCCESS;
8582}
8583
8584DEFUN (no_bgp_distance_source,
8585 no_bgp_distance_source_cmd,
8586 "no distance <1-255> A.B.C.D/M",
8587 NO_STR
8588 "Define an administrative distance\n"
8589 "Administrative distance\n"
8590 "IP source prefix\n")
8591{
8592 bgp_distance_unset (vty, argv[0], argv[1], NULL);
8593 return CMD_SUCCESS;
8594}
8595
8596DEFUN (bgp_distance_source_access_list,
8597 bgp_distance_source_access_list_cmd,
8598 "distance <1-255> A.B.C.D/M WORD",
8599 "Define an administrative distance\n"
8600 "Administrative distance\n"
8601 "IP source prefix\n"
8602 "Access list name\n")
8603{
8604 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
8605 return CMD_SUCCESS;
8606}
8607
8608DEFUN (no_bgp_distance_source_access_list,
8609 no_bgp_distance_source_access_list_cmd,
8610 "no distance <1-255> A.B.C.D/M WORD",
8611 NO_STR
8612 "Define an administrative distance\n"
8613 "Administrative distance\n"
8614 "IP source prefix\n"
8615 "Access list name\n")
8616{
8617 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
8618 return CMD_SUCCESS;
8619}
8620
8621DEFUN (bgp_damp_set,
8622 bgp_damp_set_cmd,
8623 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
8624 "BGP Specific commands\n"
8625 "Enable route-flap dampening\n"
8626 "Half-life time for the penalty\n"
8627 "Value to start reusing a route\n"
8628 "Value to start suppressing a route\n"
8629 "Maximum duration to suppress a stable route\n")
8630{
8631 struct bgp *bgp;
8632 int half = DEFAULT_HALF_LIFE * 60;
8633 int reuse = DEFAULT_REUSE;
8634 int suppress = DEFAULT_SUPPRESS;
8635 int max = 4 * half;
8636
8637 if (argc == 4)
8638 {
8639 half = atoi (argv[0]) * 60;
8640 reuse = atoi (argv[1]);
8641 suppress = atoi (argv[2]);
8642 max = atoi (argv[3]) * 60;
8643 }
8644 else if (argc == 1)
8645 {
8646 half = atoi (argv[0]) * 60;
8647 max = 4 * half;
8648 }
8649
8650 bgp = vty->index;
8651 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
8652 half, reuse, suppress, max);
8653}
8654
8655ALIAS (bgp_damp_set,
8656 bgp_damp_set2_cmd,
8657 "bgp dampening <1-45>",
8658 "BGP Specific commands\n"
8659 "Enable route-flap dampening\n"
8660 "Half-life time for the penalty\n")
8661
8662ALIAS (bgp_damp_set,
8663 bgp_damp_set3_cmd,
8664 "bgp dampening",
8665 "BGP Specific commands\n"
8666 "Enable route-flap dampening\n")
8667
8668DEFUN (bgp_damp_unset,
8669 bgp_damp_unset_cmd,
8670 "no bgp dampening",
8671 NO_STR
8672 "BGP Specific commands\n"
8673 "Enable route-flap dampening\n")
8674{
8675 struct bgp *bgp;
8676
8677 bgp = vty->index;
8678 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
8679}
8680
8681ALIAS (bgp_damp_unset,
8682 bgp_damp_unset2_cmd,
8683 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
8684 NO_STR
8685 "BGP Specific commands\n"
8686 "Enable route-flap dampening\n"
8687 "Half-life time for the penalty\n"
8688 "Value to start reusing a route\n"
8689 "Value to start suppressing a route\n"
8690 "Maximum duration to suppress a stable route\n")
8691
8692DEFUN (show_ip_bgp_dampened_paths,
8693 show_ip_bgp_dampened_paths_cmd,
8694 "show ip bgp dampened-paths",
8695 SHOW_STR
8696 IP_STR
8697 BGP_STR
8698 "Display paths suppressed due to dampening\n")
8699{
8700 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths);
8701}
8702
8703DEFUN (show_ip_bgp_flap_statistics,
8704 show_ip_bgp_flap_statistics_cmd,
8705 "show ip bgp flap-statistics",
8706 SHOW_STR
8707 IP_STR
8708 BGP_STR
8709 "Display flap statistics of routes\n")
8710{
8711 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_flap_statistics);
8712}
8713
8714/* Display specified route of BGP table. */
8715int
8716bgp_clear_damp_route (struct vty *vty, char *view_name, char *ip_str,
8717 afi_t afi, safi_t safi, struct prefix_rd *prd,
8718 int prefix_check)
8719{
8720 int ret;
8721 struct prefix match;
8722 struct bgp_node *rn;
8723 struct bgp_node *rm;
8724 struct bgp_info *ri;
8725 struct bgp_info *ri_temp;
8726 struct bgp *bgp;
8727 struct bgp_table *table;
8728
8729 /* BGP structure lookup. */
8730 if (view_name)
8731 {
8732 bgp = bgp_lookup_by_name (view_name);
8733 if (bgp == NULL)
8734 {
8735 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
8736 return CMD_WARNING;
8737 }
8738 }
8739 else
8740 {
8741 bgp = bgp_get_default ();
8742 if (bgp == NULL)
8743 {
8744 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
8745 return CMD_WARNING;
8746 }
8747 }
8748
8749 /* Check IP address argument. */
8750 ret = str2prefix (ip_str, &match);
8751 if (! ret)
8752 {
8753 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
8754 return CMD_WARNING;
8755 }
8756
8757 match.family = afi2family (afi);
8758
8759 if (safi == SAFI_MPLS_VPN)
8760 {
8761 for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn))
8762 {
8763 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
8764 continue;
8765
8766 if ((table = rn->info) != NULL)
8767 if ((rm = bgp_node_match (table, &match)) != NULL)
8768 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
8769 {
8770 ri = rm->info;
8771 while (ri)
8772 {
8773 if (ri->damp_info)
8774 {
8775 ri_temp = ri->next;
8776 bgp_damp_info_free (ri->damp_info, 1);
8777 ri = ri_temp;
8778 }
8779 else
8780 ri = ri->next;
8781 }
8782 }
8783 }
8784 }
8785 else
8786 {
8787 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
8788 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
8789 {
8790 ri = rn->info;
8791 while (ri)
8792 {
8793 if (ri->damp_info)
8794 {
8795 ri_temp = ri->next;
8796 bgp_damp_info_free (ri->damp_info, 1);
8797 ri = ri_temp;
8798 }
8799 else
8800 ri = ri->next;
8801 }
8802 }
8803 }
8804
8805 return CMD_SUCCESS;
8806}
8807
8808DEFUN (clear_ip_bgp_dampening,
8809 clear_ip_bgp_dampening_cmd,
8810 "clear ip bgp dampening",
8811 CLEAR_STR
8812 IP_STR
8813 BGP_STR
8814 "Clear route flap dampening information\n")
8815{
8816 bgp_damp_info_clean ();
8817 return CMD_SUCCESS;
8818}
8819
8820DEFUN (clear_ip_bgp_dampening_prefix,
8821 clear_ip_bgp_dampening_prefix_cmd,
8822 "clear ip bgp dampening A.B.C.D/M",
8823 CLEAR_STR
8824 IP_STR
8825 BGP_STR
8826 "Clear route flap dampening information\n"
8827 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8828{
8829 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
8830 SAFI_UNICAST, NULL, 1);
8831}
8832
8833DEFUN (clear_ip_bgp_dampening_address,
8834 clear_ip_bgp_dampening_address_cmd,
8835 "clear ip bgp dampening A.B.C.D",
8836 CLEAR_STR
8837 IP_STR
8838 BGP_STR
8839 "Clear route flap dampening information\n"
8840 "Network to clear damping information\n")
8841{
8842 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
8843 SAFI_UNICAST, NULL, 0);
8844}
8845
8846DEFUN (clear_ip_bgp_dampening_address_mask,
8847 clear_ip_bgp_dampening_address_mask_cmd,
8848 "clear ip bgp dampening A.B.C.D A.B.C.D",
8849 CLEAR_STR
8850 IP_STR
8851 BGP_STR
8852 "Clear route flap dampening information\n"
8853 "Network to clear damping information\n"
8854 "Network mask\n")
8855{
8856 int ret;
8857 char prefix_str[BUFSIZ];
8858
8859 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
8860 if (! ret)
8861 {
8862 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
8863 return CMD_WARNING;
8864 }
8865
8866 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
8867 SAFI_UNICAST, NULL, 0);
8868}
8869
8870int
8871bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
8872 afi_t afi, safi_t safi, int *write)
8873{
8874 struct bgp_node *prn;
8875 struct bgp_node *rn;
8876 struct bgp_table *table;
8877 struct prefix *p;
8878 struct prefix_rd *prd;
8879 struct bgp_static *bgp_static;
8880 u_int32_t label;
8881 char buf[SU_ADDRSTRLEN];
8882 char rdbuf[RD_ADDRSTRLEN];
8883
8884 /* Network configuration. */
8885 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
8886 if ((table = prn->info) != NULL)
8887 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
8888 if ((bgp_static = rn->info) != NULL)
8889 {
8890 p = &rn->p;
8891 prd = (struct prefix_rd *) &prn->p;
8892
8893 /* "address-family" display. */
8894 bgp_config_write_family_header (vty, afi, safi, write);
8895
8896 /* "network" configuration display. */
8897 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
8898 label = decode_label (bgp_static->tag);
8899
8900 vty_out (vty, " network %s/%d rd %s tag %d",
8901 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
8902 p->prefixlen,
8903 rdbuf, label);
8904 vty_out (vty, "%s", VTY_NEWLINE);
8905 }
8906 return 0;
8907}
8908
8909/* Configuration of static route announcement and aggregate
8910 information. */
8911int
8912bgp_config_write_network (struct vty *vty, struct bgp *bgp,
8913 afi_t afi, safi_t safi, int *write)
8914{
8915 struct bgp_node *rn;
8916 struct prefix *p;
8917 struct bgp_static *bgp_static;
8918 struct bgp_aggregate *bgp_aggregate;
8919 char buf[SU_ADDRSTRLEN];
8920
8921 if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
8922 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
8923
8924 /* Network configuration. */
8925 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
8926 if ((bgp_static = rn->info) != NULL)
8927 {
8928 p = &rn->p;
8929
8930 /* "address-family" display. */
8931 bgp_config_write_family_header (vty, afi, safi, write);
8932
8933 /* "network" configuration display. */
8934 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
8935 {
8936 u_int32_t destination;
8937 struct in_addr netmask;
8938
8939 destination = ntohl (p->u.prefix4.s_addr);
8940 masklen2ip (p->prefixlen, &netmask);
8941 vty_out (vty, " network %s",
8942 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
8943
8944 if ((IN_CLASSC (destination) && p->prefixlen == 24)
8945 || (IN_CLASSB (destination) && p->prefixlen == 16)
8946 || (IN_CLASSA (destination) && p->prefixlen == 8)
8947 || p->u.prefix4.s_addr == 0)
8948 {
8949 /* Natural mask is not display. */
8950 }
8951 else
8952 vty_out (vty, " mask %s", inet_ntoa (netmask));
8953 }
8954 else
8955 {
8956 vty_out (vty, " network %s/%d",
8957 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
8958 p->prefixlen);
8959 }
8960
8961 if (bgp_static->rmap.name)
8962 vty_out (vty, " route-map %s", bgp_static->rmap.name);
8963 else if (bgp_static->backdoor)
8964 vty_out (vty, " backdoor");
8965
8966 vty_out (vty, "%s", VTY_NEWLINE);
8967 }
8968
8969 /* Aggregate-address configuration. */
8970 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
8971 if ((bgp_aggregate = rn->info) != NULL)
8972 {
8973 p = &rn->p;
8974
8975 /* "address-family" display. */
8976 bgp_config_write_family_header (vty, afi, safi, write);
8977
8978 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
8979 {
8980 struct in_addr netmask;
8981
8982 masklen2ip (p->prefixlen, &netmask);
8983 vty_out (vty, " aggregate-address %s %s",
8984 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
8985 inet_ntoa (netmask));
8986 }
8987 else
8988 {
8989 vty_out (vty, " aggregate-address %s/%d",
8990 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
8991 p->prefixlen);
8992 }
8993
8994 if (bgp_aggregate->as_set)
8995 vty_out (vty, " as-set");
8996
8997 if (bgp_aggregate->summary_only)
8998 vty_out (vty, " summary-only");
8999
9000 vty_out (vty, "%s", VTY_NEWLINE);
9001 }
9002
9003 return 0;
9004}
9005
9006int
9007bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
9008{
9009 struct bgp_node *rn;
9010 struct bgp_distance *bdistance;
9011
9012 /* Distance configuration. */
9013 if (bgp->distance_ebgp
9014 && bgp->distance_ibgp
9015 && bgp->distance_local
9016 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
9017 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
9018 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
9019 vty_out (vty, " distance bgp %d %d %d%s",
9020 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
9021 VTY_NEWLINE);
9022
9023 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
9024 if ((bdistance = rn->info) != NULL)
9025 {
9026 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
9027 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
9028 bdistance->access_list ? bdistance->access_list : "",
9029 VTY_NEWLINE);
9030 }
9031
9032 return 0;
9033}
9034
9035/* Allocate routing table structure and install commands. */
9036void
9037bgp_route_init ()
9038{
9039 /* Init BGP distance table. */
9040 bgp_distance_table = bgp_table_init ();
9041
9042 /* IPv4 BGP commands. */
9043 install_element (BGP_NODE, &bgp_network_cmd);
9044 install_element (BGP_NODE, &bgp_network_mask_cmd);
9045 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
9046 install_element (BGP_NODE, &bgp_network_route_map_cmd);
9047 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
9048 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
9049 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
9050 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
9051 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
9052 install_element (BGP_NODE, &no_bgp_network_cmd);
9053 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
9054 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
9055 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
9056 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
9057 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
9058 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
9059 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
9060 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
9061
9062 install_element (BGP_NODE, &aggregate_address_cmd);
9063 install_element (BGP_NODE, &aggregate_address_mask_cmd);
9064 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
9065 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
9066 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
9067 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
9068 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
9069 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
9070 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
9071 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
9072 install_element (BGP_NODE, &no_aggregate_address_cmd);
9073 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
9074 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
9075 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
9076 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
9077 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
9078 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
9079 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
9080 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
9081 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
9082
9083 /* IPv4 unicast configuration. */
9084 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
9085 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
9086 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
9087 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
9088 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
9089 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
9090 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
9091 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
9092 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
9093 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
9094 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
9095 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
9096 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
9097 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
9098 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
9099 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
9100 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
9101 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
9102 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
9103 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
9104 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
9105 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
9106 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
9107 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
9108 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
9109 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
9110 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
9111 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
9112 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
9113 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
9114 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
9115 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
9116
9117 /* IPv4 multicast configuration. */
9118 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
9119 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
9120 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
9121 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
9122 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
9123 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
9124 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
9125 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
9126 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
9127 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
9128 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
9129 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
9130 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
9131 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
9132 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
9133 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
9134 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
9135 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
9136 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
9137 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
9138 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
9139 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
9140 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
9141 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
9142 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
9143 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
9144 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
9145 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
9146 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
9147 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
9148 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
9149 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
9150
9151 install_element (VIEW_NODE, &show_ip_bgp_cmd);
9152 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
9153 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
9154 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
9155 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
9156 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
9157 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
9158 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
9159 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
9160 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
9161 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
9162 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
9163 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
9164 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
9165 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
9166 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
9167 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
9168 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
9169 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
9170 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
9171 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
9172 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
9173 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
9174 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
9175 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
9176 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
9177 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
9178 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
9179 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
9180 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
9181 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
9182 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
9183 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
9184 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
9185 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
9186 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
9187 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
9188 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
9189 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
9190 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
9191 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
9192 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
9193 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
9194 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
9195 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
9196 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
9197 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
9198 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
9199 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
9200 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
9201 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
9202 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
9203 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
9204 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
9205 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
9206 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
9207 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
9208 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
9209 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
9210 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
9211 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
9212 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
9213 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
9214 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
9215 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
9216 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
9217 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
9218
9219 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
9220 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
9221 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
9222 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
9223 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
9224 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
9225 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
9226 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
9227 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
9228 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
9229 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
9230 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
9231 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
9232 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
9233 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
9234 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
9235 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
9236 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
9237 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
9238 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
9239 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
9240 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
9241 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
9242 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
9243 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
9244 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
9245 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
9246 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
9247 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
9248 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
9249 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
9250 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
9251 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
9252 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
9253 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
9254 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
9255 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
9256 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
9257 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
9258 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
9259 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
9260 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
9261 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
9262 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
9263 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
9264 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
9265 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
9266 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
9267 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
9268 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
9269 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
9270 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
9271 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
9272 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
9273 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
9274 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
9275 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
9276 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
9277 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
9278 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
9279 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
9280 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
9281 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
9282 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
9283 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
9284 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
9285 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
9286
9287 /* BGP dampening clear commands */
9288 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
9289 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
9290 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
9291 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
9292
9293#ifdef HAVE_IPV6
9294 /* New config IPv6 BGP commands. */
9295 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
9296 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
9297 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
9298 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
9299
9300 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
9301 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
9302 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
9303 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
9304
9305 /* Old config IPv6 BGP commands. */
9306 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
9307 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
9308
9309 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
9310 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
9311 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
9312 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
9313
9314 install_element (VIEW_NODE, &show_bgp_cmd);
9315 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
9316 install_element (VIEW_NODE, &show_bgp_route_cmd);
9317 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
9318 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
9319 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
9320 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
9321 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
9322 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
9323 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
9324 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
9325 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
9326 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
9327 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
9328 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
9329 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
9330 install_element (VIEW_NODE, &show_bgp_community_cmd);
9331 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
9332 install_element (VIEW_NODE, &show_bgp_community2_cmd);
9333 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
9334 install_element (VIEW_NODE, &show_bgp_community3_cmd);
9335 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
9336 install_element (VIEW_NODE, &show_bgp_community4_cmd);
9337 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
9338 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
9339 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
9340 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
9341 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
9342 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
9343 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
9344 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
9345 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
9346 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
9347 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
9348 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
9349 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
9350 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
9351 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
9352 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
9353 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
9354 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
9355 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
9356 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
9357 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
9358 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
9359 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +00009360 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
9361 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
9362 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
9363 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
9364 install_element (VIEW_NODE, &show_bgp_view_cmd);
9365 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
9366 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
9367 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
9368 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
9369 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
9370 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
9371 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
9372 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
9373 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
9374 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
9375 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
9376 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
9377 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
9378 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
9379 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
9380 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
9381 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
paul718e3742002-12-13 20:15:29 +00009382
9383 install_element (ENABLE_NODE, &show_bgp_cmd);
9384 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
9385 install_element (ENABLE_NODE, &show_bgp_route_cmd);
9386 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
9387 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
9388 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
9389 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
9390 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
9391 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
9392 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
9393 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
9394 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
9395 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
9396 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
9397 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
9398 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
9399 install_element (ENABLE_NODE, &show_bgp_community_cmd);
9400 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
9401 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
9402 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
9403 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
9404 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
9405 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
9406 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
9407 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
9408 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
9409 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
9410 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
9411 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
9412 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
9413 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
9414 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
9415 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
9416 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
9417 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
9418 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
9419 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
9420 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
9421 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
9422 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
9423 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
9424 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
9425 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
9426 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
9427 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
9428 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +00009429 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
9430 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
9431 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
9432 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
9433 install_element (ENABLE_NODE, &show_bgp_view_cmd);
9434 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
9435 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
9436 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
9437 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
9438 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
9439 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
9440 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
9441 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
9442 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
9443 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
9444 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
9445 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
9446 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
9447 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
9448 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
9449 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
9450 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
paul718e3742002-12-13 20:15:29 +00009451
9452 /* old command */
9453 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
9454 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
9455 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
9456 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
9457 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
9458 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
9459 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
9460 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
9461 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
9462 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
9463 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
9464 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
9465 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
9466 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
9467 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
9468 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
9469 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
9470 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
9471 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
9472 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
9473 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
9474 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
9475 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
9476 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
9477 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
9478 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
9479 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
9480 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
9481 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
9482 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
9483 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
9484 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
9485 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
9486 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
9487 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
9488 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
paulbb46e942003-10-24 19:02:03 +00009489
paul718e3742002-12-13 20:15:29 +00009490 /* old command */
9491 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
9492 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
9493 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
9494 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
9495 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
9496 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
9497 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
9498 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
9499 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
9500 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
9501 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
9502 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
9503 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
9504 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
9505 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
9506 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
9507 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
9508 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
9509 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
9510 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
9511 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
9512 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
9513 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
9514 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
9515 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
9516 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
9517 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
9518 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
9519 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
9520 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
9521 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
9522 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
9523 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
9524 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
9525 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
9526 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
9527
9528 /* old command */
9529 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
9530 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
9531 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
9532 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
9533
9534 /* old command */
9535 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
9536 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
9537 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
9538 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
9539
9540 /* old command */
9541 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
9542 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
9543 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
9544 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
9545#endif /* HAVE_IPV6 */
9546
9547 install_element (BGP_NODE, &bgp_distance_cmd);
9548 install_element (BGP_NODE, &no_bgp_distance_cmd);
9549 install_element (BGP_NODE, &no_bgp_distance2_cmd);
9550 install_element (BGP_NODE, &bgp_distance_source_cmd);
9551 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
9552 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
9553 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
9554
9555 install_element (BGP_NODE, &bgp_damp_set_cmd);
9556 install_element (BGP_NODE, &bgp_damp_set2_cmd);
9557 install_element (BGP_NODE, &bgp_damp_set3_cmd);
9558 install_element (BGP_NODE, &bgp_damp_unset_cmd);
9559 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
9560 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
9561 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
9562 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
9563 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
9564 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
9565}