blob: b581fd9908828dbb0a641494935caa4ede09c8b4 [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
2124 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00002125 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
Paul Jakmafb982c22007-05-04 20:15:47 +00002126
paul718e3742002-12-13 20:15:29 +00002127 /* When peer's soft reconfiguration enabled. Record input packet in
2128 Adj-RIBs-In. */
Jorge Boncompte [DTI2]343aa822012-05-07 16:53:08 +00002129 if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2130 && peer != bgp->peer_self)
paul718e3742002-12-13 20:15:29 +00002131 bgp_adj_in_set (rn, peer, attr);
2132
2133 /* Check previously received route. */
2134 for (ri = rn->info; ri; ri = ri->next)
2135 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2136 break;
2137
2138 /* AS path local-as loop check. */
2139 if (peer->change_local_as)
2140 {
2141 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
2142 aspath_loop_count = 1;
2143
2144 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
2145 {
2146 reason = "as-path contains our own AS;";
2147 goto filtered;
2148 }
2149 }
2150
2151 /* AS path loop check. */
2152 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
2153 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
2154 && aspath_loop_check(attr->aspath, bgp->confed_id)
2155 > peer->allowas_in[afi][safi]))
2156 {
2157 reason = "as-path contains our own AS;";
2158 goto filtered;
2159 }
2160
2161 /* Route reflector originator ID check. */
2162 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00002163 && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +00002164 {
2165 reason = "originator is us;";
2166 goto filtered;
2167 }
2168
2169 /* Route reflector cluster ID check. */
2170 if (bgp_cluster_filter (peer, attr))
2171 {
2172 reason = "reflected from the same cluster;";
2173 goto filtered;
2174 }
2175
2176 /* Apply incoming filter. */
2177 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
2178 {
2179 reason = "filter;";
2180 goto filtered;
2181 }
2182
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002183 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00002184 bgp_attr_dup (&new_attr, attr);
paul718e3742002-12-13 20:15:29 +00002185
David Lamparterc460e572014-06-04 00:54:58 +02002186 /* Apply incoming route-map.
2187 * NB: new_attr may now contain newly allocated values from route-map "set"
2188 * commands, so we need bgp_attr_flush in the error paths, until we intern
2189 * the attr (which takes over the memory references) */
paul718e3742002-12-13 20:15:29 +00002190 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
2191 {
2192 reason = "route-map;";
David Lamparterc460e572014-06-04 00:54:58 +02002193 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002194 goto filtered;
2195 }
2196
2197 /* IPv4 unicast next hop check. */
2198 if (afi == AFI_IP && safi == SAFI_UNICAST)
2199 {
2200 /* If the peer is EBGP and nexthop is not on connected route,
2201 discard it. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002202 if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1
Denis Ovsienko8e80bdf2011-08-05 18:52:52 +04002203 && ! bgp_nexthop_onlink (afi, &new_attr)
hasso6ffd2072005-02-02 14:50:11 +00002204 && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
paul718e3742002-12-13 20:15:29 +00002205 {
2206 reason = "non-connected next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002207 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002208 goto filtered;
2209 }
2210
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04002211 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
paul718e3742002-12-13 20:15:29 +00002212 must not be my own address. */
Jorge Boncompte [DTI2]10f9bf32012-05-07 16:52:52 +00002213 if (new_attr.nexthop.s_addr == 0
2214 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
2215 || bgp_nexthop_self (&new_attr))
paul718e3742002-12-13 20:15:29 +00002216 {
2217 reason = "martian next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002218 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002219 goto filtered;
2220 }
2221 }
2222
2223 attr_new = bgp_attr_intern (&new_attr);
2224
2225 /* If the update is implicit withdraw. */
2226 if (ri)
2227 {
Stephen Hemminger65957882010-01-15 16:22:10 +03002228 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002229
2230 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00002231 if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
2232 && attrhash_cmp (ri->attr, attr_new))
paul718e3742002-12-13 20:15:29 +00002233 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002234 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00002235
2236 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002237 && peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00002238 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2239 {
2240 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002241 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002242 peer->host,
2243 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2244 p->prefixlen);
2245
paul902212c2006-02-05 17:51:19 +00002246 if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
2247 {
2248 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2249 bgp_process (bgp, rn, afi, safi);
2250 }
paul718e3742002-12-13 20:15:29 +00002251 }
Paul Jakma16d2e242007-04-10 19:32:10 +00002252 else /* Duplicate - odd */
paul718e3742002-12-13 20:15:29 +00002253 {
2254 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002255 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002256 "%s rcvd %s/%d...duplicate ignored",
2257 peer->host,
2258 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2259 p->prefixlen);
hasso93406d82005-02-02 14:40:33 +00002260
2261 /* graceful restart STALE flag unset. */
2262 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2263 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002264 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
paul902212c2006-02-05 17:51:19 +00002265 bgp_process (bgp, rn, afi, safi);
hasso93406d82005-02-02 14:40:33 +00002266 }
paul718e3742002-12-13 20:15:29 +00002267 }
2268
2269 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002270 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05002271 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002272
paul718e3742002-12-13 20:15:29 +00002273 return 0;
2274 }
2275
Paul Jakma16d2e242007-04-10 19:32:10 +00002276 /* Withdraw/Announce before we fully processed the withdraw */
2277 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2278 {
2279 if (BGP_DEBUG (update, UPDATE_IN))
2280 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
2281 peer->host,
2282 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2283 p->prefixlen);
2284 bgp_info_restore (rn, ri);
2285 }
2286
paul718e3742002-12-13 20:15:29 +00002287 /* Received Logging. */
2288 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002289 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002290 peer->host,
2291 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2292 p->prefixlen);
2293
hasso93406d82005-02-02 14:40:33 +00002294 /* graceful restart STALE flag unset. */
2295 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma1a392d42006-09-07 00:24:49 +00002296 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
hasso93406d82005-02-02 14:40:33 +00002297
paul718e3742002-12-13 20:15:29 +00002298 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002299 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul902212c2006-02-05 17:51:19 +00002300
2301 /* implicit withdraw, decrement aggregate and pcount here.
2302 * only if update is accepted, they'll increment below.
2303 */
paul902212c2006-02-05 17:51:19 +00002304 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2305
paul718e3742002-12-13 20:15:29 +00002306 /* Update bgp route dampening information. */
2307 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002308 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002309 {
2310 /* This is implicit withdraw so we should update dampening
2311 information. */
2312 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2313 bgp_damp_withdraw (ri, rn, afi, safi, 1);
paul718e3742002-12-13 20:15:29 +00002314 }
2315
paul718e3742002-12-13 20:15:29 +00002316 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002317 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00002318 ri->attr = attr_new;
2319
2320 /* Update MPLS tag. */
2321 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002322 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002323
Lou Berger050defe2016-01-12 13:41:59 -05002324 bgp_attr_flush (&new_attr);
2325
paul718e3742002-12-13 20:15:29 +00002326 /* Update bgp route dampening information. */
2327 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002328 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002329 {
2330 /* Now we do normal update dampening. */
2331 ret = bgp_damp_update (ri, rn, afi, safi);
2332 if (ret == BGP_DAMP_SUPPRESSED)
2333 {
2334 bgp_unlock_node (rn);
2335 return 0;
2336 }
2337 }
2338
2339 /* Nexthop reachability check. */
2340 if ((afi == AFI_IP || afi == AFI_IP6)
2341 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002342 && (peer->sort == BGP_PEER_IBGP
2343 || peer->sort == BGP_PEER_CONFED
2344 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002345 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002346 {
2347 if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002348 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002349 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002350 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002351 }
2352 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002353 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002354
Lou Berger050defe2016-01-12 13:41:59 -05002355 bgp_attr_flush (&new_attr);
2356
paul718e3742002-12-13 20:15:29 +00002357 /* Process change. */
2358 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2359
2360 bgp_process (bgp, rn, afi, safi);
2361 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002362
paul718e3742002-12-13 20:15:29 +00002363 return 0;
2364 }
2365
2366 /* Received Logging. */
2367 if (BGP_DEBUG (update, UPDATE_IN))
2368 {
ajsd2c1f162004-12-08 21:10:20 +00002369 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002370 peer->host,
2371 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2372 p->prefixlen);
2373 }
2374
paul718e3742002-12-13 20:15:29 +00002375 /* Make new BGP info. */
2376 new = bgp_info_new ();
2377 new->type = type;
2378 new->sub_type = sub_type;
2379 new->peer = peer;
2380 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002381 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002382
2383 /* Update MPLS tag. */
2384 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002385 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002386
2387 /* Nexthop reachability check. */
2388 if ((afi == AFI_IP || afi == AFI_IP6)
2389 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002390 && (peer->sort == BGP_PEER_IBGP
2391 || peer->sort == BGP_PEER_CONFED
2392 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002393 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002394 {
2395 if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002396 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002397 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002398 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002399 }
2400 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002401 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002402
paul902212c2006-02-05 17:51:19 +00002403 /* Increment prefix */
paul718e3742002-12-13 20:15:29 +00002404 bgp_aggregate_increment (bgp, p, new, afi, safi);
2405
2406 /* Register new BGP information. */
2407 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002408
2409 /* route_node_get lock */
2410 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002411
Lou Berger050defe2016-01-12 13:41:59 -05002412 bgp_attr_flush (&new_attr);
2413
paul718e3742002-12-13 20:15:29 +00002414 /* If maximum prefix count is configured and current prefix
2415 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00002416 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
2417 return -1;
paul718e3742002-12-13 20:15:29 +00002418
2419 /* Process change. */
2420 bgp_process (bgp, rn, afi, safi);
2421
2422 return 0;
2423
2424 /* This BGP update is filtered. Log the reason then update BGP
2425 entry. */
2426 filtered:
2427 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002428 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002429 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2430 peer->host,
2431 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2432 p->prefixlen, reason);
2433
2434 if (ri)
paulb40d9392005-08-22 22:34:41 +00002435 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002436
2437 bgp_unlock_node (rn);
Lou Berger050defe2016-01-12 13:41:59 -05002438 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002439
paul718e3742002-12-13 20:15:29 +00002440 return 0;
2441}
2442
2443int
paulfee0f4c2004-09-13 05:12:46 +00002444bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
2445 afi_t afi, safi_t safi, int type, int sub_type,
2446 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2447{
2448 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002449 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002450 struct bgp *bgp;
2451 int ret;
2452
2453 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
2454 soft_reconfig);
2455
2456 bgp = peer->bgp;
2457
2458 /* Process the update for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002459 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002460 {
2461 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2462 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
2463 sub_type, prd, tag);
2464 }
2465
2466 return ret;
2467}
2468
2469int
paul718e3742002-12-13 20:15:29 +00002470bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
paul94f2b392005-06-28 12:44:16 +00002471 afi_t afi, safi_t safi, int type, int sub_type,
2472 struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00002473{
2474 struct bgp *bgp;
2475 char buf[SU_ADDRSTRLEN];
2476 struct bgp_node *rn;
2477 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00002478 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002479 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002480
2481 bgp = peer->bgp;
2482
David Lamparter4584c232015-04-13 09:50:00 +02002483 /* Lookup node. */
2484 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2485
2486 /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2487 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2488 * the iteration over all RS clients.
2489 * Since we need to remove the entry from adj_in anyway, do that first and
2490 * if there was no entry, we don't need to do anything more. */
2491 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2492 && peer != bgp->peer_self)
2493 if (!bgp_adj_in_unset (rn, peer))
2494 {
2495 if (BGP_DEBUG (update, UPDATE_IN))
2496 zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
2497 "not in adj-in", peer->host,
2498 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2499 p->prefixlen);
2500 bgp_unlock_node (rn);
2501 return 0;
2502 }
2503
paulfee0f4c2004-09-13 05:12:46 +00002504 /* Process the withdraw for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002505 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002506 {
2507 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2508 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
2509 }
2510
paul718e3742002-12-13 20:15:29 +00002511 /* Logging. */
2512 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002513 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00002514 peer->host,
2515 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2516 p->prefixlen);
2517
paul718e3742002-12-13 20:15:29 +00002518 /* Lookup withdrawn route. */
2519 for (ri = rn->info; ri; ri = ri->next)
2520 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2521 break;
2522
2523 /* Withdraw specified route from routing table. */
2524 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002525 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paul718e3742002-12-13 20:15:29 +00002526 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002527 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002528 "%s Can't find the route %s/%d", peer->host,
2529 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2530 p->prefixlen);
2531
2532 /* Unlock bgp_node_get() lock. */
2533 bgp_unlock_node (rn);
2534
2535 return 0;
2536}
David Lamparter6b0655a2014-06-04 06:53:35 +02002537
paul718e3742002-12-13 20:15:29 +00002538void
2539bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2540{
2541 struct bgp *bgp;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00002542 struct attr attr;
Jorge Boncompte [DTI2]577ac572012-05-07 16:53:06 +00002543 struct aspath *aspath;
paul718e3742002-12-13 20:15:29 +00002544 struct prefix p;
paul718e3742002-12-13 20:15:29 +00002545 struct peer *from;
Christian Frankedcab1bb2012-12-07 16:45:52 +00002546 struct bgp_node *rn;
2547 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00002548 int ret = RMAP_DENYMATCH;
Paul Jakmafb982c22007-05-04 20:15:47 +00002549
Paul Jakmab2497022007-06-14 11:17:58 +00002550 if (!(afi == AFI_IP || afi == AFI_IP6))
Paul Jakmafb982c22007-05-04 20:15:47 +00002551 return;
2552
paul718e3742002-12-13 20:15:29 +00002553 bgp = peer->bgp;
2554 from = bgp->peer_self;
Paul Jakmafb982c22007-05-04 20:15:47 +00002555
paul718e3742002-12-13 20:15:29 +00002556 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2557 aspath = attr.aspath;
2558 attr.local_pref = bgp->default_local_pref;
2559 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2560
2561 if (afi == AFI_IP)
2562 str2prefix ("0.0.0.0/0", &p);
paul718e3742002-12-13 20:15:29 +00002563 else if (afi == AFI_IP6)
2564 {
Jorge Boncompte [DTI2]6182d652012-05-07 16:53:02 +00002565 struct attr_extra *ae = attr.extra;
2566
paul718e3742002-12-13 20:15:29 +00002567 str2prefix ("::/0", &p);
2568
2569 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00002570 memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00002571 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002572 ae->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00002573
2574 /* If the peer is on shared nextwork and we have link-local
2575 nexthop set it. */
2576 if (peer->shared_network
2577 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2578 {
Paul Jakmafb982c22007-05-04 20:15:47 +00002579 memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00002580 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002581 ae->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00002582 }
2583 }
paul718e3742002-12-13 20:15:29 +00002584
2585 if (peer->default_rmap[afi][safi].name)
2586 {
paulfee0f4c2004-09-13 05:12:46 +00002587 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
Christian Frankedcab1bb2012-12-07 16:45:52 +00002588 for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
2589 {
2590 for (ri = rn->info; ri; ri = ri->next)
2591 {
2592 struct attr dummy_attr;
2593 struct attr_extra dummy_extra;
2594 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00002595
Christian Frankedcab1bb2012-12-07 16:45:52 +00002596 /* Provide dummy so the route-map can't modify the attributes */
2597 dummy_attr.extra = &dummy_extra;
2598 bgp_attr_dup(&dummy_attr, ri->attr);
2599 info.peer = ri->peer;
2600 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00002601
Christian Frankedcab1bb2012-12-07 16:45:52 +00002602 ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
2603 RMAP_BGP, &info);
2604
2605 /* The route map might have set attributes. If we don't flush them
2606 * here, they will be leaked. */
2607 bgp_attr_flush(&dummy_attr);
2608 if (ret != RMAP_DENYMATCH)
2609 break;
2610 }
2611 if (ret != RMAP_DENYMATCH)
2612 break;
2613 }
paulfee0f4c2004-09-13 05:12:46 +00002614 bgp->peer_self->rmap_type = 0;
2615
paul718e3742002-12-13 20:15:29 +00002616 if (ret == RMAP_DENYMATCH)
Christian Frankedcab1bb2012-12-07 16:45:52 +00002617 withdraw = 1;
paul718e3742002-12-13 20:15:29 +00002618 }
2619
2620 if (withdraw)
2621 {
2622 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2623 bgp_default_withdraw_send (peer, afi, safi);
2624 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2625 }
2626 else
2627 {
Christian Frankedcab1bb2012-12-07 16:45:52 +00002628 if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2629 {
2630 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2631 bgp_default_update_send (peer, &attr, afi, safi, from);
2632 }
paul718e3742002-12-13 20:15:29 +00002633 }
Paul Jakmafb982c22007-05-04 20:15:47 +00002634
2635 bgp_attr_extra_free (&attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002636 aspath_unintern (&aspath);
paul718e3742002-12-13 20:15:29 +00002637}
David Lamparter6b0655a2014-06-04 06:53:35 +02002638
paul718e3742002-12-13 20:15:29 +00002639static void
2640bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002641 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002642{
2643 struct bgp_node *rn;
2644 struct bgp_info *ri;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002645 struct attr attr;
2646 struct attr_extra extra;
2647
Lou Berger298cc2f2016-01-12 13:42:02 -05002648 memset(&extra, 0, sizeof(extra));
2649
paul718e3742002-12-13 20:15:29 +00002650 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002651 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002652
Lou Berger298cc2f2016-01-12 13:42:02 -05002653 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00002654 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2655 bgp_default_originate (peer, afi, safi, 0);
2656
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002657 /* It's initialized in bgp_announce_[check|check_rsclient]() */
2658 attr.extra = &extra;
2659
paul718e3742002-12-13 20:15:29 +00002660 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2661 for (ri = rn->info; ri; ri = ri->next)
2662 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2663 {
paulfee0f4c2004-09-13 05:12:46 +00002664 if ( (rsclient) ?
2665 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2666 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002667 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2668 else
2669 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2670 }
Lou Berger298cc2f2016-01-12 13:42:02 -05002671
2672 bgp_attr_flush_encap(&attr);
paul718e3742002-12-13 20:15:29 +00002673}
2674
2675void
2676bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2677{
2678 struct bgp_node *rn;
2679 struct bgp_table *table;
2680
2681 if (peer->status != Established)
2682 return;
2683
2684 if (! peer->afc_nego[afi][safi])
2685 return;
2686
2687 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2688 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2689 return;
2690
Lou Berger298cc2f2016-01-12 13:42:02 -05002691 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
paulfee0f4c2004-09-13 05:12:46 +00002692 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002693 else
2694 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2695 rn = bgp_route_next(rn))
2696 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002697 bgp_announce_table (peer, afi, safi, table, 0);
2698
2699 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2700 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002701}
2702
2703void
2704bgp_announce_route_all (struct peer *peer)
2705{
2706 afi_t afi;
2707 safi_t safi;
2708
2709 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2710 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2711 bgp_announce_route (peer, afi, safi);
2712}
David Lamparter6b0655a2014-06-04 06:53:35 +02002713
paul718e3742002-12-13 20:15:29 +00002714static void
paulfee0f4c2004-09-13 05:12:46 +00002715bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002716 safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
paulfee0f4c2004-09-13 05:12:46 +00002717{
2718 struct bgp_node *rn;
2719 struct bgp_adj_in *ain;
2720
2721 if (! table)
2722 table = rsclient->bgp->rib[afi][safi];
2723
2724 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2725 for (ain = rn->adj_in; ain; ain = ain->next)
2726 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002727 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002728 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002729
paulfee0f4c2004-09-13 05:12:46 +00002730 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
Christian Franked53d8fd2013-01-28 07:14:43 +01002731 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
paulfee0f4c2004-09-13 05:12:46 +00002732 }
2733}
2734
2735void
2736bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2737{
2738 struct bgp_table *table;
2739 struct bgp_node *rn;
2740
Lou Berger298cc2f2016-01-12 13:42:02 -05002741 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002742 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
paulfee0f4c2004-09-13 05:12:46 +00002743
2744 else
2745 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2746 rn = bgp_route_next (rn))
2747 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002748 {
2749 struct prefix_rd prd;
2750 prd.family = AF_UNSPEC;
2751 prd.prefixlen = 64;
2752 memcpy(&prd.val, rn->p.u.val, 8);
2753
2754 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
2755 }
paulfee0f4c2004-09-13 05:12:46 +00002756}
David Lamparter6b0655a2014-06-04 06:53:35 +02002757
paulfee0f4c2004-09-13 05:12:46 +00002758static void
paul718e3742002-12-13 20:15:29 +00002759bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002760 struct bgp_table *table, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00002761{
2762 int ret;
2763 struct bgp_node *rn;
2764 struct bgp_adj_in *ain;
2765
2766 if (! table)
2767 table = peer->bgp->rib[afi][safi];
2768
2769 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2770 for (ain = rn->adj_in; ain; ain = ain->next)
2771 {
2772 if (ain->peer == peer)
2773 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002774 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002775 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002776
paul718e3742002-12-13 20:15:29 +00002777 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2778 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
Christian Franked53d8fd2013-01-28 07:14:43 +01002779 prd, tag, 1);
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002780
paul718e3742002-12-13 20:15:29 +00002781 if (ret < 0)
2782 {
2783 bgp_unlock_node (rn);
2784 return;
2785 }
2786 continue;
2787 }
2788 }
2789}
2790
2791void
2792bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2793{
2794 struct bgp_node *rn;
2795 struct bgp_table *table;
2796
2797 if (peer->status != Established)
2798 return;
2799
Lou Berger298cc2f2016-01-12 13:42:02 -05002800 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002801 bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002802 else
2803 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2804 rn = bgp_route_next (rn))
2805 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002806 {
2807 struct prefix_rd prd;
2808 prd.family = AF_UNSPEC;
2809 prd.prefixlen = 64;
2810 memcpy(&prd.val, rn->p.u.val, 8);
2811
2812 bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
2813 }
paul718e3742002-12-13 20:15:29 +00002814}
David Lamparter6b0655a2014-06-04 06:53:35 +02002815
Chris Caputo228da422009-07-18 05:44:03 +00002816
2817struct bgp_clear_node_queue
2818{
2819 struct bgp_node *rn;
2820 enum bgp_clear_route_type purpose;
2821};
2822
paul200df112005-06-01 11:17:05 +00002823static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00002824bgp_clear_route_node (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002825{
Chris Caputo228da422009-07-18 05:44:03 +00002826 struct bgp_clear_node_queue *cnq = data;
2827 struct bgp_node *rn = cnq->rn;
Paul Jakma64e580a2006-02-21 01:09:01 +00002828 struct peer *peer = wq->spec.data;
paul200df112005-06-01 11:17:05 +00002829 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002830 afi_t afi = bgp_node_table (rn)->afi;
2831 safi_t safi = bgp_node_table (rn)->safi;
paul200df112005-06-01 11:17:05 +00002832
Paul Jakma64e580a2006-02-21 01:09:01 +00002833 assert (rn && peer);
paul200df112005-06-01 11:17:05 +00002834
Paul Jakma64e580a2006-02-21 01:09:01 +00002835 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002836 if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
paul200df112005-06-01 11:17:05 +00002837 {
2838 /* graceful restart STALE flag set. */
Paul Jakma64e580a2006-02-21 01:09:01 +00002839 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2840 && peer->nsf[afi][safi]
paul200df112005-06-01 11:17:05 +00002841 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
Paul Jakma1a392d42006-09-07 00:24:49 +00002842 && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
2843 bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
paul200df112005-06-01 11:17:05 +00002844 else
Paul Jakma64e580a2006-02-21 01:09:01 +00002845 bgp_rib_remove (rn, ri, peer, afi, safi);
paul200df112005-06-01 11:17:05 +00002846 break;
2847 }
paul200df112005-06-01 11:17:05 +00002848 return WQ_SUCCESS;
2849}
2850
2851static void
paul0fb58d52005-11-14 14:31:49 +00002852bgp_clear_node_queue_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002853{
Chris Caputo228da422009-07-18 05:44:03 +00002854 struct bgp_clear_node_queue *cnq = data;
2855 struct bgp_node *rn = cnq->rn;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002856 struct bgp_table *table = bgp_node_table (rn);
Paul Jakma64e580a2006-02-21 01:09:01 +00002857
2858 bgp_unlock_node (rn);
Chris Caputo228da422009-07-18 05:44:03 +00002859 bgp_table_unlock (table);
2860 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
paul200df112005-06-01 11:17:05 +00002861}
2862
2863static void
paul94f2b392005-06-28 12:44:16 +00002864bgp_clear_node_complete (struct work_queue *wq)
paul200df112005-06-01 11:17:05 +00002865{
Paul Jakma64e580a2006-02-21 01:09:01 +00002866 struct peer *peer = wq->spec.data;
2867
Paul Jakma3e0c78e2006-03-06 18:06:53 +00002868 /* Tickle FSM to start moving again */
Paul Jakmaca058a32006-09-14 02:58:49 +00002869 BGP_EVENT_ADD (peer, Clearing_Completed);
Chris Caputo228da422009-07-18 05:44:03 +00002870
2871 peer_unlock (peer); /* bgp_clear_route */
paul200df112005-06-01 11:17:05 +00002872}
2873
2874static void
Paul Jakma64e580a2006-02-21 01:09:01 +00002875bgp_clear_node_queue_init (struct peer *peer)
paul200df112005-06-01 11:17:05 +00002876{
Paul Jakmaa2943652009-07-21 14:02:04 +01002877 char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
Paul Jakma64e580a2006-02-21 01:09:01 +00002878
Paul Jakmaa2943652009-07-21 14:02:04 +01002879 snprintf (wname, sizeof(wname), "clear %s", peer->host);
Paul Jakma64e580a2006-02-21 01:09:01 +00002880#undef CLEAR_QUEUE_NAME_LEN
2881
2882 if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
paul200df112005-06-01 11:17:05 +00002883 {
2884 zlog_err ("%s: Failed to allocate work queue", __func__);
2885 exit (1);
2886 }
Paul Jakma64e580a2006-02-21 01:09:01 +00002887 peer->clear_node_queue->spec.hold = 10;
2888 peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
2889 peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
2890 peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
2891 peer->clear_node_queue->spec.max_retries = 0;
2892
2893 /* we only 'lock' this peer reference when the queue is actually active */
2894 peer->clear_node_queue->spec.data = peer;
paul200df112005-06-01 11:17:05 +00002895}
2896
paul718e3742002-12-13 20:15:29 +00002897static void
2898bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
Chris Caputo228da422009-07-18 05:44:03 +00002899 struct bgp_table *table, struct peer *rsclient,
2900 enum bgp_clear_route_type purpose)
paul718e3742002-12-13 20:15:29 +00002901{
2902 struct bgp_node *rn;
paul200df112005-06-01 11:17:05 +00002903
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002904
paul718e3742002-12-13 20:15:29 +00002905 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002906 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
Paul Jakma64e580a2006-02-21 01:09:01 +00002907
hasso6cf159b2005-03-21 10:28:14 +00002908 /* If still no table => afi/safi isn't configured at all or smth. */
2909 if (! table)
2910 return;
Paul Jakma65ca75e2006-05-04 08:08:15 +00002911
2912 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2913 {
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002914 struct bgp_info *ri;
2915 struct bgp_adj_in *ain;
2916 struct bgp_adj_out *aout;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002917
2918 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2919 * queued for every clearing peer, regardless of whether it is
2920 * relevant to the peer at hand.
2921 *
2922 * Overview: There are 3 different indices which need to be
2923 * scrubbed, potentially, when a peer is removed:
2924 *
2925 * 1 peer's routes visible via the RIB (ie accepted routes)
2926 * 2 peer's routes visible by the (optional) peer's adj-in index
2927 * 3 other routes visible by the peer's adj-out index
2928 *
2929 * 3 there is no hurry in scrubbing, once the struct peer is
2930 * removed from bgp->peer, we could just GC such deleted peer's
2931 * adj-outs at our leisure.
2932 *
2933 * 1 and 2 must be 'scrubbed' in some way, at least made
2934 * invisible via RIB index before peer session is allowed to be
2935 * brought back up. So one needs to know when such a 'search' is
2936 * complete.
2937 *
2938 * Ideally:
2939 *
2940 * - there'd be a single global queue or a single RIB walker
2941 * - rather than tracking which route_nodes still need to be
2942 * examined on a peer basis, we'd track which peers still
2943 * aren't cleared
2944 *
2945 * Given that our per-peer prefix-counts now should be reliable,
2946 * this may actually be achievable. It doesn't seem to be a huge
2947 * problem at this time,
2948 */
Jorge Boncompte [DTI2]24e50f22012-05-07 15:17:33 +00002949 for (ain = rn->adj_in; ain; ain = ain->next)
2950 if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2951 {
2952 bgp_adj_in_remove (rn, ain);
2953 bgp_unlock_node (rn);
2954 break;
2955 }
2956 for (aout = rn->adj_out; aout; aout = aout->next)
2957 if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2958 {
2959 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2960 bgp_unlock_node (rn);
2961 break;
2962 }
2963
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002964 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002965 if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002966 {
Chris Caputo228da422009-07-18 05:44:03 +00002967 struct bgp_clear_node_queue *cnq;
2968
2969 /* both unlocked in bgp_clear_node_queue_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07002970 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00002971 bgp_lock_node (rn);
2972 cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
2973 sizeof (struct bgp_clear_node_queue));
2974 cnq->rn = rn;
2975 cnq->purpose = purpose;
2976 work_queue_add (peer->clear_node_queue, cnq);
2977 break;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002978 }
Paul Jakma65ca75e2006-05-04 08:08:15 +00002979 }
2980 return;
2981}
2982
2983void
Chris Caputo228da422009-07-18 05:44:03 +00002984bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
2985 enum bgp_clear_route_type purpose)
Paul Jakma65ca75e2006-05-04 08:08:15 +00002986{
2987 struct bgp_node *rn;
2988 struct bgp_table *table;
2989 struct peer *rsclient;
2990 struct listnode *node, *nnode;
hasso6cf159b2005-03-21 10:28:14 +00002991
Paul Jakma64e580a2006-02-21 01:09:01 +00002992 if (peer->clear_node_queue == NULL)
2993 bgp_clear_node_queue_init (peer);
paul200df112005-06-01 11:17:05 +00002994
Paul Jakmaca058a32006-09-14 02:58:49 +00002995 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2996 * Idle until it receives a Clearing_Completed event. This protects
2997 * against peers which flap faster than we can we clear, which could
2998 * lead to:
Paul Jakma64e580a2006-02-21 01:09:01 +00002999 *
3000 * a) race with routes from the new session being installed before
3001 * clear_route_node visits the node (to delete the route of that
3002 * peer)
3003 * b) resource exhaustion, clear_route_node likely leads to an entry
3004 * on the process_main queue. Fast-flapping could cause that queue
3005 * to grow and grow.
paul200df112005-06-01 11:17:05 +00003006 */
Donald Sharp7ef42212015-03-30 06:32:52 -07003007
3008 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3009 * the unlock will happen upon work-queue completion; other wise, the
3010 * unlock happens at the end of this function.
3011 */
Paul Jakmaca058a32006-09-14 02:58:49 +00003012 if (!peer->clear_node_queue->thread)
Lou Berger050defe2016-01-12 13:41:59 -05003013 peer_lock (peer); /* bgp_clear_node_complete */
Chris Caputo228da422009-07-18 05:44:03 +00003014 switch (purpose)
paulfee0f4c2004-09-13 05:12:46 +00003015 {
Chris Caputo228da422009-07-18 05:44:03 +00003016 case BGP_CLEAR_ROUTE_NORMAL:
Lou Berger298cc2f2016-01-12 13:42:02 -05003017 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Chris Caputo228da422009-07-18 05:44:03 +00003018 bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
3019 else
3020 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
3021 rn = bgp_route_next (rn))
3022 if ((table = rn->info) != NULL)
3023 bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
3024
3025 for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
3026 if (CHECK_FLAG(rsclient->af_flags[afi][safi],
3027 PEER_FLAG_RSERVER_CLIENT))
3028 bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
3029 break;
3030
3031 case BGP_CLEAR_ROUTE_MY_RSCLIENT:
Lou Berger050defe2016-01-12 13:41:59 -05003032 /*
3033 * gpz 091009: TBD why don't we have special handling for
3034 * SAFI_MPLS_VPN here in the original quagga code?
3035 * (and, by extension, for SAFI_ENCAP)
3036 */
Chris Caputo228da422009-07-18 05:44:03 +00003037 bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
3038 break;
3039
3040 default:
3041 assert (0);
3042 break;
paulfee0f4c2004-09-13 05:12:46 +00003043 }
Donald Sharp7ef42212015-03-30 06:32:52 -07003044
3045 /* unlock if no nodes got added to the clear-node-queue. */
Paul Jakma65ca75e2006-05-04 08:08:15 +00003046 if (!peer->clear_node_queue->thread)
Donald Sharp7ef42212015-03-30 06:32:52 -07003047 peer_unlock (peer);
3048
paul718e3742002-12-13 20:15:29 +00003049}
3050
3051void
3052bgp_clear_route_all (struct peer *peer)
3053{
3054 afi_t afi;
3055 safi_t safi;
3056
3057 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3058 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
Chris Caputo228da422009-07-18 05:44:03 +00003059 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
paul718e3742002-12-13 20:15:29 +00003060}
3061
Lou Berger82dd7072016-01-12 13:41:57 -05003062/*
3063 * Finish freeing things when exiting
3064 */
3065static void
3066bgp_drain_workqueue_immediate (struct work_queue *wq)
3067{
3068 if (!wq)
3069 return;
3070
3071 if (!wq->thread)
3072 {
3073 /*
3074 * no thread implies no queued items
3075 */
3076 assert(!wq->items->count);
3077 return;
3078 }
3079
3080 while (wq->items->count)
3081 {
3082 if (wq->thread)
3083 thread_cancel(wq->thread);
3084 work_queue_run(wq->thread);
3085 }
3086}
3087
3088/*
3089 * Special function to process clear node queue when bgpd is exiting
3090 * and the thread scheduler is no longer running.
3091 */
3092void
3093bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
3094{
3095 if (!peer)
3096 return;
3097
3098 bgp_drain_workqueue_immediate(peer->clear_node_queue);
3099}
3100
3101/*
3102 * The work queues are not specific to a BGP instance, but the
3103 * items in them refer to BGP instances, so this should be called
3104 * before each BGP instance is deleted.
3105 */
3106void
3107bgp_process_queues_drain_immediate(void)
3108{
3109 bgp_drain_workqueue_immediate(bm->process_main_queue);
3110 bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
3111}
3112
paul718e3742002-12-13 20:15:29 +00003113void
3114bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
3115{
3116 struct bgp_table *table;
3117 struct bgp_node *rn;
3118 struct bgp_adj_in *ain;
3119
3120 table = peer->bgp->rib[afi][safi];
3121
3122 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3123 for (ain = rn->adj_in; ain ; ain = ain->next)
3124 if (ain->peer == peer)
3125 {
3126 bgp_adj_in_remove (rn, ain);
3127 bgp_unlock_node (rn);
3128 break;
3129 }
3130}
hasso93406d82005-02-02 14:40:33 +00003131
3132void
3133bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
3134{
3135 struct bgp_node *rn;
3136 struct bgp_info *ri;
3137 struct bgp_table *table;
3138
3139 table = peer->bgp->rib[afi][safi];
3140
3141 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3142 {
3143 for (ri = rn->info; ri; ri = ri->next)
3144 if (ri->peer == peer)
3145 {
3146 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
3147 bgp_rib_remove (rn, ri, peer, afi, safi);
3148 break;
3149 }
3150 }
3151}
David Lamparter6b0655a2014-06-04 06:53:35 +02003152
Lou Berger82dd7072016-01-12 13:41:57 -05003153static void
3154bgp_cleanup_table(struct bgp_table *table, safi_t safi)
3155{
3156 struct bgp_node *rn;
3157 struct bgp_info *ri;
3158 struct bgp_info *next;
3159
3160 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3161 for (ri = rn->info; ri; ri = next)
3162 {
3163 next = ri->next;
3164 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
3165 && ri->type == ZEBRA_ROUTE_BGP
3166 && ri->sub_type == BGP_ROUTE_NORMAL)
3167 bgp_zebra_withdraw (&rn->p, ri, safi);
3168 }
3169}
3170
paul718e3742002-12-13 20:15:29 +00003171/* Delete all kernel routes. */
3172void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003173bgp_cleanup_routes (void)
paul718e3742002-12-13 20:15:29 +00003174{
3175 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00003176 struct listnode *node, *nnode;
Lou Berger82dd7072016-01-12 13:41:57 -05003177 afi_t afi;
paul718e3742002-12-13 20:15:29 +00003178
paul1eb8ef22005-04-07 07:30:20 +00003179 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00003180 {
Lou Berger82dd7072016-01-12 13:41:57 -05003181 for (afi = AFI_IP; afi < AFI_MAX; ++afi)
3182 {
3183 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00003184
Lou Berger82dd7072016-01-12 13:41:57 -05003185 bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00003186
Lou Berger82dd7072016-01-12 13:41:57 -05003187 /*
3188 * VPN and ENCAP tables are two-level (RD is top level)
3189 */
3190 for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
3191 rn = bgp_route_next (rn))
Lou Berger298cc2f2016-01-12 13:42:02 -05003192 {
3193 if (rn->info)
Lou Berger82dd7072016-01-12 13:41:57 -05003194 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003195 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
3196 bgp_table_finish ((struct bgp_table **)&(rn->info));
3197 rn->info = NULL;
3198 bgp_unlock_node(rn);
Lou Berger82dd7072016-01-12 13:41:57 -05003199 }
Lou Berger298cc2f2016-01-12 13:42:02 -05003200 }
3201
3202 for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
3203 rn = bgp_route_next (rn))
3204 {
3205 if (rn->info)
3206 {
3207 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
3208 bgp_table_finish ((struct bgp_table **)&(rn->info));
3209 rn->info = NULL;
3210 bgp_unlock_node(rn);
3211 }
3212 }
Lou Berger82dd7072016-01-12 13:41:57 -05003213 }
paul718e3742002-12-13 20:15:29 +00003214 }
3215}
3216
3217void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003218bgp_reset (void)
paul718e3742002-12-13 20:15:29 +00003219{
3220 vty_reset ();
3221 bgp_zclient_reset ();
3222 access_list_reset ();
3223 prefix_list_reset ();
3224}
David Lamparter6b0655a2014-06-04 06:53:35 +02003225
paul718e3742002-12-13 20:15:29 +00003226/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3227 value. */
3228int
Paul Jakma518a4b72016-02-04 13:27:04 +00003229bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
3230 struct bgp_nlri *packet)
paul718e3742002-12-13 20:15:29 +00003231{
3232 u_char *pnt;
3233 u_char *lim;
3234 struct prefix p;
3235 int psize;
3236 int ret;
3237
3238 /* Check peer status. */
3239 if (peer->status != Established)
3240 return 0;
3241
3242 pnt = packet->nlri;
3243 lim = pnt + packet->length;
3244
3245 for (; pnt < lim; pnt += psize)
3246 {
3247 /* Clear prefix structure. */
3248 memset (&p, 0, sizeof (struct prefix));
3249
3250 /* Fetch prefix length. */
3251 p.prefixlen = *pnt++;
3252 p.family = afi2family (packet->afi);
3253
3254 /* Already checked in nlri_sanity_check(). We do double check
3255 here. */
3256 if ((packet->afi == AFI_IP && p.prefixlen > 32)
3257 || (packet->afi == AFI_IP6 && p.prefixlen > 128))
3258 return -1;
3259
3260 /* Packet size overflow check. */
3261 psize = PSIZE (p.prefixlen);
3262
3263 /* When packet overflow occur return immediately. */
3264 if (pnt + psize > lim)
3265 return -1;
3266
3267 /* Fetch prefix from NLRI packet. */
3268 memcpy (&p.u.prefix, pnt, psize);
3269
3270 /* Check address. */
3271 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
3272 {
3273 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
3274 {
paulf5ba3872004-07-09 12:11:31 +00003275 /*
3276 * From draft-ietf-idr-bgp4-22, Section 6.3:
3277 * If a BGP router receives an UPDATE message with a
3278 * semantically incorrect NLRI field, in which a prefix is
3279 * semantically incorrect (eg. an unexpected multicast IP
3280 * address), it should ignore the prefix.
3281 */
paul718e3742002-12-13 20:15:29 +00003282 zlog (peer->log, LOG_ERR,
3283 "IPv4 unicast NLRI is multicast address %s",
3284 inet_ntoa (p.u.prefix4));
paulf5ba3872004-07-09 12:11:31 +00003285
paul718e3742002-12-13 20:15:29 +00003286 return -1;
3287 }
3288 }
3289
paul718e3742002-12-13 20:15:29 +00003290 /* Check address. */
3291 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
3292 {
3293 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3294 {
3295 char buf[BUFSIZ];
3296
3297 zlog (peer->log, LOG_WARNING,
3298 "IPv6 link-local NLRI received %s ignore this NLRI",
3299 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3300
3301 continue;
3302 }
3303 }
paul718e3742002-12-13 20:15:29 +00003304
3305 /* Normal process. */
3306 if (attr)
3307 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
3308 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
3309 else
3310 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
3311 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
3312
3313 /* Address family configuration mismatch or maximum-prefix count
3314 overflow. */
3315 if (ret < 0)
3316 return -1;
3317 }
3318
3319 /* Packet length consistency check. */
3320 if (pnt != lim)
3321 return -1;
3322
3323 return 0;
3324}
3325
Paul Jakma18ab08b2016-01-27 16:37:33 +00003326static int
3327bgp_nlri_sanity_check_ip (struct peer *peer, struct bgp_nlri *nlri)
paul718e3742002-12-13 20:15:29 +00003328{
3329 u_char *end;
3330 u_char prefixlen;
3331 int psize;
Paul Jakma18ab08b2016-01-27 16:37:33 +00003332 u_char *pnt = nlri->nlri;
3333 afi_t afi = nlri->afi;
3334 safi_t safi = nlri->safi;
3335 end = pnt + nlri->length;
paul718e3742002-12-13 20:15:29 +00003336
3337 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3338 syntactic validity. If the field is syntactically incorrect,
3339 then the Error Subcode is set to Invalid Network Field. */
3340
3341 while (pnt < end)
3342 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003343 int badlength;
paul718e3742002-12-13 20:15:29 +00003344 prefixlen = *pnt++;
3345
3346 /* Prefix length check. */
Lou Berger298cc2f2016-01-12 13:42:02 -05003347 badlength = 0;
3348 if (safi == SAFI_ENCAP) {
3349 if (prefixlen > 128)
3350 badlength = 1;
3351 } else {
3352 if ((afi == AFI_IP && prefixlen > 32) ||
3353 (afi == AFI_IP6 && prefixlen > 128)) {
3354
3355 badlength = 1;
3356 }
3357 }
3358 if (badlength)
paul718e3742002-12-13 20:15:29 +00003359 {
3360 plog_err (peer->log,
3361 "%s [Error] Update packet error (wrong prefix length %d)",
3362 peer->host, prefixlen);
3363 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
3364 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
3365 return -1;
3366 }
3367
3368 /* Packet size overflow check. */
3369 psize = PSIZE (prefixlen);
3370
3371 if (pnt + psize > end)
3372 {
3373 plog_err (peer->log,
3374 "%s [Error] Update packet error"
3375 " (prefix data overflow prefix size is %d)",
3376 peer->host, psize);
3377 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
3378 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
3379 return -1;
3380 }
3381
3382 pnt += psize;
3383 }
3384
3385 /* Packet length consistency check. */
3386 if (pnt != end)
3387 {
3388 plog_err (peer->log,
3389 "%s [Error] Update packet error"
3390 " (prefix length mismatch with total length)",
3391 peer->host);
3392 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
3393 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
3394 return -1;
3395 }
3396 return 0;
3397}
David Lamparter6b0655a2014-06-04 06:53:35 +02003398
Paul Jakma18ab08b2016-01-27 16:37:33 +00003399int
3400bgp_nlri_sanity_check (struct peer *peer, struct bgp_nlri *nlri)
3401{
3402 switch (nlri->safi)
3403 {
3404 case SAFI_MPLS_LABELED_VPN:
Paul Jakma518a4b72016-02-04 13:27:04 +00003405 case SAFI_MPLS_VPN:
Paul Jakma18ab08b2016-01-27 16:37:33 +00003406 return bgp_nlri_sanity_check_vpn (peer, nlri);
3407 case SAFI_UNICAST:
3408 case SAFI_MULTICAST:
3409 return bgp_nlri_sanity_check_ip (peer, nlri);
3410 default: return -1;
3411 }
3412}
3413
paul94f2b392005-06-28 12:44:16 +00003414static struct bgp_static *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003415bgp_static_new (void)
paul718e3742002-12-13 20:15:29 +00003416{
Stephen Hemminger393deb92008-08-18 14:13:29 -07003417 return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
paul718e3742002-12-13 20:15:29 +00003418}
3419
paul94f2b392005-06-28 12:44:16 +00003420static void
paul718e3742002-12-13 20:15:29 +00003421bgp_static_free (struct bgp_static *bgp_static)
3422{
3423 if (bgp_static->rmap.name)
3424 free (bgp_static->rmap.name);
3425 XFREE (MTYPE_BGP_STATIC, bgp_static);
3426}
3427
paul94f2b392005-06-28 12:44:16 +00003428static void
paulfee0f4c2004-09-13 05:12:46 +00003429bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
3430 struct prefix *p, afi_t afi, safi_t safi)
3431{
3432 struct bgp_node *rn;
3433 struct bgp_info *ri;
3434
3435 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3436
3437 /* Check selected route and self inserted route. */
3438 for (ri = rn->info; ri; ri = ri->next)
3439 if (ri->peer == bgp->peer_self
3440 && ri->type == ZEBRA_ROUTE_BGP
3441 && ri->sub_type == BGP_ROUTE_STATIC)
3442 break;
3443
3444 /* Withdraw static BGP route from routing table. */
3445 if (ri)
3446 {
paulfee0f4c2004-09-13 05:12:46 +00003447 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003448 bgp_process (bgp, rn, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003449 }
3450
3451 /* Unlock bgp_node_lookup. */
3452 bgp_unlock_node (rn);
3453}
3454
paul94f2b392005-06-28 12:44:16 +00003455static void
paulfee0f4c2004-09-13 05:12:46 +00003456bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
Paul Jakmafb982c22007-05-04 20:15:47 +00003457 struct bgp_static *bgp_static,
3458 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00003459{
3460 struct bgp_node *rn;
3461 struct bgp_info *ri;
3462 struct bgp_info *new;
3463 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00003464 struct attr *attr_new;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003465 struct attr attr;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003466 struct attr new_attr;
3467 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00003468 struct bgp *bgp;
3469 int ret;
3470 char buf[SU_ADDRSTRLEN];
3471
3472 bgp = rsclient->bgp;
3473
Paul Jakma06e110f2006-05-12 23:29:22 +00003474 assert (bgp_static);
3475 if (!bgp_static)
3476 return;
3477
paulfee0f4c2004-09-13 05:12:46 +00003478 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3479
3480 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakma06e110f2006-05-12 23:29:22 +00003481
3482 attr.nexthop = bgp_static->igpnexthop;
3483 attr.med = bgp_static->igpmetric;
3484 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Paul Jakma41367172007-08-06 15:24:51 +00003485
Paul Jakma41367172007-08-06 15:24:51 +00003486 if (bgp_static->atomic)
3487 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3488
paulfee0f4c2004-09-13 05:12:46 +00003489 /* Apply network route-map for export to this rsclient. */
3490 if (bgp_static->rmap.name)
3491 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003492 struct attr attr_tmp = attr;
paulfee0f4c2004-09-13 05:12:46 +00003493 info.peer = rsclient;
Paul Jakmafb982c22007-05-04 20:15:47 +00003494 info.attr = &attr_tmp;
3495
paulfee0f4c2004-09-13 05:12:46 +00003496 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
3497 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
3498
3499 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3500
3501 rsclient->rmap_type = 0;
3502
3503 if (ret == RMAP_DENYMATCH)
3504 {
3505 /* Free uninterned attribute. */
Paul Jakmafb982c22007-05-04 20:15:47 +00003506 bgp_attr_flush (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003507
3508 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003509 aspath_unintern (&attr.aspath);
paulfee0f4c2004-09-13 05:12:46 +00003510 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
Paul Jakmafb982c22007-05-04 20:15:47 +00003511 bgp_attr_extra_free (&attr);
3512
paulfee0f4c2004-09-13 05:12:46 +00003513 return;
3514 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003515 attr_new = bgp_attr_intern (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003516 }
3517 else
3518 attr_new = bgp_attr_intern (&attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003519
3520 new_attr.extra = &new_extra;
Stephen Hemminger7badc262010-08-05 10:26:31 -07003521 bgp_attr_dup(&new_attr, attr_new);
Paul Jakmafb982c22007-05-04 20:15:47 +00003522
paulfee0f4c2004-09-13 05:12:46 +00003523 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3524
Paul Jakmafb982c22007-05-04 20:15:47 +00003525 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi)
3526 == RMAP_DENY)
3527 {
paulfee0f4c2004-09-13 05:12:46 +00003528 /* This BGP update is filtered. Log the reason then update BGP entry. */
3529 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00003530 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00003531 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3532 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
3533 p->prefixlen, rsclient->host);
3534
3535 bgp->peer_self->rmap_type = 0;
3536
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003537 bgp_attr_unintern (&attr_new);
3538 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003539 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003540
3541 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3542
3543 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003544 }
paulfee0f4c2004-09-13 05:12:46 +00003545
3546 bgp->peer_self->rmap_type = 0;
3547
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003548 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00003549 attr_new = bgp_attr_intern (&new_attr);
3550
3551 for (ri = rn->info; ri; ri = ri->next)
3552 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3553 && ri->sub_type == BGP_ROUTE_STATIC)
3554 break;
3555
3556 if (ri)
3557 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003558 if (attrhash_cmp (ri->attr, attr_new) &&
3559 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paulfee0f4c2004-09-13 05:12:46 +00003560 {
3561 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003562 bgp_attr_unintern (&attr_new);
3563 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003564 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003565 return;
3566 }
3567 else
3568 {
3569 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003570 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00003571
3572 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003573 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3574 bgp_info_restore(rn, ri);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003575 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00003576 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003577 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003578
3579 /* Process change. */
3580 bgp_process (bgp, rn, afi, safi);
3581 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003582 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003583 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003584 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003585 }
paulfee0f4c2004-09-13 05:12:46 +00003586 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003587
paulfee0f4c2004-09-13 05:12:46 +00003588 /* Make new BGP info. */
3589 new = bgp_info_new ();
3590 new->type = ZEBRA_ROUTE_BGP;
3591 new->sub_type = BGP_ROUTE_STATIC;
3592 new->peer = bgp->peer_self;
3593 SET_FLAG (new->flags, BGP_INFO_VALID);
3594 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003595 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003596
3597 /* Register new BGP information. */
3598 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003599
3600 /* route_node_get lock */
3601 bgp_unlock_node (rn);
3602
paulfee0f4c2004-09-13 05:12:46 +00003603 /* Process change. */
3604 bgp_process (bgp, rn, afi, safi);
3605
3606 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003607 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003608 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003609}
3610
paul94f2b392005-06-28 12:44:16 +00003611static void
paulfee0f4c2004-09-13 05:12:46 +00003612bgp_static_update_main (struct bgp *bgp, struct prefix *p,
paul718e3742002-12-13 20:15:29 +00003613 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3614{
3615 struct bgp_node *rn;
3616 struct bgp_info *ri;
3617 struct bgp_info *new;
3618 struct bgp_info info;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003619 struct attr attr;
paul718e3742002-12-13 20:15:29 +00003620 struct attr *attr_new;
3621 int ret;
3622
Paul Jakmadd8103a2006-05-12 23:27:30 +00003623 assert (bgp_static);
3624 if (!bgp_static)
3625 return;
3626
paulfee0f4c2004-09-13 05:12:46 +00003627 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003628
3629 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakmadd8103a2006-05-12 23:27:30 +00003630
3631 attr.nexthop = bgp_static->igpnexthop;
3632 attr.med = bgp_static->igpmetric;
3633 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
paul718e3742002-12-13 20:15:29 +00003634
Paul Jakma41367172007-08-06 15:24:51 +00003635 if (bgp_static->atomic)
3636 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3637
paul718e3742002-12-13 20:15:29 +00003638 /* Apply route-map. */
3639 if (bgp_static->rmap.name)
3640 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003641 struct attr attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00003642 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00003643 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00003644
paulfee0f4c2004-09-13 05:12:46 +00003645 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3646
paul718e3742002-12-13 20:15:29 +00003647 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00003648
paulfee0f4c2004-09-13 05:12:46 +00003649 bgp->peer_self->rmap_type = 0;
3650
paul718e3742002-12-13 20:15:29 +00003651 if (ret == RMAP_DENYMATCH)
3652 {
3653 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00003654 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003655
3656 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003657 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003658 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003659 bgp_static_withdraw (bgp, p, afi, safi);
3660 return;
3661 }
paul286e1e72003-08-08 00:24:31 +00003662 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003663 }
paul286e1e72003-08-08 00:24:31 +00003664 else
3665 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00003666
3667 for (ri = rn->info; ri; ri = ri->next)
3668 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3669 && ri->sub_type == BGP_ROUTE_STATIC)
3670 break;
3671
3672 if (ri)
3673 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003674 if (attrhash_cmp (ri->attr, attr_new) &&
3675 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00003676 {
3677 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003678 bgp_attr_unintern (&attr_new);
3679 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003680 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003681 return;
3682 }
3683 else
3684 {
3685 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003686 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00003687
3688 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003689 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3690 bgp_info_restore(rn, ri);
3691 else
3692 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003693 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00003694 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003695 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003696
3697 /* Process change. */
3698 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3699 bgp_process (bgp, rn, afi, safi);
3700 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003701 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003702 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003703 return;
3704 }
3705 }
3706
3707 /* Make new BGP info. */
3708 new = bgp_info_new ();
3709 new->type = ZEBRA_ROUTE_BGP;
3710 new->sub_type = BGP_ROUTE_STATIC;
3711 new->peer = bgp->peer_self;
3712 SET_FLAG (new->flags, BGP_INFO_VALID);
3713 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003714 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003715
3716 /* Aggregate address increment. */
3717 bgp_aggregate_increment (bgp, p, new, afi, safi);
3718
3719 /* Register new BGP information. */
3720 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003721
3722 /* route_node_get lock */
3723 bgp_unlock_node (rn);
3724
paul718e3742002-12-13 20:15:29 +00003725 /* Process change. */
3726 bgp_process (bgp, rn, afi, safi);
3727
3728 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003729 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003730 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003731}
3732
3733void
paulfee0f4c2004-09-13 05:12:46 +00003734bgp_static_update (struct bgp *bgp, struct prefix *p,
3735 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3736{
3737 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00003738 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00003739
3740 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
3741
paul1eb8ef22005-04-07 07:30:20 +00003742 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00003743 {
Paul Jakmada5b30f2006-05-08 14:37:17 +00003744 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
3745 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003746 }
3747}
3748
paul718e3742002-12-13 20:15:29 +00003749void
3750bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
3751 safi_t safi)
3752{
3753 struct bgp_node *rn;
3754 struct bgp_info *ri;
3755
paulfee0f4c2004-09-13 05:12:46 +00003756 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003757
3758 /* Check selected route and self inserted route. */
3759 for (ri = rn->info; ri; ri = ri->next)
3760 if (ri->peer == bgp->peer_self
3761 && ri->type == ZEBRA_ROUTE_BGP
3762 && ri->sub_type == BGP_ROUTE_STATIC)
3763 break;
3764
3765 /* Withdraw static BGP route from routing table. */
3766 if (ri)
3767 {
3768 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003769 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003770 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003771 }
3772
3773 /* Unlock bgp_node_lookup. */
3774 bgp_unlock_node (rn);
3775}
3776
3777void
paulfee0f4c2004-09-13 05:12:46 +00003778bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3779{
3780 struct bgp_static *bgp_static;
3781 struct bgp *bgp;
3782 struct bgp_node *rn;
3783 struct prefix *p;
3784
3785 bgp = rsclient->bgp;
3786
3787 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3788 if ((bgp_static = rn->info) != NULL)
3789 {
3790 p = &rn->p;
3791
3792 bgp_static_update_rsclient (rsclient, p, bgp_static,
3793 afi, safi);
3794 }
3795}
3796
Lou Bergera76d9ca2016-01-12 13:41:53 -05003797/*
3798 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3799 */
paul94f2b392005-06-28 12:44:16 +00003800static void
Lou Bergera76d9ca2016-01-12 13:41:53 -05003801bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3802 safi_t safi, struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00003803{
3804 struct bgp_node *rn;
3805 struct bgp_info *ri;
3806
paulfee0f4c2004-09-13 05:12:46 +00003807 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00003808
3809 /* Check selected route and self inserted route. */
3810 for (ri = rn->info; ri; ri = ri->next)
3811 if (ri->peer == bgp->peer_self
3812 && ri->type == ZEBRA_ROUTE_BGP
3813 && ri->sub_type == BGP_ROUTE_STATIC)
3814 break;
3815
3816 /* Withdraw static BGP route from routing table. */
3817 if (ri)
3818 {
3819 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003820 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003821 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003822 }
3823
3824 /* Unlock bgp_node_lookup. */
3825 bgp_unlock_node (rn);
3826}
3827
Lou Bergera76d9ca2016-01-12 13:41:53 -05003828static void
3829bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3830 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3831{
3832 struct bgp_node *rn;
3833 struct bgp_info *new;
3834 struct attr *attr_new;
3835 struct attr attr = { 0 };
3836 struct bgp_info *ri;
3837
3838 assert (bgp_static);
3839
3840 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3841
3842 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3843
3844 attr.nexthop = bgp_static->igpnexthop;
3845 attr.med = bgp_static->igpmetric;
3846 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3847
3848 /* Apply route-map. */
3849 if (bgp_static->rmap.name)
3850 {
3851 struct attr attr_tmp = attr;
3852 struct bgp_info info;
3853 int ret;
3854
3855 info.peer = bgp->peer_self;
3856 info.attr = &attr_tmp;
3857
3858 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3859
3860 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3861
3862 bgp->peer_self->rmap_type = 0;
3863
3864 if (ret == RMAP_DENYMATCH)
3865 {
3866 /* Free uninterned attribute. */
3867 bgp_attr_flush (&attr_tmp);
3868
3869 /* Unintern original. */
3870 aspath_unintern (&attr.aspath);
3871 bgp_attr_extra_free (&attr);
3872 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3873 bgp_static->tag);
3874 return;
3875 }
3876
3877 attr_new = bgp_attr_intern (&attr_tmp);
3878 }
3879 else
3880 {
3881 attr_new = bgp_attr_intern (&attr);
3882 }
3883
3884 for (ri = rn->info; ri; ri = ri->next)
3885 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3886 && ri->sub_type == BGP_ROUTE_STATIC)
3887 break;
3888
3889 if (ri)
3890 {
3891 if (attrhash_cmp (ri->attr, attr_new) &&
3892 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3893 {
3894 bgp_unlock_node (rn);
3895 bgp_attr_unintern (&attr_new);
3896 aspath_unintern (&attr.aspath);
3897 bgp_attr_extra_free (&attr);
3898 return;
3899 }
3900 else
3901 {
3902 /* The attribute is changed. */
3903 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3904
3905 /* Rewrite BGP route information. */
3906 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3907 bgp_info_restore(rn, ri);
3908 else
3909 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3910 bgp_attr_unintern (&ri->attr);
3911 ri->attr = attr_new;
3912 ri->uptime = bgp_clock ();
3913
3914 /* Process change. */
3915 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3916 bgp_process (bgp, rn, afi, safi);
3917 bgp_unlock_node (rn);
3918 aspath_unintern (&attr.aspath);
3919 bgp_attr_extra_free (&attr);
3920 return;
3921 }
3922 }
3923
3924
3925 /* Make new BGP info. */
3926 new = bgp_info_new ();
3927 new->type = ZEBRA_ROUTE_BGP;
3928 new->sub_type = BGP_ROUTE_STATIC;
3929 new->peer = bgp->peer_self;
3930 new->attr = attr_new;
3931 SET_FLAG (new->flags, BGP_INFO_VALID);
3932 new->uptime = bgp_clock ();
3933 new->extra = bgp_info_extra_new();
3934 memcpy (new->extra->tag, bgp_static->tag, 3);
3935
3936 /* Aggregate address increment. */
3937 bgp_aggregate_increment (bgp, p, new, afi, safi);
3938
3939 /* Register new BGP information. */
3940 bgp_info_add (rn, new);
3941
3942 /* route_node_get lock */
3943 bgp_unlock_node (rn);
3944
3945 /* Process change. */
3946 bgp_process (bgp, rn, afi, safi);
3947
3948 /* Unintern original. */
3949 aspath_unintern (&attr.aspath);
3950 bgp_attr_extra_free (&attr);
3951}
3952
paul718e3742002-12-13 20:15:29 +00003953/* Configure static BGP network. When user don't run zebra, static
3954 route should be installed as valid. */
paul94f2b392005-06-28 12:44:16 +00003955static int
paulfd79ac92004-10-13 05:06:08 +00003956bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003957 afi_t afi, safi_t safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003958{
3959 int ret;
3960 struct prefix p;
3961 struct bgp_static *bgp_static;
3962 struct bgp_node *rn;
Paul Jakma41367172007-08-06 15:24:51 +00003963 u_char need_update = 0;
paul718e3742002-12-13 20:15:29 +00003964
3965 /* Convert IP prefix string to struct prefix. */
3966 ret = str2prefix (ip_str, &p);
3967 if (! ret)
3968 {
3969 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3970 return CMD_WARNING;
3971 }
paul718e3742002-12-13 20:15:29 +00003972 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3973 {
3974 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3975 VTY_NEWLINE);
3976 return CMD_WARNING;
3977 }
paul718e3742002-12-13 20:15:29 +00003978
3979 apply_mask (&p);
3980
3981 /* Set BGP static route configuration. */
3982 rn = bgp_node_get (bgp->route[afi][safi], &p);
3983
3984 if (rn->info)
3985 {
3986 /* Configuration change. */
3987 bgp_static = rn->info;
3988
3989 /* Check previous routes are installed into BGP. */
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003990 if (bgp_static->valid && bgp_static->backdoor != backdoor)
3991 need_update = 1;
Paul Jakma41367172007-08-06 15:24:51 +00003992
paul718e3742002-12-13 20:15:29 +00003993 bgp_static->backdoor = backdoor;
Paul Jakma41367172007-08-06 15:24:51 +00003994
paul718e3742002-12-13 20:15:29 +00003995 if (rmap)
3996 {
3997 if (bgp_static->rmap.name)
3998 free (bgp_static->rmap.name);
3999 bgp_static->rmap.name = strdup (rmap);
4000 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4001 }
4002 else
4003 {
4004 if (bgp_static->rmap.name)
4005 free (bgp_static->rmap.name);
4006 bgp_static->rmap.name = NULL;
4007 bgp_static->rmap.map = NULL;
4008 bgp_static->valid = 0;
4009 }
4010 bgp_unlock_node (rn);
4011 }
4012 else
4013 {
4014 /* New configuration. */
4015 bgp_static = bgp_static_new ();
4016 bgp_static->backdoor = backdoor;
4017 bgp_static->valid = 0;
4018 bgp_static->igpmetric = 0;
4019 bgp_static->igpnexthop.s_addr = 0;
Paul Jakma41367172007-08-06 15:24:51 +00004020
paul718e3742002-12-13 20:15:29 +00004021 if (rmap)
4022 {
4023 if (bgp_static->rmap.name)
4024 free (bgp_static->rmap.name);
4025 bgp_static->rmap.name = strdup (rmap);
4026 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4027 }
4028 rn->info = bgp_static;
4029 }
4030
4031 /* If BGP scan is not enabled, we should install this route here. */
4032 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
4033 {
4034 bgp_static->valid = 1;
4035
4036 if (need_update)
4037 bgp_static_withdraw (bgp, &p, afi, safi);
4038
4039 if (! bgp_static->backdoor)
4040 bgp_static_update (bgp, &p, bgp_static, afi, safi);
4041 }
4042
4043 return CMD_SUCCESS;
4044}
4045
4046/* Configure static BGP network. */
paul94f2b392005-06-28 12:44:16 +00004047static int
paulfd79ac92004-10-13 05:06:08 +00004048bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
Michael Lambert4c9641b2010-07-22 13:20:55 -04004049 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004050{
4051 int ret;
4052 struct prefix p;
4053 struct bgp_static *bgp_static;
4054 struct bgp_node *rn;
4055
4056 /* Convert IP prefix string to struct prefix. */
4057 ret = str2prefix (ip_str, &p);
4058 if (! ret)
4059 {
4060 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4061 return CMD_WARNING;
4062 }
paul718e3742002-12-13 20:15:29 +00004063 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4064 {
4065 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4066 VTY_NEWLINE);
4067 return CMD_WARNING;
4068 }
paul718e3742002-12-13 20:15:29 +00004069
4070 apply_mask (&p);
4071
4072 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4073 if (! rn)
4074 {
4075 vty_out (vty, "%% Can't find specified static route configuration.%s",
4076 VTY_NEWLINE);
4077 return CMD_WARNING;
4078 }
4079
4080 bgp_static = rn->info;
Paul Jakma41367172007-08-06 15:24:51 +00004081
paul718e3742002-12-13 20:15:29 +00004082 /* Update BGP RIB. */
4083 if (! bgp_static->backdoor)
4084 bgp_static_withdraw (bgp, &p, afi, safi);
4085
4086 /* Clear configuration. */
4087 bgp_static_free (bgp_static);
4088 rn->info = NULL;
4089 bgp_unlock_node (rn);
4090 bgp_unlock_node (rn);
4091
4092 return CMD_SUCCESS;
4093}
4094
4095/* Called from bgp_delete(). Delete all static routes from the BGP
4096 instance. */
4097void
4098bgp_static_delete (struct bgp *bgp)
4099{
4100 afi_t afi;
4101 safi_t safi;
4102 struct bgp_node *rn;
4103 struct bgp_node *rm;
4104 struct bgp_table *table;
4105 struct bgp_static *bgp_static;
4106
4107 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4108 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4109 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4110 if (rn->info != NULL)
4111 {
Lou Berger298cc2f2016-01-12 13:42:02 -05004112 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004113 {
4114 table = rn->info;
4115
4116 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4117 {
4118 bgp_static = rn->info;
Lou Bergera76d9ca2016-01-12 13:41:53 -05004119 bgp_static_withdraw_safi (bgp, &rm->p,
4120 AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00004121 (struct prefix_rd *)&rn->p,
4122 bgp_static->tag);
4123 bgp_static_free (bgp_static);
4124 rn->info = NULL;
4125 bgp_unlock_node (rn);
4126 }
4127 }
4128 else
4129 {
4130 bgp_static = rn->info;
4131 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4132 bgp_static_free (bgp_static);
4133 rn->info = NULL;
4134 bgp_unlock_node (rn);
4135 }
4136 }
4137}
4138
Lou Bergera76d9ca2016-01-12 13:41:53 -05004139/*
4140 * gpz 110624
4141 * Currently this is used to set static routes for VPN and ENCAP.
4142 * I think it can probably be factored with bgp_static_set.
4143 */
paul718e3742002-12-13 20:15:29 +00004144int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004145bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4146 const char *rd_str, const char *tag_str,
4147 const char *rmap_str)
paul718e3742002-12-13 20:15:29 +00004148{
4149 int ret;
4150 struct prefix p;
4151 struct prefix_rd prd;
4152 struct bgp *bgp;
4153 struct bgp_node *prn;
4154 struct bgp_node *rn;
4155 struct bgp_table *table;
4156 struct bgp_static *bgp_static;
4157 u_char tag[3];
4158
4159 bgp = vty->index;
4160
4161 ret = str2prefix (ip_str, &p);
4162 if (! ret)
4163 {
4164 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4165 return CMD_WARNING;
4166 }
4167 apply_mask (&p);
4168
4169 ret = str2prefix_rd (rd_str, &prd);
4170 if (! ret)
4171 {
4172 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4173 return CMD_WARNING;
4174 }
4175
4176 ret = str2tag (tag_str, tag);
4177 if (! ret)
4178 {
4179 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4180 return CMD_WARNING;
4181 }
4182
Lou Bergera76d9ca2016-01-12 13:41:53 -05004183 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004184 (struct prefix *)&prd);
4185 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004186 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004187 else
4188 bgp_unlock_node (prn);
4189 table = prn->info;
4190
4191 rn = bgp_node_get (table, &p);
4192
4193 if (rn->info)
4194 {
4195 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4196 bgp_unlock_node (rn);
4197 }
4198 else
4199 {
4200 /* New configuration. */
4201 bgp_static = bgp_static_new ();
Lou Bergera76d9ca2016-01-12 13:41:53 -05004202 bgp_static->backdoor = 0;
4203 bgp_static->valid = 0;
4204 bgp_static->igpmetric = 0;
4205 bgp_static->igpnexthop.s_addr = 0;
4206 memcpy(bgp_static->tag, tag, 3);
4207 bgp_static->prd = prd;
4208
4209 if (rmap_str)
4210 {
4211 if (bgp_static->rmap.name)
4212 free (bgp_static->rmap.name);
4213 bgp_static->rmap.name = strdup (rmap_str);
4214 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4215 }
paul718e3742002-12-13 20:15:29 +00004216 rn->info = bgp_static;
4217
Lou Bergera76d9ca2016-01-12 13:41:53 -05004218 bgp_static->valid = 1;
4219 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004220 }
4221
4222 return CMD_SUCCESS;
4223}
4224
4225/* Configure static BGP network. */
4226int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004227bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4228 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00004229{
4230 int ret;
4231 struct bgp *bgp;
4232 struct prefix p;
4233 struct prefix_rd prd;
4234 struct bgp_node *prn;
4235 struct bgp_node *rn;
4236 struct bgp_table *table;
4237 struct bgp_static *bgp_static;
4238 u_char tag[3];
4239
4240 bgp = vty->index;
4241
4242 /* Convert IP prefix string to struct prefix. */
4243 ret = str2prefix (ip_str, &p);
4244 if (! ret)
4245 {
4246 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4247 return CMD_WARNING;
4248 }
4249 apply_mask (&p);
4250
4251 ret = str2prefix_rd (rd_str, &prd);
4252 if (! ret)
4253 {
4254 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4255 return CMD_WARNING;
4256 }
4257
4258 ret = str2tag (tag_str, tag);
4259 if (! ret)
4260 {
4261 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4262 return CMD_WARNING;
4263 }
4264
Lou Bergera76d9ca2016-01-12 13:41:53 -05004265 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004266 (struct prefix *)&prd);
4267 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004268 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004269 else
4270 bgp_unlock_node (prn);
4271 table = prn->info;
4272
4273 rn = bgp_node_lookup (table, &p);
4274
4275 if (rn)
4276 {
Lou Bergera76d9ca2016-01-12 13:41:53 -05004277 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
paul718e3742002-12-13 20:15:29 +00004278
4279 bgp_static = rn->info;
4280 bgp_static_free (bgp_static);
4281 rn->info = NULL;
4282 bgp_unlock_node (rn);
4283 bgp_unlock_node (rn);
4284 }
4285 else
4286 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4287
4288 return CMD_SUCCESS;
4289}
David Lamparter6b0655a2014-06-04 06:53:35 +02004290
paul718e3742002-12-13 20:15:29 +00004291DEFUN (bgp_network,
4292 bgp_network_cmd,
4293 "network A.B.C.D/M",
4294 "Specify a network to announce via BGP\n"
4295 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4296{
4297 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004298 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004299}
4300
4301DEFUN (bgp_network_route_map,
4302 bgp_network_route_map_cmd,
4303 "network A.B.C.D/M route-map WORD",
4304 "Specify a network to announce via BGP\n"
4305 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4306 "Route-map to modify the attributes\n"
4307 "Name of the route map\n")
4308{
4309 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004310 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004311}
4312
4313DEFUN (bgp_network_backdoor,
4314 bgp_network_backdoor_cmd,
4315 "network A.B.C.D/M backdoor",
4316 "Specify a network to announce via BGP\n"
4317 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4318 "Specify a BGP backdoor route\n")
4319{
Paul Jakma41367172007-08-06 15:24:51 +00004320 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004321 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004322}
4323
4324DEFUN (bgp_network_mask,
4325 bgp_network_mask_cmd,
4326 "network A.B.C.D mask A.B.C.D",
4327 "Specify a network to announce via BGP\n"
4328 "Network number\n"
4329 "Network mask\n"
4330 "Network mask\n")
4331{
4332 int ret;
4333 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004334
paul718e3742002-12-13 20:15:29 +00004335 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4336 if (! ret)
4337 {
4338 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4339 return CMD_WARNING;
4340 }
4341
4342 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004343 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004344}
4345
4346DEFUN (bgp_network_mask_route_map,
4347 bgp_network_mask_route_map_cmd,
4348 "network A.B.C.D mask A.B.C.D route-map WORD",
4349 "Specify a network to announce via BGP\n"
4350 "Network number\n"
4351 "Network mask\n"
4352 "Network mask\n"
4353 "Route-map to modify the attributes\n"
4354 "Name of the route map\n")
4355{
4356 int ret;
4357 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004358
paul718e3742002-12-13 20:15:29 +00004359 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4360 if (! ret)
4361 {
4362 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4363 return CMD_WARNING;
4364 }
4365
4366 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004367 AFI_IP, bgp_node_safi (vty), argv[2], 0);
paul718e3742002-12-13 20:15:29 +00004368}
4369
4370DEFUN (bgp_network_mask_backdoor,
4371 bgp_network_mask_backdoor_cmd,
4372 "network A.B.C.D mask A.B.C.D backdoor",
4373 "Specify a network to announce via BGP\n"
4374 "Network number\n"
4375 "Network mask\n"
4376 "Network mask\n"
4377 "Specify a BGP backdoor route\n")
4378{
4379 int ret;
4380 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004381
paul718e3742002-12-13 20:15:29 +00004382 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4383 if (! ret)
4384 {
4385 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4386 return CMD_WARNING;
4387 }
4388
Paul Jakma41367172007-08-06 15:24:51 +00004389 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004390 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004391}
4392
4393DEFUN (bgp_network_mask_natural,
4394 bgp_network_mask_natural_cmd,
4395 "network A.B.C.D",
4396 "Specify a network to announce via BGP\n"
4397 "Network number\n")
4398{
4399 int ret;
4400 char prefix_str[BUFSIZ];
4401
4402 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4403 if (! ret)
4404 {
4405 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4406 return CMD_WARNING;
4407 }
4408
4409 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004410 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004411}
4412
4413DEFUN (bgp_network_mask_natural_route_map,
4414 bgp_network_mask_natural_route_map_cmd,
4415 "network A.B.C.D route-map WORD",
4416 "Specify a network to announce via BGP\n"
4417 "Network number\n"
4418 "Route-map to modify the attributes\n"
4419 "Name of the route map\n")
4420{
4421 int ret;
4422 char prefix_str[BUFSIZ];
4423
4424 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4425 if (! ret)
4426 {
4427 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4428 return CMD_WARNING;
4429 }
4430
4431 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004432 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004433}
4434
4435DEFUN (bgp_network_mask_natural_backdoor,
4436 bgp_network_mask_natural_backdoor_cmd,
4437 "network A.B.C.D backdoor",
4438 "Specify a network to announce via BGP\n"
4439 "Network number\n"
4440 "Specify a BGP backdoor route\n")
4441{
4442 int ret;
4443 char prefix_str[BUFSIZ];
4444
4445 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4446 if (! ret)
4447 {
4448 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4449 return CMD_WARNING;
4450 }
4451
Paul Jakma41367172007-08-06 15:24:51 +00004452 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004453 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004454}
4455
4456DEFUN (no_bgp_network,
4457 no_bgp_network_cmd,
4458 "no network A.B.C.D/M",
4459 NO_STR
4460 "Specify a network to announce via BGP\n"
4461 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4462{
4463 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4464 bgp_node_safi (vty));
4465}
4466
4467ALIAS (no_bgp_network,
4468 no_bgp_network_route_map_cmd,
4469 "no network A.B.C.D/M route-map WORD",
4470 NO_STR
4471 "Specify a network to announce via BGP\n"
4472 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4473 "Route-map to modify the attributes\n"
4474 "Name of the route map\n")
4475
4476ALIAS (no_bgp_network,
4477 no_bgp_network_backdoor_cmd,
4478 "no network A.B.C.D/M backdoor",
4479 NO_STR
4480 "Specify a network to announce via BGP\n"
4481 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4482 "Specify a BGP backdoor route\n")
4483
4484DEFUN (no_bgp_network_mask,
4485 no_bgp_network_mask_cmd,
4486 "no network A.B.C.D mask A.B.C.D",
4487 NO_STR
4488 "Specify a network to announce via BGP\n"
4489 "Network number\n"
4490 "Network mask\n"
4491 "Network mask\n")
4492{
4493 int ret;
4494 char prefix_str[BUFSIZ];
4495
4496 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4497 if (! ret)
4498 {
4499 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4500 return CMD_WARNING;
4501 }
4502
4503 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4504 bgp_node_safi (vty));
4505}
4506
4507ALIAS (no_bgp_network_mask,
4508 no_bgp_network_mask_route_map_cmd,
4509 "no network A.B.C.D mask A.B.C.D route-map WORD",
4510 NO_STR
4511 "Specify a network to announce via BGP\n"
4512 "Network number\n"
4513 "Network mask\n"
4514 "Network mask\n"
4515 "Route-map to modify the attributes\n"
4516 "Name of the route map\n")
4517
4518ALIAS (no_bgp_network_mask,
4519 no_bgp_network_mask_backdoor_cmd,
4520 "no network A.B.C.D mask A.B.C.D backdoor",
4521 NO_STR
4522 "Specify a network to announce via BGP\n"
4523 "Network number\n"
4524 "Network mask\n"
4525 "Network mask\n"
4526 "Specify a BGP backdoor route\n")
4527
4528DEFUN (no_bgp_network_mask_natural,
4529 no_bgp_network_mask_natural_cmd,
4530 "no network A.B.C.D",
4531 NO_STR
4532 "Specify a network to announce via BGP\n"
4533 "Network number\n")
4534{
4535 int ret;
4536 char prefix_str[BUFSIZ];
4537
4538 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4539 if (! ret)
4540 {
4541 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4542 return CMD_WARNING;
4543 }
4544
4545 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4546 bgp_node_safi (vty));
4547}
4548
4549ALIAS (no_bgp_network_mask_natural,
4550 no_bgp_network_mask_natural_route_map_cmd,
4551 "no network A.B.C.D route-map WORD",
4552 NO_STR
4553 "Specify a network to announce via BGP\n"
4554 "Network number\n"
4555 "Route-map to modify the attributes\n"
4556 "Name of the route map\n")
4557
4558ALIAS (no_bgp_network_mask_natural,
4559 no_bgp_network_mask_natural_backdoor_cmd,
4560 "no network A.B.C.D backdoor",
4561 NO_STR
4562 "Specify a network to announce via BGP\n"
4563 "Network number\n"
4564 "Specify a BGP backdoor route\n")
4565
paul718e3742002-12-13 20:15:29 +00004566DEFUN (ipv6_bgp_network,
4567 ipv6_bgp_network_cmd,
4568 "network X:X::X:X/M",
4569 "Specify a network to announce via BGP\n"
4570 "IPv6 prefix <network>/<length>\n")
4571{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304572 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004573 NULL, 0);
paul718e3742002-12-13 20:15:29 +00004574}
4575
4576DEFUN (ipv6_bgp_network_route_map,
4577 ipv6_bgp_network_route_map_cmd,
4578 "network X:X::X:X/M route-map WORD",
4579 "Specify a network to announce via BGP\n"
4580 "IPv6 prefix <network>/<length>\n"
4581 "Route-map to modify the attributes\n"
4582 "Name of the route map\n")
4583{
4584 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004585 bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004586}
4587
4588DEFUN (no_ipv6_bgp_network,
4589 no_ipv6_bgp_network_cmd,
4590 "no network X:X::X:X/M",
4591 NO_STR
4592 "Specify a network to announce via BGP\n"
4593 "IPv6 prefix <network>/<length>\n")
4594{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304595 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00004596}
4597
4598ALIAS (no_ipv6_bgp_network,
4599 no_ipv6_bgp_network_route_map_cmd,
4600 "no network X:X::X:X/M route-map WORD",
4601 NO_STR
4602 "Specify a network to announce via BGP\n"
4603 "IPv6 prefix <network>/<length>\n"
4604 "Route-map to modify the attributes\n"
4605 "Name of the route map\n")
4606
4607ALIAS (ipv6_bgp_network,
4608 old_ipv6_bgp_network_cmd,
4609 "ipv6 bgp network X:X::X:X/M",
4610 IPV6_STR
4611 BGP_STR
4612 "Specify a network to announce via BGP\n"
4613 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4614
4615ALIAS (no_ipv6_bgp_network,
4616 old_no_ipv6_bgp_network_cmd,
4617 "no ipv6 bgp network X:X::X:X/M",
4618 NO_STR
4619 IPV6_STR
4620 BGP_STR
4621 "Specify a network to announce via BGP\n"
4622 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004623
4624/* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4625ALIAS_DEPRECATED (bgp_network,
4626 bgp_network_ttl_cmd,
4627 "network A.B.C.D/M pathlimit <0-255>",
4628 "Specify a network to announce via BGP\n"
4629 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4630 "AS-Path hopcount limit attribute\n"
4631 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4632ALIAS_DEPRECATED (bgp_network_backdoor,
4633 bgp_network_backdoor_ttl_cmd,
4634 "network A.B.C.D/M backdoor pathlimit <0-255>",
4635 "Specify a network to announce via BGP\n"
4636 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4637 "Specify a BGP backdoor route\n"
4638 "AS-Path hopcount limit attribute\n"
4639 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4640ALIAS_DEPRECATED (bgp_network_mask,
4641 bgp_network_mask_ttl_cmd,
4642 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4643 "Specify a network to announce via BGP\n"
4644 "Network number\n"
4645 "Network mask\n"
4646 "Network mask\n"
4647 "AS-Path hopcount limit attribute\n"
4648 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4649ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4650 bgp_network_mask_backdoor_ttl_cmd,
4651 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4652 "Specify a network to announce via BGP\n"
4653 "Network number\n"
4654 "Network mask\n"
4655 "Network mask\n"
4656 "Specify a BGP backdoor route\n"
4657 "AS-Path hopcount limit attribute\n"
4658 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4659ALIAS_DEPRECATED (bgp_network_mask_natural,
4660 bgp_network_mask_natural_ttl_cmd,
4661 "network A.B.C.D pathlimit <0-255>",
4662 "Specify a network to announce via BGP\n"
4663 "Network number\n"
4664 "AS-Path hopcount limit attribute\n"
4665 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4666ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4667 bgp_network_mask_natural_backdoor_ttl_cmd,
Christian Franke2b005152013-09-30 12:27:49 +00004668 "network A.B.C.D backdoor pathlimit <1-255>",
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004669 "Specify a network to announce via BGP\n"
4670 "Network number\n"
4671 "Specify a BGP backdoor route\n"
4672 "AS-Path hopcount limit attribute\n"
4673 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4674ALIAS_DEPRECATED (no_bgp_network,
4675 no_bgp_network_ttl_cmd,
4676 "no network A.B.C.D/M pathlimit <0-255>",
4677 NO_STR
4678 "Specify a network to announce via BGP\n"
4679 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4680 "AS-Path hopcount limit attribute\n"
4681 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4682ALIAS_DEPRECATED (no_bgp_network,
4683 no_bgp_network_backdoor_ttl_cmd,
4684 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4685 NO_STR
4686 "Specify a network to announce via BGP\n"
4687 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4688 "Specify a BGP backdoor route\n"
4689 "AS-Path hopcount limit attribute\n"
4690 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4691ALIAS_DEPRECATED (no_bgp_network,
4692 no_bgp_network_mask_ttl_cmd,
4693 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4694 NO_STR
4695 "Specify a network to announce via BGP\n"
4696 "Network number\n"
4697 "Network mask\n"
4698 "Network mask\n"
4699 "AS-Path hopcount limit attribute\n"
4700 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4701ALIAS_DEPRECATED (no_bgp_network_mask,
4702 no_bgp_network_mask_backdoor_ttl_cmd,
4703 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4704 NO_STR
4705 "Specify a network to announce via BGP\n"
4706 "Network number\n"
4707 "Network mask\n"
4708 "Network mask\n"
4709 "Specify a BGP backdoor route\n"
4710 "AS-Path hopcount limit attribute\n"
4711 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4712ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4713 no_bgp_network_mask_natural_ttl_cmd,
4714 "no network A.B.C.D pathlimit <0-255>",
4715 NO_STR
4716 "Specify a network to announce via BGP\n"
4717 "Network number\n"
4718 "AS-Path hopcount limit attribute\n"
4719 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4720ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4721 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4722 "no network A.B.C.D backdoor pathlimit <0-255>",
4723 NO_STR
4724 "Specify a network to announce via BGP\n"
4725 "Network number\n"
4726 "Specify a BGP backdoor route\n"
4727 "AS-Path hopcount limit attribute\n"
4728 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4729ALIAS_DEPRECATED (ipv6_bgp_network,
4730 ipv6_bgp_network_ttl_cmd,
4731 "network X:X::X:X/M pathlimit <0-255>",
4732 "Specify a network to announce via BGP\n"
4733 "IPv6 prefix <network>/<length>\n"
4734 "AS-Path hopcount limit attribute\n"
4735 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4736ALIAS_DEPRECATED (no_ipv6_bgp_network,
4737 no_ipv6_bgp_network_ttl_cmd,
4738 "no network X:X::X:X/M pathlimit <0-255>",
4739 NO_STR
4740 "Specify a network to announce via BGP\n"
4741 "IPv6 prefix <network>/<length>\n"
4742 "AS-Path hopcount limit attribute\n"
4743 "AS-Pathlimit TTL, in number of AS-Path hops\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02004744
paul718e3742002-12-13 20:15:29 +00004745/* Aggreagete address:
4746
4747 advertise-map Set condition to advertise attribute
4748 as-set Generate AS set path information
4749 attribute-map Set attributes of aggregate
4750 route-map Set parameters of aggregate
4751 summary-only Filter more specific routes from updates
4752 suppress-map Conditionally filter more specific routes from updates
4753 <cr>
4754 */
4755struct bgp_aggregate
4756{
4757 /* Summary-only flag. */
4758 u_char summary_only;
4759
4760 /* AS set generation. */
4761 u_char as_set;
4762
4763 /* Route-map for aggregated route. */
4764 struct route_map *map;
4765
4766 /* Suppress-count. */
4767 unsigned long count;
4768
4769 /* SAFI configuration. */
4770 safi_t safi;
4771};
4772
paul94f2b392005-06-28 12:44:16 +00004773static struct bgp_aggregate *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08004774bgp_aggregate_new (void)
paul718e3742002-12-13 20:15:29 +00004775{
Stephen Hemminger393deb92008-08-18 14:13:29 -07004776 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
paul718e3742002-12-13 20:15:29 +00004777}
4778
paul94f2b392005-06-28 12:44:16 +00004779static void
paul718e3742002-12-13 20:15:29 +00004780bgp_aggregate_free (struct bgp_aggregate *aggregate)
4781{
4782 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4783}
4784
paul94f2b392005-06-28 12:44:16 +00004785static void
paul718e3742002-12-13 20:15:29 +00004786bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4787 afi_t afi, safi_t safi, struct bgp_info *del,
4788 struct bgp_aggregate *aggregate)
4789{
4790 struct bgp_table *table;
4791 struct bgp_node *top;
4792 struct bgp_node *rn;
4793 u_char origin;
4794 struct aspath *aspath = NULL;
4795 struct aspath *asmerge = NULL;
4796 struct community *community = NULL;
4797 struct community *commerge = NULL;
paul718e3742002-12-13 20:15:29 +00004798 struct bgp_info *ri;
4799 struct bgp_info *new;
4800 int first = 1;
4801 unsigned long match = 0;
4802
paul718e3742002-12-13 20:15:29 +00004803 /* ORIGIN attribute: If at least one route among routes that are
4804 aggregated has ORIGIN with the value INCOMPLETE, then the
4805 aggregated route must have the ORIGIN attribute with the value
4806 INCOMPLETE. Otherwise, if at least one route among routes that
4807 are aggregated has ORIGIN with the value EGP, then the aggregated
4808 route must have the origin attribute with the value EGP. In all
4809 other case the value of the ORIGIN attribute of the aggregated
4810 route is INTERNAL. */
4811 origin = BGP_ORIGIN_IGP;
4812
4813 table = bgp->rib[afi][safi];
4814
4815 top = bgp_node_get (table, p);
4816 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4817 if (rn->p.prefixlen > p->prefixlen)
4818 {
4819 match = 0;
4820
4821 for (ri = rn->info; ri; ri = ri->next)
4822 {
4823 if (BGP_INFO_HOLDDOWN (ri))
4824 continue;
4825
4826 if (del && ri == del)
4827 continue;
4828
4829 if (! rinew && first)
Paul Jakma7aa9dce2014-09-19 14:42:23 +01004830 first = 0;
paul718e3742002-12-13 20:15:29 +00004831
4832#ifdef AGGREGATE_NEXTHOP_CHECK
4833 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4834 || ri->attr->med != med)
4835 {
4836 if (aspath)
4837 aspath_free (aspath);
4838 if (community)
4839 community_free (community);
4840 bgp_unlock_node (rn);
4841 bgp_unlock_node (top);
4842 return;
4843 }
4844#endif /* AGGREGATE_NEXTHOP_CHECK */
4845
4846 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4847 {
4848 if (aggregate->summary_only)
4849 {
Paul Jakmafb982c22007-05-04 20:15:47 +00004850 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00004851 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00004852 match++;
4853 }
4854
4855 aggregate->count++;
4856
4857 if (aggregate->as_set)
4858 {
4859 if (origin < ri->attr->origin)
4860 origin = ri->attr->origin;
4861
4862 if (aspath)
4863 {
4864 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4865 aspath_free (aspath);
4866 aspath = asmerge;
4867 }
4868 else
4869 aspath = aspath_dup (ri->attr->aspath);
4870
4871 if (ri->attr->community)
4872 {
4873 if (community)
4874 {
4875 commerge = community_merge (community,
4876 ri->attr->community);
4877 community = community_uniq_sort (commerge);
4878 community_free (commerge);
4879 }
4880 else
4881 community = community_dup (ri->attr->community);
4882 }
4883 }
4884 }
4885 }
4886 if (match)
4887 bgp_process (bgp, rn, afi, safi);
4888 }
4889 bgp_unlock_node (top);
4890
4891 if (rinew)
4892 {
4893 aggregate->count++;
4894
4895 if (aggregate->summary_only)
Paul Jakmafb982c22007-05-04 20:15:47 +00004896 (bgp_info_extra_get (rinew))->suppress++;
paul718e3742002-12-13 20:15:29 +00004897
4898 if (aggregate->as_set)
4899 {
4900 if (origin < rinew->attr->origin)
4901 origin = rinew->attr->origin;
4902
4903 if (aspath)
4904 {
4905 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4906 aspath_free (aspath);
4907 aspath = asmerge;
4908 }
4909 else
4910 aspath = aspath_dup (rinew->attr->aspath);
4911
4912 if (rinew->attr->community)
4913 {
4914 if (community)
4915 {
4916 commerge = community_merge (community,
4917 rinew->attr->community);
4918 community = community_uniq_sort (commerge);
4919 community_free (commerge);
4920 }
4921 else
4922 community = community_dup (rinew->attr->community);
4923 }
4924 }
4925 }
4926
4927 if (aggregate->count > 0)
4928 {
4929 rn = bgp_node_get (table, p);
4930 new = bgp_info_new ();
4931 new->type = ZEBRA_ROUTE_BGP;
4932 new->sub_type = BGP_ROUTE_AGGREGATE;
4933 new->peer = bgp->peer_self;
4934 SET_FLAG (new->flags, BGP_INFO_VALID);
4935 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03004936 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00004937
4938 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00004939 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00004940 bgp_process (bgp, rn, afi, safi);
4941 }
4942 else
4943 {
4944 if (aspath)
4945 aspath_free (aspath);
4946 if (community)
4947 community_free (community);
4948 }
4949}
4950
4951void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4952 struct bgp_aggregate *);
4953
4954void
4955bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4956 struct bgp_info *ri, afi_t afi, safi_t safi)
4957{
4958 struct bgp_node *child;
4959 struct bgp_node *rn;
4960 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004961 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004962
4963 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004964 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004965 return;
4966
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004967 table = bgp->aggregate[afi][safi];
4968
4969 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004970 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004971 return;
4972
paul718e3742002-12-13 20:15:29 +00004973 if (p->prefixlen == 0)
4974 return;
4975
4976 if (BGP_INFO_HOLDDOWN (ri))
4977 return;
4978
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004979 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004980
4981 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004982 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00004983 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
4984 {
4985 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00004986 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00004987 }
4988 bgp_unlock_node (child);
4989}
4990
4991void
4992bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
4993 struct bgp_info *del, afi_t afi, safi_t safi)
4994{
4995 struct bgp_node *child;
4996 struct bgp_node *rn;
4997 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004998 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004999
5000 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05005001 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00005002 return;
5003
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005004 table = bgp->aggregate[afi][safi];
5005
5006 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005007 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005008 return;
5009
paul718e3742002-12-13 20:15:29 +00005010 if (p->prefixlen == 0)
5011 return;
5012
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02005013 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00005014
5015 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005016 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00005017 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5018 {
5019 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00005020 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00005021 }
5022 bgp_unlock_node (child);
5023}
5024
paul94f2b392005-06-28 12:44:16 +00005025static void
paul718e3742002-12-13 20:15:29 +00005026bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
5027 struct bgp_aggregate *aggregate)
5028{
5029 struct bgp_table *table;
5030 struct bgp_node *top;
5031 struct bgp_node *rn;
5032 struct bgp_info *new;
5033 struct bgp_info *ri;
5034 unsigned long match;
5035 u_char origin = BGP_ORIGIN_IGP;
5036 struct aspath *aspath = NULL;
5037 struct aspath *asmerge = NULL;
5038 struct community *community = NULL;
5039 struct community *commerge = NULL;
5040
5041 table = bgp->rib[afi][safi];
5042
5043 /* Sanity check. */
5044 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5045 return;
5046 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5047 return;
5048
5049 /* If routes exists below this node, generate aggregate routes. */
5050 top = bgp_node_get (table, p);
5051 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5052 if (rn->p.prefixlen > p->prefixlen)
5053 {
5054 match = 0;
5055
5056 for (ri = rn->info; ri; ri = ri->next)
5057 {
5058 if (BGP_INFO_HOLDDOWN (ri))
5059 continue;
5060
5061 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5062 {
5063 /* summary-only aggregate route suppress aggregated
5064 route announcement. */
5065 if (aggregate->summary_only)
5066 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005067 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00005068 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005069 match++;
5070 }
5071 /* as-set aggregate route generate origin, as path,
5072 community aggregation. */
5073 if (aggregate->as_set)
5074 {
5075 if (origin < ri->attr->origin)
5076 origin = ri->attr->origin;
5077
5078 if (aspath)
5079 {
5080 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5081 aspath_free (aspath);
5082 aspath = asmerge;
5083 }
5084 else
5085 aspath = aspath_dup (ri->attr->aspath);
5086
5087 if (ri->attr->community)
5088 {
5089 if (community)
5090 {
5091 commerge = community_merge (community,
5092 ri->attr->community);
5093 community = community_uniq_sort (commerge);
5094 community_free (commerge);
5095 }
5096 else
5097 community = community_dup (ri->attr->community);
5098 }
5099 }
5100 aggregate->count++;
5101 }
5102 }
5103
5104 /* If this node is suppressed, process the change. */
5105 if (match)
5106 bgp_process (bgp, rn, afi, safi);
5107 }
5108 bgp_unlock_node (top);
5109
5110 /* Add aggregate route to BGP table. */
5111 if (aggregate->count)
5112 {
5113 rn = bgp_node_get (table, p);
5114
5115 new = bgp_info_new ();
5116 new->type = ZEBRA_ROUTE_BGP;
5117 new->sub_type = BGP_ROUTE_AGGREGATE;
5118 new->peer = bgp->peer_self;
5119 SET_FLAG (new->flags, BGP_INFO_VALID);
5120 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03005121 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005122
5123 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00005124 bgp_unlock_node (rn);
5125
paul718e3742002-12-13 20:15:29 +00005126 /* Process change. */
5127 bgp_process (bgp, rn, afi, safi);
5128 }
Denil Virae2a92582015-08-11 13:34:59 -07005129 else
5130 {
5131 if (aspath)
5132 aspath_free (aspath);
5133 if (community)
5134 community_free (community);
5135 }
paul718e3742002-12-13 20:15:29 +00005136}
5137
5138void
5139bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5140 safi_t safi, struct bgp_aggregate *aggregate)
5141{
5142 struct bgp_table *table;
5143 struct bgp_node *top;
5144 struct bgp_node *rn;
5145 struct bgp_info *ri;
5146 unsigned long match;
5147
5148 table = bgp->rib[afi][safi];
5149
5150 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5151 return;
5152 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5153 return;
5154
5155 /* If routes exists below this node, generate aggregate routes. */
5156 top = bgp_node_get (table, p);
5157 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5158 if (rn->p.prefixlen > p->prefixlen)
5159 {
5160 match = 0;
5161
5162 for (ri = rn->info; ri; ri = ri->next)
5163 {
5164 if (BGP_INFO_HOLDDOWN (ri))
5165 continue;
5166
5167 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5168 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005169 if (aggregate->summary_only && ri->extra)
paul718e3742002-12-13 20:15:29 +00005170 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005171 ri->extra->suppress--;
paul718e3742002-12-13 20:15:29 +00005172
Paul Jakmafb982c22007-05-04 20:15:47 +00005173 if (ri->extra->suppress == 0)
paul718e3742002-12-13 20:15:29 +00005174 {
Paul Jakma1a392d42006-09-07 00:24:49 +00005175 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005176 match++;
5177 }
5178 }
5179 aggregate->count--;
5180 }
5181 }
5182
Paul Jakmafb982c22007-05-04 20:15:47 +00005183 /* If this node was suppressed, process the change. */
paul718e3742002-12-13 20:15:29 +00005184 if (match)
5185 bgp_process (bgp, rn, afi, safi);
5186 }
5187 bgp_unlock_node (top);
5188
5189 /* Delete aggregate route from BGP table. */
5190 rn = bgp_node_get (table, p);
5191
5192 for (ri = rn->info; ri; ri = ri->next)
5193 if (ri->peer == bgp->peer_self
5194 && ri->type == ZEBRA_ROUTE_BGP
5195 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5196 break;
5197
5198 /* Withdraw static BGP route from routing table. */
5199 if (ri)
5200 {
paul718e3742002-12-13 20:15:29 +00005201 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005202 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00005203 }
5204
5205 /* Unlock bgp_node_lookup. */
5206 bgp_unlock_node (rn);
5207}
5208
5209/* Aggregate route attribute. */
5210#define AGGREGATE_SUMMARY_ONLY 1
5211#define AGGREGATE_AS_SET 1
5212
paul94f2b392005-06-28 12:44:16 +00005213static int
Robert Baysf6269b42010-08-05 10:26:28 -07005214bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5215 afi_t afi, safi_t safi)
5216{
5217 int ret;
5218 struct prefix p;
5219 struct bgp_node *rn;
5220 struct bgp *bgp;
5221 struct bgp_aggregate *aggregate;
5222
5223 /* Convert string to prefix structure. */
5224 ret = str2prefix (prefix_str, &p);
5225 if (!ret)
5226 {
5227 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5228 return CMD_WARNING;
5229 }
5230 apply_mask (&p);
5231
5232 /* Get BGP structure. */
5233 bgp = vty->index;
5234
5235 /* Old configuration check. */
5236 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
5237 if (! rn)
5238 {
5239 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5240 VTY_NEWLINE);
5241 return CMD_WARNING;
5242 }
5243
5244 aggregate = rn->info;
5245 if (aggregate->safi & SAFI_UNICAST)
5246 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5247 if (aggregate->safi & SAFI_MULTICAST)
5248 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5249
5250 /* Unlock aggregate address configuration. */
5251 rn->info = NULL;
5252 bgp_aggregate_free (aggregate);
5253 bgp_unlock_node (rn);
5254 bgp_unlock_node (rn);
5255
5256 return CMD_SUCCESS;
5257}
5258
5259static int
5260bgp_aggregate_set (struct vty *vty, const char *prefix_str,
paulfd79ac92004-10-13 05:06:08 +00005261 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00005262 u_char summary_only, u_char as_set)
5263{
5264 int ret;
5265 struct prefix p;
5266 struct bgp_node *rn;
5267 struct bgp *bgp;
5268 struct bgp_aggregate *aggregate;
5269
5270 /* Convert string to prefix structure. */
5271 ret = str2prefix (prefix_str, &p);
5272 if (!ret)
5273 {
5274 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5275 return CMD_WARNING;
5276 }
5277 apply_mask (&p);
5278
5279 /* Get BGP structure. */
5280 bgp = vty->index;
5281
5282 /* Old configuration check. */
5283 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5284
5285 if (rn->info)
5286 {
5287 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
Robert Bays368473f2010-08-05 10:26:29 -07005288 /* try to remove the old entry */
Robert Baysf6269b42010-08-05 10:26:28 -07005289 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5290 if (ret)
5291 {
Robert Bays368473f2010-08-05 10:26:29 -07005292 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5293 bgp_unlock_node (rn);
Robert Baysf6269b42010-08-05 10:26:28 -07005294 return CMD_WARNING;
5295 }
paul718e3742002-12-13 20:15:29 +00005296 }
5297
5298 /* Make aggregate address structure. */
5299 aggregate = bgp_aggregate_new ();
5300 aggregate->summary_only = summary_only;
5301 aggregate->as_set = as_set;
5302 aggregate->safi = safi;
5303 rn->info = aggregate;
5304
5305 /* Aggregate address insert into BGP routing table. */
5306 if (safi & SAFI_UNICAST)
5307 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5308 if (safi & SAFI_MULTICAST)
5309 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5310
5311 return CMD_SUCCESS;
5312}
5313
paul718e3742002-12-13 20:15:29 +00005314DEFUN (aggregate_address,
5315 aggregate_address_cmd,
5316 "aggregate-address A.B.C.D/M",
5317 "Configure BGP aggregate entries\n"
5318 "Aggregate prefix\n")
5319{
5320 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5321}
5322
5323DEFUN (aggregate_address_mask,
5324 aggregate_address_mask_cmd,
5325 "aggregate-address A.B.C.D A.B.C.D",
5326 "Configure BGP aggregate entries\n"
5327 "Aggregate address\n"
5328 "Aggregate mask\n")
5329{
5330 int ret;
5331 char prefix_str[BUFSIZ];
5332
5333 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5334
5335 if (! ret)
5336 {
5337 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5338 return CMD_WARNING;
5339 }
5340
5341 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5342 0, 0);
5343}
5344
5345DEFUN (aggregate_address_summary_only,
5346 aggregate_address_summary_only_cmd,
5347 "aggregate-address A.B.C.D/M summary-only",
5348 "Configure BGP aggregate entries\n"
5349 "Aggregate prefix\n"
5350 "Filter more specific routes from updates\n")
5351{
5352 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5353 AGGREGATE_SUMMARY_ONLY, 0);
5354}
5355
5356DEFUN (aggregate_address_mask_summary_only,
5357 aggregate_address_mask_summary_only_cmd,
5358 "aggregate-address A.B.C.D A.B.C.D summary-only",
5359 "Configure BGP aggregate entries\n"
5360 "Aggregate address\n"
5361 "Aggregate mask\n"
5362 "Filter more specific routes from updates\n")
5363{
5364 int ret;
5365 char prefix_str[BUFSIZ];
5366
5367 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5368
5369 if (! ret)
5370 {
5371 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5372 return CMD_WARNING;
5373 }
5374
5375 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5376 AGGREGATE_SUMMARY_ONLY, 0);
5377}
5378
5379DEFUN (aggregate_address_as_set,
5380 aggregate_address_as_set_cmd,
5381 "aggregate-address A.B.C.D/M as-set",
5382 "Configure BGP aggregate entries\n"
5383 "Aggregate prefix\n"
5384 "Generate AS set path information\n")
5385{
5386 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5387 0, AGGREGATE_AS_SET);
5388}
5389
5390DEFUN (aggregate_address_mask_as_set,
5391 aggregate_address_mask_as_set_cmd,
5392 "aggregate-address A.B.C.D A.B.C.D as-set",
5393 "Configure BGP aggregate entries\n"
5394 "Aggregate address\n"
5395 "Aggregate mask\n"
5396 "Generate AS set path information\n")
5397{
5398 int ret;
5399 char prefix_str[BUFSIZ];
5400
5401 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5402
5403 if (! ret)
5404 {
5405 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5406 return CMD_WARNING;
5407 }
5408
5409 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5410 0, AGGREGATE_AS_SET);
5411}
5412
5413
5414DEFUN (aggregate_address_as_set_summary,
5415 aggregate_address_as_set_summary_cmd,
5416 "aggregate-address A.B.C.D/M as-set summary-only",
5417 "Configure BGP aggregate entries\n"
5418 "Aggregate prefix\n"
5419 "Generate AS set path information\n"
5420 "Filter more specific routes from updates\n")
5421{
5422 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5423 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5424}
5425
5426ALIAS (aggregate_address_as_set_summary,
5427 aggregate_address_summary_as_set_cmd,
5428 "aggregate-address A.B.C.D/M summary-only as-set",
5429 "Configure BGP aggregate entries\n"
5430 "Aggregate prefix\n"
5431 "Filter more specific routes from updates\n"
5432 "Generate AS set path information\n")
5433
5434DEFUN (aggregate_address_mask_as_set_summary,
5435 aggregate_address_mask_as_set_summary_cmd,
5436 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5437 "Configure BGP aggregate entries\n"
5438 "Aggregate address\n"
5439 "Aggregate mask\n"
5440 "Generate AS set path information\n"
5441 "Filter more specific routes from updates\n")
5442{
5443 int ret;
5444 char prefix_str[BUFSIZ];
5445
5446 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5447
5448 if (! ret)
5449 {
5450 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5451 return CMD_WARNING;
5452 }
5453
5454 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5455 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5456}
5457
5458ALIAS (aggregate_address_mask_as_set_summary,
5459 aggregate_address_mask_summary_as_set_cmd,
5460 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5461 "Configure BGP aggregate entries\n"
5462 "Aggregate address\n"
5463 "Aggregate mask\n"
5464 "Filter more specific routes from updates\n"
5465 "Generate AS set path information\n")
5466
5467DEFUN (no_aggregate_address,
5468 no_aggregate_address_cmd,
5469 "no aggregate-address A.B.C.D/M",
5470 NO_STR
5471 "Configure BGP aggregate entries\n"
5472 "Aggregate prefix\n")
5473{
5474 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5475}
5476
5477ALIAS (no_aggregate_address,
5478 no_aggregate_address_summary_only_cmd,
5479 "no aggregate-address A.B.C.D/M summary-only",
5480 NO_STR
5481 "Configure BGP aggregate entries\n"
5482 "Aggregate prefix\n"
5483 "Filter more specific routes from updates\n")
5484
5485ALIAS (no_aggregate_address,
5486 no_aggregate_address_as_set_cmd,
5487 "no aggregate-address A.B.C.D/M as-set",
5488 NO_STR
5489 "Configure BGP aggregate entries\n"
5490 "Aggregate prefix\n"
5491 "Generate AS set path information\n")
5492
5493ALIAS (no_aggregate_address,
5494 no_aggregate_address_as_set_summary_cmd,
5495 "no aggregate-address A.B.C.D/M as-set summary-only",
5496 NO_STR
5497 "Configure BGP aggregate entries\n"
5498 "Aggregate prefix\n"
5499 "Generate AS set path information\n"
5500 "Filter more specific routes from updates\n")
5501
5502ALIAS (no_aggregate_address,
5503 no_aggregate_address_summary_as_set_cmd,
5504 "no aggregate-address A.B.C.D/M summary-only as-set",
5505 NO_STR
5506 "Configure BGP aggregate entries\n"
5507 "Aggregate prefix\n"
5508 "Filter more specific routes from updates\n"
5509 "Generate AS set path information\n")
5510
5511DEFUN (no_aggregate_address_mask,
5512 no_aggregate_address_mask_cmd,
5513 "no aggregate-address A.B.C.D A.B.C.D",
5514 NO_STR
5515 "Configure BGP aggregate entries\n"
5516 "Aggregate address\n"
5517 "Aggregate mask\n")
5518{
5519 int ret;
5520 char prefix_str[BUFSIZ];
5521
5522 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5523
5524 if (! ret)
5525 {
5526 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5527 return CMD_WARNING;
5528 }
5529
5530 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5531}
5532
5533ALIAS (no_aggregate_address_mask,
5534 no_aggregate_address_mask_summary_only_cmd,
5535 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5536 NO_STR
5537 "Configure BGP aggregate entries\n"
5538 "Aggregate address\n"
5539 "Aggregate mask\n"
5540 "Filter more specific routes from updates\n")
5541
5542ALIAS (no_aggregate_address_mask,
5543 no_aggregate_address_mask_as_set_cmd,
5544 "no aggregate-address A.B.C.D A.B.C.D as-set",
5545 NO_STR
5546 "Configure BGP aggregate entries\n"
5547 "Aggregate address\n"
5548 "Aggregate mask\n"
5549 "Generate AS set path information\n")
5550
5551ALIAS (no_aggregate_address_mask,
5552 no_aggregate_address_mask_as_set_summary_cmd,
5553 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5554 NO_STR
5555 "Configure BGP aggregate entries\n"
5556 "Aggregate address\n"
5557 "Aggregate mask\n"
5558 "Generate AS set path information\n"
5559 "Filter more specific routes from updates\n")
5560
5561ALIAS (no_aggregate_address_mask,
5562 no_aggregate_address_mask_summary_as_set_cmd,
5563 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5564 NO_STR
5565 "Configure BGP aggregate entries\n"
5566 "Aggregate address\n"
5567 "Aggregate mask\n"
5568 "Filter more specific routes from updates\n"
5569 "Generate AS set path information\n")
5570
paul718e3742002-12-13 20:15:29 +00005571DEFUN (ipv6_aggregate_address,
5572 ipv6_aggregate_address_cmd,
5573 "aggregate-address X:X::X:X/M",
5574 "Configure BGP aggregate entries\n"
5575 "Aggregate prefix\n")
5576{
5577 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5578}
5579
5580DEFUN (ipv6_aggregate_address_summary_only,
5581 ipv6_aggregate_address_summary_only_cmd,
5582 "aggregate-address X:X::X:X/M summary-only",
5583 "Configure BGP aggregate entries\n"
5584 "Aggregate prefix\n"
5585 "Filter more specific routes from updates\n")
5586{
5587 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5588 AGGREGATE_SUMMARY_ONLY, 0);
5589}
5590
5591DEFUN (no_ipv6_aggregate_address,
5592 no_ipv6_aggregate_address_cmd,
5593 "no aggregate-address X:X::X:X/M",
5594 NO_STR
5595 "Configure BGP aggregate entries\n"
5596 "Aggregate prefix\n")
5597{
5598 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5599}
5600
5601DEFUN (no_ipv6_aggregate_address_summary_only,
5602 no_ipv6_aggregate_address_summary_only_cmd,
5603 "no aggregate-address X:X::X:X/M summary-only",
5604 NO_STR
5605 "Configure BGP aggregate entries\n"
5606 "Aggregate prefix\n"
5607 "Filter more specific routes from updates\n")
5608{
5609 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5610}
5611
5612ALIAS (ipv6_aggregate_address,
5613 old_ipv6_aggregate_address_cmd,
5614 "ipv6 bgp aggregate-address X:X::X:X/M",
5615 IPV6_STR
5616 BGP_STR
5617 "Configure BGP aggregate entries\n"
5618 "Aggregate prefix\n")
5619
5620ALIAS (ipv6_aggregate_address_summary_only,
5621 old_ipv6_aggregate_address_summary_only_cmd,
5622 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5623 IPV6_STR
5624 BGP_STR
5625 "Configure BGP aggregate entries\n"
5626 "Aggregate prefix\n"
5627 "Filter more specific routes from updates\n")
5628
5629ALIAS (no_ipv6_aggregate_address,
5630 old_no_ipv6_aggregate_address_cmd,
5631 "no ipv6 bgp aggregate-address X:X::X:X/M",
5632 NO_STR
5633 IPV6_STR
5634 BGP_STR
5635 "Configure BGP aggregate entries\n"
5636 "Aggregate prefix\n")
5637
5638ALIAS (no_ipv6_aggregate_address_summary_only,
5639 old_no_ipv6_aggregate_address_summary_only_cmd,
5640 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5641 NO_STR
5642 IPV6_STR
5643 BGP_STR
5644 "Configure BGP aggregate entries\n"
5645 "Aggregate prefix\n"
5646 "Filter more specific routes from updates\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02005647
paul718e3742002-12-13 20:15:29 +00005648/* Redistribute route treatment. */
5649void
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005650bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5651 const struct in6_addr *nexthop6,
paul718e3742002-12-13 20:15:29 +00005652 u_int32_t metric, u_char type)
5653{
5654 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005655 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005656 struct bgp_info *new;
5657 struct bgp_info *bi;
5658 struct bgp_info info;
5659 struct bgp_node *bn;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00005660 struct attr attr;
paul718e3742002-12-13 20:15:29 +00005661 struct attr *new_attr;
5662 afi_t afi;
5663 int ret;
5664
5665 /* Make default attribute. */
5666 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5667 if (nexthop)
5668 attr.nexthop = *nexthop;
5669
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005670 if (nexthop6)
5671 {
5672 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5673 extra->mp_nexthop_global = *nexthop6;
5674 extra->mp_nexthop_len = 16;
5675 }
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005676
paul718e3742002-12-13 20:15:29 +00005677 attr.med = metric;
5678 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
5679
paul1eb8ef22005-04-07 07:30:20 +00005680 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005681 {
5682 afi = family2afi (p->family);
5683
5684 if (bgp->redist[afi][type])
5685 {
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005686 struct attr attr_new;
5687 struct attr_extra extra_new;
5688
paul718e3742002-12-13 20:15:29 +00005689 /* Copy attribute for modification. */
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005690 attr_new.extra = &extra_new;
Paul Jakmafb982c22007-05-04 20:15:47 +00005691 bgp_attr_dup (&attr_new, &attr);
paul718e3742002-12-13 20:15:29 +00005692
5693 if (bgp->redist_metric_flag[afi][type])
5694 attr_new.med = bgp->redist_metric[afi][type];
5695
5696 /* Apply route-map. */
Daniel Walton1994dc82015-09-17 10:15:59 -04005697 if (bgp->rmap[afi][type].name)
paul718e3742002-12-13 20:15:29 +00005698 {
5699 info.peer = bgp->peer_self;
5700 info.attr = &attr_new;
5701
paulfee0f4c2004-09-13 05:12:46 +00005702 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5703
paul718e3742002-12-13 20:15:29 +00005704 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5705 &info);
paulfee0f4c2004-09-13 05:12:46 +00005706
5707 bgp->peer_self->rmap_type = 0;
5708
paul718e3742002-12-13 20:15:29 +00005709 if (ret == RMAP_DENYMATCH)
5710 {
5711 /* Free uninterned attribute. */
5712 bgp_attr_flush (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005713
paul718e3742002-12-13 20:15:29 +00005714 /* Unintern original. */
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 bgp_redistribute_delete (p, type);
5718 return;
5719 }
5720 }
5721
Paul Jakmafb982c22007-05-04 20:15:47 +00005722 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5723 afi, SAFI_UNICAST, p, NULL);
5724
paul718e3742002-12-13 20:15:29 +00005725 new_attr = bgp_attr_intern (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005726
paul718e3742002-12-13 20:15:29 +00005727 for (bi = bn->info; bi; bi = bi->next)
5728 if (bi->peer == bgp->peer_self
5729 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5730 break;
5731
5732 if (bi)
5733 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005734 if (attrhash_cmp (bi->attr, new_attr) &&
5735 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00005736 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005737 bgp_attr_unintern (&new_attr);
5738 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005739 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005740 bgp_unlock_node (bn);
5741 return;
5742 }
5743 else
5744 {
5745 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00005746 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005747
5748 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005749 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5750 bgp_info_restore(bn, bi);
5751 else
5752 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005753 bgp_attr_unintern (&bi->attr);
paul718e3742002-12-13 20:15:29 +00005754 bi->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005755 bi->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005756
5757 /* Process change. */
5758 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5759 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5760 bgp_unlock_node (bn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005761 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005762 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005763 return;
5764 }
5765 }
5766
5767 new = bgp_info_new ();
5768 new->type = type;
5769 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
5770 new->peer = bgp->peer_self;
5771 SET_FLAG (new->flags, BGP_INFO_VALID);
5772 new->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005773 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005774
5775 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5776 bgp_info_add (bn, new);
paul200df112005-06-01 11:17:05 +00005777 bgp_unlock_node (bn);
paul718e3742002-12-13 20:15:29 +00005778 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5779 }
5780 }
5781
5782 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005783 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005784 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005785}
5786
5787void
5788bgp_redistribute_delete (struct prefix *p, u_char type)
5789{
5790 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005791 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005792 afi_t afi;
5793 struct bgp_node *rn;
5794 struct bgp_info *ri;
5795
paul1eb8ef22005-04-07 07:30:20 +00005796 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005797 {
5798 afi = family2afi (p->family);
5799
5800 if (bgp->redist[afi][type])
5801 {
paulfee0f4c2004-09-13 05:12:46 +00005802 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00005803
5804 for (ri = rn->info; ri; ri = ri->next)
5805 if (ri->peer == bgp->peer_self
5806 && ri->type == type)
5807 break;
5808
5809 if (ri)
5810 {
5811 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005812 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005813 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005814 }
5815 bgp_unlock_node (rn);
5816 }
5817 }
5818}
5819
5820/* Withdraw specified route type's route. */
5821void
5822bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5823{
5824 struct bgp_node *rn;
5825 struct bgp_info *ri;
5826 struct bgp_table *table;
5827
5828 table = bgp->rib[afi][SAFI_UNICAST];
5829
5830 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5831 {
5832 for (ri = rn->info; ri; ri = ri->next)
5833 if (ri->peer == bgp->peer_self
5834 && ri->type == type)
5835 break;
5836
5837 if (ri)
5838 {
5839 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005840 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005841 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005842 }
5843 }
5844}
David Lamparter6b0655a2014-06-04 06:53:35 +02005845
paul718e3742002-12-13 20:15:29 +00005846/* Static function to display route. */
paul94f2b392005-06-28 12:44:16 +00005847static void
paul718e3742002-12-13 20:15:29 +00005848route_vty_out_route (struct prefix *p, struct vty *vty)
5849{
5850 int len;
5851 u_int32_t destination;
5852 char buf[BUFSIZ];
5853
5854 if (p->family == AF_INET)
5855 {
5856 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5857 destination = ntohl (p->u.prefix4.s_addr);
5858
5859 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5860 || (IN_CLASSB (destination) && p->prefixlen == 16)
5861 || (IN_CLASSA (destination) && p->prefixlen == 8)
5862 || p->u.prefix4.s_addr == 0)
5863 {
5864 /* When mask is natural, mask is not displayed. */
5865 }
5866 else
5867 len += vty_out (vty, "/%d", p->prefixlen);
5868 }
5869 else
5870 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5871 p->prefixlen);
5872
5873 len = 17 - len;
5874 if (len < 1)
5875 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5876 else
5877 vty_out (vty, "%*s", len, " ");
5878}
5879
paul718e3742002-12-13 20:15:29 +00005880enum bgp_display_type
5881{
5882 normal_list,
5883};
5884
paulb40d9392005-08-22 22:34:41 +00005885/* Print the short form route status for a bgp_info */
5886static void
5887route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
paul718e3742002-12-13 20:15:29 +00005888{
paulb40d9392005-08-22 22:34:41 +00005889 /* Route status display. */
5890 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5891 vty_out (vty, "R");
5892 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
hasso93406d82005-02-02 14:40:33 +00005893 vty_out (vty, "S");
Paul Jakmafb982c22007-05-04 20:15:47 +00005894 else if (binfo->extra && binfo->extra->suppress)
paul718e3742002-12-13 20:15:29 +00005895 vty_out (vty, "s");
5896 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5897 vty_out (vty, "*");
5898 else
5899 vty_out (vty, " ");
5900
5901 /* Selected */
5902 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5903 vty_out (vty, "h");
5904 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5905 vty_out (vty, "d");
5906 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5907 vty_out (vty, ">");
Boian Bonevb366b512013-09-09 16:41:35 +00005908 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5909 vty_out (vty, "=");
paul718e3742002-12-13 20:15:29 +00005910 else
5911 vty_out (vty, " ");
5912
5913 /* Internal route. */
5914 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5915 vty_out (vty, "i");
5916 else
paulb40d9392005-08-22 22:34:41 +00005917 vty_out (vty, " ");
5918}
5919
5920/* called from terminal list command */
5921void
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005922route_vty_out(
5923 struct vty *vty,
5924 struct prefix *p,
5925 struct bgp_info *binfo,
5926 int display,
5927 safi_t safi)
paulb40d9392005-08-22 22:34:41 +00005928{
5929 struct attr *attr;
5930
5931 /* short status lead text */
5932 route_vty_short_status_out (vty, binfo);
paul718e3742002-12-13 20:15:29 +00005933
5934 /* print prefix and mask */
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005935 if (!display)
paul718e3742002-12-13 20:15:29 +00005936 route_vty_out_route (p, vty);
5937 else
5938 vty_out (vty, "%*s", 17, " ");
5939
5940 /* Print attribute */
5941 attr = binfo->attr;
5942 if (attr)
5943 {
paul718e3742002-12-13 20:15:29 +00005944
Lou Berger298cc2f2016-01-12 13:42:02 -05005945 /*
5946 * NEXTHOP start
5947 */
5948
5949 /*
5950 * For ENCAP routes, nexthop address family is not
5951 * neccessarily the same as the prefix address family.
5952 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5953 */
5954 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5955 if (attr->extra) {
5956 char buf[BUFSIZ];
5957 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5958
5959 switch (af) {
5960 case AF_INET:
5961 vty_out (vty, "%s", inet_ntop(af,
5962 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5963 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005964 case AF_INET6:
5965 vty_out (vty, "%s", inet_ntop(af,
5966 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
5967 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005968 default:
5969 vty_out(vty, "?");
5970 }
5971 } else {
5972 vty_out(vty, "?");
paul718e3742002-12-13 20:15:29 +00005973 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005974 } else {
5975
5976 if (p->family == AF_INET)
5977 {
5978 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
5979 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005980 else if (p->family == AF_INET6)
5981 {
5982 int len;
5983 char buf[BUFSIZ];
5984
5985 len = vty_out (vty, "%s",
5986 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
5987 buf, BUFSIZ));
5988 len = 16 - len;
5989 if (len < 1)
5990 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
5991 else
5992 vty_out (vty, "%*s", len, " ");
5993 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005994 else
5995 {
5996 vty_out(vty, "?");
5997 }
5998 }
5999
6000 /*
6001 * NEXTHOP end
6002 */
6003
paul718e3742002-12-13 20:15:29 +00006004
6005 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006006 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006007 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006008 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00006009
6010 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006011 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006012 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006013 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00006014
Paul Jakmafb982c22007-05-04 20:15:47 +00006015 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
paul718e3742002-12-13 20:15:29 +00006016
Paul Jakmab2518c12006-05-12 23:48:40 +00006017 /* Print aspath */
6018 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006019 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006020
Paul Jakmab2518c12006-05-12 23:48:40 +00006021 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006022 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006023 }
paul718e3742002-12-13 20:15:29 +00006024 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006025}
6026
6027/* called from terminal list command */
6028void
6029route_vty_out_tmp (struct vty *vty, struct prefix *p,
6030 struct attr *attr, safi_t safi)
6031{
6032 /* Route status display. */
6033 vty_out (vty, "*");
6034 vty_out (vty, ">");
6035 vty_out (vty, " ");
6036
6037 /* print prefix and mask */
6038 route_vty_out_route (p, vty);
6039
6040 /* Print attribute */
6041 if (attr)
6042 {
6043 if (p->family == AF_INET)
6044 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006045 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006046 vty_out (vty, "%-16s",
6047 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006048 else
6049 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6050 }
paul718e3742002-12-13 20:15:29 +00006051 else if (p->family == AF_INET6)
6052 {
6053 int len;
6054 char buf[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006055
6056 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006057
6058 len = vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006059 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6060 buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006061 len = 16 - len;
6062 if (len < 1)
6063 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6064 else
6065 vty_out (vty, "%*s", len, " ");
6066 }
paul718e3742002-12-13 20:15:29 +00006067
6068 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006069 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006070 else
6071 vty_out (vty, " ");
6072
6073 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006074 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006075 else
6076 vty_out (vty, " ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006077
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006078 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
Paul Jakmafb982c22007-05-04 20:15:47 +00006079
Paul Jakmab2518c12006-05-12 23:48:40 +00006080 /* Print aspath */
6081 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006082 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006083
Paul Jakmab2518c12006-05-12 23:48:40 +00006084 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006085 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006086 }
paul718e3742002-12-13 20:15:29 +00006087
6088 vty_out (vty, "%s", VTY_NEWLINE);
6089}
6090
ajs5a646652004-11-05 01:25:55 +00006091void
paul718e3742002-12-13 20:15:29 +00006092route_vty_out_tag (struct vty *vty, struct prefix *p,
6093 struct bgp_info *binfo, int display, safi_t safi)
6094{
6095 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006096 u_int32_t label = 0;
Paul Jakmafb982c22007-05-04 20:15:47 +00006097
6098 if (!binfo->extra)
6099 return;
6100
paulb40d9392005-08-22 22:34:41 +00006101 /* short status lead text */
6102 route_vty_short_status_out (vty, binfo);
6103
paul718e3742002-12-13 20:15:29 +00006104 /* print prefix and mask */
6105 if (! display)
6106 route_vty_out_route (p, vty);
6107 else
6108 vty_out (vty, "%*s", 17, " ");
6109
6110 /* Print attribute */
6111 attr = binfo->attr;
6112 if (attr)
6113 {
6114 if (p->family == AF_INET)
6115 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006116 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006117 vty_out (vty, "%-16s",
6118 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006119 else
6120 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6121 }
paul718e3742002-12-13 20:15:29 +00006122 else if (p->family == AF_INET6)
6123 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006124 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006125 char buf[BUFSIZ];
6126 char buf1[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006127 if (attr->extra->mp_nexthop_len == 16)
paul718e3742002-12-13 20:15:29 +00006128 vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006129 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6130 buf, BUFSIZ));
6131 else if (attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006132 vty_out (vty, "%s(%s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006133 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6134 buf, BUFSIZ),
6135 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6136 buf1, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006137
6138 }
paul718e3742002-12-13 20:15:29 +00006139 }
6140
Paul Jakmafb982c22007-05-04 20:15:47 +00006141 label = decode_label (binfo->extra->tag);
paul718e3742002-12-13 20:15:29 +00006142
6143 vty_out (vty, "notag/%d", label);
6144
6145 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006146}
6147
6148/* dampening route */
ajs5a646652004-11-05 01:25:55 +00006149static void
paul718e3742002-12-13 20:15:29 +00006150damp_route_vty_out (struct vty *vty, struct prefix *p,
6151 struct bgp_info *binfo, int display, safi_t safi)
6152{
6153 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006154 int len;
Chris Caputo50aef6f2009-06-23 06:06:49 +00006155 char timebuf[BGP_UPTIME_LEN];
paul718e3742002-12-13 20:15:29 +00006156
paulb40d9392005-08-22 22:34:41 +00006157 /* short status lead text */
6158 route_vty_short_status_out (vty, binfo);
6159
paul718e3742002-12-13 20:15:29 +00006160 /* print prefix and mask */
6161 if (! display)
6162 route_vty_out_route (p, vty);
6163 else
6164 vty_out (vty, "%*s", 17, " ");
6165
6166 len = vty_out (vty, "%s", binfo->peer->host);
6167 len = 17 - len;
6168 if (len < 1)
6169 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6170 else
6171 vty_out (vty, "%*s", len, " ");
6172
Chris Caputo50aef6f2009-06-23 06:06:49 +00006173 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006174
6175 /* Print attribute */
6176 attr = binfo->attr;
6177 if (attr)
6178 {
6179 /* Print aspath */
6180 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006181 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006182
6183 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006184 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006185 }
6186 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006187}
6188
paul718e3742002-12-13 20:15:29 +00006189/* flap route */
ajs5a646652004-11-05 01:25:55 +00006190static void
paul718e3742002-12-13 20:15:29 +00006191flap_route_vty_out (struct vty *vty, struct prefix *p,
6192 struct bgp_info *binfo, int display, safi_t safi)
6193{
6194 struct attr *attr;
6195 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00006196 char timebuf[BGP_UPTIME_LEN];
6197 int len;
Paul Jakmafb982c22007-05-04 20:15:47 +00006198
6199 if (!binfo->extra)
6200 return;
6201
6202 bdi = binfo->extra->damp_info;
paul718e3742002-12-13 20:15:29 +00006203
paulb40d9392005-08-22 22:34:41 +00006204 /* short status lead text */
6205 route_vty_short_status_out (vty, binfo);
6206
paul718e3742002-12-13 20:15:29 +00006207 /* print prefix and mask */
6208 if (! display)
6209 route_vty_out_route (p, vty);
6210 else
6211 vty_out (vty, "%*s", 17, " ");
6212
6213 len = vty_out (vty, "%s", binfo->peer->host);
6214 len = 16 - len;
6215 if (len < 1)
6216 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6217 else
6218 vty_out (vty, "%*s", len, " ");
6219
6220 len = vty_out (vty, "%d", bdi->flap);
6221 len = 5 - len;
6222 if (len < 1)
6223 vty_out (vty, " ");
6224 else
6225 vty_out (vty, "%*s ", len, " ");
6226
6227 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6228 timebuf, BGP_UPTIME_LEN));
6229
6230 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6231 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
Chris Caputo50aef6f2009-06-23 06:06:49 +00006232 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006233 else
6234 vty_out (vty, "%*s ", 8, " ");
6235
6236 /* Print attribute */
6237 attr = binfo->attr;
6238 if (attr)
6239 {
6240 /* Print aspath */
6241 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006242 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006243
6244 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006245 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006246 }
6247 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006248}
6249
paul94f2b392005-06-28 12:44:16 +00006250static void
paul718e3742002-12-13 20:15:29 +00006251route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6252 struct bgp_info *binfo, afi_t afi, safi_t safi)
6253{
6254 char buf[INET6_ADDRSTRLEN];
6255 char buf1[BUFSIZ];
6256 struct attr *attr;
6257 int sockunion_vty_out (struct vty *, union sockunion *);
John Kemp30b00172011-03-18 17:52:18 +03006258#ifdef HAVE_CLOCK_MONOTONIC
6259 time_t tbuf;
6260#endif
paul718e3742002-12-13 20:15:29 +00006261
6262 attr = binfo->attr;
6263
6264 if (attr)
6265 {
6266 /* Line1 display AS-path, Aggregator */
6267 if (attr->aspath)
6268 {
6269 vty_out (vty, " ");
paulfe69a502005-09-10 16:55:02 +00006270 if (aspath_count_hops (attr->aspath) == 0)
paul718e3742002-12-13 20:15:29 +00006271 vty_out (vty, "Local");
6272 else
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006273 aspath_print_vty (vty, "%s", attr->aspath, "");
paul718e3742002-12-13 20:15:29 +00006274 }
6275
paulb40d9392005-08-22 22:34:41 +00006276 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6277 vty_out (vty, ", (removed)");
hasso93406d82005-02-02 14:40:33 +00006278 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6279 vty_out (vty, ", (stale)");
6280 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006281 vty_out (vty, ", (aggregated by %u %s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006282 attr->extra->aggregator_as,
6283 inet_ntoa (attr->extra->aggregator_addr));
hasso93406d82005-02-02 14:40:33 +00006284 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6285 vty_out (vty, ", (Received from a RR-client)");
6286 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6287 vty_out (vty, ", (Received from a RS-client)");
6288 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6289 vty_out (vty, ", (history entry)");
6290 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6291 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00006292 vty_out (vty, "%s", VTY_NEWLINE);
6293
6294 /* Line2 display Next-hop, Neighbor, Router-id */
6295 if (p->family == AF_INET)
6296 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006297 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
Paul Jakmafb982c22007-05-04 20:15:47 +00006298 inet_ntoa (attr->extra->mp_nexthop_global_in) :
paul718e3742002-12-13 20:15:29 +00006299 inet_ntoa (attr->nexthop));
6300 }
paul718e3742002-12-13 20:15:29 +00006301 else
6302 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006303 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006304 vty_out (vty, " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006305 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
paul718e3742002-12-13 20:15:29 +00006306 buf, INET6_ADDRSTRLEN));
6307 }
paul718e3742002-12-13 20:15:29 +00006308
6309 if (binfo->peer == bgp->peer_self)
6310 {
6311 vty_out (vty, " from %s ",
6312 p->family == AF_INET ? "0.0.0.0" : "::");
6313 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6314 }
6315 else
6316 {
6317 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6318 vty_out (vty, " (inaccessible)");
Paul Jakmafb982c22007-05-04 20:15:47 +00006319 else if (binfo->extra && binfo->extra->igpmetric)
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02006320 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006321 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6322 buf[0] = '?';
6323 buf[1] = 0;
6324 }
6325 vty_out (vty, " from %s", buf);
paul718e3742002-12-13 20:15:29 +00006326 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006327 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006328 else
6329 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6330 }
6331 vty_out (vty, "%s", VTY_NEWLINE);
6332
paul718e3742002-12-13 20:15:29 +00006333 /* display nexthop local */
Paul Jakmafb982c22007-05-04 20:15:47 +00006334 if (attr->extra && attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006335 {
6336 vty_out (vty, " (%s)%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006337 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
paul718e3742002-12-13 20:15:29 +00006338 buf, INET6_ADDRSTRLEN),
6339 VTY_NEWLINE);
6340 }
paul718e3742002-12-13 20:15:29 +00006341
6342 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
6343 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6344
6345 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006346 vty_out (vty, ", metric %u", attr->med);
paul718e3742002-12-13 20:15:29 +00006347
6348 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006349 vty_out (vty, ", localpref %u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006350 else
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006351 vty_out (vty, ", localpref %u", bgp->default_local_pref);
paul718e3742002-12-13 20:15:29 +00006352
Paul Jakmafb982c22007-05-04 20:15:47 +00006353 if (attr->extra && attr->extra->weight != 0)
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006354 vty_out (vty, ", weight %u", attr->extra->weight);
paul718e3742002-12-13 20:15:29 +00006355
6356 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6357 vty_out (vty, ", valid");
6358
6359 if (binfo->peer != bgp->peer_self)
6360 {
6361 if (binfo->peer->as == binfo->peer->local_as)
6362 vty_out (vty, ", internal");
6363 else
6364 vty_out (vty, ", %s",
6365 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6366 }
6367 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6368 vty_out (vty, ", aggregated, local");
6369 else if (binfo->type != ZEBRA_ROUTE_BGP)
6370 vty_out (vty, ", sourced");
6371 else
6372 vty_out (vty, ", sourced, local");
6373
6374 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6375 vty_out (vty, ", atomic-aggregate");
6376
Josh Baileyde8d5df2011-07-20 20:46:01 -07006377 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6378 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6379 bgp_info_mpath_count (binfo)))
6380 vty_out (vty, ", multipath");
6381
paul718e3742002-12-13 20:15:29 +00006382 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6383 vty_out (vty, ", best");
6384
6385 vty_out (vty, "%s", VTY_NEWLINE);
6386
6387 /* Line 4 display Community */
6388 if (attr->community)
6389 vty_out (vty, " Community: %s%s", attr->community->str,
6390 VTY_NEWLINE);
6391
6392 /* Line 5 display Extended-community */
6393 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
Paul Jakmafb982c22007-05-04 20:15:47 +00006394 vty_out (vty, " Extended Community: %s%s",
6395 attr->extra->ecommunity->str, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006396
6397 /* Line 6 display Originator, Cluster-id */
6398 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6399 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6400 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006401 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006402 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006403 vty_out (vty, " Originator: %s",
6404 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006405
6406 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6407 {
6408 int i;
6409 vty_out (vty, ", Cluster list: ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006410 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6411 vty_out (vty, "%s ",
6412 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +00006413 }
6414 vty_out (vty, "%s", VTY_NEWLINE);
6415 }
Paul Jakma41367172007-08-06 15:24:51 +00006416
Paul Jakmafb982c22007-05-04 20:15:47 +00006417 if (binfo->extra && binfo->extra->damp_info)
paul718e3742002-12-13 20:15:29 +00006418 bgp_damp_info_vty (vty, binfo);
6419
6420 /* Line 7 display Uptime */
John Kemp30b00172011-03-18 17:52:18 +03006421#ifdef HAVE_CLOCK_MONOTONIC
6422 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
Vladimir L Ivanov213b6cd2010-10-21 14:59:54 +04006423 vty_out (vty, " Last update: %s", ctime(&tbuf));
John Kemp30b00172011-03-18 17:52:18 +03006424#else
6425 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6426#endif /* HAVE_CLOCK_MONOTONIC */
paul718e3742002-12-13 20:15:29 +00006427 }
6428 vty_out (vty, "%s", VTY_NEWLINE);
Boian Bonevb366b512013-09-09 16:41:35 +00006429}
6430
6431#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6432 "h history, * valid, > best, = multipath,%s"\
6433 " i internal, r RIB-failure, S Stale, R Removed%s"
hasso93406d82005-02-02 14:40:33 +00006434#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00006435#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6436#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6437#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6438
6439enum bgp_show_type
6440{
6441 bgp_show_type_normal,
6442 bgp_show_type_regexp,
6443 bgp_show_type_prefix_list,
6444 bgp_show_type_filter_list,
6445 bgp_show_type_route_map,
6446 bgp_show_type_neighbor,
6447 bgp_show_type_cidr_only,
6448 bgp_show_type_prefix_longer,
6449 bgp_show_type_community_all,
6450 bgp_show_type_community,
6451 bgp_show_type_community_exact,
6452 bgp_show_type_community_list,
6453 bgp_show_type_community_list_exact,
6454 bgp_show_type_flap_statistics,
6455 bgp_show_type_flap_address,
6456 bgp_show_type_flap_prefix,
6457 bgp_show_type_flap_cidr_only,
6458 bgp_show_type_flap_regexp,
6459 bgp_show_type_flap_filter_list,
6460 bgp_show_type_flap_prefix_list,
6461 bgp_show_type_flap_prefix_longer,
6462 bgp_show_type_flap_route_map,
6463 bgp_show_type_flap_neighbor,
6464 bgp_show_type_dampend_paths,
6465 bgp_show_type_damp_neighbor
6466};
6467
ajs5a646652004-11-05 01:25:55 +00006468static int
paulfee0f4c2004-09-13 05:12:46 +00006469bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00006470 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00006471{
paul718e3742002-12-13 20:15:29 +00006472 struct bgp_info *ri;
6473 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00006474 int header = 1;
paul718e3742002-12-13 20:15:29 +00006475 int display;
ajs5a646652004-11-05 01:25:55 +00006476 unsigned long output_count;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006477 unsigned long total_count;
paul718e3742002-12-13 20:15:29 +00006478
6479 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00006480 output_count = 0;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006481 total_count = 0;
paul718e3742002-12-13 20:15:29 +00006482
paul718e3742002-12-13 20:15:29 +00006483 /* Start processing of routes. */
6484 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6485 if (rn->info != NULL)
6486 {
6487 display = 0;
6488
6489 for (ri = rn->info; ri; ri = ri->next)
6490 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006491 total_count++;
ajs5a646652004-11-05 01:25:55 +00006492 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00006493 || type == bgp_show_type_flap_address
6494 || type == bgp_show_type_flap_prefix
6495 || type == bgp_show_type_flap_cidr_only
6496 || type == bgp_show_type_flap_regexp
6497 || type == bgp_show_type_flap_filter_list
6498 || type == bgp_show_type_flap_prefix_list
6499 || type == bgp_show_type_flap_prefix_longer
6500 || type == bgp_show_type_flap_route_map
6501 || type == bgp_show_type_flap_neighbor
6502 || type == bgp_show_type_dampend_paths
6503 || type == bgp_show_type_damp_neighbor)
6504 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006505 if (!(ri->extra && ri->extra->damp_info))
paul718e3742002-12-13 20:15:29 +00006506 continue;
6507 }
6508 if (type == bgp_show_type_regexp
6509 || type == bgp_show_type_flap_regexp)
6510 {
ajs5a646652004-11-05 01:25:55 +00006511 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00006512
6513 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6514 continue;
6515 }
6516 if (type == bgp_show_type_prefix_list
6517 || type == bgp_show_type_flap_prefix_list)
6518 {
ajs5a646652004-11-05 01:25:55 +00006519 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00006520
6521 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6522 continue;
6523 }
6524 if (type == bgp_show_type_filter_list
6525 || type == bgp_show_type_flap_filter_list)
6526 {
ajs5a646652004-11-05 01:25:55 +00006527 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00006528
6529 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6530 continue;
6531 }
6532 if (type == bgp_show_type_route_map
6533 || type == bgp_show_type_flap_route_map)
6534 {
ajs5a646652004-11-05 01:25:55 +00006535 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00006536 struct bgp_info binfo;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006537 struct attr dummy_attr;
6538 struct attr_extra dummy_extra;
paul718e3742002-12-13 20:15:29 +00006539 int ret;
6540
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006541 dummy_attr.extra = &dummy_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00006542 bgp_attr_dup (&dummy_attr, ri->attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006543
paul718e3742002-12-13 20:15:29 +00006544 binfo.peer = ri->peer;
6545 binfo.attr = &dummy_attr;
6546
6547 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
paul718e3742002-12-13 20:15:29 +00006548 if (ret == RMAP_DENYMATCH)
6549 continue;
6550 }
6551 if (type == bgp_show_type_neighbor
6552 || type == bgp_show_type_flap_neighbor
6553 || type == bgp_show_type_damp_neighbor)
6554 {
ajs5a646652004-11-05 01:25:55 +00006555 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00006556
6557 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6558 continue;
6559 }
6560 if (type == bgp_show_type_cidr_only
6561 || type == bgp_show_type_flap_cidr_only)
6562 {
6563 u_int32_t destination;
6564
6565 destination = ntohl (rn->p.u.prefix4.s_addr);
6566 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6567 continue;
6568 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6569 continue;
6570 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6571 continue;
6572 }
6573 if (type == bgp_show_type_prefix_longer
6574 || type == bgp_show_type_flap_prefix_longer)
6575 {
ajs5a646652004-11-05 01:25:55 +00006576 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006577
6578 if (! prefix_match (p, &rn->p))
6579 continue;
6580 }
6581 if (type == bgp_show_type_community_all)
6582 {
6583 if (! ri->attr->community)
6584 continue;
6585 }
6586 if (type == bgp_show_type_community)
6587 {
ajs5a646652004-11-05 01:25:55 +00006588 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006589
6590 if (! ri->attr->community ||
6591 ! community_match (ri->attr->community, com))
6592 continue;
6593 }
6594 if (type == bgp_show_type_community_exact)
6595 {
ajs5a646652004-11-05 01:25:55 +00006596 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006597
6598 if (! ri->attr->community ||
6599 ! community_cmp (ri->attr->community, com))
6600 continue;
6601 }
6602 if (type == bgp_show_type_community_list)
6603 {
ajs5a646652004-11-05 01:25:55 +00006604 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006605
6606 if (! community_list_match (ri->attr->community, list))
6607 continue;
6608 }
6609 if (type == bgp_show_type_community_list_exact)
6610 {
ajs5a646652004-11-05 01:25:55 +00006611 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006612
6613 if (! community_list_exact_match (ri->attr->community, list))
6614 continue;
6615 }
6616 if (type == bgp_show_type_flap_address
6617 || type == bgp_show_type_flap_prefix)
6618 {
ajs5a646652004-11-05 01:25:55 +00006619 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006620
6621 if (! prefix_match (&rn->p, p))
6622 continue;
6623
6624 if (type == bgp_show_type_flap_prefix)
6625 if (p->prefixlen != rn->p.prefixlen)
6626 continue;
6627 }
6628 if (type == bgp_show_type_dampend_paths
6629 || type == bgp_show_type_damp_neighbor)
6630 {
6631 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6632 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6633 continue;
6634 }
6635
6636 if (header)
6637 {
hasso93406d82005-02-02 14:40:33 +00006638 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6639 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6640 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006641 if (type == bgp_show_type_dampend_paths
6642 || type == bgp_show_type_damp_neighbor)
6643 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6644 else if (type == bgp_show_type_flap_statistics
6645 || type == bgp_show_type_flap_address
6646 || type == bgp_show_type_flap_prefix
6647 || type == bgp_show_type_flap_cidr_only
6648 || type == bgp_show_type_flap_regexp
6649 || type == bgp_show_type_flap_filter_list
6650 || type == bgp_show_type_flap_prefix_list
6651 || type == bgp_show_type_flap_prefix_longer
6652 || type == bgp_show_type_flap_route_map
6653 || type == bgp_show_type_flap_neighbor)
6654 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6655 else
6656 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006657 header = 0;
6658 }
6659
6660 if (type == bgp_show_type_dampend_paths
6661 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00006662 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006663 else if (type == bgp_show_type_flap_statistics
6664 || type == bgp_show_type_flap_address
6665 || type == bgp_show_type_flap_prefix
6666 || type == bgp_show_type_flap_cidr_only
6667 || type == bgp_show_type_flap_regexp
6668 || type == bgp_show_type_flap_filter_list
6669 || type == bgp_show_type_flap_prefix_list
6670 || type == bgp_show_type_flap_prefix_longer
6671 || type == bgp_show_type_flap_route_map
6672 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00006673 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006674 else
ajs5a646652004-11-05 01:25:55 +00006675 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006676 display++;
6677 }
6678 if (display)
ajs5a646652004-11-05 01:25:55 +00006679 output_count++;
paul718e3742002-12-13 20:15:29 +00006680 }
6681
6682 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00006683 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00006684 {
6685 if (type == bgp_show_type_normal)
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006686 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006687 }
6688 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006689 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6690 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006691
6692 return CMD_SUCCESS;
6693}
6694
ajs5a646652004-11-05 01:25:55 +00006695static int
paulfee0f4c2004-09-13 05:12:46 +00006696bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00006697 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00006698{
6699 struct bgp_table *table;
6700
6701 if (bgp == NULL) {
6702 bgp = bgp_get_default ();
6703 }
6704
6705 if (bgp == NULL)
6706 {
6707 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6708 return CMD_WARNING;
6709 }
6710
6711
6712 table = bgp->rib[afi][safi];
6713
ajs5a646652004-11-05 01:25:55 +00006714 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00006715}
6716
paul718e3742002-12-13 20:15:29 +00006717/* Header of detailed BGP route information */
paul94f2b392005-06-28 12:44:16 +00006718static void
paul718e3742002-12-13 20:15:29 +00006719route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6720 struct bgp_node *rn,
6721 struct prefix_rd *prd, afi_t afi, safi_t safi)
6722{
6723 struct bgp_info *ri;
6724 struct prefix *p;
6725 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006726 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00006727 char buf1[INET6_ADDRSTRLEN];
6728 char buf2[INET6_ADDRSTRLEN];
6729 int count = 0;
6730 int best = 0;
6731 int suppress = 0;
6732 int no_export = 0;
6733 int no_advertise = 0;
6734 int local_as = 0;
6735 int first = 0;
Lou Berger298cc2f2016-01-12 13:42:02 -05006736 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
paul718e3742002-12-13 20:15:29 +00006737
6738 p = &rn->p;
6739 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
Lou Berger298cc2f2016-01-12 13:42:02 -05006740 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6741 printrd ? ":" : "",
paul718e3742002-12-13 20:15:29 +00006742 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6743 p->prefixlen, VTY_NEWLINE);
6744
6745 for (ri = rn->info; ri; ri = ri->next)
6746 {
6747 count++;
6748 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6749 {
6750 best = count;
Paul Jakmafb982c22007-05-04 20:15:47 +00006751 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00006752 suppress = 1;
6753 if (ri->attr->community != NULL)
6754 {
6755 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6756 no_advertise = 1;
6757 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6758 no_export = 1;
6759 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6760 local_as = 1;
6761 }
6762 }
6763 }
6764
6765 vty_out (vty, "Paths: (%d available", count);
6766 if (best)
6767 {
6768 vty_out (vty, ", best #%d", best);
6769 if (safi == SAFI_UNICAST)
6770 vty_out (vty, ", table Default-IP-Routing-Table");
6771 }
6772 else
6773 vty_out (vty, ", no best path");
6774 if (no_advertise)
6775 vty_out (vty, ", not advertised to any peer");
6776 else if (no_export)
6777 vty_out (vty, ", not advertised to EBGP peer");
6778 else if (local_as)
6779 vty_out (vty, ", not advertised outside local AS");
6780 if (suppress)
6781 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6782 vty_out (vty, ")%s", VTY_NEWLINE);
6783
6784 /* advertised peer */
paul1eb8ef22005-04-07 07:30:20 +00006785 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006786 {
6787 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6788 {
6789 if (! first)
6790 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6791 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6792 first = 1;
6793 }
6794 }
6795 if (! first)
6796 vty_out (vty, " Not advertised to any peer");
6797 vty_out (vty, "%s", VTY_NEWLINE);
6798}
6799
6800/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +00006801static int
paulfee0f4c2004-09-13 05:12:46 +00006802bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00006803 struct bgp_table *rib, const char *ip_str,
6804 afi_t afi, safi_t safi, struct prefix_rd *prd,
6805 int prefix_check)
paul718e3742002-12-13 20:15:29 +00006806{
6807 int ret;
6808 int header;
6809 int display = 0;
6810 struct prefix match;
6811 struct bgp_node *rn;
6812 struct bgp_node *rm;
6813 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00006814 struct bgp_table *table;
6815
Lou Berger050defe2016-01-12 13:41:59 -05006816 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
paul718e3742002-12-13 20:15:29 +00006817 /* Check IP address argument. */
6818 ret = str2prefix (ip_str, &match);
6819 if (! ret)
6820 {
6821 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6822 return CMD_WARNING;
6823 }
6824
6825 match.family = afi2family (afi);
6826
Lou Berger298cc2f2016-01-12 13:42:02 -05006827 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00006828 {
paulfee0f4c2004-09-13 05:12:46 +00006829 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00006830 {
6831 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6832 continue;
6833
6834 if ((table = rn->info) != NULL)
6835 {
6836 header = 1;
6837
6838 if ((rm = bgp_node_match (table, &match)) != NULL)
6839 {
6840 if (prefix_check && rm->p.prefixlen != match.prefixlen)
Chris Caputo6c88b442010-07-27 16:28:55 +00006841 {
6842 bgp_unlock_node (rm);
6843 continue;
6844 }
paul718e3742002-12-13 20:15:29 +00006845
6846 for (ri = rm->info; ri; ri = ri->next)
6847 {
6848 if (header)
6849 {
6850 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
Lou Berger298cc2f2016-01-12 13:42:02 -05006851 AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006852
6853 header = 0;
6854 }
6855 display++;
Lou Berger298cc2f2016-01-12 13:42:02 -05006856 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006857 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006858
6859 bgp_unlock_node (rm);
paul718e3742002-12-13 20:15:29 +00006860 }
6861 }
6862 }
6863 }
6864 else
6865 {
6866 header = 1;
6867
paulfee0f4c2004-09-13 05:12:46 +00006868 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00006869 {
6870 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6871 {
6872 for (ri = rn->info; ri; ri = ri->next)
6873 {
6874 if (header)
6875 {
6876 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6877 header = 0;
6878 }
6879 display++;
6880 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
6881 }
6882 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006883
6884 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00006885 }
6886 }
6887
6888 if (! display)
6889 {
6890 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6891 return CMD_WARNING;
6892 }
6893
6894 return CMD_SUCCESS;
6895}
6896
paulfee0f4c2004-09-13 05:12:46 +00006897/* Display specified route of Main RIB */
paul94f2b392005-06-28 12:44:16 +00006898static int
paulfd79ac92004-10-13 05:06:08 +00006899bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00006900 afi_t afi, safi_t safi, struct prefix_rd *prd,
6901 int prefix_check)
6902{
6903 struct bgp *bgp;
6904
6905 /* BGP structure lookup. */
6906 if (view_name)
6907 {
6908 bgp = bgp_lookup_by_name (view_name);
6909 if (bgp == NULL)
6910 {
6911 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6912 return CMD_WARNING;
6913 }
6914 }
6915 else
6916 {
6917 bgp = bgp_get_default ();
6918 if (bgp == NULL)
6919 {
6920 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6921 return CMD_WARNING;
6922 }
6923 }
6924
6925 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
6926 afi, safi, prd, prefix_check);
6927}
6928
paul718e3742002-12-13 20:15:29 +00006929/* BGP route print out function. */
Lou Bergerf9b6c392016-01-12 13:42:09 -05006930DEFUN (show_ip_bgp,
6931 show_ip_bgp_cmd,
6932 "show ip bgp",
6933 SHOW_STR
6934 IP_STR
6935 BGP_STR)
6936{
6937 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6938}
6939
6940DEFUN (show_ip_bgp_ipv4,
6941 show_ip_bgp_ipv4_cmd,
6942 "show ip bgp ipv4 (unicast|multicast)",
6943 SHOW_STR
6944 IP_STR
6945 BGP_STR
6946 "Address family\n"
6947 "Address Family modifier\n"
6948 "Address Family modifier\n")
6949{
6950 if (strncmp (argv[0], "m", 1) == 0)
6951 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
6952 NULL);
6953
6954 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6955}
6956
6957DEFUN (show_ip_bgp_route,
6958 show_ip_bgp_route_cmd,
6959 "show ip bgp A.B.C.D",
6960 SHOW_STR
6961 IP_STR
6962 BGP_STR
6963 "Network in the BGP routing table to display\n")
6964{
6965 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
6966}
6967
6968DEFUN (show_ip_bgp_ipv4_route,
6969 show_ip_bgp_ipv4_route_cmd,
6970 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6971 SHOW_STR
6972 IP_STR
6973 BGP_STR
6974 "Address family\n"
6975 "Address Family modifier\n"
6976 "Address Family modifier\n"
6977 "Network in the BGP routing table to display\n")
6978{
6979 if (strncmp (argv[0], "m", 1) == 0)
6980 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
6981
6982 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
6983}
6984
6985DEFUN (show_ip_bgp_vpnv4_all_route,
6986 show_ip_bgp_vpnv4_all_route_cmd,
6987 "show ip bgp vpnv4 all A.B.C.D",
6988 SHOW_STR
6989 IP_STR
6990 BGP_STR
6991 "Display VPNv4 NLRI specific information\n"
6992 "Display information about all VPNv4 NLRIs\n"
6993 "Network in the BGP routing table to display\n")
6994{
6995 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
6996}
6997
6998DEFUN (show_ip_bgp_vpnv4_rd_route,
6999 show_ip_bgp_vpnv4_rd_route_cmd,
7000 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
7001 SHOW_STR
7002 IP_STR
7003 BGP_STR
7004 "Display VPNv4 NLRI specific information\n"
7005 "Display information for a route distinguisher\n"
7006 "VPN Route Distinguisher\n"
7007 "Network in the BGP routing table to display\n")
7008{
7009 int ret;
7010 struct prefix_rd prd;
7011
7012 ret = str2prefix_rd (argv[0], &prd);
7013 if (! ret)
7014 {
7015 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7016 return CMD_WARNING;
7017 }
7018 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
7019}
7020
7021DEFUN (show_ip_bgp_prefix,
7022 show_ip_bgp_prefix_cmd,
7023 "show ip bgp A.B.C.D/M",
7024 SHOW_STR
7025 IP_STR
7026 BGP_STR
7027 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7028{
7029 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
7030}
7031
7032DEFUN (show_ip_bgp_ipv4_prefix,
7033 show_ip_bgp_ipv4_prefix_cmd,
7034 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
7035 SHOW_STR
7036 IP_STR
7037 BGP_STR
7038 "Address family\n"
7039 "Address Family modifier\n"
7040 "Address Family modifier\n"
7041 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7042{
7043 if (strncmp (argv[0], "m", 1) == 0)
7044 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
7045
7046 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7047}
7048
7049DEFUN (show_ip_bgp_vpnv4_all_prefix,
7050 show_ip_bgp_vpnv4_all_prefix_cmd,
7051 "show ip bgp vpnv4 all A.B.C.D/M",
7052 SHOW_STR
7053 IP_STR
7054 BGP_STR
7055 "Display VPNv4 NLRI specific information\n"
7056 "Display information about all VPNv4 NLRIs\n"
7057 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7058{
7059 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
7060}
7061
7062DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7063 show_ip_bgp_vpnv4_rd_prefix_cmd,
7064 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7065 SHOW_STR
7066 IP_STR
7067 BGP_STR
7068 "Display VPNv4 NLRI specific information\n"
7069 "Display information for a route distinguisher\n"
7070 "VPN Route Distinguisher\n"
7071 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7072{
7073 int ret;
7074 struct prefix_rd prd;
7075
7076 ret = str2prefix_rd (argv[0], &prd);
7077 if (! ret)
7078 {
7079 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7080 return CMD_WARNING;
7081 }
7082 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
7083}
7084
7085DEFUN (show_ip_bgp_view,
7086 show_ip_bgp_view_cmd,
7087 "show ip bgp view WORD",
7088 SHOW_STR
7089 IP_STR
7090 BGP_STR
7091 "BGP view\n"
7092 "View name\n")
7093{
7094 struct bgp *bgp;
7095
7096 /* BGP structure lookup. */
7097 bgp = bgp_lookup_by_name (argv[0]);
7098 if (bgp == NULL)
7099 {
7100 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7101 return CMD_WARNING;
7102 }
7103
7104 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7105}
7106
7107DEFUN (show_ip_bgp_view_route,
7108 show_ip_bgp_view_route_cmd,
7109 "show ip bgp view WORD A.B.C.D",
7110 SHOW_STR
7111 IP_STR
7112 BGP_STR
7113 "BGP view\n"
7114 "View name\n"
7115 "Network in the BGP routing table to display\n")
7116{
7117 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7118}
7119
7120DEFUN (show_ip_bgp_view_prefix,
7121 show_ip_bgp_view_prefix_cmd,
7122 "show ip bgp view WORD A.B.C.D/M",
7123 SHOW_STR
7124 IP_STR
7125 BGP_STR
7126 "BGP view\n"
7127 "View name\n"
7128 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7129{
7130 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7131}
7132
7133DEFUN (show_bgp,
7134 show_bgp_cmd,
7135 "show bgp",
7136 SHOW_STR
7137 BGP_STR)
7138{
7139 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7140 NULL);
7141}
7142
7143ALIAS (show_bgp,
7144 show_bgp_ipv6_cmd,
7145 "show bgp ipv6",
7146 SHOW_STR
7147 BGP_STR
7148 "Address family\n")
7149
7150/* old command */
7151DEFUN (show_ipv6_bgp,
7152 show_ipv6_bgp_cmd,
7153 "show ipv6 bgp",
7154 SHOW_STR
7155 IP_STR
7156 BGP_STR)
7157{
7158 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7159 NULL);
7160}
7161
7162DEFUN (show_bgp_route,
7163 show_bgp_route_cmd,
7164 "show bgp X:X::X:X",
7165 SHOW_STR
7166 BGP_STR
7167 "Network in the BGP routing table to display\n")
7168{
7169 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7170}
7171
Lou Berger35c36862016-01-12 13:42:06 -05007172DEFUN (show_bgp_ipv4_safi,
7173 show_bgp_ipv4_safi_cmd,
7174 "show bgp ipv4 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00007175 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007176 BGP_STR
7177 "Address family\n"
7178 "Address Family modifier\n"
7179 "Address Family modifier\n")
7180{
7181 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00007182 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7183 NULL);
paul718e3742002-12-13 20:15:29 +00007184
ajs5a646652004-11-05 01:25:55 +00007185 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00007186}
7187
Lou Berger35c36862016-01-12 13:42:06 -05007188DEFUN (show_bgp_ipv4_safi_route,
7189 show_bgp_ipv4_safi_route_cmd,
7190 "show bgp ipv4 (unicast|multicast) A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007191 SHOW_STR
7192 BGP_STR
7193 "Address family\n"
7194 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00007195 "Address Family modifier\n"
7196 "Network in the BGP routing table to display\n")
7197{
7198 if (strncmp (argv[0], "m", 1) == 0)
7199 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
7200
7201 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7202}
7203
Lou Berger35c36862016-01-12 13:42:06 -05007204DEFUN (show_bgp_ipv4_vpn_route,
7205 show_bgp_ipv4_vpn_route_cmd,
7206 "show bgp ipv4 vpn A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007207 SHOW_STR
7208 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007209 "Address Family\n"
7210 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007211 "Network in the BGP routing table to display\n")
7212{
7213 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
7214}
7215
Lou Berger35c36862016-01-12 13:42:06 -05007216DEFUN (show_bgp_ipv6_vpn_route,
7217 show_bgp_ipv6_vpn_route_cmd,
7218 "show bgp ipv6 vpn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007219 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007220 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007221 "Address Family\n"
7222 "Display VPN NLRI specific information\n"
7223 "Network in the BGP routing table to display\n")
7224{
7225 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0);
7226}
Lou Berger35c36862016-01-12 13:42:06 -05007227
7228DEFUN (show_bgp_ipv4_vpn_rd_route,
7229 show_bgp_ipv4_vpn_rd_route_cmd,
7230 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7231 SHOW_STR
7232 BGP_STR
7233 IP_STR
7234 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007235 "Display information for a route distinguisher\n"
7236 "VPN Route Distinguisher\n"
7237 "Network in the BGP routing table to display\n")
7238{
7239 int ret;
7240 struct prefix_rd prd;
7241
7242 ret = str2prefix_rd (argv[0], &prd);
7243 if (! ret)
7244 {
7245 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7246 return CMD_WARNING;
7247 }
7248 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
7249}
7250
Lou Berger35c36862016-01-12 13:42:06 -05007251DEFUN (show_bgp_ipv6_vpn_rd_route,
7252 show_bgp_ipv6_vpn_rd_route_cmd,
7253 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007254 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007255 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007256 "Address Family\n"
7257 "Display VPN NLRI specific information\n"
7258 "Display information for a route distinguisher\n"
7259 "VPN Route Distinguisher\n"
7260 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007261{
Lou Berger35c36862016-01-12 13:42:06 -05007262 int ret;
7263 struct prefix_rd prd;
7264
7265 ret = str2prefix_rd (argv[0], &prd);
7266 if (! ret)
7267 {
7268 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7269 return CMD_WARNING;
7270 }
7271 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007272}
7273
Lou Berger651b4022016-01-12 13:42:07 -05007274DEFUN (show_bgp_ipv4_encap_route,
7275 show_bgp_ipv4_encap_route_cmd,
7276 "show bgp ipv4 encap A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007277 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007278 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007279 IP_STR
7280 "Display ENCAP NLRI specific information\n"
7281 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007282{
Lou Berger651b4022016-01-12 13:42:07 -05007283 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007284}
7285
Lou Berger651b4022016-01-12 13:42:07 -05007286DEFUN (show_bgp_ipv6_encap_route,
7287 show_bgp_ipv6_encap_route_cmd,
7288 "show bgp ipv6 encap X:X::X:X",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007289 SHOW_STR
7290 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007291 IP6_STR
7292 "Display ENCAP NLRI specific information\n"
7293 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007294{
Lou Berger651b4022016-01-12 13:42:07 -05007295 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007296}
7297
Lou Berger651b4022016-01-12 13:42:07 -05007298DEFUN (show_bgp_ipv4_safi_rd_route,
7299 show_bgp_ipv4_safi_rd_route_cmd,
7300 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007301 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007302 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007303 "Address Family\n"
7304 "Address Family Modifier\n"
7305 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007306 "Display information for a route distinguisher\n"
Lou Berger651b4022016-01-12 13:42:07 -05007307 "ENCAP Route Distinguisher\n"
7308 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007309{
7310 int ret;
7311 struct prefix_rd prd;
Lou Berger651b4022016-01-12 13:42:07 -05007312 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007313
Lou Berger651b4022016-01-12 13:42:07 -05007314 if (bgp_parse_safi(argv[0], &safi)) {
7315 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7316 return CMD_WARNING;
7317 }
7318 ret = str2prefix_rd (argv[1], &prd);
paul718e3742002-12-13 20:15:29 +00007319 if (! ret)
7320 {
7321 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7322 return CMD_WARNING;
7323 }
Lou Berger651b4022016-01-12 13:42:07 -05007324 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007325}
7326
Lou Berger651b4022016-01-12 13:42:07 -05007327DEFUN (show_bgp_ipv6_safi_rd_route,
7328 show_bgp_ipv6_safi_rd_route_cmd,
7329 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007330 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007331 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007332 "Address Family\n"
7333 "Address Family Modifier\n"
7334 "Address Family Modifier\n"
7335 "Display information for a route distinguisher\n"
7336 "ENCAP Route Distinguisher\n"
7337 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007338{
Lou Berger651b4022016-01-12 13:42:07 -05007339 int ret;
7340 struct prefix_rd prd;
7341 safi_t safi;
paulbb46e942003-10-24 19:02:03 +00007342
Lou Berger651b4022016-01-12 13:42:07 -05007343 if (bgp_parse_safi(argv[0], &safi)) {
7344 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7345 return CMD_WARNING;
7346 }
7347 ret = str2prefix_rd (argv[1], &prd);
7348 if (! ret)
7349 {
7350 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7351 return CMD_WARNING;
7352 }
7353 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007354}
7355
Lou Berger35c36862016-01-12 13:42:06 -05007356DEFUN (show_bgp_ipv4_prefix,
7357 show_bgp_ipv4_prefix_cmd,
7358 "show bgp ipv4 A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007359 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007360 BGP_STR
paul718e3742002-12-13 20:15:29 +00007361 IP_STR
paul718e3742002-12-13 20:15:29 +00007362 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7363{
Lou Berger35c36862016-01-12 13:42:06 -05007364 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007365}
7366
Lou Berger35c36862016-01-12 13:42:06 -05007367DEFUN (show_bgp_ipv4_safi_prefix,
7368 show_bgp_ipv4_safi_prefix_cmd,
7369 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007370 SHOW_STR
7371 BGP_STR
7372 "Address family\n"
7373 "Address Family modifier\n"
Lou Berger35c36862016-01-12 13:42:06 -05007374 "Address Family modifier\n"
7375 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04007376{
7377 if (strncmp (argv[0], "m", 1) == 0)
Lou Berger35c36862016-01-12 13:42:06 -05007378 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007379
Lou Berger35c36862016-01-12 13:42:06 -05007380 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007381}
7382
Lou Berger35c36862016-01-12 13:42:06 -05007383DEFUN (show_bgp_ipv4_vpn_prefix,
7384 show_bgp_ipv4_vpn_prefix_cmd,
7385 "show bgp ipv4 vpn A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007386 SHOW_STR
7387 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007388 IP_STR
7389 "Display VPN NLRI specific information\n"
7390 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +00007391{
Lou Berger35c36862016-01-12 13:42:06 -05007392 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007393}
7394
Lou Berger35c36862016-01-12 13:42:06 -05007395DEFUN (show_bgp_ipv6_vpn_prefix,
7396 show_bgp_ipv6_vpn_prefix_cmd,
7397 "show bgp ipv6 vpn X:X::X:X/M",
7398 SHOW_STR
7399 BGP_STR
7400 "Address Family\n"
7401 "Display VPN NLRI specific information\n"
7402 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7403{
7404 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1);
7405}
Lou Berger35c36862016-01-12 13:42:06 -05007406
Lou Berger651b4022016-01-12 13:42:07 -05007407DEFUN (show_bgp_ipv4_encap_prefix,
7408 show_bgp_ipv4_encap_prefix_cmd,
7409 "show bgp ipv4 encap A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007410 SHOW_STR
7411 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007412 IP_STR
7413 "Display ENCAP NLRI specific information\n"
7414 "Display information about ENCAP NLRIs\n"
7415 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7416{
7417 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1);
7418}
paul718e3742002-12-13 20:15:29 +00007419
Lou Berger651b4022016-01-12 13:42:07 -05007420DEFUN (show_bgp_ipv6_encap_prefix,
7421 show_bgp_ipv6_encap_prefix_cmd,
7422 "show bgp ipv6 encap X:X::X:X/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007423 SHOW_STR
7424 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007425 IP_STR
7426 "Display ENCAP NLRI specific information\n"
7427 "Display information about ENCAP NLRIs\n"
7428 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7429{
7430 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1);
7431}
Lou Berger651b4022016-01-12 13:42:07 -05007432
7433DEFUN (show_bgp_ipv4_safi_rd_prefix,
7434 show_bgp_ipv4_safi_rd_prefix_cmd,
7435 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7436 SHOW_STR
7437 BGP_STR
7438 "Address Family\n"
7439 "Address Family Modifier\n"
7440 "Address Family Modifier\n"
7441 "Display information for a route distinguisher\n"
7442 "ENCAP Route Distinguisher\n"
7443 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7444{
7445 int ret;
7446 struct prefix_rd prd;
7447 safi_t safi;
7448
7449 if (bgp_parse_safi(argv[0], &safi)) {
7450 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7451 return CMD_WARNING;
7452 }
7453
7454 ret = str2prefix_rd (argv[1], &prd);
7455 if (! ret)
7456 {
7457 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7458 return CMD_WARNING;
7459 }
7460 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1);
7461}
7462
Lou Berger651b4022016-01-12 13:42:07 -05007463DEFUN (show_bgp_ipv6_safi_rd_prefix,
7464 show_bgp_ipv6_safi_rd_prefix_cmd,
7465 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7466 SHOW_STR
7467 BGP_STR
7468 "Address Family\n"
7469 "Address Family Modifier\n"
7470 "Address Family Modifier\n"
7471 "Display information for a route distinguisher\n"
7472 "ENCAP Route Distinguisher\n"
7473 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7474{
7475 int ret;
7476 struct prefix_rd prd;
7477 safi_t safi;
7478
7479 if (bgp_parse_safi(argv[0], &safi)) {
7480 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7481 return CMD_WARNING;
7482 }
7483
7484 ret = str2prefix_rd (argv[1], &prd);
7485 if (! ret)
7486 {
7487 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7488 return CMD_WARNING;
7489 }
7490 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1);
7491}
Lou Berger651b4022016-01-12 13:42:07 -05007492
7493DEFUN (show_bgp_afi_safi_view,
7494 show_bgp_afi_safi_view_cmd,
7495 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7496 SHOW_STR
7497 BGP_STR
7498 "BGP view\n"
7499 "BGP view name\n"
7500 "Address Family\n"
7501 "Address Family\n"
7502 "Address Family Modifier\n"
7503 "Address Family Modifier\n"
7504 "Address Family Modifier\n"
7505 "Address Family Modifier\n"
7506 )
7507{
7508 struct bgp *bgp;
7509 safi_t safi;
7510 afi_t afi;
7511
7512 if (bgp_parse_afi(argv[1], &afi)) {
7513 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7514 return CMD_WARNING;
7515 }
7516 if (bgp_parse_safi(argv[2], &safi)) {
7517 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7518 return CMD_WARNING;
7519 }
7520
7521 /* BGP structure lookup. */
7522 bgp = bgp_lookup_by_name (argv[0]);
7523 if (bgp == NULL)
7524 {
7525 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7526 return CMD_WARNING;
7527 }
7528
7529 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7530}
7531
7532DEFUN (show_bgp_view_afi_safi_route,
7533 show_bgp_view_afi_safi_route_cmd,
7534 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7535 SHOW_STR
7536 BGP_STR
7537 "BGP view\n"
7538 "View name\n"
7539 "Address Family\n"
7540 "Address Family\n"
7541 "Address Family Modifier\n"
7542 "Address Family Modifier\n"
7543 "Address Family Modifier\n"
7544 "Address Family Modifier\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -04007545 "Network in the BGP routing table to display\n")
7546{
Lou Berger651b4022016-01-12 13:42:07 -05007547 safi_t safi;
7548 afi_t afi;
Michael Lambert95cbbd22010-07-23 14:43:04 -04007549
Lou Berger651b4022016-01-12 13:42:07 -05007550 if (bgp_parse_afi(argv[1], &afi)) {
7551 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7552 return CMD_WARNING;
7553 }
7554 if (bgp_parse_safi(argv[2], &safi)) {
7555 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7556 return CMD_WARNING;
7557 }
7558 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0);
7559}
7560
7561DEFUN (show_bgp_view_afi_safi_prefix,
7562 show_bgp_view_afi_safi_prefix_cmd,
7563 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7564 SHOW_STR
7565 BGP_STR
7566 "BGP view\n"
7567 "View name\n"
7568 "Address Family\n"
7569 "Address Family\n"
7570 "Address Family Modifier\n"
7571 "Address Family Modifier\n"
7572 "Address Family Modifier\n"
7573 "Address Family Modifier\n"
7574 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7575{
7576 safi_t safi;
7577 afi_t afi;
7578
7579 if (bgp_parse_afi(argv[1], &afi)) {
7580 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7581 return CMD_WARNING;
7582 }
7583 if (bgp_parse_safi(argv[2], &safi)) {
7584 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7585 return CMD_WARNING;
7586 }
7587 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1);
7588}
7589
7590/* new001 */
7591DEFUN (show_bgp_afi,
7592 show_bgp_afi_cmd,
7593 "show bgp (ipv4|ipv6)",
7594 SHOW_STR
7595 BGP_STR
7596 "Address family\n"
7597 "Address family\n")
7598{
7599 afi_t afi;
7600
7601 if (bgp_parse_afi(argv[0], &afi)) {
7602 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7603 return CMD_WARNING;
7604 }
7605 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7606 NULL);
7607}
7608
Lou Berger651b4022016-01-12 13:42:07 -05007609DEFUN (show_bgp_ipv6_safi,
7610 show_bgp_ipv6_safi_cmd,
7611 "show bgp ipv6 (unicast|multicast)",
7612 SHOW_STR
7613 BGP_STR
7614 "Address family\n"
7615 "Address Family modifier\n"
7616 "Address Family modifier\n")
7617{
7618 if (strncmp (argv[0], "m", 1) == 0)
7619 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7620 NULL);
7621
7622 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007623}
7624
Lou Berger35c36862016-01-12 13:42:06 -05007625DEFUN (show_bgp_ipv6_route,
7626 show_bgp_ipv6_route_cmd,
7627 "show bgp ipv6 X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007628 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007629 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007630 "Address family\n"
paul718e3742002-12-13 20:15:29 +00007631 "Network in the BGP routing table to display\n")
7632{
7633 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7634}
7635
Lou Berger35c36862016-01-12 13:42:06 -05007636DEFUN (show_bgp_ipv6_safi_route,
7637 show_bgp_ipv6_safi_route_cmd,
7638 "show bgp ipv6 (unicast|multicast) X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007639 SHOW_STR
7640 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007641 "Address family\n"
7642 "Address Family modifier\n"
7643 "Address Family modifier\n"
7644 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007645{
Lou Berger35c36862016-01-12 13:42:06 -05007646 if (strncmp (argv[0], "m", 1) == 0)
7647 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7648
7649 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007650}
7651
Lou Bergerf9b6c392016-01-12 13:42:09 -05007652/* old command */
7653DEFUN (show_ipv6_bgp_route,
7654 show_ipv6_bgp_route_cmd,
7655 "show ipv6 bgp X:X::X:X",
7656 SHOW_STR
7657 IP_STR
7658 BGP_STR
7659 "Network in the BGP routing table to display\n")
7660{
7661 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7662}
7663
7664DEFUN (show_bgp_prefix,
7665 show_bgp_prefix_cmd,
7666 "show bgp X:X::X:X/M",
7667 SHOW_STR
7668 BGP_STR
7669 "IPv6 prefix <network>/<length>\n")
7670{
7671 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7672}
7673
7674
Lou Berger35c36862016-01-12 13:42:06 -05007675/* new002 */
7676DEFUN (show_bgp_ipv6_prefix,
paul718e3742002-12-13 20:15:29 +00007677 show_bgp_ipv6_prefix_cmd,
7678 "show bgp ipv6 X:X::X:X/M",
7679 SHOW_STR
7680 BGP_STR
7681 "Address family\n"
Lou Berger35c36862016-01-12 13:42:06 -05007682 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7683{
7684 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7685}
Michael Lambert95cbbd22010-07-23 14:43:04 -04007686DEFUN (show_bgp_ipv6_safi_prefix,
7687 show_bgp_ipv6_safi_prefix_cmd,
7688 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7689 SHOW_STR
7690 BGP_STR
7691 "Address family\n"
7692 "Address Family modifier\n"
7693 "Address Family modifier\n"
7694 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7695{
7696 if (strncmp (argv[0], "m", 1) == 0)
7697 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7698
7699 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7700}
7701
Lou Bergerf9b6c392016-01-12 13:42:09 -05007702/* old command */
7703DEFUN (show_ipv6_bgp_prefix,
7704 show_ipv6_bgp_prefix_cmd,
7705 "show ipv6 bgp X:X::X:X/M",
7706 SHOW_STR
7707 IP_STR
7708 BGP_STR
7709 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7710{
7711 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7712}
7713
paulbb46e942003-10-24 19:02:03 +00007714DEFUN (show_bgp_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007715 show_bgp_view_cmd,
7716 "show bgp view WORD",
7717 SHOW_STR
7718 BGP_STR
7719 "BGP view\n"
7720 "View name\n")
7721{
7722 struct bgp *bgp;
7723
7724 /* BGP structure lookup. */
7725 bgp = bgp_lookup_by_name (argv[0]);
7726 if (bgp == NULL)
7727 {
7728 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7729 return CMD_WARNING;
7730 }
7731
7732 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
7733}
7734
7735DEFUN (show_bgp_view_ipv6,
Lou Berger35c36862016-01-12 13:42:06 -05007736 show_bgp_view_ipv6_cmd,
7737 "show bgp view WORD ipv6",
paulbb46e942003-10-24 19:02:03 +00007738 SHOW_STR
Lou Berger35c36862016-01-12 13:42:06 -05007739 BGP_STR
paulbb46e942003-10-24 19:02:03 +00007740 "BGP view\n"
Lou Berger35c36862016-01-12 13:42:06 -05007741 "View name\n"
7742 "Address family\n")
paulbb46e942003-10-24 19:02:03 +00007743{
7744 struct bgp *bgp;
7745
7746 /* BGP structure lookup. */
7747 bgp = bgp_lookup_by_name (argv[0]);
7748 if (bgp == NULL)
7749 {
7750 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7751 return CMD_WARNING;
7752 }
7753
ajs5a646652004-11-05 01:25:55 +00007754 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00007755}
paulbb46e942003-10-24 19:02:03 +00007756
7757DEFUN (show_bgp_view_route,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007758 show_bgp_view_route_cmd,
7759 "show bgp view WORD X:X::X:X",
7760 SHOW_STR
7761 BGP_STR
7762 "BGP view\n"
7763 "View name\n"
7764 "Network in the BGP routing table to display\n")
7765{
7766 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
7767}
7768
7769DEFUN (show_bgp_view_ipv6_route,
paulbb46e942003-10-24 19:02:03 +00007770 show_bgp_view_ipv6_route_cmd,
7771 "show bgp view WORD ipv6 X:X::X:X",
7772 SHOW_STR
7773 BGP_STR
7774 "BGP view\n"
7775 "View name\n"
7776 "Address family\n"
7777 "Network in the BGP routing table to display\n")
paulbb46e942003-10-24 19:02:03 +00007778{
Lou Berger35c36862016-01-12 13:42:06 -05007779 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paulbb46e942003-10-24 19:02:03 +00007780}
7781
Lou Bergerf9b6c392016-01-12 13:42:09 -05007782/* old command */
7783DEFUN (show_ipv6_mbgp,
7784 show_ipv6_mbgp_cmd,
7785 "show ipv6 mbgp",
7786 SHOW_STR
7787 IP_STR
7788 MBGP_STR)
7789{
7790 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7791 NULL);
7792}
7793
7794/* old command */
7795DEFUN (show_ipv6_mbgp_route,
7796 show_ipv6_mbgp_route_cmd,
7797 "show ipv6 mbgp X:X::X:X",
7798 SHOW_STR
7799 IP_STR
7800 MBGP_STR
7801 "Network in the MBGP routing table to display\n")
7802{
7803 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7804}
7805
7806/* old command */
7807DEFUN (show_ipv6_mbgp_prefix,
7808 show_ipv6_mbgp_prefix_cmd,
7809 "show ipv6 mbgp X:X::X:X/M",
7810 SHOW_STR
7811 IP_STR
7812 MBGP_STR
7813 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7814{
7815 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7816}
7817
Lou Berger35c36862016-01-12 13:42:06 -05007818DEFUN (show_bgp_view_prefix,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007819 show_bgp_view_prefix_cmd,
7820 "show bgp view WORD X:X::X:X/M",
7821 SHOW_STR
7822 BGP_STR
7823 "BGP view\n"
7824 "View name\n"
7825 "IPv6 prefix <network>/<length>\n")
7826{
7827 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7828}
7829
7830DEFUN (show_bgp_view_ipv6_prefix,
paulbb46e942003-10-24 19:02:03 +00007831 show_bgp_view_ipv6_prefix_cmd,
7832 "show bgp view WORD ipv6 X:X::X:X/M",
7833 SHOW_STR
7834 BGP_STR
7835 "BGP view\n"
7836 "View name\n"
7837 "Address family\n"
7838 "IPv6 prefix <network>/<length>\n")
paul718e3742002-12-13 20:15:29 +00007839{
Lou Berger35c36862016-01-12 13:42:06 -05007840 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007841}
7842
paul94f2b392005-06-28 12:44:16 +00007843static int
paulfd79ac92004-10-13 05:06:08 +00007844bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00007845 safi_t safi, enum bgp_show_type type)
7846{
7847 int i;
7848 struct buffer *b;
7849 char *regstr;
7850 int first;
7851 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00007852 int rc;
paul718e3742002-12-13 20:15:29 +00007853
7854 first = 0;
7855 b = buffer_new (1024);
7856 for (i = 0; i < argc; i++)
7857 {
7858 if (first)
7859 buffer_putc (b, ' ');
7860 else
7861 {
7862 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
7863 continue;
7864 first = 1;
7865 }
7866
7867 buffer_putstr (b, argv[i]);
7868 }
7869 buffer_putc (b, '\0');
7870
7871 regstr = buffer_getstr (b);
7872 buffer_free (b);
7873
7874 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00007875 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00007876 if (! regex)
7877 {
7878 vty_out (vty, "Can't compile regexp %s%s", argv[0],
7879 VTY_NEWLINE);
7880 return CMD_WARNING;
7881 }
7882
ajs5a646652004-11-05 01:25:55 +00007883 rc = bgp_show (vty, NULL, afi, safi, type, regex);
7884 bgp_regex_free (regex);
7885 return rc;
paul718e3742002-12-13 20:15:29 +00007886}
7887
Lou Bergerf9b6c392016-01-12 13:42:09 -05007888
7889DEFUN (show_ip_bgp_regexp,
7890 show_ip_bgp_regexp_cmd,
7891 "show ip bgp regexp .LINE",
7892 SHOW_STR
7893 IP_STR
7894 BGP_STR
7895 "Display routes matching the AS path regular expression\n"
7896 "A regular-expression to match the BGP AS paths\n")
7897{
7898 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7899 bgp_show_type_regexp);
7900}
7901
7902DEFUN (show_ip_bgp_flap_regexp,
7903 show_ip_bgp_flap_regexp_cmd,
7904 "show ip bgp flap-statistics regexp .LINE",
7905 SHOW_STR
7906 IP_STR
7907 BGP_STR
7908 "Display flap statistics of routes\n"
7909 "Display routes matching the AS path regular expression\n"
7910 "A regular-expression to match the BGP AS paths\n")
7911{
7912 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7913 bgp_show_type_flap_regexp);
7914}
7915
7916ALIAS (show_ip_bgp_flap_regexp,
7917 show_ip_bgp_damp_flap_regexp_cmd,
7918 "show ip bgp dampening flap-statistics regexp .LINE",
7919 SHOW_STR
7920 IP_STR
7921 BGP_STR
7922 "Display detailed information about dampening\n"
7923 "Display flap statistics of routes\n"
7924 "Display routes matching the AS path regular expression\n"
7925 "A regular-expression to match the BGP AS paths\n")
7926
7927DEFUN (show_ip_bgp_ipv4_regexp,
7928 show_ip_bgp_ipv4_regexp_cmd,
7929 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7930 SHOW_STR
7931 IP_STR
7932 BGP_STR
7933 "Address family\n"
7934 "Address Family modifier\n"
7935 "Address Family modifier\n"
7936 "Display routes matching the AS path regular expression\n"
7937 "A regular-expression to match the BGP AS paths\n")
7938{
7939 if (strncmp (argv[0], "m", 1) == 0)
7940 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
7941 bgp_show_type_regexp);
7942
7943 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7944 bgp_show_type_regexp);
7945}
7946
Lou Bergerf9b6c392016-01-12 13:42:09 -05007947DEFUN (show_bgp_regexp,
7948 show_bgp_regexp_cmd,
7949 "show bgp regexp .LINE",
7950 SHOW_STR
7951 BGP_STR
7952 "Display routes matching the AS path regular expression\n"
7953 "A regular-expression to match the BGP AS paths\n")
7954{
7955 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7956 bgp_show_type_regexp);
7957}
7958
7959/* old command */
7960DEFUN (show_ipv6_bgp_regexp,
7961 show_ipv6_bgp_regexp_cmd,
7962 "show ipv6 bgp regexp .LINE",
7963 SHOW_STR
7964 IP_STR
7965 BGP_STR
7966 "Display routes matching the AS path regular expression\n"
7967 "A regular-expression to match the BGP AS paths\n")
7968{
7969 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7970 bgp_show_type_regexp);
7971}
7972
7973/* old command */
7974DEFUN (show_ipv6_mbgp_regexp,
7975 show_ipv6_mbgp_regexp_cmd,
7976 "show ipv6 mbgp regexp .LINE",
7977 SHOW_STR
7978 IP_STR
7979 BGP_STR
7980 "Display routes matching the AS path regular expression\n"
7981 "A regular-expression to match the MBGP AS paths\n")
7982{
7983 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
7984 bgp_show_type_regexp);
7985}
Lou Bergerf9b6c392016-01-12 13:42:09 -05007986
Lou Berger651b4022016-01-12 13:42:07 -05007987DEFUN (show_bgp_ipv4_safi_flap_regexp,
7988 show_bgp_ipv4_safi_flap_regexp_cmd,
7989 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00007990 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007991 BGP_STR
paul718e3742002-12-13 20:15:29 +00007992 IP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007993 "Address Family Modifier\n"
7994 "Address Family Modifier\n"
7995 "Address Family Modifier\n"
7996 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007997 "Display flap statistics of routes\n"
7998 "Display routes matching the AS path regular expression\n"
7999 "A regular-expression to match the BGP AS paths\n")
8000{
Lou Berger651b4022016-01-12 13:42:07 -05008001 safi_t safi;
8002
8003 if (bgp_parse_safi(argv[0], &safi)) {
8004 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8005 return CMD_WARNING;
8006 }
8007 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
8008 bgp_show_type_flap_regexp);
paul718e3742002-12-13 20:15:29 +00008009}
8010
Lou Berger651b4022016-01-12 13:42:07 -05008011ALIAS (show_bgp_ipv4_safi_flap_regexp,
8012 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
8013 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
Balaji3921cc52015-05-16 23:12:17 +05308014 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308015 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008016 IP_STR
8017 "Address Family Modifier\n"
8018 "Address Family Modifier\n"
8019 "Address Family Modifier\n"
8020 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308021 "Display detailed information about dampening\n"
8022 "Display flap statistics of routes\n"
8023 "Display routes matching the AS path regular expression\n"
8024 "A regular-expression to match the BGP AS paths\n")
8025
Lou Berger651b4022016-01-12 13:42:07 -05008026DEFUN (show_bgp_ipv6_safi_flap_regexp,
8027 show_bgp_ipv6_safi_flap_regexp_cmd,
8028 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008029 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008030 BGP_STR
8031 IPV6_STR
8032 "Address Family Modifier\n"
8033 "Address Family Modifier\n"
8034 "Address Family Modifier\n"
8035 "Address Family Modifier\n"
8036 "Display flap statistics of routes\n"
8037 "Display routes matching the AS path regular expression\n"
8038 "A regular-expression to match the BGP AS paths\n")
8039{
8040 safi_t safi;
8041
8042 if (bgp_parse_safi(argv[0], &safi)) {
8043 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8044 return CMD_WARNING;
8045 }
8046 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8047 bgp_show_type_flap_regexp);
8048}
8049
8050ALIAS (show_bgp_ipv6_safi_flap_regexp,
8051 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8052 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8053 SHOW_STR
8054 BGP_STR
8055 IPV6_STR
8056 "Address Family Modifier\n"
8057 "Address Family Modifier\n"
8058 "Address Family Modifier\n"
8059 "Address Family Modifier\n"
8060 "Display detailed information about dampening\n"
8061 "Display flap statistics of routes\n"
8062 "Display routes matching the AS path regular expression\n"
8063 "A regular-expression to match the BGP AS paths\n")
Lou Berger651b4022016-01-12 13:42:07 -05008064
8065DEFUN (show_bgp_ipv4_safi_regexp,
8066 show_bgp_ipv4_safi_regexp_cmd,
8067 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8068 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008069 BGP_STR
8070 "Address family\n"
8071 "Address Family modifier\n"
8072 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008073 "Address Family modifier\n"
8074 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008075 "Display routes matching the AS path regular expression\n"
8076 "A regular-expression to match the BGP AS paths\n")
8077{
Lou Berger651b4022016-01-12 13:42:07 -05008078 safi_t safi;
8079 if (bgp_parse_safi(argv[0], &safi)) {
8080 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8081 return CMD_WARNING;
8082 }
paul718e3742002-12-13 20:15:29 +00008083
Lou Berger651b4022016-01-12 13:42:07 -05008084 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008085 bgp_show_type_regexp);
8086}
Lou Berger205e6742016-01-12 13:42:11 -05008087
Lou Berger651b4022016-01-12 13:42:07 -05008088DEFUN (show_bgp_ipv6_safi_regexp,
8089 show_bgp_ipv6_safi_regexp_cmd,
8090 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008091 SHOW_STR
8092 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008093 "Address family\n"
8094 "Address Family modifier\n"
8095 "Address Family modifier\n"
8096 "Address Family modifier\n"
8097 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008098 "Display routes matching the AS path regular expression\n"
8099 "A regular-expression to match the BGP AS paths\n")
8100{
Lou Berger651b4022016-01-12 13:42:07 -05008101 safi_t safi;
8102 if (bgp_parse_safi(argv[0], &safi)) {
8103 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8104 return CMD_WARNING;
8105 }
8106
8107 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008108 bgp_show_type_regexp);
8109}
8110
Lou Berger651b4022016-01-12 13:42:07 -05008111DEFUN (show_bgp_ipv6_regexp,
paul718e3742002-12-13 20:15:29 +00008112 show_bgp_ipv6_regexp_cmd,
8113 "show bgp ipv6 regexp .LINE",
8114 SHOW_STR
8115 BGP_STR
8116 "Address family\n"
8117 "Display routes matching the AS path regular expression\n"
8118 "A regular-expression to match the BGP AS paths\n")
paul718e3742002-12-13 20:15:29 +00008119{
8120 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8121 bgp_show_type_regexp);
8122}
8123
paul94f2b392005-06-28 12:44:16 +00008124static int
paulfd79ac92004-10-13 05:06:08 +00008125bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008126 safi_t safi, enum bgp_show_type type)
8127{
8128 struct prefix_list *plist;
8129
8130 plist = prefix_list_lookup (afi, prefix_list_str);
8131 if (plist == NULL)
8132 {
8133 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8134 prefix_list_str, VTY_NEWLINE);
8135 return CMD_WARNING;
8136 }
8137
ajs5a646652004-11-05 01:25:55 +00008138 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00008139}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008140DEFUN (show_ip_bgp_prefix_list,
8141 show_ip_bgp_prefix_list_cmd,
8142 "show ip bgp prefix-list WORD",
8143 SHOW_STR
8144 IP_STR
8145 BGP_STR
8146 "Display routes conforming to the prefix-list\n"
8147 "IP prefix-list name\n")
8148{
8149 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8150 bgp_show_type_prefix_list);
8151}
8152
8153DEFUN (show_ip_bgp_flap_prefix_list,
8154 show_ip_bgp_flap_prefix_list_cmd,
8155 "show ip bgp flap-statistics prefix-list WORD",
8156 SHOW_STR
8157 IP_STR
8158 BGP_STR
8159 "Display flap statistics of routes\n"
8160 "Display routes conforming to the prefix-list\n"
8161 "IP prefix-list name\n")
8162{
8163 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8164 bgp_show_type_flap_prefix_list);
8165}
8166
8167ALIAS (show_ip_bgp_flap_prefix_list,
8168 show_ip_bgp_damp_flap_prefix_list_cmd,
8169 "show ip bgp dampening flap-statistics prefix-list WORD",
8170 SHOW_STR
8171 IP_STR
8172 BGP_STR
8173 "Display detailed information about dampening\n"
8174 "Display flap statistics of routes\n"
8175 "Display routes conforming to the prefix-list\n"
8176 "IP prefix-list name\n")
8177
8178DEFUN (show_ip_bgp_ipv4_prefix_list,
8179 show_ip_bgp_ipv4_prefix_list_cmd,
8180 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8181 SHOW_STR
8182 IP_STR
8183 BGP_STR
8184 "Address family\n"
8185 "Address Family modifier\n"
8186 "Address Family modifier\n"
8187 "Display routes conforming to the prefix-list\n"
8188 "IP prefix-list name\n")
8189{
8190 if (strncmp (argv[0], "m", 1) == 0)
8191 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8192 bgp_show_type_prefix_list);
8193
8194 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8195 bgp_show_type_prefix_list);
8196}
8197
Lou Bergerf9b6c392016-01-12 13:42:09 -05008198DEFUN (show_bgp_prefix_list,
8199 show_bgp_prefix_list_cmd,
8200 "show bgp prefix-list WORD",
8201 SHOW_STR
8202 BGP_STR
8203 "Display routes conforming to the prefix-list\n"
8204 "IPv6 prefix-list name\n")
8205{
8206 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8207 bgp_show_type_prefix_list);
8208}
8209
8210ALIAS (show_bgp_prefix_list,
8211 show_bgp_ipv6_prefix_list_cmd,
8212 "show bgp ipv6 prefix-list WORD",
8213 SHOW_STR
8214 BGP_STR
8215 "Address family\n"
8216 "Display routes conforming to the prefix-list\n"
8217 "IPv6 prefix-list name\n")
8218
8219/* old command */
8220DEFUN (show_ipv6_bgp_prefix_list,
8221 show_ipv6_bgp_prefix_list_cmd,
8222 "show ipv6 bgp prefix-list WORD",
8223 SHOW_STR
8224 IPV6_STR
8225 BGP_STR
8226 "Display routes matching the prefix-list\n"
8227 "IPv6 prefix-list name\n")
8228{
8229 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8230 bgp_show_type_prefix_list);
8231}
8232
8233/* old command */
8234DEFUN (show_ipv6_mbgp_prefix_list,
8235 show_ipv6_mbgp_prefix_list_cmd,
8236 "show ipv6 mbgp prefix-list WORD",
8237 SHOW_STR
8238 IPV6_STR
8239 MBGP_STR
8240 "Display routes matching the prefix-list\n"
8241 "IPv6 prefix-list name\n")
8242{
8243 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8244 bgp_show_type_prefix_list);
8245}
paul718e3742002-12-13 20:15:29 +00008246
Lou Berger35c36862016-01-12 13:42:06 -05008247DEFUN (show_bgp_ipv4_prefix_list,
8248 show_bgp_ipv4_prefix_list_cmd,
8249 "show bgp ipv4 prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008250 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008251 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05008252 IP_STR
paul718e3742002-12-13 20:15:29 +00008253 "Display routes conforming to the prefix-list\n"
8254 "IP prefix-list name\n")
8255{
8256 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8257 bgp_show_type_prefix_list);
8258}
8259
Lou Berger651b4022016-01-12 13:42:07 -05008260DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8261 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8262 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008263 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008264 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008265 IP_STR
8266 "Address Family Modifier\n"
8267 "Address Family Modifier\n"
8268 "Address Family Modifier\n"
8269 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008270 "Display flap statistics of routes\n"
8271 "Display routes conforming to the prefix-list\n"
8272 "IP prefix-list name\n")
8273{
Lou Berger651b4022016-01-12 13:42:07 -05008274 safi_t safi;
8275 if (bgp_parse_safi(argv[0], &safi)) {
8276 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8277 return CMD_WARNING;
8278 }
8279 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008280 bgp_show_type_flap_prefix_list);
8281}
8282
Lou Berger651b4022016-01-12 13:42:07 -05008283ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8284 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8285 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308286 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308287 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008288 IP_STR
8289 "Address Family Modifier\n"
8290 "Address Family Modifier\n"
8291 "Address Family Modifier\n"
8292 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308293 "Display detailed information about dampening\n"
8294 "Display flap statistics of routes\n"
8295 "Display routes conforming to the prefix-list\n"
8296 "IP prefix-list name\n")
8297
Lou Berger651b4022016-01-12 13:42:07 -05008298DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8299 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8300 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008301 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008302 BGP_STR
8303 IPV6_STR
8304 "Address Family Modifier\n"
8305 "Address Family Modifier\n"
8306 "Address Family Modifier\n"
8307 "Address Family Modifier\n"
8308 "Display flap statistics of routes\n"
8309 "Display routes conforming to the prefix-list\n"
8310 "IP prefix-list name\n")
8311{
8312 safi_t safi;
8313 if (bgp_parse_safi(argv[0], &safi)) {
8314 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8315 return CMD_WARNING;
8316 }
8317 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8318 bgp_show_type_flap_prefix_list);
8319}
8320ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8321 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8322 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8323 SHOW_STR
8324 BGP_STR
8325 IPV6_STR
8326 "Address Family Modifier\n"
8327 "Address Family Modifier\n"
8328 "Address Family Modifier\n"
8329 "Address Family Modifier\n"
8330 "Display detailed information about dampening\n"
8331 "Display flap statistics of routes\n"
8332 "Display routes conforming to the prefix-list\n"
8333 "IP prefix-list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008334
8335DEFUN (show_bgp_ipv4_safi_prefix_list,
8336 show_bgp_ipv4_safi_prefix_list_cmd,
8337 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8338 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008339 BGP_STR
8340 "Address family\n"
8341 "Address Family modifier\n"
8342 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008343 "Address Family modifier\n"
8344 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008345 "Display routes conforming to the prefix-list\n"
8346 "IP prefix-list name\n")
8347{
Lou Berger651b4022016-01-12 13:42:07 -05008348 safi_t safi;
8349 if (bgp_parse_safi(argv[0], &safi)) {
8350 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8351 return CMD_WARNING;
8352 }
8353 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008354 bgp_show_type_prefix_list);
8355}
Lou Berger205e6742016-01-12 13:42:11 -05008356
Lou Berger651b4022016-01-12 13:42:07 -05008357DEFUN (show_bgp_ipv6_safi_prefix_list,
8358 show_bgp_ipv6_safi_prefix_list_cmd,
8359 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008360 SHOW_STR
8361 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008362 "Address family\n"
8363 "Address Family modifier\n"
8364 "Address Family modifier\n"
8365 "Address Family modifier\n"
8366 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008367 "Display routes conforming to the prefix-list\n"
Lou Berger651b4022016-01-12 13:42:07 -05008368 "IP prefix-list name\n")
paul718e3742002-12-13 20:15:29 +00008369{
Lou Berger651b4022016-01-12 13:42:07 -05008370 safi_t safi;
8371 if (bgp_parse_safi(argv[0], &safi)) {
8372 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8373 return CMD_WARNING;
8374 }
8375 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008376 bgp_show_type_prefix_list);
8377}
8378
paul94f2b392005-06-28 12:44:16 +00008379static int
paulfd79ac92004-10-13 05:06:08 +00008380bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008381 safi_t safi, enum bgp_show_type type)
8382{
8383 struct as_list *as_list;
8384
8385 as_list = as_list_lookup (filter);
8386 if (as_list == NULL)
8387 {
8388 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8389 return CMD_WARNING;
8390 }
8391
ajs5a646652004-11-05 01:25:55 +00008392 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00008393}
8394
Lou Bergerf9b6c392016-01-12 13:42:09 -05008395DEFUN (show_ip_bgp_filter_list,
8396 show_ip_bgp_filter_list_cmd,
8397 "show ip bgp filter-list WORD",
8398 SHOW_STR
8399 IP_STR
8400 BGP_STR
8401 "Display routes conforming to the filter-list\n"
8402 "Regular expression access list name\n")
8403{
8404 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8405 bgp_show_type_filter_list);
8406}
8407
8408DEFUN (show_ip_bgp_flap_filter_list,
8409 show_ip_bgp_flap_filter_list_cmd,
8410 "show ip bgp flap-statistics filter-list WORD",
8411 SHOW_STR
8412 IP_STR
8413 BGP_STR
8414 "Display flap statistics of routes\n"
8415 "Display routes conforming to the filter-list\n"
8416 "Regular expression access list name\n")
8417{
8418 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8419 bgp_show_type_flap_filter_list);
8420}
8421
8422ALIAS (show_ip_bgp_flap_filter_list,
8423 show_ip_bgp_damp_flap_filter_list_cmd,
8424 "show ip bgp dampening flap-statistics filter-list WORD",
8425 SHOW_STR
8426 IP_STR
8427 BGP_STR
8428 "Display detailed information about dampening\n"
8429 "Display flap statistics of routes\n"
8430 "Display routes conforming to the filter-list\n"
8431 "Regular expression access list name\n")
8432
8433DEFUN (show_ip_bgp_ipv4_filter_list,
8434 show_ip_bgp_ipv4_filter_list_cmd,
8435 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8436 SHOW_STR
8437 IP_STR
8438 BGP_STR
8439 "Address family\n"
8440 "Address Family modifier\n"
8441 "Address Family modifier\n"
8442 "Display routes conforming to the filter-list\n"
8443 "Regular expression access list name\n")
8444{
8445 if (strncmp (argv[0], "m", 1) == 0)
8446 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8447 bgp_show_type_filter_list);
8448
8449 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8450 bgp_show_type_filter_list);
8451}
8452
Lou Bergerf9b6c392016-01-12 13:42:09 -05008453DEFUN (show_bgp_filter_list,
8454 show_bgp_filter_list_cmd,
8455 "show bgp filter-list WORD",
8456 SHOW_STR
8457 BGP_STR
8458 "Display routes conforming to the filter-list\n"
8459 "Regular expression access list name\n")
8460{
8461 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8462 bgp_show_type_filter_list);
8463}
8464
8465/* old command */
8466DEFUN (show_ipv6_bgp_filter_list,
8467 show_ipv6_bgp_filter_list_cmd,
8468 "show ipv6 bgp filter-list WORD",
8469 SHOW_STR
8470 IPV6_STR
8471 BGP_STR
8472 "Display routes conforming to the filter-list\n"
8473 "Regular expression access list name\n")
8474{
8475 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8476 bgp_show_type_filter_list);
8477}
8478
8479/* old command */
8480DEFUN (show_ipv6_mbgp_filter_list,
8481 show_ipv6_mbgp_filter_list_cmd,
8482 "show ipv6 mbgp filter-list WORD",
8483 SHOW_STR
8484 IPV6_STR
8485 MBGP_STR
8486 "Display routes conforming to the filter-list\n"
8487 "Regular expression access list name\n")
8488{
8489 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8490 bgp_show_type_filter_list);
8491}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008492
8493DEFUN (show_ip_bgp_dampening_info,
8494 show_ip_bgp_dampening_params_cmd,
8495 "show ip bgp dampening parameters",
8496 SHOW_STR
8497 IP_STR
8498 BGP_STR
8499 "Display detailed information about dampening\n"
8500 "Display detail of configured dampening parameters\n")
8501{
8502 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8503}
8504
Lou Berger651b4022016-01-12 13:42:07 -05008505DEFUN (show_bgp_ipv4_filter_list,
8506 show_bgp_ipv4_filter_list_cmd,
8507 "show bgp ipv4 filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008508 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008509 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008510 IP_STR
paul718e3742002-12-13 20:15:29 +00008511 "Display routes conforming to the filter-list\n"
8512 "Regular expression access list name\n")
8513{
8514 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8515 bgp_show_type_filter_list);
8516}
8517
Lou Berger651b4022016-01-12 13:42:07 -05008518DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8519 show_bgp_ipv4_safi_flap_filter_list_cmd,
8520 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008521 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008522 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008523 IP_STR
8524 "Address Family modifier\n"
8525 "Address Family modifier\n"
8526 "Address Family modifier\n"
8527 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008528 "Display flap statistics of routes\n"
8529 "Display routes conforming to the filter-list\n"
8530 "Regular expression access list name\n")
8531{
Lou Berger651b4022016-01-12 13:42:07 -05008532 safi_t safi;
8533
8534 if (bgp_parse_safi(argv[0], &safi)) {
8535 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8536 return CMD_WARNING;
8537 }
8538 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008539 bgp_show_type_flap_filter_list);
8540}
8541
Lou Berger651b4022016-01-12 13:42:07 -05008542ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8543 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8544 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308545 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308546 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008547 IP_STR
8548 "Address Family modifier\n"
8549 "Address Family modifier\n"
8550 "Address Family modifier\n"
8551 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308552 "Display detailed information about dampening\n"
8553 "Display flap statistics of routes\n"
8554 "Display routes conforming to the filter-list\n"
8555 "Regular expression access list name\n")
8556
Lou Berger651b4022016-01-12 13:42:07 -05008557DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8558 show_bgp_ipv6_safi_flap_filter_list_cmd,
8559 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008560 SHOW_STR
8561 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008562 IPV6_STR
8563 "Address Family modifier\n"
8564 "Address Family modifier\n"
8565 "Address Family modifier\n"
8566 "Address Family modifier\n"
8567 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +00008568 "Display routes conforming to the filter-list\n"
8569 "Regular expression access list name\n")
8570{
Lou Berger651b4022016-01-12 13:42:07 -05008571 safi_t safi;
8572
8573 if (bgp_parse_safi(argv[0], &safi)) {
8574 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8575 return CMD_WARNING;
8576 }
8577 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8578 bgp_show_type_flap_filter_list);
8579}
8580ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8581 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8582 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8583 SHOW_STR
8584 BGP_STR
8585 IPV6_STR
8586 "Address Family modifier\n"
8587 "Address Family modifier\n"
8588 "Address Family modifier\n"
8589 "Address Family modifier\n"
8590 "Display detailed information about dampening\n"
8591 "Display flap statistics of routes\n"
8592 "Display routes conforming to the filter-list\n"
8593 "Regular expression access list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008594
8595DEFUN (show_bgp_ipv4_safi_filter_list,
8596 show_bgp_ipv4_safi_filter_list_cmd,
8597 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8598 SHOW_STR
8599 BGP_STR
8600 "Address Family modifier\n"
8601 "Address Family modifier\n"
8602 "Address Family modifier\n"
8603 "Address Family modifier\n"
8604 "Display routes conforming to the filter-list\n"
8605 "Regular expression access list name\n")
8606{
8607 safi_t safi;
8608
8609 if (bgp_parse_safi(argv[0], &safi)) {
8610 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8611 return CMD_WARNING;
8612 }
8613 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8614 bgp_show_type_filter_list);
8615}
Lou Berger205e6742016-01-12 13:42:11 -05008616
Lou Berger651b4022016-01-12 13:42:07 -05008617DEFUN (show_bgp_ipv6_safi_filter_list,
8618 show_bgp_ipv6_safi_filter_list_cmd,
8619 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8620 SHOW_STR
8621 BGP_STR
8622 "Address Family modifier\n"
8623 "Address Family modifier\n"
8624 "Address Family modifier\n"
8625 "Address Family modifier\n"
8626 "Display routes conforming to the filter-list\n"
8627 "Regular expression access list name\n")
8628{
8629 safi_t safi;
8630
8631 if (bgp_parse_safi(argv[0], &safi)) {
8632 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8633 return CMD_WARNING;
8634 }
8635 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8636 bgp_show_type_filter_list);
paul718e3742002-12-13 20:15:29 +00008637}
8638
Lou Bergerf9b6c392016-01-12 13:42:09 -05008639DEFUN (show_bgp_ipv6_filter_list,
paul718e3742002-12-13 20:15:29 +00008640 show_bgp_ipv6_filter_list_cmd,
8641 "show bgp ipv6 filter-list WORD",
8642 SHOW_STR
8643 BGP_STR
8644 "Address family\n"
8645 "Display routes conforming to the filter-list\n"
8646 "Regular expression access list name\n")
paul718e3742002-12-13 20:15:29 +00008647{
8648 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8649 bgp_show_type_filter_list);
8650}
8651
paul94f2b392005-06-28 12:44:16 +00008652static int
paulfd79ac92004-10-13 05:06:08 +00008653bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008654 safi_t safi, enum bgp_show_type type)
8655{
8656 struct route_map *rmap;
8657
8658 rmap = route_map_lookup_by_name (rmap_str);
8659 if (! rmap)
8660 {
8661 vty_out (vty, "%% %s is not a valid route-map name%s",
8662 rmap_str, VTY_NEWLINE);
8663 return CMD_WARNING;
8664 }
8665
ajs5a646652004-11-05 01:25:55 +00008666 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00008667}
8668
Lou Bergerf9b6c392016-01-12 13:42:09 -05008669DEFUN (show_ip_bgp_route_map,
8670 show_ip_bgp_route_map_cmd,
8671 "show ip bgp route-map WORD",
8672 SHOW_STR
8673 IP_STR
8674 BGP_STR
8675 "Display routes matching the route-map\n"
8676 "A route-map to match on\n")
8677{
8678 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8679 bgp_show_type_route_map);
8680}
8681
8682DEFUN (show_ip_bgp_flap_route_map,
8683 show_ip_bgp_flap_route_map_cmd,
8684 "show ip bgp flap-statistics route-map WORD",
8685 SHOW_STR
8686 IP_STR
8687 BGP_STR
8688 "Display flap statistics of routes\n"
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_flap_route_map);
8694}
8695
8696ALIAS (show_ip_bgp_flap_route_map,
8697 show_ip_bgp_damp_flap_route_map_cmd,
8698 "show ip bgp dampening flap-statistics route-map WORD",
8699 SHOW_STR
8700 IP_STR
8701 BGP_STR
8702 "Display detailed information about dampening\n"
8703 "Display flap statistics of routes\n"
8704 "Display routes matching the route-map\n"
8705 "A route-map to match on\n")
8706
8707DEFUN (show_ip_bgp_ipv4_route_map,
8708 show_ip_bgp_ipv4_route_map_cmd,
8709 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
8710 SHOW_STR
8711 IP_STR
8712 BGP_STR
8713 "Address family\n"
8714 "Address Family modifier\n"
8715 "Address Family modifier\n"
8716 "Display routes matching the route-map\n"
8717 "A route-map to match on\n")
8718{
8719 if (strncmp (argv[0], "m", 1) == 0)
8720 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8721 bgp_show_type_route_map);
8722
8723 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
8724 bgp_show_type_route_map);
8725}
8726
8727DEFUN (show_bgp_route_map,
8728 show_bgp_route_map_cmd,
8729 "show bgp route-map WORD",
8730 SHOW_STR
8731 BGP_STR
8732 "Display routes matching the route-map\n"
8733 "A route-map to match on\n")
8734{
8735 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8736 bgp_show_type_route_map);
8737}
8738
8739DEFUN (show_ip_bgp_cidr_only,
8740 show_ip_bgp_cidr_only_cmd,
8741 "show ip bgp cidr-only",
8742 SHOW_STR
8743 IP_STR
8744 BGP_STR
8745 "Display only routes with non-natural netmasks\n")
8746{
8747 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8748 bgp_show_type_cidr_only, NULL);
8749}
8750
8751DEFUN (show_ip_bgp_flap_cidr_only,
8752 show_ip_bgp_flap_cidr_only_cmd,
8753 "show ip bgp flap-statistics cidr-only",
8754 SHOW_STR
8755 IP_STR
8756 BGP_STR
8757 "Display flap statistics of routes\n"
8758 "Display only routes with non-natural netmasks\n")
8759{
8760 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8761 bgp_show_type_flap_cidr_only, NULL);
8762}
8763
8764ALIAS (show_ip_bgp_flap_cidr_only,
8765 show_ip_bgp_damp_flap_cidr_only_cmd,
8766 "show ip bgp dampening flap-statistics cidr-only",
8767 SHOW_STR
8768 IP_STR
8769 BGP_STR
8770 "Display detailed information about dampening\n"
8771 "Display flap statistics of routes\n"
8772 "Display only routes with non-natural netmasks\n")
8773
8774DEFUN (show_ip_bgp_ipv4_cidr_only,
8775 show_ip_bgp_ipv4_cidr_only_cmd,
8776 "show ip bgp ipv4 (unicast|multicast) cidr-only",
8777 SHOW_STR
8778 IP_STR
8779 BGP_STR
8780 "Address family\n"
8781 "Address Family modifier\n"
8782 "Address Family modifier\n"
8783 "Display only routes with non-natural netmasks\n")
8784{
8785 if (strncmp (argv[0], "m", 1) == 0)
8786 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8787 bgp_show_type_cidr_only, NULL);
8788
8789 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8790 bgp_show_type_cidr_only, NULL);
8791}
8792
8793DEFUN (show_ip_bgp_community_all,
8794 show_ip_bgp_community_all_cmd,
8795 "show ip bgp community",
8796 SHOW_STR
8797 IP_STR
8798 BGP_STR
8799 "Display routes matching the communities\n")
8800{
8801 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8802 bgp_show_type_community_all, NULL);
8803}
8804
8805DEFUN (show_ip_bgp_ipv4_community_all,
8806 show_ip_bgp_ipv4_community_all_cmd,
8807 "show ip bgp ipv4 (unicast|multicast) community",
8808 SHOW_STR
8809 IP_STR
8810 BGP_STR
8811 "Address family\n"
8812 "Address Family modifier\n"
8813 "Address Family modifier\n"
8814 "Display routes matching the communities\n")
8815{
8816 if (strncmp (argv[0], "m", 1) == 0)
8817 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8818 bgp_show_type_community_all, NULL);
8819
8820 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8821 bgp_show_type_community_all, NULL);
8822}
8823
Lou Bergerf9b6c392016-01-12 13:42:09 -05008824DEFUN (show_bgp_community_all,
8825 show_bgp_community_all_cmd,
8826 "show bgp community",
8827 SHOW_STR
8828 BGP_STR
8829 "Display routes matching the communities\n")
8830{
8831 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8832 bgp_show_type_community_all, NULL);
8833}
8834
8835ALIAS (show_bgp_community_all,
8836 show_bgp_ipv6_community_all_cmd,
8837 "show bgp ipv6 community",
8838 SHOW_STR
8839 BGP_STR
8840 "Address family\n"
8841 "Display routes matching the communities\n")
8842
8843/* old command */
8844DEFUN (show_ipv6_bgp_community_all,
8845 show_ipv6_bgp_community_all_cmd,
8846 "show ipv6 bgp community",
8847 SHOW_STR
8848 IPV6_STR
8849 BGP_STR
8850 "Display routes matching the communities\n")
8851{
8852 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8853 bgp_show_type_community_all, NULL);
8854}
8855
8856/* old command */
8857DEFUN (show_ipv6_mbgp_community_all,
8858 show_ipv6_mbgp_community_all_cmd,
8859 "show ipv6 mbgp community",
8860 SHOW_STR
8861 IPV6_STR
8862 MBGP_STR
8863 "Display routes matching the communities\n")
8864{
8865 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
8866 bgp_show_type_community_all, NULL);
8867}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008868
Lou Berger651b4022016-01-12 13:42:07 -05008869DEFUN (show_bgp_ipv4_route_map,
8870 show_bgp_ipv4_route_map_cmd,
8871 "show bgp ipv4 route-map WORD",
paul718e3742002-12-13 20:15:29 +00008872 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008873 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008874 IP_STR
paul718e3742002-12-13 20:15:29 +00008875 "Display routes matching the route-map\n"
8876 "A route-map to match on\n")
8877{
8878 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8879 bgp_show_type_route_map);
8880}
8881
Lou Berger651b4022016-01-12 13:42:07 -05008882DEFUN (show_bgp_ipv4_safi_flap_route_map,
8883 show_bgp_ipv4_safi_flap_route_map_cmd,
8884 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008885 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008886 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008887 IP_STR
8888 "Address Family Modifier\n"
8889 "Address Family Modifier\n"
8890 "Address Family Modifier\n"
8891 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008892 "Display flap statistics of routes\n"
8893 "Display routes matching the route-map\n"
8894 "A route-map to match on\n")
8895{
Lou Berger651b4022016-01-12 13:42:07 -05008896 safi_t safi;
8897 if (bgp_parse_safi(argv[0], &safi)) {
8898 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8899 return CMD_WARNING;
8900 }
8901 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008902 bgp_show_type_flap_route_map);
8903}
8904
Lou Berger651b4022016-01-12 13:42:07 -05008905ALIAS (show_bgp_ipv4_safi_flap_route_map,
8906 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
8907 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
Balaji3921cc52015-05-16 23:12:17 +05308908 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308909 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008910 IP_STR
8911 "Address Family Modifier\n"
8912 "Address Family Modifier\n"
8913 "Address Family Modifier\n"
8914 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308915 "Display detailed information about dampening\n"
8916 "Display flap statistics of routes\n"
8917 "Display routes matching the route-map\n"
8918 "A route-map to match on\n")
Lou Berger205e6742016-01-12 13:42:11 -05008919
Lou Berger651b4022016-01-12 13:42:07 -05008920DEFUN (show_bgp_ipv6_safi_flap_route_map,
8921 show_bgp_ipv6_safi_flap_route_map_cmd,
8922 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008923 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008924 BGP_STR
8925 IPV6_STR
8926 "Address Family Modifier\n"
8927 "Address Family Modifier\n"
8928 "Address Family Modifier\n"
8929 "Address Family Modifier\n"
8930 "Display flap statistics of routes\n"
8931 "Display routes matching the route-map\n"
8932 "A route-map to match on\n")
8933{
8934 safi_t safi;
8935 if (bgp_parse_safi(argv[0], &safi)) {
8936 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8937 return CMD_WARNING;
8938 }
8939 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
8940 bgp_show_type_flap_route_map);
8941}
8942ALIAS (show_bgp_ipv6_safi_flap_route_map,
8943 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
8944 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
8945 SHOW_STR
8946 BGP_STR
8947 IPV6_STR
8948 "Address Family Modifier\n"
8949 "Address Family Modifier\n"
8950 "Address Family Modifier\n"
8951 "Address Family Modifier\n"
8952 "Display detailed information about dampening\n"
8953 "Display flap statistics of routes\n"
8954 "Display routes matching the route-map\n"
8955 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05008956
8957DEFUN (show_bgp_ipv4_safi_route_map,
8958 show_bgp_ipv4_safi_route_map_cmd,
8959 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
8960 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008961 BGP_STR
8962 "Address family\n"
8963 "Address Family modifier\n"
8964 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008965 "Address Family modifier\n"
8966 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008967 "Display routes matching the route-map\n"
8968 "A route-map to match on\n")
8969{
Lou Berger651b4022016-01-12 13:42:07 -05008970 safi_t safi;
8971 if (bgp_parse_safi(argv[0], &safi)) {
8972 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8973 return CMD_WARNING;
8974 }
8975 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008976 bgp_show_type_route_map);
8977}
Lou Berger205e6742016-01-12 13:42:11 -05008978
Lou Berger651b4022016-01-12 13:42:07 -05008979DEFUN (show_bgp_ipv6_safi_route_map,
8980 show_bgp_ipv6_safi_route_map_cmd,
8981 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
paul718e3742002-12-13 20:15:29 +00008982 SHOW_STR
8983 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008984 "Address family\n"
8985 "Address Family modifier\n"
8986 "Address Family modifier\n"
8987 "Address Family modifier\n"
8988 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008989 "Display routes matching the route-map\n"
8990 "A route-map to match on\n")
8991{
Lou Berger651b4022016-01-12 13:42:07 -05008992 safi_t safi;
8993 if (bgp_parse_safi(argv[0], &safi)) {
8994 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8995 return CMD_WARNING;
8996 }
8997 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008998 bgp_show_type_route_map);
8999}
9000
Lou Berger651b4022016-01-12 13:42:07 -05009001DEFUN (show_bgp_ipv6_route_map,
paul718e3742002-12-13 20:15:29 +00009002 show_bgp_ipv6_route_map_cmd,
9003 "show bgp ipv6 route-map WORD",
9004 SHOW_STR
9005 BGP_STR
9006 "Address family\n"
9007 "Display routes matching the route-map\n"
9008 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05009009{
9010 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9011 bgp_show_type_route_map);
9012}
David Lamparter6b0655a2014-06-04 06:53:35 +02009013
Lou Berger651b4022016-01-12 13:42:07 -05009014DEFUN (show_bgp_ipv4_cidr_only,
9015 show_bgp_ipv4_cidr_only_cmd,
9016 "show bgp ipv4 cidr-only",
paul718e3742002-12-13 20:15:29 +00009017 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009018 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009019 IP_STR
paul718e3742002-12-13 20:15:29 +00009020 "Display only routes with non-natural netmasks\n")
9021{
9022 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009023 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009024}
9025
Lou Berger651b4022016-01-12 13:42:07 -05009026DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
9027 show_bgp_ipv4_safi_flap_cidr_only_cmd,
9028 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
paul718e3742002-12-13 20:15:29 +00009029 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009030 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009031 "Address Family\n"
9032 "Address Family Modifier\n"
9033 "Address Family Modifier\n"
9034 "Address Family Modifier\n"
9035 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009036 "Display flap statistics of routes\n"
9037 "Display only routes with non-natural netmasks\n")
9038{
Lou Berger651b4022016-01-12 13:42:07 -05009039 safi_t safi;
9040
9041 if (bgp_parse_safi(argv[0], &safi)) {
9042 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9043 return CMD_WARNING;
9044 }
9045 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009046}
9047
Lou Berger651b4022016-01-12 13:42:07 -05009048ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9049 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9050 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
Balaji3921cc52015-05-16 23:12:17 +05309051 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309052 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009053 "Address Family\n"
9054 "Address Family Modifier\n"
9055 "Address Family Modifier\n"
9056 "Address Family Modifier\n"
9057 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309058 "Display detailed information about dampening\n"
9059 "Display flap statistics of routes\n"
9060 "Display only routes with non-natural netmasks\n")
9061
Lou Berger651b4022016-01-12 13:42:07 -05009062DEFUN (show_bgp_ipv4_safi_cidr_only,
9063 show_bgp_ipv4_safi_cidr_only_cmd,
9064 "show bgp ipv4 (unicast|multicast) cidr-only",
paul718e3742002-12-13 20:15:29 +00009065 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009066 BGP_STR
9067 "Address family\n"
9068 "Address Family modifier\n"
9069 "Address Family modifier\n"
9070 "Display only routes with non-natural netmasks\n")
9071{
9072 if (strncmp (argv[0], "m", 1) == 0)
9073 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00009074 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009075
9076 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009077 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009078}
David Lamparter6b0655a2014-06-04 06:53:35 +02009079
Lou Berger651b4022016-01-12 13:42:07 -05009080/* new046 */
9081DEFUN (show_bgp_afi_safi_community_all,
9082 show_bgp_afi_safi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009083 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
paul718e3742002-12-13 20:15:29 +00009084 SHOW_STR
9085 BGP_STR
9086 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009087 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009088 "Address Family modifier\n"
9089 "Address Family modifier\n"
9090 "Address Family modifier\n"
9091 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009092 "Display routes matching the communities\n")
Lou Berger651b4022016-01-12 13:42:07 -05009093{
9094 safi_t safi;
9095 afi_t afi;
paul718e3742002-12-13 20:15:29 +00009096
Lou Berger651b4022016-01-12 13:42:07 -05009097 if (bgp_parse_afi(argv[0], &afi)) {
9098 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9099 return CMD_WARNING;
9100 }
9101 if (bgp_parse_safi(argv[1], &safi)) {
9102 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9103 return CMD_WARNING;
9104 }
9105
9106 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9107}
9108DEFUN (show_bgp_afi_community_all,
9109 show_bgp_afi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009110 "show bgp (ipv4|ipv6) community",
paul718e3742002-12-13 20:15:29 +00009111 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009112 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009113 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009114 "Address family\n"
paul718e3742002-12-13 20:15:29 +00009115 "Display routes matching the communities\n")
9116{
Lou Berger651b4022016-01-12 13:42:07 -05009117 afi_t afi;
9118 safi_t safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +00009119
Lou Berger651b4022016-01-12 13:42:07 -05009120 if (bgp_parse_afi(argv[0], &afi)) {
9121 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9122 return CMD_WARNING;
9123 }
9124 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00009125}
David Lamparter6b0655a2014-06-04 06:53:35 +02009126
paul94f2b392005-06-28 12:44:16 +00009127static int
Michael Lambert95cbbd22010-07-23 14:43:04 -04009128bgp_show_community (struct vty *vty, const char *view_name, int argc,
9129 const char **argv, int exact, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00009130{
9131 struct community *com;
9132 struct buffer *b;
Michael Lambert95cbbd22010-07-23 14:43:04 -04009133 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +00009134 int i;
9135 char *str;
9136 int first = 0;
9137
Michael Lambert95cbbd22010-07-23 14:43:04 -04009138 /* BGP structure lookup */
9139 if (view_name)
9140 {
9141 bgp = bgp_lookup_by_name (view_name);
9142 if (bgp == NULL)
9143 {
9144 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9145 return CMD_WARNING;
9146 }
9147 }
9148 else
9149 {
9150 bgp = bgp_get_default ();
9151 if (bgp == NULL)
9152 {
9153 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9154 return CMD_WARNING;
9155 }
9156 }
9157
paul718e3742002-12-13 20:15:29 +00009158 b = buffer_new (1024);
9159 for (i = 0; i < argc; i++)
9160 {
9161 if (first)
9162 buffer_putc (b, ' ');
9163 else
9164 {
9165 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9166 continue;
9167 first = 1;
9168 }
9169
9170 buffer_putstr (b, argv[i]);
9171 }
9172 buffer_putc (b, '\0');
9173
9174 str = buffer_getstr (b);
9175 buffer_free (b);
9176
9177 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00009178 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009179 if (! com)
9180 {
9181 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9182 return CMD_WARNING;
9183 }
9184
Michael Lambert95cbbd22010-07-23 14:43:04 -04009185 return bgp_show (vty, bgp, afi, safi,
ajs5a646652004-11-05 01:25:55 +00009186 (exact ? bgp_show_type_community_exact :
9187 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00009188}
9189
Lou Bergerf9b6c392016-01-12 13:42:09 -05009190DEFUN (show_ip_bgp_community,
9191 show_ip_bgp_community_cmd,
9192 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9193 SHOW_STR
9194 IP_STR
9195 BGP_STR
9196 "Display routes matching the communities\n"
9197 "community number\n"
9198 "Do not send outside local AS (well-known community)\n"
9199 "Do not advertise to any peer (well-known community)\n"
9200 "Do not export to next AS (well-known community)\n")
9201{
9202 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9203}
9204
9205ALIAS (show_ip_bgp_community,
9206 show_ip_bgp_community2_cmd,
9207 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9208 SHOW_STR
9209 IP_STR
9210 BGP_STR
9211 "Display routes matching the communities\n"
9212 "community number\n"
9213 "Do not send outside local AS (well-known community)\n"
9214 "Do not advertise to any peer (well-known community)\n"
9215 "Do not export to next AS (well-known community)\n"
9216 "community number\n"
9217 "Do not send outside local AS (well-known community)\n"
9218 "Do not advertise to any peer (well-known community)\n"
9219 "Do not export to next AS (well-known community)\n")
9220
9221ALIAS (show_ip_bgp_community,
9222 show_ip_bgp_community3_cmd,
9223 "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)",
9224 SHOW_STR
9225 IP_STR
9226 BGP_STR
9227 "Display routes matching the communities\n"
9228 "community number\n"
9229 "Do not send outside local AS (well-known community)\n"
9230 "Do not advertise to any peer (well-known community)\n"
9231 "Do not export to next AS (well-known community)\n"
9232 "community number\n"
9233 "Do not send outside local AS (well-known community)\n"
9234 "Do not advertise to any peer (well-known community)\n"
9235 "Do not export to next AS (well-known community)\n"
9236 "community number\n"
9237 "Do not send outside local AS (well-known community)\n"
9238 "Do not advertise to any peer (well-known community)\n"
9239 "Do not export to next AS (well-known community)\n")
9240
9241ALIAS (show_ip_bgp_community,
9242 show_ip_bgp_community4_cmd,
9243 "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)",
9244 SHOW_STR
9245 IP_STR
9246 BGP_STR
9247 "Display routes matching the communities\n"
9248 "community number\n"
9249 "Do not send outside local AS (well-known community)\n"
9250 "Do not advertise to any peer (well-known community)\n"
9251 "Do not export to next AS (well-known community)\n"
9252 "community number\n"
9253 "Do not send outside local AS (well-known community)\n"
9254 "Do not advertise to any peer (well-known community)\n"
9255 "Do not export to next AS (well-known community)\n"
9256 "community number\n"
9257 "Do not send outside local AS (well-known community)\n"
9258 "Do not advertise to any peer (well-known community)\n"
9259 "Do not export to next AS (well-known community)\n"
9260 "community number\n"
9261 "Do not send outside local AS (well-known community)\n"
9262 "Do not advertise to any peer (well-known community)\n"
9263 "Do not export to next AS (well-known community)\n")
9264
9265DEFUN (show_ip_bgp_ipv4_community,
9266 show_ip_bgp_ipv4_community_cmd,
9267 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9268 SHOW_STR
9269 IP_STR
9270 BGP_STR
9271 "Address family\n"
9272 "Address Family modifier\n"
9273 "Address Family modifier\n"
9274 "Display routes matching the communities\n"
9275 "community number\n"
9276 "Do not send outside local AS (well-known community)\n"
9277 "Do not advertise to any peer (well-known community)\n"
9278 "Do not export to next AS (well-known community)\n")
9279{
9280 if (strncmp (argv[0], "m", 1) == 0)
9281 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9282
9283 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9284}
9285
9286ALIAS (show_ip_bgp_ipv4_community,
9287 show_ip_bgp_ipv4_community2_cmd,
9288 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9289 SHOW_STR
9290 IP_STR
9291 BGP_STR
9292 "Address family\n"
9293 "Address Family modifier\n"
9294 "Address Family modifier\n"
9295 "Display routes matching the communities\n"
9296 "community number\n"
9297 "Do not send outside local AS (well-known community)\n"
9298 "Do not advertise to any peer (well-known community)\n"
9299 "Do not export to next AS (well-known community)\n"
9300 "community number\n"
9301 "Do not send outside local AS (well-known community)\n"
9302 "Do not advertise to any peer (well-known community)\n"
9303 "Do not export to next AS (well-known community)\n")
9304
9305ALIAS (show_ip_bgp_ipv4_community,
9306 show_ip_bgp_ipv4_community3_cmd,
9307 "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)",
9308 SHOW_STR
9309 IP_STR
9310 BGP_STR
9311 "Address family\n"
9312 "Address Family modifier\n"
9313 "Address Family modifier\n"
9314 "Display routes matching the communities\n"
9315 "community number\n"
9316 "Do not send outside local AS (well-known community)\n"
9317 "Do not advertise to any peer (well-known community)\n"
9318 "Do not export to next AS (well-known community)\n"
9319 "community number\n"
9320 "Do not send outside local AS (well-known community)\n"
9321 "Do not advertise to any peer (well-known community)\n"
9322 "Do not export to next AS (well-known community)\n"
9323 "community number\n"
9324 "Do not send outside local AS (well-known community)\n"
9325 "Do not advertise to any peer (well-known community)\n"
9326 "Do not export to next AS (well-known community)\n")
9327
9328ALIAS (show_ip_bgp_ipv4_community,
9329 show_ip_bgp_ipv4_community4_cmd,
9330 "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)",
9331 SHOW_STR
9332 IP_STR
9333 BGP_STR
9334 "Address family\n"
9335 "Address Family modifier\n"
9336 "Address Family modifier\n"
9337 "Display routes matching the communities\n"
9338 "community number\n"
9339 "Do not send outside local AS (well-known community)\n"
9340 "Do not advertise to any peer (well-known community)\n"
9341 "Do not export to next AS (well-known community)\n"
9342 "community number\n"
9343 "Do not send outside local AS (well-known community)\n"
9344 "Do not advertise to any peer (well-known community)\n"
9345 "Do not export to next AS (well-known community)\n"
9346 "community number\n"
9347 "Do not send outside local AS (well-known community)\n"
9348 "Do not advertise to any peer (well-known community)\n"
9349 "Do not export to next AS (well-known community)\n"
9350 "community number\n"
9351 "Do not send outside local AS (well-known community)\n"
9352 "Do not advertise to any peer (well-known community)\n"
9353 "Do not export to next AS (well-known community)\n")
9354
9355DEFUN (show_ip_bgp_community_exact,
9356 show_ip_bgp_community_exact_cmd,
9357 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9358 SHOW_STR
9359 IP_STR
9360 BGP_STR
9361 "Display routes matching the communities\n"
9362 "community number\n"
9363 "Do not send outside local AS (well-known community)\n"
9364 "Do not advertise to any peer (well-known community)\n"
9365 "Do not export to next AS (well-known community)\n"
9366 "Exact match of the communities")
9367{
9368 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9369}
9370
9371ALIAS (show_ip_bgp_community_exact,
9372 show_ip_bgp_community2_exact_cmd,
9373 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9374 SHOW_STR
9375 IP_STR
9376 BGP_STR
9377 "Display routes matching the communities\n"
9378 "community number\n"
9379 "Do not send outside local AS (well-known community)\n"
9380 "Do not advertise to any peer (well-known community)\n"
9381 "Do not export to next AS (well-known community)\n"
9382 "community number\n"
9383 "Do not send outside local AS (well-known community)\n"
9384 "Do not advertise to any peer (well-known community)\n"
9385 "Do not export to next AS (well-known community)\n"
9386 "Exact match of the communities")
9387
9388ALIAS (show_ip_bgp_community_exact,
9389 show_ip_bgp_community3_exact_cmd,
9390 "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",
9391 SHOW_STR
9392 IP_STR
9393 BGP_STR
9394 "Display routes matching the communities\n"
9395 "community number\n"
9396 "Do not send outside local AS (well-known community)\n"
9397 "Do not advertise to any peer (well-known community)\n"
9398 "Do not export to next AS (well-known community)\n"
9399 "community number\n"
9400 "Do not send outside local AS (well-known community)\n"
9401 "Do not advertise to any peer (well-known community)\n"
9402 "Do not export to next AS (well-known community)\n"
9403 "community number\n"
9404 "Do not send outside local AS (well-known community)\n"
9405 "Do not advertise to any peer (well-known community)\n"
9406 "Do not export to next AS (well-known community)\n"
9407 "Exact match of the communities")
9408
9409ALIAS (show_ip_bgp_community_exact,
9410 show_ip_bgp_community4_exact_cmd,
9411 "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",
9412 SHOW_STR
9413 IP_STR
9414 BGP_STR
9415 "Display routes matching the communities\n"
9416 "community number\n"
9417 "Do not send outside local AS (well-known community)\n"
9418 "Do not advertise to any peer (well-known community)\n"
9419 "Do not export to next AS (well-known community)\n"
9420 "community number\n"
9421 "Do not send outside local AS (well-known community)\n"
9422 "Do not advertise to any peer (well-known community)\n"
9423 "Do not export to next AS (well-known community)\n"
9424 "community number\n"
9425 "Do not send outside local AS (well-known community)\n"
9426 "Do not advertise to any peer (well-known community)\n"
9427 "Do not export to next AS (well-known community)\n"
9428 "community number\n"
9429 "Do not send outside local AS (well-known community)\n"
9430 "Do not advertise to any peer (well-known community)\n"
9431 "Do not export to next AS (well-known community)\n"
9432 "Exact match of the communities")
9433
9434DEFUN (show_ip_bgp_ipv4_community_exact,
9435 show_ip_bgp_ipv4_community_exact_cmd,
9436 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9437 SHOW_STR
9438 IP_STR
9439 BGP_STR
9440 "Address family\n"
9441 "Address Family modifier\n"
9442 "Address Family modifier\n"
9443 "Display routes matching the communities\n"
9444 "community number\n"
9445 "Do not send outside local AS (well-known community)\n"
9446 "Do not advertise to any peer (well-known community)\n"
9447 "Do not export to next AS (well-known community)\n"
9448 "Exact match of the communities")
9449{
9450 if (strncmp (argv[0], "m", 1) == 0)
9451 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9452
9453 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9454}
9455
9456ALIAS (show_ip_bgp_ipv4_community_exact,
9457 show_ip_bgp_ipv4_community2_exact_cmd,
9458 "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",
9459 SHOW_STR
9460 IP_STR
9461 BGP_STR
9462 "Address family\n"
9463 "Address Family modifier\n"
9464 "Address Family modifier\n"
9465 "Display routes matching the communities\n"
9466 "community number\n"
9467 "Do not send outside local AS (well-known community)\n"
9468 "Do not advertise to any peer (well-known community)\n"
9469 "Do not export to next AS (well-known community)\n"
9470 "community number\n"
9471 "Do not send outside local AS (well-known community)\n"
9472 "Do not advertise to any peer (well-known community)\n"
9473 "Do not export to next AS (well-known community)\n"
9474 "Exact match of the communities")
9475
9476ALIAS (show_ip_bgp_ipv4_community_exact,
9477 show_ip_bgp_ipv4_community3_exact_cmd,
9478 "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",
9479 SHOW_STR
9480 IP_STR
9481 BGP_STR
9482 "Address family\n"
9483 "Address Family modifier\n"
9484 "Address Family modifier\n"
9485 "Display routes matching the communities\n"
9486 "community number\n"
9487 "Do not send outside local AS (well-known community)\n"
9488 "Do not advertise to any peer (well-known community)\n"
9489 "Do not export to next AS (well-known community)\n"
9490 "community number\n"
9491 "Do not send outside local AS (well-known community)\n"
9492 "Do not advertise to any peer (well-known community)\n"
9493 "Do not export to next AS (well-known community)\n"
9494 "community number\n"
9495 "Do not send outside local AS (well-known community)\n"
9496 "Do not advertise to any peer (well-known community)\n"
9497 "Do not export to next AS (well-known community)\n"
9498 "Exact match of the communities")
9499
9500ALIAS (show_ip_bgp_ipv4_community_exact,
9501 show_ip_bgp_ipv4_community4_exact_cmd,
9502 "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",
9503 SHOW_STR
9504 IP_STR
9505 BGP_STR
9506 "Address family\n"
9507 "Address Family modifier\n"
9508 "Address Family modifier\n"
9509 "Display routes matching the communities\n"
9510 "community number\n"
9511 "Do not send outside local AS (well-known community)\n"
9512 "Do not advertise to any peer (well-known community)\n"
9513 "Do not export to next AS (well-known community)\n"
9514 "community number\n"
9515 "Do not send outside local AS (well-known community)\n"
9516 "Do not advertise to any peer (well-known community)\n"
9517 "Do not export to next AS (well-known community)\n"
9518 "community number\n"
9519 "Do not send outside local AS (well-known community)\n"
9520 "Do not advertise to any peer (well-known community)\n"
9521 "Do not export to next AS (well-known community)\n"
9522 "community number\n"
9523 "Do not send outside local AS (well-known community)\n"
9524 "Do not advertise to any peer (well-known community)\n"
9525 "Do not export to next AS (well-known community)\n"
9526 "Exact match of the communities")
9527
Lou Bergerf9b6c392016-01-12 13:42:09 -05009528DEFUN (show_bgp_community,
9529 show_bgp_community_cmd,
9530 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9531 SHOW_STR
9532 BGP_STR
9533 "Display routes matching the communities\n"
9534 "community number\n"
9535 "Do not send outside local AS (well-known community)\n"
9536 "Do not advertise to any peer (well-known community)\n"
9537 "Do not export to next AS (well-known community)\n")
9538{
9539 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9540}
9541
9542ALIAS (show_bgp_community,
9543 show_bgp_ipv6_community_cmd,
9544 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9545 SHOW_STR
9546 BGP_STR
9547 "Address family\n"
9548 "Display routes matching the communities\n"
9549 "community number\n"
9550 "Do not send outside local AS (well-known community)\n"
9551 "Do not advertise to any peer (well-known community)\n"
9552 "Do not export to next AS (well-known community)\n")
9553
9554ALIAS (show_bgp_community,
9555 show_bgp_community2_cmd,
9556 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9557 SHOW_STR
9558 BGP_STR
9559 "Display routes matching the communities\n"
9560 "community number\n"
9561 "Do not send outside local AS (well-known community)\n"
9562 "Do not advertise to any peer (well-known community)\n"
9563 "Do not export to next AS (well-known community)\n"
9564 "community number\n"
9565 "Do not send outside local AS (well-known community)\n"
9566 "Do not advertise to any peer (well-known community)\n"
9567 "Do not export to next AS (well-known community)\n")
9568
9569ALIAS (show_bgp_community,
9570 show_bgp_ipv6_community2_cmd,
9571 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9572 SHOW_STR
9573 BGP_STR
9574 "Address family\n"
9575 "Display routes matching the communities\n"
9576 "community number\n"
9577 "Do not send outside local AS (well-known community)\n"
9578 "Do not advertise to any peer (well-known community)\n"
9579 "Do not export to next AS (well-known community)\n"
9580 "community number\n"
9581 "Do not send outside local AS (well-known community)\n"
9582 "Do not advertise to any peer (well-known community)\n"
9583 "Do not export to next AS (well-known community)\n")
9584
9585ALIAS (show_bgp_community,
9586 show_bgp_community3_cmd,
9587 "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)",
9588 SHOW_STR
9589 BGP_STR
9590 "Display routes matching the communities\n"
9591 "community number\n"
9592 "Do not send outside local AS (well-known community)\n"
9593 "Do not advertise to any peer (well-known community)\n"
9594 "Do not export to next AS (well-known community)\n"
9595 "community number\n"
9596 "Do not send outside local AS (well-known community)\n"
9597 "Do not advertise to any peer (well-known community)\n"
9598 "Do not export to next AS (well-known community)\n"
9599 "community number\n"
9600 "Do not send outside local AS (well-known community)\n"
9601 "Do not advertise to any peer (well-known community)\n"
9602 "Do not export to next AS (well-known community)\n")
9603
9604ALIAS (show_bgp_community,
9605 show_bgp_ipv6_community3_cmd,
9606 "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)",
9607 SHOW_STR
9608 BGP_STR
9609 "Address family\n"
9610 "Display routes matching the communities\n"
9611 "community number\n"
9612 "Do not send outside local AS (well-known community)\n"
9613 "Do not advertise to any peer (well-known community)\n"
9614 "Do not export to next AS (well-known community)\n"
9615 "community number\n"
9616 "Do not send outside local AS (well-known community)\n"
9617 "Do not advertise to any peer (well-known community)\n"
9618 "Do not export to next AS (well-known community)\n"
9619 "community number\n"
9620 "Do not send outside local AS (well-known community)\n"
9621 "Do not advertise to any peer (well-known community)\n"
9622 "Do not export to next AS (well-known community)\n")
9623
9624ALIAS (show_bgp_community,
9625 show_bgp_community4_cmd,
9626 "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)",
9627 SHOW_STR
9628 BGP_STR
9629 "Display routes matching the communities\n"
9630 "community number\n"
9631 "Do not send outside local AS (well-known community)\n"
9632 "Do not advertise to any peer (well-known community)\n"
9633 "Do not export to next AS (well-known community)\n"
9634 "community number\n"
9635 "Do not send outside local AS (well-known community)\n"
9636 "Do not advertise to any peer (well-known community)\n"
9637 "Do not export to next AS (well-known community)\n"
9638 "community number\n"
9639 "Do not send outside local AS (well-known community)\n"
9640 "Do not advertise to any peer (well-known community)\n"
9641 "Do not export to next AS (well-known community)\n"
9642 "community number\n"
9643 "Do not send outside local AS (well-known community)\n"
9644 "Do not advertise to any peer (well-known community)\n"
9645 "Do not export to next AS (well-known community)\n")
9646
9647ALIAS (show_bgp_community,
9648 show_bgp_ipv6_community4_cmd,
9649 "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)",
9650 SHOW_STR
9651 BGP_STR
9652 "Address family\n"
9653 "Display routes matching the communities\n"
9654 "community number\n"
9655 "Do not send outside local AS (well-known community)\n"
9656 "Do not advertise to any peer (well-known community)\n"
9657 "Do not export to next AS (well-known community)\n"
9658 "community number\n"
9659 "Do not send outside local AS (well-known community)\n"
9660 "Do not advertise to any peer (well-known community)\n"
9661 "Do not export to next AS (well-known community)\n"
9662 "community number\n"
9663 "Do not send outside local AS (well-known community)\n"
9664 "Do not advertise to any peer (well-known community)\n"
9665 "Do not export to next AS (well-known community)\n"
9666 "community number\n"
9667 "Do not send outside local AS (well-known community)\n"
9668 "Do not advertise to any peer (well-known community)\n"
9669 "Do not export to next AS (well-known community)\n")
9670
9671/* old command */
9672DEFUN (show_ipv6_bgp_community,
9673 show_ipv6_bgp_community_cmd,
9674 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9675 SHOW_STR
9676 IPV6_STR
9677 BGP_STR
9678 "Display routes matching the communities\n"
9679 "community number\n"
9680 "Do not send outside local AS (well-known community)\n"
9681 "Do not advertise to any peer (well-known community)\n"
9682 "Do not export to next AS (well-known community)\n")
9683{
9684 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9685}
9686
9687/* old command */
9688ALIAS (show_ipv6_bgp_community,
9689 show_ipv6_bgp_community2_cmd,
9690 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9691 SHOW_STR
9692 IPV6_STR
9693 BGP_STR
9694 "Display routes matching the communities\n"
9695 "community number\n"
9696 "Do not send outside local AS (well-known community)\n"
9697 "Do not advertise to any peer (well-known community)\n"
9698 "Do not export to next AS (well-known community)\n"
9699 "community number\n"
9700 "Do not send outside local AS (well-known community)\n"
9701 "Do not advertise to any peer (well-known community)\n"
9702 "Do not export to next AS (well-known community)\n")
9703
9704/* old command */
9705ALIAS (show_ipv6_bgp_community,
9706 show_ipv6_bgp_community3_cmd,
9707 "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)",
9708 SHOW_STR
9709 IPV6_STR
9710 BGP_STR
9711 "Display routes matching the communities\n"
9712 "community number\n"
9713 "Do not send outside local AS (well-known community)\n"
9714 "Do not advertise to any peer (well-known community)\n"
9715 "Do not export to next AS (well-known community)\n"
9716 "community number\n"
9717 "Do not send outside local AS (well-known community)\n"
9718 "Do not advertise to any peer (well-known community)\n"
9719 "Do not export to next AS (well-known community)\n"
9720 "community number\n"
9721 "Do not send outside local AS (well-known community)\n"
9722 "Do not advertise to any peer (well-known community)\n"
9723 "Do not export to next AS (well-known community)\n")
9724
9725/* old command */
9726ALIAS (show_ipv6_bgp_community,
9727 show_ipv6_bgp_community4_cmd,
9728 "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)",
9729 SHOW_STR
9730 IPV6_STR
9731 BGP_STR
9732 "Display routes matching the communities\n"
9733 "community number\n"
9734 "Do not send outside local AS (well-known community)\n"
9735 "Do not advertise to any peer (well-known community)\n"
9736 "Do not export to next AS (well-known community)\n"
9737 "community number\n"
9738 "Do not send outside local AS (well-known community)\n"
9739 "Do not advertise to any peer (well-known community)\n"
9740 "Do not export to next AS (well-known community)\n"
9741 "community number\n"
9742 "Do not send outside local AS (well-known community)\n"
9743 "Do not advertise to any peer (well-known community)\n"
9744 "Do not export to next AS (well-known community)\n"
9745 "community number\n"
9746 "Do not send outside local AS (well-known community)\n"
9747 "Do not advertise to any peer (well-known community)\n"
9748 "Do not export to next AS (well-known community)\n")
9749
9750DEFUN (show_bgp_community_exact,
9751 show_bgp_community_exact_cmd,
9752 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9753 SHOW_STR
9754 BGP_STR
9755 "Display routes matching the communities\n"
9756 "community number\n"
9757 "Do not send outside local AS (well-known community)\n"
9758 "Do not advertise to any peer (well-known community)\n"
9759 "Do not export to next AS (well-known community)\n"
9760 "Exact match of the communities")
9761{
9762 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9763}
9764
9765ALIAS (show_bgp_community_exact,
9766 show_bgp_ipv6_community_exact_cmd,
9767 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9768 SHOW_STR
9769 BGP_STR
9770 "Address family\n"
9771 "Display routes matching the communities\n"
9772 "community number\n"
9773 "Do not send outside local AS (well-known community)\n"
9774 "Do not advertise to any peer (well-known community)\n"
9775 "Do not export to next AS (well-known community)\n"
9776 "Exact match of the communities")
9777
9778ALIAS (show_bgp_community_exact,
9779 show_bgp_community2_exact_cmd,
9780 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9781 SHOW_STR
9782 BGP_STR
9783 "Display routes matching the communities\n"
9784 "community number\n"
9785 "Do not send outside local AS (well-known community)\n"
9786 "Do not advertise to any peer (well-known community)\n"
9787 "Do not export to next AS (well-known community)\n"
9788 "community number\n"
9789 "Do not send outside local AS (well-known community)\n"
9790 "Do not advertise to any peer (well-known community)\n"
9791 "Do not export to next AS (well-known community)\n"
9792 "Exact match of the communities")
9793
9794ALIAS (show_bgp_community_exact,
9795 show_bgp_ipv6_community2_exact_cmd,
9796 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9797 SHOW_STR
9798 BGP_STR
9799 "Address family\n"
9800 "Display routes matching the communities\n"
9801 "community number\n"
9802 "Do not send outside local AS (well-known community)\n"
9803 "Do not advertise to any peer (well-known community)\n"
9804 "Do not export to next AS (well-known community)\n"
9805 "community number\n"
9806 "Do not send outside local AS (well-known community)\n"
9807 "Do not advertise to any peer (well-known community)\n"
9808 "Do not export to next AS (well-known community)\n"
9809 "Exact match of the communities")
9810
9811ALIAS (show_bgp_community_exact,
9812 show_bgp_community3_exact_cmd,
9813 "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",
9814 SHOW_STR
9815 BGP_STR
9816 "Display routes matching the communities\n"
9817 "community number\n"
9818 "Do not send outside local AS (well-known community)\n"
9819 "Do not advertise to any peer (well-known community)\n"
9820 "Do not export to next AS (well-known community)\n"
9821 "community number\n"
9822 "Do not send outside local AS (well-known community)\n"
9823 "Do not advertise to any peer (well-known community)\n"
9824 "Do not export to next AS (well-known community)\n"
9825 "community number\n"
9826 "Do not send outside local AS (well-known community)\n"
9827 "Do not advertise to any peer (well-known community)\n"
9828 "Do not export to next AS (well-known community)\n"
9829 "Exact match of the communities")
9830
9831ALIAS (show_bgp_community_exact,
9832 show_bgp_ipv6_community3_exact_cmd,
9833 "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",
9834 SHOW_STR
9835 BGP_STR
9836 "Address family\n"
9837 "Display routes matching the communities\n"
9838 "community number\n"
9839 "Do not send outside local AS (well-known community)\n"
9840 "Do not advertise to any peer (well-known community)\n"
9841 "Do not export to next AS (well-known community)\n"
9842 "community number\n"
9843 "Do not send outside local AS (well-known community)\n"
9844 "Do not advertise to any peer (well-known community)\n"
9845 "Do not export to next AS (well-known community)\n"
9846 "community number\n"
9847 "Do not send outside local AS (well-known community)\n"
9848 "Do not advertise to any peer (well-known community)\n"
9849 "Do not export to next AS (well-known community)\n"
9850 "Exact match of the communities")
9851
9852ALIAS (show_bgp_community_exact,
9853 show_bgp_community4_exact_cmd,
9854 "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",
9855 SHOW_STR
9856 BGP_STR
9857 "Display routes matching the communities\n"
9858 "community number\n"
9859 "Do not send outside local AS (well-known community)\n"
9860 "Do not advertise to any peer (well-known community)\n"
9861 "Do not export to next AS (well-known community)\n"
9862 "community number\n"
9863 "Do not send outside local AS (well-known community)\n"
9864 "Do not advertise to any peer (well-known community)\n"
9865 "Do not export to next AS (well-known community)\n"
9866 "community number\n"
9867 "Do not send outside local AS (well-known community)\n"
9868 "Do not advertise to any peer (well-known community)\n"
9869 "Do not export to next AS (well-known community)\n"
9870 "community number\n"
9871 "Do not send outside local AS (well-known community)\n"
9872 "Do not advertise to any peer (well-known community)\n"
9873 "Do not export to next AS (well-known community)\n"
9874 "Exact match of the communities")
9875
9876ALIAS (show_bgp_community_exact,
9877 show_bgp_ipv6_community4_exact_cmd,
9878 "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",
9879 SHOW_STR
9880 BGP_STR
9881 "Address family\n"
9882 "Display routes matching the communities\n"
9883 "community number\n"
9884 "Do not send outside local AS (well-known community)\n"
9885 "Do not advertise to any peer (well-known community)\n"
9886 "Do not export to next AS (well-known community)\n"
9887 "community number\n"
9888 "Do not send outside local AS (well-known community)\n"
9889 "Do not advertise to any peer (well-known community)\n"
9890 "Do not export to next AS (well-known community)\n"
9891 "community number\n"
9892 "Do not send outside local AS (well-known community)\n"
9893 "Do not advertise to any peer (well-known community)\n"
9894 "Do not export to next AS (well-known community)\n"
9895 "community number\n"
9896 "Do not send outside local AS (well-known community)\n"
9897 "Do not advertise to any peer (well-known community)\n"
9898 "Do not export to next AS (well-known community)\n"
9899 "Exact match of the communities")
9900
9901/* old command */
9902DEFUN (show_ipv6_bgp_community_exact,
9903 show_ipv6_bgp_community_exact_cmd,
9904 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9905 SHOW_STR
9906 IPV6_STR
9907 BGP_STR
9908 "Display routes matching the communities\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 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9916}
9917
9918/* old command */
9919ALIAS (show_ipv6_bgp_community_exact,
9920 show_ipv6_bgp_community2_exact_cmd,
9921 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9922 SHOW_STR
9923 IPV6_STR
9924 BGP_STR
9925 "Display routes matching the communities\n"
9926 "community number\n"
9927 "Do not send outside local AS (well-known community)\n"
9928 "Do not advertise to any peer (well-known community)\n"
9929 "Do not export to next AS (well-known community)\n"
9930 "community number\n"
9931 "Do not send outside local AS (well-known community)\n"
9932 "Do not advertise to any peer (well-known community)\n"
9933 "Do not export to next AS (well-known community)\n"
9934 "Exact match of the communities")
9935
9936/* old command */
9937ALIAS (show_ipv6_bgp_community_exact,
9938 show_ipv6_bgp_community3_exact_cmd,
9939 "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",
9940 SHOW_STR
9941 IPV6_STR
9942 BGP_STR
9943 "Display routes matching the communities\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 "community number\n"
9949 "Do not send outside local AS (well-known community)\n"
9950 "Do not advertise to any peer (well-known community)\n"
9951 "Do not export to next AS (well-known community)\n"
9952 "community number\n"
9953 "Do not send outside local AS (well-known community)\n"
9954 "Do not advertise to any peer (well-known community)\n"
9955 "Do not export to next AS (well-known community)\n"
9956 "Exact match of the communities")
9957
9958/* old command */
9959ALIAS (show_ipv6_bgp_community_exact,
9960 show_ipv6_bgp_community4_exact_cmd,
9961 "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",
9962 SHOW_STR
9963 IPV6_STR
9964 BGP_STR
9965 "Display routes matching the communities\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 "community number\n"
9971 "Do not send outside local AS (well-known community)\n"
9972 "Do not advertise to any peer (well-known community)\n"
9973 "Do not export to next AS (well-known community)\n"
9974 "community number\n"
9975 "Do not send outside local AS (well-known community)\n"
9976 "Do not advertise to any peer (well-known community)\n"
9977 "Do not export to next AS (well-known community)\n"
9978 "community number\n"
9979 "Do not send outside local AS (well-known community)\n"
9980 "Do not advertise to any peer (well-known community)\n"
9981 "Do not export to next AS (well-known community)\n"
9982 "Exact match of the communities")
9983
9984/* old command */
9985DEFUN (show_ipv6_mbgp_community,
9986 show_ipv6_mbgp_community_cmd,
9987 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
9988 SHOW_STR
9989 IPV6_STR
9990 MBGP_STR
9991 "Display routes matching the communities\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{
9997 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
9998}
9999
10000/* old command */
10001ALIAS (show_ipv6_mbgp_community,
10002 show_ipv6_mbgp_community2_cmd,
10003 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10004 SHOW_STR
10005 IPV6_STR
10006 MBGP_STR
10007 "Display routes matching the communities\n"
10008 "community number\n"
10009 "Do not send outside local AS (well-known community)\n"
10010 "Do not advertise to any peer (well-known community)\n"
10011 "Do not export to next AS (well-known community)\n"
10012 "community number\n"
10013 "Do not send outside local AS (well-known community)\n"
10014 "Do not advertise to any peer (well-known community)\n"
10015 "Do not export to next AS (well-known community)\n")
10016
10017/* old command */
10018ALIAS (show_ipv6_mbgp_community,
10019 show_ipv6_mbgp_community3_cmd,
10020 "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)",
10021 SHOW_STR
10022 IPV6_STR
10023 MBGP_STR
10024 "Display routes matching the communities\n"
10025 "community number\n"
10026 "Do not send outside local AS (well-known community)\n"
10027 "Do not advertise to any peer (well-known community)\n"
10028 "Do not export to next AS (well-known community)\n"
10029 "community number\n"
10030 "Do not send outside local AS (well-known community)\n"
10031 "Do not advertise to any peer (well-known community)\n"
10032 "Do not export to next AS (well-known community)\n"
10033 "community number\n"
10034 "Do not send outside local AS (well-known community)\n"
10035 "Do not advertise to any peer (well-known community)\n"
10036 "Do not export to next AS (well-known community)\n")
10037
10038/* old command */
10039ALIAS (show_ipv6_mbgp_community,
10040 show_ipv6_mbgp_community4_cmd,
10041 "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)",
10042 SHOW_STR
10043 IPV6_STR
10044 MBGP_STR
10045 "Display routes matching the communities\n"
10046 "community number\n"
10047 "Do not send outside local AS (well-known community)\n"
10048 "Do not advertise to any peer (well-known community)\n"
10049 "Do not export to next AS (well-known community)\n"
10050 "community number\n"
10051 "Do not send outside local AS (well-known community)\n"
10052 "Do not advertise to any peer (well-known community)\n"
10053 "Do not export to next AS (well-known community)\n"
10054 "community number\n"
10055 "Do not send outside local AS (well-known community)\n"
10056 "Do not advertise to any peer (well-known community)\n"
10057 "Do not export to next AS (well-known community)\n"
10058 "community number\n"
10059 "Do not send outside local AS (well-known community)\n"
10060 "Do not advertise to any peer (well-known community)\n"
10061 "Do not export to next AS (well-known community)\n")
10062
10063/* old command */
10064DEFUN (show_ipv6_mbgp_community_exact,
10065 show_ipv6_mbgp_community_exact_cmd,
10066 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10067 SHOW_STR
10068 IPV6_STR
10069 MBGP_STR
10070 "Display routes matching the communities\n"
10071 "community number\n"
10072 "Do not send outside local AS (well-known community)\n"
10073 "Do not advertise to any peer (well-known community)\n"
10074 "Do not export to next AS (well-known community)\n"
10075 "Exact match of the communities")
10076{
10077 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10078}
10079
10080/* old command */
10081ALIAS (show_ipv6_mbgp_community_exact,
10082 show_ipv6_mbgp_community2_exact_cmd,
10083 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10084 SHOW_STR
10085 IPV6_STR
10086 MBGP_STR
10087 "Display routes matching the communities\n"
10088 "community number\n"
10089 "Do not send outside local AS (well-known community)\n"
10090 "Do not advertise to any peer (well-known community)\n"
10091 "Do not export to next AS (well-known community)\n"
10092 "community number\n"
10093 "Do not send outside local AS (well-known community)\n"
10094 "Do not advertise to any peer (well-known community)\n"
10095 "Do not export to next AS (well-known community)\n"
10096 "Exact match of the communities")
10097
10098/* old command */
10099ALIAS (show_ipv6_mbgp_community_exact,
10100 show_ipv6_mbgp_community3_exact_cmd,
10101 "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",
10102 SHOW_STR
10103 IPV6_STR
10104 MBGP_STR
10105 "Display routes matching the communities\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 "community number\n"
10111 "Do not send outside local AS (well-known community)\n"
10112 "Do not advertise to any peer (well-known community)\n"
10113 "Do not export to next AS (well-known community)\n"
10114 "community number\n"
10115 "Do not send outside local AS (well-known community)\n"
10116 "Do not advertise to any peer (well-known community)\n"
10117 "Do not export to next AS (well-known community)\n"
10118 "Exact match of the communities")
10119
10120/* old command */
10121ALIAS (show_ipv6_mbgp_community_exact,
10122 show_ipv6_mbgp_community4_exact_cmd,
10123 "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",
10124 SHOW_STR
10125 IPV6_STR
10126 MBGP_STR
10127 "Display routes matching the communities\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 "community number\n"
10133 "Do not send outside local AS (well-known community)\n"
10134 "Do not advertise to any peer (well-known community)\n"
10135 "Do not export to next AS (well-known community)\n"
10136 "community number\n"
10137 "Do not send outside local AS (well-known community)\n"
10138 "Do not advertise to any peer (well-known community)\n"
10139 "Do not export to next AS (well-known community)\n"
10140 "community number\n"
10141 "Do not send outside local AS (well-known community)\n"
10142 "Do not advertise to any peer (well-known community)\n"
10143 "Do not export to next AS (well-known community)\n"
10144 "Exact match of the communities")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010145
Lou Berger651b4022016-01-12 13:42:07 -050010146DEFUN (show_bgp_ipv4_community,
10147 show_bgp_ipv4_community_cmd,
10148 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010149 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010150 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010151 IP_STR
paul718e3742002-12-13 20:15:29 +000010152 "Display routes matching the communities\n"
10153 "community number\n"
10154 "Do not send outside local AS (well-known community)\n"
10155 "Do not advertise to any peer (well-known community)\n"
10156 "Do not export to next AS (well-known community)\n")
10157{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010158 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010159}
10160
Lou Berger651b4022016-01-12 13:42:07 -050010161ALIAS (show_bgp_ipv4_community,
10162 show_bgp_ipv4_community2_cmd,
10163 "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 +000010164 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010165 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010166 IP_STR
paul718e3742002-12-13 20:15:29 +000010167 "Display routes matching the communities\n"
10168 "community number\n"
10169 "Do not send outside local AS (well-known community)\n"
10170 "Do not advertise to any peer (well-known community)\n"
10171 "Do not export to next AS (well-known community)\n"
10172 "community number\n"
10173 "Do not send outside local AS (well-known community)\n"
10174 "Do not advertise to any peer (well-known community)\n"
10175 "Do not export to next AS (well-known community)\n")
10176
Lou Berger651b4022016-01-12 13:42:07 -050010177ALIAS (show_bgp_ipv4_community,
10178 show_bgp_ipv4_community3_cmd,
10179 "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 +000010180 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010181 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010182 IP_STR
paul718e3742002-12-13 20:15:29 +000010183 "Display routes matching the communities\n"
10184 "community number\n"
10185 "Do not send outside local AS (well-known community)\n"
10186 "Do not advertise to any peer (well-known community)\n"
10187 "Do not export to next AS (well-known community)\n"
10188 "community number\n"
10189 "Do not send outside local AS (well-known community)\n"
10190 "Do not advertise to any peer (well-known community)\n"
10191 "Do not export to next AS (well-known community)\n"
10192 "community number\n"
10193 "Do not send outside local AS (well-known community)\n"
10194 "Do not advertise to any peer (well-known community)\n"
10195 "Do not export to next AS (well-known community)\n")
10196
Lou Berger651b4022016-01-12 13:42:07 -050010197ALIAS (show_bgp_ipv4_community,
10198 show_bgp_ipv4_community4_cmd,
10199 "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 +000010200 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010201 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010202 IP_STR
paul718e3742002-12-13 20:15:29 +000010203 "Display routes matching the communities\n"
10204 "community number\n"
10205 "Do not send outside local AS (well-known community)\n"
10206 "Do not advertise to any peer (well-known community)\n"
10207 "Do not export to next AS (well-known community)\n"
10208 "community number\n"
10209 "Do not send outside local AS (well-known community)\n"
10210 "Do not advertise to any peer (well-known community)\n"
10211 "Do not export to next AS (well-known community)\n"
10212 "community number\n"
10213 "Do not send outside local AS (well-known community)\n"
10214 "Do not advertise to any peer (well-known community)\n"
10215 "Do not export to next AS (well-known community)\n"
10216 "community number\n"
10217 "Do not send outside local AS (well-known community)\n"
10218 "Do not advertise to any peer (well-known community)\n"
10219 "Do not export to next AS (well-known community)\n")
10220
Lou Berger651b4022016-01-12 13:42:07 -050010221DEFUN (show_bgp_ipv4_safi_community,
10222 show_bgp_ipv4_safi_community_cmd,
10223 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010224 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010225 BGP_STR
10226 "Address family\n"
10227 "Address Family modifier\n"
10228 "Address Family modifier\n"
10229 "Display routes matching the communities\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{
10235 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010236 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010237
Michael Lambert95cbbd22010-07-23 14:43:04 -040010238 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010239}
10240
Lou Berger651b4022016-01-12 13:42:07 -050010241ALIAS (show_bgp_ipv4_safi_community,
10242 show_bgp_ipv4_safi_community2_cmd,
10243 "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 +000010244 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010245 BGP_STR
10246 "Address family\n"
10247 "Address Family modifier\n"
10248 "Address Family modifier\n"
10249 "Display routes matching the communities\n"
10250 "community number\n"
10251 "Do not send outside local AS (well-known community)\n"
10252 "Do not advertise to any peer (well-known community)\n"
10253 "Do not export to next AS (well-known community)\n"
10254 "community number\n"
10255 "Do not send outside local AS (well-known community)\n"
10256 "Do not advertise to any peer (well-known community)\n"
10257 "Do not export to next AS (well-known community)\n")
10258
Lou Berger651b4022016-01-12 13:42:07 -050010259ALIAS (show_bgp_ipv4_safi_community,
10260 show_bgp_ipv4_safi_community3_cmd,
10261 "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 +000010262 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010263 BGP_STR
10264 "Address family\n"
10265 "Address Family modifier\n"
10266 "Address Family modifier\n"
10267 "Display routes matching the communities\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 "community number\n"
10273 "Do not send outside local AS (well-known community)\n"
10274 "Do not advertise to any peer (well-known community)\n"
10275 "Do not export to next AS (well-known community)\n"
10276 "community number\n"
10277 "Do not send outside local AS (well-known community)\n"
10278 "Do not advertise to any peer (well-known community)\n"
10279 "Do not export to next AS (well-known community)\n")
10280
Lou Berger651b4022016-01-12 13:42:07 -050010281ALIAS (show_bgp_ipv4_safi_community,
10282 show_bgp_ipv4_safi_community4_cmd,
10283 "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 +000010284 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010285 BGP_STR
10286 "Address family\n"
10287 "Address Family modifier\n"
10288 "Address Family modifier\n"
10289 "Display routes matching the communities\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 "community number\n"
10295 "Do not send outside local AS (well-known community)\n"
10296 "Do not advertise to any peer (well-known community)\n"
10297 "Do not export to next AS (well-known community)\n"
10298 "community number\n"
10299 "Do not send outside local AS (well-known community)\n"
10300 "Do not advertise to any peer (well-known community)\n"
10301 "Do not export to next AS (well-known community)\n"
10302 "community number\n"
10303 "Do not send outside local AS (well-known community)\n"
10304 "Do not advertise to any peer (well-known community)\n"
10305 "Do not export to next AS (well-known community)\n")
10306
Michael Lambert95cbbd22010-07-23 14:43:04 -040010307DEFUN (show_bgp_view_afi_safi_community_all,
10308 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010309 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010310 SHOW_STR
10311 BGP_STR
10312 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010313 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010314 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010315 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010316 "Address Family modifier\n"
10317 "Address Family modifier\n"
Christian Franke2b005152013-09-30 12:27:49 +000010318 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010319{
10320 int afi;
10321 int safi;
10322 struct bgp *bgp;
10323
10324 /* BGP structure lookup. */
10325 bgp = bgp_lookup_by_name (argv[0]);
10326 if (bgp == NULL)
10327 {
10328 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10329 return CMD_WARNING;
10330 }
10331
Michael Lambert95cbbd22010-07-23 14:43:04 -040010332 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10333 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010334 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10335}
10336
10337DEFUN (show_bgp_view_afi_safi_community,
10338 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010339 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010340 SHOW_STR
10341 BGP_STR
10342 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010343 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010344 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010345 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010346 "Address family modifier\n"
10347 "Address family modifier\n"
10348 "Display routes matching the communities\n"
10349 "community number\n"
10350 "Do not send outside local AS (well-known community)\n"
10351 "Do not advertise to any peer (well-known community)\n"
10352 "Do not export to next AS (well-known community)\n")
10353{
10354 int afi;
10355 int safi;
10356
Michael Lambert95cbbd22010-07-23 14:43:04 -040010357 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10358 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10359 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010360}
10361
10362ALIAS (show_bgp_view_afi_safi_community,
10363 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010364 "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 -040010365 SHOW_STR
10366 BGP_STR
10367 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010368 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010369 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010370 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010371 "Address family modifier\n"
10372 "Address family modifier\n"
10373 "Display routes matching the communities\n"
10374 "community number\n"
10375 "Do not send outside local AS (well-known community)\n"
10376 "Do not advertise to any peer (well-known community)\n"
10377 "Do not export to next AS (well-known community)\n"
10378 "community number\n"
10379 "Do not send outside local AS (well-known community)\n"
10380 "Do not advertise to any peer (well-known community)\n"
10381 "Do not export to next AS (well-known community)\n")
10382
10383ALIAS (show_bgp_view_afi_safi_community,
10384 show_bgp_view_afi_safi_community3_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010385 "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 -040010386 SHOW_STR
10387 BGP_STR
10388 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010389 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010390 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010391 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010392 "Address family modifier\n"
10393 "Address family modifier\n"
10394 "Display routes matching the communities\n"
10395 "community number\n"
10396 "Do not send outside local AS (well-known community)\n"
10397 "Do not advertise to any peer (well-known community)\n"
10398 "Do not export to next AS (well-known community)\n"
10399 "community number\n"
10400 "Do not send outside local AS (well-known community)\n"
10401 "Do not advertise to any peer (well-known community)\n"
10402 "Do not export to next AS (well-known community)\n"
10403 "community number\n"
10404 "Do not send outside local AS (well-known community)\n"
10405 "Do not advertise to any peer (well-known community)\n"
10406 "Do not export to next AS (well-known community)\n")
10407
10408ALIAS (show_bgp_view_afi_safi_community,
10409 show_bgp_view_afi_safi_community4_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010410 "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 -040010411 SHOW_STR
10412 BGP_STR
10413 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010414 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010415 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010416 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010417 "Address family modifier\n"
10418 "Address family modifier\n"
10419 "Display routes matching the communities\n"
10420 "community number\n"
10421 "Do not send outside local AS (well-known community)\n"
10422 "Do not advertise to any peer (well-known community)\n"
10423 "Do not export to next AS (well-known community)\n"
10424 "community number\n"
10425 "Do not send outside local AS (well-known community)\n"
10426 "Do not advertise to any peer (well-known community)\n"
10427 "Do not export to next AS (well-known community)\n"
10428 "community number\n"
10429 "Do not send outside local AS (well-known community)\n"
10430 "Do not advertise to any peer (well-known community)\n"
10431 "Do not export to next AS (well-known community)\n"
10432 "community number\n"
10433 "Do not send outside local AS (well-known community)\n"
10434 "Do not advertise to any peer (well-known community)\n"
10435 "Do not export to next AS (well-known community)\n")
10436
Lou Berger651b4022016-01-12 13:42:07 -050010437DEFUN (show_bgp_ipv4_community_exact,
10438 show_bgp_ipv4_community_exact_cmd,
10439 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010440 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010441 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010442 IP_STR
paul718e3742002-12-13 20:15:29 +000010443 "Display routes matching the communities\n"
10444 "community number\n"
10445 "Do not send outside local AS (well-known community)\n"
10446 "Do not advertise to any peer (well-known community)\n"
10447 "Do not export to next AS (well-known community)\n"
10448 "Exact match of the communities")
10449{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010450 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010451}
10452
Lou Berger651b4022016-01-12 13:42:07 -050010453ALIAS (show_bgp_ipv4_community_exact,
10454 show_bgp_ipv4_community2_exact_cmd,
10455 "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 +000010456 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010457 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010458 IP_STR
paul718e3742002-12-13 20:15:29 +000010459 "Display routes matching the communities\n"
10460 "community number\n"
10461 "Do not send outside local AS (well-known community)\n"
10462 "Do not advertise to any peer (well-known community)\n"
10463 "Do not export to next AS (well-known community)\n"
10464 "community number\n"
10465 "Do not send outside local AS (well-known community)\n"
10466 "Do not advertise to any peer (well-known community)\n"
10467 "Do not export to next AS (well-known community)\n"
10468 "Exact match of the communities")
10469
Lou Berger651b4022016-01-12 13:42:07 -050010470ALIAS (show_bgp_ipv4_community_exact,
10471 show_bgp_ipv4_community3_exact_cmd,
10472 "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 +000010473 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010474 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010475 IP_STR
paul718e3742002-12-13 20:15:29 +000010476 "Display routes matching the communities\n"
10477 "community number\n"
10478 "Do not send outside local AS (well-known community)\n"
10479 "Do not advertise to any peer (well-known community)\n"
10480 "Do not export to next AS (well-known community)\n"
10481 "community number\n"
10482 "Do not send outside local AS (well-known community)\n"
10483 "Do not advertise to any peer (well-known community)\n"
10484 "Do not export to next AS (well-known community)\n"
10485 "community number\n"
10486 "Do not send outside local AS (well-known community)\n"
10487 "Do not advertise to any peer (well-known community)\n"
10488 "Do not export to next AS (well-known community)\n"
10489 "Exact match of the communities")
10490
Lou Berger651b4022016-01-12 13:42:07 -050010491ALIAS (show_bgp_ipv4_community_exact,
10492 show_bgp_ipv4_community4_exact_cmd,
10493 "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 +000010494 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010495 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010496 IP_STR
paul718e3742002-12-13 20:15:29 +000010497 "Display routes matching the communities\n"
10498 "community number\n"
10499 "Do not send outside local AS (well-known community)\n"
10500 "Do not advertise to any peer (well-known community)\n"
10501 "Do not export to next AS (well-known community)\n"
10502 "community number\n"
10503 "Do not send outside local AS (well-known community)\n"
10504 "Do not advertise to any peer (well-known community)\n"
10505 "Do not export to next AS (well-known community)\n"
10506 "community number\n"
10507 "Do not send outside local AS (well-known community)\n"
10508 "Do not advertise to any peer (well-known community)\n"
10509 "Do not export to next AS (well-known community)\n"
10510 "community number\n"
10511 "Do not send outside local AS (well-known community)\n"
10512 "Do not advertise to any peer (well-known community)\n"
10513 "Do not export to next AS (well-known community)\n"
10514 "Exact match of the communities")
10515
Lou Berger651b4022016-01-12 13:42:07 -050010516DEFUN (show_bgp_ipv4_safi_community4_exact,
10517 show_bgp_ipv4_safi_community_exact_cmd,
10518 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010519 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010520 BGP_STR
10521 "Address family\n"
10522 "Address Family modifier\n"
10523 "Address Family modifier\n"
10524 "Display routes matching the communities\n"
10525 "community number\n"
10526 "Do not send outside local AS (well-known community)\n"
10527 "Do not advertise to any peer (well-known community)\n"
10528 "Do not export to next AS (well-known community)\n"
10529 "Exact match of the communities")
10530{
10531 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010532 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010533
Michael Lambert95cbbd22010-07-23 14:43:04 -040010534 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010535}
10536
Lou Berger651b4022016-01-12 13:42:07 -050010537ALIAS (show_bgp_ipv4_safi_community4_exact,
10538 show_bgp_ipv4_safi_community2_exact_cmd,
10539 "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 +000010540 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010541 BGP_STR
10542 "Address family\n"
10543 "Address Family modifier\n"
10544 "Address Family modifier\n"
10545 "Display routes matching the communities\n"
10546 "community number\n"
10547 "Do not send outside local AS (well-known community)\n"
10548 "Do not advertise to any peer (well-known community)\n"
10549 "Do not export to next AS (well-known community)\n"
10550 "community number\n"
10551 "Do not send outside local AS (well-known community)\n"
10552 "Do not advertise to any peer (well-known community)\n"
10553 "Do not export to next AS (well-known community)\n"
10554 "Exact match of the communities")
10555
Lou Berger651b4022016-01-12 13:42:07 -050010556ALIAS (show_bgp_ipv4_safi_community4_exact,
10557 show_bgp_ipv4_safi_community3_exact_cmd,
10558 "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 +000010559 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010560 BGP_STR
10561 "Address family\n"
10562 "Address Family modifier\n"
10563 "Address Family modifier\n"
10564 "Display routes matching the communities\n"
10565 "community number\n"
10566 "Do not send outside local AS (well-known community)\n"
10567 "Do not advertise to any peer (well-known community)\n"
10568 "Do not export to next AS (well-known community)\n"
10569 "community number\n"
10570 "Do not send outside local AS (well-known community)\n"
10571 "Do not advertise to any peer (well-known community)\n"
10572 "Do not export to next AS (well-known community)\n"
10573 "community number\n"
10574 "Do not send outside local AS (well-known community)\n"
10575 "Do not advertise to any peer (well-known community)\n"
10576 "Do not export to next AS (well-known community)\n"
10577 "Exact match of the communities")
10578
Lou Berger651b4022016-01-12 13:42:07 -050010579ALIAS (show_bgp_ipv4_safi_community4_exact,
10580 show_bgp_ipv4_safi_community4_exact_cmd,
10581 "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 +000010582 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010583 BGP_STR
10584 "Address family\n"
10585 "Address Family modifier\n"
10586 "Address Family modifier\n"
10587 "Display routes matching the communities\n"
10588 "community number\n"
10589 "Do not send outside local AS (well-known community)\n"
10590 "Do not advertise to any peer (well-known community)\n"
10591 "Do not export to next AS (well-known community)\n"
10592 "community number\n"
10593 "Do not send outside local AS (well-known community)\n"
10594 "Do not advertise to any peer (well-known community)\n"
10595 "Do not export to next AS (well-known community)\n"
10596 "community number\n"
10597 "Do not send outside local AS (well-known community)\n"
10598 "Do not advertise to any peer (well-known community)\n"
10599 "Do not export to next AS (well-known community)\n"
10600 "community number\n"
10601 "Do not send outside local AS (well-known community)\n"
10602 "Do not advertise to any peer (well-known community)\n"
10603 "Do not export to next AS (well-known community)\n"
10604 "Exact match of the communities")
10605
Lou Bergerf9b6c392016-01-12 13:42:09 -050010606DEFUN (show_bgp_ipv6_safi_community,
10607 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010608 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010609 SHOW_STR
10610 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010611 "Address family\n"
10612 "Address family modifier\n"
10613 "Address family modifier\n"
10614 "Address family modifier\n"
10615 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010616 "Display routes matching the communities\n"
10617 "community number\n"
10618 "Do not send outside local AS (well-known community)\n"
10619 "Do not advertise to any peer (well-known community)\n"
10620 "Do not export to next AS (well-known community)\n")
10621{
Lou Berger651b4022016-01-12 13:42:07 -050010622 safi_t safi;
10623
10624 if (bgp_parse_safi(argv[0], &safi)) {
10625 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10626 return CMD_WARNING;
10627 }
10628 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010629}
10630
Lou Bergerf9b6c392016-01-12 13:42:09 -050010631ALIAS (show_bgp_ipv6_safi_community,
10632 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010633 "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 +000010634 SHOW_STR
10635 BGP_STR
10636 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010637 "Address family modifier\n"
10638 "Address family modifier\n"
10639 "Address family modifier\n"
10640 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010641 "Display routes matching the communities\n"
10642 "community number\n"
10643 "Do not send outside local AS (well-known community)\n"
10644 "Do not advertise to any peer (well-known community)\n"
10645 "Do not export to next AS (well-known community)\n"
10646 "community number\n"
10647 "Do not send outside local AS (well-known community)\n"
10648 "Do not advertise to any peer (well-known community)\n"
10649 "Do not export to next AS (well-known community)\n")
10650
Lou Bergerf9b6c392016-01-12 13:42:09 -050010651ALIAS (show_bgp_ipv6_safi_community,
10652 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010653 "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 +000010654 SHOW_STR
10655 BGP_STR
10656 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010657 "Address family modifier\n"
10658 "Address family modifier\n"
10659 "Address family modifier\n"
10660 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010661 "Display routes matching the communities\n"
10662 "community number\n"
10663 "Do not send outside local AS (well-known community)\n"
10664 "Do not advertise to any peer (well-known community)\n"
10665 "Do not export to next AS (well-known community)\n"
10666 "community number\n"
10667 "Do not send outside local AS (well-known community)\n"
10668 "Do not advertise to any peer (well-known community)\n"
10669 "Do not export to next AS (well-known community)\n"
10670 "community number\n"
10671 "Do not send outside local AS (well-known community)\n"
10672 "Do not advertise to any peer (well-known community)\n"
10673 "Do not export to next AS (well-known community)\n")
10674
Lou Bergerf9b6c392016-01-12 13:42:09 -050010675ALIAS (show_bgp_ipv6_safi_community,
10676 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010677 "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 +000010678 SHOW_STR
10679 BGP_STR
10680 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010681 "Address family modifier\n"
10682 "Address family modifier\n"
10683 "Address family modifier\n"
10684 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010685 "Display routes matching the communities\n"
10686 "community number\n"
10687 "Do not send outside local AS (well-known community)\n"
10688 "Do not advertise to any peer (well-known community)\n"
10689 "Do not export to next AS (well-known community)\n"
10690 "community number\n"
10691 "Do not send outside local AS (well-known community)\n"
10692 "Do not advertise to any peer (well-known community)\n"
10693 "Do not export to next AS (well-known community)\n"
10694 "community number\n"
10695 "Do not send outside local AS (well-known community)\n"
10696 "Do not advertise to any peer (well-known community)\n"
10697 "Do not export to next AS (well-known community)\n"
10698 "community number\n"
10699 "Do not send outside local AS (well-known community)\n"
10700 "Do not advertise to any peer (well-known community)\n"
10701 "Do not export to next AS (well-known community)\n")
10702
paul718e3742002-12-13 20:15:29 +000010703
Lou Bergerf9b6c392016-01-12 13:42:09 -050010704DEFUN (show_bgp_ipv6_safi_community_exact,
10705 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010706 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010707 SHOW_STR
10708 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010709 "Address family\n"
10710 "Address family modifier\n"
10711 "Address family modifier\n"
10712 "Address family modifier\n"
10713 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010714 "Display routes matching the communities\n"
10715 "community number\n"
10716 "Do not send outside local AS (well-known community)\n"
10717 "Do not advertise to any peer (well-known community)\n"
10718 "Do not export to next AS (well-known community)\n"
10719 "Exact match of the communities")
10720{
Lou Berger651b4022016-01-12 13:42:07 -050010721 safi_t safi;
10722
10723 if (bgp_parse_safi(argv[0], &safi)) {
10724 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10725 return CMD_WARNING;
10726 }
10727 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010728}
10729
paul718e3742002-12-13 20:15:29 +000010730
10731ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010732 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010733 "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 +000010734 SHOW_STR
10735 BGP_STR
10736 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010737 "Address family modifier\n"
10738 "Address family modifier\n"
10739 "Address family modifier\n"
10740 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010741 "Display routes matching the communities\n"
10742 "community number\n"
10743 "Do not send outside local AS (well-known community)\n"
10744 "Do not advertise to any peer (well-known community)\n"
10745 "Do not export to next AS (well-known community)\n"
10746 "community number\n"
10747 "Do not send outside local AS (well-known community)\n"
10748 "Do not advertise to any peer (well-known community)\n"
10749 "Do not export to next AS (well-known community)\n"
10750 "Exact match of the communities")
10751
10752ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010753 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010754 "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 +000010755 SHOW_STR
10756 BGP_STR
10757 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010758 "Address family modifier\n"
10759 "Address family modifier\n"
10760 "Address family modifier\n"
10761 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010762 "Display routes matching the communities\n"
10763 "community number\n"
10764 "Do not send outside local AS (well-known community)\n"
10765 "Do not advertise to any peer (well-known community)\n"
10766 "Do not export to next AS (well-known community)\n"
10767 "community number\n"
10768 "Do not send outside local AS (well-known community)\n"
10769 "Do not advertise to any peer (well-known community)\n"
10770 "Do not export to next AS (well-known community)\n"
10771 "community number\n"
10772 "Do not send outside local AS (well-known community)\n"
10773 "Do not advertise to any peer (well-known community)\n"
10774 "Do not export to next AS (well-known community)\n"
10775 "Exact match of the communities")
10776
10777ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010778 show_bgp_ipv6_safi_community4_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010779 "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 +000010780 SHOW_STR
10781 BGP_STR
10782 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010783 "Address family modifier\n"
10784 "Address family modifier\n"
10785 "Address family modifier\n"
10786 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010787 "Display routes matching the communities\n"
10788 "community number\n"
10789 "Do not send outside local AS (well-known community)\n"
10790 "Do not advertise to any peer (well-known community)\n"
10791 "Do not export to next AS (well-known community)\n"
10792 "community number\n"
10793 "Do not send outside local AS (well-known community)\n"
10794 "Do not advertise to any peer (well-known community)\n"
10795 "Do not export to next AS (well-known community)\n"
10796 "community number\n"
10797 "Do not send outside local AS (well-known community)\n"
10798 "Do not advertise to any peer (well-known community)\n"
10799 "Do not export to next AS (well-known community)\n"
10800 "community number\n"
10801 "Do not send outside local AS (well-known community)\n"
10802 "Do not advertise to any peer (well-known community)\n"
10803 "Do not export to next AS (well-known community)\n"
10804 "Exact match of the communities")
10805
paul94f2b392005-06-28 12:44:16 +000010806static int
paulfd79ac92004-10-13 05:06:08 +000010807bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040010808 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000010809{
10810 struct community_list *list;
10811
hassofee6e4e2005-02-02 16:29:31 +000010812 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010813 if (list == NULL)
10814 {
10815 vty_out (vty, "%% %s is not a valid community-list name%s", com,
10816 VTY_NEWLINE);
10817 return CMD_WARNING;
10818 }
10819
ajs5a646652004-11-05 01:25:55 +000010820 return bgp_show (vty, NULL, afi, safi,
10821 (exact ? bgp_show_type_community_list_exact :
10822 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000010823}
10824
Lou Bergerf9b6c392016-01-12 13:42:09 -050010825DEFUN (show_ip_bgp_community_list,
10826 show_ip_bgp_community_list_cmd,
10827 "show ip bgp community-list (<1-500>|WORD)",
10828 SHOW_STR
10829 IP_STR
10830 BGP_STR
10831 "Display routes matching the community-list\n"
10832 "community-list number\n"
10833 "community-list name\n")
10834{
10835 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
10836}
10837
10838DEFUN (show_ip_bgp_ipv4_community_list,
10839 show_ip_bgp_ipv4_community_list_cmd,
10840 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10841 SHOW_STR
10842 IP_STR
10843 BGP_STR
10844 "Address family\n"
10845 "Address Family modifier\n"
10846 "Address Family modifier\n"
10847 "Display routes matching the community-list\n"
10848 "community-list number\n"
10849 "community-list name\n")
10850{
10851 if (strncmp (argv[0], "m", 1) == 0)
10852 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
10853
10854 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
10855}
10856
10857DEFUN (show_ip_bgp_community_list_exact,
10858 show_ip_bgp_community_list_exact_cmd,
10859 "show ip bgp community-list (<1-500>|WORD) exact-match",
10860 SHOW_STR
10861 IP_STR
10862 BGP_STR
10863 "Display routes matching the community-list\n"
10864 "community-list number\n"
10865 "community-list name\n"
10866 "Exact match of the communities\n")
10867{
10868 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
10869}
10870
10871DEFUN (show_ip_bgp_ipv4_community_list_exact,
10872 show_ip_bgp_ipv4_community_list_exact_cmd,
10873 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10874 SHOW_STR
10875 IP_STR
10876 BGP_STR
10877 "Address family\n"
10878 "Address Family modifier\n"
10879 "Address Family modifier\n"
10880 "Display routes matching the community-list\n"
10881 "community-list number\n"
10882 "community-list name\n"
10883 "Exact match of the communities\n")
10884{
10885 if (strncmp (argv[0], "m", 1) == 0)
10886 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
10887
10888 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
10889}
10890
Lou Bergerf9b6c392016-01-12 13:42:09 -050010891DEFUN (show_bgp_community_list,
10892 show_bgp_community_list_cmd,
10893 "show bgp community-list (<1-500>|WORD)",
10894 SHOW_STR
10895 BGP_STR
10896 "Display routes matching the community-list\n"
10897 "community-list number\n"
10898 "community-list name\n")
10899{
10900 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10901}
10902
10903ALIAS (show_bgp_community_list,
10904 show_bgp_ipv6_community_list_cmd,
10905 "show bgp ipv6 community-list (<1-500>|WORD)",
10906 SHOW_STR
10907 BGP_STR
10908 "Address family\n"
10909 "Display routes matching the community-list\n"
10910 "community-list number\n"
10911 "community-list name\n")
10912
10913/* old command */
10914DEFUN (show_ipv6_bgp_community_list,
10915 show_ipv6_bgp_community_list_cmd,
10916 "show ipv6 bgp community-list WORD",
10917 SHOW_STR
10918 IPV6_STR
10919 BGP_STR
10920 "Display routes matching the community-list\n"
10921 "community-list name\n")
10922{
10923 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10924}
10925
10926/* old command */
10927DEFUN (show_ipv6_mbgp_community_list,
10928 show_ipv6_mbgp_community_list_cmd,
10929 "show ipv6 mbgp community-list WORD",
10930 SHOW_STR
10931 IPV6_STR
10932 MBGP_STR
10933 "Display routes matching the community-list\n"
10934 "community-list name\n")
10935{
10936 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
10937}
10938
10939DEFUN (show_bgp_community_list_exact,
10940 show_bgp_community_list_exact_cmd,
10941 "show bgp community-list (<1-500>|WORD) exact-match",
10942 SHOW_STR
10943 BGP_STR
10944 "Display routes matching the community-list\n"
10945 "community-list number\n"
10946 "community-list name\n"
10947 "Exact match of the communities\n")
10948{
10949 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10950}
10951
10952ALIAS (show_bgp_community_list_exact,
10953 show_bgp_ipv6_community_list_exact_cmd,
10954 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10955 SHOW_STR
10956 BGP_STR
10957 "Address family\n"
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/* old command */
10964DEFUN (show_ipv6_bgp_community_list_exact,
10965 show_ipv6_bgp_community_list_exact_cmd,
10966 "show ipv6 bgp community-list WORD exact-match",
10967 SHOW_STR
10968 IPV6_STR
10969 BGP_STR
10970 "Display routes matching the community-list\n"
10971 "community-list name\n"
10972 "Exact match of the communities\n")
10973{
10974 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10975}
10976
10977/* old command */
10978DEFUN (show_ipv6_mbgp_community_list_exact,
10979 show_ipv6_mbgp_community_list_exact_cmd,
10980 "show ipv6 mbgp community-list WORD exact-match",
10981 SHOW_STR
10982 IPV6_STR
10983 MBGP_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_MULTICAST);
10989}
Lou Bergerf9b6c392016-01-12 13:42:09 -050010990
Lou Berger651b4022016-01-12 13:42:07 -050010991DEFUN (show_bgp_ipv4_community_list,
10992 show_bgp_ipv4_community_list_cmd,
10993 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010994 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010995 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010996 IP_STR
paul718e3742002-12-13 20:15:29 +000010997 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010998 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010999 "community-list name\n")
11000{
11001 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11002}
11003
Lou Berger651b4022016-01-12 13:42:07 -050011004DEFUN (show_bgp_ipv4_safi_community_list,
11005 show_bgp_ipv4_safi_community_list_cmd,
11006 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011007 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011008 BGP_STR
11009 "Address family\n"
11010 "Address Family modifier\n"
11011 "Address Family modifier\n"
11012 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011013 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011014 "community-list name\n")
11015{
11016 if (strncmp (argv[0], "m", 1) == 0)
11017 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11018
11019 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11020}
11021
Lou Berger651b4022016-01-12 13:42:07 -050011022DEFUN (show_bgp_ipv4_community_list_exact,
11023 show_bgp_ipv4_community_list_exact_cmd,
11024 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011025 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011026 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011027 IP_STR
paul718e3742002-12-13 20:15:29 +000011028 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011029 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011030 "community-list name\n"
11031 "Exact match of the communities\n")
11032{
11033 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11034}
11035
Lou Berger651b4022016-01-12 13:42:07 -050011036DEFUN (show_bgp_ipv4_safi_community_list_exact,
11037 show_bgp_ipv4_safi_community_list_exact_cmd,
11038 "show bgp ipv4 (unicast|multicast) 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
11041 "Address family\n"
11042 "Address Family modifier\n"
11043 "Address Family modifier\n"
11044 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011045 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011046 "community-list name\n"
11047 "Exact match of the communities\n")
11048{
11049 if (strncmp (argv[0], "m", 1) == 0)
11050 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11051
11052 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11053}
11054
Lou Bergerf9b6c392016-01-12 13:42:09 -050011055DEFUN (show_bgp_ipv6_safi_community_list,
11056 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011057 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011058 SHOW_STR
11059 BGP_STR
11060 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011061 "Address family modifier\n"
11062 "Address family modifier\n"
11063 "Address family modifier\n"
11064 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011065 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011066 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011067 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011068{
Lou Berger651b4022016-01-12 13:42:07 -050011069 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011070
Lou Berger651b4022016-01-12 13:42:07 -050011071 if (bgp_parse_safi(argv[0], &safi)) {
11072 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11073 return CMD_WARNING;
11074 }
11075 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011076}
11077
Lou Bergerf9b6c392016-01-12 13:42:09 -050011078DEFUN (show_bgp_ipv6_safi_community_list_exact,
11079 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011080 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011081 SHOW_STR
11082 BGP_STR
11083 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011084 "Address family modifier\n"
11085 "Address family modifier\n"
11086 "Address family modifier\n"
11087 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011088 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011089 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011090 "community-list name\n"
11091 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011092{
Lou Berger651b4022016-01-12 13:42:07 -050011093 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011094
Lou Berger651b4022016-01-12 13:42:07 -050011095 if (bgp_parse_safi(argv[0], &safi)) {
11096 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11097 return CMD_WARNING;
11098 }
11099 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011100}
David Lamparter6b0655a2014-06-04 06:53:35 +020011101
paul94f2b392005-06-28 12:44:16 +000011102static int
paulfd79ac92004-10-13 05:06:08 +000011103bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000011104 safi_t safi, enum bgp_show_type type)
11105{
11106 int ret;
11107 struct prefix *p;
11108
11109 p = prefix_new();
11110
11111 ret = str2prefix (prefix, p);
11112 if (! ret)
11113 {
11114 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
11115 return CMD_WARNING;
11116 }
11117
ajs5a646652004-11-05 01:25:55 +000011118 ret = bgp_show (vty, NULL, afi, safi, type, p);
11119 prefix_free(p);
11120 return ret;
paul718e3742002-12-13 20:15:29 +000011121}
11122
Lou Bergerf9b6c392016-01-12 13:42:09 -050011123DEFUN (show_ip_bgp_prefix_longer,
11124 show_ip_bgp_prefix_longer_cmd,
11125 "show ip bgp A.B.C.D/M longer-prefixes",
11126 SHOW_STR
11127 IP_STR
11128 BGP_STR
11129 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11130 "Display route and more specific routes\n")
11131{
11132 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11133 bgp_show_type_prefix_longer);
11134}
11135
11136DEFUN (show_ip_bgp_flap_prefix_longer,
11137 show_ip_bgp_flap_prefix_longer_cmd,
11138 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11139 SHOW_STR
11140 IP_STR
11141 BGP_STR
11142 "Display flap statistics of routes\n"
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_flap_prefix_longer);
11148}
11149
11150ALIAS (show_ip_bgp_flap_prefix_longer,
11151 show_ip_bgp_damp_flap_prefix_longer_cmd,
11152 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11153 SHOW_STR
11154 IP_STR
11155 BGP_STR
11156 "Display detailed information about dampening\n"
11157 "Display flap statistics of routes\n"
11158 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11159 "Display route and more specific routes\n")
11160
11161DEFUN (show_ip_bgp_ipv4_prefix_longer,
11162 show_ip_bgp_ipv4_prefix_longer_cmd,
11163 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11164 SHOW_STR
11165 IP_STR
11166 BGP_STR
11167 "Address family\n"
11168 "Address Family modifier\n"
11169 "Address Family modifier\n"
11170 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11171 "Display route and more specific routes\n")
11172{
11173 if (strncmp (argv[0], "m", 1) == 0)
11174 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
11175 bgp_show_type_prefix_longer);
11176
11177 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
11178 bgp_show_type_prefix_longer);
11179}
11180
11181DEFUN (show_ip_bgp_flap_address,
11182 show_ip_bgp_flap_address_cmd,
11183 "show ip bgp flap-statistics A.B.C.D",
11184 SHOW_STR
11185 IP_STR
11186 BGP_STR
11187 "Display flap statistics of routes\n"
11188 "Network in the BGP routing table to display\n")
11189{
11190 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11191 bgp_show_type_flap_address);
11192}
11193
11194ALIAS (show_ip_bgp_flap_address,
11195 show_ip_bgp_damp_flap_address_cmd,
11196 "show ip bgp dampening flap-statistics A.B.C.D",
11197 SHOW_STR
11198 IP_STR
11199 BGP_STR
11200 "Display detailed information about dampening\n"
11201 "Display flap statistics of routes\n"
11202 "Network in the BGP routing table to display\n")
11203
11204DEFUN (show_ip_bgp_flap_prefix,
11205 show_ip_bgp_flap_prefix_cmd,
11206 "show ip bgp flap-statistics A.B.C.D/M",
11207 SHOW_STR
11208 IP_STR
11209 BGP_STR
11210 "Display flap statistics of routes\n"
11211 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11212{
11213 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11214 bgp_show_type_flap_prefix);
11215}
11216
11217ALIAS (show_ip_bgp_flap_prefix,
11218 show_ip_bgp_damp_flap_prefix_cmd,
11219 "show ip bgp dampening flap-statistics A.B.C.D/M",
11220 SHOW_STR
11221 IP_STR
11222 BGP_STR
11223 "Display detailed information about dampening\n"
11224 "Display flap statistics of routes\n"
11225 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11226
Lou Bergerf9b6c392016-01-12 13:42:09 -050011227DEFUN (show_bgp_prefix_longer,
11228 show_bgp_prefix_longer_cmd,
11229 "show bgp X:X::X:X/M longer-prefixes",
11230 SHOW_STR
11231 BGP_STR
11232 "IPv6 prefix <network>/<length>\n"
11233 "Display route and more specific routes\n")
11234{
11235 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11236 bgp_show_type_prefix_longer);
11237}
11238
11239/* old command */
11240DEFUN (show_ipv6_bgp_prefix_longer,
11241 show_ipv6_bgp_prefix_longer_cmd,
11242 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11243 SHOW_STR
11244 IPV6_STR
11245 BGP_STR
11246 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\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_mbgp_prefix_longer,
11255 show_ipv6_mbgp_prefix_longer_cmd,
11256 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11257 SHOW_STR
11258 IPV6_STR
11259 MBGP_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_MULTICAST,
11264 bgp_show_type_prefix_longer);
11265}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011266
Lou Berger651b4022016-01-12 13:42:07 -050011267DEFUN (show_bgp_ipv4_prefix_longer,
11268 show_bgp_ipv4_prefix_longer_cmd,
11269 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011270 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011271 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011272 IP_STR
paul718e3742002-12-13 20:15:29 +000011273 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11274 "Display route and more specific routes\n")
11275{
11276 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11277 bgp_show_type_prefix_longer);
11278}
11279
Lou Berger651b4022016-01-12 13:42:07 -050011280DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
11281 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
11282 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011283 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011284 BGP_STR
11285 "Address family\n"
11286 "Address Family modifier\n"
11287 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050011288 "Address Family modifier\n"
11289 "Address Family modifier\n"
11290 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000011291 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11292 "Display route and more specific routes\n")
11293{
Lou Berger651b4022016-01-12 13:42:07 -050011294 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011295
Lou Berger651b4022016-01-12 13:42:07 -050011296 if (bgp_parse_safi(argv[0], &safi)) {
11297 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11298 return CMD_WARNING;
11299 }
11300 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11301 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000011302}
11303
Lou Berger651b4022016-01-12 13:42:07 -050011304ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
11305 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
11306 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011307 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011308 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011309 "Address family\n"
11310 "Address Family modifier\n"
11311 "Address Family modifier\n"
11312 "Address Family modifier\n"
11313 "Address Family modifier\n"
11314 "Display detailed information about dampening\n"
11315 "Display flap statistics of routes\n"
11316 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11317 "Display route and more specific routes\n")
11318
Lou Berger651b4022016-01-12 13:42:07 -050011319DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
11320 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
11321 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
11322 SHOW_STR
11323 BGP_STR
11324 "Address family\n"
11325 "Address Family modifier\n"
11326 "Address Family modifier\n"
11327 "Address Family modifier\n"
11328 "Address Family modifier\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{
11333 safi_t safi;
11334
11335 if (bgp_parse_safi(argv[0], &safi)) {
11336 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11337 return CMD_WARNING;
11338 }
11339 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11340 bgp_show_type_flap_prefix_longer);
11341}
11342ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
11343 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
11344 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
11345 SHOW_STR
11346 BGP_STR
11347 "Address family\n"
11348 "Address Family modifier\n"
11349 "Address Family modifier\n"
11350 "Address Family modifier\n"
11351 "Address Family modifier\n"
11352 "Display detailed information about dampening\n"
11353 "Display flap statistics of routes\n"
11354 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11355 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050011356
11357DEFUN (show_bgp_ipv4_safi_prefix_longer,
11358 show_bgp_ipv4_safi_prefix_longer_cmd,
11359 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
11360 SHOW_STR
11361 BGP_STR
11362 "Address family\n"
11363 "Address Family modifier\n"
11364 "Address Family modifier\n"
11365 "Address Family modifier\n"
11366 "Address Family modifier\n"
11367 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11368 "Display route and more specific routes\n")
11369{
11370 safi_t safi;
11371
11372 if (bgp_parse_safi(argv[0], &safi)) {
11373 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11374 return CMD_WARNING;
11375 }
11376
11377 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11378 bgp_show_type_prefix_longer);
11379}
11380
Lou Berger651b4022016-01-12 13:42:07 -050011381DEFUN (show_bgp_ipv6_safi_prefix_longer,
11382 show_bgp_ipv6_safi_prefix_longer_cmd,
11383 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
11384 SHOW_STR
11385 BGP_STR
11386 "Address family\n"
11387 "Address Family modifier\n"
11388 "Address Family modifier\n"
11389 "Address Family modifier\n"
11390 "Address Family modifier\n"
11391 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11392 "Display route and more specific routes\n")
11393{
11394 safi_t safi;
11395
11396 if (bgp_parse_safi(argv[0], &safi)) {
11397 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11398 return CMD_WARNING;
11399 }
11400
11401 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11402 bgp_show_type_prefix_longer);
11403}
Lou Berger651b4022016-01-12 13:42:07 -050011404
11405DEFUN (show_bgp_ipv4_safi_flap_address,
11406 show_bgp_ipv4_safi_flap_address_cmd,
11407 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
11408 SHOW_STR
11409 BGP_STR
11410 "Address family\n"
11411 "Address Family modifier\n"
11412 "Address Family modifier\n"
11413 "Address Family modifier\n"
11414 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011415 "Display flap statistics of routes\n"
11416 "Network in the BGP routing table to display\n")
11417{
Lou Berger651b4022016-01-12 13:42:07 -050011418 safi_t safi;
11419
11420 if (bgp_parse_safi(argv[0], &safi)) {
11421 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11422 return CMD_WARNING;
11423 }
11424 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011425 bgp_show_type_flap_address);
11426}
Lou Berger651b4022016-01-12 13:42:07 -050011427ALIAS (show_bgp_ipv4_safi_flap_address,
11428 show_bgp_ipv4_safi_damp_flap_address_cmd,
11429 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053011430 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011431 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011432 "Address family\n"
11433 "Address Family modifier\n"
11434 "Address Family modifier\n"
11435 "Address Family modifier\n"
11436 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011437 "Display detailed information about dampening\n"
11438 "Display flap statistics of routes\n"
11439 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050011440
Lou Berger651b4022016-01-12 13:42:07 -050011441DEFUN (show_bgp_ipv6_flap_address,
11442 show_bgp_ipv6_flap_address_cmd,
11443 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000011444 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011445 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"
11451 "Display flap statistics of routes\n"
11452 "Network in the BGP routing table to display\n")
11453{
11454 safi_t safi;
11455
11456 if (bgp_parse_safi(argv[0], &safi)) {
11457 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11458 return CMD_WARNING;
11459 }
11460 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11461 bgp_show_type_flap_address);
11462}
11463ALIAS (show_bgp_ipv6_flap_address,
11464 show_bgp_ipv6_damp_flap_address_cmd,
11465 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
11466 SHOW_STR
11467 BGP_STR
11468 "Address family\n"
11469 "Address Family modifier\n"
11470 "Address Family modifier\n"
11471 "Address Family modifier\n"
11472 "Address Family modifier\n"
11473 "Display detailed information about dampening\n"
11474 "Display flap statistics of routes\n"
11475 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050011476
11477DEFUN (show_bgp_ipv4_safi_flap_prefix,
11478 show_bgp_ipv4_safi_flap_prefix_cmd,
11479 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
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"
paul718e3742002-12-13 20:15:29 +000011487 "Display flap statistics of routes\n"
11488 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11489{
Lou Berger651b4022016-01-12 13:42:07 -050011490 safi_t safi;
11491
11492 if (bgp_parse_safi(argv[0], &safi)) {
11493 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11494 return CMD_WARNING;
11495 }
11496 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011497 bgp_show_type_flap_prefix);
11498}
Balaji3921cc52015-05-16 23:12:17 +053011499
Lou Berger651b4022016-01-12 13:42:07 -050011500ALIAS (show_bgp_ipv4_safi_flap_prefix,
11501 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
11502 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053011503 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011504 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011505 "Address family\n"
11506 "Address Family modifier\n"
11507 "Address Family modifier\n"
11508 "Address Family modifier\n"
11509 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011510 "Display detailed information about dampening\n"
11511 "Display flap statistics of routes\n"
11512 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11513
Lou Berger651b4022016-01-12 13:42:07 -050011514DEFUN (show_bgp_ipv6_safi_flap_prefix,
11515 show_bgp_ipv6_safi_flap_prefix_cmd,
11516 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000011517 SHOW_STR
11518 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"
11524 "Display flap statistics of routes\n"
11525 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000011526{
Lou Berger651b4022016-01-12 13:42:07 -050011527 safi_t safi;
11528
11529 if (bgp_parse_safi(argv[0], &safi)) {
11530 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11531 return CMD_WARNING;
11532 }
11533 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
11534 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000011535}
11536
Lou Berger651b4022016-01-12 13:42:07 -050011537ALIAS (show_bgp_ipv6_safi_flap_prefix,
11538 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
11539 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
11540 SHOW_STR
11541 BGP_STR
11542 "Address family\n"
11543 "Address Family modifier\n"
11544 "Address Family modifier\n"
11545 "Address Family modifier\n"
11546 "Address Family modifier\n"
11547 "Display detailed information about dampening\n"
11548 "Display flap statistics of routes\n"
11549 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11550
11551DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000011552 show_bgp_ipv6_prefix_longer_cmd,
11553 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11554 SHOW_STR
11555 BGP_STR
11556 "Address family\n"
11557 "IPv6 prefix <network>/<length>\n"
11558 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000011559{
11560 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11561 bgp_show_type_prefix_longer);
11562}
11563
paul94f2b392005-06-28 12:44:16 +000011564static struct peer *
paulfd79ac92004-10-13 05:06:08 +000011565peer_lookup_in_view (struct vty *vty, const char *view_name,
11566 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000011567{
11568 int ret;
11569 struct bgp *bgp;
11570 struct peer *peer;
11571 union sockunion su;
11572
11573 /* BGP structure lookup. */
11574 if (view_name)
11575 {
11576 bgp = bgp_lookup_by_name (view_name);
11577 if (! bgp)
11578 {
11579 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11580 return NULL;
11581 }
11582 }
paul5228ad22004-06-04 17:58:18 +000011583 else
paulbb46e942003-10-24 19:02:03 +000011584 {
11585 bgp = bgp_get_default ();
11586 if (! bgp)
11587 {
11588 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11589 return NULL;
11590 }
11591 }
11592
11593 /* Get peer sockunion. */
11594 ret = str2sockunion (ip_str, &su);
11595 if (ret < 0)
11596 {
11597 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
11598 return NULL;
11599 }
11600
11601 /* Peer structure lookup. */
11602 peer = peer_lookup (bgp, &su);
11603 if (! peer)
11604 {
11605 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
11606 return NULL;
11607 }
11608
11609 return peer;
11610}
David Lamparter6b0655a2014-06-04 06:53:35 +020011611
Paul Jakma2815e612006-09-14 02:56:07 +000011612enum bgp_stats
11613{
11614 BGP_STATS_MAXBITLEN = 0,
11615 BGP_STATS_RIB,
11616 BGP_STATS_PREFIXES,
11617 BGP_STATS_TOTPLEN,
11618 BGP_STATS_UNAGGREGATEABLE,
11619 BGP_STATS_MAX_AGGREGATEABLE,
11620 BGP_STATS_AGGREGATES,
11621 BGP_STATS_SPACE,
11622 BGP_STATS_ASPATH_COUNT,
11623 BGP_STATS_ASPATH_MAXHOPS,
11624 BGP_STATS_ASPATH_TOTHOPS,
11625 BGP_STATS_ASPATH_MAXSIZE,
11626 BGP_STATS_ASPATH_TOTSIZE,
11627 BGP_STATS_ASN_HIGHEST,
11628 BGP_STATS_MAX,
11629};
paulbb46e942003-10-24 19:02:03 +000011630
Paul Jakma2815e612006-09-14 02:56:07 +000011631static const char *table_stats_strs[] =
11632{
11633 [BGP_STATS_PREFIXES] = "Total Prefixes",
11634 [BGP_STATS_TOTPLEN] = "Average prefix length",
11635 [BGP_STATS_RIB] = "Total Advertisements",
11636 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
11637 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
11638 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
11639 [BGP_STATS_SPACE] = "Address space advertised",
11640 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
11641 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
11642 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
11643 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
11644 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
11645 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
11646 [BGP_STATS_MAX] = NULL,
11647};
11648
11649struct bgp_table_stats
11650{
11651 struct bgp_table *table;
11652 unsigned long long counts[BGP_STATS_MAX];
11653};
11654
11655#if 0
11656#define TALLY_SIGFIG 100000
11657static unsigned long
11658ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
11659{
11660 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
11661 unsigned long res = (newtot * TALLY_SIGFIG) / count;
11662 unsigned long ret = newtot / count;
11663
11664 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
11665 return ret + 1;
11666 else
11667 return ret;
11668}
11669#endif
11670
11671static int
11672bgp_table_stats_walker (struct thread *t)
11673{
11674 struct bgp_node *rn;
11675 struct bgp_node *top;
11676 struct bgp_table_stats *ts = THREAD_ARG (t);
11677 unsigned int space = 0;
11678
Paul Jakma53d9f672006-10-15 23:41:16 +000011679 if (!(top = bgp_table_top (ts->table)))
11680 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000011681
11682 switch (top->p.family)
11683 {
11684 case AF_INET:
11685 space = IPV4_MAX_BITLEN;
11686 break;
11687 case AF_INET6:
11688 space = IPV6_MAX_BITLEN;
11689 break;
11690 }
11691
11692 ts->counts[BGP_STATS_MAXBITLEN] = space;
11693
11694 for (rn = top; rn; rn = bgp_route_next (rn))
11695 {
11696 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070011697 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000011698 unsigned int rinum = 0;
11699
11700 if (rn == top)
11701 continue;
11702
11703 if (!rn->info)
11704 continue;
11705
11706 ts->counts[BGP_STATS_PREFIXES]++;
11707 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
11708
11709#if 0
11710 ts->counts[BGP_STATS_AVGPLEN]
11711 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
11712 ts->counts[BGP_STATS_AVGPLEN],
11713 rn->p.prefixlen);
11714#endif
11715
11716 /* check if the prefix is included by any other announcements */
11717 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070011718 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000011719
11720 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000011721 {
11722 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
11723 /* announced address space */
11724 if (space)
11725 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
11726 }
Paul Jakma2815e612006-09-14 02:56:07 +000011727 else if (prn->info)
11728 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
11729
Paul Jakma2815e612006-09-14 02:56:07 +000011730 for (ri = rn->info; ri; ri = ri->next)
11731 {
11732 rinum++;
11733 ts->counts[BGP_STATS_RIB]++;
11734
11735 if (ri->attr &&
11736 (CHECK_FLAG (ri->attr->flag,
11737 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
11738 ts->counts[BGP_STATS_AGGREGATES]++;
11739
11740 /* as-path stats */
11741 if (ri->attr && ri->attr->aspath)
11742 {
11743 unsigned int hops = aspath_count_hops (ri->attr->aspath);
11744 unsigned int size = aspath_size (ri->attr->aspath);
11745 as_t highest = aspath_highest (ri->attr->aspath);
11746
11747 ts->counts[BGP_STATS_ASPATH_COUNT]++;
11748
11749 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
11750 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
11751
11752 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
11753 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
11754
11755 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
11756 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
11757#if 0
11758 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
11759 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11760 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
11761 hops);
11762 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
11763 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11764 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
11765 size);
11766#endif
11767 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
11768 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
11769 }
11770 }
11771 }
11772 return 0;
11773}
11774
11775static int
11776bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
11777{
11778 struct bgp_table_stats ts;
11779 unsigned int i;
11780
11781 if (!bgp->rib[afi][safi])
11782 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011783 vty_out (vty, "%% No RIB exists for the AFI/SAFI%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011784 return CMD_WARNING;
11785 }
11786
11787 memset (&ts, 0, sizeof (ts));
11788 ts.table = bgp->rib[afi][safi];
11789 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
11790
11791 vty_out (vty, "BGP %s RIB statistics%s%s",
11792 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
11793
11794 for (i = 0; i < BGP_STATS_MAX; i++)
11795 {
11796 if (!table_stats_strs[i])
11797 continue;
11798
11799 switch (i)
11800 {
11801#if 0
11802 case BGP_STATS_ASPATH_AVGHOPS:
11803 case BGP_STATS_ASPATH_AVGSIZE:
11804 case BGP_STATS_AVGPLEN:
11805 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11806 vty_out (vty, "%12.2f",
11807 (float)ts.counts[i] / (float)TALLY_SIGFIG);
11808 break;
11809#endif
11810 case BGP_STATS_ASPATH_TOTHOPS:
11811 case BGP_STATS_ASPATH_TOTSIZE:
11812 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11813 vty_out (vty, "%12.2f",
11814 ts.counts[i] ?
11815 (float)ts.counts[i] /
11816 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
11817 : 0);
11818 break;
11819 case BGP_STATS_TOTPLEN:
11820 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11821 vty_out (vty, "%12.2f",
11822 ts.counts[i] ?
11823 (float)ts.counts[i] /
11824 (float)ts.counts[BGP_STATS_PREFIXES]
11825 : 0);
11826 break;
11827 case BGP_STATS_SPACE:
11828 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11829 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
11830 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
11831 break;
Paul Jakma30a22312008-08-15 14:05:22 +010011832 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000011833 vty_out (vty, "%12.2f%s",
11834 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000011835 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000011836 VTY_NEWLINE);
11837 vty_out (vty, "%30s: ", "/8 equivalent ");
11838 vty_out (vty, "%12.2f%s",
11839 (float)ts.counts[BGP_STATS_SPACE] /
11840 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
11841 VTY_NEWLINE);
11842 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
11843 break;
11844 vty_out (vty, "%30s: ", "/24 equivalent ");
11845 vty_out (vty, "%12.2f",
11846 (float)ts.counts[BGP_STATS_SPACE] /
11847 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
11848 break;
11849 default:
11850 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11851 vty_out (vty, "%12llu", ts.counts[i]);
11852 }
11853
11854 vty_out (vty, "%s", VTY_NEWLINE);
11855 }
11856 return CMD_SUCCESS;
11857}
11858
11859static int
11860bgp_table_stats_vty (struct vty *vty, const char *name,
11861 const char *afi_str, const char *safi_str)
11862{
11863 struct bgp *bgp;
11864 afi_t afi;
11865 safi_t safi;
11866
11867 if (name)
11868 bgp = bgp_lookup_by_name (name);
11869 else
11870 bgp = bgp_get_default ();
11871
11872 if (!bgp)
11873 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011874 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011875 return CMD_WARNING;
11876 }
11877 if (strncmp (afi_str, "ipv", 3) == 0)
11878 {
11879 if (strncmp (afi_str, "ipv4", 4) == 0)
11880 afi = AFI_IP;
11881 else if (strncmp (afi_str, "ipv6", 4) == 0)
11882 afi = AFI_IP6;
11883 else
11884 {
11885 vty_out (vty, "%% Invalid address family %s%s",
11886 afi_str, VTY_NEWLINE);
11887 return CMD_WARNING;
11888 }
Lou Berger298cc2f2016-01-12 13:42:02 -050011889 switch (safi_str[0]) {
11890 case 'm':
11891 safi = SAFI_MULTICAST;
11892 break;
11893 case 'u':
11894 safi = SAFI_UNICAST;
11895 break;
11896 case 'v':
11897 safi = SAFI_MPLS_LABELED_VPN;
11898 break;
11899 case 'e':
11900 safi = SAFI_ENCAP;
11901 break;
11902 default:
11903 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011904 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050011905 return CMD_WARNING;
11906 }
Paul Jakma2815e612006-09-14 02:56:07 +000011907 }
11908 else
11909 {
Lou Berger298cc2f2016-01-12 13:42:02 -050011910 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011911 afi_str, VTY_NEWLINE);
11912 return CMD_WARNING;
11913 }
11914
Paul Jakma2815e612006-09-14 02:56:07 +000011915 return bgp_table_stats (vty, bgp, afi, safi);
11916}
11917
11918DEFUN (show_bgp_statistics,
11919 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011920 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011921 SHOW_STR
11922 BGP_STR
11923 "Address family\n"
11924 "Address family\n"
11925 "Address Family modifier\n"
11926 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011927 "Address Family modifier\n"
11928 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011929 "BGP RIB advertisement statistics\n")
11930{
11931 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11932}
11933
Lou Bergerf9b6c392016-01-12 13:42:09 -050011934ALIAS (show_bgp_statistics,
11935 show_bgp_statistics_vpnv4_cmd,
11936 "show bgp (ipv4) (vpnv4) statistics",
11937 SHOW_STR
11938 BGP_STR
11939 "Address family\n"
11940 "Address Family modifier\n"
11941 "BGP RIB advertisement statistics\n")
11942
Paul Jakma2815e612006-09-14 02:56:07 +000011943DEFUN (show_bgp_statistics_view,
11944 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011945 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011946 SHOW_STR
11947 BGP_STR
11948 "BGP view\n"
11949 "Address family\n"
11950 "Address family\n"
11951 "Address Family modifier\n"
11952 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011953 "Address Family modifier\n"
11954 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011955 "BGP RIB advertisement statistics\n")
11956{
11957 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11958}
11959
11960ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011961 show_bgp_statistics_view_vpnv4_cmd,
11962 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011963 SHOW_STR
11964 BGP_STR
11965 "BGP view\n"
11966 "Address family\n"
11967 "Address Family modifier\n"
11968 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020011969
Paul Jakmaff7924f2006-09-04 01:10:36 +000011970enum bgp_pcounts
11971{
11972 PCOUNT_ADJ_IN = 0,
11973 PCOUNT_DAMPED,
11974 PCOUNT_REMOVED,
11975 PCOUNT_HISTORY,
11976 PCOUNT_STALE,
11977 PCOUNT_VALID,
11978 PCOUNT_ALL,
11979 PCOUNT_COUNTED,
11980 PCOUNT_PFCNT, /* the figure we display to users */
11981 PCOUNT_MAX,
11982};
11983
11984static const char *pcount_strs[] =
11985{
11986 [PCOUNT_ADJ_IN] = "Adj-in",
11987 [PCOUNT_DAMPED] = "Damped",
11988 [PCOUNT_REMOVED] = "Removed",
11989 [PCOUNT_HISTORY] = "History",
11990 [PCOUNT_STALE] = "Stale",
11991 [PCOUNT_VALID] = "Valid",
11992 [PCOUNT_ALL] = "All RIB",
11993 [PCOUNT_COUNTED] = "PfxCt counted",
11994 [PCOUNT_PFCNT] = "Useable",
11995 [PCOUNT_MAX] = NULL,
11996};
11997
Paul Jakma2815e612006-09-14 02:56:07 +000011998struct peer_pcounts
11999{
12000 unsigned int count[PCOUNT_MAX];
12001 const struct peer *peer;
12002 const struct bgp_table *table;
12003};
12004
Paul Jakmaff7924f2006-09-04 01:10:36 +000012005static int
Paul Jakma2815e612006-09-14 02:56:07 +000012006bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000012007{
12008 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000012009 struct peer_pcounts *pc = THREAD_ARG (t);
12010 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012011
Paul Jakma2815e612006-09-14 02:56:07 +000012012 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012013 {
12014 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000012015 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012016
12017 for (ain = rn->adj_in; ain; ain = ain->next)
12018 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000012019 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012020
Paul Jakmaff7924f2006-09-04 01:10:36 +000012021 for (ri = rn->info; ri; ri = ri->next)
12022 {
12023 char buf[SU_ADDRSTRLEN];
12024
12025 if (ri->peer != peer)
12026 continue;
12027
Paul Jakma2815e612006-09-14 02:56:07 +000012028 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012029
12030 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000012031 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012032 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000012033 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012034 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000012035 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012036 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000012037 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012038 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000012039 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012040 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000012041 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012042
12043 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
12044 {
Paul Jakma2815e612006-09-14 02:56:07 +000012045 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012046 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012047 plog_warn (peer->log,
12048 "%s [pcount] %s/%d is counted but flags 0x%x",
12049 peer->host,
12050 inet_ntop(rn->p.family, &rn->p.u.prefix,
12051 buf, SU_ADDRSTRLEN),
12052 rn->p.prefixlen,
12053 ri->flags);
12054 }
12055 else
12056 {
Paul Jakma1a392d42006-09-07 00:24:49 +000012057 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012058 plog_warn (peer->log,
12059 "%s [pcount] %s/%d not counted but flags 0x%x",
12060 peer->host,
12061 inet_ntop(rn->p.family, &rn->p.u.prefix,
12062 buf, SU_ADDRSTRLEN),
12063 rn->p.prefixlen,
12064 ri->flags);
12065 }
12066 }
12067 }
Paul Jakma2815e612006-09-14 02:56:07 +000012068 return 0;
12069}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012070
Paul Jakma2815e612006-09-14 02:56:07 +000012071static int
12072bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
12073{
12074 struct peer_pcounts pcounts = { .peer = peer };
12075 unsigned int i;
12076
12077 if (!peer || !peer->bgp || !peer->afc[afi][safi]
12078 || !peer->bgp->rib[afi][safi])
12079 {
12080 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12081 return CMD_WARNING;
12082 }
12083
12084 memset (&pcounts, 0, sizeof(pcounts));
12085 pcounts.peer = peer;
12086 pcounts.table = peer->bgp->rib[afi][safi];
12087
12088 /* in-place call via thread subsystem so as to record execution time
12089 * stats for the thread-walk (i.e. ensure this can't be blamed on
12090 * on just vty_read()).
12091 */
12092 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
12093
Paul Jakmaff7924f2006-09-04 01:10:36 +000012094 vty_out (vty, "Prefix counts for %s, %s%s",
12095 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
12096 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
12097 vty_out (vty, "%sCounts from RIB table walk:%s%s",
12098 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12099
12100 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000012101 vty_out (vty, "%20s: %-10d%s",
12102 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012103
Paul Jakma2815e612006-09-14 02:56:07 +000012104 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000012105 {
12106 vty_out (vty, "%s [pcount] PfxCt drift!%s",
12107 peer->host, VTY_NEWLINE);
12108 vty_out (vty, "Please report this bug, with the above command output%s",
12109 VTY_NEWLINE);
12110 }
12111
12112 return CMD_SUCCESS;
12113}
12114
Lou Bergerf9b6c392016-01-12 13:42:09 -050012115DEFUN (show_ip_bgp_neighbor_prefix_counts,
12116 show_ip_bgp_neighbor_prefix_counts_cmd,
12117 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12118 SHOW_STR
12119 IP_STR
12120 BGP_STR
12121 "Detailed information on TCP and BGP neighbor connections\n"
12122 "Neighbor to display information about\n"
12123 "Neighbor to display information about\n"
12124 "Display detailed prefix count information\n")
12125{
12126 struct peer *peer;
12127
12128 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12129 if (! peer)
12130 return CMD_WARNING;
12131
12132 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12133}
12134
Paul Jakmaff7924f2006-09-04 01:10:36 +000012135DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
12136 show_bgp_ipv6_neighbor_prefix_counts_cmd,
12137 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12138 SHOW_STR
12139 BGP_STR
12140 "Address family\n"
12141 "Detailed information on TCP and BGP neighbor connections\n"
12142 "Neighbor to display information about\n"
12143 "Neighbor to display information about\n"
12144 "Display detailed prefix count information\n")
12145{
12146 struct peer *peer;
12147
12148 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12149 if (! peer)
12150 return CMD_WARNING;
12151
12152 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
12153}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012154
12155DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
12156 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
12157 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12158 SHOW_STR
12159 IP_STR
12160 BGP_STR
12161 "Address family\n"
12162 "Address Family modifier\n"
12163 "Address Family modifier\n"
12164 "Detailed information on TCP and BGP neighbor connections\n"
12165 "Neighbor to display information about\n"
12166 "Neighbor to display information about\n"
12167 "Display detailed prefix count information\n")
12168{
12169 struct peer *peer;
12170
12171 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12172 if (! peer)
12173 return CMD_WARNING;
12174
12175 if (strncmp (argv[0], "m", 1) == 0)
12176 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
12177
12178 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12179}
12180
12181DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
12182 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
12183 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12184 SHOW_STR
12185 IP_STR
12186 BGP_STR
12187 "Address family\n"
12188 "Address Family modifier\n"
12189 "Address Family modifier\n"
12190 "Detailed information on TCP and BGP neighbor connections\n"
12191 "Neighbor to display information about\n"
12192 "Neighbor to display information about\n"
12193 "Display detailed prefix count information\n")
12194{
12195 struct peer *peer;
12196
12197 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12198 if (! peer)
12199 return CMD_WARNING;
12200
12201 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
12202}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012203
Lou Berger651b4022016-01-12 13:42:07 -050012204DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
12205 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
12206 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012207 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000012208 BGP_STR
12209 "Address family\n"
12210 "Address Family modifier\n"
12211 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012212 "Address Family modifier\n"
12213 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000012214 "Detailed information on TCP and BGP neighbor connections\n"
12215 "Neighbor to display information about\n"
12216 "Neighbor to display information about\n"
12217 "Display detailed prefix count information\n")
12218{
12219 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012220 safi_t safi;
12221
12222 if (bgp_parse_safi(argv[0], &safi)) {
12223 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12224 return CMD_WARNING;
12225 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000012226
12227 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12228 if (! peer)
12229 return CMD_WARNING;
12230
Lou Berger651b4022016-01-12 13:42:07 -050012231 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012232}
Lou Berger205e6742016-01-12 13:42:11 -050012233
Lou Berger651b4022016-01-12 13:42:07 -050012234DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
12235 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
12236 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12237 SHOW_STR
12238 BGP_STR
12239 "Address family\n"
12240 "Address Family modifier\n"
12241 "Address Family modifier\n"
12242 "Address Family modifier\n"
12243 "Address Family modifier\n"
12244 "Detailed information on TCP and BGP neighbor connections\n"
12245 "Neighbor to display information about\n"
12246 "Neighbor to display information about\n"
12247 "Display detailed prefix count information\n")
12248{
12249 struct peer *peer;
12250 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012251
Lou Berger651b4022016-01-12 13:42:07 -050012252 if (bgp_parse_safi(argv[0], &safi)) {
12253 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12254 return CMD_WARNING;
12255 }
12256
12257 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12258 if (! peer)
12259 return CMD_WARNING;
12260
12261 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
12262}
Lou Berger651b4022016-01-12 13:42:07 -050012263
12264DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
12265 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
12266 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012267 SHOW_STR
12268 IP_STR
12269 BGP_STR
12270 "Address family\n"
12271 "Address Family modifier\n"
12272 "Address Family modifier\n"
12273 "Detailed information on TCP and BGP neighbor connections\n"
12274 "Neighbor to display information about\n"
12275 "Neighbor to display information about\n"
12276 "Display detailed prefix count information\n")
12277{
12278 struct peer *peer;
12279
12280 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12281 if (! peer)
12282 return CMD_WARNING;
12283
Lou Berger651b4022016-01-12 13:42:07 -050012284 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012285}
12286
12287
paul94f2b392005-06-28 12:44:16 +000012288static void
paul718e3742002-12-13 20:15:29 +000012289show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
12290 int in)
12291{
12292 struct bgp_table *table;
12293 struct bgp_adj_in *ain;
12294 struct bgp_adj_out *adj;
12295 unsigned long output_count;
12296 struct bgp_node *rn;
12297 int header1 = 1;
12298 struct bgp *bgp;
12299 int header2 = 1;
12300
paulbb46e942003-10-24 19:02:03 +000012301 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000012302
12303 if (! bgp)
12304 return;
12305
12306 table = bgp->rib[afi][safi];
12307
12308 output_count = 0;
12309
12310 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
12311 PEER_STATUS_DEFAULT_ORIGINATE))
12312 {
12313 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 +000012314 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12315 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012316
12317 vty_out (vty, "Originating default network 0.0.0.0%s%s",
12318 VTY_NEWLINE, VTY_NEWLINE);
12319 header1 = 0;
12320 }
12321
12322 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
12323 if (in)
12324 {
12325 for (ain = rn->adj_in; ain; ain = ain->next)
12326 if (ain->peer == peer)
12327 {
12328 if (header1)
12329 {
12330 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 +000012331 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12332 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012333 header1 = 0;
12334 }
12335 if (header2)
12336 {
12337 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12338 header2 = 0;
12339 }
12340 if (ain->attr)
12341 {
12342 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
12343 output_count++;
12344 }
12345 }
12346 }
12347 else
12348 {
12349 for (adj = rn->adj_out; adj; adj = adj->next)
12350 if (adj->peer == peer)
12351 {
12352 if (header1)
12353 {
12354 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 +000012355 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12356 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012357 header1 = 0;
12358 }
12359 if (header2)
12360 {
12361 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12362 header2 = 0;
12363 }
12364 if (adj->attr)
12365 {
12366 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
12367 output_count++;
12368 }
12369 }
12370 }
12371
12372 if (output_count != 0)
12373 vty_out (vty, "%sTotal number of prefixes %ld%s",
12374 VTY_NEWLINE, output_count, VTY_NEWLINE);
12375}
12376
paul94f2b392005-06-28 12:44:16 +000012377static int
paulbb46e942003-10-24 19:02:03 +000012378peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
12379{
paul718e3742002-12-13 20:15:29 +000012380 if (! peer || ! peer->afc[afi][safi])
12381 {
12382 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12383 return CMD_WARNING;
12384 }
12385
12386 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
12387 {
12388 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
12389 VTY_NEWLINE);
12390 return CMD_WARNING;
12391 }
12392
12393 show_adj_route (vty, peer, afi, safi, in);
12394
12395 return CMD_SUCCESS;
12396}
12397
Lou Bergerf9b6c392016-01-12 13:42:09 -050012398DEFUN (show_ip_bgp_view_neighbor_advertised_route,
12399 show_ip_bgp_view_neighbor_advertised_route_cmd,
12400 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12401 SHOW_STR
12402 IP_STR
12403 BGP_STR
12404 "BGP view\n"
12405 "View name\n"
12406 "Detailed information on TCP and BGP neighbor connections\n"
12407 "Neighbor to display information about\n"
12408 "Neighbor to display information about\n"
12409 "Display the routes advertised to a BGP neighbor\n")
12410{
12411 struct peer *peer;
12412
12413 if (argc == 2)
12414 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12415 else
12416 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12417
12418 if (! peer)
12419 return CMD_WARNING;
12420
12421 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12422}
12423
12424ALIAS (show_ip_bgp_view_neighbor_advertised_route,
12425 show_ip_bgp_neighbor_advertised_route_cmd,
12426 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12427 SHOW_STR
12428 IP_STR
12429 BGP_STR
12430 "Detailed information on TCP and BGP neighbor connections\n"
12431 "Neighbor to display information about\n"
12432 "Neighbor to display information about\n"
12433 "Display the routes advertised to a BGP neighbor\n")
12434
12435DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
12436 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
12437 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12438 SHOW_STR
12439 IP_STR
12440 BGP_STR
12441 "Address family\n"
12442 "Address Family modifier\n"
12443 "Address Family modifier\n"
12444 "Detailed information on TCP and BGP neighbor connections\n"
12445 "Neighbor to display information about\n"
12446 "Neighbor to display information about\n"
12447 "Display the routes advertised to a BGP neighbor\n")
12448{
12449 struct peer *peer;
12450
12451 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12452 if (! peer)
12453 return CMD_WARNING;
12454
12455 if (strncmp (argv[0], "m", 1) == 0)
12456 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
12457
12458 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12459}
12460
Lou Bergerf9b6c392016-01-12 13:42:09 -050012461DEFUN (show_bgp_view_neighbor_advertised_route,
12462 show_bgp_view_neighbor_advertised_route_cmd,
12463 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12464 SHOW_STR
12465 BGP_STR
12466 "BGP view\n"
12467 "View name\n"
12468 "Detailed information on TCP and BGP neighbor connections\n"
12469 "Neighbor to display information about\n"
12470 "Neighbor to display information about\n"
12471 "Display the routes advertised to a BGP neighbor\n")
12472{
12473 struct peer *peer;
12474
12475 if (argc == 2)
12476 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12477 else
12478 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12479
12480 if (! peer)
12481 return CMD_WARNING;
12482
12483 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12484}
12485
12486DEFUN (show_bgp_view_neighbor_received_routes,
12487 show_bgp_view_neighbor_received_routes_cmd,
12488 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12489 SHOW_STR
12490 BGP_STR
12491 "BGP view\n"
12492 "View name\n"
12493 "Detailed information on TCP and BGP neighbor connections\n"
12494 "Neighbor to display information about\n"
12495 "Neighbor to display information about\n"
12496 "Display the received routes from neighbor\n")
12497{
12498 struct peer *peer;
12499
12500 if (argc == 2)
12501 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12502 else
12503 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12504
12505 if (! peer)
12506 return CMD_WARNING;
12507
12508 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12509}
12510
12511ALIAS (show_bgp_view_neighbor_advertised_route,
12512 show_bgp_neighbor_advertised_route_cmd,
12513 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12514 SHOW_STR
12515 BGP_STR
12516 "Detailed information on TCP and BGP neighbor connections\n"
12517 "Neighbor to display information about\n"
12518 "Neighbor to display information about\n"
12519 "Display the routes advertised to a BGP neighbor\n")
12520
12521ALIAS (show_bgp_view_neighbor_advertised_route,
12522 show_bgp_ipv6_neighbor_advertised_route_cmd,
12523 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12524 SHOW_STR
12525 BGP_STR
12526 "Address family\n"
12527 "Detailed information on TCP and BGP neighbor connections\n"
12528 "Neighbor to display information about\n"
12529 "Neighbor to display information about\n"
12530 "Display the routes advertised to a BGP neighbor\n")
12531
12532/* old command */
12533ALIAS (show_bgp_view_neighbor_advertised_route,
12534 ipv6_bgp_neighbor_advertised_route_cmd,
12535 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12536 SHOW_STR
12537 IPV6_STR
12538 BGP_STR
12539 "Detailed information on TCP and BGP neighbor connections\n"
12540 "Neighbor to display information about\n"
12541 "Neighbor to display information about\n"
12542 "Display the routes advertised to a BGP neighbor\n")
12543
12544/* old command */
12545DEFUN (ipv6_mbgp_neighbor_advertised_route,
12546 ipv6_mbgp_neighbor_advertised_route_cmd,
12547 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12548 SHOW_STR
12549 IPV6_STR
12550 MBGP_STR
12551 "Detailed information on TCP and BGP neighbor connections\n"
12552 "Neighbor to display information about\n"
12553 "Neighbor to display information about\n"
12554 "Display the routes advertised to a BGP neighbor\n")
12555{
12556 struct peer *peer;
12557
12558 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12559 if (! peer)
12560 return CMD_WARNING;
12561
12562 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
12563}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012564
12565DEFUN (show_ip_bgp_view_neighbor_received_routes,
12566 show_ip_bgp_view_neighbor_received_routes_cmd,
12567 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12568 SHOW_STR
12569 IP_STR
12570 BGP_STR
12571 "BGP view\n"
12572 "View name\n"
12573 "Detailed information on TCP and BGP neighbor connections\n"
12574 "Neighbor to display information about\n"
12575 "Neighbor to display information about\n"
12576 "Display the received routes from neighbor\n")
12577{
12578 struct peer *peer;
12579
12580 if (argc == 2)
12581 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12582 else
12583 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12584
12585 if (! peer)
12586 return CMD_WARNING;
12587
12588 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12589}
12590
12591ALIAS (show_ip_bgp_view_neighbor_received_routes,
12592 show_ip_bgp_neighbor_received_routes_cmd,
12593 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12594 SHOW_STR
12595 IP_STR
12596 BGP_STR
12597 "Detailed information on TCP and BGP neighbor connections\n"
12598 "Neighbor to display information about\n"
12599 "Neighbor to display information about\n"
12600 "Display the received routes from neighbor\n")
12601
12602ALIAS (show_bgp_view_neighbor_received_routes,
12603 show_bgp_ipv6_neighbor_received_routes_cmd,
12604 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
12605 SHOW_STR
12606 BGP_STR
12607 "Address family\n"
12608 "Detailed information on TCP and BGP neighbor connections\n"
12609 "Neighbor to display information about\n"
12610 "Neighbor to display information about\n"
12611 "Display the received routes from neighbor\n")
12612
12613DEFUN (show_bgp_neighbor_received_prefix_filter,
12614 show_bgp_neighbor_received_prefix_filter_cmd,
12615 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12616 SHOW_STR
12617 BGP_STR
12618 "Detailed information on TCP and BGP neighbor connections\n"
12619 "Neighbor to display information about\n"
12620 "Neighbor to display information about\n"
12621 "Display information received from a BGP neighbor\n"
12622 "Display the prefixlist filter\n")
12623{
12624 char name[BUFSIZ];
12625 union sockunion su;
12626 struct peer *peer;
12627 int count, ret;
12628
12629 ret = str2sockunion (argv[0], &su);
12630 if (ret < 0)
12631 {
12632 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12633 return CMD_WARNING;
12634 }
12635
12636 peer = peer_lookup (NULL, &su);
12637 if (! peer)
12638 return CMD_WARNING;
12639
12640 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12641 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12642 if (count)
12643 {
12644 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12645 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12646 }
12647
12648 return CMD_SUCCESS;
12649}
12650
12651/* old command */
12652ALIAS (show_bgp_view_neighbor_received_routes,
12653 ipv6_bgp_neighbor_received_routes_cmd,
12654 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12655 SHOW_STR
12656 IPV6_STR
12657 BGP_STR
12658 "Detailed information on TCP and BGP neighbor connections\n"
12659 "Neighbor to display information about\n"
12660 "Neighbor to display information about\n"
12661 "Display the received routes from neighbor\n")
12662
12663/* old command */
12664DEFUN (ipv6_mbgp_neighbor_received_routes,
12665 ipv6_mbgp_neighbor_received_routes_cmd,
12666 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12667 SHOW_STR
12668 IPV6_STR
12669 MBGP_STR
12670 "Detailed information on TCP and BGP neighbor connections\n"
12671 "Neighbor to display information about\n"
12672 "Neighbor to display information about\n"
12673 "Display the received routes from neighbor\n")
12674{
12675 struct peer *peer;
12676
12677 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12678 if (! peer)
12679 return CMD_WARNING;
12680
12681 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
12682}
12683
12684DEFUN (show_bgp_view_neighbor_received_prefix_filter,
12685 show_bgp_view_neighbor_received_prefix_filter_cmd,
12686 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12687 SHOW_STR
12688 BGP_STR
12689 "BGP view\n"
12690 "View name\n"
12691 "Detailed information on TCP and BGP neighbor connections\n"
12692 "Neighbor to display information about\n"
12693 "Neighbor to display information about\n"
12694 "Display information received from a BGP neighbor\n"
12695 "Display the prefixlist filter\n")
12696{
12697 char name[BUFSIZ];
12698 union sockunion su;
12699 struct peer *peer;
12700 struct bgp *bgp;
12701 int count, ret;
12702
12703 /* BGP structure lookup. */
12704 bgp = bgp_lookup_by_name (argv[0]);
12705 if (bgp == NULL)
12706 {
12707 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
12708 return CMD_WARNING;
12709 }
12710
12711 ret = str2sockunion (argv[1], &su);
12712 if (ret < 0)
12713 {
12714 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
12715 return CMD_WARNING;
12716 }
12717
12718 peer = peer_lookup (bgp, &su);
12719 if (! peer)
12720 return CMD_WARNING;
12721
12722 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12723 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12724 if (count)
12725 {
12726 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12727 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12728 }
12729
12730 return CMD_SUCCESS;
12731}
12732
12733
12734DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
12735 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
12736 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
12737 SHOW_STR
12738 IP_STR
12739 BGP_STR
12740 "Address family\n"
12741 "Address Family modifier\n"
12742 "Address Family modifier\n"
12743 "Detailed information on TCP and BGP neighbor connections\n"
12744 "Neighbor to display information about\n"
12745 "Neighbor to display information about\n"
12746 "Display the received routes from neighbor\n")
12747{
12748 struct peer *peer;
12749
12750 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12751 if (! peer)
12752 return CMD_WARNING;
12753
12754 if (strncmp (argv[0], "m", 1) == 0)
12755 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
12756
12757 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12758}
12759
Lou Berger651b4022016-01-12 13:42:07 -050012760DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
12761 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
12762 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012763 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012764 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012765 "Address Family modifier\n"
12766 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012767 "Detailed information on TCP and BGP neighbor connections\n"
12768 "Neighbor to display information about\n"
12769 "Neighbor to display information about\n"
12770 "Display the routes advertised to a BGP neighbor\n")
12771{
12772 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012773 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012774
Lou Berger651b4022016-01-12 13:42:07 -050012775 if (bgp_parse_safi(argv[0], &safi)) {
12776 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012777 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050012778 }
paul718e3742002-12-13 20:15:29 +000012779
paulbb46e942003-10-24 19:02:03 +000012780 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12781 if (! peer)
12782 return CMD_WARNING;
12783
Lou Berger651b4022016-01-12 13:42:07 -050012784 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
12785}
Lou Berger205e6742016-01-12 13:42:11 -050012786
Lou Berger651b4022016-01-12 13:42:07 -050012787DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
12788 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
12789 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12790 SHOW_STR
12791 BGP_STR
12792 "Address Family modifier\n"
12793 "Address Family modifier\n"
12794 "Address Family modifier\n"
12795 "Detailed information on TCP and BGP neighbor connections\n"
12796 "Neighbor to display information about\n"
12797 "Neighbor to display information about\n"
12798 "Display the routes advertised to a BGP neighbor\n")
12799{
12800 struct peer *peer;
12801 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000012802
Lou Berger651b4022016-01-12 13:42:07 -050012803 if (bgp_parse_safi(argv[0], &safi)) {
12804 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12805 return CMD_WARNING;
12806 }
12807
12808 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12809 if (! peer)
12810 return CMD_WARNING;
12811
12812 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000012813}
12814
Lou Bergerf9b6c392016-01-12 13:42:09 -050012815DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050012816 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
12817 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000012818 SHOW_STR
12819 BGP_STR
12820 "BGP view\n"
12821 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050012822 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000012823 "Detailed information on TCP and BGP neighbor connections\n"
12824 "Neighbor to display information about\n"
12825 "Neighbor to display information about\n"
12826 "Display the routes advertised to a BGP neighbor\n")
12827{
12828 struct peer *peer;
12829
12830 if (argc == 2)
12831 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12832 else
12833 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12834
12835 if (! peer)
12836 return CMD_WARNING;
12837
12838 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12839}
12840
Lou Bergerf9b6c392016-01-12 13:42:09 -050012841DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050012842 show_bgp_view_ipv6_neighbor_received_routes_cmd,
12843 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000012844 SHOW_STR
12845 BGP_STR
12846 "BGP view\n"
12847 "View name\n"
12848 "Address family\n"
12849 "Detailed information on TCP and BGP neighbor connections\n"
12850 "Neighbor to display information about\n"
12851 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000012852 "Display the received routes from neighbor\n")
12853{
12854 struct peer *peer;
12855
12856 if (argc == 2)
12857 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12858 else
12859 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12860
12861 if (! peer)
12862 return CMD_WARNING;
12863
12864 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12865}
Lou Berger651b4022016-01-12 13:42:07 -050012866
12867DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
12868 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
12869 "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 +010012870 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012871 BGP_STR
12872 "Address family\n"
12873 "Address Family modifier\n"
12874 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012875 "Address Family modifier\n"
12876 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000012877 "Detailed information on TCP and BGP neighbor connections\n"
12878 "Neighbor to display information about\n"
12879 "Neighbor to display information about\n"
12880 "Display the received routes from neighbor\n")
12881{
paulbb46e942003-10-24 19:02:03 +000012882 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012883 safi_t safi;
12884
12885 if (bgp_parse_safi(argv[0], &safi)) {
12886 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12887 return CMD_WARNING;
12888 }
paul718e3742002-12-13 20:15:29 +000012889
paulbb46e942003-10-24 19:02:03 +000012890 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12891 if (! peer)
12892 return CMD_WARNING;
12893
Lou Berger651b4022016-01-12 13:42:07 -050012894 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000012895}
Lou Berger205e6742016-01-12 13:42:11 -050012896
Lou Berger651b4022016-01-12 13:42:07 -050012897DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
12898 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
12899 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
12900 SHOW_STR
12901 BGP_STR
12902 "Address family\n"
12903 "Address Family modifier\n"
12904 "Address Family modifier\n"
12905 "Address Family modifier\n"
12906 "Address Family modifier\n"
12907 "Detailed information on TCP and BGP neighbor connections\n"
12908 "Neighbor to display information about\n"
12909 "Neighbor to display information about\n"
12910 "Display the received routes from neighbor\n")
12911{
12912 struct peer *peer;
12913 safi_t safi;
12914
12915 if (bgp_parse_safi(argv[0], &safi)) {
12916 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12917 return CMD_WARNING;
12918 }
12919
12920 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12921 if (! peer)
12922 return CMD_WARNING;
12923
12924 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
12925}
paul718e3742002-12-13 20:15:29 +000012926
Michael Lambert95cbbd22010-07-23 14:43:04 -040012927DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
12928 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040012929 "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 -040012930 SHOW_STR
12931 BGP_STR
12932 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000012933 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012934 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012935 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012936 "Address family modifier\n"
12937 "Address family modifier\n"
12938 "Detailed information on TCP and BGP neighbor connections\n"
12939 "Neighbor to display information about\n"
12940 "Neighbor to display information about\n"
12941 "Display the advertised routes to neighbor\n"
12942 "Display the received routes from neighbor\n")
12943{
12944 int afi;
12945 int safi;
12946 int in;
12947 struct peer *peer;
12948
David Lamparter94bad672015-03-03 08:52:22 +010012949 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040012950
12951 if (! peer)
12952 return CMD_WARNING;
12953
Michael Lambert95cbbd22010-07-23 14:43:04 -040012954 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12955 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12956 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040012957
12958 return peer_adj_routes (vty, peer, afi, safi, in);
12959}
12960
Lou Bergerf9b6c392016-01-12 13:42:09 -050012961DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
12962 show_ip_bgp_neighbor_received_prefix_filter_cmd,
12963 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12964 SHOW_STR
12965 IP_STR
12966 BGP_STR
12967 "Detailed information on TCP and BGP neighbor connections\n"
12968 "Neighbor to display information about\n"
12969 "Neighbor to display information about\n"
12970 "Display information received from a BGP neighbor\n"
12971 "Display the prefixlist filter\n")
12972{
12973 char name[BUFSIZ];
12974 union sockunion su;
12975 struct peer *peer;
12976 int count, ret;
12977
12978 ret = str2sockunion (argv[0], &su);
12979 if (ret < 0)
12980 {
12981 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12982 return CMD_WARNING;
12983 }
12984
12985 peer = peer_lookup (NULL, &su);
12986 if (! peer)
12987 return CMD_WARNING;
12988
12989 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
12990 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
12991 if (count)
12992 {
12993 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
12994 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
12995 }
12996
12997 return CMD_SUCCESS;
12998}
12999
13000DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
13001 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
13002 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13003 SHOW_STR
13004 IP_STR
13005 BGP_STR
13006 "Address family\n"
13007 "Address Family modifier\n"
13008 "Address Family modifier\n"
13009 "Detailed information on TCP and BGP neighbor connections\n"
13010 "Neighbor to display information about\n"
13011 "Neighbor to display information about\n"
13012 "Display information received from a BGP neighbor\n"
13013 "Display the prefixlist filter\n")
13014{
13015 char name[BUFSIZ];
13016 union sockunion su;
13017 struct peer *peer;
13018 int count, ret;
13019
13020 ret = str2sockunion (argv[1], &su);
13021 if (ret < 0)
13022 {
13023 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13024 return CMD_WARNING;
13025 }
13026
13027 peer = peer_lookup (NULL, &su);
13028 if (! peer)
13029 return CMD_WARNING;
13030
13031 if (strncmp (argv[0], "m", 1) == 0)
13032 {
13033 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
13034 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13035 if (count)
13036 {
13037 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
13038 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13039 }
13040 }
13041 else
13042 {
13043 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13044 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13045 if (count)
13046 {
13047 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13048 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13049 }
13050 }
13051
13052 return CMD_SUCCESS;
13053}
13054
13055ALIAS (show_bgp_view_neighbor_received_routes,
13056 show_bgp_neighbor_received_routes_cmd,
13057 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13058 SHOW_STR
13059 BGP_STR
13060 "Detailed information on TCP and BGP neighbor connections\n"
13061 "Neighbor to display information about\n"
13062 "Neighbor to display information about\n"
13063 "Display the received routes from neighbor\n")
13064
Lou Berger651b4022016-01-12 13:42:07 -050013065DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
13066 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
13067 "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 +000013068 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013069 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013070 IP_STR
13071 "Address Family modifier\n"
13072 "Address Family modifier\n"
13073 "Address Family modifier\n"
13074 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013075 "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 information received from a BGP neighbor\n"
13079 "Display the prefixlist filter\n")
13080{
13081 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013082 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013083 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013084 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050013085 safi_t safi;
paul718e3742002-12-13 20:15:29 +000013086
Lou Berger651b4022016-01-12 13:42:07 -050013087 if (bgp_parse_safi(argv[0], &safi)) {
13088 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013089 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013090 }
paul718e3742002-12-13 20:15:29 +000013091
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013092 ret = str2sockunion (argv[1], &su);
13093 if (ret < 0)
13094 {
13095 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13096 return CMD_WARNING;
13097 }
paul718e3742002-12-13 20:15:29 +000013098
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013099 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013100 if (! peer)
13101 return CMD_WARNING;
13102
Lou Berger651b4022016-01-12 13:42:07 -050013103 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
13104 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13105 if (count) {
13106 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
13107 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13108 }
paul718e3742002-12-13 20:15:29 +000013109
13110 return CMD_SUCCESS;
13111}
Lou Berger205e6742016-01-12 13:42:11 -050013112
Lou Berger651b4022016-01-12 13:42:07 -050013113DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
13114 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
13115 "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 +000013116 SHOW_STR
13117 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013118 IP_STR
13119 "Address Family modifier\n"
13120 "Address Family modifier\n"
13121 "Address Family modifier\n"
13122 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013123 "Detailed information on TCP and BGP neighbor connections\n"
13124 "Neighbor to display information about\n"
13125 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050013126 "Display information received from a BGP neighbor\n"
13127 "Display the prefixlist filter\n")
13128{
13129 char name[BUFSIZ];
13130 union sockunion su;
13131 struct peer *peer;
13132 int count, ret;
13133 safi_t safi;
13134
13135 if (bgp_parse_safi(argv[0], &safi)) {
13136 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13137 return CMD_WARNING;
13138 }
13139
13140 ret = str2sockunion (argv[1], &su);
13141 if (ret < 0)
13142 {
13143 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13144 return CMD_WARNING;
13145 }
13146
13147 peer = peer_lookup (NULL, &su);
13148 if (! peer)
13149 return CMD_WARNING;
13150
13151 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
13152 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13153 if (count) {
13154 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
13155 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13156 }
13157
13158 return CMD_SUCCESS;
13159}
paul718e3742002-12-13 20:15:29 +000013160
Lou Bergerf9b6c392016-01-12 13:42:09 -050013161DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013162 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
13163 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013164 SHOW_STR
13165 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013166 "Address family\n"
paul718e3742002-12-13 20:15:29 +000013167 "Detailed information on TCP and BGP neighbor connections\n"
13168 "Neighbor to display information about\n"
13169 "Neighbor to display information about\n"
13170 "Display information received from a BGP neighbor\n"
13171 "Display the prefixlist filter\n")
13172{
13173 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013174 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013175 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013176 int count, ret;
paul718e3742002-12-13 20:15:29 +000013177
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013178 ret = str2sockunion (argv[0], &su);
13179 if (ret < 0)
13180 {
13181 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13182 return CMD_WARNING;
13183 }
paul718e3742002-12-13 20:15:29 +000013184
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013185 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013186 if (! peer)
13187 return CMD_WARNING;
13188
13189 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13190 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13191 if (count)
13192 {
13193 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13194 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13195 }
13196
13197 return CMD_SUCCESS;
13198}
13199
Lou Bergerf9b6c392016-01-12 13:42:09 -050013200DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013201 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
13202 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000013203 SHOW_STR
13204 BGP_STR
13205 "BGP view\n"
13206 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013207 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013208 "Detailed information on TCP and BGP neighbor connections\n"
13209 "Neighbor to display information about\n"
13210 "Neighbor to display information about\n"
13211 "Display information received from a BGP neighbor\n"
13212 "Display the prefixlist filter\n")
13213{
13214 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013215 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000013216 struct peer *peer;
13217 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013218 int count, ret;
paulbb46e942003-10-24 19:02:03 +000013219
13220 /* BGP structure lookup. */
13221 bgp = bgp_lookup_by_name (argv[0]);
13222 if (bgp == NULL)
13223 {
13224 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13225 return CMD_WARNING;
13226 }
13227
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013228 ret = str2sockunion (argv[1], &su);
13229 if (ret < 0)
13230 {
13231 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13232 return CMD_WARNING;
13233 }
paulbb46e942003-10-24 19:02:03 +000013234
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013235 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000013236 if (! peer)
13237 return CMD_WARNING;
13238
13239 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13240 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13241 if (count)
13242 {
13243 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13244 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13245 }
13246
13247 return CMD_SUCCESS;
13248}
David Lamparter6b0655a2014-06-04 06:53:35 +020013249
paul94f2b392005-06-28 12:44:16 +000013250static int
paulbb46e942003-10-24 19:02:03 +000013251bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000013252 safi_t safi, enum bgp_show_type type)
13253{
paul718e3742002-12-13 20:15:29 +000013254 if (! peer || ! peer->afc[afi][safi])
13255 {
13256 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013257 return CMD_WARNING;
13258 }
13259
ajs5a646652004-11-05 01:25:55 +000013260 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000013261}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013262DEFUN (show_ip_bgp_neighbor_routes,
13263 show_ip_bgp_neighbor_routes_cmd,
13264 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
13265 SHOW_STR
13266 IP_STR
13267 BGP_STR
13268 "Detailed information on TCP and BGP neighbor connections\n"
13269 "Neighbor to display information about\n"
13270 "Neighbor to display information about\n"
13271 "Display routes learned from neighbor\n")
13272{
13273 struct peer *peer;
13274
13275 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13276 if (! peer)
13277 return CMD_WARNING;
13278
13279 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13280 bgp_show_type_neighbor);
13281}
13282
13283DEFUN (show_ip_bgp_neighbor_flap,
13284 show_ip_bgp_neighbor_flap_cmd,
13285 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
13286 SHOW_STR
13287 IP_STR
13288 BGP_STR
13289 "Detailed information on TCP and BGP neighbor connections\n"
13290 "Neighbor to display information about\n"
13291 "Neighbor to display information about\n"
13292 "Display flap statistics of the routes learned from neighbor\n")
13293{
13294 struct peer *peer;
13295
13296 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13297 if (! peer)
13298 return CMD_WARNING;
13299
13300 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13301 bgp_show_type_flap_neighbor);
13302}
13303
13304DEFUN (show_ip_bgp_neighbor_damp,
13305 show_ip_bgp_neighbor_damp_cmd,
13306 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13307 SHOW_STR
13308 IP_STR
13309 BGP_STR
13310 "Detailed information on TCP and BGP neighbor connections\n"
13311 "Neighbor to display information about\n"
13312 "Neighbor to display information about\n"
13313 "Display the dampened routes received from neighbor\n")
13314{
13315 struct peer *peer;
13316
13317 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13318 if (! peer)
13319 return CMD_WARNING;
13320
13321 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13322 bgp_show_type_damp_neighbor);
13323}
13324
13325DEFUN (show_ip_bgp_ipv4_neighbor_routes,
13326 show_ip_bgp_ipv4_neighbor_routes_cmd,
13327 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
13328 SHOW_STR
13329 IP_STR
13330 BGP_STR
13331 "Address family\n"
13332 "Address Family modifier\n"
13333 "Address Family modifier\n"
13334 "Detailed information on TCP and BGP neighbor connections\n"
13335 "Neighbor to display information about\n"
13336 "Neighbor to display information about\n"
13337 "Display routes learned from neighbor\n")
13338{
13339 struct peer *peer;
13340
13341 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13342 if (! peer)
13343 return CMD_WARNING;
13344
13345 if (strncmp (argv[0], "m", 1) == 0)
13346 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
13347 bgp_show_type_neighbor);
13348
13349 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13350 bgp_show_type_neighbor);
13351}
13352
13353DEFUN (show_ip_bgp_view_rsclient,
13354 show_ip_bgp_view_rsclient_cmd,
13355 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
13356 SHOW_STR
13357 IP_STR
13358 BGP_STR
13359 "BGP view\n"
13360 "View name\n"
13361 "Information about Route Server Client\n"
13362 NEIGHBOR_ADDR_STR)
13363{
13364 struct bgp_table *table;
13365 struct peer *peer;
13366
13367 if (argc == 2)
13368 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13369 else
13370 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13371
13372 if (! peer)
13373 return CMD_WARNING;
13374
13375 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13376 {
13377 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13378 VTY_NEWLINE);
13379 return CMD_WARNING;
13380 }
13381
13382 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13383 PEER_FLAG_RSERVER_CLIENT))
13384 {
13385 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13386 VTY_NEWLINE);
13387 return CMD_WARNING;
13388 }
13389
13390 table = peer->rib[AFI_IP][SAFI_UNICAST];
13391
13392 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13393}
13394
13395ALIAS (show_ip_bgp_view_rsclient,
13396 show_ip_bgp_rsclient_cmd,
13397 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
13398 SHOW_STR
13399 IP_STR
13400 BGP_STR
13401 "Information about Route Server Client\n"
13402 NEIGHBOR_ADDR_STR)
13403
13404DEFUN (show_bgp_view_ipv4_safi_rsclient,
13405 show_bgp_view_ipv4_safi_rsclient_cmd,
13406 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13407 SHOW_STR
13408 BGP_STR
13409 "BGP view\n"
13410 "View name\n"
13411 "Address family\n"
13412 "Address Family modifier\n"
13413 "Address Family modifier\n"
13414 "Information about Route Server Client\n"
13415 NEIGHBOR_ADDR_STR)
13416{
13417 struct bgp_table *table;
13418 struct peer *peer;
13419 safi_t safi;
13420
13421 if (argc == 3) {
13422 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13423 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13424 } else {
13425 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13426 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13427 }
13428
13429 if (! peer)
13430 return CMD_WARNING;
13431
13432 if (! peer->afc[AFI_IP][safi])
13433 {
13434 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13435 VTY_NEWLINE);
13436 return CMD_WARNING;
13437 }
13438
13439 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13440 PEER_FLAG_RSERVER_CLIENT))
13441 {
13442 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13443 VTY_NEWLINE);
13444 return CMD_WARNING;
13445 }
13446
13447 table = peer->rib[AFI_IP][safi];
13448
13449 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13450}
13451
13452ALIAS (show_bgp_view_ipv4_safi_rsclient,
13453 show_bgp_ipv4_safi_rsclient_cmd,
13454 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13455 SHOW_STR
13456 BGP_STR
13457 "Address family\n"
13458 "Address Family modifier\n"
13459 "Address Family modifier\n"
13460 "Information about Route Server Client\n"
13461 NEIGHBOR_ADDR_STR)
13462
13463DEFUN (show_ip_bgp_view_rsclient_route,
13464 show_ip_bgp_view_rsclient_route_cmd,
13465 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13466 SHOW_STR
13467 IP_STR
13468 BGP_STR
13469 "BGP view\n"
13470 "View name\n"
13471 "Information about Route Server Client\n"
13472 NEIGHBOR_ADDR_STR
13473 "Network in the BGP routing table to display\n")
13474{
13475 struct bgp *bgp;
13476 struct peer *peer;
13477
13478 /* BGP structure lookup. */
13479 if (argc == 3)
13480 {
13481 bgp = bgp_lookup_by_name (argv[0]);
13482 if (bgp == NULL)
13483 {
13484 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13485 return CMD_WARNING;
13486 }
13487 }
13488 else
13489 {
13490 bgp = bgp_get_default ();
13491 if (bgp == NULL)
13492 {
13493 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13494 return CMD_WARNING;
13495 }
13496 }
13497
13498 if (argc == 3)
13499 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13500 else
13501 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13502
13503 if (! peer)
13504 return CMD_WARNING;
13505
13506 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13507 {
13508 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13509 VTY_NEWLINE);
13510 return CMD_WARNING;
13511}
13512
13513 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13514 PEER_FLAG_RSERVER_CLIENT))
13515 {
13516 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13517 VTY_NEWLINE);
13518 return CMD_WARNING;
13519 }
13520
13521 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13522 (argc == 3) ? argv[2] : argv[1],
13523 AFI_IP, SAFI_UNICAST, NULL, 0);
13524}
13525
13526ALIAS (show_ip_bgp_view_rsclient_route,
13527 show_ip_bgp_rsclient_route_cmd,
13528 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13529 SHOW_STR
13530 IP_STR
13531 BGP_STR
13532 "Information about Route Server Client\n"
13533 NEIGHBOR_ADDR_STR
13534 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000013535
Lou Berger651b4022016-01-12 13:42:07 -050013536DEFUN (show_bgp_ipv4_safi_neighbor_flap,
13537 show_bgp_ipv4_safi_neighbor_flap_cmd,
13538 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013539 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013540 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013541 "Address Family Modifier\n"
13542 "Address Family Modifier\n"
13543 "Address Family Modifier\n"
13544 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013545 "Detailed information on TCP and BGP neighbor connections\n"
13546 "Neighbor to display information about\n"
13547 "Neighbor to display information about\n"
13548 "Display flap statistics of the routes learned from neighbor\n")
13549{
paulbb46e942003-10-24 19:02:03 +000013550 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013551 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013552
Lou Berger651b4022016-01-12 13:42:07 -050013553 if (bgp_parse_safi(argv[0], &safi)) {
13554 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13555 return CMD_WARNING;
13556 }
13557
13558 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013559 if (! peer)
13560 return CMD_WARNING;
13561
Lou Berger651b4022016-01-12 13:42:07 -050013562 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013563 bgp_show_type_flap_neighbor);
13564}
Lou Berger205e6742016-01-12 13:42:11 -050013565
Lou Berger651b4022016-01-12 13:42:07 -050013566DEFUN (show_bgp_ipv6_safi_neighbor_flap,
13567 show_bgp_ipv6_safi_neighbor_flap_cmd,
13568 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013569 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013570 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013571 "Address Family Modifier\n"
13572 "Address Family Modifier\n"
13573 "Address Family Modifier\n"
13574 "Address Family Modifier\n"
13575 "Detailed information on TCP and BGP neighbor connections\n"
13576 "Neighbor to display information about\n"
13577 "Neighbor to display information about\n"
13578 "Display flap statistics of the routes learned from neighbor\n")
13579{
13580 struct peer *peer;
13581 safi_t safi;
13582
13583 if (bgp_parse_safi(argv[0], &safi)) {
13584 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13585 return CMD_WARNING;
13586 }
13587
13588 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13589 if (! peer)
13590 return CMD_WARNING;
13591
13592 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13593 bgp_show_type_flap_neighbor);
13594}
Lou Berger651b4022016-01-12 13:42:07 -050013595
13596DEFUN (show_bgp_ipv4_safi_neighbor_damp,
13597 show_bgp_ipv4_safi_neighbor_damp_cmd,
13598 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13599 SHOW_STR
13600 BGP_STR
13601 "Address Family Modifier\n"
13602 "Address Family Modifier\n"
13603 "Address Family Modifier\n"
13604 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013605 "Detailed information on TCP and BGP neighbor connections\n"
13606 "Neighbor to display information about\n"
13607 "Neighbor to display information about\n"
13608 "Display the dampened routes received from neighbor\n")
13609{
paulbb46e942003-10-24 19:02:03 +000013610 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013611 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013612
Lou Berger651b4022016-01-12 13:42:07 -050013613 if (bgp_parse_safi(argv[0], &safi)) {
13614 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13615 return CMD_WARNING;
13616 }
13617
13618 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013619 if (! peer)
13620 return CMD_WARNING;
13621
Lou Berger651b4022016-01-12 13:42:07 -050013622 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013623 bgp_show_type_damp_neighbor);
13624}
Lou Berger205e6742016-01-12 13:42:11 -050013625
Lou Berger651b4022016-01-12 13:42:07 -050013626DEFUN (show_bgp_ipv6_safi_neighbor_damp,
13627 show_bgp_ipv6_safi_neighbor_damp_cmd,
13628 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000013629 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050013630 BGP_STR
13631 "Address Family Modifier\n"
13632 "Address Family Modifier\n"
13633 "Address Family Modifier\n"
13634 "Address Family Modifier\n"
13635 "Detailed information on TCP and BGP neighbor connections\n"
13636 "Neighbor to display information about\n"
13637 "Neighbor to display information about\n"
13638 "Display the dampened routes received from neighbor\n")
13639{
13640 struct peer *peer;
13641 safi_t safi;
13642
13643 if (bgp_parse_safi(argv[0], &safi)) {
13644 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13645 return CMD_WARNING;
13646 }
13647
13648 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13649 if (! peer)
13650 return CMD_WARNING;
13651
13652 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13653 bgp_show_type_damp_neighbor);
13654}
Lou Berger651b4022016-01-12 13:42:07 -050013655
13656DEFUN (show_bgp_ipv4_safi_neighbor_routes,
13657 show_bgp_ipv4_safi_neighbor_routes_cmd,
13658 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
13659 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013660 BGP_STR
13661 "Address family\n"
13662 "Address Family modifier\n"
13663 "Address Family modifier\n"
13664 "Detailed information on TCP and BGP neighbor connections\n"
13665 "Neighbor to display information about\n"
13666 "Neighbor to display information about\n"
13667 "Display routes learned from neighbor\n")
13668{
paulbb46e942003-10-24 19:02:03 +000013669 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013670 safi_t safi;
13671
13672 if (bgp_parse_safi(argv[0], &safi)) {
13673 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13674 return CMD_WARNING;
13675 }
paulbb46e942003-10-24 19:02:03 +000013676
13677 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13678 if (! peer)
13679 return CMD_WARNING;
13680
Lou Berger651b4022016-01-12 13:42:07 -050013681 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013682 bgp_show_type_neighbor);
13683}
Lou Berger205e6742016-01-12 13:42:11 -050013684
Lou Berger651b4022016-01-12 13:42:07 -050013685DEFUN (show_bgp_ipv6_safi_neighbor_routes,
13686 show_bgp_ipv6_safi_neighbor_routes_cmd,
13687 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000013688 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000013689 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013690 "Address family\n"
13691 "Address Family modifier\n"
13692 "Address Family modifier\n"
13693 "Detailed information on TCP and BGP neighbor connections\n"
13694 NEIGHBOR_ADDR_STR
13695 NEIGHBOR_ADDR_STR
13696 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000013697{
paulfee0f4c2004-09-13 05:12:46 +000013698 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013699 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000013700
Lou Berger651b4022016-01-12 13:42:07 -050013701 if (bgp_parse_safi(argv[0], &safi)) {
13702 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13703 return CMD_WARNING;
13704 }
paulfee0f4c2004-09-13 05:12:46 +000013705
Lou Berger651b4022016-01-12 13:42:07 -050013706 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000013707 if (! peer)
13708 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013709
13710 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13711 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000013712}
paulfee0f4c2004-09-13 05:12:46 +000013713
Michael Lambert95cbbd22010-07-23 14:43:04 -040013714DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
13715 show_bgp_view_ipv4_safi_rsclient_route_cmd,
13716 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13717 SHOW_STR
13718 BGP_STR
13719 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013720 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013721 "Address family\n"
13722 "Address Family modifier\n"
13723 "Address Family modifier\n"
13724 "Information about Route Server Client\n"
13725 NEIGHBOR_ADDR_STR
13726 "Network in the BGP routing table to display\n")
13727{
13728 struct bgp *bgp;
13729 struct peer *peer;
13730 safi_t safi;
13731
13732 /* BGP structure lookup. */
13733 if (argc == 4)
13734 {
13735 bgp = bgp_lookup_by_name (argv[0]);
13736 if (bgp == NULL)
13737 {
13738 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13739 return CMD_WARNING;
13740 }
13741 }
13742 else
13743 {
13744 bgp = bgp_get_default ();
13745 if (bgp == NULL)
13746 {
13747 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13748 return CMD_WARNING;
13749 }
13750 }
13751
13752 if (argc == 4) {
13753 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13754 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13755 } else {
13756 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13757 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13758 }
13759
13760 if (! peer)
13761 return CMD_WARNING;
13762
13763 if (! peer->afc[AFI_IP][safi])
13764 {
13765 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13766 VTY_NEWLINE);
13767 return CMD_WARNING;
13768}
13769
13770 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13771 PEER_FLAG_RSERVER_CLIENT))
13772 {
13773 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13774 VTY_NEWLINE);
13775 return CMD_WARNING;
13776 }
13777
13778 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13779 (argc == 4) ? argv[3] : argv[2],
13780 AFI_IP, safi, NULL, 0);
13781}
13782
13783ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
13784 show_bgp_ipv4_safi_rsclient_route_cmd,
13785 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13786 SHOW_STR
13787 BGP_STR
13788 "Address family\n"
13789 "Address Family modifier\n"
13790 "Address Family modifier\n"
13791 "Information about Route Server Client\n"
13792 NEIGHBOR_ADDR_STR
13793 "Network in the BGP routing table to display\n")
13794
paulfee0f4c2004-09-13 05:12:46 +000013795
Michael Lambert95cbbd22010-07-23 14:43:04 -040013796DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
13797 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
13798 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13799 SHOW_STR
13800 BGP_STR
13801 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013802 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013803 "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 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13809{
13810 struct bgp *bgp;
13811 struct peer *peer;
13812 safi_t safi;
13813
13814 /* BGP structure lookup. */
13815 if (argc == 4)
13816 {
13817 bgp = bgp_lookup_by_name (argv[0]);
13818 if (bgp == NULL)
13819 {
13820 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13821 return CMD_WARNING;
13822 }
13823 }
13824 else
13825 {
13826 bgp = bgp_get_default ();
13827 if (bgp == NULL)
13828 {
13829 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13830 return CMD_WARNING;
13831 }
13832 }
13833
13834 if (argc == 4) {
13835 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13836 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13837 } else {
13838 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13839 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13840 }
13841
13842 if (! peer)
13843 return CMD_WARNING;
13844
13845 if (! peer->afc[AFI_IP][safi])
13846 {
13847 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13848 VTY_NEWLINE);
13849 return CMD_WARNING;
13850}
13851
13852 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13853 PEER_FLAG_RSERVER_CLIENT))
13854{
13855 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13856 VTY_NEWLINE);
13857 return CMD_WARNING;
13858 }
13859
13860 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13861 (argc == 4) ? argv[3] : argv[2],
13862 AFI_IP, safi, NULL, 1);
13863}
13864
Lou Bergerf9b6c392016-01-12 13:42:09 -050013865DEFUN (show_ip_bgp_view_rsclient_prefix,
13866 show_ip_bgp_view_rsclient_prefix_cmd,
13867 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13868 SHOW_STR
13869 IP_STR
13870 BGP_STR
13871 "BGP view\n"
13872 "View name\n"
13873 "Information about Route Server Client\n"
13874 NEIGHBOR_ADDR_STR
13875 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13876{
13877 struct bgp *bgp;
13878 struct peer *peer;
13879
13880 /* BGP structure lookup. */
13881 if (argc == 3)
13882 {
13883 bgp = bgp_lookup_by_name (argv[0]);
13884 if (bgp == NULL)
13885 {
13886 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13887 return CMD_WARNING;
13888 }
13889 }
13890 else
13891 {
13892 bgp = bgp_get_default ();
13893 if (bgp == NULL)
13894 {
13895 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13896 return CMD_WARNING;
13897 }
13898 }
13899
13900 if (argc == 3)
13901 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13902 else
13903 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13904
13905 if (! peer)
13906 return CMD_WARNING;
13907
13908 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13909 {
13910 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13911 VTY_NEWLINE);
13912 return CMD_WARNING;
13913}
13914
13915 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13916 PEER_FLAG_RSERVER_CLIENT))
13917{
13918 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13919 VTY_NEWLINE);
13920 return CMD_WARNING;
13921 }
13922
13923 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13924 (argc == 3) ? argv[2] : argv[1],
13925 AFI_IP, SAFI_UNICAST, NULL, 1);
13926}
13927
13928ALIAS (show_ip_bgp_view_rsclient_prefix,
13929 show_ip_bgp_rsclient_prefix_cmd,
13930 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13931 SHOW_STR
13932 IP_STR
13933 BGP_STR
13934 "Information about Route Server Client\n"
13935 NEIGHBOR_ADDR_STR
13936 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13937
Michael Lambert95cbbd22010-07-23 14:43:04 -040013938ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
13939 show_bgp_ipv4_safi_rsclient_prefix_cmd,
13940 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13941 SHOW_STR
13942 BGP_STR
13943 "Address family\n"
13944 "Address Family modifier\n"
13945 "Address Family modifier\n"
13946 "Information about Route Server Client\n"
13947 NEIGHBOR_ADDR_STR
13948 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000013949
Lou Bergerf9b6c392016-01-12 13:42:09 -050013950DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050013951 show_bgp_view_ipv6_neighbor_routes_cmd,
13952 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +000013953 SHOW_STR
13954 BGP_STR
13955 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013956 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013957 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013958 "Detailed information on TCP and BGP neighbor connections\n"
13959 "Neighbor to display information about\n"
13960 "Neighbor to display information about\n"
13961 "Display routes learned from neighbor\n")
13962{
13963 struct peer *peer;
13964
13965 if (argc == 2)
13966 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13967 else
13968 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13969
13970 if (! peer)
13971 return CMD_WARNING;
13972
13973 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13974 bgp_show_type_neighbor);
13975}
13976
Lou Berger651b4022016-01-12 13:42:07 -050013977DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050013978 show_bgp_view_neighbor_damp_cmd,
13979 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13980 SHOW_STR
13981 BGP_STR
13982 "BGP view\n"
13983 "View name\n"
13984 "Detailed information on TCP and BGP neighbor connections\n"
13985 "Neighbor to display information about\n"
13986 "Neighbor to display information about\n"
13987 "Display the dampened routes received from neighbor\n")
13988{
13989 struct peer *peer;
13990
13991 if (argc == 2)
13992 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13993 else
13994 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13995
13996 if (! peer)
13997 return CMD_WARNING;
13998
13999 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14000 bgp_show_type_damp_neighbor);
14001}
14002
14003DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050014004 show_bgp_view_ipv6_neighbor_damp_cmd,
14005 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000014006 SHOW_STR
14007 BGP_STR
14008 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014009 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014010 "Address family\n"
14011 "Detailed information on TCP and BGP neighbor connections\n"
14012 "Neighbor to display information about\n"
14013 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000014014 "Display the dampened routes received from neighbor\n")
14015{
14016 struct peer *peer;
14017
14018 if (argc == 2)
14019 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14020 else
14021 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14022
14023 if (! peer)
14024 return CMD_WARNING;
14025
14026 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14027 bgp_show_type_damp_neighbor);
14028}
14029
Lou Bergerf9b6c392016-01-12 13:42:09 -050014030DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050014031 show_bgp_view_ipv6_neighbor_flap_cmd,
14032 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000014033 SHOW_STR
14034 BGP_STR
14035 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014036 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014037 "Address family\n"
14038 "Detailed information on TCP and BGP neighbor connections\n"
14039 "Neighbor to display information about\n"
14040 "Neighbor to display information about\n"
14041 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000014042{
14043 struct peer *peer;
14044
14045 if (argc == 2)
14046 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14047 else
14048 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14049
14050 if (! peer)
14051 return CMD_WARNING;
14052
14053 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14054 bgp_show_type_flap_neighbor);
14055}
14056
Lou Bergerf9b6c392016-01-12 13:42:09 -050014057DEFUN (show_bgp_view_neighbor_flap,
14058 show_bgp_view_neighbor_flap_cmd,
14059 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14060 SHOW_STR
14061 BGP_STR
14062 "BGP view\n"
14063 "View name\n"
14064 "Detailed information on TCP and BGP neighbor connections\n"
14065 "Neighbor to display information about\n"
14066 "Neighbor to display information about\n"
14067 "Display flap statistics of the routes learned from neighbor\n")
14068{
14069 struct peer *peer;
14070
14071 if (argc == 2)
14072 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14073 else
14074 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14075
14076 if (! peer)
14077 return CMD_WARNING;
14078
14079 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14080 bgp_show_type_flap_neighbor);
14081}
14082
14083ALIAS (show_bgp_view_neighbor_flap,
14084 show_bgp_neighbor_flap_cmd,
14085 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14086 SHOW_STR
14087 BGP_STR
14088 "Detailed information on TCP and BGP neighbor connections\n"
14089 "Neighbor to display information about\n"
14090 "Neighbor to display information about\n"
14091 "Display flap statistics of the routes learned from neighbor\n")
14092
14093ALIAS (show_bgp_view_neighbor_damp,
14094 show_bgp_neighbor_damp_cmd,
14095 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14096 SHOW_STR
14097 BGP_STR
14098 "Detailed information on TCP and BGP neighbor connections\n"
14099 "Neighbor to display information about\n"
14100 "Neighbor to display information about\n"
14101 "Display the dampened routes received from neighbor\n")
14102
14103DEFUN (show_bgp_view_neighbor_routes,
14104 show_bgp_view_neighbor_routes_cmd,
14105 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
14106 SHOW_STR
14107 BGP_STR
14108 "BGP view\n"
14109 "View name\n"
14110 "Detailed information on TCP and BGP neighbor connections\n"
14111 "Neighbor to display information about\n"
14112 "Neighbor to display information about\n"
14113 "Display routes learned from neighbor\n")
14114{
14115 struct peer *peer;
14116
14117 if (argc == 2)
14118 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14119 else
14120 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14121
14122 if (! peer)
14123 return CMD_WARNING;
14124
14125 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14126 bgp_show_type_neighbor);
14127}
14128
14129ALIAS (show_bgp_view_neighbor_routes,
14130 show_bgp_neighbor_routes_cmd,
14131 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
14132 SHOW_STR
14133 BGP_STR
14134 "Detailed information on TCP and BGP neighbor connections\n"
14135 "Neighbor to display information about\n"
14136 "Neighbor to display information about\n"
14137 "Display routes learned from neighbor\n")
14138
paulbb46e942003-10-24 19:02:03 +000014139ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000014140 show_bgp_ipv6_neighbor_routes_cmd,
14141 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
14142 SHOW_STR
14143 BGP_STR
14144 "Address family\n"
14145 "Detailed information on TCP and BGP neighbor connections\n"
14146 "Neighbor to display information about\n"
14147 "Neighbor to display information about\n"
14148 "Display routes learned from neighbor\n")
14149
Lou Bergerf9b6c392016-01-12 13:42:09 -050014150/* old command */
14151ALIAS (show_bgp_view_neighbor_routes,
14152 ipv6_bgp_neighbor_routes_cmd,
14153 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
14154 SHOW_STR
14155 IPV6_STR
14156 BGP_STR
14157 "Detailed information on TCP and BGP neighbor connections\n"
14158 "Neighbor to display information about\n"
14159 "Neighbor to display information about\n"
14160 "Display routes learned from neighbor\n")
14161
14162/* old command */
14163DEFUN (ipv6_mbgp_neighbor_routes,
14164 ipv6_mbgp_neighbor_routes_cmd,
14165 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
14166 SHOW_STR
14167 IPV6_STR
14168 MBGP_STR
14169 "Detailed information on TCP and BGP neighbor connections\n"
14170 "Neighbor to display information about\n"
14171 "Neighbor to display information about\n"
14172 "Display routes learned from neighbor\n")
14173{
14174 struct peer *peer;
14175
14176 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14177 if (! peer)
14178 return CMD_WARNING;
14179
14180 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
14181 bgp_show_type_neighbor);
14182}
14183
paulbb46e942003-10-24 19:02:03 +000014184ALIAS (show_bgp_view_neighbor_flap,
14185 show_bgp_ipv6_neighbor_flap_cmd,
14186 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14187 SHOW_STR
14188 BGP_STR
14189 "Address family\n"
14190 "Detailed information on TCP and BGP neighbor connections\n"
14191 "Neighbor to display information about\n"
14192 "Neighbor to display information about\n"
14193 "Display flap statistics of the routes learned from neighbor\n")
14194
14195ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000014196 show_bgp_ipv6_neighbor_damp_cmd,
14197 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14198 SHOW_STR
14199 BGP_STR
14200 "Address family\n"
14201 "Detailed information on TCP and BGP neighbor connections\n"
14202 "Neighbor to display information about\n"
14203 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000014204 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014205
Lou Bergerf9b6c392016-01-12 13:42:09 -050014206DEFUN (show_bgp_view_rsclient,
14207 show_bgp_view_rsclient_cmd,
14208 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14209 SHOW_STR
14210 BGP_STR
14211 "BGP view\n"
14212 "View name\n"
14213 "Information about Route Server Client\n"
14214 NEIGHBOR_ADDR_STR)
14215{
14216 struct bgp_table *table;
14217 struct peer *peer;
14218
14219 if (argc == 2)
14220 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14221 else
14222 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14223
14224 if (! peer)
14225 return CMD_WARNING;
14226
14227 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14228 {
14229 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14230 VTY_NEWLINE);
14231 return CMD_WARNING;
14232 }
14233
14234 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14235 PEER_FLAG_RSERVER_CLIENT))
14236 {
14237 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14238 VTY_NEWLINE);
14239 return CMD_WARNING;
14240 }
14241
14242 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14243
14244 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14245}
14246
14247ALIAS (show_bgp_view_rsclient,
14248 show_bgp_rsclient_cmd,
14249 "show bgp rsclient (A.B.C.D|X:X::X:X)",
14250 SHOW_STR
14251 BGP_STR
14252 "Information about Route Server Client\n"
14253 NEIGHBOR_ADDR_STR)
14254
Lou Berger651b4022016-01-12 13:42:07 -050014255DEFUN (show_bgp_view_ipv4_rsclient,
14256 show_bgp_view_ipv4_rsclient_cmd,
14257 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014258 SHOW_STR
14259 BGP_STR
14260 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014261 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014262 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014263 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014264 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014265{
Lou Berger651b4022016-01-12 13:42:07 -050014266 struct bgp_table *table;
14267 struct peer *peer;
14268
14269 if (argc == 2)
14270 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14271 else
14272 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14273
14274 if (! peer)
14275 return CMD_WARNING;
14276
14277 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14278 {
14279 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14280 VTY_NEWLINE);
14281 return CMD_WARNING;
14282 }
14283
14284 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14285 PEER_FLAG_RSERVER_CLIENT))
14286 {
14287 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14288 VTY_NEWLINE);
14289 return CMD_WARNING;
14290 }
14291
14292 table = peer->rib[AFI_IP][SAFI_UNICAST];
14293
14294 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14295}
14296DEFUN (show_bgp_view_ipv6_rsclient,
14297 show_bgp_view_ipv6_rsclient_cmd,
14298 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
14299 SHOW_STR
14300 BGP_STR
14301 "BGP view\n"
14302 "BGP view name\n"
14303 "Address Family\n"
14304 "Information about Route Server Client\n"
14305 NEIGHBOR_ADDR_STR2)
14306{
14307 struct bgp_table *table;
14308 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000014309
14310 if (argc == 2)
14311 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14312 else
14313 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14314
14315 if (! peer)
14316 return CMD_WARNING;
14317
14318 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14319 {
14320 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14321 VTY_NEWLINE);
14322 return CMD_WARNING;
14323 }
14324
14325 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14326 PEER_FLAG_RSERVER_CLIENT))
14327 {
14328 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14329 VTY_NEWLINE);
14330 return CMD_WARNING;
14331 }
14332
14333 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14334
ajs5a646652004-11-05 01:25:55 +000014335 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000014336}
14337
Lou Berger651b4022016-01-12 13:42:07 -050014338ALIAS (show_bgp_view_ipv4_rsclient,
14339 show_bgp_ipv4_rsclient_cmd,
14340 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014341 SHOW_STR
14342 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014343 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014344 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014345 NEIGHBOR_ADDR_STR2)
14346
Lou Berger651b4022016-01-12 13:42:07 -050014347ALIAS (show_bgp_view_ipv6_rsclient,
14348 show_bgp_ipv6_rsclient_cmd,
14349 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
14350 SHOW_STR
14351 BGP_STR
14352 "Address Family\n"
14353 "Information about Route Server Client\n"
14354 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014355
Michael Lambert95cbbd22010-07-23 14:43:04 -040014356DEFUN (show_bgp_view_ipv6_safi_rsclient,
14357 show_bgp_view_ipv6_safi_rsclient_cmd,
14358 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14359 SHOW_STR
14360 BGP_STR
14361 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014362 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014363 "Address family\n"
14364 "Address Family modifier\n"
14365 "Address Family modifier\n"
14366 "Information about Route Server Client\n"
14367 NEIGHBOR_ADDR_STR)
14368{
14369 struct bgp_table *table;
14370 struct peer *peer;
14371 safi_t safi;
14372
14373 if (argc == 3) {
14374 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14375 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14376 } else {
14377 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14378 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14379 }
14380
14381 if (! peer)
14382 return CMD_WARNING;
14383
14384 if (! peer->afc[AFI_IP6][safi])
14385 {
14386 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14387 VTY_NEWLINE);
14388 return CMD_WARNING;
14389 }
14390
14391 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14392 PEER_FLAG_RSERVER_CLIENT))
14393 {
14394 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14395 VTY_NEWLINE);
14396 return CMD_WARNING;
14397 }
14398
14399 table = peer->rib[AFI_IP6][safi];
14400
14401 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14402}
14403
14404ALIAS (show_bgp_view_ipv6_safi_rsclient,
14405 show_bgp_ipv6_safi_rsclient_cmd,
14406 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14407 SHOW_STR
14408 BGP_STR
14409 "Address family\n"
14410 "Address Family modifier\n"
14411 "Address Family modifier\n"
14412 "Information about Route Server Client\n"
14413 NEIGHBOR_ADDR_STR)
14414
paulfee0f4c2004-09-13 05:12:46 +000014415DEFUN (show_bgp_view_rsclient_route,
14416 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014417 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14418 SHOW_STR
14419 BGP_STR
14420 "BGP view\n"
14421 "View name\n"
14422 "Information about Route Server Client\n"
14423 NEIGHBOR_ADDR_STR
14424 "Network in the BGP routing table to display\n")
14425{
14426 struct bgp *bgp;
14427 struct peer *peer;
14428
14429 /* BGP structure lookup. */
14430 if (argc == 3)
14431 {
14432 bgp = bgp_lookup_by_name (argv[0]);
14433 if (bgp == NULL)
14434 {
14435 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14436 return CMD_WARNING;
14437 }
14438 }
14439 else
14440 {
14441 bgp = bgp_get_default ();
14442 if (bgp == NULL)
14443 {
14444 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14445 return CMD_WARNING;
14446 }
14447 }
14448
14449 if (argc == 3)
14450 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14451 else
14452 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14453
14454 if (! peer)
14455 return CMD_WARNING;
14456
14457 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14458 {
14459 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14460 VTY_NEWLINE);
14461 return CMD_WARNING;
14462 }
14463
14464 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14465 PEER_FLAG_RSERVER_CLIENT))
14466 {
14467 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14468 VTY_NEWLINE);
14469 return CMD_WARNING;
14470 }
14471
14472 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14473 (argc == 3) ? argv[2] : argv[1],
14474 AFI_IP6, SAFI_UNICAST, NULL, 0);
14475}
14476
14477DEFUN (show_bgp_view_ipv6_rsclient_route,
14478 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014479 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014480 SHOW_STR
14481 BGP_STR
14482 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050014483 "BGP view name\n"
14484 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000014485 "Information about Route Server Client\n"
14486 NEIGHBOR_ADDR_STR
14487 "Network in the BGP routing table to display\n")
14488{
14489 struct bgp *bgp;
14490 struct peer *peer;
14491
14492 /* BGP structure lookup. */
14493 if (argc == 3)
14494 {
14495 bgp = bgp_lookup_by_name (argv[0]);
14496 if (bgp == NULL)
14497 {
14498 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14499 return CMD_WARNING;
14500 }
14501 }
14502 else
14503 {
14504 bgp = bgp_get_default ();
14505 if (bgp == NULL)
14506 {
14507 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14508 return CMD_WARNING;
14509 }
14510 }
14511
14512 if (argc == 3)
14513 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14514 else
14515 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14516
14517 if (! peer)
14518 return CMD_WARNING;
14519
14520 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14521 {
14522 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14523 VTY_NEWLINE);
14524 return CMD_WARNING;
14525 }
14526
14527 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14528 PEER_FLAG_RSERVER_CLIENT))
14529 {
14530 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14531 VTY_NEWLINE);
14532 return CMD_WARNING;
14533 }
14534
14535 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14536 (argc == 3) ? argv[2] : argv[1],
14537 AFI_IP6, SAFI_UNICAST, NULL, 0);
14538}
14539
Lou Bergerf9b6c392016-01-12 13:42:09 -050014540ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000014541 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014542 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14543 SHOW_STR
14544 BGP_STR
14545 "Information about Route Server Client\n"
14546 NEIGHBOR_ADDR_STR
14547 "Network in the BGP routing table to display\n")
14548
14549ALIAS (show_bgp_view_ipv6_rsclient_route,
14550 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014551 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014552 SHOW_STR
14553 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014554 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014555 "Information about Route Server Client\n"
14556 NEIGHBOR_ADDR_STR
14557 "Network in the BGP routing table to display\n")
14558
Michael Lambert95cbbd22010-07-23 14:43:04 -040014559DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
14560 show_bgp_view_ipv6_safi_rsclient_route_cmd,
14561 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14562 SHOW_STR
14563 BGP_STR
14564 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014565 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014566 "Address family\n"
14567 "Address Family modifier\n"
14568 "Address Family modifier\n"
14569 "Information about Route Server Client\n"
14570 NEIGHBOR_ADDR_STR
14571 "Network in the BGP routing table to display\n")
14572{
14573 struct bgp *bgp;
14574 struct peer *peer;
14575 safi_t safi;
14576
14577 /* BGP structure lookup. */
14578 if (argc == 4)
14579 {
14580 bgp = bgp_lookup_by_name (argv[0]);
14581 if (bgp == NULL)
14582 {
14583 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14584 return CMD_WARNING;
14585 }
14586 }
14587 else
14588 {
14589 bgp = bgp_get_default ();
14590 if (bgp == NULL)
14591 {
14592 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14593 return CMD_WARNING;
14594 }
14595 }
14596
14597 if (argc == 4) {
14598 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14599 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14600 } else {
14601 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14602 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14603 }
14604
14605 if (! peer)
14606 return CMD_WARNING;
14607
14608 if (! peer->afc[AFI_IP6][safi])
14609 {
14610 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14611 VTY_NEWLINE);
14612 return CMD_WARNING;
14613}
14614
14615 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14616 PEER_FLAG_RSERVER_CLIENT))
14617 {
14618 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14619 VTY_NEWLINE);
14620 return CMD_WARNING;
14621 }
14622
14623 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14624 (argc == 4) ? argv[3] : argv[2],
14625 AFI_IP6, safi, NULL, 0);
14626}
14627
14628ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
14629 show_bgp_ipv6_safi_rsclient_route_cmd,
14630 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14631 SHOW_STR
14632 BGP_STR
14633 "Address family\n"
14634 "Address Family modifier\n"
14635 "Address Family modifier\n"
14636 "Information about Route Server Client\n"
14637 NEIGHBOR_ADDR_STR
14638 "Network in the BGP routing table to display\n")
14639
Lou Berger651b4022016-01-12 13:42:07 -050014640
paulfee0f4c2004-09-13 05:12:46 +000014641DEFUN (show_bgp_view_rsclient_prefix,
14642 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014643 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14644 SHOW_STR
14645 BGP_STR
14646 "BGP view\n"
14647 "View name\n"
14648 "Information about Route Server Client\n"
14649 NEIGHBOR_ADDR_STR
14650 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14651{
14652 struct bgp *bgp;
14653 struct peer *peer;
14654
14655 /* BGP structure lookup. */
14656 if (argc == 3)
14657 {
14658 bgp = bgp_lookup_by_name (argv[0]);
14659 if (bgp == NULL)
14660 {
14661 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14662 return CMD_WARNING;
14663 }
14664 }
14665 else
14666 {
14667 bgp = bgp_get_default ();
14668 if (bgp == NULL)
14669 {
14670 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14671 return CMD_WARNING;
14672 }
14673 }
14674
14675 if (argc == 3)
14676 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14677 else
14678 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14679
14680 if (! peer)
14681 return CMD_WARNING;
14682
14683 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14684 {
14685 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14686 VTY_NEWLINE);
14687 return CMD_WARNING;
14688 }
14689
14690 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14691 PEER_FLAG_RSERVER_CLIENT))
14692 {
14693 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14694 VTY_NEWLINE);
14695 return CMD_WARNING;
14696 }
14697
14698 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14699 (argc == 3) ? argv[2] : argv[1],
14700 AFI_IP6, SAFI_UNICAST, NULL, 1);
14701}
14702
14703DEFUN (show_bgp_view_ipv6_rsclient_prefix,
14704 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014705 "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 +000014706 SHOW_STR
14707 BGP_STR
14708 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014709 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014710 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014711 "Information about Route Server Client\n"
14712 NEIGHBOR_ADDR_STR
14713 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14714{
14715 struct bgp *bgp;
14716 struct peer *peer;
14717
14718 /* BGP structure lookup. */
14719 if (argc == 3)
14720 {
14721 bgp = bgp_lookup_by_name (argv[0]);
14722 if (bgp == NULL)
14723 {
14724 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14725 return CMD_WARNING;
14726 }
14727 }
14728 else
14729 {
14730 bgp = bgp_get_default ();
14731 if (bgp == NULL)
14732 {
14733 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14734 return CMD_WARNING;
14735 }
14736 }
14737
14738 if (argc == 3)
14739 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14740 else
14741 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14742
14743 if (! peer)
14744 return CMD_WARNING;
14745
14746 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14747 {
14748 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14749 VTY_NEWLINE);
14750 return CMD_WARNING;
14751 }
14752
14753 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14754 PEER_FLAG_RSERVER_CLIENT))
14755 {
14756 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14757 VTY_NEWLINE);
14758 return CMD_WARNING;
14759 }
14760
14761 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14762 (argc == 3) ? argv[2] : argv[1],
14763 AFI_IP6, SAFI_UNICAST, NULL, 1);
14764}
14765
Lou Bergerf9b6c392016-01-12 13:42:09 -050014766ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000014767 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014768 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14769 SHOW_STR
14770 BGP_STR
14771 "Information about Route Server Client\n"
14772 NEIGHBOR_ADDR_STR
14773 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14774
14775ALIAS (show_bgp_view_ipv6_rsclient_prefix,
14776 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014777 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000014778 SHOW_STR
14779 BGP_STR
14780 "Information about Route Server Client\n"
14781 NEIGHBOR_ADDR_STR
14782 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14783
Michael Lambert95cbbd22010-07-23 14:43:04 -040014784DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
14785 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
14786 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14787 SHOW_STR
14788 BGP_STR
14789 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014790 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014791 "Address family\n"
14792 "Address Family modifier\n"
14793 "Address Family modifier\n"
14794 "Information about Route Server Client\n"
14795 NEIGHBOR_ADDR_STR
14796 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14797{
14798 struct bgp *bgp;
14799 struct peer *peer;
14800 safi_t safi;
14801
14802 /* BGP structure lookup. */
14803 if (argc == 4)
14804 {
14805 bgp = bgp_lookup_by_name (argv[0]);
14806 if (bgp == NULL)
14807 {
14808 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14809 return CMD_WARNING;
14810 }
14811 }
14812 else
14813 {
14814 bgp = bgp_get_default ();
14815 if (bgp == NULL)
14816 {
14817 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14818 return CMD_WARNING;
14819 }
14820 }
14821
14822 if (argc == 4) {
14823 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14824 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14825 } else {
14826 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14827 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14828 }
14829
14830 if (! peer)
14831 return CMD_WARNING;
14832
14833 if (! peer->afc[AFI_IP6][safi])
14834 {
14835 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14836 VTY_NEWLINE);
14837 return CMD_WARNING;
14838}
14839
14840 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14841 PEER_FLAG_RSERVER_CLIENT))
14842{
14843 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14844 VTY_NEWLINE);
14845 return CMD_WARNING;
14846 }
14847
14848 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14849 (argc == 4) ? argv[3] : argv[2],
14850 AFI_IP6, safi, NULL, 1);
14851}
14852
14853ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
14854 show_bgp_ipv6_safi_rsclient_prefix_cmd,
14855 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14856 SHOW_STR
14857 BGP_STR
14858 "Address family\n"
14859 "Address Family modifier\n"
14860 "Address Family modifier\n"
14861 "Information about Route Server Client\n"
14862 NEIGHBOR_ADDR_STR
14863 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14864
paul718e3742002-12-13 20:15:29 +000014865struct bgp_table *bgp_distance_table;
14866
14867struct bgp_distance
14868{
14869 /* Distance value for the IP source prefix. */
14870 u_char distance;
14871
14872 /* Name of the access-list to be matched. */
14873 char *access_list;
14874};
14875
paul94f2b392005-06-28 12:44:16 +000014876static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080014877bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000014878{
Stephen Hemminger393deb92008-08-18 14:13:29 -070014879 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000014880}
14881
paul94f2b392005-06-28 12:44:16 +000014882static void
paul718e3742002-12-13 20:15:29 +000014883bgp_distance_free (struct bgp_distance *bdistance)
14884{
14885 XFREE (MTYPE_BGP_DISTANCE, bdistance);
14886}
14887
paul94f2b392005-06-28 12:44:16 +000014888static int
paulfd79ac92004-10-13 05:06:08 +000014889bgp_distance_set (struct vty *vty, const char *distance_str,
14890 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014891{
14892 int ret;
14893 struct prefix_ipv4 p;
14894 u_char distance;
14895 struct bgp_node *rn;
14896 struct bgp_distance *bdistance;
14897
14898 ret = str2prefix_ipv4 (ip_str, &p);
14899 if (ret == 0)
14900 {
14901 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14902 return CMD_WARNING;
14903 }
14904
14905 distance = atoi (distance_str);
14906
14907 /* Get BGP distance node. */
14908 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
14909 if (rn->info)
14910 {
14911 bdistance = rn->info;
14912 bgp_unlock_node (rn);
14913 }
14914 else
14915 {
14916 bdistance = bgp_distance_new ();
14917 rn->info = bdistance;
14918 }
14919
14920 /* Set distance value. */
14921 bdistance->distance = distance;
14922
14923 /* Reset access-list configuration. */
14924 if (bdistance->access_list)
14925 {
14926 free (bdistance->access_list);
14927 bdistance->access_list = NULL;
14928 }
14929 if (access_list_str)
14930 bdistance->access_list = strdup (access_list_str);
14931
14932 return CMD_SUCCESS;
14933}
14934
paul94f2b392005-06-28 12:44:16 +000014935static int
paulfd79ac92004-10-13 05:06:08 +000014936bgp_distance_unset (struct vty *vty, const char *distance_str,
14937 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014938{
14939 int ret;
14940 struct prefix_ipv4 p;
14941 u_char distance;
14942 struct bgp_node *rn;
14943 struct bgp_distance *bdistance;
14944
14945 ret = str2prefix_ipv4 (ip_str, &p);
14946 if (ret == 0)
14947 {
14948 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14949 return CMD_WARNING;
14950 }
14951
14952 distance = atoi (distance_str);
14953
14954 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
14955 if (! rn)
14956 {
14957 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
14958 return CMD_WARNING;
14959 }
14960
14961 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010014962
14963 if (bdistance->distance != distance)
14964 {
14965 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
14966 return CMD_WARNING;
14967 }
14968
paul718e3742002-12-13 20:15:29 +000014969 if (bdistance->access_list)
14970 free (bdistance->access_list);
14971 bgp_distance_free (bdistance);
14972
14973 rn->info = NULL;
14974 bgp_unlock_node (rn);
14975 bgp_unlock_node (rn);
14976
14977 return CMD_SUCCESS;
14978}
14979
paul718e3742002-12-13 20:15:29 +000014980/* Apply BGP information to distance method. */
14981u_char
14982bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
14983{
14984 struct bgp_node *rn;
14985 struct prefix_ipv4 q;
14986 struct peer *peer;
14987 struct bgp_distance *bdistance;
14988 struct access_list *alist;
14989 struct bgp_static *bgp_static;
14990
14991 if (! bgp)
14992 return 0;
14993
14994 if (p->family != AF_INET)
14995 return 0;
14996
14997 peer = rinfo->peer;
14998
14999 if (peer->su.sa.sa_family != AF_INET)
15000 return 0;
15001
15002 memset (&q, 0, sizeof (struct prefix_ipv4));
15003 q.family = AF_INET;
15004 q.prefix = peer->su.sin.sin_addr;
15005 q.prefixlen = IPV4_MAX_BITLEN;
15006
15007 /* Check source address. */
15008 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15009 if (rn)
15010 {
15011 bdistance = rn->info;
15012 bgp_unlock_node (rn);
15013
15014 if (bdistance->access_list)
15015 {
15016 alist = access_list_lookup (AFI_IP, bdistance->access_list);
15017 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15018 return bdistance->distance;
15019 }
15020 else
15021 return bdistance->distance;
15022 }
15023
15024 /* Backdoor check. */
15025 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
15026 if (rn)
15027 {
15028 bgp_static = rn->info;
15029 bgp_unlock_node (rn);
15030
15031 if (bgp_static->backdoor)
15032 {
15033 if (bgp->distance_local)
15034 return bgp->distance_local;
15035 else
15036 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15037 }
15038 }
15039
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000015040 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000015041 {
15042 if (bgp->distance_ebgp)
15043 return bgp->distance_ebgp;
15044 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15045 }
15046 else
15047 {
15048 if (bgp->distance_ibgp)
15049 return bgp->distance_ibgp;
15050 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15051 }
15052}
15053
15054DEFUN (bgp_distance,
15055 bgp_distance_cmd,
15056 "distance bgp <1-255> <1-255> <1-255>",
15057 "Define an administrative distance\n"
15058 "BGP distance\n"
15059 "Distance for routes external to the AS\n"
15060 "Distance for routes internal to the AS\n"
15061 "Distance for local routes\n")
15062{
15063 struct bgp *bgp;
15064
15065 bgp = vty->index;
15066
15067 bgp->distance_ebgp = atoi (argv[0]);
15068 bgp->distance_ibgp = atoi (argv[1]);
15069 bgp->distance_local = atoi (argv[2]);
15070 return CMD_SUCCESS;
15071}
15072
15073DEFUN (no_bgp_distance,
15074 no_bgp_distance_cmd,
15075 "no distance bgp <1-255> <1-255> <1-255>",
15076 NO_STR
15077 "Define an administrative distance\n"
15078 "BGP distance\n"
15079 "Distance for routes external to the AS\n"
15080 "Distance for routes internal to the AS\n"
15081 "Distance for local routes\n")
15082{
15083 struct bgp *bgp;
15084
15085 bgp = vty->index;
15086
15087 bgp->distance_ebgp= 0;
15088 bgp->distance_ibgp = 0;
15089 bgp->distance_local = 0;
15090 return CMD_SUCCESS;
15091}
15092
15093ALIAS (no_bgp_distance,
15094 no_bgp_distance2_cmd,
15095 "no distance bgp",
15096 NO_STR
15097 "Define an administrative distance\n"
15098 "BGP distance\n")
15099
15100DEFUN (bgp_distance_source,
15101 bgp_distance_source_cmd,
15102 "distance <1-255> A.B.C.D/M",
15103 "Define an administrative distance\n"
15104 "Administrative distance\n"
15105 "IP source prefix\n")
15106{
15107 bgp_distance_set (vty, argv[0], argv[1], NULL);
15108 return CMD_SUCCESS;
15109}
15110
15111DEFUN (no_bgp_distance_source,
15112 no_bgp_distance_source_cmd,
15113 "no distance <1-255> A.B.C.D/M",
15114 NO_STR
15115 "Define an administrative distance\n"
15116 "Administrative distance\n"
15117 "IP source prefix\n")
15118{
15119 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15120 return CMD_SUCCESS;
15121}
15122
15123DEFUN (bgp_distance_source_access_list,
15124 bgp_distance_source_access_list_cmd,
15125 "distance <1-255> A.B.C.D/M WORD",
15126 "Define an administrative distance\n"
15127 "Administrative distance\n"
15128 "IP source prefix\n"
15129 "Access list name\n")
15130{
15131 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15132 return CMD_SUCCESS;
15133}
15134
15135DEFUN (no_bgp_distance_source_access_list,
15136 no_bgp_distance_source_access_list_cmd,
15137 "no distance <1-255> A.B.C.D/M WORD",
15138 NO_STR
15139 "Define an administrative distance\n"
15140 "Administrative distance\n"
15141 "IP source prefix\n"
15142 "Access list name\n")
15143{
15144 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15145 return CMD_SUCCESS;
15146}
David Lamparter6b0655a2014-06-04 06:53:35 +020015147
paul718e3742002-12-13 20:15:29 +000015148DEFUN (bgp_damp_set,
15149 bgp_damp_set_cmd,
15150 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15151 "BGP Specific commands\n"
15152 "Enable route-flap dampening\n"
15153 "Half-life time for the penalty\n"
15154 "Value to start reusing a route\n"
15155 "Value to start suppressing a route\n"
15156 "Maximum duration to suppress a stable route\n")
15157{
15158 struct bgp *bgp;
15159 int half = DEFAULT_HALF_LIFE * 60;
15160 int reuse = DEFAULT_REUSE;
15161 int suppress = DEFAULT_SUPPRESS;
15162 int max = 4 * half;
15163
15164 if (argc == 4)
15165 {
15166 half = atoi (argv[0]) * 60;
15167 reuse = atoi (argv[1]);
15168 suppress = atoi (argv[2]);
15169 max = atoi (argv[3]) * 60;
15170 }
15171 else if (argc == 1)
15172 {
15173 half = atoi (argv[0]) * 60;
15174 max = 4 * half;
15175 }
15176
15177 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000015178
15179 if (suppress < reuse)
15180 {
15181 vty_out (vty, "Suppress value cannot be less than reuse value %s",
15182 VTY_NEWLINE);
15183 return 0;
15184 }
15185
paul718e3742002-12-13 20:15:29 +000015186 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
15187 half, reuse, suppress, max);
15188}
15189
15190ALIAS (bgp_damp_set,
15191 bgp_damp_set2_cmd,
15192 "bgp dampening <1-45>",
15193 "BGP Specific commands\n"
15194 "Enable route-flap dampening\n"
15195 "Half-life time for the penalty\n")
15196
15197ALIAS (bgp_damp_set,
15198 bgp_damp_set3_cmd,
15199 "bgp dampening",
15200 "BGP Specific commands\n"
15201 "Enable route-flap dampening\n")
15202
15203DEFUN (bgp_damp_unset,
15204 bgp_damp_unset_cmd,
15205 "no bgp dampening",
15206 NO_STR
15207 "BGP Specific commands\n"
15208 "Enable route-flap dampening\n")
15209{
15210 struct bgp *bgp;
15211
15212 bgp = vty->index;
15213 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
15214}
15215
15216ALIAS (bgp_damp_unset,
15217 bgp_damp_unset2_cmd,
15218 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15219 NO_STR
15220 "BGP Specific commands\n"
15221 "Enable route-flap dampening\n"
15222 "Half-life time for the penalty\n"
15223 "Value to start reusing a route\n"
15224 "Value to start suppressing a route\n"
15225 "Maximum duration to suppress a stable route\n")
15226
Lou Bergerf9b6c392016-01-12 13:42:09 -050015227DEFUN (show_ip_bgp_dampened_paths,
15228 show_ip_bgp_dampened_paths_cmd,
15229 "show ip bgp dampened-paths",
15230 SHOW_STR
15231 IP_STR
15232 BGP_STR
15233 "Display paths suppressed due to dampening\n")
15234{
15235 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
15236 NULL);
15237}
15238
15239ALIAS (show_ip_bgp_dampened_paths,
15240 show_ip_bgp_damp_dampened_paths_cmd,
15241 "show ip bgp dampening dampened-paths",
15242 SHOW_STR
15243 IP_STR
15244 BGP_STR
15245 "Display detailed information about dampening\n"
15246 "Display paths suppressed due to dampening\n")
15247
15248DEFUN (show_ip_bgp_flap_statistics,
15249 show_ip_bgp_flap_statistics_cmd,
15250 "show ip bgp flap-statistics",
15251 SHOW_STR
15252 IP_STR
15253 BGP_STR
15254 "Display flap statistics of routes\n")
15255{
15256 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
15257 bgp_show_type_flap_statistics, NULL);
15258}
15259
15260ALIAS (show_ip_bgp_flap_statistics,
15261 show_ip_bgp_damp_flap_statistics_cmd,
15262 "show ip bgp dampening flap-statistics",
15263 SHOW_STR
15264 IP_STR
15265 BGP_STR
15266 "Display detailed information about dampening\n"
15267 "Display flap statistics of routes\n")
15268
Lou Berger651b4022016-01-12 13:42:07 -050015269DEFUN (show_bgp_ipv4_safi_dampened_paths,
15270 show_bgp_ipv4_safi_dampened_paths_cmd,
15271 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015272 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015273 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015274 IP_STR
15275 "Address Family modifier\n"
15276 "Address Family modifier\n"
15277 "Address Family modifier\n"
15278 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015279 "Display paths suppressed due to dampening\n")
15280{
Lou Berger651b4022016-01-12 13:42:07 -050015281 safi_t safi;
paul718e3742002-12-13 20:15:29 +000015282
Lou Berger651b4022016-01-12 13:42:07 -050015283 if (bgp_parse_safi(argv[0], &safi)) {
15284 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15285 return CMD_WARNING;
15286 }
15287
15288 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
15289}
15290ALIAS (show_bgp_ipv4_safi_dampened_paths,
15291 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
15292 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053015293 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015294 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015295 IP_STR
15296 "Address Family modifier\n"
15297 "Address Family modifier\n"
15298 "Address Family modifier\n"
15299 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015300 "Display detailed information about dampening\n"
15301 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050015302
Lou Berger651b4022016-01-12 13:42:07 -050015303DEFUN (show_bgp_ipv6_safi_dampened_paths,
15304 show_bgp_ipv6_safi_dampened_paths_cmd,
15305 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015306 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015307 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015308 IPV6_STR
15309 "Address Family modifier\n"
15310 "Address Family modifier\n"
15311 "Address Family modifier\n"
15312 "Address Family modifier\n"
15313 "Display paths suppressed due to dampening\n")
15314{
15315 safi_t safi;
15316
15317 if (bgp_parse_safi(argv[0], &safi)) {
15318 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15319 return CMD_WARNING;
15320 }
15321
15322 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
15323}
15324ALIAS (show_bgp_ipv6_safi_dampened_paths,
15325 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
15326 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
15327 SHOW_STR
15328 BGP_STR
15329 IPV6_STR
15330 "Address Family modifier\n"
15331 "Address Family modifier\n"
15332 "Address Family modifier\n"
15333 "Address Family modifier\n"
15334 "Display detailed information about dampening\n"
15335 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050015336
15337DEFUN (show_bgp_ipv4_safi_flap_statistics,
15338 show_bgp_ipv4_safi_flap_statistics_cmd,
15339 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
15340 SHOW_STR
15341 BGP_STR
15342 "Address Family\n"
15343 "Address Family modifier\n"
15344 "Address Family modifier\n"
15345 "Address Family modifier\n"
15346 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015347 "Display flap statistics of routes\n")
15348{
Lou Berger651b4022016-01-12 13:42:07 -050015349 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020015350
Lou Berger651b4022016-01-12 13:42:07 -050015351 if (bgp_parse_safi(argv[0], &safi)) {
15352 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15353 return CMD_WARNING;
15354 }
15355
15356 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
15357}
15358ALIAS (show_bgp_ipv4_safi_flap_statistics,
15359 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
15360 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053015361 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015362 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015363 "Address Family\n"
15364 "Address Family modifier\n"
15365 "Address Family modifier\n"
15366 "Address Family modifier\n"
15367 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015368 "Display detailed information about dampening\n"
15369 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050015370
Lou Berger651b4022016-01-12 13:42:07 -050015371DEFUN (show_bgp_ipv6_safi_flap_statistics,
15372 show_bgp_ipv6_safi_flap_statistics_cmd,
15373 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
15374 SHOW_STR
15375 BGP_STR
15376 "Address Family\n"
15377 "Address Family modifier\n"
15378 "Address Family modifier\n"
15379 "Address Family modifier\n"
15380 "Address Family modifier\n"
15381 "Display flap statistics of routes\n")
15382{
15383 safi_t safi;
15384
15385 if (bgp_parse_safi(argv[0], &safi)) {
15386 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15387 return CMD_WARNING;
15388 }
15389
15390 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
15391}
15392ALIAS (show_bgp_ipv6_safi_flap_statistics,
15393 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
15394 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
15395 SHOW_STR
15396 BGP_STR
15397 "Address Family\n"
15398 "Address Family modifier\n"
15399 "Address Family modifier\n"
15400 "Address Family modifier\n"
15401 "Address Family modifier\n"
15402 "Display detailed information about dampening\n"
15403 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053015404
paul718e3742002-12-13 20:15:29 +000015405/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000015406static int
paulfd79ac92004-10-13 05:06:08 +000015407bgp_clear_damp_route (struct vty *vty, const char *view_name,
15408 const char *ip_str, afi_t afi, safi_t safi,
15409 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000015410{
15411 int ret;
15412 struct prefix match;
15413 struct bgp_node *rn;
15414 struct bgp_node *rm;
15415 struct bgp_info *ri;
15416 struct bgp_info *ri_temp;
15417 struct bgp *bgp;
15418 struct bgp_table *table;
15419
15420 /* BGP structure lookup. */
15421 if (view_name)
15422 {
15423 bgp = bgp_lookup_by_name (view_name);
15424 if (bgp == NULL)
15425 {
15426 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
15427 return CMD_WARNING;
15428 }
15429 }
15430 else
15431 {
15432 bgp = bgp_get_default ();
15433 if (bgp == NULL)
15434 {
15435 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
15436 return CMD_WARNING;
15437 }
15438 }
15439
15440 /* Check IP address argument. */
15441 ret = str2prefix (ip_str, &match);
15442 if (! ret)
15443 {
15444 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
15445 return CMD_WARNING;
15446 }
15447
15448 match.family = afi2family (afi);
15449
Lou Berger298cc2f2016-01-12 13:42:02 -050015450 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000015451 {
Lou Berger298cc2f2016-01-12 13:42:02 -050015452 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000015453 {
15454 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
15455 continue;
15456
15457 if ((table = rn->info) != NULL)
15458 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015459 {
15460 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
15461 {
15462 ri = rm->info;
15463 while (ri)
15464 {
15465 if (ri->extra && ri->extra->damp_info)
15466 {
15467 ri_temp = ri->next;
15468 bgp_damp_info_free (ri->extra->damp_info, 1);
15469 ri = ri_temp;
15470 }
15471 else
15472 ri = ri->next;
15473 }
15474 }
15475
15476 bgp_unlock_node (rm);
15477 }
paul718e3742002-12-13 20:15:29 +000015478 }
15479 }
15480 else
15481 {
15482 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015483 {
15484 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
15485 {
15486 ri = rn->info;
15487 while (ri)
15488 {
15489 if (ri->extra && ri->extra->damp_info)
15490 {
15491 ri_temp = ri->next;
15492 bgp_damp_info_free (ri->extra->damp_info, 1);
15493 ri = ri_temp;
15494 }
15495 else
15496 ri = ri->next;
15497 }
15498 }
15499
15500 bgp_unlock_node (rn);
15501 }
paul718e3742002-12-13 20:15:29 +000015502 }
15503
15504 return CMD_SUCCESS;
15505}
15506
15507DEFUN (clear_ip_bgp_dampening,
15508 clear_ip_bgp_dampening_cmd,
15509 "clear ip bgp dampening",
15510 CLEAR_STR
15511 IP_STR
15512 BGP_STR
15513 "Clear route flap dampening information\n")
15514{
15515 bgp_damp_info_clean ();
15516 return CMD_SUCCESS;
15517}
15518
15519DEFUN (clear_ip_bgp_dampening_prefix,
15520 clear_ip_bgp_dampening_prefix_cmd,
15521 "clear ip bgp dampening A.B.C.D/M",
15522 CLEAR_STR
15523 IP_STR
15524 BGP_STR
15525 "Clear route flap dampening information\n"
15526 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15527{
15528 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15529 SAFI_UNICAST, NULL, 1);
15530}
15531
15532DEFUN (clear_ip_bgp_dampening_address,
15533 clear_ip_bgp_dampening_address_cmd,
15534 "clear ip bgp dampening A.B.C.D",
15535 CLEAR_STR
15536 IP_STR
15537 BGP_STR
15538 "Clear route flap dampening information\n"
15539 "Network to clear damping information\n")
15540{
15541 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15542 SAFI_UNICAST, NULL, 0);
15543}
15544
15545DEFUN (clear_ip_bgp_dampening_address_mask,
15546 clear_ip_bgp_dampening_address_mask_cmd,
15547 "clear ip bgp dampening A.B.C.D A.B.C.D",
15548 CLEAR_STR
15549 IP_STR
15550 BGP_STR
15551 "Clear route flap dampening information\n"
15552 "Network to clear damping information\n"
15553 "Network mask\n")
15554{
15555 int ret;
15556 char prefix_str[BUFSIZ];
15557
15558 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
15559 if (! ret)
15560 {
15561 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
15562 return CMD_WARNING;
15563 }
15564
15565 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
15566 SAFI_UNICAST, NULL, 0);
15567}
David Lamparter6b0655a2014-06-04 06:53:35 +020015568
Lou Berger298cc2f2016-01-12 13:42:02 -050015569/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000015570static int
paul718e3742002-12-13 20:15:29 +000015571bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
15572 afi_t afi, safi_t safi, int *write)
15573{
15574 struct bgp_node *prn;
15575 struct bgp_node *rn;
15576 struct bgp_table *table;
15577 struct prefix *p;
15578 struct prefix_rd *prd;
15579 struct bgp_static *bgp_static;
15580 u_int32_t label;
15581 char buf[SU_ADDRSTRLEN];
15582 char rdbuf[RD_ADDRSTRLEN];
15583
15584 /* Network configuration. */
15585 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
15586 if ((table = prn->info) != NULL)
15587 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
15588 if ((bgp_static = rn->info) != NULL)
15589 {
15590 p = &rn->p;
15591 prd = (struct prefix_rd *) &prn->p;
15592
15593 /* "address-family" display. */
15594 bgp_config_write_family_header (vty, afi, safi, write);
15595
15596 /* "network" configuration display. */
15597 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
15598 label = decode_label (bgp_static->tag);
15599
15600 vty_out (vty, " network %s/%d rd %s tag %d",
15601 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15602 p->prefixlen,
15603 rdbuf, label);
15604 vty_out (vty, "%s", VTY_NEWLINE);
15605 }
15606 return 0;
15607}
15608
15609/* Configuration of static route announcement and aggregate
15610 information. */
15611int
15612bgp_config_write_network (struct vty *vty, struct bgp *bgp,
15613 afi_t afi, safi_t safi, int *write)
15614{
15615 struct bgp_node *rn;
15616 struct prefix *p;
15617 struct bgp_static *bgp_static;
15618 struct bgp_aggregate *bgp_aggregate;
15619 char buf[SU_ADDRSTRLEN];
15620
Lou Berger298cc2f2016-01-12 13:42:02 -050015621 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000015622 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
15623
15624 /* Network configuration. */
15625 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
15626 if ((bgp_static = rn->info) != NULL)
15627 {
15628 p = &rn->p;
15629
15630 /* "address-family" display. */
15631 bgp_config_write_family_header (vty, afi, safi, write);
15632
15633 /* "network" configuration display. */
15634 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15635 {
15636 u_int32_t destination;
15637 struct in_addr netmask;
15638
15639 destination = ntohl (p->u.prefix4.s_addr);
15640 masklen2ip (p->prefixlen, &netmask);
15641 vty_out (vty, " network %s",
15642 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
15643
15644 if ((IN_CLASSC (destination) && p->prefixlen == 24)
15645 || (IN_CLASSB (destination) && p->prefixlen == 16)
15646 || (IN_CLASSA (destination) && p->prefixlen == 8)
15647 || p->u.prefix4.s_addr == 0)
15648 {
15649 /* Natural mask is not display. */
15650 }
15651 else
15652 vty_out (vty, " mask %s", inet_ntoa (netmask));
15653 }
15654 else
15655 {
15656 vty_out (vty, " network %s/%d",
15657 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15658 p->prefixlen);
15659 }
15660
15661 if (bgp_static->rmap.name)
15662 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000015663 else
15664 {
15665 if (bgp_static->backdoor)
15666 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000015667 }
paul718e3742002-12-13 20:15:29 +000015668
15669 vty_out (vty, "%s", VTY_NEWLINE);
15670 }
15671
15672 /* Aggregate-address configuration. */
15673 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
15674 if ((bgp_aggregate = rn->info) != NULL)
15675 {
15676 p = &rn->p;
15677
15678 /* "address-family" display. */
15679 bgp_config_write_family_header (vty, afi, safi, write);
15680
15681 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15682 {
15683 struct in_addr netmask;
15684
15685 masklen2ip (p->prefixlen, &netmask);
15686 vty_out (vty, " aggregate-address %s %s",
15687 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15688 inet_ntoa (netmask));
15689 }
15690 else
15691 {
15692 vty_out (vty, " aggregate-address %s/%d",
15693 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15694 p->prefixlen);
15695 }
15696
15697 if (bgp_aggregate->as_set)
15698 vty_out (vty, " as-set");
15699
15700 if (bgp_aggregate->summary_only)
15701 vty_out (vty, " summary-only");
15702
15703 vty_out (vty, "%s", VTY_NEWLINE);
15704 }
15705
15706 return 0;
15707}
15708
15709int
15710bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
15711{
15712 struct bgp_node *rn;
15713 struct bgp_distance *bdistance;
15714
15715 /* Distance configuration. */
15716 if (bgp->distance_ebgp
15717 && bgp->distance_ibgp
15718 && bgp->distance_local
15719 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
15720 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
15721 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
15722 vty_out (vty, " distance bgp %d %d %d%s",
15723 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
15724 VTY_NEWLINE);
15725
15726 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
15727 if ((bdistance = rn->info) != NULL)
15728 {
15729 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
15730 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
15731 bdistance->access_list ? bdistance->access_list : "",
15732 VTY_NEWLINE);
15733 }
15734
15735 return 0;
15736}
15737
15738/* Allocate routing table structure and install commands. */
15739void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080015740bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000015741{
15742 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000015743 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000015744
15745 /* IPv4 BGP commands. */
15746 install_element (BGP_NODE, &bgp_network_cmd);
15747 install_element (BGP_NODE, &bgp_network_mask_cmd);
15748 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
15749 install_element (BGP_NODE, &bgp_network_route_map_cmd);
15750 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
15751 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
15752 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
15753 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
15754 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
15755 install_element (BGP_NODE, &no_bgp_network_cmd);
15756 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
15757 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
15758 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
15759 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
15760 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15761 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
15762 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
15763 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
15764
15765 install_element (BGP_NODE, &aggregate_address_cmd);
15766 install_element (BGP_NODE, &aggregate_address_mask_cmd);
15767 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
15768 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
15769 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
15770 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
15771 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
15772 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
15773 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
15774 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
15775 install_element (BGP_NODE, &no_aggregate_address_cmd);
15776 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
15777 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
15778 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
15779 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
15780 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
15781 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
15782 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
15783 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15784 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15785
15786 /* IPv4 unicast configuration. */
15787 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
15788 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
15789 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
15790 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
15791 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
15792 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015793 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000015794 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
15795 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
15796 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
15797 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
15798 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015799
paul718e3742002-12-13 20:15:29 +000015800 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
15801 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
15802 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
15803 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
15804 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
15805 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
15806 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
15807 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
15808 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
15809 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
15810 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
15811 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
15812 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
15813 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
15814 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
15815 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
15816 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
15817 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
15818 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15819 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15820
15821 /* IPv4 multicast configuration. */
15822 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
15823 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
15824 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
15825 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
15826 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
15827 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
15828 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
15829 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
15830 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
15831 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
15832 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
15833 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15834 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
15835 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
15836 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
15837 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
15838 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
15839 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
15840 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
15841 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
15842 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
15843 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
15844 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
15845 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
15846 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
15847 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
15848 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
15849 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
15850 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
15851 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
15852 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15853 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15854
Michael Lambert95cbbd22010-07-23 14:43:04 -040015855 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015856 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015857 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
15858 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
15859 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15860 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15861 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
15862 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
15863 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15864 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15865 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015866 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015867 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15868 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15869 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15870 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15871 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15872 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15873 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
15874 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
15875 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15876 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
15877 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
15878 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
15879 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
15880 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
15881 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
15882 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
15883 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
15884 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
15885 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
15886 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
15887 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
15888 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
15889 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
15890 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
15891 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
15892 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
15893 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
15894 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015895 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15896 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
15897 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
15898 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
15899 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015900 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
15901 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
15902 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
15903 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
15904 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
15905 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
15906 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
15907 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
15908 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
15909 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
15910 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
15911 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
15912 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
15913 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
15914 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
15915 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
15916 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
15917 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
15918 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015919 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015920 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
15921 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
15922 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
15923 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
15924 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
15925 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
15926 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
15927 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
15928 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
15929 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
15930 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
15931 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
15932 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
15933 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
15934 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
15935 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
15936 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
15937 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
15938 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
15939 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
15940 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
15941 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
15942 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
15943 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
15944 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
15945 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
15946 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
15947 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
15948 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
15949 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
15950 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
15951 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
15952 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
15953 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
15954 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
15955 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
15956 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
15957 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
15958 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
15959 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
15960 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
15961 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
15962 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
15963 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
15964 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015965 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015966 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015967 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015968 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015969 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015970 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010015971
15972 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040015973 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015974 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15975 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15976 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15977 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15978 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015979 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015980 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15981 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15982 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15983 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15984 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15985 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15986 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
15987 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15988 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
15989 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
15990 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
15991 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
15992 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
15993 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
15994 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
15995 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015996 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15997 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
15998 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
15999 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
16000 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016001 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
16002 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
16003 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
16004 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
16005 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16006 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16007 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16008 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016009 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016010 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016011 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016012 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016013
Michael Lambert95cbbd22010-07-23 14:43:04 -040016014 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016015 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016016 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd);
16017 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd);
16018 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16019 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16020 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_route_cmd);
16021 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_route_cmd);
16022 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16023 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16024 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016025 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016026 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16027 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16028 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16029 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16030 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16031 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16032 install_element (ENABLE_NODE, &show_bgp_afi_safi_view_cmd);
16033 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_route_cmd);
16034 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16035 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_regexp_cmd);
16036 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_regexp_cmd);
16037 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_list_cmd);
16038 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
16039 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
16040 install_element (ENABLE_NODE, &show_bgp_ipv4_filter_list_cmd);
16041 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
16042 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
16043 install_element (ENABLE_NODE, &show_bgp_ipv4_route_map_cmd);
16044 install_element (ENABLE_NODE, &show_bgp_ipv4_cidr_only_cmd);
16045 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
16046 install_element (ENABLE_NODE, &show_bgp_ipv4_community_cmd);
16047 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_cmd);
16048 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_cmd);
16049 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_cmd);
16050 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_cmd);
16051 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_cmd);
16052 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_cmd);
16053 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016054 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16055 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd);
16056 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd);
16057 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd);
16058 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016059 install_element (ENABLE_NODE, &show_bgp_ipv4_community_exact_cmd);
16060 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_exact_cmd);
16061 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_exact_cmd);
16062 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_exact_cmd);
16063 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16064 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16065 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16066 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16067 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_cmd);
16068 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16069 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16070 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16071 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16072 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16073 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16074 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16075 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16076 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16077 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016078 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016079 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16080 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16081 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16082 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16083 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16084 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16085 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16086 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16087 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16088 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16089 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16090 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16091 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16092 install_element (ENABLE_NODE, &show_bgp_ipv6_flap_address_cmd);
16093 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16094 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16095 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16096 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16097 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16098 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16099 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16100 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16101 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16102 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16103 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16104 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16105 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16106 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16107 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16108 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16109 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16110 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16111 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16112 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16113 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16114 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16115 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16116 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16117 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16118 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16119 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16120 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16121 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16122 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16123 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016124 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016125 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016126 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016127 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016128 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016129 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016130
16131 /* BGP dampening clear commands */
16132 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
16133 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
16134 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
16135 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
16136
Paul Jakmaff7924f2006-09-04 01:10:36 +000016137 /* prefix count */
Lou Berger651b4022016-01-12 13:42:07 -050016138 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_prefix_counts_cmd);
16139 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_prefix_counts_cmd);
Paul Jakmaff7924f2006-09-04 01:10:36 +000016140 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd);
16141
paul718e3742002-12-13 20:15:29 +000016142 /* New config IPv6 BGP commands. */
16143 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
16144 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
16145 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
16146 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
16147
16148 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
16149 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
16150 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
16151 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
16152
G.Balaji73bfe0b2011-09-23 22:36:20 +053016153 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
16154 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
16155
paul718e3742002-12-13 20:15:29 +000016156 /* Old config IPv6 BGP commands. */
16157 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
16158 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
16159
16160 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
16161 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
16162 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
16163 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
16164
Michael Lambert95cbbd22010-07-23 14:43:04 -040016165 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016166 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016167 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016168 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016169 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016170 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016171 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016172 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016173 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016174 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
16175 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
16176 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
16177 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
16178 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16179 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16180 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16181 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016182 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
paul718e3742002-12-13 20:15:29 +000016183 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016184 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016185 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016186 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016187 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016188 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016189 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016190 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
16191 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016192 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016193 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016194 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016195 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016196 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016197 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016198 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016199 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016200 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016201 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016202 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016203 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016204 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016205 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016206 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16207 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016208 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016209 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016210 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016211 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016212 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016213
16214 /* Restricted:
16215 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
16216 */
Paul Jakma62687ff2008-08-23 14:27:06 +010016217 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016218 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016219 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016220 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016221 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
16222 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
16223 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
16224 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
16225 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16226 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16227 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16228 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
16229 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016230 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016231 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016232 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016233 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016234 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016235 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016236 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016237 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016238 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016239 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016240
Michael Lambert95cbbd22010-07-23 14:43:04 -040016241 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016242 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016243 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016244 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016245 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016246 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016247 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016248 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016249 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016250 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_cmd);
16251 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_cmd);
16252 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_cmd);
16253 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_cmd);
16254 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16255 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16256 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16257 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016258 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016259 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016260 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016261 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016262 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016263 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016264 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016265 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016266 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016267 install_element (ENABLE_NODE, &show_bgp_ipv4_rsclient_cmd);
16268 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016269 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016270 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016271 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016272 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016273 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016274 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016275 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016276 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016277 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016278 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016279 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016280 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016281 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016282 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016283 install_element (ENABLE_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16284 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016285 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016286 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016287 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016288 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016289 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma2815e612006-09-14 02:56:07 +000016290
16291 /* Statistics */
16292 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016293 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000016294
16295 install_element (BGP_NODE, &bgp_distance_cmd);
16296 install_element (BGP_NODE, &no_bgp_distance_cmd);
16297 install_element (BGP_NODE, &no_bgp_distance2_cmd);
16298 install_element (BGP_NODE, &bgp_distance_source_cmd);
16299 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
16300 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
16301 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
16302
16303 install_element (BGP_NODE, &bgp_damp_set_cmd);
16304 install_element (BGP_NODE, &bgp_damp_set2_cmd);
16305 install_element (BGP_NODE, &bgp_damp_set3_cmd);
16306 install_element (BGP_NODE, &bgp_damp_unset_cmd);
16307 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
16308 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
16309 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
16310 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
16311 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
16312 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016313
16314 /* Deprecated AS-Pathlimit commands */
16315 install_element (BGP_NODE, &bgp_network_ttl_cmd);
16316 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
16317 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
16318 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
16319 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16320 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16321
16322 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
16323 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
16324 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16325 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
16326 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16327 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16328
16329 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
16330 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
16331 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
16332 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
16333 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16334 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16335
16336 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
16337 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
16338 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16339 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
16340 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16341 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16342
16343 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
16344 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
16345 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
16346 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
16347 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16348 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16349
16350 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
16351 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
16352 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16353 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
16354 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16355 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000016356
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016357 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
16358 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016359
16360 /* old style commands */
16361 install_element (VIEW_NODE, &show_ip_bgp_cmd);
16362 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
16363 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
16364 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
16365 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16366 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16367 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
16368 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16369 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16370 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16371 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
16372 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
16373 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
16374 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
16375 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16376 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
16377 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16378 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
16379 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16380 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
16381 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16382 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
16383 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16384 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
16385 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16386 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
16387 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
16388 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
16389 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
16390 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
16391 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
16392 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
16393 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
16394 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
16395 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
16396 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
16397 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
16398 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16399 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16400 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16401 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16402 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
16403 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16404 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
16405 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16406 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
16407 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16408 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16409 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16410 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16411 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16412 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
16413 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16414 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16415 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16416 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
16417 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
16418 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16419 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
16420 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16421 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
16422 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
16423 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
16424 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16425 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16426 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
16427 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
16428 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16429 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16430 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16431 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16432 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16433 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
16434 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16435 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
16436 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
16437 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
16438 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
16439 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16440 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16441 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16442 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
16443 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16444 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16445 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
16446 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
16447 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16448 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
16449 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16450 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16451 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16452 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
16453 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
16454 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
16455 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
16456 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
16457 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
16458 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
16459 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
16460 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
16461 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
16462 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
16463 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
16464 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
16465 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
16466 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16467 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16468 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16469 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16470 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
16471 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16472 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16473 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16474 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
16475 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
16476 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
16477 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
16478 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16479 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16480 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
16481 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16482 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16483 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16484 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
16485 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
16486 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
16487 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
16488 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16489 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
16490 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16491 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
16492 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16493 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
16494 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16495 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
16496 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16497 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
16498 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16499 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
16500 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
16501 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
16502 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
16503 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
16504 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
16505 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
16506 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
16507 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
16508 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
16509 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
16510 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
16511 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16512 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16513 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16514 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16515 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
16516 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16517 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
16518 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16519 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
16520 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16521 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16522 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16523 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16524 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16525 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
16526 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16527 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16528 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16529 install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd);
16530 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
16531 install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16532 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
16533 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16534 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
16535 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd);
16536 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
16537 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16538 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16539 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
16540 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd);
16541 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
16542 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16543 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16544 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16545 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16546 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16547 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
16548 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16549 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
16550 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
16551 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
16552 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
16553 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16554 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16555 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16556 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
16557 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16558 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16559 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
16560 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
16561 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
16562 install_element (VIEW_NODE, &show_bgp_cmd);
16563 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
16564 install_element (VIEW_NODE, &show_bgp_route_cmd);
16565 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
16566 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
16567 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
16568 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
16569 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
16570 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
16571 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
16572 install_element (VIEW_NODE, &show_bgp_community_cmd);
16573 install_element (VIEW_NODE, &show_bgp_community2_cmd);
16574 install_element (VIEW_NODE, &show_bgp_community3_cmd);
16575 install_element (VIEW_NODE, &show_bgp_community4_cmd);
16576 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
16577 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
16578 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
16579 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
16580 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16581 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
16582 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
16583 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
16584 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
16585 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
16586 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
16587 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16588 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
16589 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
16590 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
16591 install_element (VIEW_NODE, &show_bgp_view_cmd);
16592 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
16593 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
16594 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16595 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16596 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
16597 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16598 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
16599 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
16600 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
16601 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
16602 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
16603 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
16604 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
16605 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
16606 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
16607 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
16608 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
16609 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
16610 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
16611 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
16612 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
16613 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16614 install_element (ENABLE_NODE, &show_bgp_cmd);
16615 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
16616 install_element (ENABLE_NODE, &show_bgp_route_cmd);
16617 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
16618 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
16619 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
16620 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
16621 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
16622 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
16623 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
16624 install_element (ENABLE_NODE, &show_bgp_community_cmd);
16625 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
16626 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
16627 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
16628 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
16629 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
16630 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
16631 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
16632 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16633 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
16634 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
16635 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
16636 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
16637 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
16638 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16639 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
16640 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
16641 install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
16642 install_element (ENABLE_NODE, &show_bgp_view_cmd);
16643 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
16644 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
16645 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16646 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16647 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
16648 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16649 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
16650 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
16651 install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
16652 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
16653 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
16654 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
16655 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
16656 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
16657 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
16658 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
16659 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
16660 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
16661 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
16662 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
16663 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
16664 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
16665 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
16666 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
16667 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
16668 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
16669 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
16670 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16671 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16672 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
16673 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
16674 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
16675 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
16676 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16677 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
16678 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
16679 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
16680 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
16681 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
16682 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
16683 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
16684 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16685 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16686 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16687 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
16688 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16689 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16690 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
16691 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
16692 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
16693 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
16694 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
16695 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
16696 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
16697 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
16698 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
16699 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
16700 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
16701 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
16702 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
16703 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
16704 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
16705 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
16706 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16707 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16708 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
16709 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
16710 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
16711 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
16712 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16713 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
16714 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
16715 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
16716 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
16717 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
16718 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
16719 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
16720 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16721 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16722 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16723 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
16724 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16725 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16726 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16727 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16728 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16729 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16730 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16731 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16732 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16733 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16734 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
16735 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
16736 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16737 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16738 /* old with name safi collision */
16739 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
16740 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
16741 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
16742 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
16743 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
16744 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
16745 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
16746 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
16747 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
16748 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
16749 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
16750 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
16751 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
16752 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
16753 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
16754 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
16755 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
16756 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
16757 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
16758 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
16759 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
16760 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
16761 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
16762 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
16763 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16764 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
16765 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16766 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
16767
16768 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
16769 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
16770 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
16771 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
16772 install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
16773 install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
16774
16775 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
16776 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
16777 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
16778 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
16779 install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
16780 install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016781}
Chris Caputo228da422009-07-18 05:44:03 +000016782
16783void
16784bgp_route_finish (void)
16785{
16786 bgp_table_unlock (bgp_distance_table);
16787 bgp_distance_table = NULL;
16788}