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