blob: f99045a8483a0cb3d478499309e3213a2013e95e [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"
paul200df112005-06-01 11:17:05 +000036#include "workqueue.h"
paul718e3742002-12-13 20:15:29 +000037
38#include "bgpd/bgpd.h"
39#include "bgpd/bgp_table.h"
40#include "bgpd/bgp_route.h"
41#include "bgpd/bgp_attr.h"
42#include "bgpd/bgp_debug.h"
43#include "bgpd/bgp_aspath.h"
44#include "bgpd/bgp_regex.h"
45#include "bgpd/bgp_community.h"
46#include "bgpd/bgp_ecommunity.h"
47#include "bgpd/bgp_clist.h"
48#include "bgpd/bgp_packet.h"
49#include "bgpd/bgp_filter.h"
50#include "bgpd/bgp_fsm.h"
51#include "bgpd/bgp_mplsvpn.h"
52#include "bgpd/bgp_nexthop.h"
53#include "bgpd/bgp_damp.h"
54#include "bgpd/bgp_advertise.h"
55#include "bgpd/bgp_zebra.h"
hasso0a486e52005-02-01 20:57:17 +000056#include "bgpd/bgp_vty.h"
Josh Bailey96450fa2011-07-20 20:45:12 -070057#include "bgpd/bgp_mpath.h"
paul718e3742002-12-13 20:15:29 +000058
59/* Extern from bgp_dump.c */
Stephen Hemmingerdde72582009-05-08 15:19:07 -070060extern const char *bgp_origin_str[];
61extern const char *bgp_origin_long_str[];
David Lamparter6b0655a2014-06-04 06:53:35 +020062
paul94f2b392005-06-28 12:44:16 +000063static struct bgp_node *
paulfee0f4c2004-09-13 05:12:46 +000064bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
paul718e3742002-12-13 20:15:29 +000065 struct prefix_rd *prd)
66{
67 struct bgp_node *rn;
68 struct bgp_node *prn = NULL;
Paul Jakmada5b30f2006-05-08 14:37:17 +000069
70 assert (table);
71 if (!table)
72 return NULL;
73
Lou Berger298cc2f2016-01-12 13:42:02 -050074 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000075 {
paulfee0f4c2004-09-13 05:12:46 +000076 prn = bgp_node_get (table, (struct prefix *) prd);
paul718e3742002-12-13 20:15:29 +000077
78 if (prn->info == NULL)
Paul Jakma64e580a2006-02-21 01:09:01 +000079 prn->info = bgp_table_init (afi, safi);
paul718e3742002-12-13 20:15:29 +000080 else
81 bgp_unlock_node (prn);
82 table = prn->info;
83 }
paul718e3742002-12-13 20:15:29 +000084
85 rn = bgp_node_get (table, p);
86
Lou Berger298cc2f2016-01-12 13:42:02 -050087 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000088 rn->prn = prn;
89
90 return rn;
91}
David Lamparter6b0655a2014-06-04 06:53:35 +020092
Paul Jakmafb982c22007-05-04 20:15:47 +000093/* Allocate bgp_info_extra */
94static struct bgp_info_extra *
95bgp_info_extra_new (void)
96{
97 struct bgp_info_extra *new;
98 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra));
99 return new;
100}
101
102static void
103bgp_info_extra_free (struct bgp_info_extra **extra)
104{
105 if (extra && *extra)
106 {
107 if ((*extra)->damp_info)
108 bgp_damp_info_free ((*extra)->damp_info, 0);
109
110 (*extra)->damp_info = NULL;
111
112 XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra);
113
114 *extra = NULL;
115 }
116}
117
118/* Get bgp_info extra information for the given bgp_info, lazy allocated
119 * if required.
120 */
121struct bgp_info_extra *
122bgp_info_extra_get (struct bgp_info *ri)
123{
124 if (!ri->extra)
125 ri->extra = bgp_info_extra_new();
126 return ri->extra;
127}
128
paul718e3742002-12-13 20:15:29 +0000129/* Allocate new bgp info structure. */
paul200df112005-06-01 11:17:05 +0000130static struct bgp_info *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -0800131bgp_info_new (void)
paul718e3742002-12-13 20:15:29 +0000132{
Stephen Hemminger393deb92008-08-18 14:13:29 -0700133 return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
paul718e3742002-12-13 20:15:29 +0000134}
135
136/* Free bgp route information. */
paul200df112005-06-01 11:17:05 +0000137static void
paul718e3742002-12-13 20:15:29 +0000138bgp_info_free (struct bgp_info *binfo)
139{
140 if (binfo->attr)
Paul Jakmaf6f434b2010-11-23 21:28:03 +0000141 bgp_attr_unintern (&binfo->attr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000142
143 bgp_info_extra_free (&binfo->extra);
Josh Baileyde8d5df2011-07-20 20:46:01 -0700144 bgp_info_mpath_free (&binfo->mpath);
paul718e3742002-12-13 20:15:29 +0000145
paul200df112005-06-01 11:17:05 +0000146 peer_unlock (binfo->peer); /* bgp_info peer reference */
147
paul718e3742002-12-13 20:15:29 +0000148 XFREE (MTYPE_BGP_ROUTE, binfo);
149}
150
paul200df112005-06-01 11:17:05 +0000151struct bgp_info *
152bgp_info_lock (struct bgp_info *binfo)
153{
154 binfo->lock++;
155 return binfo;
156}
157
158struct bgp_info *
159bgp_info_unlock (struct bgp_info *binfo)
160{
161 assert (binfo && binfo->lock > 0);
162 binfo->lock--;
163
164 if (binfo->lock == 0)
165 {
166#if 0
167 zlog_debug ("%s: unlocked and freeing", __func__);
168 zlog_backtrace (LOG_DEBUG);
169#endif
170 bgp_info_free (binfo);
171 return NULL;
172 }
173
174#if 0
175 if (binfo->lock == 1)
176 {
177 zlog_debug ("%s: unlocked to 1", __func__);
178 zlog_backtrace (LOG_DEBUG);
179 }
180#endif
181
182 return binfo;
183}
184
paul718e3742002-12-13 20:15:29 +0000185void
186bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
187{
188 struct bgp_info *top;
189
190 top = rn->info;
paul200df112005-06-01 11:17:05 +0000191
paul718e3742002-12-13 20:15:29 +0000192 ri->next = rn->info;
193 ri->prev = NULL;
194 if (top)
195 top->prev = ri;
196 rn->info = ri;
paul200df112005-06-01 11:17:05 +0000197
198 bgp_info_lock (ri);
199 bgp_lock_node (rn);
200 peer_lock (ri->peer); /* bgp_info peer reference */
paul718e3742002-12-13 20:15:29 +0000201}
202
paulb40d9392005-08-22 22:34:41 +0000203/* Do the actual removal of info from RIB, for use by bgp_process
204 completion callback *only* */
205static void
206bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri)
paul718e3742002-12-13 20:15:29 +0000207{
208 if (ri->next)
209 ri->next->prev = ri->prev;
210 if (ri->prev)
211 ri->prev->next = ri->next;
212 else
213 rn->info = ri->next;
paul200df112005-06-01 11:17:05 +0000214
Josh Baileyde8d5df2011-07-20 20:46:01 -0700215 bgp_info_mpath_dequeue (ri);
paul200df112005-06-01 11:17:05 +0000216 bgp_info_unlock (ri);
217 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +0000218}
219
paulb40d9392005-08-22 22:34:41 +0000220void
221bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
222{
Paul Jakma1a392d42006-09-07 00:24:49 +0000223 bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED);
224 /* set of previous already took care of pcount */
paulb40d9392005-08-22 22:34:41 +0000225 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
226}
227
Andrew J. Schorr8d452102006-11-28 19:50:46 +0000228/* undo the effects of a previous call to bgp_info_delete; typically
229 called when a route is deleted and then quickly re-added before the
230 deletion has been processed */
231static void
232bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri)
233{
234 bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED);
235 /* unset of previous already took care of pcount */
236 SET_FLAG (ri->flags, BGP_INFO_VALID);
237}
238
Paul Jakma1a392d42006-09-07 00:24:49 +0000239/* Adjust pcount as required */
240static void
241bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri)
242{
Avneesh Sachdev67174042012-08-17 08:19:49 -0700243 struct bgp_table *table;
244
245 assert (rn && bgp_node_table (rn));
Paul Jakma6f585442006-10-22 19:13:07 +0000246 assert (ri && ri->peer && ri->peer->bgp);
247
Avneesh Sachdev67174042012-08-17 08:19:49 -0700248 table = bgp_node_table (rn);
249
Paul Jakma1a392d42006-09-07 00:24:49 +0000250 /* Ignore 'pcount' for RS-client tables */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700251 if (table->type != BGP_TABLE_MAIN
Paul Jakma1a392d42006-09-07 00:24:49 +0000252 || ri->peer == ri->peer->bgp->peer_self)
253 return;
254
255 if (BGP_INFO_HOLDDOWN (ri)
256 && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
257 {
258
259 UNSET_FLAG (ri->flags, BGP_INFO_COUNTED);
260
261 /* slight hack, but more robust against errors. */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700262 if (ri->peer->pcount[table->afi][table->safi])
263 ri->peer->pcount[table->afi][table->safi]--;
Paul Jakma1a392d42006-09-07 00:24:49 +0000264 else
265 {
266 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
267 __func__, ri->peer->host);
268 zlog_backtrace (LOG_WARNING);
269 zlog_warn ("%s: Please report to Quagga bugzilla", __func__);
270 }
271 }
272 else if (!BGP_INFO_HOLDDOWN (ri)
273 && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
274 {
275 SET_FLAG (ri->flags, BGP_INFO_COUNTED);
Avneesh Sachdev67174042012-08-17 08:19:49 -0700276 ri->peer->pcount[table->afi][table->safi]++;
Paul Jakma1a392d42006-09-07 00:24:49 +0000277 }
278}
279
280
281/* Set/unset bgp_info flags, adjusting any other state as needed.
282 * This is here primarily to keep prefix-count in check.
283 */
284void
285bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
286{
287 SET_FLAG (ri->flags, flag);
288
289 /* early bath if we know it's not a flag that changes useability state */
290 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
291 return;
292
293 bgp_pcount_adjust (rn, ri);
294}
295
296void
297bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
298{
299 UNSET_FLAG (ri->flags, flag);
300
301 /* early bath if we know it's not a flag that changes useability state */
302 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
303 return;
304
305 bgp_pcount_adjust (rn, ri);
306}
307
paul718e3742002-12-13 20:15:29 +0000308/* Get MED value. If MED value is missing and "bgp bestpath
309 missing-as-worst" is specified, treat it as the worst value. */
paul94f2b392005-06-28 12:44:16 +0000310static u_int32_t
paul718e3742002-12-13 20:15:29 +0000311bgp_med_value (struct attr *attr, struct bgp *bgp)
312{
313 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
314 return attr->med;
315 else
316 {
317 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
paul3b424972003-10-13 09:47:32 +0000318 return BGP_MED_MAX;
paul718e3742002-12-13 20:15:29 +0000319 else
320 return 0;
321 }
322}
323
Paul Jakma6d4742b2015-11-25 17:14:37 +0000324/* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
325 * is preferred, or 0 if they are the same (usually will only occur if
326 * multipath is enabled */
paul94f2b392005-06-28 12:44:16 +0000327static int
Josh Bailey96450fa2011-07-20 20:45:12 -0700328bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
Paul Jakma6d4742b2015-11-25 17:14:37 +0000329 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +0000330{
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000331 struct attr *newattr, *existattr;
332 struct attr_extra *newattre, *existattre;
333 bgp_peer_sort_t new_sort;
334 bgp_peer_sort_t exist_sort;
paul718e3742002-12-13 20:15:29 +0000335 u_int32_t new_pref;
336 u_int32_t exist_pref;
337 u_int32_t new_med;
338 u_int32_t exist_med;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000339 u_int32_t new_weight;
340 u_int32_t exist_weight;
341 uint32_t newm, existm;
paul718e3742002-12-13 20:15:29 +0000342 struct in_addr new_id;
343 struct in_addr exist_id;
344 int new_cluster;
345 int exist_cluster;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000346 int internal_as_route;
347 int confed_as_route;
paul718e3742002-12-13 20:15:29 +0000348 int ret;
Josh Bailey96450fa2011-07-20 20:45:12 -0700349
paul718e3742002-12-13 20:15:29 +0000350 /* 0. Null check. */
351 if (new == NULL)
paul718e3742002-12-13 20:15:29 +0000352 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000353 if (exist == NULL)
354 return -1;
paul718e3742002-12-13 20:15:29 +0000355
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000356 newattr = new->attr;
357 existattr = exist->attr;
358 newattre = newattr->extra;
359 existattre = existattr->extra;
360
paul718e3742002-12-13 20:15:29 +0000361 /* 1. Weight check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000362 new_weight = exist_weight = 0;
363
364 if (newattre)
365 new_weight = newattre->weight;
366 if (existattre)
367 exist_weight = existattre->weight;
368
Paul Jakmafb982c22007-05-04 20:15:47 +0000369 if (new_weight > exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000370 return -1;
Paul Jakmafb982c22007-05-04 20:15:47 +0000371 if (new_weight < exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000372 return 1;
paul718e3742002-12-13 20:15:29 +0000373
374 /* 2. Local preference check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000375 new_pref = exist_pref = bgp->default_local_pref;
paul718e3742002-12-13 20:15:29 +0000376
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000377 if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
378 new_pref = newattr->local_pref;
379 if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
380 exist_pref = existattr->local_pref;
381
paul718e3742002-12-13 20:15:29 +0000382 if (new_pref > exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000383 return -1;
paul718e3742002-12-13 20:15:29 +0000384 if (new_pref < exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000385 return 1;
paul718e3742002-12-13 20:15:29 +0000386
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000387 /* 3. Local route check. We prefer:
388 * - BGP_ROUTE_STATIC
389 * - BGP_ROUTE_AGGREGATE
390 * - BGP_ROUTE_REDISTRIBUTE
391 */
392 if (! (new->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000393 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000394 if (! (exist->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000395 return 1;
paul718e3742002-12-13 20:15:29 +0000396
397 /* 4. AS path length check. */
398 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
399 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000400 int exist_hops = aspath_count_hops (existattr->aspath);
401 int exist_confeds = aspath_count_confeds (existattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000402
hasso68118452005-04-08 15:40:36 +0000403 if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
404 {
paulfe69a502005-09-10 16:55:02 +0000405 int aspath_hops;
406
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000407 aspath_hops = aspath_count_hops (newattr->aspath);
408 aspath_hops += aspath_count_confeds (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000409
410 if ( aspath_hops < (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000411 return -1;
paulfe69a502005-09-10 16:55:02 +0000412 if ( aspath_hops > (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000413 return 1;
hasso68118452005-04-08 15:40:36 +0000414 }
415 else
416 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000417 int newhops = aspath_count_hops (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000418
419 if (newhops < exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000420 return -1;
paulfe69a502005-09-10 16:55:02 +0000421 if (newhops > exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000422 return 1;
hasso68118452005-04-08 15:40:36 +0000423 }
paul718e3742002-12-13 20:15:29 +0000424 }
425
426 /* 5. Origin check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000427 if (newattr->origin < existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000428 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000429 if (newattr->origin > existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000430 return 1;
paul718e3742002-12-13 20:15:29 +0000431
432 /* 6. MED check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000433 internal_as_route = (aspath_count_hops (newattr->aspath) == 0
434 && aspath_count_hops (existattr->aspath) == 0);
435 confed_as_route = (aspath_count_confeds (newattr->aspath) > 0
436 && aspath_count_confeds (existattr->aspath) > 0
437 && aspath_count_hops (newattr->aspath) == 0
438 && aspath_count_hops (existattr->aspath) == 0);
paul718e3742002-12-13 20:15:29 +0000439
440 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
441 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
442 && confed_as_route)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000443 || aspath_cmp_left (newattr->aspath, existattr->aspath)
444 || aspath_cmp_left_confed (newattr->aspath, existattr->aspath)
paul718e3742002-12-13 20:15:29 +0000445 || internal_as_route)
446 {
447 new_med = bgp_med_value (new->attr, bgp);
448 exist_med = bgp_med_value (exist->attr, bgp);
449
450 if (new_med < exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000451 return -1;
paul718e3742002-12-13 20:15:29 +0000452 if (new_med > exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000453 return 1;
paul718e3742002-12-13 20:15:29 +0000454 }
455
456 /* 7. Peer type check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000457 new_sort = new->peer->sort;
458 exist_sort = exist->peer->sort;
459
460 if (new_sort == BGP_PEER_EBGP
461 && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000462 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000463 if (exist_sort == BGP_PEER_EBGP
464 && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000465 return 1;
paul718e3742002-12-13 20:15:29 +0000466
467 /* 8. IGP metric check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000468 newm = existm = 0;
469
470 if (new->extra)
471 newm = new->extra->igpmetric;
472 if (exist->extra)
473 existm = exist->extra->igpmetric;
474
Josh Bailey96450fa2011-07-20 20:45:12 -0700475 if (newm < existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000476 return -1;
Josh Bailey96450fa2011-07-20 20:45:12 -0700477 if (newm > existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000478 return 1;
paul718e3742002-12-13 20:15:29 +0000479
480 /* 9. Maximum path check. */
Paul Jakma6d4742b2015-11-25 17:14:37 +0000481 if (bgp_mpath_is_configured (bgp, afi, safi))
Josh Bailey96450fa2011-07-20 20:45:12 -0700482 {
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000483 if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX))
484 {
Paul Jakma6d4742b2015-11-25 17:14:37 +0000485 /*
486 * For the two paths, all comparison steps till IGP metric
487 * have succeeded - including AS_PATH hop count. Since 'bgp
488 * bestpath as-path multipath-relax' knob is on, we don't need
489 * an exact match of AS_PATH. Thus, mark the paths are equal.
490 * That will trigger both these paths to get into the multipath
491 * array.
492 */
493 return 0;
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000494 }
495 else if (new->peer->sort == BGP_PEER_IBGP)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000496 {
497 if (aspath_cmp (new->attr->aspath, exist->attr->aspath))
498 return 0;
499 }
Josh Bailey96450fa2011-07-20 20:45:12 -0700500 else if (new->peer->as == exist->peer->as)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000501 return 0;
Josh Bailey96450fa2011-07-20 20:45:12 -0700502 }
paul718e3742002-12-13 20:15:29 +0000503
504 /* 10. If both paths are external, prefer the path that was received
505 first (the oldest one). This step minimizes route-flap, since a
506 newer path won't displace an older one, even if it was the
507 preferred route based on the additional decision criteria below. */
508 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000509 && new_sort == BGP_PEER_EBGP
510 && exist_sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +0000511 {
512 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000513 return -1;
paul718e3742002-12-13 20:15:29 +0000514 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000515 return 1;
paul718e3742002-12-13 20:15:29 +0000516 }
517
vivekbd4b7f12014-09-30 15:54:45 -0700518 /* 11. Router-ID comparision. */
519 /* If one of the paths is "stale", the corresponding peer router-id will
520 * be 0 and would always win over the other path. If originator id is
521 * used for the comparision, it will decide which path is better.
522 */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000523 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
524 new_id.s_addr = newattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000525 else
526 new_id.s_addr = new->peer->remote_id.s_addr;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000527 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
528 exist_id.s_addr = existattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000529 else
530 exist_id.s_addr = exist->peer->remote_id.s_addr;
531
532 if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000533 return -1;
paul718e3742002-12-13 20:15:29 +0000534 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000535 return 1;
paul718e3742002-12-13 20:15:29 +0000536
537 /* 12. Cluster length comparision. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000538 new_cluster = exist_cluster = 0;
539
540 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
541 new_cluster = newattre->cluster->length;
542 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
543 exist_cluster = existattre->cluster->length;
paul718e3742002-12-13 20:15:29 +0000544
545 if (new_cluster < exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000546 return -1;
paul718e3742002-12-13 20:15:29 +0000547 if (new_cluster > exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000548 return 1;
paul718e3742002-12-13 20:15:29 +0000549
550 /* 13. Neighbor address comparision. */
vivekbd4b7f12014-09-30 15:54:45 -0700551 /* Do this only if neither path is "stale" as stale paths do not have
552 * valid peer information (as the connection may or may not be up).
553 */
554 if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000555 return -1;
vivekbd4b7f12014-09-30 15:54:45 -0700556 if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000557 return 1;
Timo Teräs2820a012015-06-24 15:27:21 +0300558 /* locally configured routes to advertise do not have su_remote */
559 if (new->peer->su_remote == NULL)
Timo Teräs2820a012015-06-24 15:27:21 +0300560 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000561 if (exist->peer->su_remote == NULL)
562 return -1;
Timo Teräs2820a012015-06-24 15:27:21 +0300563
paul718e3742002-12-13 20:15:29 +0000564 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
565
566 if (ret == 1)
paul718e3742002-12-13 20:15:29 +0000567 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000568 if (ret == -1)
569 return -1;
paul718e3742002-12-13 20:15:29 +0000570
Paul Jakma6d4742b2015-11-25 17:14:37 +0000571 return -1;
paul718e3742002-12-13 20:15:29 +0000572}
573
paul94f2b392005-06-28 12:44:16 +0000574static enum filter_type
paul718e3742002-12-13 20:15:29 +0000575bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
576 afi_t afi, safi_t safi)
577{
578 struct bgp_filter *filter;
579
580 filter = &peer->filter[afi][safi];
581
Paul Jakma650f76c2009-06-25 18:06:31 +0100582#define FILTER_EXIST_WARN(F,f,filter) \
583 if (BGP_DEBUG (update, UPDATE_IN) \
584 && !(F ## _IN (filter))) \
585 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
586 peer->host, #f, F ## _IN_NAME(filter));
587
588 if (DISTRIBUTE_IN_NAME (filter)) {
589 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
590
paul718e3742002-12-13 20:15:29 +0000591 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
592 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100593 }
paul718e3742002-12-13 20:15:29 +0000594
Paul Jakma650f76c2009-06-25 18:06:31 +0100595 if (PREFIX_LIST_IN_NAME (filter)) {
596 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
597
paul718e3742002-12-13 20:15:29 +0000598 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
599 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100600 }
paul718e3742002-12-13 20:15:29 +0000601
Paul Jakma650f76c2009-06-25 18:06:31 +0100602 if (FILTER_LIST_IN_NAME (filter)) {
603 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
604
paul718e3742002-12-13 20:15:29 +0000605 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
606 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100607 }
608
paul718e3742002-12-13 20:15:29 +0000609 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100610#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000611}
612
paul94f2b392005-06-28 12:44:16 +0000613static enum filter_type
paul718e3742002-12-13 20:15:29 +0000614bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
615 afi_t afi, safi_t safi)
616{
617 struct bgp_filter *filter;
618
619 filter = &peer->filter[afi][safi];
620
Paul Jakma650f76c2009-06-25 18:06:31 +0100621#define FILTER_EXIST_WARN(F,f,filter) \
622 if (BGP_DEBUG (update, UPDATE_OUT) \
623 && !(F ## _OUT (filter))) \
624 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
625 peer->host, #f, F ## _OUT_NAME(filter));
626
627 if (DISTRIBUTE_OUT_NAME (filter)) {
628 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
629
paul718e3742002-12-13 20:15:29 +0000630 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
631 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100632 }
paul718e3742002-12-13 20:15:29 +0000633
Paul Jakma650f76c2009-06-25 18:06:31 +0100634 if (PREFIX_LIST_OUT_NAME (filter)) {
635 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
636
paul718e3742002-12-13 20:15:29 +0000637 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
638 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100639 }
paul718e3742002-12-13 20:15:29 +0000640
Paul Jakma650f76c2009-06-25 18:06:31 +0100641 if (FILTER_LIST_OUT_NAME (filter)) {
642 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
643
paul718e3742002-12-13 20:15:29 +0000644 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
645 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100646 }
paul718e3742002-12-13 20:15:29 +0000647
648 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100649#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000650}
651
652/* If community attribute includes no_export then return 1. */
paul94f2b392005-06-28 12:44:16 +0000653static int
paul718e3742002-12-13 20:15:29 +0000654bgp_community_filter (struct peer *peer, struct attr *attr)
655{
656 if (attr->community)
657 {
658 /* NO_ADVERTISE check. */
659 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
660 return 1;
661
662 /* NO_EXPORT check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000663 if (peer->sort == BGP_PEER_EBGP &&
paul718e3742002-12-13 20:15:29 +0000664 community_include (attr->community, COMMUNITY_NO_EXPORT))
665 return 1;
666
667 /* NO_EXPORT_SUBCONFED check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000668 if (peer->sort == BGP_PEER_EBGP
669 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000670 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
671 return 1;
672 }
673 return 0;
674}
675
676/* Route reflection loop check. */
677static int
678bgp_cluster_filter (struct peer *peer, struct attr *attr)
679{
680 struct in_addr cluster_id;
681
Paul Jakmafb982c22007-05-04 20:15:47 +0000682 if (attr->extra && attr->extra->cluster)
paul718e3742002-12-13 20:15:29 +0000683 {
684 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
685 cluster_id = peer->bgp->cluster_id;
686 else
687 cluster_id = peer->bgp->router_id;
688
Paul Jakmafb982c22007-05-04 20:15:47 +0000689 if (cluster_loop_check (attr->extra->cluster, cluster_id))
paul718e3742002-12-13 20:15:29 +0000690 return 1;
691 }
692 return 0;
693}
David Lamparter6b0655a2014-06-04 06:53:35 +0200694
paul94f2b392005-06-28 12:44:16 +0000695static int
paul718e3742002-12-13 20:15:29 +0000696bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
697 afi_t afi, safi_t safi)
698{
699 struct bgp_filter *filter;
700 struct bgp_info info;
701 route_map_result_t ret;
702
703 filter = &peer->filter[afi][safi];
704
705 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000706 if (peer->weight)
707 (bgp_attr_extra_get (attr))->weight = peer->weight;
paul718e3742002-12-13 20:15:29 +0000708
709 /* Route map apply. */
710 if (ROUTE_MAP_IN_NAME (filter))
711 {
712 /* Duplicate current value to new strucutre for modification. */
713 info.peer = peer;
714 info.attr = attr;
715
paulac41b2a2003-08-12 05:32:27 +0000716 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
717
paul718e3742002-12-13 20:15:29 +0000718 /* Apply BGP route map to the attribute. */
719 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
paulac41b2a2003-08-12 05:32:27 +0000720
721 peer->rmap_type = 0;
722
paul718e3742002-12-13 20:15:29 +0000723 if (ret == RMAP_DENYMATCH)
David Lamparterc460e572014-06-04 00:54:58 +0200724 /* caller has multiple error paths with bgp_attr_flush() */
725 return RMAP_DENY;
paul718e3742002-12-13 20:15:29 +0000726 }
727 return RMAP_PERMIT;
728}
David Lamparter6b0655a2014-06-04 06:53:35 +0200729
paul94f2b392005-06-28 12:44:16 +0000730static int
paulfee0f4c2004-09-13 05:12:46 +0000731bgp_export_modifier (struct peer *rsclient, struct peer *peer,
732 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
733{
734 struct bgp_filter *filter;
735 struct bgp_info info;
736 route_map_result_t ret;
737
738 filter = &peer->filter[afi][safi];
739
740 /* Route map apply. */
741 if (ROUTE_MAP_EXPORT_NAME (filter))
742 {
743 /* Duplicate current value to new strucutre for modification. */
744 info.peer = rsclient;
745 info.attr = attr;
746
747 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
748
749 /* Apply BGP route map to the attribute. */
750 ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
751
752 rsclient->rmap_type = 0;
753
754 if (ret == RMAP_DENYMATCH)
755 {
756 /* Free newly generated AS path and community by route-map. */
757 bgp_attr_flush (attr);
758 return RMAP_DENY;
759 }
760 }
761 return RMAP_PERMIT;
762}
763
paul94f2b392005-06-28 12:44:16 +0000764static int
paulfee0f4c2004-09-13 05:12:46 +0000765bgp_import_modifier (struct peer *rsclient, struct peer *peer,
766 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
767{
768 struct bgp_filter *filter;
769 struct bgp_info info;
770 route_map_result_t ret;
771
772 filter = &rsclient->filter[afi][safi];
773
774 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000775 if (peer->weight)
776 (bgp_attr_extra_get (attr))->weight = peer->weight;
paulfee0f4c2004-09-13 05:12:46 +0000777
778 /* Route map apply. */
779 if (ROUTE_MAP_IMPORT_NAME (filter))
780 {
781 /* Duplicate current value to new strucutre for modification. */
782 info.peer = peer;
783 info.attr = attr;
784
785 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
786
787 /* Apply BGP route map to the attribute. */
788 ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
789
790 peer->rmap_type = 0;
791
792 if (ret == RMAP_DENYMATCH)
793 {
794 /* Free newly generated AS path and community by route-map. */
795 bgp_attr_flush (attr);
796 return RMAP_DENY;
797 }
798 }
799 return RMAP_PERMIT;
800}
David Lamparter6b0655a2014-06-04 06:53:35 +0200801
paul94f2b392005-06-28 12:44:16 +0000802static int
paul718e3742002-12-13 20:15:29 +0000803bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
804 struct attr *attr, afi_t afi, safi_t safi)
805{
806 int ret;
807 char buf[SU_ADDRSTRLEN];
808 struct bgp_filter *filter;
paul718e3742002-12-13 20:15:29 +0000809 struct peer *from;
810 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +0000811 int transparent;
812 int reflect;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700813 struct attr *riattr;
paul718e3742002-12-13 20:15:29 +0000814
815 from = ri->peer;
816 filter = &peer->filter[afi][safi];
817 bgp = peer->bgp;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700818 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paul718e3742002-12-13 20:15:29 +0000819
Paul Jakma750e8142008-07-22 21:11:48 +0000820 if (DISABLE_BGP_ANNOUNCE)
821 return 0;
paul718e3742002-12-13 20:15:29 +0000822
paulfee0f4c2004-09-13 05:12:46 +0000823 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
824 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
825 return 0;
826
paul718e3742002-12-13 20:15:29 +0000827 /* Do not send back route to sender. */
828 if (from == peer)
829 return 0;
830
831 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000832 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +0000833 if (! UNSUPPRESS_MAP_NAME (filter))
834 return 0;
835
836 /* Default route check. */
837 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
838 {
839 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
840 return 0;
paul718e3742002-12-13 20:15:29 +0000841 else if (p->family == AF_INET6 && p->prefixlen == 0)
842 return 0;
paul718e3742002-12-13 20:15:29 +0000843 }
844
paul286e1e72003-08-08 00:24:31 +0000845 /* Transparency check. */
846 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
847 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
848 transparent = 1;
849 else
850 transparent = 0;
851
paul718e3742002-12-13 20:15:29 +0000852 /* If community is not disabled check the no-export and local. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700853 if (! transparent && bgp_community_filter (peer, riattr))
paul718e3742002-12-13 20:15:29 +0000854 return 0;
855
856 /* If the attribute has originator-id and it is same as remote
857 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700858 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paul718e3742002-12-13 20:15:29 +0000859 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700860 if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +0000861 {
862 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000863 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000864 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
865 peer->host,
866 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
867 p->prefixlen);
868 return 0;
869 }
870 }
871
872 /* ORF prefix-list filter check */
873 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
874 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
875 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
876 if (peer->orf_plist[afi][safi])
877 {
878 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
879 return 0;
880 }
881
882 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700883 if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
paul718e3742002-12-13 20:15:29 +0000884 {
885 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000886 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000887 "%s [Update:SEND] %s/%d is filtered",
888 peer->host,
889 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
890 p->prefixlen);
891 return 0;
892 }
893
894#ifdef BGP_SEND_ASPATH_CHECK
895 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700896 if (aspath_loop_check (riattr->aspath, peer->as))
paul718e3742002-12-13 20:15:29 +0000897 {
898 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000899 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400900 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000901 peer->host, peer->as);
902 return 0;
903 }
904#endif /* BGP_SEND_ASPATH_CHECK */
905
906 /* If we're a CONFED we need to loop check the CONFED ID too */
907 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
908 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700909 if (aspath_loop_check(riattr->aspath, bgp->confed_id))
paul718e3742002-12-13 20:15:29 +0000910 {
911 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000912 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400913 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000914 peer->host,
915 bgp->confed_id);
916 return 0;
917 }
918 }
919
920 /* Route-Reflect check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000921 if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +0000922 reflect = 1;
923 else
924 reflect = 0;
925
926 /* IBGP reflection check. */
927 if (reflect)
928 {
929 /* A route from a Client peer. */
930 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
931 {
932 /* Reflect to all the Non-Client peers and also to the
933 Client peers other than the originator. Originator check
934 is already done. So there is noting to do. */
935 /* no bgp client-to-client reflection check. */
936 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
937 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
938 return 0;
939 }
940 else
941 {
942 /* A route from a Non-client peer. Reflect to all other
943 clients. */
944 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
945 return 0;
946 }
947 }
Paul Jakma41367172007-08-06 15:24:51 +0000948
paul718e3742002-12-13 20:15:29 +0000949 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700950 bgp_attr_dup (attr, riattr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000951
paul718e3742002-12-13 20:15:29 +0000952 /* If local-preference is not set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000953 if ((peer->sort == BGP_PEER_IBGP
954 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000955 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
956 {
957 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
958 attr->local_pref = bgp->default_local_pref;
959 }
960
Pradosh Mohapatra689bb662013-09-07 07:13:37 +0000961 /* If originator-id is not set and the route is to be reflected,
962 set the originator id */
963 if (peer && from && peer->sort == BGP_PEER_IBGP &&
964 from->sort == BGP_PEER_IBGP &&
965 (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))))
966 {
967 attr->extra = bgp_attr_extra_get(attr);
968 IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id));
969 SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
970 }
971
paul718e3742002-12-13 20:15:29 +0000972 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000973 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +0000974 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
975 {
976 if (ri->peer != bgp->peer_self && ! transparent
977 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
978 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
979 }
980
Lou Berger298cc2f2016-01-12 13:42:02 -0500981
982#define NEXTHOP_IS_V4 (\
983 (safi != SAFI_ENCAP && p->family == AF_INET) || \
984 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4))
985
Lou Berger298cc2f2016-01-12 13:42:02 -0500986#define NEXTHOP_IS_V6 (\
987 (safi != SAFI_ENCAP && p->family == AF_INET6) || \
988 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
Lou Berger298cc2f2016-01-12 13:42:02 -0500989
paul718e3742002-12-13 20:15:29 +0000990 /* next-hop-set */
Timo Teräs9e7a53c2014-04-24 10:22:37 +0300991 if (transparent
992 || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
paul718e3742002-12-13 20:15:29 +0000993 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
Lou Berger298cc2f2016-01-12 13:42:02 -0500994 && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr)
Lou Berger298cc2f2016-01-12 13:42:02 -0500995 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +0000996 ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paul286e1e72003-08-08 00:24:31 +0000997 )))
paul718e3742002-12-13 20:15:29 +0000998 {
999 /* NEXT-HOP Unchanged. */
1000 }
1001 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
Lou Berger298cc2f2016-01-12 13:42:02 -05001002 || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0)
Lou Berger298cc2f2016-01-12 13:42:02 -05001003 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001004 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001005 || (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001006 && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0))
1007 {
1008 /* Set IPv4 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001009 if (NEXTHOP_IS_V4)
paul718e3742002-12-13 20:15:29 +00001010 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001011 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001012 memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4,
1013 IPV4_MAX_BYTELEN);
paul718e3742002-12-13 20:15:29 +00001014 else
1015 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
1016 }
paul718e3742002-12-13 20:15:29 +00001017 /* Set IPv6 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001018 if (NEXTHOP_IS_V6)
paul718e3742002-12-13 20:15:29 +00001019 {
1020 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001021 memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00001022 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001023 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001024 }
paul718e3742002-12-13 20:15:29 +00001025 }
1026
Lou Berger298cc2f2016-01-12 13:42:02 -05001027 if (p->family == AF_INET6 && safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00001028 {
paulfee0f4c2004-09-13 05:12:46 +00001029 /* Left nexthop_local unchanged if so configured. */
1030 if ( CHECK_FLAG (peer->af_flags[afi][safi],
1031 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1032 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001033 if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) )
1034 attr->extra->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001035 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001036 attr->extra->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001037 }
1038
1039 /* Default nexthop_local treatment for non-RS-Clients */
1040 else
1041 {
paul718e3742002-12-13 20:15:29 +00001042 /* Link-local address should not be transit to different peer. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001043 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001044
1045 /* Set link-local address for shared network peer. */
1046 if (peer->shared_network
1047 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
1048 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001049 memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00001050 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001051 attr->extra->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00001052 }
1053
1054 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1055 address.*/
1056 if (reflect)
Paul Jakmafb982c22007-05-04 20:15:47 +00001057 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001058
1059 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1060 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
Paul Jakmafb982c22007-05-04 20:15:47 +00001061 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001062 }
paulfee0f4c2004-09-13 05:12:46 +00001063
1064 }
paul718e3742002-12-13 20:15:29 +00001065
1066 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001067 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001068 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1069 && aspath_private_as_check (attr->aspath))
1070 attr->aspath = aspath_empty_get ();
1071
1072 /* Route map & unsuppress-map apply. */
1073 if (ROUTE_MAP_OUT_NAME (filter)
Paul Jakmafb982c22007-05-04 20:15:47 +00001074 || (ri->extra && ri->extra->suppress) )
paul718e3742002-12-13 20:15:29 +00001075 {
Paul Jakma7c7fa1b2006-02-18 10:52:09 +00001076 struct bgp_info info;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001077 struct attr dummy_attr;
1078 struct attr_extra dummy_extra;
1079
1080 dummy_attr.extra = &dummy_extra;
1081
paul718e3742002-12-13 20:15:29 +00001082 info.peer = peer;
1083 info.attr = attr;
1084
1085 /* The route reflector is not allowed to modify the attributes
1086 of the reflected IBGP routes. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001087 if (from->sort == BGP_PEER_IBGP
1088 && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +00001089 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001090 bgp_attr_dup (&dummy_attr, attr);
Paul Jakma9eda90c2007-08-30 13:36:17 +00001091 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00001092 }
paulac41b2a2003-08-12 05:32:27 +00001093
1094 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
1095
Paul Jakmafb982c22007-05-04 20:15:47 +00001096 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00001097 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1098 else
1099 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1100
paulac41b2a2003-08-12 05:32:27 +00001101 peer->rmap_type = 0;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001102
paul718e3742002-12-13 20:15:29 +00001103 if (ret == RMAP_DENYMATCH)
1104 {
1105 bgp_attr_flush (attr);
1106 return 0;
1107 }
1108 }
1109 return 1;
1110}
1111
paul94f2b392005-06-28 12:44:16 +00001112static int
paulfee0f4c2004-09-13 05:12:46 +00001113bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
1114 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001115{
paulfee0f4c2004-09-13 05:12:46 +00001116 int ret;
1117 char buf[SU_ADDRSTRLEN];
1118 struct bgp_filter *filter;
1119 struct bgp_info info;
1120 struct peer *from;
Josh Bailey0b597ef2011-07-20 20:49:11 -07001121 struct attr *riattr;
paulfee0f4c2004-09-13 05:12:46 +00001122
1123 from = ri->peer;
1124 filter = &rsclient->filter[afi][safi];
Josh Bailey0b597ef2011-07-20 20:49:11 -07001125 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paulfee0f4c2004-09-13 05:12:46 +00001126
Paul Jakma750e8142008-07-22 21:11:48 +00001127 if (DISABLE_BGP_ANNOUNCE)
1128 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001129
1130 /* Do not send back route to sender. */
1131 if (from == rsclient)
1132 return 0;
1133
1134 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001135 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001136 if (! UNSUPPRESS_MAP_NAME (filter))
1137 return 0;
1138
1139 /* Default route check. */
1140 if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
1141 PEER_STATUS_DEFAULT_ORIGINATE))
1142 {
1143 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
1144 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001145 else if (p->family == AF_INET6 && p->prefixlen == 0)
1146 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001147 }
1148
1149 /* If the attribute has originator-id and it is same as remote
1150 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001151 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paulfee0f4c2004-09-13 05:12:46 +00001152 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001153 if (IPV4_ADDR_SAME (&rsclient->remote_id,
Josh Bailey0b597ef2011-07-20 20:49:11 -07001154 &riattr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001155 {
1156 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001157 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001158 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1159 rsclient->host,
1160 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1161 p->prefixlen);
1162 return 0;
1163 }
1164 }
1165
1166 /* ORF prefix-list filter check */
1167 if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
1168 && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
1169 || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
1170 if (rsclient->orf_plist[afi][safi])
1171 {
1172 if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
1173 return 0;
1174 }
1175
1176 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001177 if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
paulfee0f4c2004-09-13 05:12:46 +00001178 {
1179 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001180 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001181 "%s [Update:SEND] %s/%d is filtered",
1182 rsclient->host,
1183 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1184 p->prefixlen);
1185 return 0;
1186 }
1187
1188#ifdef BGP_SEND_ASPATH_CHECK
1189 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001190 if (aspath_loop_check (riattr->aspath, rsclient->as))
paulfee0f4c2004-09-13 05:12:46 +00001191 {
1192 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001193 zlog (rsclient->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001194 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paulfee0f4c2004-09-13 05:12:46 +00001195 rsclient->host, rsclient->as);
1196 return 0;
1197 }
1198#endif /* BGP_SEND_ASPATH_CHECK */
1199
1200 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001201 bgp_attr_dup (attr, riattr);
paulfee0f4c2004-09-13 05:12:46 +00001202
1203 /* next-hop-set */
1204 if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
paulfee0f4c2004-09-13 05:12:46 +00001205 || (p->family == AF_INET6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001206 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paulfee0f4c2004-09-13 05:12:46 +00001207 )
1208 {
1209 /* Set IPv4 nexthop. */
1210 if (p->family == AF_INET)
1211 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001212 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001213 memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4,
paulfee0f4c2004-09-13 05:12:46 +00001214 IPV4_MAX_BYTELEN);
1215 else
1216 memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
1217 }
paulfee0f4c2004-09-13 05:12:46 +00001218 /* Set IPv6 nexthop. */
1219 if (p->family == AF_INET6)
1220 {
1221 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001222 memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global,
paulfee0f4c2004-09-13 05:12:46 +00001223 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001224 attr->extra->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001225 }
paulfee0f4c2004-09-13 05:12:46 +00001226 }
1227
paulfee0f4c2004-09-13 05:12:46 +00001228 if (p->family == AF_INET6)
1229 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001230 struct attr_extra *attre = attr->extra;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001231
paulfee0f4c2004-09-13 05:12:46 +00001232 /* Left nexthop_local unchanged if so configured. */
1233 if ( CHECK_FLAG (rsclient->af_flags[afi][safi],
1234 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1235 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001236 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1237 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001238 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001239 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001240 }
1241
1242 /* Default nexthop_local treatment for RS-Clients */
1243 else
1244 {
1245 /* Announcer and RS-Client are both in the same network */
1246 if (rsclient->shared_network && from->shared_network &&
1247 (rsclient->ifindex == from->ifindex))
1248 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001249 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1250 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001251 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001252 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001253 }
1254
1255 /* Set link-local address for shared network peer. */
1256 else if (rsclient->shared_network
1257 && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
1258 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001259 memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local,
paulfee0f4c2004-09-13 05:12:46 +00001260 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001261 attre->mp_nexthop_len = 32;
paulfee0f4c2004-09-13 05:12:46 +00001262 }
1263
1264 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001265 attre->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001266 }
1267
1268 }
paulfee0f4c2004-09-13 05:12:46 +00001269
1270 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001271 if (rsclient->sort == BGP_PEER_EBGP
paulfee0f4c2004-09-13 05:12:46 +00001272 && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1273 && aspath_private_as_check (attr->aspath))
1274 attr->aspath = aspath_empty_get ();
1275
1276 /* Route map & unsuppress-map apply. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001277 if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) )
paulfee0f4c2004-09-13 05:12:46 +00001278 {
1279 info.peer = rsclient;
1280 info.attr = attr;
1281
1282 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
1283
Paul Jakmafb982c22007-05-04 20:15:47 +00001284 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001285 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1286 else
1287 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1288
1289 rsclient->rmap_type = 0;
1290
1291 if (ret == RMAP_DENYMATCH)
1292 {
1293 bgp_attr_flush (attr);
1294 return 0;
1295 }
1296 }
1297
1298 return 1;
1299}
1300
1301struct bgp_info_pair
1302{
1303 struct bgp_info *old;
1304 struct bgp_info *new;
1305};
1306
paul94f2b392005-06-28 12:44:16 +00001307static void
Josh Bailey96450fa2011-07-20 20:45:12 -07001308bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
Paul Jakma6d4742b2015-11-25 17:14:37 +00001309 struct bgp_info_pair *result,
1310 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00001311{
paul718e3742002-12-13 20:15:29 +00001312 struct bgp_info *new_select;
1313 struct bgp_info *old_select;
paulfee0f4c2004-09-13 05:12:46 +00001314 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00001315 struct bgp_info *ri1;
1316 struct bgp_info *ri2;
paulb40d9392005-08-22 22:34:41 +00001317 struct bgp_info *nextri = NULL;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001318 int cmpret, do_mpath;
Josh Bailey96450fa2011-07-20 20:45:12 -07001319 struct list mp_list;
Paul Jakma91b9e852015-12-01 14:32:11 +00001320
1321 result->old = result->new = NULL;
1322
1323 if (rn->info == NULL)
1324 {
1325 char buf[PREFIX_STRLEN];
1326 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1327 __func__,
1328 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1329 return;
1330 }
1331
Josh Bailey96450fa2011-07-20 20:45:12 -07001332 bgp_mp_list_init (&mp_list);
Paul Jakma6d4742b2015-11-25 17:14:37 +00001333 do_mpath = bgp_mpath_is_configured (bgp, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001334
paul718e3742002-12-13 20:15:29 +00001335 /* bgp deterministic-med */
1336 new_select = NULL;
1337 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1338 for (ri1 = rn->info; ri1; ri1 = ri1->next)
1339 {
1340 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
1341 continue;
1342 if (BGP_INFO_HOLDDOWN (ri1))
1343 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001344 if (ri1->peer && ri1->peer != bgp->peer_self)
1345 if (ri1->peer->status != Established)
1346 continue;
paul718e3742002-12-13 20:15:29 +00001347
1348 new_select = ri1;
Josh Bailey6918e742011-07-20 20:48:20 -07001349 if (do_mpath)
1350 bgp_mp_list_add (&mp_list, ri1);
1351 old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
paul718e3742002-12-13 20:15:29 +00001352 if (ri1->next)
1353 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
1354 {
1355 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
1356 continue;
1357 if (BGP_INFO_HOLDDOWN (ri2))
1358 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001359 if (ri2->peer &&
1360 ri2->peer != bgp->peer_self &&
1361 !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
1362 if (ri2->peer->status != Established)
1363 continue;
paul718e3742002-12-13 20:15:29 +00001364
1365 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
1366 || aspath_cmp_left_confed (ri1->attr->aspath,
1367 ri2->attr->aspath))
1368 {
Josh Bailey6918e742011-07-20 20:48:20 -07001369 if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED))
1370 old_select = ri2;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001371 if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi))
1372 == -1)
paul718e3742002-12-13 20:15:29 +00001373 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001374 bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001375 new_select = ri2;
1376 }
1377
Paul Jakma6d4742b2015-11-25 17:14:37 +00001378 if (do_mpath)
1379 {
1380 if (cmpret != 0)
1381 bgp_mp_list_clear (&mp_list);
1382
1383 if (cmpret == 0 || cmpret == -1)
1384 bgp_mp_list_add (&mp_list, ri2);
1385 }
Josh Bailey6918e742011-07-20 20:48:20 -07001386
Paul Jakma1a392d42006-09-07 00:24:49 +00001387 bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001388 }
1389 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001390 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
1391 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
Josh Bailey6918e742011-07-20 20:48:20 -07001392
Paul Jakma6d4742b2015-11-25 17:14:37 +00001393 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey6918e742011-07-20 20:48:20 -07001394 bgp_mp_list_clear (&mp_list);
paul718e3742002-12-13 20:15:29 +00001395 }
1396
1397 /* Check old selected route and new selected route. */
1398 old_select = NULL;
1399 new_select = NULL;
paulb40d9392005-08-22 22:34:41 +00001400 for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
paul718e3742002-12-13 20:15:29 +00001401 {
1402 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
1403 old_select = ri;
1404
1405 if (BGP_INFO_HOLDDOWN (ri))
paulb40d9392005-08-22 22:34:41 +00001406 {
1407 /* reap REMOVED routes, if needs be
1408 * selected route must stay for a while longer though
1409 */
1410 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
1411 && (ri != old_select))
1412 bgp_info_reap (rn, ri);
1413
1414 continue;
1415 }
paul718e3742002-12-13 20:15:29 +00001416
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001417 if (ri->peer &&
1418 ri->peer != bgp->peer_self &&
1419 !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
1420 if (ri->peer->status != Established)
1421 continue;
1422
paul718e3742002-12-13 20:15:29 +00001423 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
1424 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
1425 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001426 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001427 continue;
1428 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001429 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
1430 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001431
Paul Jakma6d4742b2015-11-25 17:14:37 +00001432 if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1)
Josh Bailey96450fa2011-07-20 20:45:12 -07001433 {
Josh Bailey6918e742011-07-20 20:48:20 -07001434 if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1435 bgp_mp_dmed_deselect (new_select);
1436
Josh Bailey96450fa2011-07-20 20:45:12 -07001437 new_select = ri;
Josh Bailey96450fa2011-07-20 20:45:12 -07001438 }
Paul Jakma6d4742b2015-11-25 17:14:37 +00001439 else if (cmpret == 1 && do_mpath
1440 && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Josh Bailey6918e742011-07-20 20:48:20 -07001441 bgp_mp_dmed_deselect (ri);
Josh Bailey96450fa2011-07-20 20:45:12 -07001442
Paul Jakma6d4742b2015-11-25 17:14:37 +00001443 if (do_mpath)
1444 {
1445 if (cmpret != 0)
1446 bgp_mp_list_clear (&mp_list);
1447
1448 if (cmpret == 0 || cmpret == -1)
1449 bgp_mp_list_add (&mp_list, ri);
1450 }
paul718e3742002-12-13 20:15:29 +00001451 }
paulfee0f4c2004-09-13 05:12:46 +00001452
Josh Bailey6918e742011-07-20 20:48:20 -07001453 if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Paul Jakma6d4742b2015-11-25 17:14:37 +00001454 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001455
Josh Bailey0b597ef2011-07-20 20:49:11 -07001456 bgp_info_mpath_aggregate_update (new_select, old_select);
Josh Bailey96450fa2011-07-20 20:45:12 -07001457 bgp_mp_list_clear (&mp_list);
1458
1459 result->old = old_select;
1460 result->new = new_select;
1461
1462 return;
paulfee0f4c2004-09-13 05:12:46 +00001463}
1464
paul94f2b392005-06-28 12:44:16 +00001465static int
paulfee0f4c2004-09-13 05:12:46 +00001466bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
Paul Jakma9eda90c2007-08-30 13:36:17 +00001467 struct bgp_node *rn, afi_t afi, safi_t safi)
1468{
paulfee0f4c2004-09-13 05:12:46 +00001469 struct prefix *p;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001470 struct attr attr;
1471 struct attr_extra extra;
paulfee0f4c2004-09-13 05:12:46 +00001472
Lou Berger050defe2016-01-12 13:41:59 -05001473 memset (&attr, 0, sizeof(struct attr));
1474 memset (&extra, 0, sizeof(struct attr_extra));
1475
paulfee0f4c2004-09-13 05:12:46 +00001476 p = &rn->p;
1477
Paul Jakma9eda90c2007-08-30 13:36:17 +00001478 /* Announce route to Established peer. */
1479 if (peer->status != Established)
paulfee0f4c2004-09-13 05:12:46 +00001480 return 0;
1481
Paul Jakma9eda90c2007-08-30 13:36:17 +00001482 /* Address family configuration check. */
1483 if (! peer->afc_nego[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001484 return 0;
1485
Paul Jakma9eda90c2007-08-30 13:36:17 +00001486 /* First update is deferred until ORF or ROUTE-REFRESH is received */
paulfee0f4c2004-09-13 05:12:46 +00001487 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1488 PEER_STATUS_ORF_WAIT_REFRESH))
1489 return 0;
1490
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001491 /* It's initialized in bgp_announce_[check|check_rsclient]() */
1492 attr.extra = &extra;
1493
Avneesh Sachdev67174042012-08-17 08:19:49 -07001494 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001495 {
1496 case BGP_TABLE_MAIN:
1497 /* Announcement to peer->conf. If the route is filtered,
1498 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001499 if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
1500 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
paulfee0f4c2004-09-13 05:12:46 +00001501 else
1502 bgp_adj_out_unset (rn, peer, p, afi, safi);
1503 break;
1504 case BGP_TABLE_RSCLIENT:
1505 /* Announcement to peer->conf. If the route is filtered,
1506 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001507 if (selected &&
1508 bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
1509 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
1510 else
1511 bgp_adj_out_unset (rn, peer, p, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001512 break;
1513 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001514
Lou Berger050defe2016-01-12 13:41:59 -05001515 bgp_attr_flush (&attr);
paulfee0f4c2004-09-13 05:12:46 +00001516 return 0;
paul200df112005-06-01 11:17:05 +00001517}
paulfee0f4c2004-09-13 05:12:46 +00001518
paul200df112005-06-01 11:17:05 +00001519struct bgp_process_queue
paulfee0f4c2004-09-13 05:12:46 +00001520{
paul200df112005-06-01 11:17:05 +00001521 struct bgp *bgp;
1522 struct bgp_node *rn;
1523 afi_t afi;
1524 safi_t safi;
1525};
1526
1527static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001528bgp_process_rsclient (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001529{
paul0fb58d52005-11-14 14:31:49 +00001530 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001531 struct bgp *bgp = pq->bgp;
1532 struct bgp_node *rn = pq->rn;
1533 afi_t afi = pq->afi;
1534 safi_t safi = pq->safi;
paulfee0f4c2004-09-13 05:12:46 +00001535 struct bgp_info *new_select;
1536 struct bgp_info *old_select;
1537 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001538 struct listnode *node, *nnode;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001539 struct peer *rsclient = bgp_node_table (rn)->owner;
paul200df112005-06-01 11:17:05 +00001540
paulfee0f4c2004-09-13 05:12:46 +00001541 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001542 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001543 new_select = old_and_new.new;
1544 old_select = old_and_new.old;
1545
paul200df112005-06-01 11:17:05 +00001546 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
1547 {
Chris Caputo228da422009-07-18 05:44:03 +00001548 if (rsclient->group)
1549 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient))
1550 {
1551 /* Nothing to do. */
1552 if (old_select && old_select == new_select)
1553 if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1554 continue;
paulfee0f4c2004-09-13 05:12:46 +00001555
Chris Caputo228da422009-07-18 05:44:03 +00001556 if (old_select)
1557 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1558 if (new_select)
1559 {
1560 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1561 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001562 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1563 }
paulfee0f4c2004-09-13 05:12:46 +00001564
Chris Caputo228da422009-07-18 05:44:03 +00001565 bgp_process_announce_selected (rsclient, new_select, rn,
1566 afi, safi);
1567 }
paul200df112005-06-01 11:17:05 +00001568 }
1569 else
1570 {
hassob7395792005-08-26 12:58:38 +00001571 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001572 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hassob7395792005-08-26 12:58:38 +00001573 if (new_select)
1574 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001575 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1576 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001577 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hassob7395792005-08-26 12:58:38 +00001578 }
Paul Jakma9eda90c2007-08-30 13:36:17 +00001579 bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
paul200df112005-06-01 11:17:05 +00001580 }
paulfee0f4c2004-09-13 05:12:46 +00001581
paulb40d9392005-08-22 22:34:41 +00001582 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1583 bgp_info_reap (rn, old_select);
1584
paul200df112005-06-01 11:17:05 +00001585 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1586 return WQ_SUCCESS;
paulfee0f4c2004-09-13 05:12:46 +00001587}
1588
paul200df112005-06-01 11:17:05 +00001589static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001590bgp_process_main (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001591{
paul0fb58d52005-11-14 14:31:49 +00001592 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001593 struct bgp *bgp = pq->bgp;
1594 struct bgp_node *rn = pq->rn;
1595 afi_t afi = pq->afi;
1596 safi_t safi = pq->safi;
1597 struct prefix *p = &rn->p;
paulfee0f4c2004-09-13 05:12:46 +00001598 struct bgp_info *new_select;
1599 struct bgp_info *old_select;
1600 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001601 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00001602 struct peer *peer;
Paul Jakmafb982c22007-05-04 20:15:47 +00001603
paulfee0f4c2004-09-13 05:12:46 +00001604 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001605 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001606 old_select = old_and_new.old;
1607 new_select = old_and_new.new;
1608
1609 /* Nothing to do. */
1610 if (old_select && old_select == new_select)
1611 {
1612 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
paul200df112005-06-01 11:17:05 +00001613 {
Josh Bailey8196f132011-07-20 20:47:07 -07001614 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) ||
1615 CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG))
G.Balaji5a616c02011-11-26 21:58:42 +04001616 bgp_zebra_announce (p, old_select, bgp, safi);
paul200df112005-06-01 11:17:05 +00001617
Josh Bailey8196f132011-07-20 20:47:07 -07001618 UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
paul200df112005-06-01 11:17:05 +00001619 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1620 return WQ_SUCCESS;
1621 }
paulfee0f4c2004-09-13 05:12:46 +00001622 }
paul718e3742002-12-13 20:15:29 +00001623
hasso338b3422005-02-23 14:27:24 +00001624 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001625 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hasso338b3422005-02-23 14:27:24 +00001626 if (new_select)
1627 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001628 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1629 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001630 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hasso338b3422005-02-23 14:27:24 +00001631 }
1632
1633
paul718e3742002-12-13 20:15:29 +00001634 /* Check each BGP peer. */
paul1eb8ef22005-04-07 07:30:20 +00001635 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00001636 {
Paul Jakma9eda90c2007-08-30 13:36:17 +00001637 bgp_process_announce_selected (peer, new_select, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001638 }
1639
1640 /* FIB update. */
G.Balaji5a616c02011-11-26 21:58:42 +04001641 if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
1642 ! bgp_option_check (BGP_OPT_NO_FIB)))
paul718e3742002-12-13 20:15:29 +00001643 {
1644 if (new_select
1645 && new_select->type == ZEBRA_ROUTE_BGP
1646 && new_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001647 bgp_zebra_announce (p, new_select, bgp, safi);
paul718e3742002-12-13 20:15:29 +00001648 else
1649 {
1650 /* Withdraw the route from the kernel. */
1651 if (old_select
1652 && old_select->type == ZEBRA_ROUTE_BGP
1653 && old_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001654 bgp_zebra_withdraw (p, old_select, safi);
paul718e3742002-12-13 20:15:29 +00001655 }
1656 }
paulb40d9392005-08-22 22:34:41 +00001657
Lou Berger050defe2016-01-12 13:41:59 -05001658 /* Reap old select bgp_info, if it has been removed */
paulb40d9392005-08-22 22:34:41 +00001659 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1660 bgp_info_reap (rn, old_select);
1661
paul200df112005-06-01 11:17:05 +00001662 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1663 return WQ_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001664}
1665
paul200df112005-06-01 11:17:05 +00001666static void
paul0fb58d52005-11-14 14:31:49 +00001667bgp_processq_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001668{
paul0fb58d52005-11-14 14:31:49 +00001669 struct bgp_process_queue *pq = data;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001670 struct bgp_table *table = bgp_node_table (pq->rn);
paul0fb58d52005-11-14 14:31:49 +00001671
Chris Caputo228da422009-07-18 05:44:03 +00001672 bgp_unlock (pq->bgp);
paul200df112005-06-01 11:17:05 +00001673 bgp_unlock_node (pq->rn);
Chris Caputo228da422009-07-18 05:44:03 +00001674 bgp_table_unlock (table);
paul200df112005-06-01 11:17:05 +00001675 XFREE (MTYPE_BGP_PROCESS_QUEUE, pq);
1676}
1677
1678static void
1679bgp_process_queue_init (void)
1680{
1681 bm->process_main_queue
1682 = work_queue_new (bm->master, "process_main_queue");
1683 bm->process_rsclient_queue
1684 = work_queue_new (bm->master, "process_rsclient_queue");
1685
1686 if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
1687 {
1688 zlog_err ("%s: Failed to allocate work queue", __func__);
1689 exit (1);
1690 }
1691
1692 bm->process_main_queue->spec.workfunc = &bgp_process_main;
paul200df112005-06-01 11:17:05 +00001693 bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
Paul Jakma838bbde2010-01-08 14:05:32 +00001694 bm->process_main_queue->spec.max_retries = 0;
1695 bm->process_main_queue->spec.hold = 50;
1696
Paul Jakma838bbde2010-01-08 14:05:32 +00001697 bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient;
David Lamparterd43f8b32015-03-03 08:54:54 +01001698 bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del;
1699 bm->process_rsclient_queue->spec.max_retries = 0;
1700 bm->process_rsclient_queue->spec.hold = 50;
paul200df112005-06-01 11:17:05 +00001701}
1702
1703void
paulfee0f4c2004-09-13 05:12:46 +00001704bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1705{
paul200df112005-06-01 11:17:05 +00001706 struct bgp_process_queue *pqnode;
1707
1708 /* already scheduled for processing? */
1709 if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
1710 return;
1711
Paul Jakma91b9e852015-12-01 14:32:11 +00001712 if (rn->info == NULL)
1713 {
1714 /* XXX: Perhaps remove before next release, after we've flushed out
1715 * any obvious cases
1716 */
1717 assert (rn->info != NULL);
1718 char buf[PREFIX_STRLEN];
1719 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1720 __func__,
1721 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1722 return;
1723 }
1724
paul200df112005-06-01 11:17:05 +00001725 if ( (bm->process_main_queue == NULL) ||
1726 (bm->process_rsclient_queue == NULL) )
1727 bgp_process_queue_init ();
1728
1729 pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
1730 sizeof (struct bgp_process_queue));
1731 if (!pqnode)
1732 return;
Chris Caputo228da422009-07-18 05:44:03 +00001733
1734 /* all unlocked in bgp_processq_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07001735 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00001736 pqnode->rn = bgp_lock_node (rn);
paul200df112005-06-01 11:17:05 +00001737 pqnode->bgp = bgp;
Chris Caputo228da422009-07-18 05:44:03 +00001738 bgp_lock (bgp);
paul200df112005-06-01 11:17:05 +00001739 pqnode->afi = afi;
1740 pqnode->safi = safi;
1741
Avneesh Sachdev67174042012-08-17 08:19:49 -07001742 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001743 {
paul200df112005-06-01 11:17:05 +00001744 case BGP_TABLE_MAIN:
1745 work_queue_add (bm->process_main_queue, pqnode);
1746 break;
1747 case BGP_TABLE_RSCLIENT:
1748 work_queue_add (bm->process_rsclient_queue, pqnode);
1749 break;
paulfee0f4c2004-09-13 05:12:46 +00001750 }
paul200df112005-06-01 11:17:05 +00001751
Stephen Hemminger07ff4dc2013-01-04 22:29:20 +00001752 SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
paul200df112005-06-01 11:17:05 +00001753 return;
paulfee0f4c2004-09-13 05:12:46 +00001754}
hasso0a486e52005-02-01 20:57:17 +00001755
paul94f2b392005-06-28 12:44:16 +00001756static int
hasso0a486e52005-02-01 20:57:17 +00001757bgp_maximum_prefix_restart_timer (struct thread *thread)
1758{
1759 struct peer *peer;
1760
1761 peer = THREAD_ARG (thread);
1762 peer->t_pmax_restart = NULL;
1763
1764 if (BGP_DEBUG (events, EVENTS))
1765 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1766 peer->host);
1767
1768 peer_clear (peer);
1769
1770 return 0;
1771}
1772
paulfee0f4c2004-09-13 05:12:46 +00001773int
paul5228ad22004-06-04 17:58:18 +00001774bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1775 safi_t safi, int always)
paul718e3742002-12-13 20:15:29 +00001776{
hassoe0701b72004-05-20 09:19:34 +00001777 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1778 return 0;
1779
1780 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +00001781 {
hassoe0701b72004-05-20 09:19:34 +00001782 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1783 && ! always)
1784 return 0;
paul718e3742002-12-13 20:15:29 +00001785
hassoe0701b72004-05-20 09:19:34 +00001786 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001787 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1788 "limit %ld", afi_safi_print (afi, safi), peer->host,
1789 peer->pcount[afi][safi], peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001790 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
paul718e3742002-12-13 20:15:29 +00001791
hassoe0701b72004-05-20 09:19:34 +00001792 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1793 return 0;
paul718e3742002-12-13 20:15:29 +00001794
hassoe0701b72004-05-20 09:19:34 +00001795 {
paul5228ad22004-06-04 17:58:18 +00001796 u_int8_t ndata[7];
hassoe0701b72004-05-20 09:19:34 +00001797
1798 if (safi == SAFI_MPLS_VPN)
Denis Ovsienko42e6d742011-07-14 12:36:19 +04001799 safi = SAFI_MPLS_LABELED_VPN;
paul5228ad22004-06-04 17:58:18 +00001800
1801 ndata[0] = (afi >> 8);
1802 ndata[1] = afi;
1803 ndata[2] = safi;
1804 ndata[3] = (peer->pmax[afi][safi] >> 24);
1805 ndata[4] = (peer->pmax[afi][safi] >> 16);
1806 ndata[5] = (peer->pmax[afi][safi] >> 8);
1807 ndata[6] = (peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001808
1809 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1810 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1811 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1812 }
hasso0a486e52005-02-01 20:57:17 +00001813
1814 /* restart timer start */
1815 if (peer->pmax_restart[afi][safi])
1816 {
1817 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1818
1819 if (BGP_DEBUG (events, EVENTS))
1820 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1821 peer->host, peer->v_pmax_restart);
1822
1823 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1824 peer->v_pmax_restart);
1825 }
1826
hassoe0701b72004-05-20 09:19:34 +00001827 return 1;
paul718e3742002-12-13 20:15:29 +00001828 }
hassoe0701b72004-05-20 09:19:34 +00001829 else
1830 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1831
1832 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1833 {
1834 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1835 && ! always)
1836 return 0;
1837
1838 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001839 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1840 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1841 peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001842 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1843 }
1844 else
1845 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
paul718e3742002-12-13 20:15:29 +00001846 return 0;
1847}
1848
paulb40d9392005-08-22 22:34:41 +00001849/* Unconditionally remove the route from the RIB, without taking
1850 * damping into consideration (eg, because the session went down)
1851 */
paul94f2b392005-06-28 12:44:16 +00001852static void
paul718e3742002-12-13 20:15:29 +00001853bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1854 afi_t afi, safi_t safi)
1855{
paul902212c2006-02-05 17:51:19 +00001856 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1857
1858 if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1859 bgp_info_delete (rn, ri); /* keep historical info */
1860
paulb40d9392005-08-22 22:34:41 +00001861 bgp_process (peer->bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001862}
1863
paul94f2b392005-06-28 12:44:16 +00001864static void
paul718e3742002-12-13 20:15:29 +00001865bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
Lou Berger050defe2016-01-12 13:41:59 -05001866 afi_t afi, safi_t safi, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00001867{
paul718e3742002-12-13 20:15:29 +00001868 int status = BGP_DAMP_NONE;
1869
paulb40d9392005-08-22 22:34:41 +00001870 /* apply dampening, if result is suppressed, we'll be retaining
1871 * the bgp_info in the RIB for historical reference.
1872 */
1873 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001874 && peer->sort == BGP_PEER_EBGP)
paulb40d9392005-08-22 22:34:41 +00001875 if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0))
1876 == BGP_DAMP_SUPPRESSED)
paul902212c2006-02-05 17:51:19 +00001877 {
paul902212c2006-02-05 17:51:19 +00001878 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1879 return;
1880 }
1881
1882 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00001883}
1884
paul94f2b392005-06-28 12:44:16 +00001885static void
paulfee0f4c2004-09-13 05:12:46 +00001886bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1887 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1888 int sub_type, struct prefix_rd *prd, u_char *tag)
1889{
1890 struct bgp_node *rn;
1891 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001892 struct attr new_attr;
1893 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00001894 struct attr *attr_new;
1895 struct attr *attr_new2;
1896 struct bgp_info *ri;
1897 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001898 const char *reason;
paulfee0f4c2004-09-13 05:12:46 +00001899 char buf[SU_ADDRSTRLEN];
1900
1901 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1902 if (peer == rsclient)
1903 return;
1904
1905 bgp = peer->bgp;
1906 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1907
1908 /* Check previously received route. */
1909 for (ri = rn->info; ri; ri = ri->next)
1910 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1911 break;
1912
1913 /* AS path loop check. */
Milan Kocian000e1572013-10-18 07:59:38 +00001914 if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001915 {
1916 reason = "as-path contains our own AS;";
1917 goto filtered;
1918 }
1919
1920 /* Route reflector originator ID check. */
1921 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00001922 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001923 {
1924 reason = "originator is us;";
1925 goto filtered;
1926 }
Paul Jakmafb982c22007-05-04 20:15:47 +00001927
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001928 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00001929 bgp_attr_dup (&new_attr, attr);
paulfee0f4c2004-09-13 05:12:46 +00001930
1931 /* Apply export policy. */
1932 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1933 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1934 {
1935 reason = "export-policy;";
1936 goto filtered;
1937 }
1938
1939 attr_new2 = bgp_attr_intern (&new_attr);
Paul Jakmafb982c22007-05-04 20:15:47 +00001940
paulfee0f4c2004-09-13 05:12:46 +00001941 /* Apply import policy. */
1942 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1943 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001944 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001945
1946 reason = "import-policy;";
1947 goto filtered;
1948 }
1949
1950 attr_new = bgp_attr_intern (&new_attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001951 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001952
1953 /* IPv4 unicast next hop check. */
G.Balaji5a616c02011-11-26 21:58:42 +04001954 if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
paulfee0f4c2004-09-13 05:12:46 +00001955 {
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001956 /* Next hop must not be 0.0.0.0 nor Class D/E address. */
paulfee0f4c2004-09-13 05:12:46 +00001957 if (new_attr.nexthop.s_addr == 0
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001958 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
paulfee0f4c2004-09-13 05:12:46 +00001959 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001960 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00001961
1962 reason = "martian next-hop;";
1963 goto filtered;
1964 }
1965 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001966
paulfee0f4c2004-09-13 05:12:46 +00001967 /* If the update is implicit withdraw. */
1968 if (ri)
1969 {
Stephen Hemminger65957882010-01-15 16:22:10 +03001970 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00001971
1972 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00001973 if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
1974 && attrhash_cmp (ri->attr, attr_new))
paulfee0f4c2004-09-13 05:12:46 +00001975 {
1976
Paul Jakma1a392d42006-09-07 00:24:49 +00001977 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00001978
1979 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001980 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001981 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1982 peer->host,
1983 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1984 p->prefixlen, rsclient->host);
1985
Chris Caputo228da422009-07-18 05:44:03 +00001986 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001987 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05001988 bgp_attr_flush(&new_attr);
Chris Caputo228da422009-07-18 05:44:03 +00001989 return;
paulfee0f4c2004-09-13 05:12:46 +00001990 }
1991
Paul Jakma16d2e242007-04-10 19:32:10 +00001992 /* Withdraw/Announce before we fully processed the withdraw */
1993 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
1994 bgp_info_restore (rn, ri);
1995
paulfee0f4c2004-09-13 05:12:46 +00001996 /* Received Logging. */
1997 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001998 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00001999 peer->host,
2000 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2001 p->prefixlen, rsclient->host);
2002
2003 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002004 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00002005
2006 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002007 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00002008 ri->attr = attr_new;
2009
2010 /* Update MPLS tag. */
2011 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002012 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002013
Paul Jakma1a392d42006-09-07 00:24:49 +00002014 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002015
2016 /* Process change. */
2017 bgp_process (bgp, rn, afi, safi);
2018 bgp_unlock_node (rn);
2019
2020 return;
2021 }
2022
2023 /* Received Logging. */
2024 if (BGP_DEBUG (update, UPDATE_IN))
2025 {
ajsd2c1f162004-12-08 21:10:20 +00002026 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00002027 peer->host,
2028 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2029 p->prefixlen, rsclient->host);
2030 }
2031
2032 /* Make new BGP info. */
2033 new = bgp_info_new ();
2034 new->type = type;
2035 new->sub_type = sub_type;
2036 new->peer = peer;
2037 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002038 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00002039
2040 /* Update MPLS tag. */
2041 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002042 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002043
Paul Jakma1a392d42006-09-07 00:24:49 +00002044 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002045
2046 /* Register new BGP information. */
2047 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002048
2049 /* route_node_get lock */
2050 bgp_unlock_node (rn);
2051
paulfee0f4c2004-09-13 05:12:46 +00002052 /* Process change. */
2053 bgp_process (bgp, rn, afi, safi);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002054
paulfee0f4c2004-09-13 05:12:46 +00002055 return;
2056
2057 filtered:
2058
2059 /* This BGP update is filtered. Log the reason then update BGP entry. */
2060 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002061 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002062 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
2063 peer->host,
2064 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2065 p->prefixlen, rsclient->host, reason);
2066
2067 if (ri)
paulb40d9392005-08-22 22:34:41 +00002068 bgp_rib_remove (rn, ri, peer, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002069
2070 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002071
paulfee0f4c2004-09-13 05:12:46 +00002072 return;
2073}
2074
paul94f2b392005-06-28 12:44:16 +00002075static void
paulfee0f4c2004-09-13 05:12:46 +00002076bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
2077 struct peer *peer, struct prefix *p, int type, int sub_type,
2078 struct prefix_rd *prd, u_char *tag)
Chris Caputo228da422009-07-18 05:44:03 +00002079{
paulfee0f4c2004-09-13 05:12:46 +00002080 struct bgp_node *rn;
2081 struct bgp_info *ri;
2082 char buf[SU_ADDRSTRLEN];
2083
2084 if (rsclient == peer)
Chris Caputo228da422009-07-18 05:44:03 +00002085 return;
paulfee0f4c2004-09-13 05:12:46 +00002086
2087 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
2088
2089 /* Lookup withdrawn route. */
2090 for (ri = rn->info; ri; ri = ri->next)
2091 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2092 break;
2093
2094 /* Withdraw specified route from routing table. */
2095 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002096 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paulfee0f4c2004-09-13 05:12:46 +00002097 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002098 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002099 "%s Can't find the route %s/%d", peer->host,
2100 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2101 p->prefixlen);
2102
2103 /* Unlock bgp_node_get() lock. */
Chris Caputo228da422009-07-18 05:44:03 +00002104 bgp_unlock_node (rn);
2105}
paulfee0f4c2004-09-13 05:12:46 +00002106
paul94f2b392005-06-28 12:44:16 +00002107static int
paulfee0f4c2004-09-13 05:12:46 +00002108bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
paul718e3742002-12-13 20:15:29 +00002109 afi_t afi, safi_t safi, int type, int sub_type,
2110 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2111{
2112 int ret;
2113 int aspath_loop_count = 0;
2114 struct bgp_node *rn;
2115 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002116 struct attr new_attr;
2117 struct attr_extra new_extra;
paul718e3742002-12-13 20:15:29 +00002118 struct attr *attr_new;
2119 struct bgp_info *ri;
2120 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00002121 const char *reason;
paul718e3742002-12-13 20:15:29 +00002122 char buf[SU_ADDRSTRLEN];
2123
Lou Berger370b7e52016-02-04 21:29:49 -05002124 memset (&new_attr, 0, sizeof(struct attr));
2125 memset (&new_extra, 0, sizeof(struct attr_extra));
2126
paul718e3742002-12-13 20:15:29 +00002127 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00002128 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
Paul Jakmafb982c22007-05-04 20:15:47 +00002129
paul718e3742002-12-13 20:15:29 +00002130 /* When peer's soft reconfiguration enabled. Record input packet in
2131 Adj-RIBs-In. */
Jorge Boncompte [DTI2]343aa822012-05-07 16:53:08 +00002132 if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2133 && peer != bgp->peer_self)
paul718e3742002-12-13 20:15:29 +00002134 bgp_adj_in_set (rn, peer, attr);
2135
2136 /* Check previously received route. */
2137 for (ri = rn->info; ri; ri = ri->next)
2138 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2139 break;
2140
2141 /* AS path local-as loop check. */
2142 if (peer->change_local_as)
2143 {
2144 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
2145 aspath_loop_count = 1;
2146
2147 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
2148 {
2149 reason = "as-path contains our own AS;";
2150 goto filtered;
2151 }
2152 }
2153
2154 /* AS path loop check. */
2155 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
2156 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
2157 && aspath_loop_check(attr->aspath, bgp->confed_id)
2158 > peer->allowas_in[afi][safi]))
2159 {
2160 reason = "as-path contains our own AS;";
2161 goto filtered;
2162 }
2163
2164 /* Route reflector originator ID check. */
2165 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00002166 && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +00002167 {
2168 reason = "originator is us;";
2169 goto filtered;
2170 }
2171
2172 /* Route reflector cluster ID check. */
2173 if (bgp_cluster_filter (peer, attr))
2174 {
2175 reason = "reflected from the same cluster;";
2176 goto filtered;
2177 }
2178
2179 /* Apply incoming filter. */
2180 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
2181 {
2182 reason = "filter;";
2183 goto filtered;
2184 }
2185
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002186 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00002187 bgp_attr_dup (&new_attr, attr);
paul718e3742002-12-13 20:15:29 +00002188
David Lamparterc460e572014-06-04 00:54:58 +02002189 /* Apply incoming route-map.
2190 * NB: new_attr may now contain newly allocated values from route-map "set"
2191 * commands, so we need bgp_attr_flush in the error paths, until we intern
2192 * the attr (which takes over the memory references) */
paul718e3742002-12-13 20:15:29 +00002193 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
2194 {
2195 reason = "route-map;";
David Lamparterc460e572014-06-04 00:54:58 +02002196 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002197 goto filtered;
2198 }
2199
2200 /* IPv4 unicast next hop check. */
2201 if (afi == AFI_IP && safi == SAFI_UNICAST)
2202 {
2203 /* If the peer is EBGP and nexthop is not on connected route,
2204 discard it. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002205 if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1
Denis Ovsienko8e80bdf2011-08-05 18:52:52 +04002206 && ! bgp_nexthop_onlink (afi, &new_attr)
hasso6ffd2072005-02-02 14:50:11 +00002207 && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
paul718e3742002-12-13 20:15:29 +00002208 {
2209 reason = "non-connected next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002210 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002211 goto filtered;
2212 }
2213
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04002214 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
paul718e3742002-12-13 20:15:29 +00002215 must not be my own address. */
Jorge Boncompte [DTI2]10f9bf32012-05-07 16:52:52 +00002216 if (new_attr.nexthop.s_addr == 0
2217 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
2218 || bgp_nexthop_self (&new_attr))
paul718e3742002-12-13 20:15:29 +00002219 {
2220 reason = "martian next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002221 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002222 goto filtered;
2223 }
2224 }
2225
2226 attr_new = bgp_attr_intern (&new_attr);
2227
2228 /* If the update is implicit withdraw. */
2229 if (ri)
2230 {
Stephen Hemminger65957882010-01-15 16:22:10 +03002231 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002232
2233 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00002234 if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
2235 && attrhash_cmp (ri->attr, attr_new))
paul718e3742002-12-13 20:15:29 +00002236 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002237 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00002238
2239 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002240 && peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00002241 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2242 {
2243 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002244 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002245 peer->host,
2246 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2247 p->prefixlen);
2248
paul902212c2006-02-05 17:51:19 +00002249 if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
2250 {
2251 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2252 bgp_process (bgp, rn, afi, safi);
2253 }
paul718e3742002-12-13 20:15:29 +00002254 }
Paul Jakma16d2e242007-04-10 19:32:10 +00002255 else /* Duplicate - odd */
paul718e3742002-12-13 20:15:29 +00002256 {
2257 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002258 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002259 "%s rcvd %s/%d...duplicate ignored",
2260 peer->host,
2261 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2262 p->prefixlen);
hasso93406d82005-02-02 14:40:33 +00002263
2264 /* graceful restart STALE flag unset. */
2265 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2266 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002267 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
paul902212c2006-02-05 17:51:19 +00002268 bgp_process (bgp, rn, afi, safi);
hasso93406d82005-02-02 14:40:33 +00002269 }
paul718e3742002-12-13 20:15:29 +00002270 }
2271
2272 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002273 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05002274 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002275
paul718e3742002-12-13 20:15:29 +00002276 return 0;
2277 }
2278
Paul Jakma16d2e242007-04-10 19:32:10 +00002279 /* Withdraw/Announce before we fully processed the withdraw */
2280 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2281 {
2282 if (BGP_DEBUG (update, UPDATE_IN))
2283 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
2284 peer->host,
2285 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2286 p->prefixlen);
2287 bgp_info_restore (rn, ri);
2288 }
2289
paul718e3742002-12-13 20:15:29 +00002290 /* Received Logging. */
2291 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002292 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002293 peer->host,
2294 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2295 p->prefixlen);
2296
hasso93406d82005-02-02 14:40:33 +00002297 /* graceful restart STALE flag unset. */
2298 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma1a392d42006-09-07 00:24:49 +00002299 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
hasso93406d82005-02-02 14:40:33 +00002300
paul718e3742002-12-13 20:15:29 +00002301 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002302 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul902212c2006-02-05 17:51:19 +00002303
2304 /* implicit withdraw, decrement aggregate and pcount here.
2305 * only if update is accepted, they'll increment below.
2306 */
paul902212c2006-02-05 17:51:19 +00002307 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2308
paul718e3742002-12-13 20:15:29 +00002309 /* Update bgp route dampening information. */
2310 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002311 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002312 {
2313 /* This is implicit withdraw so we should update dampening
2314 information. */
2315 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2316 bgp_damp_withdraw (ri, rn, afi, safi, 1);
paul718e3742002-12-13 20:15:29 +00002317 }
2318
paul718e3742002-12-13 20:15:29 +00002319 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002320 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00002321 ri->attr = attr_new;
2322
2323 /* Update MPLS tag. */
2324 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002325 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002326
Lou Berger050defe2016-01-12 13:41:59 -05002327 bgp_attr_flush (&new_attr);
2328
paul718e3742002-12-13 20:15:29 +00002329 /* Update bgp route dampening information. */
2330 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002331 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002332 {
2333 /* Now we do normal update dampening. */
2334 ret = bgp_damp_update (ri, rn, afi, safi);
2335 if (ret == BGP_DAMP_SUPPRESSED)
2336 {
2337 bgp_unlock_node (rn);
2338 return 0;
2339 }
2340 }
2341
2342 /* Nexthop reachability check. */
2343 if ((afi == AFI_IP || afi == AFI_IP6)
2344 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002345 && (peer->sort == BGP_PEER_IBGP
2346 || peer->sort == BGP_PEER_CONFED
2347 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002348 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002349 {
2350 if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002351 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002352 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002353 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002354 }
2355 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002356 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002357
Lou Berger050defe2016-01-12 13:41:59 -05002358 bgp_attr_flush (&new_attr);
2359
paul718e3742002-12-13 20:15:29 +00002360 /* Process change. */
2361 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2362
2363 bgp_process (bgp, rn, afi, safi);
2364 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002365
paul718e3742002-12-13 20:15:29 +00002366 return 0;
2367 }
2368
2369 /* Received Logging. */
2370 if (BGP_DEBUG (update, UPDATE_IN))
2371 {
ajsd2c1f162004-12-08 21:10:20 +00002372 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002373 peer->host,
2374 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2375 p->prefixlen);
2376 }
2377
paul718e3742002-12-13 20:15:29 +00002378 /* Make new BGP info. */
2379 new = bgp_info_new ();
2380 new->type = type;
2381 new->sub_type = sub_type;
2382 new->peer = peer;
2383 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002384 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002385
2386 /* Update MPLS tag. */
2387 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002388 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002389
2390 /* Nexthop reachability check. */
2391 if ((afi == AFI_IP || afi == AFI_IP6)
2392 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002393 && (peer->sort == BGP_PEER_IBGP
2394 || peer->sort == BGP_PEER_CONFED
2395 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002396 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002397 {
2398 if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002399 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002400 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002401 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002402 }
2403 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002404 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002405
paul902212c2006-02-05 17:51:19 +00002406 /* Increment prefix */
paul718e3742002-12-13 20:15:29 +00002407 bgp_aggregate_increment (bgp, p, new, afi, safi);
2408
2409 /* Register new BGP information. */
2410 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002411
2412 /* route_node_get lock */
2413 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002414
Lou Berger050defe2016-01-12 13:41:59 -05002415 bgp_attr_flush (&new_attr);
2416
paul718e3742002-12-13 20:15:29 +00002417 /* If maximum prefix count is configured and current prefix
2418 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00002419 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
2420 return -1;
paul718e3742002-12-13 20:15:29 +00002421
2422 /* Process change. */
2423 bgp_process (bgp, rn, afi, safi);
2424
2425 return 0;
2426
2427 /* This BGP update is filtered. Log the reason then update BGP
2428 entry. */
2429 filtered:
2430 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002431 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002432 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2433 peer->host,
2434 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2435 p->prefixlen, reason);
2436
2437 if (ri)
paulb40d9392005-08-22 22:34:41 +00002438 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002439
2440 bgp_unlock_node (rn);
Lou Berger050defe2016-01-12 13:41:59 -05002441 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002442
paul718e3742002-12-13 20:15:29 +00002443 return 0;
2444}
2445
2446int
paulfee0f4c2004-09-13 05:12:46 +00002447bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
2448 afi_t afi, safi_t safi, int type, int sub_type,
2449 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2450{
2451 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002452 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002453 struct bgp *bgp;
2454 int ret;
2455
2456 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
2457 soft_reconfig);
2458
2459 bgp = peer->bgp;
2460
2461 /* Process the update for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002462 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002463 {
2464 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2465 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
2466 sub_type, prd, tag);
2467 }
2468
2469 return ret;
2470}
2471
2472int
paul718e3742002-12-13 20:15:29 +00002473bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
paul94f2b392005-06-28 12:44:16 +00002474 afi_t afi, safi_t safi, int type, int sub_type,
2475 struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00002476{
2477 struct bgp *bgp;
2478 char buf[SU_ADDRSTRLEN];
2479 struct bgp_node *rn;
2480 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00002481 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002482 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002483
2484 bgp = peer->bgp;
2485
David Lamparter4584c232015-04-13 09:50:00 +02002486 /* Lookup node. */
2487 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2488
2489 /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2490 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2491 * the iteration over all RS clients.
2492 * Since we need to remove the entry from adj_in anyway, do that first and
2493 * if there was no entry, we don't need to do anything more. */
2494 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2495 && peer != bgp->peer_self)
2496 if (!bgp_adj_in_unset (rn, peer))
2497 {
2498 if (BGP_DEBUG (update, UPDATE_IN))
2499 zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
2500 "not in adj-in", peer->host,
2501 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2502 p->prefixlen);
2503 bgp_unlock_node (rn);
2504 return 0;
2505 }
2506
paulfee0f4c2004-09-13 05:12:46 +00002507 /* Process the withdraw for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002508 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002509 {
2510 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2511 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
2512 }
2513
paul718e3742002-12-13 20:15:29 +00002514 /* Logging. */
2515 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002516 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00002517 peer->host,
2518 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2519 p->prefixlen);
2520
paul718e3742002-12-13 20:15:29 +00002521 /* Lookup withdrawn route. */
2522 for (ri = rn->info; ri; ri = ri->next)
2523 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2524 break;
2525
2526 /* Withdraw specified route from routing table. */
2527 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002528 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paul718e3742002-12-13 20:15:29 +00002529 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002530 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002531 "%s Can't find the route %s/%d", peer->host,
2532 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2533 p->prefixlen);
2534
2535 /* Unlock bgp_node_get() lock. */
2536 bgp_unlock_node (rn);
2537
2538 return 0;
2539}
David Lamparter6b0655a2014-06-04 06:53:35 +02002540
paul718e3742002-12-13 20:15:29 +00002541void
2542bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2543{
2544 struct bgp *bgp;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00002545 struct attr attr;
Jorge Boncompte [DTI2]577ac572012-05-07 16:53:06 +00002546 struct aspath *aspath;
paul718e3742002-12-13 20:15:29 +00002547 struct prefix p;
paul718e3742002-12-13 20:15:29 +00002548 struct peer *from;
Christian Frankedcab1bb2012-12-07 16:45:52 +00002549 struct bgp_node *rn;
2550 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00002551 int ret = RMAP_DENYMATCH;
Paul Jakmafb982c22007-05-04 20:15:47 +00002552
Paul Jakmab2497022007-06-14 11:17:58 +00002553 if (!(afi == AFI_IP || afi == AFI_IP6))
Paul Jakmafb982c22007-05-04 20:15:47 +00002554 return;
2555
paul718e3742002-12-13 20:15:29 +00002556 bgp = peer->bgp;
2557 from = bgp->peer_self;
Paul Jakmafb982c22007-05-04 20:15:47 +00002558
paul718e3742002-12-13 20:15:29 +00002559 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2560 aspath = attr.aspath;
2561 attr.local_pref = bgp->default_local_pref;
2562 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2563
2564 if (afi == AFI_IP)
2565 str2prefix ("0.0.0.0/0", &p);
paul718e3742002-12-13 20:15:29 +00002566 else if (afi == AFI_IP6)
2567 {
Jorge Boncompte [DTI2]6182d652012-05-07 16:53:02 +00002568 struct attr_extra *ae = attr.extra;
2569
paul718e3742002-12-13 20:15:29 +00002570 str2prefix ("::/0", &p);
2571
2572 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00002573 memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00002574 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002575 ae->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00002576
2577 /* If the peer is on shared nextwork and we have link-local
2578 nexthop set it. */
2579 if (peer->shared_network
2580 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2581 {
Paul Jakmafb982c22007-05-04 20:15:47 +00002582 memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00002583 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002584 ae->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00002585 }
2586 }
paul718e3742002-12-13 20:15:29 +00002587
2588 if (peer->default_rmap[afi][safi].name)
2589 {
paulfee0f4c2004-09-13 05:12:46 +00002590 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
Christian Frankedcab1bb2012-12-07 16:45:52 +00002591 for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
2592 {
2593 for (ri = rn->info; ri; ri = ri->next)
2594 {
2595 struct attr dummy_attr;
2596 struct attr_extra dummy_extra;
2597 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00002598
Christian Frankedcab1bb2012-12-07 16:45:52 +00002599 /* Provide dummy so the route-map can't modify the attributes */
2600 dummy_attr.extra = &dummy_extra;
2601 bgp_attr_dup(&dummy_attr, ri->attr);
2602 info.peer = ri->peer;
2603 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00002604
Christian Frankedcab1bb2012-12-07 16:45:52 +00002605 ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
2606 RMAP_BGP, &info);
2607
2608 /* The route map might have set attributes. If we don't flush them
2609 * here, they will be leaked. */
2610 bgp_attr_flush(&dummy_attr);
2611 if (ret != RMAP_DENYMATCH)
2612 break;
2613 }
2614 if (ret != RMAP_DENYMATCH)
2615 break;
2616 }
paulfee0f4c2004-09-13 05:12:46 +00002617 bgp->peer_self->rmap_type = 0;
2618
paul718e3742002-12-13 20:15:29 +00002619 if (ret == RMAP_DENYMATCH)
Christian Frankedcab1bb2012-12-07 16:45:52 +00002620 withdraw = 1;
paul718e3742002-12-13 20:15:29 +00002621 }
2622
2623 if (withdraw)
2624 {
2625 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2626 bgp_default_withdraw_send (peer, afi, safi);
2627 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2628 }
2629 else
2630 {
Christian Frankedcab1bb2012-12-07 16:45:52 +00002631 if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2632 {
2633 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2634 bgp_default_update_send (peer, &attr, afi, safi, from);
2635 }
paul718e3742002-12-13 20:15:29 +00002636 }
Paul Jakmafb982c22007-05-04 20:15:47 +00002637
2638 bgp_attr_extra_free (&attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002639 aspath_unintern (&aspath);
paul718e3742002-12-13 20:15:29 +00002640}
David Lamparter6b0655a2014-06-04 06:53:35 +02002641
paul718e3742002-12-13 20:15:29 +00002642static void
2643bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002644 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002645{
2646 struct bgp_node *rn;
2647 struct bgp_info *ri;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002648 struct attr attr;
2649 struct attr_extra extra;
2650
Lou Berger298cc2f2016-01-12 13:42:02 -05002651 memset(&extra, 0, sizeof(extra));
2652
paul718e3742002-12-13 20:15:29 +00002653 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002654 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002655
Lou Berger298cc2f2016-01-12 13:42:02 -05002656 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00002657 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2658 bgp_default_originate (peer, afi, safi, 0);
2659
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002660 /* It's initialized in bgp_announce_[check|check_rsclient]() */
2661 attr.extra = &extra;
2662
paul718e3742002-12-13 20:15:29 +00002663 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2664 for (ri = rn->info; ri; ri = ri->next)
2665 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2666 {
paulfee0f4c2004-09-13 05:12:46 +00002667 if ( (rsclient) ?
2668 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2669 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002670 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2671 else
2672 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2673 }
Lou Berger298cc2f2016-01-12 13:42:02 -05002674
2675 bgp_attr_flush_encap(&attr);
paul718e3742002-12-13 20:15:29 +00002676}
2677
2678void
2679bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2680{
2681 struct bgp_node *rn;
2682 struct bgp_table *table;
2683
2684 if (peer->status != Established)
2685 return;
2686
2687 if (! peer->afc_nego[afi][safi])
2688 return;
2689
2690 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2691 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2692 return;
2693
Lou Berger298cc2f2016-01-12 13:42:02 -05002694 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
paulfee0f4c2004-09-13 05:12:46 +00002695 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002696 else
2697 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2698 rn = bgp_route_next(rn))
2699 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002700 bgp_announce_table (peer, afi, safi, table, 0);
2701
2702 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2703 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002704}
2705
2706void
2707bgp_announce_route_all (struct peer *peer)
2708{
2709 afi_t afi;
2710 safi_t safi;
2711
2712 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2713 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2714 bgp_announce_route (peer, afi, safi);
2715}
David Lamparter6b0655a2014-06-04 06:53:35 +02002716
paul718e3742002-12-13 20:15:29 +00002717static void
paulfee0f4c2004-09-13 05:12:46 +00002718bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002719 safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
paulfee0f4c2004-09-13 05:12:46 +00002720{
2721 struct bgp_node *rn;
2722 struct bgp_adj_in *ain;
2723
2724 if (! table)
2725 table = rsclient->bgp->rib[afi][safi];
2726
2727 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2728 for (ain = rn->adj_in; ain; ain = ain->next)
2729 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002730 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002731 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002732
paulfee0f4c2004-09-13 05:12:46 +00002733 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
Christian Franked53d8fd2013-01-28 07:14:43 +01002734 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
paulfee0f4c2004-09-13 05:12:46 +00002735 }
2736}
2737
2738void
2739bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2740{
2741 struct bgp_table *table;
2742 struct bgp_node *rn;
2743
Lou Berger298cc2f2016-01-12 13:42:02 -05002744 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002745 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
paulfee0f4c2004-09-13 05:12:46 +00002746
2747 else
2748 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2749 rn = bgp_route_next (rn))
2750 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002751 {
2752 struct prefix_rd prd;
2753 prd.family = AF_UNSPEC;
2754 prd.prefixlen = 64;
2755 memcpy(&prd.val, rn->p.u.val, 8);
2756
2757 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
2758 }
paulfee0f4c2004-09-13 05:12:46 +00002759}
David Lamparter6b0655a2014-06-04 06:53:35 +02002760
paulfee0f4c2004-09-13 05:12:46 +00002761static void
paul718e3742002-12-13 20:15:29 +00002762bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002763 struct bgp_table *table, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00002764{
2765 int ret;
2766 struct bgp_node *rn;
2767 struct bgp_adj_in *ain;
2768
2769 if (! table)
2770 table = peer->bgp->rib[afi][safi];
2771
2772 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2773 for (ain = rn->adj_in; ain; ain = ain->next)
2774 {
2775 if (ain->peer == peer)
2776 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002777 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002778 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002779
paul718e3742002-12-13 20:15:29 +00002780 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2781 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
Christian Franked53d8fd2013-01-28 07:14:43 +01002782 prd, tag, 1);
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002783
paul718e3742002-12-13 20:15:29 +00002784 if (ret < 0)
2785 {
2786 bgp_unlock_node (rn);
2787 return;
2788 }
2789 continue;
2790 }
2791 }
2792}
2793
2794void
2795bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2796{
2797 struct bgp_node *rn;
2798 struct bgp_table *table;
2799
2800 if (peer->status != Established)
2801 return;
2802
Lou Berger298cc2f2016-01-12 13:42:02 -05002803 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002804 bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002805 else
2806 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2807 rn = bgp_route_next (rn))
2808 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002809 {
2810 struct prefix_rd prd;
2811 prd.family = AF_UNSPEC;
2812 prd.prefixlen = 64;
2813 memcpy(&prd.val, rn->p.u.val, 8);
2814
2815 bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
2816 }
paul718e3742002-12-13 20:15:29 +00002817}
David Lamparter6b0655a2014-06-04 06:53:35 +02002818
Chris Caputo228da422009-07-18 05:44:03 +00002819
2820struct bgp_clear_node_queue
2821{
2822 struct bgp_node *rn;
2823 enum bgp_clear_route_type purpose;
2824};
2825
paul200df112005-06-01 11:17:05 +00002826static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00002827bgp_clear_route_node (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002828{
Chris Caputo228da422009-07-18 05:44:03 +00002829 struct bgp_clear_node_queue *cnq = data;
2830 struct bgp_node *rn = cnq->rn;
Paul Jakma64e580a2006-02-21 01:09:01 +00002831 struct peer *peer = wq->spec.data;
paul200df112005-06-01 11:17:05 +00002832 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002833 afi_t afi = bgp_node_table (rn)->afi;
2834 safi_t safi = bgp_node_table (rn)->safi;
paul200df112005-06-01 11:17:05 +00002835
Paul Jakma64e580a2006-02-21 01:09:01 +00002836 assert (rn && peer);
paul200df112005-06-01 11:17:05 +00002837
Paul Jakma64e580a2006-02-21 01:09:01 +00002838 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002839 if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
paul200df112005-06-01 11:17:05 +00002840 {
2841 /* graceful restart STALE flag set. */
Paul Jakma64e580a2006-02-21 01:09:01 +00002842 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2843 && peer->nsf[afi][safi]
paul200df112005-06-01 11:17:05 +00002844 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
Paul Jakma1a392d42006-09-07 00:24:49 +00002845 && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
2846 bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
paul200df112005-06-01 11:17:05 +00002847 else
Paul Jakma64e580a2006-02-21 01:09:01 +00002848 bgp_rib_remove (rn, ri, peer, afi, safi);
paul200df112005-06-01 11:17:05 +00002849 break;
2850 }
paul200df112005-06-01 11:17:05 +00002851 return WQ_SUCCESS;
2852}
2853
2854static void
paul0fb58d52005-11-14 14:31:49 +00002855bgp_clear_node_queue_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002856{
Chris Caputo228da422009-07-18 05:44:03 +00002857 struct bgp_clear_node_queue *cnq = data;
2858 struct bgp_node *rn = cnq->rn;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002859 struct bgp_table *table = bgp_node_table (rn);
Paul Jakma64e580a2006-02-21 01:09:01 +00002860
2861 bgp_unlock_node (rn);
Chris Caputo228da422009-07-18 05:44:03 +00002862 bgp_table_unlock (table);
2863 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
paul200df112005-06-01 11:17:05 +00002864}
2865
2866static void
paul94f2b392005-06-28 12:44:16 +00002867bgp_clear_node_complete (struct work_queue *wq)
paul200df112005-06-01 11:17:05 +00002868{
Paul Jakma64e580a2006-02-21 01:09:01 +00002869 struct peer *peer = wq->spec.data;
2870
Paul Jakma3e0c78e2006-03-06 18:06:53 +00002871 /* Tickle FSM to start moving again */
Paul Jakmaca058a32006-09-14 02:58:49 +00002872 BGP_EVENT_ADD (peer, Clearing_Completed);
Chris Caputo228da422009-07-18 05:44:03 +00002873
2874 peer_unlock (peer); /* bgp_clear_route */
paul200df112005-06-01 11:17:05 +00002875}
2876
2877static void
Paul Jakma64e580a2006-02-21 01:09:01 +00002878bgp_clear_node_queue_init (struct peer *peer)
paul200df112005-06-01 11:17:05 +00002879{
Paul Jakmaa2943652009-07-21 14:02:04 +01002880 char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
Paul Jakma64e580a2006-02-21 01:09:01 +00002881
Paul Jakmaa2943652009-07-21 14:02:04 +01002882 snprintf (wname, sizeof(wname), "clear %s", peer->host);
Paul Jakma64e580a2006-02-21 01:09:01 +00002883#undef CLEAR_QUEUE_NAME_LEN
2884
2885 if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
paul200df112005-06-01 11:17:05 +00002886 {
2887 zlog_err ("%s: Failed to allocate work queue", __func__);
2888 exit (1);
2889 }
Paul Jakma64e580a2006-02-21 01:09:01 +00002890 peer->clear_node_queue->spec.hold = 10;
2891 peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
2892 peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
2893 peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
2894 peer->clear_node_queue->spec.max_retries = 0;
2895
2896 /* we only 'lock' this peer reference when the queue is actually active */
2897 peer->clear_node_queue->spec.data = peer;
paul200df112005-06-01 11:17:05 +00002898}
2899
paul718e3742002-12-13 20:15:29 +00002900static void
2901bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
Chris Caputo228da422009-07-18 05:44:03 +00002902 struct bgp_table *table, struct peer *rsclient,
2903 enum bgp_clear_route_type purpose)
paul718e3742002-12-13 20:15:29 +00002904{
2905 struct bgp_node *rn;
paul200df112005-06-01 11:17:05 +00002906
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002907
paul718e3742002-12-13 20:15:29 +00002908 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002909 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
Paul Jakma64e580a2006-02-21 01:09:01 +00002910
hasso6cf159b2005-03-21 10:28:14 +00002911 /* If still no table => afi/safi isn't configured at all or smth. */
2912 if (! table)
2913 return;
Paul Jakma65ca75e2006-05-04 08:08:15 +00002914
2915 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2916 {
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002917 struct bgp_info *ri;
2918 struct bgp_adj_in *ain;
2919 struct bgp_adj_out *aout;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002920
2921 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2922 * queued for every clearing peer, regardless of whether it is
2923 * relevant to the peer at hand.
2924 *
2925 * Overview: There are 3 different indices which need to be
2926 * scrubbed, potentially, when a peer is removed:
2927 *
2928 * 1 peer's routes visible via the RIB (ie accepted routes)
2929 * 2 peer's routes visible by the (optional) peer's adj-in index
2930 * 3 other routes visible by the peer's adj-out index
2931 *
2932 * 3 there is no hurry in scrubbing, once the struct peer is
2933 * removed from bgp->peer, we could just GC such deleted peer's
2934 * adj-outs at our leisure.
2935 *
2936 * 1 and 2 must be 'scrubbed' in some way, at least made
2937 * invisible via RIB index before peer session is allowed to be
2938 * brought back up. So one needs to know when such a 'search' is
2939 * complete.
2940 *
2941 * Ideally:
2942 *
2943 * - there'd be a single global queue or a single RIB walker
2944 * - rather than tracking which route_nodes still need to be
2945 * examined on a peer basis, we'd track which peers still
2946 * aren't cleared
2947 *
2948 * Given that our per-peer prefix-counts now should be reliable,
2949 * this may actually be achievable. It doesn't seem to be a huge
2950 * problem at this time,
2951 */
Jorge Boncompte [DTI2]24e50f22012-05-07 15:17:33 +00002952 for (ain = rn->adj_in; ain; ain = ain->next)
2953 if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2954 {
2955 bgp_adj_in_remove (rn, ain);
2956 bgp_unlock_node (rn);
2957 break;
2958 }
2959 for (aout = rn->adj_out; aout; aout = aout->next)
2960 if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2961 {
2962 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2963 bgp_unlock_node (rn);
2964 break;
2965 }
2966
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002967 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002968 if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002969 {
Chris Caputo228da422009-07-18 05:44:03 +00002970 struct bgp_clear_node_queue *cnq;
2971
2972 /* both unlocked in bgp_clear_node_queue_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07002973 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00002974 bgp_lock_node (rn);
2975 cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
2976 sizeof (struct bgp_clear_node_queue));
2977 cnq->rn = rn;
2978 cnq->purpose = purpose;
2979 work_queue_add (peer->clear_node_queue, cnq);
2980 break;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002981 }
Paul Jakma65ca75e2006-05-04 08:08:15 +00002982 }
2983 return;
2984}
2985
2986void
Chris Caputo228da422009-07-18 05:44:03 +00002987bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
2988 enum bgp_clear_route_type purpose)
Paul Jakma65ca75e2006-05-04 08:08:15 +00002989{
2990 struct bgp_node *rn;
2991 struct bgp_table *table;
2992 struct peer *rsclient;
2993 struct listnode *node, *nnode;
hasso6cf159b2005-03-21 10:28:14 +00002994
Paul Jakma64e580a2006-02-21 01:09:01 +00002995 if (peer->clear_node_queue == NULL)
2996 bgp_clear_node_queue_init (peer);
paul200df112005-06-01 11:17:05 +00002997
Paul Jakmaca058a32006-09-14 02:58:49 +00002998 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2999 * Idle until it receives a Clearing_Completed event. This protects
3000 * against peers which flap faster than we can we clear, which could
3001 * lead to:
Paul Jakma64e580a2006-02-21 01:09:01 +00003002 *
3003 * a) race with routes from the new session being installed before
3004 * clear_route_node visits the node (to delete the route of that
3005 * peer)
3006 * b) resource exhaustion, clear_route_node likely leads to an entry
3007 * on the process_main queue. Fast-flapping could cause that queue
3008 * to grow and grow.
paul200df112005-06-01 11:17:05 +00003009 */
Donald Sharp7ef42212015-03-30 06:32:52 -07003010
3011 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3012 * the unlock will happen upon work-queue completion; other wise, the
3013 * unlock happens at the end of this function.
3014 */
Paul Jakmaca058a32006-09-14 02:58:49 +00003015 if (!peer->clear_node_queue->thread)
Lou Berger050defe2016-01-12 13:41:59 -05003016 peer_lock (peer); /* bgp_clear_node_complete */
Chris Caputo228da422009-07-18 05:44:03 +00003017 switch (purpose)
paulfee0f4c2004-09-13 05:12:46 +00003018 {
Chris Caputo228da422009-07-18 05:44:03 +00003019 case BGP_CLEAR_ROUTE_NORMAL:
Lou Berger298cc2f2016-01-12 13:42:02 -05003020 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Chris Caputo228da422009-07-18 05:44:03 +00003021 bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
3022 else
3023 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
3024 rn = bgp_route_next (rn))
3025 if ((table = rn->info) != NULL)
3026 bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
3027
3028 for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
3029 if (CHECK_FLAG(rsclient->af_flags[afi][safi],
3030 PEER_FLAG_RSERVER_CLIENT))
3031 bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
3032 break;
3033
3034 case BGP_CLEAR_ROUTE_MY_RSCLIENT:
Lou Berger050defe2016-01-12 13:41:59 -05003035 /*
3036 * gpz 091009: TBD why don't we have special handling for
3037 * SAFI_MPLS_VPN here in the original quagga code?
3038 * (and, by extension, for SAFI_ENCAP)
3039 */
Chris Caputo228da422009-07-18 05:44:03 +00003040 bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
3041 break;
3042
3043 default:
3044 assert (0);
3045 break;
paulfee0f4c2004-09-13 05:12:46 +00003046 }
Donald Sharp7ef42212015-03-30 06:32:52 -07003047
3048 /* unlock if no nodes got added to the clear-node-queue. */
Paul Jakma65ca75e2006-05-04 08:08:15 +00003049 if (!peer->clear_node_queue->thread)
Donald Sharp7ef42212015-03-30 06:32:52 -07003050 peer_unlock (peer);
3051
paul718e3742002-12-13 20:15:29 +00003052}
3053
3054void
3055bgp_clear_route_all (struct peer *peer)
3056{
3057 afi_t afi;
3058 safi_t safi;
3059
3060 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3061 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
Chris Caputo228da422009-07-18 05:44:03 +00003062 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
paul718e3742002-12-13 20:15:29 +00003063}
3064
Lou Berger82dd7072016-01-12 13:41:57 -05003065/*
3066 * Finish freeing things when exiting
3067 */
3068static void
3069bgp_drain_workqueue_immediate (struct work_queue *wq)
3070{
3071 if (!wq)
3072 return;
3073
3074 if (!wq->thread)
3075 {
3076 /*
3077 * no thread implies no queued items
3078 */
3079 assert(!wq->items->count);
3080 return;
3081 }
3082
3083 while (wq->items->count)
3084 {
3085 if (wq->thread)
3086 thread_cancel(wq->thread);
3087 work_queue_run(wq->thread);
3088 }
3089}
3090
3091/*
3092 * Special function to process clear node queue when bgpd is exiting
3093 * and the thread scheduler is no longer running.
3094 */
3095void
3096bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
3097{
3098 if (!peer)
3099 return;
3100
3101 bgp_drain_workqueue_immediate(peer->clear_node_queue);
3102}
3103
3104/*
3105 * The work queues are not specific to a BGP instance, but the
3106 * items in them refer to BGP instances, so this should be called
3107 * before each BGP instance is deleted.
3108 */
3109void
3110bgp_process_queues_drain_immediate(void)
3111{
3112 bgp_drain_workqueue_immediate(bm->process_main_queue);
3113 bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
3114}
3115
paul718e3742002-12-13 20:15:29 +00003116void
3117bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
3118{
3119 struct bgp_table *table;
3120 struct bgp_node *rn;
3121 struct bgp_adj_in *ain;
3122
3123 table = peer->bgp->rib[afi][safi];
3124
3125 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3126 for (ain = rn->adj_in; ain ; ain = ain->next)
3127 if (ain->peer == peer)
3128 {
3129 bgp_adj_in_remove (rn, ain);
3130 bgp_unlock_node (rn);
3131 break;
3132 }
3133}
hasso93406d82005-02-02 14:40:33 +00003134
3135void
3136bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
3137{
3138 struct bgp_node *rn;
3139 struct bgp_info *ri;
3140 struct bgp_table *table;
3141
3142 table = peer->bgp->rib[afi][safi];
3143
3144 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3145 {
3146 for (ri = rn->info; ri; ri = ri->next)
3147 if (ri->peer == peer)
3148 {
3149 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
3150 bgp_rib_remove (rn, ri, peer, afi, safi);
3151 break;
3152 }
3153 }
3154}
David Lamparter6b0655a2014-06-04 06:53:35 +02003155
Lou Berger82dd7072016-01-12 13:41:57 -05003156static void
3157bgp_cleanup_table(struct bgp_table *table, safi_t safi)
3158{
3159 struct bgp_node *rn;
3160 struct bgp_info *ri;
3161 struct bgp_info *next;
3162
3163 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3164 for (ri = rn->info; ri; ri = next)
3165 {
3166 next = ri->next;
3167 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
3168 && ri->type == ZEBRA_ROUTE_BGP
3169 && ri->sub_type == BGP_ROUTE_NORMAL)
3170 bgp_zebra_withdraw (&rn->p, ri, safi);
3171 }
3172}
3173
paul718e3742002-12-13 20:15:29 +00003174/* Delete all kernel routes. */
3175void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003176bgp_cleanup_routes (void)
paul718e3742002-12-13 20:15:29 +00003177{
3178 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00003179 struct listnode *node, *nnode;
Lou Berger82dd7072016-01-12 13:41:57 -05003180 afi_t afi;
paul718e3742002-12-13 20:15:29 +00003181
paul1eb8ef22005-04-07 07:30:20 +00003182 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00003183 {
Lou Berger82dd7072016-01-12 13:41:57 -05003184 for (afi = AFI_IP; afi < AFI_MAX; ++afi)
3185 {
3186 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00003187
Lou Berger82dd7072016-01-12 13:41:57 -05003188 bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00003189
Lou Berger82dd7072016-01-12 13:41:57 -05003190 /*
3191 * VPN and ENCAP tables are two-level (RD is top level)
3192 */
3193 for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
3194 rn = bgp_route_next (rn))
Lou Berger298cc2f2016-01-12 13:42:02 -05003195 {
3196 if (rn->info)
Lou Berger82dd7072016-01-12 13:41:57 -05003197 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003198 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
3199 bgp_table_finish ((struct bgp_table **)&(rn->info));
3200 rn->info = NULL;
3201 bgp_unlock_node(rn);
Lou Berger82dd7072016-01-12 13:41:57 -05003202 }
Lou Berger298cc2f2016-01-12 13:42:02 -05003203 }
3204
3205 for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
3206 rn = bgp_route_next (rn))
3207 {
3208 if (rn->info)
3209 {
3210 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
3211 bgp_table_finish ((struct bgp_table **)&(rn->info));
3212 rn->info = NULL;
3213 bgp_unlock_node(rn);
3214 }
3215 }
Lou Berger82dd7072016-01-12 13:41:57 -05003216 }
paul718e3742002-12-13 20:15:29 +00003217 }
3218}
3219
3220void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003221bgp_reset (void)
paul718e3742002-12-13 20:15:29 +00003222{
3223 vty_reset ();
3224 bgp_zclient_reset ();
3225 access_list_reset ();
3226 prefix_list_reset ();
3227}
David Lamparter6b0655a2014-06-04 06:53:35 +02003228
paul718e3742002-12-13 20:15:29 +00003229/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3230 value. */
3231int
Paul Jakma518a4b72016-02-04 13:27:04 +00003232bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
3233 struct bgp_nlri *packet)
paul718e3742002-12-13 20:15:29 +00003234{
3235 u_char *pnt;
3236 u_char *lim;
3237 struct prefix p;
3238 int psize;
3239 int ret;
3240
3241 /* Check peer status. */
3242 if (peer->status != Established)
3243 return 0;
3244
3245 pnt = packet->nlri;
3246 lim = pnt + packet->length;
3247
Paul Jakma405e9e12016-02-04 17:00:18 +00003248 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3249 syntactic validity. If the field is syntactically incorrect,
3250 then the Error Subcode is set to Invalid Network Field. */
paul718e3742002-12-13 20:15:29 +00003251 for (; pnt < lim; pnt += psize)
3252 {
3253 /* Clear prefix structure. */
3254 memset (&p, 0, sizeof (struct prefix));
3255
3256 /* Fetch prefix length. */
3257 p.prefixlen = *pnt++;
Paul Jakma405e9e12016-02-04 17:00:18 +00003258 /* afi/safi validity already verified by caller, bgp_update_receive */
paul718e3742002-12-13 20:15:29 +00003259 p.family = afi2family (packet->afi);
3260
Paul Jakma405e9e12016-02-04 17:00:18 +00003261 /* Prefix length check. */
3262 if (p.prefixlen > prefix_blen (&p) * 8)
3263 {
3264 plog_err (peer->log,
3265 "%s [Error] Update packet error"
3266 " (wrong prefix length %u for afi %u)",
3267 peer->host, p.prefixlen, packet->afi);
3268 return -1;
3269 }
3270
paul718e3742002-12-13 20:15:29 +00003271 /* Packet size overflow check. */
3272 psize = PSIZE (p.prefixlen);
3273
3274 /* When packet overflow occur return immediately. */
3275 if (pnt + psize > lim)
Paul Jakma405e9e12016-02-04 17:00:18 +00003276 {
3277 plog_err (peer->log,
3278 "%s [Error] Update packet error"
3279 " (prefix length %u overflows packet)",
3280 peer->host, p.prefixlen);
3281 return -1;
3282 }
3283
3284 /* Defensive coding, double-check the psize fits in a struct prefix */
3285 if (psize > (ssize_t) sizeof(p.u))
3286 {
3287 plog_err (peer->log,
3288 "%s [Error] Update packet error"
3289 " (prefix length %u too large for prefix storage %zu!?!!",
3290 peer->host, p.prefixlen, sizeof(p.u));
3291 return -1;
3292 }
paul718e3742002-12-13 20:15:29 +00003293
3294 /* Fetch prefix from NLRI packet. */
3295 memcpy (&p.u.prefix, pnt, psize);
3296
3297 /* Check address. */
3298 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
3299 {
3300 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
3301 {
paulf5ba3872004-07-09 12:11:31 +00003302 /*
Paul Jakma405e9e12016-02-04 17:00:18 +00003303 * From RFC4271 Section 6.3:
3304 *
3305 * If a prefix in the NLRI field is semantically incorrect
3306 * (e.g., an unexpected multicast IP address), an error SHOULD
3307 * be logged locally, and the prefix SHOULD be ignored.
paulf5ba3872004-07-09 12:11:31 +00003308 */
paul718e3742002-12-13 20:15:29 +00003309 zlog (peer->log, LOG_ERR,
Paul Jakma405e9e12016-02-04 17:00:18 +00003310 "%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3311 peer->host, inet_ntoa (p.u.prefix4));
3312 continue;
paul718e3742002-12-13 20:15:29 +00003313 }
3314 }
3315
paul718e3742002-12-13 20:15:29 +00003316 /* Check address. */
3317 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
3318 {
3319 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3320 {
3321 char buf[BUFSIZ];
3322
Paul Jakma405e9e12016-02-04 17:00:18 +00003323 zlog (peer->log, LOG_ERR,
3324 "%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3325 peer->host,
paul718e3742002-12-13 20:15:29 +00003326 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00003327 continue;
3328 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003329 if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6))
3330 {
3331 char buf[BUFSIZ];
3332
3333 zlog (peer->log, LOG_ERR,
3334 "%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3335 peer->host,
3336 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3337 continue;
3338 }
3339 }
paul718e3742002-12-13 20:15:29 +00003340
3341 /* Normal process. */
3342 if (attr)
3343 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
3344 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
3345 else
3346 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
3347 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
3348
3349 /* Address family configuration mismatch or maximum-prefix count
3350 overflow. */
3351 if (ret < 0)
3352 return -1;
3353 }
3354
3355 /* Packet length consistency check. */
3356 if (pnt != lim)
paul718e3742002-12-13 20:15:29 +00003357 {
3358 plog_err (peer->log,
Paul Jakma405e9e12016-02-04 17:00:18 +00003359 "%s [Error] Update packet error"
3360 " (prefix length mismatch with total length)",
3361 peer->host);
paul718e3742002-12-13 20:15:29 +00003362 return -1;
3363 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003364
paul718e3742002-12-13 20:15:29 +00003365 return 0;
3366}
David Lamparter6b0655a2014-06-04 06:53:35 +02003367
paul94f2b392005-06-28 12:44:16 +00003368static struct bgp_static *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003369bgp_static_new (void)
paul718e3742002-12-13 20:15:29 +00003370{
Stephen Hemminger393deb92008-08-18 14:13:29 -07003371 return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
paul718e3742002-12-13 20:15:29 +00003372}
3373
paul94f2b392005-06-28 12:44:16 +00003374static void
paul718e3742002-12-13 20:15:29 +00003375bgp_static_free (struct bgp_static *bgp_static)
3376{
3377 if (bgp_static->rmap.name)
3378 free (bgp_static->rmap.name);
3379 XFREE (MTYPE_BGP_STATIC, bgp_static);
3380}
3381
paul94f2b392005-06-28 12:44:16 +00003382static void
paulfee0f4c2004-09-13 05:12:46 +00003383bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
3384 struct prefix *p, afi_t afi, safi_t safi)
3385{
3386 struct bgp_node *rn;
3387 struct bgp_info *ri;
3388
3389 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3390
3391 /* Check selected route and self inserted route. */
3392 for (ri = rn->info; ri; ri = ri->next)
3393 if (ri->peer == bgp->peer_self
3394 && ri->type == ZEBRA_ROUTE_BGP
3395 && ri->sub_type == BGP_ROUTE_STATIC)
3396 break;
3397
3398 /* Withdraw static BGP route from routing table. */
3399 if (ri)
3400 {
paulfee0f4c2004-09-13 05:12:46 +00003401 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003402 bgp_process (bgp, rn, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003403 }
3404
3405 /* Unlock bgp_node_lookup. */
3406 bgp_unlock_node (rn);
3407}
3408
paul94f2b392005-06-28 12:44:16 +00003409static void
paulfee0f4c2004-09-13 05:12:46 +00003410bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
Paul Jakmafb982c22007-05-04 20:15:47 +00003411 struct bgp_static *bgp_static,
3412 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00003413{
3414 struct bgp_node *rn;
3415 struct bgp_info *ri;
3416 struct bgp_info *new;
3417 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00003418 struct attr *attr_new;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003419 struct attr attr;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003420 struct attr new_attr;
3421 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00003422 struct bgp *bgp;
3423 int ret;
3424 char buf[SU_ADDRSTRLEN];
3425
3426 bgp = rsclient->bgp;
3427
Paul Jakma06e110f2006-05-12 23:29:22 +00003428 assert (bgp_static);
3429 if (!bgp_static)
3430 return;
3431
paulfee0f4c2004-09-13 05:12:46 +00003432 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3433
3434 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakma06e110f2006-05-12 23:29:22 +00003435
3436 attr.nexthop = bgp_static->igpnexthop;
3437 attr.med = bgp_static->igpmetric;
3438 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Paul Jakma41367172007-08-06 15:24:51 +00003439
Paul Jakma41367172007-08-06 15:24:51 +00003440 if (bgp_static->atomic)
3441 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3442
paulfee0f4c2004-09-13 05:12:46 +00003443 /* Apply network route-map for export to this rsclient. */
3444 if (bgp_static->rmap.name)
3445 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003446 struct attr attr_tmp = attr;
paulfee0f4c2004-09-13 05:12:46 +00003447 info.peer = rsclient;
Paul Jakmafb982c22007-05-04 20:15:47 +00003448 info.attr = &attr_tmp;
3449
paulfee0f4c2004-09-13 05:12:46 +00003450 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
3451 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
3452
3453 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3454
3455 rsclient->rmap_type = 0;
3456
3457 if (ret == RMAP_DENYMATCH)
3458 {
3459 /* Free uninterned attribute. */
Paul Jakmafb982c22007-05-04 20:15:47 +00003460 bgp_attr_flush (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003461
3462 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003463 aspath_unintern (&attr.aspath);
paulfee0f4c2004-09-13 05:12:46 +00003464 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
Paul Jakmafb982c22007-05-04 20:15:47 +00003465 bgp_attr_extra_free (&attr);
3466
paulfee0f4c2004-09-13 05:12:46 +00003467 return;
3468 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003469 attr_new = bgp_attr_intern (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003470 }
3471 else
3472 attr_new = bgp_attr_intern (&attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003473
3474 new_attr.extra = &new_extra;
Stephen Hemminger7badc262010-08-05 10:26:31 -07003475 bgp_attr_dup(&new_attr, attr_new);
Paul Jakmafb982c22007-05-04 20:15:47 +00003476
paulfee0f4c2004-09-13 05:12:46 +00003477 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3478
Paul Jakmafb982c22007-05-04 20:15:47 +00003479 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi)
3480 == RMAP_DENY)
3481 {
paulfee0f4c2004-09-13 05:12:46 +00003482 /* This BGP update is filtered. Log the reason then update BGP entry. */
3483 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00003484 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00003485 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3486 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
3487 p->prefixlen, rsclient->host);
3488
3489 bgp->peer_self->rmap_type = 0;
3490
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003491 bgp_attr_unintern (&attr_new);
3492 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003493 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003494
3495 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3496
3497 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003498 }
paulfee0f4c2004-09-13 05:12:46 +00003499
3500 bgp->peer_self->rmap_type = 0;
3501
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003502 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00003503 attr_new = bgp_attr_intern (&new_attr);
3504
3505 for (ri = rn->info; ri; ri = ri->next)
3506 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3507 && ri->sub_type == BGP_ROUTE_STATIC)
3508 break;
3509
3510 if (ri)
3511 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003512 if (attrhash_cmp (ri->attr, attr_new) &&
3513 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paulfee0f4c2004-09-13 05:12:46 +00003514 {
3515 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003516 bgp_attr_unintern (&attr_new);
3517 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003518 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003519 return;
3520 }
3521 else
3522 {
3523 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003524 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00003525
3526 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003527 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3528 bgp_info_restore(rn, ri);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003529 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00003530 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003531 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003532
3533 /* Process change. */
3534 bgp_process (bgp, rn, afi, safi);
3535 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003536 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003537 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003538 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003539 }
paulfee0f4c2004-09-13 05:12:46 +00003540 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003541
paulfee0f4c2004-09-13 05:12:46 +00003542 /* Make new BGP info. */
3543 new = bgp_info_new ();
3544 new->type = ZEBRA_ROUTE_BGP;
3545 new->sub_type = BGP_ROUTE_STATIC;
3546 new->peer = bgp->peer_self;
3547 SET_FLAG (new->flags, BGP_INFO_VALID);
3548 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003549 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003550
3551 /* Register new BGP information. */
3552 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003553
3554 /* route_node_get lock */
3555 bgp_unlock_node (rn);
3556
paulfee0f4c2004-09-13 05:12:46 +00003557 /* Process change. */
3558 bgp_process (bgp, rn, afi, safi);
3559
3560 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003561 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003562 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003563}
3564
paul94f2b392005-06-28 12:44:16 +00003565static void
paulfee0f4c2004-09-13 05:12:46 +00003566bgp_static_update_main (struct bgp *bgp, struct prefix *p,
paul718e3742002-12-13 20:15:29 +00003567 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3568{
3569 struct bgp_node *rn;
3570 struct bgp_info *ri;
3571 struct bgp_info *new;
3572 struct bgp_info info;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003573 struct attr attr;
paul718e3742002-12-13 20:15:29 +00003574 struct attr *attr_new;
3575 int ret;
3576
Paul Jakmadd8103a2006-05-12 23:27:30 +00003577 assert (bgp_static);
3578 if (!bgp_static)
3579 return;
3580
paulfee0f4c2004-09-13 05:12:46 +00003581 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003582
3583 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakmadd8103a2006-05-12 23:27:30 +00003584
3585 attr.nexthop = bgp_static->igpnexthop;
3586 attr.med = bgp_static->igpmetric;
3587 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
paul718e3742002-12-13 20:15:29 +00003588
Paul Jakma41367172007-08-06 15:24:51 +00003589 if (bgp_static->atomic)
3590 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3591
paul718e3742002-12-13 20:15:29 +00003592 /* Apply route-map. */
3593 if (bgp_static->rmap.name)
3594 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003595 struct attr attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00003596 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00003597 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00003598
paulfee0f4c2004-09-13 05:12:46 +00003599 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3600
paul718e3742002-12-13 20:15:29 +00003601 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00003602
paulfee0f4c2004-09-13 05:12:46 +00003603 bgp->peer_self->rmap_type = 0;
3604
paul718e3742002-12-13 20:15:29 +00003605 if (ret == RMAP_DENYMATCH)
3606 {
3607 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00003608 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003609
3610 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003611 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003612 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003613 bgp_static_withdraw (bgp, p, afi, safi);
3614 return;
3615 }
paul286e1e72003-08-08 00:24:31 +00003616 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003617 }
paul286e1e72003-08-08 00:24:31 +00003618 else
3619 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00003620
3621 for (ri = rn->info; ri; ri = ri->next)
3622 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3623 && ri->sub_type == BGP_ROUTE_STATIC)
3624 break;
3625
3626 if (ri)
3627 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003628 if (attrhash_cmp (ri->attr, attr_new) &&
3629 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00003630 {
3631 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003632 bgp_attr_unintern (&attr_new);
3633 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003634 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003635 return;
3636 }
3637 else
3638 {
3639 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003640 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00003641
3642 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003643 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3644 bgp_info_restore(rn, ri);
3645 else
3646 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003647 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00003648 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003649 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003650
3651 /* Process change. */
3652 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3653 bgp_process (bgp, rn, afi, safi);
3654 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003655 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003656 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003657 return;
3658 }
3659 }
3660
3661 /* Make new BGP info. */
3662 new = bgp_info_new ();
3663 new->type = ZEBRA_ROUTE_BGP;
3664 new->sub_type = BGP_ROUTE_STATIC;
3665 new->peer = bgp->peer_self;
3666 SET_FLAG (new->flags, BGP_INFO_VALID);
3667 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003668 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003669
3670 /* Aggregate address increment. */
3671 bgp_aggregate_increment (bgp, p, new, afi, safi);
3672
3673 /* Register new BGP information. */
3674 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003675
3676 /* route_node_get lock */
3677 bgp_unlock_node (rn);
3678
paul718e3742002-12-13 20:15:29 +00003679 /* Process change. */
3680 bgp_process (bgp, rn, afi, safi);
3681
3682 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003683 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003684 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003685}
3686
3687void
paulfee0f4c2004-09-13 05:12:46 +00003688bgp_static_update (struct bgp *bgp, struct prefix *p,
3689 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3690{
3691 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00003692 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00003693
3694 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
3695
paul1eb8ef22005-04-07 07:30:20 +00003696 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00003697 {
Paul Jakmada5b30f2006-05-08 14:37:17 +00003698 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
3699 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003700 }
3701}
3702
paul718e3742002-12-13 20:15:29 +00003703void
3704bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
3705 safi_t safi)
3706{
3707 struct bgp_node *rn;
3708 struct bgp_info *ri;
3709
paulfee0f4c2004-09-13 05:12:46 +00003710 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003711
3712 /* Check selected route and self inserted route. */
3713 for (ri = rn->info; ri; ri = ri->next)
3714 if (ri->peer == bgp->peer_self
3715 && ri->type == ZEBRA_ROUTE_BGP
3716 && ri->sub_type == BGP_ROUTE_STATIC)
3717 break;
3718
3719 /* Withdraw static BGP route from routing table. */
3720 if (ri)
3721 {
3722 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003723 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003724 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003725 }
3726
3727 /* Unlock bgp_node_lookup. */
3728 bgp_unlock_node (rn);
3729}
3730
3731void
paulfee0f4c2004-09-13 05:12:46 +00003732bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3733{
3734 struct bgp_static *bgp_static;
3735 struct bgp *bgp;
3736 struct bgp_node *rn;
3737 struct prefix *p;
3738
3739 bgp = rsclient->bgp;
3740
3741 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3742 if ((bgp_static = rn->info) != NULL)
3743 {
3744 p = &rn->p;
3745
3746 bgp_static_update_rsclient (rsclient, p, bgp_static,
3747 afi, safi);
3748 }
3749}
3750
Lou Bergera76d9ca2016-01-12 13:41:53 -05003751/*
3752 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3753 */
paul94f2b392005-06-28 12:44:16 +00003754static void
Lou Bergera76d9ca2016-01-12 13:41:53 -05003755bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3756 safi_t safi, struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00003757{
3758 struct bgp_node *rn;
3759 struct bgp_info *ri;
3760
paulfee0f4c2004-09-13 05:12:46 +00003761 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00003762
3763 /* Check selected route and self inserted route. */
3764 for (ri = rn->info; ri; ri = ri->next)
3765 if (ri->peer == bgp->peer_self
3766 && ri->type == ZEBRA_ROUTE_BGP
3767 && ri->sub_type == BGP_ROUTE_STATIC)
3768 break;
3769
3770 /* Withdraw static BGP route from routing table. */
3771 if (ri)
3772 {
3773 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003774 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003775 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003776 }
3777
3778 /* Unlock bgp_node_lookup. */
3779 bgp_unlock_node (rn);
3780}
3781
Lou Bergera76d9ca2016-01-12 13:41:53 -05003782static void
3783bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3784 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3785{
3786 struct bgp_node *rn;
3787 struct bgp_info *new;
3788 struct attr *attr_new;
3789 struct attr attr = { 0 };
3790 struct bgp_info *ri;
3791
3792 assert (bgp_static);
3793
3794 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3795
3796 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3797
3798 attr.nexthop = bgp_static->igpnexthop;
3799 attr.med = bgp_static->igpmetric;
3800 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3801
3802 /* Apply route-map. */
3803 if (bgp_static->rmap.name)
3804 {
3805 struct attr attr_tmp = attr;
3806 struct bgp_info info;
3807 int ret;
3808
3809 info.peer = bgp->peer_self;
3810 info.attr = &attr_tmp;
3811
3812 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3813
3814 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3815
3816 bgp->peer_self->rmap_type = 0;
3817
3818 if (ret == RMAP_DENYMATCH)
3819 {
3820 /* Free uninterned attribute. */
3821 bgp_attr_flush (&attr_tmp);
3822
3823 /* Unintern original. */
3824 aspath_unintern (&attr.aspath);
3825 bgp_attr_extra_free (&attr);
3826 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3827 bgp_static->tag);
3828 return;
3829 }
3830
3831 attr_new = bgp_attr_intern (&attr_tmp);
3832 }
3833 else
3834 {
3835 attr_new = bgp_attr_intern (&attr);
3836 }
3837
3838 for (ri = rn->info; ri; ri = ri->next)
3839 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3840 && ri->sub_type == BGP_ROUTE_STATIC)
3841 break;
3842
3843 if (ri)
3844 {
3845 if (attrhash_cmp (ri->attr, attr_new) &&
3846 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3847 {
3848 bgp_unlock_node (rn);
3849 bgp_attr_unintern (&attr_new);
3850 aspath_unintern (&attr.aspath);
3851 bgp_attr_extra_free (&attr);
3852 return;
3853 }
3854 else
3855 {
3856 /* The attribute is changed. */
3857 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3858
3859 /* Rewrite BGP route information. */
3860 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3861 bgp_info_restore(rn, ri);
3862 else
3863 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3864 bgp_attr_unintern (&ri->attr);
3865 ri->attr = attr_new;
3866 ri->uptime = bgp_clock ();
3867
3868 /* Process change. */
3869 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3870 bgp_process (bgp, rn, afi, safi);
3871 bgp_unlock_node (rn);
3872 aspath_unintern (&attr.aspath);
3873 bgp_attr_extra_free (&attr);
3874 return;
3875 }
3876 }
3877
3878
3879 /* Make new BGP info. */
3880 new = bgp_info_new ();
3881 new->type = ZEBRA_ROUTE_BGP;
3882 new->sub_type = BGP_ROUTE_STATIC;
3883 new->peer = bgp->peer_self;
3884 new->attr = attr_new;
3885 SET_FLAG (new->flags, BGP_INFO_VALID);
3886 new->uptime = bgp_clock ();
3887 new->extra = bgp_info_extra_new();
3888 memcpy (new->extra->tag, bgp_static->tag, 3);
3889
3890 /* Aggregate address increment. */
3891 bgp_aggregate_increment (bgp, p, new, afi, safi);
3892
3893 /* Register new BGP information. */
3894 bgp_info_add (rn, new);
3895
3896 /* route_node_get lock */
3897 bgp_unlock_node (rn);
3898
3899 /* Process change. */
3900 bgp_process (bgp, rn, afi, safi);
3901
3902 /* Unintern original. */
3903 aspath_unintern (&attr.aspath);
3904 bgp_attr_extra_free (&attr);
3905}
3906
paul718e3742002-12-13 20:15:29 +00003907/* Configure static BGP network. When user don't run zebra, static
3908 route should be installed as valid. */
paul94f2b392005-06-28 12:44:16 +00003909static int
paulfd79ac92004-10-13 05:06:08 +00003910bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003911 afi_t afi, safi_t safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003912{
3913 int ret;
3914 struct prefix p;
3915 struct bgp_static *bgp_static;
3916 struct bgp_node *rn;
Paul Jakma41367172007-08-06 15:24:51 +00003917 u_char need_update = 0;
paul718e3742002-12-13 20:15:29 +00003918
3919 /* Convert IP prefix string to struct prefix. */
3920 ret = str2prefix (ip_str, &p);
3921 if (! ret)
3922 {
3923 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3924 return CMD_WARNING;
3925 }
paul718e3742002-12-13 20:15:29 +00003926 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3927 {
3928 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3929 VTY_NEWLINE);
3930 return CMD_WARNING;
3931 }
paul718e3742002-12-13 20:15:29 +00003932
3933 apply_mask (&p);
3934
3935 /* Set BGP static route configuration. */
3936 rn = bgp_node_get (bgp->route[afi][safi], &p);
3937
3938 if (rn->info)
3939 {
3940 /* Configuration change. */
3941 bgp_static = rn->info;
3942
3943 /* Check previous routes are installed into BGP. */
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003944 if (bgp_static->valid && bgp_static->backdoor != backdoor)
3945 need_update = 1;
Paul Jakma41367172007-08-06 15:24:51 +00003946
paul718e3742002-12-13 20:15:29 +00003947 bgp_static->backdoor = backdoor;
Paul Jakma41367172007-08-06 15:24:51 +00003948
paul718e3742002-12-13 20:15:29 +00003949 if (rmap)
3950 {
3951 if (bgp_static->rmap.name)
3952 free (bgp_static->rmap.name);
3953 bgp_static->rmap.name = strdup (rmap);
3954 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3955 }
3956 else
3957 {
3958 if (bgp_static->rmap.name)
3959 free (bgp_static->rmap.name);
3960 bgp_static->rmap.name = NULL;
3961 bgp_static->rmap.map = NULL;
3962 bgp_static->valid = 0;
3963 }
3964 bgp_unlock_node (rn);
3965 }
3966 else
3967 {
3968 /* New configuration. */
3969 bgp_static = bgp_static_new ();
3970 bgp_static->backdoor = backdoor;
3971 bgp_static->valid = 0;
3972 bgp_static->igpmetric = 0;
3973 bgp_static->igpnexthop.s_addr = 0;
Paul Jakma41367172007-08-06 15:24:51 +00003974
paul718e3742002-12-13 20:15:29 +00003975 if (rmap)
3976 {
3977 if (bgp_static->rmap.name)
3978 free (bgp_static->rmap.name);
3979 bgp_static->rmap.name = strdup (rmap);
3980 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3981 }
3982 rn->info = bgp_static;
3983 }
3984
3985 /* If BGP scan is not enabled, we should install this route here. */
3986 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3987 {
3988 bgp_static->valid = 1;
3989
3990 if (need_update)
3991 bgp_static_withdraw (bgp, &p, afi, safi);
3992
3993 if (! bgp_static->backdoor)
3994 bgp_static_update (bgp, &p, bgp_static, afi, safi);
3995 }
3996
3997 return CMD_SUCCESS;
3998}
3999
4000/* Configure static BGP network. */
paul94f2b392005-06-28 12:44:16 +00004001static int
paulfd79ac92004-10-13 05:06:08 +00004002bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
Michael Lambert4c9641b2010-07-22 13:20:55 -04004003 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004004{
4005 int ret;
4006 struct prefix p;
4007 struct bgp_static *bgp_static;
4008 struct bgp_node *rn;
4009
4010 /* Convert IP prefix string to struct prefix. */
4011 ret = str2prefix (ip_str, &p);
4012 if (! ret)
4013 {
4014 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4015 return CMD_WARNING;
4016 }
paul718e3742002-12-13 20:15:29 +00004017 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4018 {
4019 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4020 VTY_NEWLINE);
4021 return CMD_WARNING;
4022 }
paul718e3742002-12-13 20:15:29 +00004023
4024 apply_mask (&p);
4025
4026 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4027 if (! rn)
4028 {
4029 vty_out (vty, "%% Can't find specified static route configuration.%s",
4030 VTY_NEWLINE);
4031 return CMD_WARNING;
4032 }
4033
4034 bgp_static = rn->info;
Paul Jakma41367172007-08-06 15:24:51 +00004035
paul718e3742002-12-13 20:15:29 +00004036 /* Update BGP RIB. */
4037 if (! bgp_static->backdoor)
4038 bgp_static_withdraw (bgp, &p, afi, safi);
4039
4040 /* Clear configuration. */
4041 bgp_static_free (bgp_static);
4042 rn->info = NULL;
4043 bgp_unlock_node (rn);
4044 bgp_unlock_node (rn);
4045
4046 return CMD_SUCCESS;
4047}
4048
4049/* Called from bgp_delete(). Delete all static routes from the BGP
4050 instance. */
4051void
4052bgp_static_delete (struct bgp *bgp)
4053{
4054 afi_t afi;
4055 safi_t safi;
4056 struct bgp_node *rn;
4057 struct bgp_node *rm;
4058 struct bgp_table *table;
4059 struct bgp_static *bgp_static;
4060
4061 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4062 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4063 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4064 if (rn->info != NULL)
4065 {
Lou Berger298cc2f2016-01-12 13:42:02 -05004066 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004067 {
4068 table = rn->info;
4069
4070 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4071 {
4072 bgp_static = rn->info;
Lou Bergera76d9ca2016-01-12 13:41:53 -05004073 bgp_static_withdraw_safi (bgp, &rm->p,
4074 AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00004075 (struct prefix_rd *)&rn->p,
4076 bgp_static->tag);
4077 bgp_static_free (bgp_static);
4078 rn->info = NULL;
4079 bgp_unlock_node (rn);
4080 }
4081 }
4082 else
4083 {
4084 bgp_static = rn->info;
4085 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4086 bgp_static_free (bgp_static);
4087 rn->info = NULL;
4088 bgp_unlock_node (rn);
4089 }
4090 }
4091}
4092
Lou Bergera76d9ca2016-01-12 13:41:53 -05004093/*
4094 * gpz 110624
4095 * Currently this is used to set static routes for VPN and ENCAP.
4096 * I think it can probably be factored with bgp_static_set.
4097 */
paul718e3742002-12-13 20:15:29 +00004098int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004099bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4100 const char *rd_str, const char *tag_str,
4101 const char *rmap_str)
paul718e3742002-12-13 20:15:29 +00004102{
4103 int ret;
4104 struct prefix p;
4105 struct prefix_rd prd;
4106 struct bgp *bgp;
4107 struct bgp_node *prn;
4108 struct bgp_node *rn;
4109 struct bgp_table *table;
4110 struct bgp_static *bgp_static;
4111 u_char tag[3];
4112
4113 bgp = vty->index;
4114
4115 ret = str2prefix (ip_str, &p);
4116 if (! ret)
4117 {
4118 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4119 return CMD_WARNING;
4120 }
4121 apply_mask (&p);
4122
4123 ret = str2prefix_rd (rd_str, &prd);
4124 if (! ret)
4125 {
4126 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4127 return CMD_WARNING;
4128 }
4129
4130 ret = str2tag (tag_str, tag);
4131 if (! ret)
4132 {
4133 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4134 return CMD_WARNING;
4135 }
4136
Lou Bergera76d9ca2016-01-12 13:41:53 -05004137 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004138 (struct prefix *)&prd);
4139 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004140 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004141 else
4142 bgp_unlock_node (prn);
4143 table = prn->info;
4144
4145 rn = bgp_node_get (table, &p);
4146
4147 if (rn->info)
4148 {
4149 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4150 bgp_unlock_node (rn);
4151 }
4152 else
4153 {
4154 /* New configuration. */
4155 bgp_static = bgp_static_new ();
Lou Bergera76d9ca2016-01-12 13:41:53 -05004156 bgp_static->backdoor = 0;
4157 bgp_static->valid = 0;
4158 bgp_static->igpmetric = 0;
4159 bgp_static->igpnexthop.s_addr = 0;
4160 memcpy(bgp_static->tag, tag, 3);
4161 bgp_static->prd = prd;
4162
4163 if (rmap_str)
4164 {
4165 if (bgp_static->rmap.name)
4166 free (bgp_static->rmap.name);
4167 bgp_static->rmap.name = strdup (rmap_str);
4168 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4169 }
paul718e3742002-12-13 20:15:29 +00004170 rn->info = bgp_static;
4171
Lou Bergera76d9ca2016-01-12 13:41:53 -05004172 bgp_static->valid = 1;
4173 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004174 }
4175
4176 return CMD_SUCCESS;
4177}
4178
4179/* Configure static BGP network. */
4180int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004181bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4182 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00004183{
4184 int ret;
4185 struct bgp *bgp;
4186 struct prefix p;
4187 struct prefix_rd prd;
4188 struct bgp_node *prn;
4189 struct bgp_node *rn;
4190 struct bgp_table *table;
4191 struct bgp_static *bgp_static;
4192 u_char tag[3];
4193
4194 bgp = vty->index;
4195
4196 /* Convert IP prefix string to struct prefix. */
4197 ret = str2prefix (ip_str, &p);
4198 if (! ret)
4199 {
4200 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4201 return CMD_WARNING;
4202 }
4203 apply_mask (&p);
4204
4205 ret = str2prefix_rd (rd_str, &prd);
4206 if (! ret)
4207 {
4208 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4209 return CMD_WARNING;
4210 }
4211
4212 ret = str2tag (tag_str, tag);
4213 if (! ret)
4214 {
4215 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4216 return CMD_WARNING;
4217 }
4218
Lou Bergera76d9ca2016-01-12 13:41:53 -05004219 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004220 (struct prefix *)&prd);
4221 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004222 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004223 else
4224 bgp_unlock_node (prn);
4225 table = prn->info;
4226
4227 rn = bgp_node_lookup (table, &p);
4228
4229 if (rn)
4230 {
Lou Bergera76d9ca2016-01-12 13:41:53 -05004231 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
paul718e3742002-12-13 20:15:29 +00004232
4233 bgp_static = rn->info;
4234 bgp_static_free (bgp_static);
4235 rn->info = NULL;
4236 bgp_unlock_node (rn);
4237 bgp_unlock_node (rn);
4238 }
4239 else
4240 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4241
4242 return CMD_SUCCESS;
4243}
David Lamparter6b0655a2014-06-04 06:53:35 +02004244
paul718e3742002-12-13 20:15:29 +00004245DEFUN (bgp_network,
4246 bgp_network_cmd,
4247 "network A.B.C.D/M",
4248 "Specify a network to announce via BGP\n"
4249 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4250{
4251 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004252 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004253}
4254
4255DEFUN (bgp_network_route_map,
4256 bgp_network_route_map_cmd,
4257 "network A.B.C.D/M route-map WORD",
4258 "Specify a network to announce via BGP\n"
4259 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4260 "Route-map to modify the attributes\n"
4261 "Name of the route map\n")
4262{
4263 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004264 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004265}
4266
4267DEFUN (bgp_network_backdoor,
4268 bgp_network_backdoor_cmd,
4269 "network A.B.C.D/M backdoor",
4270 "Specify a network to announce via BGP\n"
4271 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4272 "Specify a BGP backdoor route\n")
4273{
Paul Jakma41367172007-08-06 15:24:51 +00004274 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004275 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004276}
4277
4278DEFUN (bgp_network_mask,
4279 bgp_network_mask_cmd,
4280 "network A.B.C.D mask A.B.C.D",
4281 "Specify a network to announce via BGP\n"
4282 "Network number\n"
4283 "Network mask\n"
4284 "Network mask\n")
4285{
4286 int ret;
4287 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004288
paul718e3742002-12-13 20:15:29 +00004289 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4290 if (! ret)
4291 {
4292 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4293 return CMD_WARNING;
4294 }
4295
4296 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004297 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004298}
4299
4300DEFUN (bgp_network_mask_route_map,
4301 bgp_network_mask_route_map_cmd,
4302 "network A.B.C.D mask A.B.C.D route-map WORD",
4303 "Specify a network to announce via BGP\n"
4304 "Network number\n"
4305 "Network mask\n"
4306 "Network mask\n"
4307 "Route-map to modify the attributes\n"
4308 "Name of the route map\n")
4309{
4310 int ret;
4311 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004312
paul718e3742002-12-13 20:15:29 +00004313 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4314 if (! ret)
4315 {
4316 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4317 return CMD_WARNING;
4318 }
4319
4320 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004321 AFI_IP, bgp_node_safi (vty), argv[2], 0);
paul718e3742002-12-13 20:15:29 +00004322}
4323
4324DEFUN (bgp_network_mask_backdoor,
4325 bgp_network_mask_backdoor_cmd,
4326 "network A.B.C.D mask A.B.C.D backdoor",
4327 "Specify a network to announce via BGP\n"
4328 "Network number\n"
4329 "Network mask\n"
4330 "Network mask\n"
4331 "Specify a BGP backdoor route\n")
4332{
4333 int ret;
4334 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004335
paul718e3742002-12-13 20:15:29 +00004336 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4337 if (! ret)
4338 {
4339 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4340 return CMD_WARNING;
4341 }
4342
Paul Jakma41367172007-08-06 15:24:51 +00004343 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004344 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004345}
4346
4347DEFUN (bgp_network_mask_natural,
4348 bgp_network_mask_natural_cmd,
4349 "network A.B.C.D",
4350 "Specify a network to announce via BGP\n"
4351 "Network number\n")
4352{
4353 int ret;
4354 char prefix_str[BUFSIZ];
4355
4356 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4357 if (! ret)
4358 {
4359 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4360 return CMD_WARNING;
4361 }
4362
4363 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004364 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004365}
4366
4367DEFUN (bgp_network_mask_natural_route_map,
4368 bgp_network_mask_natural_route_map_cmd,
4369 "network A.B.C.D route-map WORD",
4370 "Specify a network to announce via BGP\n"
4371 "Network number\n"
4372 "Route-map to modify the attributes\n"
4373 "Name of the route map\n")
4374{
4375 int ret;
4376 char prefix_str[BUFSIZ];
4377
4378 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4379 if (! ret)
4380 {
4381 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4382 return CMD_WARNING;
4383 }
4384
4385 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004386 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004387}
4388
4389DEFUN (bgp_network_mask_natural_backdoor,
4390 bgp_network_mask_natural_backdoor_cmd,
4391 "network A.B.C.D backdoor",
4392 "Specify a network to announce via BGP\n"
4393 "Network number\n"
4394 "Specify a BGP backdoor route\n")
4395{
4396 int ret;
4397 char prefix_str[BUFSIZ];
4398
4399 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4400 if (! ret)
4401 {
4402 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4403 return CMD_WARNING;
4404 }
4405
Paul Jakma41367172007-08-06 15:24:51 +00004406 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004407 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004408}
4409
4410DEFUN (no_bgp_network,
4411 no_bgp_network_cmd,
4412 "no network A.B.C.D/M",
4413 NO_STR
4414 "Specify a network to announce via BGP\n"
4415 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4416{
4417 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4418 bgp_node_safi (vty));
4419}
4420
4421ALIAS (no_bgp_network,
4422 no_bgp_network_route_map_cmd,
4423 "no network A.B.C.D/M route-map WORD",
4424 NO_STR
4425 "Specify a network to announce via BGP\n"
4426 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4427 "Route-map to modify the attributes\n"
4428 "Name of the route map\n")
4429
4430ALIAS (no_bgp_network,
4431 no_bgp_network_backdoor_cmd,
4432 "no network A.B.C.D/M backdoor",
4433 NO_STR
4434 "Specify a network to announce via BGP\n"
4435 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4436 "Specify a BGP backdoor route\n")
4437
4438DEFUN (no_bgp_network_mask,
4439 no_bgp_network_mask_cmd,
4440 "no network A.B.C.D mask A.B.C.D",
4441 NO_STR
4442 "Specify a network to announce via BGP\n"
4443 "Network number\n"
4444 "Network mask\n"
4445 "Network mask\n")
4446{
4447 int ret;
4448 char prefix_str[BUFSIZ];
4449
4450 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4451 if (! ret)
4452 {
4453 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4454 return CMD_WARNING;
4455 }
4456
4457 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4458 bgp_node_safi (vty));
4459}
4460
4461ALIAS (no_bgp_network_mask,
4462 no_bgp_network_mask_route_map_cmd,
4463 "no network A.B.C.D mask A.B.C.D route-map WORD",
4464 NO_STR
4465 "Specify a network to announce via BGP\n"
4466 "Network number\n"
4467 "Network mask\n"
4468 "Network mask\n"
4469 "Route-map to modify the attributes\n"
4470 "Name of the route map\n")
4471
4472ALIAS (no_bgp_network_mask,
4473 no_bgp_network_mask_backdoor_cmd,
4474 "no network A.B.C.D mask A.B.C.D backdoor",
4475 NO_STR
4476 "Specify a network to announce via BGP\n"
4477 "Network number\n"
4478 "Network mask\n"
4479 "Network mask\n"
4480 "Specify a BGP backdoor route\n")
4481
4482DEFUN (no_bgp_network_mask_natural,
4483 no_bgp_network_mask_natural_cmd,
4484 "no network A.B.C.D",
4485 NO_STR
4486 "Specify a network to announce via BGP\n"
4487 "Network number\n")
4488{
4489 int ret;
4490 char prefix_str[BUFSIZ];
4491
4492 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4493 if (! ret)
4494 {
4495 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4496 return CMD_WARNING;
4497 }
4498
4499 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4500 bgp_node_safi (vty));
4501}
4502
4503ALIAS (no_bgp_network_mask_natural,
4504 no_bgp_network_mask_natural_route_map_cmd,
4505 "no network A.B.C.D route-map WORD",
4506 NO_STR
4507 "Specify a network to announce via BGP\n"
4508 "Network number\n"
4509 "Route-map to modify the attributes\n"
4510 "Name of the route map\n")
4511
4512ALIAS (no_bgp_network_mask_natural,
4513 no_bgp_network_mask_natural_backdoor_cmd,
4514 "no network A.B.C.D backdoor",
4515 NO_STR
4516 "Specify a network to announce via BGP\n"
4517 "Network number\n"
4518 "Specify a BGP backdoor route\n")
4519
paul718e3742002-12-13 20:15:29 +00004520DEFUN (ipv6_bgp_network,
4521 ipv6_bgp_network_cmd,
4522 "network X:X::X:X/M",
4523 "Specify a network to announce via BGP\n"
4524 "IPv6 prefix <network>/<length>\n")
4525{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304526 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004527 NULL, 0);
paul718e3742002-12-13 20:15:29 +00004528}
4529
4530DEFUN (ipv6_bgp_network_route_map,
4531 ipv6_bgp_network_route_map_cmd,
4532 "network X:X::X:X/M route-map WORD",
4533 "Specify a network to announce via BGP\n"
4534 "IPv6 prefix <network>/<length>\n"
4535 "Route-map to modify the attributes\n"
4536 "Name of the route map\n")
4537{
4538 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004539 bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004540}
4541
4542DEFUN (no_ipv6_bgp_network,
4543 no_ipv6_bgp_network_cmd,
4544 "no network X:X::X:X/M",
4545 NO_STR
4546 "Specify a network to announce via BGP\n"
4547 "IPv6 prefix <network>/<length>\n")
4548{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304549 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00004550}
4551
4552ALIAS (no_ipv6_bgp_network,
4553 no_ipv6_bgp_network_route_map_cmd,
4554 "no network X:X::X:X/M route-map WORD",
4555 NO_STR
4556 "Specify a network to announce via BGP\n"
4557 "IPv6 prefix <network>/<length>\n"
4558 "Route-map to modify the attributes\n"
4559 "Name of the route map\n")
4560
4561ALIAS (ipv6_bgp_network,
4562 old_ipv6_bgp_network_cmd,
4563 "ipv6 bgp network X:X::X:X/M",
4564 IPV6_STR
4565 BGP_STR
4566 "Specify a network to announce via BGP\n"
4567 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4568
4569ALIAS (no_ipv6_bgp_network,
4570 old_no_ipv6_bgp_network_cmd,
4571 "no ipv6 bgp network X:X::X:X/M",
4572 NO_STR
4573 IPV6_STR
4574 BGP_STR
4575 "Specify a network to announce via BGP\n"
4576 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004577
4578/* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4579ALIAS_DEPRECATED (bgp_network,
4580 bgp_network_ttl_cmd,
4581 "network A.B.C.D/M pathlimit <0-255>",
4582 "Specify a network to announce via BGP\n"
4583 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4584 "AS-Path hopcount limit attribute\n"
4585 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4586ALIAS_DEPRECATED (bgp_network_backdoor,
4587 bgp_network_backdoor_ttl_cmd,
4588 "network A.B.C.D/M backdoor pathlimit <0-255>",
4589 "Specify a network to announce via BGP\n"
4590 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4591 "Specify a BGP backdoor route\n"
4592 "AS-Path hopcount limit attribute\n"
4593 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4594ALIAS_DEPRECATED (bgp_network_mask,
4595 bgp_network_mask_ttl_cmd,
4596 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4597 "Specify a network to announce via BGP\n"
4598 "Network number\n"
4599 "Network mask\n"
4600 "Network mask\n"
4601 "AS-Path hopcount limit attribute\n"
4602 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4603ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4604 bgp_network_mask_backdoor_ttl_cmd,
4605 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4606 "Specify a network to announce via BGP\n"
4607 "Network number\n"
4608 "Network mask\n"
4609 "Network mask\n"
4610 "Specify a BGP backdoor route\n"
4611 "AS-Path hopcount limit attribute\n"
4612 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4613ALIAS_DEPRECATED (bgp_network_mask_natural,
4614 bgp_network_mask_natural_ttl_cmd,
4615 "network A.B.C.D pathlimit <0-255>",
4616 "Specify a network to announce via BGP\n"
4617 "Network number\n"
4618 "AS-Path hopcount limit attribute\n"
4619 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4620ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4621 bgp_network_mask_natural_backdoor_ttl_cmd,
Christian Franke2b005152013-09-30 12:27:49 +00004622 "network A.B.C.D backdoor pathlimit <1-255>",
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004623 "Specify a network to announce via BGP\n"
4624 "Network number\n"
4625 "Specify a BGP backdoor route\n"
4626 "AS-Path hopcount limit attribute\n"
4627 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4628ALIAS_DEPRECATED (no_bgp_network,
4629 no_bgp_network_ttl_cmd,
4630 "no network A.B.C.D/M pathlimit <0-255>",
4631 NO_STR
4632 "Specify a network to announce via BGP\n"
4633 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4634 "AS-Path hopcount limit attribute\n"
4635 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4636ALIAS_DEPRECATED (no_bgp_network,
4637 no_bgp_network_backdoor_ttl_cmd,
4638 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4639 NO_STR
4640 "Specify a network to announce via BGP\n"
4641 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4642 "Specify a BGP backdoor route\n"
4643 "AS-Path hopcount limit attribute\n"
4644 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4645ALIAS_DEPRECATED (no_bgp_network,
4646 no_bgp_network_mask_ttl_cmd,
4647 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4648 NO_STR
4649 "Specify a network to announce via BGP\n"
4650 "Network number\n"
4651 "Network mask\n"
4652 "Network mask\n"
4653 "AS-Path hopcount limit attribute\n"
4654 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4655ALIAS_DEPRECATED (no_bgp_network_mask,
4656 no_bgp_network_mask_backdoor_ttl_cmd,
4657 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4658 NO_STR
4659 "Specify a network to announce via BGP\n"
4660 "Network number\n"
4661 "Network mask\n"
4662 "Network mask\n"
4663 "Specify a BGP backdoor route\n"
4664 "AS-Path hopcount limit attribute\n"
4665 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4666ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4667 no_bgp_network_mask_natural_ttl_cmd,
4668 "no network A.B.C.D pathlimit <0-255>",
4669 NO_STR
4670 "Specify a network to announce via BGP\n"
4671 "Network number\n"
4672 "AS-Path hopcount limit attribute\n"
4673 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4674ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4675 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4676 "no network A.B.C.D backdoor pathlimit <0-255>",
4677 NO_STR
4678 "Specify a network to announce via BGP\n"
4679 "Network number\n"
4680 "Specify a BGP backdoor route\n"
4681 "AS-Path hopcount limit attribute\n"
4682 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4683ALIAS_DEPRECATED (ipv6_bgp_network,
4684 ipv6_bgp_network_ttl_cmd,
4685 "network X:X::X:X/M pathlimit <0-255>",
4686 "Specify a network to announce via BGP\n"
4687 "IPv6 prefix <network>/<length>\n"
4688 "AS-Path hopcount limit attribute\n"
4689 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4690ALIAS_DEPRECATED (no_ipv6_bgp_network,
4691 no_ipv6_bgp_network_ttl_cmd,
4692 "no network X:X::X:X/M pathlimit <0-255>",
4693 NO_STR
4694 "Specify a network to announce via BGP\n"
4695 "IPv6 prefix <network>/<length>\n"
4696 "AS-Path hopcount limit attribute\n"
4697 "AS-Pathlimit TTL, in number of AS-Path hops\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02004698
paul718e3742002-12-13 20:15:29 +00004699/* Aggreagete address:
4700
4701 advertise-map Set condition to advertise attribute
4702 as-set Generate AS set path information
4703 attribute-map Set attributes of aggregate
4704 route-map Set parameters of aggregate
4705 summary-only Filter more specific routes from updates
4706 suppress-map Conditionally filter more specific routes from updates
4707 <cr>
4708 */
4709struct bgp_aggregate
4710{
4711 /* Summary-only flag. */
4712 u_char summary_only;
4713
4714 /* AS set generation. */
4715 u_char as_set;
4716
4717 /* Route-map for aggregated route. */
4718 struct route_map *map;
4719
4720 /* Suppress-count. */
4721 unsigned long count;
4722
4723 /* SAFI configuration. */
4724 safi_t safi;
4725};
4726
paul94f2b392005-06-28 12:44:16 +00004727static struct bgp_aggregate *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08004728bgp_aggregate_new (void)
paul718e3742002-12-13 20:15:29 +00004729{
Stephen Hemminger393deb92008-08-18 14:13:29 -07004730 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
paul718e3742002-12-13 20:15:29 +00004731}
4732
paul94f2b392005-06-28 12:44:16 +00004733static void
paul718e3742002-12-13 20:15:29 +00004734bgp_aggregate_free (struct bgp_aggregate *aggregate)
4735{
4736 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4737}
4738
paul94f2b392005-06-28 12:44:16 +00004739static void
paul718e3742002-12-13 20:15:29 +00004740bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4741 afi_t afi, safi_t safi, struct bgp_info *del,
4742 struct bgp_aggregate *aggregate)
4743{
4744 struct bgp_table *table;
4745 struct bgp_node *top;
4746 struct bgp_node *rn;
4747 u_char origin;
4748 struct aspath *aspath = NULL;
4749 struct aspath *asmerge = NULL;
4750 struct community *community = NULL;
4751 struct community *commerge = NULL;
paul718e3742002-12-13 20:15:29 +00004752 struct bgp_info *ri;
4753 struct bgp_info *new;
4754 int first = 1;
4755 unsigned long match = 0;
4756
paul718e3742002-12-13 20:15:29 +00004757 /* ORIGIN attribute: If at least one route among routes that are
4758 aggregated has ORIGIN with the value INCOMPLETE, then the
4759 aggregated route must have the ORIGIN attribute with the value
4760 INCOMPLETE. Otherwise, if at least one route among routes that
4761 are aggregated has ORIGIN with the value EGP, then the aggregated
4762 route must have the origin attribute with the value EGP. In all
4763 other case the value of the ORIGIN attribute of the aggregated
4764 route is INTERNAL. */
4765 origin = BGP_ORIGIN_IGP;
4766
4767 table = bgp->rib[afi][safi];
4768
4769 top = bgp_node_get (table, p);
4770 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4771 if (rn->p.prefixlen > p->prefixlen)
4772 {
4773 match = 0;
4774
4775 for (ri = rn->info; ri; ri = ri->next)
4776 {
4777 if (BGP_INFO_HOLDDOWN (ri))
4778 continue;
4779
4780 if (del && ri == del)
4781 continue;
4782
4783 if (! rinew && first)
Paul Jakma7aa9dce2014-09-19 14:42:23 +01004784 first = 0;
paul718e3742002-12-13 20:15:29 +00004785
4786#ifdef AGGREGATE_NEXTHOP_CHECK
4787 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4788 || ri->attr->med != med)
4789 {
4790 if (aspath)
4791 aspath_free (aspath);
4792 if (community)
4793 community_free (community);
4794 bgp_unlock_node (rn);
4795 bgp_unlock_node (top);
4796 return;
4797 }
4798#endif /* AGGREGATE_NEXTHOP_CHECK */
4799
4800 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4801 {
4802 if (aggregate->summary_only)
4803 {
Paul Jakmafb982c22007-05-04 20:15:47 +00004804 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00004805 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00004806 match++;
4807 }
4808
4809 aggregate->count++;
4810
4811 if (aggregate->as_set)
4812 {
4813 if (origin < ri->attr->origin)
4814 origin = ri->attr->origin;
4815
4816 if (aspath)
4817 {
4818 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4819 aspath_free (aspath);
4820 aspath = asmerge;
4821 }
4822 else
4823 aspath = aspath_dup (ri->attr->aspath);
4824
4825 if (ri->attr->community)
4826 {
4827 if (community)
4828 {
4829 commerge = community_merge (community,
4830 ri->attr->community);
4831 community = community_uniq_sort (commerge);
4832 community_free (commerge);
4833 }
4834 else
4835 community = community_dup (ri->attr->community);
4836 }
4837 }
4838 }
4839 }
4840 if (match)
4841 bgp_process (bgp, rn, afi, safi);
4842 }
4843 bgp_unlock_node (top);
4844
4845 if (rinew)
4846 {
4847 aggregate->count++;
4848
4849 if (aggregate->summary_only)
Paul Jakmafb982c22007-05-04 20:15:47 +00004850 (bgp_info_extra_get (rinew))->suppress++;
paul718e3742002-12-13 20:15:29 +00004851
4852 if (aggregate->as_set)
4853 {
4854 if (origin < rinew->attr->origin)
4855 origin = rinew->attr->origin;
4856
4857 if (aspath)
4858 {
4859 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4860 aspath_free (aspath);
4861 aspath = asmerge;
4862 }
4863 else
4864 aspath = aspath_dup (rinew->attr->aspath);
4865
4866 if (rinew->attr->community)
4867 {
4868 if (community)
4869 {
4870 commerge = community_merge (community,
4871 rinew->attr->community);
4872 community = community_uniq_sort (commerge);
4873 community_free (commerge);
4874 }
4875 else
4876 community = community_dup (rinew->attr->community);
4877 }
4878 }
4879 }
4880
4881 if (aggregate->count > 0)
4882 {
4883 rn = bgp_node_get (table, p);
4884 new = bgp_info_new ();
4885 new->type = ZEBRA_ROUTE_BGP;
4886 new->sub_type = BGP_ROUTE_AGGREGATE;
4887 new->peer = bgp->peer_self;
4888 SET_FLAG (new->flags, BGP_INFO_VALID);
4889 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03004890 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00004891
4892 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00004893 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00004894 bgp_process (bgp, rn, afi, safi);
4895 }
4896 else
4897 {
4898 if (aspath)
4899 aspath_free (aspath);
4900 if (community)
4901 community_free (community);
4902 }
4903}
4904
4905void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4906 struct bgp_aggregate *);
4907
4908void
4909bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4910 struct bgp_info *ri, afi_t afi, safi_t safi)
4911{
4912 struct bgp_node *child;
4913 struct bgp_node *rn;
4914 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004915 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004916
4917 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004918 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004919 return;
4920
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004921 table = bgp->aggregate[afi][safi];
4922
4923 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004924 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004925 return;
4926
paul718e3742002-12-13 20:15:29 +00004927 if (p->prefixlen == 0)
4928 return;
4929
4930 if (BGP_INFO_HOLDDOWN (ri))
4931 return;
4932
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004933 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004934
4935 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004936 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00004937 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
4938 {
4939 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00004940 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00004941 }
4942 bgp_unlock_node (child);
4943}
4944
4945void
4946bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
4947 struct bgp_info *del, afi_t afi, safi_t safi)
4948{
4949 struct bgp_node *child;
4950 struct bgp_node *rn;
4951 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004952 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004953
4954 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004955 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004956 return;
4957
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004958 table = bgp->aggregate[afi][safi];
4959
4960 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004961 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004962 return;
4963
paul718e3742002-12-13 20:15:29 +00004964 if (p->prefixlen == 0)
4965 return;
4966
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004967 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004968
4969 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004970 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00004971 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
4972 {
4973 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00004974 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00004975 }
4976 bgp_unlock_node (child);
4977}
4978
paul94f2b392005-06-28 12:44:16 +00004979static void
paul718e3742002-12-13 20:15:29 +00004980bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
4981 struct bgp_aggregate *aggregate)
4982{
4983 struct bgp_table *table;
4984 struct bgp_node *top;
4985 struct bgp_node *rn;
4986 struct bgp_info *new;
4987 struct bgp_info *ri;
4988 unsigned long match;
4989 u_char origin = BGP_ORIGIN_IGP;
4990 struct aspath *aspath = NULL;
4991 struct aspath *asmerge = NULL;
4992 struct community *community = NULL;
4993 struct community *commerge = NULL;
4994
4995 table = bgp->rib[afi][safi];
4996
4997 /* Sanity check. */
4998 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
4999 return;
5000 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5001 return;
5002
5003 /* If routes exists below this node, generate aggregate routes. */
5004 top = bgp_node_get (table, p);
5005 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5006 if (rn->p.prefixlen > p->prefixlen)
5007 {
5008 match = 0;
5009
5010 for (ri = rn->info; ri; ri = ri->next)
5011 {
5012 if (BGP_INFO_HOLDDOWN (ri))
5013 continue;
5014
5015 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5016 {
5017 /* summary-only aggregate route suppress aggregated
5018 route announcement. */
5019 if (aggregate->summary_only)
5020 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005021 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00005022 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005023 match++;
5024 }
5025 /* as-set aggregate route generate origin, as path,
5026 community aggregation. */
5027 if (aggregate->as_set)
5028 {
5029 if (origin < ri->attr->origin)
5030 origin = ri->attr->origin;
5031
5032 if (aspath)
5033 {
5034 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5035 aspath_free (aspath);
5036 aspath = asmerge;
5037 }
5038 else
5039 aspath = aspath_dup (ri->attr->aspath);
5040
5041 if (ri->attr->community)
5042 {
5043 if (community)
5044 {
5045 commerge = community_merge (community,
5046 ri->attr->community);
5047 community = community_uniq_sort (commerge);
5048 community_free (commerge);
5049 }
5050 else
5051 community = community_dup (ri->attr->community);
5052 }
5053 }
5054 aggregate->count++;
5055 }
5056 }
5057
5058 /* If this node is suppressed, process the change. */
5059 if (match)
5060 bgp_process (bgp, rn, afi, safi);
5061 }
5062 bgp_unlock_node (top);
5063
5064 /* Add aggregate route to BGP table. */
5065 if (aggregate->count)
5066 {
5067 rn = bgp_node_get (table, p);
5068
5069 new = bgp_info_new ();
5070 new->type = ZEBRA_ROUTE_BGP;
5071 new->sub_type = BGP_ROUTE_AGGREGATE;
5072 new->peer = bgp->peer_self;
5073 SET_FLAG (new->flags, BGP_INFO_VALID);
5074 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03005075 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005076
5077 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00005078 bgp_unlock_node (rn);
5079
paul718e3742002-12-13 20:15:29 +00005080 /* Process change. */
5081 bgp_process (bgp, rn, afi, safi);
5082 }
Denil Virae2a92582015-08-11 13:34:59 -07005083 else
5084 {
5085 if (aspath)
5086 aspath_free (aspath);
5087 if (community)
5088 community_free (community);
5089 }
paul718e3742002-12-13 20:15:29 +00005090}
5091
5092void
5093bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5094 safi_t safi, struct bgp_aggregate *aggregate)
5095{
5096 struct bgp_table *table;
5097 struct bgp_node *top;
5098 struct bgp_node *rn;
5099 struct bgp_info *ri;
5100 unsigned long match;
5101
5102 table = bgp->rib[afi][safi];
5103
5104 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5105 return;
5106 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5107 return;
5108
5109 /* If routes exists below this node, generate aggregate routes. */
5110 top = bgp_node_get (table, p);
5111 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5112 if (rn->p.prefixlen > p->prefixlen)
5113 {
5114 match = 0;
5115
5116 for (ri = rn->info; ri; ri = ri->next)
5117 {
5118 if (BGP_INFO_HOLDDOWN (ri))
5119 continue;
5120
5121 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5122 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005123 if (aggregate->summary_only && ri->extra)
paul718e3742002-12-13 20:15:29 +00005124 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005125 ri->extra->suppress--;
paul718e3742002-12-13 20:15:29 +00005126
Paul Jakmafb982c22007-05-04 20:15:47 +00005127 if (ri->extra->suppress == 0)
paul718e3742002-12-13 20:15:29 +00005128 {
Paul Jakma1a392d42006-09-07 00:24:49 +00005129 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005130 match++;
5131 }
5132 }
5133 aggregate->count--;
5134 }
5135 }
5136
Paul Jakmafb982c22007-05-04 20:15:47 +00005137 /* If this node was suppressed, process the change. */
paul718e3742002-12-13 20:15:29 +00005138 if (match)
5139 bgp_process (bgp, rn, afi, safi);
5140 }
5141 bgp_unlock_node (top);
5142
5143 /* Delete aggregate route from BGP table. */
5144 rn = bgp_node_get (table, p);
5145
5146 for (ri = rn->info; ri; ri = ri->next)
5147 if (ri->peer == bgp->peer_self
5148 && ri->type == ZEBRA_ROUTE_BGP
5149 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5150 break;
5151
5152 /* Withdraw static BGP route from routing table. */
5153 if (ri)
5154 {
paul718e3742002-12-13 20:15:29 +00005155 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005156 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00005157 }
5158
5159 /* Unlock bgp_node_lookup. */
5160 bgp_unlock_node (rn);
5161}
5162
5163/* Aggregate route attribute. */
5164#define AGGREGATE_SUMMARY_ONLY 1
5165#define AGGREGATE_AS_SET 1
5166
paul94f2b392005-06-28 12:44:16 +00005167static int
Robert Baysf6269b42010-08-05 10:26:28 -07005168bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5169 afi_t afi, safi_t safi)
5170{
5171 int ret;
5172 struct prefix p;
5173 struct bgp_node *rn;
5174 struct bgp *bgp;
5175 struct bgp_aggregate *aggregate;
5176
5177 /* Convert string to prefix structure. */
5178 ret = str2prefix (prefix_str, &p);
5179 if (!ret)
5180 {
5181 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5182 return CMD_WARNING;
5183 }
5184 apply_mask (&p);
5185
5186 /* Get BGP structure. */
5187 bgp = vty->index;
5188
5189 /* Old configuration check. */
5190 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
5191 if (! rn)
5192 {
5193 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5194 VTY_NEWLINE);
5195 return CMD_WARNING;
5196 }
5197
5198 aggregate = rn->info;
5199 if (aggregate->safi & SAFI_UNICAST)
5200 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5201 if (aggregate->safi & SAFI_MULTICAST)
5202 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5203
5204 /* Unlock aggregate address configuration. */
5205 rn->info = NULL;
5206 bgp_aggregate_free (aggregate);
5207 bgp_unlock_node (rn);
5208 bgp_unlock_node (rn);
5209
5210 return CMD_SUCCESS;
5211}
5212
5213static int
5214bgp_aggregate_set (struct vty *vty, const char *prefix_str,
paulfd79ac92004-10-13 05:06:08 +00005215 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00005216 u_char summary_only, u_char as_set)
5217{
5218 int ret;
5219 struct prefix p;
5220 struct bgp_node *rn;
5221 struct bgp *bgp;
5222 struct bgp_aggregate *aggregate;
5223
5224 /* Convert string to prefix structure. */
5225 ret = str2prefix (prefix_str, &p);
5226 if (!ret)
5227 {
5228 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5229 return CMD_WARNING;
5230 }
5231 apply_mask (&p);
5232
5233 /* Get BGP structure. */
5234 bgp = vty->index;
5235
5236 /* Old configuration check. */
5237 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5238
5239 if (rn->info)
5240 {
5241 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
Robert Bays368473f2010-08-05 10:26:29 -07005242 /* try to remove the old entry */
Robert Baysf6269b42010-08-05 10:26:28 -07005243 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5244 if (ret)
5245 {
Robert Bays368473f2010-08-05 10:26:29 -07005246 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5247 bgp_unlock_node (rn);
Robert Baysf6269b42010-08-05 10:26:28 -07005248 return CMD_WARNING;
5249 }
paul718e3742002-12-13 20:15:29 +00005250 }
5251
5252 /* Make aggregate address structure. */
5253 aggregate = bgp_aggregate_new ();
5254 aggregate->summary_only = summary_only;
5255 aggregate->as_set = as_set;
5256 aggregate->safi = safi;
5257 rn->info = aggregate;
5258
5259 /* Aggregate address insert into BGP routing table. */
5260 if (safi & SAFI_UNICAST)
5261 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5262 if (safi & SAFI_MULTICAST)
5263 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5264
5265 return CMD_SUCCESS;
5266}
5267
paul718e3742002-12-13 20:15:29 +00005268DEFUN (aggregate_address,
5269 aggregate_address_cmd,
5270 "aggregate-address A.B.C.D/M",
5271 "Configure BGP aggregate entries\n"
5272 "Aggregate prefix\n")
5273{
5274 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5275}
5276
5277DEFUN (aggregate_address_mask,
5278 aggregate_address_mask_cmd,
5279 "aggregate-address A.B.C.D A.B.C.D",
5280 "Configure BGP aggregate entries\n"
5281 "Aggregate address\n"
5282 "Aggregate mask\n")
5283{
5284 int ret;
5285 char prefix_str[BUFSIZ];
5286
5287 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5288
5289 if (! ret)
5290 {
5291 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5292 return CMD_WARNING;
5293 }
5294
5295 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5296 0, 0);
5297}
5298
5299DEFUN (aggregate_address_summary_only,
5300 aggregate_address_summary_only_cmd,
5301 "aggregate-address A.B.C.D/M summary-only",
5302 "Configure BGP aggregate entries\n"
5303 "Aggregate prefix\n"
5304 "Filter more specific routes from updates\n")
5305{
5306 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5307 AGGREGATE_SUMMARY_ONLY, 0);
5308}
5309
5310DEFUN (aggregate_address_mask_summary_only,
5311 aggregate_address_mask_summary_only_cmd,
5312 "aggregate-address A.B.C.D A.B.C.D summary-only",
5313 "Configure BGP aggregate entries\n"
5314 "Aggregate address\n"
5315 "Aggregate mask\n"
5316 "Filter more specific routes from updates\n")
5317{
5318 int ret;
5319 char prefix_str[BUFSIZ];
5320
5321 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5322
5323 if (! ret)
5324 {
5325 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5326 return CMD_WARNING;
5327 }
5328
5329 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5330 AGGREGATE_SUMMARY_ONLY, 0);
5331}
5332
5333DEFUN (aggregate_address_as_set,
5334 aggregate_address_as_set_cmd,
5335 "aggregate-address A.B.C.D/M as-set",
5336 "Configure BGP aggregate entries\n"
5337 "Aggregate prefix\n"
5338 "Generate AS set path information\n")
5339{
5340 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5341 0, AGGREGATE_AS_SET);
5342}
5343
5344DEFUN (aggregate_address_mask_as_set,
5345 aggregate_address_mask_as_set_cmd,
5346 "aggregate-address A.B.C.D A.B.C.D as-set",
5347 "Configure BGP aggregate entries\n"
5348 "Aggregate address\n"
5349 "Aggregate mask\n"
5350 "Generate AS set path information\n")
5351{
5352 int ret;
5353 char prefix_str[BUFSIZ];
5354
5355 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5356
5357 if (! ret)
5358 {
5359 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5360 return CMD_WARNING;
5361 }
5362
5363 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5364 0, AGGREGATE_AS_SET);
5365}
5366
5367
5368DEFUN (aggregate_address_as_set_summary,
5369 aggregate_address_as_set_summary_cmd,
5370 "aggregate-address A.B.C.D/M as-set summary-only",
5371 "Configure BGP aggregate entries\n"
5372 "Aggregate prefix\n"
5373 "Generate AS set path information\n"
5374 "Filter more specific routes from updates\n")
5375{
5376 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5377 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5378}
5379
5380ALIAS (aggregate_address_as_set_summary,
5381 aggregate_address_summary_as_set_cmd,
5382 "aggregate-address A.B.C.D/M summary-only as-set",
5383 "Configure BGP aggregate entries\n"
5384 "Aggregate prefix\n"
5385 "Filter more specific routes from updates\n"
5386 "Generate AS set path information\n")
5387
5388DEFUN (aggregate_address_mask_as_set_summary,
5389 aggregate_address_mask_as_set_summary_cmd,
5390 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5391 "Configure BGP aggregate entries\n"
5392 "Aggregate address\n"
5393 "Aggregate mask\n"
5394 "Generate AS set path information\n"
5395 "Filter more specific routes from updates\n")
5396{
5397 int ret;
5398 char prefix_str[BUFSIZ];
5399
5400 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5401
5402 if (! ret)
5403 {
5404 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5405 return CMD_WARNING;
5406 }
5407
5408 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5409 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5410}
5411
5412ALIAS (aggregate_address_mask_as_set_summary,
5413 aggregate_address_mask_summary_as_set_cmd,
5414 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5415 "Configure BGP aggregate entries\n"
5416 "Aggregate address\n"
5417 "Aggregate mask\n"
5418 "Filter more specific routes from updates\n"
5419 "Generate AS set path information\n")
5420
5421DEFUN (no_aggregate_address,
5422 no_aggregate_address_cmd,
5423 "no aggregate-address A.B.C.D/M",
5424 NO_STR
5425 "Configure BGP aggregate entries\n"
5426 "Aggregate prefix\n")
5427{
5428 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5429}
5430
5431ALIAS (no_aggregate_address,
5432 no_aggregate_address_summary_only_cmd,
5433 "no aggregate-address A.B.C.D/M summary-only",
5434 NO_STR
5435 "Configure BGP aggregate entries\n"
5436 "Aggregate prefix\n"
5437 "Filter more specific routes from updates\n")
5438
5439ALIAS (no_aggregate_address,
5440 no_aggregate_address_as_set_cmd,
5441 "no aggregate-address A.B.C.D/M as-set",
5442 NO_STR
5443 "Configure BGP aggregate entries\n"
5444 "Aggregate prefix\n"
5445 "Generate AS set path information\n")
5446
5447ALIAS (no_aggregate_address,
5448 no_aggregate_address_as_set_summary_cmd,
5449 "no aggregate-address A.B.C.D/M as-set summary-only",
5450 NO_STR
5451 "Configure BGP aggregate entries\n"
5452 "Aggregate prefix\n"
5453 "Generate AS set path information\n"
5454 "Filter more specific routes from updates\n")
5455
5456ALIAS (no_aggregate_address,
5457 no_aggregate_address_summary_as_set_cmd,
5458 "no aggregate-address A.B.C.D/M summary-only as-set",
5459 NO_STR
5460 "Configure BGP aggregate entries\n"
5461 "Aggregate prefix\n"
5462 "Filter more specific routes from updates\n"
5463 "Generate AS set path information\n")
5464
5465DEFUN (no_aggregate_address_mask,
5466 no_aggregate_address_mask_cmd,
5467 "no aggregate-address A.B.C.D A.B.C.D",
5468 NO_STR
5469 "Configure BGP aggregate entries\n"
5470 "Aggregate address\n"
5471 "Aggregate mask\n")
5472{
5473 int ret;
5474 char prefix_str[BUFSIZ];
5475
5476 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5477
5478 if (! ret)
5479 {
5480 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5481 return CMD_WARNING;
5482 }
5483
5484 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5485}
5486
5487ALIAS (no_aggregate_address_mask,
5488 no_aggregate_address_mask_summary_only_cmd,
5489 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5490 NO_STR
5491 "Configure BGP aggregate entries\n"
5492 "Aggregate address\n"
5493 "Aggregate mask\n"
5494 "Filter more specific routes from updates\n")
5495
5496ALIAS (no_aggregate_address_mask,
5497 no_aggregate_address_mask_as_set_cmd,
5498 "no aggregate-address A.B.C.D A.B.C.D as-set",
5499 NO_STR
5500 "Configure BGP aggregate entries\n"
5501 "Aggregate address\n"
5502 "Aggregate mask\n"
5503 "Generate AS set path information\n")
5504
5505ALIAS (no_aggregate_address_mask,
5506 no_aggregate_address_mask_as_set_summary_cmd,
5507 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5508 NO_STR
5509 "Configure BGP aggregate entries\n"
5510 "Aggregate address\n"
5511 "Aggregate mask\n"
5512 "Generate AS set path information\n"
5513 "Filter more specific routes from updates\n")
5514
5515ALIAS (no_aggregate_address_mask,
5516 no_aggregate_address_mask_summary_as_set_cmd,
5517 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5518 NO_STR
5519 "Configure BGP aggregate entries\n"
5520 "Aggregate address\n"
5521 "Aggregate mask\n"
5522 "Filter more specific routes from updates\n"
5523 "Generate AS set path information\n")
5524
paul718e3742002-12-13 20:15:29 +00005525DEFUN (ipv6_aggregate_address,
5526 ipv6_aggregate_address_cmd,
5527 "aggregate-address X:X::X:X/M",
5528 "Configure BGP aggregate entries\n"
5529 "Aggregate prefix\n")
5530{
5531 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5532}
5533
5534DEFUN (ipv6_aggregate_address_summary_only,
5535 ipv6_aggregate_address_summary_only_cmd,
5536 "aggregate-address X:X::X:X/M summary-only",
5537 "Configure BGP aggregate entries\n"
5538 "Aggregate prefix\n"
5539 "Filter more specific routes from updates\n")
5540{
5541 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5542 AGGREGATE_SUMMARY_ONLY, 0);
5543}
5544
5545DEFUN (no_ipv6_aggregate_address,
5546 no_ipv6_aggregate_address_cmd,
5547 "no aggregate-address X:X::X:X/M",
5548 NO_STR
5549 "Configure BGP aggregate entries\n"
5550 "Aggregate prefix\n")
5551{
5552 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5553}
5554
5555DEFUN (no_ipv6_aggregate_address_summary_only,
5556 no_ipv6_aggregate_address_summary_only_cmd,
5557 "no aggregate-address X:X::X:X/M summary-only",
5558 NO_STR
5559 "Configure BGP aggregate entries\n"
5560 "Aggregate prefix\n"
5561 "Filter more specific routes from updates\n")
5562{
5563 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5564}
5565
5566ALIAS (ipv6_aggregate_address,
5567 old_ipv6_aggregate_address_cmd,
5568 "ipv6 bgp aggregate-address X:X::X:X/M",
5569 IPV6_STR
5570 BGP_STR
5571 "Configure BGP aggregate entries\n"
5572 "Aggregate prefix\n")
5573
5574ALIAS (ipv6_aggregate_address_summary_only,
5575 old_ipv6_aggregate_address_summary_only_cmd,
5576 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5577 IPV6_STR
5578 BGP_STR
5579 "Configure BGP aggregate entries\n"
5580 "Aggregate prefix\n"
5581 "Filter more specific routes from updates\n")
5582
5583ALIAS (no_ipv6_aggregate_address,
5584 old_no_ipv6_aggregate_address_cmd,
5585 "no ipv6 bgp aggregate-address X:X::X:X/M",
5586 NO_STR
5587 IPV6_STR
5588 BGP_STR
5589 "Configure BGP aggregate entries\n"
5590 "Aggregate prefix\n")
5591
5592ALIAS (no_ipv6_aggregate_address_summary_only,
5593 old_no_ipv6_aggregate_address_summary_only_cmd,
5594 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5595 NO_STR
5596 IPV6_STR
5597 BGP_STR
5598 "Configure BGP aggregate entries\n"
5599 "Aggregate prefix\n"
5600 "Filter more specific routes from updates\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02005601
paul718e3742002-12-13 20:15:29 +00005602/* Redistribute route treatment. */
5603void
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005604bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5605 const struct in6_addr *nexthop6,
paul718e3742002-12-13 20:15:29 +00005606 u_int32_t metric, u_char type)
5607{
5608 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005609 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005610 struct bgp_info *new;
5611 struct bgp_info *bi;
5612 struct bgp_info info;
5613 struct bgp_node *bn;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00005614 struct attr attr;
paul718e3742002-12-13 20:15:29 +00005615 struct attr *new_attr;
5616 afi_t afi;
5617 int ret;
5618
5619 /* Make default attribute. */
5620 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5621 if (nexthop)
5622 attr.nexthop = *nexthop;
5623
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005624 if (nexthop6)
5625 {
5626 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5627 extra->mp_nexthop_global = *nexthop6;
5628 extra->mp_nexthop_len = 16;
5629 }
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005630
paul718e3742002-12-13 20:15:29 +00005631 attr.med = metric;
5632 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
5633
paul1eb8ef22005-04-07 07:30:20 +00005634 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005635 {
5636 afi = family2afi (p->family);
5637
5638 if (bgp->redist[afi][type])
5639 {
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005640 struct attr attr_new;
5641 struct attr_extra extra_new;
5642
paul718e3742002-12-13 20:15:29 +00005643 /* Copy attribute for modification. */
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005644 attr_new.extra = &extra_new;
Paul Jakmafb982c22007-05-04 20:15:47 +00005645 bgp_attr_dup (&attr_new, &attr);
paul718e3742002-12-13 20:15:29 +00005646
5647 if (bgp->redist_metric_flag[afi][type])
5648 attr_new.med = bgp->redist_metric[afi][type];
5649
5650 /* Apply route-map. */
Daniel Walton1994dc82015-09-17 10:15:59 -04005651 if (bgp->rmap[afi][type].name)
paul718e3742002-12-13 20:15:29 +00005652 {
5653 info.peer = bgp->peer_self;
5654 info.attr = &attr_new;
5655
paulfee0f4c2004-09-13 05:12:46 +00005656 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5657
paul718e3742002-12-13 20:15:29 +00005658 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5659 &info);
paulfee0f4c2004-09-13 05:12:46 +00005660
5661 bgp->peer_self->rmap_type = 0;
5662
paul718e3742002-12-13 20:15:29 +00005663 if (ret == RMAP_DENYMATCH)
5664 {
5665 /* Free uninterned attribute. */
5666 bgp_attr_flush (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005667
paul718e3742002-12-13 20:15:29 +00005668 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005669 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005670 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005671 bgp_redistribute_delete (p, type);
5672 return;
5673 }
5674 }
5675
Paul Jakmafb982c22007-05-04 20:15:47 +00005676 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5677 afi, SAFI_UNICAST, p, NULL);
5678
paul718e3742002-12-13 20:15:29 +00005679 new_attr = bgp_attr_intern (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005680
paul718e3742002-12-13 20:15:29 +00005681 for (bi = bn->info; bi; bi = bi->next)
5682 if (bi->peer == bgp->peer_self
5683 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5684 break;
5685
5686 if (bi)
5687 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005688 if (attrhash_cmp (bi->attr, new_attr) &&
5689 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00005690 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005691 bgp_attr_unintern (&new_attr);
5692 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005693 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005694 bgp_unlock_node (bn);
5695 return;
5696 }
5697 else
5698 {
5699 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00005700 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005701
5702 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005703 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5704 bgp_info_restore(bn, bi);
5705 else
5706 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005707 bgp_attr_unintern (&bi->attr);
paul718e3742002-12-13 20:15:29 +00005708 bi->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005709 bi->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005710
5711 /* Process change. */
5712 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5713 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5714 bgp_unlock_node (bn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005715 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005716 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005717 return;
5718 }
5719 }
5720
5721 new = bgp_info_new ();
5722 new->type = type;
5723 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
5724 new->peer = bgp->peer_self;
5725 SET_FLAG (new->flags, BGP_INFO_VALID);
5726 new->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005727 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005728
5729 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5730 bgp_info_add (bn, new);
paul200df112005-06-01 11:17:05 +00005731 bgp_unlock_node (bn);
paul718e3742002-12-13 20:15:29 +00005732 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5733 }
5734 }
5735
5736 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005737 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005738 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005739}
5740
5741void
5742bgp_redistribute_delete (struct prefix *p, u_char type)
5743{
5744 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005745 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005746 afi_t afi;
5747 struct bgp_node *rn;
5748 struct bgp_info *ri;
5749
paul1eb8ef22005-04-07 07:30:20 +00005750 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005751 {
5752 afi = family2afi (p->family);
5753
5754 if (bgp->redist[afi][type])
5755 {
paulfee0f4c2004-09-13 05:12:46 +00005756 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00005757
5758 for (ri = rn->info; ri; ri = ri->next)
5759 if (ri->peer == bgp->peer_self
5760 && ri->type == type)
5761 break;
5762
5763 if (ri)
5764 {
5765 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005766 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005767 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005768 }
5769 bgp_unlock_node (rn);
5770 }
5771 }
5772}
5773
5774/* Withdraw specified route type's route. */
5775void
5776bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5777{
5778 struct bgp_node *rn;
5779 struct bgp_info *ri;
5780 struct bgp_table *table;
5781
5782 table = bgp->rib[afi][SAFI_UNICAST];
5783
5784 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5785 {
5786 for (ri = rn->info; ri; ri = ri->next)
5787 if (ri->peer == bgp->peer_self
5788 && ri->type == type)
5789 break;
5790
5791 if (ri)
5792 {
5793 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005794 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005795 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005796 }
5797 }
5798}
David Lamparter6b0655a2014-06-04 06:53:35 +02005799
paul718e3742002-12-13 20:15:29 +00005800/* Static function to display route. */
paul94f2b392005-06-28 12:44:16 +00005801static void
paul718e3742002-12-13 20:15:29 +00005802route_vty_out_route (struct prefix *p, struct vty *vty)
5803{
5804 int len;
5805 u_int32_t destination;
5806 char buf[BUFSIZ];
5807
5808 if (p->family == AF_INET)
5809 {
5810 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5811 destination = ntohl (p->u.prefix4.s_addr);
5812
5813 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5814 || (IN_CLASSB (destination) && p->prefixlen == 16)
5815 || (IN_CLASSA (destination) && p->prefixlen == 8)
5816 || p->u.prefix4.s_addr == 0)
5817 {
5818 /* When mask is natural, mask is not displayed. */
5819 }
5820 else
5821 len += vty_out (vty, "/%d", p->prefixlen);
5822 }
5823 else
5824 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5825 p->prefixlen);
5826
5827 len = 17 - len;
5828 if (len < 1)
5829 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5830 else
5831 vty_out (vty, "%*s", len, " ");
5832}
5833
paul718e3742002-12-13 20:15:29 +00005834enum bgp_display_type
5835{
5836 normal_list,
5837};
5838
paulb40d9392005-08-22 22:34:41 +00005839/* Print the short form route status for a bgp_info */
5840static void
5841route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
paul718e3742002-12-13 20:15:29 +00005842{
paulb40d9392005-08-22 22:34:41 +00005843 /* Route status display. */
5844 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5845 vty_out (vty, "R");
5846 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
hasso93406d82005-02-02 14:40:33 +00005847 vty_out (vty, "S");
Paul Jakmafb982c22007-05-04 20:15:47 +00005848 else if (binfo->extra && binfo->extra->suppress)
paul718e3742002-12-13 20:15:29 +00005849 vty_out (vty, "s");
5850 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5851 vty_out (vty, "*");
5852 else
5853 vty_out (vty, " ");
5854
5855 /* Selected */
5856 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5857 vty_out (vty, "h");
5858 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5859 vty_out (vty, "d");
5860 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5861 vty_out (vty, ">");
Boian Bonevb366b512013-09-09 16:41:35 +00005862 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5863 vty_out (vty, "=");
paul718e3742002-12-13 20:15:29 +00005864 else
5865 vty_out (vty, " ");
5866
5867 /* Internal route. */
5868 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5869 vty_out (vty, "i");
5870 else
paulb40d9392005-08-22 22:34:41 +00005871 vty_out (vty, " ");
5872}
5873
5874/* called from terminal list command */
5875void
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005876route_vty_out(
5877 struct vty *vty,
5878 struct prefix *p,
5879 struct bgp_info *binfo,
5880 int display,
5881 safi_t safi)
paulb40d9392005-08-22 22:34:41 +00005882{
5883 struct attr *attr;
5884
5885 /* short status lead text */
5886 route_vty_short_status_out (vty, binfo);
paul718e3742002-12-13 20:15:29 +00005887
5888 /* print prefix and mask */
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005889 if (!display)
paul718e3742002-12-13 20:15:29 +00005890 route_vty_out_route (p, vty);
5891 else
5892 vty_out (vty, "%*s", 17, " ");
5893
5894 /* Print attribute */
5895 attr = binfo->attr;
5896 if (attr)
5897 {
paul718e3742002-12-13 20:15:29 +00005898
Lou Berger298cc2f2016-01-12 13:42:02 -05005899 /*
5900 * NEXTHOP start
5901 */
5902
5903 /*
5904 * For ENCAP routes, nexthop address family is not
5905 * neccessarily the same as the prefix address family.
5906 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5907 */
5908 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5909 if (attr->extra) {
5910 char buf[BUFSIZ];
5911 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5912
5913 switch (af) {
5914 case AF_INET:
5915 vty_out (vty, "%s", inet_ntop(af,
5916 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5917 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005918 case AF_INET6:
5919 vty_out (vty, "%s", inet_ntop(af,
5920 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
5921 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005922 default:
5923 vty_out(vty, "?");
5924 }
5925 } else {
5926 vty_out(vty, "?");
paul718e3742002-12-13 20:15:29 +00005927 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005928 } else {
5929
5930 if (p->family == AF_INET)
5931 {
5932 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
5933 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005934 else if (p->family == AF_INET6)
5935 {
5936 int len;
5937 char buf[BUFSIZ];
5938
5939 len = vty_out (vty, "%s",
5940 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
5941 buf, BUFSIZ));
5942 len = 16 - len;
5943 if (len < 1)
5944 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
5945 else
5946 vty_out (vty, "%*s", len, " ");
5947 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005948 else
5949 {
5950 vty_out(vty, "?");
5951 }
5952 }
5953
5954 /*
5955 * NEXTHOP end
5956 */
5957
paul718e3742002-12-13 20:15:29 +00005958
5959 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005960 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00005961 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005962 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00005963
5964 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005965 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00005966 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005967 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00005968
Paul Jakmafb982c22007-05-04 20:15:47 +00005969 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
paul718e3742002-12-13 20:15:29 +00005970
Paul Jakmab2518c12006-05-12 23:48:40 +00005971 /* Print aspath */
5972 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00005973 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00005974
Paul Jakmab2518c12006-05-12 23:48:40 +00005975 /* Print origin */
paul718e3742002-12-13 20:15:29 +00005976 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00005977 }
paul718e3742002-12-13 20:15:29 +00005978 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005979}
5980
5981/* called from terminal list command */
5982void
5983route_vty_out_tmp (struct vty *vty, struct prefix *p,
5984 struct attr *attr, safi_t safi)
5985{
5986 /* Route status display. */
5987 vty_out (vty, "*");
5988 vty_out (vty, ">");
5989 vty_out (vty, " ");
5990
5991 /* print prefix and mask */
5992 route_vty_out_route (p, vty);
5993
5994 /* Print attribute */
5995 if (attr)
5996 {
5997 if (p->family == AF_INET)
5998 {
Lou Berger298cc2f2016-01-12 13:42:02 -05005999 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006000 vty_out (vty, "%-16s",
6001 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006002 else
6003 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6004 }
paul718e3742002-12-13 20:15:29 +00006005 else if (p->family == AF_INET6)
6006 {
6007 int len;
6008 char buf[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006009
6010 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006011
6012 len = vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006013 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6014 buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006015 len = 16 - len;
6016 if (len < 1)
6017 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6018 else
6019 vty_out (vty, "%*s", len, " ");
6020 }
paul718e3742002-12-13 20:15:29 +00006021
6022 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006023 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006024 else
6025 vty_out (vty, " ");
6026
6027 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006028 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006029 else
6030 vty_out (vty, " ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006031
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006032 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
Paul Jakmafb982c22007-05-04 20:15:47 +00006033
Paul Jakmab2518c12006-05-12 23:48:40 +00006034 /* Print aspath */
6035 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006036 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006037
Paul Jakmab2518c12006-05-12 23:48:40 +00006038 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006039 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006040 }
paul718e3742002-12-13 20:15:29 +00006041
6042 vty_out (vty, "%s", VTY_NEWLINE);
6043}
6044
ajs5a646652004-11-05 01:25:55 +00006045void
paul718e3742002-12-13 20:15:29 +00006046route_vty_out_tag (struct vty *vty, struct prefix *p,
6047 struct bgp_info *binfo, int display, safi_t safi)
6048{
6049 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006050 u_int32_t label = 0;
Paul Jakmafb982c22007-05-04 20:15:47 +00006051
6052 if (!binfo->extra)
6053 return;
6054
paulb40d9392005-08-22 22:34:41 +00006055 /* short status lead text */
6056 route_vty_short_status_out (vty, binfo);
6057
paul718e3742002-12-13 20:15:29 +00006058 /* print prefix and mask */
6059 if (! display)
6060 route_vty_out_route (p, vty);
6061 else
6062 vty_out (vty, "%*s", 17, " ");
6063
6064 /* Print attribute */
6065 attr = binfo->attr;
6066 if (attr)
6067 {
6068 if (p->family == AF_INET)
6069 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006070 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006071 vty_out (vty, "%-16s",
6072 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006073 else
6074 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6075 }
paul718e3742002-12-13 20:15:29 +00006076 else if (p->family == AF_INET6)
6077 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006078 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006079 char buf[BUFSIZ];
6080 char buf1[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006081 if (attr->extra->mp_nexthop_len == 16)
paul718e3742002-12-13 20:15:29 +00006082 vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006083 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6084 buf, BUFSIZ));
6085 else if (attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006086 vty_out (vty, "%s(%s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006087 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6088 buf, BUFSIZ),
6089 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6090 buf1, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006091
6092 }
paul718e3742002-12-13 20:15:29 +00006093 }
6094
Paul Jakmafb982c22007-05-04 20:15:47 +00006095 label = decode_label (binfo->extra->tag);
paul718e3742002-12-13 20:15:29 +00006096
6097 vty_out (vty, "notag/%d", label);
6098
6099 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006100}
6101
6102/* dampening route */
ajs5a646652004-11-05 01:25:55 +00006103static void
paul718e3742002-12-13 20:15:29 +00006104damp_route_vty_out (struct vty *vty, struct prefix *p,
6105 struct bgp_info *binfo, int display, safi_t safi)
6106{
6107 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006108 int len;
Chris Caputo50aef6f2009-06-23 06:06:49 +00006109 char timebuf[BGP_UPTIME_LEN];
paul718e3742002-12-13 20:15:29 +00006110
paulb40d9392005-08-22 22:34:41 +00006111 /* short status lead text */
6112 route_vty_short_status_out (vty, binfo);
6113
paul718e3742002-12-13 20:15:29 +00006114 /* print prefix and mask */
6115 if (! display)
6116 route_vty_out_route (p, vty);
6117 else
6118 vty_out (vty, "%*s", 17, " ");
6119
6120 len = vty_out (vty, "%s", binfo->peer->host);
6121 len = 17 - len;
6122 if (len < 1)
6123 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6124 else
6125 vty_out (vty, "%*s", len, " ");
6126
Chris Caputo50aef6f2009-06-23 06:06:49 +00006127 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006128
6129 /* Print attribute */
6130 attr = binfo->attr;
6131 if (attr)
6132 {
6133 /* Print aspath */
6134 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006135 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006136
6137 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006138 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006139 }
6140 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006141}
6142
paul718e3742002-12-13 20:15:29 +00006143/* flap route */
ajs5a646652004-11-05 01:25:55 +00006144static void
paul718e3742002-12-13 20:15:29 +00006145flap_route_vty_out (struct vty *vty, struct prefix *p,
6146 struct bgp_info *binfo, int display, safi_t safi)
6147{
6148 struct attr *attr;
6149 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00006150 char timebuf[BGP_UPTIME_LEN];
6151 int len;
Paul Jakmafb982c22007-05-04 20:15:47 +00006152
6153 if (!binfo->extra)
6154 return;
6155
6156 bdi = binfo->extra->damp_info;
paul718e3742002-12-13 20:15:29 +00006157
paulb40d9392005-08-22 22:34:41 +00006158 /* short status lead text */
6159 route_vty_short_status_out (vty, binfo);
6160
paul718e3742002-12-13 20:15:29 +00006161 /* print prefix and mask */
6162 if (! display)
6163 route_vty_out_route (p, vty);
6164 else
6165 vty_out (vty, "%*s", 17, " ");
6166
6167 len = vty_out (vty, "%s", binfo->peer->host);
6168 len = 16 - len;
6169 if (len < 1)
6170 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6171 else
6172 vty_out (vty, "%*s", len, " ");
6173
6174 len = vty_out (vty, "%d", bdi->flap);
6175 len = 5 - len;
6176 if (len < 1)
6177 vty_out (vty, " ");
6178 else
6179 vty_out (vty, "%*s ", len, " ");
6180
6181 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6182 timebuf, BGP_UPTIME_LEN));
6183
6184 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6185 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
Chris Caputo50aef6f2009-06-23 06:06:49 +00006186 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006187 else
6188 vty_out (vty, "%*s ", 8, " ");
6189
6190 /* Print attribute */
6191 attr = binfo->attr;
6192 if (attr)
6193 {
6194 /* Print aspath */
6195 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006196 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006197
6198 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006199 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006200 }
6201 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006202}
6203
paul94f2b392005-06-28 12:44:16 +00006204static void
paul718e3742002-12-13 20:15:29 +00006205route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6206 struct bgp_info *binfo, afi_t afi, safi_t safi)
6207{
6208 char buf[INET6_ADDRSTRLEN];
6209 char buf1[BUFSIZ];
6210 struct attr *attr;
6211 int sockunion_vty_out (struct vty *, union sockunion *);
John Kemp30b00172011-03-18 17:52:18 +03006212#ifdef HAVE_CLOCK_MONOTONIC
6213 time_t tbuf;
6214#endif
paul718e3742002-12-13 20:15:29 +00006215
6216 attr = binfo->attr;
6217
6218 if (attr)
6219 {
6220 /* Line1 display AS-path, Aggregator */
6221 if (attr->aspath)
6222 {
6223 vty_out (vty, " ");
paulfe69a502005-09-10 16:55:02 +00006224 if (aspath_count_hops (attr->aspath) == 0)
paul718e3742002-12-13 20:15:29 +00006225 vty_out (vty, "Local");
6226 else
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006227 aspath_print_vty (vty, "%s", attr->aspath, "");
paul718e3742002-12-13 20:15:29 +00006228 }
6229
paulb40d9392005-08-22 22:34:41 +00006230 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6231 vty_out (vty, ", (removed)");
hasso93406d82005-02-02 14:40:33 +00006232 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6233 vty_out (vty, ", (stale)");
6234 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006235 vty_out (vty, ", (aggregated by %u %s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006236 attr->extra->aggregator_as,
6237 inet_ntoa (attr->extra->aggregator_addr));
hasso93406d82005-02-02 14:40:33 +00006238 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6239 vty_out (vty, ", (Received from a RR-client)");
6240 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6241 vty_out (vty, ", (Received from a RS-client)");
6242 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6243 vty_out (vty, ", (history entry)");
6244 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6245 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00006246 vty_out (vty, "%s", VTY_NEWLINE);
6247
6248 /* Line2 display Next-hop, Neighbor, Router-id */
6249 if (p->family == AF_INET)
6250 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006251 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
Paul Jakmafb982c22007-05-04 20:15:47 +00006252 inet_ntoa (attr->extra->mp_nexthop_global_in) :
paul718e3742002-12-13 20:15:29 +00006253 inet_ntoa (attr->nexthop));
6254 }
paul718e3742002-12-13 20:15:29 +00006255 else
6256 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006257 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006258 vty_out (vty, " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006259 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
paul718e3742002-12-13 20:15:29 +00006260 buf, INET6_ADDRSTRLEN));
6261 }
paul718e3742002-12-13 20:15:29 +00006262
6263 if (binfo->peer == bgp->peer_self)
6264 {
6265 vty_out (vty, " from %s ",
6266 p->family == AF_INET ? "0.0.0.0" : "::");
6267 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6268 }
6269 else
6270 {
6271 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6272 vty_out (vty, " (inaccessible)");
Paul Jakmafb982c22007-05-04 20:15:47 +00006273 else if (binfo->extra && binfo->extra->igpmetric)
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02006274 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006275 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6276 buf[0] = '?';
6277 buf[1] = 0;
6278 }
6279 vty_out (vty, " from %s", buf);
paul718e3742002-12-13 20:15:29 +00006280 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006281 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006282 else
6283 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6284 }
6285 vty_out (vty, "%s", VTY_NEWLINE);
6286
paul718e3742002-12-13 20:15:29 +00006287 /* display nexthop local */
Paul Jakmafb982c22007-05-04 20:15:47 +00006288 if (attr->extra && attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006289 {
6290 vty_out (vty, " (%s)%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006291 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
paul718e3742002-12-13 20:15:29 +00006292 buf, INET6_ADDRSTRLEN),
6293 VTY_NEWLINE);
6294 }
paul718e3742002-12-13 20:15:29 +00006295
6296 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
6297 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6298
6299 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006300 vty_out (vty, ", metric %u", attr->med);
paul718e3742002-12-13 20:15:29 +00006301
6302 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006303 vty_out (vty, ", localpref %u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006304 else
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006305 vty_out (vty, ", localpref %u", bgp->default_local_pref);
paul718e3742002-12-13 20:15:29 +00006306
Paul Jakmafb982c22007-05-04 20:15:47 +00006307 if (attr->extra && attr->extra->weight != 0)
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006308 vty_out (vty, ", weight %u", attr->extra->weight);
paul718e3742002-12-13 20:15:29 +00006309
6310 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6311 vty_out (vty, ", valid");
6312
6313 if (binfo->peer != bgp->peer_self)
6314 {
6315 if (binfo->peer->as == binfo->peer->local_as)
6316 vty_out (vty, ", internal");
6317 else
6318 vty_out (vty, ", %s",
6319 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6320 }
6321 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6322 vty_out (vty, ", aggregated, local");
6323 else if (binfo->type != ZEBRA_ROUTE_BGP)
6324 vty_out (vty, ", sourced");
6325 else
6326 vty_out (vty, ", sourced, local");
6327
6328 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6329 vty_out (vty, ", atomic-aggregate");
6330
Josh Baileyde8d5df2011-07-20 20:46:01 -07006331 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6332 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6333 bgp_info_mpath_count (binfo)))
6334 vty_out (vty, ", multipath");
6335
paul718e3742002-12-13 20:15:29 +00006336 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6337 vty_out (vty, ", best");
6338
6339 vty_out (vty, "%s", VTY_NEWLINE);
6340
6341 /* Line 4 display Community */
6342 if (attr->community)
6343 vty_out (vty, " Community: %s%s", attr->community->str,
6344 VTY_NEWLINE);
6345
6346 /* Line 5 display Extended-community */
6347 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
Paul Jakmafb982c22007-05-04 20:15:47 +00006348 vty_out (vty, " Extended Community: %s%s",
6349 attr->extra->ecommunity->str, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006350
6351 /* Line 6 display Originator, Cluster-id */
6352 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6353 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6354 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006355 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006356 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006357 vty_out (vty, " Originator: %s",
6358 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006359
6360 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6361 {
6362 int i;
6363 vty_out (vty, ", Cluster list: ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006364 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6365 vty_out (vty, "%s ",
6366 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +00006367 }
6368 vty_out (vty, "%s", VTY_NEWLINE);
6369 }
Paul Jakma41367172007-08-06 15:24:51 +00006370
Paul Jakmafb982c22007-05-04 20:15:47 +00006371 if (binfo->extra && binfo->extra->damp_info)
paul718e3742002-12-13 20:15:29 +00006372 bgp_damp_info_vty (vty, binfo);
6373
6374 /* Line 7 display Uptime */
John Kemp30b00172011-03-18 17:52:18 +03006375#ifdef HAVE_CLOCK_MONOTONIC
6376 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
Vladimir L Ivanov213b6cd2010-10-21 14:59:54 +04006377 vty_out (vty, " Last update: %s", ctime(&tbuf));
John Kemp30b00172011-03-18 17:52:18 +03006378#else
6379 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6380#endif /* HAVE_CLOCK_MONOTONIC */
paul718e3742002-12-13 20:15:29 +00006381 }
6382 vty_out (vty, "%s", VTY_NEWLINE);
Boian Bonevb366b512013-09-09 16:41:35 +00006383}
6384
6385#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6386 "h history, * valid, > best, = multipath,%s"\
6387 " i internal, r RIB-failure, S Stale, R Removed%s"
hasso93406d82005-02-02 14:40:33 +00006388#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00006389#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6390#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6391#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6392
6393enum bgp_show_type
6394{
6395 bgp_show_type_normal,
6396 bgp_show_type_regexp,
6397 bgp_show_type_prefix_list,
6398 bgp_show_type_filter_list,
6399 bgp_show_type_route_map,
6400 bgp_show_type_neighbor,
6401 bgp_show_type_cidr_only,
6402 bgp_show_type_prefix_longer,
6403 bgp_show_type_community_all,
6404 bgp_show_type_community,
6405 bgp_show_type_community_exact,
6406 bgp_show_type_community_list,
6407 bgp_show_type_community_list_exact,
6408 bgp_show_type_flap_statistics,
6409 bgp_show_type_flap_address,
6410 bgp_show_type_flap_prefix,
6411 bgp_show_type_flap_cidr_only,
6412 bgp_show_type_flap_regexp,
6413 bgp_show_type_flap_filter_list,
6414 bgp_show_type_flap_prefix_list,
6415 bgp_show_type_flap_prefix_longer,
6416 bgp_show_type_flap_route_map,
6417 bgp_show_type_flap_neighbor,
6418 bgp_show_type_dampend_paths,
6419 bgp_show_type_damp_neighbor
6420};
6421
ajs5a646652004-11-05 01:25:55 +00006422static int
paulfee0f4c2004-09-13 05:12:46 +00006423bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00006424 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00006425{
paul718e3742002-12-13 20:15:29 +00006426 struct bgp_info *ri;
6427 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00006428 int header = 1;
paul718e3742002-12-13 20:15:29 +00006429 int display;
ajs5a646652004-11-05 01:25:55 +00006430 unsigned long output_count;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006431 unsigned long total_count;
paul718e3742002-12-13 20:15:29 +00006432
6433 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00006434 output_count = 0;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006435 total_count = 0;
paul718e3742002-12-13 20:15:29 +00006436
paul718e3742002-12-13 20:15:29 +00006437 /* Start processing of routes. */
6438 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6439 if (rn->info != NULL)
6440 {
6441 display = 0;
6442
6443 for (ri = rn->info; ri; ri = ri->next)
6444 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006445 total_count++;
ajs5a646652004-11-05 01:25:55 +00006446 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00006447 || type == bgp_show_type_flap_address
6448 || type == bgp_show_type_flap_prefix
6449 || type == bgp_show_type_flap_cidr_only
6450 || type == bgp_show_type_flap_regexp
6451 || type == bgp_show_type_flap_filter_list
6452 || type == bgp_show_type_flap_prefix_list
6453 || type == bgp_show_type_flap_prefix_longer
6454 || type == bgp_show_type_flap_route_map
6455 || type == bgp_show_type_flap_neighbor
6456 || type == bgp_show_type_dampend_paths
6457 || type == bgp_show_type_damp_neighbor)
6458 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006459 if (!(ri->extra && ri->extra->damp_info))
paul718e3742002-12-13 20:15:29 +00006460 continue;
6461 }
6462 if (type == bgp_show_type_regexp
6463 || type == bgp_show_type_flap_regexp)
6464 {
ajs5a646652004-11-05 01:25:55 +00006465 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00006466
6467 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6468 continue;
6469 }
6470 if (type == bgp_show_type_prefix_list
6471 || type == bgp_show_type_flap_prefix_list)
6472 {
ajs5a646652004-11-05 01:25:55 +00006473 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00006474
6475 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6476 continue;
6477 }
6478 if (type == bgp_show_type_filter_list
6479 || type == bgp_show_type_flap_filter_list)
6480 {
ajs5a646652004-11-05 01:25:55 +00006481 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00006482
6483 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6484 continue;
6485 }
6486 if (type == bgp_show_type_route_map
6487 || type == bgp_show_type_flap_route_map)
6488 {
ajs5a646652004-11-05 01:25:55 +00006489 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00006490 struct bgp_info binfo;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006491 struct attr dummy_attr;
6492 struct attr_extra dummy_extra;
paul718e3742002-12-13 20:15:29 +00006493 int ret;
6494
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006495 dummy_attr.extra = &dummy_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00006496 bgp_attr_dup (&dummy_attr, ri->attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006497
paul718e3742002-12-13 20:15:29 +00006498 binfo.peer = ri->peer;
6499 binfo.attr = &dummy_attr;
6500
6501 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
paul718e3742002-12-13 20:15:29 +00006502 if (ret == RMAP_DENYMATCH)
6503 continue;
6504 }
6505 if (type == bgp_show_type_neighbor
6506 || type == bgp_show_type_flap_neighbor
6507 || type == bgp_show_type_damp_neighbor)
6508 {
ajs5a646652004-11-05 01:25:55 +00006509 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00006510
6511 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6512 continue;
6513 }
6514 if (type == bgp_show_type_cidr_only
6515 || type == bgp_show_type_flap_cidr_only)
6516 {
6517 u_int32_t destination;
6518
6519 destination = ntohl (rn->p.u.prefix4.s_addr);
6520 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6521 continue;
6522 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6523 continue;
6524 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6525 continue;
6526 }
6527 if (type == bgp_show_type_prefix_longer
6528 || type == bgp_show_type_flap_prefix_longer)
6529 {
ajs5a646652004-11-05 01:25:55 +00006530 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006531
6532 if (! prefix_match (p, &rn->p))
6533 continue;
6534 }
6535 if (type == bgp_show_type_community_all)
6536 {
6537 if (! ri->attr->community)
6538 continue;
6539 }
6540 if (type == bgp_show_type_community)
6541 {
ajs5a646652004-11-05 01:25:55 +00006542 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006543
6544 if (! ri->attr->community ||
6545 ! community_match (ri->attr->community, com))
6546 continue;
6547 }
6548 if (type == bgp_show_type_community_exact)
6549 {
ajs5a646652004-11-05 01:25:55 +00006550 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006551
6552 if (! ri->attr->community ||
6553 ! community_cmp (ri->attr->community, com))
6554 continue;
6555 }
6556 if (type == bgp_show_type_community_list)
6557 {
ajs5a646652004-11-05 01:25:55 +00006558 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006559
6560 if (! community_list_match (ri->attr->community, list))
6561 continue;
6562 }
6563 if (type == bgp_show_type_community_list_exact)
6564 {
ajs5a646652004-11-05 01:25:55 +00006565 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006566
6567 if (! community_list_exact_match (ri->attr->community, list))
6568 continue;
6569 }
6570 if (type == bgp_show_type_flap_address
6571 || type == bgp_show_type_flap_prefix)
6572 {
ajs5a646652004-11-05 01:25:55 +00006573 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006574
6575 if (! prefix_match (&rn->p, p))
6576 continue;
6577
6578 if (type == bgp_show_type_flap_prefix)
6579 if (p->prefixlen != rn->p.prefixlen)
6580 continue;
6581 }
6582 if (type == bgp_show_type_dampend_paths
6583 || type == bgp_show_type_damp_neighbor)
6584 {
6585 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6586 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6587 continue;
6588 }
6589
6590 if (header)
6591 {
hasso93406d82005-02-02 14:40:33 +00006592 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6593 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6594 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006595 if (type == bgp_show_type_dampend_paths
6596 || type == bgp_show_type_damp_neighbor)
6597 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6598 else if (type == bgp_show_type_flap_statistics
6599 || type == bgp_show_type_flap_address
6600 || type == bgp_show_type_flap_prefix
6601 || type == bgp_show_type_flap_cidr_only
6602 || type == bgp_show_type_flap_regexp
6603 || type == bgp_show_type_flap_filter_list
6604 || type == bgp_show_type_flap_prefix_list
6605 || type == bgp_show_type_flap_prefix_longer
6606 || type == bgp_show_type_flap_route_map
6607 || type == bgp_show_type_flap_neighbor)
6608 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6609 else
6610 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006611 header = 0;
6612 }
6613
6614 if (type == bgp_show_type_dampend_paths
6615 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00006616 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006617 else if (type == bgp_show_type_flap_statistics
6618 || type == bgp_show_type_flap_address
6619 || type == bgp_show_type_flap_prefix
6620 || type == bgp_show_type_flap_cidr_only
6621 || type == bgp_show_type_flap_regexp
6622 || type == bgp_show_type_flap_filter_list
6623 || type == bgp_show_type_flap_prefix_list
6624 || type == bgp_show_type_flap_prefix_longer
6625 || type == bgp_show_type_flap_route_map
6626 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00006627 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006628 else
ajs5a646652004-11-05 01:25:55 +00006629 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006630 display++;
6631 }
6632 if (display)
ajs5a646652004-11-05 01:25:55 +00006633 output_count++;
paul718e3742002-12-13 20:15:29 +00006634 }
6635
6636 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00006637 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00006638 {
6639 if (type == bgp_show_type_normal)
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006640 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006641 }
6642 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006643 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6644 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006645
6646 return CMD_SUCCESS;
6647}
6648
ajs5a646652004-11-05 01:25:55 +00006649static int
paulfee0f4c2004-09-13 05:12:46 +00006650bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00006651 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00006652{
6653 struct bgp_table *table;
6654
6655 if (bgp == NULL) {
6656 bgp = bgp_get_default ();
6657 }
6658
6659 if (bgp == NULL)
6660 {
6661 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6662 return CMD_WARNING;
6663 }
6664
6665
6666 table = bgp->rib[afi][safi];
6667
ajs5a646652004-11-05 01:25:55 +00006668 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00006669}
6670
paul718e3742002-12-13 20:15:29 +00006671/* Header of detailed BGP route information */
paul94f2b392005-06-28 12:44:16 +00006672static void
paul718e3742002-12-13 20:15:29 +00006673route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6674 struct bgp_node *rn,
6675 struct prefix_rd *prd, afi_t afi, safi_t safi)
6676{
6677 struct bgp_info *ri;
6678 struct prefix *p;
6679 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006680 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00006681 char buf1[INET6_ADDRSTRLEN];
6682 char buf2[INET6_ADDRSTRLEN];
6683 int count = 0;
6684 int best = 0;
6685 int suppress = 0;
6686 int no_export = 0;
6687 int no_advertise = 0;
6688 int local_as = 0;
6689 int first = 0;
Lou Berger298cc2f2016-01-12 13:42:02 -05006690 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
paul718e3742002-12-13 20:15:29 +00006691
6692 p = &rn->p;
6693 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
Lou Berger298cc2f2016-01-12 13:42:02 -05006694 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6695 printrd ? ":" : "",
paul718e3742002-12-13 20:15:29 +00006696 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6697 p->prefixlen, VTY_NEWLINE);
6698
6699 for (ri = rn->info; ri; ri = ri->next)
6700 {
6701 count++;
6702 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6703 {
6704 best = count;
Paul Jakmafb982c22007-05-04 20:15:47 +00006705 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00006706 suppress = 1;
6707 if (ri->attr->community != NULL)
6708 {
6709 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6710 no_advertise = 1;
6711 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6712 no_export = 1;
6713 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6714 local_as = 1;
6715 }
6716 }
6717 }
6718
6719 vty_out (vty, "Paths: (%d available", count);
6720 if (best)
6721 {
6722 vty_out (vty, ", best #%d", best);
6723 if (safi == SAFI_UNICAST)
6724 vty_out (vty, ", table Default-IP-Routing-Table");
6725 }
6726 else
6727 vty_out (vty, ", no best path");
6728 if (no_advertise)
6729 vty_out (vty, ", not advertised to any peer");
6730 else if (no_export)
6731 vty_out (vty, ", not advertised to EBGP peer");
6732 else if (local_as)
6733 vty_out (vty, ", not advertised outside local AS");
6734 if (suppress)
6735 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6736 vty_out (vty, ")%s", VTY_NEWLINE);
6737
6738 /* advertised peer */
paul1eb8ef22005-04-07 07:30:20 +00006739 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006740 {
6741 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6742 {
6743 if (! first)
6744 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6745 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6746 first = 1;
6747 }
6748 }
6749 if (! first)
6750 vty_out (vty, " Not advertised to any peer");
6751 vty_out (vty, "%s", VTY_NEWLINE);
6752}
6753
6754/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +00006755static int
paulfee0f4c2004-09-13 05:12:46 +00006756bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00006757 struct bgp_table *rib, const char *ip_str,
6758 afi_t afi, safi_t safi, struct prefix_rd *prd,
6759 int prefix_check)
paul718e3742002-12-13 20:15:29 +00006760{
6761 int ret;
6762 int header;
6763 int display = 0;
6764 struct prefix match;
6765 struct bgp_node *rn;
6766 struct bgp_node *rm;
6767 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00006768 struct bgp_table *table;
6769
Lou Berger050defe2016-01-12 13:41:59 -05006770 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
paul718e3742002-12-13 20:15:29 +00006771 /* Check IP address argument. */
6772 ret = str2prefix (ip_str, &match);
6773 if (! ret)
6774 {
6775 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6776 return CMD_WARNING;
6777 }
6778
6779 match.family = afi2family (afi);
6780
Lou Berger298cc2f2016-01-12 13:42:02 -05006781 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00006782 {
paulfee0f4c2004-09-13 05:12:46 +00006783 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00006784 {
6785 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6786 continue;
6787
6788 if ((table = rn->info) != NULL)
6789 {
6790 header = 1;
6791
6792 if ((rm = bgp_node_match (table, &match)) != NULL)
6793 {
6794 if (prefix_check && rm->p.prefixlen != match.prefixlen)
Chris Caputo6c88b442010-07-27 16:28:55 +00006795 {
6796 bgp_unlock_node (rm);
6797 continue;
6798 }
paul718e3742002-12-13 20:15:29 +00006799
6800 for (ri = rm->info; ri; ri = ri->next)
6801 {
6802 if (header)
6803 {
6804 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
Lou Berger298cc2f2016-01-12 13:42:02 -05006805 AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006806
6807 header = 0;
6808 }
6809 display++;
Lou Berger298cc2f2016-01-12 13:42:02 -05006810 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006811 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006812
6813 bgp_unlock_node (rm);
paul718e3742002-12-13 20:15:29 +00006814 }
6815 }
6816 }
6817 }
6818 else
6819 {
6820 header = 1;
6821
paulfee0f4c2004-09-13 05:12:46 +00006822 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00006823 {
6824 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6825 {
6826 for (ri = rn->info; ri; ri = ri->next)
6827 {
6828 if (header)
6829 {
6830 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6831 header = 0;
6832 }
6833 display++;
6834 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
6835 }
6836 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006837
6838 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00006839 }
6840 }
6841
6842 if (! display)
6843 {
6844 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6845 return CMD_WARNING;
6846 }
6847
6848 return CMD_SUCCESS;
6849}
6850
paulfee0f4c2004-09-13 05:12:46 +00006851/* Display specified route of Main RIB */
paul94f2b392005-06-28 12:44:16 +00006852static int
paulfd79ac92004-10-13 05:06:08 +00006853bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00006854 afi_t afi, safi_t safi, struct prefix_rd *prd,
6855 int prefix_check)
6856{
6857 struct bgp *bgp;
6858
6859 /* BGP structure lookup. */
6860 if (view_name)
6861 {
6862 bgp = bgp_lookup_by_name (view_name);
6863 if (bgp == NULL)
6864 {
6865 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6866 return CMD_WARNING;
6867 }
6868 }
6869 else
6870 {
6871 bgp = bgp_get_default ();
6872 if (bgp == NULL)
6873 {
6874 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6875 return CMD_WARNING;
6876 }
6877 }
6878
6879 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
6880 afi, safi, prd, prefix_check);
6881}
6882
paul718e3742002-12-13 20:15:29 +00006883/* BGP route print out function. */
Lou Bergerf9b6c392016-01-12 13:42:09 -05006884DEFUN (show_ip_bgp,
6885 show_ip_bgp_cmd,
6886 "show ip bgp",
6887 SHOW_STR
6888 IP_STR
6889 BGP_STR)
6890{
6891 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6892}
6893
6894DEFUN (show_ip_bgp_ipv4,
6895 show_ip_bgp_ipv4_cmd,
6896 "show ip bgp ipv4 (unicast|multicast)",
6897 SHOW_STR
6898 IP_STR
6899 BGP_STR
6900 "Address family\n"
6901 "Address Family modifier\n"
6902 "Address Family modifier\n")
6903{
6904 if (strncmp (argv[0], "m", 1) == 0)
6905 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
6906 NULL);
6907
6908 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6909}
6910
6911DEFUN (show_ip_bgp_route,
6912 show_ip_bgp_route_cmd,
6913 "show ip bgp A.B.C.D",
6914 SHOW_STR
6915 IP_STR
6916 BGP_STR
6917 "Network in the BGP routing table to display\n")
6918{
6919 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
6920}
6921
6922DEFUN (show_ip_bgp_ipv4_route,
6923 show_ip_bgp_ipv4_route_cmd,
6924 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6925 SHOW_STR
6926 IP_STR
6927 BGP_STR
6928 "Address family\n"
6929 "Address Family modifier\n"
6930 "Address Family modifier\n"
6931 "Network in the BGP routing table to display\n")
6932{
6933 if (strncmp (argv[0], "m", 1) == 0)
6934 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
6935
6936 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
6937}
6938
6939DEFUN (show_ip_bgp_vpnv4_all_route,
6940 show_ip_bgp_vpnv4_all_route_cmd,
6941 "show ip bgp vpnv4 all A.B.C.D",
6942 SHOW_STR
6943 IP_STR
6944 BGP_STR
6945 "Display VPNv4 NLRI specific information\n"
6946 "Display information about all VPNv4 NLRIs\n"
6947 "Network in the BGP routing table to display\n")
6948{
6949 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
6950}
6951
6952DEFUN (show_ip_bgp_vpnv4_rd_route,
6953 show_ip_bgp_vpnv4_rd_route_cmd,
6954 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6955 SHOW_STR
6956 IP_STR
6957 BGP_STR
6958 "Display VPNv4 NLRI specific information\n"
6959 "Display information for a route distinguisher\n"
6960 "VPN Route Distinguisher\n"
6961 "Network in the BGP routing table to display\n")
6962{
6963 int ret;
6964 struct prefix_rd prd;
6965
6966 ret = str2prefix_rd (argv[0], &prd);
6967 if (! ret)
6968 {
6969 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
6970 return CMD_WARNING;
6971 }
6972 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
6973}
6974
6975DEFUN (show_ip_bgp_prefix,
6976 show_ip_bgp_prefix_cmd,
6977 "show ip bgp A.B.C.D/M",
6978 SHOW_STR
6979 IP_STR
6980 BGP_STR
6981 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6982{
6983 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
6984}
6985
6986DEFUN (show_ip_bgp_ipv4_prefix,
6987 show_ip_bgp_ipv4_prefix_cmd,
6988 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6989 SHOW_STR
6990 IP_STR
6991 BGP_STR
6992 "Address family\n"
6993 "Address Family modifier\n"
6994 "Address Family modifier\n"
6995 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6996{
6997 if (strncmp (argv[0], "m", 1) == 0)
6998 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
6999
7000 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7001}
7002
7003DEFUN (show_ip_bgp_vpnv4_all_prefix,
7004 show_ip_bgp_vpnv4_all_prefix_cmd,
7005 "show ip bgp vpnv4 all A.B.C.D/M",
7006 SHOW_STR
7007 IP_STR
7008 BGP_STR
7009 "Display VPNv4 NLRI specific information\n"
7010 "Display information about all VPNv4 NLRIs\n"
7011 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7012{
7013 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
7014}
7015
7016DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7017 show_ip_bgp_vpnv4_rd_prefix_cmd,
7018 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7019 SHOW_STR
7020 IP_STR
7021 BGP_STR
7022 "Display VPNv4 NLRI specific information\n"
7023 "Display information for a route distinguisher\n"
7024 "VPN Route Distinguisher\n"
7025 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7026{
7027 int ret;
7028 struct prefix_rd prd;
7029
7030 ret = str2prefix_rd (argv[0], &prd);
7031 if (! ret)
7032 {
7033 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7034 return CMD_WARNING;
7035 }
7036 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
7037}
7038
7039DEFUN (show_ip_bgp_view,
7040 show_ip_bgp_view_cmd,
7041 "show ip bgp view WORD",
7042 SHOW_STR
7043 IP_STR
7044 BGP_STR
7045 "BGP view\n"
7046 "View name\n")
7047{
7048 struct bgp *bgp;
7049
7050 /* BGP structure lookup. */
7051 bgp = bgp_lookup_by_name (argv[0]);
7052 if (bgp == NULL)
7053 {
7054 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7055 return CMD_WARNING;
7056 }
7057
7058 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7059}
7060
7061DEFUN (show_ip_bgp_view_route,
7062 show_ip_bgp_view_route_cmd,
7063 "show ip bgp view WORD A.B.C.D",
7064 SHOW_STR
7065 IP_STR
7066 BGP_STR
7067 "BGP view\n"
7068 "View name\n"
7069 "Network in the BGP routing table to display\n")
7070{
7071 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7072}
7073
7074DEFUN (show_ip_bgp_view_prefix,
7075 show_ip_bgp_view_prefix_cmd,
7076 "show ip bgp view WORD A.B.C.D/M",
7077 SHOW_STR
7078 IP_STR
7079 BGP_STR
7080 "BGP view\n"
7081 "View name\n"
7082 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7083{
7084 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7085}
7086
7087DEFUN (show_bgp,
7088 show_bgp_cmd,
7089 "show bgp",
7090 SHOW_STR
7091 BGP_STR)
7092{
7093 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7094 NULL);
7095}
7096
7097ALIAS (show_bgp,
7098 show_bgp_ipv6_cmd,
7099 "show bgp ipv6",
7100 SHOW_STR
7101 BGP_STR
7102 "Address family\n")
7103
7104/* old command */
7105DEFUN (show_ipv6_bgp,
7106 show_ipv6_bgp_cmd,
7107 "show ipv6 bgp",
7108 SHOW_STR
7109 IP_STR
7110 BGP_STR)
7111{
7112 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7113 NULL);
7114}
7115
7116DEFUN (show_bgp_route,
7117 show_bgp_route_cmd,
7118 "show bgp X:X::X:X",
7119 SHOW_STR
7120 BGP_STR
7121 "Network in the BGP routing table to display\n")
7122{
7123 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7124}
7125
Lou Berger35c36862016-01-12 13:42:06 -05007126DEFUN (show_bgp_ipv4_safi,
7127 show_bgp_ipv4_safi_cmd,
7128 "show bgp ipv4 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00007129 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007130 BGP_STR
7131 "Address family\n"
7132 "Address Family modifier\n"
7133 "Address Family modifier\n")
7134{
7135 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00007136 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7137 NULL);
paul718e3742002-12-13 20:15:29 +00007138
ajs5a646652004-11-05 01:25:55 +00007139 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00007140}
7141
Lou Berger35c36862016-01-12 13:42:06 -05007142DEFUN (show_bgp_ipv4_safi_route,
7143 show_bgp_ipv4_safi_route_cmd,
7144 "show bgp ipv4 (unicast|multicast) A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007145 SHOW_STR
7146 BGP_STR
7147 "Address family\n"
7148 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00007149 "Address Family modifier\n"
7150 "Network in the BGP routing table to display\n")
7151{
7152 if (strncmp (argv[0], "m", 1) == 0)
7153 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
7154
7155 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7156}
7157
Lou Berger35c36862016-01-12 13:42:06 -05007158DEFUN (show_bgp_ipv4_vpn_route,
7159 show_bgp_ipv4_vpn_route_cmd,
7160 "show bgp ipv4 vpn A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007161 SHOW_STR
7162 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007163 "Address Family\n"
7164 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007165 "Network in the BGP routing table to display\n")
7166{
7167 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
7168}
7169
Lou Berger35c36862016-01-12 13:42:06 -05007170DEFUN (show_bgp_ipv6_vpn_route,
7171 show_bgp_ipv6_vpn_route_cmd,
7172 "show bgp ipv6 vpn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007173 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007174 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007175 "Address Family\n"
7176 "Display VPN NLRI specific information\n"
7177 "Network in the BGP routing table to display\n")
7178{
7179 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0);
7180}
Lou Berger35c36862016-01-12 13:42:06 -05007181
7182DEFUN (show_bgp_ipv4_vpn_rd_route,
7183 show_bgp_ipv4_vpn_rd_route_cmd,
7184 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7185 SHOW_STR
7186 BGP_STR
7187 IP_STR
7188 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007189 "Display information for a route distinguisher\n"
7190 "VPN Route Distinguisher\n"
7191 "Network in the BGP routing table to display\n")
7192{
7193 int ret;
7194 struct prefix_rd prd;
7195
7196 ret = str2prefix_rd (argv[0], &prd);
7197 if (! ret)
7198 {
7199 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7200 return CMD_WARNING;
7201 }
7202 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
7203}
7204
Lou Berger35c36862016-01-12 13:42:06 -05007205DEFUN (show_bgp_ipv6_vpn_rd_route,
7206 show_bgp_ipv6_vpn_rd_route_cmd,
7207 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007208 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007209 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007210 "Address Family\n"
7211 "Display VPN NLRI specific information\n"
7212 "Display information for a route distinguisher\n"
7213 "VPN Route Distinguisher\n"
7214 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007215{
Lou Berger35c36862016-01-12 13:42:06 -05007216 int ret;
7217 struct prefix_rd prd;
7218
7219 ret = str2prefix_rd (argv[0], &prd);
7220 if (! ret)
7221 {
7222 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7223 return CMD_WARNING;
7224 }
7225 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007226}
7227
Lou Berger651b4022016-01-12 13:42:07 -05007228DEFUN (show_bgp_ipv4_encap_route,
7229 show_bgp_ipv4_encap_route_cmd,
7230 "show bgp ipv4 encap A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007231 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007232 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007233 IP_STR
7234 "Display ENCAP NLRI specific information\n"
7235 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007236{
Lou Berger651b4022016-01-12 13:42:07 -05007237 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007238}
7239
Lou Berger651b4022016-01-12 13:42:07 -05007240DEFUN (show_bgp_ipv6_encap_route,
7241 show_bgp_ipv6_encap_route_cmd,
7242 "show bgp ipv6 encap X:X::X:X",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007243 SHOW_STR
7244 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007245 IP6_STR
7246 "Display ENCAP NLRI specific information\n"
7247 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007248{
Lou Berger651b4022016-01-12 13:42:07 -05007249 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007250}
7251
Lou Berger651b4022016-01-12 13:42:07 -05007252DEFUN (show_bgp_ipv4_safi_rd_route,
7253 show_bgp_ipv4_safi_rd_route_cmd,
7254 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007255 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007256 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007257 "Address Family\n"
7258 "Address Family Modifier\n"
7259 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007260 "Display information for a route distinguisher\n"
Lou Berger651b4022016-01-12 13:42:07 -05007261 "ENCAP Route Distinguisher\n"
7262 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007263{
7264 int ret;
7265 struct prefix_rd prd;
Lou Berger651b4022016-01-12 13:42:07 -05007266 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007267
Lou Berger651b4022016-01-12 13:42:07 -05007268 if (bgp_parse_safi(argv[0], &safi)) {
7269 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7270 return CMD_WARNING;
7271 }
7272 ret = str2prefix_rd (argv[1], &prd);
paul718e3742002-12-13 20:15:29 +00007273 if (! ret)
7274 {
7275 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7276 return CMD_WARNING;
7277 }
Lou Berger651b4022016-01-12 13:42:07 -05007278 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007279}
7280
Lou Berger651b4022016-01-12 13:42:07 -05007281DEFUN (show_bgp_ipv6_safi_rd_route,
7282 show_bgp_ipv6_safi_rd_route_cmd,
7283 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007284 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007285 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007286 "Address Family\n"
7287 "Address Family Modifier\n"
7288 "Address Family Modifier\n"
7289 "Display information for a route distinguisher\n"
7290 "ENCAP Route Distinguisher\n"
7291 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007292{
Lou Berger651b4022016-01-12 13:42:07 -05007293 int ret;
7294 struct prefix_rd prd;
7295 safi_t safi;
paulbb46e942003-10-24 19:02:03 +00007296
Lou Berger651b4022016-01-12 13:42:07 -05007297 if (bgp_parse_safi(argv[0], &safi)) {
7298 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7299 return CMD_WARNING;
7300 }
7301 ret = str2prefix_rd (argv[1], &prd);
7302 if (! ret)
7303 {
7304 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7305 return CMD_WARNING;
7306 }
7307 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007308}
7309
Lou Berger35c36862016-01-12 13:42:06 -05007310DEFUN (show_bgp_ipv4_prefix,
7311 show_bgp_ipv4_prefix_cmd,
7312 "show bgp ipv4 A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007313 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007314 BGP_STR
paul718e3742002-12-13 20:15:29 +00007315 IP_STR
paul718e3742002-12-13 20:15:29 +00007316 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7317{
Lou Berger35c36862016-01-12 13:42:06 -05007318 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007319}
7320
Lou Berger35c36862016-01-12 13:42:06 -05007321DEFUN (show_bgp_ipv4_safi_prefix,
7322 show_bgp_ipv4_safi_prefix_cmd,
7323 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007324 SHOW_STR
7325 BGP_STR
7326 "Address family\n"
7327 "Address Family modifier\n"
Lou Berger35c36862016-01-12 13:42:06 -05007328 "Address Family modifier\n"
7329 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04007330{
7331 if (strncmp (argv[0], "m", 1) == 0)
Lou Berger35c36862016-01-12 13:42:06 -05007332 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007333
Lou Berger35c36862016-01-12 13:42:06 -05007334 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007335}
7336
Lou Berger35c36862016-01-12 13:42:06 -05007337DEFUN (show_bgp_ipv4_vpn_prefix,
7338 show_bgp_ipv4_vpn_prefix_cmd,
7339 "show bgp ipv4 vpn A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007340 SHOW_STR
7341 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007342 IP_STR
7343 "Display VPN NLRI specific information\n"
7344 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +00007345{
Lou Berger35c36862016-01-12 13:42:06 -05007346 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007347}
7348
Lou Berger35c36862016-01-12 13:42:06 -05007349DEFUN (show_bgp_ipv6_vpn_prefix,
7350 show_bgp_ipv6_vpn_prefix_cmd,
7351 "show bgp ipv6 vpn X:X::X:X/M",
7352 SHOW_STR
7353 BGP_STR
7354 "Address Family\n"
7355 "Display VPN NLRI specific information\n"
7356 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7357{
7358 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1);
7359}
Lou Berger35c36862016-01-12 13:42:06 -05007360
Lou Berger651b4022016-01-12 13:42:07 -05007361DEFUN (show_bgp_ipv4_encap_prefix,
7362 show_bgp_ipv4_encap_prefix_cmd,
7363 "show bgp ipv4 encap A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007364 SHOW_STR
7365 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007366 IP_STR
7367 "Display ENCAP NLRI specific information\n"
7368 "Display information about ENCAP NLRIs\n"
7369 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7370{
7371 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1);
7372}
paul718e3742002-12-13 20:15:29 +00007373
Lou Berger651b4022016-01-12 13:42:07 -05007374DEFUN (show_bgp_ipv6_encap_prefix,
7375 show_bgp_ipv6_encap_prefix_cmd,
7376 "show bgp ipv6 encap X:X::X:X/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007377 SHOW_STR
7378 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007379 IP_STR
7380 "Display ENCAP NLRI specific information\n"
7381 "Display information about ENCAP NLRIs\n"
7382 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7383{
7384 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1);
7385}
Lou Berger651b4022016-01-12 13:42:07 -05007386
7387DEFUN (show_bgp_ipv4_safi_rd_prefix,
7388 show_bgp_ipv4_safi_rd_prefix_cmd,
7389 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7390 SHOW_STR
7391 BGP_STR
7392 "Address Family\n"
7393 "Address Family Modifier\n"
7394 "Address Family Modifier\n"
7395 "Display information for a route distinguisher\n"
7396 "ENCAP Route Distinguisher\n"
7397 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7398{
7399 int ret;
7400 struct prefix_rd prd;
7401 safi_t safi;
7402
7403 if (bgp_parse_safi(argv[0], &safi)) {
7404 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7405 return CMD_WARNING;
7406 }
7407
7408 ret = str2prefix_rd (argv[1], &prd);
7409 if (! ret)
7410 {
7411 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7412 return CMD_WARNING;
7413 }
7414 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1);
7415}
7416
Lou Berger651b4022016-01-12 13:42:07 -05007417DEFUN (show_bgp_ipv6_safi_rd_prefix,
7418 show_bgp_ipv6_safi_rd_prefix_cmd,
7419 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7420 SHOW_STR
7421 BGP_STR
7422 "Address Family\n"
7423 "Address Family Modifier\n"
7424 "Address Family Modifier\n"
7425 "Display information for a route distinguisher\n"
7426 "ENCAP Route Distinguisher\n"
7427 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7428{
7429 int ret;
7430 struct prefix_rd prd;
7431 safi_t safi;
7432
7433 if (bgp_parse_safi(argv[0], &safi)) {
7434 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7435 return CMD_WARNING;
7436 }
7437
7438 ret = str2prefix_rd (argv[1], &prd);
7439 if (! ret)
7440 {
7441 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7442 return CMD_WARNING;
7443 }
7444 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1);
7445}
Lou Berger651b4022016-01-12 13:42:07 -05007446
7447DEFUN (show_bgp_afi_safi_view,
7448 show_bgp_afi_safi_view_cmd,
7449 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7450 SHOW_STR
7451 BGP_STR
7452 "BGP view\n"
7453 "BGP view name\n"
7454 "Address Family\n"
7455 "Address Family\n"
7456 "Address Family Modifier\n"
7457 "Address Family Modifier\n"
7458 "Address Family Modifier\n"
7459 "Address Family Modifier\n"
7460 )
7461{
7462 struct bgp *bgp;
7463 safi_t safi;
7464 afi_t afi;
7465
7466 if (bgp_parse_afi(argv[1], &afi)) {
7467 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7468 return CMD_WARNING;
7469 }
7470 if (bgp_parse_safi(argv[2], &safi)) {
7471 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7472 return CMD_WARNING;
7473 }
7474
7475 /* BGP structure lookup. */
7476 bgp = bgp_lookup_by_name (argv[0]);
7477 if (bgp == NULL)
7478 {
7479 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7480 return CMD_WARNING;
7481 }
7482
7483 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7484}
7485
7486DEFUN (show_bgp_view_afi_safi_route,
7487 show_bgp_view_afi_safi_route_cmd,
7488 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7489 SHOW_STR
7490 BGP_STR
7491 "BGP view\n"
7492 "View name\n"
7493 "Address Family\n"
7494 "Address Family\n"
7495 "Address Family Modifier\n"
7496 "Address Family Modifier\n"
7497 "Address Family Modifier\n"
7498 "Address Family Modifier\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -04007499 "Network in the BGP routing table to display\n")
7500{
Lou Berger651b4022016-01-12 13:42:07 -05007501 safi_t safi;
7502 afi_t afi;
Michael Lambert95cbbd22010-07-23 14:43:04 -04007503
Lou Berger651b4022016-01-12 13:42:07 -05007504 if (bgp_parse_afi(argv[1], &afi)) {
7505 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7506 return CMD_WARNING;
7507 }
7508 if (bgp_parse_safi(argv[2], &safi)) {
7509 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7510 return CMD_WARNING;
7511 }
7512 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0);
7513}
7514
7515DEFUN (show_bgp_view_afi_safi_prefix,
7516 show_bgp_view_afi_safi_prefix_cmd,
7517 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7518 SHOW_STR
7519 BGP_STR
7520 "BGP view\n"
7521 "View name\n"
7522 "Address Family\n"
7523 "Address Family\n"
7524 "Address Family Modifier\n"
7525 "Address Family Modifier\n"
7526 "Address Family Modifier\n"
7527 "Address Family Modifier\n"
7528 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7529{
7530 safi_t safi;
7531 afi_t afi;
7532
7533 if (bgp_parse_afi(argv[1], &afi)) {
7534 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7535 return CMD_WARNING;
7536 }
7537 if (bgp_parse_safi(argv[2], &safi)) {
7538 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7539 return CMD_WARNING;
7540 }
7541 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1);
7542}
7543
7544/* new001 */
7545DEFUN (show_bgp_afi,
7546 show_bgp_afi_cmd,
7547 "show bgp (ipv4|ipv6)",
7548 SHOW_STR
7549 BGP_STR
7550 "Address family\n"
7551 "Address family\n")
7552{
7553 afi_t afi;
7554
7555 if (bgp_parse_afi(argv[0], &afi)) {
7556 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7557 return CMD_WARNING;
7558 }
7559 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7560 NULL);
7561}
7562
Lou Berger651b4022016-01-12 13:42:07 -05007563DEFUN (show_bgp_ipv6_safi,
7564 show_bgp_ipv6_safi_cmd,
7565 "show bgp ipv6 (unicast|multicast)",
7566 SHOW_STR
7567 BGP_STR
7568 "Address family\n"
7569 "Address Family modifier\n"
7570 "Address Family modifier\n")
7571{
7572 if (strncmp (argv[0], "m", 1) == 0)
7573 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7574 NULL);
7575
7576 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007577}
7578
Lou Berger35c36862016-01-12 13:42:06 -05007579DEFUN (show_bgp_ipv6_route,
7580 show_bgp_ipv6_route_cmd,
7581 "show bgp ipv6 X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007582 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007583 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007584 "Address family\n"
paul718e3742002-12-13 20:15:29 +00007585 "Network in the BGP routing table to display\n")
7586{
7587 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7588}
7589
Lou Berger35c36862016-01-12 13:42:06 -05007590DEFUN (show_bgp_ipv6_safi_route,
7591 show_bgp_ipv6_safi_route_cmd,
7592 "show bgp ipv6 (unicast|multicast) X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007593 SHOW_STR
7594 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007595 "Address family\n"
7596 "Address Family modifier\n"
7597 "Address Family modifier\n"
7598 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007599{
Lou Berger35c36862016-01-12 13:42:06 -05007600 if (strncmp (argv[0], "m", 1) == 0)
7601 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7602
7603 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007604}
7605
Lou Bergerf9b6c392016-01-12 13:42:09 -05007606/* old command */
7607DEFUN (show_ipv6_bgp_route,
7608 show_ipv6_bgp_route_cmd,
7609 "show ipv6 bgp X:X::X:X",
7610 SHOW_STR
7611 IP_STR
7612 BGP_STR
7613 "Network in the BGP routing table to display\n")
7614{
7615 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7616}
7617
7618DEFUN (show_bgp_prefix,
7619 show_bgp_prefix_cmd,
7620 "show bgp X:X::X:X/M",
7621 SHOW_STR
7622 BGP_STR
7623 "IPv6 prefix <network>/<length>\n")
7624{
7625 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7626}
7627
7628
Lou Berger35c36862016-01-12 13:42:06 -05007629/* new002 */
7630DEFUN (show_bgp_ipv6_prefix,
paul718e3742002-12-13 20:15:29 +00007631 show_bgp_ipv6_prefix_cmd,
7632 "show bgp ipv6 X:X::X:X/M",
7633 SHOW_STR
7634 BGP_STR
7635 "Address family\n"
Lou Berger35c36862016-01-12 13:42:06 -05007636 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7637{
7638 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7639}
Michael Lambert95cbbd22010-07-23 14:43:04 -04007640DEFUN (show_bgp_ipv6_safi_prefix,
7641 show_bgp_ipv6_safi_prefix_cmd,
7642 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7643 SHOW_STR
7644 BGP_STR
7645 "Address family\n"
7646 "Address Family modifier\n"
7647 "Address Family modifier\n"
7648 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7649{
7650 if (strncmp (argv[0], "m", 1) == 0)
7651 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7652
7653 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7654}
7655
Lou Bergerf9b6c392016-01-12 13:42:09 -05007656/* old command */
7657DEFUN (show_ipv6_bgp_prefix,
7658 show_ipv6_bgp_prefix_cmd,
7659 "show ipv6 bgp X:X::X:X/M",
7660 SHOW_STR
7661 IP_STR
7662 BGP_STR
7663 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7664{
7665 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7666}
7667
paulbb46e942003-10-24 19:02:03 +00007668DEFUN (show_bgp_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007669 show_bgp_view_cmd,
7670 "show bgp view WORD",
7671 SHOW_STR
7672 BGP_STR
7673 "BGP view\n"
7674 "View name\n")
7675{
7676 struct bgp *bgp;
7677
7678 /* BGP structure lookup. */
7679 bgp = bgp_lookup_by_name (argv[0]);
7680 if (bgp == NULL)
7681 {
7682 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7683 return CMD_WARNING;
7684 }
7685
7686 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
7687}
7688
7689DEFUN (show_bgp_view_ipv6,
Lou Berger35c36862016-01-12 13:42:06 -05007690 show_bgp_view_ipv6_cmd,
7691 "show bgp view WORD ipv6",
paulbb46e942003-10-24 19:02:03 +00007692 SHOW_STR
Lou Berger35c36862016-01-12 13:42:06 -05007693 BGP_STR
paulbb46e942003-10-24 19:02:03 +00007694 "BGP view\n"
Lou Berger35c36862016-01-12 13:42:06 -05007695 "View name\n"
7696 "Address family\n")
paulbb46e942003-10-24 19:02:03 +00007697{
7698 struct bgp *bgp;
7699
7700 /* BGP structure lookup. */
7701 bgp = bgp_lookup_by_name (argv[0]);
7702 if (bgp == NULL)
7703 {
7704 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7705 return CMD_WARNING;
7706 }
7707
ajs5a646652004-11-05 01:25:55 +00007708 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00007709}
paulbb46e942003-10-24 19:02:03 +00007710
7711DEFUN (show_bgp_view_route,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007712 show_bgp_view_route_cmd,
7713 "show bgp view WORD X:X::X:X",
7714 SHOW_STR
7715 BGP_STR
7716 "BGP view\n"
7717 "View name\n"
7718 "Network in the BGP routing table to display\n")
7719{
7720 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
7721}
7722
7723DEFUN (show_bgp_view_ipv6_route,
paulbb46e942003-10-24 19:02:03 +00007724 show_bgp_view_ipv6_route_cmd,
7725 "show bgp view WORD ipv6 X:X::X:X",
7726 SHOW_STR
7727 BGP_STR
7728 "BGP view\n"
7729 "View name\n"
7730 "Address family\n"
7731 "Network in the BGP routing table to display\n")
paulbb46e942003-10-24 19:02:03 +00007732{
Lou Berger35c36862016-01-12 13:42:06 -05007733 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paulbb46e942003-10-24 19:02:03 +00007734}
7735
Lou Bergerf9b6c392016-01-12 13:42:09 -05007736/* old command */
7737DEFUN (show_ipv6_mbgp,
7738 show_ipv6_mbgp_cmd,
7739 "show ipv6 mbgp",
7740 SHOW_STR
7741 IP_STR
7742 MBGP_STR)
7743{
7744 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7745 NULL);
7746}
7747
7748/* old command */
7749DEFUN (show_ipv6_mbgp_route,
7750 show_ipv6_mbgp_route_cmd,
7751 "show ipv6 mbgp X:X::X:X",
7752 SHOW_STR
7753 IP_STR
7754 MBGP_STR
7755 "Network in the MBGP routing table to display\n")
7756{
7757 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7758}
7759
7760/* old command */
7761DEFUN (show_ipv6_mbgp_prefix,
7762 show_ipv6_mbgp_prefix_cmd,
7763 "show ipv6 mbgp X:X::X:X/M",
7764 SHOW_STR
7765 IP_STR
7766 MBGP_STR
7767 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7768{
7769 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7770}
7771
Lou Berger35c36862016-01-12 13:42:06 -05007772DEFUN (show_bgp_view_prefix,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007773 show_bgp_view_prefix_cmd,
7774 "show bgp view WORD X:X::X:X/M",
7775 SHOW_STR
7776 BGP_STR
7777 "BGP view\n"
7778 "View name\n"
7779 "IPv6 prefix <network>/<length>\n")
7780{
7781 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7782}
7783
7784DEFUN (show_bgp_view_ipv6_prefix,
paulbb46e942003-10-24 19:02:03 +00007785 show_bgp_view_ipv6_prefix_cmd,
7786 "show bgp view WORD ipv6 X:X::X:X/M",
7787 SHOW_STR
7788 BGP_STR
7789 "BGP view\n"
7790 "View name\n"
7791 "Address family\n"
7792 "IPv6 prefix <network>/<length>\n")
paul718e3742002-12-13 20:15:29 +00007793{
Lou Berger35c36862016-01-12 13:42:06 -05007794 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007795}
7796
paul94f2b392005-06-28 12:44:16 +00007797static int
paulfd79ac92004-10-13 05:06:08 +00007798bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00007799 safi_t safi, enum bgp_show_type type)
7800{
7801 int i;
7802 struct buffer *b;
7803 char *regstr;
7804 int first;
7805 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00007806 int rc;
paul718e3742002-12-13 20:15:29 +00007807
7808 first = 0;
7809 b = buffer_new (1024);
7810 for (i = 0; i < argc; i++)
7811 {
7812 if (first)
7813 buffer_putc (b, ' ');
7814 else
7815 {
7816 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
7817 continue;
7818 first = 1;
7819 }
7820
7821 buffer_putstr (b, argv[i]);
7822 }
7823 buffer_putc (b, '\0');
7824
7825 regstr = buffer_getstr (b);
7826 buffer_free (b);
7827
7828 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00007829 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00007830 if (! regex)
7831 {
7832 vty_out (vty, "Can't compile regexp %s%s", argv[0],
7833 VTY_NEWLINE);
7834 return CMD_WARNING;
7835 }
7836
ajs5a646652004-11-05 01:25:55 +00007837 rc = bgp_show (vty, NULL, afi, safi, type, regex);
7838 bgp_regex_free (regex);
7839 return rc;
paul718e3742002-12-13 20:15:29 +00007840}
7841
Lou Bergerf9b6c392016-01-12 13:42:09 -05007842
7843DEFUN (show_ip_bgp_regexp,
7844 show_ip_bgp_regexp_cmd,
7845 "show ip bgp regexp .LINE",
7846 SHOW_STR
7847 IP_STR
7848 BGP_STR
7849 "Display routes matching the AS path regular expression\n"
7850 "A regular-expression to match the BGP AS paths\n")
7851{
7852 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7853 bgp_show_type_regexp);
7854}
7855
7856DEFUN (show_ip_bgp_flap_regexp,
7857 show_ip_bgp_flap_regexp_cmd,
7858 "show ip bgp flap-statistics regexp .LINE",
7859 SHOW_STR
7860 IP_STR
7861 BGP_STR
7862 "Display flap statistics of routes\n"
7863 "Display routes matching the AS path regular expression\n"
7864 "A regular-expression to match the BGP AS paths\n")
7865{
7866 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7867 bgp_show_type_flap_regexp);
7868}
7869
7870ALIAS (show_ip_bgp_flap_regexp,
7871 show_ip_bgp_damp_flap_regexp_cmd,
7872 "show ip bgp dampening flap-statistics regexp .LINE",
7873 SHOW_STR
7874 IP_STR
7875 BGP_STR
7876 "Display detailed information about dampening\n"
7877 "Display flap statistics of routes\n"
7878 "Display routes matching the AS path regular expression\n"
7879 "A regular-expression to match the BGP AS paths\n")
7880
7881DEFUN (show_ip_bgp_ipv4_regexp,
7882 show_ip_bgp_ipv4_regexp_cmd,
7883 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7884 SHOW_STR
7885 IP_STR
7886 BGP_STR
7887 "Address family\n"
7888 "Address Family modifier\n"
7889 "Address Family modifier\n"
7890 "Display routes matching the AS path regular expression\n"
7891 "A regular-expression to match the BGP AS paths\n")
7892{
7893 if (strncmp (argv[0], "m", 1) == 0)
7894 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
7895 bgp_show_type_regexp);
7896
7897 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7898 bgp_show_type_regexp);
7899}
7900
Lou Bergerf9b6c392016-01-12 13:42:09 -05007901DEFUN (show_bgp_regexp,
7902 show_bgp_regexp_cmd,
7903 "show bgp regexp .LINE",
7904 SHOW_STR
7905 BGP_STR
7906 "Display routes matching the AS path regular expression\n"
7907 "A regular-expression to match the BGP AS paths\n")
7908{
7909 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7910 bgp_show_type_regexp);
7911}
7912
7913/* old command */
7914DEFUN (show_ipv6_bgp_regexp,
7915 show_ipv6_bgp_regexp_cmd,
7916 "show ipv6 bgp regexp .LINE",
7917 SHOW_STR
7918 IP_STR
7919 BGP_STR
7920 "Display routes matching the AS path regular expression\n"
7921 "A regular-expression to match the BGP AS paths\n")
7922{
7923 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7924 bgp_show_type_regexp);
7925}
7926
7927/* old command */
7928DEFUN (show_ipv6_mbgp_regexp,
7929 show_ipv6_mbgp_regexp_cmd,
7930 "show ipv6 mbgp regexp .LINE",
7931 SHOW_STR
7932 IP_STR
7933 BGP_STR
7934 "Display routes matching the AS path regular expression\n"
7935 "A regular-expression to match the MBGP AS paths\n")
7936{
7937 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
7938 bgp_show_type_regexp);
7939}
Lou Bergerf9b6c392016-01-12 13:42:09 -05007940
Lou Berger651b4022016-01-12 13:42:07 -05007941DEFUN (show_bgp_ipv4_safi_flap_regexp,
7942 show_bgp_ipv4_safi_flap_regexp_cmd,
7943 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00007944 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007945 BGP_STR
paul718e3742002-12-13 20:15:29 +00007946 IP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007947 "Address Family Modifier\n"
7948 "Address Family Modifier\n"
7949 "Address Family Modifier\n"
7950 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007951 "Display flap statistics of routes\n"
7952 "Display routes matching the AS path regular expression\n"
7953 "A regular-expression to match the BGP AS paths\n")
7954{
Lou Berger651b4022016-01-12 13:42:07 -05007955 safi_t safi;
7956
7957 if (bgp_parse_safi(argv[0], &safi)) {
7958 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7959 return CMD_WARNING;
7960 }
7961 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
7962 bgp_show_type_flap_regexp);
paul718e3742002-12-13 20:15:29 +00007963}
7964
Lou Berger651b4022016-01-12 13:42:07 -05007965ALIAS (show_bgp_ipv4_safi_flap_regexp,
7966 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
7967 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
Balaji3921cc52015-05-16 23:12:17 +05307968 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05307969 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007970 IP_STR
7971 "Address Family Modifier\n"
7972 "Address Family Modifier\n"
7973 "Address Family Modifier\n"
7974 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05307975 "Display detailed information about dampening\n"
7976 "Display flap statistics of routes\n"
7977 "Display routes matching the AS path regular expression\n"
7978 "A regular-expression to match the BGP AS paths\n")
7979
Lou Berger651b4022016-01-12 13:42:07 -05007980DEFUN (show_bgp_ipv6_safi_flap_regexp,
7981 show_bgp_ipv6_safi_flap_regexp_cmd,
7982 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00007983 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05007984 BGP_STR
7985 IPV6_STR
7986 "Address Family Modifier\n"
7987 "Address Family Modifier\n"
7988 "Address Family Modifier\n"
7989 "Address Family Modifier\n"
7990 "Display flap statistics of routes\n"
7991 "Display routes matching the AS path regular expression\n"
7992 "A regular-expression to match the BGP AS paths\n")
7993{
7994 safi_t safi;
7995
7996 if (bgp_parse_safi(argv[0], &safi)) {
7997 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7998 return CMD_WARNING;
7999 }
8000 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8001 bgp_show_type_flap_regexp);
8002}
8003
8004ALIAS (show_bgp_ipv6_safi_flap_regexp,
8005 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8006 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8007 SHOW_STR
8008 BGP_STR
8009 IPV6_STR
8010 "Address Family Modifier\n"
8011 "Address Family Modifier\n"
8012 "Address Family Modifier\n"
8013 "Address Family Modifier\n"
8014 "Display detailed information about dampening\n"
8015 "Display flap statistics of routes\n"
8016 "Display routes matching the AS path regular expression\n"
8017 "A regular-expression to match the BGP AS paths\n")
Lou Berger651b4022016-01-12 13:42:07 -05008018
8019DEFUN (show_bgp_ipv4_safi_regexp,
8020 show_bgp_ipv4_safi_regexp_cmd,
8021 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8022 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008023 BGP_STR
8024 "Address family\n"
8025 "Address Family modifier\n"
8026 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008027 "Address Family modifier\n"
8028 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008029 "Display routes matching the AS path regular expression\n"
8030 "A regular-expression to match the BGP AS paths\n")
8031{
Lou Berger651b4022016-01-12 13:42:07 -05008032 safi_t safi;
8033 if (bgp_parse_safi(argv[0], &safi)) {
8034 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8035 return CMD_WARNING;
8036 }
paul718e3742002-12-13 20:15:29 +00008037
Lou Berger651b4022016-01-12 13:42:07 -05008038 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008039 bgp_show_type_regexp);
8040}
Lou Berger205e6742016-01-12 13:42:11 -05008041
Lou Berger651b4022016-01-12 13:42:07 -05008042DEFUN (show_bgp_ipv6_safi_regexp,
8043 show_bgp_ipv6_safi_regexp_cmd,
8044 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008045 SHOW_STR
8046 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008047 "Address family\n"
8048 "Address Family modifier\n"
8049 "Address Family modifier\n"
8050 "Address Family modifier\n"
8051 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008052 "Display routes matching the AS path regular expression\n"
8053 "A regular-expression to match the BGP AS paths\n")
8054{
Lou Berger651b4022016-01-12 13:42:07 -05008055 safi_t safi;
8056 if (bgp_parse_safi(argv[0], &safi)) {
8057 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8058 return CMD_WARNING;
8059 }
8060
8061 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008062 bgp_show_type_regexp);
8063}
8064
Lou Berger651b4022016-01-12 13:42:07 -05008065DEFUN (show_bgp_ipv6_regexp,
paul718e3742002-12-13 20:15:29 +00008066 show_bgp_ipv6_regexp_cmd,
8067 "show bgp ipv6 regexp .LINE",
8068 SHOW_STR
8069 BGP_STR
8070 "Address family\n"
8071 "Display routes matching the AS path regular expression\n"
8072 "A regular-expression to match the BGP AS paths\n")
paul718e3742002-12-13 20:15:29 +00008073{
8074 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8075 bgp_show_type_regexp);
8076}
8077
paul94f2b392005-06-28 12:44:16 +00008078static int
paulfd79ac92004-10-13 05:06:08 +00008079bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008080 safi_t safi, enum bgp_show_type type)
8081{
8082 struct prefix_list *plist;
8083
8084 plist = prefix_list_lookup (afi, prefix_list_str);
8085 if (plist == NULL)
8086 {
8087 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8088 prefix_list_str, VTY_NEWLINE);
8089 return CMD_WARNING;
8090 }
8091
ajs5a646652004-11-05 01:25:55 +00008092 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00008093}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008094DEFUN (show_ip_bgp_prefix_list,
8095 show_ip_bgp_prefix_list_cmd,
8096 "show ip bgp prefix-list WORD",
8097 SHOW_STR
8098 IP_STR
8099 BGP_STR
8100 "Display routes conforming to the prefix-list\n"
8101 "IP prefix-list name\n")
8102{
8103 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8104 bgp_show_type_prefix_list);
8105}
8106
8107DEFUN (show_ip_bgp_flap_prefix_list,
8108 show_ip_bgp_flap_prefix_list_cmd,
8109 "show ip bgp flap-statistics prefix-list WORD",
8110 SHOW_STR
8111 IP_STR
8112 BGP_STR
8113 "Display flap statistics of routes\n"
8114 "Display routes conforming to the prefix-list\n"
8115 "IP prefix-list name\n")
8116{
8117 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8118 bgp_show_type_flap_prefix_list);
8119}
8120
8121ALIAS (show_ip_bgp_flap_prefix_list,
8122 show_ip_bgp_damp_flap_prefix_list_cmd,
8123 "show ip bgp dampening flap-statistics prefix-list WORD",
8124 SHOW_STR
8125 IP_STR
8126 BGP_STR
8127 "Display detailed information about dampening\n"
8128 "Display flap statistics of routes\n"
8129 "Display routes conforming to the prefix-list\n"
8130 "IP prefix-list name\n")
8131
8132DEFUN (show_ip_bgp_ipv4_prefix_list,
8133 show_ip_bgp_ipv4_prefix_list_cmd,
8134 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8135 SHOW_STR
8136 IP_STR
8137 BGP_STR
8138 "Address family\n"
8139 "Address Family modifier\n"
8140 "Address Family modifier\n"
8141 "Display routes conforming to the prefix-list\n"
8142 "IP prefix-list name\n")
8143{
8144 if (strncmp (argv[0], "m", 1) == 0)
8145 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8146 bgp_show_type_prefix_list);
8147
8148 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8149 bgp_show_type_prefix_list);
8150}
8151
Lou Bergerf9b6c392016-01-12 13:42:09 -05008152DEFUN (show_bgp_prefix_list,
8153 show_bgp_prefix_list_cmd,
8154 "show bgp prefix-list WORD",
8155 SHOW_STR
8156 BGP_STR
8157 "Display routes conforming to the prefix-list\n"
8158 "IPv6 prefix-list name\n")
8159{
8160 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8161 bgp_show_type_prefix_list);
8162}
8163
8164ALIAS (show_bgp_prefix_list,
8165 show_bgp_ipv6_prefix_list_cmd,
8166 "show bgp ipv6 prefix-list WORD",
8167 SHOW_STR
8168 BGP_STR
8169 "Address family\n"
8170 "Display routes conforming to the prefix-list\n"
8171 "IPv6 prefix-list name\n")
8172
8173/* old command */
8174DEFUN (show_ipv6_bgp_prefix_list,
8175 show_ipv6_bgp_prefix_list_cmd,
8176 "show ipv6 bgp prefix-list WORD",
8177 SHOW_STR
8178 IPV6_STR
8179 BGP_STR
8180 "Display routes matching the prefix-list\n"
8181 "IPv6 prefix-list name\n")
8182{
8183 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8184 bgp_show_type_prefix_list);
8185}
8186
8187/* old command */
8188DEFUN (show_ipv6_mbgp_prefix_list,
8189 show_ipv6_mbgp_prefix_list_cmd,
8190 "show ipv6 mbgp prefix-list WORD",
8191 SHOW_STR
8192 IPV6_STR
8193 MBGP_STR
8194 "Display routes matching the prefix-list\n"
8195 "IPv6 prefix-list name\n")
8196{
8197 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8198 bgp_show_type_prefix_list);
8199}
paul718e3742002-12-13 20:15:29 +00008200
Lou Berger35c36862016-01-12 13:42:06 -05008201DEFUN (show_bgp_ipv4_prefix_list,
8202 show_bgp_ipv4_prefix_list_cmd,
8203 "show bgp ipv4 prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008204 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008205 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05008206 IP_STR
paul718e3742002-12-13 20:15:29 +00008207 "Display routes conforming to the prefix-list\n"
8208 "IP prefix-list name\n")
8209{
8210 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8211 bgp_show_type_prefix_list);
8212}
8213
Lou Berger651b4022016-01-12 13:42:07 -05008214DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8215 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8216 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008217 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008218 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008219 IP_STR
8220 "Address Family Modifier\n"
8221 "Address Family Modifier\n"
8222 "Address Family Modifier\n"
8223 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008224 "Display flap statistics of routes\n"
8225 "Display routes conforming to the prefix-list\n"
8226 "IP prefix-list name\n")
8227{
Lou Berger651b4022016-01-12 13:42:07 -05008228 safi_t safi;
8229 if (bgp_parse_safi(argv[0], &safi)) {
8230 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8231 return CMD_WARNING;
8232 }
8233 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008234 bgp_show_type_flap_prefix_list);
8235}
8236
Lou Berger651b4022016-01-12 13:42:07 -05008237ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8238 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8239 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308240 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308241 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008242 IP_STR
8243 "Address Family Modifier\n"
8244 "Address Family Modifier\n"
8245 "Address Family Modifier\n"
8246 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308247 "Display detailed information about dampening\n"
8248 "Display flap statistics of routes\n"
8249 "Display routes conforming to the prefix-list\n"
8250 "IP prefix-list name\n")
8251
Lou Berger651b4022016-01-12 13:42:07 -05008252DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8253 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8254 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008255 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008256 BGP_STR
8257 IPV6_STR
8258 "Address Family Modifier\n"
8259 "Address Family Modifier\n"
8260 "Address Family Modifier\n"
8261 "Address Family Modifier\n"
8262 "Display flap statistics of routes\n"
8263 "Display routes conforming to the prefix-list\n"
8264 "IP prefix-list name\n")
8265{
8266 safi_t safi;
8267 if (bgp_parse_safi(argv[0], &safi)) {
8268 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8269 return CMD_WARNING;
8270 }
8271 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8272 bgp_show_type_flap_prefix_list);
8273}
8274ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8275 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8276 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8277 SHOW_STR
8278 BGP_STR
8279 IPV6_STR
8280 "Address Family Modifier\n"
8281 "Address Family Modifier\n"
8282 "Address Family Modifier\n"
8283 "Address Family Modifier\n"
8284 "Display detailed information about dampening\n"
8285 "Display flap statistics of routes\n"
8286 "Display routes conforming to the prefix-list\n"
8287 "IP prefix-list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008288
8289DEFUN (show_bgp_ipv4_safi_prefix_list,
8290 show_bgp_ipv4_safi_prefix_list_cmd,
8291 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8292 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008293 BGP_STR
8294 "Address family\n"
8295 "Address Family modifier\n"
8296 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008297 "Address Family modifier\n"
8298 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008299 "Display routes conforming to the prefix-list\n"
8300 "IP prefix-list name\n")
8301{
Lou Berger651b4022016-01-12 13:42:07 -05008302 safi_t safi;
8303 if (bgp_parse_safi(argv[0], &safi)) {
8304 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8305 return CMD_WARNING;
8306 }
8307 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008308 bgp_show_type_prefix_list);
8309}
Lou Berger205e6742016-01-12 13:42:11 -05008310
Lou Berger651b4022016-01-12 13:42:07 -05008311DEFUN (show_bgp_ipv6_safi_prefix_list,
8312 show_bgp_ipv6_safi_prefix_list_cmd,
8313 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008314 SHOW_STR
8315 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008316 "Address family\n"
8317 "Address Family modifier\n"
8318 "Address Family modifier\n"
8319 "Address Family modifier\n"
8320 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008321 "Display routes conforming to the prefix-list\n"
Lou Berger651b4022016-01-12 13:42:07 -05008322 "IP prefix-list name\n")
paul718e3742002-12-13 20:15:29 +00008323{
Lou Berger651b4022016-01-12 13:42:07 -05008324 safi_t safi;
8325 if (bgp_parse_safi(argv[0], &safi)) {
8326 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8327 return CMD_WARNING;
8328 }
8329 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008330 bgp_show_type_prefix_list);
8331}
8332
paul94f2b392005-06-28 12:44:16 +00008333static int
paulfd79ac92004-10-13 05:06:08 +00008334bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008335 safi_t safi, enum bgp_show_type type)
8336{
8337 struct as_list *as_list;
8338
8339 as_list = as_list_lookup (filter);
8340 if (as_list == NULL)
8341 {
8342 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8343 return CMD_WARNING;
8344 }
8345
ajs5a646652004-11-05 01:25:55 +00008346 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00008347}
8348
Lou Bergerf9b6c392016-01-12 13:42:09 -05008349DEFUN (show_ip_bgp_filter_list,
8350 show_ip_bgp_filter_list_cmd,
8351 "show ip bgp filter-list WORD",
8352 SHOW_STR
8353 IP_STR
8354 BGP_STR
8355 "Display routes conforming to the filter-list\n"
8356 "Regular expression access list name\n")
8357{
8358 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8359 bgp_show_type_filter_list);
8360}
8361
8362DEFUN (show_ip_bgp_flap_filter_list,
8363 show_ip_bgp_flap_filter_list_cmd,
8364 "show ip bgp flap-statistics filter-list WORD",
8365 SHOW_STR
8366 IP_STR
8367 BGP_STR
8368 "Display flap statistics of routes\n"
8369 "Display routes conforming to the filter-list\n"
8370 "Regular expression access list name\n")
8371{
8372 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8373 bgp_show_type_flap_filter_list);
8374}
8375
8376ALIAS (show_ip_bgp_flap_filter_list,
8377 show_ip_bgp_damp_flap_filter_list_cmd,
8378 "show ip bgp dampening flap-statistics filter-list WORD",
8379 SHOW_STR
8380 IP_STR
8381 BGP_STR
8382 "Display detailed information about dampening\n"
8383 "Display flap statistics of routes\n"
8384 "Display routes conforming to the filter-list\n"
8385 "Regular expression access list name\n")
8386
8387DEFUN (show_ip_bgp_ipv4_filter_list,
8388 show_ip_bgp_ipv4_filter_list_cmd,
8389 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8390 SHOW_STR
8391 IP_STR
8392 BGP_STR
8393 "Address family\n"
8394 "Address Family modifier\n"
8395 "Address Family modifier\n"
8396 "Display routes conforming to the filter-list\n"
8397 "Regular expression access list name\n")
8398{
8399 if (strncmp (argv[0], "m", 1) == 0)
8400 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8401 bgp_show_type_filter_list);
8402
8403 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8404 bgp_show_type_filter_list);
8405}
8406
Lou Bergerf9b6c392016-01-12 13:42:09 -05008407DEFUN (show_bgp_filter_list,
8408 show_bgp_filter_list_cmd,
8409 "show bgp filter-list WORD",
8410 SHOW_STR
8411 BGP_STR
8412 "Display routes conforming to the filter-list\n"
8413 "Regular expression access list name\n")
8414{
8415 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8416 bgp_show_type_filter_list);
8417}
8418
8419/* old command */
8420DEFUN (show_ipv6_bgp_filter_list,
8421 show_ipv6_bgp_filter_list_cmd,
8422 "show ipv6 bgp filter-list WORD",
8423 SHOW_STR
8424 IPV6_STR
8425 BGP_STR
8426 "Display routes conforming to the filter-list\n"
8427 "Regular expression access list name\n")
8428{
8429 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8430 bgp_show_type_filter_list);
8431}
8432
8433/* old command */
8434DEFUN (show_ipv6_mbgp_filter_list,
8435 show_ipv6_mbgp_filter_list_cmd,
8436 "show ipv6 mbgp filter-list WORD",
8437 SHOW_STR
8438 IPV6_STR
8439 MBGP_STR
8440 "Display routes conforming to the filter-list\n"
8441 "Regular expression access list name\n")
8442{
8443 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8444 bgp_show_type_filter_list);
8445}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008446
8447DEFUN (show_ip_bgp_dampening_info,
8448 show_ip_bgp_dampening_params_cmd,
8449 "show ip bgp dampening parameters",
8450 SHOW_STR
8451 IP_STR
8452 BGP_STR
8453 "Display detailed information about dampening\n"
8454 "Display detail of configured dampening parameters\n")
8455{
8456 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8457}
8458
Lou Berger651b4022016-01-12 13:42:07 -05008459DEFUN (show_bgp_ipv4_filter_list,
8460 show_bgp_ipv4_filter_list_cmd,
8461 "show bgp ipv4 filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008462 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008463 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008464 IP_STR
paul718e3742002-12-13 20:15:29 +00008465 "Display routes conforming to the filter-list\n"
8466 "Regular expression access list name\n")
8467{
8468 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8469 bgp_show_type_filter_list);
8470}
8471
Lou Berger651b4022016-01-12 13:42:07 -05008472DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8473 show_bgp_ipv4_safi_flap_filter_list_cmd,
8474 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008475 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008476 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008477 IP_STR
8478 "Address Family modifier\n"
8479 "Address Family modifier\n"
8480 "Address Family modifier\n"
8481 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008482 "Display flap statistics of routes\n"
8483 "Display routes conforming to the filter-list\n"
8484 "Regular expression access list name\n")
8485{
Lou Berger651b4022016-01-12 13:42:07 -05008486 safi_t safi;
8487
8488 if (bgp_parse_safi(argv[0], &safi)) {
8489 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8490 return CMD_WARNING;
8491 }
8492 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008493 bgp_show_type_flap_filter_list);
8494}
8495
Lou Berger651b4022016-01-12 13:42:07 -05008496ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8497 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8498 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308499 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308500 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008501 IP_STR
8502 "Address Family modifier\n"
8503 "Address Family modifier\n"
8504 "Address Family modifier\n"
8505 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308506 "Display detailed information about dampening\n"
8507 "Display flap statistics of routes\n"
8508 "Display routes conforming to the filter-list\n"
8509 "Regular expression access list name\n")
8510
Lou Berger651b4022016-01-12 13:42:07 -05008511DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8512 show_bgp_ipv6_safi_flap_filter_list_cmd,
8513 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008514 SHOW_STR
8515 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008516 IPV6_STR
8517 "Address Family modifier\n"
8518 "Address Family modifier\n"
8519 "Address Family modifier\n"
8520 "Address Family modifier\n"
8521 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +00008522 "Display routes conforming to the filter-list\n"
8523 "Regular expression access list name\n")
8524{
Lou Berger651b4022016-01-12 13:42:07 -05008525 safi_t safi;
8526
8527 if (bgp_parse_safi(argv[0], &safi)) {
8528 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8529 return CMD_WARNING;
8530 }
8531 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8532 bgp_show_type_flap_filter_list);
8533}
8534ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8535 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8536 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8537 SHOW_STR
8538 BGP_STR
8539 IPV6_STR
8540 "Address Family modifier\n"
8541 "Address Family modifier\n"
8542 "Address Family modifier\n"
8543 "Address Family modifier\n"
8544 "Display detailed information about dampening\n"
8545 "Display flap statistics of routes\n"
8546 "Display routes conforming to the filter-list\n"
8547 "Regular expression access list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008548
8549DEFUN (show_bgp_ipv4_safi_filter_list,
8550 show_bgp_ipv4_safi_filter_list_cmd,
8551 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8552 SHOW_STR
8553 BGP_STR
8554 "Address Family modifier\n"
8555 "Address Family modifier\n"
8556 "Address Family modifier\n"
8557 "Address Family modifier\n"
8558 "Display routes conforming to the filter-list\n"
8559 "Regular expression access list name\n")
8560{
8561 safi_t safi;
8562
8563 if (bgp_parse_safi(argv[0], &safi)) {
8564 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8565 return CMD_WARNING;
8566 }
8567 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8568 bgp_show_type_filter_list);
8569}
Lou Berger205e6742016-01-12 13:42:11 -05008570
Lou Berger651b4022016-01-12 13:42:07 -05008571DEFUN (show_bgp_ipv6_safi_filter_list,
8572 show_bgp_ipv6_safi_filter_list_cmd,
8573 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8574 SHOW_STR
8575 BGP_STR
8576 "Address Family modifier\n"
8577 "Address Family modifier\n"
8578 "Address Family modifier\n"
8579 "Address Family modifier\n"
8580 "Display routes conforming to the filter-list\n"
8581 "Regular expression access list name\n")
8582{
8583 safi_t safi;
8584
8585 if (bgp_parse_safi(argv[0], &safi)) {
8586 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8587 return CMD_WARNING;
8588 }
8589 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8590 bgp_show_type_filter_list);
paul718e3742002-12-13 20:15:29 +00008591}
8592
Lou Bergerf9b6c392016-01-12 13:42:09 -05008593DEFUN (show_bgp_ipv6_filter_list,
paul718e3742002-12-13 20:15:29 +00008594 show_bgp_ipv6_filter_list_cmd,
8595 "show bgp ipv6 filter-list WORD",
8596 SHOW_STR
8597 BGP_STR
8598 "Address family\n"
8599 "Display routes conforming to the filter-list\n"
8600 "Regular expression access list name\n")
paul718e3742002-12-13 20:15:29 +00008601{
8602 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8603 bgp_show_type_filter_list);
8604}
8605
Balaji9c52cae2016-01-20 22:59:26 +05308606
8607DEFUN (show_ip_bgp_ipv4_dampening_parameters,
8608 show_ip_bgp_ipv4_dampening_parameters_cmd,
8609 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
8610 SHOW_STR
8611 IP_STR
8612 BGP_STR
8613 "Address family\n"
8614 "Address Family modifier\n"
8615 "Address Family modifier\n"
8616 "Display detailed information about dampening\n"
8617 "Display detail of configured dampening parameters\n")
8618{
8619 if (strncmp(argv[0], "m", 1) == 0)
8620 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST);
8621
8622 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8623}
8624
8625
8626DEFUN (show_ip_bgp_ipv4_dampening_flap_stats,
8627 show_ip_bgp_ipv4_dampening_flap_stats_cmd,
8628 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
8629 SHOW_STR
8630 IP_STR
8631 BGP_STR
8632 "Address family\n"
8633 "Address Family modifier\n"
8634 "Address Family modifier\n"
8635 "Display detailed information about dampening\n"
8636 "Display flap statistics of routes\n")
8637{
8638 if (strncmp(argv[0], "m", 1) == 0)
8639 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8640 bgp_show_type_flap_statistics, NULL);
8641
8642 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8643 bgp_show_type_flap_statistics, NULL);
8644}
8645
8646DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths,
8647 show_ip_bgp_ipv4_dampening_dampd_paths_cmd,
8648 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
8649 SHOW_STR
8650 IP_STR
8651 BGP_STR
8652 "Address family\n"
8653 "Address Family modifier\n"
8654 "Address Family modifier\n"
8655 "Display detailed information about dampening\n"
8656 "Display paths suppressed due to dampening\n")
8657{
8658 if (strncmp(argv[0], "m", 1) == 0)
8659 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8660 bgp_show_type_dampend_paths, NULL);
8661
8662 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8663 bgp_show_type_dampend_paths, NULL);
8664}
8665
paul94f2b392005-06-28 12:44:16 +00008666static int
paulfd79ac92004-10-13 05:06:08 +00008667bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008668 safi_t safi, enum bgp_show_type type)
8669{
8670 struct route_map *rmap;
8671
8672 rmap = route_map_lookup_by_name (rmap_str);
8673 if (! rmap)
8674 {
8675 vty_out (vty, "%% %s is not a valid route-map name%s",
8676 rmap_str, VTY_NEWLINE);
8677 return CMD_WARNING;
8678 }
8679
ajs5a646652004-11-05 01:25:55 +00008680 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00008681}
8682
Lou Bergerf9b6c392016-01-12 13:42:09 -05008683DEFUN (show_ip_bgp_route_map,
8684 show_ip_bgp_route_map_cmd,
8685 "show ip bgp route-map WORD",
8686 SHOW_STR
8687 IP_STR
8688 BGP_STR
8689 "Display routes matching the route-map\n"
8690 "A route-map to match on\n")
8691{
8692 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8693 bgp_show_type_route_map);
8694}
8695
8696DEFUN (show_ip_bgp_flap_route_map,
8697 show_ip_bgp_flap_route_map_cmd,
8698 "show ip bgp flap-statistics route-map WORD",
8699 SHOW_STR
8700 IP_STR
8701 BGP_STR
8702 "Display flap statistics of routes\n"
8703 "Display routes matching the route-map\n"
8704 "A route-map to match on\n")
8705{
8706 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8707 bgp_show_type_flap_route_map);
8708}
8709
8710ALIAS (show_ip_bgp_flap_route_map,
8711 show_ip_bgp_damp_flap_route_map_cmd,
8712 "show ip bgp dampening flap-statistics route-map WORD",
8713 SHOW_STR
8714 IP_STR
8715 BGP_STR
8716 "Display detailed information about dampening\n"
8717 "Display flap statistics of routes\n"
8718 "Display routes matching the route-map\n"
8719 "A route-map to match on\n")
8720
8721DEFUN (show_ip_bgp_ipv4_route_map,
8722 show_ip_bgp_ipv4_route_map_cmd,
8723 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
8724 SHOW_STR
8725 IP_STR
8726 BGP_STR
8727 "Address family\n"
8728 "Address Family modifier\n"
8729 "Address Family modifier\n"
8730 "Display routes matching the route-map\n"
8731 "A route-map to match on\n")
8732{
8733 if (strncmp (argv[0], "m", 1) == 0)
8734 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8735 bgp_show_type_route_map);
8736
8737 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
8738 bgp_show_type_route_map);
8739}
8740
8741DEFUN (show_bgp_route_map,
8742 show_bgp_route_map_cmd,
8743 "show bgp route-map WORD",
8744 SHOW_STR
8745 BGP_STR
8746 "Display routes matching the route-map\n"
8747 "A route-map to match on\n")
8748{
8749 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8750 bgp_show_type_route_map);
8751}
8752
8753DEFUN (show_ip_bgp_cidr_only,
8754 show_ip_bgp_cidr_only_cmd,
8755 "show ip bgp cidr-only",
8756 SHOW_STR
8757 IP_STR
8758 BGP_STR
8759 "Display only routes with non-natural netmasks\n")
8760{
8761 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8762 bgp_show_type_cidr_only, NULL);
8763}
8764
8765DEFUN (show_ip_bgp_flap_cidr_only,
8766 show_ip_bgp_flap_cidr_only_cmd,
8767 "show ip bgp flap-statistics cidr-only",
8768 SHOW_STR
8769 IP_STR
8770 BGP_STR
8771 "Display flap statistics of routes\n"
8772 "Display only routes with non-natural netmasks\n")
8773{
8774 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8775 bgp_show_type_flap_cidr_only, NULL);
8776}
8777
8778ALIAS (show_ip_bgp_flap_cidr_only,
8779 show_ip_bgp_damp_flap_cidr_only_cmd,
8780 "show ip bgp dampening flap-statistics cidr-only",
8781 SHOW_STR
8782 IP_STR
8783 BGP_STR
8784 "Display detailed information about dampening\n"
8785 "Display flap statistics of routes\n"
8786 "Display only routes with non-natural netmasks\n")
8787
8788DEFUN (show_ip_bgp_ipv4_cidr_only,
8789 show_ip_bgp_ipv4_cidr_only_cmd,
8790 "show ip bgp ipv4 (unicast|multicast) cidr-only",
8791 SHOW_STR
8792 IP_STR
8793 BGP_STR
8794 "Address family\n"
8795 "Address Family modifier\n"
8796 "Address Family modifier\n"
8797 "Display only routes with non-natural netmasks\n")
8798{
8799 if (strncmp (argv[0], "m", 1) == 0)
8800 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8801 bgp_show_type_cidr_only, NULL);
8802
8803 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8804 bgp_show_type_cidr_only, NULL);
8805}
8806
8807DEFUN (show_ip_bgp_community_all,
8808 show_ip_bgp_community_all_cmd,
8809 "show ip bgp community",
8810 SHOW_STR
8811 IP_STR
8812 BGP_STR
8813 "Display routes matching the communities\n")
8814{
8815 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8816 bgp_show_type_community_all, NULL);
8817}
8818
8819DEFUN (show_ip_bgp_ipv4_community_all,
8820 show_ip_bgp_ipv4_community_all_cmd,
8821 "show ip bgp ipv4 (unicast|multicast) community",
8822 SHOW_STR
8823 IP_STR
8824 BGP_STR
8825 "Address family\n"
8826 "Address Family modifier\n"
8827 "Address Family modifier\n"
8828 "Display routes matching the communities\n")
8829{
8830 if (strncmp (argv[0], "m", 1) == 0)
8831 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8832 bgp_show_type_community_all, NULL);
8833
8834 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8835 bgp_show_type_community_all, NULL);
8836}
8837
Lou Bergerf9b6c392016-01-12 13:42:09 -05008838DEFUN (show_bgp_community_all,
8839 show_bgp_community_all_cmd,
8840 "show bgp community",
8841 SHOW_STR
8842 BGP_STR
8843 "Display routes matching the communities\n")
8844{
8845 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8846 bgp_show_type_community_all, NULL);
8847}
8848
8849ALIAS (show_bgp_community_all,
8850 show_bgp_ipv6_community_all_cmd,
8851 "show bgp ipv6 community",
8852 SHOW_STR
8853 BGP_STR
8854 "Address family\n"
8855 "Display routes matching the communities\n")
8856
8857/* old command */
8858DEFUN (show_ipv6_bgp_community_all,
8859 show_ipv6_bgp_community_all_cmd,
8860 "show ipv6 bgp community",
8861 SHOW_STR
8862 IPV6_STR
8863 BGP_STR
8864 "Display routes matching the communities\n")
8865{
8866 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8867 bgp_show_type_community_all, NULL);
8868}
8869
8870/* old command */
8871DEFUN (show_ipv6_mbgp_community_all,
8872 show_ipv6_mbgp_community_all_cmd,
8873 "show ipv6 mbgp community",
8874 SHOW_STR
8875 IPV6_STR
8876 MBGP_STR
8877 "Display routes matching the communities\n")
8878{
8879 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
8880 bgp_show_type_community_all, NULL);
8881}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008882
Lou Berger651b4022016-01-12 13:42:07 -05008883DEFUN (show_bgp_ipv4_route_map,
8884 show_bgp_ipv4_route_map_cmd,
8885 "show bgp ipv4 route-map WORD",
paul718e3742002-12-13 20:15:29 +00008886 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008887 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008888 IP_STR
paul718e3742002-12-13 20:15:29 +00008889 "Display routes matching the route-map\n"
8890 "A route-map to match on\n")
8891{
8892 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8893 bgp_show_type_route_map);
8894}
8895
Lou Berger651b4022016-01-12 13:42:07 -05008896DEFUN (show_bgp_ipv4_safi_flap_route_map,
8897 show_bgp_ipv4_safi_flap_route_map_cmd,
8898 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008899 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008900 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008901 IP_STR
8902 "Address Family Modifier\n"
8903 "Address Family Modifier\n"
8904 "Address Family Modifier\n"
8905 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008906 "Display flap statistics of routes\n"
8907 "Display routes matching the route-map\n"
8908 "A route-map to match on\n")
8909{
Lou Berger651b4022016-01-12 13:42:07 -05008910 safi_t safi;
8911 if (bgp_parse_safi(argv[0], &safi)) {
8912 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8913 return CMD_WARNING;
8914 }
8915 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008916 bgp_show_type_flap_route_map);
8917}
8918
Lou Berger651b4022016-01-12 13:42:07 -05008919ALIAS (show_bgp_ipv4_safi_flap_route_map,
8920 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
8921 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
Balaji3921cc52015-05-16 23:12:17 +05308922 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308923 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008924 IP_STR
8925 "Address Family Modifier\n"
8926 "Address Family Modifier\n"
8927 "Address Family Modifier\n"
8928 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308929 "Display detailed information about dampening\n"
8930 "Display flap statistics of routes\n"
8931 "Display routes matching the route-map\n"
8932 "A route-map to match on\n")
Lou Berger205e6742016-01-12 13:42:11 -05008933
Lou Berger651b4022016-01-12 13:42:07 -05008934DEFUN (show_bgp_ipv6_safi_flap_route_map,
8935 show_bgp_ipv6_safi_flap_route_map_cmd,
8936 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008937 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008938 BGP_STR
8939 IPV6_STR
8940 "Address Family Modifier\n"
8941 "Address Family Modifier\n"
8942 "Address Family Modifier\n"
8943 "Address Family Modifier\n"
8944 "Display flap statistics of routes\n"
8945 "Display routes matching the route-map\n"
8946 "A route-map to match on\n")
8947{
8948 safi_t safi;
8949 if (bgp_parse_safi(argv[0], &safi)) {
8950 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8951 return CMD_WARNING;
8952 }
8953 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
8954 bgp_show_type_flap_route_map);
8955}
8956ALIAS (show_bgp_ipv6_safi_flap_route_map,
8957 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
8958 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
8959 SHOW_STR
8960 BGP_STR
8961 IPV6_STR
8962 "Address Family Modifier\n"
8963 "Address Family Modifier\n"
8964 "Address Family Modifier\n"
8965 "Address Family Modifier\n"
8966 "Display detailed information about dampening\n"
8967 "Display flap statistics of routes\n"
8968 "Display routes matching the route-map\n"
8969 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05008970
8971DEFUN (show_bgp_ipv4_safi_route_map,
8972 show_bgp_ipv4_safi_route_map_cmd,
8973 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
8974 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008975 BGP_STR
8976 "Address family\n"
8977 "Address Family modifier\n"
8978 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008979 "Address Family modifier\n"
8980 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008981 "Display routes matching the route-map\n"
8982 "A route-map to match on\n")
8983{
Lou Berger651b4022016-01-12 13:42:07 -05008984 safi_t safi;
8985 if (bgp_parse_safi(argv[0], &safi)) {
8986 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8987 return CMD_WARNING;
8988 }
8989 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008990 bgp_show_type_route_map);
8991}
Lou Berger205e6742016-01-12 13:42:11 -05008992
Lou Berger651b4022016-01-12 13:42:07 -05008993DEFUN (show_bgp_ipv6_safi_route_map,
8994 show_bgp_ipv6_safi_route_map_cmd,
8995 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
paul718e3742002-12-13 20:15:29 +00008996 SHOW_STR
8997 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008998 "Address family\n"
8999 "Address Family modifier\n"
9000 "Address Family modifier\n"
9001 "Address Family modifier\n"
9002 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009003 "Display routes matching the route-map\n"
9004 "A route-map to match on\n")
9005{
Lou Berger651b4022016-01-12 13:42:07 -05009006 safi_t safi;
9007 if (bgp_parse_safi(argv[0], &safi)) {
9008 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9009 return CMD_WARNING;
9010 }
9011 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00009012 bgp_show_type_route_map);
9013}
9014
Lou Berger651b4022016-01-12 13:42:07 -05009015DEFUN (show_bgp_ipv6_route_map,
paul718e3742002-12-13 20:15:29 +00009016 show_bgp_ipv6_route_map_cmd,
9017 "show bgp ipv6 route-map WORD",
9018 SHOW_STR
9019 BGP_STR
9020 "Address family\n"
9021 "Display routes matching the route-map\n"
9022 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05009023{
9024 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9025 bgp_show_type_route_map);
9026}
David Lamparter6b0655a2014-06-04 06:53:35 +02009027
Lou Berger651b4022016-01-12 13:42:07 -05009028DEFUN (show_bgp_ipv4_cidr_only,
9029 show_bgp_ipv4_cidr_only_cmd,
9030 "show bgp ipv4 cidr-only",
paul718e3742002-12-13 20:15:29 +00009031 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009032 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009033 IP_STR
paul718e3742002-12-13 20:15:29 +00009034 "Display only routes with non-natural netmasks\n")
9035{
9036 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009037 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009038}
9039
Lou Berger651b4022016-01-12 13:42:07 -05009040DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
9041 show_bgp_ipv4_safi_flap_cidr_only_cmd,
9042 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
paul718e3742002-12-13 20:15:29 +00009043 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009044 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009045 "Address Family\n"
9046 "Address Family Modifier\n"
9047 "Address Family Modifier\n"
9048 "Address Family Modifier\n"
9049 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009050 "Display flap statistics of routes\n"
9051 "Display only routes with non-natural netmasks\n")
9052{
Lou Berger651b4022016-01-12 13:42:07 -05009053 safi_t safi;
9054
9055 if (bgp_parse_safi(argv[0], &safi)) {
9056 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9057 return CMD_WARNING;
9058 }
9059 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009060}
9061
Lou Berger651b4022016-01-12 13:42:07 -05009062ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9063 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9064 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
Balaji3921cc52015-05-16 23:12:17 +05309065 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309066 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009067 "Address Family\n"
9068 "Address Family Modifier\n"
9069 "Address Family Modifier\n"
9070 "Address Family Modifier\n"
9071 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309072 "Display detailed information about dampening\n"
9073 "Display flap statistics of routes\n"
9074 "Display only routes with non-natural netmasks\n")
9075
Lou Berger651b4022016-01-12 13:42:07 -05009076DEFUN (show_bgp_ipv4_safi_cidr_only,
9077 show_bgp_ipv4_safi_cidr_only_cmd,
9078 "show bgp ipv4 (unicast|multicast) cidr-only",
paul718e3742002-12-13 20:15:29 +00009079 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009080 BGP_STR
9081 "Address family\n"
9082 "Address Family modifier\n"
9083 "Address Family modifier\n"
9084 "Display only routes with non-natural netmasks\n")
9085{
9086 if (strncmp (argv[0], "m", 1) == 0)
9087 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00009088 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009089
9090 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009091 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009092}
David Lamparter6b0655a2014-06-04 06:53:35 +02009093
Lou Berger651b4022016-01-12 13:42:07 -05009094/* new046 */
9095DEFUN (show_bgp_afi_safi_community_all,
9096 show_bgp_afi_safi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009097 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
paul718e3742002-12-13 20:15:29 +00009098 SHOW_STR
9099 BGP_STR
9100 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009101 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009102 "Address Family modifier\n"
9103 "Address Family modifier\n"
9104 "Address Family modifier\n"
9105 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009106 "Display routes matching the communities\n")
Lou Berger651b4022016-01-12 13:42:07 -05009107{
9108 safi_t safi;
9109 afi_t afi;
paul718e3742002-12-13 20:15:29 +00009110
Lou Berger651b4022016-01-12 13:42:07 -05009111 if (bgp_parse_afi(argv[0], &afi)) {
9112 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9113 return CMD_WARNING;
9114 }
9115 if (bgp_parse_safi(argv[1], &safi)) {
9116 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9117 return CMD_WARNING;
9118 }
9119
9120 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9121}
9122DEFUN (show_bgp_afi_community_all,
9123 show_bgp_afi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009124 "show bgp (ipv4|ipv6) community",
paul718e3742002-12-13 20:15:29 +00009125 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009126 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009127 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009128 "Address family\n"
paul718e3742002-12-13 20:15:29 +00009129 "Display routes matching the communities\n")
9130{
Lou Berger651b4022016-01-12 13:42:07 -05009131 afi_t afi;
9132 safi_t safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +00009133
Lou Berger651b4022016-01-12 13:42:07 -05009134 if (bgp_parse_afi(argv[0], &afi)) {
9135 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9136 return CMD_WARNING;
9137 }
9138 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00009139}
David Lamparter6b0655a2014-06-04 06:53:35 +02009140
paul94f2b392005-06-28 12:44:16 +00009141static int
Michael Lambert95cbbd22010-07-23 14:43:04 -04009142bgp_show_community (struct vty *vty, const char *view_name, int argc,
9143 const char **argv, int exact, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00009144{
9145 struct community *com;
9146 struct buffer *b;
Michael Lambert95cbbd22010-07-23 14:43:04 -04009147 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +00009148 int i;
9149 char *str;
9150 int first = 0;
9151
Michael Lambert95cbbd22010-07-23 14:43:04 -04009152 /* BGP structure lookup */
9153 if (view_name)
9154 {
9155 bgp = bgp_lookup_by_name (view_name);
9156 if (bgp == NULL)
9157 {
9158 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9159 return CMD_WARNING;
9160 }
9161 }
9162 else
9163 {
9164 bgp = bgp_get_default ();
9165 if (bgp == NULL)
9166 {
9167 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9168 return CMD_WARNING;
9169 }
9170 }
9171
paul718e3742002-12-13 20:15:29 +00009172 b = buffer_new (1024);
9173 for (i = 0; i < argc; i++)
9174 {
9175 if (first)
9176 buffer_putc (b, ' ');
9177 else
9178 {
9179 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9180 continue;
9181 first = 1;
9182 }
9183
9184 buffer_putstr (b, argv[i]);
9185 }
9186 buffer_putc (b, '\0');
9187
9188 str = buffer_getstr (b);
9189 buffer_free (b);
9190
9191 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00009192 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009193 if (! com)
9194 {
9195 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9196 return CMD_WARNING;
9197 }
9198
Michael Lambert95cbbd22010-07-23 14:43:04 -04009199 return bgp_show (vty, bgp, afi, safi,
ajs5a646652004-11-05 01:25:55 +00009200 (exact ? bgp_show_type_community_exact :
9201 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00009202}
9203
Lou Bergerf9b6c392016-01-12 13:42:09 -05009204DEFUN (show_ip_bgp_community,
9205 show_ip_bgp_community_cmd,
9206 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9207 SHOW_STR
9208 IP_STR
9209 BGP_STR
9210 "Display routes matching the communities\n"
9211 "community number\n"
9212 "Do not send outside local AS (well-known community)\n"
9213 "Do not advertise to any peer (well-known community)\n"
9214 "Do not export to next AS (well-known community)\n")
9215{
9216 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9217}
9218
9219ALIAS (show_ip_bgp_community,
9220 show_ip_bgp_community2_cmd,
9221 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9222 SHOW_STR
9223 IP_STR
9224 BGP_STR
9225 "Display routes matching the communities\n"
9226 "community number\n"
9227 "Do not send outside local AS (well-known community)\n"
9228 "Do not advertise to any peer (well-known community)\n"
9229 "Do not export to next AS (well-known community)\n"
9230 "community number\n"
9231 "Do not send outside local AS (well-known community)\n"
9232 "Do not advertise to any peer (well-known community)\n"
9233 "Do not export to next AS (well-known community)\n")
9234
9235ALIAS (show_ip_bgp_community,
9236 show_ip_bgp_community3_cmd,
9237 "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)",
9238 SHOW_STR
9239 IP_STR
9240 BGP_STR
9241 "Display routes matching the communities\n"
9242 "community number\n"
9243 "Do not send outside local AS (well-known community)\n"
9244 "Do not advertise to any peer (well-known community)\n"
9245 "Do not export to next AS (well-known community)\n"
9246 "community number\n"
9247 "Do not send outside local AS (well-known community)\n"
9248 "Do not advertise to any peer (well-known community)\n"
9249 "Do not export to next AS (well-known community)\n"
9250 "community number\n"
9251 "Do not send outside local AS (well-known community)\n"
9252 "Do not advertise to any peer (well-known community)\n"
9253 "Do not export to next AS (well-known community)\n")
9254
9255ALIAS (show_ip_bgp_community,
9256 show_ip_bgp_community4_cmd,
9257 "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)",
9258 SHOW_STR
9259 IP_STR
9260 BGP_STR
9261 "Display routes matching the communities\n"
9262 "community number\n"
9263 "Do not send outside local AS (well-known community)\n"
9264 "Do not advertise to any peer (well-known community)\n"
9265 "Do not export to next AS (well-known community)\n"
9266 "community number\n"
9267 "Do not send outside local AS (well-known community)\n"
9268 "Do not advertise to any peer (well-known community)\n"
9269 "Do not export to next AS (well-known community)\n"
9270 "community number\n"
9271 "Do not send outside local AS (well-known community)\n"
9272 "Do not advertise to any peer (well-known community)\n"
9273 "Do not export to next AS (well-known community)\n"
9274 "community number\n"
9275 "Do not send outside local AS (well-known community)\n"
9276 "Do not advertise to any peer (well-known community)\n"
9277 "Do not export to next AS (well-known community)\n")
9278
9279DEFUN (show_ip_bgp_ipv4_community,
9280 show_ip_bgp_ipv4_community_cmd,
9281 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9282 SHOW_STR
9283 IP_STR
9284 BGP_STR
9285 "Address family\n"
9286 "Address Family modifier\n"
9287 "Address Family modifier\n"
9288 "Display routes matching the communities\n"
9289 "community number\n"
9290 "Do not send outside local AS (well-known community)\n"
9291 "Do not advertise to any peer (well-known community)\n"
9292 "Do not export to next AS (well-known community)\n")
9293{
9294 if (strncmp (argv[0], "m", 1) == 0)
9295 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9296
9297 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9298}
9299
9300ALIAS (show_ip_bgp_ipv4_community,
9301 show_ip_bgp_ipv4_community2_cmd,
9302 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9303 SHOW_STR
9304 IP_STR
9305 BGP_STR
9306 "Address family\n"
9307 "Address Family modifier\n"
9308 "Address Family modifier\n"
9309 "Display routes matching the communities\n"
9310 "community number\n"
9311 "Do not send outside local AS (well-known community)\n"
9312 "Do not advertise to any peer (well-known community)\n"
9313 "Do not export to next AS (well-known community)\n"
9314 "community number\n"
9315 "Do not send outside local AS (well-known community)\n"
9316 "Do not advertise to any peer (well-known community)\n"
9317 "Do not export to next AS (well-known community)\n")
9318
9319ALIAS (show_ip_bgp_ipv4_community,
9320 show_ip_bgp_ipv4_community3_cmd,
9321 "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)",
9322 SHOW_STR
9323 IP_STR
9324 BGP_STR
9325 "Address family\n"
9326 "Address Family modifier\n"
9327 "Address Family modifier\n"
9328 "Display routes matching the communities\n"
9329 "community number\n"
9330 "Do not send outside local AS (well-known community)\n"
9331 "Do not advertise to any peer (well-known community)\n"
9332 "Do not export to next AS (well-known community)\n"
9333 "community number\n"
9334 "Do not send outside local AS (well-known community)\n"
9335 "Do not advertise to any peer (well-known community)\n"
9336 "Do not export to next AS (well-known community)\n"
9337 "community number\n"
9338 "Do not send outside local AS (well-known community)\n"
9339 "Do not advertise to any peer (well-known community)\n"
9340 "Do not export to next AS (well-known community)\n")
9341
9342ALIAS (show_ip_bgp_ipv4_community,
9343 show_ip_bgp_ipv4_community4_cmd,
9344 "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)",
9345 SHOW_STR
9346 IP_STR
9347 BGP_STR
9348 "Address family\n"
9349 "Address Family modifier\n"
9350 "Address Family modifier\n"
9351 "Display routes matching the communities\n"
9352 "community number\n"
9353 "Do not send outside local AS (well-known community)\n"
9354 "Do not advertise to any peer (well-known community)\n"
9355 "Do not export to next AS (well-known community)\n"
9356 "community number\n"
9357 "Do not send outside local AS (well-known community)\n"
9358 "Do not advertise to any peer (well-known community)\n"
9359 "Do not export to next AS (well-known community)\n"
9360 "community number\n"
9361 "Do not send outside local AS (well-known community)\n"
9362 "Do not advertise to any peer (well-known community)\n"
9363 "Do not export to next AS (well-known community)\n"
9364 "community number\n"
9365 "Do not send outside local AS (well-known community)\n"
9366 "Do not advertise to any peer (well-known community)\n"
9367 "Do not export to next AS (well-known community)\n")
9368
9369DEFUN (show_ip_bgp_community_exact,
9370 show_ip_bgp_community_exact_cmd,
9371 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9372 SHOW_STR
9373 IP_STR
9374 BGP_STR
9375 "Display routes matching the communities\n"
9376 "community number\n"
9377 "Do not send outside local AS (well-known community)\n"
9378 "Do not advertise to any peer (well-known community)\n"
9379 "Do not export to next AS (well-known community)\n"
9380 "Exact match of the communities")
9381{
9382 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9383}
9384
9385ALIAS (show_ip_bgp_community_exact,
9386 show_ip_bgp_community2_exact_cmd,
9387 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9388 SHOW_STR
9389 IP_STR
9390 BGP_STR
9391 "Display routes matching the communities\n"
9392 "community number\n"
9393 "Do not send outside local AS (well-known community)\n"
9394 "Do not advertise to any peer (well-known community)\n"
9395 "Do not export to next AS (well-known community)\n"
9396 "community number\n"
9397 "Do not send outside local AS (well-known community)\n"
9398 "Do not advertise to any peer (well-known community)\n"
9399 "Do not export to next AS (well-known community)\n"
9400 "Exact match of the communities")
9401
9402ALIAS (show_ip_bgp_community_exact,
9403 show_ip_bgp_community3_exact_cmd,
9404 "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",
9405 SHOW_STR
9406 IP_STR
9407 BGP_STR
9408 "Display routes matching the communities\n"
9409 "community number\n"
9410 "Do not send outside local AS (well-known community)\n"
9411 "Do not advertise to any peer (well-known community)\n"
9412 "Do not export to next AS (well-known community)\n"
9413 "community number\n"
9414 "Do not send outside local AS (well-known community)\n"
9415 "Do not advertise to any peer (well-known community)\n"
9416 "Do not export to next AS (well-known community)\n"
9417 "community number\n"
9418 "Do not send outside local AS (well-known community)\n"
9419 "Do not advertise to any peer (well-known community)\n"
9420 "Do not export to next AS (well-known community)\n"
9421 "Exact match of the communities")
9422
9423ALIAS (show_ip_bgp_community_exact,
9424 show_ip_bgp_community4_exact_cmd,
9425 "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",
9426 SHOW_STR
9427 IP_STR
9428 BGP_STR
9429 "Display routes matching the communities\n"
9430 "community number\n"
9431 "Do not send outside local AS (well-known community)\n"
9432 "Do not advertise to any peer (well-known community)\n"
9433 "Do not export to next AS (well-known community)\n"
9434 "community number\n"
9435 "Do not send outside local AS (well-known community)\n"
9436 "Do not advertise to any peer (well-known community)\n"
9437 "Do not export to next AS (well-known community)\n"
9438 "community number\n"
9439 "Do not send outside local AS (well-known community)\n"
9440 "Do not advertise to any peer (well-known community)\n"
9441 "Do not export to next AS (well-known community)\n"
9442 "community number\n"
9443 "Do not send outside local AS (well-known community)\n"
9444 "Do not advertise to any peer (well-known community)\n"
9445 "Do not export to next AS (well-known community)\n"
9446 "Exact match of the communities")
9447
9448DEFUN (show_ip_bgp_ipv4_community_exact,
9449 show_ip_bgp_ipv4_community_exact_cmd,
9450 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9451 SHOW_STR
9452 IP_STR
9453 BGP_STR
9454 "Address family\n"
9455 "Address Family modifier\n"
9456 "Address Family modifier\n"
9457 "Display routes matching the communities\n"
9458 "community number\n"
9459 "Do not send outside local AS (well-known community)\n"
9460 "Do not advertise to any peer (well-known community)\n"
9461 "Do not export to next AS (well-known community)\n"
9462 "Exact match of the communities")
9463{
9464 if (strncmp (argv[0], "m", 1) == 0)
9465 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9466
9467 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9468}
9469
9470ALIAS (show_ip_bgp_ipv4_community_exact,
9471 show_ip_bgp_ipv4_community2_exact_cmd,
9472 "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",
9473 SHOW_STR
9474 IP_STR
9475 BGP_STR
9476 "Address family\n"
9477 "Address Family modifier\n"
9478 "Address Family modifier\n"
9479 "Display routes matching the communities\n"
9480 "community number\n"
9481 "Do not send outside local AS (well-known community)\n"
9482 "Do not advertise to any peer (well-known community)\n"
9483 "Do not export to next AS (well-known community)\n"
9484 "community number\n"
9485 "Do not send outside local AS (well-known community)\n"
9486 "Do not advertise to any peer (well-known community)\n"
9487 "Do not export to next AS (well-known community)\n"
9488 "Exact match of the communities")
9489
9490ALIAS (show_ip_bgp_ipv4_community_exact,
9491 show_ip_bgp_ipv4_community3_exact_cmd,
9492 "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",
9493 SHOW_STR
9494 IP_STR
9495 BGP_STR
9496 "Address family\n"
9497 "Address Family modifier\n"
9498 "Address Family modifier\n"
9499 "Display routes matching the communities\n"
9500 "community number\n"
9501 "Do not send outside local AS (well-known community)\n"
9502 "Do not advertise to any peer (well-known community)\n"
9503 "Do not export to next AS (well-known community)\n"
9504 "community number\n"
9505 "Do not send outside local AS (well-known community)\n"
9506 "Do not advertise to any peer (well-known community)\n"
9507 "Do not export to next AS (well-known community)\n"
9508 "community number\n"
9509 "Do not send outside local AS (well-known community)\n"
9510 "Do not advertise to any peer (well-known community)\n"
9511 "Do not export to next AS (well-known community)\n"
9512 "Exact match of the communities")
9513
9514ALIAS (show_ip_bgp_ipv4_community_exact,
9515 show_ip_bgp_ipv4_community4_exact_cmd,
9516 "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",
9517 SHOW_STR
9518 IP_STR
9519 BGP_STR
9520 "Address family\n"
9521 "Address Family modifier\n"
9522 "Address Family modifier\n"
9523 "Display routes matching the communities\n"
9524 "community number\n"
9525 "Do not send outside local AS (well-known community)\n"
9526 "Do not advertise to any peer (well-known community)\n"
9527 "Do not export to next AS (well-known community)\n"
9528 "community number\n"
9529 "Do not send outside local AS (well-known community)\n"
9530 "Do not advertise to any peer (well-known community)\n"
9531 "Do not export to next AS (well-known community)\n"
9532 "community number\n"
9533 "Do not send outside local AS (well-known community)\n"
9534 "Do not advertise to any peer (well-known community)\n"
9535 "Do not export to next AS (well-known community)\n"
9536 "community number\n"
9537 "Do not send outside local AS (well-known community)\n"
9538 "Do not advertise to any peer (well-known community)\n"
9539 "Do not export to next AS (well-known community)\n"
9540 "Exact match of the communities")
9541
Lou Bergerf9b6c392016-01-12 13:42:09 -05009542DEFUN (show_bgp_community,
9543 show_bgp_community_cmd,
9544 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9545 SHOW_STR
9546 BGP_STR
9547 "Display routes matching the communities\n"
9548 "community number\n"
9549 "Do not send outside local AS (well-known community)\n"
9550 "Do not advertise to any peer (well-known community)\n"
9551 "Do not export to next AS (well-known community)\n")
9552{
9553 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9554}
9555
9556ALIAS (show_bgp_community,
9557 show_bgp_ipv6_community_cmd,
9558 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9559 SHOW_STR
9560 BGP_STR
9561 "Address family\n"
9562 "Display routes matching the communities\n"
9563 "community number\n"
9564 "Do not send outside local AS (well-known community)\n"
9565 "Do not advertise to any peer (well-known community)\n"
9566 "Do not export to next AS (well-known community)\n")
9567
9568ALIAS (show_bgp_community,
9569 show_bgp_community2_cmd,
9570 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9571 SHOW_STR
9572 BGP_STR
9573 "Display routes matching the communities\n"
9574 "community number\n"
9575 "Do not send outside local AS (well-known community)\n"
9576 "Do not advertise to any peer (well-known community)\n"
9577 "Do not export to next AS (well-known community)\n"
9578 "community number\n"
9579 "Do not send outside local AS (well-known community)\n"
9580 "Do not advertise to any peer (well-known community)\n"
9581 "Do not export to next AS (well-known community)\n")
9582
9583ALIAS (show_bgp_community,
9584 show_bgp_ipv6_community2_cmd,
9585 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9586 SHOW_STR
9587 BGP_STR
9588 "Address family\n"
9589 "Display routes matching the communities\n"
9590 "community number\n"
9591 "Do not send outside local AS (well-known community)\n"
9592 "Do not advertise to any peer (well-known community)\n"
9593 "Do not export to next AS (well-known community)\n"
9594 "community number\n"
9595 "Do not send outside local AS (well-known community)\n"
9596 "Do not advertise to any peer (well-known community)\n"
9597 "Do not export to next AS (well-known community)\n")
9598
9599ALIAS (show_bgp_community,
9600 show_bgp_community3_cmd,
9601 "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)",
9602 SHOW_STR
9603 BGP_STR
9604 "Display routes matching the communities\n"
9605 "community number\n"
9606 "Do not send outside local AS (well-known community)\n"
9607 "Do not advertise to any peer (well-known community)\n"
9608 "Do not export to next AS (well-known community)\n"
9609 "community number\n"
9610 "Do not send outside local AS (well-known community)\n"
9611 "Do not advertise to any peer (well-known community)\n"
9612 "Do not export to next AS (well-known community)\n"
9613 "community number\n"
9614 "Do not send outside local AS (well-known community)\n"
9615 "Do not advertise to any peer (well-known community)\n"
9616 "Do not export to next AS (well-known community)\n")
9617
9618ALIAS (show_bgp_community,
9619 show_bgp_ipv6_community3_cmd,
9620 "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)",
9621 SHOW_STR
9622 BGP_STR
9623 "Address family\n"
9624 "Display routes matching the communities\n"
9625 "community number\n"
9626 "Do not send outside local AS (well-known community)\n"
9627 "Do not advertise to any peer (well-known community)\n"
9628 "Do not export to next AS (well-known community)\n"
9629 "community number\n"
9630 "Do not send outside local AS (well-known community)\n"
9631 "Do not advertise to any peer (well-known community)\n"
9632 "Do not export to next AS (well-known community)\n"
9633 "community number\n"
9634 "Do not send outside local AS (well-known community)\n"
9635 "Do not advertise to any peer (well-known community)\n"
9636 "Do not export to next AS (well-known community)\n")
9637
9638ALIAS (show_bgp_community,
9639 show_bgp_community4_cmd,
9640 "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)",
9641 SHOW_STR
9642 BGP_STR
9643 "Display routes matching the communities\n"
9644 "community number\n"
9645 "Do not send outside local AS (well-known community)\n"
9646 "Do not advertise to any peer (well-known community)\n"
9647 "Do not export to next AS (well-known community)\n"
9648 "community number\n"
9649 "Do not send outside local AS (well-known community)\n"
9650 "Do not advertise to any peer (well-known community)\n"
9651 "Do not export to next AS (well-known community)\n"
9652 "community number\n"
9653 "Do not send outside local AS (well-known community)\n"
9654 "Do not advertise to any peer (well-known community)\n"
9655 "Do not export to next AS (well-known community)\n"
9656 "community number\n"
9657 "Do not send outside local AS (well-known community)\n"
9658 "Do not advertise to any peer (well-known community)\n"
9659 "Do not export to next AS (well-known community)\n")
9660
9661ALIAS (show_bgp_community,
9662 show_bgp_ipv6_community4_cmd,
9663 "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)",
9664 SHOW_STR
9665 BGP_STR
9666 "Address family\n"
9667 "Display routes matching the communities\n"
9668 "community number\n"
9669 "Do not send outside local AS (well-known community)\n"
9670 "Do not advertise to any peer (well-known community)\n"
9671 "Do not export to next AS (well-known community)\n"
9672 "community number\n"
9673 "Do not send outside local AS (well-known community)\n"
9674 "Do not advertise to any peer (well-known community)\n"
9675 "Do not export to next AS (well-known community)\n"
9676 "community number\n"
9677 "Do not send outside local AS (well-known community)\n"
9678 "Do not advertise to any peer (well-known community)\n"
9679 "Do not export to next AS (well-known community)\n"
9680 "community number\n"
9681 "Do not send outside local AS (well-known community)\n"
9682 "Do not advertise to any peer (well-known community)\n"
9683 "Do not export to next AS (well-known community)\n")
9684
9685/* old command */
9686DEFUN (show_ipv6_bgp_community,
9687 show_ipv6_bgp_community_cmd,
9688 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9689 SHOW_STR
9690 IPV6_STR
9691 BGP_STR
9692 "Display routes matching the communities\n"
9693 "community number\n"
9694 "Do not send outside local AS (well-known community)\n"
9695 "Do not advertise to any peer (well-known community)\n"
9696 "Do not export to next AS (well-known community)\n")
9697{
9698 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9699}
9700
9701/* old command */
9702ALIAS (show_ipv6_bgp_community,
9703 show_ipv6_bgp_community2_cmd,
9704 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9705 SHOW_STR
9706 IPV6_STR
9707 BGP_STR
9708 "Display routes matching the communities\n"
9709 "community number\n"
9710 "Do not send outside local AS (well-known community)\n"
9711 "Do not advertise to any peer (well-known community)\n"
9712 "Do not export to next AS (well-known community)\n"
9713 "community number\n"
9714 "Do not send outside local AS (well-known community)\n"
9715 "Do not advertise to any peer (well-known community)\n"
9716 "Do not export to next AS (well-known community)\n")
9717
9718/* old command */
9719ALIAS (show_ipv6_bgp_community,
9720 show_ipv6_bgp_community3_cmd,
9721 "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)",
9722 SHOW_STR
9723 IPV6_STR
9724 BGP_STR
9725 "Display routes matching the communities\n"
9726 "community number\n"
9727 "Do not send outside local AS (well-known community)\n"
9728 "Do not advertise to any peer (well-known community)\n"
9729 "Do not export to next AS (well-known community)\n"
9730 "community number\n"
9731 "Do not send outside local AS (well-known community)\n"
9732 "Do not advertise to any peer (well-known community)\n"
9733 "Do not export to next AS (well-known community)\n"
9734 "community number\n"
9735 "Do not send outside local AS (well-known community)\n"
9736 "Do not advertise to any peer (well-known community)\n"
9737 "Do not export to next AS (well-known community)\n")
9738
9739/* old command */
9740ALIAS (show_ipv6_bgp_community,
9741 show_ipv6_bgp_community4_cmd,
9742 "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)",
9743 SHOW_STR
9744 IPV6_STR
9745 BGP_STR
9746 "Display routes matching the communities\n"
9747 "community number\n"
9748 "Do not send outside local AS (well-known community)\n"
9749 "Do not advertise to any peer (well-known community)\n"
9750 "Do not export to next AS (well-known community)\n"
9751 "community number\n"
9752 "Do not send outside local AS (well-known community)\n"
9753 "Do not advertise to any peer (well-known community)\n"
9754 "Do not export to next AS (well-known community)\n"
9755 "community number\n"
9756 "Do not send outside local AS (well-known community)\n"
9757 "Do not advertise to any peer (well-known community)\n"
9758 "Do not export to next AS (well-known community)\n"
9759 "community number\n"
9760 "Do not send outside local AS (well-known community)\n"
9761 "Do not advertise to any peer (well-known community)\n"
9762 "Do not export to next AS (well-known community)\n")
9763
9764DEFUN (show_bgp_community_exact,
9765 show_bgp_community_exact_cmd,
9766 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9767 SHOW_STR
9768 BGP_STR
9769 "Display routes matching the communities\n"
9770 "community number\n"
9771 "Do not send outside local AS (well-known community)\n"
9772 "Do not advertise to any peer (well-known community)\n"
9773 "Do not export to next AS (well-known community)\n"
9774 "Exact match of the communities")
9775{
9776 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9777}
9778
9779ALIAS (show_bgp_community_exact,
9780 show_bgp_ipv6_community_exact_cmd,
9781 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9782 SHOW_STR
9783 BGP_STR
9784 "Address family\n"
9785 "Display routes matching the communities\n"
9786 "community number\n"
9787 "Do not send outside local AS (well-known community)\n"
9788 "Do not advertise to any peer (well-known community)\n"
9789 "Do not export to next AS (well-known community)\n"
9790 "Exact match of the communities")
9791
9792ALIAS (show_bgp_community_exact,
9793 show_bgp_community2_exact_cmd,
9794 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9795 SHOW_STR
9796 BGP_STR
9797 "Display routes matching the communities\n"
9798 "community number\n"
9799 "Do not send outside local AS (well-known community)\n"
9800 "Do not advertise to any peer (well-known community)\n"
9801 "Do not export to next AS (well-known community)\n"
9802 "community number\n"
9803 "Do not send outside local AS (well-known community)\n"
9804 "Do not advertise to any peer (well-known community)\n"
9805 "Do not export to next AS (well-known community)\n"
9806 "Exact match of the communities")
9807
9808ALIAS (show_bgp_community_exact,
9809 show_bgp_ipv6_community2_exact_cmd,
9810 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9811 SHOW_STR
9812 BGP_STR
9813 "Address family\n"
9814 "Display routes matching the communities\n"
9815 "community number\n"
9816 "Do not send outside local AS (well-known community)\n"
9817 "Do not advertise to any peer (well-known community)\n"
9818 "Do not export to next AS (well-known community)\n"
9819 "community number\n"
9820 "Do not send outside local AS (well-known community)\n"
9821 "Do not advertise to any peer (well-known community)\n"
9822 "Do not export to next AS (well-known community)\n"
9823 "Exact match of the communities")
9824
9825ALIAS (show_bgp_community_exact,
9826 show_bgp_community3_exact_cmd,
9827 "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",
9828 SHOW_STR
9829 BGP_STR
9830 "Display routes matching the communities\n"
9831 "community number\n"
9832 "Do not send outside local AS (well-known community)\n"
9833 "Do not advertise to any peer (well-known community)\n"
9834 "Do not export to next AS (well-known community)\n"
9835 "community number\n"
9836 "Do not send outside local AS (well-known community)\n"
9837 "Do not advertise to any peer (well-known community)\n"
9838 "Do not export to next AS (well-known community)\n"
9839 "community number\n"
9840 "Do not send outside local AS (well-known community)\n"
9841 "Do not advertise to any peer (well-known community)\n"
9842 "Do not export to next AS (well-known community)\n"
9843 "Exact match of the communities")
9844
9845ALIAS (show_bgp_community_exact,
9846 show_bgp_ipv6_community3_exact_cmd,
9847 "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",
9848 SHOW_STR
9849 BGP_STR
9850 "Address family\n"
9851 "Display routes matching the communities\n"
9852 "community number\n"
9853 "Do not send outside local AS (well-known community)\n"
9854 "Do not advertise to any peer (well-known community)\n"
9855 "Do not export to next AS (well-known community)\n"
9856 "community number\n"
9857 "Do not send outside local AS (well-known community)\n"
9858 "Do not advertise to any peer (well-known community)\n"
9859 "Do not export to next AS (well-known community)\n"
9860 "community number\n"
9861 "Do not send outside local AS (well-known community)\n"
9862 "Do not advertise to any peer (well-known community)\n"
9863 "Do not export to next AS (well-known community)\n"
9864 "Exact match of the communities")
9865
9866ALIAS (show_bgp_community_exact,
9867 show_bgp_community4_exact_cmd,
9868 "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",
9869 SHOW_STR
9870 BGP_STR
9871 "Display routes matching the communities\n"
9872 "community number\n"
9873 "Do not send outside local AS (well-known community)\n"
9874 "Do not advertise to any peer (well-known community)\n"
9875 "Do not export to next AS (well-known community)\n"
9876 "community number\n"
9877 "Do not send outside local AS (well-known community)\n"
9878 "Do not advertise to any peer (well-known community)\n"
9879 "Do not export to next AS (well-known community)\n"
9880 "community number\n"
9881 "Do not send outside local AS (well-known community)\n"
9882 "Do not advertise to any peer (well-known community)\n"
9883 "Do not export to next AS (well-known community)\n"
9884 "community number\n"
9885 "Do not send outside local AS (well-known community)\n"
9886 "Do not advertise to any peer (well-known community)\n"
9887 "Do not export to next AS (well-known community)\n"
9888 "Exact match of the communities")
9889
9890ALIAS (show_bgp_community_exact,
9891 show_bgp_ipv6_community4_exact_cmd,
9892 "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",
9893 SHOW_STR
9894 BGP_STR
9895 "Address family\n"
9896 "Display routes matching the communities\n"
9897 "community number\n"
9898 "Do not send outside local AS (well-known community)\n"
9899 "Do not advertise to any peer (well-known community)\n"
9900 "Do not export to next AS (well-known community)\n"
9901 "community number\n"
9902 "Do not send outside local AS (well-known community)\n"
9903 "Do not advertise to any peer (well-known community)\n"
9904 "Do not export to next AS (well-known community)\n"
9905 "community number\n"
9906 "Do not send outside local AS (well-known community)\n"
9907 "Do not advertise to any peer (well-known community)\n"
9908 "Do not export to next AS (well-known community)\n"
9909 "community number\n"
9910 "Do not send outside local AS (well-known community)\n"
9911 "Do not advertise to any peer (well-known community)\n"
9912 "Do not export to next AS (well-known community)\n"
9913 "Exact match of the communities")
9914
9915/* old command */
9916DEFUN (show_ipv6_bgp_community_exact,
9917 show_ipv6_bgp_community_exact_cmd,
9918 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9919 SHOW_STR
9920 IPV6_STR
9921 BGP_STR
9922 "Display routes matching the communities\n"
9923 "community number\n"
9924 "Do not send outside local AS (well-known community)\n"
9925 "Do not advertise to any peer (well-known community)\n"
9926 "Do not export to next AS (well-known community)\n"
9927 "Exact match of the communities")
9928{
9929 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9930}
9931
9932/* old command */
9933ALIAS (show_ipv6_bgp_community_exact,
9934 show_ipv6_bgp_community2_exact_cmd,
9935 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9936 SHOW_STR
9937 IPV6_STR
9938 BGP_STR
9939 "Display routes matching the communities\n"
9940 "community number\n"
9941 "Do not send outside local AS (well-known community)\n"
9942 "Do not advertise to any peer (well-known community)\n"
9943 "Do not export to next AS (well-known community)\n"
9944 "community number\n"
9945 "Do not send outside local AS (well-known community)\n"
9946 "Do not advertise to any peer (well-known community)\n"
9947 "Do not export to next AS (well-known community)\n"
9948 "Exact match of the communities")
9949
9950/* old command */
9951ALIAS (show_ipv6_bgp_community_exact,
9952 show_ipv6_bgp_community3_exact_cmd,
9953 "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",
9954 SHOW_STR
9955 IPV6_STR
9956 BGP_STR
9957 "Display routes matching the communities\n"
9958 "community number\n"
9959 "Do not send outside local AS (well-known community)\n"
9960 "Do not advertise to any peer (well-known community)\n"
9961 "Do not export to next AS (well-known community)\n"
9962 "community number\n"
9963 "Do not send outside local AS (well-known community)\n"
9964 "Do not advertise to any peer (well-known community)\n"
9965 "Do not export to next AS (well-known community)\n"
9966 "community number\n"
9967 "Do not send outside local AS (well-known community)\n"
9968 "Do not advertise to any peer (well-known community)\n"
9969 "Do not export to next AS (well-known community)\n"
9970 "Exact match of the communities")
9971
9972/* old command */
9973ALIAS (show_ipv6_bgp_community_exact,
9974 show_ipv6_bgp_community4_exact_cmd,
9975 "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",
9976 SHOW_STR
9977 IPV6_STR
9978 BGP_STR
9979 "Display routes matching the communities\n"
9980 "community number\n"
9981 "Do not send outside local AS (well-known community)\n"
9982 "Do not advertise to any peer (well-known community)\n"
9983 "Do not export to next AS (well-known community)\n"
9984 "community number\n"
9985 "Do not send outside local AS (well-known community)\n"
9986 "Do not advertise to any peer (well-known community)\n"
9987 "Do not export to next AS (well-known community)\n"
9988 "community number\n"
9989 "Do not send outside local AS (well-known community)\n"
9990 "Do not advertise to any peer (well-known community)\n"
9991 "Do not export to next AS (well-known community)\n"
9992 "community number\n"
9993 "Do not send outside local AS (well-known community)\n"
9994 "Do not advertise to any peer (well-known community)\n"
9995 "Do not export to next AS (well-known community)\n"
9996 "Exact match of the communities")
9997
9998/* old command */
9999DEFUN (show_ipv6_mbgp_community,
10000 show_ipv6_mbgp_community_cmd,
10001 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10002 SHOW_STR
10003 IPV6_STR
10004 MBGP_STR
10005 "Display routes matching the communities\n"
10006 "community number\n"
10007 "Do not send outside local AS (well-known community)\n"
10008 "Do not advertise to any peer (well-known community)\n"
10009 "Do not export to next AS (well-known community)\n")
10010{
10011 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
10012}
10013
10014/* old command */
10015ALIAS (show_ipv6_mbgp_community,
10016 show_ipv6_mbgp_community2_cmd,
10017 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10018 SHOW_STR
10019 IPV6_STR
10020 MBGP_STR
10021 "Display routes matching the communities\n"
10022 "community number\n"
10023 "Do not send outside local AS (well-known community)\n"
10024 "Do not advertise to any peer (well-known community)\n"
10025 "Do not export to next AS (well-known community)\n"
10026 "community number\n"
10027 "Do not send outside local AS (well-known community)\n"
10028 "Do not advertise to any peer (well-known community)\n"
10029 "Do not export to next AS (well-known community)\n")
10030
10031/* old command */
10032ALIAS (show_ipv6_mbgp_community,
10033 show_ipv6_mbgp_community3_cmd,
10034 "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)",
10035 SHOW_STR
10036 IPV6_STR
10037 MBGP_STR
10038 "Display routes matching the communities\n"
10039 "community number\n"
10040 "Do not send outside local AS (well-known community)\n"
10041 "Do not advertise to any peer (well-known community)\n"
10042 "Do not export to next AS (well-known community)\n"
10043 "community number\n"
10044 "Do not send outside local AS (well-known community)\n"
10045 "Do not advertise to any peer (well-known community)\n"
10046 "Do not export to next AS (well-known community)\n"
10047 "community number\n"
10048 "Do not send outside local AS (well-known community)\n"
10049 "Do not advertise to any peer (well-known community)\n"
10050 "Do not export to next AS (well-known community)\n")
10051
10052/* old command */
10053ALIAS (show_ipv6_mbgp_community,
10054 show_ipv6_mbgp_community4_cmd,
10055 "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)",
10056 SHOW_STR
10057 IPV6_STR
10058 MBGP_STR
10059 "Display routes matching the communities\n"
10060 "community number\n"
10061 "Do not send outside local AS (well-known community)\n"
10062 "Do not advertise to any peer (well-known community)\n"
10063 "Do not export to next AS (well-known community)\n"
10064 "community number\n"
10065 "Do not send outside local AS (well-known community)\n"
10066 "Do not advertise to any peer (well-known community)\n"
10067 "Do not export to next AS (well-known community)\n"
10068 "community number\n"
10069 "Do not send outside local AS (well-known community)\n"
10070 "Do not advertise to any peer (well-known community)\n"
10071 "Do not export to next AS (well-known community)\n"
10072 "community number\n"
10073 "Do not send outside local AS (well-known community)\n"
10074 "Do not advertise to any peer (well-known community)\n"
10075 "Do not export to next AS (well-known community)\n")
10076
10077/* old command */
10078DEFUN (show_ipv6_mbgp_community_exact,
10079 show_ipv6_mbgp_community_exact_cmd,
10080 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10081 SHOW_STR
10082 IPV6_STR
10083 MBGP_STR
10084 "Display routes matching the communities\n"
10085 "community number\n"
10086 "Do not send outside local AS (well-known community)\n"
10087 "Do not advertise to any peer (well-known community)\n"
10088 "Do not export to next AS (well-known community)\n"
10089 "Exact match of the communities")
10090{
10091 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10092}
10093
10094/* old command */
10095ALIAS (show_ipv6_mbgp_community_exact,
10096 show_ipv6_mbgp_community2_exact_cmd,
10097 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10098 SHOW_STR
10099 IPV6_STR
10100 MBGP_STR
10101 "Display routes matching the communities\n"
10102 "community number\n"
10103 "Do not send outside local AS (well-known community)\n"
10104 "Do not advertise to any peer (well-known community)\n"
10105 "Do not export to next AS (well-known community)\n"
10106 "community number\n"
10107 "Do not send outside local AS (well-known community)\n"
10108 "Do not advertise to any peer (well-known community)\n"
10109 "Do not export to next AS (well-known community)\n"
10110 "Exact match of the communities")
10111
10112/* old command */
10113ALIAS (show_ipv6_mbgp_community_exact,
10114 show_ipv6_mbgp_community3_exact_cmd,
10115 "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",
10116 SHOW_STR
10117 IPV6_STR
10118 MBGP_STR
10119 "Display routes matching the communities\n"
10120 "community number\n"
10121 "Do not send outside local AS (well-known community)\n"
10122 "Do not advertise to any peer (well-known community)\n"
10123 "Do not export to next AS (well-known community)\n"
10124 "community number\n"
10125 "Do not send outside local AS (well-known community)\n"
10126 "Do not advertise to any peer (well-known community)\n"
10127 "Do not export to next AS (well-known community)\n"
10128 "community number\n"
10129 "Do not send outside local AS (well-known community)\n"
10130 "Do not advertise to any peer (well-known community)\n"
10131 "Do not export to next AS (well-known community)\n"
10132 "Exact match of the communities")
10133
10134/* old command */
10135ALIAS (show_ipv6_mbgp_community_exact,
10136 show_ipv6_mbgp_community4_exact_cmd,
10137 "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",
10138 SHOW_STR
10139 IPV6_STR
10140 MBGP_STR
10141 "Display routes matching the communities\n"
10142 "community number\n"
10143 "Do not send outside local AS (well-known community)\n"
10144 "Do not advertise to any peer (well-known community)\n"
10145 "Do not export to next AS (well-known community)\n"
10146 "community number\n"
10147 "Do not send outside local AS (well-known community)\n"
10148 "Do not advertise to any peer (well-known community)\n"
10149 "Do not export to next AS (well-known community)\n"
10150 "community number\n"
10151 "Do not send outside local AS (well-known community)\n"
10152 "Do not advertise to any peer (well-known community)\n"
10153 "Do not export to next AS (well-known community)\n"
10154 "community number\n"
10155 "Do not send outside local AS (well-known community)\n"
10156 "Do not advertise to any peer (well-known community)\n"
10157 "Do not export to next AS (well-known community)\n"
10158 "Exact match of the communities")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010159
Lou Berger651b4022016-01-12 13:42:07 -050010160DEFUN (show_bgp_ipv4_community,
10161 show_bgp_ipv4_community_cmd,
10162 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010163 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010164 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010165 IP_STR
paul718e3742002-12-13 20:15:29 +000010166 "Display routes matching the communities\n"
10167 "community number\n"
10168 "Do not send outside local AS (well-known community)\n"
10169 "Do not advertise to any peer (well-known community)\n"
10170 "Do not export to next AS (well-known community)\n")
10171{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010172 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010173}
10174
Lou Berger651b4022016-01-12 13:42:07 -050010175ALIAS (show_bgp_ipv4_community,
10176 show_bgp_ipv4_community2_cmd,
10177 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010178 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010179 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010180 IP_STR
paul718e3742002-12-13 20:15:29 +000010181 "Display routes matching the communities\n"
10182 "community number\n"
10183 "Do not send outside local AS (well-known community)\n"
10184 "Do not advertise to any peer (well-known community)\n"
10185 "Do not export to next AS (well-known community)\n"
10186 "community number\n"
10187 "Do not send outside local AS (well-known community)\n"
10188 "Do not advertise to any peer (well-known community)\n"
10189 "Do not export to next AS (well-known community)\n")
10190
Lou Berger651b4022016-01-12 13:42:07 -050010191ALIAS (show_bgp_ipv4_community,
10192 show_bgp_ipv4_community3_cmd,
10193 "show bgp ipv4 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)",
paul718e3742002-12-13 20:15:29 +000010194 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010195 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010196 IP_STR
paul718e3742002-12-13 20:15:29 +000010197 "Display routes matching the communities\n"
10198 "community number\n"
10199 "Do not send outside local AS (well-known community)\n"
10200 "Do not advertise to any peer (well-known community)\n"
10201 "Do not export to next AS (well-known community)\n"
10202 "community number\n"
10203 "Do not send outside local AS (well-known community)\n"
10204 "Do not advertise to any peer (well-known community)\n"
10205 "Do not export to next AS (well-known community)\n"
10206 "community number\n"
10207 "Do not send outside local AS (well-known community)\n"
10208 "Do not advertise to any peer (well-known community)\n"
10209 "Do not export to next AS (well-known community)\n")
10210
Lou Berger651b4022016-01-12 13:42:07 -050010211ALIAS (show_bgp_ipv4_community,
10212 show_bgp_ipv4_community4_cmd,
10213 "show bgp ipv4 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)",
paul718e3742002-12-13 20:15:29 +000010214 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010215 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010216 IP_STR
paul718e3742002-12-13 20:15:29 +000010217 "Display routes matching the communities\n"
10218 "community number\n"
10219 "Do not send outside local AS (well-known community)\n"
10220 "Do not advertise to any peer (well-known community)\n"
10221 "Do not export to next AS (well-known community)\n"
10222 "community number\n"
10223 "Do not send outside local AS (well-known community)\n"
10224 "Do not advertise to any peer (well-known community)\n"
10225 "Do not export to next AS (well-known community)\n"
10226 "community number\n"
10227 "Do not send outside local AS (well-known community)\n"
10228 "Do not advertise to any peer (well-known community)\n"
10229 "Do not export to next AS (well-known community)\n"
10230 "community number\n"
10231 "Do not send outside local AS (well-known community)\n"
10232 "Do not advertise to any peer (well-known community)\n"
10233 "Do not export to next AS (well-known community)\n")
10234
Lou Berger651b4022016-01-12 13:42:07 -050010235DEFUN (show_bgp_ipv4_safi_community,
10236 show_bgp_ipv4_safi_community_cmd,
10237 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010238 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010239 BGP_STR
10240 "Address family\n"
10241 "Address Family modifier\n"
10242 "Address Family modifier\n"
10243 "Display routes matching the communities\n"
10244 "community number\n"
10245 "Do not send outside local AS (well-known community)\n"
10246 "Do not advertise to any peer (well-known community)\n"
10247 "Do not export to next AS (well-known community)\n")
10248{
10249 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010250 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010251
Michael Lambert95cbbd22010-07-23 14:43:04 -040010252 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010253}
10254
Lou Berger651b4022016-01-12 13:42:07 -050010255ALIAS (show_bgp_ipv4_safi_community,
10256 show_bgp_ipv4_safi_community2_cmd,
10257 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010258 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010259 BGP_STR
10260 "Address family\n"
10261 "Address Family modifier\n"
10262 "Address Family modifier\n"
10263 "Display routes matching the communities\n"
10264 "community number\n"
10265 "Do not send outside local AS (well-known community)\n"
10266 "Do not advertise to any peer (well-known community)\n"
10267 "Do not export to next AS (well-known community)\n"
10268 "community number\n"
10269 "Do not send outside local AS (well-known community)\n"
10270 "Do not advertise to any peer (well-known community)\n"
10271 "Do not export to next AS (well-known community)\n")
10272
Lou Berger651b4022016-01-12 13:42:07 -050010273ALIAS (show_bgp_ipv4_safi_community,
10274 show_bgp_ipv4_safi_community3_cmd,
10275 "show 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)",
paul718e3742002-12-13 20:15:29 +000010276 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010277 BGP_STR
10278 "Address family\n"
10279 "Address Family modifier\n"
10280 "Address Family modifier\n"
10281 "Display routes matching the communities\n"
10282 "community number\n"
10283 "Do not send outside local AS (well-known community)\n"
10284 "Do not advertise to any peer (well-known community)\n"
10285 "Do not export to next AS (well-known community)\n"
10286 "community number\n"
10287 "Do not send outside local AS (well-known community)\n"
10288 "Do not advertise to any peer (well-known community)\n"
10289 "Do not export to next AS (well-known community)\n"
10290 "community number\n"
10291 "Do not send outside local AS (well-known community)\n"
10292 "Do not advertise to any peer (well-known community)\n"
10293 "Do not export to next AS (well-known community)\n")
10294
Lou Berger651b4022016-01-12 13:42:07 -050010295ALIAS (show_bgp_ipv4_safi_community,
10296 show_bgp_ipv4_safi_community4_cmd,
10297 "show 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)",
paul718e3742002-12-13 20:15:29 +000010298 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010299 BGP_STR
10300 "Address family\n"
10301 "Address Family modifier\n"
10302 "Address Family modifier\n"
10303 "Display routes matching the communities\n"
10304 "community number\n"
10305 "Do not send outside local AS (well-known community)\n"
10306 "Do not advertise to any peer (well-known community)\n"
10307 "Do not export to next AS (well-known community)\n"
10308 "community number\n"
10309 "Do not send outside local AS (well-known community)\n"
10310 "Do not advertise to any peer (well-known community)\n"
10311 "Do not export to next AS (well-known community)\n"
10312 "community number\n"
10313 "Do not send outside local AS (well-known community)\n"
10314 "Do not advertise to any peer (well-known community)\n"
10315 "Do not export to next AS (well-known community)\n"
10316 "community number\n"
10317 "Do not send outside local AS (well-known community)\n"
10318 "Do not advertise to any peer (well-known community)\n"
10319 "Do not export to next AS (well-known community)\n")
10320
Michael Lambert95cbbd22010-07-23 14:43:04 -040010321DEFUN (show_bgp_view_afi_safi_community_all,
10322 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010323 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010324 SHOW_STR
10325 BGP_STR
10326 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010327 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010328 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010329 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010330 "Address Family modifier\n"
10331 "Address Family modifier\n"
Christian Franke2b005152013-09-30 12:27:49 +000010332 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010333{
10334 int afi;
10335 int safi;
10336 struct bgp *bgp;
10337
10338 /* BGP structure lookup. */
10339 bgp = bgp_lookup_by_name (argv[0]);
10340 if (bgp == NULL)
10341 {
10342 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10343 return CMD_WARNING;
10344 }
10345
Michael Lambert95cbbd22010-07-23 14:43:04 -040010346 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10347 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010348 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10349}
10350
10351DEFUN (show_bgp_view_afi_safi_community,
10352 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010353 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010354 SHOW_STR
10355 BGP_STR
10356 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010357 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010358 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010359 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010360 "Address family modifier\n"
10361 "Address family modifier\n"
10362 "Display routes matching the communities\n"
10363 "community number\n"
10364 "Do not send outside local AS (well-known community)\n"
10365 "Do not advertise to any peer (well-known community)\n"
10366 "Do not export to next AS (well-known community)\n")
10367{
10368 int afi;
10369 int safi;
10370
Michael Lambert95cbbd22010-07-23 14:43:04 -040010371 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10372 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10373 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010374}
10375
10376ALIAS (show_bgp_view_afi_safi_community,
10377 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010378 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010379 SHOW_STR
10380 BGP_STR
10381 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010382 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010383 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010384 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010385 "Address family modifier\n"
10386 "Address family modifier\n"
10387 "Display routes matching the communities\n"
10388 "community number\n"
10389 "Do not send outside local AS (well-known community)\n"
10390 "Do not advertise to any peer (well-known community)\n"
10391 "Do not export to next AS (well-known community)\n"
10392 "community number\n"
10393 "Do not send outside local AS (well-known community)\n"
10394 "Do not advertise to any peer (well-known community)\n"
10395 "Do not export to next AS (well-known community)\n")
10396
10397ALIAS (show_bgp_view_afi_safi_community,
10398 show_bgp_view_afi_safi_community3_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010399 "show bgp view WORD (ipv4|ipv6) (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)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010400 SHOW_STR
10401 BGP_STR
10402 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010403 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010404 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010405 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010406 "Address family modifier\n"
10407 "Address family modifier\n"
10408 "Display routes matching the communities\n"
10409 "community number\n"
10410 "Do not send outside local AS (well-known community)\n"
10411 "Do not advertise to any peer (well-known community)\n"
10412 "Do not export to next AS (well-known community)\n"
10413 "community number\n"
10414 "Do not send outside local AS (well-known community)\n"
10415 "Do not advertise to any peer (well-known community)\n"
10416 "Do not export to next AS (well-known community)\n"
10417 "community number\n"
10418 "Do not send outside local AS (well-known community)\n"
10419 "Do not advertise to any peer (well-known community)\n"
10420 "Do not export to next AS (well-known community)\n")
10421
10422ALIAS (show_bgp_view_afi_safi_community,
10423 show_bgp_view_afi_safi_community4_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010424 "show bgp view WORD (ipv4|ipv6) (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)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010425 SHOW_STR
10426 BGP_STR
10427 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010428 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010429 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010430 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010431 "Address family modifier\n"
10432 "Address family modifier\n"
10433 "Display routes matching the communities\n"
10434 "community number\n"
10435 "Do not send outside local AS (well-known community)\n"
10436 "Do not advertise to any peer (well-known community)\n"
10437 "Do not export to next AS (well-known community)\n"
10438 "community number\n"
10439 "Do not send outside local AS (well-known community)\n"
10440 "Do not advertise to any peer (well-known community)\n"
10441 "Do not export to next AS (well-known community)\n"
10442 "community number\n"
10443 "Do not send outside local AS (well-known community)\n"
10444 "Do not advertise to any peer (well-known community)\n"
10445 "Do not export to next AS (well-known community)\n"
10446 "community number\n"
10447 "Do not send outside local AS (well-known community)\n"
10448 "Do not advertise to any peer (well-known community)\n"
10449 "Do not export to next AS (well-known community)\n")
10450
Lou Berger651b4022016-01-12 13:42:07 -050010451DEFUN (show_bgp_ipv4_community_exact,
10452 show_bgp_ipv4_community_exact_cmd,
10453 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010454 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010455 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010456 IP_STR
paul718e3742002-12-13 20:15:29 +000010457 "Display routes matching the communities\n"
10458 "community number\n"
10459 "Do not send outside local AS (well-known community)\n"
10460 "Do not advertise to any peer (well-known community)\n"
10461 "Do not export to next AS (well-known community)\n"
10462 "Exact match of the communities")
10463{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010464 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010465}
10466
Lou Berger651b4022016-01-12 13:42:07 -050010467ALIAS (show_bgp_ipv4_community_exact,
10468 show_bgp_ipv4_community2_exact_cmd,
10469 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010470 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010471 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010472 IP_STR
paul718e3742002-12-13 20:15:29 +000010473 "Display routes matching the communities\n"
10474 "community number\n"
10475 "Do not send outside local AS (well-known community)\n"
10476 "Do not advertise to any peer (well-known community)\n"
10477 "Do not export to next AS (well-known community)\n"
10478 "community number\n"
10479 "Do not send outside local AS (well-known community)\n"
10480 "Do not advertise to any peer (well-known community)\n"
10481 "Do not export to next AS (well-known community)\n"
10482 "Exact match of the communities")
10483
Lou Berger651b4022016-01-12 13:42:07 -050010484ALIAS (show_bgp_ipv4_community_exact,
10485 show_bgp_ipv4_community3_exact_cmd,
10486 "show bgp ipv4 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",
paul718e3742002-12-13 20:15:29 +000010487 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010488 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010489 IP_STR
paul718e3742002-12-13 20:15:29 +000010490 "Display routes matching the communities\n"
10491 "community number\n"
10492 "Do not send outside local AS (well-known community)\n"
10493 "Do not advertise to any peer (well-known community)\n"
10494 "Do not export to next AS (well-known community)\n"
10495 "community number\n"
10496 "Do not send outside local AS (well-known community)\n"
10497 "Do not advertise to any peer (well-known community)\n"
10498 "Do not export to next AS (well-known community)\n"
10499 "community number\n"
10500 "Do not send outside local AS (well-known community)\n"
10501 "Do not advertise to any peer (well-known community)\n"
10502 "Do not export to next AS (well-known community)\n"
10503 "Exact match of the communities")
10504
Lou Berger651b4022016-01-12 13:42:07 -050010505ALIAS (show_bgp_ipv4_community_exact,
10506 show_bgp_ipv4_community4_exact_cmd,
10507 "show bgp ipv4 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",
paul718e3742002-12-13 20:15:29 +000010508 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010509 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010510 IP_STR
paul718e3742002-12-13 20:15:29 +000010511 "Display routes matching the communities\n"
10512 "community number\n"
10513 "Do not send outside local AS (well-known community)\n"
10514 "Do not advertise to any peer (well-known community)\n"
10515 "Do not export to next AS (well-known community)\n"
10516 "community number\n"
10517 "Do not send outside local AS (well-known community)\n"
10518 "Do not advertise to any peer (well-known community)\n"
10519 "Do not export to next AS (well-known community)\n"
10520 "community number\n"
10521 "Do not send outside local AS (well-known community)\n"
10522 "Do not advertise to any peer (well-known community)\n"
10523 "Do not export to next AS (well-known community)\n"
10524 "community number\n"
10525 "Do not send outside local AS (well-known community)\n"
10526 "Do not advertise to any peer (well-known community)\n"
10527 "Do not export to next AS (well-known community)\n"
10528 "Exact match of the communities")
10529
Lou Berger651b4022016-01-12 13:42:07 -050010530DEFUN (show_bgp_ipv4_safi_community4_exact,
10531 show_bgp_ipv4_safi_community_exact_cmd,
10532 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010533 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010534 BGP_STR
10535 "Address family\n"
10536 "Address Family modifier\n"
10537 "Address Family modifier\n"
10538 "Display routes matching the communities\n"
10539 "community number\n"
10540 "Do not send outside local AS (well-known community)\n"
10541 "Do not advertise to any peer (well-known community)\n"
10542 "Do not export to next AS (well-known community)\n"
10543 "Exact match of the communities")
10544{
10545 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010546 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010547
Michael Lambert95cbbd22010-07-23 14:43:04 -040010548 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010549}
10550
Lou Berger651b4022016-01-12 13:42:07 -050010551ALIAS (show_bgp_ipv4_safi_community4_exact,
10552 show_bgp_ipv4_safi_community2_exact_cmd,
10553 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010554 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010555 BGP_STR
10556 "Address family\n"
10557 "Address Family modifier\n"
10558 "Address Family modifier\n"
10559 "Display routes matching the communities\n"
10560 "community number\n"
10561 "Do not send outside local AS (well-known community)\n"
10562 "Do not advertise to any peer (well-known community)\n"
10563 "Do not export to next AS (well-known community)\n"
10564 "community number\n"
10565 "Do not send outside local AS (well-known community)\n"
10566 "Do not advertise to any peer (well-known community)\n"
10567 "Do not export to next AS (well-known community)\n"
10568 "Exact match of the communities")
10569
Lou Berger651b4022016-01-12 13:42:07 -050010570ALIAS (show_bgp_ipv4_safi_community4_exact,
10571 show_bgp_ipv4_safi_community3_exact_cmd,
10572 "show 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",
paul718e3742002-12-13 20:15:29 +000010573 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010574 BGP_STR
10575 "Address family\n"
10576 "Address Family modifier\n"
10577 "Address Family modifier\n"
10578 "Display routes matching the communities\n"
10579 "community number\n"
10580 "Do not send outside local AS (well-known community)\n"
10581 "Do not advertise to any peer (well-known community)\n"
10582 "Do not export to next AS (well-known community)\n"
10583 "community number\n"
10584 "Do not send outside local AS (well-known community)\n"
10585 "Do not advertise to any peer (well-known community)\n"
10586 "Do not export to next AS (well-known community)\n"
10587 "community number\n"
10588 "Do not send outside local AS (well-known community)\n"
10589 "Do not advertise to any peer (well-known community)\n"
10590 "Do not export to next AS (well-known community)\n"
10591 "Exact match of the communities")
10592
Lou Berger651b4022016-01-12 13:42:07 -050010593ALIAS (show_bgp_ipv4_safi_community4_exact,
10594 show_bgp_ipv4_safi_community4_exact_cmd,
10595 "show 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",
paul718e3742002-12-13 20:15:29 +000010596 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010597 BGP_STR
10598 "Address family\n"
10599 "Address Family modifier\n"
10600 "Address Family modifier\n"
10601 "Display routes matching the communities\n"
10602 "community number\n"
10603 "Do not send outside local AS (well-known community)\n"
10604 "Do not advertise to any peer (well-known community)\n"
10605 "Do not export to next AS (well-known community)\n"
10606 "community number\n"
10607 "Do not send outside local AS (well-known community)\n"
10608 "Do not advertise to any peer (well-known community)\n"
10609 "Do not export to next AS (well-known community)\n"
10610 "community number\n"
10611 "Do not send outside local AS (well-known community)\n"
10612 "Do not advertise to any peer (well-known community)\n"
10613 "Do not export to next AS (well-known community)\n"
10614 "community number\n"
10615 "Do not send outside local AS (well-known community)\n"
10616 "Do not advertise to any peer (well-known community)\n"
10617 "Do not export to next AS (well-known community)\n"
10618 "Exact match of the communities")
10619
Lou Bergerf9b6c392016-01-12 13:42:09 -050010620DEFUN (show_bgp_ipv6_safi_community,
10621 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010622 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010623 SHOW_STR
10624 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010625 "Address family\n"
10626 "Address family modifier\n"
10627 "Address family modifier\n"
10628 "Address family modifier\n"
10629 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010630 "Display routes matching the communities\n"
10631 "community number\n"
10632 "Do not send outside local AS (well-known community)\n"
10633 "Do not advertise to any peer (well-known community)\n"
10634 "Do not export to next AS (well-known community)\n")
10635{
Lou Berger651b4022016-01-12 13:42:07 -050010636 safi_t safi;
10637
10638 if (bgp_parse_safi(argv[0], &safi)) {
10639 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10640 return CMD_WARNING;
10641 }
10642 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010643}
10644
Lou Bergerf9b6c392016-01-12 13:42:09 -050010645ALIAS (show_bgp_ipv6_safi_community,
10646 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010647 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010648 SHOW_STR
10649 BGP_STR
10650 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010651 "Address family modifier\n"
10652 "Address family modifier\n"
10653 "Address family modifier\n"
10654 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010655 "Display routes matching the communities\n"
10656 "community number\n"
10657 "Do not send outside local AS (well-known community)\n"
10658 "Do not advertise to any peer (well-known community)\n"
10659 "Do not export to next AS (well-known community)\n"
10660 "community number\n"
10661 "Do not send outside local AS (well-known community)\n"
10662 "Do not advertise to any peer (well-known community)\n"
10663 "Do not export to next AS (well-known community)\n")
10664
Lou Bergerf9b6c392016-01-12 13:42:09 -050010665ALIAS (show_bgp_ipv6_safi_community,
10666 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010667 "show bgp ipv6 (encap|multicast|unicast|vpn) 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)",
paul718e3742002-12-13 20:15:29 +000010668 SHOW_STR
10669 BGP_STR
10670 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010671 "Address family modifier\n"
10672 "Address family modifier\n"
10673 "Address family modifier\n"
10674 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010675 "Display routes matching the communities\n"
10676 "community number\n"
10677 "Do not send outside local AS (well-known community)\n"
10678 "Do not advertise to any peer (well-known community)\n"
10679 "Do not export to next AS (well-known community)\n"
10680 "community number\n"
10681 "Do not send outside local AS (well-known community)\n"
10682 "Do not advertise to any peer (well-known community)\n"
10683 "Do not export to next AS (well-known community)\n"
10684 "community number\n"
10685 "Do not send outside local AS (well-known community)\n"
10686 "Do not advertise to any peer (well-known community)\n"
10687 "Do not export to next AS (well-known community)\n")
10688
Lou Bergerf9b6c392016-01-12 13:42:09 -050010689ALIAS (show_bgp_ipv6_safi_community,
10690 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010691 "show bgp ipv6 (encap|multicast|unicast|vpn) 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)",
paul718e3742002-12-13 20:15:29 +000010692 SHOW_STR
10693 BGP_STR
10694 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010695 "Address family modifier\n"
10696 "Address family modifier\n"
10697 "Address family modifier\n"
10698 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010699 "Display routes matching the communities\n"
10700 "community number\n"
10701 "Do not send outside local AS (well-known community)\n"
10702 "Do not advertise to any peer (well-known community)\n"
10703 "Do not export to next AS (well-known community)\n"
10704 "community number\n"
10705 "Do not send outside local AS (well-known community)\n"
10706 "Do not advertise to any peer (well-known community)\n"
10707 "Do not export to next AS (well-known community)\n"
10708 "community number\n"
10709 "Do not send outside local AS (well-known community)\n"
10710 "Do not advertise to any peer (well-known community)\n"
10711 "Do not export to next AS (well-known community)\n"
10712 "community number\n"
10713 "Do not send outside local AS (well-known community)\n"
10714 "Do not advertise to any peer (well-known community)\n"
10715 "Do not export to next AS (well-known community)\n")
10716
paul718e3742002-12-13 20:15:29 +000010717
Lou Bergerf9b6c392016-01-12 13:42:09 -050010718DEFUN (show_bgp_ipv6_safi_community_exact,
10719 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010720 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010721 SHOW_STR
10722 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010723 "Address family\n"
10724 "Address family modifier\n"
10725 "Address family modifier\n"
10726 "Address family modifier\n"
10727 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010728 "Display routes matching the communities\n"
10729 "community number\n"
10730 "Do not send outside local AS (well-known community)\n"
10731 "Do not advertise to any peer (well-known community)\n"
10732 "Do not export to next AS (well-known community)\n"
10733 "Exact match of the communities")
10734{
Lou Berger651b4022016-01-12 13:42:07 -050010735 safi_t safi;
10736
10737 if (bgp_parse_safi(argv[0], &safi)) {
10738 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10739 return CMD_WARNING;
10740 }
10741 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010742}
10743
paul718e3742002-12-13 20:15:29 +000010744
10745ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010746 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010747 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010748 SHOW_STR
10749 BGP_STR
10750 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010751 "Address family modifier\n"
10752 "Address family modifier\n"
10753 "Address family modifier\n"
10754 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010755 "Display routes matching the communities\n"
10756 "community number\n"
10757 "Do not send outside local AS (well-known community)\n"
10758 "Do not advertise to any peer (well-known community)\n"
10759 "Do not export to next AS (well-known community)\n"
10760 "community number\n"
10761 "Do not send outside local AS (well-known community)\n"
10762 "Do not advertise to any peer (well-known community)\n"
10763 "Do not export to next AS (well-known community)\n"
10764 "Exact match of the communities")
10765
10766ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010767 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010768 "show bgp ipv6 (encap|multicast|unicast|vpn) 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",
paul718e3742002-12-13 20:15:29 +000010769 SHOW_STR
10770 BGP_STR
10771 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010772 "Address family modifier\n"
10773 "Address family modifier\n"
10774 "Address family modifier\n"
10775 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010776 "Display routes matching the communities\n"
10777 "community number\n"
10778 "Do not send outside local AS (well-known community)\n"
10779 "Do not advertise to any peer (well-known community)\n"
10780 "Do not export to next AS (well-known community)\n"
10781 "community number\n"
10782 "Do not send outside local AS (well-known community)\n"
10783 "Do not advertise to any peer (well-known community)\n"
10784 "Do not export to next AS (well-known community)\n"
10785 "community number\n"
10786 "Do not send outside local AS (well-known community)\n"
10787 "Do not advertise to any peer (well-known community)\n"
10788 "Do not export to next AS (well-known community)\n"
10789 "Exact match of the communities")
10790
10791ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010792 show_bgp_ipv6_safi_community4_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010793 "show bgp ipv6 (encap|multicast|unicast|vpn) 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",
paul718e3742002-12-13 20:15:29 +000010794 SHOW_STR
10795 BGP_STR
10796 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010797 "Address family modifier\n"
10798 "Address family modifier\n"
10799 "Address family modifier\n"
10800 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010801 "Display routes matching the communities\n"
10802 "community number\n"
10803 "Do not send outside local AS (well-known community)\n"
10804 "Do not advertise to any peer (well-known community)\n"
10805 "Do not export to next AS (well-known community)\n"
10806 "community number\n"
10807 "Do not send outside local AS (well-known community)\n"
10808 "Do not advertise to any peer (well-known community)\n"
10809 "Do not export to next AS (well-known community)\n"
10810 "community number\n"
10811 "Do not send outside local AS (well-known community)\n"
10812 "Do not advertise to any peer (well-known community)\n"
10813 "Do not export to next AS (well-known community)\n"
10814 "community number\n"
10815 "Do not send outside local AS (well-known community)\n"
10816 "Do not advertise to any peer (well-known community)\n"
10817 "Do not export to next AS (well-known community)\n"
10818 "Exact match of the communities")
10819
paul94f2b392005-06-28 12:44:16 +000010820static int
paulfd79ac92004-10-13 05:06:08 +000010821bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040010822 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000010823{
10824 struct community_list *list;
10825
hassofee6e4e2005-02-02 16:29:31 +000010826 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010827 if (list == NULL)
10828 {
10829 vty_out (vty, "%% %s is not a valid community-list name%s", com,
10830 VTY_NEWLINE);
10831 return CMD_WARNING;
10832 }
10833
ajs5a646652004-11-05 01:25:55 +000010834 return bgp_show (vty, NULL, afi, safi,
10835 (exact ? bgp_show_type_community_list_exact :
10836 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000010837}
10838
Lou Bergerf9b6c392016-01-12 13:42:09 -050010839DEFUN (show_ip_bgp_community_list,
10840 show_ip_bgp_community_list_cmd,
10841 "show ip bgp community-list (<1-500>|WORD)",
10842 SHOW_STR
10843 IP_STR
10844 BGP_STR
10845 "Display routes matching the community-list\n"
10846 "community-list number\n"
10847 "community-list name\n")
10848{
10849 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
10850}
10851
10852DEFUN (show_ip_bgp_ipv4_community_list,
10853 show_ip_bgp_ipv4_community_list_cmd,
10854 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10855 SHOW_STR
10856 IP_STR
10857 BGP_STR
10858 "Address family\n"
10859 "Address Family modifier\n"
10860 "Address Family modifier\n"
10861 "Display routes matching the community-list\n"
10862 "community-list number\n"
10863 "community-list name\n")
10864{
10865 if (strncmp (argv[0], "m", 1) == 0)
10866 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
10867
10868 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
10869}
10870
10871DEFUN (show_ip_bgp_community_list_exact,
10872 show_ip_bgp_community_list_exact_cmd,
10873 "show ip bgp community-list (<1-500>|WORD) exact-match",
10874 SHOW_STR
10875 IP_STR
10876 BGP_STR
10877 "Display routes matching the community-list\n"
10878 "community-list number\n"
10879 "community-list name\n"
10880 "Exact match of the communities\n")
10881{
10882 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
10883}
10884
10885DEFUN (show_ip_bgp_ipv4_community_list_exact,
10886 show_ip_bgp_ipv4_community_list_exact_cmd,
10887 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10888 SHOW_STR
10889 IP_STR
10890 BGP_STR
10891 "Address family\n"
10892 "Address Family modifier\n"
10893 "Address Family modifier\n"
10894 "Display routes matching the community-list\n"
10895 "community-list number\n"
10896 "community-list name\n"
10897 "Exact match of the communities\n")
10898{
10899 if (strncmp (argv[0], "m", 1) == 0)
10900 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
10901
10902 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
10903}
10904
Lou Bergerf9b6c392016-01-12 13:42:09 -050010905DEFUN (show_bgp_community_list,
10906 show_bgp_community_list_cmd,
10907 "show bgp community-list (<1-500>|WORD)",
10908 SHOW_STR
10909 BGP_STR
10910 "Display routes matching the community-list\n"
10911 "community-list number\n"
10912 "community-list name\n")
10913{
10914 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10915}
10916
10917ALIAS (show_bgp_community_list,
10918 show_bgp_ipv6_community_list_cmd,
10919 "show bgp ipv6 community-list (<1-500>|WORD)",
10920 SHOW_STR
10921 BGP_STR
10922 "Address family\n"
10923 "Display routes matching the community-list\n"
10924 "community-list number\n"
10925 "community-list name\n")
10926
10927/* old command */
10928DEFUN (show_ipv6_bgp_community_list,
10929 show_ipv6_bgp_community_list_cmd,
10930 "show ipv6 bgp community-list WORD",
10931 SHOW_STR
10932 IPV6_STR
10933 BGP_STR
10934 "Display routes matching the community-list\n"
10935 "community-list name\n")
10936{
10937 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10938}
10939
10940/* old command */
10941DEFUN (show_ipv6_mbgp_community_list,
10942 show_ipv6_mbgp_community_list_cmd,
10943 "show ipv6 mbgp community-list WORD",
10944 SHOW_STR
10945 IPV6_STR
10946 MBGP_STR
10947 "Display routes matching the community-list\n"
10948 "community-list name\n")
10949{
10950 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
10951}
10952
10953DEFUN (show_bgp_community_list_exact,
10954 show_bgp_community_list_exact_cmd,
10955 "show bgp community-list (<1-500>|WORD) exact-match",
10956 SHOW_STR
10957 BGP_STR
10958 "Display routes matching the community-list\n"
10959 "community-list number\n"
10960 "community-list name\n"
10961 "Exact match of the communities\n")
10962{
10963 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10964}
10965
10966ALIAS (show_bgp_community_list_exact,
10967 show_bgp_ipv6_community_list_exact_cmd,
10968 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10969 SHOW_STR
10970 BGP_STR
10971 "Address family\n"
10972 "Display routes matching the community-list\n"
10973 "community-list number\n"
10974 "community-list name\n"
10975 "Exact match of the communities\n")
10976
10977/* old command */
10978DEFUN (show_ipv6_bgp_community_list_exact,
10979 show_ipv6_bgp_community_list_exact_cmd,
10980 "show ipv6 bgp community-list WORD exact-match",
10981 SHOW_STR
10982 IPV6_STR
10983 BGP_STR
10984 "Display routes matching the community-list\n"
10985 "community-list name\n"
10986 "Exact match of the communities\n")
10987{
10988 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10989}
10990
10991/* old command */
10992DEFUN (show_ipv6_mbgp_community_list_exact,
10993 show_ipv6_mbgp_community_list_exact_cmd,
10994 "show ipv6 mbgp community-list WORD exact-match",
10995 SHOW_STR
10996 IPV6_STR
10997 MBGP_STR
10998 "Display routes matching the community-list\n"
10999 "community-list name\n"
11000 "Exact match of the communities\n")
11001{
11002 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
11003}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011004
Lou Berger651b4022016-01-12 13:42:07 -050011005DEFUN (show_bgp_ipv4_community_list,
11006 show_bgp_ipv4_community_list_cmd,
11007 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011008 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011009 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011010 IP_STR
paul718e3742002-12-13 20:15:29 +000011011 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011012 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011013 "community-list name\n")
11014{
11015 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11016}
11017
Lou Berger651b4022016-01-12 13:42:07 -050011018DEFUN (show_bgp_ipv4_safi_community_list,
11019 show_bgp_ipv4_safi_community_list_cmd,
11020 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011021 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011022 BGP_STR
11023 "Address family\n"
11024 "Address Family modifier\n"
11025 "Address Family modifier\n"
11026 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011027 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011028 "community-list name\n")
11029{
11030 if (strncmp (argv[0], "m", 1) == 0)
11031 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11032
11033 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11034}
11035
Lou Berger651b4022016-01-12 13:42:07 -050011036DEFUN (show_bgp_ipv4_community_list_exact,
11037 show_bgp_ipv4_community_list_exact_cmd,
11038 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011039 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011040 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011041 IP_STR
paul718e3742002-12-13 20:15:29 +000011042 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011043 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011044 "community-list name\n"
11045 "Exact match of the communities\n")
11046{
11047 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11048}
11049
Lou Berger651b4022016-01-12 13:42:07 -050011050DEFUN (show_bgp_ipv4_safi_community_list_exact,
11051 show_bgp_ipv4_safi_community_list_exact_cmd,
11052 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011053 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011054 BGP_STR
11055 "Address family\n"
11056 "Address Family modifier\n"
11057 "Address Family modifier\n"
11058 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011059 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011060 "community-list name\n"
11061 "Exact match of the communities\n")
11062{
11063 if (strncmp (argv[0], "m", 1) == 0)
11064 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11065
11066 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11067}
11068
Lou Bergerf9b6c392016-01-12 13:42:09 -050011069DEFUN (show_bgp_ipv6_safi_community_list,
11070 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011071 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011072 SHOW_STR
11073 BGP_STR
11074 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011075 "Address family modifier\n"
11076 "Address family modifier\n"
11077 "Address family modifier\n"
11078 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011079 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011080 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011081 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011082{
Lou Berger651b4022016-01-12 13:42:07 -050011083 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011084
Lou Berger651b4022016-01-12 13:42:07 -050011085 if (bgp_parse_safi(argv[0], &safi)) {
11086 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11087 return CMD_WARNING;
11088 }
11089 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011090}
11091
Lou Bergerf9b6c392016-01-12 13:42:09 -050011092DEFUN (show_bgp_ipv6_safi_community_list_exact,
11093 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011094 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011095 SHOW_STR
11096 BGP_STR
11097 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011098 "Address family modifier\n"
11099 "Address family modifier\n"
11100 "Address family modifier\n"
11101 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011102 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011103 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011104 "community-list name\n"
11105 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011106{
Lou Berger651b4022016-01-12 13:42:07 -050011107 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011108
Lou Berger651b4022016-01-12 13:42:07 -050011109 if (bgp_parse_safi(argv[0], &safi)) {
11110 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11111 return CMD_WARNING;
11112 }
11113 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011114}
David Lamparter6b0655a2014-06-04 06:53:35 +020011115
paul94f2b392005-06-28 12:44:16 +000011116static int
paulfd79ac92004-10-13 05:06:08 +000011117bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000011118 safi_t safi, enum bgp_show_type type)
11119{
11120 int ret;
11121 struct prefix *p;
11122
11123 p = prefix_new();
11124
11125 ret = str2prefix (prefix, p);
11126 if (! ret)
11127 {
11128 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
11129 return CMD_WARNING;
11130 }
11131
ajs5a646652004-11-05 01:25:55 +000011132 ret = bgp_show (vty, NULL, afi, safi, type, p);
11133 prefix_free(p);
11134 return ret;
paul718e3742002-12-13 20:15:29 +000011135}
11136
Lou Bergerf9b6c392016-01-12 13:42:09 -050011137DEFUN (show_ip_bgp_prefix_longer,
11138 show_ip_bgp_prefix_longer_cmd,
11139 "show ip bgp A.B.C.D/M longer-prefixes",
11140 SHOW_STR
11141 IP_STR
11142 BGP_STR
11143 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11144 "Display route and more specific routes\n")
11145{
11146 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11147 bgp_show_type_prefix_longer);
11148}
11149
11150DEFUN (show_ip_bgp_flap_prefix_longer,
11151 show_ip_bgp_flap_prefix_longer_cmd,
11152 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11153 SHOW_STR
11154 IP_STR
11155 BGP_STR
11156 "Display flap statistics of routes\n"
11157 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11158 "Display route and more specific routes\n")
11159{
11160 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11161 bgp_show_type_flap_prefix_longer);
11162}
11163
11164ALIAS (show_ip_bgp_flap_prefix_longer,
11165 show_ip_bgp_damp_flap_prefix_longer_cmd,
11166 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11167 SHOW_STR
11168 IP_STR
11169 BGP_STR
11170 "Display detailed information about dampening\n"
11171 "Display flap statistics of routes\n"
11172 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11173 "Display route and more specific routes\n")
11174
11175DEFUN (show_ip_bgp_ipv4_prefix_longer,
11176 show_ip_bgp_ipv4_prefix_longer_cmd,
11177 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11178 SHOW_STR
11179 IP_STR
11180 BGP_STR
11181 "Address family\n"
11182 "Address Family modifier\n"
11183 "Address Family modifier\n"
11184 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11185 "Display route and more specific routes\n")
11186{
11187 if (strncmp (argv[0], "m", 1) == 0)
11188 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
11189 bgp_show_type_prefix_longer);
11190
11191 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
11192 bgp_show_type_prefix_longer);
11193}
11194
11195DEFUN (show_ip_bgp_flap_address,
11196 show_ip_bgp_flap_address_cmd,
11197 "show ip bgp flap-statistics A.B.C.D",
11198 SHOW_STR
11199 IP_STR
11200 BGP_STR
11201 "Display flap statistics of routes\n"
11202 "Network in the BGP routing table to display\n")
11203{
11204 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11205 bgp_show_type_flap_address);
11206}
11207
11208ALIAS (show_ip_bgp_flap_address,
11209 show_ip_bgp_damp_flap_address_cmd,
11210 "show ip bgp dampening flap-statistics A.B.C.D",
11211 SHOW_STR
11212 IP_STR
11213 BGP_STR
11214 "Display detailed information about dampening\n"
11215 "Display flap statistics of routes\n"
11216 "Network in the BGP routing table to display\n")
11217
11218DEFUN (show_ip_bgp_flap_prefix,
11219 show_ip_bgp_flap_prefix_cmd,
11220 "show ip bgp flap-statistics A.B.C.D/M",
11221 SHOW_STR
11222 IP_STR
11223 BGP_STR
11224 "Display flap statistics of routes\n"
11225 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11226{
11227 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11228 bgp_show_type_flap_prefix);
11229}
11230
11231ALIAS (show_ip_bgp_flap_prefix,
11232 show_ip_bgp_damp_flap_prefix_cmd,
11233 "show ip bgp dampening flap-statistics A.B.C.D/M",
11234 SHOW_STR
11235 IP_STR
11236 BGP_STR
11237 "Display detailed information about dampening\n"
11238 "Display flap statistics of routes\n"
11239 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11240
Lou Bergerf9b6c392016-01-12 13:42:09 -050011241DEFUN (show_bgp_prefix_longer,
11242 show_bgp_prefix_longer_cmd,
11243 "show bgp X:X::X:X/M longer-prefixes",
11244 SHOW_STR
11245 BGP_STR
11246 "IPv6 prefix <network>/<length>\n"
11247 "Display route and more specific routes\n")
11248{
11249 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11250 bgp_show_type_prefix_longer);
11251}
11252
11253/* old command */
11254DEFUN (show_ipv6_bgp_prefix_longer,
11255 show_ipv6_bgp_prefix_longer_cmd,
11256 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11257 SHOW_STR
11258 IPV6_STR
11259 BGP_STR
11260 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11261 "Display route and more specific routes\n")
11262{
11263 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11264 bgp_show_type_prefix_longer);
11265}
11266
11267/* old command */
11268DEFUN (show_ipv6_mbgp_prefix_longer,
11269 show_ipv6_mbgp_prefix_longer_cmd,
11270 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11271 SHOW_STR
11272 IPV6_STR
11273 MBGP_STR
11274 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11275 "Display route and more specific routes\n")
11276{
11277 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
11278 bgp_show_type_prefix_longer);
11279}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011280
Lou Berger651b4022016-01-12 13:42:07 -050011281DEFUN (show_bgp_ipv4_prefix_longer,
11282 show_bgp_ipv4_prefix_longer_cmd,
11283 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011284 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011285 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011286 IP_STR
paul718e3742002-12-13 20:15:29 +000011287 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11288 "Display route and more specific routes\n")
11289{
11290 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11291 bgp_show_type_prefix_longer);
11292}
11293
Lou Berger651b4022016-01-12 13:42:07 -050011294DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
11295 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
11296 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011297 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011298 BGP_STR
11299 "Address family\n"
11300 "Address Family modifier\n"
11301 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050011302 "Address Family modifier\n"
11303 "Address Family modifier\n"
11304 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000011305 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11306 "Display route and more specific routes\n")
11307{
Lou Berger651b4022016-01-12 13:42:07 -050011308 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011309
Lou Berger651b4022016-01-12 13:42:07 -050011310 if (bgp_parse_safi(argv[0], &safi)) {
11311 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11312 return CMD_WARNING;
11313 }
11314 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11315 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000011316}
11317
Lou Berger651b4022016-01-12 13:42:07 -050011318ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
11319 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
11320 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011321 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011322 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011323 "Address family\n"
11324 "Address Family modifier\n"
11325 "Address Family modifier\n"
11326 "Address Family modifier\n"
11327 "Address Family modifier\n"
11328 "Display detailed information about dampening\n"
11329 "Display flap statistics of routes\n"
11330 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11331 "Display route and more specific routes\n")
11332
Lou Berger651b4022016-01-12 13:42:07 -050011333DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
11334 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
11335 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
11336 SHOW_STR
11337 BGP_STR
11338 "Address family\n"
11339 "Address Family modifier\n"
11340 "Address Family modifier\n"
11341 "Address Family modifier\n"
11342 "Address Family modifier\n"
11343 "Display flap statistics of routes\n"
11344 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11345 "Display route and more specific routes\n")
11346{
11347 safi_t safi;
11348
11349 if (bgp_parse_safi(argv[0], &safi)) {
11350 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11351 return CMD_WARNING;
11352 }
11353 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11354 bgp_show_type_flap_prefix_longer);
11355}
11356ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
11357 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
11358 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
11359 SHOW_STR
11360 BGP_STR
11361 "Address family\n"
11362 "Address Family modifier\n"
11363 "Address Family modifier\n"
11364 "Address Family modifier\n"
11365 "Address Family modifier\n"
11366 "Display detailed information about dampening\n"
11367 "Display flap statistics of routes\n"
11368 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11369 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050011370
11371DEFUN (show_bgp_ipv4_safi_prefix_longer,
11372 show_bgp_ipv4_safi_prefix_longer_cmd,
11373 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
11374 SHOW_STR
11375 BGP_STR
11376 "Address family\n"
11377 "Address Family modifier\n"
11378 "Address Family modifier\n"
11379 "Address Family modifier\n"
11380 "Address Family modifier\n"
11381 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11382 "Display route and more specific routes\n")
11383{
11384 safi_t safi;
11385
11386 if (bgp_parse_safi(argv[0], &safi)) {
11387 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11388 return CMD_WARNING;
11389 }
11390
11391 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11392 bgp_show_type_prefix_longer);
11393}
11394
Lou Berger651b4022016-01-12 13:42:07 -050011395DEFUN (show_bgp_ipv6_safi_prefix_longer,
11396 show_bgp_ipv6_safi_prefix_longer_cmd,
11397 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
11398 SHOW_STR
11399 BGP_STR
11400 "Address family\n"
11401 "Address Family modifier\n"
11402 "Address Family modifier\n"
11403 "Address Family modifier\n"
11404 "Address Family modifier\n"
11405 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11406 "Display route and more specific routes\n")
11407{
11408 safi_t safi;
11409
11410 if (bgp_parse_safi(argv[0], &safi)) {
11411 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11412 return CMD_WARNING;
11413 }
11414
11415 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11416 bgp_show_type_prefix_longer);
11417}
Lou Berger651b4022016-01-12 13:42:07 -050011418
11419DEFUN (show_bgp_ipv4_safi_flap_address,
11420 show_bgp_ipv4_safi_flap_address_cmd,
11421 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
11422 SHOW_STR
11423 BGP_STR
11424 "Address family\n"
11425 "Address Family modifier\n"
11426 "Address Family modifier\n"
11427 "Address Family modifier\n"
11428 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011429 "Display flap statistics of routes\n"
11430 "Network in the BGP routing table to display\n")
11431{
Lou Berger651b4022016-01-12 13:42:07 -050011432 safi_t safi;
11433
11434 if (bgp_parse_safi(argv[0], &safi)) {
11435 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11436 return CMD_WARNING;
11437 }
11438 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011439 bgp_show_type_flap_address);
11440}
Lou Berger651b4022016-01-12 13:42:07 -050011441ALIAS (show_bgp_ipv4_safi_flap_address,
11442 show_bgp_ipv4_safi_damp_flap_address_cmd,
11443 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053011444 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011445 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011446 "Address family\n"
11447 "Address Family modifier\n"
11448 "Address Family modifier\n"
11449 "Address Family modifier\n"
11450 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011451 "Display detailed information about dampening\n"
11452 "Display flap statistics of routes\n"
11453 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050011454
Lou Berger651b4022016-01-12 13:42:07 -050011455DEFUN (show_bgp_ipv6_flap_address,
11456 show_bgp_ipv6_flap_address_cmd,
11457 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000011458 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011459 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011460 "Address family\n"
11461 "Address Family modifier\n"
11462 "Address Family modifier\n"
11463 "Address Family modifier\n"
11464 "Address Family modifier\n"
11465 "Display flap statistics of routes\n"
11466 "Network in the BGP routing table to display\n")
11467{
11468 safi_t safi;
11469
11470 if (bgp_parse_safi(argv[0], &safi)) {
11471 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11472 return CMD_WARNING;
11473 }
11474 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11475 bgp_show_type_flap_address);
11476}
11477ALIAS (show_bgp_ipv6_flap_address,
11478 show_bgp_ipv6_damp_flap_address_cmd,
11479 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
11480 SHOW_STR
11481 BGP_STR
11482 "Address family\n"
11483 "Address Family modifier\n"
11484 "Address Family modifier\n"
11485 "Address Family modifier\n"
11486 "Address Family modifier\n"
11487 "Display detailed information about dampening\n"
11488 "Display flap statistics of routes\n"
11489 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050011490
11491DEFUN (show_bgp_ipv4_safi_flap_prefix,
11492 show_bgp_ipv4_safi_flap_prefix_cmd,
11493 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
11494 SHOW_STR
11495 BGP_STR
11496 "Address family\n"
11497 "Address Family modifier\n"
11498 "Address Family modifier\n"
11499 "Address Family modifier\n"
11500 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011501 "Display flap statistics of routes\n"
11502 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11503{
Lou Berger651b4022016-01-12 13:42:07 -050011504 safi_t safi;
11505
11506 if (bgp_parse_safi(argv[0], &safi)) {
11507 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11508 return CMD_WARNING;
11509 }
11510 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011511 bgp_show_type_flap_prefix);
11512}
Balaji3921cc52015-05-16 23:12:17 +053011513
Lou Berger651b4022016-01-12 13:42:07 -050011514ALIAS (show_bgp_ipv4_safi_flap_prefix,
11515 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
11516 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053011517 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011518 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011519 "Address family\n"
11520 "Address Family modifier\n"
11521 "Address Family modifier\n"
11522 "Address Family modifier\n"
11523 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011524 "Display detailed information about dampening\n"
11525 "Display flap statistics of routes\n"
11526 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11527
Lou Berger651b4022016-01-12 13:42:07 -050011528DEFUN (show_bgp_ipv6_safi_flap_prefix,
11529 show_bgp_ipv6_safi_flap_prefix_cmd,
11530 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000011531 SHOW_STR
11532 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011533 "Address family\n"
11534 "Address Family modifier\n"
11535 "Address Family modifier\n"
11536 "Address Family modifier\n"
11537 "Address Family modifier\n"
11538 "Display flap statistics of routes\n"
11539 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000011540{
Lou Berger651b4022016-01-12 13:42:07 -050011541 safi_t safi;
11542
11543 if (bgp_parse_safi(argv[0], &safi)) {
11544 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11545 return CMD_WARNING;
11546 }
11547 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
11548 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000011549}
11550
Lou Berger651b4022016-01-12 13:42:07 -050011551ALIAS (show_bgp_ipv6_safi_flap_prefix,
11552 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
11553 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
11554 SHOW_STR
11555 BGP_STR
11556 "Address family\n"
11557 "Address Family modifier\n"
11558 "Address Family modifier\n"
11559 "Address Family modifier\n"
11560 "Address Family modifier\n"
11561 "Display detailed information about dampening\n"
11562 "Display flap statistics of routes\n"
11563 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11564
11565DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000011566 show_bgp_ipv6_prefix_longer_cmd,
11567 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11568 SHOW_STR
11569 BGP_STR
11570 "Address family\n"
11571 "IPv6 prefix <network>/<length>\n"
11572 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000011573{
11574 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11575 bgp_show_type_prefix_longer);
11576}
11577
paul94f2b392005-06-28 12:44:16 +000011578static struct peer *
paulfd79ac92004-10-13 05:06:08 +000011579peer_lookup_in_view (struct vty *vty, const char *view_name,
11580 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000011581{
11582 int ret;
11583 struct bgp *bgp;
11584 struct peer *peer;
11585 union sockunion su;
11586
11587 /* BGP structure lookup. */
11588 if (view_name)
11589 {
11590 bgp = bgp_lookup_by_name (view_name);
11591 if (! bgp)
11592 {
11593 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11594 return NULL;
11595 }
11596 }
paul5228ad22004-06-04 17:58:18 +000011597 else
paulbb46e942003-10-24 19:02:03 +000011598 {
11599 bgp = bgp_get_default ();
11600 if (! bgp)
11601 {
11602 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11603 return NULL;
11604 }
11605 }
11606
11607 /* Get peer sockunion. */
11608 ret = str2sockunion (ip_str, &su);
11609 if (ret < 0)
11610 {
11611 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
11612 return NULL;
11613 }
11614
11615 /* Peer structure lookup. */
11616 peer = peer_lookup (bgp, &su);
11617 if (! peer)
11618 {
11619 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
11620 return NULL;
11621 }
11622
11623 return peer;
11624}
David Lamparter6b0655a2014-06-04 06:53:35 +020011625
Paul Jakma2815e612006-09-14 02:56:07 +000011626enum bgp_stats
11627{
11628 BGP_STATS_MAXBITLEN = 0,
11629 BGP_STATS_RIB,
11630 BGP_STATS_PREFIXES,
11631 BGP_STATS_TOTPLEN,
11632 BGP_STATS_UNAGGREGATEABLE,
11633 BGP_STATS_MAX_AGGREGATEABLE,
11634 BGP_STATS_AGGREGATES,
11635 BGP_STATS_SPACE,
11636 BGP_STATS_ASPATH_COUNT,
11637 BGP_STATS_ASPATH_MAXHOPS,
11638 BGP_STATS_ASPATH_TOTHOPS,
11639 BGP_STATS_ASPATH_MAXSIZE,
11640 BGP_STATS_ASPATH_TOTSIZE,
11641 BGP_STATS_ASN_HIGHEST,
11642 BGP_STATS_MAX,
11643};
paulbb46e942003-10-24 19:02:03 +000011644
Paul Jakma2815e612006-09-14 02:56:07 +000011645static const char *table_stats_strs[] =
11646{
11647 [BGP_STATS_PREFIXES] = "Total Prefixes",
11648 [BGP_STATS_TOTPLEN] = "Average prefix length",
11649 [BGP_STATS_RIB] = "Total Advertisements",
11650 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
11651 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
11652 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
11653 [BGP_STATS_SPACE] = "Address space advertised",
11654 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
11655 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
11656 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
11657 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
11658 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
11659 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
11660 [BGP_STATS_MAX] = NULL,
11661};
11662
11663struct bgp_table_stats
11664{
11665 struct bgp_table *table;
11666 unsigned long long counts[BGP_STATS_MAX];
11667};
11668
11669#if 0
11670#define TALLY_SIGFIG 100000
11671static unsigned long
11672ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
11673{
11674 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
11675 unsigned long res = (newtot * TALLY_SIGFIG) / count;
11676 unsigned long ret = newtot / count;
11677
11678 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
11679 return ret + 1;
11680 else
11681 return ret;
11682}
11683#endif
11684
11685static int
11686bgp_table_stats_walker (struct thread *t)
11687{
11688 struct bgp_node *rn;
11689 struct bgp_node *top;
11690 struct bgp_table_stats *ts = THREAD_ARG (t);
11691 unsigned int space = 0;
11692
Paul Jakma53d9f672006-10-15 23:41:16 +000011693 if (!(top = bgp_table_top (ts->table)))
11694 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000011695
11696 switch (top->p.family)
11697 {
11698 case AF_INET:
11699 space = IPV4_MAX_BITLEN;
11700 break;
11701 case AF_INET6:
11702 space = IPV6_MAX_BITLEN;
11703 break;
11704 }
11705
11706 ts->counts[BGP_STATS_MAXBITLEN] = space;
11707
11708 for (rn = top; rn; rn = bgp_route_next (rn))
11709 {
11710 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070011711 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000011712 unsigned int rinum = 0;
11713
11714 if (rn == top)
11715 continue;
11716
11717 if (!rn->info)
11718 continue;
11719
11720 ts->counts[BGP_STATS_PREFIXES]++;
11721 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
11722
11723#if 0
11724 ts->counts[BGP_STATS_AVGPLEN]
11725 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
11726 ts->counts[BGP_STATS_AVGPLEN],
11727 rn->p.prefixlen);
11728#endif
11729
11730 /* check if the prefix is included by any other announcements */
11731 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070011732 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000011733
11734 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000011735 {
11736 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
11737 /* announced address space */
11738 if (space)
11739 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
11740 }
Paul Jakma2815e612006-09-14 02:56:07 +000011741 else if (prn->info)
11742 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
11743
Paul Jakma2815e612006-09-14 02:56:07 +000011744 for (ri = rn->info; ri; ri = ri->next)
11745 {
11746 rinum++;
11747 ts->counts[BGP_STATS_RIB]++;
11748
11749 if (ri->attr &&
11750 (CHECK_FLAG (ri->attr->flag,
11751 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
11752 ts->counts[BGP_STATS_AGGREGATES]++;
11753
11754 /* as-path stats */
11755 if (ri->attr && ri->attr->aspath)
11756 {
11757 unsigned int hops = aspath_count_hops (ri->attr->aspath);
11758 unsigned int size = aspath_size (ri->attr->aspath);
11759 as_t highest = aspath_highest (ri->attr->aspath);
11760
11761 ts->counts[BGP_STATS_ASPATH_COUNT]++;
11762
11763 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
11764 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
11765
11766 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
11767 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
11768
11769 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
11770 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
11771#if 0
11772 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
11773 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11774 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
11775 hops);
11776 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
11777 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11778 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
11779 size);
11780#endif
11781 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
11782 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
11783 }
11784 }
11785 }
11786 return 0;
11787}
11788
11789static int
11790bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
11791{
11792 struct bgp_table_stats ts;
11793 unsigned int i;
11794
11795 if (!bgp->rib[afi][safi])
11796 {
Donald Sharp3c964042016-01-25 23:38:53 -050011797 vty_out (vty, "%% No RIB exists for the specified AFI(%d)/SAFI(%d) %s",
11798 afi, safi, VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011799 return CMD_WARNING;
11800 }
11801
11802 memset (&ts, 0, sizeof (ts));
11803 ts.table = bgp->rib[afi][safi];
11804 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
11805
11806 vty_out (vty, "BGP %s RIB statistics%s%s",
11807 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
11808
11809 for (i = 0; i < BGP_STATS_MAX; i++)
11810 {
11811 if (!table_stats_strs[i])
11812 continue;
11813
11814 switch (i)
11815 {
11816#if 0
11817 case BGP_STATS_ASPATH_AVGHOPS:
11818 case BGP_STATS_ASPATH_AVGSIZE:
11819 case BGP_STATS_AVGPLEN:
11820 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11821 vty_out (vty, "%12.2f",
11822 (float)ts.counts[i] / (float)TALLY_SIGFIG);
11823 break;
11824#endif
11825 case BGP_STATS_ASPATH_TOTHOPS:
11826 case BGP_STATS_ASPATH_TOTSIZE:
11827 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11828 vty_out (vty, "%12.2f",
11829 ts.counts[i] ?
11830 (float)ts.counts[i] /
11831 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
11832 : 0);
11833 break;
11834 case BGP_STATS_TOTPLEN:
11835 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11836 vty_out (vty, "%12.2f",
11837 ts.counts[i] ?
11838 (float)ts.counts[i] /
11839 (float)ts.counts[BGP_STATS_PREFIXES]
11840 : 0);
11841 break;
11842 case BGP_STATS_SPACE:
11843 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11844 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
11845 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
11846 break;
Paul Jakma30a22312008-08-15 14:05:22 +010011847 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000011848 vty_out (vty, "%12.2f%s",
11849 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000011850 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000011851 VTY_NEWLINE);
11852 vty_out (vty, "%30s: ", "/8 equivalent ");
11853 vty_out (vty, "%12.2f%s",
11854 (float)ts.counts[BGP_STATS_SPACE] /
11855 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
11856 VTY_NEWLINE);
11857 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
11858 break;
11859 vty_out (vty, "%30s: ", "/24 equivalent ");
11860 vty_out (vty, "%12.2f",
11861 (float)ts.counts[BGP_STATS_SPACE] /
11862 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
11863 break;
11864 default:
11865 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11866 vty_out (vty, "%12llu", ts.counts[i]);
11867 }
11868
11869 vty_out (vty, "%s", VTY_NEWLINE);
11870 }
11871 return CMD_SUCCESS;
11872}
11873
11874static int
11875bgp_table_stats_vty (struct vty *vty, const char *name,
11876 const char *afi_str, const char *safi_str)
11877{
11878 struct bgp *bgp;
11879 afi_t afi;
11880 safi_t safi;
11881
11882 if (name)
11883 bgp = bgp_lookup_by_name (name);
11884 else
11885 bgp = bgp_get_default ();
11886
11887 if (!bgp)
11888 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011889 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011890 return CMD_WARNING;
11891 }
11892 if (strncmp (afi_str, "ipv", 3) == 0)
11893 {
11894 if (strncmp (afi_str, "ipv4", 4) == 0)
11895 afi = AFI_IP;
11896 else if (strncmp (afi_str, "ipv6", 4) == 0)
11897 afi = AFI_IP6;
11898 else
11899 {
11900 vty_out (vty, "%% Invalid address family %s%s",
11901 afi_str, VTY_NEWLINE);
11902 return CMD_WARNING;
11903 }
Lou Berger298cc2f2016-01-12 13:42:02 -050011904 switch (safi_str[0]) {
11905 case 'm':
11906 safi = SAFI_MULTICAST;
11907 break;
11908 case 'u':
11909 safi = SAFI_UNICAST;
11910 break;
11911 case 'v':
Donald Sharp3c964042016-01-25 23:38:53 -050011912 safi = SAFI_MPLS_VPN;
Lou Berger298cc2f2016-01-12 13:42:02 -050011913 break;
11914 case 'e':
11915 safi = SAFI_ENCAP;
11916 break;
11917 default:
11918 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011919 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050011920 return CMD_WARNING;
11921 }
Paul Jakma2815e612006-09-14 02:56:07 +000011922 }
11923 else
11924 {
Lou Berger298cc2f2016-01-12 13:42:02 -050011925 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011926 afi_str, VTY_NEWLINE);
11927 return CMD_WARNING;
11928 }
11929
Paul Jakma2815e612006-09-14 02:56:07 +000011930 return bgp_table_stats (vty, bgp, afi, safi);
11931}
11932
11933DEFUN (show_bgp_statistics,
11934 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011935 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011936 SHOW_STR
11937 BGP_STR
11938 "Address family\n"
11939 "Address family\n"
11940 "Address Family modifier\n"
11941 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011942 "Address Family modifier\n"
11943 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011944 "BGP RIB advertisement statistics\n")
11945{
11946 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11947}
11948
Lou Bergerf9b6c392016-01-12 13:42:09 -050011949ALIAS (show_bgp_statistics,
11950 show_bgp_statistics_vpnv4_cmd,
11951 "show bgp (ipv4) (vpnv4) statistics",
11952 SHOW_STR
11953 BGP_STR
11954 "Address family\n"
11955 "Address Family modifier\n"
11956 "BGP RIB advertisement statistics\n")
11957
Paul Jakma2815e612006-09-14 02:56:07 +000011958DEFUN (show_bgp_statistics_view,
11959 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011960 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011961 SHOW_STR
11962 BGP_STR
11963 "BGP view\n"
11964 "Address family\n"
11965 "Address family\n"
11966 "Address Family modifier\n"
11967 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011968 "Address Family modifier\n"
11969 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011970 "BGP RIB advertisement statistics\n")
11971{
11972 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11973}
11974
11975ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011976 show_bgp_statistics_view_vpnv4_cmd,
11977 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011978 SHOW_STR
11979 BGP_STR
11980 "BGP view\n"
11981 "Address family\n"
11982 "Address Family modifier\n"
11983 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020011984
Paul Jakmaff7924f2006-09-04 01:10:36 +000011985enum bgp_pcounts
11986{
11987 PCOUNT_ADJ_IN = 0,
11988 PCOUNT_DAMPED,
11989 PCOUNT_REMOVED,
11990 PCOUNT_HISTORY,
11991 PCOUNT_STALE,
11992 PCOUNT_VALID,
11993 PCOUNT_ALL,
11994 PCOUNT_COUNTED,
11995 PCOUNT_PFCNT, /* the figure we display to users */
11996 PCOUNT_MAX,
11997};
11998
11999static const char *pcount_strs[] =
12000{
12001 [PCOUNT_ADJ_IN] = "Adj-in",
12002 [PCOUNT_DAMPED] = "Damped",
12003 [PCOUNT_REMOVED] = "Removed",
12004 [PCOUNT_HISTORY] = "History",
12005 [PCOUNT_STALE] = "Stale",
12006 [PCOUNT_VALID] = "Valid",
12007 [PCOUNT_ALL] = "All RIB",
12008 [PCOUNT_COUNTED] = "PfxCt counted",
12009 [PCOUNT_PFCNT] = "Useable",
12010 [PCOUNT_MAX] = NULL,
12011};
12012
Paul Jakma2815e612006-09-14 02:56:07 +000012013struct peer_pcounts
12014{
12015 unsigned int count[PCOUNT_MAX];
12016 const struct peer *peer;
12017 const struct bgp_table *table;
12018};
12019
Paul Jakmaff7924f2006-09-04 01:10:36 +000012020static int
Paul Jakma2815e612006-09-14 02:56:07 +000012021bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000012022{
12023 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000012024 struct peer_pcounts *pc = THREAD_ARG (t);
12025 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012026
Paul Jakma2815e612006-09-14 02:56:07 +000012027 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012028 {
12029 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000012030 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012031
12032 for (ain = rn->adj_in; ain; ain = ain->next)
12033 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000012034 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012035
Paul Jakmaff7924f2006-09-04 01:10:36 +000012036 for (ri = rn->info; ri; ri = ri->next)
12037 {
12038 char buf[SU_ADDRSTRLEN];
12039
12040 if (ri->peer != peer)
12041 continue;
12042
Paul Jakma2815e612006-09-14 02:56:07 +000012043 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012044
12045 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000012046 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012047 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000012048 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012049 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000012050 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012051 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000012052 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012053 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000012054 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012055 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000012056 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012057
12058 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
12059 {
Paul Jakma2815e612006-09-14 02:56:07 +000012060 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012061 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012062 plog_warn (peer->log,
12063 "%s [pcount] %s/%d is counted but flags 0x%x",
12064 peer->host,
12065 inet_ntop(rn->p.family, &rn->p.u.prefix,
12066 buf, SU_ADDRSTRLEN),
12067 rn->p.prefixlen,
12068 ri->flags);
12069 }
12070 else
12071 {
Paul Jakma1a392d42006-09-07 00:24:49 +000012072 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012073 plog_warn (peer->log,
12074 "%s [pcount] %s/%d not counted but flags 0x%x",
12075 peer->host,
12076 inet_ntop(rn->p.family, &rn->p.u.prefix,
12077 buf, SU_ADDRSTRLEN),
12078 rn->p.prefixlen,
12079 ri->flags);
12080 }
12081 }
12082 }
Paul Jakma2815e612006-09-14 02:56:07 +000012083 return 0;
12084}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012085
Paul Jakma2815e612006-09-14 02:56:07 +000012086static int
12087bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
12088{
12089 struct peer_pcounts pcounts = { .peer = peer };
12090 unsigned int i;
12091
12092 if (!peer || !peer->bgp || !peer->afc[afi][safi]
12093 || !peer->bgp->rib[afi][safi])
12094 {
12095 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12096 return CMD_WARNING;
12097 }
12098
12099 memset (&pcounts, 0, sizeof(pcounts));
12100 pcounts.peer = peer;
12101 pcounts.table = peer->bgp->rib[afi][safi];
12102
12103 /* in-place call via thread subsystem so as to record execution time
12104 * stats for the thread-walk (i.e. ensure this can't be blamed on
12105 * on just vty_read()).
12106 */
12107 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
12108
Paul Jakmaff7924f2006-09-04 01:10:36 +000012109 vty_out (vty, "Prefix counts for %s, %s%s",
12110 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
12111 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
12112 vty_out (vty, "%sCounts from RIB table walk:%s%s",
12113 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12114
12115 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000012116 vty_out (vty, "%20s: %-10d%s",
12117 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012118
Paul Jakma2815e612006-09-14 02:56:07 +000012119 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000012120 {
12121 vty_out (vty, "%s [pcount] PfxCt drift!%s",
12122 peer->host, VTY_NEWLINE);
12123 vty_out (vty, "Please report this bug, with the above command output%s",
12124 VTY_NEWLINE);
12125 }
12126
12127 return CMD_SUCCESS;
12128}
12129
Lou Bergerf9b6c392016-01-12 13:42:09 -050012130DEFUN (show_ip_bgp_neighbor_prefix_counts,
12131 show_ip_bgp_neighbor_prefix_counts_cmd,
12132 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12133 SHOW_STR
12134 IP_STR
12135 BGP_STR
12136 "Detailed information on TCP and BGP neighbor connections\n"
12137 "Neighbor to display information about\n"
12138 "Neighbor to display information about\n"
12139 "Display detailed prefix count information\n")
12140{
12141 struct peer *peer;
12142
12143 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12144 if (! peer)
12145 return CMD_WARNING;
12146
12147 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12148}
12149
Paul Jakmaff7924f2006-09-04 01:10:36 +000012150DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
12151 show_bgp_ipv6_neighbor_prefix_counts_cmd,
12152 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12153 SHOW_STR
12154 BGP_STR
12155 "Address family\n"
12156 "Detailed information on TCP and BGP neighbor connections\n"
12157 "Neighbor to display information about\n"
12158 "Neighbor to display information about\n"
12159 "Display detailed prefix count information\n")
12160{
12161 struct peer *peer;
12162
12163 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12164 if (! peer)
12165 return CMD_WARNING;
12166
12167 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
12168}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012169
12170DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
12171 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
12172 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12173 SHOW_STR
12174 IP_STR
12175 BGP_STR
12176 "Address family\n"
12177 "Address Family modifier\n"
12178 "Address Family modifier\n"
12179 "Detailed information on TCP and BGP neighbor connections\n"
12180 "Neighbor to display information about\n"
12181 "Neighbor to display information about\n"
12182 "Display detailed prefix count information\n")
12183{
12184 struct peer *peer;
12185
12186 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12187 if (! peer)
12188 return CMD_WARNING;
12189
12190 if (strncmp (argv[0], "m", 1) == 0)
12191 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
12192
12193 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12194}
12195
12196DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
12197 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
12198 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12199 SHOW_STR
12200 IP_STR
12201 BGP_STR
12202 "Address family\n"
12203 "Address Family modifier\n"
12204 "Address Family modifier\n"
12205 "Detailed information on TCP and BGP neighbor connections\n"
12206 "Neighbor to display information about\n"
12207 "Neighbor to display information about\n"
12208 "Display detailed prefix count information\n")
12209{
12210 struct peer *peer;
12211
12212 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12213 if (! peer)
12214 return CMD_WARNING;
12215
12216 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
12217}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012218
Lou Berger651b4022016-01-12 13:42:07 -050012219DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
12220 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
12221 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012222 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000012223 BGP_STR
12224 "Address family\n"
12225 "Address Family modifier\n"
12226 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012227 "Address Family modifier\n"
12228 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000012229 "Detailed information on TCP and BGP neighbor connections\n"
12230 "Neighbor to display information about\n"
12231 "Neighbor to display information about\n"
12232 "Display detailed prefix count information\n")
12233{
12234 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012235 safi_t safi;
12236
12237 if (bgp_parse_safi(argv[0], &safi)) {
12238 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12239 return CMD_WARNING;
12240 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000012241
12242 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12243 if (! peer)
12244 return CMD_WARNING;
12245
Lou Berger651b4022016-01-12 13:42:07 -050012246 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012247}
Lou Berger205e6742016-01-12 13:42:11 -050012248
Lou Berger651b4022016-01-12 13:42:07 -050012249DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
12250 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
12251 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12252 SHOW_STR
12253 BGP_STR
12254 "Address family\n"
12255 "Address Family modifier\n"
12256 "Address Family modifier\n"
12257 "Address Family modifier\n"
12258 "Address Family modifier\n"
12259 "Detailed information on TCP and BGP neighbor connections\n"
12260 "Neighbor to display information about\n"
12261 "Neighbor to display information about\n"
12262 "Display detailed prefix count information\n")
12263{
12264 struct peer *peer;
12265 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012266
Lou Berger651b4022016-01-12 13:42:07 -050012267 if (bgp_parse_safi(argv[0], &safi)) {
12268 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12269 return CMD_WARNING;
12270 }
12271
12272 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12273 if (! peer)
12274 return CMD_WARNING;
12275
12276 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
12277}
Lou Berger651b4022016-01-12 13:42:07 -050012278
12279DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
12280 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
12281 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012282 SHOW_STR
12283 IP_STR
12284 BGP_STR
12285 "Address family\n"
12286 "Address Family modifier\n"
12287 "Address Family modifier\n"
12288 "Detailed information on TCP and BGP neighbor connections\n"
12289 "Neighbor to display information about\n"
12290 "Neighbor to display information about\n"
12291 "Display detailed prefix count information\n")
12292{
12293 struct peer *peer;
12294
12295 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12296 if (! peer)
12297 return CMD_WARNING;
12298
Lou Berger651b4022016-01-12 13:42:07 -050012299 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012300}
12301
12302
paul94f2b392005-06-28 12:44:16 +000012303static void
paul718e3742002-12-13 20:15:29 +000012304show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
12305 int in)
12306{
12307 struct bgp_table *table;
12308 struct bgp_adj_in *ain;
12309 struct bgp_adj_out *adj;
12310 unsigned long output_count;
12311 struct bgp_node *rn;
12312 int header1 = 1;
12313 struct bgp *bgp;
12314 int header2 = 1;
12315
paulbb46e942003-10-24 19:02:03 +000012316 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000012317
12318 if (! bgp)
12319 return;
12320
12321 table = bgp->rib[afi][safi];
12322
12323 output_count = 0;
12324
12325 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
12326 PEER_STATUS_DEFAULT_ORIGINATE))
12327 {
12328 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +000012329 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12330 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012331
12332 vty_out (vty, "Originating default network 0.0.0.0%s%s",
12333 VTY_NEWLINE, VTY_NEWLINE);
12334 header1 = 0;
12335 }
12336
12337 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
12338 if (in)
12339 {
12340 for (ain = rn->adj_in; ain; ain = ain->next)
12341 if (ain->peer == peer)
12342 {
12343 if (header1)
12344 {
12345 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +000012346 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12347 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012348 header1 = 0;
12349 }
12350 if (header2)
12351 {
12352 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12353 header2 = 0;
12354 }
12355 if (ain->attr)
12356 {
12357 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
12358 output_count++;
12359 }
12360 }
12361 }
12362 else
12363 {
12364 for (adj = rn->adj_out; adj; adj = adj->next)
12365 if (adj->peer == peer)
12366 {
12367 if (header1)
12368 {
12369 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +000012370 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12371 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012372 header1 = 0;
12373 }
12374 if (header2)
12375 {
12376 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12377 header2 = 0;
12378 }
12379 if (adj->attr)
12380 {
12381 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
12382 output_count++;
12383 }
12384 }
12385 }
12386
12387 if (output_count != 0)
12388 vty_out (vty, "%sTotal number of prefixes %ld%s",
12389 VTY_NEWLINE, output_count, VTY_NEWLINE);
12390}
12391
paul94f2b392005-06-28 12:44:16 +000012392static int
paulbb46e942003-10-24 19:02:03 +000012393peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
12394{
paul718e3742002-12-13 20:15:29 +000012395 if (! peer || ! peer->afc[afi][safi])
12396 {
12397 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12398 return CMD_WARNING;
12399 }
12400
12401 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
12402 {
12403 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
12404 VTY_NEWLINE);
12405 return CMD_WARNING;
12406 }
12407
12408 show_adj_route (vty, peer, afi, safi, in);
12409
12410 return CMD_SUCCESS;
12411}
12412
Lou Bergerf9b6c392016-01-12 13:42:09 -050012413DEFUN (show_ip_bgp_view_neighbor_advertised_route,
12414 show_ip_bgp_view_neighbor_advertised_route_cmd,
12415 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12416 SHOW_STR
12417 IP_STR
12418 BGP_STR
12419 "BGP view\n"
12420 "View name\n"
12421 "Detailed information on TCP and BGP neighbor connections\n"
12422 "Neighbor to display information about\n"
12423 "Neighbor to display information about\n"
12424 "Display the routes advertised to a BGP neighbor\n")
12425{
12426 struct peer *peer;
12427
12428 if (argc == 2)
12429 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12430 else
12431 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12432
12433 if (! peer)
12434 return CMD_WARNING;
12435
12436 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12437}
12438
12439ALIAS (show_ip_bgp_view_neighbor_advertised_route,
12440 show_ip_bgp_neighbor_advertised_route_cmd,
12441 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12442 SHOW_STR
12443 IP_STR
12444 BGP_STR
12445 "Detailed information on TCP and BGP neighbor connections\n"
12446 "Neighbor to display information about\n"
12447 "Neighbor to display information about\n"
12448 "Display the routes advertised to a BGP neighbor\n")
12449
12450DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
12451 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
12452 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12453 SHOW_STR
12454 IP_STR
12455 BGP_STR
12456 "Address family\n"
12457 "Address Family modifier\n"
12458 "Address Family modifier\n"
12459 "Detailed information on TCP and BGP neighbor connections\n"
12460 "Neighbor to display information about\n"
12461 "Neighbor to display information about\n"
12462 "Display the routes advertised to a BGP neighbor\n")
12463{
12464 struct peer *peer;
12465
12466 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12467 if (! peer)
12468 return CMD_WARNING;
12469
12470 if (strncmp (argv[0], "m", 1) == 0)
12471 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
12472
12473 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12474}
12475
Lou Bergerf9b6c392016-01-12 13:42:09 -050012476DEFUN (show_bgp_view_neighbor_advertised_route,
12477 show_bgp_view_neighbor_advertised_route_cmd,
12478 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12479 SHOW_STR
12480 BGP_STR
12481 "BGP view\n"
12482 "View name\n"
12483 "Detailed information on TCP and BGP neighbor connections\n"
12484 "Neighbor to display information about\n"
12485 "Neighbor to display information about\n"
12486 "Display the routes advertised to a BGP neighbor\n")
12487{
12488 struct peer *peer;
12489
12490 if (argc == 2)
12491 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12492 else
12493 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12494
12495 if (! peer)
12496 return CMD_WARNING;
12497
12498 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12499}
12500
12501DEFUN (show_bgp_view_neighbor_received_routes,
12502 show_bgp_view_neighbor_received_routes_cmd,
12503 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12504 SHOW_STR
12505 BGP_STR
12506 "BGP view\n"
12507 "View name\n"
12508 "Detailed information on TCP and BGP neighbor connections\n"
12509 "Neighbor to display information about\n"
12510 "Neighbor to display information about\n"
12511 "Display the received routes from neighbor\n")
12512{
12513 struct peer *peer;
12514
12515 if (argc == 2)
12516 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12517 else
12518 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12519
12520 if (! peer)
12521 return CMD_WARNING;
12522
12523 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12524}
12525
12526ALIAS (show_bgp_view_neighbor_advertised_route,
12527 show_bgp_neighbor_advertised_route_cmd,
12528 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12529 SHOW_STR
12530 BGP_STR
12531 "Detailed information on TCP and BGP neighbor connections\n"
12532 "Neighbor to display information about\n"
12533 "Neighbor to display information about\n"
12534 "Display the routes advertised to a BGP neighbor\n")
12535
12536ALIAS (show_bgp_view_neighbor_advertised_route,
12537 show_bgp_ipv6_neighbor_advertised_route_cmd,
12538 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12539 SHOW_STR
12540 BGP_STR
12541 "Address family\n"
12542 "Detailed information on TCP and BGP neighbor connections\n"
12543 "Neighbor to display information about\n"
12544 "Neighbor to display information about\n"
12545 "Display the routes advertised to a BGP neighbor\n")
12546
12547/* old command */
12548ALIAS (show_bgp_view_neighbor_advertised_route,
12549 ipv6_bgp_neighbor_advertised_route_cmd,
12550 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12551 SHOW_STR
12552 IPV6_STR
12553 BGP_STR
12554 "Detailed information on TCP and BGP neighbor connections\n"
12555 "Neighbor to display information about\n"
12556 "Neighbor to display information about\n"
12557 "Display the routes advertised to a BGP neighbor\n")
12558
12559/* old command */
12560DEFUN (ipv6_mbgp_neighbor_advertised_route,
12561 ipv6_mbgp_neighbor_advertised_route_cmd,
12562 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12563 SHOW_STR
12564 IPV6_STR
12565 MBGP_STR
12566 "Detailed information on TCP and BGP neighbor connections\n"
12567 "Neighbor to display information about\n"
12568 "Neighbor to display information about\n"
12569 "Display the routes advertised to a BGP neighbor\n")
12570{
12571 struct peer *peer;
12572
12573 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12574 if (! peer)
12575 return CMD_WARNING;
12576
12577 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
12578}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012579
12580DEFUN (show_ip_bgp_view_neighbor_received_routes,
12581 show_ip_bgp_view_neighbor_received_routes_cmd,
12582 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12583 SHOW_STR
12584 IP_STR
12585 BGP_STR
12586 "BGP view\n"
12587 "View name\n"
12588 "Detailed information on TCP and BGP neighbor connections\n"
12589 "Neighbor to display information about\n"
12590 "Neighbor to display information about\n"
12591 "Display the received routes from neighbor\n")
12592{
12593 struct peer *peer;
12594
12595 if (argc == 2)
12596 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12597 else
12598 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12599
12600 if (! peer)
12601 return CMD_WARNING;
12602
12603 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12604}
12605
12606ALIAS (show_ip_bgp_view_neighbor_received_routes,
12607 show_ip_bgp_neighbor_received_routes_cmd,
12608 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12609 SHOW_STR
12610 IP_STR
12611 BGP_STR
12612 "Detailed information on TCP and BGP neighbor connections\n"
12613 "Neighbor to display information about\n"
12614 "Neighbor to display information about\n"
12615 "Display the received routes from neighbor\n")
12616
12617ALIAS (show_bgp_view_neighbor_received_routes,
12618 show_bgp_ipv6_neighbor_received_routes_cmd,
12619 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
12620 SHOW_STR
12621 BGP_STR
12622 "Address family\n"
12623 "Detailed information on TCP and BGP neighbor connections\n"
12624 "Neighbor to display information about\n"
12625 "Neighbor to display information about\n"
12626 "Display the received routes from neighbor\n")
12627
12628DEFUN (show_bgp_neighbor_received_prefix_filter,
12629 show_bgp_neighbor_received_prefix_filter_cmd,
12630 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12631 SHOW_STR
12632 BGP_STR
12633 "Detailed information on TCP and BGP neighbor connections\n"
12634 "Neighbor to display information about\n"
12635 "Neighbor to display information about\n"
12636 "Display information received from a BGP neighbor\n"
12637 "Display the prefixlist filter\n")
12638{
12639 char name[BUFSIZ];
12640 union sockunion su;
12641 struct peer *peer;
12642 int count, ret;
12643
12644 ret = str2sockunion (argv[0], &su);
12645 if (ret < 0)
12646 {
12647 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12648 return CMD_WARNING;
12649 }
12650
12651 peer = peer_lookup (NULL, &su);
12652 if (! peer)
12653 return CMD_WARNING;
12654
12655 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12656 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12657 if (count)
12658 {
12659 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12660 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12661 }
12662
12663 return CMD_SUCCESS;
12664}
12665
12666/* old command */
12667ALIAS (show_bgp_view_neighbor_received_routes,
12668 ipv6_bgp_neighbor_received_routes_cmd,
12669 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12670 SHOW_STR
12671 IPV6_STR
12672 BGP_STR
12673 "Detailed information on TCP and BGP neighbor connections\n"
12674 "Neighbor to display information about\n"
12675 "Neighbor to display information about\n"
12676 "Display the received routes from neighbor\n")
12677
12678/* old command */
12679DEFUN (ipv6_mbgp_neighbor_received_routes,
12680 ipv6_mbgp_neighbor_received_routes_cmd,
12681 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12682 SHOW_STR
12683 IPV6_STR
12684 MBGP_STR
12685 "Detailed information on TCP and BGP neighbor connections\n"
12686 "Neighbor to display information about\n"
12687 "Neighbor to display information about\n"
12688 "Display the received routes from neighbor\n")
12689{
12690 struct peer *peer;
12691
12692 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12693 if (! peer)
12694 return CMD_WARNING;
12695
12696 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
12697}
12698
12699DEFUN (show_bgp_view_neighbor_received_prefix_filter,
12700 show_bgp_view_neighbor_received_prefix_filter_cmd,
12701 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12702 SHOW_STR
12703 BGP_STR
12704 "BGP view\n"
12705 "View name\n"
12706 "Detailed information on TCP and BGP neighbor connections\n"
12707 "Neighbor to display information about\n"
12708 "Neighbor to display information about\n"
12709 "Display information received from a BGP neighbor\n"
12710 "Display the prefixlist filter\n")
12711{
12712 char name[BUFSIZ];
12713 union sockunion su;
12714 struct peer *peer;
12715 struct bgp *bgp;
12716 int count, ret;
12717
12718 /* BGP structure lookup. */
12719 bgp = bgp_lookup_by_name (argv[0]);
12720 if (bgp == NULL)
12721 {
12722 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
12723 return CMD_WARNING;
12724 }
12725
12726 ret = str2sockunion (argv[1], &su);
12727 if (ret < 0)
12728 {
12729 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
12730 return CMD_WARNING;
12731 }
12732
12733 peer = peer_lookup (bgp, &su);
12734 if (! peer)
12735 return CMD_WARNING;
12736
12737 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12738 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12739 if (count)
12740 {
12741 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12742 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12743 }
12744
12745 return CMD_SUCCESS;
12746}
12747
12748
12749DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
12750 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
12751 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
12752 SHOW_STR
12753 IP_STR
12754 BGP_STR
12755 "Address family\n"
12756 "Address Family modifier\n"
12757 "Address Family modifier\n"
12758 "Detailed information on TCP and BGP neighbor connections\n"
12759 "Neighbor to display information about\n"
12760 "Neighbor to display information about\n"
12761 "Display the received routes from neighbor\n")
12762{
12763 struct peer *peer;
12764
12765 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12766 if (! peer)
12767 return CMD_WARNING;
12768
12769 if (strncmp (argv[0], "m", 1) == 0)
12770 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
12771
12772 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12773}
12774
Lou Berger651b4022016-01-12 13:42:07 -050012775DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
12776 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
12777 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012778 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012779 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012780 "Address Family modifier\n"
12781 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012782 "Detailed information on TCP and BGP neighbor connections\n"
12783 "Neighbor to display information about\n"
12784 "Neighbor to display information about\n"
12785 "Display the routes advertised to a BGP neighbor\n")
12786{
12787 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012788 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012789
Lou Berger651b4022016-01-12 13:42:07 -050012790 if (bgp_parse_safi(argv[0], &safi)) {
12791 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012792 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050012793 }
paul718e3742002-12-13 20:15:29 +000012794
paulbb46e942003-10-24 19:02:03 +000012795 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12796 if (! peer)
12797 return CMD_WARNING;
12798
Lou Berger651b4022016-01-12 13:42:07 -050012799 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
12800}
Lou Berger205e6742016-01-12 13:42:11 -050012801
Lou Berger651b4022016-01-12 13:42:07 -050012802DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
12803 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
12804 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12805 SHOW_STR
12806 BGP_STR
12807 "Address Family modifier\n"
12808 "Address Family modifier\n"
12809 "Address Family modifier\n"
12810 "Detailed information on TCP and BGP neighbor connections\n"
12811 "Neighbor to display information about\n"
12812 "Neighbor to display information about\n"
12813 "Display the routes advertised to a BGP neighbor\n")
12814{
12815 struct peer *peer;
12816 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000012817
Lou Berger651b4022016-01-12 13:42:07 -050012818 if (bgp_parse_safi(argv[0], &safi)) {
12819 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12820 return CMD_WARNING;
12821 }
12822
12823 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12824 if (! peer)
12825 return CMD_WARNING;
12826
12827 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000012828}
12829
Lou Bergerf9b6c392016-01-12 13:42:09 -050012830DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050012831 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
12832 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000012833 SHOW_STR
12834 BGP_STR
12835 "BGP view\n"
12836 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050012837 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000012838 "Detailed information on TCP and BGP neighbor connections\n"
12839 "Neighbor to display information about\n"
12840 "Neighbor to display information about\n"
12841 "Display the routes advertised to a BGP neighbor\n")
12842{
12843 struct peer *peer;
12844
12845 if (argc == 2)
12846 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12847 else
12848 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12849
12850 if (! peer)
12851 return CMD_WARNING;
12852
12853 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12854}
12855
Lou Bergerf9b6c392016-01-12 13:42:09 -050012856DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050012857 show_bgp_view_ipv6_neighbor_received_routes_cmd,
12858 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000012859 SHOW_STR
12860 BGP_STR
12861 "BGP view\n"
12862 "View name\n"
12863 "Address family\n"
12864 "Detailed information on TCP and BGP neighbor connections\n"
12865 "Neighbor to display information about\n"
12866 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000012867 "Display the received routes from neighbor\n")
12868{
12869 struct peer *peer;
12870
12871 if (argc == 2)
12872 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12873 else
12874 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12875
12876 if (! peer)
12877 return CMD_WARNING;
12878
12879 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12880}
Lou Berger651b4022016-01-12 13:42:07 -050012881
12882DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
12883 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
12884 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012885 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012886 BGP_STR
12887 "Address family\n"
12888 "Address Family modifier\n"
12889 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012890 "Address Family modifier\n"
12891 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000012892 "Detailed information on TCP and BGP neighbor connections\n"
12893 "Neighbor to display information about\n"
12894 "Neighbor to display information about\n"
12895 "Display the received routes from neighbor\n")
12896{
paulbb46e942003-10-24 19:02:03 +000012897 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012898 safi_t safi;
12899
12900 if (bgp_parse_safi(argv[0], &safi)) {
12901 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12902 return CMD_WARNING;
12903 }
paul718e3742002-12-13 20:15:29 +000012904
paulbb46e942003-10-24 19:02:03 +000012905 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12906 if (! peer)
12907 return CMD_WARNING;
12908
Lou Berger651b4022016-01-12 13:42:07 -050012909 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000012910}
Lou Berger205e6742016-01-12 13:42:11 -050012911
Lou Berger651b4022016-01-12 13:42:07 -050012912DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
12913 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
12914 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
12915 SHOW_STR
12916 BGP_STR
12917 "Address family\n"
12918 "Address Family modifier\n"
12919 "Address Family modifier\n"
12920 "Address Family modifier\n"
12921 "Address Family modifier\n"
12922 "Detailed information on TCP and BGP neighbor connections\n"
12923 "Neighbor to display information about\n"
12924 "Neighbor to display information about\n"
12925 "Display the received routes from neighbor\n")
12926{
12927 struct peer *peer;
12928 safi_t safi;
12929
12930 if (bgp_parse_safi(argv[0], &safi)) {
12931 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12932 return CMD_WARNING;
12933 }
12934
12935 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12936 if (! peer)
12937 return CMD_WARNING;
12938
12939 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
12940}
paul718e3742002-12-13 20:15:29 +000012941
Michael Lambert95cbbd22010-07-23 14:43:04 -040012942DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
12943 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040012944 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) (advertised-routes|received-routes)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040012945 SHOW_STR
12946 BGP_STR
12947 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000012948 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012949 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012950 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012951 "Address family modifier\n"
12952 "Address family modifier\n"
12953 "Detailed information on TCP and BGP neighbor connections\n"
12954 "Neighbor to display information about\n"
12955 "Neighbor to display information about\n"
12956 "Display the advertised routes to neighbor\n"
12957 "Display the received routes from neighbor\n")
12958{
12959 int afi;
12960 int safi;
12961 int in;
12962 struct peer *peer;
12963
David Lamparter94bad672015-03-03 08:52:22 +010012964 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040012965
12966 if (! peer)
12967 return CMD_WARNING;
12968
Michael Lambert95cbbd22010-07-23 14:43:04 -040012969 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12970 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12971 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040012972
12973 return peer_adj_routes (vty, peer, afi, safi, in);
12974}
12975
Lou Bergerf9b6c392016-01-12 13:42:09 -050012976DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
12977 show_ip_bgp_neighbor_received_prefix_filter_cmd,
12978 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12979 SHOW_STR
12980 IP_STR
12981 BGP_STR
12982 "Detailed information on TCP and BGP neighbor connections\n"
12983 "Neighbor to display information about\n"
12984 "Neighbor to display information about\n"
12985 "Display information received from a BGP neighbor\n"
12986 "Display the prefixlist filter\n")
12987{
12988 char name[BUFSIZ];
12989 union sockunion su;
12990 struct peer *peer;
12991 int count, ret;
12992
12993 ret = str2sockunion (argv[0], &su);
12994 if (ret < 0)
12995 {
12996 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12997 return CMD_WARNING;
12998 }
12999
13000 peer = peer_lookup (NULL, &su);
13001 if (! peer)
13002 return CMD_WARNING;
13003
13004 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13005 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13006 if (count)
13007 {
13008 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13009 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13010 }
13011
13012 return CMD_SUCCESS;
13013}
13014
13015DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
13016 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
13017 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13018 SHOW_STR
13019 IP_STR
13020 BGP_STR
13021 "Address family\n"
13022 "Address Family modifier\n"
13023 "Address Family modifier\n"
13024 "Detailed information on TCP and BGP neighbor connections\n"
13025 "Neighbor to display information about\n"
13026 "Neighbor to display information about\n"
13027 "Display information received from a BGP neighbor\n"
13028 "Display the prefixlist filter\n")
13029{
13030 char name[BUFSIZ];
13031 union sockunion su;
13032 struct peer *peer;
13033 int count, ret;
13034
13035 ret = str2sockunion (argv[1], &su);
13036 if (ret < 0)
13037 {
13038 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13039 return CMD_WARNING;
13040 }
13041
13042 peer = peer_lookup (NULL, &su);
13043 if (! peer)
13044 return CMD_WARNING;
13045
13046 if (strncmp (argv[0], "m", 1) == 0)
13047 {
13048 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
13049 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13050 if (count)
13051 {
13052 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
13053 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13054 }
13055 }
13056 else
13057 {
13058 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13059 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13060 if (count)
13061 {
13062 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13063 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13064 }
13065 }
13066
13067 return CMD_SUCCESS;
13068}
13069
13070ALIAS (show_bgp_view_neighbor_received_routes,
13071 show_bgp_neighbor_received_routes_cmd,
13072 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13073 SHOW_STR
13074 BGP_STR
13075 "Detailed information on TCP and BGP neighbor connections\n"
13076 "Neighbor to display information about\n"
13077 "Neighbor to display information about\n"
13078 "Display the received routes from neighbor\n")
13079
Lou Berger651b4022016-01-12 13:42:07 -050013080DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
13081 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
13082 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013083 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013084 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013085 IP_STR
13086 "Address Family modifier\n"
13087 "Address Family modifier\n"
13088 "Address Family modifier\n"
13089 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013090 "Detailed information on TCP and BGP neighbor connections\n"
13091 "Neighbor to display information about\n"
13092 "Neighbor to display information about\n"
13093 "Display information received from a BGP neighbor\n"
13094 "Display the prefixlist filter\n")
13095{
13096 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013097 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013098 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013099 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050013100 safi_t safi;
paul718e3742002-12-13 20:15:29 +000013101
Lou Berger651b4022016-01-12 13:42:07 -050013102 if (bgp_parse_safi(argv[0], &safi)) {
13103 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013104 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013105 }
paul718e3742002-12-13 20:15:29 +000013106
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013107 ret = str2sockunion (argv[1], &su);
13108 if (ret < 0)
13109 {
13110 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13111 return CMD_WARNING;
13112 }
paul718e3742002-12-13 20:15:29 +000013113
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013114 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013115 if (! peer)
13116 return CMD_WARNING;
13117
Lou Berger651b4022016-01-12 13:42:07 -050013118 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
13119 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13120 if (count) {
13121 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
13122 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13123 }
paul718e3742002-12-13 20:15:29 +000013124
13125 return CMD_SUCCESS;
13126}
Lou Berger205e6742016-01-12 13:42:11 -050013127
Lou Berger651b4022016-01-12 13:42:07 -050013128DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
13129 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
13130 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013131 SHOW_STR
13132 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013133 IP_STR
13134 "Address Family modifier\n"
13135 "Address Family modifier\n"
13136 "Address Family modifier\n"
13137 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013138 "Detailed information on TCP and BGP neighbor connections\n"
13139 "Neighbor to display information about\n"
13140 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050013141 "Display information received from a BGP neighbor\n"
13142 "Display the prefixlist filter\n")
13143{
13144 char name[BUFSIZ];
13145 union sockunion su;
13146 struct peer *peer;
13147 int count, ret;
13148 safi_t safi;
13149
13150 if (bgp_parse_safi(argv[0], &safi)) {
13151 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13152 return CMD_WARNING;
13153 }
13154
13155 ret = str2sockunion (argv[1], &su);
13156 if (ret < 0)
13157 {
13158 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13159 return CMD_WARNING;
13160 }
13161
13162 peer = peer_lookup (NULL, &su);
13163 if (! peer)
13164 return CMD_WARNING;
13165
13166 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
13167 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13168 if (count) {
13169 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
13170 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13171 }
13172
13173 return CMD_SUCCESS;
13174}
paul718e3742002-12-13 20:15:29 +000013175
Lou Bergerf9b6c392016-01-12 13:42:09 -050013176DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013177 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
13178 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013179 SHOW_STR
13180 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013181 "Address family\n"
paul718e3742002-12-13 20:15:29 +000013182 "Detailed information on TCP and BGP neighbor connections\n"
13183 "Neighbor to display information about\n"
13184 "Neighbor to display information about\n"
13185 "Display information received from a BGP neighbor\n"
13186 "Display the prefixlist filter\n")
13187{
13188 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013189 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013190 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013191 int count, ret;
paul718e3742002-12-13 20:15:29 +000013192
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013193 ret = str2sockunion (argv[0], &su);
13194 if (ret < 0)
13195 {
13196 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13197 return CMD_WARNING;
13198 }
paul718e3742002-12-13 20:15:29 +000013199
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013200 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013201 if (! peer)
13202 return CMD_WARNING;
13203
13204 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13205 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13206 if (count)
13207 {
13208 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13209 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13210 }
13211
13212 return CMD_SUCCESS;
13213}
13214
Lou Bergerf9b6c392016-01-12 13:42:09 -050013215DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013216 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
13217 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000013218 SHOW_STR
13219 BGP_STR
13220 "BGP view\n"
13221 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013222 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013223 "Detailed information on TCP and BGP neighbor connections\n"
13224 "Neighbor to display information about\n"
13225 "Neighbor to display information about\n"
13226 "Display information received from a BGP neighbor\n"
13227 "Display the prefixlist filter\n")
13228{
13229 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013230 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000013231 struct peer *peer;
13232 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013233 int count, ret;
paulbb46e942003-10-24 19:02:03 +000013234
13235 /* BGP structure lookup. */
13236 bgp = bgp_lookup_by_name (argv[0]);
13237 if (bgp == NULL)
13238 {
13239 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13240 return CMD_WARNING;
13241 }
13242
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013243 ret = str2sockunion (argv[1], &su);
13244 if (ret < 0)
13245 {
13246 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13247 return CMD_WARNING;
13248 }
paulbb46e942003-10-24 19:02:03 +000013249
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013250 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000013251 if (! peer)
13252 return CMD_WARNING;
13253
13254 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13255 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13256 if (count)
13257 {
13258 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13259 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13260 }
13261
13262 return CMD_SUCCESS;
13263}
David Lamparter6b0655a2014-06-04 06:53:35 +020013264
paul94f2b392005-06-28 12:44:16 +000013265static int
paulbb46e942003-10-24 19:02:03 +000013266bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000013267 safi_t safi, enum bgp_show_type type)
13268{
paul718e3742002-12-13 20:15:29 +000013269 if (! peer || ! peer->afc[afi][safi])
13270 {
13271 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013272 return CMD_WARNING;
13273 }
13274
ajs5a646652004-11-05 01:25:55 +000013275 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000013276}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013277DEFUN (show_ip_bgp_neighbor_routes,
13278 show_ip_bgp_neighbor_routes_cmd,
13279 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
13280 SHOW_STR
13281 IP_STR
13282 BGP_STR
13283 "Detailed information on TCP and BGP neighbor connections\n"
13284 "Neighbor to display information about\n"
13285 "Neighbor to display information about\n"
13286 "Display routes learned from neighbor\n")
13287{
13288 struct peer *peer;
13289
13290 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13291 if (! peer)
13292 return CMD_WARNING;
13293
13294 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13295 bgp_show_type_neighbor);
13296}
13297
13298DEFUN (show_ip_bgp_neighbor_flap,
13299 show_ip_bgp_neighbor_flap_cmd,
13300 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
13301 SHOW_STR
13302 IP_STR
13303 BGP_STR
13304 "Detailed information on TCP and BGP neighbor connections\n"
13305 "Neighbor to display information about\n"
13306 "Neighbor to display information about\n"
13307 "Display flap statistics of the routes learned from neighbor\n")
13308{
13309 struct peer *peer;
13310
13311 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13312 if (! peer)
13313 return CMD_WARNING;
13314
13315 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13316 bgp_show_type_flap_neighbor);
13317}
13318
13319DEFUN (show_ip_bgp_neighbor_damp,
13320 show_ip_bgp_neighbor_damp_cmd,
13321 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13322 SHOW_STR
13323 IP_STR
13324 BGP_STR
13325 "Detailed information on TCP and BGP neighbor connections\n"
13326 "Neighbor to display information about\n"
13327 "Neighbor to display information about\n"
13328 "Display the dampened routes received from neighbor\n")
13329{
13330 struct peer *peer;
13331
13332 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13333 if (! peer)
13334 return CMD_WARNING;
13335
13336 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13337 bgp_show_type_damp_neighbor);
13338}
13339
13340DEFUN (show_ip_bgp_ipv4_neighbor_routes,
13341 show_ip_bgp_ipv4_neighbor_routes_cmd,
13342 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
13343 SHOW_STR
13344 IP_STR
13345 BGP_STR
13346 "Address family\n"
13347 "Address Family modifier\n"
13348 "Address Family modifier\n"
13349 "Detailed information on TCP and BGP neighbor connections\n"
13350 "Neighbor to display information about\n"
13351 "Neighbor to display information about\n"
13352 "Display routes learned from neighbor\n")
13353{
13354 struct peer *peer;
13355
13356 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13357 if (! peer)
13358 return CMD_WARNING;
13359
13360 if (strncmp (argv[0], "m", 1) == 0)
13361 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
13362 bgp_show_type_neighbor);
13363
13364 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13365 bgp_show_type_neighbor);
13366}
13367
13368DEFUN (show_ip_bgp_view_rsclient,
13369 show_ip_bgp_view_rsclient_cmd,
13370 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
13371 SHOW_STR
13372 IP_STR
13373 BGP_STR
13374 "BGP view\n"
13375 "View name\n"
13376 "Information about Route Server Client\n"
13377 NEIGHBOR_ADDR_STR)
13378{
13379 struct bgp_table *table;
13380 struct peer *peer;
13381
13382 if (argc == 2)
13383 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13384 else
13385 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13386
13387 if (! peer)
13388 return CMD_WARNING;
13389
13390 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13391 {
13392 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13393 VTY_NEWLINE);
13394 return CMD_WARNING;
13395 }
13396
13397 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13398 PEER_FLAG_RSERVER_CLIENT))
13399 {
13400 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13401 VTY_NEWLINE);
13402 return CMD_WARNING;
13403 }
13404
13405 table = peer->rib[AFI_IP][SAFI_UNICAST];
13406
13407 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13408}
13409
13410ALIAS (show_ip_bgp_view_rsclient,
13411 show_ip_bgp_rsclient_cmd,
13412 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
13413 SHOW_STR
13414 IP_STR
13415 BGP_STR
13416 "Information about Route Server Client\n"
13417 NEIGHBOR_ADDR_STR)
13418
13419DEFUN (show_bgp_view_ipv4_safi_rsclient,
13420 show_bgp_view_ipv4_safi_rsclient_cmd,
13421 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13422 SHOW_STR
13423 BGP_STR
13424 "BGP view\n"
13425 "View name\n"
13426 "Address family\n"
13427 "Address Family modifier\n"
13428 "Address Family modifier\n"
13429 "Information about Route Server Client\n"
13430 NEIGHBOR_ADDR_STR)
13431{
13432 struct bgp_table *table;
13433 struct peer *peer;
13434 safi_t safi;
13435
13436 if (argc == 3) {
13437 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13438 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13439 } else {
13440 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13441 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13442 }
13443
13444 if (! peer)
13445 return CMD_WARNING;
13446
13447 if (! peer->afc[AFI_IP][safi])
13448 {
13449 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13450 VTY_NEWLINE);
13451 return CMD_WARNING;
13452 }
13453
13454 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13455 PEER_FLAG_RSERVER_CLIENT))
13456 {
13457 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13458 VTY_NEWLINE);
13459 return CMD_WARNING;
13460 }
13461
13462 table = peer->rib[AFI_IP][safi];
13463
13464 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13465}
13466
13467ALIAS (show_bgp_view_ipv4_safi_rsclient,
13468 show_bgp_ipv4_safi_rsclient_cmd,
13469 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13470 SHOW_STR
13471 BGP_STR
13472 "Address family\n"
13473 "Address Family modifier\n"
13474 "Address Family modifier\n"
13475 "Information about Route Server Client\n"
13476 NEIGHBOR_ADDR_STR)
13477
13478DEFUN (show_ip_bgp_view_rsclient_route,
13479 show_ip_bgp_view_rsclient_route_cmd,
13480 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13481 SHOW_STR
13482 IP_STR
13483 BGP_STR
13484 "BGP view\n"
13485 "View name\n"
13486 "Information about Route Server Client\n"
13487 NEIGHBOR_ADDR_STR
13488 "Network in the BGP routing table to display\n")
13489{
13490 struct bgp *bgp;
13491 struct peer *peer;
13492
13493 /* BGP structure lookup. */
13494 if (argc == 3)
13495 {
13496 bgp = bgp_lookup_by_name (argv[0]);
13497 if (bgp == NULL)
13498 {
13499 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13500 return CMD_WARNING;
13501 }
13502 }
13503 else
13504 {
13505 bgp = bgp_get_default ();
13506 if (bgp == NULL)
13507 {
13508 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13509 return CMD_WARNING;
13510 }
13511 }
13512
13513 if (argc == 3)
13514 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13515 else
13516 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13517
13518 if (! peer)
13519 return CMD_WARNING;
13520
13521 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13522 {
13523 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13524 VTY_NEWLINE);
13525 return CMD_WARNING;
13526}
13527
13528 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13529 PEER_FLAG_RSERVER_CLIENT))
13530 {
13531 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13532 VTY_NEWLINE);
13533 return CMD_WARNING;
13534 }
13535
13536 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13537 (argc == 3) ? argv[2] : argv[1],
13538 AFI_IP, SAFI_UNICAST, NULL, 0);
13539}
13540
13541ALIAS (show_ip_bgp_view_rsclient_route,
13542 show_ip_bgp_rsclient_route_cmd,
13543 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13544 SHOW_STR
13545 IP_STR
13546 BGP_STR
13547 "Information about Route Server Client\n"
13548 NEIGHBOR_ADDR_STR
13549 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000013550
Lou Berger651b4022016-01-12 13:42:07 -050013551DEFUN (show_bgp_ipv4_safi_neighbor_flap,
13552 show_bgp_ipv4_safi_neighbor_flap_cmd,
13553 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013554 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013555 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013556 "Address Family Modifier\n"
13557 "Address Family Modifier\n"
13558 "Address Family Modifier\n"
13559 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013560 "Detailed information on TCP and BGP neighbor connections\n"
13561 "Neighbor to display information about\n"
13562 "Neighbor to display information about\n"
13563 "Display flap statistics of the routes learned from neighbor\n")
13564{
paulbb46e942003-10-24 19:02:03 +000013565 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013566 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013567
Lou Berger651b4022016-01-12 13:42:07 -050013568 if (bgp_parse_safi(argv[0], &safi)) {
13569 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13570 return CMD_WARNING;
13571 }
13572
13573 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013574 if (! peer)
13575 return CMD_WARNING;
13576
Lou Berger651b4022016-01-12 13:42:07 -050013577 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013578 bgp_show_type_flap_neighbor);
13579}
Lou Berger205e6742016-01-12 13:42:11 -050013580
Lou Berger651b4022016-01-12 13:42:07 -050013581DEFUN (show_bgp_ipv6_safi_neighbor_flap,
13582 show_bgp_ipv6_safi_neighbor_flap_cmd,
13583 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013584 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013585 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013586 "Address Family Modifier\n"
13587 "Address Family Modifier\n"
13588 "Address Family Modifier\n"
13589 "Address Family Modifier\n"
13590 "Detailed information on TCP and BGP neighbor connections\n"
13591 "Neighbor to display information about\n"
13592 "Neighbor to display information about\n"
13593 "Display flap statistics of the routes learned from neighbor\n")
13594{
13595 struct peer *peer;
13596 safi_t safi;
13597
13598 if (bgp_parse_safi(argv[0], &safi)) {
13599 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13600 return CMD_WARNING;
13601 }
13602
13603 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13604 if (! peer)
13605 return CMD_WARNING;
13606
13607 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13608 bgp_show_type_flap_neighbor);
13609}
Lou Berger651b4022016-01-12 13:42:07 -050013610
13611DEFUN (show_bgp_ipv4_safi_neighbor_damp,
13612 show_bgp_ipv4_safi_neighbor_damp_cmd,
13613 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13614 SHOW_STR
13615 BGP_STR
13616 "Address Family Modifier\n"
13617 "Address Family Modifier\n"
13618 "Address Family Modifier\n"
13619 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013620 "Detailed information on TCP and BGP neighbor connections\n"
13621 "Neighbor to display information about\n"
13622 "Neighbor to display information about\n"
13623 "Display the dampened routes received from neighbor\n")
13624{
paulbb46e942003-10-24 19:02:03 +000013625 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013626 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013627
Lou Berger651b4022016-01-12 13:42:07 -050013628 if (bgp_parse_safi(argv[0], &safi)) {
13629 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13630 return CMD_WARNING;
13631 }
13632
13633 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013634 if (! peer)
13635 return CMD_WARNING;
13636
Lou Berger651b4022016-01-12 13:42:07 -050013637 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013638 bgp_show_type_damp_neighbor);
13639}
Lou Berger205e6742016-01-12 13:42:11 -050013640
Lou Berger651b4022016-01-12 13:42:07 -050013641DEFUN (show_bgp_ipv6_safi_neighbor_damp,
13642 show_bgp_ipv6_safi_neighbor_damp_cmd,
13643 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000013644 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050013645 BGP_STR
13646 "Address Family Modifier\n"
13647 "Address Family Modifier\n"
13648 "Address Family Modifier\n"
13649 "Address Family Modifier\n"
13650 "Detailed information on TCP and BGP neighbor connections\n"
13651 "Neighbor to display information about\n"
13652 "Neighbor to display information about\n"
13653 "Display the dampened routes received from neighbor\n")
13654{
13655 struct peer *peer;
13656 safi_t safi;
13657
13658 if (bgp_parse_safi(argv[0], &safi)) {
13659 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13660 return CMD_WARNING;
13661 }
13662
13663 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13664 if (! peer)
13665 return CMD_WARNING;
13666
13667 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13668 bgp_show_type_damp_neighbor);
13669}
Lou Berger651b4022016-01-12 13:42:07 -050013670
13671DEFUN (show_bgp_ipv4_safi_neighbor_routes,
13672 show_bgp_ipv4_safi_neighbor_routes_cmd,
13673 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
13674 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013675 BGP_STR
13676 "Address family\n"
13677 "Address Family modifier\n"
13678 "Address Family modifier\n"
13679 "Detailed information on TCP and BGP neighbor connections\n"
13680 "Neighbor to display information about\n"
13681 "Neighbor to display information about\n"
13682 "Display routes learned from neighbor\n")
13683{
paulbb46e942003-10-24 19:02:03 +000013684 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013685 safi_t safi;
13686
13687 if (bgp_parse_safi(argv[0], &safi)) {
13688 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13689 return CMD_WARNING;
13690 }
paulbb46e942003-10-24 19:02:03 +000013691
13692 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13693 if (! peer)
13694 return CMD_WARNING;
13695
Lou Berger651b4022016-01-12 13:42:07 -050013696 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013697 bgp_show_type_neighbor);
13698}
Lou Berger205e6742016-01-12 13:42:11 -050013699
Lou Berger651b4022016-01-12 13:42:07 -050013700DEFUN (show_bgp_ipv6_safi_neighbor_routes,
13701 show_bgp_ipv6_safi_neighbor_routes_cmd,
13702 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000013703 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000013704 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013705 "Address family\n"
13706 "Address Family modifier\n"
13707 "Address Family modifier\n"
13708 "Detailed information on TCP and BGP neighbor connections\n"
13709 NEIGHBOR_ADDR_STR
13710 NEIGHBOR_ADDR_STR
13711 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000013712{
paulfee0f4c2004-09-13 05:12:46 +000013713 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013714 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000013715
Lou Berger651b4022016-01-12 13:42:07 -050013716 if (bgp_parse_safi(argv[0], &safi)) {
13717 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13718 return CMD_WARNING;
13719 }
paulfee0f4c2004-09-13 05:12:46 +000013720
Lou Berger651b4022016-01-12 13:42:07 -050013721 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000013722 if (! peer)
13723 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013724
13725 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13726 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000013727}
paulfee0f4c2004-09-13 05:12:46 +000013728
Michael Lambert95cbbd22010-07-23 14:43:04 -040013729DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
13730 show_bgp_view_ipv4_safi_rsclient_route_cmd,
13731 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13732 SHOW_STR
13733 BGP_STR
13734 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013735 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013736 "Address family\n"
13737 "Address Family modifier\n"
13738 "Address Family modifier\n"
13739 "Information about Route Server Client\n"
13740 NEIGHBOR_ADDR_STR
13741 "Network in the BGP routing table to display\n")
13742{
13743 struct bgp *bgp;
13744 struct peer *peer;
13745 safi_t safi;
13746
13747 /* BGP structure lookup. */
13748 if (argc == 4)
13749 {
13750 bgp = bgp_lookup_by_name (argv[0]);
13751 if (bgp == NULL)
13752 {
13753 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13754 return CMD_WARNING;
13755 }
13756 }
13757 else
13758 {
13759 bgp = bgp_get_default ();
13760 if (bgp == NULL)
13761 {
13762 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13763 return CMD_WARNING;
13764 }
13765 }
13766
13767 if (argc == 4) {
13768 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13769 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13770 } else {
13771 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13772 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13773 }
13774
13775 if (! peer)
13776 return CMD_WARNING;
13777
13778 if (! peer->afc[AFI_IP][safi])
13779 {
13780 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13781 VTY_NEWLINE);
13782 return CMD_WARNING;
13783}
13784
13785 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13786 PEER_FLAG_RSERVER_CLIENT))
13787 {
13788 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13789 VTY_NEWLINE);
13790 return CMD_WARNING;
13791 }
13792
13793 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13794 (argc == 4) ? argv[3] : argv[2],
13795 AFI_IP, safi, NULL, 0);
13796}
13797
13798ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
13799 show_bgp_ipv4_safi_rsclient_route_cmd,
13800 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13801 SHOW_STR
13802 BGP_STR
13803 "Address family\n"
13804 "Address Family modifier\n"
13805 "Address Family modifier\n"
13806 "Information about Route Server Client\n"
13807 NEIGHBOR_ADDR_STR
13808 "Network in the BGP routing table to display\n")
13809
paulfee0f4c2004-09-13 05:12:46 +000013810
Michael Lambert95cbbd22010-07-23 14:43:04 -040013811DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
13812 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
13813 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13814 SHOW_STR
13815 BGP_STR
13816 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013817 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013818 "Address family\n"
13819 "Address Family modifier\n"
13820 "Address Family modifier\n"
13821 "Information about Route Server Client\n"
13822 NEIGHBOR_ADDR_STR
13823 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13824{
13825 struct bgp *bgp;
13826 struct peer *peer;
13827 safi_t safi;
13828
13829 /* BGP structure lookup. */
13830 if (argc == 4)
13831 {
13832 bgp = bgp_lookup_by_name (argv[0]);
13833 if (bgp == NULL)
13834 {
13835 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13836 return CMD_WARNING;
13837 }
13838 }
13839 else
13840 {
13841 bgp = bgp_get_default ();
13842 if (bgp == NULL)
13843 {
13844 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13845 return CMD_WARNING;
13846 }
13847 }
13848
13849 if (argc == 4) {
13850 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13851 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13852 } else {
13853 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13854 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13855 }
13856
13857 if (! peer)
13858 return CMD_WARNING;
13859
13860 if (! peer->afc[AFI_IP][safi])
13861 {
13862 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13863 VTY_NEWLINE);
13864 return CMD_WARNING;
13865}
13866
13867 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13868 PEER_FLAG_RSERVER_CLIENT))
13869{
13870 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13871 VTY_NEWLINE);
13872 return CMD_WARNING;
13873 }
13874
13875 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13876 (argc == 4) ? argv[3] : argv[2],
13877 AFI_IP, safi, NULL, 1);
13878}
13879
Lou Bergerf9b6c392016-01-12 13:42:09 -050013880DEFUN (show_ip_bgp_view_rsclient_prefix,
13881 show_ip_bgp_view_rsclient_prefix_cmd,
13882 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13883 SHOW_STR
13884 IP_STR
13885 BGP_STR
13886 "BGP view\n"
13887 "View name\n"
13888 "Information about Route Server Client\n"
13889 NEIGHBOR_ADDR_STR
13890 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13891{
13892 struct bgp *bgp;
13893 struct peer *peer;
13894
13895 /* BGP structure lookup. */
13896 if (argc == 3)
13897 {
13898 bgp = bgp_lookup_by_name (argv[0]);
13899 if (bgp == NULL)
13900 {
13901 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13902 return CMD_WARNING;
13903 }
13904 }
13905 else
13906 {
13907 bgp = bgp_get_default ();
13908 if (bgp == NULL)
13909 {
13910 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13911 return CMD_WARNING;
13912 }
13913 }
13914
13915 if (argc == 3)
13916 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13917 else
13918 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13919
13920 if (! peer)
13921 return CMD_WARNING;
13922
13923 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13924 {
13925 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13926 VTY_NEWLINE);
13927 return CMD_WARNING;
13928}
13929
13930 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13931 PEER_FLAG_RSERVER_CLIENT))
13932{
13933 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13934 VTY_NEWLINE);
13935 return CMD_WARNING;
13936 }
13937
13938 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13939 (argc == 3) ? argv[2] : argv[1],
13940 AFI_IP, SAFI_UNICAST, NULL, 1);
13941}
13942
13943ALIAS (show_ip_bgp_view_rsclient_prefix,
13944 show_ip_bgp_rsclient_prefix_cmd,
13945 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13946 SHOW_STR
13947 IP_STR
13948 BGP_STR
13949 "Information about Route Server Client\n"
13950 NEIGHBOR_ADDR_STR
13951 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13952
Michael Lambert95cbbd22010-07-23 14:43:04 -040013953ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
13954 show_bgp_ipv4_safi_rsclient_prefix_cmd,
13955 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13956 SHOW_STR
13957 BGP_STR
13958 "Address family\n"
13959 "Address Family modifier\n"
13960 "Address Family modifier\n"
13961 "Information about Route Server Client\n"
13962 NEIGHBOR_ADDR_STR
13963 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000013964
Lou Bergerf9b6c392016-01-12 13:42:09 -050013965DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050013966 show_bgp_view_ipv6_neighbor_routes_cmd,
13967 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +000013968 SHOW_STR
13969 BGP_STR
13970 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013971 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013972 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013973 "Detailed information on TCP and BGP neighbor connections\n"
13974 "Neighbor to display information about\n"
13975 "Neighbor to display information about\n"
13976 "Display routes learned from neighbor\n")
13977{
13978 struct peer *peer;
13979
13980 if (argc == 2)
13981 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13982 else
13983 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13984
13985 if (! peer)
13986 return CMD_WARNING;
13987
13988 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13989 bgp_show_type_neighbor);
13990}
13991
Lou Berger651b4022016-01-12 13:42:07 -050013992DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050013993 show_bgp_view_neighbor_damp_cmd,
13994 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13995 SHOW_STR
13996 BGP_STR
13997 "BGP view\n"
13998 "View name\n"
13999 "Detailed information on TCP and BGP neighbor connections\n"
14000 "Neighbor to display information about\n"
14001 "Neighbor to display information about\n"
14002 "Display the dampened routes received from neighbor\n")
14003{
14004 struct peer *peer;
14005
14006 if (argc == 2)
14007 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14008 else
14009 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14010
14011 if (! peer)
14012 return CMD_WARNING;
14013
14014 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14015 bgp_show_type_damp_neighbor);
14016}
14017
14018DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050014019 show_bgp_view_ipv6_neighbor_damp_cmd,
14020 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000014021 SHOW_STR
14022 BGP_STR
14023 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014024 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014025 "Address family\n"
14026 "Detailed information on TCP and BGP neighbor connections\n"
14027 "Neighbor to display information about\n"
14028 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000014029 "Display the dampened routes received from neighbor\n")
14030{
14031 struct peer *peer;
14032
14033 if (argc == 2)
14034 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14035 else
14036 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14037
14038 if (! peer)
14039 return CMD_WARNING;
14040
14041 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14042 bgp_show_type_damp_neighbor);
14043}
14044
Lou Bergerf9b6c392016-01-12 13:42:09 -050014045DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050014046 show_bgp_view_ipv6_neighbor_flap_cmd,
14047 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000014048 SHOW_STR
14049 BGP_STR
14050 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014051 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014052 "Address family\n"
14053 "Detailed information on TCP and BGP neighbor connections\n"
14054 "Neighbor to display information about\n"
14055 "Neighbor to display information about\n"
14056 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000014057{
14058 struct peer *peer;
14059
14060 if (argc == 2)
14061 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14062 else
14063 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14064
14065 if (! peer)
14066 return CMD_WARNING;
14067
14068 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14069 bgp_show_type_flap_neighbor);
14070}
14071
Lou Bergerf9b6c392016-01-12 13:42:09 -050014072DEFUN (show_bgp_view_neighbor_flap,
14073 show_bgp_view_neighbor_flap_cmd,
14074 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14075 SHOW_STR
14076 BGP_STR
14077 "BGP view\n"
14078 "View name\n"
14079 "Detailed information on TCP and BGP neighbor connections\n"
14080 "Neighbor to display information about\n"
14081 "Neighbor to display information about\n"
14082 "Display flap statistics of the routes learned from neighbor\n")
14083{
14084 struct peer *peer;
14085
14086 if (argc == 2)
14087 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14088 else
14089 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14090
14091 if (! peer)
14092 return CMD_WARNING;
14093
14094 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14095 bgp_show_type_flap_neighbor);
14096}
14097
14098ALIAS (show_bgp_view_neighbor_flap,
14099 show_bgp_neighbor_flap_cmd,
14100 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14101 SHOW_STR
14102 BGP_STR
14103 "Detailed information on TCP and BGP neighbor connections\n"
14104 "Neighbor to display information about\n"
14105 "Neighbor to display information about\n"
14106 "Display flap statistics of the routes learned from neighbor\n")
14107
14108ALIAS (show_bgp_view_neighbor_damp,
14109 show_bgp_neighbor_damp_cmd,
14110 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14111 SHOW_STR
14112 BGP_STR
14113 "Detailed information on TCP and BGP neighbor connections\n"
14114 "Neighbor to display information about\n"
14115 "Neighbor to display information about\n"
14116 "Display the dampened routes received from neighbor\n")
14117
14118DEFUN (show_bgp_view_neighbor_routes,
14119 show_bgp_view_neighbor_routes_cmd,
14120 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
14121 SHOW_STR
14122 BGP_STR
14123 "BGP view\n"
14124 "View name\n"
14125 "Detailed information on TCP and BGP neighbor connections\n"
14126 "Neighbor to display information about\n"
14127 "Neighbor to display information about\n"
14128 "Display routes learned from neighbor\n")
14129{
14130 struct peer *peer;
14131
14132 if (argc == 2)
14133 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14134 else
14135 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14136
14137 if (! peer)
14138 return CMD_WARNING;
14139
14140 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14141 bgp_show_type_neighbor);
14142}
14143
14144ALIAS (show_bgp_view_neighbor_routes,
14145 show_bgp_neighbor_routes_cmd,
14146 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
14147 SHOW_STR
14148 BGP_STR
14149 "Detailed information on TCP and BGP neighbor connections\n"
14150 "Neighbor to display information about\n"
14151 "Neighbor to display information about\n"
14152 "Display routes learned from neighbor\n")
14153
paulbb46e942003-10-24 19:02:03 +000014154ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000014155 show_bgp_ipv6_neighbor_routes_cmd,
14156 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
14157 SHOW_STR
14158 BGP_STR
14159 "Address family\n"
14160 "Detailed information on TCP and BGP neighbor connections\n"
14161 "Neighbor to display information about\n"
14162 "Neighbor to display information about\n"
14163 "Display routes learned from neighbor\n")
14164
Lou Bergerf9b6c392016-01-12 13:42:09 -050014165/* old command */
14166ALIAS (show_bgp_view_neighbor_routes,
14167 ipv6_bgp_neighbor_routes_cmd,
14168 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
14169 SHOW_STR
14170 IPV6_STR
14171 BGP_STR
14172 "Detailed information on TCP and BGP neighbor connections\n"
14173 "Neighbor to display information about\n"
14174 "Neighbor to display information about\n"
14175 "Display routes learned from neighbor\n")
14176
14177/* old command */
14178DEFUN (ipv6_mbgp_neighbor_routes,
14179 ipv6_mbgp_neighbor_routes_cmd,
14180 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
14181 SHOW_STR
14182 IPV6_STR
14183 MBGP_STR
14184 "Detailed information on TCP and BGP neighbor connections\n"
14185 "Neighbor to display information about\n"
14186 "Neighbor to display information about\n"
14187 "Display routes learned from neighbor\n")
14188{
14189 struct peer *peer;
14190
14191 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14192 if (! peer)
14193 return CMD_WARNING;
14194
14195 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
14196 bgp_show_type_neighbor);
14197}
14198
paulbb46e942003-10-24 19:02:03 +000014199ALIAS (show_bgp_view_neighbor_flap,
14200 show_bgp_ipv6_neighbor_flap_cmd,
14201 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14202 SHOW_STR
14203 BGP_STR
14204 "Address family\n"
14205 "Detailed information on TCP and BGP neighbor connections\n"
14206 "Neighbor to display information about\n"
14207 "Neighbor to display information about\n"
14208 "Display flap statistics of the routes learned from neighbor\n")
14209
14210ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000014211 show_bgp_ipv6_neighbor_damp_cmd,
14212 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14213 SHOW_STR
14214 BGP_STR
14215 "Address family\n"
14216 "Detailed information on TCP and BGP neighbor connections\n"
14217 "Neighbor to display information about\n"
14218 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000014219 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014220
Lou Bergerf9b6c392016-01-12 13:42:09 -050014221DEFUN (show_bgp_view_rsclient,
14222 show_bgp_view_rsclient_cmd,
14223 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14224 SHOW_STR
14225 BGP_STR
14226 "BGP view\n"
14227 "View name\n"
14228 "Information about Route Server Client\n"
14229 NEIGHBOR_ADDR_STR)
14230{
14231 struct bgp_table *table;
14232 struct peer *peer;
14233
14234 if (argc == 2)
14235 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14236 else
14237 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14238
14239 if (! peer)
14240 return CMD_WARNING;
14241
14242 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14243 {
14244 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14245 VTY_NEWLINE);
14246 return CMD_WARNING;
14247 }
14248
14249 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14250 PEER_FLAG_RSERVER_CLIENT))
14251 {
14252 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14253 VTY_NEWLINE);
14254 return CMD_WARNING;
14255 }
14256
14257 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14258
14259 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14260}
14261
14262ALIAS (show_bgp_view_rsclient,
14263 show_bgp_rsclient_cmd,
14264 "show bgp rsclient (A.B.C.D|X:X::X:X)",
14265 SHOW_STR
14266 BGP_STR
14267 "Information about Route Server Client\n"
14268 NEIGHBOR_ADDR_STR)
14269
Lou Berger651b4022016-01-12 13:42:07 -050014270DEFUN (show_bgp_view_ipv4_rsclient,
14271 show_bgp_view_ipv4_rsclient_cmd,
14272 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014273 SHOW_STR
14274 BGP_STR
14275 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014276 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014277 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014278 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014279 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014280{
Lou Berger651b4022016-01-12 13:42:07 -050014281 struct bgp_table *table;
14282 struct peer *peer;
14283
14284 if (argc == 2)
14285 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14286 else
14287 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14288
14289 if (! peer)
14290 return CMD_WARNING;
14291
14292 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14293 {
14294 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14295 VTY_NEWLINE);
14296 return CMD_WARNING;
14297 }
14298
14299 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14300 PEER_FLAG_RSERVER_CLIENT))
14301 {
14302 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14303 VTY_NEWLINE);
14304 return CMD_WARNING;
14305 }
14306
14307 table = peer->rib[AFI_IP][SAFI_UNICAST];
14308
14309 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14310}
14311DEFUN (show_bgp_view_ipv6_rsclient,
14312 show_bgp_view_ipv6_rsclient_cmd,
14313 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
14314 SHOW_STR
14315 BGP_STR
14316 "BGP view\n"
14317 "BGP view name\n"
14318 "Address Family\n"
14319 "Information about Route Server Client\n"
14320 NEIGHBOR_ADDR_STR2)
14321{
14322 struct bgp_table *table;
14323 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000014324
14325 if (argc == 2)
14326 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14327 else
14328 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14329
14330 if (! peer)
14331 return CMD_WARNING;
14332
14333 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14334 {
14335 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14336 VTY_NEWLINE);
14337 return CMD_WARNING;
14338 }
14339
14340 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14341 PEER_FLAG_RSERVER_CLIENT))
14342 {
14343 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14344 VTY_NEWLINE);
14345 return CMD_WARNING;
14346 }
14347
14348 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14349
ajs5a646652004-11-05 01:25:55 +000014350 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000014351}
14352
Lou Berger651b4022016-01-12 13:42:07 -050014353ALIAS (show_bgp_view_ipv4_rsclient,
14354 show_bgp_ipv4_rsclient_cmd,
14355 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014356 SHOW_STR
14357 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014358 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014359 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014360 NEIGHBOR_ADDR_STR2)
14361
Lou Berger651b4022016-01-12 13:42:07 -050014362ALIAS (show_bgp_view_ipv6_rsclient,
14363 show_bgp_ipv6_rsclient_cmd,
14364 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
14365 SHOW_STR
14366 BGP_STR
14367 "Address Family\n"
14368 "Information about Route Server Client\n"
14369 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014370
Michael Lambert95cbbd22010-07-23 14:43:04 -040014371DEFUN (show_bgp_view_ipv6_safi_rsclient,
14372 show_bgp_view_ipv6_safi_rsclient_cmd,
14373 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14374 SHOW_STR
14375 BGP_STR
14376 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014377 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014378 "Address family\n"
14379 "Address Family modifier\n"
14380 "Address Family modifier\n"
14381 "Information about Route Server Client\n"
14382 NEIGHBOR_ADDR_STR)
14383{
14384 struct bgp_table *table;
14385 struct peer *peer;
14386 safi_t safi;
14387
14388 if (argc == 3) {
14389 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14390 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14391 } else {
14392 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14393 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14394 }
14395
14396 if (! peer)
14397 return CMD_WARNING;
14398
14399 if (! peer->afc[AFI_IP6][safi])
14400 {
14401 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14402 VTY_NEWLINE);
14403 return CMD_WARNING;
14404 }
14405
14406 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14407 PEER_FLAG_RSERVER_CLIENT))
14408 {
14409 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14410 VTY_NEWLINE);
14411 return CMD_WARNING;
14412 }
14413
14414 table = peer->rib[AFI_IP6][safi];
14415
14416 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14417}
14418
14419ALIAS (show_bgp_view_ipv6_safi_rsclient,
14420 show_bgp_ipv6_safi_rsclient_cmd,
14421 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14422 SHOW_STR
14423 BGP_STR
14424 "Address family\n"
14425 "Address Family modifier\n"
14426 "Address Family modifier\n"
14427 "Information about Route Server Client\n"
14428 NEIGHBOR_ADDR_STR)
14429
paulfee0f4c2004-09-13 05:12:46 +000014430DEFUN (show_bgp_view_rsclient_route,
14431 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014432 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14433 SHOW_STR
14434 BGP_STR
14435 "BGP view\n"
14436 "View name\n"
14437 "Information about Route Server Client\n"
14438 NEIGHBOR_ADDR_STR
14439 "Network in the BGP routing table to display\n")
14440{
14441 struct bgp *bgp;
14442 struct peer *peer;
14443
14444 /* BGP structure lookup. */
14445 if (argc == 3)
14446 {
14447 bgp = bgp_lookup_by_name (argv[0]);
14448 if (bgp == NULL)
14449 {
14450 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14451 return CMD_WARNING;
14452 }
14453 }
14454 else
14455 {
14456 bgp = bgp_get_default ();
14457 if (bgp == NULL)
14458 {
14459 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14460 return CMD_WARNING;
14461 }
14462 }
14463
14464 if (argc == 3)
14465 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14466 else
14467 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14468
14469 if (! peer)
14470 return CMD_WARNING;
14471
14472 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14473 {
14474 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14475 VTY_NEWLINE);
14476 return CMD_WARNING;
14477 }
14478
14479 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14480 PEER_FLAG_RSERVER_CLIENT))
14481 {
14482 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14483 VTY_NEWLINE);
14484 return CMD_WARNING;
14485 }
14486
14487 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14488 (argc == 3) ? argv[2] : argv[1],
14489 AFI_IP6, SAFI_UNICAST, NULL, 0);
14490}
14491
14492DEFUN (show_bgp_view_ipv6_rsclient_route,
14493 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014494 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014495 SHOW_STR
14496 BGP_STR
14497 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050014498 "BGP view name\n"
14499 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000014500 "Information about Route Server Client\n"
14501 NEIGHBOR_ADDR_STR
14502 "Network in the BGP routing table to display\n")
14503{
14504 struct bgp *bgp;
14505 struct peer *peer;
14506
14507 /* BGP structure lookup. */
14508 if (argc == 3)
14509 {
14510 bgp = bgp_lookup_by_name (argv[0]);
14511 if (bgp == NULL)
14512 {
14513 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14514 return CMD_WARNING;
14515 }
14516 }
14517 else
14518 {
14519 bgp = bgp_get_default ();
14520 if (bgp == NULL)
14521 {
14522 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14523 return CMD_WARNING;
14524 }
14525 }
14526
14527 if (argc == 3)
14528 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14529 else
14530 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14531
14532 if (! peer)
14533 return CMD_WARNING;
14534
14535 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14536 {
14537 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14538 VTY_NEWLINE);
14539 return CMD_WARNING;
14540 }
14541
14542 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14543 PEER_FLAG_RSERVER_CLIENT))
14544 {
14545 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14546 VTY_NEWLINE);
14547 return CMD_WARNING;
14548 }
14549
14550 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14551 (argc == 3) ? argv[2] : argv[1],
14552 AFI_IP6, SAFI_UNICAST, NULL, 0);
14553}
14554
Lou Bergerf9b6c392016-01-12 13:42:09 -050014555ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000014556 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014557 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14558 SHOW_STR
14559 BGP_STR
14560 "Information about Route Server Client\n"
14561 NEIGHBOR_ADDR_STR
14562 "Network in the BGP routing table to display\n")
14563
14564ALIAS (show_bgp_view_ipv6_rsclient_route,
14565 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014566 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014567 SHOW_STR
14568 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014569 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014570 "Information about Route Server Client\n"
14571 NEIGHBOR_ADDR_STR
14572 "Network in the BGP routing table to display\n")
14573
Michael Lambert95cbbd22010-07-23 14:43:04 -040014574DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
14575 show_bgp_view_ipv6_safi_rsclient_route_cmd,
14576 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14577 SHOW_STR
14578 BGP_STR
14579 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014580 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014581 "Address family\n"
14582 "Address Family modifier\n"
14583 "Address Family modifier\n"
14584 "Information about Route Server Client\n"
14585 NEIGHBOR_ADDR_STR
14586 "Network in the BGP routing table to display\n")
14587{
14588 struct bgp *bgp;
14589 struct peer *peer;
14590 safi_t safi;
14591
14592 /* BGP structure lookup. */
14593 if (argc == 4)
14594 {
14595 bgp = bgp_lookup_by_name (argv[0]);
14596 if (bgp == NULL)
14597 {
14598 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14599 return CMD_WARNING;
14600 }
14601 }
14602 else
14603 {
14604 bgp = bgp_get_default ();
14605 if (bgp == NULL)
14606 {
14607 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14608 return CMD_WARNING;
14609 }
14610 }
14611
14612 if (argc == 4) {
14613 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14614 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14615 } else {
14616 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14617 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14618 }
14619
14620 if (! peer)
14621 return CMD_WARNING;
14622
14623 if (! peer->afc[AFI_IP6][safi])
14624 {
14625 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14626 VTY_NEWLINE);
14627 return CMD_WARNING;
14628}
14629
14630 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14631 PEER_FLAG_RSERVER_CLIENT))
14632 {
14633 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14634 VTY_NEWLINE);
14635 return CMD_WARNING;
14636 }
14637
14638 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14639 (argc == 4) ? argv[3] : argv[2],
14640 AFI_IP6, safi, NULL, 0);
14641}
14642
14643ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
14644 show_bgp_ipv6_safi_rsclient_route_cmd,
14645 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14646 SHOW_STR
14647 BGP_STR
14648 "Address family\n"
14649 "Address Family modifier\n"
14650 "Address Family modifier\n"
14651 "Information about Route Server Client\n"
14652 NEIGHBOR_ADDR_STR
14653 "Network in the BGP routing table to display\n")
14654
Lou Berger651b4022016-01-12 13:42:07 -050014655
paulfee0f4c2004-09-13 05:12:46 +000014656DEFUN (show_bgp_view_rsclient_prefix,
14657 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014658 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14659 SHOW_STR
14660 BGP_STR
14661 "BGP view\n"
14662 "View name\n"
14663 "Information about Route Server Client\n"
14664 NEIGHBOR_ADDR_STR
14665 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14666{
14667 struct bgp *bgp;
14668 struct peer *peer;
14669
14670 /* BGP structure lookup. */
14671 if (argc == 3)
14672 {
14673 bgp = bgp_lookup_by_name (argv[0]);
14674 if (bgp == NULL)
14675 {
14676 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14677 return CMD_WARNING;
14678 }
14679 }
14680 else
14681 {
14682 bgp = bgp_get_default ();
14683 if (bgp == NULL)
14684 {
14685 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14686 return CMD_WARNING;
14687 }
14688 }
14689
14690 if (argc == 3)
14691 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14692 else
14693 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14694
14695 if (! peer)
14696 return CMD_WARNING;
14697
14698 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14699 {
14700 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14701 VTY_NEWLINE);
14702 return CMD_WARNING;
14703 }
14704
14705 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14706 PEER_FLAG_RSERVER_CLIENT))
14707 {
14708 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14709 VTY_NEWLINE);
14710 return CMD_WARNING;
14711 }
14712
14713 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14714 (argc == 3) ? argv[2] : argv[1],
14715 AFI_IP6, SAFI_UNICAST, NULL, 1);
14716}
14717
14718DEFUN (show_bgp_view_ipv6_rsclient_prefix,
14719 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014720 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000014721 SHOW_STR
14722 BGP_STR
14723 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014724 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014725 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014726 "Information about Route Server Client\n"
14727 NEIGHBOR_ADDR_STR
14728 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14729{
14730 struct bgp *bgp;
14731 struct peer *peer;
14732
14733 /* BGP structure lookup. */
14734 if (argc == 3)
14735 {
14736 bgp = bgp_lookup_by_name (argv[0]);
14737 if (bgp == NULL)
14738 {
14739 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14740 return CMD_WARNING;
14741 }
14742 }
14743 else
14744 {
14745 bgp = bgp_get_default ();
14746 if (bgp == NULL)
14747 {
14748 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14749 return CMD_WARNING;
14750 }
14751 }
14752
14753 if (argc == 3)
14754 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14755 else
14756 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14757
14758 if (! peer)
14759 return CMD_WARNING;
14760
14761 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14762 {
14763 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14764 VTY_NEWLINE);
14765 return CMD_WARNING;
14766 }
14767
14768 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14769 PEER_FLAG_RSERVER_CLIENT))
14770 {
14771 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14772 VTY_NEWLINE);
14773 return CMD_WARNING;
14774 }
14775
14776 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14777 (argc == 3) ? argv[2] : argv[1],
14778 AFI_IP6, SAFI_UNICAST, NULL, 1);
14779}
14780
Lou Bergerf9b6c392016-01-12 13:42:09 -050014781ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000014782 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014783 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14784 SHOW_STR
14785 BGP_STR
14786 "Information about Route Server Client\n"
14787 NEIGHBOR_ADDR_STR
14788 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14789
14790ALIAS (show_bgp_view_ipv6_rsclient_prefix,
14791 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014792 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000014793 SHOW_STR
14794 BGP_STR
14795 "Information about Route Server Client\n"
14796 NEIGHBOR_ADDR_STR
14797 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14798
Michael Lambert95cbbd22010-07-23 14:43:04 -040014799DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
14800 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
14801 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14802 SHOW_STR
14803 BGP_STR
14804 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014805 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014806 "Address family\n"
14807 "Address Family modifier\n"
14808 "Address Family modifier\n"
14809 "Information about Route Server Client\n"
14810 NEIGHBOR_ADDR_STR
14811 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14812{
14813 struct bgp *bgp;
14814 struct peer *peer;
14815 safi_t safi;
14816
14817 /* BGP structure lookup. */
14818 if (argc == 4)
14819 {
14820 bgp = bgp_lookup_by_name (argv[0]);
14821 if (bgp == NULL)
14822 {
14823 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14824 return CMD_WARNING;
14825 }
14826 }
14827 else
14828 {
14829 bgp = bgp_get_default ();
14830 if (bgp == NULL)
14831 {
14832 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14833 return CMD_WARNING;
14834 }
14835 }
14836
14837 if (argc == 4) {
14838 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14839 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14840 } else {
14841 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14842 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14843 }
14844
14845 if (! peer)
14846 return CMD_WARNING;
14847
14848 if (! peer->afc[AFI_IP6][safi])
14849 {
14850 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14851 VTY_NEWLINE);
14852 return CMD_WARNING;
14853}
14854
14855 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14856 PEER_FLAG_RSERVER_CLIENT))
14857{
14858 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14859 VTY_NEWLINE);
14860 return CMD_WARNING;
14861 }
14862
14863 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14864 (argc == 4) ? argv[3] : argv[2],
14865 AFI_IP6, safi, NULL, 1);
14866}
14867
14868ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
14869 show_bgp_ipv6_safi_rsclient_prefix_cmd,
14870 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14871 SHOW_STR
14872 BGP_STR
14873 "Address family\n"
14874 "Address Family modifier\n"
14875 "Address Family modifier\n"
14876 "Information about Route Server Client\n"
14877 NEIGHBOR_ADDR_STR
14878 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14879
paul718e3742002-12-13 20:15:29 +000014880struct bgp_table *bgp_distance_table;
14881
14882struct bgp_distance
14883{
14884 /* Distance value for the IP source prefix. */
14885 u_char distance;
14886
14887 /* Name of the access-list to be matched. */
14888 char *access_list;
14889};
14890
paul94f2b392005-06-28 12:44:16 +000014891static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080014892bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000014893{
Stephen Hemminger393deb92008-08-18 14:13:29 -070014894 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000014895}
14896
paul94f2b392005-06-28 12:44:16 +000014897static void
paul718e3742002-12-13 20:15:29 +000014898bgp_distance_free (struct bgp_distance *bdistance)
14899{
14900 XFREE (MTYPE_BGP_DISTANCE, bdistance);
14901}
14902
paul94f2b392005-06-28 12:44:16 +000014903static int
paulfd79ac92004-10-13 05:06:08 +000014904bgp_distance_set (struct vty *vty, const char *distance_str,
14905 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014906{
14907 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010014908 struct prefix p;
paul718e3742002-12-13 20:15:29 +000014909 u_char distance;
14910 struct bgp_node *rn;
14911 struct bgp_distance *bdistance;
14912
Roman Hoog Antink6184c392014-03-17 14:01:42 +010014913 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000014914 if (ret == 0)
14915 {
14916 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14917 return CMD_WARNING;
14918 }
14919
14920 distance = atoi (distance_str);
14921
14922 /* Get BGP distance node. */
14923 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
14924 if (rn->info)
14925 {
14926 bdistance = rn->info;
14927 bgp_unlock_node (rn);
14928 }
14929 else
14930 {
14931 bdistance = bgp_distance_new ();
14932 rn->info = bdistance;
14933 }
14934
14935 /* Set distance value. */
14936 bdistance->distance = distance;
14937
14938 /* Reset access-list configuration. */
14939 if (bdistance->access_list)
14940 {
14941 free (bdistance->access_list);
14942 bdistance->access_list = NULL;
14943 }
14944 if (access_list_str)
14945 bdistance->access_list = strdup (access_list_str);
14946
14947 return CMD_SUCCESS;
14948}
14949
paul94f2b392005-06-28 12:44:16 +000014950static int
paulfd79ac92004-10-13 05:06:08 +000014951bgp_distance_unset (struct vty *vty, const char *distance_str,
14952 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014953{
14954 int ret;
Roman Hoog Antink6184c392014-03-17 14:01:42 +010014955 struct prefix p;
paul718e3742002-12-13 20:15:29 +000014956 u_char distance;
14957 struct bgp_node *rn;
14958 struct bgp_distance *bdistance;
14959
Roman Hoog Antink6184c392014-03-17 14:01:42 +010014960 ret = str2prefix (ip_str, &p);
paul718e3742002-12-13 20:15:29 +000014961 if (ret == 0)
14962 {
14963 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14964 return CMD_WARNING;
14965 }
14966
14967 distance = atoi (distance_str);
14968
14969 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
14970 if (! rn)
14971 {
14972 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
14973 return CMD_WARNING;
14974 }
14975
14976 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010014977
14978 if (bdistance->distance != distance)
14979 {
14980 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
14981 return CMD_WARNING;
14982 }
14983
paul718e3742002-12-13 20:15:29 +000014984 if (bdistance->access_list)
14985 free (bdistance->access_list);
14986 bgp_distance_free (bdistance);
14987
14988 rn->info = NULL;
14989 bgp_unlock_node (rn);
14990 bgp_unlock_node (rn);
14991
14992 return CMD_SUCCESS;
14993}
14994
paul718e3742002-12-13 20:15:29 +000014995/* Apply BGP information to distance method. */
14996u_char
14997bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
14998{
14999 struct bgp_node *rn;
15000 struct prefix_ipv4 q;
15001 struct peer *peer;
15002 struct bgp_distance *bdistance;
15003 struct access_list *alist;
15004 struct bgp_static *bgp_static;
15005
15006 if (! bgp)
15007 return 0;
15008
15009 if (p->family != AF_INET)
15010 return 0;
15011
15012 peer = rinfo->peer;
15013
15014 if (peer->su.sa.sa_family != AF_INET)
15015 return 0;
15016
15017 memset (&q, 0, sizeof (struct prefix_ipv4));
15018 q.family = AF_INET;
15019 q.prefix = peer->su.sin.sin_addr;
15020 q.prefixlen = IPV4_MAX_BITLEN;
15021
15022 /* Check source address. */
15023 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15024 if (rn)
15025 {
15026 bdistance = rn->info;
15027 bgp_unlock_node (rn);
15028
15029 if (bdistance->access_list)
15030 {
15031 alist = access_list_lookup (AFI_IP, bdistance->access_list);
15032 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15033 return bdistance->distance;
15034 }
15035 else
15036 return bdistance->distance;
15037 }
15038
15039 /* Backdoor check. */
15040 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
15041 if (rn)
15042 {
15043 bgp_static = rn->info;
15044 bgp_unlock_node (rn);
15045
15046 if (bgp_static->backdoor)
15047 {
15048 if (bgp->distance_local)
15049 return bgp->distance_local;
15050 else
15051 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15052 }
15053 }
15054
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000015055 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000015056 {
15057 if (bgp->distance_ebgp)
15058 return bgp->distance_ebgp;
15059 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15060 }
15061 else
15062 {
15063 if (bgp->distance_ibgp)
15064 return bgp->distance_ibgp;
15065 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15066 }
15067}
15068
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015069#ifdef HAVE_IPV6
15070/* Apply BGP information to ipv6 distance method. */
15071u_char
15072ipv6_bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
15073{
15074 struct bgp_node *rn;
15075 struct prefix_ipv6 q;
15076 struct peer *peer;
15077 struct bgp_distance *bdistance;
15078 struct access_list *alist;
15079 struct bgp_static *bgp_static;
15080
15081 if (! bgp)
15082 return 0;
15083
15084 if (p->family != AF_INET6)
15085 return 0;
15086
15087 peer = rinfo->peer;
15088
15089 if (peer->su.sa.sa_family != AF_INET6)
15090 return 0;
15091
15092 memset (&q, 0, sizeof (struct prefix_ipv6));
15093 q.family = AF_INET;
15094 q.prefix = peer->su.sin6.sin6_addr;
15095 q.prefixlen = IPV6_MAX_BITLEN;
15096
15097 /* Check source address. */
15098 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15099 if (rn)
15100 {
15101 bdistance = rn->info;
15102 bgp_unlock_node (rn);
15103
15104 if (bdistance->access_list)
15105 {
15106 alist = access_list_lookup (AFI_IP6, bdistance->access_list);
15107 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15108 return bdistance->distance;
15109 }
15110 else
15111 return bdistance->distance;
15112 }
15113 /* Backdoor check. */
15114 rn = bgp_node_lookup (bgp->route[AFI_IP6][SAFI_UNICAST], p);
15115 if (rn)
15116 {
15117 bgp_static = rn->info;
15118 bgp_unlock_node (rn);
15119
15120 if (bgp_static->backdoor)
15121 {
15122 if (bgp->ipv6_distance_local)
15123 return bgp->ipv6_distance_local;
15124 else
15125 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15126 }
15127 }
15128
15129 if (peer_sort (peer) == BGP_PEER_EBGP)
15130 {
15131 if (bgp->ipv6_distance_ebgp)
15132 return bgp->ipv6_distance_ebgp;
15133 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15134 }
15135 else
15136 {
15137 if (bgp->ipv6_distance_ibgp)
15138 return bgp->ipv6_distance_ibgp;
15139 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15140 }
15141}
15142#endif /* HAVE_IPV6 */
15143
paul718e3742002-12-13 20:15:29 +000015144DEFUN (bgp_distance,
15145 bgp_distance_cmd,
15146 "distance bgp <1-255> <1-255> <1-255>",
15147 "Define an administrative distance\n"
15148 "BGP distance\n"
15149 "Distance for routes external to the AS\n"
15150 "Distance for routes internal to the AS\n"
15151 "Distance for local routes\n")
15152{
15153 struct bgp *bgp;
15154
15155 bgp = vty->index;
15156
15157 bgp->distance_ebgp = atoi (argv[0]);
15158 bgp->distance_ibgp = atoi (argv[1]);
15159 bgp->distance_local = atoi (argv[2]);
15160 return CMD_SUCCESS;
15161}
15162
15163DEFUN (no_bgp_distance,
15164 no_bgp_distance_cmd,
15165 "no distance bgp <1-255> <1-255> <1-255>",
15166 NO_STR
15167 "Define an administrative distance\n"
15168 "BGP distance\n"
15169 "Distance for routes external to the AS\n"
15170 "Distance for routes internal to the AS\n"
15171 "Distance for local routes\n")
15172{
15173 struct bgp *bgp;
15174
15175 bgp = vty->index;
15176
15177 bgp->distance_ebgp= 0;
15178 bgp->distance_ibgp = 0;
15179 bgp->distance_local = 0;
15180 return CMD_SUCCESS;
15181}
15182
15183ALIAS (no_bgp_distance,
15184 no_bgp_distance2_cmd,
15185 "no distance bgp",
15186 NO_STR
15187 "Define an administrative distance\n"
15188 "BGP distance\n")
15189
15190DEFUN (bgp_distance_source,
15191 bgp_distance_source_cmd,
15192 "distance <1-255> A.B.C.D/M",
15193 "Define an administrative distance\n"
15194 "Administrative distance\n"
15195 "IP source prefix\n")
15196{
15197 bgp_distance_set (vty, argv[0], argv[1], NULL);
15198 return CMD_SUCCESS;
15199}
15200
15201DEFUN (no_bgp_distance_source,
15202 no_bgp_distance_source_cmd,
15203 "no distance <1-255> A.B.C.D/M",
15204 NO_STR
15205 "Define an administrative distance\n"
15206 "Administrative distance\n"
15207 "IP source prefix\n")
15208{
15209 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15210 return CMD_SUCCESS;
15211}
15212
15213DEFUN (bgp_distance_source_access_list,
15214 bgp_distance_source_access_list_cmd,
15215 "distance <1-255> A.B.C.D/M WORD",
15216 "Define an administrative distance\n"
15217 "Administrative distance\n"
15218 "IP source prefix\n"
15219 "Access list name\n")
15220{
15221 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15222 return CMD_SUCCESS;
15223}
15224
15225DEFUN (no_bgp_distance_source_access_list,
15226 no_bgp_distance_source_access_list_cmd,
15227 "no distance <1-255> A.B.C.D/M WORD",
15228 NO_STR
15229 "Define an administrative distance\n"
15230 "Administrative distance\n"
15231 "IP source prefix\n"
15232 "Access list name\n")
15233{
15234 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15235 return CMD_SUCCESS;
15236}
David Lamparter6b0655a2014-06-04 06:53:35 +020015237
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015238#ifdef HAVE_IPV6
15239DEFUN (ipv6_bgp_distance,
15240 ipv6_bgp_distance_cmd,
15241 "distance bgp <1-255> <1-255> <1-255>",
15242 "Define an administrative distance\n"
15243 "BGP distance\n"
15244 "Distance for routes external to the AS\n"
15245 "Distance for routes internal to the AS\n"
15246 "Distance for local routes\n")
15247{
15248 struct bgp *bgp;
15249
15250 bgp = vty->index;
15251
15252 bgp->ipv6_distance_ebgp = atoi (argv[0]);
15253 bgp->ipv6_distance_ibgp = atoi (argv[1]);
15254 bgp->ipv6_distance_local = atoi (argv[2]);
15255 return CMD_SUCCESS;
15256}
15257
15258DEFUN (no_ipv6_bgp_distance,
15259 no_ipv6_bgp_distance_cmd,
15260 "no distance bgp <1-255> <1-255> <1-255>",
15261 NO_STR
15262 "Define an administrative distance\n"
15263 "BGP distance\n"
15264 "Distance for routes external to the AS\n"
15265 "Distance for routes internal to the AS\n"
15266 "Distance for local routes\n")
15267{
15268 struct bgp *bgp;
15269
15270 bgp = vty->index;
15271
15272 bgp->ipv6_distance_ebgp= 0;
15273 bgp->ipv6_distance_ibgp = 0;
15274 bgp->ipv6_distance_local = 0;
15275 return CMD_SUCCESS;
15276}
15277
15278ALIAS (no_ipv6_bgp_distance,
15279 no_ipv6_bgp_distance2_cmd,
15280 "no distance bgp",
15281 NO_STR
15282 "Define an administrative distance\n"
15283 "BGP distance\n")
15284
15285DEFUN (ipv6_bgp_distance_source,
15286 ipv6_bgp_distance_source_cmd,
15287 "distance <1-255> X:X::X:X/M",
15288 "Define an administrative distance\n"
15289 "Administrative distance\n"
15290 "IP source prefix\n")
15291{
15292 bgp_distance_set (vty, argv[0], argv[1], NULL);
15293 return CMD_SUCCESS;
15294}
15295
15296DEFUN (no_ipv6_bgp_distance_source,
15297 no_ipv6_bgp_distance_source_cmd,
15298 "no distance <1-255> X:X::X:X/M",
15299 NO_STR
15300 "Define an administrative distance\n"
15301 "Administrative distance\n"
15302 "IP source prefix\n")
15303{
15304 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15305 return CMD_SUCCESS;
15306}
15307
15308DEFUN (ipv6_bgp_distance_source_access_list,
15309 ipv6_bgp_distance_source_access_list_cmd,
15310 "distance <1-255> X:X::X:X/M WORD",
15311 "Define an administrative distance\n"
15312 "Administrative distance\n"
15313 "IP source prefix\n"
15314 "Access list name\n")
15315{
15316 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15317 return CMD_SUCCESS;
15318}
15319
15320DEFUN (no_ipv6_bgp_distance_source_access_list,
15321 no_ipv6_bgp_distance_source_access_list_cmd,
15322 "no distance <1-255> X:X::X:X/M WORD",
15323 NO_STR
15324 "Define an administrative distance\n"
15325 "Administrative distance\n"
15326 "IP source prefix\n"
15327 "Access list name\n")
15328{
15329 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15330 return CMD_SUCCESS;
15331}
15332#endif
15333
paul718e3742002-12-13 20:15:29 +000015334DEFUN (bgp_damp_set,
15335 bgp_damp_set_cmd,
15336 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15337 "BGP Specific commands\n"
15338 "Enable route-flap dampening\n"
15339 "Half-life time for the penalty\n"
15340 "Value to start reusing a route\n"
15341 "Value to start suppressing a route\n"
15342 "Maximum duration to suppress a stable route\n")
15343{
15344 struct bgp *bgp;
15345 int half = DEFAULT_HALF_LIFE * 60;
15346 int reuse = DEFAULT_REUSE;
15347 int suppress = DEFAULT_SUPPRESS;
15348 int max = 4 * half;
15349
15350 if (argc == 4)
15351 {
15352 half = atoi (argv[0]) * 60;
15353 reuse = atoi (argv[1]);
15354 suppress = atoi (argv[2]);
15355 max = atoi (argv[3]) * 60;
15356 }
15357 else if (argc == 1)
15358 {
15359 half = atoi (argv[0]) * 60;
15360 max = 4 * half;
15361 }
15362
15363 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000015364
15365 if (suppress < reuse)
15366 {
15367 vty_out (vty, "Suppress value cannot be less than reuse value %s",
15368 VTY_NEWLINE);
15369 return 0;
15370 }
15371
paul718e3742002-12-13 20:15:29 +000015372 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
15373 half, reuse, suppress, max);
15374}
15375
15376ALIAS (bgp_damp_set,
15377 bgp_damp_set2_cmd,
15378 "bgp dampening <1-45>",
15379 "BGP Specific commands\n"
15380 "Enable route-flap dampening\n"
15381 "Half-life time for the penalty\n")
15382
15383ALIAS (bgp_damp_set,
15384 bgp_damp_set3_cmd,
15385 "bgp dampening",
15386 "BGP Specific commands\n"
15387 "Enable route-flap dampening\n")
15388
15389DEFUN (bgp_damp_unset,
15390 bgp_damp_unset_cmd,
15391 "no bgp dampening",
15392 NO_STR
15393 "BGP Specific commands\n"
15394 "Enable route-flap dampening\n")
15395{
15396 struct bgp *bgp;
15397
15398 bgp = vty->index;
15399 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
15400}
15401
15402ALIAS (bgp_damp_unset,
15403 bgp_damp_unset2_cmd,
15404 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15405 NO_STR
15406 "BGP Specific commands\n"
15407 "Enable route-flap dampening\n"
15408 "Half-life time for the penalty\n"
15409 "Value to start reusing a route\n"
15410 "Value to start suppressing a route\n"
15411 "Maximum duration to suppress a stable route\n")
15412
Lou Bergerf9b6c392016-01-12 13:42:09 -050015413DEFUN (show_ip_bgp_dampened_paths,
15414 show_ip_bgp_dampened_paths_cmd,
15415 "show ip bgp dampened-paths",
15416 SHOW_STR
15417 IP_STR
15418 BGP_STR
15419 "Display paths suppressed due to dampening\n")
15420{
15421 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
15422 NULL);
15423}
15424
15425ALIAS (show_ip_bgp_dampened_paths,
15426 show_ip_bgp_damp_dampened_paths_cmd,
15427 "show ip bgp dampening dampened-paths",
15428 SHOW_STR
15429 IP_STR
15430 BGP_STR
15431 "Display detailed information about dampening\n"
15432 "Display paths suppressed due to dampening\n")
15433
15434DEFUN (show_ip_bgp_flap_statistics,
15435 show_ip_bgp_flap_statistics_cmd,
15436 "show ip bgp flap-statistics",
15437 SHOW_STR
15438 IP_STR
15439 BGP_STR
15440 "Display flap statistics of routes\n")
15441{
15442 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
15443 bgp_show_type_flap_statistics, NULL);
15444}
15445
15446ALIAS (show_ip_bgp_flap_statistics,
15447 show_ip_bgp_damp_flap_statistics_cmd,
15448 "show ip bgp dampening flap-statistics",
15449 SHOW_STR
15450 IP_STR
15451 BGP_STR
15452 "Display detailed information about dampening\n"
15453 "Display flap statistics of routes\n")
15454
Lou Berger651b4022016-01-12 13:42:07 -050015455DEFUN (show_bgp_ipv4_safi_dampened_paths,
15456 show_bgp_ipv4_safi_dampened_paths_cmd,
15457 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015458 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015459 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015460 IP_STR
15461 "Address Family modifier\n"
15462 "Address Family modifier\n"
15463 "Address Family modifier\n"
15464 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015465 "Display paths suppressed due to dampening\n")
15466{
Lou Berger651b4022016-01-12 13:42:07 -050015467 safi_t safi;
paul718e3742002-12-13 20:15:29 +000015468
Lou Berger651b4022016-01-12 13:42:07 -050015469 if (bgp_parse_safi(argv[0], &safi)) {
15470 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15471 return CMD_WARNING;
15472 }
15473
15474 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
15475}
15476ALIAS (show_bgp_ipv4_safi_dampened_paths,
15477 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
15478 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053015479 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015480 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015481 IP_STR
15482 "Address Family modifier\n"
15483 "Address Family modifier\n"
15484 "Address Family modifier\n"
15485 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015486 "Display detailed information about dampening\n"
15487 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050015488
Lou Berger651b4022016-01-12 13:42:07 -050015489DEFUN (show_bgp_ipv6_safi_dampened_paths,
15490 show_bgp_ipv6_safi_dampened_paths_cmd,
15491 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015492 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015493 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015494 IPV6_STR
15495 "Address Family modifier\n"
15496 "Address Family modifier\n"
15497 "Address Family modifier\n"
15498 "Address Family modifier\n"
15499 "Display paths suppressed due to dampening\n")
15500{
15501 safi_t safi;
15502
15503 if (bgp_parse_safi(argv[0], &safi)) {
15504 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15505 return CMD_WARNING;
15506 }
15507
15508 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
15509}
15510ALIAS (show_bgp_ipv6_safi_dampened_paths,
15511 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
15512 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
15513 SHOW_STR
15514 BGP_STR
15515 IPV6_STR
15516 "Address Family modifier\n"
15517 "Address Family modifier\n"
15518 "Address Family modifier\n"
15519 "Address Family modifier\n"
15520 "Display detailed information about dampening\n"
15521 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050015522
15523DEFUN (show_bgp_ipv4_safi_flap_statistics,
15524 show_bgp_ipv4_safi_flap_statistics_cmd,
15525 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
15526 SHOW_STR
15527 BGP_STR
15528 "Address Family\n"
15529 "Address Family modifier\n"
15530 "Address Family modifier\n"
15531 "Address Family modifier\n"
15532 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015533 "Display flap statistics of routes\n")
15534{
Lou Berger651b4022016-01-12 13:42:07 -050015535 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020015536
Lou Berger651b4022016-01-12 13:42:07 -050015537 if (bgp_parse_safi(argv[0], &safi)) {
15538 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15539 return CMD_WARNING;
15540 }
15541
15542 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
15543}
15544ALIAS (show_bgp_ipv4_safi_flap_statistics,
15545 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
15546 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053015547 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015548 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015549 "Address Family\n"
15550 "Address Family modifier\n"
15551 "Address Family modifier\n"
15552 "Address Family modifier\n"
15553 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015554 "Display detailed information about dampening\n"
15555 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050015556
Lou Berger651b4022016-01-12 13:42:07 -050015557DEFUN (show_bgp_ipv6_safi_flap_statistics,
15558 show_bgp_ipv6_safi_flap_statistics_cmd,
15559 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
15560 SHOW_STR
15561 BGP_STR
15562 "Address Family\n"
15563 "Address Family modifier\n"
15564 "Address Family modifier\n"
15565 "Address Family modifier\n"
15566 "Address Family modifier\n"
15567 "Display flap statistics of routes\n")
15568{
15569 safi_t safi;
15570
15571 if (bgp_parse_safi(argv[0], &safi)) {
15572 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15573 return CMD_WARNING;
15574 }
15575
15576 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
15577}
15578ALIAS (show_bgp_ipv6_safi_flap_statistics,
15579 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
15580 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
15581 SHOW_STR
15582 BGP_STR
15583 "Address Family\n"
15584 "Address Family modifier\n"
15585 "Address Family modifier\n"
15586 "Address Family modifier\n"
15587 "Address Family modifier\n"
15588 "Display detailed information about dampening\n"
15589 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053015590
paul718e3742002-12-13 20:15:29 +000015591/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000015592static int
paulfd79ac92004-10-13 05:06:08 +000015593bgp_clear_damp_route (struct vty *vty, const char *view_name,
15594 const char *ip_str, afi_t afi, safi_t safi,
15595 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000015596{
15597 int ret;
15598 struct prefix match;
15599 struct bgp_node *rn;
15600 struct bgp_node *rm;
15601 struct bgp_info *ri;
15602 struct bgp_info *ri_temp;
15603 struct bgp *bgp;
15604 struct bgp_table *table;
15605
15606 /* BGP structure lookup. */
15607 if (view_name)
15608 {
15609 bgp = bgp_lookup_by_name (view_name);
15610 if (bgp == NULL)
15611 {
15612 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
15613 return CMD_WARNING;
15614 }
15615 }
15616 else
15617 {
15618 bgp = bgp_get_default ();
15619 if (bgp == NULL)
15620 {
15621 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
15622 return CMD_WARNING;
15623 }
15624 }
15625
15626 /* Check IP address argument. */
15627 ret = str2prefix (ip_str, &match);
15628 if (! ret)
15629 {
15630 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
15631 return CMD_WARNING;
15632 }
15633
15634 match.family = afi2family (afi);
15635
Lou Berger298cc2f2016-01-12 13:42:02 -050015636 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000015637 {
Lou Berger298cc2f2016-01-12 13:42:02 -050015638 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000015639 {
15640 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
15641 continue;
15642
15643 if ((table = rn->info) != NULL)
15644 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015645 {
15646 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
15647 {
15648 ri = rm->info;
15649 while (ri)
15650 {
15651 if (ri->extra && ri->extra->damp_info)
15652 {
15653 ri_temp = ri->next;
15654 bgp_damp_info_free (ri->extra->damp_info, 1);
15655 ri = ri_temp;
15656 }
15657 else
15658 ri = ri->next;
15659 }
15660 }
15661
15662 bgp_unlock_node (rm);
15663 }
paul718e3742002-12-13 20:15:29 +000015664 }
15665 }
15666 else
15667 {
15668 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015669 {
15670 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
15671 {
15672 ri = rn->info;
15673 while (ri)
15674 {
15675 if (ri->extra && ri->extra->damp_info)
15676 {
15677 ri_temp = ri->next;
15678 bgp_damp_info_free (ri->extra->damp_info, 1);
15679 ri = ri_temp;
15680 }
15681 else
15682 ri = ri->next;
15683 }
15684 }
15685
15686 bgp_unlock_node (rn);
15687 }
paul718e3742002-12-13 20:15:29 +000015688 }
15689
15690 return CMD_SUCCESS;
15691}
15692
15693DEFUN (clear_ip_bgp_dampening,
15694 clear_ip_bgp_dampening_cmd,
15695 "clear ip bgp dampening",
15696 CLEAR_STR
15697 IP_STR
15698 BGP_STR
15699 "Clear route flap dampening information\n")
15700{
15701 bgp_damp_info_clean ();
15702 return CMD_SUCCESS;
15703}
15704
15705DEFUN (clear_ip_bgp_dampening_prefix,
15706 clear_ip_bgp_dampening_prefix_cmd,
15707 "clear ip bgp dampening A.B.C.D/M",
15708 CLEAR_STR
15709 IP_STR
15710 BGP_STR
15711 "Clear route flap dampening information\n"
15712 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15713{
15714 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15715 SAFI_UNICAST, NULL, 1);
15716}
15717
15718DEFUN (clear_ip_bgp_dampening_address,
15719 clear_ip_bgp_dampening_address_cmd,
15720 "clear ip bgp dampening A.B.C.D",
15721 CLEAR_STR
15722 IP_STR
15723 BGP_STR
15724 "Clear route flap dampening information\n"
15725 "Network to clear damping information\n")
15726{
15727 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15728 SAFI_UNICAST, NULL, 0);
15729}
15730
15731DEFUN (clear_ip_bgp_dampening_address_mask,
15732 clear_ip_bgp_dampening_address_mask_cmd,
15733 "clear ip bgp dampening A.B.C.D A.B.C.D",
15734 CLEAR_STR
15735 IP_STR
15736 BGP_STR
15737 "Clear route flap dampening information\n"
15738 "Network to clear damping information\n"
15739 "Network mask\n")
15740{
15741 int ret;
15742 char prefix_str[BUFSIZ];
15743
15744 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
15745 if (! ret)
15746 {
15747 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
15748 return CMD_WARNING;
15749 }
15750
15751 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
15752 SAFI_UNICAST, NULL, 0);
15753}
David Lamparter6b0655a2014-06-04 06:53:35 +020015754
Lou Berger298cc2f2016-01-12 13:42:02 -050015755/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000015756static int
paul718e3742002-12-13 20:15:29 +000015757bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
15758 afi_t afi, safi_t safi, int *write)
15759{
15760 struct bgp_node *prn;
15761 struct bgp_node *rn;
15762 struct bgp_table *table;
15763 struct prefix *p;
15764 struct prefix_rd *prd;
15765 struct bgp_static *bgp_static;
15766 u_int32_t label;
15767 char buf[SU_ADDRSTRLEN];
15768 char rdbuf[RD_ADDRSTRLEN];
15769
15770 /* Network configuration. */
15771 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
15772 if ((table = prn->info) != NULL)
15773 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
15774 if ((bgp_static = rn->info) != NULL)
15775 {
15776 p = &rn->p;
15777 prd = (struct prefix_rd *) &prn->p;
15778
15779 /* "address-family" display. */
15780 bgp_config_write_family_header (vty, afi, safi, write);
15781
15782 /* "network" configuration display. */
15783 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
15784 label = decode_label (bgp_static->tag);
15785
15786 vty_out (vty, " network %s/%d rd %s tag %d",
15787 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15788 p->prefixlen,
15789 rdbuf, label);
15790 vty_out (vty, "%s", VTY_NEWLINE);
15791 }
15792 return 0;
15793}
15794
15795/* Configuration of static route announcement and aggregate
15796 information. */
15797int
15798bgp_config_write_network (struct vty *vty, struct bgp *bgp,
15799 afi_t afi, safi_t safi, int *write)
15800{
15801 struct bgp_node *rn;
15802 struct prefix *p;
15803 struct bgp_static *bgp_static;
15804 struct bgp_aggregate *bgp_aggregate;
15805 char buf[SU_ADDRSTRLEN];
15806
Lou Berger298cc2f2016-01-12 13:42:02 -050015807 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000015808 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
15809
15810 /* Network configuration. */
15811 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
15812 if ((bgp_static = rn->info) != NULL)
15813 {
15814 p = &rn->p;
15815
15816 /* "address-family" display. */
15817 bgp_config_write_family_header (vty, afi, safi, write);
15818
15819 /* "network" configuration display. */
15820 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15821 {
15822 u_int32_t destination;
15823 struct in_addr netmask;
15824
15825 destination = ntohl (p->u.prefix4.s_addr);
15826 masklen2ip (p->prefixlen, &netmask);
15827 vty_out (vty, " network %s",
15828 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
15829
15830 if ((IN_CLASSC (destination) && p->prefixlen == 24)
15831 || (IN_CLASSB (destination) && p->prefixlen == 16)
15832 || (IN_CLASSA (destination) && p->prefixlen == 8)
15833 || p->u.prefix4.s_addr == 0)
15834 {
15835 /* Natural mask is not display. */
15836 }
15837 else
15838 vty_out (vty, " mask %s", inet_ntoa (netmask));
15839 }
15840 else
15841 {
15842 vty_out (vty, " network %s/%d",
15843 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15844 p->prefixlen);
15845 }
15846
15847 if (bgp_static->rmap.name)
15848 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000015849 else
15850 {
15851 if (bgp_static->backdoor)
15852 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000015853 }
paul718e3742002-12-13 20:15:29 +000015854
15855 vty_out (vty, "%s", VTY_NEWLINE);
15856 }
15857
15858 /* Aggregate-address configuration. */
15859 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
15860 if ((bgp_aggregate = rn->info) != NULL)
15861 {
15862 p = &rn->p;
15863
15864 /* "address-family" display. */
15865 bgp_config_write_family_header (vty, afi, safi, write);
15866
15867 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15868 {
15869 struct in_addr netmask;
15870
15871 masklen2ip (p->prefixlen, &netmask);
15872 vty_out (vty, " aggregate-address %s %s",
15873 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15874 inet_ntoa (netmask));
15875 }
15876 else
15877 {
15878 vty_out (vty, " aggregate-address %s/%d",
15879 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15880 p->prefixlen);
15881 }
15882
15883 if (bgp_aggregate->as_set)
15884 vty_out (vty, " as-set");
15885
15886 if (bgp_aggregate->summary_only)
15887 vty_out (vty, " summary-only");
15888
15889 vty_out (vty, "%s", VTY_NEWLINE);
15890 }
15891
15892 return 0;
15893}
15894
15895int
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015896bgp_config_write_distance (struct vty *vty, struct bgp *bgp,
15897 afi_t afi, safi_t safi, int *write)
paul718e3742002-12-13 20:15:29 +000015898{
15899 struct bgp_node *rn;
15900 struct bgp_distance *bdistance;
15901
Roman Hoog Antink6184c392014-03-17 14:01:42 +010015902 if (afi == AFI_IP && safi == SAFI_UNICAST)
15903 {
15904 /* Distance configuration. */
15905 if (bgp->distance_ebgp
15906 && bgp->distance_ibgp
15907 && bgp->distance_local
15908 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
15909 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
15910 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
15911 vty_out (vty, " distance bgp %d %d %d%s",
15912 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
15913 VTY_NEWLINE);
15914
15915 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
15916 if ((bdistance = rn->info) != NULL)
15917 {
15918 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
15919 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
15920 bdistance->access_list ? bdistance->access_list : "",
15921 VTY_NEWLINE);
15922 }
15923 }
15924
15925#ifdef HAVE_IPV6
15926 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
15927 {
15928 bgp_config_write_family_header (vty, afi, safi, write);
15929 if (bgp->ipv6_distance_ebgp
15930 && bgp->ipv6_distance_ibgp
15931 && bgp->ipv6_distance_local
15932 && (bgp->ipv6_distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
15933 || bgp->ipv6_distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
15934 || bgp->ipv6_distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
15935 vty_out (vty, " distance bgp %d %d %d%s",
15936 bgp->ipv6_distance_ebgp, bgp->ipv6_distance_ibgp, bgp->ipv6_distance_local,
15937 VTY_NEWLINE);
15938
15939 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
15940 if ((bdistance = rn->info) != NULL)
15941 {
15942 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
15943 inet6_ntoa (rn->p.u.prefix6), rn->p.prefixlen,
15944 bdistance->access_list ? bdistance->access_list : "",
15945 VTY_NEWLINE);
15946 }
15947 }
15948#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000015949
15950 return 0;
15951}
15952
15953/* Allocate routing table structure and install commands. */
15954void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080015955bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000015956{
15957 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000015958 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000015959
15960 /* IPv4 BGP commands. */
15961 install_element (BGP_NODE, &bgp_network_cmd);
15962 install_element (BGP_NODE, &bgp_network_mask_cmd);
15963 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
15964 install_element (BGP_NODE, &bgp_network_route_map_cmd);
15965 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
15966 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
15967 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
15968 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
15969 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
15970 install_element (BGP_NODE, &no_bgp_network_cmd);
15971 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
15972 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
15973 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
15974 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
15975 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15976 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
15977 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
15978 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
15979
15980 install_element (BGP_NODE, &aggregate_address_cmd);
15981 install_element (BGP_NODE, &aggregate_address_mask_cmd);
15982 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
15983 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
15984 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
15985 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
15986 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
15987 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
15988 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
15989 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
15990 install_element (BGP_NODE, &no_aggregate_address_cmd);
15991 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
15992 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
15993 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
15994 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
15995 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
15996 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
15997 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
15998 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15999 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16000
16001 /* IPv4 unicast configuration. */
16002 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
16003 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
16004 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
16005 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
16006 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
16007 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016008 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000016009 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
16010 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
16011 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
16012 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
16013 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016014
paul718e3742002-12-13 20:15:29 +000016015 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
16016 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
16017 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
16018 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
16019 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
16020 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
16021 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
16022 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
16023 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
16024 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
16025 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
16026 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
16027 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
16028 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
16029 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
16030 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
16031 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
16032 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
16033 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16034 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16035
16036 /* IPv4 multicast configuration. */
16037 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
16038 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
16039 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
16040 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
16041 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
16042 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
16043 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
16044 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
16045 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
16046 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
16047 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
16048 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
16049 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
16050 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
16051 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
16052 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
16053 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
16054 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
16055 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
16056 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
16057 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
16058 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
16059 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
16060 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
16061 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
16062 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
16063 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
16064 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
16065 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
16066 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
16067 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
16068 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
16069
Michael Lambert95cbbd22010-07-23 14:43:04 -040016070 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016071 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016072 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
16073 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
16074 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16075 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16076 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
16077 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
16078 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16079 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16080 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016081 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016082 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16083 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16084 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16085 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16086 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16087 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16088 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
16089 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
16090 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16091 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
16092 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
16093 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
16094 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
16095 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
16096 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
16097 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
16098 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
16099 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
16100 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
16101 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
16102 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
16103 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
16104 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
16105 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
16106 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
16107 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
16108 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
16109 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016110 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16111 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
16112 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
16113 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
16114 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016115 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
16116 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
16117 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
16118 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
16119 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16120 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16121 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16122 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16123 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
16124 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16125 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16126 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16127 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16128 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16129 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16130 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16131 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16132 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16133 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016134 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016135 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16136 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16137 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16138 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16139 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16140 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16141 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16142 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16143 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16144 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16145 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16146 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16147 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16148 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
16149 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16150 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16151 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16152 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16153 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16154 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16155 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16156 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16157 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16158 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16159 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16160 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16161 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16162 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16163 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16164 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16165 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16166 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16167 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16168 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16169 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16170 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16171 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16172 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16173 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16174 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16175 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16176 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16177 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16178 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16179 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016180 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016181 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016182 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016183 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016184 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016185 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016186
16187 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040016188 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016189 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16190 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16191 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16192 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16193 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016194 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016195 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16196 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16197 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16198 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16199 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16200 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16201 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
16202 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16203 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
16204 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
16205 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
16206 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
16207 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
16208 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
16209 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
16210 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016211 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16212 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
16213 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
16214 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
16215 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016216 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
16217 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
16218 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
16219 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
16220 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16221 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16222 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16223 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016224 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016225 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016226 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016227 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016228
Michael Lambert95cbbd22010-07-23 14:43:04 -040016229 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016230 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016231 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd);
16232 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd);
16233 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16234 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16235 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_route_cmd);
16236 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_route_cmd);
16237 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16238 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16239 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016240 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016241 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16242 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16243 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16244 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16245 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16246 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16247 install_element (ENABLE_NODE, &show_bgp_afi_safi_view_cmd);
16248 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_route_cmd);
16249 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16250 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_regexp_cmd);
16251 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_regexp_cmd);
16252 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_list_cmd);
16253 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
16254 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
16255 install_element (ENABLE_NODE, &show_bgp_ipv4_filter_list_cmd);
16256 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
16257 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
16258 install_element (ENABLE_NODE, &show_bgp_ipv4_route_map_cmd);
16259 install_element (ENABLE_NODE, &show_bgp_ipv4_cidr_only_cmd);
16260 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
16261 install_element (ENABLE_NODE, &show_bgp_ipv4_community_cmd);
16262 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_cmd);
16263 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_cmd);
16264 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_cmd);
16265 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_cmd);
16266 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_cmd);
16267 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_cmd);
16268 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016269 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16270 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd);
16271 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd);
16272 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd);
16273 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016274 install_element (ENABLE_NODE, &show_bgp_ipv4_community_exact_cmd);
16275 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_exact_cmd);
16276 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_exact_cmd);
16277 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_exact_cmd);
16278 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16279 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16280 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16281 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16282 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_cmd);
16283 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16284 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16285 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16286 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16287 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16288 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16289 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16290 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16291 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16292 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016293 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016294 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16295 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16296 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16297 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16298 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16299 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16300 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16301 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16302 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16303 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16304 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16305 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16306 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16307 install_element (ENABLE_NODE, &show_bgp_ipv6_flap_address_cmd);
16308 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16309 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16310 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16311 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16312 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16313 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16314 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16315 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16316 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16317 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16318 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16319 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16320 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16321 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16322 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16323 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16324 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16325 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16326 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16327 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16328 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16329 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16330 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16331 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16332 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16333 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16334 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16335 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16336 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16337 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16338 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016339 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016340 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016341 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016342 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016343 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016344 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016345
16346 /* BGP dampening clear commands */
16347 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
16348 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
16349 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
16350 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
16351
Paul Jakmaff7924f2006-09-04 01:10:36 +000016352 /* prefix count */
Lou Berger651b4022016-01-12 13:42:07 -050016353 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_prefix_counts_cmd);
16354 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_prefix_counts_cmd);
Paul Jakmaff7924f2006-09-04 01:10:36 +000016355 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd);
16356
paul718e3742002-12-13 20:15:29 +000016357 /* New config IPv6 BGP commands. */
16358 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
16359 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
16360 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
16361 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
16362
16363 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
16364 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
16365 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
16366 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
16367
G.Balaji73bfe0b2011-09-23 22:36:20 +053016368 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
16369 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
16370
paul718e3742002-12-13 20:15:29 +000016371 /* Old config IPv6 BGP commands. */
16372 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
16373 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
16374
16375 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
16376 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
16377 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
16378 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
16379
Michael Lambert95cbbd22010-07-23 14:43:04 -040016380 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016381 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016382 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016383 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016384 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016385 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016386 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016387 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016388 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016389 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
16390 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
16391 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
16392 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
16393 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16394 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16395 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16396 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016397 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
paul718e3742002-12-13 20:15:29 +000016398 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016399 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016400 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016401 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016402 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016403 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016404 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016405 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
16406 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016407 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016408 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016409 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016410 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016411 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016412 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016413 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016414 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016415 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016416 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016417 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016418 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016419 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016420 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016421 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16422 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016423 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016424 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016425 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016426 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016427 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016428
16429 /* Restricted:
16430 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
16431 */
Paul Jakma62687ff2008-08-23 14:27:06 +010016432 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016433 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016434 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016435 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016436 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
16437 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
16438 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
16439 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
16440 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16441 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16442 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16443 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
16444 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016445 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016446 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016447 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016448 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016449 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016450 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016451 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016452 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016453 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016454 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016455
Michael Lambert95cbbd22010-07-23 14:43:04 -040016456 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016457 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016458 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016459 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016460 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016461 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016462 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016463 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016464 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016465 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_cmd);
16466 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_cmd);
16467 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_cmd);
16468 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_cmd);
16469 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16470 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16471 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16472 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016473 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016474 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016475 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016476 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016477 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016478 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016479 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016480 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016481 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016482 install_element (ENABLE_NODE, &show_bgp_ipv4_rsclient_cmd);
16483 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016484 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016485 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016486 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016487 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016488 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016489 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016490 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016491 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016492 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016493 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016494 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016495 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016496 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016497 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016498 install_element (ENABLE_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16499 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016500 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016501 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016502 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016503 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016504 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma2815e612006-09-14 02:56:07 +000016505
16506 /* Statistics */
16507 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016508 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000016509
16510 install_element (BGP_NODE, &bgp_distance_cmd);
16511 install_element (BGP_NODE, &no_bgp_distance_cmd);
16512 install_element (BGP_NODE, &no_bgp_distance2_cmd);
16513 install_element (BGP_NODE, &bgp_distance_source_cmd);
16514 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
16515 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
16516 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
Roman Hoog Antink6184c392014-03-17 14:01:42 +010016517#ifdef HAVE_IPV6
16518 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_cmd);
16519 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_cmd);
16520 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance2_cmd);
16521 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd);
16522 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd);
16523 install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd);
16524 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd);
16525#endif /* HAVE_IPV6 */
paul718e3742002-12-13 20:15:29 +000016526
16527 install_element (BGP_NODE, &bgp_damp_set_cmd);
16528 install_element (BGP_NODE, &bgp_damp_set2_cmd);
16529 install_element (BGP_NODE, &bgp_damp_set3_cmd);
16530 install_element (BGP_NODE, &bgp_damp_unset_cmd);
16531 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
16532 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
16533 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
16534 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
16535 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
16536 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Balaji9145f0e2016-01-20 22:59:27 +053016537
16538 /* IPv4 Multicast Mode */
16539 install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd);
16540 install_element (BGP_IPV4M_NODE, &bgp_damp_set2_cmd);
16541 install_element (BGP_IPV4M_NODE, &bgp_damp_set3_cmd);
16542 install_element (BGP_IPV4M_NODE, &bgp_damp_unset_cmd);
16543 install_element (BGP_IPV4M_NODE, &bgp_damp_unset2_cmd);
16544
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016545
16546 /* Deprecated AS-Pathlimit commands */
16547 install_element (BGP_NODE, &bgp_network_ttl_cmd);
16548 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
16549 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
16550 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
16551 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16552 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16553
16554 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
16555 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
16556 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16557 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
16558 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16559 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16560
16561 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
16562 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
16563 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
16564 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
16565 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16566 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16567
16568 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
16569 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
16570 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16571 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
16572 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16573 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16574
16575 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
16576 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
16577 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
16578 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
16579 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16580 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16581
16582 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
16583 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
16584 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16585 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
16586 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16587 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000016588
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016589 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
16590 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016591
16592 /* old style commands */
16593 install_element (VIEW_NODE, &show_ip_bgp_cmd);
16594 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
16595 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
16596 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
16597 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16598 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16599 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
16600 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16601 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16602 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16603 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
16604 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
16605 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
16606 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
16607 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16608 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
16609 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16610 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
16611 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16612 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
16613 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16614 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
16615 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16616 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
16617 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16618 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
16619 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
16620 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
16621 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
16622 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
16623 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
16624 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
16625 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
16626 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
16627 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
16628 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
16629 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
16630 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16631 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16632 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16633 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16634 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
16635 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16636 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
16637 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16638 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
16639 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16640 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16641 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16642 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16643 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16644 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
16645 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16646 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16647 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16648 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053016649 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016650 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053016651 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd);
16652 install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016653 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16654 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
16655 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16656 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
16657 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
16658 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
16659 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16660 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16661 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
16662 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
16663 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16664 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16665 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16666 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16667 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16668 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
16669 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16670 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
16671 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
16672 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
16673 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
16674 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16675 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16676 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16677 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
16678 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16679 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16680 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
16681 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
16682 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16683 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
16684 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16685 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16686 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16687 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
16688 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
16689 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
16690 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
16691 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
16692 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
16693 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
16694 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
16695 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
16696 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
16697 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
16698 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
16699 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
16700 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
16701 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16702 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16703 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16704 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16705 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
16706 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16707 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16708 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16709 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
16710 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
16711 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
16712 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
16713 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16714 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16715 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
16716 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16717 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16718 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16719 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
16720 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
16721 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
16722 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
16723 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16724 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
16725 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16726 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
16727 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16728 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
16729 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16730 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
16731 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16732 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
16733 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16734 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
16735 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
16736 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
16737 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
16738 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
16739 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
16740 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
16741 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
16742 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
16743 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
16744 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
16745 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
16746 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16747 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16748 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16749 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16750 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
16751 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16752 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
16753 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16754 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
16755 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16756 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16757 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16758 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16759 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16760 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
16761 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16762 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16763 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16764 install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd);
16765 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
Balaji9c52cae2016-01-20 22:59:26 +053016766 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd);
16767 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd);
16768 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016769 install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16770 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
16771 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16772 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
16773 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd);
16774 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
16775 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16776 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16777 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
16778 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd);
16779 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
16780 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16781 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16782 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16783 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16784 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16785 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
16786 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16787 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
16788 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
16789 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
16790 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
16791 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16792 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16793 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16794 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
16795 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16796 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16797 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
16798 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
16799 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
16800 install_element (VIEW_NODE, &show_bgp_cmd);
16801 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
16802 install_element (VIEW_NODE, &show_bgp_route_cmd);
16803 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
16804 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
16805 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
16806 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
16807 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
16808 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
16809 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
16810 install_element (VIEW_NODE, &show_bgp_community_cmd);
16811 install_element (VIEW_NODE, &show_bgp_community2_cmd);
16812 install_element (VIEW_NODE, &show_bgp_community3_cmd);
16813 install_element (VIEW_NODE, &show_bgp_community4_cmd);
16814 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
16815 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
16816 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
16817 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
16818 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16819 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
16820 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
16821 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
16822 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
16823 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
16824 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
16825 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16826 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
16827 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
16828 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
16829 install_element (VIEW_NODE, &show_bgp_view_cmd);
16830 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
16831 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
16832 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16833 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16834 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
16835 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16836 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
16837 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
16838 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
16839 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
16840 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
16841 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
16842 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
16843 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
16844 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
16845 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
16846 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
16847 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
16848 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
16849 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
16850 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
16851 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16852 install_element (ENABLE_NODE, &show_bgp_cmd);
16853 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
16854 install_element (ENABLE_NODE, &show_bgp_route_cmd);
16855 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
16856 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
16857 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
16858 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
16859 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
16860 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
16861 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
16862 install_element (ENABLE_NODE, &show_bgp_community_cmd);
16863 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
16864 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
16865 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
16866 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
16867 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
16868 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
16869 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
16870 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16871 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
16872 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
16873 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
16874 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
16875 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
16876 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16877 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
16878 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
16879 install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
16880 install_element (ENABLE_NODE, &show_bgp_view_cmd);
16881 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
16882 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
16883 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16884 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16885 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
16886 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16887 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
16888 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
16889 install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
16890 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
16891 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
16892 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
16893 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
16894 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
16895 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
16896 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
16897 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
16898 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
16899 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
16900 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
16901 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
16902 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
16903 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
16904 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
16905 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
16906 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
16907 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
16908 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16909 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16910 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
16911 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
16912 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
16913 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
16914 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16915 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
16916 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
16917 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
16918 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
16919 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
16920 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
16921 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
16922 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16923 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16924 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16925 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
16926 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16927 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16928 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
16929 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
16930 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
16931 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
16932 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
16933 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
16934 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
16935 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
16936 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
16937 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
16938 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
16939 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
16940 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
16941 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
16942 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
16943 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
16944 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16945 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16946 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
16947 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
16948 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
16949 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
16950 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16951 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
16952 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
16953 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
16954 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
16955 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
16956 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
16957 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
16958 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16959 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16960 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16961 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
16962 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16963 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16964 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16965 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16966 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16967 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16968 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16969 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16970 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16971 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16972 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
16973 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
16974 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16975 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16976 /* old with name safi collision */
16977 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
16978 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
16979 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
16980 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
16981 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
16982 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
16983 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
16984 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
16985 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
16986 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
16987 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
16988 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
16989 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
16990 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
16991 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
16992 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
16993 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
16994 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
16995 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
16996 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
16997 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
16998 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
16999 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
17000 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
17001 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
17002 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
17003 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
17004 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
17005
17006 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
17007 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
17008 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
17009 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
17010 install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
17011 install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
17012
17013 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
17014 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
17015 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
17016 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
17017 install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
17018 install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000017019}
Chris Caputo228da422009-07-18 05:44:03 +000017020
17021void
17022bgp_route_finish (void)
17023{
17024 bgp_table_unlock (bgp_distance_table);
17025 bgp_distance_table = NULL;
17026}