blob: c364372f8bf7adbb6a6b82dd2187d9c7d64c2aac [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
23#include "prefix.h"
24#include "linklist.h"
25#include "memory.h"
26#include "command.h"
27#include "stream.h"
28#include "filter.h"
29#include "str.h"
30#include "log.h"
31#include "routemap.h"
32#include "buffer.h"
33#include "sockunion.h"
34#include "plist.h"
35#include "thread.h"
paul200df112005-06-01 11:17:05 +000036#include "workqueue.h"
paul718e3742002-12-13 20:15:29 +000037
38#include "bgpd/bgpd.h"
39#include "bgpd/bgp_table.h"
40#include "bgpd/bgp_route.h"
41#include "bgpd/bgp_attr.h"
42#include "bgpd/bgp_debug.h"
43#include "bgpd/bgp_aspath.h"
44#include "bgpd/bgp_regex.h"
45#include "bgpd/bgp_community.h"
46#include "bgpd/bgp_ecommunity.h"
47#include "bgpd/bgp_clist.h"
48#include "bgpd/bgp_packet.h"
49#include "bgpd/bgp_filter.h"
50#include "bgpd/bgp_fsm.h"
51#include "bgpd/bgp_mplsvpn.h"
52#include "bgpd/bgp_nexthop.h"
53#include "bgpd/bgp_damp.h"
54#include "bgpd/bgp_advertise.h"
55#include "bgpd/bgp_zebra.h"
hasso0a486e52005-02-01 20:57:17 +000056#include "bgpd/bgp_vty.h"
Josh Bailey96450fa2011-07-20 20:45:12 -070057#include "bgpd/bgp_mpath.h"
paul718e3742002-12-13 20:15:29 +000058
59/* Extern from bgp_dump.c */
Stephen Hemmingerdde72582009-05-08 15:19:07 -070060extern const char *bgp_origin_str[];
61extern const char *bgp_origin_long_str[];
David Lamparter6b0655a2014-06-04 06:53:35 +020062
paul94f2b392005-06-28 12:44:16 +000063static struct bgp_node *
paulfee0f4c2004-09-13 05:12:46 +000064bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
paul718e3742002-12-13 20:15:29 +000065 struct prefix_rd *prd)
66{
67 struct bgp_node *rn;
68 struct bgp_node *prn = NULL;
Paul Jakmada5b30f2006-05-08 14:37:17 +000069
70 assert (table);
71 if (!table)
72 return NULL;
73
Lou Berger298cc2f2016-01-12 13:42:02 -050074 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000075 {
paulfee0f4c2004-09-13 05:12:46 +000076 prn = bgp_node_get (table, (struct prefix *) prd);
paul718e3742002-12-13 20:15:29 +000077
78 if (prn->info == NULL)
Paul Jakma64e580a2006-02-21 01:09:01 +000079 prn->info = bgp_table_init (afi, safi);
paul718e3742002-12-13 20:15:29 +000080 else
81 bgp_unlock_node (prn);
82 table = prn->info;
83 }
paul718e3742002-12-13 20:15:29 +000084
85 rn = bgp_node_get (table, p);
86
Lou Berger298cc2f2016-01-12 13:42:02 -050087 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000088 rn->prn = prn;
89
90 return rn;
91}
David Lamparter6b0655a2014-06-04 06:53:35 +020092
Paul Jakmafb982c22007-05-04 20:15:47 +000093/* Allocate bgp_info_extra */
94static struct bgp_info_extra *
95bgp_info_extra_new (void)
96{
97 struct bgp_info_extra *new;
98 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra));
99 return new;
100}
101
102static void
103bgp_info_extra_free (struct bgp_info_extra **extra)
104{
105 if (extra && *extra)
106 {
107 if ((*extra)->damp_info)
108 bgp_damp_info_free ((*extra)->damp_info, 0);
109
110 (*extra)->damp_info = NULL;
111
112 XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra);
113
114 *extra = NULL;
115 }
116}
117
118/* Get bgp_info extra information for the given bgp_info, lazy allocated
119 * if required.
120 */
121struct bgp_info_extra *
122bgp_info_extra_get (struct bgp_info *ri)
123{
124 if (!ri->extra)
125 ri->extra = bgp_info_extra_new();
126 return ri->extra;
127}
128
paul718e3742002-12-13 20:15:29 +0000129/* Allocate new bgp info structure. */
paul200df112005-06-01 11:17:05 +0000130static struct bgp_info *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -0800131bgp_info_new (void)
paul718e3742002-12-13 20:15:29 +0000132{
Stephen Hemminger393deb92008-08-18 14:13:29 -0700133 return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
paul718e3742002-12-13 20:15:29 +0000134}
135
136/* Free bgp route information. */
paul200df112005-06-01 11:17:05 +0000137static void
paul718e3742002-12-13 20:15:29 +0000138bgp_info_free (struct bgp_info *binfo)
139{
140 if (binfo->attr)
Paul Jakmaf6f434b2010-11-23 21:28:03 +0000141 bgp_attr_unintern (&binfo->attr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000142
143 bgp_info_extra_free (&binfo->extra);
Josh Baileyde8d5df2011-07-20 20:46:01 -0700144 bgp_info_mpath_free (&binfo->mpath);
paul718e3742002-12-13 20:15:29 +0000145
paul200df112005-06-01 11:17:05 +0000146 peer_unlock (binfo->peer); /* bgp_info peer reference */
147
paul718e3742002-12-13 20:15:29 +0000148 XFREE (MTYPE_BGP_ROUTE, binfo);
149}
150
paul200df112005-06-01 11:17:05 +0000151struct bgp_info *
152bgp_info_lock (struct bgp_info *binfo)
153{
154 binfo->lock++;
155 return binfo;
156}
157
158struct bgp_info *
159bgp_info_unlock (struct bgp_info *binfo)
160{
161 assert (binfo && binfo->lock > 0);
162 binfo->lock--;
163
164 if (binfo->lock == 0)
165 {
166#if 0
167 zlog_debug ("%s: unlocked and freeing", __func__);
168 zlog_backtrace (LOG_DEBUG);
169#endif
170 bgp_info_free (binfo);
171 return NULL;
172 }
173
174#if 0
175 if (binfo->lock == 1)
176 {
177 zlog_debug ("%s: unlocked to 1", __func__);
178 zlog_backtrace (LOG_DEBUG);
179 }
180#endif
181
182 return binfo;
183}
184
paul718e3742002-12-13 20:15:29 +0000185void
186bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
187{
188 struct bgp_info *top;
189
190 top = rn->info;
paul200df112005-06-01 11:17:05 +0000191
paul718e3742002-12-13 20:15:29 +0000192 ri->next = rn->info;
193 ri->prev = NULL;
194 if (top)
195 top->prev = ri;
196 rn->info = ri;
paul200df112005-06-01 11:17:05 +0000197
198 bgp_info_lock (ri);
199 bgp_lock_node (rn);
200 peer_lock (ri->peer); /* bgp_info peer reference */
paul718e3742002-12-13 20:15:29 +0000201}
202
paulb40d9392005-08-22 22:34:41 +0000203/* Do the actual removal of info from RIB, for use by bgp_process
204 completion callback *only* */
205static void
206bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri)
paul718e3742002-12-13 20:15:29 +0000207{
208 if (ri->next)
209 ri->next->prev = ri->prev;
210 if (ri->prev)
211 ri->prev->next = ri->next;
212 else
213 rn->info = ri->next;
paul200df112005-06-01 11:17:05 +0000214
Josh Baileyde8d5df2011-07-20 20:46:01 -0700215 bgp_info_mpath_dequeue (ri);
paul200df112005-06-01 11:17:05 +0000216 bgp_info_unlock (ri);
217 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +0000218}
219
paulb40d9392005-08-22 22:34:41 +0000220void
221bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
222{
Paul Jakma1a392d42006-09-07 00:24:49 +0000223 bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED);
224 /* set of previous already took care of pcount */
paulb40d9392005-08-22 22:34:41 +0000225 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
226}
227
Andrew J. Schorr8d452102006-11-28 19:50:46 +0000228/* undo the effects of a previous call to bgp_info_delete; typically
229 called when a route is deleted and then quickly re-added before the
230 deletion has been processed */
231static void
232bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri)
233{
234 bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED);
235 /* unset of previous already took care of pcount */
236 SET_FLAG (ri->flags, BGP_INFO_VALID);
237}
238
Paul Jakma1a392d42006-09-07 00:24:49 +0000239/* Adjust pcount as required */
240static void
241bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri)
242{
Avneesh Sachdev67174042012-08-17 08:19:49 -0700243 struct bgp_table *table;
244
245 assert (rn && bgp_node_table (rn));
Paul Jakma6f585442006-10-22 19:13:07 +0000246 assert (ri && ri->peer && ri->peer->bgp);
247
Avneesh Sachdev67174042012-08-17 08:19:49 -0700248 table = bgp_node_table (rn);
249
Paul Jakma1a392d42006-09-07 00:24:49 +0000250 /* Ignore 'pcount' for RS-client tables */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700251 if (table->type != BGP_TABLE_MAIN
Paul Jakma1a392d42006-09-07 00:24:49 +0000252 || ri->peer == ri->peer->bgp->peer_self)
253 return;
254
255 if (BGP_INFO_HOLDDOWN (ri)
256 && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
257 {
258
259 UNSET_FLAG (ri->flags, BGP_INFO_COUNTED);
260
261 /* slight hack, but more robust against errors. */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700262 if (ri->peer->pcount[table->afi][table->safi])
263 ri->peer->pcount[table->afi][table->safi]--;
Paul Jakma1a392d42006-09-07 00:24:49 +0000264 else
265 {
266 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
267 __func__, ri->peer->host);
268 zlog_backtrace (LOG_WARNING);
269 zlog_warn ("%s: Please report to Quagga bugzilla", __func__);
270 }
271 }
272 else if (!BGP_INFO_HOLDDOWN (ri)
273 && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
274 {
275 SET_FLAG (ri->flags, BGP_INFO_COUNTED);
Avneesh Sachdev67174042012-08-17 08:19:49 -0700276 ri->peer->pcount[table->afi][table->safi]++;
Paul Jakma1a392d42006-09-07 00:24:49 +0000277 }
278}
279
280
281/* Set/unset bgp_info flags, adjusting any other state as needed.
282 * This is here primarily to keep prefix-count in check.
283 */
284void
285bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
286{
287 SET_FLAG (ri->flags, flag);
288
289 /* early bath if we know it's not a flag that changes useability state */
290 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
291 return;
292
293 bgp_pcount_adjust (rn, ri);
294}
295
296void
297bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
298{
299 UNSET_FLAG (ri->flags, flag);
300
301 /* early bath if we know it's not a flag that changes useability state */
302 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
303 return;
304
305 bgp_pcount_adjust (rn, ri);
306}
307
paul718e3742002-12-13 20:15:29 +0000308/* Get MED value. If MED value is missing and "bgp bestpath
309 missing-as-worst" is specified, treat it as the worst value. */
paul94f2b392005-06-28 12:44:16 +0000310static u_int32_t
paul718e3742002-12-13 20:15:29 +0000311bgp_med_value (struct attr *attr, struct bgp *bgp)
312{
313 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
314 return attr->med;
315 else
316 {
317 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
paul3b424972003-10-13 09:47:32 +0000318 return BGP_MED_MAX;
paul718e3742002-12-13 20:15:29 +0000319 else
320 return 0;
321 }
322}
323
Paul Jakma6d4742b2015-11-25 17:14:37 +0000324/* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
325 * is preferred, or 0 if they are the same (usually will only occur if
326 * multipath is enabled */
paul94f2b392005-06-28 12:44:16 +0000327static int
Josh Bailey96450fa2011-07-20 20:45:12 -0700328bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
Paul Jakma6d4742b2015-11-25 17:14:37 +0000329 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +0000330{
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000331 struct attr *newattr, *existattr;
332 struct attr_extra *newattre, *existattre;
333 bgp_peer_sort_t new_sort;
334 bgp_peer_sort_t exist_sort;
paul718e3742002-12-13 20:15:29 +0000335 u_int32_t new_pref;
336 u_int32_t exist_pref;
337 u_int32_t new_med;
338 u_int32_t exist_med;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000339 u_int32_t new_weight;
340 u_int32_t exist_weight;
341 uint32_t newm, existm;
paul718e3742002-12-13 20:15:29 +0000342 struct in_addr new_id;
343 struct in_addr exist_id;
344 int new_cluster;
345 int exist_cluster;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000346 int internal_as_route;
347 int confed_as_route;
paul718e3742002-12-13 20:15:29 +0000348 int ret;
Josh Bailey96450fa2011-07-20 20:45:12 -0700349
paul718e3742002-12-13 20:15:29 +0000350 /* 0. Null check. */
351 if (new == NULL)
paul718e3742002-12-13 20:15:29 +0000352 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000353 if (exist == NULL)
354 return -1;
paul718e3742002-12-13 20:15:29 +0000355
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000356 newattr = new->attr;
357 existattr = exist->attr;
358 newattre = newattr->extra;
359 existattre = existattr->extra;
360
paul718e3742002-12-13 20:15:29 +0000361 /* 1. Weight check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000362 new_weight = exist_weight = 0;
363
364 if (newattre)
365 new_weight = newattre->weight;
366 if (existattre)
367 exist_weight = existattre->weight;
368
Paul Jakmafb982c22007-05-04 20:15:47 +0000369 if (new_weight > exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000370 return -1;
Paul Jakmafb982c22007-05-04 20:15:47 +0000371 if (new_weight < exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000372 return 1;
paul718e3742002-12-13 20:15:29 +0000373
374 /* 2. Local preference check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000375 new_pref = exist_pref = bgp->default_local_pref;
paul718e3742002-12-13 20:15:29 +0000376
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000377 if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
378 new_pref = newattr->local_pref;
379 if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
380 exist_pref = existattr->local_pref;
381
paul718e3742002-12-13 20:15:29 +0000382 if (new_pref > exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000383 return -1;
paul718e3742002-12-13 20:15:29 +0000384 if (new_pref < exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000385 return 1;
paul718e3742002-12-13 20:15:29 +0000386
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000387 /* 3. Local route check. We prefer:
388 * - BGP_ROUTE_STATIC
389 * - BGP_ROUTE_AGGREGATE
390 * - BGP_ROUTE_REDISTRIBUTE
391 */
392 if (! (new->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000393 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000394 if (! (exist->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000395 return 1;
paul718e3742002-12-13 20:15:29 +0000396
397 /* 4. AS path length check. */
398 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
399 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000400 int exist_hops = aspath_count_hops (existattr->aspath);
401 int exist_confeds = aspath_count_confeds (existattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000402
hasso68118452005-04-08 15:40:36 +0000403 if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
404 {
paulfe69a502005-09-10 16:55:02 +0000405 int aspath_hops;
406
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000407 aspath_hops = aspath_count_hops (newattr->aspath);
408 aspath_hops += aspath_count_confeds (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000409
410 if ( aspath_hops < (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000411 return -1;
paulfe69a502005-09-10 16:55:02 +0000412 if ( aspath_hops > (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000413 return 1;
hasso68118452005-04-08 15:40:36 +0000414 }
415 else
416 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000417 int newhops = aspath_count_hops (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000418
419 if (newhops < exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000420 return -1;
paulfe69a502005-09-10 16:55:02 +0000421 if (newhops > exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000422 return 1;
hasso68118452005-04-08 15:40:36 +0000423 }
paul718e3742002-12-13 20:15:29 +0000424 }
425
426 /* 5. Origin check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000427 if (newattr->origin < existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000428 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000429 if (newattr->origin > existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000430 return 1;
paul718e3742002-12-13 20:15:29 +0000431
432 /* 6. MED check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000433 internal_as_route = (aspath_count_hops (newattr->aspath) == 0
434 && aspath_count_hops (existattr->aspath) == 0);
435 confed_as_route = (aspath_count_confeds (newattr->aspath) > 0
436 && aspath_count_confeds (existattr->aspath) > 0
437 && aspath_count_hops (newattr->aspath) == 0
438 && aspath_count_hops (existattr->aspath) == 0);
paul718e3742002-12-13 20:15:29 +0000439
440 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
441 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
442 && confed_as_route)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000443 || aspath_cmp_left (newattr->aspath, existattr->aspath)
444 || aspath_cmp_left_confed (newattr->aspath, existattr->aspath)
paul718e3742002-12-13 20:15:29 +0000445 || internal_as_route)
446 {
447 new_med = bgp_med_value (new->attr, bgp);
448 exist_med = bgp_med_value (exist->attr, bgp);
449
450 if (new_med < exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000451 return -1;
paul718e3742002-12-13 20:15:29 +0000452 if (new_med > exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000453 return 1;
paul718e3742002-12-13 20:15:29 +0000454 }
455
456 /* 7. Peer type check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000457 new_sort = new->peer->sort;
458 exist_sort = exist->peer->sort;
459
460 if (new_sort == BGP_PEER_EBGP
461 && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000462 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000463 if (exist_sort == BGP_PEER_EBGP
464 && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000465 return 1;
paul718e3742002-12-13 20:15:29 +0000466
467 /* 8. IGP metric check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000468 newm = existm = 0;
469
470 if (new->extra)
471 newm = new->extra->igpmetric;
472 if (exist->extra)
473 existm = exist->extra->igpmetric;
474
Josh Bailey96450fa2011-07-20 20:45:12 -0700475 if (newm < existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000476 return -1;
Josh Bailey96450fa2011-07-20 20:45:12 -0700477 if (newm > existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000478 return 1;
paul718e3742002-12-13 20:15:29 +0000479
480 /* 9. Maximum path check. */
Paul Jakma6d4742b2015-11-25 17:14:37 +0000481 if (bgp_mpath_is_configured (bgp, afi, safi))
Josh Bailey96450fa2011-07-20 20:45:12 -0700482 {
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000483 if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX))
484 {
Paul Jakma6d4742b2015-11-25 17:14:37 +0000485 /*
486 * For the two paths, all comparison steps till IGP metric
487 * have succeeded - including AS_PATH hop count. Since 'bgp
488 * bestpath as-path multipath-relax' knob is on, we don't need
489 * an exact match of AS_PATH. Thus, mark the paths are equal.
490 * That will trigger both these paths to get into the multipath
491 * array.
492 */
493 return 0;
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000494 }
495 else if (new->peer->sort == BGP_PEER_IBGP)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000496 {
497 if (aspath_cmp (new->attr->aspath, exist->attr->aspath))
498 return 0;
499 }
Josh Bailey96450fa2011-07-20 20:45:12 -0700500 else if (new->peer->as == exist->peer->as)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000501 return 0;
Josh Bailey96450fa2011-07-20 20:45:12 -0700502 }
paul718e3742002-12-13 20:15:29 +0000503
504 /* 10. If both paths are external, prefer the path that was received
505 first (the oldest one). This step minimizes route-flap, since a
506 newer path won't displace an older one, even if it was the
507 preferred route based on the additional decision criteria below. */
508 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000509 && new_sort == BGP_PEER_EBGP
510 && exist_sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +0000511 {
512 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000513 return -1;
paul718e3742002-12-13 20:15:29 +0000514 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000515 return 1;
paul718e3742002-12-13 20:15:29 +0000516 }
517
vivekbd4b7f12014-09-30 15:54:45 -0700518 /* 11. Router-ID comparision. */
519 /* If one of the paths is "stale", the corresponding peer router-id will
520 * be 0 and would always win over the other path. If originator id is
521 * used for the comparision, it will decide which path is better.
522 */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000523 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
524 new_id.s_addr = newattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000525 else
526 new_id.s_addr = new->peer->remote_id.s_addr;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000527 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
528 exist_id.s_addr = existattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000529 else
530 exist_id.s_addr = exist->peer->remote_id.s_addr;
531
532 if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000533 return -1;
paul718e3742002-12-13 20:15:29 +0000534 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000535 return 1;
paul718e3742002-12-13 20:15:29 +0000536
537 /* 12. Cluster length comparision. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000538 new_cluster = exist_cluster = 0;
539
540 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
541 new_cluster = newattre->cluster->length;
542 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
543 exist_cluster = existattre->cluster->length;
paul718e3742002-12-13 20:15:29 +0000544
545 if (new_cluster < exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000546 return -1;
paul718e3742002-12-13 20:15:29 +0000547 if (new_cluster > exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000548 return 1;
paul718e3742002-12-13 20:15:29 +0000549
550 /* 13. Neighbor address comparision. */
vivekbd4b7f12014-09-30 15:54:45 -0700551 /* Do this only if neither path is "stale" as stale paths do not have
552 * valid peer information (as the connection may or may not be up).
553 */
554 if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000555 return -1;
vivekbd4b7f12014-09-30 15:54:45 -0700556 if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000557 return 1;
Timo Teräs2820a012015-06-24 15:27:21 +0300558 /* locally configured routes to advertise do not have su_remote */
559 if (new->peer->su_remote == NULL)
Timo Teräs2820a012015-06-24 15:27:21 +0300560 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000561 if (exist->peer->su_remote == NULL)
562 return -1;
Timo Teräs2820a012015-06-24 15:27:21 +0300563
paul718e3742002-12-13 20:15:29 +0000564 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
565
566 if (ret == 1)
paul718e3742002-12-13 20:15:29 +0000567 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000568 if (ret == -1)
569 return -1;
paul718e3742002-12-13 20:15:29 +0000570
Paul Jakma6d4742b2015-11-25 17:14:37 +0000571 return -1;
paul718e3742002-12-13 20:15:29 +0000572}
573
paul94f2b392005-06-28 12:44:16 +0000574static enum filter_type
paul718e3742002-12-13 20:15:29 +0000575bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
576 afi_t afi, safi_t safi)
577{
578 struct bgp_filter *filter;
579
580 filter = &peer->filter[afi][safi];
581
Paul Jakma650f76c2009-06-25 18:06:31 +0100582#define FILTER_EXIST_WARN(F,f,filter) \
583 if (BGP_DEBUG (update, UPDATE_IN) \
584 && !(F ## _IN (filter))) \
585 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
586 peer->host, #f, F ## _IN_NAME(filter));
587
588 if (DISTRIBUTE_IN_NAME (filter)) {
589 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
590
paul718e3742002-12-13 20:15:29 +0000591 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
592 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100593 }
paul718e3742002-12-13 20:15:29 +0000594
Paul Jakma650f76c2009-06-25 18:06:31 +0100595 if (PREFIX_LIST_IN_NAME (filter)) {
596 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
597
paul718e3742002-12-13 20:15:29 +0000598 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
599 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100600 }
paul718e3742002-12-13 20:15:29 +0000601
Paul Jakma650f76c2009-06-25 18:06:31 +0100602 if (FILTER_LIST_IN_NAME (filter)) {
603 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
604
paul718e3742002-12-13 20:15:29 +0000605 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
606 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100607 }
608
paul718e3742002-12-13 20:15:29 +0000609 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100610#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000611}
612
paul94f2b392005-06-28 12:44:16 +0000613static enum filter_type
paul718e3742002-12-13 20:15:29 +0000614bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
615 afi_t afi, safi_t safi)
616{
617 struct bgp_filter *filter;
618
619 filter = &peer->filter[afi][safi];
620
Paul Jakma650f76c2009-06-25 18:06:31 +0100621#define FILTER_EXIST_WARN(F,f,filter) \
622 if (BGP_DEBUG (update, UPDATE_OUT) \
623 && !(F ## _OUT (filter))) \
624 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
625 peer->host, #f, F ## _OUT_NAME(filter));
626
627 if (DISTRIBUTE_OUT_NAME (filter)) {
628 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
629
paul718e3742002-12-13 20:15:29 +0000630 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
631 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100632 }
paul718e3742002-12-13 20:15:29 +0000633
Paul Jakma650f76c2009-06-25 18:06:31 +0100634 if (PREFIX_LIST_OUT_NAME (filter)) {
635 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
636
paul718e3742002-12-13 20:15:29 +0000637 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
638 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100639 }
paul718e3742002-12-13 20:15:29 +0000640
Paul Jakma650f76c2009-06-25 18:06:31 +0100641 if (FILTER_LIST_OUT_NAME (filter)) {
642 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
643
paul718e3742002-12-13 20:15:29 +0000644 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
645 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100646 }
paul718e3742002-12-13 20:15:29 +0000647
648 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100649#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000650}
651
652/* If community attribute includes no_export then return 1. */
paul94f2b392005-06-28 12:44:16 +0000653static int
paul718e3742002-12-13 20:15:29 +0000654bgp_community_filter (struct peer *peer, struct attr *attr)
655{
656 if (attr->community)
657 {
658 /* NO_ADVERTISE check. */
659 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
660 return 1;
661
662 /* NO_EXPORT check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000663 if (peer->sort == BGP_PEER_EBGP &&
paul718e3742002-12-13 20:15:29 +0000664 community_include (attr->community, COMMUNITY_NO_EXPORT))
665 return 1;
666
667 /* NO_EXPORT_SUBCONFED check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000668 if (peer->sort == BGP_PEER_EBGP
669 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000670 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
671 return 1;
672 }
673 return 0;
674}
675
676/* Route reflection loop check. */
677static int
678bgp_cluster_filter (struct peer *peer, struct attr *attr)
679{
680 struct in_addr cluster_id;
681
Paul Jakmafb982c22007-05-04 20:15:47 +0000682 if (attr->extra && attr->extra->cluster)
paul718e3742002-12-13 20:15:29 +0000683 {
684 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
685 cluster_id = peer->bgp->cluster_id;
686 else
687 cluster_id = peer->bgp->router_id;
688
Paul Jakmafb982c22007-05-04 20:15:47 +0000689 if (cluster_loop_check (attr->extra->cluster, cluster_id))
paul718e3742002-12-13 20:15:29 +0000690 return 1;
691 }
692 return 0;
693}
David Lamparter6b0655a2014-06-04 06:53:35 +0200694
paul94f2b392005-06-28 12:44:16 +0000695static int
paul718e3742002-12-13 20:15:29 +0000696bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
697 afi_t afi, safi_t safi)
698{
699 struct bgp_filter *filter;
700 struct bgp_info info;
701 route_map_result_t ret;
702
703 filter = &peer->filter[afi][safi];
704
705 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000706 if (peer->weight)
707 (bgp_attr_extra_get (attr))->weight = peer->weight;
paul718e3742002-12-13 20:15:29 +0000708
709 /* Route map apply. */
710 if (ROUTE_MAP_IN_NAME (filter))
711 {
712 /* Duplicate current value to new strucutre for modification. */
713 info.peer = peer;
714 info.attr = attr;
715
paulac41b2a2003-08-12 05:32:27 +0000716 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
717
paul718e3742002-12-13 20:15:29 +0000718 /* Apply BGP route map to the attribute. */
719 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
paulac41b2a2003-08-12 05:32:27 +0000720
721 peer->rmap_type = 0;
722
paul718e3742002-12-13 20:15:29 +0000723 if (ret == RMAP_DENYMATCH)
David Lamparterc460e572014-06-04 00:54:58 +0200724 /* caller has multiple error paths with bgp_attr_flush() */
725 return RMAP_DENY;
paul718e3742002-12-13 20:15:29 +0000726 }
727 return RMAP_PERMIT;
728}
David Lamparter6b0655a2014-06-04 06:53:35 +0200729
paul94f2b392005-06-28 12:44:16 +0000730static int
paulfee0f4c2004-09-13 05:12:46 +0000731bgp_export_modifier (struct peer *rsclient, struct peer *peer,
732 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
733{
734 struct bgp_filter *filter;
735 struct bgp_info info;
736 route_map_result_t ret;
737
738 filter = &peer->filter[afi][safi];
739
740 /* Route map apply. */
741 if (ROUTE_MAP_EXPORT_NAME (filter))
742 {
743 /* Duplicate current value to new strucutre for modification. */
744 info.peer = rsclient;
745 info.attr = attr;
746
747 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
748
749 /* Apply BGP route map to the attribute. */
750 ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
751
752 rsclient->rmap_type = 0;
753
754 if (ret == RMAP_DENYMATCH)
755 {
756 /* Free newly generated AS path and community by route-map. */
757 bgp_attr_flush (attr);
758 return RMAP_DENY;
759 }
760 }
761 return RMAP_PERMIT;
762}
763
paul94f2b392005-06-28 12:44:16 +0000764static int
paulfee0f4c2004-09-13 05:12:46 +0000765bgp_import_modifier (struct peer *rsclient, struct peer *peer,
766 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
767{
768 struct bgp_filter *filter;
769 struct bgp_info info;
770 route_map_result_t ret;
771
772 filter = &rsclient->filter[afi][safi];
773
774 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000775 if (peer->weight)
776 (bgp_attr_extra_get (attr))->weight = peer->weight;
paulfee0f4c2004-09-13 05:12:46 +0000777
778 /* Route map apply. */
779 if (ROUTE_MAP_IMPORT_NAME (filter))
780 {
781 /* Duplicate current value to new strucutre for modification. */
782 info.peer = peer;
783 info.attr = attr;
784
785 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
786
787 /* Apply BGP route map to the attribute. */
788 ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
789
790 peer->rmap_type = 0;
791
792 if (ret == RMAP_DENYMATCH)
793 {
794 /* Free newly generated AS path and community by route-map. */
795 bgp_attr_flush (attr);
796 return RMAP_DENY;
797 }
798 }
799 return RMAP_PERMIT;
800}
David Lamparter6b0655a2014-06-04 06:53:35 +0200801
paul94f2b392005-06-28 12:44:16 +0000802static int
paul718e3742002-12-13 20:15:29 +0000803bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
804 struct attr *attr, afi_t afi, safi_t safi)
805{
806 int ret;
807 char buf[SU_ADDRSTRLEN];
808 struct bgp_filter *filter;
paul718e3742002-12-13 20:15:29 +0000809 struct peer *from;
810 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +0000811 int transparent;
812 int reflect;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700813 struct attr *riattr;
paul718e3742002-12-13 20:15:29 +0000814
815 from = ri->peer;
816 filter = &peer->filter[afi][safi];
817 bgp = peer->bgp;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700818 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paul718e3742002-12-13 20:15:29 +0000819
Paul Jakma750e8142008-07-22 21:11:48 +0000820 if (DISABLE_BGP_ANNOUNCE)
821 return 0;
paul718e3742002-12-13 20:15:29 +0000822
paulfee0f4c2004-09-13 05:12:46 +0000823 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
824 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
825 return 0;
826
paul718e3742002-12-13 20:15:29 +0000827 /* Do not send back route to sender. */
828 if (from == peer)
829 return 0;
830
831 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000832 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +0000833 if (! UNSUPPRESS_MAP_NAME (filter))
834 return 0;
835
836 /* Default route check. */
837 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
838 {
839 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
840 return 0;
paul718e3742002-12-13 20:15:29 +0000841 else if (p->family == AF_INET6 && p->prefixlen == 0)
842 return 0;
paul718e3742002-12-13 20:15:29 +0000843 }
844
paul286e1e72003-08-08 00:24:31 +0000845 /* Transparency check. */
846 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
847 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
848 transparent = 1;
849 else
850 transparent = 0;
851
paul718e3742002-12-13 20:15:29 +0000852 /* If community is not disabled check the no-export and local. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700853 if (! transparent && bgp_community_filter (peer, riattr))
paul718e3742002-12-13 20:15:29 +0000854 return 0;
855
856 /* If the attribute has originator-id and it is same as remote
857 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700858 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paul718e3742002-12-13 20:15:29 +0000859 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700860 if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +0000861 {
862 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000863 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000864 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
865 peer->host,
866 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
867 p->prefixlen);
868 return 0;
869 }
870 }
871
872 /* ORF prefix-list filter check */
873 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
874 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
875 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
876 if (peer->orf_plist[afi][safi])
877 {
878 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
879 return 0;
880 }
881
882 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700883 if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
paul718e3742002-12-13 20:15:29 +0000884 {
885 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000886 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000887 "%s [Update:SEND] %s/%d is filtered",
888 peer->host,
889 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
890 p->prefixlen);
891 return 0;
892 }
893
894#ifdef BGP_SEND_ASPATH_CHECK
895 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700896 if (aspath_loop_check (riattr->aspath, peer->as))
paul718e3742002-12-13 20:15:29 +0000897 {
898 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000899 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400900 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000901 peer->host, peer->as);
902 return 0;
903 }
904#endif /* BGP_SEND_ASPATH_CHECK */
905
906 /* If we're a CONFED we need to loop check the CONFED ID too */
907 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
908 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700909 if (aspath_loop_check(riattr->aspath, bgp->confed_id))
paul718e3742002-12-13 20:15:29 +0000910 {
911 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000912 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400913 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000914 peer->host,
915 bgp->confed_id);
916 return 0;
917 }
918 }
919
920 /* Route-Reflect check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000921 if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +0000922 reflect = 1;
923 else
924 reflect = 0;
925
926 /* IBGP reflection check. */
927 if (reflect)
928 {
929 /* A route from a Client peer. */
930 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
931 {
932 /* Reflect to all the Non-Client peers and also to the
933 Client peers other than the originator. Originator check
934 is already done. So there is noting to do. */
935 /* no bgp client-to-client reflection check. */
936 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
937 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
938 return 0;
939 }
940 else
941 {
942 /* A route from a Non-client peer. Reflect to all other
943 clients. */
944 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
945 return 0;
946 }
947 }
Paul Jakma41367172007-08-06 15:24:51 +0000948
paul718e3742002-12-13 20:15:29 +0000949 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700950 bgp_attr_dup (attr, riattr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000951
paul718e3742002-12-13 20:15:29 +0000952 /* If local-preference is not set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000953 if ((peer->sort == BGP_PEER_IBGP
954 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000955 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
956 {
957 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
958 attr->local_pref = bgp->default_local_pref;
959 }
960
Pradosh Mohapatra689bb662013-09-07 07:13:37 +0000961 /* If originator-id is not set and the route is to be reflected,
962 set the originator id */
963 if (peer && from && peer->sort == BGP_PEER_IBGP &&
964 from->sort == BGP_PEER_IBGP &&
965 (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))))
966 {
967 attr->extra = bgp_attr_extra_get(attr);
968 IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id));
969 SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
970 }
971
paul718e3742002-12-13 20:15:29 +0000972 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000973 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +0000974 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
975 {
976 if (ri->peer != bgp->peer_self && ! transparent
977 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
978 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
979 }
980
Lou Berger298cc2f2016-01-12 13:42:02 -0500981
982#define NEXTHOP_IS_V4 (\
983 (safi != SAFI_ENCAP && p->family == AF_INET) || \
984 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4))
985
Lou Berger298cc2f2016-01-12 13:42:02 -0500986#define NEXTHOP_IS_V6 (\
987 (safi != SAFI_ENCAP && p->family == AF_INET6) || \
988 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
Lou Berger298cc2f2016-01-12 13:42:02 -0500989
paul718e3742002-12-13 20:15:29 +0000990 /* next-hop-set */
Timo Teräs9e7a53c2014-04-24 10:22:37 +0300991 if (transparent
992 || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
paul718e3742002-12-13 20:15:29 +0000993 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
Lou Berger298cc2f2016-01-12 13:42:02 -0500994 && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr)
Lou Berger298cc2f2016-01-12 13:42:02 -0500995 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +0000996 ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paul286e1e72003-08-08 00:24:31 +0000997 )))
paul718e3742002-12-13 20:15:29 +0000998 {
999 /* NEXT-HOP Unchanged. */
1000 }
1001 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
Lou Berger298cc2f2016-01-12 13:42:02 -05001002 || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0)
Lou Berger298cc2f2016-01-12 13:42:02 -05001003 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001004 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001005 || (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001006 && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0))
1007 {
1008 /* Set IPv4 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001009 if (NEXTHOP_IS_V4)
paul718e3742002-12-13 20:15:29 +00001010 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001011 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001012 memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4,
1013 IPV4_MAX_BYTELEN);
paul718e3742002-12-13 20:15:29 +00001014 else
1015 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
1016 }
paul718e3742002-12-13 20:15:29 +00001017 /* Set IPv6 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001018 if (NEXTHOP_IS_V6)
paul718e3742002-12-13 20:15:29 +00001019 {
1020 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001021 memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00001022 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001023 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001024 }
paul718e3742002-12-13 20:15:29 +00001025 }
1026
Lou Berger298cc2f2016-01-12 13:42:02 -05001027 if (p->family == AF_INET6 && safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00001028 {
paulfee0f4c2004-09-13 05:12:46 +00001029 /* Left nexthop_local unchanged if so configured. */
1030 if ( CHECK_FLAG (peer->af_flags[afi][safi],
1031 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1032 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001033 if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) )
1034 attr->extra->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001035 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001036 attr->extra->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001037 }
1038
1039 /* Default nexthop_local treatment for non-RS-Clients */
1040 else
1041 {
paul718e3742002-12-13 20:15:29 +00001042 /* Link-local address should not be transit to different peer. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001043 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001044
1045 /* Set link-local address for shared network peer. */
1046 if (peer->shared_network
1047 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
1048 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001049 memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00001050 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001051 attr->extra->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00001052 }
1053
1054 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1055 address.*/
1056 if (reflect)
Paul Jakmafb982c22007-05-04 20:15:47 +00001057 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001058
1059 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1060 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
Paul Jakmafb982c22007-05-04 20:15:47 +00001061 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001062 }
paulfee0f4c2004-09-13 05:12:46 +00001063
1064 }
paul718e3742002-12-13 20:15:29 +00001065
1066 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001067 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001068 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1069 && aspath_private_as_check (attr->aspath))
1070 attr->aspath = aspath_empty_get ();
1071
1072 /* Route map & unsuppress-map apply. */
1073 if (ROUTE_MAP_OUT_NAME (filter)
Paul Jakmafb982c22007-05-04 20:15:47 +00001074 || (ri->extra && ri->extra->suppress) )
paul718e3742002-12-13 20:15:29 +00001075 {
Paul Jakma7c7fa1b2006-02-18 10:52:09 +00001076 struct bgp_info info;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001077 struct attr dummy_attr;
1078 struct attr_extra dummy_extra;
1079
1080 dummy_attr.extra = &dummy_extra;
1081
paul718e3742002-12-13 20:15:29 +00001082 info.peer = peer;
1083 info.attr = attr;
1084
1085 /* The route reflector is not allowed to modify the attributes
1086 of the reflected IBGP routes. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001087 if (from->sort == BGP_PEER_IBGP
1088 && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +00001089 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001090 bgp_attr_dup (&dummy_attr, attr);
Paul Jakma9eda90c2007-08-30 13:36:17 +00001091 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00001092 }
paulac41b2a2003-08-12 05:32:27 +00001093
1094 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
1095
Paul Jakmafb982c22007-05-04 20:15:47 +00001096 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00001097 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1098 else
1099 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1100
paulac41b2a2003-08-12 05:32:27 +00001101 peer->rmap_type = 0;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001102
paul718e3742002-12-13 20:15:29 +00001103 if (ret == RMAP_DENYMATCH)
1104 {
1105 bgp_attr_flush (attr);
1106 return 0;
1107 }
1108 }
1109 return 1;
1110}
1111
paul94f2b392005-06-28 12:44:16 +00001112static int
paulfee0f4c2004-09-13 05:12:46 +00001113bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
1114 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001115{
paulfee0f4c2004-09-13 05:12:46 +00001116 int ret;
1117 char buf[SU_ADDRSTRLEN];
1118 struct bgp_filter *filter;
1119 struct bgp_info info;
1120 struct peer *from;
Josh Bailey0b597ef2011-07-20 20:49:11 -07001121 struct attr *riattr;
paulfee0f4c2004-09-13 05:12:46 +00001122
1123 from = ri->peer;
1124 filter = &rsclient->filter[afi][safi];
Josh Bailey0b597ef2011-07-20 20:49:11 -07001125 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paulfee0f4c2004-09-13 05:12:46 +00001126
Paul Jakma750e8142008-07-22 21:11:48 +00001127 if (DISABLE_BGP_ANNOUNCE)
1128 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001129
1130 /* Do not send back route to sender. */
1131 if (from == rsclient)
1132 return 0;
1133
1134 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001135 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001136 if (! UNSUPPRESS_MAP_NAME (filter))
1137 return 0;
1138
1139 /* Default route check. */
1140 if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
1141 PEER_STATUS_DEFAULT_ORIGINATE))
1142 {
1143 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
1144 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001145 else if (p->family == AF_INET6 && p->prefixlen == 0)
1146 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001147 }
1148
1149 /* If the attribute has originator-id and it is same as remote
1150 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001151 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paulfee0f4c2004-09-13 05:12:46 +00001152 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001153 if (IPV4_ADDR_SAME (&rsclient->remote_id,
Josh Bailey0b597ef2011-07-20 20:49:11 -07001154 &riattr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001155 {
1156 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001157 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001158 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1159 rsclient->host,
1160 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1161 p->prefixlen);
1162 return 0;
1163 }
1164 }
1165
1166 /* ORF prefix-list filter check */
1167 if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
1168 && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
1169 || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
1170 if (rsclient->orf_plist[afi][safi])
1171 {
1172 if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
1173 return 0;
1174 }
1175
1176 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001177 if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
paulfee0f4c2004-09-13 05:12:46 +00001178 {
1179 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001180 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001181 "%s [Update:SEND] %s/%d is filtered",
1182 rsclient->host,
1183 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1184 p->prefixlen);
1185 return 0;
1186 }
1187
1188#ifdef BGP_SEND_ASPATH_CHECK
1189 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001190 if (aspath_loop_check (riattr->aspath, rsclient->as))
paulfee0f4c2004-09-13 05:12:46 +00001191 {
1192 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001193 zlog (rsclient->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001194 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paulfee0f4c2004-09-13 05:12:46 +00001195 rsclient->host, rsclient->as);
1196 return 0;
1197 }
1198#endif /* BGP_SEND_ASPATH_CHECK */
1199
1200 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001201 bgp_attr_dup (attr, riattr);
paulfee0f4c2004-09-13 05:12:46 +00001202
1203 /* next-hop-set */
1204 if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
paulfee0f4c2004-09-13 05:12:46 +00001205 || (p->family == AF_INET6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001206 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paulfee0f4c2004-09-13 05:12:46 +00001207 )
1208 {
1209 /* Set IPv4 nexthop. */
1210 if (p->family == AF_INET)
1211 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001212 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001213 memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4,
paulfee0f4c2004-09-13 05:12:46 +00001214 IPV4_MAX_BYTELEN);
1215 else
1216 memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
1217 }
paulfee0f4c2004-09-13 05:12:46 +00001218 /* Set IPv6 nexthop. */
1219 if (p->family == AF_INET6)
1220 {
1221 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001222 memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global,
paulfee0f4c2004-09-13 05:12:46 +00001223 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001224 attr->extra->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001225 }
paulfee0f4c2004-09-13 05:12:46 +00001226 }
1227
paulfee0f4c2004-09-13 05:12:46 +00001228 if (p->family == AF_INET6)
1229 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001230 struct attr_extra *attre = attr->extra;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001231
paulfee0f4c2004-09-13 05:12:46 +00001232 /* Left nexthop_local unchanged if so configured. */
1233 if ( CHECK_FLAG (rsclient->af_flags[afi][safi],
1234 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1235 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001236 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1237 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001238 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001239 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001240 }
1241
1242 /* Default nexthop_local treatment for RS-Clients */
1243 else
1244 {
1245 /* Announcer and RS-Client are both in the same network */
1246 if (rsclient->shared_network && from->shared_network &&
1247 (rsclient->ifindex == from->ifindex))
1248 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001249 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1250 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001251 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001252 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001253 }
1254
1255 /* Set link-local address for shared network peer. */
1256 else if (rsclient->shared_network
1257 && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
1258 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001259 memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local,
paulfee0f4c2004-09-13 05:12:46 +00001260 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001261 attre->mp_nexthop_len = 32;
paulfee0f4c2004-09-13 05:12:46 +00001262 }
1263
1264 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001265 attre->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001266 }
1267
1268 }
paulfee0f4c2004-09-13 05:12:46 +00001269
1270 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001271 if (rsclient->sort == BGP_PEER_EBGP
paulfee0f4c2004-09-13 05:12:46 +00001272 && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1273 && aspath_private_as_check (attr->aspath))
1274 attr->aspath = aspath_empty_get ();
1275
1276 /* Route map & unsuppress-map apply. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001277 if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) )
paulfee0f4c2004-09-13 05:12:46 +00001278 {
1279 info.peer = rsclient;
1280 info.attr = attr;
1281
1282 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
1283
Paul Jakmafb982c22007-05-04 20:15:47 +00001284 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001285 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1286 else
1287 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1288
1289 rsclient->rmap_type = 0;
1290
1291 if (ret == RMAP_DENYMATCH)
1292 {
1293 bgp_attr_flush (attr);
1294 return 0;
1295 }
1296 }
1297
1298 return 1;
1299}
1300
1301struct bgp_info_pair
1302{
1303 struct bgp_info *old;
1304 struct bgp_info *new;
1305};
1306
paul94f2b392005-06-28 12:44:16 +00001307static void
Josh Bailey96450fa2011-07-20 20:45:12 -07001308bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
Paul Jakma6d4742b2015-11-25 17:14:37 +00001309 struct bgp_info_pair *result,
1310 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00001311{
paul718e3742002-12-13 20:15:29 +00001312 struct bgp_info *new_select;
1313 struct bgp_info *old_select;
paulfee0f4c2004-09-13 05:12:46 +00001314 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00001315 struct bgp_info *ri1;
1316 struct bgp_info *ri2;
paulb40d9392005-08-22 22:34:41 +00001317 struct bgp_info *nextri = NULL;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001318 int cmpret, do_mpath;
Josh Bailey96450fa2011-07-20 20:45:12 -07001319 struct list mp_list;
Paul Jakma91b9e852015-12-01 14:32:11 +00001320
1321 result->old = result->new = NULL;
1322
1323 if (rn->info == NULL)
1324 {
1325 char buf[PREFIX_STRLEN];
1326 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1327 __func__,
1328 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1329 return;
1330 }
1331
Josh Bailey96450fa2011-07-20 20:45:12 -07001332 bgp_mp_list_init (&mp_list);
Paul Jakma6d4742b2015-11-25 17:14:37 +00001333 do_mpath = bgp_mpath_is_configured (bgp, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001334
paul718e3742002-12-13 20:15:29 +00001335 /* bgp deterministic-med */
1336 new_select = NULL;
1337 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1338 for (ri1 = rn->info; ri1; ri1 = ri1->next)
1339 {
1340 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
1341 continue;
1342 if (BGP_INFO_HOLDDOWN (ri1))
1343 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001344 if (ri1->peer && ri1->peer != bgp->peer_self)
1345 if (ri1->peer->status != Established)
1346 continue;
paul718e3742002-12-13 20:15:29 +00001347
1348 new_select = ri1;
Josh Bailey6918e742011-07-20 20:48:20 -07001349 if (do_mpath)
1350 bgp_mp_list_add (&mp_list, ri1);
1351 old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
paul718e3742002-12-13 20:15:29 +00001352 if (ri1->next)
1353 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
1354 {
1355 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
1356 continue;
1357 if (BGP_INFO_HOLDDOWN (ri2))
1358 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001359 if (ri2->peer &&
1360 ri2->peer != bgp->peer_self &&
1361 !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
1362 if (ri2->peer->status != Established)
1363 continue;
paul718e3742002-12-13 20:15:29 +00001364
1365 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
1366 || aspath_cmp_left_confed (ri1->attr->aspath,
1367 ri2->attr->aspath))
1368 {
Josh Bailey6918e742011-07-20 20:48:20 -07001369 if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED))
1370 old_select = ri2;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001371 if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi))
1372 == -1)
paul718e3742002-12-13 20:15:29 +00001373 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001374 bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001375 new_select = ri2;
1376 }
1377
Paul Jakma6d4742b2015-11-25 17:14:37 +00001378 if (do_mpath)
1379 {
1380 if (cmpret != 0)
1381 bgp_mp_list_clear (&mp_list);
1382
1383 if (cmpret == 0 || cmpret == -1)
1384 bgp_mp_list_add (&mp_list, ri2);
1385 }
Josh Bailey6918e742011-07-20 20:48:20 -07001386
Paul Jakma1a392d42006-09-07 00:24:49 +00001387 bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001388 }
1389 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001390 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
1391 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
Josh Bailey6918e742011-07-20 20:48:20 -07001392
Paul Jakma6d4742b2015-11-25 17:14:37 +00001393 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey6918e742011-07-20 20:48:20 -07001394 bgp_mp_list_clear (&mp_list);
paul718e3742002-12-13 20:15:29 +00001395 }
1396
1397 /* Check old selected route and new selected route. */
1398 old_select = NULL;
1399 new_select = NULL;
paulb40d9392005-08-22 22:34:41 +00001400 for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
paul718e3742002-12-13 20:15:29 +00001401 {
1402 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
1403 old_select = ri;
1404
1405 if (BGP_INFO_HOLDDOWN (ri))
paulb40d9392005-08-22 22:34:41 +00001406 {
1407 /* reap REMOVED routes, if needs be
1408 * selected route must stay for a while longer though
1409 */
1410 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
1411 && (ri != old_select))
1412 bgp_info_reap (rn, ri);
1413
1414 continue;
1415 }
paul718e3742002-12-13 20:15:29 +00001416
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001417 if (ri->peer &&
1418 ri->peer != bgp->peer_self &&
1419 !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
1420 if (ri->peer->status != Established)
1421 continue;
1422
paul718e3742002-12-13 20:15:29 +00001423 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
1424 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
1425 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001426 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001427 continue;
1428 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001429 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
1430 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001431
Paul Jakma6d4742b2015-11-25 17:14:37 +00001432 if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1)
Josh Bailey96450fa2011-07-20 20:45:12 -07001433 {
Josh Bailey6918e742011-07-20 20:48:20 -07001434 if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1435 bgp_mp_dmed_deselect (new_select);
1436
Josh Bailey96450fa2011-07-20 20:45:12 -07001437 new_select = ri;
Josh Bailey96450fa2011-07-20 20:45:12 -07001438 }
Paul Jakma6d4742b2015-11-25 17:14:37 +00001439 else if (cmpret == 1 && do_mpath
1440 && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Josh Bailey6918e742011-07-20 20:48:20 -07001441 bgp_mp_dmed_deselect (ri);
Josh Bailey96450fa2011-07-20 20:45:12 -07001442
Paul Jakma6d4742b2015-11-25 17:14:37 +00001443 if (do_mpath)
1444 {
1445 if (cmpret != 0)
1446 bgp_mp_list_clear (&mp_list);
1447
1448 if (cmpret == 0 || cmpret == -1)
1449 bgp_mp_list_add (&mp_list, ri);
1450 }
paul718e3742002-12-13 20:15:29 +00001451 }
paulfee0f4c2004-09-13 05:12:46 +00001452
Josh Bailey6918e742011-07-20 20:48:20 -07001453 if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Paul Jakma6d4742b2015-11-25 17:14:37 +00001454 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001455
Josh Bailey0b597ef2011-07-20 20:49:11 -07001456 bgp_info_mpath_aggregate_update (new_select, old_select);
Josh Bailey96450fa2011-07-20 20:45:12 -07001457 bgp_mp_list_clear (&mp_list);
1458
1459 result->old = old_select;
1460 result->new = new_select;
1461
1462 return;
paulfee0f4c2004-09-13 05:12:46 +00001463}
1464
paul94f2b392005-06-28 12:44:16 +00001465static int
paulfee0f4c2004-09-13 05:12:46 +00001466bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
Paul Jakma9eda90c2007-08-30 13:36:17 +00001467 struct bgp_node *rn, afi_t afi, safi_t safi)
1468{
paulfee0f4c2004-09-13 05:12:46 +00001469 struct prefix *p;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001470 struct attr attr;
1471 struct attr_extra extra;
paulfee0f4c2004-09-13 05:12:46 +00001472
Lou Berger050defe2016-01-12 13:41:59 -05001473 memset (&attr, 0, sizeof(struct attr));
1474 memset (&extra, 0, sizeof(struct attr_extra));
1475
paulfee0f4c2004-09-13 05:12:46 +00001476 p = &rn->p;
1477
Paul Jakma9eda90c2007-08-30 13:36:17 +00001478 /* Announce route to Established peer. */
1479 if (peer->status != Established)
paulfee0f4c2004-09-13 05:12:46 +00001480 return 0;
1481
Paul Jakma9eda90c2007-08-30 13:36:17 +00001482 /* Address family configuration check. */
1483 if (! peer->afc_nego[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001484 return 0;
1485
Paul Jakma9eda90c2007-08-30 13:36:17 +00001486 /* First update is deferred until ORF or ROUTE-REFRESH is received */
paulfee0f4c2004-09-13 05:12:46 +00001487 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1488 PEER_STATUS_ORF_WAIT_REFRESH))
1489 return 0;
1490
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001491 /* It's initialized in bgp_announce_[check|check_rsclient]() */
1492 attr.extra = &extra;
1493
Avneesh Sachdev67174042012-08-17 08:19:49 -07001494 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001495 {
1496 case BGP_TABLE_MAIN:
1497 /* Announcement to peer->conf. If the route is filtered,
1498 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001499 if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
1500 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
paulfee0f4c2004-09-13 05:12:46 +00001501 else
1502 bgp_adj_out_unset (rn, peer, p, afi, safi);
1503 break;
1504 case BGP_TABLE_RSCLIENT:
1505 /* Announcement to peer->conf. If the route is filtered,
1506 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001507 if (selected &&
1508 bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
1509 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
1510 else
1511 bgp_adj_out_unset (rn, peer, p, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001512 break;
1513 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001514
Lou Berger050defe2016-01-12 13:41:59 -05001515 bgp_attr_flush (&attr);
paulfee0f4c2004-09-13 05:12:46 +00001516 return 0;
paul200df112005-06-01 11:17:05 +00001517}
paulfee0f4c2004-09-13 05:12:46 +00001518
paul200df112005-06-01 11:17:05 +00001519struct bgp_process_queue
paulfee0f4c2004-09-13 05:12:46 +00001520{
paul200df112005-06-01 11:17:05 +00001521 struct bgp *bgp;
1522 struct bgp_node *rn;
1523 afi_t afi;
1524 safi_t safi;
1525};
1526
1527static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001528bgp_process_rsclient (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001529{
paul0fb58d52005-11-14 14:31:49 +00001530 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001531 struct bgp *bgp = pq->bgp;
1532 struct bgp_node *rn = pq->rn;
1533 afi_t afi = pq->afi;
1534 safi_t safi = pq->safi;
paulfee0f4c2004-09-13 05:12:46 +00001535 struct bgp_info *new_select;
1536 struct bgp_info *old_select;
1537 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001538 struct listnode *node, *nnode;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001539 struct peer *rsclient = bgp_node_table (rn)->owner;
paul200df112005-06-01 11:17:05 +00001540
paulfee0f4c2004-09-13 05:12:46 +00001541 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001542 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001543 new_select = old_and_new.new;
1544 old_select = old_and_new.old;
1545
paul200df112005-06-01 11:17:05 +00001546 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
1547 {
Chris Caputo228da422009-07-18 05:44:03 +00001548 if (rsclient->group)
1549 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient))
1550 {
1551 /* Nothing to do. */
1552 if (old_select && old_select == new_select)
1553 if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1554 continue;
paulfee0f4c2004-09-13 05:12:46 +00001555
Chris Caputo228da422009-07-18 05:44:03 +00001556 if (old_select)
1557 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1558 if (new_select)
1559 {
1560 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1561 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001562 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1563 }
paulfee0f4c2004-09-13 05:12:46 +00001564
Chris Caputo228da422009-07-18 05:44:03 +00001565 bgp_process_announce_selected (rsclient, new_select, rn,
1566 afi, safi);
1567 }
paul200df112005-06-01 11:17:05 +00001568 }
1569 else
1570 {
hassob7395792005-08-26 12:58:38 +00001571 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001572 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hassob7395792005-08-26 12:58:38 +00001573 if (new_select)
1574 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001575 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1576 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001577 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hassob7395792005-08-26 12:58:38 +00001578 }
Paul Jakma9eda90c2007-08-30 13:36:17 +00001579 bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
paul200df112005-06-01 11:17:05 +00001580 }
paulfee0f4c2004-09-13 05:12:46 +00001581
paulb40d9392005-08-22 22:34:41 +00001582 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1583 bgp_info_reap (rn, old_select);
1584
paul200df112005-06-01 11:17:05 +00001585 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1586 return WQ_SUCCESS;
paulfee0f4c2004-09-13 05:12:46 +00001587}
1588
paul200df112005-06-01 11:17:05 +00001589static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001590bgp_process_main (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001591{
paul0fb58d52005-11-14 14:31:49 +00001592 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001593 struct bgp *bgp = pq->bgp;
1594 struct bgp_node *rn = pq->rn;
1595 afi_t afi = pq->afi;
1596 safi_t safi = pq->safi;
1597 struct prefix *p = &rn->p;
paulfee0f4c2004-09-13 05:12:46 +00001598 struct bgp_info *new_select;
1599 struct bgp_info *old_select;
1600 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001601 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00001602 struct peer *peer;
Paul Jakmafb982c22007-05-04 20:15:47 +00001603
paulfee0f4c2004-09-13 05:12:46 +00001604 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001605 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001606 old_select = old_and_new.old;
1607 new_select = old_and_new.new;
1608
1609 /* Nothing to do. */
1610 if (old_select && old_select == new_select)
1611 {
1612 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
paul200df112005-06-01 11:17:05 +00001613 {
Josh Bailey8196f132011-07-20 20:47:07 -07001614 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) ||
1615 CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG))
G.Balaji5a616c02011-11-26 21:58:42 +04001616 bgp_zebra_announce (p, old_select, bgp, safi);
paul200df112005-06-01 11:17:05 +00001617
Josh Bailey8196f132011-07-20 20:47:07 -07001618 UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
paul200df112005-06-01 11:17:05 +00001619 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1620 return WQ_SUCCESS;
1621 }
paulfee0f4c2004-09-13 05:12:46 +00001622 }
paul718e3742002-12-13 20:15:29 +00001623
hasso338b3422005-02-23 14:27:24 +00001624 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001625 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hasso338b3422005-02-23 14:27:24 +00001626 if (new_select)
1627 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001628 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1629 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001630 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hasso338b3422005-02-23 14:27:24 +00001631 }
1632
1633
paul718e3742002-12-13 20:15:29 +00001634 /* Check each BGP peer. */
paul1eb8ef22005-04-07 07:30:20 +00001635 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00001636 {
Paul Jakma9eda90c2007-08-30 13:36:17 +00001637 bgp_process_announce_selected (peer, new_select, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001638 }
1639
1640 /* FIB update. */
G.Balaji5a616c02011-11-26 21:58:42 +04001641 if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
1642 ! bgp_option_check (BGP_OPT_NO_FIB)))
paul718e3742002-12-13 20:15:29 +00001643 {
1644 if (new_select
1645 && new_select->type == ZEBRA_ROUTE_BGP
1646 && new_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001647 bgp_zebra_announce (p, new_select, bgp, safi);
paul718e3742002-12-13 20:15:29 +00001648 else
1649 {
1650 /* Withdraw the route from the kernel. */
1651 if (old_select
1652 && old_select->type == ZEBRA_ROUTE_BGP
1653 && old_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001654 bgp_zebra_withdraw (p, old_select, safi);
paul718e3742002-12-13 20:15:29 +00001655 }
1656 }
paulb40d9392005-08-22 22:34:41 +00001657
Lou Berger050defe2016-01-12 13:41:59 -05001658 /* Reap old select bgp_info, if it has been removed */
paulb40d9392005-08-22 22:34:41 +00001659 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1660 bgp_info_reap (rn, old_select);
1661
paul200df112005-06-01 11:17:05 +00001662 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1663 return WQ_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001664}
1665
paul200df112005-06-01 11:17:05 +00001666static void
paul0fb58d52005-11-14 14:31:49 +00001667bgp_processq_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001668{
paul0fb58d52005-11-14 14:31:49 +00001669 struct bgp_process_queue *pq = data;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001670 struct bgp_table *table = bgp_node_table (pq->rn);
paul0fb58d52005-11-14 14:31:49 +00001671
Chris Caputo228da422009-07-18 05:44:03 +00001672 bgp_unlock (pq->bgp);
paul200df112005-06-01 11:17:05 +00001673 bgp_unlock_node (pq->rn);
Chris Caputo228da422009-07-18 05:44:03 +00001674 bgp_table_unlock (table);
paul200df112005-06-01 11:17:05 +00001675 XFREE (MTYPE_BGP_PROCESS_QUEUE, pq);
1676}
1677
1678static void
1679bgp_process_queue_init (void)
1680{
1681 bm->process_main_queue
1682 = work_queue_new (bm->master, "process_main_queue");
1683 bm->process_rsclient_queue
1684 = work_queue_new (bm->master, "process_rsclient_queue");
1685
1686 if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
1687 {
1688 zlog_err ("%s: Failed to allocate work queue", __func__);
1689 exit (1);
1690 }
1691
1692 bm->process_main_queue->spec.workfunc = &bgp_process_main;
paul200df112005-06-01 11:17:05 +00001693 bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
Paul Jakma838bbde2010-01-08 14:05:32 +00001694 bm->process_main_queue->spec.max_retries = 0;
1695 bm->process_main_queue->spec.hold = 50;
1696
Paul Jakma838bbde2010-01-08 14:05:32 +00001697 bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient;
David Lamparterd43f8b32015-03-03 08:54:54 +01001698 bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del;
1699 bm->process_rsclient_queue->spec.max_retries = 0;
1700 bm->process_rsclient_queue->spec.hold = 50;
paul200df112005-06-01 11:17:05 +00001701}
1702
1703void
paulfee0f4c2004-09-13 05:12:46 +00001704bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1705{
paul200df112005-06-01 11:17:05 +00001706 struct bgp_process_queue *pqnode;
1707
1708 /* already scheduled for processing? */
1709 if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
1710 return;
1711
Paul Jakma91b9e852015-12-01 14:32:11 +00001712 if (rn->info == NULL)
1713 {
1714 /* XXX: Perhaps remove before next release, after we've flushed out
1715 * any obvious cases
1716 */
1717 assert (rn->info != NULL);
1718 char buf[PREFIX_STRLEN];
1719 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1720 __func__,
1721 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1722 return;
1723 }
1724
paul200df112005-06-01 11:17:05 +00001725 if ( (bm->process_main_queue == NULL) ||
1726 (bm->process_rsclient_queue == NULL) )
1727 bgp_process_queue_init ();
1728
1729 pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
1730 sizeof (struct bgp_process_queue));
1731 if (!pqnode)
1732 return;
Chris Caputo228da422009-07-18 05:44:03 +00001733
1734 /* all unlocked in bgp_processq_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07001735 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00001736 pqnode->rn = bgp_lock_node (rn);
paul200df112005-06-01 11:17:05 +00001737 pqnode->bgp = bgp;
Chris Caputo228da422009-07-18 05:44:03 +00001738 bgp_lock (bgp);
paul200df112005-06-01 11:17:05 +00001739 pqnode->afi = afi;
1740 pqnode->safi = safi;
1741
Avneesh Sachdev67174042012-08-17 08:19:49 -07001742 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001743 {
paul200df112005-06-01 11:17:05 +00001744 case BGP_TABLE_MAIN:
1745 work_queue_add (bm->process_main_queue, pqnode);
1746 break;
1747 case BGP_TABLE_RSCLIENT:
1748 work_queue_add (bm->process_rsclient_queue, pqnode);
1749 break;
paulfee0f4c2004-09-13 05:12:46 +00001750 }
paul200df112005-06-01 11:17:05 +00001751
Stephen Hemminger07ff4dc2013-01-04 22:29:20 +00001752 SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
paul200df112005-06-01 11:17:05 +00001753 return;
paulfee0f4c2004-09-13 05:12:46 +00001754}
hasso0a486e52005-02-01 20:57:17 +00001755
paul94f2b392005-06-28 12:44:16 +00001756static int
hasso0a486e52005-02-01 20:57:17 +00001757bgp_maximum_prefix_restart_timer (struct thread *thread)
1758{
1759 struct peer *peer;
1760
1761 peer = THREAD_ARG (thread);
1762 peer->t_pmax_restart = NULL;
1763
1764 if (BGP_DEBUG (events, EVENTS))
1765 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1766 peer->host);
1767
1768 peer_clear (peer);
1769
1770 return 0;
1771}
1772
paulfee0f4c2004-09-13 05:12:46 +00001773int
paul5228ad22004-06-04 17:58:18 +00001774bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1775 safi_t safi, int always)
paul718e3742002-12-13 20:15:29 +00001776{
hassoe0701b72004-05-20 09:19:34 +00001777 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1778 return 0;
1779
1780 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +00001781 {
hassoe0701b72004-05-20 09:19:34 +00001782 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1783 && ! always)
1784 return 0;
paul718e3742002-12-13 20:15:29 +00001785
hassoe0701b72004-05-20 09:19:34 +00001786 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001787 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1788 "limit %ld", afi_safi_print (afi, safi), peer->host,
1789 peer->pcount[afi][safi], peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001790 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
paul718e3742002-12-13 20:15:29 +00001791
hassoe0701b72004-05-20 09:19:34 +00001792 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1793 return 0;
paul718e3742002-12-13 20:15:29 +00001794
hassoe0701b72004-05-20 09:19:34 +00001795 {
paul5228ad22004-06-04 17:58:18 +00001796 u_int8_t ndata[7];
hassoe0701b72004-05-20 09:19:34 +00001797
1798 if (safi == SAFI_MPLS_VPN)
Denis Ovsienko42e6d742011-07-14 12:36:19 +04001799 safi = SAFI_MPLS_LABELED_VPN;
paul5228ad22004-06-04 17:58:18 +00001800
1801 ndata[0] = (afi >> 8);
1802 ndata[1] = afi;
1803 ndata[2] = safi;
1804 ndata[3] = (peer->pmax[afi][safi] >> 24);
1805 ndata[4] = (peer->pmax[afi][safi] >> 16);
1806 ndata[5] = (peer->pmax[afi][safi] >> 8);
1807 ndata[6] = (peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001808
1809 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1810 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1811 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1812 }
hasso0a486e52005-02-01 20:57:17 +00001813
1814 /* restart timer start */
1815 if (peer->pmax_restart[afi][safi])
1816 {
1817 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1818
1819 if (BGP_DEBUG (events, EVENTS))
1820 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1821 peer->host, peer->v_pmax_restart);
1822
1823 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1824 peer->v_pmax_restart);
1825 }
1826
hassoe0701b72004-05-20 09:19:34 +00001827 return 1;
paul718e3742002-12-13 20:15:29 +00001828 }
hassoe0701b72004-05-20 09:19:34 +00001829 else
1830 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1831
1832 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1833 {
1834 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1835 && ! always)
1836 return 0;
1837
1838 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001839 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1840 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1841 peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001842 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1843 }
1844 else
1845 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
paul718e3742002-12-13 20:15:29 +00001846 return 0;
1847}
1848
paulb40d9392005-08-22 22:34:41 +00001849/* Unconditionally remove the route from the RIB, without taking
1850 * damping into consideration (eg, because the session went down)
1851 */
paul94f2b392005-06-28 12:44:16 +00001852static void
paul718e3742002-12-13 20:15:29 +00001853bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1854 afi_t afi, safi_t safi)
1855{
paul902212c2006-02-05 17:51:19 +00001856 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1857
1858 if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1859 bgp_info_delete (rn, ri); /* keep historical info */
1860
paulb40d9392005-08-22 22:34:41 +00001861 bgp_process (peer->bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001862}
1863
paul94f2b392005-06-28 12:44:16 +00001864static void
paul718e3742002-12-13 20:15:29 +00001865bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
Lou Berger050defe2016-01-12 13:41:59 -05001866 afi_t afi, safi_t safi, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00001867{
paul718e3742002-12-13 20:15:29 +00001868 int status = BGP_DAMP_NONE;
1869
paulb40d9392005-08-22 22:34:41 +00001870 /* apply dampening, if result is suppressed, we'll be retaining
1871 * the bgp_info in the RIB for historical reference.
1872 */
1873 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001874 && peer->sort == BGP_PEER_EBGP)
paulb40d9392005-08-22 22:34:41 +00001875 if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0))
1876 == BGP_DAMP_SUPPRESSED)
paul902212c2006-02-05 17:51:19 +00001877 {
paul902212c2006-02-05 17:51:19 +00001878 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1879 return;
1880 }
1881
1882 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00001883}
1884
paul94f2b392005-06-28 12:44:16 +00001885static void
paulfee0f4c2004-09-13 05:12:46 +00001886bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1887 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1888 int sub_type, struct prefix_rd *prd, u_char *tag)
1889{
1890 struct bgp_node *rn;
1891 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001892 struct attr new_attr;
1893 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00001894 struct attr *attr_new;
1895 struct attr *attr_new2;
1896 struct bgp_info *ri;
1897 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001898 const char *reason;
paulfee0f4c2004-09-13 05:12:46 +00001899 char buf[SU_ADDRSTRLEN];
1900
1901 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1902 if (peer == rsclient)
1903 return;
1904
1905 bgp = peer->bgp;
1906 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1907
1908 /* Check previously received route. */
1909 for (ri = rn->info; ri; ri = ri->next)
1910 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1911 break;
1912
1913 /* AS path loop check. */
Milan Kocian000e1572013-10-18 07:59:38 +00001914 if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001915 {
1916 reason = "as-path contains our own AS;";
1917 goto filtered;
1918 }
1919
1920 /* Route reflector originator ID check. */
1921 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00001922 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001923 {
1924 reason = "originator is us;";
1925 goto filtered;
1926 }
Paul Jakmafb982c22007-05-04 20:15:47 +00001927
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001928 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00001929 bgp_attr_dup (&new_attr, attr);
paulfee0f4c2004-09-13 05:12:46 +00001930
1931 /* Apply export policy. */
1932 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1933 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1934 {
1935 reason = "export-policy;";
1936 goto filtered;
1937 }
1938
1939 attr_new2 = bgp_attr_intern (&new_attr);
Paul Jakmafb982c22007-05-04 20:15:47 +00001940
paulfee0f4c2004-09-13 05:12:46 +00001941 /* Apply import policy. */
1942 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1943 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001944 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001945
1946 reason = "import-policy;";
1947 goto filtered;
1948 }
1949
1950 attr_new = bgp_attr_intern (&new_attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001951 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001952
1953 /* IPv4 unicast next hop check. */
G.Balaji5a616c02011-11-26 21:58:42 +04001954 if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
paulfee0f4c2004-09-13 05:12:46 +00001955 {
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001956 /* Next hop must not be 0.0.0.0 nor Class D/E address. */
paulfee0f4c2004-09-13 05:12:46 +00001957 if (new_attr.nexthop.s_addr == 0
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001958 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
paulfee0f4c2004-09-13 05:12:46 +00001959 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001960 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00001961
1962 reason = "martian next-hop;";
1963 goto filtered;
1964 }
1965 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001966
paulfee0f4c2004-09-13 05:12:46 +00001967 /* If the update is implicit withdraw. */
1968 if (ri)
1969 {
Stephen Hemminger65957882010-01-15 16:22:10 +03001970 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00001971
1972 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00001973 if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
1974 && attrhash_cmp (ri->attr, attr_new))
paulfee0f4c2004-09-13 05:12:46 +00001975 {
1976
Paul Jakma1a392d42006-09-07 00:24:49 +00001977 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00001978
1979 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001980 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001981 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1982 peer->host,
1983 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1984 p->prefixlen, rsclient->host);
1985
Chris Caputo228da422009-07-18 05:44:03 +00001986 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001987 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05001988 bgp_attr_flush(&new_attr);
Chris Caputo228da422009-07-18 05:44:03 +00001989 return;
paulfee0f4c2004-09-13 05:12:46 +00001990 }
1991
Paul Jakma16d2e242007-04-10 19:32:10 +00001992 /* Withdraw/Announce before we fully processed the withdraw */
1993 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
1994 bgp_info_restore (rn, ri);
1995
paulfee0f4c2004-09-13 05:12:46 +00001996 /* Received Logging. */
1997 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001998 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00001999 peer->host,
2000 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2001 p->prefixlen, rsclient->host);
2002
2003 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002004 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00002005
2006 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002007 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00002008 ri->attr = attr_new;
2009
2010 /* Update MPLS tag. */
2011 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002012 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002013
Paul Jakma1a392d42006-09-07 00:24:49 +00002014 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002015
2016 /* Process change. */
2017 bgp_process (bgp, rn, afi, safi);
2018 bgp_unlock_node (rn);
2019
2020 return;
2021 }
2022
2023 /* Received Logging. */
2024 if (BGP_DEBUG (update, UPDATE_IN))
2025 {
ajsd2c1f162004-12-08 21:10:20 +00002026 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00002027 peer->host,
2028 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2029 p->prefixlen, rsclient->host);
2030 }
2031
2032 /* Make new BGP info. */
2033 new = bgp_info_new ();
2034 new->type = type;
2035 new->sub_type = sub_type;
2036 new->peer = peer;
2037 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002038 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00002039
2040 /* Update MPLS tag. */
2041 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002042 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002043
Paul Jakma1a392d42006-09-07 00:24:49 +00002044 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002045
2046 /* Register new BGP information. */
2047 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002048
2049 /* route_node_get lock */
2050 bgp_unlock_node (rn);
2051
paulfee0f4c2004-09-13 05:12:46 +00002052 /* Process change. */
2053 bgp_process (bgp, rn, afi, safi);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002054
paulfee0f4c2004-09-13 05:12:46 +00002055 return;
2056
2057 filtered:
2058
2059 /* This BGP update is filtered. Log the reason then update BGP entry. */
2060 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002061 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002062 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
2063 peer->host,
2064 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2065 p->prefixlen, rsclient->host, reason);
2066
2067 if (ri)
paulb40d9392005-08-22 22:34:41 +00002068 bgp_rib_remove (rn, ri, peer, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002069
2070 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002071
paulfee0f4c2004-09-13 05:12:46 +00002072 return;
2073}
2074
paul94f2b392005-06-28 12:44:16 +00002075static void
paulfee0f4c2004-09-13 05:12:46 +00002076bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
2077 struct peer *peer, struct prefix *p, int type, int sub_type,
2078 struct prefix_rd *prd, u_char *tag)
Chris Caputo228da422009-07-18 05:44:03 +00002079{
paulfee0f4c2004-09-13 05:12:46 +00002080 struct bgp_node *rn;
2081 struct bgp_info *ri;
2082 char buf[SU_ADDRSTRLEN];
2083
2084 if (rsclient == peer)
Chris Caputo228da422009-07-18 05:44:03 +00002085 return;
paulfee0f4c2004-09-13 05:12:46 +00002086
2087 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
2088
2089 /* Lookup withdrawn route. */
2090 for (ri = rn->info; ri; ri = ri->next)
2091 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2092 break;
2093
2094 /* Withdraw specified route from routing table. */
2095 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002096 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paulfee0f4c2004-09-13 05:12:46 +00002097 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002098 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002099 "%s Can't find the route %s/%d", peer->host,
2100 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2101 p->prefixlen);
2102
2103 /* Unlock bgp_node_get() lock. */
Chris Caputo228da422009-07-18 05:44:03 +00002104 bgp_unlock_node (rn);
2105}
paulfee0f4c2004-09-13 05:12:46 +00002106
paul94f2b392005-06-28 12:44:16 +00002107static int
paulfee0f4c2004-09-13 05:12:46 +00002108bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
paul718e3742002-12-13 20:15:29 +00002109 afi_t afi, safi_t safi, int type, int sub_type,
2110 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2111{
2112 int ret;
2113 int aspath_loop_count = 0;
2114 struct bgp_node *rn;
2115 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002116 struct attr new_attr;
2117 struct attr_extra new_extra;
paul718e3742002-12-13 20:15:29 +00002118 struct attr *attr_new;
2119 struct bgp_info *ri;
2120 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00002121 const char *reason;
paul718e3742002-12-13 20:15:29 +00002122 char buf[SU_ADDRSTRLEN];
2123
Lou Berger370b7e52016-02-04 21:29:49 -05002124 memset (&new_attr, 0, sizeof(struct attr));
2125 memset (&new_extra, 0, sizeof(struct attr_extra));
2126
paul718e3742002-12-13 20:15:29 +00002127 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00002128 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
Paul Jakmafb982c22007-05-04 20:15:47 +00002129
paul718e3742002-12-13 20:15:29 +00002130 /* When peer's soft reconfiguration enabled. Record input packet in
2131 Adj-RIBs-In. */
Jorge Boncompte [DTI2]343aa822012-05-07 16:53:08 +00002132 if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2133 && peer != bgp->peer_self)
paul718e3742002-12-13 20:15:29 +00002134 bgp_adj_in_set (rn, peer, attr);
2135
2136 /* Check previously received route. */
2137 for (ri = rn->info; ri; ri = ri->next)
2138 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2139 break;
2140
2141 /* AS path local-as loop check. */
2142 if (peer->change_local_as)
2143 {
2144 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
2145 aspath_loop_count = 1;
2146
2147 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
2148 {
2149 reason = "as-path contains our own AS;";
2150 goto filtered;
2151 }
2152 }
2153
2154 /* AS path loop check. */
2155 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
2156 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
2157 && aspath_loop_check(attr->aspath, bgp->confed_id)
2158 > peer->allowas_in[afi][safi]))
2159 {
2160 reason = "as-path contains our own AS;";
2161 goto filtered;
2162 }
2163
2164 /* Route reflector originator ID check. */
2165 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00002166 && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +00002167 {
2168 reason = "originator is us;";
2169 goto filtered;
2170 }
2171
2172 /* Route reflector cluster ID check. */
2173 if (bgp_cluster_filter (peer, attr))
2174 {
2175 reason = "reflected from the same cluster;";
2176 goto filtered;
2177 }
2178
2179 /* Apply incoming filter. */
2180 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
2181 {
2182 reason = "filter;";
2183 goto filtered;
2184 }
2185
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002186 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00002187 bgp_attr_dup (&new_attr, attr);
paul718e3742002-12-13 20:15:29 +00002188
David Lamparterc460e572014-06-04 00:54:58 +02002189 /* Apply incoming route-map.
2190 * NB: new_attr may now contain newly allocated values from route-map "set"
2191 * commands, so we need bgp_attr_flush in the error paths, until we intern
2192 * the attr (which takes over the memory references) */
paul718e3742002-12-13 20:15:29 +00002193 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
2194 {
2195 reason = "route-map;";
David Lamparterc460e572014-06-04 00:54:58 +02002196 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002197 goto filtered;
2198 }
2199
2200 /* IPv4 unicast next hop check. */
2201 if (afi == AFI_IP && safi == SAFI_UNICAST)
2202 {
2203 /* If the peer is EBGP and nexthop is not on connected route,
2204 discard it. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002205 if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1
Denis Ovsienko8e80bdf2011-08-05 18:52:52 +04002206 && ! bgp_nexthop_onlink (afi, &new_attr)
hasso6ffd2072005-02-02 14:50:11 +00002207 && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
paul718e3742002-12-13 20:15:29 +00002208 {
2209 reason = "non-connected next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002210 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002211 goto filtered;
2212 }
2213
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04002214 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
paul718e3742002-12-13 20:15:29 +00002215 must not be my own address. */
Jorge Boncompte [DTI2]10f9bf32012-05-07 16:52:52 +00002216 if (new_attr.nexthop.s_addr == 0
2217 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
2218 || bgp_nexthop_self (&new_attr))
paul718e3742002-12-13 20:15:29 +00002219 {
2220 reason = "martian next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002221 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002222 goto filtered;
2223 }
2224 }
2225
2226 attr_new = bgp_attr_intern (&new_attr);
2227
2228 /* If the update is implicit withdraw. */
2229 if (ri)
2230 {
Stephen Hemminger65957882010-01-15 16:22:10 +03002231 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002232
2233 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00002234 if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
2235 && attrhash_cmp (ri->attr, attr_new))
paul718e3742002-12-13 20:15:29 +00002236 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002237 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00002238
2239 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002240 && peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00002241 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2242 {
2243 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002244 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002245 peer->host,
2246 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2247 p->prefixlen);
2248
paul902212c2006-02-05 17:51:19 +00002249 if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
2250 {
2251 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2252 bgp_process (bgp, rn, afi, safi);
2253 }
paul718e3742002-12-13 20:15:29 +00002254 }
Paul Jakma16d2e242007-04-10 19:32:10 +00002255 else /* Duplicate - odd */
paul718e3742002-12-13 20:15:29 +00002256 {
2257 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002258 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002259 "%s rcvd %s/%d...duplicate ignored",
2260 peer->host,
2261 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2262 p->prefixlen);
hasso93406d82005-02-02 14:40:33 +00002263
2264 /* graceful restart STALE flag unset. */
2265 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2266 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002267 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
paul902212c2006-02-05 17:51:19 +00002268 bgp_process (bgp, rn, afi, safi);
hasso93406d82005-02-02 14:40:33 +00002269 }
paul718e3742002-12-13 20:15:29 +00002270 }
2271
2272 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002273 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05002274 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002275
paul718e3742002-12-13 20:15:29 +00002276 return 0;
2277 }
2278
Paul Jakma16d2e242007-04-10 19:32:10 +00002279 /* Withdraw/Announce before we fully processed the withdraw */
2280 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2281 {
2282 if (BGP_DEBUG (update, UPDATE_IN))
2283 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
2284 peer->host,
2285 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2286 p->prefixlen);
2287 bgp_info_restore (rn, ri);
2288 }
2289
paul718e3742002-12-13 20:15:29 +00002290 /* Received Logging. */
2291 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002292 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002293 peer->host,
2294 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2295 p->prefixlen);
2296
hasso93406d82005-02-02 14:40:33 +00002297 /* graceful restart STALE flag unset. */
2298 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma1a392d42006-09-07 00:24:49 +00002299 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
hasso93406d82005-02-02 14:40:33 +00002300
paul718e3742002-12-13 20:15:29 +00002301 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002302 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul902212c2006-02-05 17:51:19 +00002303
2304 /* implicit withdraw, decrement aggregate and pcount here.
2305 * only if update is accepted, they'll increment below.
2306 */
paul902212c2006-02-05 17:51:19 +00002307 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2308
paul718e3742002-12-13 20:15:29 +00002309 /* Update bgp route dampening information. */
2310 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002311 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002312 {
2313 /* This is implicit withdraw so we should update dampening
2314 information. */
2315 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2316 bgp_damp_withdraw (ri, rn, afi, safi, 1);
paul718e3742002-12-13 20:15:29 +00002317 }
2318
paul718e3742002-12-13 20:15:29 +00002319 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002320 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00002321 ri->attr = attr_new;
2322
2323 /* Update MPLS tag. */
2324 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002325 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002326
Lou Berger050defe2016-01-12 13:41:59 -05002327 bgp_attr_flush (&new_attr);
2328
paul718e3742002-12-13 20:15:29 +00002329 /* Update bgp route dampening information. */
2330 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002331 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002332 {
2333 /* Now we do normal update dampening. */
2334 ret = bgp_damp_update (ri, rn, afi, safi);
2335 if (ret == BGP_DAMP_SUPPRESSED)
2336 {
2337 bgp_unlock_node (rn);
2338 return 0;
2339 }
2340 }
2341
2342 /* Nexthop reachability check. */
2343 if ((afi == AFI_IP || afi == AFI_IP6)
2344 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002345 && (peer->sort == BGP_PEER_IBGP
2346 || peer->sort == BGP_PEER_CONFED
2347 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002348 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002349 {
2350 if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002351 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002352 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002353 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002354 }
2355 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002356 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002357
Lou Berger050defe2016-01-12 13:41:59 -05002358 bgp_attr_flush (&new_attr);
2359
paul718e3742002-12-13 20:15:29 +00002360 /* Process change. */
2361 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2362
2363 bgp_process (bgp, rn, afi, safi);
2364 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002365
paul718e3742002-12-13 20:15:29 +00002366 return 0;
2367 }
2368
2369 /* Received Logging. */
2370 if (BGP_DEBUG (update, UPDATE_IN))
2371 {
ajsd2c1f162004-12-08 21:10:20 +00002372 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002373 peer->host,
2374 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2375 p->prefixlen);
2376 }
2377
paul718e3742002-12-13 20:15:29 +00002378 /* Make new BGP info. */
2379 new = bgp_info_new ();
2380 new->type = type;
2381 new->sub_type = sub_type;
2382 new->peer = peer;
2383 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002384 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002385
2386 /* Update MPLS tag. */
2387 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002388 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002389
2390 /* Nexthop reachability check. */
2391 if ((afi == AFI_IP || afi == AFI_IP6)
2392 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002393 && (peer->sort == BGP_PEER_IBGP
2394 || peer->sort == BGP_PEER_CONFED
2395 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002396 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002397 {
2398 if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002399 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002400 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002401 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002402 }
2403 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002404 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002405
paul902212c2006-02-05 17:51:19 +00002406 /* Increment prefix */
paul718e3742002-12-13 20:15:29 +00002407 bgp_aggregate_increment (bgp, p, new, afi, safi);
2408
2409 /* Register new BGP information. */
2410 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002411
2412 /* route_node_get lock */
2413 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002414
Lou Berger050defe2016-01-12 13:41:59 -05002415 bgp_attr_flush (&new_attr);
2416
paul718e3742002-12-13 20:15:29 +00002417 /* If maximum prefix count is configured and current prefix
2418 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00002419 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
2420 return -1;
paul718e3742002-12-13 20:15:29 +00002421
2422 /* Process change. */
2423 bgp_process (bgp, rn, afi, safi);
2424
2425 return 0;
2426
2427 /* This BGP update is filtered. Log the reason then update BGP
2428 entry. */
2429 filtered:
2430 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002431 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002432 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2433 peer->host,
2434 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2435 p->prefixlen, reason);
2436
2437 if (ri)
paulb40d9392005-08-22 22:34:41 +00002438 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002439
2440 bgp_unlock_node (rn);
Lou Berger050defe2016-01-12 13:41:59 -05002441 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002442
paul718e3742002-12-13 20:15:29 +00002443 return 0;
2444}
2445
2446int
paulfee0f4c2004-09-13 05:12:46 +00002447bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
2448 afi_t afi, safi_t safi, int type, int sub_type,
2449 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2450{
2451 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002452 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002453 struct bgp *bgp;
2454 int ret;
2455
2456 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
2457 soft_reconfig);
2458
2459 bgp = peer->bgp;
2460
2461 /* Process the update for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002462 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002463 {
2464 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2465 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
2466 sub_type, prd, tag);
2467 }
2468
2469 return ret;
2470}
2471
2472int
paul718e3742002-12-13 20:15:29 +00002473bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
paul94f2b392005-06-28 12:44:16 +00002474 afi_t afi, safi_t safi, int type, int sub_type,
2475 struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00002476{
2477 struct bgp *bgp;
2478 char buf[SU_ADDRSTRLEN];
2479 struct bgp_node *rn;
2480 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00002481 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002482 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002483
2484 bgp = peer->bgp;
2485
David Lamparter4584c232015-04-13 09:50:00 +02002486 /* Lookup node. */
2487 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2488
2489 /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2490 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2491 * the iteration over all RS clients.
2492 * Since we need to remove the entry from adj_in anyway, do that first and
2493 * if there was no entry, we don't need to do anything more. */
2494 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2495 && peer != bgp->peer_self)
2496 if (!bgp_adj_in_unset (rn, peer))
2497 {
2498 if (BGP_DEBUG (update, UPDATE_IN))
2499 zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
2500 "not in adj-in", peer->host,
2501 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2502 p->prefixlen);
2503 bgp_unlock_node (rn);
2504 return 0;
2505 }
2506
paulfee0f4c2004-09-13 05:12:46 +00002507 /* Process the withdraw for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002508 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002509 {
2510 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2511 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
2512 }
2513
paul718e3742002-12-13 20:15:29 +00002514 /* Logging. */
2515 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002516 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00002517 peer->host,
2518 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2519 p->prefixlen);
2520
paul718e3742002-12-13 20:15:29 +00002521 /* Lookup withdrawn route. */
2522 for (ri = rn->info; ri; ri = ri->next)
2523 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2524 break;
2525
2526 /* Withdraw specified route from routing table. */
2527 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002528 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paul718e3742002-12-13 20:15:29 +00002529 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002530 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002531 "%s Can't find the route %s/%d", peer->host,
2532 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2533 p->prefixlen);
2534
2535 /* Unlock bgp_node_get() lock. */
2536 bgp_unlock_node (rn);
2537
2538 return 0;
2539}
David Lamparter6b0655a2014-06-04 06:53:35 +02002540
paul718e3742002-12-13 20:15:29 +00002541void
2542bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2543{
2544 struct bgp *bgp;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00002545 struct attr attr;
Jorge Boncompte [DTI2]577ac572012-05-07 16:53:06 +00002546 struct aspath *aspath;
paul718e3742002-12-13 20:15:29 +00002547 struct prefix p;
paul718e3742002-12-13 20:15:29 +00002548 struct peer *from;
Christian Frankedcab1bb2012-12-07 16:45:52 +00002549 struct bgp_node *rn;
2550 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00002551 int ret = RMAP_DENYMATCH;
Paul Jakmafb982c22007-05-04 20:15:47 +00002552
Paul Jakmab2497022007-06-14 11:17:58 +00002553 if (!(afi == AFI_IP || afi == AFI_IP6))
Paul Jakmafb982c22007-05-04 20:15:47 +00002554 return;
2555
paul718e3742002-12-13 20:15:29 +00002556 bgp = peer->bgp;
2557 from = bgp->peer_self;
Paul Jakmafb982c22007-05-04 20:15:47 +00002558
paul718e3742002-12-13 20:15:29 +00002559 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2560 aspath = attr.aspath;
2561 attr.local_pref = bgp->default_local_pref;
2562 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2563
2564 if (afi == AFI_IP)
2565 str2prefix ("0.0.0.0/0", &p);
paul718e3742002-12-13 20:15:29 +00002566 else if (afi == AFI_IP6)
2567 {
Jorge Boncompte [DTI2]6182d652012-05-07 16:53:02 +00002568 struct attr_extra *ae = attr.extra;
2569
paul718e3742002-12-13 20:15:29 +00002570 str2prefix ("::/0", &p);
2571
2572 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00002573 memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00002574 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002575 ae->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00002576
2577 /* If the peer is on shared nextwork and we have link-local
2578 nexthop set it. */
2579 if (peer->shared_network
2580 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2581 {
Paul Jakmafb982c22007-05-04 20:15:47 +00002582 memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00002583 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002584 ae->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00002585 }
2586 }
paul718e3742002-12-13 20:15:29 +00002587
2588 if (peer->default_rmap[afi][safi].name)
2589 {
paulfee0f4c2004-09-13 05:12:46 +00002590 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
Christian Frankedcab1bb2012-12-07 16:45:52 +00002591 for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
2592 {
2593 for (ri = rn->info; ri; ri = ri->next)
2594 {
2595 struct attr dummy_attr;
2596 struct attr_extra dummy_extra;
2597 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00002598
Christian Frankedcab1bb2012-12-07 16:45:52 +00002599 /* Provide dummy so the route-map can't modify the attributes */
2600 dummy_attr.extra = &dummy_extra;
2601 bgp_attr_dup(&dummy_attr, ri->attr);
2602 info.peer = ri->peer;
2603 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00002604
Christian Frankedcab1bb2012-12-07 16:45:52 +00002605 ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
2606 RMAP_BGP, &info);
2607
2608 /* The route map might have set attributes. If we don't flush them
2609 * here, they will be leaked. */
2610 bgp_attr_flush(&dummy_attr);
2611 if (ret != RMAP_DENYMATCH)
2612 break;
2613 }
2614 if (ret != RMAP_DENYMATCH)
2615 break;
2616 }
paulfee0f4c2004-09-13 05:12:46 +00002617 bgp->peer_self->rmap_type = 0;
2618
paul718e3742002-12-13 20:15:29 +00002619 if (ret == RMAP_DENYMATCH)
Christian Frankedcab1bb2012-12-07 16:45:52 +00002620 withdraw = 1;
paul718e3742002-12-13 20:15:29 +00002621 }
2622
2623 if (withdraw)
2624 {
2625 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2626 bgp_default_withdraw_send (peer, afi, safi);
2627 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2628 }
2629 else
2630 {
Christian Frankedcab1bb2012-12-07 16:45:52 +00002631 if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2632 {
2633 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2634 bgp_default_update_send (peer, &attr, afi, safi, from);
2635 }
paul718e3742002-12-13 20:15:29 +00002636 }
Paul Jakmafb982c22007-05-04 20:15:47 +00002637
2638 bgp_attr_extra_free (&attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002639 aspath_unintern (&aspath);
paul718e3742002-12-13 20:15:29 +00002640}
David Lamparter6b0655a2014-06-04 06:53:35 +02002641
paul718e3742002-12-13 20:15:29 +00002642static void
2643bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002644 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002645{
2646 struct bgp_node *rn;
2647 struct bgp_info *ri;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002648 struct attr attr;
2649 struct attr_extra extra;
2650
Lou Berger298cc2f2016-01-12 13:42:02 -05002651 memset(&extra, 0, sizeof(extra));
2652
paul718e3742002-12-13 20:15:29 +00002653 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002654 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002655
Lou Berger298cc2f2016-01-12 13:42:02 -05002656 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00002657 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2658 bgp_default_originate (peer, afi, safi, 0);
2659
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002660 /* It's initialized in bgp_announce_[check|check_rsclient]() */
2661 attr.extra = &extra;
2662
paul718e3742002-12-13 20:15:29 +00002663 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2664 for (ri = rn->info; ri; ri = ri->next)
2665 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2666 {
paulfee0f4c2004-09-13 05:12:46 +00002667 if ( (rsclient) ?
2668 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2669 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002670 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2671 else
2672 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2673 }
Lou Berger298cc2f2016-01-12 13:42:02 -05002674
2675 bgp_attr_flush_encap(&attr);
paul718e3742002-12-13 20:15:29 +00002676}
2677
2678void
2679bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2680{
2681 struct bgp_node *rn;
2682 struct bgp_table *table;
2683
2684 if (peer->status != Established)
2685 return;
2686
2687 if (! peer->afc_nego[afi][safi])
2688 return;
2689
2690 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2691 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2692 return;
2693
Lou Berger298cc2f2016-01-12 13:42:02 -05002694 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
paulfee0f4c2004-09-13 05:12:46 +00002695 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002696 else
2697 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2698 rn = bgp_route_next(rn))
2699 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002700 bgp_announce_table (peer, afi, safi, table, 0);
2701
2702 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2703 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002704}
2705
2706void
2707bgp_announce_route_all (struct peer *peer)
2708{
2709 afi_t afi;
2710 safi_t safi;
2711
2712 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2713 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2714 bgp_announce_route (peer, afi, safi);
2715}
David Lamparter6b0655a2014-06-04 06:53:35 +02002716
paul718e3742002-12-13 20:15:29 +00002717static void
paulfee0f4c2004-09-13 05:12:46 +00002718bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002719 safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
paulfee0f4c2004-09-13 05:12:46 +00002720{
2721 struct bgp_node *rn;
2722 struct bgp_adj_in *ain;
2723
2724 if (! table)
2725 table = rsclient->bgp->rib[afi][safi];
2726
2727 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2728 for (ain = rn->adj_in; ain; ain = ain->next)
2729 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002730 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002731 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002732
paulfee0f4c2004-09-13 05:12:46 +00002733 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
Christian Franked53d8fd2013-01-28 07:14:43 +01002734 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
paulfee0f4c2004-09-13 05:12:46 +00002735 }
2736}
2737
2738void
2739bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2740{
2741 struct bgp_table *table;
2742 struct bgp_node *rn;
2743
Lou Berger298cc2f2016-01-12 13:42:02 -05002744 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002745 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
paulfee0f4c2004-09-13 05:12:46 +00002746
2747 else
2748 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2749 rn = bgp_route_next (rn))
2750 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002751 {
2752 struct prefix_rd prd;
2753 prd.family = AF_UNSPEC;
2754 prd.prefixlen = 64;
2755 memcpy(&prd.val, rn->p.u.val, 8);
2756
2757 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
2758 }
paulfee0f4c2004-09-13 05:12:46 +00002759}
David Lamparter6b0655a2014-06-04 06:53:35 +02002760
paulfee0f4c2004-09-13 05:12:46 +00002761static void
paul718e3742002-12-13 20:15:29 +00002762bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002763 struct bgp_table *table, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00002764{
2765 int ret;
2766 struct bgp_node *rn;
2767 struct bgp_adj_in *ain;
2768
2769 if (! table)
2770 table = peer->bgp->rib[afi][safi];
2771
2772 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2773 for (ain = rn->adj_in; ain; ain = ain->next)
2774 {
2775 if (ain->peer == peer)
2776 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002777 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002778 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002779
paul718e3742002-12-13 20:15:29 +00002780 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2781 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
Christian Franked53d8fd2013-01-28 07:14:43 +01002782 prd, tag, 1);
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002783
paul718e3742002-12-13 20:15:29 +00002784 if (ret < 0)
2785 {
2786 bgp_unlock_node (rn);
2787 return;
2788 }
2789 continue;
2790 }
2791 }
2792}
2793
2794void
2795bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2796{
2797 struct bgp_node *rn;
2798 struct bgp_table *table;
2799
2800 if (peer->status != Established)
2801 return;
2802
Lou Berger298cc2f2016-01-12 13:42:02 -05002803 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002804 bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002805 else
2806 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2807 rn = bgp_route_next (rn))
2808 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002809 {
2810 struct prefix_rd prd;
2811 prd.family = AF_UNSPEC;
2812 prd.prefixlen = 64;
2813 memcpy(&prd.val, rn->p.u.val, 8);
2814
2815 bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
2816 }
paul718e3742002-12-13 20:15:29 +00002817}
David Lamparter6b0655a2014-06-04 06:53:35 +02002818
Chris Caputo228da422009-07-18 05:44:03 +00002819
2820struct bgp_clear_node_queue
2821{
2822 struct bgp_node *rn;
2823 enum bgp_clear_route_type purpose;
2824};
2825
paul200df112005-06-01 11:17:05 +00002826static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00002827bgp_clear_route_node (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002828{
Chris Caputo228da422009-07-18 05:44:03 +00002829 struct bgp_clear_node_queue *cnq = data;
2830 struct bgp_node *rn = cnq->rn;
Paul Jakma64e580a2006-02-21 01:09:01 +00002831 struct peer *peer = wq->spec.data;
paul200df112005-06-01 11:17:05 +00002832 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002833 afi_t afi = bgp_node_table (rn)->afi;
2834 safi_t safi = bgp_node_table (rn)->safi;
paul200df112005-06-01 11:17:05 +00002835
Paul Jakma64e580a2006-02-21 01:09:01 +00002836 assert (rn && peer);
paul200df112005-06-01 11:17:05 +00002837
Paul Jakma64e580a2006-02-21 01:09:01 +00002838 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002839 if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
paul200df112005-06-01 11:17:05 +00002840 {
2841 /* graceful restart STALE flag set. */
Paul Jakma64e580a2006-02-21 01:09:01 +00002842 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2843 && peer->nsf[afi][safi]
paul200df112005-06-01 11:17:05 +00002844 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
Paul Jakma1a392d42006-09-07 00:24:49 +00002845 && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
2846 bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
paul200df112005-06-01 11:17:05 +00002847 else
Paul Jakma64e580a2006-02-21 01:09:01 +00002848 bgp_rib_remove (rn, ri, peer, afi, safi);
paul200df112005-06-01 11:17:05 +00002849 break;
2850 }
paul200df112005-06-01 11:17:05 +00002851 return WQ_SUCCESS;
2852}
2853
2854static void
paul0fb58d52005-11-14 14:31:49 +00002855bgp_clear_node_queue_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002856{
Chris Caputo228da422009-07-18 05:44:03 +00002857 struct bgp_clear_node_queue *cnq = data;
2858 struct bgp_node *rn = cnq->rn;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002859 struct bgp_table *table = bgp_node_table (rn);
Paul Jakma64e580a2006-02-21 01:09:01 +00002860
2861 bgp_unlock_node (rn);
Chris Caputo228da422009-07-18 05:44:03 +00002862 bgp_table_unlock (table);
2863 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
paul200df112005-06-01 11:17:05 +00002864}
2865
2866static void
paul94f2b392005-06-28 12:44:16 +00002867bgp_clear_node_complete (struct work_queue *wq)
paul200df112005-06-01 11:17:05 +00002868{
Paul Jakma64e580a2006-02-21 01:09:01 +00002869 struct peer *peer = wq->spec.data;
2870
Paul Jakma3e0c78e2006-03-06 18:06:53 +00002871 /* Tickle FSM to start moving again */
Paul Jakmaca058a32006-09-14 02:58:49 +00002872 BGP_EVENT_ADD (peer, Clearing_Completed);
Chris Caputo228da422009-07-18 05:44:03 +00002873
2874 peer_unlock (peer); /* bgp_clear_route */
paul200df112005-06-01 11:17:05 +00002875}
2876
2877static void
Paul Jakma64e580a2006-02-21 01:09:01 +00002878bgp_clear_node_queue_init (struct peer *peer)
paul200df112005-06-01 11:17:05 +00002879{
Paul Jakmaa2943652009-07-21 14:02:04 +01002880 char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
Paul Jakma64e580a2006-02-21 01:09:01 +00002881
Paul Jakmaa2943652009-07-21 14:02:04 +01002882 snprintf (wname, sizeof(wname), "clear %s", peer->host);
Paul Jakma64e580a2006-02-21 01:09:01 +00002883#undef CLEAR_QUEUE_NAME_LEN
2884
2885 if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
paul200df112005-06-01 11:17:05 +00002886 {
2887 zlog_err ("%s: Failed to allocate work queue", __func__);
2888 exit (1);
2889 }
Paul Jakma64e580a2006-02-21 01:09:01 +00002890 peer->clear_node_queue->spec.hold = 10;
2891 peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
2892 peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
2893 peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
2894 peer->clear_node_queue->spec.max_retries = 0;
2895
2896 /* we only 'lock' this peer reference when the queue is actually active */
2897 peer->clear_node_queue->spec.data = peer;
paul200df112005-06-01 11:17:05 +00002898}
2899
paul718e3742002-12-13 20:15:29 +00002900static void
2901bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
Chris Caputo228da422009-07-18 05:44:03 +00002902 struct bgp_table *table, struct peer *rsclient,
2903 enum bgp_clear_route_type purpose)
paul718e3742002-12-13 20:15:29 +00002904{
2905 struct bgp_node *rn;
paul200df112005-06-01 11:17:05 +00002906
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002907
paul718e3742002-12-13 20:15:29 +00002908 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002909 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
Paul Jakma64e580a2006-02-21 01:09:01 +00002910
hasso6cf159b2005-03-21 10:28:14 +00002911 /* If still no table => afi/safi isn't configured at all or smth. */
2912 if (! table)
2913 return;
Paul Jakma65ca75e2006-05-04 08:08:15 +00002914
2915 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2916 {
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002917 struct bgp_info *ri;
2918 struct bgp_adj_in *ain;
2919 struct bgp_adj_out *aout;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002920
2921 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2922 * queued for every clearing peer, regardless of whether it is
2923 * relevant to the peer at hand.
2924 *
2925 * Overview: There are 3 different indices which need to be
2926 * scrubbed, potentially, when a peer is removed:
2927 *
2928 * 1 peer's routes visible via the RIB (ie accepted routes)
2929 * 2 peer's routes visible by the (optional) peer's adj-in index
2930 * 3 other routes visible by the peer's adj-out index
2931 *
2932 * 3 there is no hurry in scrubbing, once the struct peer is
2933 * removed from bgp->peer, we could just GC such deleted peer's
2934 * adj-outs at our leisure.
2935 *
2936 * 1 and 2 must be 'scrubbed' in some way, at least made
2937 * invisible via RIB index before peer session is allowed to be
2938 * brought back up. So one needs to know when such a 'search' is
2939 * complete.
2940 *
2941 * Ideally:
2942 *
2943 * - there'd be a single global queue or a single RIB walker
2944 * - rather than tracking which route_nodes still need to be
2945 * examined on a peer basis, we'd track which peers still
2946 * aren't cleared
2947 *
2948 * Given that our per-peer prefix-counts now should be reliable,
2949 * this may actually be achievable. It doesn't seem to be a huge
2950 * problem at this time,
2951 */
Jorge Boncompte [DTI2]24e50f22012-05-07 15:17:33 +00002952 for (ain = rn->adj_in; ain; ain = ain->next)
2953 if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2954 {
2955 bgp_adj_in_remove (rn, ain);
2956 bgp_unlock_node (rn);
2957 break;
2958 }
2959 for (aout = rn->adj_out; aout; aout = aout->next)
2960 if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2961 {
2962 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2963 bgp_unlock_node (rn);
2964 break;
2965 }
2966
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002967 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002968 if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002969 {
Chris Caputo228da422009-07-18 05:44:03 +00002970 struct bgp_clear_node_queue *cnq;
2971
2972 /* both unlocked in bgp_clear_node_queue_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07002973 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00002974 bgp_lock_node (rn);
2975 cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
2976 sizeof (struct bgp_clear_node_queue));
2977 cnq->rn = rn;
2978 cnq->purpose = purpose;
2979 work_queue_add (peer->clear_node_queue, cnq);
2980 break;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002981 }
Paul Jakma65ca75e2006-05-04 08:08:15 +00002982 }
2983 return;
2984}
2985
2986void
Chris Caputo228da422009-07-18 05:44:03 +00002987bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
2988 enum bgp_clear_route_type purpose)
Paul Jakma65ca75e2006-05-04 08:08:15 +00002989{
2990 struct bgp_node *rn;
2991 struct bgp_table *table;
2992 struct peer *rsclient;
2993 struct listnode *node, *nnode;
hasso6cf159b2005-03-21 10:28:14 +00002994
Paul Jakma64e580a2006-02-21 01:09:01 +00002995 if (peer->clear_node_queue == NULL)
2996 bgp_clear_node_queue_init (peer);
paul200df112005-06-01 11:17:05 +00002997
Paul Jakmaca058a32006-09-14 02:58:49 +00002998 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2999 * Idle until it receives a Clearing_Completed event. This protects
3000 * against peers which flap faster than we can we clear, which could
3001 * lead to:
Paul Jakma64e580a2006-02-21 01:09:01 +00003002 *
3003 * a) race with routes from the new session being installed before
3004 * clear_route_node visits the node (to delete the route of that
3005 * peer)
3006 * b) resource exhaustion, clear_route_node likely leads to an entry
3007 * on the process_main queue. Fast-flapping could cause that queue
3008 * to grow and grow.
paul200df112005-06-01 11:17:05 +00003009 */
Donald Sharp7ef42212015-03-30 06:32:52 -07003010
3011 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3012 * the unlock will happen upon work-queue completion; other wise, the
3013 * unlock happens at the end of this function.
3014 */
Paul Jakmaca058a32006-09-14 02:58:49 +00003015 if (!peer->clear_node_queue->thread)
Lou Berger050defe2016-01-12 13:41:59 -05003016 peer_lock (peer); /* bgp_clear_node_complete */
Chris Caputo228da422009-07-18 05:44:03 +00003017 switch (purpose)
paulfee0f4c2004-09-13 05:12:46 +00003018 {
Chris Caputo228da422009-07-18 05:44:03 +00003019 case BGP_CLEAR_ROUTE_NORMAL:
Lou Berger298cc2f2016-01-12 13:42:02 -05003020 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Chris Caputo228da422009-07-18 05:44:03 +00003021 bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
3022 else
3023 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
3024 rn = bgp_route_next (rn))
3025 if ((table = rn->info) != NULL)
3026 bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
3027
3028 for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
3029 if (CHECK_FLAG(rsclient->af_flags[afi][safi],
3030 PEER_FLAG_RSERVER_CLIENT))
3031 bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
3032 break;
3033
3034 case BGP_CLEAR_ROUTE_MY_RSCLIENT:
Lou Berger050defe2016-01-12 13:41:59 -05003035 /*
3036 * gpz 091009: TBD why don't we have special handling for
3037 * SAFI_MPLS_VPN here in the original quagga code?
3038 * (and, by extension, for SAFI_ENCAP)
3039 */
Chris Caputo228da422009-07-18 05:44:03 +00003040 bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
3041 break;
3042
3043 default:
3044 assert (0);
3045 break;
paulfee0f4c2004-09-13 05:12:46 +00003046 }
Donald Sharp7ef42212015-03-30 06:32:52 -07003047
3048 /* unlock if no nodes got added to the clear-node-queue. */
Paul Jakma65ca75e2006-05-04 08:08:15 +00003049 if (!peer->clear_node_queue->thread)
Donald Sharp7ef42212015-03-30 06:32:52 -07003050 peer_unlock (peer);
3051
paul718e3742002-12-13 20:15:29 +00003052}
3053
3054void
3055bgp_clear_route_all (struct peer *peer)
3056{
3057 afi_t afi;
3058 safi_t safi;
3059
3060 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3061 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
Chris Caputo228da422009-07-18 05:44:03 +00003062 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
paul718e3742002-12-13 20:15:29 +00003063}
3064
Lou Berger82dd7072016-01-12 13:41:57 -05003065/*
3066 * Finish freeing things when exiting
3067 */
3068static void
3069bgp_drain_workqueue_immediate (struct work_queue *wq)
3070{
3071 if (!wq)
3072 return;
3073
3074 if (!wq->thread)
3075 {
3076 /*
3077 * no thread implies no queued items
3078 */
3079 assert(!wq->items->count);
3080 return;
3081 }
3082
3083 while (wq->items->count)
3084 {
3085 if (wq->thread)
3086 thread_cancel(wq->thread);
3087 work_queue_run(wq->thread);
3088 }
3089}
3090
3091/*
3092 * Special function to process clear node queue when bgpd is exiting
3093 * and the thread scheduler is no longer running.
3094 */
3095void
3096bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
3097{
3098 if (!peer)
3099 return;
3100
3101 bgp_drain_workqueue_immediate(peer->clear_node_queue);
3102}
3103
3104/*
3105 * The work queues are not specific to a BGP instance, but the
3106 * items in them refer to BGP instances, so this should be called
3107 * before each BGP instance is deleted.
3108 */
3109void
3110bgp_process_queues_drain_immediate(void)
3111{
3112 bgp_drain_workqueue_immediate(bm->process_main_queue);
3113 bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
3114}
3115
paul718e3742002-12-13 20:15:29 +00003116void
3117bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
3118{
3119 struct bgp_table *table;
3120 struct bgp_node *rn;
3121 struct bgp_adj_in *ain;
3122
3123 table = peer->bgp->rib[afi][safi];
3124
3125 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3126 for (ain = rn->adj_in; ain ; ain = ain->next)
3127 if (ain->peer == peer)
3128 {
3129 bgp_adj_in_remove (rn, ain);
3130 bgp_unlock_node (rn);
3131 break;
3132 }
3133}
hasso93406d82005-02-02 14:40:33 +00003134
3135void
3136bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
3137{
3138 struct bgp_node *rn;
3139 struct bgp_info *ri;
3140 struct bgp_table *table;
3141
3142 table = peer->bgp->rib[afi][safi];
3143
3144 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3145 {
3146 for (ri = rn->info; ri; ri = ri->next)
3147 if (ri->peer == peer)
3148 {
3149 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
3150 bgp_rib_remove (rn, ri, peer, afi, safi);
3151 break;
3152 }
3153 }
3154}
David Lamparter6b0655a2014-06-04 06:53:35 +02003155
Lou Berger82dd7072016-01-12 13:41:57 -05003156static void
3157bgp_cleanup_table(struct bgp_table *table, safi_t safi)
3158{
3159 struct bgp_node *rn;
3160 struct bgp_info *ri;
3161 struct bgp_info *next;
3162
3163 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3164 for (ri = rn->info; ri; ri = next)
3165 {
3166 next = ri->next;
3167 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
3168 && ri->type == ZEBRA_ROUTE_BGP
3169 && ri->sub_type == BGP_ROUTE_NORMAL)
3170 bgp_zebra_withdraw (&rn->p, ri, safi);
3171 }
3172}
3173
paul718e3742002-12-13 20:15:29 +00003174/* Delete all kernel routes. */
3175void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003176bgp_cleanup_routes (void)
paul718e3742002-12-13 20:15:29 +00003177{
3178 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00003179 struct listnode *node, *nnode;
Lou Berger82dd7072016-01-12 13:41:57 -05003180 afi_t afi;
paul718e3742002-12-13 20:15:29 +00003181
paul1eb8ef22005-04-07 07:30:20 +00003182 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00003183 {
Lou Berger82dd7072016-01-12 13:41:57 -05003184 for (afi = AFI_IP; afi < AFI_MAX; ++afi)
3185 {
3186 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00003187
Lou Berger82dd7072016-01-12 13:41:57 -05003188 bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00003189
Lou Berger82dd7072016-01-12 13:41:57 -05003190 /*
3191 * VPN and ENCAP tables are two-level (RD is top level)
3192 */
3193 for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
3194 rn = bgp_route_next (rn))
Lou Berger298cc2f2016-01-12 13:42:02 -05003195 {
3196 if (rn->info)
Lou Berger82dd7072016-01-12 13:41:57 -05003197 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003198 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
3199 bgp_table_finish ((struct bgp_table **)&(rn->info));
3200 rn->info = NULL;
3201 bgp_unlock_node(rn);
Lou Berger82dd7072016-01-12 13:41:57 -05003202 }
Lou Berger298cc2f2016-01-12 13:42:02 -05003203 }
3204
3205 for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
3206 rn = bgp_route_next (rn))
3207 {
3208 if (rn->info)
3209 {
3210 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
3211 bgp_table_finish ((struct bgp_table **)&(rn->info));
3212 rn->info = NULL;
3213 bgp_unlock_node(rn);
3214 }
3215 }
Lou Berger82dd7072016-01-12 13:41:57 -05003216 }
paul718e3742002-12-13 20:15:29 +00003217 }
3218}
3219
3220void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003221bgp_reset (void)
paul718e3742002-12-13 20:15:29 +00003222{
3223 vty_reset ();
3224 bgp_zclient_reset ();
3225 access_list_reset ();
3226 prefix_list_reset ();
3227}
David Lamparter6b0655a2014-06-04 06:53:35 +02003228
paul718e3742002-12-13 20:15:29 +00003229/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3230 value. */
3231int
Paul Jakma518a4b72016-02-04 13:27:04 +00003232bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
3233 struct bgp_nlri *packet)
paul718e3742002-12-13 20:15:29 +00003234{
3235 u_char *pnt;
3236 u_char *lim;
3237 struct prefix p;
3238 int psize;
3239 int ret;
3240
3241 /* Check peer status. */
3242 if (peer->status != Established)
3243 return 0;
3244
3245 pnt = packet->nlri;
3246 lim = pnt + packet->length;
3247
Paul Jakma405e9e12016-02-04 17:00:18 +00003248 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3249 syntactic validity. If the field is syntactically incorrect,
3250 then the Error Subcode is set to Invalid Network Field. */
paul718e3742002-12-13 20:15:29 +00003251 for (; pnt < lim; pnt += psize)
3252 {
3253 /* Clear prefix structure. */
3254 memset (&p, 0, sizeof (struct prefix));
3255
3256 /* Fetch prefix length. */
3257 p.prefixlen = *pnt++;
Paul Jakma405e9e12016-02-04 17:00:18 +00003258 /* afi/safi validity already verified by caller, bgp_update_receive */
paul718e3742002-12-13 20:15:29 +00003259 p.family = afi2family (packet->afi);
3260
Paul Jakma405e9e12016-02-04 17:00:18 +00003261 /* Prefix length check. */
3262 if (p.prefixlen > prefix_blen (&p) * 8)
3263 {
3264 plog_err (peer->log,
3265 "%s [Error] Update packet error"
3266 " (wrong prefix length %u for afi %u)",
3267 peer->host, p.prefixlen, packet->afi);
3268 return -1;
3269 }
3270
paul718e3742002-12-13 20:15:29 +00003271 /* Packet size overflow check. */
3272 psize = PSIZE (p.prefixlen);
3273
3274 /* When packet overflow occur return immediately. */
3275 if (pnt + psize > lim)
Paul Jakma405e9e12016-02-04 17:00:18 +00003276 {
3277 plog_err (peer->log,
3278 "%s [Error] Update packet error"
3279 " (prefix length %u overflows packet)",
3280 peer->host, p.prefixlen);
3281 return -1;
3282 }
3283
3284 /* Defensive coding, double-check the psize fits in a struct prefix */
3285 if (psize > (ssize_t) sizeof(p.u))
3286 {
3287 plog_err (peer->log,
3288 "%s [Error] Update packet error"
3289 " (prefix length %u too large for prefix storage %zu!?!!",
3290 peer->host, p.prefixlen, sizeof(p.u));
3291 return -1;
3292 }
paul718e3742002-12-13 20:15:29 +00003293
3294 /* Fetch prefix from NLRI packet. */
3295 memcpy (&p.u.prefix, pnt, psize);
3296
3297 /* Check address. */
3298 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
3299 {
3300 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
3301 {
paulf5ba3872004-07-09 12:11:31 +00003302 /*
Paul Jakma405e9e12016-02-04 17:00:18 +00003303 * From RFC4271 Section 6.3:
3304 *
3305 * If a prefix in the NLRI field is semantically incorrect
3306 * (e.g., an unexpected multicast IP address), an error SHOULD
3307 * be logged locally, and the prefix SHOULD be ignored.
paulf5ba3872004-07-09 12:11:31 +00003308 */
paul718e3742002-12-13 20:15:29 +00003309 zlog (peer->log, LOG_ERR,
Paul Jakma405e9e12016-02-04 17:00:18 +00003310 "%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3311 peer->host, inet_ntoa (p.u.prefix4));
3312 continue;
paul718e3742002-12-13 20:15:29 +00003313 }
3314 }
3315
paul718e3742002-12-13 20:15:29 +00003316 /* Check address. */
3317 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
3318 {
3319 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3320 {
3321 char buf[BUFSIZ];
3322
Paul Jakma405e9e12016-02-04 17:00:18 +00003323 zlog (peer->log, LOG_ERR,
3324 "%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3325 peer->host,
paul718e3742002-12-13 20:15:29 +00003326 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00003327 continue;
3328 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003329 if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6))
3330 {
3331 char buf[BUFSIZ];
3332
3333 zlog (peer->log, LOG_ERR,
3334 "%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3335 peer->host,
3336 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3337 continue;
3338 }
3339 }
paul718e3742002-12-13 20:15:29 +00003340
3341 /* Normal process. */
3342 if (attr)
3343 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
3344 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
3345 else
3346 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
3347 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
3348
3349 /* Address family configuration mismatch or maximum-prefix count
3350 overflow. */
3351 if (ret < 0)
3352 return -1;
3353 }
3354
3355 /* Packet length consistency check. */
3356 if (pnt != lim)
paul718e3742002-12-13 20:15:29 +00003357 {
3358 plog_err (peer->log,
Paul Jakma405e9e12016-02-04 17:00:18 +00003359 "%s [Error] Update packet error"
3360 " (prefix length mismatch with total length)",
3361 peer->host);
paul718e3742002-12-13 20:15:29 +00003362 return -1;
3363 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003364
paul718e3742002-12-13 20:15:29 +00003365 return 0;
3366}
David Lamparter6b0655a2014-06-04 06:53:35 +02003367
paul94f2b392005-06-28 12:44:16 +00003368static struct bgp_static *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003369bgp_static_new (void)
paul718e3742002-12-13 20:15:29 +00003370{
Stephen Hemminger393deb92008-08-18 14:13:29 -07003371 return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
paul718e3742002-12-13 20:15:29 +00003372}
3373
paul94f2b392005-06-28 12:44:16 +00003374static void
paul718e3742002-12-13 20:15:29 +00003375bgp_static_free (struct bgp_static *bgp_static)
3376{
3377 if (bgp_static->rmap.name)
3378 free (bgp_static->rmap.name);
3379 XFREE (MTYPE_BGP_STATIC, bgp_static);
3380}
3381
paul94f2b392005-06-28 12:44:16 +00003382static void
paulfee0f4c2004-09-13 05:12:46 +00003383bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
3384 struct prefix *p, afi_t afi, safi_t safi)
3385{
3386 struct bgp_node *rn;
3387 struct bgp_info *ri;
3388
3389 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3390
3391 /* Check selected route and self inserted route. */
3392 for (ri = rn->info; ri; ri = ri->next)
3393 if (ri->peer == bgp->peer_self
3394 && ri->type == ZEBRA_ROUTE_BGP
3395 && ri->sub_type == BGP_ROUTE_STATIC)
3396 break;
3397
3398 /* Withdraw static BGP route from routing table. */
3399 if (ri)
3400 {
paulfee0f4c2004-09-13 05:12:46 +00003401 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003402 bgp_process (bgp, rn, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003403 }
3404
3405 /* Unlock bgp_node_lookup. */
3406 bgp_unlock_node (rn);
3407}
3408
paul94f2b392005-06-28 12:44:16 +00003409static void
paulfee0f4c2004-09-13 05:12:46 +00003410bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
Paul Jakmafb982c22007-05-04 20:15:47 +00003411 struct bgp_static *bgp_static,
3412 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00003413{
3414 struct bgp_node *rn;
3415 struct bgp_info *ri;
3416 struct bgp_info *new;
3417 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00003418 struct attr *attr_new;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003419 struct attr attr;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003420 struct attr new_attr;
3421 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00003422 struct bgp *bgp;
3423 int ret;
3424 char buf[SU_ADDRSTRLEN];
3425
3426 bgp = rsclient->bgp;
3427
Paul Jakma06e110f2006-05-12 23:29:22 +00003428 assert (bgp_static);
3429 if (!bgp_static)
3430 return;
3431
paulfee0f4c2004-09-13 05:12:46 +00003432 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3433
3434 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakma06e110f2006-05-12 23:29:22 +00003435
3436 attr.nexthop = bgp_static->igpnexthop;
3437 attr.med = bgp_static->igpmetric;
3438 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Paul Jakma41367172007-08-06 15:24:51 +00003439
Paul Jakma41367172007-08-06 15:24:51 +00003440 if (bgp_static->atomic)
3441 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3442
paulfee0f4c2004-09-13 05:12:46 +00003443 /* Apply network route-map for export to this rsclient. */
3444 if (bgp_static->rmap.name)
3445 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003446 struct attr attr_tmp = attr;
paulfee0f4c2004-09-13 05:12:46 +00003447 info.peer = rsclient;
Paul Jakmafb982c22007-05-04 20:15:47 +00003448 info.attr = &attr_tmp;
3449
paulfee0f4c2004-09-13 05:12:46 +00003450 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
3451 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
3452
3453 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3454
3455 rsclient->rmap_type = 0;
3456
3457 if (ret == RMAP_DENYMATCH)
3458 {
3459 /* Free uninterned attribute. */
Paul Jakmafb982c22007-05-04 20:15:47 +00003460 bgp_attr_flush (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003461
3462 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003463 aspath_unintern (&attr.aspath);
paulfee0f4c2004-09-13 05:12:46 +00003464 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
Paul Jakmafb982c22007-05-04 20:15:47 +00003465 bgp_attr_extra_free (&attr);
3466
paulfee0f4c2004-09-13 05:12:46 +00003467 return;
3468 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003469 attr_new = bgp_attr_intern (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003470 }
3471 else
3472 attr_new = bgp_attr_intern (&attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003473
3474 new_attr.extra = &new_extra;
Stephen Hemminger7badc262010-08-05 10:26:31 -07003475 bgp_attr_dup(&new_attr, attr_new);
Paul Jakmafb982c22007-05-04 20:15:47 +00003476
paulfee0f4c2004-09-13 05:12:46 +00003477 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3478
Paul Jakmafb982c22007-05-04 20:15:47 +00003479 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi)
3480 == RMAP_DENY)
3481 {
paulfee0f4c2004-09-13 05:12:46 +00003482 /* This BGP update is filtered. Log the reason then update BGP entry. */
3483 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00003484 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00003485 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3486 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
3487 p->prefixlen, rsclient->host);
3488
3489 bgp->peer_self->rmap_type = 0;
3490
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003491 bgp_attr_unintern (&attr_new);
3492 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003493 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003494
3495 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3496
3497 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003498 }
paulfee0f4c2004-09-13 05:12:46 +00003499
3500 bgp->peer_self->rmap_type = 0;
3501
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003502 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00003503 attr_new = bgp_attr_intern (&new_attr);
3504
3505 for (ri = rn->info; ri; ri = ri->next)
3506 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3507 && ri->sub_type == BGP_ROUTE_STATIC)
3508 break;
3509
3510 if (ri)
3511 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003512 if (attrhash_cmp (ri->attr, attr_new) &&
3513 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paulfee0f4c2004-09-13 05:12:46 +00003514 {
3515 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003516 bgp_attr_unintern (&attr_new);
3517 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003518 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003519 return;
3520 }
3521 else
3522 {
3523 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003524 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00003525
3526 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003527 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3528 bgp_info_restore(rn, ri);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003529 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00003530 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003531 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003532
3533 /* Process change. */
3534 bgp_process (bgp, rn, afi, safi);
3535 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003536 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003537 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003538 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003539 }
paulfee0f4c2004-09-13 05:12:46 +00003540 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003541
paulfee0f4c2004-09-13 05:12:46 +00003542 /* Make new BGP info. */
3543 new = bgp_info_new ();
3544 new->type = ZEBRA_ROUTE_BGP;
3545 new->sub_type = BGP_ROUTE_STATIC;
3546 new->peer = bgp->peer_self;
3547 SET_FLAG (new->flags, BGP_INFO_VALID);
3548 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003549 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003550
3551 /* Register new BGP information. */
3552 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003553
3554 /* route_node_get lock */
3555 bgp_unlock_node (rn);
3556
paulfee0f4c2004-09-13 05:12:46 +00003557 /* Process change. */
3558 bgp_process (bgp, rn, afi, safi);
3559
3560 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003561 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003562 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003563}
3564
paul94f2b392005-06-28 12:44:16 +00003565static void
paulfee0f4c2004-09-13 05:12:46 +00003566bgp_static_update_main (struct bgp *bgp, struct prefix *p,
paul718e3742002-12-13 20:15:29 +00003567 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3568{
3569 struct bgp_node *rn;
3570 struct bgp_info *ri;
3571 struct bgp_info *new;
3572 struct bgp_info info;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003573 struct attr attr;
paul718e3742002-12-13 20:15:29 +00003574 struct attr *attr_new;
3575 int ret;
3576
Paul Jakmadd8103a2006-05-12 23:27:30 +00003577 assert (bgp_static);
3578 if (!bgp_static)
3579 return;
3580
paulfee0f4c2004-09-13 05:12:46 +00003581 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003582
3583 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakmadd8103a2006-05-12 23:27:30 +00003584
3585 attr.nexthop = bgp_static->igpnexthop;
3586 attr.med = bgp_static->igpmetric;
3587 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
paul718e3742002-12-13 20:15:29 +00003588
Paul Jakma41367172007-08-06 15:24:51 +00003589 if (bgp_static->atomic)
3590 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3591
paul718e3742002-12-13 20:15:29 +00003592 /* Apply route-map. */
3593 if (bgp_static->rmap.name)
3594 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003595 struct attr attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00003596 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00003597 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00003598
paulfee0f4c2004-09-13 05:12:46 +00003599 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3600
paul718e3742002-12-13 20:15:29 +00003601 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00003602
paulfee0f4c2004-09-13 05:12:46 +00003603 bgp->peer_self->rmap_type = 0;
3604
paul718e3742002-12-13 20:15:29 +00003605 if (ret == RMAP_DENYMATCH)
3606 {
3607 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00003608 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003609
3610 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003611 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003612 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003613 bgp_static_withdraw (bgp, p, afi, safi);
3614 return;
3615 }
paul286e1e72003-08-08 00:24:31 +00003616 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003617 }
paul286e1e72003-08-08 00:24:31 +00003618 else
3619 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00003620
3621 for (ri = rn->info; ri; ri = ri->next)
3622 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3623 && ri->sub_type == BGP_ROUTE_STATIC)
3624 break;
3625
3626 if (ri)
3627 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003628 if (attrhash_cmp (ri->attr, attr_new) &&
3629 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00003630 {
3631 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003632 bgp_attr_unintern (&attr_new);
3633 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003634 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003635 return;
3636 }
3637 else
3638 {
3639 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003640 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00003641
3642 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003643 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3644 bgp_info_restore(rn, ri);
3645 else
3646 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003647 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00003648 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003649 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003650
3651 /* Process change. */
3652 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3653 bgp_process (bgp, rn, afi, safi);
3654 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003655 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003656 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003657 return;
3658 }
3659 }
3660
3661 /* Make new BGP info. */
3662 new = bgp_info_new ();
3663 new->type = ZEBRA_ROUTE_BGP;
3664 new->sub_type = BGP_ROUTE_STATIC;
3665 new->peer = bgp->peer_self;
3666 SET_FLAG (new->flags, BGP_INFO_VALID);
3667 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003668 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003669
3670 /* Aggregate address increment. */
3671 bgp_aggregate_increment (bgp, p, new, afi, safi);
3672
3673 /* Register new BGP information. */
3674 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003675
3676 /* route_node_get lock */
3677 bgp_unlock_node (rn);
3678
paul718e3742002-12-13 20:15:29 +00003679 /* Process change. */
3680 bgp_process (bgp, rn, afi, safi);
3681
3682 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003683 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003684 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003685}
3686
3687void
paulfee0f4c2004-09-13 05:12:46 +00003688bgp_static_update (struct bgp *bgp, struct prefix *p,
3689 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3690{
3691 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00003692 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00003693
3694 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
3695
paul1eb8ef22005-04-07 07:30:20 +00003696 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00003697 {
Paul Jakmada5b30f2006-05-08 14:37:17 +00003698 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
3699 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003700 }
3701}
3702
paul718e3742002-12-13 20:15:29 +00003703void
3704bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
3705 safi_t safi)
3706{
3707 struct bgp_node *rn;
3708 struct bgp_info *ri;
3709
paulfee0f4c2004-09-13 05:12:46 +00003710 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003711
3712 /* Check selected route and self inserted route. */
3713 for (ri = rn->info; ri; ri = ri->next)
3714 if (ri->peer == bgp->peer_self
3715 && ri->type == ZEBRA_ROUTE_BGP
3716 && ri->sub_type == BGP_ROUTE_STATIC)
3717 break;
3718
3719 /* Withdraw static BGP route from routing table. */
3720 if (ri)
3721 {
3722 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003723 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003724 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003725 }
3726
3727 /* Unlock bgp_node_lookup. */
3728 bgp_unlock_node (rn);
3729}
3730
3731void
paulfee0f4c2004-09-13 05:12:46 +00003732bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3733{
3734 struct bgp_static *bgp_static;
3735 struct bgp *bgp;
3736 struct bgp_node *rn;
3737 struct prefix *p;
3738
3739 bgp = rsclient->bgp;
3740
3741 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3742 if ((bgp_static = rn->info) != NULL)
3743 {
3744 p = &rn->p;
3745
3746 bgp_static_update_rsclient (rsclient, p, bgp_static,
3747 afi, safi);
3748 }
3749}
3750
Lou Bergera76d9ca2016-01-12 13:41:53 -05003751/*
3752 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3753 */
paul94f2b392005-06-28 12:44:16 +00003754static void
Lou Bergera76d9ca2016-01-12 13:41:53 -05003755bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3756 safi_t safi, struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00003757{
3758 struct bgp_node *rn;
3759 struct bgp_info *ri;
3760
paulfee0f4c2004-09-13 05:12:46 +00003761 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00003762
3763 /* Check selected route and self inserted route. */
3764 for (ri = rn->info; ri; ri = ri->next)
3765 if (ri->peer == bgp->peer_self
3766 && ri->type == ZEBRA_ROUTE_BGP
3767 && ri->sub_type == BGP_ROUTE_STATIC)
3768 break;
3769
3770 /* Withdraw static BGP route from routing table. */
3771 if (ri)
3772 {
3773 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003774 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003775 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003776 }
3777
3778 /* Unlock bgp_node_lookup. */
3779 bgp_unlock_node (rn);
3780}
3781
Lou Bergera76d9ca2016-01-12 13:41:53 -05003782static void
3783bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3784 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3785{
3786 struct bgp_node *rn;
3787 struct bgp_info *new;
3788 struct attr *attr_new;
3789 struct attr attr = { 0 };
3790 struct bgp_info *ri;
3791
3792 assert (bgp_static);
3793
3794 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3795
3796 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3797
3798 attr.nexthop = bgp_static->igpnexthop;
3799 attr.med = bgp_static->igpmetric;
3800 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3801
3802 /* Apply route-map. */
3803 if (bgp_static->rmap.name)
3804 {
3805 struct attr attr_tmp = attr;
3806 struct bgp_info info;
3807 int ret;
3808
3809 info.peer = bgp->peer_self;
3810 info.attr = &attr_tmp;
3811
3812 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3813
3814 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3815
3816 bgp->peer_self->rmap_type = 0;
3817
3818 if (ret == RMAP_DENYMATCH)
3819 {
3820 /* Free uninterned attribute. */
3821 bgp_attr_flush (&attr_tmp);
3822
3823 /* Unintern original. */
3824 aspath_unintern (&attr.aspath);
3825 bgp_attr_extra_free (&attr);
3826 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3827 bgp_static->tag);
3828 return;
3829 }
3830
3831 attr_new = bgp_attr_intern (&attr_tmp);
3832 }
3833 else
3834 {
3835 attr_new = bgp_attr_intern (&attr);
3836 }
3837
3838 for (ri = rn->info; ri; ri = ri->next)
3839 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3840 && ri->sub_type == BGP_ROUTE_STATIC)
3841 break;
3842
3843 if (ri)
3844 {
3845 if (attrhash_cmp (ri->attr, attr_new) &&
3846 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3847 {
3848 bgp_unlock_node (rn);
3849 bgp_attr_unintern (&attr_new);
3850 aspath_unintern (&attr.aspath);
3851 bgp_attr_extra_free (&attr);
3852 return;
3853 }
3854 else
3855 {
3856 /* The attribute is changed. */
3857 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3858
3859 /* Rewrite BGP route information. */
3860 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3861 bgp_info_restore(rn, ri);
3862 else
3863 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3864 bgp_attr_unintern (&ri->attr);
3865 ri->attr = attr_new;
3866 ri->uptime = bgp_clock ();
3867
3868 /* Process change. */
3869 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3870 bgp_process (bgp, rn, afi, safi);
3871 bgp_unlock_node (rn);
3872 aspath_unintern (&attr.aspath);
3873 bgp_attr_extra_free (&attr);
3874 return;
3875 }
3876 }
3877
3878
3879 /* Make new BGP info. */
3880 new = bgp_info_new ();
3881 new->type = ZEBRA_ROUTE_BGP;
3882 new->sub_type = BGP_ROUTE_STATIC;
3883 new->peer = bgp->peer_self;
3884 new->attr = attr_new;
3885 SET_FLAG (new->flags, BGP_INFO_VALID);
3886 new->uptime = bgp_clock ();
3887 new->extra = bgp_info_extra_new();
3888 memcpy (new->extra->tag, bgp_static->tag, 3);
3889
3890 /* Aggregate address increment. */
3891 bgp_aggregate_increment (bgp, p, new, afi, safi);
3892
3893 /* Register new BGP information. */
3894 bgp_info_add (rn, new);
3895
3896 /* route_node_get lock */
3897 bgp_unlock_node (rn);
3898
3899 /* Process change. */
3900 bgp_process (bgp, rn, afi, safi);
3901
3902 /* Unintern original. */
3903 aspath_unintern (&attr.aspath);
3904 bgp_attr_extra_free (&attr);
3905}
3906
paul718e3742002-12-13 20:15:29 +00003907/* Configure static BGP network. When user don't run zebra, static
3908 route should be installed as valid. */
paul94f2b392005-06-28 12:44:16 +00003909static int
paulfd79ac92004-10-13 05:06:08 +00003910bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003911 afi_t afi, safi_t safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003912{
3913 int ret;
3914 struct prefix p;
3915 struct bgp_static *bgp_static;
3916 struct bgp_node *rn;
Paul Jakma41367172007-08-06 15:24:51 +00003917 u_char need_update = 0;
paul718e3742002-12-13 20:15:29 +00003918
3919 /* Convert IP prefix string to struct prefix. */
3920 ret = str2prefix (ip_str, &p);
3921 if (! ret)
3922 {
3923 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3924 return CMD_WARNING;
3925 }
paul718e3742002-12-13 20:15:29 +00003926 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3927 {
3928 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3929 VTY_NEWLINE);
3930 return CMD_WARNING;
3931 }
paul718e3742002-12-13 20:15:29 +00003932
3933 apply_mask (&p);
3934
3935 /* Set BGP static route configuration. */
3936 rn = bgp_node_get (bgp->route[afi][safi], &p);
3937
3938 if (rn->info)
3939 {
3940 /* Configuration change. */
3941 bgp_static = rn->info;
3942
3943 /* Check previous routes are installed into BGP. */
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003944 if (bgp_static->valid && bgp_static->backdoor != backdoor)
3945 need_update = 1;
Paul Jakma41367172007-08-06 15:24:51 +00003946
paul718e3742002-12-13 20:15:29 +00003947 bgp_static->backdoor = backdoor;
Paul Jakma41367172007-08-06 15:24:51 +00003948
paul718e3742002-12-13 20:15:29 +00003949 if (rmap)
3950 {
3951 if (bgp_static->rmap.name)
3952 free (bgp_static->rmap.name);
3953 bgp_static->rmap.name = strdup (rmap);
3954 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3955 }
3956 else
3957 {
3958 if (bgp_static->rmap.name)
3959 free (bgp_static->rmap.name);
3960 bgp_static->rmap.name = NULL;
3961 bgp_static->rmap.map = NULL;
3962 bgp_static->valid = 0;
3963 }
3964 bgp_unlock_node (rn);
3965 }
3966 else
3967 {
3968 /* New configuration. */
3969 bgp_static = bgp_static_new ();
3970 bgp_static->backdoor = backdoor;
3971 bgp_static->valid = 0;
3972 bgp_static->igpmetric = 0;
3973 bgp_static->igpnexthop.s_addr = 0;
Paul Jakma41367172007-08-06 15:24:51 +00003974
paul718e3742002-12-13 20:15:29 +00003975 if (rmap)
3976 {
3977 if (bgp_static->rmap.name)
3978 free (bgp_static->rmap.name);
3979 bgp_static->rmap.name = strdup (rmap);
3980 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3981 }
3982 rn->info = bgp_static;
3983 }
3984
3985 /* If BGP scan is not enabled, we should install this route here. */
3986 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3987 {
3988 bgp_static->valid = 1;
3989
3990 if (need_update)
3991 bgp_static_withdraw (bgp, &p, afi, safi);
3992
3993 if (! bgp_static->backdoor)
3994 bgp_static_update (bgp, &p, bgp_static, afi, safi);
3995 }
3996
3997 return CMD_SUCCESS;
3998}
3999
4000/* Configure static BGP network. */
paul94f2b392005-06-28 12:44:16 +00004001static int
paulfd79ac92004-10-13 05:06:08 +00004002bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
Michael Lambert4c9641b2010-07-22 13:20:55 -04004003 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004004{
4005 int ret;
4006 struct prefix p;
4007 struct bgp_static *bgp_static;
4008 struct bgp_node *rn;
4009
4010 /* Convert IP prefix string to struct prefix. */
4011 ret = str2prefix (ip_str, &p);
4012 if (! ret)
4013 {
4014 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4015 return CMD_WARNING;
4016 }
paul718e3742002-12-13 20:15:29 +00004017 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4018 {
4019 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4020 VTY_NEWLINE);
4021 return CMD_WARNING;
4022 }
paul718e3742002-12-13 20:15:29 +00004023
4024 apply_mask (&p);
4025
4026 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4027 if (! rn)
4028 {
4029 vty_out (vty, "%% Can't find specified static route configuration.%s",
4030 VTY_NEWLINE);
4031 return CMD_WARNING;
4032 }
4033
4034 bgp_static = rn->info;
Paul Jakma41367172007-08-06 15:24:51 +00004035
paul718e3742002-12-13 20:15:29 +00004036 /* Update BGP RIB. */
4037 if (! bgp_static->backdoor)
4038 bgp_static_withdraw (bgp, &p, afi, safi);
4039
4040 /* Clear configuration. */
4041 bgp_static_free (bgp_static);
4042 rn->info = NULL;
4043 bgp_unlock_node (rn);
4044 bgp_unlock_node (rn);
4045
4046 return CMD_SUCCESS;
4047}
4048
4049/* Called from bgp_delete(). Delete all static routes from the BGP
4050 instance. */
4051void
4052bgp_static_delete (struct bgp *bgp)
4053{
4054 afi_t afi;
4055 safi_t safi;
4056 struct bgp_node *rn;
4057 struct bgp_node *rm;
4058 struct bgp_table *table;
4059 struct bgp_static *bgp_static;
4060
4061 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4062 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4063 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4064 if (rn->info != NULL)
4065 {
Lou Berger298cc2f2016-01-12 13:42:02 -05004066 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004067 {
4068 table = rn->info;
4069
4070 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4071 {
4072 bgp_static = rn->info;
Lou Bergera76d9ca2016-01-12 13:41:53 -05004073 bgp_static_withdraw_safi (bgp, &rm->p,
4074 AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00004075 (struct prefix_rd *)&rn->p,
4076 bgp_static->tag);
4077 bgp_static_free (bgp_static);
4078 rn->info = NULL;
4079 bgp_unlock_node (rn);
4080 }
4081 }
4082 else
4083 {
4084 bgp_static = rn->info;
4085 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4086 bgp_static_free (bgp_static);
4087 rn->info = NULL;
4088 bgp_unlock_node (rn);
4089 }
4090 }
4091}
4092
Lou Bergera76d9ca2016-01-12 13:41:53 -05004093/*
4094 * gpz 110624
4095 * Currently this is used to set static routes for VPN and ENCAP.
4096 * I think it can probably be factored with bgp_static_set.
4097 */
paul718e3742002-12-13 20:15:29 +00004098int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004099bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4100 const char *rd_str, const char *tag_str,
4101 const char *rmap_str)
paul718e3742002-12-13 20:15:29 +00004102{
4103 int ret;
4104 struct prefix p;
4105 struct prefix_rd prd;
4106 struct bgp *bgp;
4107 struct bgp_node *prn;
4108 struct bgp_node *rn;
4109 struct bgp_table *table;
4110 struct bgp_static *bgp_static;
4111 u_char tag[3];
4112
4113 bgp = vty->index;
4114
4115 ret = str2prefix (ip_str, &p);
4116 if (! ret)
4117 {
4118 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4119 return CMD_WARNING;
4120 }
4121 apply_mask (&p);
4122
4123 ret = str2prefix_rd (rd_str, &prd);
4124 if (! ret)
4125 {
4126 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4127 return CMD_WARNING;
4128 }
4129
4130 ret = str2tag (tag_str, tag);
4131 if (! ret)
4132 {
4133 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4134 return CMD_WARNING;
4135 }
4136
Lou Bergera76d9ca2016-01-12 13:41:53 -05004137 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004138 (struct prefix *)&prd);
4139 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004140 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004141 else
4142 bgp_unlock_node (prn);
4143 table = prn->info;
4144
4145 rn = bgp_node_get (table, &p);
4146
4147 if (rn->info)
4148 {
4149 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4150 bgp_unlock_node (rn);
4151 }
4152 else
4153 {
4154 /* New configuration. */
4155 bgp_static = bgp_static_new ();
Lou Bergera76d9ca2016-01-12 13:41:53 -05004156 bgp_static->backdoor = 0;
4157 bgp_static->valid = 0;
4158 bgp_static->igpmetric = 0;
4159 bgp_static->igpnexthop.s_addr = 0;
4160 memcpy(bgp_static->tag, tag, 3);
4161 bgp_static->prd = prd;
4162
4163 if (rmap_str)
4164 {
4165 if (bgp_static->rmap.name)
4166 free (bgp_static->rmap.name);
4167 bgp_static->rmap.name = strdup (rmap_str);
4168 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4169 }
paul718e3742002-12-13 20:15:29 +00004170 rn->info = bgp_static;
4171
Lou Bergera76d9ca2016-01-12 13:41:53 -05004172 bgp_static->valid = 1;
4173 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004174 }
4175
4176 return CMD_SUCCESS;
4177}
4178
4179/* Configure static BGP network. */
4180int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004181bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4182 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00004183{
4184 int ret;
4185 struct bgp *bgp;
4186 struct prefix p;
4187 struct prefix_rd prd;
4188 struct bgp_node *prn;
4189 struct bgp_node *rn;
4190 struct bgp_table *table;
4191 struct bgp_static *bgp_static;
4192 u_char tag[3];
4193
4194 bgp = vty->index;
4195
4196 /* Convert IP prefix string to struct prefix. */
4197 ret = str2prefix (ip_str, &p);
4198 if (! ret)
4199 {
4200 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4201 return CMD_WARNING;
4202 }
4203 apply_mask (&p);
4204
4205 ret = str2prefix_rd (rd_str, &prd);
4206 if (! ret)
4207 {
4208 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4209 return CMD_WARNING;
4210 }
4211
4212 ret = str2tag (tag_str, tag);
4213 if (! ret)
4214 {
4215 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4216 return CMD_WARNING;
4217 }
4218
Lou Bergera76d9ca2016-01-12 13:41:53 -05004219 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004220 (struct prefix *)&prd);
4221 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004222 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004223 else
4224 bgp_unlock_node (prn);
4225 table = prn->info;
4226
4227 rn = bgp_node_lookup (table, &p);
4228
4229 if (rn)
4230 {
Lou Bergera76d9ca2016-01-12 13:41:53 -05004231 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
paul718e3742002-12-13 20:15:29 +00004232
4233 bgp_static = rn->info;
4234 bgp_static_free (bgp_static);
4235 rn->info = NULL;
4236 bgp_unlock_node (rn);
4237 bgp_unlock_node (rn);
4238 }
4239 else
4240 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4241
4242 return CMD_SUCCESS;
4243}
David Lamparter6b0655a2014-06-04 06:53:35 +02004244
paul718e3742002-12-13 20:15:29 +00004245DEFUN (bgp_network,
4246 bgp_network_cmd,
4247 "network A.B.C.D/M",
4248 "Specify a network to announce via BGP\n"
4249 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4250{
4251 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004252 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004253}
4254
4255DEFUN (bgp_network_route_map,
4256 bgp_network_route_map_cmd,
4257 "network A.B.C.D/M route-map WORD",
4258 "Specify a network to announce via BGP\n"
4259 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4260 "Route-map to modify the attributes\n"
4261 "Name of the route map\n")
4262{
4263 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004264 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004265}
4266
4267DEFUN (bgp_network_backdoor,
4268 bgp_network_backdoor_cmd,
4269 "network A.B.C.D/M backdoor",
4270 "Specify a network to announce via BGP\n"
4271 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4272 "Specify a BGP backdoor route\n")
4273{
Paul Jakma41367172007-08-06 15:24:51 +00004274 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004275 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004276}
4277
4278DEFUN (bgp_network_mask,
4279 bgp_network_mask_cmd,
4280 "network A.B.C.D mask A.B.C.D",
4281 "Specify a network to announce via BGP\n"
4282 "Network number\n"
4283 "Network mask\n"
4284 "Network mask\n")
4285{
4286 int ret;
4287 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004288
paul718e3742002-12-13 20:15:29 +00004289 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4290 if (! ret)
4291 {
4292 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4293 return CMD_WARNING;
4294 }
4295
4296 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004297 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004298}
4299
4300DEFUN (bgp_network_mask_route_map,
4301 bgp_network_mask_route_map_cmd,
4302 "network A.B.C.D mask A.B.C.D route-map WORD",
4303 "Specify a network to announce via BGP\n"
4304 "Network number\n"
4305 "Network mask\n"
4306 "Network mask\n"
4307 "Route-map to modify the attributes\n"
4308 "Name of the route map\n")
4309{
4310 int ret;
4311 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004312
paul718e3742002-12-13 20:15:29 +00004313 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4314 if (! ret)
4315 {
4316 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4317 return CMD_WARNING;
4318 }
4319
4320 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004321 AFI_IP, bgp_node_safi (vty), argv[2], 0);
paul718e3742002-12-13 20:15:29 +00004322}
4323
4324DEFUN (bgp_network_mask_backdoor,
4325 bgp_network_mask_backdoor_cmd,
4326 "network A.B.C.D mask A.B.C.D backdoor",
4327 "Specify a network to announce via BGP\n"
4328 "Network number\n"
4329 "Network mask\n"
4330 "Network mask\n"
4331 "Specify a BGP backdoor route\n")
4332{
4333 int ret;
4334 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004335
paul718e3742002-12-13 20:15:29 +00004336 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4337 if (! ret)
4338 {
4339 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4340 return CMD_WARNING;
4341 }
4342
Paul Jakma41367172007-08-06 15:24:51 +00004343 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004344 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004345}
4346
4347DEFUN (bgp_network_mask_natural,
4348 bgp_network_mask_natural_cmd,
4349 "network A.B.C.D",
4350 "Specify a network to announce via BGP\n"
4351 "Network number\n")
4352{
4353 int ret;
4354 char prefix_str[BUFSIZ];
4355
4356 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4357 if (! ret)
4358 {
4359 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4360 return CMD_WARNING;
4361 }
4362
4363 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004364 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004365}
4366
4367DEFUN (bgp_network_mask_natural_route_map,
4368 bgp_network_mask_natural_route_map_cmd,
4369 "network A.B.C.D route-map WORD",
4370 "Specify a network to announce via BGP\n"
4371 "Network number\n"
4372 "Route-map to modify the attributes\n"
4373 "Name of the route map\n")
4374{
4375 int ret;
4376 char prefix_str[BUFSIZ];
4377
4378 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4379 if (! ret)
4380 {
4381 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4382 return CMD_WARNING;
4383 }
4384
4385 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004386 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004387}
4388
4389DEFUN (bgp_network_mask_natural_backdoor,
4390 bgp_network_mask_natural_backdoor_cmd,
4391 "network A.B.C.D backdoor",
4392 "Specify a network to announce via BGP\n"
4393 "Network number\n"
4394 "Specify a BGP backdoor route\n")
4395{
4396 int ret;
4397 char prefix_str[BUFSIZ];
4398
4399 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4400 if (! ret)
4401 {
4402 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4403 return CMD_WARNING;
4404 }
4405
Paul Jakma41367172007-08-06 15:24:51 +00004406 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004407 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004408}
4409
4410DEFUN (no_bgp_network,
4411 no_bgp_network_cmd,
4412 "no network A.B.C.D/M",
4413 NO_STR
4414 "Specify a network to announce via BGP\n"
4415 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4416{
4417 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4418 bgp_node_safi (vty));
4419}
4420
4421ALIAS (no_bgp_network,
4422 no_bgp_network_route_map_cmd,
4423 "no network A.B.C.D/M route-map WORD",
4424 NO_STR
4425 "Specify a network to announce via BGP\n"
4426 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4427 "Route-map to modify the attributes\n"
4428 "Name of the route map\n")
4429
4430ALIAS (no_bgp_network,
4431 no_bgp_network_backdoor_cmd,
4432 "no network A.B.C.D/M backdoor",
4433 NO_STR
4434 "Specify a network to announce via BGP\n"
4435 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4436 "Specify a BGP backdoor route\n")
4437
4438DEFUN (no_bgp_network_mask,
4439 no_bgp_network_mask_cmd,
4440 "no network A.B.C.D mask A.B.C.D",
4441 NO_STR
4442 "Specify a network to announce via BGP\n"
4443 "Network number\n"
4444 "Network mask\n"
4445 "Network mask\n")
4446{
4447 int ret;
4448 char prefix_str[BUFSIZ];
4449
4450 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4451 if (! ret)
4452 {
4453 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4454 return CMD_WARNING;
4455 }
4456
4457 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4458 bgp_node_safi (vty));
4459}
4460
4461ALIAS (no_bgp_network_mask,
4462 no_bgp_network_mask_route_map_cmd,
4463 "no network A.B.C.D mask A.B.C.D route-map WORD",
4464 NO_STR
4465 "Specify a network to announce via BGP\n"
4466 "Network number\n"
4467 "Network mask\n"
4468 "Network mask\n"
4469 "Route-map to modify the attributes\n"
4470 "Name of the route map\n")
4471
4472ALIAS (no_bgp_network_mask,
4473 no_bgp_network_mask_backdoor_cmd,
4474 "no network A.B.C.D mask A.B.C.D backdoor",
4475 NO_STR
4476 "Specify a network to announce via BGP\n"
4477 "Network number\n"
4478 "Network mask\n"
4479 "Network mask\n"
4480 "Specify a BGP backdoor route\n")
4481
4482DEFUN (no_bgp_network_mask_natural,
4483 no_bgp_network_mask_natural_cmd,
4484 "no network A.B.C.D",
4485 NO_STR
4486 "Specify a network to announce via BGP\n"
4487 "Network number\n")
4488{
4489 int ret;
4490 char prefix_str[BUFSIZ];
4491
4492 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4493 if (! ret)
4494 {
4495 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4496 return CMD_WARNING;
4497 }
4498
4499 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4500 bgp_node_safi (vty));
4501}
4502
4503ALIAS (no_bgp_network_mask_natural,
4504 no_bgp_network_mask_natural_route_map_cmd,
4505 "no network A.B.C.D route-map WORD",
4506 NO_STR
4507 "Specify a network to announce via BGP\n"
4508 "Network number\n"
4509 "Route-map to modify the attributes\n"
4510 "Name of the route map\n")
4511
4512ALIAS (no_bgp_network_mask_natural,
4513 no_bgp_network_mask_natural_backdoor_cmd,
4514 "no network A.B.C.D backdoor",
4515 NO_STR
4516 "Specify a network to announce via BGP\n"
4517 "Network number\n"
4518 "Specify a BGP backdoor route\n")
4519
paul718e3742002-12-13 20:15:29 +00004520DEFUN (ipv6_bgp_network,
4521 ipv6_bgp_network_cmd,
4522 "network X:X::X:X/M",
4523 "Specify a network to announce via BGP\n"
4524 "IPv6 prefix <network>/<length>\n")
4525{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304526 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004527 NULL, 0);
paul718e3742002-12-13 20:15:29 +00004528}
4529
4530DEFUN (ipv6_bgp_network_route_map,
4531 ipv6_bgp_network_route_map_cmd,
4532 "network X:X::X:X/M route-map WORD",
4533 "Specify a network to announce via BGP\n"
4534 "IPv6 prefix <network>/<length>\n"
4535 "Route-map to modify the attributes\n"
4536 "Name of the route map\n")
4537{
4538 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004539 bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004540}
4541
4542DEFUN (no_ipv6_bgp_network,
4543 no_ipv6_bgp_network_cmd,
4544 "no network X:X::X:X/M",
4545 NO_STR
4546 "Specify a network to announce via BGP\n"
4547 "IPv6 prefix <network>/<length>\n")
4548{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304549 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00004550}
4551
4552ALIAS (no_ipv6_bgp_network,
4553 no_ipv6_bgp_network_route_map_cmd,
4554 "no network X:X::X:X/M route-map WORD",
4555 NO_STR
4556 "Specify a network to announce via BGP\n"
4557 "IPv6 prefix <network>/<length>\n"
4558 "Route-map to modify the attributes\n"
4559 "Name of the route map\n")
4560
4561ALIAS (ipv6_bgp_network,
4562 old_ipv6_bgp_network_cmd,
4563 "ipv6 bgp network X:X::X:X/M",
4564 IPV6_STR
4565 BGP_STR
4566 "Specify a network to announce via BGP\n"
4567 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4568
4569ALIAS (no_ipv6_bgp_network,
4570 old_no_ipv6_bgp_network_cmd,
4571 "no ipv6 bgp network X:X::X:X/M",
4572 NO_STR
4573 IPV6_STR
4574 BGP_STR
4575 "Specify a network to announce via BGP\n"
4576 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004577
4578/* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4579ALIAS_DEPRECATED (bgp_network,
4580 bgp_network_ttl_cmd,
4581 "network A.B.C.D/M pathlimit <0-255>",
4582 "Specify a network to announce via BGP\n"
4583 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4584 "AS-Path hopcount limit attribute\n"
4585 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4586ALIAS_DEPRECATED (bgp_network_backdoor,
4587 bgp_network_backdoor_ttl_cmd,
4588 "network A.B.C.D/M backdoor pathlimit <0-255>",
4589 "Specify a network to announce via BGP\n"
4590 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4591 "Specify a BGP backdoor route\n"
4592 "AS-Path hopcount limit attribute\n"
4593 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4594ALIAS_DEPRECATED (bgp_network_mask,
4595 bgp_network_mask_ttl_cmd,
4596 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4597 "Specify a network to announce via BGP\n"
4598 "Network number\n"
4599 "Network mask\n"
4600 "Network mask\n"
4601 "AS-Path hopcount limit attribute\n"
4602 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4603ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4604 bgp_network_mask_backdoor_ttl_cmd,
4605 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4606 "Specify a network to announce via BGP\n"
4607 "Network number\n"
4608 "Network mask\n"
4609 "Network mask\n"
4610 "Specify a BGP backdoor route\n"
4611 "AS-Path hopcount limit attribute\n"
4612 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4613ALIAS_DEPRECATED (bgp_network_mask_natural,
4614 bgp_network_mask_natural_ttl_cmd,
4615 "network A.B.C.D pathlimit <0-255>",
4616 "Specify a network to announce via BGP\n"
4617 "Network number\n"
4618 "AS-Path hopcount limit attribute\n"
4619 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4620ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4621 bgp_network_mask_natural_backdoor_ttl_cmd,
Christian Franke2b005152013-09-30 12:27:49 +00004622 "network A.B.C.D backdoor pathlimit <1-255>",
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004623 "Specify a network to announce via BGP\n"
4624 "Network number\n"
4625 "Specify a BGP backdoor route\n"
4626 "AS-Path hopcount limit attribute\n"
4627 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4628ALIAS_DEPRECATED (no_bgp_network,
4629 no_bgp_network_ttl_cmd,
4630 "no network A.B.C.D/M pathlimit <0-255>",
4631 NO_STR
4632 "Specify a network to announce via BGP\n"
4633 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4634 "AS-Path hopcount limit attribute\n"
4635 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4636ALIAS_DEPRECATED (no_bgp_network,
4637 no_bgp_network_backdoor_ttl_cmd,
4638 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4639 NO_STR
4640 "Specify a network to announce via BGP\n"
4641 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4642 "Specify a BGP backdoor route\n"
4643 "AS-Path hopcount limit attribute\n"
4644 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4645ALIAS_DEPRECATED (no_bgp_network,
4646 no_bgp_network_mask_ttl_cmd,
4647 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4648 NO_STR
4649 "Specify a network to announce via BGP\n"
4650 "Network number\n"
4651 "Network mask\n"
4652 "Network mask\n"
4653 "AS-Path hopcount limit attribute\n"
4654 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4655ALIAS_DEPRECATED (no_bgp_network_mask,
4656 no_bgp_network_mask_backdoor_ttl_cmd,
4657 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4658 NO_STR
4659 "Specify a network to announce via BGP\n"
4660 "Network number\n"
4661 "Network mask\n"
4662 "Network mask\n"
4663 "Specify a BGP backdoor route\n"
4664 "AS-Path hopcount limit attribute\n"
4665 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4666ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4667 no_bgp_network_mask_natural_ttl_cmd,
4668 "no network A.B.C.D pathlimit <0-255>",
4669 NO_STR
4670 "Specify a network to announce via BGP\n"
4671 "Network number\n"
4672 "AS-Path hopcount limit attribute\n"
4673 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4674ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4675 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4676 "no network A.B.C.D backdoor pathlimit <0-255>",
4677 NO_STR
4678 "Specify a network to announce via BGP\n"
4679 "Network number\n"
4680 "Specify a BGP backdoor route\n"
4681 "AS-Path hopcount limit attribute\n"
4682 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4683ALIAS_DEPRECATED (ipv6_bgp_network,
4684 ipv6_bgp_network_ttl_cmd,
4685 "network X:X::X:X/M pathlimit <0-255>",
4686 "Specify a network to announce via BGP\n"
4687 "IPv6 prefix <network>/<length>\n"
4688 "AS-Path hopcount limit attribute\n"
4689 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4690ALIAS_DEPRECATED (no_ipv6_bgp_network,
4691 no_ipv6_bgp_network_ttl_cmd,
4692 "no network X:X::X:X/M pathlimit <0-255>",
4693 NO_STR
4694 "Specify a network to announce via BGP\n"
4695 "IPv6 prefix <network>/<length>\n"
4696 "AS-Path hopcount limit attribute\n"
4697 "AS-Pathlimit TTL, in number of AS-Path hops\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02004698
paul718e3742002-12-13 20:15:29 +00004699/* Aggreagete address:
4700
4701 advertise-map Set condition to advertise attribute
4702 as-set Generate AS set path information
4703 attribute-map Set attributes of aggregate
4704 route-map Set parameters of aggregate
4705 summary-only Filter more specific routes from updates
4706 suppress-map Conditionally filter more specific routes from updates
4707 <cr>
4708 */
4709struct bgp_aggregate
4710{
4711 /* Summary-only flag. */
4712 u_char summary_only;
4713
4714 /* AS set generation. */
4715 u_char as_set;
4716
4717 /* Route-map for aggregated route. */
4718 struct route_map *map;
4719
4720 /* Suppress-count. */
4721 unsigned long count;
4722
4723 /* SAFI configuration. */
4724 safi_t safi;
4725};
4726
paul94f2b392005-06-28 12:44:16 +00004727static struct bgp_aggregate *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08004728bgp_aggregate_new (void)
paul718e3742002-12-13 20:15:29 +00004729{
Stephen Hemminger393deb92008-08-18 14:13:29 -07004730 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
paul718e3742002-12-13 20:15:29 +00004731}
4732
paul94f2b392005-06-28 12:44:16 +00004733static void
paul718e3742002-12-13 20:15:29 +00004734bgp_aggregate_free (struct bgp_aggregate *aggregate)
4735{
4736 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4737}
4738
paul94f2b392005-06-28 12:44:16 +00004739static void
paul718e3742002-12-13 20:15:29 +00004740bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4741 afi_t afi, safi_t safi, struct bgp_info *del,
4742 struct bgp_aggregate *aggregate)
4743{
4744 struct bgp_table *table;
4745 struct bgp_node *top;
4746 struct bgp_node *rn;
4747 u_char origin;
4748 struct aspath *aspath = NULL;
4749 struct aspath *asmerge = NULL;
4750 struct community *community = NULL;
4751 struct community *commerge = NULL;
paul718e3742002-12-13 20:15:29 +00004752 struct bgp_info *ri;
4753 struct bgp_info *new;
4754 int first = 1;
4755 unsigned long match = 0;
4756
paul718e3742002-12-13 20:15:29 +00004757 /* ORIGIN attribute: If at least one route among routes that are
4758 aggregated has ORIGIN with the value INCOMPLETE, then the
4759 aggregated route must have the ORIGIN attribute with the value
4760 INCOMPLETE. Otherwise, if at least one route among routes that
4761 are aggregated has ORIGIN with the value EGP, then the aggregated
4762 route must have the origin attribute with the value EGP. In all
4763 other case the value of the ORIGIN attribute of the aggregated
4764 route is INTERNAL. */
4765 origin = BGP_ORIGIN_IGP;
4766
4767 table = bgp->rib[afi][safi];
4768
4769 top = bgp_node_get (table, p);
4770 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4771 if (rn->p.prefixlen > p->prefixlen)
4772 {
4773 match = 0;
4774
4775 for (ri = rn->info; ri; ri = ri->next)
4776 {
4777 if (BGP_INFO_HOLDDOWN (ri))
4778 continue;
4779
4780 if (del && ri == del)
4781 continue;
4782
4783 if (! rinew && first)
Paul Jakma7aa9dce2014-09-19 14:42:23 +01004784 first = 0;
paul718e3742002-12-13 20:15:29 +00004785
4786#ifdef AGGREGATE_NEXTHOP_CHECK
4787 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4788 || ri->attr->med != med)
4789 {
4790 if (aspath)
4791 aspath_free (aspath);
4792 if (community)
4793 community_free (community);
4794 bgp_unlock_node (rn);
4795 bgp_unlock_node (top);
4796 return;
4797 }
4798#endif /* AGGREGATE_NEXTHOP_CHECK */
4799
4800 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4801 {
4802 if (aggregate->summary_only)
4803 {
Paul Jakmafb982c22007-05-04 20:15:47 +00004804 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00004805 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00004806 match++;
4807 }
4808
4809 aggregate->count++;
4810
4811 if (aggregate->as_set)
4812 {
4813 if (origin < ri->attr->origin)
4814 origin = ri->attr->origin;
4815
4816 if (aspath)
4817 {
4818 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4819 aspath_free (aspath);
4820 aspath = asmerge;
4821 }
4822 else
4823 aspath = aspath_dup (ri->attr->aspath);
4824
4825 if (ri->attr->community)
4826 {
4827 if (community)
4828 {
4829 commerge = community_merge (community,
4830 ri->attr->community);
4831 community = community_uniq_sort (commerge);
4832 community_free (commerge);
4833 }
4834 else
4835 community = community_dup (ri->attr->community);
4836 }
4837 }
4838 }
4839 }
4840 if (match)
4841 bgp_process (bgp, rn, afi, safi);
4842 }
4843 bgp_unlock_node (top);
4844
4845 if (rinew)
4846 {
4847 aggregate->count++;
4848
4849 if (aggregate->summary_only)
Paul Jakmafb982c22007-05-04 20:15:47 +00004850 (bgp_info_extra_get (rinew))->suppress++;
paul718e3742002-12-13 20:15:29 +00004851
4852 if (aggregate->as_set)
4853 {
4854 if (origin < rinew->attr->origin)
4855 origin = rinew->attr->origin;
4856
4857 if (aspath)
4858 {
4859 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4860 aspath_free (aspath);
4861 aspath = asmerge;
4862 }
4863 else
4864 aspath = aspath_dup (rinew->attr->aspath);
4865
4866 if (rinew->attr->community)
4867 {
4868 if (community)
4869 {
4870 commerge = community_merge (community,
4871 rinew->attr->community);
4872 community = community_uniq_sort (commerge);
4873 community_free (commerge);
4874 }
4875 else
4876 community = community_dup (rinew->attr->community);
4877 }
4878 }
4879 }
4880
4881 if (aggregate->count > 0)
4882 {
4883 rn = bgp_node_get (table, p);
4884 new = bgp_info_new ();
4885 new->type = ZEBRA_ROUTE_BGP;
4886 new->sub_type = BGP_ROUTE_AGGREGATE;
4887 new->peer = bgp->peer_self;
4888 SET_FLAG (new->flags, BGP_INFO_VALID);
4889 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03004890 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00004891
4892 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00004893 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00004894 bgp_process (bgp, rn, afi, safi);
4895 }
4896 else
4897 {
4898 if (aspath)
4899 aspath_free (aspath);
4900 if (community)
4901 community_free (community);
4902 }
4903}
4904
4905void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4906 struct bgp_aggregate *);
4907
4908void
4909bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4910 struct bgp_info *ri, afi_t afi, safi_t safi)
4911{
4912 struct bgp_node *child;
4913 struct bgp_node *rn;
4914 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004915 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004916
4917 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004918 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004919 return;
4920
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004921 table = bgp->aggregate[afi][safi];
4922
4923 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004924 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004925 return;
4926
paul718e3742002-12-13 20:15:29 +00004927 if (p->prefixlen == 0)
4928 return;
4929
4930 if (BGP_INFO_HOLDDOWN (ri))
4931 return;
4932
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004933 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004934
4935 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004936 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00004937 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
4938 {
4939 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00004940 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00004941 }
4942 bgp_unlock_node (child);
4943}
4944
4945void
4946bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
4947 struct bgp_info *del, afi_t afi, safi_t safi)
4948{
4949 struct bgp_node *child;
4950 struct bgp_node *rn;
4951 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004952 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004953
4954 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004955 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004956 return;
4957
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004958 table = bgp->aggregate[afi][safi];
4959
4960 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004961 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004962 return;
4963
paul718e3742002-12-13 20:15:29 +00004964 if (p->prefixlen == 0)
4965 return;
4966
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004967 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004968
4969 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004970 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00004971 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
4972 {
4973 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00004974 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00004975 }
4976 bgp_unlock_node (child);
4977}
4978
paul94f2b392005-06-28 12:44:16 +00004979static void
paul718e3742002-12-13 20:15:29 +00004980bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
4981 struct bgp_aggregate *aggregate)
4982{
4983 struct bgp_table *table;
4984 struct bgp_node *top;
4985 struct bgp_node *rn;
4986 struct bgp_info *new;
4987 struct bgp_info *ri;
4988 unsigned long match;
4989 u_char origin = BGP_ORIGIN_IGP;
4990 struct aspath *aspath = NULL;
4991 struct aspath *asmerge = NULL;
4992 struct community *community = NULL;
4993 struct community *commerge = NULL;
4994
4995 table = bgp->rib[afi][safi];
4996
4997 /* Sanity check. */
4998 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
4999 return;
5000 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5001 return;
5002
5003 /* If routes exists below this node, generate aggregate routes. */
5004 top = bgp_node_get (table, p);
5005 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5006 if (rn->p.prefixlen > p->prefixlen)
5007 {
5008 match = 0;
5009
5010 for (ri = rn->info; ri; ri = ri->next)
5011 {
5012 if (BGP_INFO_HOLDDOWN (ri))
5013 continue;
5014
5015 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5016 {
5017 /* summary-only aggregate route suppress aggregated
5018 route announcement. */
5019 if (aggregate->summary_only)
5020 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005021 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00005022 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005023 match++;
5024 }
5025 /* as-set aggregate route generate origin, as path,
5026 community aggregation. */
5027 if (aggregate->as_set)
5028 {
5029 if (origin < ri->attr->origin)
5030 origin = ri->attr->origin;
5031
5032 if (aspath)
5033 {
5034 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5035 aspath_free (aspath);
5036 aspath = asmerge;
5037 }
5038 else
5039 aspath = aspath_dup (ri->attr->aspath);
5040
5041 if (ri->attr->community)
5042 {
5043 if (community)
5044 {
5045 commerge = community_merge (community,
5046 ri->attr->community);
5047 community = community_uniq_sort (commerge);
5048 community_free (commerge);
5049 }
5050 else
5051 community = community_dup (ri->attr->community);
5052 }
5053 }
5054 aggregate->count++;
5055 }
5056 }
5057
5058 /* If this node is suppressed, process the change. */
5059 if (match)
5060 bgp_process (bgp, rn, afi, safi);
5061 }
5062 bgp_unlock_node (top);
5063
5064 /* Add aggregate route to BGP table. */
5065 if (aggregate->count)
5066 {
5067 rn = bgp_node_get (table, p);
5068
5069 new = bgp_info_new ();
5070 new->type = ZEBRA_ROUTE_BGP;
5071 new->sub_type = BGP_ROUTE_AGGREGATE;
5072 new->peer = bgp->peer_self;
5073 SET_FLAG (new->flags, BGP_INFO_VALID);
5074 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03005075 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005076
5077 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00005078 bgp_unlock_node (rn);
5079
paul718e3742002-12-13 20:15:29 +00005080 /* Process change. */
5081 bgp_process (bgp, rn, afi, safi);
5082 }
Denil Virae2a92582015-08-11 13:34:59 -07005083 else
5084 {
5085 if (aspath)
5086 aspath_free (aspath);
5087 if (community)
5088 community_free (community);
5089 }
paul718e3742002-12-13 20:15:29 +00005090}
5091
5092void
5093bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5094 safi_t safi, struct bgp_aggregate *aggregate)
5095{
5096 struct bgp_table *table;
5097 struct bgp_node *top;
5098 struct bgp_node *rn;
5099 struct bgp_info *ri;
5100 unsigned long match;
5101
5102 table = bgp->rib[afi][safi];
5103
5104 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5105 return;
5106 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5107 return;
5108
5109 /* If routes exists below this node, generate aggregate routes. */
5110 top = bgp_node_get (table, p);
5111 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5112 if (rn->p.prefixlen > p->prefixlen)
5113 {
5114 match = 0;
5115
5116 for (ri = rn->info; ri; ri = ri->next)
5117 {
5118 if (BGP_INFO_HOLDDOWN (ri))
5119 continue;
5120
5121 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5122 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005123 if (aggregate->summary_only && ri->extra)
paul718e3742002-12-13 20:15:29 +00005124 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005125 ri->extra->suppress--;
paul718e3742002-12-13 20:15:29 +00005126
Paul Jakmafb982c22007-05-04 20:15:47 +00005127 if (ri->extra->suppress == 0)
paul718e3742002-12-13 20:15:29 +00005128 {
Paul Jakma1a392d42006-09-07 00:24:49 +00005129 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005130 match++;
5131 }
5132 }
5133 aggregate->count--;
5134 }
5135 }
5136
Paul Jakmafb982c22007-05-04 20:15:47 +00005137 /* If this node was suppressed, process the change. */
paul718e3742002-12-13 20:15:29 +00005138 if (match)
5139 bgp_process (bgp, rn, afi, safi);
5140 }
5141 bgp_unlock_node (top);
5142
5143 /* Delete aggregate route from BGP table. */
5144 rn = bgp_node_get (table, p);
5145
5146 for (ri = rn->info; ri; ri = ri->next)
5147 if (ri->peer == bgp->peer_self
5148 && ri->type == ZEBRA_ROUTE_BGP
5149 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5150 break;
5151
5152 /* Withdraw static BGP route from routing table. */
5153 if (ri)
5154 {
paul718e3742002-12-13 20:15:29 +00005155 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005156 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00005157 }
5158
5159 /* Unlock bgp_node_lookup. */
5160 bgp_unlock_node (rn);
5161}
5162
5163/* Aggregate route attribute. */
5164#define AGGREGATE_SUMMARY_ONLY 1
5165#define AGGREGATE_AS_SET 1
5166
paul94f2b392005-06-28 12:44:16 +00005167static int
Robert Baysf6269b42010-08-05 10:26:28 -07005168bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5169 afi_t afi, safi_t safi)
5170{
5171 int ret;
5172 struct prefix p;
5173 struct bgp_node *rn;
5174 struct bgp *bgp;
5175 struct bgp_aggregate *aggregate;
5176
5177 /* Convert string to prefix structure. */
5178 ret = str2prefix (prefix_str, &p);
5179 if (!ret)
5180 {
5181 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5182 return CMD_WARNING;
5183 }
5184 apply_mask (&p);
5185
5186 /* Get BGP structure. */
5187 bgp = vty->index;
5188
5189 /* Old configuration check. */
5190 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
5191 if (! rn)
5192 {
5193 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5194 VTY_NEWLINE);
5195 return CMD_WARNING;
5196 }
5197
5198 aggregate = rn->info;
5199 if (aggregate->safi & SAFI_UNICAST)
5200 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5201 if (aggregate->safi & SAFI_MULTICAST)
5202 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5203
5204 /* Unlock aggregate address configuration. */
5205 rn->info = NULL;
5206 bgp_aggregate_free (aggregate);
5207 bgp_unlock_node (rn);
5208 bgp_unlock_node (rn);
5209
5210 return CMD_SUCCESS;
5211}
5212
5213static int
5214bgp_aggregate_set (struct vty *vty, const char *prefix_str,
paulfd79ac92004-10-13 05:06:08 +00005215 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00005216 u_char summary_only, u_char as_set)
5217{
5218 int ret;
5219 struct prefix p;
5220 struct bgp_node *rn;
5221 struct bgp *bgp;
5222 struct bgp_aggregate *aggregate;
5223
5224 /* Convert string to prefix structure. */
5225 ret = str2prefix (prefix_str, &p);
5226 if (!ret)
5227 {
5228 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5229 return CMD_WARNING;
5230 }
5231 apply_mask (&p);
5232
5233 /* Get BGP structure. */
5234 bgp = vty->index;
5235
5236 /* Old configuration check. */
5237 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5238
5239 if (rn->info)
5240 {
5241 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
Robert Bays368473f2010-08-05 10:26:29 -07005242 /* try to remove the old entry */
Robert Baysf6269b42010-08-05 10:26:28 -07005243 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5244 if (ret)
5245 {
Robert Bays368473f2010-08-05 10:26:29 -07005246 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5247 bgp_unlock_node (rn);
Robert Baysf6269b42010-08-05 10:26:28 -07005248 return CMD_WARNING;
5249 }
paul718e3742002-12-13 20:15:29 +00005250 }
5251
5252 /* Make aggregate address structure. */
5253 aggregate = bgp_aggregate_new ();
5254 aggregate->summary_only = summary_only;
5255 aggregate->as_set = as_set;
5256 aggregate->safi = safi;
5257 rn->info = aggregate;
5258
5259 /* Aggregate address insert into BGP routing table. */
5260 if (safi & SAFI_UNICAST)
5261 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5262 if (safi & SAFI_MULTICAST)
5263 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5264
5265 return CMD_SUCCESS;
5266}
5267
paul718e3742002-12-13 20:15:29 +00005268DEFUN (aggregate_address,
5269 aggregate_address_cmd,
5270 "aggregate-address A.B.C.D/M",
5271 "Configure BGP aggregate entries\n"
5272 "Aggregate prefix\n")
5273{
5274 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5275}
5276
5277DEFUN (aggregate_address_mask,
5278 aggregate_address_mask_cmd,
5279 "aggregate-address A.B.C.D A.B.C.D",
5280 "Configure BGP aggregate entries\n"
5281 "Aggregate address\n"
5282 "Aggregate mask\n")
5283{
5284 int ret;
5285 char prefix_str[BUFSIZ];
5286
5287 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5288
5289 if (! ret)
5290 {
5291 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5292 return CMD_WARNING;
5293 }
5294
5295 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5296 0, 0);
5297}
5298
5299DEFUN (aggregate_address_summary_only,
5300 aggregate_address_summary_only_cmd,
5301 "aggregate-address A.B.C.D/M summary-only",
5302 "Configure BGP aggregate entries\n"
5303 "Aggregate prefix\n"
5304 "Filter more specific routes from updates\n")
5305{
5306 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5307 AGGREGATE_SUMMARY_ONLY, 0);
5308}
5309
5310DEFUN (aggregate_address_mask_summary_only,
5311 aggregate_address_mask_summary_only_cmd,
5312 "aggregate-address A.B.C.D A.B.C.D summary-only",
5313 "Configure BGP aggregate entries\n"
5314 "Aggregate address\n"
5315 "Aggregate mask\n"
5316 "Filter more specific routes from updates\n")
5317{
5318 int ret;
5319 char prefix_str[BUFSIZ];
5320
5321 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5322
5323 if (! ret)
5324 {
5325 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5326 return CMD_WARNING;
5327 }
5328
5329 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5330 AGGREGATE_SUMMARY_ONLY, 0);
5331}
5332
5333DEFUN (aggregate_address_as_set,
5334 aggregate_address_as_set_cmd,
5335 "aggregate-address A.B.C.D/M as-set",
5336 "Configure BGP aggregate entries\n"
5337 "Aggregate prefix\n"
5338 "Generate AS set path information\n")
5339{
5340 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5341 0, AGGREGATE_AS_SET);
5342}
5343
5344DEFUN (aggregate_address_mask_as_set,
5345 aggregate_address_mask_as_set_cmd,
5346 "aggregate-address A.B.C.D A.B.C.D as-set",
5347 "Configure BGP aggregate entries\n"
5348 "Aggregate address\n"
5349 "Aggregate mask\n"
5350 "Generate AS set path information\n")
5351{
5352 int ret;
5353 char prefix_str[BUFSIZ];
5354
5355 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5356
5357 if (! ret)
5358 {
5359 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5360 return CMD_WARNING;
5361 }
5362
5363 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5364 0, AGGREGATE_AS_SET);
5365}
5366
5367
5368DEFUN (aggregate_address_as_set_summary,
5369 aggregate_address_as_set_summary_cmd,
5370 "aggregate-address A.B.C.D/M as-set summary-only",
5371 "Configure BGP aggregate entries\n"
5372 "Aggregate prefix\n"
5373 "Generate AS set path information\n"
5374 "Filter more specific routes from updates\n")
5375{
5376 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5377 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5378}
5379
5380ALIAS (aggregate_address_as_set_summary,
5381 aggregate_address_summary_as_set_cmd,
5382 "aggregate-address A.B.C.D/M summary-only as-set",
5383 "Configure BGP aggregate entries\n"
5384 "Aggregate prefix\n"
5385 "Filter more specific routes from updates\n"
5386 "Generate AS set path information\n")
5387
5388DEFUN (aggregate_address_mask_as_set_summary,
5389 aggregate_address_mask_as_set_summary_cmd,
5390 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5391 "Configure BGP aggregate entries\n"
5392 "Aggregate address\n"
5393 "Aggregate mask\n"
5394 "Generate AS set path information\n"
5395 "Filter more specific routes from updates\n")
5396{
5397 int ret;
5398 char prefix_str[BUFSIZ];
5399
5400 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5401
5402 if (! ret)
5403 {
5404 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5405 return CMD_WARNING;
5406 }
5407
5408 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5409 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5410}
5411
5412ALIAS (aggregate_address_mask_as_set_summary,
5413 aggregate_address_mask_summary_as_set_cmd,
5414 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5415 "Configure BGP aggregate entries\n"
5416 "Aggregate address\n"
5417 "Aggregate mask\n"
5418 "Filter more specific routes from updates\n"
5419 "Generate AS set path information\n")
5420
5421DEFUN (no_aggregate_address,
5422 no_aggregate_address_cmd,
5423 "no aggregate-address A.B.C.D/M",
5424 NO_STR
5425 "Configure BGP aggregate entries\n"
5426 "Aggregate prefix\n")
5427{
5428 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5429}
5430
5431ALIAS (no_aggregate_address,
5432 no_aggregate_address_summary_only_cmd,
5433 "no aggregate-address A.B.C.D/M summary-only",
5434 NO_STR
5435 "Configure BGP aggregate entries\n"
5436 "Aggregate prefix\n"
5437 "Filter more specific routes from updates\n")
5438
5439ALIAS (no_aggregate_address,
5440 no_aggregate_address_as_set_cmd,
5441 "no aggregate-address A.B.C.D/M as-set",
5442 NO_STR
5443 "Configure BGP aggregate entries\n"
5444 "Aggregate prefix\n"
5445 "Generate AS set path information\n")
5446
5447ALIAS (no_aggregate_address,
5448 no_aggregate_address_as_set_summary_cmd,
5449 "no aggregate-address A.B.C.D/M as-set summary-only",
5450 NO_STR
5451 "Configure BGP aggregate entries\n"
5452 "Aggregate prefix\n"
5453 "Generate AS set path information\n"
5454 "Filter more specific routes from updates\n")
5455
5456ALIAS (no_aggregate_address,
5457 no_aggregate_address_summary_as_set_cmd,
5458 "no aggregate-address A.B.C.D/M summary-only as-set",
5459 NO_STR
5460 "Configure BGP aggregate entries\n"
5461 "Aggregate prefix\n"
5462 "Filter more specific routes from updates\n"
5463 "Generate AS set path information\n")
5464
5465DEFUN (no_aggregate_address_mask,
5466 no_aggregate_address_mask_cmd,
5467 "no aggregate-address A.B.C.D A.B.C.D",
5468 NO_STR
5469 "Configure BGP aggregate entries\n"
5470 "Aggregate address\n"
5471 "Aggregate mask\n")
5472{
5473 int ret;
5474 char prefix_str[BUFSIZ];
5475
5476 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5477
5478 if (! ret)
5479 {
5480 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5481 return CMD_WARNING;
5482 }
5483
5484 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5485}
5486
5487ALIAS (no_aggregate_address_mask,
5488 no_aggregate_address_mask_summary_only_cmd,
5489 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5490 NO_STR
5491 "Configure BGP aggregate entries\n"
5492 "Aggregate address\n"
5493 "Aggregate mask\n"
5494 "Filter more specific routes from updates\n")
5495
5496ALIAS (no_aggregate_address_mask,
5497 no_aggregate_address_mask_as_set_cmd,
5498 "no aggregate-address A.B.C.D A.B.C.D as-set",
5499 NO_STR
5500 "Configure BGP aggregate entries\n"
5501 "Aggregate address\n"
5502 "Aggregate mask\n"
5503 "Generate AS set path information\n")
5504
5505ALIAS (no_aggregate_address_mask,
5506 no_aggregate_address_mask_as_set_summary_cmd,
5507 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5508 NO_STR
5509 "Configure BGP aggregate entries\n"
5510 "Aggregate address\n"
5511 "Aggregate mask\n"
5512 "Generate AS set path information\n"
5513 "Filter more specific routes from updates\n")
5514
5515ALIAS (no_aggregate_address_mask,
5516 no_aggregate_address_mask_summary_as_set_cmd,
5517 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5518 NO_STR
5519 "Configure BGP aggregate entries\n"
5520 "Aggregate address\n"
5521 "Aggregate mask\n"
5522 "Filter more specific routes from updates\n"
5523 "Generate AS set path information\n")
5524
paul718e3742002-12-13 20:15:29 +00005525DEFUN (ipv6_aggregate_address,
5526 ipv6_aggregate_address_cmd,
5527 "aggregate-address X:X::X:X/M",
5528 "Configure BGP aggregate entries\n"
5529 "Aggregate prefix\n")
5530{
5531 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5532}
5533
5534DEFUN (ipv6_aggregate_address_summary_only,
5535 ipv6_aggregate_address_summary_only_cmd,
5536 "aggregate-address X:X::X:X/M summary-only",
5537 "Configure BGP aggregate entries\n"
5538 "Aggregate prefix\n"
5539 "Filter more specific routes from updates\n")
5540{
5541 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5542 AGGREGATE_SUMMARY_ONLY, 0);
5543}
5544
5545DEFUN (no_ipv6_aggregate_address,
5546 no_ipv6_aggregate_address_cmd,
5547 "no aggregate-address X:X::X:X/M",
5548 NO_STR
5549 "Configure BGP aggregate entries\n"
5550 "Aggregate prefix\n")
5551{
5552 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5553}
5554
5555DEFUN (no_ipv6_aggregate_address_summary_only,
5556 no_ipv6_aggregate_address_summary_only_cmd,
5557 "no aggregate-address X:X::X:X/M summary-only",
5558 NO_STR
5559 "Configure BGP aggregate entries\n"
5560 "Aggregate prefix\n"
5561 "Filter more specific routes from updates\n")
5562{
5563 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5564}
5565
5566ALIAS (ipv6_aggregate_address,
5567 old_ipv6_aggregate_address_cmd,
5568 "ipv6 bgp aggregate-address X:X::X:X/M",
5569 IPV6_STR
5570 BGP_STR
5571 "Configure BGP aggregate entries\n"
5572 "Aggregate prefix\n")
5573
5574ALIAS (ipv6_aggregate_address_summary_only,
5575 old_ipv6_aggregate_address_summary_only_cmd,
5576 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5577 IPV6_STR
5578 BGP_STR
5579 "Configure BGP aggregate entries\n"
5580 "Aggregate prefix\n"
5581 "Filter more specific routes from updates\n")
5582
5583ALIAS (no_ipv6_aggregate_address,
5584 old_no_ipv6_aggregate_address_cmd,
5585 "no ipv6 bgp aggregate-address X:X::X:X/M",
5586 NO_STR
5587 IPV6_STR
5588 BGP_STR
5589 "Configure BGP aggregate entries\n"
5590 "Aggregate prefix\n")
5591
5592ALIAS (no_ipv6_aggregate_address_summary_only,
5593 old_no_ipv6_aggregate_address_summary_only_cmd,
5594 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5595 NO_STR
5596 IPV6_STR
5597 BGP_STR
5598 "Configure BGP aggregate entries\n"
5599 "Aggregate prefix\n"
5600 "Filter more specific routes from updates\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02005601
paul718e3742002-12-13 20:15:29 +00005602/* Redistribute route treatment. */
5603void
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005604bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5605 const struct in6_addr *nexthop6,
paul718e3742002-12-13 20:15:29 +00005606 u_int32_t metric, u_char type)
5607{
5608 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005609 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005610 struct bgp_info *new;
5611 struct bgp_info *bi;
5612 struct bgp_info info;
5613 struct bgp_node *bn;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00005614 struct attr attr;
paul718e3742002-12-13 20:15:29 +00005615 struct attr *new_attr;
5616 afi_t afi;
5617 int ret;
5618
5619 /* Make default attribute. */
5620 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5621 if (nexthop)
5622 attr.nexthop = *nexthop;
5623
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005624 if (nexthop6)
5625 {
5626 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5627 extra->mp_nexthop_global = *nexthop6;
5628 extra->mp_nexthop_len = 16;
5629 }
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005630
paul718e3742002-12-13 20:15:29 +00005631 attr.med = metric;
5632 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
5633
paul1eb8ef22005-04-07 07:30:20 +00005634 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005635 {
5636 afi = family2afi (p->family);
5637
5638 if (bgp->redist[afi][type])
5639 {
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005640 struct attr attr_new;
5641 struct attr_extra extra_new;
5642
paul718e3742002-12-13 20:15:29 +00005643 /* Copy attribute for modification. */
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005644 attr_new.extra = &extra_new;
Paul Jakmafb982c22007-05-04 20:15:47 +00005645 bgp_attr_dup (&attr_new, &attr);
paul718e3742002-12-13 20:15:29 +00005646
5647 if (bgp->redist_metric_flag[afi][type])
5648 attr_new.med = bgp->redist_metric[afi][type];
5649
5650 /* Apply route-map. */
Daniel Walton1994dc82015-09-17 10:15:59 -04005651 if (bgp->rmap[afi][type].name)
paul718e3742002-12-13 20:15:29 +00005652 {
5653 info.peer = bgp->peer_self;
5654 info.attr = &attr_new;
5655
paulfee0f4c2004-09-13 05:12:46 +00005656 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5657
paul718e3742002-12-13 20:15:29 +00005658 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5659 &info);
paulfee0f4c2004-09-13 05:12:46 +00005660
5661 bgp->peer_self->rmap_type = 0;
5662
paul718e3742002-12-13 20:15:29 +00005663 if (ret == RMAP_DENYMATCH)
5664 {
5665 /* Free uninterned attribute. */
5666 bgp_attr_flush (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005667
paul718e3742002-12-13 20:15:29 +00005668 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005669 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005670 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005671 bgp_redistribute_delete (p, type);
5672 return;
5673 }
5674 }
5675
Paul Jakmafb982c22007-05-04 20:15:47 +00005676 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5677 afi, SAFI_UNICAST, p, NULL);
5678
paul718e3742002-12-13 20:15:29 +00005679 new_attr = bgp_attr_intern (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005680
paul718e3742002-12-13 20:15:29 +00005681 for (bi = bn->info; bi; bi = bi->next)
5682 if (bi->peer == bgp->peer_self
5683 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5684 break;
5685
5686 if (bi)
5687 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005688 if (attrhash_cmp (bi->attr, new_attr) &&
5689 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00005690 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005691 bgp_attr_unintern (&new_attr);
5692 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005693 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005694 bgp_unlock_node (bn);
5695 return;
5696 }
5697 else
5698 {
5699 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00005700 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005701
5702 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005703 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5704 bgp_info_restore(bn, bi);
5705 else
5706 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005707 bgp_attr_unintern (&bi->attr);
paul718e3742002-12-13 20:15:29 +00005708 bi->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005709 bi->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005710
5711 /* Process change. */
5712 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5713 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5714 bgp_unlock_node (bn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005715 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005716 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005717 return;
5718 }
5719 }
5720
5721 new = bgp_info_new ();
5722 new->type = type;
5723 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
5724 new->peer = bgp->peer_self;
5725 SET_FLAG (new->flags, BGP_INFO_VALID);
5726 new->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005727 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005728
5729 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5730 bgp_info_add (bn, new);
paul200df112005-06-01 11:17:05 +00005731 bgp_unlock_node (bn);
paul718e3742002-12-13 20:15:29 +00005732 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5733 }
5734 }
5735
5736 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005737 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005738 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005739}
5740
5741void
5742bgp_redistribute_delete (struct prefix *p, u_char type)
5743{
5744 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005745 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005746 afi_t afi;
5747 struct bgp_node *rn;
5748 struct bgp_info *ri;
5749
paul1eb8ef22005-04-07 07:30:20 +00005750 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005751 {
5752 afi = family2afi (p->family);
5753
5754 if (bgp->redist[afi][type])
5755 {
paulfee0f4c2004-09-13 05:12:46 +00005756 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00005757
5758 for (ri = rn->info; ri; ri = ri->next)
5759 if (ri->peer == bgp->peer_self
5760 && ri->type == type)
5761 break;
5762
5763 if (ri)
5764 {
5765 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005766 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005767 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005768 }
5769 bgp_unlock_node (rn);
5770 }
5771 }
5772}
5773
5774/* Withdraw specified route type's route. */
5775void
5776bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5777{
5778 struct bgp_node *rn;
5779 struct bgp_info *ri;
5780 struct bgp_table *table;
5781
5782 table = bgp->rib[afi][SAFI_UNICAST];
5783
5784 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5785 {
5786 for (ri = rn->info; ri; ri = ri->next)
5787 if (ri->peer == bgp->peer_self
5788 && ri->type == type)
5789 break;
5790
5791 if (ri)
5792 {
5793 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005794 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005795 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005796 }
5797 }
5798}
David Lamparter6b0655a2014-06-04 06:53:35 +02005799
paul718e3742002-12-13 20:15:29 +00005800/* Static function to display route. */
paul94f2b392005-06-28 12:44:16 +00005801static void
paul718e3742002-12-13 20:15:29 +00005802route_vty_out_route (struct prefix *p, struct vty *vty)
5803{
5804 int len;
5805 u_int32_t destination;
5806 char buf[BUFSIZ];
5807
5808 if (p->family == AF_INET)
5809 {
5810 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5811 destination = ntohl (p->u.prefix4.s_addr);
5812
5813 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5814 || (IN_CLASSB (destination) && p->prefixlen == 16)
5815 || (IN_CLASSA (destination) && p->prefixlen == 8)
5816 || p->u.prefix4.s_addr == 0)
5817 {
5818 /* When mask is natural, mask is not displayed. */
5819 }
5820 else
5821 len += vty_out (vty, "/%d", p->prefixlen);
5822 }
5823 else
5824 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5825 p->prefixlen);
5826
5827 len = 17 - len;
5828 if (len < 1)
5829 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5830 else
5831 vty_out (vty, "%*s", len, " ");
5832}
5833
paul718e3742002-12-13 20:15:29 +00005834enum bgp_display_type
5835{
5836 normal_list,
5837};
5838
paulb40d9392005-08-22 22:34:41 +00005839/* Print the short form route status for a bgp_info */
5840static void
5841route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
paul718e3742002-12-13 20:15:29 +00005842{
paulb40d9392005-08-22 22:34:41 +00005843 /* Route status display. */
5844 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5845 vty_out (vty, "R");
5846 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
hasso93406d82005-02-02 14:40:33 +00005847 vty_out (vty, "S");
Paul Jakmafb982c22007-05-04 20:15:47 +00005848 else if (binfo->extra && binfo->extra->suppress)
paul718e3742002-12-13 20:15:29 +00005849 vty_out (vty, "s");
5850 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5851 vty_out (vty, "*");
5852 else
5853 vty_out (vty, " ");
5854
5855 /* Selected */
5856 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5857 vty_out (vty, "h");
5858 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5859 vty_out (vty, "d");
5860 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5861 vty_out (vty, ">");
Boian Bonevb366b512013-09-09 16:41:35 +00005862 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5863 vty_out (vty, "=");
paul718e3742002-12-13 20:15:29 +00005864 else
5865 vty_out (vty, " ");
5866
5867 /* Internal route. */
5868 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5869 vty_out (vty, "i");
5870 else
paulb40d9392005-08-22 22:34:41 +00005871 vty_out (vty, " ");
5872}
5873
5874/* called from terminal list command */
5875void
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005876route_vty_out(
5877 struct vty *vty,
5878 struct prefix *p,
5879 struct bgp_info *binfo,
5880 int display,
5881 safi_t safi)
paulb40d9392005-08-22 22:34:41 +00005882{
5883 struct attr *attr;
5884
5885 /* short status lead text */
5886 route_vty_short_status_out (vty, binfo);
paul718e3742002-12-13 20:15:29 +00005887
5888 /* print prefix and mask */
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005889 if (!display)
paul718e3742002-12-13 20:15:29 +00005890 route_vty_out_route (p, vty);
5891 else
5892 vty_out (vty, "%*s", 17, " ");
5893
5894 /* Print attribute */
5895 attr = binfo->attr;
5896 if (attr)
5897 {
paul718e3742002-12-13 20:15:29 +00005898
Lou Berger298cc2f2016-01-12 13:42:02 -05005899 /*
5900 * NEXTHOP start
5901 */
5902
5903 /*
5904 * For ENCAP routes, nexthop address family is not
5905 * neccessarily the same as the prefix address family.
5906 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5907 */
5908 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5909 if (attr->extra) {
5910 char buf[BUFSIZ];
5911 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5912
5913 switch (af) {
5914 case AF_INET:
5915 vty_out (vty, "%s", inet_ntop(af,
5916 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5917 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005918 case AF_INET6:
5919 vty_out (vty, "%s", inet_ntop(af,
5920 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
5921 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005922 default:
5923 vty_out(vty, "?");
5924 }
5925 } else {
5926 vty_out(vty, "?");
paul718e3742002-12-13 20:15:29 +00005927 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005928 } else {
5929
5930 if (p->family == AF_INET)
5931 {
5932 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
5933 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005934 else if (p->family == AF_INET6)
5935 {
5936 int len;
5937 char buf[BUFSIZ];
5938
5939 len = vty_out (vty, "%s",
5940 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
5941 buf, BUFSIZ));
5942 len = 16 - len;
5943 if (len < 1)
5944 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
5945 else
5946 vty_out (vty, "%*s", len, " ");
5947 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005948 else
5949 {
5950 vty_out(vty, "?");
5951 }
5952 }
5953
5954 /*
5955 * NEXTHOP end
5956 */
5957
paul718e3742002-12-13 20:15:29 +00005958
5959 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005960 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00005961 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005962 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00005963
5964 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005965 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00005966 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005967 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00005968
Paul Jakmafb982c22007-05-04 20:15:47 +00005969 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
paul718e3742002-12-13 20:15:29 +00005970
Paul Jakmab2518c12006-05-12 23:48:40 +00005971 /* Print aspath */
5972 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00005973 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00005974
Paul Jakmab2518c12006-05-12 23:48:40 +00005975 /* Print origin */
paul718e3742002-12-13 20:15:29 +00005976 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00005977 }
paul718e3742002-12-13 20:15:29 +00005978 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005979}
5980
5981/* called from terminal list command */
5982void
5983route_vty_out_tmp (struct vty *vty, struct prefix *p,
5984 struct attr *attr, safi_t safi)
5985{
5986 /* Route status display. */
5987 vty_out (vty, "*");
5988 vty_out (vty, ">");
5989 vty_out (vty, " ");
5990
5991 /* print prefix and mask */
5992 route_vty_out_route (p, vty);
5993
5994 /* Print attribute */
5995 if (attr)
5996 {
5997 if (p->family == AF_INET)
5998 {
Lou Berger298cc2f2016-01-12 13:42:02 -05005999 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006000 vty_out (vty, "%-16s",
6001 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006002 else
6003 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6004 }
paul718e3742002-12-13 20:15:29 +00006005 else if (p->family == AF_INET6)
6006 {
6007 int len;
6008 char buf[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006009
6010 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006011
6012 len = vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006013 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6014 buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006015 len = 16 - len;
6016 if (len < 1)
6017 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6018 else
6019 vty_out (vty, "%*s", len, " ");
6020 }
paul718e3742002-12-13 20:15:29 +00006021
6022 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006023 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006024 else
6025 vty_out (vty, " ");
6026
6027 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006028 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006029 else
6030 vty_out (vty, " ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006031
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006032 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
Paul Jakmafb982c22007-05-04 20:15:47 +00006033
Paul Jakmab2518c12006-05-12 23:48:40 +00006034 /* Print aspath */
6035 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006036 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006037
Paul Jakmab2518c12006-05-12 23:48:40 +00006038 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006039 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006040 }
paul718e3742002-12-13 20:15:29 +00006041
6042 vty_out (vty, "%s", VTY_NEWLINE);
6043}
6044
ajs5a646652004-11-05 01:25:55 +00006045void
paul718e3742002-12-13 20:15:29 +00006046route_vty_out_tag (struct vty *vty, struct prefix *p,
6047 struct bgp_info *binfo, int display, safi_t safi)
6048{
6049 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006050 u_int32_t label = 0;
Paul Jakmafb982c22007-05-04 20:15:47 +00006051
6052 if (!binfo->extra)
6053 return;
6054
paulb40d9392005-08-22 22:34:41 +00006055 /* short status lead text */
6056 route_vty_short_status_out (vty, binfo);
6057
paul718e3742002-12-13 20:15:29 +00006058 /* print prefix and mask */
6059 if (! display)
6060 route_vty_out_route (p, vty);
6061 else
6062 vty_out (vty, "%*s", 17, " ");
6063
6064 /* Print attribute */
6065 attr = binfo->attr;
6066 if (attr)
6067 {
6068 if (p->family == AF_INET)
6069 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006070 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006071 vty_out (vty, "%-16s",
6072 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006073 else
6074 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6075 }
paul718e3742002-12-13 20:15:29 +00006076 else if (p->family == AF_INET6)
6077 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006078 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006079 char buf[BUFSIZ];
6080 char buf1[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006081 if (attr->extra->mp_nexthop_len == 16)
paul718e3742002-12-13 20:15:29 +00006082 vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006083 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6084 buf, BUFSIZ));
6085 else if (attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006086 vty_out (vty, "%s(%s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006087 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6088 buf, BUFSIZ),
6089 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6090 buf1, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006091
6092 }
paul718e3742002-12-13 20:15:29 +00006093 }
6094
Paul Jakmafb982c22007-05-04 20:15:47 +00006095 label = decode_label (binfo->extra->tag);
paul718e3742002-12-13 20:15:29 +00006096
6097 vty_out (vty, "notag/%d", label);
6098
6099 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006100}
6101
6102/* dampening route */
ajs5a646652004-11-05 01:25:55 +00006103static void
paul718e3742002-12-13 20:15:29 +00006104damp_route_vty_out (struct vty *vty, struct prefix *p,
6105 struct bgp_info *binfo, int display, safi_t safi)
6106{
6107 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006108 int len;
Chris Caputo50aef6f2009-06-23 06:06:49 +00006109 char timebuf[BGP_UPTIME_LEN];
paul718e3742002-12-13 20:15:29 +00006110
paulb40d9392005-08-22 22:34:41 +00006111 /* short status lead text */
6112 route_vty_short_status_out (vty, binfo);
6113
paul718e3742002-12-13 20:15:29 +00006114 /* print prefix and mask */
6115 if (! display)
6116 route_vty_out_route (p, vty);
6117 else
6118 vty_out (vty, "%*s", 17, " ");
6119
6120 len = vty_out (vty, "%s", binfo->peer->host);
6121 len = 17 - len;
6122 if (len < 1)
6123 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6124 else
6125 vty_out (vty, "%*s", len, " ");
6126
Chris Caputo50aef6f2009-06-23 06:06:49 +00006127 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006128
6129 /* Print attribute */
6130 attr = binfo->attr;
6131 if (attr)
6132 {
6133 /* Print aspath */
6134 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006135 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006136
6137 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006138 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006139 }
6140 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006141}
6142
paul718e3742002-12-13 20:15:29 +00006143/* flap route */
ajs5a646652004-11-05 01:25:55 +00006144static void
paul718e3742002-12-13 20:15:29 +00006145flap_route_vty_out (struct vty *vty, struct prefix *p,
6146 struct bgp_info *binfo, int display, safi_t safi)
6147{
6148 struct attr *attr;
6149 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00006150 char timebuf[BGP_UPTIME_LEN];
6151 int len;
Paul Jakmafb982c22007-05-04 20:15:47 +00006152
6153 if (!binfo->extra)
6154 return;
6155
6156 bdi = binfo->extra->damp_info;
paul718e3742002-12-13 20:15:29 +00006157
paulb40d9392005-08-22 22:34:41 +00006158 /* short status lead text */
6159 route_vty_short_status_out (vty, binfo);
6160
paul718e3742002-12-13 20:15:29 +00006161 /* print prefix and mask */
6162 if (! display)
6163 route_vty_out_route (p, vty);
6164 else
6165 vty_out (vty, "%*s", 17, " ");
6166
6167 len = vty_out (vty, "%s", binfo->peer->host);
6168 len = 16 - len;
6169 if (len < 1)
6170 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6171 else
6172 vty_out (vty, "%*s", len, " ");
6173
6174 len = vty_out (vty, "%d", bdi->flap);
6175 len = 5 - len;
6176 if (len < 1)
6177 vty_out (vty, " ");
6178 else
6179 vty_out (vty, "%*s ", len, " ");
6180
6181 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6182 timebuf, BGP_UPTIME_LEN));
6183
6184 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6185 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
Chris Caputo50aef6f2009-06-23 06:06:49 +00006186 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006187 else
6188 vty_out (vty, "%*s ", 8, " ");
6189
6190 /* Print attribute */
6191 attr = binfo->attr;
6192 if (attr)
6193 {
6194 /* Print aspath */
6195 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006196 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006197
6198 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006199 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006200 }
6201 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006202}
6203
paul94f2b392005-06-28 12:44:16 +00006204static void
paul718e3742002-12-13 20:15:29 +00006205route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6206 struct bgp_info *binfo, afi_t afi, safi_t safi)
6207{
6208 char buf[INET6_ADDRSTRLEN];
6209 char buf1[BUFSIZ];
6210 struct attr *attr;
6211 int sockunion_vty_out (struct vty *, union sockunion *);
John Kemp30b00172011-03-18 17:52:18 +03006212#ifdef HAVE_CLOCK_MONOTONIC
6213 time_t tbuf;
6214#endif
paul718e3742002-12-13 20:15:29 +00006215
6216 attr = binfo->attr;
6217
6218 if (attr)
6219 {
6220 /* Line1 display AS-path, Aggregator */
6221 if (attr->aspath)
6222 {
6223 vty_out (vty, " ");
paulfe69a502005-09-10 16:55:02 +00006224 if (aspath_count_hops (attr->aspath) == 0)
paul718e3742002-12-13 20:15:29 +00006225 vty_out (vty, "Local");
6226 else
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006227 aspath_print_vty (vty, "%s", attr->aspath, "");
paul718e3742002-12-13 20:15:29 +00006228 }
6229
paulb40d9392005-08-22 22:34:41 +00006230 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6231 vty_out (vty, ", (removed)");
hasso93406d82005-02-02 14:40:33 +00006232 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6233 vty_out (vty, ", (stale)");
6234 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006235 vty_out (vty, ", (aggregated by %u %s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006236 attr->extra->aggregator_as,
6237 inet_ntoa (attr->extra->aggregator_addr));
hasso93406d82005-02-02 14:40:33 +00006238 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6239 vty_out (vty, ", (Received from a RR-client)");
6240 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6241 vty_out (vty, ", (Received from a RS-client)");
6242 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6243 vty_out (vty, ", (history entry)");
6244 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6245 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00006246 vty_out (vty, "%s", VTY_NEWLINE);
6247
6248 /* Line2 display Next-hop, Neighbor, Router-id */
6249 if (p->family == AF_INET)
6250 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006251 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
Paul Jakmafb982c22007-05-04 20:15:47 +00006252 inet_ntoa (attr->extra->mp_nexthop_global_in) :
paul718e3742002-12-13 20:15:29 +00006253 inet_ntoa (attr->nexthop));
6254 }
paul718e3742002-12-13 20:15:29 +00006255 else
6256 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006257 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006258 vty_out (vty, " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006259 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
paul718e3742002-12-13 20:15:29 +00006260 buf, INET6_ADDRSTRLEN));
6261 }
paul718e3742002-12-13 20:15:29 +00006262
6263 if (binfo->peer == bgp->peer_self)
6264 {
6265 vty_out (vty, " from %s ",
6266 p->family == AF_INET ? "0.0.0.0" : "::");
6267 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6268 }
6269 else
6270 {
6271 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6272 vty_out (vty, " (inaccessible)");
Paul Jakmafb982c22007-05-04 20:15:47 +00006273 else if (binfo->extra && binfo->extra->igpmetric)
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02006274 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006275 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6276 buf[0] = '?';
6277 buf[1] = 0;
6278 }
6279 vty_out (vty, " from %s", buf);
paul718e3742002-12-13 20:15:29 +00006280 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006281 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006282 else
6283 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6284 }
6285 vty_out (vty, "%s", VTY_NEWLINE);
6286
paul718e3742002-12-13 20:15:29 +00006287 /* display nexthop local */
Paul Jakmafb982c22007-05-04 20:15:47 +00006288 if (attr->extra && attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006289 {
6290 vty_out (vty, " (%s)%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006291 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
paul718e3742002-12-13 20:15:29 +00006292 buf, INET6_ADDRSTRLEN),
6293 VTY_NEWLINE);
6294 }
paul718e3742002-12-13 20:15:29 +00006295
6296 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
6297 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6298
6299 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006300 vty_out (vty, ", metric %u", attr->med);
paul718e3742002-12-13 20:15:29 +00006301
6302 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006303 vty_out (vty, ", localpref %u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006304 else
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006305 vty_out (vty, ", localpref %u", bgp->default_local_pref);
paul718e3742002-12-13 20:15:29 +00006306
Paul Jakmafb982c22007-05-04 20:15:47 +00006307 if (attr->extra && attr->extra->weight != 0)
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006308 vty_out (vty, ", weight %u", attr->extra->weight);
paul718e3742002-12-13 20:15:29 +00006309
6310 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6311 vty_out (vty, ", valid");
6312
6313 if (binfo->peer != bgp->peer_self)
6314 {
6315 if (binfo->peer->as == binfo->peer->local_as)
6316 vty_out (vty, ", internal");
6317 else
6318 vty_out (vty, ", %s",
6319 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6320 }
6321 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6322 vty_out (vty, ", aggregated, local");
6323 else if (binfo->type != ZEBRA_ROUTE_BGP)
6324 vty_out (vty, ", sourced");
6325 else
6326 vty_out (vty, ", sourced, local");
6327
6328 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6329 vty_out (vty, ", atomic-aggregate");
6330
Josh Baileyde8d5df2011-07-20 20:46:01 -07006331 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6332 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6333 bgp_info_mpath_count (binfo)))
6334 vty_out (vty, ", multipath");
6335
paul718e3742002-12-13 20:15:29 +00006336 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6337 vty_out (vty, ", best");
6338
6339 vty_out (vty, "%s", VTY_NEWLINE);
6340
6341 /* Line 4 display Community */
6342 if (attr->community)
6343 vty_out (vty, " Community: %s%s", attr->community->str,
6344 VTY_NEWLINE);
6345
6346 /* Line 5 display Extended-community */
6347 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
Paul Jakmafb982c22007-05-04 20:15:47 +00006348 vty_out (vty, " Extended Community: %s%s",
6349 attr->extra->ecommunity->str, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006350
6351 /* Line 6 display Originator, Cluster-id */
6352 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6353 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6354 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006355 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006356 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006357 vty_out (vty, " Originator: %s",
6358 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006359
6360 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6361 {
6362 int i;
6363 vty_out (vty, ", Cluster list: ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006364 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6365 vty_out (vty, "%s ",
6366 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +00006367 }
6368 vty_out (vty, "%s", VTY_NEWLINE);
6369 }
Paul Jakma41367172007-08-06 15:24:51 +00006370
Paul Jakmafb982c22007-05-04 20:15:47 +00006371 if (binfo->extra && binfo->extra->damp_info)
paul718e3742002-12-13 20:15:29 +00006372 bgp_damp_info_vty (vty, binfo);
6373
6374 /* Line 7 display Uptime */
John Kemp30b00172011-03-18 17:52:18 +03006375#ifdef HAVE_CLOCK_MONOTONIC
6376 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
Vladimir L Ivanov213b6cd2010-10-21 14:59:54 +04006377 vty_out (vty, " Last update: %s", ctime(&tbuf));
John Kemp30b00172011-03-18 17:52:18 +03006378#else
6379 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6380#endif /* HAVE_CLOCK_MONOTONIC */
paul718e3742002-12-13 20:15:29 +00006381 }
6382 vty_out (vty, "%s", VTY_NEWLINE);
Boian Bonevb366b512013-09-09 16:41:35 +00006383}
6384
6385#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6386 "h history, * valid, > best, = multipath,%s"\
6387 " i internal, r RIB-failure, S Stale, R Removed%s"
hasso93406d82005-02-02 14:40:33 +00006388#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00006389#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6390#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6391#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6392
6393enum bgp_show_type
6394{
6395 bgp_show_type_normal,
6396 bgp_show_type_regexp,
6397 bgp_show_type_prefix_list,
6398 bgp_show_type_filter_list,
6399 bgp_show_type_route_map,
6400 bgp_show_type_neighbor,
6401 bgp_show_type_cidr_only,
6402 bgp_show_type_prefix_longer,
6403 bgp_show_type_community_all,
6404 bgp_show_type_community,
6405 bgp_show_type_community_exact,
6406 bgp_show_type_community_list,
6407 bgp_show_type_community_list_exact,
6408 bgp_show_type_flap_statistics,
6409 bgp_show_type_flap_address,
6410 bgp_show_type_flap_prefix,
6411 bgp_show_type_flap_cidr_only,
6412 bgp_show_type_flap_regexp,
6413 bgp_show_type_flap_filter_list,
6414 bgp_show_type_flap_prefix_list,
6415 bgp_show_type_flap_prefix_longer,
6416 bgp_show_type_flap_route_map,
6417 bgp_show_type_flap_neighbor,
6418 bgp_show_type_dampend_paths,
6419 bgp_show_type_damp_neighbor
6420};
6421
ajs5a646652004-11-05 01:25:55 +00006422static int
paulfee0f4c2004-09-13 05:12:46 +00006423bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00006424 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00006425{
paul718e3742002-12-13 20:15:29 +00006426 struct bgp_info *ri;
6427 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00006428 int header = 1;
paul718e3742002-12-13 20:15:29 +00006429 int display;
ajs5a646652004-11-05 01:25:55 +00006430 unsigned long output_count;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006431 unsigned long total_count;
paul718e3742002-12-13 20:15:29 +00006432
6433 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00006434 output_count = 0;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006435 total_count = 0;
paul718e3742002-12-13 20:15:29 +00006436
paul718e3742002-12-13 20:15:29 +00006437 /* Start processing of routes. */
6438 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6439 if (rn->info != NULL)
6440 {
6441 display = 0;
6442
6443 for (ri = rn->info; ri; ri = ri->next)
6444 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006445 total_count++;
ajs5a646652004-11-05 01:25:55 +00006446 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00006447 || type == bgp_show_type_flap_address
6448 || type == bgp_show_type_flap_prefix
6449 || type == bgp_show_type_flap_cidr_only
6450 || type == bgp_show_type_flap_regexp
6451 || type == bgp_show_type_flap_filter_list
6452 || type == bgp_show_type_flap_prefix_list
6453 || type == bgp_show_type_flap_prefix_longer
6454 || type == bgp_show_type_flap_route_map
6455 || type == bgp_show_type_flap_neighbor
6456 || type == bgp_show_type_dampend_paths
6457 || type == bgp_show_type_damp_neighbor)
6458 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006459 if (!(ri->extra && ri->extra->damp_info))
paul718e3742002-12-13 20:15:29 +00006460 continue;
6461 }
6462 if (type == bgp_show_type_regexp
6463 || type == bgp_show_type_flap_regexp)
6464 {
ajs5a646652004-11-05 01:25:55 +00006465 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00006466
6467 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6468 continue;
6469 }
6470 if (type == bgp_show_type_prefix_list
6471 || type == bgp_show_type_flap_prefix_list)
6472 {
ajs5a646652004-11-05 01:25:55 +00006473 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00006474
6475 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6476 continue;
6477 }
6478 if (type == bgp_show_type_filter_list
6479 || type == bgp_show_type_flap_filter_list)
6480 {
ajs5a646652004-11-05 01:25:55 +00006481 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00006482
6483 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6484 continue;
6485 }
6486 if (type == bgp_show_type_route_map
6487 || type == bgp_show_type_flap_route_map)
6488 {
ajs5a646652004-11-05 01:25:55 +00006489 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00006490 struct bgp_info binfo;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006491 struct attr dummy_attr;
6492 struct attr_extra dummy_extra;
paul718e3742002-12-13 20:15:29 +00006493 int ret;
6494
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006495 dummy_attr.extra = &dummy_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00006496 bgp_attr_dup (&dummy_attr, ri->attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006497
paul718e3742002-12-13 20:15:29 +00006498 binfo.peer = ri->peer;
6499 binfo.attr = &dummy_attr;
6500
6501 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
paul718e3742002-12-13 20:15:29 +00006502 if (ret == RMAP_DENYMATCH)
6503 continue;
6504 }
6505 if (type == bgp_show_type_neighbor
6506 || type == bgp_show_type_flap_neighbor
6507 || type == bgp_show_type_damp_neighbor)
6508 {
ajs5a646652004-11-05 01:25:55 +00006509 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00006510
6511 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6512 continue;
6513 }
6514 if (type == bgp_show_type_cidr_only
6515 || type == bgp_show_type_flap_cidr_only)
6516 {
6517 u_int32_t destination;
6518
6519 destination = ntohl (rn->p.u.prefix4.s_addr);
6520 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6521 continue;
6522 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6523 continue;
6524 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6525 continue;
6526 }
6527 if (type == bgp_show_type_prefix_longer
6528 || type == bgp_show_type_flap_prefix_longer)
6529 {
ajs5a646652004-11-05 01:25:55 +00006530 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006531
6532 if (! prefix_match (p, &rn->p))
6533 continue;
6534 }
6535 if (type == bgp_show_type_community_all)
6536 {
6537 if (! ri->attr->community)
6538 continue;
6539 }
6540 if (type == bgp_show_type_community)
6541 {
ajs5a646652004-11-05 01:25:55 +00006542 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006543
6544 if (! ri->attr->community ||
6545 ! community_match (ri->attr->community, com))
6546 continue;
6547 }
6548 if (type == bgp_show_type_community_exact)
6549 {
ajs5a646652004-11-05 01:25:55 +00006550 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006551
6552 if (! ri->attr->community ||
6553 ! community_cmp (ri->attr->community, com))
6554 continue;
6555 }
6556 if (type == bgp_show_type_community_list)
6557 {
ajs5a646652004-11-05 01:25:55 +00006558 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006559
6560 if (! community_list_match (ri->attr->community, list))
6561 continue;
6562 }
6563 if (type == bgp_show_type_community_list_exact)
6564 {
ajs5a646652004-11-05 01:25:55 +00006565 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006566
6567 if (! community_list_exact_match (ri->attr->community, list))
6568 continue;
6569 }
6570 if (type == bgp_show_type_flap_address
6571 || type == bgp_show_type_flap_prefix)
6572 {
ajs5a646652004-11-05 01:25:55 +00006573 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006574
6575 if (! prefix_match (&rn->p, p))
6576 continue;
6577
6578 if (type == bgp_show_type_flap_prefix)
6579 if (p->prefixlen != rn->p.prefixlen)
6580 continue;
6581 }
6582 if (type == bgp_show_type_dampend_paths
6583 || type == bgp_show_type_damp_neighbor)
6584 {
6585 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6586 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6587 continue;
6588 }
6589
6590 if (header)
6591 {
hasso93406d82005-02-02 14:40:33 +00006592 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6593 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6594 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006595 if (type == bgp_show_type_dampend_paths
6596 || type == bgp_show_type_damp_neighbor)
6597 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6598 else if (type == bgp_show_type_flap_statistics
6599 || type == bgp_show_type_flap_address
6600 || type == bgp_show_type_flap_prefix
6601 || type == bgp_show_type_flap_cidr_only
6602 || type == bgp_show_type_flap_regexp
6603 || type == bgp_show_type_flap_filter_list
6604 || type == bgp_show_type_flap_prefix_list
6605 || type == bgp_show_type_flap_prefix_longer
6606 || type == bgp_show_type_flap_route_map
6607 || type == bgp_show_type_flap_neighbor)
6608 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6609 else
6610 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006611 header = 0;
6612 }
6613
6614 if (type == bgp_show_type_dampend_paths
6615 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00006616 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006617 else if (type == bgp_show_type_flap_statistics
6618 || type == bgp_show_type_flap_address
6619 || type == bgp_show_type_flap_prefix
6620 || type == bgp_show_type_flap_cidr_only
6621 || type == bgp_show_type_flap_regexp
6622 || type == bgp_show_type_flap_filter_list
6623 || type == bgp_show_type_flap_prefix_list
6624 || type == bgp_show_type_flap_prefix_longer
6625 || type == bgp_show_type_flap_route_map
6626 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00006627 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006628 else
ajs5a646652004-11-05 01:25:55 +00006629 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006630 display++;
6631 }
6632 if (display)
ajs5a646652004-11-05 01:25:55 +00006633 output_count++;
paul718e3742002-12-13 20:15:29 +00006634 }
6635
6636 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00006637 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00006638 {
6639 if (type == bgp_show_type_normal)
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006640 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006641 }
6642 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006643 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6644 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006645
6646 return CMD_SUCCESS;
6647}
6648
ajs5a646652004-11-05 01:25:55 +00006649static int
paulfee0f4c2004-09-13 05:12:46 +00006650bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00006651 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00006652{
6653 struct bgp_table *table;
6654
6655 if (bgp == NULL) {
6656 bgp = bgp_get_default ();
6657 }
6658
6659 if (bgp == NULL)
6660 {
6661 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6662 return CMD_WARNING;
6663 }
6664
6665
6666 table = bgp->rib[afi][safi];
6667
ajs5a646652004-11-05 01:25:55 +00006668 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00006669}
6670
paul718e3742002-12-13 20:15:29 +00006671/* Header of detailed BGP route information */
paul94f2b392005-06-28 12:44:16 +00006672static void
paul718e3742002-12-13 20:15:29 +00006673route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6674 struct bgp_node *rn,
6675 struct prefix_rd *prd, afi_t afi, safi_t safi)
6676{
6677 struct bgp_info *ri;
6678 struct prefix *p;
6679 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006680 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00006681 char buf1[INET6_ADDRSTRLEN];
6682 char buf2[INET6_ADDRSTRLEN];
6683 int count = 0;
6684 int best = 0;
6685 int suppress = 0;
6686 int no_export = 0;
6687 int no_advertise = 0;
6688 int local_as = 0;
6689 int first = 0;
Lou Berger298cc2f2016-01-12 13:42:02 -05006690 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
paul718e3742002-12-13 20:15:29 +00006691
6692 p = &rn->p;
6693 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
Lou Berger298cc2f2016-01-12 13:42:02 -05006694 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6695 printrd ? ":" : "",
paul718e3742002-12-13 20:15:29 +00006696 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6697 p->prefixlen, VTY_NEWLINE);
6698
6699 for (ri = rn->info; ri; ri = ri->next)
6700 {
6701 count++;
6702 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6703 {
6704 best = count;
Paul Jakmafb982c22007-05-04 20:15:47 +00006705 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00006706 suppress = 1;
6707 if (ri->attr->community != NULL)
6708 {
6709 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6710 no_advertise = 1;
6711 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6712 no_export = 1;
6713 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6714 local_as = 1;
6715 }
6716 }
6717 }
6718
6719 vty_out (vty, "Paths: (%d available", count);
6720 if (best)
6721 {
6722 vty_out (vty, ", best #%d", best);
6723 if (safi == SAFI_UNICAST)
6724 vty_out (vty, ", table Default-IP-Routing-Table");
6725 }
6726 else
6727 vty_out (vty, ", no best path");
6728 if (no_advertise)
6729 vty_out (vty, ", not advertised to any peer");
6730 else if (no_export)
6731 vty_out (vty, ", not advertised to EBGP peer");
6732 else if (local_as)
6733 vty_out (vty, ", not advertised outside local AS");
6734 if (suppress)
6735 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6736 vty_out (vty, ")%s", VTY_NEWLINE);
6737
6738 /* advertised peer */
paul1eb8ef22005-04-07 07:30:20 +00006739 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006740 {
6741 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6742 {
6743 if (! first)
6744 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6745 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6746 first = 1;
6747 }
6748 }
6749 if (! first)
6750 vty_out (vty, " Not advertised to any peer");
6751 vty_out (vty, "%s", VTY_NEWLINE);
6752}
6753
6754/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +00006755static int
paulfee0f4c2004-09-13 05:12:46 +00006756bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00006757 struct bgp_table *rib, const char *ip_str,
6758 afi_t afi, safi_t safi, struct prefix_rd *prd,
6759 int prefix_check)
paul718e3742002-12-13 20:15:29 +00006760{
6761 int ret;
6762 int header;
6763 int display = 0;
6764 struct prefix match;
6765 struct bgp_node *rn;
6766 struct bgp_node *rm;
6767 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00006768 struct bgp_table *table;
6769
Lou Berger050defe2016-01-12 13:41:59 -05006770 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
paul718e3742002-12-13 20:15:29 +00006771 /* Check IP address argument. */
6772 ret = str2prefix (ip_str, &match);
6773 if (! ret)
6774 {
6775 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6776 return CMD_WARNING;
6777 }
6778
6779 match.family = afi2family (afi);
6780
Lou Berger298cc2f2016-01-12 13:42:02 -05006781 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00006782 {
paulfee0f4c2004-09-13 05:12:46 +00006783 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00006784 {
6785 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6786 continue;
6787
6788 if ((table = rn->info) != NULL)
6789 {
6790 header = 1;
6791
6792 if ((rm = bgp_node_match (table, &match)) != NULL)
6793 {
6794 if (prefix_check && rm->p.prefixlen != match.prefixlen)
Chris Caputo6c88b442010-07-27 16:28:55 +00006795 {
6796 bgp_unlock_node (rm);
6797 continue;
6798 }
paul718e3742002-12-13 20:15:29 +00006799
6800 for (ri = rm->info; ri; ri = ri->next)
6801 {
6802 if (header)
6803 {
6804 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
Lou Berger298cc2f2016-01-12 13:42:02 -05006805 AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006806
6807 header = 0;
6808 }
6809 display++;
Lou Berger298cc2f2016-01-12 13:42:02 -05006810 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006811 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006812
6813 bgp_unlock_node (rm);
paul718e3742002-12-13 20:15:29 +00006814 }
6815 }
6816 }
6817 }
6818 else
6819 {
6820 header = 1;
6821
paulfee0f4c2004-09-13 05:12:46 +00006822 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00006823 {
6824 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6825 {
6826 for (ri = rn->info; ri; ri = ri->next)
6827 {
6828 if (header)
6829 {
6830 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6831 header = 0;
6832 }
6833 display++;
6834 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
6835 }
6836 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006837
6838 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00006839 }
6840 }
6841
6842 if (! display)
6843 {
6844 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6845 return CMD_WARNING;
6846 }
6847
6848 return CMD_SUCCESS;
6849}
6850
paulfee0f4c2004-09-13 05:12:46 +00006851/* Display specified route of Main RIB */
paul94f2b392005-06-28 12:44:16 +00006852static int
paulfd79ac92004-10-13 05:06:08 +00006853bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00006854 afi_t afi, safi_t safi, struct prefix_rd *prd,
6855 int prefix_check)
6856{
6857 struct bgp *bgp;
6858
6859 /* BGP structure lookup. */
6860 if (view_name)
6861 {
6862 bgp = bgp_lookup_by_name (view_name);
6863 if (bgp == NULL)
6864 {
6865 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6866 return CMD_WARNING;
6867 }
6868 }
6869 else
6870 {
6871 bgp = bgp_get_default ();
6872 if (bgp == NULL)
6873 {
6874 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6875 return CMD_WARNING;
6876 }
6877 }
6878
6879 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
6880 afi, safi, prd, prefix_check);
6881}
6882
paul718e3742002-12-13 20:15:29 +00006883/* BGP route print out function. */
Lou Bergerf9b6c392016-01-12 13:42:09 -05006884DEFUN (show_ip_bgp,
6885 show_ip_bgp_cmd,
6886 "show ip bgp",
6887 SHOW_STR
6888 IP_STR
6889 BGP_STR)
6890{
6891 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6892}
6893
6894DEFUN (show_ip_bgp_ipv4,
6895 show_ip_bgp_ipv4_cmd,
6896 "show ip bgp ipv4 (unicast|multicast)",
6897 SHOW_STR
6898 IP_STR
6899 BGP_STR
6900 "Address family\n"
6901 "Address Family modifier\n"
6902 "Address Family modifier\n")
6903{
6904 if (strncmp (argv[0], "m", 1) == 0)
6905 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
6906 NULL);
6907
6908 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6909}
6910
6911DEFUN (show_ip_bgp_route,
6912 show_ip_bgp_route_cmd,
6913 "show ip bgp A.B.C.D",
6914 SHOW_STR
6915 IP_STR
6916 BGP_STR
6917 "Network in the BGP routing table to display\n")
6918{
6919 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
6920}
6921
6922DEFUN (show_ip_bgp_ipv4_route,
6923 show_ip_bgp_ipv4_route_cmd,
6924 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6925 SHOW_STR
6926 IP_STR
6927 BGP_STR
6928 "Address family\n"
6929 "Address Family modifier\n"
6930 "Address Family modifier\n"
6931 "Network in the BGP routing table to display\n")
6932{
6933 if (strncmp (argv[0], "m", 1) == 0)
6934 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
6935
6936 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
6937}
6938
6939DEFUN (show_ip_bgp_vpnv4_all_route,
6940 show_ip_bgp_vpnv4_all_route_cmd,
6941 "show ip bgp vpnv4 all A.B.C.D",
6942 SHOW_STR
6943 IP_STR
6944 BGP_STR
6945 "Display VPNv4 NLRI specific information\n"
6946 "Display information about all VPNv4 NLRIs\n"
6947 "Network in the BGP routing table to display\n")
6948{
6949 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
6950}
6951
6952DEFUN (show_ip_bgp_vpnv4_rd_route,
6953 show_ip_bgp_vpnv4_rd_route_cmd,
6954 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6955 SHOW_STR
6956 IP_STR
6957 BGP_STR
6958 "Display VPNv4 NLRI specific information\n"
6959 "Display information for a route distinguisher\n"
6960 "VPN Route Distinguisher\n"
6961 "Network in the BGP routing table to display\n")
6962{
6963 int ret;
6964 struct prefix_rd prd;
6965
6966 ret = str2prefix_rd (argv[0], &prd);
6967 if (! ret)
6968 {
6969 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
6970 return CMD_WARNING;
6971 }
6972 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
6973}
6974
6975DEFUN (show_ip_bgp_prefix,
6976 show_ip_bgp_prefix_cmd,
6977 "show ip bgp A.B.C.D/M",
6978 SHOW_STR
6979 IP_STR
6980 BGP_STR
6981 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6982{
6983 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
6984}
6985
6986DEFUN (show_ip_bgp_ipv4_prefix,
6987 show_ip_bgp_ipv4_prefix_cmd,
6988 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6989 SHOW_STR
6990 IP_STR
6991 BGP_STR
6992 "Address family\n"
6993 "Address Family modifier\n"
6994 "Address Family modifier\n"
6995 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6996{
6997 if (strncmp (argv[0], "m", 1) == 0)
6998 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
6999
7000 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7001}
7002
7003DEFUN (show_ip_bgp_vpnv4_all_prefix,
7004 show_ip_bgp_vpnv4_all_prefix_cmd,
7005 "show ip bgp vpnv4 all A.B.C.D/M",
7006 SHOW_STR
7007 IP_STR
7008 BGP_STR
7009 "Display VPNv4 NLRI specific information\n"
7010 "Display information about all VPNv4 NLRIs\n"
7011 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7012{
7013 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
7014}
7015
7016DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7017 show_ip_bgp_vpnv4_rd_prefix_cmd,
7018 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7019 SHOW_STR
7020 IP_STR
7021 BGP_STR
7022 "Display VPNv4 NLRI specific information\n"
7023 "Display information for a route distinguisher\n"
7024 "VPN Route Distinguisher\n"
7025 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7026{
7027 int ret;
7028 struct prefix_rd prd;
7029
7030 ret = str2prefix_rd (argv[0], &prd);
7031 if (! ret)
7032 {
7033 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7034 return CMD_WARNING;
7035 }
7036 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
7037}
7038
7039DEFUN (show_ip_bgp_view,
7040 show_ip_bgp_view_cmd,
7041 "show ip bgp view WORD",
7042 SHOW_STR
7043 IP_STR
7044 BGP_STR
7045 "BGP view\n"
7046 "View name\n")
7047{
7048 struct bgp *bgp;
7049
7050 /* BGP structure lookup. */
7051 bgp = bgp_lookup_by_name (argv[0]);
7052 if (bgp == NULL)
7053 {
7054 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7055 return CMD_WARNING;
7056 }
7057
7058 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7059}
7060
7061DEFUN (show_ip_bgp_view_route,
7062 show_ip_bgp_view_route_cmd,
7063 "show ip bgp view WORD A.B.C.D",
7064 SHOW_STR
7065 IP_STR
7066 BGP_STR
7067 "BGP view\n"
7068 "View name\n"
7069 "Network in the BGP routing table to display\n")
7070{
7071 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7072}
7073
7074DEFUN (show_ip_bgp_view_prefix,
7075 show_ip_bgp_view_prefix_cmd,
7076 "show ip bgp view WORD A.B.C.D/M",
7077 SHOW_STR
7078 IP_STR
7079 BGP_STR
7080 "BGP view\n"
7081 "View name\n"
7082 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7083{
7084 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7085}
7086
7087DEFUN (show_bgp,
7088 show_bgp_cmd,
7089 "show bgp",
7090 SHOW_STR
7091 BGP_STR)
7092{
7093 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7094 NULL);
7095}
7096
7097ALIAS (show_bgp,
7098 show_bgp_ipv6_cmd,
7099 "show bgp ipv6",
7100 SHOW_STR
7101 BGP_STR
7102 "Address family\n")
7103
7104/* old command */
7105DEFUN (show_ipv6_bgp,
7106 show_ipv6_bgp_cmd,
7107 "show ipv6 bgp",
7108 SHOW_STR
7109 IP_STR
7110 BGP_STR)
7111{
7112 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7113 NULL);
7114}
7115
7116DEFUN (show_bgp_route,
7117 show_bgp_route_cmd,
7118 "show bgp X:X::X:X",
7119 SHOW_STR
7120 BGP_STR
7121 "Network in the BGP routing table to display\n")
7122{
7123 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7124}
7125
Lou Berger35c36862016-01-12 13:42:06 -05007126DEFUN (show_bgp_ipv4_safi,
7127 show_bgp_ipv4_safi_cmd,
7128 "show bgp ipv4 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00007129 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007130 BGP_STR
7131 "Address family\n"
7132 "Address Family modifier\n"
7133 "Address Family modifier\n")
7134{
7135 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00007136 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7137 NULL);
paul718e3742002-12-13 20:15:29 +00007138
ajs5a646652004-11-05 01:25:55 +00007139 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00007140}
7141
Lou Berger35c36862016-01-12 13:42:06 -05007142DEFUN (show_bgp_ipv4_safi_route,
7143 show_bgp_ipv4_safi_route_cmd,
7144 "show bgp ipv4 (unicast|multicast) A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007145 SHOW_STR
7146 BGP_STR
7147 "Address family\n"
7148 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00007149 "Address Family modifier\n"
7150 "Network in the BGP routing table to display\n")
7151{
7152 if (strncmp (argv[0], "m", 1) == 0)
7153 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
7154
7155 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7156}
7157
Lou Berger35c36862016-01-12 13:42:06 -05007158DEFUN (show_bgp_ipv4_vpn_route,
7159 show_bgp_ipv4_vpn_route_cmd,
7160 "show bgp ipv4 vpn A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007161 SHOW_STR
7162 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007163 "Address Family\n"
7164 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007165 "Network in the BGP routing table to display\n")
7166{
7167 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
7168}
7169
Lou Berger35c36862016-01-12 13:42:06 -05007170DEFUN (show_bgp_ipv6_vpn_route,
7171 show_bgp_ipv6_vpn_route_cmd,
7172 "show bgp ipv6 vpn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007173 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007174 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007175 "Address Family\n"
7176 "Display VPN NLRI specific information\n"
7177 "Network in the BGP routing table to display\n")
7178{
7179 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0);
7180}
Lou Berger35c36862016-01-12 13:42:06 -05007181
7182DEFUN (show_bgp_ipv4_vpn_rd_route,
7183 show_bgp_ipv4_vpn_rd_route_cmd,
7184 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7185 SHOW_STR
7186 BGP_STR
7187 IP_STR
7188 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007189 "Display information for a route distinguisher\n"
7190 "VPN Route Distinguisher\n"
7191 "Network in the BGP routing table to display\n")
7192{
7193 int ret;
7194 struct prefix_rd prd;
7195
7196 ret = str2prefix_rd (argv[0], &prd);
7197 if (! ret)
7198 {
7199 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7200 return CMD_WARNING;
7201 }
7202 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
7203}
7204
Lou Berger35c36862016-01-12 13:42:06 -05007205DEFUN (show_bgp_ipv6_vpn_rd_route,
7206 show_bgp_ipv6_vpn_rd_route_cmd,
7207 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007208 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007209 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007210 "Address Family\n"
7211 "Display VPN NLRI specific information\n"
7212 "Display information for a route distinguisher\n"
7213 "VPN Route Distinguisher\n"
7214 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007215{
Lou Berger35c36862016-01-12 13:42:06 -05007216 int ret;
7217 struct prefix_rd prd;
7218
7219 ret = str2prefix_rd (argv[0], &prd);
7220 if (! ret)
7221 {
7222 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7223 return CMD_WARNING;
7224 }
7225 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007226}
7227
Lou Berger651b4022016-01-12 13:42:07 -05007228DEFUN (show_bgp_ipv4_encap_route,
7229 show_bgp_ipv4_encap_route_cmd,
7230 "show bgp ipv4 encap A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007231 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007232 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007233 IP_STR
7234 "Display ENCAP NLRI specific information\n"
7235 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007236{
Lou Berger651b4022016-01-12 13:42:07 -05007237 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007238}
7239
Lou Berger651b4022016-01-12 13:42:07 -05007240DEFUN (show_bgp_ipv6_encap_route,
7241 show_bgp_ipv6_encap_route_cmd,
7242 "show bgp ipv6 encap X:X::X:X",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007243 SHOW_STR
7244 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007245 IP6_STR
7246 "Display ENCAP NLRI specific information\n"
7247 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007248{
Lou Berger651b4022016-01-12 13:42:07 -05007249 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007250}
7251
Lou Berger651b4022016-01-12 13:42:07 -05007252DEFUN (show_bgp_ipv4_safi_rd_route,
7253 show_bgp_ipv4_safi_rd_route_cmd,
7254 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007255 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007256 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007257 "Address Family\n"
7258 "Address Family Modifier\n"
7259 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007260 "Display information for a route distinguisher\n"
Lou Berger651b4022016-01-12 13:42:07 -05007261 "ENCAP Route Distinguisher\n"
7262 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007263{
7264 int ret;
7265 struct prefix_rd prd;
Lou Berger651b4022016-01-12 13:42:07 -05007266 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007267
Lou Berger651b4022016-01-12 13:42:07 -05007268 if (bgp_parse_safi(argv[0], &safi)) {
7269 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7270 return CMD_WARNING;
7271 }
7272 ret = str2prefix_rd (argv[1], &prd);
paul718e3742002-12-13 20:15:29 +00007273 if (! ret)
7274 {
7275 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7276 return CMD_WARNING;
7277 }
Lou Berger651b4022016-01-12 13:42:07 -05007278 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007279}
7280
Lou Berger651b4022016-01-12 13:42:07 -05007281DEFUN (show_bgp_ipv6_safi_rd_route,
7282 show_bgp_ipv6_safi_rd_route_cmd,
7283 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007284 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007285 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007286 "Address Family\n"
7287 "Address Family Modifier\n"
7288 "Address Family Modifier\n"
7289 "Display information for a route distinguisher\n"
7290 "ENCAP Route Distinguisher\n"
7291 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007292{
Lou Berger651b4022016-01-12 13:42:07 -05007293 int ret;
7294 struct prefix_rd prd;
7295 safi_t safi;
paulbb46e942003-10-24 19:02:03 +00007296
Lou Berger651b4022016-01-12 13:42:07 -05007297 if (bgp_parse_safi(argv[0], &safi)) {
7298 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7299 return CMD_WARNING;
7300 }
7301 ret = str2prefix_rd (argv[1], &prd);
7302 if (! ret)
7303 {
7304 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7305 return CMD_WARNING;
7306 }
7307 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007308}
7309
Lou Berger35c36862016-01-12 13:42:06 -05007310DEFUN (show_bgp_ipv4_prefix,
7311 show_bgp_ipv4_prefix_cmd,
7312 "show bgp ipv4 A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007313 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007314 BGP_STR
paul718e3742002-12-13 20:15:29 +00007315 IP_STR
paul718e3742002-12-13 20:15:29 +00007316 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7317{
Lou Berger35c36862016-01-12 13:42:06 -05007318 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007319}
7320
Lou Berger35c36862016-01-12 13:42:06 -05007321DEFUN (show_bgp_ipv4_safi_prefix,
7322 show_bgp_ipv4_safi_prefix_cmd,
7323 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007324 SHOW_STR
7325 BGP_STR
7326 "Address family\n"
7327 "Address Family modifier\n"
Lou Berger35c36862016-01-12 13:42:06 -05007328 "Address Family modifier\n"
7329 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04007330{
7331 if (strncmp (argv[0], "m", 1) == 0)
Lou Berger35c36862016-01-12 13:42:06 -05007332 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007333
Lou Berger35c36862016-01-12 13:42:06 -05007334 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007335}
7336
Lou Berger35c36862016-01-12 13:42:06 -05007337DEFUN (show_bgp_ipv4_vpn_prefix,
7338 show_bgp_ipv4_vpn_prefix_cmd,
7339 "show bgp ipv4 vpn A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007340 SHOW_STR
7341 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007342 IP_STR
7343 "Display VPN NLRI specific information\n"
7344 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +00007345{
Lou Berger35c36862016-01-12 13:42:06 -05007346 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007347}
7348
Lou Berger35c36862016-01-12 13:42:06 -05007349DEFUN (show_bgp_ipv6_vpn_prefix,
7350 show_bgp_ipv6_vpn_prefix_cmd,
7351 "show bgp ipv6 vpn X:X::X:X/M",
7352 SHOW_STR
7353 BGP_STR
7354 "Address Family\n"
7355 "Display VPN NLRI specific information\n"
7356 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7357{
7358 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1);
7359}
Lou Berger35c36862016-01-12 13:42:06 -05007360
Lou Berger651b4022016-01-12 13:42:07 -05007361DEFUN (show_bgp_ipv4_encap_prefix,
7362 show_bgp_ipv4_encap_prefix_cmd,
7363 "show bgp ipv4 encap A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007364 SHOW_STR
7365 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007366 IP_STR
7367 "Display ENCAP NLRI specific information\n"
7368 "Display information about ENCAP NLRIs\n"
7369 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7370{
7371 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1);
7372}
paul718e3742002-12-13 20:15:29 +00007373
Lou Berger651b4022016-01-12 13:42:07 -05007374DEFUN (show_bgp_ipv6_encap_prefix,
7375 show_bgp_ipv6_encap_prefix_cmd,
7376 "show bgp ipv6 encap X:X::X:X/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007377 SHOW_STR
7378 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007379 IP_STR
7380 "Display ENCAP NLRI specific information\n"
7381 "Display information about ENCAP NLRIs\n"
7382 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7383{
7384 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1);
7385}
Lou Berger651b4022016-01-12 13:42:07 -05007386
7387DEFUN (show_bgp_ipv4_safi_rd_prefix,
7388 show_bgp_ipv4_safi_rd_prefix_cmd,
7389 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7390 SHOW_STR
7391 BGP_STR
7392 "Address Family\n"
7393 "Address Family Modifier\n"
7394 "Address Family Modifier\n"
7395 "Display information for a route distinguisher\n"
7396 "ENCAP Route Distinguisher\n"
7397 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7398{
7399 int ret;
7400 struct prefix_rd prd;
7401 safi_t safi;
7402
7403 if (bgp_parse_safi(argv[0], &safi)) {
7404 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7405 return CMD_WARNING;
7406 }
7407
7408 ret = str2prefix_rd (argv[1], &prd);
7409 if (! ret)
7410 {
7411 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7412 return CMD_WARNING;
7413 }
7414 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1);
7415}
7416
Lou Berger651b4022016-01-12 13:42:07 -05007417DEFUN (show_bgp_ipv6_safi_rd_prefix,
7418 show_bgp_ipv6_safi_rd_prefix_cmd,
7419 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7420 SHOW_STR
7421 BGP_STR
7422 "Address Family\n"
7423 "Address Family Modifier\n"
7424 "Address Family Modifier\n"
7425 "Display information for a route distinguisher\n"
7426 "ENCAP Route Distinguisher\n"
7427 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7428{
7429 int ret;
7430 struct prefix_rd prd;
7431 safi_t safi;
7432
7433 if (bgp_parse_safi(argv[0], &safi)) {
7434 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7435 return CMD_WARNING;
7436 }
7437
7438 ret = str2prefix_rd (argv[1], &prd);
7439 if (! ret)
7440 {
7441 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7442 return CMD_WARNING;
7443 }
7444 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1);
7445}
Lou Berger651b4022016-01-12 13:42:07 -05007446
7447DEFUN (show_bgp_afi_safi_view,
7448 show_bgp_afi_safi_view_cmd,
7449 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7450 SHOW_STR
7451 BGP_STR
7452 "BGP view\n"
7453 "BGP view name\n"
7454 "Address Family\n"
7455 "Address Family\n"
7456 "Address Family Modifier\n"
7457 "Address Family Modifier\n"
7458 "Address Family Modifier\n"
7459 "Address Family Modifier\n"
7460 )
7461{
7462 struct bgp *bgp;
7463 safi_t safi;
7464 afi_t afi;
7465
7466 if (bgp_parse_afi(argv[1], &afi)) {
7467 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7468 return CMD_WARNING;
7469 }
7470 if (bgp_parse_safi(argv[2], &safi)) {
7471 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7472 return CMD_WARNING;
7473 }
7474
7475 /* BGP structure lookup. */
7476 bgp = bgp_lookup_by_name (argv[0]);
7477 if (bgp == NULL)
7478 {
7479 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7480 return CMD_WARNING;
7481 }
7482
7483 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7484}
7485
7486DEFUN (show_bgp_view_afi_safi_route,
7487 show_bgp_view_afi_safi_route_cmd,
7488 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7489 SHOW_STR
7490 BGP_STR
7491 "BGP view\n"
7492 "View name\n"
7493 "Address Family\n"
7494 "Address Family\n"
7495 "Address Family Modifier\n"
7496 "Address Family Modifier\n"
7497 "Address Family Modifier\n"
7498 "Address Family Modifier\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -04007499 "Network in the BGP routing table to display\n")
7500{
Lou Berger651b4022016-01-12 13:42:07 -05007501 safi_t safi;
7502 afi_t afi;
Michael Lambert95cbbd22010-07-23 14:43:04 -04007503
Lou Berger651b4022016-01-12 13:42:07 -05007504 if (bgp_parse_afi(argv[1], &afi)) {
7505 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7506 return CMD_WARNING;
7507 }
7508 if (bgp_parse_safi(argv[2], &safi)) {
7509 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7510 return CMD_WARNING;
7511 }
7512 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0);
7513}
7514
7515DEFUN (show_bgp_view_afi_safi_prefix,
7516 show_bgp_view_afi_safi_prefix_cmd,
7517 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7518 SHOW_STR
7519 BGP_STR
7520 "BGP view\n"
7521 "View name\n"
7522 "Address Family\n"
7523 "Address Family\n"
7524 "Address Family Modifier\n"
7525 "Address Family Modifier\n"
7526 "Address Family Modifier\n"
7527 "Address Family Modifier\n"
7528 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7529{
7530 safi_t safi;
7531 afi_t afi;
7532
7533 if (bgp_parse_afi(argv[1], &afi)) {
7534 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7535 return CMD_WARNING;
7536 }
7537 if (bgp_parse_safi(argv[2], &safi)) {
7538 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7539 return CMD_WARNING;
7540 }
7541 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1);
7542}
7543
7544/* new001 */
7545DEFUN (show_bgp_afi,
7546 show_bgp_afi_cmd,
7547 "show bgp (ipv4|ipv6)",
7548 SHOW_STR
7549 BGP_STR
7550 "Address family\n"
7551 "Address family\n")
7552{
7553 afi_t afi;
7554
7555 if (bgp_parse_afi(argv[0], &afi)) {
7556 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7557 return CMD_WARNING;
7558 }
7559 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7560 NULL);
7561}
7562
Lou Berger651b4022016-01-12 13:42:07 -05007563DEFUN (show_bgp_ipv6_safi,
7564 show_bgp_ipv6_safi_cmd,
7565 "show bgp ipv6 (unicast|multicast)",
7566 SHOW_STR
7567 BGP_STR
7568 "Address family\n"
7569 "Address Family modifier\n"
7570 "Address Family modifier\n")
7571{
7572 if (strncmp (argv[0], "m", 1) == 0)
7573 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7574 NULL);
7575
7576 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007577}
7578
Lou Berger35c36862016-01-12 13:42:06 -05007579DEFUN (show_bgp_ipv6_route,
7580 show_bgp_ipv6_route_cmd,
7581 "show bgp ipv6 X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007582 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007583 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007584 "Address family\n"
paul718e3742002-12-13 20:15:29 +00007585 "Network in the BGP routing table to display\n")
7586{
7587 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7588}
7589
Lou Berger35c36862016-01-12 13:42:06 -05007590DEFUN (show_bgp_ipv6_safi_route,
7591 show_bgp_ipv6_safi_route_cmd,
7592 "show bgp ipv6 (unicast|multicast) X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007593 SHOW_STR
7594 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007595 "Address family\n"
7596 "Address Family modifier\n"
7597 "Address Family modifier\n"
7598 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007599{
Lou Berger35c36862016-01-12 13:42:06 -05007600 if (strncmp (argv[0], "m", 1) == 0)
7601 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7602
7603 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007604}
7605
Lou Bergerf9b6c392016-01-12 13:42:09 -05007606/* old command */
7607DEFUN (show_ipv6_bgp_route,
7608 show_ipv6_bgp_route_cmd,
7609 "show ipv6 bgp X:X::X:X",
7610 SHOW_STR
7611 IP_STR
7612 BGP_STR
7613 "Network in the BGP routing table to display\n")
7614{
7615 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7616}
7617
7618DEFUN (show_bgp_prefix,
7619 show_bgp_prefix_cmd,
7620 "show bgp X:X::X:X/M",
7621 SHOW_STR
7622 BGP_STR
7623 "IPv6 prefix <network>/<length>\n")
7624{
7625 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7626}
7627
7628
Lou Berger35c36862016-01-12 13:42:06 -05007629/* new002 */
7630DEFUN (show_bgp_ipv6_prefix,
paul718e3742002-12-13 20:15:29 +00007631 show_bgp_ipv6_prefix_cmd,
7632 "show bgp ipv6 X:X::X:X/M",
7633 SHOW_STR
7634 BGP_STR
7635 "Address family\n"
Lou Berger35c36862016-01-12 13:42:06 -05007636 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7637{
7638 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7639}
Michael Lambert95cbbd22010-07-23 14:43:04 -04007640DEFUN (show_bgp_ipv6_safi_prefix,
7641 show_bgp_ipv6_safi_prefix_cmd,
7642 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7643 SHOW_STR
7644 BGP_STR
7645 "Address family\n"
7646 "Address Family modifier\n"
7647 "Address Family modifier\n"
7648 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7649{
7650 if (strncmp (argv[0], "m", 1) == 0)
7651 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7652
7653 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7654}
7655
Lou Bergerf9b6c392016-01-12 13:42:09 -05007656/* old command */
7657DEFUN (show_ipv6_bgp_prefix,
7658 show_ipv6_bgp_prefix_cmd,
7659 "show ipv6 bgp X:X::X:X/M",
7660 SHOW_STR
7661 IP_STR
7662 BGP_STR
7663 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7664{
7665 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7666}
7667
paulbb46e942003-10-24 19:02:03 +00007668DEFUN (show_bgp_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007669 show_bgp_view_cmd,
7670 "show bgp view WORD",
7671 SHOW_STR
7672 BGP_STR
7673 "BGP view\n"
7674 "View name\n")
7675{
7676 struct bgp *bgp;
7677
7678 /* BGP structure lookup. */
7679 bgp = bgp_lookup_by_name (argv[0]);
7680 if (bgp == NULL)
7681 {
7682 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7683 return CMD_WARNING;
7684 }
7685
7686 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
7687}
7688
7689DEFUN (show_bgp_view_ipv6,
Lou Berger35c36862016-01-12 13:42:06 -05007690 show_bgp_view_ipv6_cmd,
7691 "show bgp view WORD ipv6",
paulbb46e942003-10-24 19:02:03 +00007692 SHOW_STR
Lou Berger35c36862016-01-12 13:42:06 -05007693 BGP_STR
paulbb46e942003-10-24 19:02:03 +00007694 "BGP view\n"
Lou Berger35c36862016-01-12 13:42:06 -05007695 "View name\n"
7696 "Address family\n")
paulbb46e942003-10-24 19:02:03 +00007697{
7698 struct bgp *bgp;
7699
7700 /* BGP structure lookup. */
7701 bgp = bgp_lookup_by_name (argv[0]);
7702 if (bgp == NULL)
7703 {
7704 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7705 return CMD_WARNING;
7706 }
7707
ajs5a646652004-11-05 01:25:55 +00007708 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00007709}
paulbb46e942003-10-24 19:02:03 +00007710
7711DEFUN (show_bgp_view_route,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007712 show_bgp_view_route_cmd,
7713 "show bgp view WORD X:X::X:X",
7714 SHOW_STR
7715 BGP_STR
7716 "BGP view\n"
7717 "View name\n"
7718 "Network in the BGP routing table to display\n")
7719{
7720 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
7721}
7722
7723DEFUN (show_bgp_view_ipv6_route,
paulbb46e942003-10-24 19:02:03 +00007724 show_bgp_view_ipv6_route_cmd,
7725 "show bgp view WORD ipv6 X:X::X:X",
7726 SHOW_STR
7727 BGP_STR
7728 "BGP view\n"
7729 "View name\n"
7730 "Address family\n"
7731 "Network in the BGP routing table to display\n")
paulbb46e942003-10-24 19:02:03 +00007732{
Lou Berger35c36862016-01-12 13:42:06 -05007733 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paulbb46e942003-10-24 19:02:03 +00007734}
7735
Lou Bergerf9b6c392016-01-12 13:42:09 -05007736/* old command */
7737DEFUN (show_ipv6_mbgp,
7738 show_ipv6_mbgp_cmd,
7739 "show ipv6 mbgp",
7740 SHOW_STR
7741 IP_STR
7742 MBGP_STR)
7743{
7744 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7745 NULL);
7746}
7747
7748/* old command */
7749DEFUN (show_ipv6_mbgp_route,
7750 show_ipv6_mbgp_route_cmd,
7751 "show ipv6 mbgp X:X::X:X",
7752 SHOW_STR
7753 IP_STR
7754 MBGP_STR
7755 "Network in the MBGP routing table to display\n")
7756{
7757 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7758}
7759
7760/* old command */
7761DEFUN (show_ipv6_mbgp_prefix,
7762 show_ipv6_mbgp_prefix_cmd,
7763 "show ipv6 mbgp X:X::X:X/M",
7764 SHOW_STR
7765 IP_STR
7766 MBGP_STR
7767 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7768{
7769 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7770}
7771
Lou Berger35c36862016-01-12 13:42:06 -05007772DEFUN (show_bgp_view_prefix,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007773 show_bgp_view_prefix_cmd,
7774 "show bgp view WORD X:X::X:X/M",
7775 SHOW_STR
7776 BGP_STR
7777 "BGP view\n"
7778 "View name\n"
7779 "IPv6 prefix <network>/<length>\n")
7780{
7781 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7782}
7783
7784DEFUN (show_bgp_view_ipv6_prefix,
paulbb46e942003-10-24 19:02:03 +00007785 show_bgp_view_ipv6_prefix_cmd,
7786 "show bgp view WORD ipv6 X:X::X:X/M",
7787 SHOW_STR
7788 BGP_STR
7789 "BGP view\n"
7790 "View name\n"
7791 "Address family\n"
7792 "IPv6 prefix <network>/<length>\n")
paul718e3742002-12-13 20:15:29 +00007793{
Lou Berger35c36862016-01-12 13:42:06 -05007794 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007795}
7796
paul94f2b392005-06-28 12:44:16 +00007797static int
paulfd79ac92004-10-13 05:06:08 +00007798bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00007799 safi_t safi, enum bgp_show_type type)
7800{
7801 int i;
7802 struct buffer *b;
7803 char *regstr;
7804 int first;
7805 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00007806 int rc;
paul718e3742002-12-13 20:15:29 +00007807
7808 first = 0;
7809 b = buffer_new (1024);
7810 for (i = 0; i < argc; i++)
7811 {
7812 if (first)
7813 buffer_putc (b, ' ');
7814 else
7815 {
7816 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
7817 continue;
7818 first = 1;
7819 }
7820
7821 buffer_putstr (b, argv[i]);
7822 }
7823 buffer_putc (b, '\0');
7824
7825 regstr = buffer_getstr (b);
7826 buffer_free (b);
7827
7828 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00007829 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00007830 if (! regex)
7831 {
7832 vty_out (vty, "Can't compile regexp %s%s", argv[0],
7833 VTY_NEWLINE);
7834 return CMD_WARNING;
7835 }
7836
ajs5a646652004-11-05 01:25:55 +00007837 rc = bgp_show (vty, NULL, afi, safi, type, regex);
7838 bgp_regex_free (regex);
7839 return rc;
paul718e3742002-12-13 20:15:29 +00007840}
7841
Lou Bergerf9b6c392016-01-12 13:42:09 -05007842
7843DEFUN (show_ip_bgp_regexp,
7844 show_ip_bgp_regexp_cmd,
7845 "show ip bgp regexp .LINE",
7846 SHOW_STR
7847 IP_STR
7848 BGP_STR
7849 "Display routes matching the AS path regular expression\n"
7850 "A regular-expression to match the BGP AS paths\n")
7851{
7852 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7853 bgp_show_type_regexp);
7854}
7855
7856DEFUN (show_ip_bgp_flap_regexp,
7857 show_ip_bgp_flap_regexp_cmd,
7858 "show ip bgp flap-statistics regexp .LINE",
7859 SHOW_STR
7860 IP_STR
7861 BGP_STR
7862 "Display flap statistics of routes\n"
7863 "Display routes matching the AS path regular expression\n"
7864 "A regular-expression to match the BGP AS paths\n")
7865{
7866 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7867 bgp_show_type_flap_regexp);
7868}
7869
7870ALIAS (show_ip_bgp_flap_regexp,
7871 show_ip_bgp_damp_flap_regexp_cmd,
7872 "show ip bgp dampening flap-statistics regexp .LINE",
7873 SHOW_STR
7874 IP_STR
7875 BGP_STR
7876 "Display detailed information about dampening\n"
7877 "Display flap statistics of routes\n"
7878 "Display routes matching the AS path regular expression\n"
7879 "A regular-expression to match the BGP AS paths\n")
7880
7881DEFUN (show_ip_bgp_ipv4_regexp,
7882 show_ip_bgp_ipv4_regexp_cmd,
7883 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7884 SHOW_STR
7885 IP_STR
7886 BGP_STR
7887 "Address family\n"
7888 "Address Family modifier\n"
7889 "Address Family modifier\n"
7890 "Display routes matching the AS path regular expression\n"
7891 "A regular-expression to match the BGP AS paths\n")
7892{
7893 if (strncmp (argv[0], "m", 1) == 0)
7894 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
7895 bgp_show_type_regexp);
7896
7897 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7898 bgp_show_type_regexp);
7899}
7900
Lou Bergerf9b6c392016-01-12 13:42:09 -05007901DEFUN (show_bgp_regexp,
7902 show_bgp_regexp_cmd,
7903 "show bgp regexp .LINE",
7904 SHOW_STR
7905 BGP_STR
7906 "Display routes matching the AS path regular expression\n"
7907 "A regular-expression to match the BGP AS paths\n")
7908{
7909 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7910 bgp_show_type_regexp);
7911}
7912
7913/* old command */
7914DEFUN (show_ipv6_bgp_regexp,
7915 show_ipv6_bgp_regexp_cmd,
7916 "show ipv6 bgp regexp .LINE",
7917 SHOW_STR
7918 IP_STR
7919 BGP_STR
7920 "Display routes matching the AS path regular expression\n"
7921 "A regular-expression to match the BGP AS paths\n")
7922{
7923 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7924 bgp_show_type_regexp);
7925}
7926
7927/* old command */
7928DEFUN (show_ipv6_mbgp_regexp,
7929 show_ipv6_mbgp_regexp_cmd,
7930 "show ipv6 mbgp regexp .LINE",
7931 SHOW_STR
7932 IP_STR
7933 BGP_STR
7934 "Display routes matching the AS path regular expression\n"
7935 "A regular-expression to match the MBGP AS paths\n")
7936{
7937 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
7938 bgp_show_type_regexp);
7939}
Lou Bergerf9b6c392016-01-12 13:42:09 -05007940
Lou Berger651b4022016-01-12 13:42:07 -05007941DEFUN (show_bgp_ipv4_safi_flap_regexp,
7942 show_bgp_ipv4_safi_flap_regexp_cmd,
7943 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00007944 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007945 BGP_STR
paul718e3742002-12-13 20:15:29 +00007946 IP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007947 "Address Family Modifier\n"
7948 "Address Family Modifier\n"
7949 "Address Family Modifier\n"
7950 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007951 "Display flap statistics of routes\n"
7952 "Display routes matching the AS path regular expression\n"
7953 "A regular-expression to match the BGP AS paths\n")
7954{
Lou Berger651b4022016-01-12 13:42:07 -05007955 safi_t safi;
7956
7957 if (bgp_parse_safi(argv[0], &safi)) {
7958 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7959 return CMD_WARNING;
7960 }
7961 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
7962 bgp_show_type_flap_regexp);
paul718e3742002-12-13 20:15:29 +00007963}
7964
Lou Berger651b4022016-01-12 13:42:07 -05007965ALIAS (show_bgp_ipv4_safi_flap_regexp,
7966 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
7967 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
Balaji3921cc52015-05-16 23:12:17 +05307968 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05307969 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007970 IP_STR
7971 "Address Family Modifier\n"
7972 "Address Family Modifier\n"
7973 "Address Family Modifier\n"
7974 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05307975 "Display detailed information about dampening\n"
7976 "Display flap statistics of routes\n"
7977 "Display routes matching the AS path regular expression\n"
7978 "A regular-expression to match the BGP AS paths\n")
7979
Lou Berger651b4022016-01-12 13:42:07 -05007980DEFUN (show_bgp_ipv6_safi_flap_regexp,
7981 show_bgp_ipv6_safi_flap_regexp_cmd,
7982 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00007983 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05007984 BGP_STR
7985 IPV6_STR
7986 "Address Family Modifier\n"
7987 "Address Family Modifier\n"
7988 "Address Family Modifier\n"
7989 "Address Family Modifier\n"
7990 "Display flap statistics of routes\n"
7991 "Display routes matching the AS path regular expression\n"
7992 "A regular-expression to match the BGP AS paths\n")
7993{
7994 safi_t safi;
7995
7996 if (bgp_parse_safi(argv[0], &safi)) {
7997 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7998 return CMD_WARNING;
7999 }
8000 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8001 bgp_show_type_flap_regexp);
8002}
8003
8004ALIAS (show_bgp_ipv6_safi_flap_regexp,
8005 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8006 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8007 SHOW_STR
8008 BGP_STR
8009 IPV6_STR
8010 "Address Family Modifier\n"
8011 "Address Family Modifier\n"
8012 "Address Family Modifier\n"
8013 "Address Family Modifier\n"
8014 "Display detailed information about dampening\n"
8015 "Display flap statistics of routes\n"
8016 "Display routes matching the AS path regular expression\n"
8017 "A regular-expression to match the BGP AS paths\n")
Lou Berger651b4022016-01-12 13:42:07 -05008018
8019DEFUN (show_bgp_ipv4_safi_regexp,
8020 show_bgp_ipv4_safi_regexp_cmd,
8021 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8022 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008023 BGP_STR
8024 "Address family\n"
8025 "Address Family modifier\n"
8026 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008027 "Address Family modifier\n"
8028 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008029 "Display routes matching the AS path regular expression\n"
8030 "A regular-expression to match the BGP AS paths\n")
8031{
Lou Berger651b4022016-01-12 13:42:07 -05008032 safi_t safi;
8033 if (bgp_parse_safi(argv[0], &safi)) {
8034 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8035 return CMD_WARNING;
8036 }
paul718e3742002-12-13 20:15:29 +00008037
Lou Berger651b4022016-01-12 13:42:07 -05008038 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008039 bgp_show_type_regexp);
8040}
Lou Berger205e6742016-01-12 13:42:11 -05008041
Lou Berger651b4022016-01-12 13:42:07 -05008042DEFUN (show_bgp_ipv6_safi_regexp,
8043 show_bgp_ipv6_safi_regexp_cmd,
8044 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008045 SHOW_STR
8046 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008047 "Address family\n"
8048 "Address Family modifier\n"
8049 "Address Family modifier\n"
8050 "Address Family modifier\n"
8051 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008052 "Display routes matching the AS path regular expression\n"
8053 "A regular-expression to match the BGP AS paths\n")
8054{
Lou Berger651b4022016-01-12 13:42:07 -05008055 safi_t safi;
8056 if (bgp_parse_safi(argv[0], &safi)) {
8057 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8058 return CMD_WARNING;
8059 }
8060
8061 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008062 bgp_show_type_regexp);
8063}
8064
Lou Berger651b4022016-01-12 13:42:07 -05008065DEFUN (show_bgp_ipv6_regexp,
paul718e3742002-12-13 20:15:29 +00008066 show_bgp_ipv6_regexp_cmd,
8067 "show bgp ipv6 regexp .LINE",
8068 SHOW_STR
8069 BGP_STR
8070 "Address family\n"
8071 "Display routes matching the AS path regular expression\n"
8072 "A regular-expression to match the BGP AS paths\n")
paul718e3742002-12-13 20:15:29 +00008073{
8074 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8075 bgp_show_type_regexp);
8076}
8077
paul94f2b392005-06-28 12:44:16 +00008078static int
paulfd79ac92004-10-13 05:06:08 +00008079bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008080 safi_t safi, enum bgp_show_type type)
8081{
8082 struct prefix_list *plist;
8083
8084 plist = prefix_list_lookup (afi, prefix_list_str);
8085 if (plist == NULL)
8086 {
8087 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8088 prefix_list_str, VTY_NEWLINE);
8089 return CMD_WARNING;
8090 }
8091
ajs5a646652004-11-05 01:25:55 +00008092 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00008093}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008094DEFUN (show_ip_bgp_prefix_list,
8095 show_ip_bgp_prefix_list_cmd,
8096 "show ip bgp prefix-list WORD",
8097 SHOW_STR
8098 IP_STR
8099 BGP_STR
8100 "Display routes conforming to the prefix-list\n"
8101 "IP prefix-list name\n")
8102{
8103 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8104 bgp_show_type_prefix_list);
8105}
8106
8107DEFUN (show_ip_bgp_flap_prefix_list,
8108 show_ip_bgp_flap_prefix_list_cmd,
8109 "show ip bgp flap-statistics prefix-list WORD",
8110 SHOW_STR
8111 IP_STR
8112 BGP_STR
8113 "Display flap statistics of routes\n"
8114 "Display routes conforming to the prefix-list\n"
8115 "IP prefix-list name\n")
8116{
8117 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8118 bgp_show_type_flap_prefix_list);
8119}
8120
8121ALIAS (show_ip_bgp_flap_prefix_list,
8122 show_ip_bgp_damp_flap_prefix_list_cmd,
8123 "show ip bgp dampening flap-statistics prefix-list WORD",
8124 SHOW_STR
8125 IP_STR
8126 BGP_STR
8127 "Display detailed information about dampening\n"
8128 "Display flap statistics of routes\n"
8129 "Display routes conforming to the prefix-list\n"
8130 "IP prefix-list name\n")
8131
8132DEFUN (show_ip_bgp_ipv4_prefix_list,
8133 show_ip_bgp_ipv4_prefix_list_cmd,
8134 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8135 SHOW_STR
8136 IP_STR
8137 BGP_STR
8138 "Address family\n"
8139 "Address Family modifier\n"
8140 "Address Family modifier\n"
8141 "Display routes conforming to the prefix-list\n"
8142 "IP prefix-list name\n")
8143{
8144 if (strncmp (argv[0], "m", 1) == 0)
8145 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8146 bgp_show_type_prefix_list);
8147
8148 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8149 bgp_show_type_prefix_list);
8150}
8151
Lou Bergerf9b6c392016-01-12 13:42:09 -05008152DEFUN (show_bgp_prefix_list,
8153 show_bgp_prefix_list_cmd,
8154 "show bgp prefix-list WORD",
8155 SHOW_STR
8156 BGP_STR
8157 "Display routes conforming to the prefix-list\n"
8158 "IPv6 prefix-list name\n")
8159{
8160 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8161 bgp_show_type_prefix_list);
8162}
8163
8164ALIAS (show_bgp_prefix_list,
8165 show_bgp_ipv6_prefix_list_cmd,
8166 "show bgp ipv6 prefix-list WORD",
8167 SHOW_STR
8168 BGP_STR
8169 "Address family\n"
8170 "Display routes conforming to the prefix-list\n"
8171 "IPv6 prefix-list name\n")
8172
8173/* old command */
8174DEFUN (show_ipv6_bgp_prefix_list,
8175 show_ipv6_bgp_prefix_list_cmd,
8176 "show ipv6 bgp prefix-list WORD",
8177 SHOW_STR
8178 IPV6_STR
8179 BGP_STR
8180 "Display routes matching the prefix-list\n"
8181 "IPv6 prefix-list name\n")
8182{
8183 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8184 bgp_show_type_prefix_list);
8185}
8186
8187/* old command */
8188DEFUN (show_ipv6_mbgp_prefix_list,
8189 show_ipv6_mbgp_prefix_list_cmd,
8190 "show ipv6 mbgp prefix-list WORD",
8191 SHOW_STR
8192 IPV6_STR
8193 MBGP_STR
8194 "Display routes matching the prefix-list\n"
8195 "IPv6 prefix-list name\n")
8196{
8197 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8198 bgp_show_type_prefix_list);
8199}
paul718e3742002-12-13 20:15:29 +00008200
Lou Berger35c36862016-01-12 13:42:06 -05008201DEFUN (show_bgp_ipv4_prefix_list,
8202 show_bgp_ipv4_prefix_list_cmd,
8203 "show bgp ipv4 prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008204 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008205 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05008206 IP_STR
paul718e3742002-12-13 20:15:29 +00008207 "Display routes conforming to the prefix-list\n"
8208 "IP prefix-list name\n")
8209{
8210 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8211 bgp_show_type_prefix_list);
8212}
8213
Lou Berger651b4022016-01-12 13:42:07 -05008214DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8215 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8216 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008217 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008218 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008219 IP_STR
8220 "Address Family Modifier\n"
8221 "Address Family Modifier\n"
8222 "Address Family Modifier\n"
8223 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008224 "Display flap statistics of routes\n"
8225 "Display routes conforming to the prefix-list\n"
8226 "IP prefix-list name\n")
8227{
Lou Berger651b4022016-01-12 13:42:07 -05008228 safi_t safi;
8229 if (bgp_parse_safi(argv[0], &safi)) {
8230 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8231 return CMD_WARNING;
8232 }
8233 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008234 bgp_show_type_flap_prefix_list);
8235}
8236
Lou Berger651b4022016-01-12 13:42:07 -05008237ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8238 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8239 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308240 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308241 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008242 IP_STR
8243 "Address Family Modifier\n"
8244 "Address Family Modifier\n"
8245 "Address Family Modifier\n"
8246 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308247 "Display detailed information about dampening\n"
8248 "Display flap statistics of routes\n"
8249 "Display routes conforming to the prefix-list\n"
8250 "IP prefix-list name\n")
8251
Lou Berger651b4022016-01-12 13:42:07 -05008252DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8253 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8254 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008255 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008256 BGP_STR
8257 IPV6_STR
8258 "Address Family Modifier\n"
8259 "Address Family Modifier\n"
8260 "Address Family Modifier\n"
8261 "Address Family Modifier\n"
8262 "Display flap statistics of routes\n"
8263 "Display routes conforming to the prefix-list\n"
8264 "IP prefix-list name\n")
8265{
8266 safi_t safi;
8267 if (bgp_parse_safi(argv[0], &safi)) {
8268 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8269 return CMD_WARNING;
8270 }
8271 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8272 bgp_show_type_flap_prefix_list);
8273}
8274ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8275 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8276 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8277 SHOW_STR
8278 BGP_STR
8279 IPV6_STR
8280 "Address Family Modifier\n"
8281 "Address Family Modifier\n"
8282 "Address Family Modifier\n"
8283 "Address Family Modifier\n"
8284 "Display detailed information about dampening\n"
8285 "Display flap statistics of routes\n"
8286 "Display routes conforming to the prefix-list\n"
8287 "IP prefix-list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008288
8289DEFUN (show_bgp_ipv4_safi_prefix_list,
8290 show_bgp_ipv4_safi_prefix_list_cmd,
8291 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8292 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008293 BGP_STR
8294 "Address family\n"
8295 "Address Family modifier\n"
8296 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008297 "Address Family modifier\n"
8298 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008299 "Display routes conforming to the prefix-list\n"
8300 "IP prefix-list name\n")
8301{
Lou Berger651b4022016-01-12 13:42:07 -05008302 safi_t safi;
8303 if (bgp_parse_safi(argv[0], &safi)) {
8304 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8305 return CMD_WARNING;
8306 }
8307 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008308 bgp_show_type_prefix_list);
8309}
Lou Berger205e6742016-01-12 13:42:11 -05008310
Lou Berger651b4022016-01-12 13:42:07 -05008311DEFUN (show_bgp_ipv6_safi_prefix_list,
8312 show_bgp_ipv6_safi_prefix_list_cmd,
8313 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008314 SHOW_STR
8315 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008316 "Address family\n"
8317 "Address Family modifier\n"
8318 "Address Family modifier\n"
8319 "Address Family modifier\n"
8320 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008321 "Display routes conforming to the prefix-list\n"
Lou Berger651b4022016-01-12 13:42:07 -05008322 "IP prefix-list name\n")
paul718e3742002-12-13 20:15:29 +00008323{
Lou Berger651b4022016-01-12 13:42:07 -05008324 safi_t safi;
8325 if (bgp_parse_safi(argv[0], &safi)) {
8326 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8327 return CMD_WARNING;
8328 }
8329 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008330 bgp_show_type_prefix_list);
8331}
8332
paul94f2b392005-06-28 12:44:16 +00008333static int
paulfd79ac92004-10-13 05:06:08 +00008334bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008335 safi_t safi, enum bgp_show_type type)
8336{
8337 struct as_list *as_list;
8338
8339 as_list = as_list_lookup (filter);
8340 if (as_list == NULL)
8341 {
8342 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8343 return CMD_WARNING;
8344 }
8345
ajs5a646652004-11-05 01:25:55 +00008346 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00008347}
8348
Lou Bergerf9b6c392016-01-12 13:42:09 -05008349DEFUN (show_ip_bgp_filter_list,
8350 show_ip_bgp_filter_list_cmd,
8351 "show ip bgp filter-list WORD",
8352 SHOW_STR
8353 IP_STR
8354 BGP_STR
8355 "Display routes conforming to the filter-list\n"
8356 "Regular expression access list name\n")
8357{
8358 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8359 bgp_show_type_filter_list);
8360}
8361
8362DEFUN (show_ip_bgp_flap_filter_list,
8363 show_ip_bgp_flap_filter_list_cmd,
8364 "show ip bgp flap-statistics filter-list WORD",
8365 SHOW_STR
8366 IP_STR
8367 BGP_STR
8368 "Display flap statistics of routes\n"
8369 "Display routes conforming to the filter-list\n"
8370 "Regular expression access list name\n")
8371{
8372 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8373 bgp_show_type_flap_filter_list);
8374}
8375
8376ALIAS (show_ip_bgp_flap_filter_list,
8377 show_ip_bgp_damp_flap_filter_list_cmd,
8378 "show ip bgp dampening flap-statistics filter-list WORD",
8379 SHOW_STR
8380 IP_STR
8381 BGP_STR
8382 "Display detailed information about dampening\n"
8383 "Display flap statistics of routes\n"
8384 "Display routes conforming to the filter-list\n"
8385 "Regular expression access list name\n")
8386
8387DEFUN (show_ip_bgp_ipv4_filter_list,
8388 show_ip_bgp_ipv4_filter_list_cmd,
8389 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8390 SHOW_STR
8391 IP_STR
8392 BGP_STR
8393 "Address family\n"
8394 "Address Family modifier\n"
8395 "Address Family modifier\n"
8396 "Display routes conforming to the filter-list\n"
8397 "Regular expression access list name\n")
8398{
8399 if (strncmp (argv[0], "m", 1) == 0)
8400 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8401 bgp_show_type_filter_list);
8402
8403 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8404 bgp_show_type_filter_list);
8405}
8406
Lou Bergerf9b6c392016-01-12 13:42:09 -05008407DEFUN (show_bgp_filter_list,
8408 show_bgp_filter_list_cmd,
8409 "show bgp filter-list WORD",
8410 SHOW_STR
8411 BGP_STR
8412 "Display routes conforming to the filter-list\n"
8413 "Regular expression access list name\n")
8414{
8415 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8416 bgp_show_type_filter_list);
8417}
8418
8419/* old command */
8420DEFUN (show_ipv6_bgp_filter_list,
8421 show_ipv6_bgp_filter_list_cmd,
8422 "show ipv6 bgp filter-list WORD",
8423 SHOW_STR
8424 IPV6_STR
8425 BGP_STR
8426 "Display routes conforming to the filter-list\n"
8427 "Regular expression access list name\n")
8428{
8429 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8430 bgp_show_type_filter_list);
8431}
8432
8433/* old command */
8434DEFUN (show_ipv6_mbgp_filter_list,
8435 show_ipv6_mbgp_filter_list_cmd,
8436 "show ipv6 mbgp filter-list WORD",
8437 SHOW_STR
8438 IPV6_STR
8439 MBGP_STR
8440 "Display routes conforming to the filter-list\n"
8441 "Regular expression access list name\n")
8442{
8443 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8444 bgp_show_type_filter_list);
8445}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008446
8447DEFUN (show_ip_bgp_dampening_info,
8448 show_ip_bgp_dampening_params_cmd,
8449 "show ip bgp dampening parameters",
8450 SHOW_STR
8451 IP_STR
8452 BGP_STR
8453 "Display detailed information about dampening\n"
8454 "Display detail of configured dampening parameters\n")
8455{
8456 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8457}
8458
Lou Berger651b4022016-01-12 13:42:07 -05008459DEFUN (show_bgp_ipv4_filter_list,
8460 show_bgp_ipv4_filter_list_cmd,
8461 "show bgp ipv4 filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008462 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008463 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008464 IP_STR
paul718e3742002-12-13 20:15:29 +00008465 "Display routes conforming to the filter-list\n"
8466 "Regular expression access list name\n")
8467{
8468 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8469 bgp_show_type_filter_list);
8470}
8471
Lou Berger651b4022016-01-12 13:42:07 -05008472DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8473 show_bgp_ipv4_safi_flap_filter_list_cmd,
8474 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008475 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008476 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008477 IP_STR
8478 "Address Family modifier\n"
8479 "Address Family modifier\n"
8480 "Address Family modifier\n"
8481 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008482 "Display flap statistics of routes\n"
8483 "Display routes conforming to the filter-list\n"
8484 "Regular expression access list name\n")
8485{
Lou Berger651b4022016-01-12 13:42:07 -05008486 safi_t safi;
8487
8488 if (bgp_parse_safi(argv[0], &safi)) {
8489 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8490 return CMD_WARNING;
8491 }
8492 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008493 bgp_show_type_flap_filter_list);
8494}
8495
Lou Berger651b4022016-01-12 13:42:07 -05008496ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8497 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8498 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308499 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308500 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008501 IP_STR
8502 "Address Family modifier\n"
8503 "Address Family modifier\n"
8504 "Address Family modifier\n"
8505 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308506 "Display detailed information about dampening\n"
8507 "Display flap statistics of routes\n"
8508 "Display routes conforming to the filter-list\n"
8509 "Regular expression access list name\n")
8510
Lou Berger651b4022016-01-12 13:42:07 -05008511DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8512 show_bgp_ipv6_safi_flap_filter_list_cmd,
8513 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008514 SHOW_STR
8515 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008516 IPV6_STR
8517 "Address Family modifier\n"
8518 "Address Family modifier\n"
8519 "Address Family modifier\n"
8520 "Address Family modifier\n"
8521 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +00008522 "Display routes conforming to the filter-list\n"
8523 "Regular expression access list name\n")
8524{
Lou Berger651b4022016-01-12 13:42:07 -05008525 safi_t safi;
8526
8527 if (bgp_parse_safi(argv[0], &safi)) {
8528 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8529 return CMD_WARNING;
8530 }
8531 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8532 bgp_show_type_flap_filter_list);
8533}
8534ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8535 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8536 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8537 SHOW_STR
8538 BGP_STR
8539 IPV6_STR
8540 "Address Family modifier\n"
8541 "Address Family modifier\n"
8542 "Address Family modifier\n"
8543 "Address Family modifier\n"
8544 "Display detailed information about dampening\n"
8545 "Display flap statistics of routes\n"
8546 "Display routes conforming to the filter-list\n"
8547 "Regular expression access list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008548
8549DEFUN (show_bgp_ipv4_safi_filter_list,
8550 show_bgp_ipv4_safi_filter_list_cmd,
8551 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8552 SHOW_STR
8553 BGP_STR
8554 "Address Family modifier\n"
8555 "Address Family modifier\n"
8556 "Address Family modifier\n"
8557 "Address Family modifier\n"
8558 "Display routes conforming to the filter-list\n"
8559 "Regular expression access list name\n")
8560{
8561 safi_t safi;
8562
8563 if (bgp_parse_safi(argv[0], &safi)) {
8564 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8565 return CMD_WARNING;
8566 }
8567 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8568 bgp_show_type_filter_list);
8569}
Lou Berger205e6742016-01-12 13:42:11 -05008570
Lou Berger651b4022016-01-12 13:42:07 -05008571DEFUN (show_bgp_ipv6_safi_filter_list,
8572 show_bgp_ipv6_safi_filter_list_cmd,
8573 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8574 SHOW_STR
8575 BGP_STR
8576 "Address Family modifier\n"
8577 "Address Family modifier\n"
8578 "Address Family modifier\n"
8579 "Address Family modifier\n"
8580 "Display routes conforming to the filter-list\n"
8581 "Regular expression access list name\n")
8582{
8583 safi_t safi;
8584
8585 if (bgp_parse_safi(argv[0], &safi)) {
8586 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8587 return CMD_WARNING;
8588 }
8589 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8590 bgp_show_type_filter_list);
paul718e3742002-12-13 20:15:29 +00008591}
8592
Lou Bergerf9b6c392016-01-12 13:42:09 -05008593DEFUN (show_bgp_ipv6_filter_list,
paul718e3742002-12-13 20:15:29 +00008594 show_bgp_ipv6_filter_list_cmd,
8595 "show bgp ipv6 filter-list WORD",
8596 SHOW_STR
8597 BGP_STR
8598 "Address family\n"
8599 "Display routes conforming to the filter-list\n"
8600 "Regular expression access list name\n")
paul718e3742002-12-13 20:15:29 +00008601{
8602 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8603 bgp_show_type_filter_list);
8604}
8605
paul94f2b392005-06-28 12:44:16 +00008606static int
paulfd79ac92004-10-13 05:06:08 +00008607bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008608 safi_t safi, enum bgp_show_type type)
8609{
8610 struct route_map *rmap;
8611
8612 rmap = route_map_lookup_by_name (rmap_str);
8613 if (! rmap)
8614 {
8615 vty_out (vty, "%% %s is not a valid route-map name%s",
8616 rmap_str, VTY_NEWLINE);
8617 return CMD_WARNING;
8618 }
8619
ajs5a646652004-11-05 01:25:55 +00008620 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00008621}
8622
Lou Bergerf9b6c392016-01-12 13:42:09 -05008623DEFUN (show_ip_bgp_route_map,
8624 show_ip_bgp_route_map_cmd,
8625 "show ip bgp route-map WORD",
8626 SHOW_STR
8627 IP_STR
8628 BGP_STR
8629 "Display routes matching the route-map\n"
8630 "A route-map to match on\n")
8631{
8632 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8633 bgp_show_type_route_map);
8634}
8635
8636DEFUN (show_ip_bgp_flap_route_map,
8637 show_ip_bgp_flap_route_map_cmd,
8638 "show ip bgp flap-statistics route-map WORD",
8639 SHOW_STR
8640 IP_STR
8641 BGP_STR
8642 "Display flap statistics of routes\n"
8643 "Display routes matching the route-map\n"
8644 "A route-map to match on\n")
8645{
8646 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8647 bgp_show_type_flap_route_map);
8648}
8649
8650ALIAS (show_ip_bgp_flap_route_map,
8651 show_ip_bgp_damp_flap_route_map_cmd,
8652 "show ip bgp dampening flap-statistics route-map WORD",
8653 SHOW_STR
8654 IP_STR
8655 BGP_STR
8656 "Display detailed information about dampening\n"
8657 "Display flap statistics of routes\n"
8658 "Display routes matching the route-map\n"
8659 "A route-map to match on\n")
8660
8661DEFUN (show_ip_bgp_ipv4_route_map,
8662 show_ip_bgp_ipv4_route_map_cmd,
8663 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
8664 SHOW_STR
8665 IP_STR
8666 BGP_STR
8667 "Address family\n"
8668 "Address Family modifier\n"
8669 "Address Family modifier\n"
8670 "Display routes matching the route-map\n"
8671 "A route-map to match on\n")
8672{
8673 if (strncmp (argv[0], "m", 1) == 0)
8674 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8675 bgp_show_type_route_map);
8676
8677 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
8678 bgp_show_type_route_map);
8679}
8680
8681DEFUN (show_bgp_route_map,
8682 show_bgp_route_map_cmd,
8683 "show bgp route-map WORD",
8684 SHOW_STR
8685 BGP_STR
8686 "Display routes matching the route-map\n"
8687 "A route-map to match on\n")
8688{
8689 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8690 bgp_show_type_route_map);
8691}
8692
8693DEFUN (show_ip_bgp_cidr_only,
8694 show_ip_bgp_cidr_only_cmd,
8695 "show ip bgp cidr-only",
8696 SHOW_STR
8697 IP_STR
8698 BGP_STR
8699 "Display only routes with non-natural netmasks\n")
8700{
8701 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8702 bgp_show_type_cidr_only, NULL);
8703}
8704
8705DEFUN (show_ip_bgp_flap_cidr_only,
8706 show_ip_bgp_flap_cidr_only_cmd,
8707 "show ip bgp flap-statistics cidr-only",
8708 SHOW_STR
8709 IP_STR
8710 BGP_STR
8711 "Display flap statistics of routes\n"
8712 "Display only routes with non-natural netmasks\n")
8713{
8714 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8715 bgp_show_type_flap_cidr_only, NULL);
8716}
8717
8718ALIAS (show_ip_bgp_flap_cidr_only,
8719 show_ip_bgp_damp_flap_cidr_only_cmd,
8720 "show ip bgp dampening flap-statistics cidr-only",
8721 SHOW_STR
8722 IP_STR
8723 BGP_STR
8724 "Display detailed information about dampening\n"
8725 "Display flap statistics of routes\n"
8726 "Display only routes with non-natural netmasks\n")
8727
8728DEFUN (show_ip_bgp_ipv4_cidr_only,
8729 show_ip_bgp_ipv4_cidr_only_cmd,
8730 "show ip bgp ipv4 (unicast|multicast) cidr-only",
8731 SHOW_STR
8732 IP_STR
8733 BGP_STR
8734 "Address family\n"
8735 "Address Family modifier\n"
8736 "Address Family modifier\n"
8737 "Display only routes with non-natural netmasks\n")
8738{
8739 if (strncmp (argv[0], "m", 1) == 0)
8740 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8741 bgp_show_type_cidr_only, NULL);
8742
8743 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8744 bgp_show_type_cidr_only, NULL);
8745}
8746
8747DEFUN (show_ip_bgp_community_all,
8748 show_ip_bgp_community_all_cmd,
8749 "show ip bgp community",
8750 SHOW_STR
8751 IP_STR
8752 BGP_STR
8753 "Display routes matching the communities\n")
8754{
8755 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8756 bgp_show_type_community_all, NULL);
8757}
8758
8759DEFUN (show_ip_bgp_ipv4_community_all,
8760 show_ip_bgp_ipv4_community_all_cmd,
8761 "show ip bgp ipv4 (unicast|multicast) community",
8762 SHOW_STR
8763 IP_STR
8764 BGP_STR
8765 "Address family\n"
8766 "Address Family modifier\n"
8767 "Address Family modifier\n"
8768 "Display routes matching the communities\n")
8769{
8770 if (strncmp (argv[0], "m", 1) == 0)
8771 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8772 bgp_show_type_community_all, NULL);
8773
8774 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8775 bgp_show_type_community_all, NULL);
8776}
8777
Lou Bergerf9b6c392016-01-12 13:42:09 -05008778DEFUN (show_bgp_community_all,
8779 show_bgp_community_all_cmd,
8780 "show bgp community",
8781 SHOW_STR
8782 BGP_STR
8783 "Display routes matching the communities\n")
8784{
8785 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8786 bgp_show_type_community_all, NULL);
8787}
8788
8789ALIAS (show_bgp_community_all,
8790 show_bgp_ipv6_community_all_cmd,
8791 "show bgp ipv6 community",
8792 SHOW_STR
8793 BGP_STR
8794 "Address family\n"
8795 "Display routes matching the communities\n")
8796
8797/* old command */
8798DEFUN (show_ipv6_bgp_community_all,
8799 show_ipv6_bgp_community_all_cmd,
8800 "show ipv6 bgp community",
8801 SHOW_STR
8802 IPV6_STR
8803 BGP_STR
8804 "Display routes matching the communities\n")
8805{
8806 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8807 bgp_show_type_community_all, NULL);
8808}
8809
8810/* old command */
8811DEFUN (show_ipv6_mbgp_community_all,
8812 show_ipv6_mbgp_community_all_cmd,
8813 "show ipv6 mbgp community",
8814 SHOW_STR
8815 IPV6_STR
8816 MBGP_STR
8817 "Display routes matching the communities\n")
8818{
8819 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
8820 bgp_show_type_community_all, NULL);
8821}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008822
Lou Berger651b4022016-01-12 13:42:07 -05008823DEFUN (show_bgp_ipv4_route_map,
8824 show_bgp_ipv4_route_map_cmd,
8825 "show bgp ipv4 route-map WORD",
paul718e3742002-12-13 20:15:29 +00008826 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008827 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008828 IP_STR
paul718e3742002-12-13 20:15:29 +00008829 "Display routes matching the route-map\n"
8830 "A route-map to match on\n")
8831{
8832 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8833 bgp_show_type_route_map);
8834}
8835
Lou Berger651b4022016-01-12 13:42:07 -05008836DEFUN (show_bgp_ipv4_safi_flap_route_map,
8837 show_bgp_ipv4_safi_flap_route_map_cmd,
8838 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008839 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008840 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008841 IP_STR
8842 "Address Family Modifier\n"
8843 "Address Family Modifier\n"
8844 "Address Family Modifier\n"
8845 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008846 "Display flap statistics of routes\n"
8847 "Display routes matching the route-map\n"
8848 "A route-map to match on\n")
8849{
Lou Berger651b4022016-01-12 13:42:07 -05008850 safi_t safi;
8851 if (bgp_parse_safi(argv[0], &safi)) {
8852 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8853 return CMD_WARNING;
8854 }
8855 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008856 bgp_show_type_flap_route_map);
8857}
8858
Lou Berger651b4022016-01-12 13:42:07 -05008859ALIAS (show_bgp_ipv4_safi_flap_route_map,
8860 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
8861 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
Balaji3921cc52015-05-16 23:12:17 +05308862 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308863 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008864 IP_STR
8865 "Address Family Modifier\n"
8866 "Address Family Modifier\n"
8867 "Address Family Modifier\n"
8868 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308869 "Display detailed information about dampening\n"
8870 "Display flap statistics of routes\n"
8871 "Display routes matching the route-map\n"
8872 "A route-map to match on\n")
Lou Berger205e6742016-01-12 13:42:11 -05008873
Lou Berger651b4022016-01-12 13:42:07 -05008874DEFUN (show_bgp_ipv6_safi_flap_route_map,
8875 show_bgp_ipv6_safi_flap_route_map_cmd,
8876 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008877 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008878 BGP_STR
8879 IPV6_STR
8880 "Address Family Modifier\n"
8881 "Address Family Modifier\n"
8882 "Address Family Modifier\n"
8883 "Address Family Modifier\n"
8884 "Display flap statistics of routes\n"
8885 "Display routes matching the route-map\n"
8886 "A route-map to match on\n")
8887{
8888 safi_t safi;
8889 if (bgp_parse_safi(argv[0], &safi)) {
8890 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8891 return CMD_WARNING;
8892 }
8893 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
8894 bgp_show_type_flap_route_map);
8895}
8896ALIAS (show_bgp_ipv6_safi_flap_route_map,
8897 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
8898 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
8899 SHOW_STR
8900 BGP_STR
8901 IPV6_STR
8902 "Address Family Modifier\n"
8903 "Address Family Modifier\n"
8904 "Address Family Modifier\n"
8905 "Address Family Modifier\n"
8906 "Display detailed information about dampening\n"
8907 "Display flap statistics of routes\n"
8908 "Display routes matching the route-map\n"
8909 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05008910
8911DEFUN (show_bgp_ipv4_safi_route_map,
8912 show_bgp_ipv4_safi_route_map_cmd,
8913 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
8914 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008915 BGP_STR
8916 "Address family\n"
8917 "Address Family modifier\n"
8918 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008919 "Address Family modifier\n"
8920 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008921 "Display routes matching the route-map\n"
8922 "A route-map to match on\n")
8923{
Lou Berger651b4022016-01-12 13:42:07 -05008924 safi_t safi;
8925 if (bgp_parse_safi(argv[0], &safi)) {
8926 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8927 return CMD_WARNING;
8928 }
8929 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008930 bgp_show_type_route_map);
8931}
Lou Berger205e6742016-01-12 13:42:11 -05008932
Lou Berger651b4022016-01-12 13:42:07 -05008933DEFUN (show_bgp_ipv6_safi_route_map,
8934 show_bgp_ipv6_safi_route_map_cmd,
8935 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
paul718e3742002-12-13 20:15:29 +00008936 SHOW_STR
8937 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008938 "Address family\n"
8939 "Address Family modifier\n"
8940 "Address Family modifier\n"
8941 "Address Family modifier\n"
8942 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008943 "Display routes matching the route-map\n"
8944 "A route-map to match on\n")
8945{
Lou Berger651b4022016-01-12 13:42:07 -05008946 safi_t safi;
8947 if (bgp_parse_safi(argv[0], &safi)) {
8948 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8949 return CMD_WARNING;
8950 }
8951 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008952 bgp_show_type_route_map);
8953}
8954
Lou Berger651b4022016-01-12 13:42:07 -05008955DEFUN (show_bgp_ipv6_route_map,
paul718e3742002-12-13 20:15:29 +00008956 show_bgp_ipv6_route_map_cmd,
8957 "show bgp ipv6 route-map WORD",
8958 SHOW_STR
8959 BGP_STR
8960 "Address family\n"
8961 "Display routes matching the route-map\n"
8962 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05008963{
8964 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8965 bgp_show_type_route_map);
8966}
David Lamparter6b0655a2014-06-04 06:53:35 +02008967
Lou Berger651b4022016-01-12 13:42:07 -05008968DEFUN (show_bgp_ipv4_cidr_only,
8969 show_bgp_ipv4_cidr_only_cmd,
8970 "show bgp ipv4 cidr-only",
paul718e3742002-12-13 20:15:29 +00008971 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008972 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008973 IP_STR
paul718e3742002-12-13 20:15:29 +00008974 "Display only routes with non-natural netmasks\n")
8975{
8976 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00008977 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00008978}
8979
Lou Berger651b4022016-01-12 13:42:07 -05008980DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
8981 show_bgp_ipv4_safi_flap_cidr_only_cmd,
8982 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
paul718e3742002-12-13 20:15:29 +00008983 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008984 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008985 "Address Family\n"
8986 "Address Family Modifier\n"
8987 "Address Family Modifier\n"
8988 "Address Family Modifier\n"
8989 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008990 "Display flap statistics of routes\n"
8991 "Display only routes with non-natural netmasks\n")
8992{
Lou Berger651b4022016-01-12 13:42:07 -05008993 safi_t safi;
8994
8995 if (bgp_parse_safi(argv[0], &safi)) {
8996 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8997 return CMD_WARNING;
8998 }
8999 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009000}
9001
Lou Berger651b4022016-01-12 13:42:07 -05009002ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9003 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9004 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
Balaji3921cc52015-05-16 23:12:17 +05309005 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309006 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009007 "Address Family\n"
9008 "Address Family Modifier\n"
9009 "Address Family Modifier\n"
9010 "Address Family Modifier\n"
9011 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309012 "Display detailed information about dampening\n"
9013 "Display flap statistics of routes\n"
9014 "Display only routes with non-natural netmasks\n")
9015
Lou Berger651b4022016-01-12 13:42:07 -05009016DEFUN (show_bgp_ipv4_safi_cidr_only,
9017 show_bgp_ipv4_safi_cidr_only_cmd,
9018 "show bgp ipv4 (unicast|multicast) cidr-only",
paul718e3742002-12-13 20:15:29 +00009019 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009020 BGP_STR
9021 "Address family\n"
9022 "Address Family modifier\n"
9023 "Address Family modifier\n"
9024 "Display only routes with non-natural netmasks\n")
9025{
9026 if (strncmp (argv[0], "m", 1) == 0)
9027 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00009028 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009029
9030 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009031 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009032}
David Lamparter6b0655a2014-06-04 06:53:35 +02009033
Lou Berger651b4022016-01-12 13:42:07 -05009034/* new046 */
9035DEFUN (show_bgp_afi_safi_community_all,
9036 show_bgp_afi_safi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009037 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
paul718e3742002-12-13 20:15:29 +00009038 SHOW_STR
9039 BGP_STR
9040 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009041 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009042 "Address Family modifier\n"
9043 "Address Family modifier\n"
9044 "Address Family modifier\n"
9045 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009046 "Display routes matching the communities\n")
Lou Berger651b4022016-01-12 13:42:07 -05009047{
9048 safi_t safi;
9049 afi_t afi;
paul718e3742002-12-13 20:15:29 +00009050
Lou Berger651b4022016-01-12 13:42:07 -05009051 if (bgp_parse_afi(argv[0], &afi)) {
9052 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9053 return CMD_WARNING;
9054 }
9055 if (bgp_parse_safi(argv[1], &safi)) {
9056 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9057 return CMD_WARNING;
9058 }
9059
9060 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9061}
9062DEFUN (show_bgp_afi_community_all,
9063 show_bgp_afi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009064 "show bgp (ipv4|ipv6) community",
paul718e3742002-12-13 20:15:29 +00009065 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009066 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009067 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009068 "Address family\n"
paul718e3742002-12-13 20:15:29 +00009069 "Display routes matching the communities\n")
9070{
Lou Berger651b4022016-01-12 13:42:07 -05009071 afi_t afi;
9072 safi_t safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +00009073
Lou Berger651b4022016-01-12 13:42:07 -05009074 if (bgp_parse_afi(argv[0], &afi)) {
9075 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9076 return CMD_WARNING;
9077 }
9078 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00009079}
David Lamparter6b0655a2014-06-04 06:53:35 +02009080
paul94f2b392005-06-28 12:44:16 +00009081static int
Michael Lambert95cbbd22010-07-23 14:43:04 -04009082bgp_show_community (struct vty *vty, const char *view_name, int argc,
9083 const char **argv, int exact, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00009084{
9085 struct community *com;
9086 struct buffer *b;
Michael Lambert95cbbd22010-07-23 14:43:04 -04009087 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +00009088 int i;
9089 char *str;
9090 int first = 0;
9091
Michael Lambert95cbbd22010-07-23 14:43:04 -04009092 /* BGP structure lookup */
9093 if (view_name)
9094 {
9095 bgp = bgp_lookup_by_name (view_name);
9096 if (bgp == NULL)
9097 {
9098 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9099 return CMD_WARNING;
9100 }
9101 }
9102 else
9103 {
9104 bgp = bgp_get_default ();
9105 if (bgp == NULL)
9106 {
9107 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9108 return CMD_WARNING;
9109 }
9110 }
9111
paul718e3742002-12-13 20:15:29 +00009112 b = buffer_new (1024);
9113 for (i = 0; i < argc; i++)
9114 {
9115 if (first)
9116 buffer_putc (b, ' ');
9117 else
9118 {
9119 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9120 continue;
9121 first = 1;
9122 }
9123
9124 buffer_putstr (b, argv[i]);
9125 }
9126 buffer_putc (b, '\0');
9127
9128 str = buffer_getstr (b);
9129 buffer_free (b);
9130
9131 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00009132 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009133 if (! com)
9134 {
9135 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9136 return CMD_WARNING;
9137 }
9138
Michael Lambert95cbbd22010-07-23 14:43:04 -04009139 return bgp_show (vty, bgp, afi, safi,
ajs5a646652004-11-05 01:25:55 +00009140 (exact ? bgp_show_type_community_exact :
9141 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00009142}
9143
Lou Bergerf9b6c392016-01-12 13:42:09 -05009144DEFUN (show_ip_bgp_community,
9145 show_ip_bgp_community_cmd,
9146 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9147 SHOW_STR
9148 IP_STR
9149 BGP_STR
9150 "Display routes matching the communities\n"
9151 "community number\n"
9152 "Do not send outside local AS (well-known community)\n"
9153 "Do not advertise to any peer (well-known community)\n"
9154 "Do not export to next AS (well-known community)\n")
9155{
9156 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9157}
9158
9159ALIAS (show_ip_bgp_community,
9160 show_ip_bgp_community2_cmd,
9161 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9162 SHOW_STR
9163 IP_STR
9164 BGP_STR
9165 "Display routes matching the communities\n"
9166 "community number\n"
9167 "Do not send outside local AS (well-known community)\n"
9168 "Do not advertise to any peer (well-known community)\n"
9169 "Do not export to next AS (well-known community)\n"
9170 "community number\n"
9171 "Do not send outside local AS (well-known community)\n"
9172 "Do not advertise to any peer (well-known community)\n"
9173 "Do not export to next AS (well-known community)\n")
9174
9175ALIAS (show_ip_bgp_community,
9176 show_ip_bgp_community3_cmd,
9177 "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)",
9178 SHOW_STR
9179 IP_STR
9180 BGP_STR
9181 "Display routes matching the communities\n"
9182 "community number\n"
9183 "Do not send outside local AS (well-known community)\n"
9184 "Do not advertise to any peer (well-known community)\n"
9185 "Do not export to next AS (well-known community)\n"
9186 "community number\n"
9187 "Do not send outside local AS (well-known community)\n"
9188 "Do not advertise to any peer (well-known community)\n"
9189 "Do not export to next AS (well-known community)\n"
9190 "community number\n"
9191 "Do not send outside local AS (well-known community)\n"
9192 "Do not advertise to any peer (well-known community)\n"
9193 "Do not export to next AS (well-known community)\n")
9194
9195ALIAS (show_ip_bgp_community,
9196 show_ip_bgp_community4_cmd,
9197 "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)",
9198 SHOW_STR
9199 IP_STR
9200 BGP_STR
9201 "Display routes matching the communities\n"
9202 "community number\n"
9203 "Do not send outside local AS (well-known community)\n"
9204 "Do not advertise to any peer (well-known community)\n"
9205 "Do not export to next AS (well-known community)\n"
9206 "community number\n"
9207 "Do not send outside local AS (well-known community)\n"
9208 "Do not advertise to any peer (well-known community)\n"
9209 "Do not export to next AS (well-known community)\n"
9210 "community number\n"
9211 "Do not send outside local AS (well-known community)\n"
9212 "Do not advertise to any peer (well-known community)\n"
9213 "Do not export to next AS (well-known community)\n"
9214 "community number\n"
9215 "Do not send outside local AS (well-known community)\n"
9216 "Do not advertise to any peer (well-known community)\n"
9217 "Do not export to next AS (well-known community)\n")
9218
9219DEFUN (show_ip_bgp_ipv4_community,
9220 show_ip_bgp_ipv4_community_cmd,
9221 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9222 SHOW_STR
9223 IP_STR
9224 BGP_STR
9225 "Address family\n"
9226 "Address Family modifier\n"
9227 "Address Family modifier\n"
9228 "Display routes matching the communities\n"
9229 "community number\n"
9230 "Do not send outside local AS (well-known community)\n"
9231 "Do not advertise to any peer (well-known community)\n"
9232 "Do not export to next AS (well-known community)\n")
9233{
9234 if (strncmp (argv[0], "m", 1) == 0)
9235 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9236
9237 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9238}
9239
9240ALIAS (show_ip_bgp_ipv4_community,
9241 show_ip_bgp_ipv4_community2_cmd,
9242 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9243 SHOW_STR
9244 IP_STR
9245 BGP_STR
9246 "Address family\n"
9247 "Address Family modifier\n"
9248 "Address Family modifier\n"
9249 "Display routes matching the communities\n"
9250 "community number\n"
9251 "Do not send outside local AS (well-known community)\n"
9252 "Do not advertise to any peer (well-known community)\n"
9253 "Do not export to next AS (well-known community)\n"
9254 "community number\n"
9255 "Do not send outside local AS (well-known community)\n"
9256 "Do not advertise to any peer (well-known community)\n"
9257 "Do not export to next AS (well-known community)\n")
9258
9259ALIAS (show_ip_bgp_ipv4_community,
9260 show_ip_bgp_ipv4_community3_cmd,
9261 "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)",
9262 SHOW_STR
9263 IP_STR
9264 BGP_STR
9265 "Address family\n"
9266 "Address Family modifier\n"
9267 "Address Family modifier\n"
9268 "Display routes matching the communities\n"
9269 "community number\n"
9270 "Do not send outside local AS (well-known community)\n"
9271 "Do not advertise to any peer (well-known community)\n"
9272 "Do not export to next AS (well-known community)\n"
9273 "community number\n"
9274 "Do not send outside local AS (well-known community)\n"
9275 "Do not advertise to any peer (well-known community)\n"
9276 "Do not export to next AS (well-known community)\n"
9277 "community number\n"
9278 "Do not send outside local AS (well-known community)\n"
9279 "Do not advertise to any peer (well-known community)\n"
9280 "Do not export to next AS (well-known community)\n")
9281
9282ALIAS (show_ip_bgp_ipv4_community,
9283 show_ip_bgp_ipv4_community4_cmd,
9284 "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)",
9285 SHOW_STR
9286 IP_STR
9287 BGP_STR
9288 "Address family\n"
9289 "Address Family modifier\n"
9290 "Address Family modifier\n"
9291 "Display routes matching the communities\n"
9292 "community number\n"
9293 "Do not send outside local AS (well-known community)\n"
9294 "Do not advertise to any peer (well-known community)\n"
9295 "Do not export to next AS (well-known community)\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 "community number\n"
9305 "Do not send outside local AS (well-known community)\n"
9306 "Do not advertise to any peer (well-known community)\n"
9307 "Do not export to next AS (well-known community)\n")
9308
9309DEFUN (show_ip_bgp_community_exact,
9310 show_ip_bgp_community_exact_cmd,
9311 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9312 SHOW_STR
9313 IP_STR
9314 BGP_STR
9315 "Display routes matching the communities\n"
9316 "community number\n"
9317 "Do not send outside local AS (well-known community)\n"
9318 "Do not advertise to any peer (well-known community)\n"
9319 "Do not export to next AS (well-known community)\n"
9320 "Exact match of the communities")
9321{
9322 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9323}
9324
9325ALIAS (show_ip_bgp_community_exact,
9326 show_ip_bgp_community2_exact_cmd,
9327 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9328 SHOW_STR
9329 IP_STR
9330 BGP_STR
9331 "Display routes matching the communities\n"
9332 "community number\n"
9333 "Do not send outside local AS (well-known community)\n"
9334 "Do not advertise to any peer (well-known community)\n"
9335 "Do not export to next AS (well-known community)\n"
9336 "community number\n"
9337 "Do not send outside local AS (well-known community)\n"
9338 "Do not advertise to any peer (well-known community)\n"
9339 "Do not export to next AS (well-known community)\n"
9340 "Exact match of the communities")
9341
9342ALIAS (show_ip_bgp_community_exact,
9343 show_ip_bgp_community3_exact_cmd,
9344 "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",
9345 SHOW_STR
9346 IP_STR
9347 BGP_STR
9348 "Display routes matching the communities\n"
9349 "community number\n"
9350 "Do not send outside local AS (well-known community)\n"
9351 "Do not advertise to any peer (well-known community)\n"
9352 "Do not export to next AS (well-known community)\n"
9353 "community number\n"
9354 "Do not send outside local AS (well-known community)\n"
9355 "Do not advertise to any peer (well-known community)\n"
9356 "Do not export to next AS (well-known community)\n"
9357 "community number\n"
9358 "Do not send outside local AS (well-known community)\n"
9359 "Do not advertise to any peer (well-known community)\n"
9360 "Do not export to next AS (well-known community)\n"
9361 "Exact match of the communities")
9362
9363ALIAS (show_ip_bgp_community_exact,
9364 show_ip_bgp_community4_exact_cmd,
9365 "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",
9366 SHOW_STR
9367 IP_STR
9368 BGP_STR
9369 "Display routes matching the communities\n"
9370 "community number\n"
9371 "Do not send outside local AS (well-known community)\n"
9372 "Do not advertise to any peer (well-known community)\n"
9373 "Do not export to next AS (well-known community)\n"
9374 "community number\n"
9375 "Do not send outside local AS (well-known community)\n"
9376 "Do not advertise to any peer (well-known community)\n"
9377 "Do not export to next AS (well-known community)\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
9388DEFUN (show_ip_bgp_ipv4_community_exact,
9389 show_ip_bgp_ipv4_community_exact_cmd,
9390 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9391 SHOW_STR
9392 IP_STR
9393 BGP_STR
9394 "Address family\n"
9395 "Address Family modifier\n"
9396 "Address Family modifier\n"
9397 "Display routes matching the communities\n"
9398 "community number\n"
9399 "Do not send outside local AS (well-known community)\n"
9400 "Do not advertise to any peer (well-known community)\n"
9401 "Do not export to next AS (well-known community)\n"
9402 "Exact match of the communities")
9403{
9404 if (strncmp (argv[0], "m", 1) == 0)
9405 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9406
9407 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9408}
9409
9410ALIAS (show_ip_bgp_ipv4_community_exact,
9411 show_ip_bgp_ipv4_community2_exact_cmd,
9412 "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",
9413 SHOW_STR
9414 IP_STR
9415 BGP_STR
9416 "Address family\n"
9417 "Address Family modifier\n"
9418 "Address Family modifier\n"
9419 "Display routes matching the communities\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 "Exact match of the communities")
9429
9430ALIAS (show_ip_bgp_ipv4_community_exact,
9431 show_ip_bgp_ipv4_community3_exact_cmd,
9432 "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",
9433 SHOW_STR
9434 IP_STR
9435 BGP_STR
9436 "Address family\n"
9437 "Address Family modifier\n"
9438 "Address Family modifier\n"
9439 "Display routes matching the communities\n"
9440 "community number\n"
9441 "Do not send outside local AS (well-known community)\n"
9442 "Do not advertise to any peer (well-known community)\n"
9443 "Do not export to next AS (well-known community)\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 "community number\n"
9449 "Do not send outside local AS (well-known community)\n"
9450 "Do not advertise to any peer (well-known community)\n"
9451 "Do not export to next AS (well-known community)\n"
9452 "Exact match of the communities")
9453
9454ALIAS (show_ip_bgp_ipv4_community_exact,
9455 show_ip_bgp_ipv4_community4_exact_cmd,
9456 "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",
9457 SHOW_STR
9458 IP_STR
9459 BGP_STR
9460 "Address family\n"
9461 "Address Family modifier\n"
9462 "Address Family modifier\n"
9463 "Display routes matching the communities\n"
9464 "community number\n"
9465 "Do not send outside local AS (well-known community)\n"
9466 "Do not advertise to any peer (well-known community)\n"
9467 "Do not export to next AS (well-known community)\n"
9468 "community number\n"
9469 "Do not send outside local AS (well-known community)\n"
9470 "Do not advertise to any peer (well-known community)\n"
9471 "Do not export to next AS (well-known community)\n"
9472 "community number\n"
9473 "Do not send outside local AS (well-known community)\n"
9474 "Do not advertise to any peer (well-known community)\n"
9475 "Do not export to next AS (well-known community)\n"
9476 "community number\n"
9477 "Do not send outside local AS (well-known community)\n"
9478 "Do not advertise to any peer (well-known community)\n"
9479 "Do not export to next AS (well-known community)\n"
9480 "Exact match of the communities")
9481
Lou Bergerf9b6c392016-01-12 13:42:09 -05009482DEFUN (show_bgp_community,
9483 show_bgp_community_cmd,
9484 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9485 SHOW_STR
9486 BGP_STR
9487 "Display routes matching the communities\n"
9488 "community number\n"
9489 "Do not send outside local AS (well-known community)\n"
9490 "Do not advertise to any peer (well-known community)\n"
9491 "Do not export to next AS (well-known community)\n")
9492{
9493 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9494}
9495
9496ALIAS (show_bgp_community,
9497 show_bgp_ipv6_community_cmd,
9498 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9499 SHOW_STR
9500 BGP_STR
9501 "Address family\n"
9502 "Display routes matching the communities\n"
9503 "community number\n"
9504 "Do not send outside local AS (well-known community)\n"
9505 "Do not advertise to any peer (well-known community)\n"
9506 "Do not export to next AS (well-known community)\n")
9507
9508ALIAS (show_bgp_community,
9509 show_bgp_community2_cmd,
9510 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9511 SHOW_STR
9512 BGP_STR
9513 "Display routes matching the communities\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
9523ALIAS (show_bgp_community,
9524 show_bgp_ipv6_community2_cmd,
9525 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9526 SHOW_STR
9527 BGP_STR
9528 "Address family\n"
9529 "Display routes matching the communities\n"
9530 "community number\n"
9531 "Do not send outside local AS (well-known community)\n"
9532 "Do not advertise to any peer (well-known community)\n"
9533 "Do not export to next AS (well-known community)\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
9539ALIAS (show_bgp_community,
9540 show_bgp_community3_cmd,
9541 "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)",
9542 SHOW_STR
9543 BGP_STR
9544 "Display routes matching the communities\n"
9545 "community number\n"
9546 "Do not send outside local AS (well-known community)\n"
9547 "Do not advertise to any peer (well-known community)\n"
9548 "Do not export to next AS (well-known community)\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 "community number\n"
9554 "Do not send outside local AS (well-known community)\n"
9555 "Do not advertise to any peer (well-known community)\n"
9556 "Do not export to next AS (well-known community)\n")
9557
9558ALIAS (show_bgp_community,
9559 show_bgp_ipv6_community3_cmd,
9560 "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)",
9561 SHOW_STR
9562 BGP_STR
9563 "Address family\n"
9564 "Display routes matching the communities\n"
9565 "community number\n"
9566 "Do not send outside local AS (well-known community)\n"
9567 "Do not advertise to any peer (well-known community)\n"
9568 "Do not export to next AS (well-known community)\n"
9569 "community number\n"
9570 "Do not send outside local AS (well-known community)\n"
9571 "Do not advertise to any peer (well-known community)\n"
9572 "Do not export to next AS (well-known community)\n"
9573 "community number\n"
9574 "Do not send outside local AS (well-known community)\n"
9575 "Do not advertise to any peer (well-known community)\n"
9576 "Do not export to next AS (well-known community)\n")
9577
9578ALIAS (show_bgp_community,
9579 show_bgp_community4_cmd,
9580 "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)",
9581 SHOW_STR
9582 BGP_STR
9583 "Display routes matching the communities\n"
9584 "community number\n"
9585 "Do not send outside local AS (well-known community)\n"
9586 "Do not advertise to any peer (well-known community)\n"
9587 "Do not export to next AS (well-known community)\n"
9588 "community number\n"
9589 "Do not send outside local AS (well-known community)\n"
9590 "Do not advertise to any peer (well-known community)\n"
9591 "Do not export to next AS (well-known community)\n"
9592 "community number\n"
9593 "Do not send outside local AS (well-known community)\n"
9594 "Do not advertise to any peer (well-known community)\n"
9595 "Do not export to next AS (well-known community)\n"
9596 "community number\n"
9597 "Do not send outside local AS (well-known community)\n"
9598 "Do not advertise to any peer (well-known community)\n"
9599 "Do not export to next AS (well-known community)\n")
9600
9601ALIAS (show_bgp_community,
9602 show_bgp_ipv6_community4_cmd,
9603 "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)",
9604 SHOW_STR
9605 BGP_STR
9606 "Address family\n"
9607 "Display routes matching the communities\n"
9608 "community number\n"
9609 "Do not send outside local AS (well-known community)\n"
9610 "Do not advertise to any peer (well-known community)\n"
9611 "Do not export to next AS (well-known community)\n"
9612 "community number\n"
9613 "Do not send outside local AS (well-known community)\n"
9614 "Do not advertise to any peer (well-known community)\n"
9615 "Do not export to next AS (well-known community)\n"
9616 "community number\n"
9617 "Do not send outside local AS (well-known community)\n"
9618 "Do not advertise to any peer (well-known community)\n"
9619 "Do not export to next AS (well-known community)\n"
9620 "community number\n"
9621 "Do not send outside local AS (well-known community)\n"
9622 "Do not advertise to any peer (well-known community)\n"
9623 "Do not export to next AS (well-known community)\n")
9624
9625/* old command */
9626DEFUN (show_ipv6_bgp_community,
9627 show_ipv6_bgp_community_cmd,
9628 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9629 SHOW_STR
9630 IPV6_STR
9631 BGP_STR
9632 "Display routes matching the communities\n"
9633 "community number\n"
9634 "Do not send outside local AS (well-known community)\n"
9635 "Do not advertise to any peer (well-known community)\n"
9636 "Do not export to next AS (well-known community)\n")
9637{
9638 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9639}
9640
9641/* old command */
9642ALIAS (show_ipv6_bgp_community,
9643 show_ipv6_bgp_community2_cmd,
9644 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9645 SHOW_STR
9646 IPV6_STR
9647 BGP_STR
9648 "Display routes matching the communities\n"
9649 "community number\n"
9650 "Do not send outside local AS (well-known community)\n"
9651 "Do not advertise to any peer (well-known community)\n"
9652 "Do not export to next AS (well-known community)\n"
9653 "community number\n"
9654 "Do not send outside local AS (well-known community)\n"
9655 "Do not advertise to any peer (well-known community)\n"
9656 "Do not export to next AS (well-known community)\n")
9657
9658/* old command */
9659ALIAS (show_ipv6_bgp_community,
9660 show_ipv6_bgp_community3_cmd,
9661 "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)",
9662 SHOW_STR
9663 IPV6_STR
9664 BGP_STR
9665 "Display routes matching the communities\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 "community number\n"
9671 "Do not send outside local AS (well-known community)\n"
9672 "Do not advertise to any peer (well-known community)\n"
9673 "Do not export to next AS (well-known community)\n"
9674 "community number\n"
9675 "Do not send outside local AS (well-known community)\n"
9676 "Do not advertise to any peer (well-known community)\n"
9677 "Do not export to next AS (well-known community)\n")
9678
9679/* old command */
9680ALIAS (show_ipv6_bgp_community,
9681 show_ipv6_bgp_community4_cmd,
9682 "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)",
9683 SHOW_STR
9684 IPV6_STR
9685 BGP_STR
9686 "Display routes matching the communities\n"
9687 "community number\n"
9688 "Do not send outside local AS (well-known community)\n"
9689 "Do not advertise to any peer (well-known community)\n"
9690 "Do not export to next AS (well-known community)\n"
9691 "community number\n"
9692 "Do not send outside local AS (well-known community)\n"
9693 "Do not advertise to any peer (well-known community)\n"
9694 "Do not export to next AS (well-known community)\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
9704DEFUN (show_bgp_community_exact,
9705 show_bgp_community_exact_cmd,
9706 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9707 SHOW_STR
9708 BGP_STR
9709 "Display routes matching the communities\n"
9710 "community number\n"
9711 "Do not send outside local AS (well-known community)\n"
9712 "Do not advertise to any peer (well-known community)\n"
9713 "Do not export to next AS (well-known community)\n"
9714 "Exact match of the communities")
9715{
9716 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9717}
9718
9719ALIAS (show_bgp_community_exact,
9720 show_bgp_ipv6_community_exact_cmd,
9721 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9722 SHOW_STR
9723 BGP_STR
9724 "Address family\n"
9725 "Display routes matching the communities\n"
9726 "community number\n"
9727 "Do not send outside local AS (well-known community)\n"
9728 "Do not advertise to any peer (well-known community)\n"
9729 "Do not export to next AS (well-known community)\n"
9730 "Exact match of the communities")
9731
9732ALIAS (show_bgp_community_exact,
9733 show_bgp_community2_exact_cmd,
9734 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9735 SHOW_STR
9736 BGP_STR
9737 "Display routes matching the communities\n"
9738 "community number\n"
9739 "Do not send outside local AS (well-known community)\n"
9740 "Do not advertise to any peer (well-known community)\n"
9741 "Do not export to next AS (well-known community)\n"
9742 "community number\n"
9743 "Do not send outside local AS (well-known community)\n"
9744 "Do not advertise to any peer (well-known community)\n"
9745 "Do not export to next AS (well-known community)\n"
9746 "Exact match of the communities")
9747
9748ALIAS (show_bgp_community_exact,
9749 show_bgp_ipv6_community2_exact_cmd,
9750 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9751 SHOW_STR
9752 BGP_STR
9753 "Address family\n"
9754 "Display routes matching the communities\n"
9755 "community number\n"
9756 "Do not send outside local AS (well-known community)\n"
9757 "Do not advertise to any peer (well-known community)\n"
9758 "Do not export to next AS (well-known community)\n"
9759 "community number\n"
9760 "Do not send outside local AS (well-known community)\n"
9761 "Do not advertise to any peer (well-known community)\n"
9762 "Do not export to next AS (well-known community)\n"
9763 "Exact match of the communities")
9764
9765ALIAS (show_bgp_community_exact,
9766 show_bgp_community3_exact_cmd,
9767 "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",
9768 SHOW_STR
9769 BGP_STR
9770 "Display routes matching the communities\n"
9771 "community number\n"
9772 "Do not send outside local AS (well-known community)\n"
9773 "Do not advertise to any peer (well-known community)\n"
9774 "Do not export to next AS (well-known community)\n"
9775 "community number\n"
9776 "Do not send outside local AS (well-known community)\n"
9777 "Do not advertise to any peer (well-known community)\n"
9778 "Do not export to next AS (well-known community)\n"
9779 "community number\n"
9780 "Do not send outside local AS (well-known community)\n"
9781 "Do not advertise to any peer (well-known community)\n"
9782 "Do not export to next AS (well-known community)\n"
9783 "Exact match of the communities")
9784
9785ALIAS (show_bgp_community_exact,
9786 show_bgp_ipv6_community3_exact_cmd,
9787 "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",
9788 SHOW_STR
9789 BGP_STR
9790 "Address family\n"
9791 "Display routes matching the communities\n"
9792 "community number\n"
9793 "Do not send outside local AS (well-known community)\n"
9794 "Do not advertise to any peer (well-known community)\n"
9795 "Do not export to next AS (well-known community)\n"
9796 "community number\n"
9797 "Do not send outside local AS (well-known community)\n"
9798 "Do not advertise to any peer (well-known community)\n"
9799 "Do not export to next AS (well-known community)\n"
9800 "community number\n"
9801 "Do not send outside local AS (well-known community)\n"
9802 "Do not advertise to any peer (well-known community)\n"
9803 "Do not export to next AS (well-known community)\n"
9804 "Exact match of the communities")
9805
9806ALIAS (show_bgp_community_exact,
9807 show_bgp_community4_exact_cmd,
9808 "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",
9809 SHOW_STR
9810 BGP_STR
9811 "Display routes matching the communities\n"
9812 "community number\n"
9813 "Do not send outside local AS (well-known community)\n"
9814 "Do not advertise to any peer (well-known community)\n"
9815 "Do not export to next AS (well-known community)\n"
9816 "community number\n"
9817 "Do not send outside local AS (well-known community)\n"
9818 "Do not advertise to any peer (well-known community)\n"
9819 "Do not export to next AS (well-known community)\n"
9820 "community number\n"
9821 "Do not send outside local AS (well-known community)\n"
9822 "Do not advertise to any peer (well-known community)\n"
9823 "Do not export to next AS (well-known community)\n"
9824 "community number\n"
9825 "Do not send outside local AS (well-known community)\n"
9826 "Do not advertise to any peer (well-known community)\n"
9827 "Do not export to next AS (well-known community)\n"
9828 "Exact match of the communities")
9829
9830ALIAS (show_bgp_community_exact,
9831 show_bgp_ipv6_community4_exact_cmd,
9832 "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",
9833 SHOW_STR
9834 BGP_STR
9835 "Address family\n"
9836 "Display routes matching the communities\n"
9837 "community number\n"
9838 "Do not send outside local AS (well-known community)\n"
9839 "Do not advertise to any peer (well-known community)\n"
9840 "Do not export to next AS (well-known community)\n"
9841 "community number\n"
9842 "Do not send outside local AS (well-known community)\n"
9843 "Do not advertise to any peer (well-known community)\n"
9844 "Do not export to next AS (well-known community)\n"
9845 "community number\n"
9846 "Do not send outside local AS (well-known community)\n"
9847 "Do not advertise to any peer (well-known community)\n"
9848 "Do not export to next AS (well-known community)\n"
9849 "community number\n"
9850 "Do not send outside local AS (well-known community)\n"
9851 "Do not advertise to any peer (well-known community)\n"
9852 "Do not export to next AS (well-known community)\n"
9853 "Exact match of the communities")
9854
9855/* old command */
9856DEFUN (show_ipv6_bgp_community_exact,
9857 show_ipv6_bgp_community_exact_cmd,
9858 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9859 SHOW_STR
9860 IPV6_STR
9861 BGP_STR
9862 "Display routes matching the communities\n"
9863 "community number\n"
9864 "Do not send outside local AS (well-known community)\n"
9865 "Do not advertise to any peer (well-known community)\n"
9866 "Do not export to next AS (well-known community)\n"
9867 "Exact match of the communities")
9868{
9869 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9870}
9871
9872/* old command */
9873ALIAS (show_ipv6_bgp_community_exact,
9874 show_ipv6_bgp_community2_exact_cmd,
9875 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9876 SHOW_STR
9877 IPV6_STR
9878 BGP_STR
9879 "Display routes matching the communities\n"
9880 "community number\n"
9881 "Do not send outside local AS (well-known community)\n"
9882 "Do not advertise to any peer (well-known community)\n"
9883 "Do not export to next AS (well-known community)\n"
9884 "community number\n"
9885 "Do not send outside local AS (well-known community)\n"
9886 "Do not advertise to any peer (well-known community)\n"
9887 "Do not export to next AS (well-known community)\n"
9888 "Exact match of the communities")
9889
9890/* old command */
9891ALIAS (show_ipv6_bgp_community_exact,
9892 show_ipv6_bgp_community3_exact_cmd,
9893 "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",
9894 SHOW_STR
9895 IPV6_STR
9896 BGP_STR
9897 "Display routes matching the communities\n"
9898 "community number\n"
9899 "Do not send outside local AS (well-known community)\n"
9900 "Do not advertise to any peer (well-known community)\n"
9901 "Do not export to next AS (well-known community)\n"
9902 "community number\n"
9903 "Do not send outside local AS (well-known community)\n"
9904 "Do not advertise to any peer (well-known community)\n"
9905 "Do not export to next AS (well-known community)\n"
9906 "community number\n"
9907 "Do not send outside local AS (well-known community)\n"
9908 "Do not advertise to any peer (well-known community)\n"
9909 "Do not export to next AS (well-known community)\n"
9910 "Exact match of the communities")
9911
9912/* old command */
9913ALIAS (show_ipv6_bgp_community_exact,
9914 show_ipv6_bgp_community4_exact_cmd,
9915 "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",
9916 SHOW_STR
9917 IPV6_STR
9918 BGP_STR
9919 "Display routes matching the communities\n"
9920 "community number\n"
9921 "Do not send outside local AS (well-known community)\n"
9922 "Do not advertise to any peer (well-known community)\n"
9923 "Do not export to next AS (well-known community)\n"
9924 "community number\n"
9925 "Do not send outside local AS (well-known community)\n"
9926 "Do not advertise to any peer (well-known community)\n"
9927 "Do not export to next AS (well-known community)\n"
9928 "community number\n"
9929 "Do not send outside local AS (well-known community)\n"
9930 "Do not advertise to any peer (well-known community)\n"
9931 "Do not export to next AS (well-known community)\n"
9932 "community number\n"
9933 "Do not send outside local AS (well-known community)\n"
9934 "Do not advertise to any peer (well-known community)\n"
9935 "Do not export to next AS (well-known community)\n"
9936 "Exact match of the communities")
9937
9938/* old command */
9939DEFUN (show_ipv6_mbgp_community,
9940 show_ipv6_mbgp_community_cmd,
9941 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
9942 SHOW_STR
9943 IPV6_STR
9944 MBGP_STR
9945 "Display routes matching the communities\n"
9946 "community number\n"
9947 "Do not send outside local AS (well-known community)\n"
9948 "Do not advertise to any peer (well-known community)\n"
9949 "Do not export to next AS (well-known community)\n")
9950{
9951 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
9952}
9953
9954/* old command */
9955ALIAS (show_ipv6_mbgp_community,
9956 show_ipv6_mbgp_community2_cmd,
9957 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9958 SHOW_STR
9959 IPV6_STR
9960 MBGP_STR
9961 "Display routes matching the communities\n"
9962 "community number\n"
9963 "Do not send outside local AS (well-known community)\n"
9964 "Do not advertise to any peer (well-known community)\n"
9965 "Do not export to next AS (well-known community)\n"
9966 "community number\n"
9967 "Do not send outside local AS (well-known community)\n"
9968 "Do not advertise to any peer (well-known community)\n"
9969 "Do not export to next AS (well-known community)\n")
9970
9971/* old command */
9972ALIAS (show_ipv6_mbgp_community,
9973 show_ipv6_mbgp_community3_cmd,
9974 "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)",
9975 SHOW_STR
9976 IPV6_STR
9977 MBGP_STR
9978 "Display routes matching the communities\n"
9979 "community number\n"
9980 "Do not send outside local AS (well-known community)\n"
9981 "Do not advertise to any peer (well-known community)\n"
9982 "Do not export to next AS (well-known community)\n"
9983 "community number\n"
9984 "Do not send outside local AS (well-known community)\n"
9985 "Do not advertise to any peer (well-known community)\n"
9986 "Do not export to next AS (well-known community)\n"
9987 "community number\n"
9988 "Do not send outside local AS (well-known community)\n"
9989 "Do not advertise to any peer (well-known community)\n"
9990 "Do not export to next AS (well-known community)\n")
9991
9992/* old command */
9993ALIAS (show_ipv6_mbgp_community,
9994 show_ipv6_mbgp_community4_cmd,
9995 "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)",
9996 SHOW_STR
9997 IPV6_STR
9998 MBGP_STR
9999 "Display routes matching the communities\n"
10000 "community number\n"
10001 "Do not send outside local AS (well-known community)\n"
10002 "Do not advertise to any peer (well-known community)\n"
10003 "Do not export to next AS (well-known community)\n"
10004 "community number\n"
10005 "Do not send outside local AS (well-known community)\n"
10006 "Do not advertise to any peer (well-known community)\n"
10007 "Do not export to next AS (well-known community)\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 */
10018DEFUN (show_ipv6_mbgp_community_exact,
10019 show_ipv6_mbgp_community_exact_cmd,
10020 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
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 "Exact match of the communities")
10030{
10031 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10032}
10033
10034/* old command */
10035ALIAS (show_ipv6_mbgp_community_exact,
10036 show_ipv6_mbgp_community2_exact_cmd,
10037 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10038 SHOW_STR
10039 IPV6_STR
10040 MBGP_STR
10041 "Display routes matching the communities\n"
10042 "community number\n"
10043 "Do not send outside local AS (well-known community)\n"
10044 "Do not advertise to any peer (well-known community)\n"
10045 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
10051
10052/* old command */
10053ALIAS (show_ipv6_mbgp_community_exact,
10054 show_ipv6_mbgp_community3_exact_cmd,
10055 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10056 SHOW_STR
10057 IPV6_STR
10058 MBGP_STR
10059 "Display routes matching the communities\n"
10060 "community number\n"
10061 "Do not send outside local AS (well-known community)\n"
10062 "Do not advertise to any peer (well-known community)\n"
10063 "Do not export to next AS (well-known community)\n"
10064 "community number\n"
10065 "Do not send outside local AS (well-known community)\n"
10066 "Do not advertise to any peer (well-known community)\n"
10067 "Do not export to next AS (well-known community)\n"
10068 "community number\n"
10069 "Do not send outside local AS (well-known community)\n"
10070 "Do not advertise to any peer (well-known community)\n"
10071 "Do not export to next AS (well-known community)\n"
10072 "Exact match of the communities")
10073
10074/* old command */
10075ALIAS (show_ipv6_mbgp_community_exact,
10076 show_ipv6_mbgp_community4_exact_cmd,
10077 "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",
10078 SHOW_STR
10079 IPV6_STR
10080 MBGP_STR
10081 "Display routes matching the communities\n"
10082 "community number\n"
10083 "Do not send outside local AS (well-known community)\n"
10084 "Do not advertise to any peer (well-known community)\n"
10085 "Do not export to next AS (well-known community)\n"
10086 "community number\n"
10087 "Do not send outside local AS (well-known community)\n"
10088 "Do not advertise to any peer (well-known community)\n"
10089 "Do not export to next AS (well-known community)\n"
10090 "community number\n"
10091 "Do not send outside local AS (well-known community)\n"
10092 "Do not advertise to any peer (well-known community)\n"
10093 "Do not export to next AS (well-known community)\n"
10094 "community number\n"
10095 "Do not send outside local AS (well-known community)\n"
10096 "Do not advertise to any peer (well-known community)\n"
10097 "Do not export to next AS (well-known community)\n"
10098 "Exact match of the communities")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010099
Lou Berger651b4022016-01-12 13:42:07 -050010100DEFUN (show_bgp_ipv4_community,
10101 show_bgp_ipv4_community_cmd,
10102 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010103 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010104 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010105 IP_STR
paul718e3742002-12-13 20:15:29 +000010106 "Display routes matching the communities\n"
10107 "community number\n"
10108 "Do not send outside local AS (well-known community)\n"
10109 "Do not advertise to any peer (well-known community)\n"
10110 "Do not export to next AS (well-known community)\n")
10111{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010112 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010113}
10114
Lou Berger651b4022016-01-12 13:42:07 -050010115ALIAS (show_bgp_ipv4_community,
10116 show_bgp_ipv4_community2_cmd,
10117 "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 +000010118 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010119 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010120 IP_STR
paul718e3742002-12-13 20:15:29 +000010121 "Display routes matching the communities\n"
10122 "community number\n"
10123 "Do not send outside local AS (well-known community)\n"
10124 "Do not advertise to any peer (well-known community)\n"
10125 "Do not export to next AS (well-known community)\n"
10126 "community number\n"
10127 "Do not send outside local AS (well-known community)\n"
10128 "Do not advertise to any peer (well-known community)\n"
10129 "Do not export to next AS (well-known community)\n")
10130
Lou Berger651b4022016-01-12 13:42:07 -050010131ALIAS (show_bgp_ipv4_community,
10132 show_bgp_ipv4_community3_cmd,
10133 "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 +000010134 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010135 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010136 IP_STR
paul718e3742002-12-13 20:15:29 +000010137 "Display routes matching the communities\n"
10138 "community number\n"
10139 "Do not send outside local AS (well-known community)\n"
10140 "Do not advertise to any peer (well-known community)\n"
10141 "Do not export to next AS (well-known community)\n"
10142 "community number\n"
10143 "Do not send outside local AS (well-known community)\n"
10144 "Do not advertise to any peer (well-known community)\n"
10145 "Do not export to next AS (well-known community)\n"
10146 "community number\n"
10147 "Do not send outside local AS (well-known community)\n"
10148 "Do not advertise to any peer (well-known community)\n"
10149 "Do not export to next AS (well-known community)\n")
10150
Lou Berger651b4022016-01-12 13:42:07 -050010151ALIAS (show_bgp_ipv4_community,
10152 show_bgp_ipv4_community4_cmd,
10153 "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 +000010154 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010155 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010156 IP_STR
paul718e3742002-12-13 20:15:29 +000010157 "Display routes matching the communities\n"
10158 "community number\n"
10159 "Do not send outside local AS (well-known community)\n"
10160 "Do not advertise to any peer (well-known community)\n"
10161 "Do not export to next AS (well-known community)\n"
10162 "community number\n"
10163 "Do not send outside local AS (well-known community)\n"
10164 "Do not advertise to any peer (well-known community)\n"
10165 "Do not export to next AS (well-known community)\n"
10166 "community number\n"
10167 "Do not send outside local AS (well-known community)\n"
10168 "Do not advertise to any peer (well-known community)\n"
10169 "Do not export to next AS (well-known community)\n"
10170 "community number\n"
10171 "Do not send outside local AS (well-known community)\n"
10172 "Do not advertise to any peer (well-known community)\n"
10173 "Do not export to next AS (well-known community)\n")
10174
Lou Berger651b4022016-01-12 13:42:07 -050010175DEFUN (show_bgp_ipv4_safi_community,
10176 show_bgp_ipv4_safi_community_cmd,
10177 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010178 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010179 BGP_STR
10180 "Address family\n"
10181 "Address Family modifier\n"
10182 "Address Family modifier\n"
10183 "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{
10189 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010190 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010191
Michael Lambert95cbbd22010-07-23 14:43:04 -040010192 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010193}
10194
Lou Berger651b4022016-01-12 13:42:07 -050010195ALIAS (show_bgp_ipv4_safi_community,
10196 show_bgp_ipv4_safi_community2_cmd,
10197 "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 +000010198 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010199 BGP_STR
10200 "Address family\n"
10201 "Address Family modifier\n"
10202 "Address Family modifier\n"
10203 "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
Lou Berger651b4022016-01-12 13:42:07 -050010213ALIAS (show_bgp_ipv4_safi_community,
10214 show_bgp_ipv4_safi_community3_cmd,
10215 "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 +000010216 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010217 BGP_STR
10218 "Address family\n"
10219 "Address Family modifier\n"
10220 "Address Family modifier\n"
10221 "Display routes matching the communities\n"
10222 "community number\n"
10223 "Do not send outside local AS (well-known community)\n"
10224 "Do not advertise to any peer (well-known community)\n"
10225 "Do not export to next AS (well-known community)\n"
10226 "community number\n"
10227 "Do not send outside local AS (well-known community)\n"
10228 "Do not advertise to any peer (well-known community)\n"
10229 "Do not export to next AS (well-known community)\n"
10230 "community number\n"
10231 "Do not send outside local AS (well-known community)\n"
10232 "Do not advertise to any peer (well-known community)\n"
10233 "Do not export to next AS (well-known community)\n")
10234
Lou Berger651b4022016-01-12 13:42:07 -050010235ALIAS (show_bgp_ipv4_safi_community,
10236 show_bgp_ipv4_safi_community4_cmd,
10237 "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 +000010238 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010239 BGP_STR
10240 "Address family\n"
10241 "Address Family modifier\n"
10242 "Address Family modifier\n"
10243 "Display routes matching the communities\n"
10244 "community number\n"
10245 "Do not send outside local AS (well-known community)\n"
10246 "Do not advertise to any peer (well-known community)\n"
10247 "Do not export to next AS (well-known community)\n"
10248 "community number\n"
10249 "Do not send outside local AS (well-known community)\n"
10250 "Do not advertise to any peer (well-known community)\n"
10251 "Do not export to next AS (well-known community)\n"
10252 "community number\n"
10253 "Do not send outside local AS (well-known community)\n"
10254 "Do not advertise to any peer (well-known community)\n"
10255 "Do not export to next AS (well-known community)\n"
10256 "community number\n"
10257 "Do not send outside local AS (well-known community)\n"
10258 "Do not advertise to any peer (well-known community)\n"
10259 "Do not export to next AS (well-known community)\n")
10260
Michael Lambert95cbbd22010-07-23 14:43:04 -040010261DEFUN (show_bgp_view_afi_safi_community_all,
10262 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010263 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010264 SHOW_STR
10265 BGP_STR
10266 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010267 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010268 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010269 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010270 "Address Family modifier\n"
10271 "Address Family modifier\n"
Christian Franke2b005152013-09-30 12:27:49 +000010272 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010273{
10274 int afi;
10275 int safi;
10276 struct bgp *bgp;
10277
10278 /* BGP structure lookup. */
10279 bgp = bgp_lookup_by_name (argv[0]);
10280 if (bgp == NULL)
10281 {
10282 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10283 return CMD_WARNING;
10284 }
10285
Michael Lambert95cbbd22010-07-23 14:43:04 -040010286 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10287 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010288 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10289}
10290
10291DEFUN (show_bgp_view_afi_safi_community,
10292 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010293 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010294 SHOW_STR
10295 BGP_STR
10296 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010297 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010298 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010299 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010300 "Address family modifier\n"
10301 "Address family modifier\n"
10302 "Display routes matching the communities\n"
10303 "community number\n"
10304 "Do not send outside local AS (well-known community)\n"
10305 "Do not advertise to any peer (well-known community)\n"
10306 "Do not export to next AS (well-known community)\n")
10307{
10308 int afi;
10309 int safi;
10310
Michael Lambert95cbbd22010-07-23 14:43:04 -040010311 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10312 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10313 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010314}
10315
10316ALIAS (show_bgp_view_afi_safi_community,
10317 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010318 "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 -040010319 SHOW_STR
10320 BGP_STR
10321 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010322 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010323 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010324 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010325 "Address family modifier\n"
10326 "Address family modifier\n"
10327 "Display routes matching the communities\n"
10328 "community number\n"
10329 "Do not send outside local AS (well-known community)\n"
10330 "Do not advertise to any peer (well-known community)\n"
10331 "Do not export to next AS (well-known community)\n"
10332 "community number\n"
10333 "Do not send outside local AS (well-known community)\n"
10334 "Do not advertise to any peer (well-known community)\n"
10335 "Do not export to next AS (well-known community)\n")
10336
10337ALIAS (show_bgp_view_afi_safi_community,
10338 show_bgp_view_afi_safi_community3_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) (AA:NN|local-AS|no-advertise|no-export) (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 "community number\n"
10354 "Do not send outside local AS (well-known community)\n"
10355 "Do not advertise to any peer (well-known community)\n"
10356 "Do not export to next AS (well-known community)\n"
10357 "community number\n"
10358 "Do not send outside local AS (well-known community)\n"
10359 "Do not advertise to any peer (well-known community)\n"
10360 "Do not export to next AS (well-known community)\n")
10361
10362ALIAS (show_bgp_view_afi_safi_community,
10363 show_bgp_view_afi_safi_community4_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) (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 "community number\n"
10383 "Do not send outside local AS (well-known community)\n"
10384 "Do not advertise to any peer (well-known community)\n"
10385 "Do not export to next AS (well-known community)\n"
10386 "community number\n"
10387 "Do not send outside local AS (well-known community)\n"
10388 "Do not advertise to any peer (well-known community)\n"
10389 "Do not export to next AS (well-known community)\n")
10390
Lou Berger651b4022016-01-12 13:42:07 -050010391DEFUN (show_bgp_ipv4_community_exact,
10392 show_bgp_ipv4_community_exact_cmd,
10393 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010394 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010395 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010396 IP_STR
paul718e3742002-12-13 20:15:29 +000010397 "Display routes matching the communities\n"
10398 "community number\n"
10399 "Do not send outside local AS (well-known community)\n"
10400 "Do not advertise to any peer (well-known community)\n"
10401 "Do not export to next AS (well-known community)\n"
10402 "Exact match of the communities")
10403{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010404 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010405}
10406
Lou Berger651b4022016-01-12 13:42:07 -050010407ALIAS (show_bgp_ipv4_community_exact,
10408 show_bgp_ipv4_community2_exact_cmd,
10409 "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 +000010410 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010411 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010412 IP_STR
paul718e3742002-12-13 20:15:29 +000010413 "Display routes matching the communities\n"
10414 "community number\n"
10415 "Do not send outside local AS (well-known community)\n"
10416 "Do not advertise to any peer (well-known community)\n"
10417 "Do not export to next AS (well-known community)\n"
10418 "community number\n"
10419 "Do not send outside local AS (well-known community)\n"
10420 "Do not advertise to any peer (well-known community)\n"
10421 "Do not export to next AS (well-known community)\n"
10422 "Exact match of the communities")
10423
Lou Berger651b4022016-01-12 13:42:07 -050010424ALIAS (show_bgp_ipv4_community_exact,
10425 show_bgp_ipv4_community3_exact_cmd,
10426 "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 +000010427 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010428 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010429 IP_STR
paul718e3742002-12-13 20:15:29 +000010430 "Display routes matching the communities\n"
10431 "community number\n"
10432 "Do not send outside local AS (well-known community)\n"
10433 "Do not advertise to any peer (well-known community)\n"
10434 "Do not export to next AS (well-known community)\n"
10435 "community number\n"
10436 "Do not send outside local AS (well-known community)\n"
10437 "Do not advertise to any peer (well-known community)\n"
10438 "Do not export to next AS (well-known community)\n"
10439 "community number\n"
10440 "Do not send outside local AS (well-known community)\n"
10441 "Do not advertise to any peer (well-known community)\n"
10442 "Do not export to next AS (well-known community)\n"
10443 "Exact match of the communities")
10444
Lou Berger651b4022016-01-12 13:42:07 -050010445ALIAS (show_bgp_ipv4_community_exact,
10446 show_bgp_ipv4_community4_exact_cmd,
10447 "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 +000010448 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010449 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010450 IP_STR
paul718e3742002-12-13 20:15:29 +000010451 "Display routes matching the communities\n"
10452 "community number\n"
10453 "Do not send outside local AS (well-known community)\n"
10454 "Do not advertise to any peer (well-known community)\n"
10455 "Do not export to next AS (well-known community)\n"
10456 "community number\n"
10457 "Do not send outside local AS (well-known community)\n"
10458 "Do not advertise to any peer (well-known community)\n"
10459 "Do not export to next AS (well-known community)\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 -050010470DEFUN (show_bgp_ipv4_safi_community4_exact,
10471 show_bgp_ipv4_safi_community_exact_cmd,
10472 "show bgp ipv4 (unicast|multicast) community (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
10475 "Address family\n"
10476 "Address Family modifier\n"
10477 "Address Family modifier\n"
10478 "Display routes matching the communities\n"
10479 "community number\n"
10480 "Do not send outside local AS (well-known community)\n"
10481 "Do not advertise to any peer (well-known community)\n"
10482 "Do not export to next AS (well-known community)\n"
10483 "Exact match of the communities")
10484{
10485 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010486 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010487
Michael Lambert95cbbd22010-07-23 14:43:04 -040010488 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010489}
10490
Lou Berger651b4022016-01-12 13:42:07 -050010491ALIAS (show_bgp_ipv4_safi_community4_exact,
10492 show_bgp_ipv4_safi_community2_exact_cmd,
10493 "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 +000010494 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010495 BGP_STR
10496 "Address family\n"
10497 "Address Family modifier\n"
10498 "Address Family modifier\n"
10499 "Display routes matching the communities\n"
10500 "community number\n"
10501 "Do not send outside local AS (well-known community)\n"
10502 "Do not advertise to any peer (well-known community)\n"
10503 "Do not export to next AS (well-known community)\n"
10504 "community number\n"
10505 "Do not send outside local AS (well-known community)\n"
10506 "Do not advertise to any peer (well-known community)\n"
10507 "Do not export to next AS (well-known community)\n"
10508 "Exact match of the communities")
10509
Lou Berger651b4022016-01-12 13:42:07 -050010510ALIAS (show_bgp_ipv4_safi_community4_exact,
10511 show_bgp_ipv4_safi_community3_exact_cmd,
10512 "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 +000010513 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010514 BGP_STR
10515 "Address family\n"
10516 "Address Family modifier\n"
10517 "Address Family modifier\n"
10518 "Display routes matching the communities\n"
10519 "community number\n"
10520 "Do not send outside local AS (well-known community)\n"
10521 "Do not advertise to any peer (well-known community)\n"
10522 "Do not export to next AS (well-known community)\n"
10523 "community number\n"
10524 "Do not send outside local AS (well-known community)\n"
10525 "Do not advertise to any peer (well-known community)\n"
10526 "Do not export to next AS (well-known community)\n"
10527 "community number\n"
10528 "Do not send outside local AS (well-known community)\n"
10529 "Do not advertise to any peer (well-known community)\n"
10530 "Do not export to next AS (well-known community)\n"
10531 "Exact match of the communities")
10532
Lou Berger651b4022016-01-12 13:42:07 -050010533ALIAS (show_bgp_ipv4_safi_community4_exact,
10534 show_bgp_ipv4_safi_community4_exact_cmd,
10535 "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 +000010536 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010537 BGP_STR
10538 "Address family\n"
10539 "Address Family modifier\n"
10540 "Address Family modifier\n"
10541 "Display routes matching the communities\n"
10542 "community number\n"
10543 "Do not send outside local AS (well-known community)\n"
10544 "Do not advertise to any peer (well-known community)\n"
10545 "Do not export to next AS (well-known community)\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 "community number\n"
10555 "Do not send outside local AS (well-known community)\n"
10556 "Do not advertise to any peer (well-known community)\n"
10557 "Do not export to next AS (well-known community)\n"
10558 "Exact match of the communities")
10559
Lou Bergerf9b6c392016-01-12 13:42:09 -050010560DEFUN (show_bgp_ipv6_safi_community,
10561 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010562 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010563 SHOW_STR
10564 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010565 "Address family\n"
10566 "Address family modifier\n"
10567 "Address family modifier\n"
10568 "Address family modifier\n"
10569 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010570 "Display routes matching the communities\n"
10571 "community number\n"
10572 "Do not send outside local AS (well-known community)\n"
10573 "Do not advertise to any peer (well-known community)\n"
10574 "Do not export to next AS (well-known community)\n")
10575{
Lou Berger651b4022016-01-12 13:42:07 -050010576 safi_t safi;
10577
10578 if (bgp_parse_safi(argv[0], &safi)) {
10579 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10580 return CMD_WARNING;
10581 }
10582 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010583}
10584
Lou Bergerf9b6c392016-01-12 13:42:09 -050010585ALIAS (show_bgp_ipv6_safi_community,
10586 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010587 "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 +000010588 SHOW_STR
10589 BGP_STR
10590 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010591 "Address family modifier\n"
10592 "Address family modifier\n"
10593 "Address family modifier\n"
10594 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010595 "Display routes matching the communities\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
Lou Bergerf9b6c392016-01-12 13:42:09 -050010605ALIAS (show_bgp_ipv6_safi_community,
10606 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010607 "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 +000010608 SHOW_STR
10609 BGP_STR
10610 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010611 "Address family modifier\n"
10612 "Address family modifier\n"
10613 "Address family modifier\n"
10614 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010615 "Display routes matching the communities\n"
10616 "community number\n"
10617 "Do not send outside local AS (well-known community)\n"
10618 "Do not advertise to any peer (well-known community)\n"
10619 "Do not export to next AS (well-known community)\n"
10620 "community number\n"
10621 "Do not send outside local AS (well-known community)\n"
10622 "Do not advertise to any peer (well-known community)\n"
10623 "Do not export to next AS (well-known community)\n"
10624 "community number\n"
10625 "Do not send outside local AS (well-known community)\n"
10626 "Do not advertise to any peer (well-known community)\n"
10627 "Do not export to next AS (well-known community)\n")
10628
Lou Bergerf9b6c392016-01-12 13:42:09 -050010629ALIAS (show_bgp_ipv6_safi_community,
10630 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010631 "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 +000010632 SHOW_STR
10633 BGP_STR
10634 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010635 "Address family modifier\n"
10636 "Address family modifier\n"
10637 "Address family modifier\n"
10638 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010639 "Display routes matching the communities\n"
10640 "community number\n"
10641 "Do not send outside local AS (well-known community)\n"
10642 "Do not advertise to any peer (well-known community)\n"
10643 "Do not export to next AS (well-known community)\n"
10644 "community number\n"
10645 "Do not send outside local AS (well-known community)\n"
10646 "Do not advertise to any peer (well-known community)\n"
10647 "Do not export to next AS (well-known community)\n"
10648 "community number\n"
10649 "Do not send outside local AS (well-known community)\n"
10650 "Do not advertise to any peer (well-known community)\n"
10651 "Do not export to next AS (well-known community)\n"
10652 "community number\n"
10653 "Do not send outside local AS (well-known community)\n"
10654 "Do not advertise to any peer (well-known community)\n"
10655 "Do not export to next AS (well-known community)\n")
10656
paul718e3742002-12-13 20:15:29 +000010657
Lou Bergerf9b6c392016-01-12 13:42:09 -050010658DEFUN (show_bgp_ipv6_safi_community_exact,
10659 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010660 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010661 SHOW_STR
10662 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010663 "Address family\n"
10664 "Address family modifier\n"
10665 "Address family modifier\n"
10666 "Address family modifier\n"
10667 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010668 "Display routes matching the communities\n"
10669 "community number\n"
10670 "Do not send outside local AS (well-known community)\n"
10671 "Do not advertise to any peer (well-known community)\n"
10672 "Do not export to next AS (well-known community)\n"
10673 "Exact match of the communities")
10674{
Lou Berger651b4022016-01-12 13:42:07 -050010675 safi_t safi;
10676
10677 if (bgp_parse_safi(argv[0], &safi)) {
10678 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10679 return CMD_WARNING;
10680 }
10681 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010682}
10683
paul718e3742002-12-13 20:15:29 +000010684
10685ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010686 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010687 "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 +000010688 SHOW_STR
10689 BGP_STR
10690 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010691 "Address family modifier\n"
10692 "Address family modifier\n"
10693 "Address family modifier\n"
10694 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010695 "Display routes matching the communities\n"
10696 "community number\n"
10697 "Do not send outside local AS (well-known community)\n"
10698 "Do not advertise to any peer (well-known community)\n"
10699 "Do not export to next AS (well-known community)\n"
10700 "community number\n"
10701 "Do not send outside local AS (well-known community)\n"
10702 "Do not advertise to any peer (well-known community)\n"
10703 "Do not export to next AS (well-known community)\n"
10704 "Exact match of the communities")
10705
10706ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010707 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010708 "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 +000010709 SHOW_STR
10710 BGP_STR
10711 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010712 "Address family modifier\n"
10713 "Address family modifier\n"
10714 "Address family modifier\n"
10715 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010716 "Display routes matching the communities\n"
10717 "community number\n"
10718 "Do not send outside local AS (well-known community)\n"
10719 "Do not advertise to any peer (well-known community)\n"
10720 "Do not export to next AS (well-known community)\n"
10721 "community number\n"
10722 "Do not send outside local AS (well-known community)\n"
10723 "Do not advertise to any peer (well-known community)\n"
10724 "Do not export to next AS (well-known community)\n"
10725 "community number\n"
10726 "Do not send outside local AS (well-known community)\n"
10727 "Do not advertise to any peer (well-known community)\n"
10728 "Do not export to next AS (well-known community)\n"
10729 "Exact match of the communities")
10730
10731ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010732 show_bgp_ipv6_safi_community4_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) (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 "community number\n"
10751 "Do not send outside local AS (well-known community)\n"
10752 "Do not advertise to any peer (well-known community)\n"
10753 "Do not export to next AS (well-known community)\n"
10754 "community number\n"
10755 "Do not send outside local AS (well-known community)\n"
10756 "Do not advertise to any peer (well-known community)\n"
10757 "Do not export to next AS (well-known community)\n"
10758 "Exact match of the communities")
10759
paul94f2b392005-06-28 12:44:16 +000010760static int
paulfd79ac92004-10-13 05:06:08 +000010761bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040010762 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000010763{
10764 struct community_list *list;
10765
hassofee6e4e2005-02-02 16:29:31 +000010766 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010767 if (list == NULL)
10768 {
10769 vty_out (vty, "%% %s is not a valid community-list name%s", com,
10770 VTY_NEWLINE);
10771 return CMD_WARNING;
10772 }
10773
ajs5a646652004-11-05 01:25:55 +000010774 return bgp_show (vty, NULL, afi, safi,
10775 (exact ? bgp_show_type_community_list_exact :
10776 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000010777}
10778
Lou Bergerf9b6c392016-01-12 13:42:09 -050010779DEFUN (show_ip_bgp_community_list,
10780 show_ip_bgp_community_list_cmd,
10781 "show ip bgp community-list (<1-500>|WORD)",
10782 SHOW_STR
10783 IP_STR
10784 BGP_STR
10785 "Display routes matching the community-list\n"
10786 "community-list number\n"
10787 "community-list name\n")
10788{
10789 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
10790}
10791
10792DEFUN (show_ip_bgp_ipv4_community_list,
10793 show_ip_bgp_ipv4_community_list_cmd,
10794 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10795 SHOW_STR
10796 IP_STR
10797 BGP_STR
10798 "Address family\n"
10799 "Address Family modifier\n"
10800 "Address Family modifier\n"
10801 "Display routes matching the community-list\n"
10802 "community-list number\n"
10803 "community-list name\n")
10804{
10805 if (strncmp (argv[0], "m", 1) == 0)
10806 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
10807
10808 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
10809}
10810
10811DEFUN (show_ip_bgp_community_list_exact,
10812 show_ip_bgp_community_list_exact_cmd,
10813 "show ip bgp community-list (<1-500>|WORD) exact-match",
10814 SHOW_STR
10815 IP_STR
10816 BGP_STR
10817 "Display routes matching the community-list\n"
10818 "community-list number\n"
10819 "community-list name\n"
10820 "Exact match of the communities\n")
10821{
10822 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
10823}
10824
10825DEFUN (show_ip_bgp_ipv4_community_list_exact,
10826 show_ip_bgp_ipv4_community_list_exact_cmd,
10827 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10828 SHOW_STR
10829 IP_STR
10830 BGP_STR
10831 "Address family\n"
10832 "Address Family modifier\n"
10833 "Address Family modifier\n"
10834 "Display routes matching the community-list\n"
10835 "community-list number\n"
10836 "community-list name\n"
10837 "Exact match of the communities\n")
10838{
10839 if (strncmp (argv[0], "m", 1) == 0)
10840 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
10841
10842 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
10843}
10844
Lou Bergerf9b6c392016-01-12 13:42:09 -050010845DEFUN (show_bgp_community_list,
10846 show_bgp_community_list_cmd,
10847 "show bgp community-list (<1-500>|WORD)",
10848 SHOW_STR
10849 BGP_STR
10850 "Display routes matching the community-list\n"
10851 "community-list number\n"
10852 "community-list name\n")
10853{
10854 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10855}
10856
10857ALIAS (show_bgp_community_list,
10858 show_bgp_ipv6_community_list_cmd,
10859 "show bgp ipv6 community-list (<1-500>|WORD)",
10860 SHOW_STR
10861 BGP_STR
10862 "Address family\n"
10863 "Display routes matching the community-list\n"
10864 "community-list number\n"
10865 "community-list name\n")
10866
10867/* old command */
10868DEFUN (show_ipv6_bgp_community_list,
10869 show_ipv6_bgp_community_list_cmd,
10870 "show ipv6 bgp community-list WORD",
10871 SHOW_STR
10872 IPV6_STR
10873 BGP_STR
10874 "Display routes matching the community-list\n"
10875 "community-list name\n")
10876{
10877 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10878}
10879
10880/* old command */
10881DEFUN (show_ipv6_mbgp_community_list,
10882 show_ipv6_mbgp_community_list_cmd,
10883 "show ipv6 mbgp community-list WORD",
10884 SHOW_STR
10885 IPV6_STR
10886 MBGP_STR
10887 "Display routes matching the community-list\n"
10888 "community-list name\n")
10889{
10890 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
10891}
10892
10893DEFUN (show_bgp_community_list_exact,
10894 show_bgp_community_list_exact_cmd,
10895 "show bgp community-list (<1-500>|WORD) exact-match",
10896 SHOW_STR
10897 BGP_STR
10898 "Display routes matching the community-list\n"
10899 "community-list number\n"
10900 "community-list name\n"
10901 "Exact match of the communities\n")
10902{
10903 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10904}
10905
10906ALIAS (show_bgp_community_list_exact,
10907 show_bgp_ipv6_community_list_exact_cmd,
10908 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10909 SHOW_STR
10910 BGP_STR
10911 "Address family\n"
10912 "Display routes matching the community-list\n"
10913 "community-list number\n"
10914 "community-list name\n"
10915 "Exact match of the communities\n")
10916
10917/* old command */
10918DEFUN (show_ipv6_bgp_community_list_exact,
10919 show_ipv6_bgp_community_list_exact_cmd,
10920 "show ipv6 bgp community-list WORD exact-match",
10921 SHOW_STR
10922 IPV6_STR
10923 BGP_STR
10924 "Display routes matching the community-list\n"
10925 "community-list name\n"
10926 "Exact match of the communities\n")
10927{
10928 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10929}
10930
10931/* old command */
10932DEFUN (show_ipv6_mbgp_community_list_exact,
10933 show_ipv6_mbgp_community_list_exact_cmd,
10934 "show ipv6 mbgp community-list WORD exact-match",
10935 SHOW_STR
10936 IPV6_STR
10937 MBGP_STR
10938 "Display routes matching the community-list\n"
10939 "community-list name\n"
10940 "Exact match of the communities\n")
10941{
10942 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
10943}
Lou Bergerf9b6c392016-01-12 13:42:09 -050010944
Lou Berger651b4022016-01-12 13:42:07 -050010945DEFUN (show_bgp_ipv4_community_list,
10946 show_bgp_ipv4_community_list_cmd,
10947 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010948 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010949 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010950 IP_STR
paul718e3742002-12-13 20:15:29 +000010951 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010952 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010953 "community-list name\n")
10954{
10955 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
10956}
10957
Lou Berger651b4022016-01-12 13:42:07 -050010958DEFUN (show_bgp_ipv4_safi_community_list,
10959 show_bgp_ipv4_safi_community_list_cmd,
10960 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010961 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010962 BGP_STR
10963 "Address family\n"
10964 "Address Family modifier\n"
10965 "Address Family modifier\n"
10966 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010967 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010968 "community-list name\n")
10969{
10970 if (strncmp (argv[0], "m", 1) == 0)
10971 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
10972
10973 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
10974}
10975
Lou Berger651b4022016-01-12 13:42:07 -050010976DEFUN (show_bgp_ipv4_community_list_exact,
10977 show_bgp_ipv4_community_list_exact_cmd,
10978 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000010979 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010980 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010981 IP_STR
paul718e3742002-12-13 20:15:29 +000010982 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010983 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010984 "community-list name\n"
10985 "Exact match of the communities\n")
10986{
10987 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
10988}
10989
Lou Berger651b4022016-01-12 13:42:07 -050010990DEFUN (show_bgp_ipv4_safi_community_list_exact,
10991 show_bgp_ipv4_safi_community_list_exact_cmd,
10992 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000010993 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010994 BGP_STR
10995 "Address family\n"
10996 "Address Family modifier\n"
10997 "Address Family modifier\n"
10998 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010999 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011000 "community-list name\n"
11001 "Exact match of the communities\n")
11002{
11003 if (strncmp (argv[0], "m", 1) == 0)
11004 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11005
11006 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11007}
11008
Lou Bergerf9b6c392016-01-12 13:42:09 -050011009DEFUN (show_bgp_ipv6_safi_community_list,
11010 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011011 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011012 SHOW_STR
11013 BGP_STR
11014 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011015 "Address family modifier\n"
11016 "Address family modifier\n"
11017 "Address family modifier\n"
11018 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011019 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011020 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011021 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011022{
Lou Berger651b4022016-01-12 13:42:07 -050011023 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011024
Lou Berger651b4022016-01-12 13:42:07 -050011025 if (bgp_parse_safi(argv[0], &safi)) {
11026 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11027 return CMD_WARNING;
11028 }
11029 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011030}
11031
Lou Bergerf9b6c392016-01-12 13:42:09 -050011032DEFUN (show_bgp_ipv6_safi_community_list_exact,
11033 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011034 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011035 SHOW_STR
11036 BGP_STR
11037 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011038 "Address family modifier\n"
11039 "Address family modifier\n"
11040 "Address family modifier\n"
11041 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011042 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011043 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011044 "community-list name\n"
11045 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011046{
Lou Berger651b4022016-01-12 13:42:07 -050011047 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011048
Lou Berger651b4022016-01-12 13:42:07 -050011049 if (bgp_parse_safi(argv[0], &safi)) {
11050 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11051 return CMD_WARNING;
11052 }
11053 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011054}
David Lamparter6b0655a2014-06-04 06:53:35 +020011055
paul94f2b392005-06-28 12:44:16 +000011056static int
paulfd79ac92004-10-13 05:06:08 +000011057bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000011058 safi_t safi, enum bgp_show_type type)
11059{
11060 int ret;
11061 struct prefix *p;
11062
11063 p = prefix_new();
11064
11065 ret = str2prefix (prefix, p);
11066 if (! ret)
11067 {
11068 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
11069 return CMD_WARNING;
11070 }
11071
ajs5a646652004-11-05 01:25:55 +000011072 ret = bgp_show (vty, NULL, afi, safi, type, p);
11073 prefix_free(p);
11074 return ret;
paul718e3742002-12-13 20:15:29 +000011075}
11076
Lou Bergerf9b6c392016-01-12 13:42:09 -050011077DEFUN (show_ip_bgp_prefix_longer,
11078 show_ip_bgp_prefix_longer_cmd,
11079 "show ip bgp A.B.C.D/M longer-prefixes",
11080 SHOW_STR
11081 IP_STR
11082 BGP_STR
11083 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11084 "Display route and more specific routes\n")
11085{
11086 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11087 bgp_show_type_prefix_longer);
11088}
11089
11090DEFUN (show_ip_bgp_flap_prefix_longer,
11091 show_ip_bgp_flap_prefix_longer_cmd,
11092 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11093 SHOW_STR
11094 IP_STR
11095 BGP_STR
11096 "Display flap statistics of routes\n"
11097 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11098 "Display route and more specific routes\n")
11099{
11100 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11101 bgp_show_type_flap_prefix_longer);
11102}
11103
11104ALIAS (show_ip_bgp_flap_prefix_longer,
11105 show_ip_bgp_damp_flap_prefix_longer_cmd,
11106 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11107 SHOW_STR
11108 IP_STR
11109 BGP_STR
11110 "Display detailed information about dampening\n"
11111 "Display flap statistics of routes\n"
11112 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11113 "Display route and more specific routes\n")
11114
11115DEFUN (show_ip_bgp_ipv4_prefix_longer,
11116 show_ip_bgp_ipv4_prefix_longer_cmd,
11117 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11118 SHOW_STR
11119 IP_STR
11120 BGP_STR
11121 "Address family\n"
11122 "Address Family modifier\n"
11123 "Address Family modifier\n"
11124 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11125 "Display route and more specific routes\n")
11126{
11127 if (strncmp (argv[0], "m", 1) == 0)
11128 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
11129 bgp_show_type_prefix_longer);
11130
11131 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
11132 bgp_show_type_prefix_longer);
11133}
11134
11135DEFUN (show_ip_bgp_flap_address,
11136 show_ip_bgp_flap_address_cmd,
11137 "show ip bgp flap-statistics A.B.C.D",
11138 SHOW_STR
11139 IP_STR
11140 BGP_STR
11141 "Display flap statistics of routes\n"
11142 "Network in the BGP routing table to display\n")
11143{
11144 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11145 bgp_show_type_flap_address);
11146}
11147
11148ALIAS (show_ip_bgp_flap_address,
11149 show_ip_bgp_damp_flap_address_cmd,
11150 "show ip bgp dampening flap-statistics A.B.C.D",
11151 SHOW_STR
11152 IP_STR
11153 BGP_STR
11154 "Display detailed information about dampening\n"
11155 "Display flap statistics of routes\n"
11156 "Network in the BGP routing table to display\n")
11157
11158DEFUN (show_ip_bgp_flap_prefix,
11159 show_ip_bgp_flap_prefix_cmd,
11160 "show ip bgp flap-statistics A.B.C.D/M",
11161 SHOW_STR
11162 IP_STR
11163 BGP_STR
11164 "Display flap statistics of routes\n"
11165 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11166{
11167 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11168 bgp_show_type_flap_prefix);
11169}
11170
11171ALIAS (show_ip_bgp_flap_prefix,
11172 show_ip_bgp_damp_flap_prefix_cmd,
11173 "show ip bgp dampening flap-statistics A.B.C.D/M",
11174 SHOW_STR
11175 IP_STR
11176 BGP_STR
11177 "Display detailed information about dampening\n"
11178 "Display flap statistics of routes\n"
11179 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11180
Lou Bergerf9b6c392016-01-12 13:42:09 -050011181DEFUN (show_bgp_prefix_longer,
11182 show_bgp_prefix_longer_cmd,
11183 "show bgp X:X::X:X/M longer-prefixes",
11184 SHOW_STR
11185 BGP_STR
11186 "IPv6 prefix <network>/<length>\n"
11187 "Display route and more specific routes\n")
11188{
11189 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11190 bgp_show_type_prefix_longer);
11191}
11192
11193/* old command */
11194DEFUN (show_ipv6_bgp_prefix_longer,
11195 show_ipv6_bgp_prefix_longer_cmd,
11196 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11197 SHOW_STR
11198 IPV6_STR
11199 BGP_STR
11200 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11201 "Display route and more specific routes\n")
11202{
11203 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11204 bgp_show_type_prefix_longer);
11205}
11206
11207/* old command */
11208DEFUN (show_ipv6_mbgp_prefix_longer,
11209 show_ipv6_mbgp_prefix_longer_cmd,
11210 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11211 SHOW_STR
11212 IPV6_STR
11213 MBGP_STR
11214 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11215 "Display route and more specific routes\n")
11216{
11217 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
11218 bgp_show_type_prefix_longer);
11219}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011220
Lou Berger651b4022016-01-12 13:42:07 -050011221DEFUN (show_bgp_ipv4_prefix_longer,
11222 show_bgp_ipv4_prefix_longer_cmd,
11223 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011224 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011225 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011226 IP_STR
paul718e3742002-12-13 20:15:29 +000011227 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11228 "Display route and more specific routes\n")
11229{
11230 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11231 bgp_show_type_prefix_longer);
11232}
11233
Lou Berger651b4022016-01-12 13:42:07 -050011234DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
11235 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
11236 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011237 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011238 BGP_STR
11239 "Address family\n"
11240 "Address Family modifier\n"
11241 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050011242 "Address Family modifier\n"
11243 "Address Family modifier\n"
11244 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000011245 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11246 "Display route and more specific routes\n")
11247{
Lou Berger651b4022016-01-12 13:42:07 -050011248 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011249
Lou Berger651b4022016-01-12 13:42:07 -050011250 if (bgp_parse_safi(argv[0], &safi)) {
11251 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11252 return CMD_WARNING;
11253 }
11254 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11255 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000011256}
11257
Lou Berger651b4022016-01-12 13:42:07 -050011258ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
11259 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
11260 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011261 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011262 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011263 "Address family\n"
11264 "Address Family modifier\n"
11265 "Address Family modifier\n"
11266 "Address Family modifier\n"
11267 "Address Family modifier\n"
11268 "Display detailed information about dampening\n"
11269 "Display flap statistics of routes\n"
11270 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11271 "Display route and more specific routes\n")
11272
Lou Berger651b4022016-01-12 13:42:07 -050011273DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
11274 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
11275 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
11276 SHOW_STR
11277 BGP_STR
11278 "Address family\n"
11279 "Address Family modifier\n"
11280 "Address Family modifier\n"
11281 "Address Family modifier\n"
11282 "Address Family modifier\n"
11283 "Display flap statistics of routes\n"
11284 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11285 "Display route and more specific routes\n")
11286{
11287 safi_t safi;
11288
11289 if (bgp_parse_safi(argv[0], &safi)) {
11290 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11291 return CMD_WARNING;
11292 }
11293 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11294 bgp_show_type_flap_prefix_longer);
11295}
11296ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
11297 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
11298 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
11299 SHOW_STR
11300 BGP_STR
11301 "Address family\n"
11302 "Address Family modifier\n"
11303 "Address Family modifier\n"
11304 "Address Family modifier\n"
11305 "Address Family modifier\n"
11306 "Display detailed information about dampening\n"
11307 "Display flap statistics of routes\n"
11308 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11309 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050011310
11311DEFUN (show_bgp_ipv4_safi_prefix_longer,
11312 show_bgp_ipv4_safi_prefix_longer_cmd,
11313 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
11314 SHOW_STR
11315 BGP_STR
11316 "Address family\n"
11317 "Address Family modifier\n"
11318 "Address Family modifier\n"
11319 "Address Family modifier\n"
11320 "Address Family modifier\n"
11321 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11322 "Display route and more specific routes\n")
11323{
11324 safi_t safi;
11325
11326 if (bgp_parse_safi(argv[0], &safi)) {
11327 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11328 return CMD_WARNING;
11329 }
11330
11331 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11332 bgp_show_type_prefix_longer);
11333}
11334
Lou Berger651b4022016-01-12 13:42:07 -050011335DEFUN (show_bgp_ipv6_safi_prefix_longer,
11336 show_bgp_ipv6_safi_prefix_longer_cmd,
11337 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
11338 SHOW_STR
11339 BGP_STR
11340 "Address family\n"
11341 "Address Family modifier\n"
11342 "Address Family modifier\n"
11343 "Address Family modifier\n"
11344 "Address Family modifier\n"
11345 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11346 "Display route and more specific routes\n")
11347{
11348 safi_t safi;
11349
11350 if (bgp_parse_safi(argv[0], &safi)) {
11351 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11352 return CMD_WARNING;
11353 }
11354
11355 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11356 bgp_show_type_prefix_longer);
11357}
Lou Berger651b4022016-01-12 13:42:07 -050011358
11359DEFUN (show_bgp_ipv4_safi_flap_address,
11360 show_bgp_ipv4_safi_flap_address_cmd,
11361 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
11362 SHOW_STR
11363 BGP_STR
11364 "Address family\n"
11365 "Address Family modifier\n"
11366 "Address Family modifier\n"
11367 "Address Family modifier\n"
11368 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011369 "Display flap statistics of routes\n"
11370 "Network in the BGP routing table to display\n")
11371{
Lou Berger651b4022016-01-12 13:42:07 -050011372 safi_t safi;
11373
11374 if (bgp_parse_safi(argv[0], &safi)) {
11375 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11376 return CMD_WARNING;
11377 }
11378 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011379 bgp_show_type_flap_address);
11380}
Lou Berger651b4022016-01-12 13:42:07 -050011381ALIAS (show_bgp_ipv4_safi_flap_address,
11382 show_bgp_ipv4_safi_damp_flap_address_cmd,
11383 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053011384 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011385 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011386 "Address family\n"
11387 "Address Family modifier\n"
11388 "Address Family modifier\n"
11389 "Address Family modifier\n"
11390 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011391 "Display detailed information about dampening\n"
11392 "Display flap statistics of routes\n"
11393 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050011394
Lou Berger651b4022016-01-12 13:42:07 -050011395DEFUN (show_bgp_ipv6_flap_address,
11396 show_bgp_ipv6_flap_address_cmd,
11397 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000011398 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011399 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011400 "Address family\n"
11401 "Address Family modifier\n"
11402 "Address Family modifier\n"
11403 "Address Family modifier\n"
11404 "Address Family modifier\n"
11405 "Display flap statistics of routes\n"
11406 "Network in the BGP routing table to display\n")
11407{
11408 safi_t safi;
11409
11410 if (bgp_parse_safi(argv[0], &safi)) {
11411 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11412 return CMD_WARNING;
11413 }
11414 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11415 bgp_show_type_flap_address);
11416}
11417ALIAS (show_bgp_ipv6_flap_address,
11418 show_bgp_ipv6_damp_flap_address_cmd,
11419 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
11420 SHOW_STR
11421 BGP_STR
11422 "Address family\n"
11423 "Address Family modifier\n"
11424 "Address Family modifier\n"
11425 "Address Family modifier\n"
11426 "Address Family modifier\n"
11427 "Display detailed information about dampening\n"
11428 "Display flap statistics of routes\n"
11429 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050011430
11431DEFUN (show_bgp_ipv4_safi_flap_prefix,
11432 show_bgp_ipv4_safi_flap_prefix_cmd,
11433 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
11434 SHOW_STR
11435 BGP_STR
11436 "Address family\n"
11437 "Address Family modifier\n"
11438 "Address Family modifier\n"
11439 "Address Family modifier\n"
11440 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011441 "Display flap statistics of routes\n"
11442 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11443{
Lou Berger651b4022016-01-12 13:42:07 -050011444 safi_t safi;
11445
11446 if (bgp_parse_safi(argv[0], &safi)) {
11447 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11448 return CMD_WARNING;
11449 }
11450 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011451 bgp_show_type_flap_prefix);
11452}
Balaji3921cc52015-05-16 23:12:17 +053011453
Lou Berger651b4022016-01-12 13:42:07 -050011454ALIAS (show_bgp_ipv4_safi_flap_prefix,
11455 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
11456 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053011457 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011458 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011459 "Address family\n"
11460 "Address Family modifier\n"
11461 "Address Family modifier\n"
11462 "Address Family modifier\n"
11463 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011464 "Display detailed information about dampening\n"
11465 "Display flap statistics of routes\n"
11466 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11467
Lou Berger651b4022016-01-12 13:42:07 -050011468DEFUN (show_bgp_ipv6_safi_flap_prefix,
11469 show_bgp_ipv6_safi_flap_prefix_cmd,
11470 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000011471 SHOW_STR
11472 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011473 "Address family\n"
11474 "Address Family modifier\n"
11475 "Address Family modifier\n"
11476 "Address Family modifier\n"
11477 "Address Family modifier\n"
11478 "Display flap statistics of routes\n"
11479 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000011480{
Lou Berger651b4022016-01-12 13:42:07 -050011481 safi_t safi;
11482
11483 if (bgp_parse_safi(argv[0], &safi)) {
11484 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11485 return CMD_WARNING;
11486 }
11487 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
11488 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000011489}
11490
Lou Berger651b4022016-01-12 13:42:07 -050011491ALIAS (show_bgp_ipv6_safi_flap_prefix,
11492 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
11493 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
11494 SHOW_STR
11495 BGP_STR
11496 "Address family\n"
11497 "Address Family modifier\n"
11498 "Address Family modifier\n"
11499 "Address Family modifier\n"
11500 "Address Family modifier\n"
11501 "Display detailed information about dampening\n"
11502 "Display flap statistics of routes\n"
11503 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11504
11505DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000011506 show_bgp_ipv6_prefix_longer_cmd,
11507 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11508 SHOW_STR
11509 BGP_STR
11510 "Address family\n"
11511 "IPv6 prefix <network>/<length>\n"
11512 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000011513{
11514 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11515 bgp_show_type_prefix_longer);
11516}
11517
paul94f2b392005-06-28 12:44:16 +000011518static struct peer *
paulfd79ac92004-10-13 05:06:08 +000011519peer_lookup_in_view (struct vty *vty, const char *view_name,
11520 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000011521{
11522 int ret;
11523 struct bgp *bgp;
11524 struct peer *peer;
11525 union sockunion su;
11526
11527 /* BGP structure lookup. */
11528 if (view_name)
11529 {
11530 bgp = bgp_lookup_by_name (view_name);
11531 if (! bgp)
11532 {
11533 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11534 return NULL;
11535 }
11536 }
paul5228ad22004-06-04 17:58:18 +000011537 else
paulbb46e942003-10-24 19:02:03 +000011538 {
11539 bgp = bgp_get_default ();
11540 if (! bgp)
11541 {
11542 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11543 return NULL;
11544 }
11545 }
11546
11547 /* Get peer sockunion. */
11548 ret = str2sockunion (ip_str, &su);
11549 if (ret < 0)
11550 {
11551 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
11552 return NULL;
11553 }
11554
11555 /* Peer structure lookup. */
11556 peer = peer_lookup (bgp, &su);
11557 if (! peer)
11558 {
11559 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
11560 return NULL;
11561 }
11562
11563 return peer;
11564}
David Lamparter6b0655a2014-06-04 06:53:35 +020011565
Paul Jakma2815e612006-09-14 02:56:07 +000011566enum bgp_stats
11567{
11568 BGP_STATS_MAXBITLEN = 0,
11569 BGP_STATS_RIB,
11570 BGP_STATS_PREFIXES,
11571 BGP_STATS_TOTPLEN,
11572 BGP_STATS_UNAGGREGATEABLE,
11573 BGP_STATS_MAX_AGGREGATEABLE,
11574 BGP_STATS_AGGREGATES,
11575 BGP_STATS_SPACE,
11576 BGP_STATS_ASPATH_COUNT,
11577 BGP_STATS_ASPATH_MAXHOPS,
11578 BGP_STATS_ASPATH_TOTHOPS,
11579 BGP_STATS_ASPATH_MAXSIZE,
11580 BGP_STATS_ASPATH_TOTSIZE,
11581 BGP_STATS_ASN_HIGHEST,
11582 BGP_STATS_MAX,
11583};
paulbb46e942003-10-24 19:02:03 +000011584
Paul Jakma2815e612006-09-14 02:56:07 +000011585static const char *table_stats_strs[] =
11586{
11587 [BGP_STATS_PREFIXES] = "Total Prefixes",
11588 [BGP_STATS_TOTPLEN] = "Average prefix length",
11589 [BGP_STATS_RIB] = "Total Advertisements",
11590 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
11591 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
11592 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
11593 [BGP_STATS_SPACE] = "Address space advertised",
11594 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
11595 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
11596 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
11597 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
11598 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
11599 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
11600 [BGP_STATS_MAX] = NULL,
11601};
11602
11603struct bgp_table_stats
11604{
11605 struct bgp_table *table;
11606 unsigned long long counts[BGP_STATS_MAX];
11607};
11608
11609#if 0
11610#define TALLY_SIGFIG 100000
11611static unsigned long
11612ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
11613{
11614 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
11615 unsigned long res = (newtot * TALLY_SIGFIG) / count;
11616 unsigned long ret = newtot / count;
11617
11618 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
11619 return ret + 1;
11620 else
11621 return ret;
11622}
11623#endif
11624
11625static int
11626bgp_table_stats_walker (struct thread *t)
11627{
11628 struct bgp_node *rn;
11629 struct bgp_node *top;
11630 struct bgp_table_stats *ts = THREAD_ARG (t);
11631 unsigned int space = 0;
11632
Paul Jakma53d9f672006-10-15 23:41:16 +000011633 if (!(top = bgp_table_top (ts->table)))
11634 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000011635
11636 switch (top->p.family)
11637 {
11638 case AF_INET:
11639 space = IPV4_MAX_BITLEN;
11640 break;
11641 case AF_INET6:
11642 space = IPV6_MAX_BITLEN;
11643 break;
11644 }
11645
11646 ts->counts[BGP_STATS_MAXBITLEN] = space;
11647
11648 for (rn = top; rn; rn = bgp_route_next (rn))
11649 {
11650 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070011651 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000011652 unsigned int rinum = 0;
11653
11654 if (rn == top)
11655 continue;
11656
11657 if (!rn->info)
11658 continue;
11659
11660 ts->counts[BGP_STATS_PREFIXES]++;
11661 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
11662
11663#if 0
11664 ts->counts[BGP_STATS_AVGPLEN]
11665 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
11666 ts->counts[BGP_STATS_AVGPLEN],
11667 rn->p.prefixlen);
11668#endif
11669
11670 /* check if the prefix is included by any other announcements */
11671 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070011672 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000011673
11674 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000011675 {
11676 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
11677 /* announced address space */
11678 if (space)
11679 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
11680 }
Paul Jakma2815e612006-09-14 02:56:07 +000011681 else if (prn->info)
11682 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
11683
Paul Jakma2815e612006-09-14 02:56:07 +000011684 for (ri = rn->info; ri; ri = ri->next)
11685 {
11686 rinum++;
11687 ts->counts[BGP_STATS_RIB]++;
11688
11689 if (ri->attr &&
11690 (CHECK_FLAG (ri->attr->flag,
11691 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
11692 ts->counts[BGP_STATS_AGGREGATES]++;
11693
11694 /* as-path stats */
11695 if (ri->attr && ri->attr->aspath)
11696 {
11697 unsigned int hops = aspath_count_hops (ri->attr->aspath);
11698 unsigned int size = aspath_size (ri->attr->aspath);
11699 as_t highest = aspath_highest (ri->attr->aspath);
11700
11701 ts->counts[BGP_STATS_ASPATH_COUNT]++;
11702
11703 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
11704 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
11705
11706 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
11707 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
11708
11709 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
11710 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
11711#if 0
11712 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
11713 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11714 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
11715 hops);
11716 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
11717 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11718 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
11719 size);
11720#endif
11721 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
11722 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
11723 }
11724 }
11725 }
11726 return 0;
11727}
11728
11729static int
11730bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
11731{
11732 struct bgp_table_stats ts;
11733 unsigned int i;
11734
11735 if (!bgp->rib[afi][safi])
11736 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011737 vty_out (vty, "%% No RIB exists for the AFI/SAFI%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011738 return CMD_WARNING;
11739 }
11740
11741 memset (&ts, 0, sizeof (ts));
11742 ts.table = bgp->rib[afi][safi];
11743 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
11744
11745 vty_out (vty, "BGP %s RIB statistics%s%s",
11746 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
11747
11748 for (i = 0; i < BGP_STATS_MAX; i++)
11749 {
11750 if (!table_stats_strs[i])
11751 continue;
11752
11753 switch (i)
11754 {
11755#if 0
11756 case BGP_STATS_ASPATH_AVGHOPS:
11757 case BGP_STATS_ASPATH_AVGSIZE:
11758 case BGP_STATS_AVGPLEN:
11759 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11760 vty_out (vty, "%12.2f",
11761 (float)ts.counts[i] / (float)TALLY_SIGFIG);
11762 break;
11763#endif
11764 case BGP_STATS_ASPATH_TOTHOPS:
11765 case BGP_STATS_ASPATH_TOTSIZE:
11766 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11767 vty_out (vty, "%12.2f",
11768 ts.counts[i] ?
11769 (float)ts.counts[i] /
11770 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
11771 : 0);
11772 break;
11773 case BGP_STATS_TOTPLEN:
11774 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11775 vty_out (vty, "%12.2f",
11776 ts.counts[i] ?
11777 (float)ts.counts[i] /
11778 (float)ts.counts[BGP_STATS_PREFIXES]
11779 : 0);
11780 break;
11781 case BGP_STATS_SPACE:
11782 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11783 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
11784 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
11785 break;
Paul Jakma30a22312008-08-15 14:05:22 +010011786 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000011787 vty_out (vty, "%12.2f%s",
11788 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000011789 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000011790 VTY_NEWLINE);
11791 vty_out (vty, "%30s: ", "/8 equivalent ");
11792 vty_out (vty, "%12.2f%s",
11793 (float)ts.counts[BGP_STATS_SPACE] /
11794 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
11795 VTY_NEWLINE);
11796 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
11797 break;
11798 vty_out (vty, "%30s: ", "/24 equivalent ");
11799 vty_out (vty, "%12.2f",
11800 (float)ts.counts[BGP_STATS_SPACE] /
11801 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
11802 break;
11803 default:
11804 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11805 vty_out (vty, "%12llu", ts.counts[i]);
11806 }
11807
11808 vty_out (vty, "%s", VTY_NEWLINE);
11809 }
11810 return CMD_SUCCESS;
11811}
11812
11813static int
11814bgp_table_stats_vty (struct vty *vty, const char *name,
11815 const char *afi_str, const char *safi_str)
11816{
11817 struct bgp *bgp;
11818 afi_t afi;
11819 safi_t safi;
11820
11821 if (name)
11822 bgp = bgp_lookup_by_name (name);
11823 else
11824 bgp = bgp_get_default ();
11825
11826 if (!bgp)
11827 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011828 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011829 return CMD_WARNING;
11830 }
11831 if (strncmp (afi_str, "ipv", 3) == 0)
11832 {
11833 if (strncmp (afi_str, "ipv4", 4) == 0)
11834 afi = AFI_IP;
11835 else if (strncmp (afi_str, "ipv6", 4) == 0)
11836 afi = AFI_IP6;
11837 else
11838 {
11839 vty_out (vty, "%% Invalid address family %s%s",
11840 afi_str, VTY_NEWLINE);
11841 return CMD_WARNING;
11842 }
Lou Berger298cc2f2016-01-12 13:42:02 -050011843 switch (safi_str[0]) {
11844 case 'm':
11845 safi = SAFI_MULTICAST;
11846 break;
11847 case 'u':
11848 safi = SAFI_UNICAST;
11849 break;
11850 case 'v':
11851 safi = SAFI_MPLS_LABELED_VPN;
11852 break;
11853 case 'e':
11854 safi = SAFI_ENCAP;
11855 break;
11856 default:
11857 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011858 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050011859 return CMD_WARNING;
11860 }
Paul Jakma2815e612006-09-14 02:56:07 +000011861 }
11862 else
11863 {
Lou Berger298cc2f2016-01-12 13:42:02 -050011864 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011865 afi_str, VTY_NEWLINE);
11866 return CMD_WARNING;
11867 }
11868
Paul Jakma2815e612006-09-14 02:56:07 +000011869 return bgp_table_stats (vty, bgp, afi, safi);
11870}
11871
11872DEFUN (show_bgp_statistics,
11873 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011874 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011875 SHOW_STR
11876 BGP_STR
11877 "Address family\n"
11878 "Address family\n"
11879 "Address Family modifier\n"
11880 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011881 "Address Family modifier\n"
11882 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011883 "BGP RIB advertisement statistics\n")
11884{
11885 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11886}
11887
Lou Bergerf9b6c392016-01-12 13:42:09 -050011888ALIAS (show_bgp_statistics,
11889 show_bgp_statistics_vpnv4_cmd,
11890 "show bgp (ipv4) (vpnv4) statistics",
11891 SHOW_STR
11892 BGP_STR
11893 "Address family\n"
11894 "Address Family modifier\n"
11895 "BGP RIB advertisement statistics\n")
11896
Paul Jakma2815e612006-09-14 02:56:07 +000011897DEFUN (show_bgp_statistics_view,
11898 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011899 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011900 SHOW_STR
11901 BGP_STR
11902 "BGP view\n"
11903 "Address family\n"
11904 "Address family\n"
11905 "Address Family modifier\n"
11906 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011907 "Address Family modifier\n"
11908 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011909 "BGP RIB advertisement statistics\n")
11910{
11911 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11912}
11913
11914ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011915 show_bgp_statistics_view_vpnv4_cmd,
11916 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011917 SHOW_STR
11918 BGP_STR
11919 "BGP view\n"
11920 "Address family\n"
11921 "Address Family modifier\n"
11922 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020011923
Paul Jakmaff7924f2006-09-04 01:10:36 +000011924enum bgp_pcounts
11925{
11926 PCOUNT_ADJ_IN = 0,
11927 PCOUNT_DAMPED,
11928 PCOUNT_REMOVED,
11929 PCOUNT_HISTORY,
11930 PCOUNT_STALE,
11931 PCOUNT_VALID,
11932 PCOUNT_ALL,
11933 PCOUNT_COUNTED,
11934 PCOUNT_PFCNT, /* the figure we display to users */
11935 PCOUNT_MAX,
11936};
11937
11938static const char *pcount_strs[] =
11939{
11940 [PCOUNT_ADJ_IN] = "Adj-in",
11941 [PCOUNT_DAMPED] = "Damped",
11942 [PCOUNT_REMOVED] = "Removed",
11943 [PCOUNT_HISTORY] = "History",
11944 [PCOUNT_STALE] = "Stale",
11945 [PCOUNT_VALID] = "Valid",
11946 [PCOUNT_ALL] = "All RIB",
11947 [PCOUNT_COUNTED] = "PfxCt counted",
11948 [PCOUNT_PFCNT] = "Useable",
11949 [PCOUNT_MAX] = NULL,
11950};
11951
Paul Jakma2815e612006-09-14 02:56:07 +000011952struct peer_pcounts
11953{
11954 unsigned int count[PCOUNT_MAX];
11955 const struct peer *peer;
11956 const struct bgp_table *table;
11957};
11958
Paul Jakmaff7924f2006-09-04 01:10:36 +000011959static int
Paul Jakma2815e612006-09-14 02:56:07 +000011960bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000011961{
11962 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000011963 struct peer_pcounts *pc = THREAD_ARG (t);
11964 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011965
Paul Jakma2815e612006-09-14 02:56:07 +000011966 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000011967 {
11968 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000011969 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011970
11971 for (ain = rn->adj_in; ain; ain = ain->next)
11972 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000011973 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011974
Paul Jakmaff7924f2006-09-04 01:10:36 +000011975 for (ri = rn->info; ri; ri = ri->next)
11976 {
11977 char buf[SU_ADDRSTRLEN];
11978
11979 if (ri->peer != peer)
11980 continue;
11981
Paul Jakma2815e612006-09-14 02:56:07 +000011982 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011983
11984 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000011985 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011986 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000011987 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011988 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000011989 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011990 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000011991 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011992 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000011993 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000011994 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000011995 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011996
11997 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
11998 {
Paul Jakma2815e612006-09-14 02:56:07 +000011999 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012000 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012001 plog_warn (peer->log,
12002 "%s [pcount] %s/%d is counted but flags 0x%x",
12003 peer->host,
12004 inet_ntop(rn->p.family, &rn->p.u.prefix,
12005 buf, SU_ADDRSTRLEN),
12006 rn->p.prefixlen,
12007 ri->flags);
12008 }
12009 else
12010 {
Paul Jakma1a392d42006-09-07 00:24:49 +000012011 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012012 plog_warn (peer->log,
12013 "%s [pcount] %s/%d not counted but flags 0x%x",
12014 peer->host,
12015 inet_ntop(rn->p.family, &rn->p.u.prefix,
12016 buf, SU_ADDRSTRLEN),
12017 rn->p.prefixlen,
12018 ri->flags);
12019 }
12020 }
12021 }
Paul Jakma2815e612006-09-14 02:56:07 +000012022 return 0;
12023}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012024
Paul Jakma2815e612006-09-14 02:56:07 +000012025static int
12026bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
12027{
12028 struct peer_pcounts pcounts = { .peer = peer };
12029 unsigned int i;
12030
12031 if (!peer || !peer->bgp || !peer->afc[afi][safi]
12032 || !peer->bgp->rib[afi][safi])
12033 {
12034 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12035 return CMD_WARNING;
12036 }
12037
12038 memset (&pcounts, 0, sizeof(pcounts));
12039 pcounts.peer = peer;
12040 pcounts.table = peer->bgp->rib[afi][safi];
12041
12042 /* in-place call via thread subsystem so as to record execution time
12043 * stats for the thread-walk (i.e. ensure this can't be blamed on
12044 * on just vty_read()).
12045 */
12046 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
12047
Paul Jakmaff7924f2006-09-04 01:10:36 +000012048 vty_out (vty, "Prefix counts for %s, %s%s",
12049 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
12050 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
12051 vty_out (vty, "%sCounts from RIB table walk:%s%s",
12052 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12053
12054 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000012055 vty_out (vty, "%20s: %-10d%s",
12056 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012057
Paul Jakma2815e612006-09-14 02:56:07 +000012058 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000012059 {
12060 vty_out (vty, "%s [pcount] PfxCt drift!%s",
12061 peer->host, VTY_NEWLINE);
12062 vty_out (vty, "Please report this bug, with the above command output%s",
12063 VTY_NEWLINE);
12064 }
12065
12066 return CMD_SUCCESS;
12067}
12068
Lou Bergerf9b6c392016-01-12 13:42:09 -050012069DEFUN (show_ip_bgp_neighbor_prefix_counts,
12070 show_ip_bgp_neighbor_prefix_counts_cmd,
12071 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12072 SHOW_STR
12073 IP_STR
12074 BGP_STR
12075 "Detailed information on TCP and BGP neighbor connections\n"
12076 "Neighbor to display information about\n"
12077 "Neighbor to display information about\n"
12078 "Display detailed prefix count information\n")
12079{
12080 struct peer *peer;
12081
12082 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12083 if (! peer)
12084 return CMD_WARNING;
12085
12086 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12087}
12088
Paul Jakmaff7924f2006-09-04 01:10:36 +000012089DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
12090 show_bgp_ipv6_neighbor_prefix_counts_cmd,
12091 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12092 SHOW_STR
12093 BGP_STR
12094 "Address family\n"
12095 "Detailed information on TCP and BGP neighbor connections\n"
12096 "Neighbor to display information about\n"
12097 "Neighbor to display information about\n"
12098 "Display detailed prefix count information\n")
12099{
12100 struct peer *peer;
12101
12102 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12103 if (! peer)
12104 return CMD_WARNING;
12105
12106 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
12107}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012108
12109DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
12110 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
12111 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12112 SHOW_STR
12113 IP_STR
12114 BGP_STR
12115 "Address family\n"
12116 "Address Family modifier\n"
12117 "Address Family modifier\n"
12118 "Detailed information on TCP and BGP neighbor connections\n"
12119 "Neighbor to display information about\n"
12120 "Neighbor to display information about\n"
12121 "Display detailed prefix count information\n")
12122{
12123 struct peer *peer;
12124
12125 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12126 if (! peer)
12127 return CMD_WARNING;
12128
12129 if (strncmp (argv[0], "m", 1) == 0)
12130 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
12131
12132 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12133}
12134
12135DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
12136 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
12137 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12138 SHOW_STR
12139 IP_STR
12140 BGP_STR
12141 "Address family\n"
12142 "Address Family modifier\n"
12143 "Address Family modifier\n"
12144 "Detailed information on TCP and BGP neighbor connections\n"
12145 "Neighbor to display information about\n"
12146 "Neighbor to display information about\n"
12147 "Display detailed prefix count information\n")
12148{
12149 struct peer *peer;
12150
12151 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12152 if (! peer)
12153 return CMD_WARNING;
12154
12155 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
12156}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012157
Lou Berger651b4022016-01-12 13:42:07 -050012158DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
12159 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
12160 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012161 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000012162 BGP_STR
12163 "Address family\n"
12164 "Address Family modifier\n"
12165 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012166 "Address Family modifier\n"
12167 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000012168 "Detailed information on TCP and BGP neighbor connections\n"
12169 "Neighbor to display information about\n"
12170 "Neighbor to display information about\n"
12171 "Display detailed prefix count information\n")
12172{
12173 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012174 safi_t safi;
12175
12176 if (bgp_parse_safi(argv[0], &safi)) {
12177 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12178 return CMD_WARNING;
12179 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000012180
12181 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12182 if (! peer)
12183 return CMD_WARNING;
12184
Lou Berger651b4022016-01-12 13:42:07 -050012185 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012186}
Lou Berger205e6742016-01-12 13:42:11 -050012187
Lou Berger651b4022016-01-12 13:42:07 -050012188DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
12189 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
12190 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12191 SHOW_STR
12192 BGP_STR
12193 "Address family\n"
12194 "Address Family modifier\n"
12195 "Address Family modifier\n"
12196 "Address Family modifier\n"
12197 "Address Family modifier\n"
12198 "Detailed information on TCP and BGP neighbor connections\n"
12199 "Neighbor to display information about\n"
12200 "Neighbor to display information about\n"
12201 "Display detailed prefix count information\n")
12202{
12203 struct peer *peer;
12204 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012205
Lou Berger651b4022016-01-12 13:42:07 -050012206 if (bgp_parse_safi(argv[0], &safi)) {
12207 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12208 return CMD_WARNING;
12209 }
12210
12211 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12212 if (! peer)
12213 return CMD_WARNING;
12214
12215 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
12216}
Lou Berger651b4022016-01-12 13:42:07 -050012217
12218DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
12219 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
12220 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012221 SHOW_STR
12222 IP_STR
12223 BGP_STR
12224 "Address family\n"
12225 "Address Family modifier\n"
12226 "Address Family modifier\n"
12227 "Detailed information on TCP and BGP neighbor connections\n"
12228 "Neighbor to display information about\n"
12229 "Neighbor to display information about\n"
12230 "Display detailed prefix count information\n")
12231{
12232 struct peer *peer;
12233
12234 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12235 if (! peer)
12236 return CMD_WARNING;
12237
Lou Berger651b4022016-01-12 13:42:07 -050012238 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012239}
12240
12241
paul94f2b392005-06-28 12:44:16 +000012242static void
paul718e3742002-12-13 20:15:29 +000012243show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
12244 int in)
12245{
12246 struct bgp_table *table;
12247 struct bgp_adj_in *ain;
12248 struct bgp_adj_out *adj;
12249 unsigned long output_count;
12250 struct bgp_node *rn;
12251 int header1 = 1;
12252 struct bgp *bgp;
12253 int header2 = 1;
12254
paulbb46e942003-10-24 19:02:03 +000012255 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000012256
12257 if (! bgp)
12258 return;
12259
12260 table = bgp->rib[afi][safi];
12261
12262 output_count = 0;
12263
12264 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
12265 PEER_STATUS_DEFAULT_ORIGINATE))
12266 {
12267 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 +000012268 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12269 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012270
12271 vty_out (vty, "Originating default network 0.0.0.0%s%s",
12272 VTY_NEWLINE, VTY_NEWLINE);
12273 header1 = 0;
12274 }
12275
12276 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
12277 if (in)
12278 {
12279 for (ain = rn->adj_in; ain; ain = ain->next)
12280 if (ain->peer == peer)
12281 {
12282 if (header1)
12283 {
12284 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 +000012285 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12286 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012287 header1 = 0;
12288 }
12289 if (header2)
12290 {
12291 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12292 header2 = 0;
12293 }
12294 if (ain->attr)
12295 {
12296 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
12297 output_count++;
12298 }
12299 }
12300 }
12301 else
12302 {
12303 for (adj = rn->adj_out; adj; adj = adj->next)
12304 if (adj->peer == peer)
12305 {
12306 if (header1)
12307 {
12308 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 +000012309 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12310 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012311 header1 = 0;
12312 }
12313 if (header2)
12314 {
12315 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12316 header2 = 0;
12317 }
12318 if (adj->attr)
12319 {
12320 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
12321 output_count++;
12322 }
12323 }
12324 }
12325
12326 if (output_count != 0)
12327 vty_out (vty, "%sTotal number of prefixes %ld%s",
12328 VTY_NEWLINE, output_count, VTY_NEWLINE);
12329}
12330
paul94f2b392005-06-28 12:44:16 +000012331static int
paulbb46e942003-10-24 19:02:03 +000012332peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
12333{
paul718e3742002-12-13 20:15:29 +000012334 if (! peer || ! peer->afc[afi][safi])
12335 {
12336 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12337 return CMD_WARNING;
12338 }
12339
12340 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
12341 {
12342 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
12343 VTY_NEWLINE);
12344 return CMD_WARNING;
12345 }
12346
12347 show_adj_route (vty, peer, afi, safi, in);
12348
12349 return CMD_SUCCESS;
12350}
12351
Lou Bergerf9b6c392016-01-12 13:42:09 -050012352DEFUN (show_ip_bgp_view_neighbor_advertised_route,
12353 show_ip_bgp_view_neighbor_advertised_route_cmd,
12354 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12355 SHOW_STR
12356 IP_STR
12357 BGP_STR
12358 "BGP view\n"
12359 "View name\n"
12360 "Detailed information on TCP and BGP neighbor connections\n"
12361 "Neighbor to display information about\n"
12362 "Neighbor to display information about\n"
12363 "Display the routes advertised to a BGP neighbor\n")
12364{
12365 struct peer *peer;
12366
12367 if (argc == 2)
12368 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12369 else
12370 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12371
12372 if (! peer)
12373 return CMD_WARNING;
12374
12375 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12376}
12377
12378ALIAS (show_ip_bgp_view_neighbor_advertised_route,
12379 show_ip_bgp_neighbor_advertised_route_cmd,
12380 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12381 SHOW_STR
12382 IP_STR
12383 BGP_STR
12384 "Detailed information on TCP and BGP neighbor connections\n"
12385 "Neighbor to display information about\n"
12386 "Neighbor to display information about\n"
12387 "Display the routes advertised to a BGP neighbor\n")
12388
12389DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
12390 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
12391 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12392 SHOW_STR
12393 IP_STR
12394 BGP_STR
12395 "Address family\n"
12396 "Address Family modifier\n"
12397 "Address Family modifier\n"
12398 "Detailed information on TCP and BGP neighbor connections\n"
12399 "Neighbor to display information about\n"
12400 "Neighbor to display information about\n"
12401 "Display the routes advertised to a BGP neighbor\n")
12402{
12403 struct peer *peer;
12404
12405 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12406 if (! peer)
12407 return CMD_WARNING;
12408
12409 if (strncmp (argv[0], "m", 1) == 0)
12410 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
12411
12412 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12413}
12414
Lou Bergerf9b6c392016-01-12 13:42:09 -050012415DEFUN (show_bgp_view_neighbor_advertised_route,
12416 show_bgp_view_neighbor_advertised_route_cmd,
12417 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12418 SHOW_STR
12419 BGP_STR
12420 "BGP view\n"
12421 "View name\n"
12422 "Detailed information on TCP and BGP neighbor connections\n"
12423 "Neighbor to display information about\n"
12424 "Neighbor to display information about\n"
12425 "Display the routes advertised to a BGP neighbor\n")
12426{
12427 struct peer *peer;
12428
12429 if (argc == 2)
12430 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12431 else
12432 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12433
12434 if (! peer)
12435 return CMD_WARNING;
12436
12437 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12438}
12439
12440DEFUN (show_bgp_view_neighbor_received_routes,
12441 show_bgp_view_neighbor_received_routes_cmd,
12442 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12443 SHOW_STR
12444 BGP_STR
12445 "BGP view\n"
12446 "View name\n"
12447 "Detailed information on TCP and BGP neighbor connections\n"
12448 "Neighbor to display information about\n"
12449 "Neighbor to display information about\n"
12450 "Display the received routes from neighbor\n")
12451{
12452 struct peer *peer;
12453
12454 if (argc == 2)
12455 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12456 else
12457 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12458
12459 if (! peer)
12460 return CMD_WARNING;
12461
12462 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12463}
12464
12465ALIAS (show_bgp_view_neighbor_advertised_route,
12466 show_bgp_neighbor_advertised_route_cmd,
12467 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12468 SHOW_STR
12469 BGP_STR
12470 "Detailed information on TCP and BGP neighbor connections\n"
12471 "Neighbor to display information about\n"
12472 "Neighbor to display information about\n"
12473 "Display the routes advertised to a BGP neighbor\n")
12474
12475ALIAS (show_bgp_view_neighbor_advertised_route,
12476 show_bgp_ipv6_neighbor_advertised_route_cmd,
12477 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12478 SHOW_STR
12479 BGP_STR
12480 "Address family\n"
12481 "Detailed information on TCP and BGP neighbor connections\n"
12482 "Neighbor to display information about\n"
12483 "Neighbor to display information about\n"
12484 "Display the routes advertised to a BGP neighbor\n")
12485
12486/* old command */
12487ALIAS (show_bgp_view_neighbor_advertised_route,
12488 ipv6_bgp_neighbor_advertised_route_cmd,
12489 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12490 SHOW_STR
12491 IPV6_STR
12492 BGP_STR
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 routes advertised to a BGP neighbor\n")
12497
12498/* old command */
12499DEFUN (ipv6_mbgp_neighbor_advertised_route,
12500 ipv6_mbgp_neighbor_advertised_route_cmd,
12501 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12502 SHOW_STR
12503 IPV6_STR
12504 MBGP_STR
12505 "Detailed information on TCP and BGP neighbor connections\n"
12506 "Neighbor to display information about\n"
12507 "Neighbor to display information about\n"
12508 "Display the routes advertised to a BGP neighbor\n")
12509{
12510 struct peer *peer;
12511
12512 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12513 if (! peer)
12514 return CMD_WARNING;
12515
12516 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
12517}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012518
12519DEFUN (show_ip_bgp_view_neighbor_received_routes,
12520 show_ip_bgp_view_neighbor_received_routes_cmd,
12521 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12522 SHOW_STR
12523 IP_STR
12524 BGP_STR
12525 "BGP view\n"
12526 "View name\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 received routes from neighbor\n")
12531{
12532 struct peer *peer;
12533
12534 if (argc == 2)
12535 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12536 else
12537 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12538
12539 if (! peer)
12540 return CMD_WARNING;
12541
12542 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12543}
12544
12545ALIAS (show_ip_bgp_view_neighbor_received_routes,
12546 show_ip_bgp_neighbor_received_routes_cmd,
12547 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12548 SHOW_STR
12549 IP_STR
12550 BGP_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 received routes from neighbor\n")
12555
12556ALIAS (show_bgp_view_neighbor_received_routes,
12557 show_bgp_ipv6_neighbor_received_routes_cmd,
12558 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
12559 SHOW_STR
12560 BGP_STR
12561 "Address family\n"
12562 "Detailed information on TCP and BGP neighbor connections\n"
12563 "Neighbor to display information about\n"
12564 "Neighbor to display information about\n"
12565 "Display the received routes from neighbor\n")
12566
12567DEFUN (show_bgp_neighbor_received_prefix_filter,
12568 show_bgp_neighbor_received_prefix_filter_cmd,
12569 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12570 SHOW_STR
12571 BGP_STR
12572 "Detailed information on TCP and BGP neighbor connections\n"
12573 "Neighbor to display information about\n"
12574 "Neighbor to display information about\n"
12575 "Display information received from a BGP neighbor\n"
12576 "Display the prefixlist filter\n")
12577{
12578 char name[BUFSIZ];
12579 union sockunion su;
12580 struct peer *peer;
12581 int count, ret;
12582
12583 ret = str2sockunion (argv[0], &su);
12584 if (ret < 0)
12585 {
12586 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12587 return CMD_WARNING;
12588 }
12589
12590 peer = peer_lookup (NULL, &su);
12591 if (! peer)
12592 return CMD_WARNING;
12593
12594 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12595 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12596 if (count)
12597 {
12598 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12599 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12600 }
12601
12602 return CMD_SUCCESS;
12603}
12604
12605/* old command */
12606ALIAS (show_bgp_view_neighbor_received_routes,
12607 ipv6_bgp_neighbor_received_routes_cmd,
12608 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12609 SHOW_STR
12610 IPV6_STR
12611 BGP_STR
12612 "Detailed information on TCP and BGP neighbor connections\n"
12613 "Neighbor to display information about\n"
12614 "Neighbor to display information about\n"
12615 "Display the received routes from neighbor\n")
12616
12617/* old command */
12618DEFUN (ipv6_mbgp_neighbor_received_routes,
12619 ipv6_mbgp_neighbor_received_routes_cmd,
12620 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12621 SHOW_STR
12622 IPV6_STR
12623 MBGP_STR
12624 "Detailed information on TCP and BGP neighbor connections\n"
12625 "Neighbor to display information about\n"
12626 "Neighbor to display information about\n"
12627 "Display the received routes from neighbor\n")
12628{
12629 struct peer *peer;
12630
12631 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12632 if (! peer)
12633 return CMD_WARNING;
12634
12635 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
12636}
12637
12638DEFUN (show_bgp_view_neighbor_received_prefix_filter,
12639 show_bgp_view_neighbor_received_prefix_filter_cmd,
12640 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12641 SHOW_STR
12642 BGP_STR
12643 "BGP view\n"
12644 "View name\n"
12645 "Detailed information on TCP and BGP neighbor connections\n"
12646 "Neighbor to display information about\n"
12647 "Neighbor to display information about\n"
12648 "Display information received from a BGP neighbor\n"
12649 "Display the prefixlist filter\n")
12650{
12651 char name[BUFSIZ];
12652 union sockunion su;
12653 struct peer *peer;
12654 struct bgp *bgp;
12655 int count, ret;
12656
12657 /* BGP structure lookup. */
12658 bgp = bgp_lookup_by_name (argv[0]);
12659 if (bgp == NULL)
12660 {
12661 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
12662 return CMD_WARNING;
12663 }
12664
12665 ret = str2sockunion (argv[1], &su);
12666 if (ret < 0)
12667 {
12668 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
12669 return CMD_WARNING;
12670 }
12671
12672 peer = peer_lookup (bgp, &su);
12673 if (! peer)
12674 return CMD_WARNING;
12675
12676 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12677 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12678 if (count)
12679 {
12680 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12681 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12682 }
12683
12684 return CMD_SUCCESS;
12685}
12686
12687
12688DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
12689 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
12690 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
12691 SHOW_STR
12692 IP_STR
12693 BGP_STR
12694 "Address family\n"
12695 "Address Family modifier\n"
12696 "Address Family modifier\n"
12697 "Detailed information on TCP and BGP neighbor connections\n"
12698 "Neighbor to display information about\n"
12699 "Neighbor to display information about\n"
12700 "Display the received routes from neighbor\n")
12701{
12702 struct peer *peer;
12703
12704 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12705 if (! peer)
12706 return CMD_WARNING;
12707
12708 if (strncmp (argv[0], "m", 1) == 0)
12709 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
12710
12711 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12712}
12713
Lou Berger651b4022016-01-12 13:42:07 -050012714DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
12715 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
12716 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012717 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012718 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012719 "Address Family modifier\n"
12720 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012721 "Detailed information on TCP and BGP neighbor connections\n"
12722 "Neighbor to display information about\n"
12723 "Neighbor to display information about\n"
12724 "Display the routes advertised to a BGP neighbor\n")
12725{
12726 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012727 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012728
Lou Berger651b4022016-01-12 13:42:07 -050012729 if (bgp_parse_safi(argv[0], &safi)) {
12730 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012731 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050012732 }
paul718e3742002-12-13 20:15:29 +000012733
paulbb46e942003-10-24 19:02:03 +000012734 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12735 if (! peer)
12736 return CMD_WARNING;
12737
Lou Berger651b4022016-01-12 13:42:07 -050012738 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
12739}
Lou Berger205e6742016-01-12 13:42:11 -050012740
Lou Berger651b4022016-01-12 13:42:07 -050012741DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
12742 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
12743 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12744 SHOW_STR
12745 BGP_STR
12746 "Address Family modifier\n"
12747 "Address Family modifier\n"
12748 "Address Family modifier\n"
12749 "Detailed information on TCP and BGP neighbor connections\n"
12750 "Neighbor to display information about\n"
12751 "Neighbor to display information about\n"
12752 "Display the routes advertised to a BGP neighbor\n")
12753{
12754 struct peer *peer;
12755 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000012756
Lou Berger651b4022016-01-12 13:42:07 -050012757 if (bgp_parse_safi(argv[0], &safi)) {
12758 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12759 return CMD_WARNING;
12760 }
12761
12762 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12763 if (! peer)
12764 return CMD_WARNING;
12765
12766 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000012767}
12768
Lou Bergerf9b6c392016-01-12 13:42:09 -050012769DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050012770 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
12771 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000012772 SHOW_STR
12773 BGP_STR
12774 "BGP view\n"
12775 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050012776 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000012777 "Detailed information on TCP and BGP neighbor connections\n"
12778 "Neighbor to display information about\n"
12779 "Neighbor to display information about\n"
12780 "Display the routes advertised to a BGP neighbor\n")
12781{
12782 struct peer *peer;
12783
12784 if (argc == 2)
12785 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12786 else
12787 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12788
12789 if (! peer)
12790 return CMD_WARNING;
12791
12792 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12793}
12794
Lou Bergerf9b6c392016-01-12 13:42:09 -050012795DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050012796 show_bgp_view_ipv6_neighbor_received_routes_cmd,
12797 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000012798 SHOW_STR
12799 BGP_STR
12800 "BGP view\n"
12801 "View name\n"
12802 "Address family\n"
12803 "Detailed information on TCP and BGP neighbor connections\n"
12804 "Neighbor to display information about\n"
12805 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000012806 "Display the received routes from neighbor\n")
12807{
12808 struct peer *peer;
12809
12810 if (argc == 2)
12811 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12812 else
12813 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12814
12815 if (! peer)
12816 return CMD_WARNING;
12817
12818 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12819}
Lou Berger651b4022016-01-12 13:42:07 -050012820
12821DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
12822 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
12823 "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 +010012824 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012825 BGP_STR
12826 "Address family\n"
12827 "Address Family modifier\n"
12828 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012829 "Address Family modifier\n"
12830 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000012831 "Detailed information on TCP and BGP neighbor connections\n"
12832 "Neighbor to display information about\n"
12833 "Neighbor to display information about\n"
12834 "Display the received routes from neighbor\n")
12835{
paulbb46e942003-10-24 19:02:03 +000012836 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012837 safi_t safi;
12838
12839 if (bgp_parse_safi(argv[0], &safi)) {
12840 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12841 return CMD_WARNING;
12842 }
paul718e3742002-12-13 20:15:29 +000012843
paulbb46e942003-10-24 19:02:03 +000012844 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12845 if (! peer)
12846 return CMD_WARNING;
12847
Lou Berger651b4022016-01-12 13:42:07 -050012848 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000012849}
Lou Berger205e6742016-01-12 13:42:11 -050012850
Lou Berger651b4022016-01-12 13:42:07 -050012851DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
12852 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
12853 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
12854 SHOW_STR
12855 BGP_STR
12856 "Address family\n"
12857 "Address Family modifier\n"
12858 "Address Family modifier\n"
12859 "Address Family modifier\n"
12860 "Address Family modifier\n"
12861 "Detailed information on TCP and BGP neighbor connections\n"
12862 "Neighbor to display information about\n"
12863 "Neighbor to display information about\n"
12864 "Display the received routes from neighbor\n")
12865{
12866 struct peer *peer;
12867 safi_t safi;
12868
12869 if (bgp_parse_safi(argv[0], &safi)) {
12870 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12871 return CMD_WARNING;
12872 }
12873
12874 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12875 if (! peer)
12876 return CMD_WARNING;
12877
12878 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
12879}
paul718e3742002-12-13 20:15:29 +000012880
Michael Lambert95cbbd22010-07-23 14:43:04 -040012881DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
12882 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040012883 "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 -040012884 SHOW_STR
12885 BGP_STR
12886 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000012887 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012888 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012889 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012890 "Address family modifier\n"
12891 "Address family modifier\n"
12892 "Detailed information on TCP and BGP neighbor connections\n"
12893 "Neighbor to display information about\n"
12894 "Neighbor to display information about\n"
12895 "Display the advertised routes to neighbor\n"
12896 "Display the received routes from neighbor\n")
12897{
12898 int afi;
12899 int safi;
12900 int in;
12901 struct peer *peer;
12902
David Lamparter94bad672015-03-03 08:52:22 +010012903 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040012904
12905 if (! peer)
12906 return CMD_WARNING;
12907
Michael Lambert95cbbd22010-07-23 14:43:04 -040012908 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12909 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12910 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040012911
12912 return peer_adj_routes (vty, peer, afi, safi, in);
12913}
12914
Lou Bergerf9b6c392016-01-12 13:42:09 -050012915DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
12916 show_ip_bgp_neighbor_received_prefix_filter_cmd,
12917 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12918 SHOW_STR
12919 IP_STR
12920 BGP_STR
12921 "Detailed information on TCP and BGP neighbor connections\n"
12922 "Neighbor to display information about\n"
12923 "Neighbor to display information about\n"
12924 "Display information received from a BGP neighbor\n"
12925 "Display the prefixlist filter\n")
12926{
12927 char name[BUFSIZ];
12928 union sockunion su;
12929 struct peer *peer;
12930 int count, ret;
12931
12932 ret = str2sockunion (argv[0], &su);
12933 if (ret < 0)
12934 {
12935 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12936 return CMD_WARNING;
12937 }
12938
12939 peer = peer_lookup (NULL, &su);
12940 if (! peer)
12941 return CMD_WARNING;
12942
12943 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
12944 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
12945 if (count)
12946 {
12947 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
12948 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
12949 }
12950
12951 return CMD_SUCCESS;
12952}
12953
12954DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
12955 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
12956 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12957 SHOW_STR
12958 IP_STR
12959 BGP_STR
12960 "Address family\n"
12961 "Address Family modifier\n"
12962 "Address Family modifier\n"
12963 "Detailed information on TCP and BGP neighbor connections\n"
12964 "Neighbor to display information about\n"
12965 "Neighbor to display information about\n"
12966 "Display information received from a BGP neighbor\n"
12967 "Display the prefixlist filter\n")
12968{
12969 char name[BUFSIZ];
12970 union sockunion su;
12971 struct peer *peer;
12972 int count, ret;
12973
12974 ret = str2sockunion (argv[1], &su);
12975 if (ret < 0)
12976 {
12977 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
12978 return CMD_WARNING;
12979 }
12980
12981 peer = peer_lookup (NULL, &su);
12982 if (! peer)
12983 return CMD_WARNING;
12984
12985 if (strncmp (argv[0], "m", 1) == 0)
12986 {
12987 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
12988 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
12989 if (count)
12990 {
12991 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
12992 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
12993 }
12994 }
12995 else
12996 {
12997 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
12998 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
12999 if (count)
13000 {
13001 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13002 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13003 }
13004 }
13005
13006 return CMD_SUCCESS;
13007}
13008
13009ALIAS (show_bgp_view_neighbor_received_routes,
13010 show_bgp_neighbor_received_routes_cmd,
13011 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13012 SHOW_STR
13013 BGP_STR
13014 "Detailed information on TCP and BGP neighbor connections\n"
13015 "Neighbor to display information about\n"
13016 "Neighbor to display information about\n"
13017 "Display the received routes from neighbor\n")
13018
Lou Berger651b4022016-01-12 13:42:07 -050013019DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
13020 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
13021 "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 +000013022 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013023 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013024 IP_STR
13025 "Address Family modifier\n"
13026 "Address Family modifier\n"
13027 "Address Family modifier\n"
13028 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013029 "Detailed information on TCP and BGP neighbor connections\n"
13030 "Neighbor to display information about\n"
13031 "Neighbor to display information about\n"
13032 "Display information received from a BGP neighbor\n"
13033 "Display the prefixlist filter\n")
13034{
13035 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013036 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013037 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013038 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050013039 safi_t safi;
paul718e3742002-12-13 20:15:29 +000013040
Lou Berger651b4022016-01-12 13:42:07 -050013041 if (bgp_parse_safi(argv[0], &safi)) {
13042 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013043 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013044 }
paul718e3742002-12-13 20:15:29 +000013045
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013046 ret = str2sockunion (argv[1], &su);
13047 if (ret < 0)
13048 {
13049 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13050 return CMD_WARNING;
13051 }
paul718e3742002-12-13 20:15:29 +000013052
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013053 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013054 if (! peer)
13055 return CMD_WARNING;
13056
Lou Berger651b4022016-01-12 13:42:07 -050013057 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
13058 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13059 if (count) {
13060 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
13061 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13062 }
paul718e3742002-12-13 20:15:29 +000013063
13064 return CMD_SUCCESS;
13065}
Lou Berger205e6742016-01-12 13:42:11 -050013066
Lou Berger651b4022016-01-12 13:42:07 -050013067DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
13068 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
13069 "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 +000013070 SHOW_STR
13071 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013072 IP_STR
13073 "Address Family modifier\n"
13074 "Address Family modifier\n"
13075 "Address Family modifier\n"
13076 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013077 "Detailed information on TCP and BGP neighbor connections\n"
13078 "Neighbor to display information about\n"
13079 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050013080 "Display information received from a BGP neighbor\n"
13081 "Display the prefixlist filter\n")
13082{
13083 char name[BUFSIZ];
13084 union sockunion su;
13085 struct peer *peer;
13086 int count, ret;
13087 safi_t safi;
13088
13089 if (bgp_parse_safi(argv[0], &safi)) {
13090 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13091 return CMD_WARNING;
13092 }
13093
13094 ret = str2sockunion (argv[1], &su);
13095 if (ret < 0)
13096 {
13097 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13098 return CMD_WARNING;
13099 }
13100
13101 peer = peer_lookup (NULL, &su);
13102 if (! peer)
13103 return CMD_WARNING;
13104
13105 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
13106 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13107 if (count) {
13108 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
13109 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13110 }
13111
13112 return CMD_SUCCESS;
13113}
paul718e3742002-12-13 20:15:29 +000013114
Lou Bergerf9b6c392016-01-12 13:42:09 -050013115DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013116 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
13117 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013118 SHOW_STR
13119 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013120 "Address family\n"
paul718e3742002-12-13 20:15:29 +000013121 "Detailed information on TCP and BGP neighbor connections\n"
13122 "Neighbor to display information about\n"
13123 "Neighbor to display information about\n"
13124 "Display information received from a BGP neighbor\n"
13125 "Display the prefixlist filter\n")
13126{
13127 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013128 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013129 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013130 int count, ret;
paul718e3742002-12-13 20:15:29 +000013131
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013132 ret = str2sockunion (argv[0], &su);
13133 if (ret < 0)
13134 {
13135 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13136 return CMD_WARNING;
13137 }
paul718e3742002-12-13 20:15:29 +000013138
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013139 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013140 if (! peer)
13141 return CMD_WARNING;
13142
13143 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13144 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13145 if (count)
13146 {
13147 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13148 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13149 }
13150
13151 return CMD_SUCCESS;
13152}
13153
Lou Bergerf9b6c392016-01-12 13:42:09 -050013154DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013155 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
13156 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000013157 SHOW_STR
13158 BGP_STR
13159 "BGP view\n"
13160 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013161 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013162 "Detailed information on TCP and BGP neighbor connections\n"
13163 "Neighbor to display information about\n"
13164 "Neighbor to display information about\n"
13165 "Display information received from a BGP neighbor\n"
13166 "Display the prefixlist filter\n")
13167{
13168 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013169 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000013170 struct peer *peer;
13171 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013172 int count, ret;
paulbb46e942003-10-24 19:02:03 +000013173
13174 /* BGP structure lookup. */
13175 bgp = bgp_lookup_by_name (argv[0]);
13176 if (bgp == NULL)
13177 {
13178 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13179 return CMD_WARNING;
13180 }
13181
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013182 ret = str2sockunion (argv[1], &su);
13183 if (ret < 0)
13184 {
13185 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13186 return CMD_WARNING;
13187 }
paulbb46e942003-10-24 19:02:03 +000013188
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013189 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000013190 if (! peer)
13191 return CMD_WARNING;
13192
13193 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13194 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13195 if (count)
13196 {
13197 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13198 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13199 }
13200
13201 return CMD_SUCCESS;
13202}
David Lamparter6b0655a2014-06-04 06:53:35 +020013203
paul94f2b392005-06-28 12:44:16 +000013204static int
paulbb46e942003-10-24 19:02:03 +000013205bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000013206 safi_t safi, enum bgp_show_type type)
13207{
paul718e3742002-12-13 20:15:29 +000013208 if (! peer || ! peer->afc[afi][safi])
13209 {
13210 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013211 return CMD_WARNING;
13212 }
13213
ajs5a646652004-11-05 01:25:55 +000013214 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000013215}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013216DEFUN (show_ip_bgp_neighbor_routes,
13217 show_ip_bgp_neighbor_routes_cmd,
13218 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
13219 SHOW_STR
13220 IP_STR
13221 BGP_STR
13222 "Detailed information on TCP and BGP neighbor connections\n"
13223 "Neighbor to display information about\n"
13224 "Neighbor to display information about\n"
13225 "Display routes learned from neighbor\n")
13226{
13227 struct peer *peer;
13228
13229 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13230 if (! peer)
13231 return CMD_WARNING;
13232
13233 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13234 bgp_show_type_neighbor);
13235}
13236
13237DEFUN (show_ip_bgp_neighbor_flap,
13238 show_ip_bgp_neighbor_flap_cmd,
13239 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
13240 SHOW_STR
13241 IP_STR
13242 BGP_STR
13243 "Detailed information on TCP and BGP neighbor connections\n"
13244 "Neighbor to display information about\n"
13245 "Neighbor to display information about\n"
13246 "Display flap statistics of the routes learned from neighbor\n")
13247{
13248 struct peer *peer;
13249
13250 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13251 if (! peer)
13252 return CMD_WARNING;
13253
13254 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13255 bgp_show_type_flap_neighbor);
13256}
13257
13258DEFUN (show_ip_bgp_neighbor_damp,
13259 show_ip_bgp_neighbor_damp_cmd,
13260 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13261 SHOW_STR
13262 IP_STR
13263 BGP_STR
13264 "Detailed information on TCP and BGP neighbor connections\n"
13265 "Neighbor to display information about\n"
13266 "Neighbor to display information about\n"
13267 "Display the dampened routes received from neighbor\n")
13268{
13269 struct peer *peer;
13270
13271 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13272 if (! peer)
13273 return CMD_WARNING;
13274
13275 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13276 bgp_show_type_damp_neighbor);
13277}
13278
13279DEFUN (show_ip_bgp_ipv4_neighbor_routes,
13280 show_ip_bgp_ipv4_neighbor_routes_cmd,
13281 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
13282 SHOW_STR
13283 IP_STR
13284 BGP_STR
13285 "Address family\n"
13286 "Address Family modifier\n"
13287 "Address Family modifier\n"
13288 "Detailed information on TCP and BGP neighbor connections\n"
13289 "Neighbor to display information about\n"
13290 "Neighbor to display information about\n"
13291 "Display routes learned from neighbor\n")
13292{
13293 struct peer *peer;
13294
13295 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13296 if (! peer)
13297 return CMD_WARNING;
13298
13299 if (strncmp (argv[0], "m", 1) == 0)
13300 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
13301 bgp_show_type_neighbor);
13302
13303 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13304 bgp_show_type_neighbor);
13305}
13306
13307DEFUN (show_ip_bgp_view_rsclient,
13308 show_ip_bgp_view_rsclient_cmd,
13309 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
13310 SHOW_STR
13311 IP_STR
13312 BGP_STR
13313 "BGP view\n"
13314 "View name\n"
13315 "Information about Route Server Client\n"
13316 NEIGHBOR_ADDR_STR)
13317{
13318 struct bgp_table *table;
13319 struct peer *peer;
13320
13321 if (argc == 2)
13322 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13323 else
13324 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13325
13326 if (! peer)
13327 return CMD_WARNING;
13328
13329 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13330 {
13331 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13332 VTY_NEWLINE);
13333 return CMD_WARNING;
13334 }
13335
13336 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13337 PEER_FLAG_RSERVER_CLIENT))
13338 {
13339 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13340 VTY_NEWLINE);
13341 return CMD_WARNING;
13342 }
13343
13344 table = peer->rib[AFI_IP][SAFI_UNICAST];
13345
13346 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13347}
13348
13349ALIAS (show_ip_bgp_view_rsclient,
13350 show_ip_bgp_rsclient_cmd,
13351 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
13352 SHOW_STR
13353 IP_STR
13354 BGP_STR
13355 "Information about Route Server Client\n"
13356 NEIGHBOR_ADDR_STR)
13357
13358DEFUN (show_bgp_view_ipv4_safi_rsclient,
13359 show_bgp_view_ipv4_safi_rsclient_cmd,
13360 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13361 SHOW_STR
13362 BGP_STR
13363 "BGP view\n"
13364 "View name\n"
13365 "Address family\n"
13366 "Address Family modifier\n"
13367 "Address Family modifier\n"
13368 "Information about Route Server Client\n"
13369 NEIGHBOR_ADDR_STR)
13370{
13371 struct bgp_table *table;
13372 struct peer *peer;
13373 safi_t safi;
13374
13375 if (argc == 3) {
13376 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13377 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13378 } else {
13379 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13380 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13381 }
13382
13383 if (! peer)
13384 return CMD_WARNING;
13385
13386 if (! peer->afc[AFI_IP][safi])
13387 {
13388 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13389 VTY_NEWLINE);
13390 return CMD_WARNING;
13391 }
13392
13393 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13394 PEER_FLAG_RSERVER_CLIENT))
13395 {
13396 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13397 VTY_NEWLINE);
13398 return CMD_WARNING;
13399 }
13400
13401 table = peer->rib[AFI_IP][safi];
13402
13403 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13404}
13405
13406ALIAS (show_bgp_view_ipv4_safi_rsclient,
13407 show_bgp_ipv4_safi_rsclient_cmd,
13408 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13409 SHOW_STR
13410 BGP_STR
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
13417DEFUN (show_ip_bgp_view_rsclient_route,
13418 show_ip_bgp_view_rsclient_route_cmd,
13419 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13420 SHOW_STR
13421 IP_STR
13422 BGP_STR
13423 "BGP view\n"
13424 "View name\n"
13425 "Information about Route Server Client\n"
13426 NEIGHBOR_ADDR_STR
13427 "Network in the BGP routing table to display\n")
13428{
13429 struct bgp *bgp;
13430 struct peer *peer;
13431
13432 /* BGP structure lookup. */
13433 if (argc == 3)
13434 {
13435 bgp = bgp_lookup_by_name (argv[0]);
13436 if (bgp == NULL)
13437 {
13438 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13439 return CMD_WARNING;
13440 }
13441 }
13442 else
13443 {
13444 bgp = bgp_get_default ();
13445 if (bgp == NULL)
13446 {
13447 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13448 return CMD_WARNING;
13449 }
13450 }
13451
13452 if (argc == 3)
13453 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13454 else
13455 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13456
13457 if (! peer)
13458 return CMD_WARNING;
13459
13460 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13461 {
13462 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13463 VTY_NEWLINE);
13464 return CMD_WARNING;
13465}
13466
13467 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13468 PEER_FLAG_RSERVER_CLIENT))
13469 {
13470 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13471 VTY_NEWLINE);
13472 return CMD_WARNING;
13473 }
13474
13475 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13476 (argc == 3) ? argv[2] : argv[1],
13477 AFI_IP, SAFI_UNICAST, NULL, 0);
13478}
13479
13480ALIAS (show_ip_bgp_view_rsclient_route,
13481 show_ip_bgp_rsclient_route_cmd,
13482 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13483 SHOW_STR
13484 IP_STR
13485 BGP_STR
13486 "Information about Route Server Client\n"
13487 NEIGHBOR_ADDR_STR
13488 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000013489
Lou Berger651b4022016-01-12 13:42:07 -050013490DEFUN (show_bgp_ipv4_safi_neighbor_flap,
13491 show_bgp_ipv4_safi_neighbor_flap_cmd,
13492 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013493 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013494 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013495 "Address Family Modifier\n"
13496 "Address Family Modifier\n"
13497 "Address Family Modifier\n"
13498 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013499 "Detailed information on TCP and BGP neighbor connections\n"
13500 "Neighbor to display information about\n"
13501 "Neighbor to display information about\n"
13502 "Display flap statistics of the routes learned from neighbor\n")
13503{
paulbb46e942003-10-24 19:02:03 +000013504 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013505 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013506
Lou Berger651b4022016-01-12 13:42:07 -050013507 if (bgp_parse_safi(argv[0], &safi)) {
13508 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13509 return CMD_WARNING;
13510 }
13511
13512 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013513 if (! peer)
13514 return CMD_WARNING;
13515
Lou Berger651b4022016-01-12 13:42:07 -050013516 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013517 bgp_show_type_flap_neighbor);
13518}
Lou Berger205e6742016-01-12 13:42:11 -050013519
Lou Berger651b4022016-01-12 13:42:07 -050013520DEFUN (show_bgp_ipv6_safi_neighbor_flap,
13521 show_bgp_ipv6_safi_neighbor_flap_cmd,
13522 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013523 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013524 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013525 "Address Family Modifier\n"
13526 "Address Family Modifier\n"
13527 "Address Family Modifier\n"
13528 "Address Family Modifier\n"
13529 "Detailed information on TCP and BGP neighbor connections\n"
13530 "Neighbor to display information about\n"
13531 "Neighbor to display information about\n"
13532 "Display flap statistics of the routes learned from neighbor\n")
13533{
13534 struct peer *peer;
13535 safi_t safi;
13536
13537 if (bgp_parse_safi(argv[0], &safi)) {
13538 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13539 return CMD_WARNING;
13540 }
13541
13542 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13543 if (! peer)
13544 return CMD_WARNING;
13545
13546 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13547 bgp_show_type_flap_neighbor);
13548}
Lou Berger651b4022016-01-12 13:42:07 -050013549
13550DEFUN (show_bgp_ipv4_safi_neighbor_damp,
13551 show_bgp_ipv4_safi_neighbor_damp_cmd,
13552 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13553 SHOW_STR
13554 BGP_STR
13555 "Address Family Modifier\n"
13556 "Address Family Modifier\n"
13557 "Address Family Modifier\n"
13558 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013559 "Detailed information on TCP and BGP neighbor connections\n"
13560 "Neighbor to display information about\n"
13561 "Neighbor to display information about\n"
13562 "Display the dampened routes received from neighbor\n")
13563{
paulbb46e942003-10-24 19:02:03 +000013564 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013565 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013566
Lou Berger651b4022016-01-12 13:42:07 -050013567 if (bgp_parse_safi(argv[0], &safi)) {
13568 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13569 return CMD_WARNING;
13570 }
13571
13572 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013573 if (! peer)
13574 return CMD_WARNING;
13575
Lou Berger651b4022016-01-12 13:42:07 -050013576 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013577 bgp_show_type_damp_neighbor);
13578}
Lou Berger205e6742016-01-12 13:42:11 -050013579
Lou Berger651b4022016-01-12 13:42:07 -050013580DEFUN (show_bgp_ipv6_safi_neighbor_damp,
13581 show_bgp_ipv6_safi_neighbor_damp_cmd,
13582 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000013583 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050013584 BGP_STR
13585 "Address Family Modifier\n"
13586 "Address Family Modifier\n"
13587 "Address Family Modifier\n"
13588 "Address Family Modifier\n"
13589 "Detailed information on TCP and BGP neighbor connections\n"
13590 "Neighbor to display information about\n"
13591 "Neighbor to display information about\n"
13592 "Display the dampened routes received from neighbor\n")
13593{
13594 struct peer *peer;
13595 safi_t safi;
13596
13597 if (bgp_parse_safi(argv[0], &safi)) {
13598 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13599 return CMD_WARNING;
13600 }
13601
13602 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13603 if (! peer)
13604 return CMD_WARNING;
13605
13606 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13607 bgp_show_type_damp_neighbor);
13608}
Lou Berger651b4022016-01-12 13:42:07 -050013609
13610DEFUN (show_bgp_ipv4_safi_neighbor_routes,
13611 show_bgp_ipv4_safi_neighbor_routes_cmd,
13612 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
13613 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013614 BGP_STR
13615 "Address family\n"
13616 "Address Family modifier\n"
13617 "Address Family modifier\n"
13618 "Detailed information on TCP and BGP neighbor connections\n"
13619 "Neighbor to display information about\n"
13620 "Neighbor to display information about\n"
13621 "Display routes learned from neighbor\n")
13622{
paulbb46e942003-10-24 19:02:03 +000013623 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013624 safi_t safi;
13625
13626 if (bgp_parse_safi(argv[0], &safi)) {
13627 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13628 return CMD_WARNING;
13629 }
paulbb46e942003-10-24 19:02:03 +000013630
13631 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13632 if (! peer)
13633 return CMD_WARNING;
13634
Lou Berger651b4022016-01-12 13:42:07 -050013635 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013636 bgp_show_type_neighbor);
13637}
Lou Berger205e6742016-01-12 13:42:11 -050013638
Lou Berger651b4022016-01-12 13:42:07 -050013639DEFUN (show_bgp_ipv6_safi_neighbor_routes,
13640 show_bgp_ipv6_safi_neighbor_routes_cmd,
13641 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000013642 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000013643 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013644 "Address family\n"
13645 "Address Family modifier\n"
13646 "Address Family modifier\n"
13647 "Detailed information on TCP and BGP neighbor connections\n"
13648 NEIGHBOR_ADDR_STR
13649 NEIGHBOR_ADDR_STR
13650 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000013651{
paulfee0f4c2004-09-13 05:12:46 +000013652 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013653 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000013654
Lou Berger651b4022016-01-12 13:42:07 -050013655 if (bgp_parse_safi(argv[0], &safi)) {
13656 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13657 return CMD_WARNING;
13658 }
paulfee0f4c2004-09-13 05:12:46 +000013659
Lou Berger651b4022016-01-12 13:42:07 -050013660 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000013661 if (! peer)
13662 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013663
13664 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13665 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000013666}
paulfee0f4c2004-09-13 05:12:46 +000013667
Michael Lambert95cbbd22010-07-23 14:43:04 -040013668DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
13669 show_bgp_view_ipv4_safi_rsclient_route_cmd,
13670 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13671 SHOW_STR
13672 BGP_STR
13673 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013674 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013675 "Address family\n"
13676 "Address Family modifier\n"
13677 "Address Family modifier\n"
13678 "Information about Route Server Client\n"
13679 NEIGHBOR_ADDR_STR
13680 "Network in the BGP routing table to display\n")
13681{
13682 struct bgp *bgp;
13683 struct peer *peer;
13684 safi_t safi;
13685
13686 /* BGP structure lookup. */
13687 if (argc == 4)
13688 {
13689 bgp = bgp_lookup_by_name (argv[0]);
13690 if (bgp == NULL)
13691 {
13692 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13693 return CMD_WARNING;
13694 }
13695 }
13696 else
13697 {
13698 bgp = bgp_get_default ();
13699 if (bgp == NULL)
13700 {
13701 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13702 return CMD_WARNING;
13703 }
13704 }
13705
13706 if (argc == 4) {
13707 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13708 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13709 } else {
13710 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13711 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13712 }
13713
13714 if (! peer)
13715 return CMD_WARNING;
13716
13717 if (! peer->afc[AFI_IP][safi])
13718 {
13719 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13720 VTY_NEWLINE);
13721 return CMD_WARNING;
13722}
13723
13724 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13725 PEER_FLAG_RSERVER_CLIENT))
13726 {
13727 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13728 VTY_NEWLINE);
13729 return CMD_WARNING;
13730 }
13731
13732 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13733 (argc == 4) ? argv[3] : argv[2],
13734 AFI_IP, safi, NULL, 0);
13735}
13736
13737ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
13738 show_bgp_ipv4_safi_rsclient_route_cmd,
13739 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13740 SHOW_STR
13741 BGP_STR
13742 "Address family\n"
13743 "Address Family modifier\n"
13744 "Address Family modifier\n"
13745 "Information about Route Server Client\n"
13746 NEIGHBOR_ADDR_STR
13747 "Network in the BGP routing table to display\n")
13748
paulfee0f4c2004-09-13 05:12:46 +000013749
Michael Lambert95cbbd22010-07-23 14:43:04 -040013750DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
13751 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
13752 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13753 SHOW_STR
13754 BGP_STR
13755 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013756 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013757 "Address family\n"
13758 "Address Family modifier\n"
13759 "Address Family modifier\n"
13760 "Information about Route Server Client\n"
13761 NEIGHBOR_ADDR_STR
13762 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13763{
13764 struct bgp *bgp;
13765 struct peer *peer;
13766 safi_t safi;
13767
13768 /* BGP structure lookup. */
13769 if (argc == 4)
13770 {
13771 bgp = bgp_lookup_by_name (argv[0]);
13772 if (bgp == NULL)
13773 {
13774 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13775 return CMD_WARNING;
13776 }
13777 }
13778 else
13779 {
13780 bgp = bgp_get_default ();
13781 if (bgp == NULL)
13782 {
13783 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13784 return CMD_WARNING;
13785 }
13786 }
13787
13788 if (argc == 4) {
13789 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13790 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13791 } else {
13792 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13793 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13794 }
13795
13796 if (! peer)
13797 return CMD_WARNING;
13798
13799 if (! peer->afc[AFI_IP][safi])
13800 {
13801 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13802 VTY_NEWLINE);
13803 return CMD_WARNING;
13804}
13805
13806 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13807 PEER_FLAG_RSERVER_CLIENT))
13808{
13809 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13810 VTY_NEWLINE);
13811 return CMD_WARNING;
13812 }
13813
13814 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13815 (argc == 4) ? argv[3] : argv[2],
13816 AFI_IP, safi, NULL, 1);
13817}
13818
Lou Bergerf9b6c392016-01-12 13:42:09 -050013819DEFUN (show_ip_bgp_view_rsclient_prefix,
13820 show_ip_bgp_view_rsclient_prefix_cmd,
13821 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13822 SHOW_STR
13823 IP_STR
13824 BGP_STR
13825 "BGP view\n"
13826 "View name\n"
13827 "Information about Route Server Client\n"
13828 NEIGHBOR_ADDR_STR
13829 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13830{
13831 struct bgp *bgp;
13832 struct peer *peer;
13833
13834 /* BGP structure lookup. */
13835 if (argc == 3)
13836 {
13837 bgp = bgp_lookup_by_name (argv[0]);
13838 if (bgp == NULL)
13839 {
13840 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13841 return CMD_WARNING;
13842 }
13843 }
13844 else
13845 {
13846 bgp = bgp_get_default ();
13847 if (bgp == NULL)
13848 {
13849 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13850 return CMD_WARNING;
13851 }
13852 }
13853
13854 if (argc == 3)
13855 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13856 else
13857 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13858
13859 if (! peer)
13860 return CMD_WARNING;
13861
13862 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13863 {
13864 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13865 VTY_NEWLINE);
13866 return CMD_WARNING;
13867}
13868
13869 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13870 PEER_FLAG_RSERVER_CLIENT))
13871{
13872 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13873 VTY_NEWLINE);
13874 return CMD_WARNING;
13875 }
13876
13877 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13878 (argc == 3) ? argv[2] : argv[1],
13879 AFI_IP, SAFI_UNICAST, NULL, 1);
13880}
13881
13882ALIAS (show_ip_bgp_view_rsclient_prefix,
13883 show_ip_bgp_rsclient_prefix_cmd,
13884 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13885 SHOW_STR
13886 IP_STR
13887 BGP_STR
13888 "Information about Route Server Client\n"
13889 NEIGHBOR_ADDR_STR
13890 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13891
Michael Lambert95cbbd22010-07-23 14:43:04 -040013892ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
13893 show_bgp_ipv4_safi_rsclient_prefix_cmd,
13894 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13895 SHOW_STR
13896 BGP_STR
13897 "Address family\n"
13898 "Address Family modifier\n"
13899 "Address Family modifier\n"
13900 "Information about Route Server Client\n"
13901 NEIGHBOR_ADDR_STR
13902 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000013903
Lou Bergerf9b6c392016-01-12 13:42:09 -050013904DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050013905 show_bgp_view_ipv6_neighbor_routes_cmd,
13906 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +000013907 SHOW_STR
13908 BGP_STR
13909 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013910 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013911 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013912 "Detailed information on TCP and BGP neighbor connections\n"
13913 "Neighbor to display information about\n"
13914 "Neighbor to display information about\n"
13915 "Display routes learned from neighbor\n")
13916{
13917 struct peer *peer;
13918
13919 if (argc == 2)
13920 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13921 else
13922 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13923
13924 if (! peer)
13925 return CMD_WARNING;
13926
13927 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13928 bgp_show_type_neighbor);
13929}
13930
Lou Berger651b4022016-01-12 13:42:07 -050013931DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050013932 show_bgp_view_neighbor_damp_cmd,
13933 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13934 SHOW_STR
13935 BGP_STR
13936 "BGP view\n"
13937 "View name\n"
13938 "Detailed information on TCP and BGP neighbor connections\n"
13939 "Neighbor to display information about\n"
13940 "Neighbor to display information about\n"
13941 "Display the dampened routes received from neighbor\n")
13942{
13943 struct peer *peer;
13944
13945 if (argc == 2)
13946 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13947 else
13948 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13949
13950 if (! peer)
13951 return CMD_WARNING;
13952
13953 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13954 bgp_show_type_damp_neighbor);
13955}
13956
13957DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050013958 show_bgp_view_ipv6_neighbor_damp_cmd,
13959 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000013960 SHOW_STR
13961 BGP_STR
13962 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013963 "View name\n"
paulbb46e942003-10-24 19:02:03 +000013964 "Address family\n"
13965 "Detailed information on TCP and BGP neighbor connections\n"
13966 "Neighbor to display information about\n"
13967 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000013968 "Display the dampened routes received from neighbor\n")
13969{
13970 struct peer *peer;
13971
13972 if (argc == 2)
13973 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13974 else
13975 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13976
13977 if (! peer)
13978 return CMD_WARNING;
13979
13980 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13981 bgp_show_type_damp_neighbor);
13982}
13983
Lou Bergerf9b6c392016-01-12 13:42:09 -050013984DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050013985 show_bgp_view_ipv6_neighbor_flap_cmd,
13986 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000013987 SHOW_STR
13988 BGP_STR
13989 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013990 "View name\n"
paulbb46e942003-10-24 19:02:03 +000013991 "Address family\n"
13992 "Detailed information on TCP and BGP neighbor connections\n"
13993 "Neighbor to display information about\n"
13994 "Neighbor to display information about\n"
13995 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000013996{
13997 struct peer *peer;
13998
13999 if (argc == 2)
14000 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14001 else
14002 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14003
14004 if (! peer)
14005 return CMD_WARNING;
14006
14007 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14008 bgp_show_type_flap_neighbor);
14009}
14010
Lou Bergerf9b6c392016-01-12 13:42:09 -050014011DEFUN (show_bgp_view_neighbor_flap,
14012 show_bgp_view_neighbor_flap_cmd,
14013 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14014 SHOW_STR
14015 BGP_STR
14016 "BGP view\n"
14017 "View name\n"
14018 "Detailed information on TCP and BGP neighbor connections\n"
14019 "Neighbor to display information about\n"
14020 "Neighbor to display information about\n"
14021 "Display flap statistics of the routes learned from neighbor\n")
14022{
14023 struct peer *peer;
14024
14025 if (argc == 2)
14026 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14027 else
14028 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14029
14030 if (! peer)
14031 return CMD_WARNING;
14032
14033 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14034 bgp_show_type_flap_neighbor);
14035}
14036
14037ALIAS (show_bgp_view_neighbor_flap,
14038 show_bgp_neighbor_flap_cmd,
14039 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14040 SHOW_STR
14041 BGP_STR
14042 "Detailed information on TCP and BGP neighbor connections\n"
14043 "Neighbor to display information about\n"
14044 "Neighbor to display information about\n"
14045 "Display flap statistics of the routes learned from neighbor\n")
14046
14047ALIAS (show_bgp_view_neighbor_damp,
14048 show_bgp_neighbor_damp_cmd,
14049 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14050 SHOW_STR
14051 BGP_STR
14052 "Detailed information on TCP and BGP neighbor connections\n"
14053 "Neighbor to display information about\n"
14054 "Neighbor to display information about\n"
14055 "Display the dampened routes received from neighbor\n")
14056
14057DEFUN (show_bgp_view_neighbor_routes,
14058 show_bgp_view_neighbor_routes_cmd,
14059 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
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 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_neighbor);
14081}
14082
14083ALIAS (show_bgp_view_neighbor_routes,
14084 show_bgp_neighbor_routes_cmd,
14085 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
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 routes learned from neighbor\n")
14092
paulbb46e942003-10-24 19:02:03 +000014093ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000014094 show_bgp_ipv6_neighbor_routes_cmd,
14095 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
14096 SHOW_STR
14097 BGP_STR
14098 "Address family\n"
14099 "Detailed information on TCP and BGP neighbor connections\n"
14100 "Neighbor to display information about\n"
14101 "Neighbor to display information about\n"
14102 "Display routes learned from neighbor\n")
14103
Lou Bergerf9b6c392016-01-12 13:42:09 -050014104/* old command */
14105ALIAS (show_bgp_view_neighbor_routes,
14106 ipv6_bgp_neighbor_routes_cmd,
14107 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
14108 SHOW_STR
14109 IPV6_STR
14110 BGP_STR
14111 "Detailed information on TCP and BGP neighbor connections\n"
14112 "Neighbor to display information about\n"
14113 "Neighbor to display information about\n"
14114 "Display routes learned from neighbor\n")
14115
14116/* old command */
14117DEFUN (ipv6_mbgp_neighbor_routes,
14118 ipv6_mbgp_neighbor_routes_cmd,
14119 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
14120 SHOW_STR
14121 IPV6_STR
14122 MBGP_STR
14123 "Detailed information on TCP and BGP neighbor connections\n"
14124 "Neighbor to display information about\n"
14125 "Neighbor to display information about\n"
14126 "Display routes learned from neighbor\n")
14127{
14128 struct peer *peer;
14129
14130 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14131 if (! peer)
14132 return CMD_WARNING;
14133
14134 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
14135 bgp_show_type_neighbor);
14136}
14137
paulbb46e942003-10-24 19:02:03 +000014138ALIAS (show_bgp_view_neighbor_flap,
14139 show_bgp_ipv6_neighbor_flap_cmd,
14140 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14141 SHOW_STR
14142 BGP_STR
14143 "Address family\n"
14144 "Detailed information on TCP and BGP neighbor connections\n"
14145 "Neighbor to display information about\n"
14146 "Neighbor to display information about\n"
14147 "Display flap statistics of the routes learned from neighbor\n")
14148
14149ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000014150 show_bgp_ipv6_neighbor_damp_cmd,
14151 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14152 SHOW_STR
14153 BGP_STR
14154 "Address family\n"
14155 "Detailed information on TCP and BGP neighbor connections\n"
14156 "Neighbor to display information about\n"
14157 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000014158 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014159
Lou Bergerf9b6c392016-01-12 13:42:09 -050014160DEFUN (show_bgp_view_rsclient,
14161 show_bgp_view_rsclient_cmd,
14162 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14163 SHOW_STR
14164 BGP_STR
14165 "BGP view\n"
14166 "View name\n"
14167 "Information about Route Server Client\n"
14168 NEIGHBOR_ADDR_STR)
14169{
14170 struct bgp_table *table;
14171 struct peer *peer;
14172
14173 if (argc == 2)
14174 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14175 else
14176 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14177
14178 if (! peer)
14179 return CMD_WARNING;
14180
14181 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14182 {
14183 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14184 VTY_NEWLINE);
14185 return CMD_WARNING;
14186 }
14187
14188 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14189 PEER_FLAG_RSERVER_CLIENT))
14190 {
14191 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14192 VTY_NEWLINE);
14193 return CMD_WARNING;
14194 }
14195
14196 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14197
14198 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14199}
14200
14201ALIAS (show_bgp_view_rsclient,
14202 show_bgp_rsclient_cmd,
14203 "show bgp rsclient (A.B.C.D|X:X::X:X)",
14204 SHOW_STR
14205 BGP_STR
14206 "Information about Route Server Client\n"
14207 NEIGHBOR_ADDR_STR)
14208
Lou Berger651b4022016-01-12 13:42:07 -050014209DEFUN (show_bgp_view_ipv4_rsclient,
14210 show_bgp_view_ipv4_rsclient_cmd,
14211 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014212 SHOW_STR
14213 BGP_STR
14214 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014215 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014216 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014217 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014218 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014219{
Lou Berger651b4022016-01-12 13:42:07 -050014220 struct bgp_table *table;
14221 struct peer *peer;
14222
14223 if (argc == 2)
14224 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14225 else
14226 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14227
14228 if (! peer)
14229 return CMD_WARNING;
14230
14231 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14232 {
14233 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14234 VTY_NEWLINE);
14235 return CMD_WARNING;
14236 }
14237
14238 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14239 PEER_FLAG_RSERVER_CLIENT))
14240 {
14241 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14242 VTY_NEWLINE);
14243 return CMD_WARNING;
14244 }
14245
14246 table = peer->rib[AFI_IP][SAFI_UNICAST];
14247
14248 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14249}
14250DEFUN (show_bgp_view_ipv6_rsclient,
14251 show_bgp_view_ipv6_rsclient_cmd,
14252 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
14253 SHOW_STR
14254 BGP_STR
14255 "BGP view\n"
14256 "BGP view name\n"
14257 "Address Family\n"
14258 "Information about Route Server Client\n"
14259 NEIGHBOR_ADDR_STR2)
14260{
14261 struct bgp_table *table;
14262 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000014263
14264 if (argc == 2)
14265 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14266 else
14267 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14268
14269 if (! peer)
14270 return CMD_WARNING;
14271
14272 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14273 {
14274 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14275 VTY_NEWLINE);
14276 return CMD_WARNING;
14277 }
14278
14279 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14280 PEER_FLAG_RSERVER_CLIENT))
14281 {
14282 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14283 VTY_NEWLINE);
14284 return CMD_WARNING;
14285 }
14286
14287 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14288
ajs5a646652004-11-05 01:25:55 +000014289 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000014290}
14291
Lou Berger651b4022016-01-12 13:42:07 -050014292ALIAS (show_bgp_view_ipv4_rsclient,
14293 show_bgp_ipv4_rsclient_cmd,
14294 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014295 SHOW_STR
14296 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014297 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014298 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014299 NEIGHBOR_ADDR_STR2)
14300
Lou Berger651b4022016-01-12 13:42:07 -050014301ALIAS (show_bgp_view_ipv6_rsclient,
14302 show_bgp_ipv6_rsclient_cmd,
14303 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
14304 SHOW_STR
14305 BGP_STR
14306 "Address Family\n"
14307 "Information about Route Server Client\n"
14308 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014309
Michael Lambert95cbbd22010-07-23 14:43:04 -040014310DEFUN (show_bgp_view_ipv6_safi_rsclient,
14311 show_bgp_view_ipv6_safi_rsclient_cmd,
14312 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14313 SHOW_STR
14314 BGP_STR
14315 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014316 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014317 "Address family\n"
14318 "Address Family modifier\n"
14319 "Address Family modifier\n"
14320 "Information about Route Server Client\n"
14321 NEIGHBOR_ADDR_STR)
14322{
14323 struct bgp_table *table;
14324 struct peer *peer;
14325 safi_t safi;
14326
14327 if (argc == 3) {
14328 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14329 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14330 } else {
14331 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14332 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14333 }
14334
14335 if (! peer)
14336 return CMD_WARNING;
14337
14338 if (! peer->afc[AFI_IP6][safi])
14339 {
14340 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14341 VTY_NEWLINE);
14342 return CMD_WARNING;
14343 }
14344
14345 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14346 PEER_FLAG_RSERVER_CLIENT))
14347 {
14348 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14349 VTY_NEWLINE);
14350 return CMD_WARNING;
14351 }
14352
14353 table = peer->rib[AFI_IP6][safi];
14354
14355 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14356}
14357
14358ALIAS (show_bgp_view_ipv6_safi_rsclient,
14359 show_bgp_ipv6_safi_rsclient_cmd,
14360 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14361 SHOW_STR
14362 BGP_STR
14363 "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
paulfee0f4c2004-09-13 05:12:46 +000014369DEFUN (show_bgp_view_rsclient_route,
14370 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014371 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14372 SHOW_STR
14373 BGP_STR
14374 "BGP view\n"
14375 "View name\n"
14376 "Information about Route Server Client\n"
14377 NEIGHBOR_ADDR_STR
14378 "Network in the BGP routing table to display\n")
14379{
14380 struct bgp *bgp;
14381 struct peer *peer;
14382
14383 /* BGP structure lookup. */
14384 if (argc == 3)
14385 {
14386 bgp = bgp_lookup_by_name (argv[0]);
14387 if (bgp == NULL)
14388 {
14389 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14390 return CMD_WARNING;
14391 }
14392 }
14393 else
14394 {
14395 bgp = bgp_get_default ();
14396 if (bgp == NULL)
14397 {
14398 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14399 return CMD_WARNING;
14400 }
14401 }
14402
14403 if (argc == 3)
14404 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14405 else
14406 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14407
14408 if (! peer)
14409 return CMD_WARNING;
14410
14411 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14412 {
14413 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14414 VTY_NEWLINE);
14415 return CMD_WARNING;
14416 }
14417
14418 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14419 PEER_FLAG_RSERVER_CLIENT))
14420 {
14421 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14422 VTY_NEWLINE);
14423 return CMD_WARNING;
14424 }
14425
14426 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14427 (argc == 3) ? argv[2] : argv[1],
14428 AFI_IP6, SAFI_UNICAST, NULL, 0);
14429}
14430
14431DEFUN (show_bgp_view_ipv6_rsclient_route,
14432 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014433 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014434 SHOW_STR
14435 BGP_STR
14436 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050014437 "BGP view name\n"
14438 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000014439 "Information about Route Server Client\n"
14440 NEIGHBOR_ADDR_STR
14441 "Network in the BGP routing table to display\n")
14442{
14443 struct bgp *bgp;
14444 struct peer *peer;
14445
14446 /* BGP structure lookup. */
14447 if (argc == 3)
14448 {
14449 bgp = bgp_lookup_by_name (argv[0]);
14450 if (bgp == NULL)
14451 {
14452 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14453 return CMD_WARNING;
14454 }
14455 }
14456 else
14457 {
14458 bgp = bgp_get_default ();
14459 if (bgp == NULL)
14460 {
14461 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14462 return CMD_WARNING;
14463 }
14464 }
14465
14466 if (argc == 3)
14467 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14468 else
14469 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14470
14471 if (! peer)
14472 return CMD_WARNING;
14473
14474 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14475 {
14476 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14477 VTY_NEWLINE);
14478 return CMD_WARNING;
14479 }
14480
14481 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14482 PEER_FLAG_RSERVER_CLIENT))
14483 {
14484 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14485 VTY_NEWLINE);
14486 return CMD_WARNING;
14487 }
14488
14489 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14490 (argc == 3) ? argv[2] : argv[1],
14491 AFI_IP6, SAFI_UNICAST, NULL, 0);
14492}
14493
Lou Bergerf9b6c392016-01-12 13:42:09 -050014494ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000014495 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014496 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14497 SHOW_STR
14498 BGP_STR
14499 "Information about Route Server Client\n"
14500 NEIGHBOR_ADDR_STR
14501 "Network in the BGP routing table to display\n")
14502
14503ALIAS (show_bgp_view_ipv6_rsclient_route,
14504 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014505 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014506 SHOW_STR
14507 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014508 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014509 "Information about Route Server Client\n"
14510 NEIGHBOR_ADDR_STR
14511 "Network in the BGP routing table to display\n")
14512
Michael Lambert95cbbd22010-07-23 14:43:04 -040014513DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
14514 show_bgp_view_ipv6_safi_rsclient_route_cmd,
14515 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14516 SHOW_STR
14517 BGP_STR
14518 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014519 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014520 "Address family\n"
14521 "Address Family modifier\n"
14522 "Address Family modifier\n"
14523 "Information about Route Server Client\n"
14524 NEIGHBOR_ADDR_STR
14525 "Network in the BGP routing table to display\n")
14526{
14527 struct bgp *bgp;
14528 struct peer *peer;
14529 safi_t safi;
14530
14531 /* BGP structure lookup. */
14532 if (argc == 4)
14533 {
14534 bgp = bgp_lookup_by_name (argv[0]);
14535 if (bgp == NULL)
14536 {
14537 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14538 return CMD_WARNING;
14539 }
14540 }
14541 else
14542 {
14543 bgp = bgp_get_default ();
14544 if (bgp == NULL)
14545 {
14546 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14547 return CMD_WARNING;
14548 }
14549 }
14550
14551 if (argc == 4) {
14552 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14553 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14554 } else {
14555 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14556 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14557 }
14558
14559 if (! peer)
14560 return CMD_WARNING;
14561
14562 if (! peer->afc[AFI_IP6][safi])
14563 {
14564 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14565 VTY_NEWLINE);
14566 return CMD_WARNING;
14567}
14568
14569 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14570 PEER_FLAG_RSERVER_CLIENT))
14571 {
14572 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14573 VTY_NEWLINE);
14574 return CMD_WARNING;
14575 }
14576
14577 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14578 (argc == 4) ? argv[3] : argv[2],
14579 AFI_IP6, safi, NULL, 0);
14580}
14581
14582ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
14583 show_bgp_ipv6_safi_rsclient_route_cmd,
14584 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14585 SHOW_STR
14586 BGP_STR
14587 "Address family\n"
14588 "Address Family modifier\n"
14589 "Address Family modifier\n"
14590 "Information about Route Server Client\n"
14591 NEIGHBOR_ADDR_STR
14592 "Network in the BGP routing table to display\n")
14593
Lou Berger651b4022016-01-12 13:42:07 -050014594
paulfee0f4c2004-09-13 05:12:46 +000014595DEFUN (show_bgp_view_rsclient_prefix,
14596 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014597 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14598 SHOW_STR
14599 BGP_STR
14600 "BGP view\n"
14601 "View name\n"
14602 "Information about Route Server Client\n"
14603 NEIGHBOR_ADDR_STR
14604 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14605{
14606 struct bgp *bgp;
14607 struct peer *peer;
14608
14609 /* BGP structure lookup. */
14610 if (argc == 3)
14611 {
14612 bgp = bgp_lookup_by_name (argv[0]);
14613 if (bgp == NULL)
14614 {
14615 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14616 return CMD_WARNING;
14617 }
14618 }
14619 else
14620 {
14621 bgp = bgp_get_default ();
14622 if (bgp == NULL)
14623 {
14624 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14625 return CMD_WARNING;
14626 }
14627 }
14628
14629 if (argc == 3)
14630 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14631 else
14632 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14633
14634 if (! peer)
14635 return CMD_WARNING;
14636
14637 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14638 {
14639 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14640 VTY_NEWLINE);
14641 return CMD_WARNING;
14642 }
14643
14644 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14645 PEER_FLAG_RSERVER_CLIENT))
14646 {
14647 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14648 VTY_NEWLINE);
14649 return CMD_WARNING;
14650 }
14651
14652 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14653 (argc == 3) ? argv[2] : argv[1],
14654 AFI_IP6, SAFI_UNICAST, NULL, 1);
14655}
14656
14657DEFUN (show_bgp_view_ipv6_rsclient_prefix,
14658 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014659 "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 +000014660 SHOW_STR
14661 BGP_STR
14662 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014663 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014664 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014665 "Information about Route Server Client\n"
14666 NEIGHBOR_ADDR_STR
14667 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14668{
14669 struct bgp *bgp;
14670 struct peer *peer;
14671
14672 /* BGP structure lookup. */
14673 if (argc == 3)
14674 {
14675 bgp = bgp_lookup_by_name (argv[0]);
14676 if (bgp == NULL)
14677 {
14678 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14679 return CMD_WARNING;
14680 }
14681 }
14682 else
14683 {
14684 bgp = bgp_get_default ();
14685 if (bgp == NULL)
14686 {
14687 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14688 return CMD_WARNING;
14689 }
14690 }
14691
14692 if (argc == 3)
14693 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14694 else
14695 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14696
14697 if (! peer)
14698 return CMD_WARNING;
14699
14700 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14701 {
14702 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14703 VTY_NEWLINE);
14704 return CMD_WARNING;
14705 }
14706
14707 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14708 PEER_FLAG_RSERVER_CLIENT))
14709 {
14710 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14711 VTY_NEWLINE);
14712 return CMD_WARNING;
14713 }
14714
14715 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14716 (argc == 3) ? argv[2] : argv[1],
14717 AFI_IP6, SAFI_UNICAST, NULL, 1);
14718}
14719
Lou Bergerf9b6c392016-01-12 13:42:09 -050014720ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000014721 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014722 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14723 SHOW_STR
14724 BGP_STR
14725 "Information about Route Server Client\n"
14726 NEIGHBOR_ADDR_STR
14727 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14728
14729ALIAS (show_bgp_view_ipv6_rsclient_prefix,
14730 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014731 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000014732 SHOW_STR
14733 BGP_STR
14734 "Information about Route Server Client\n"
14735 NEIGHBOR_ADDR_STR
14736 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14737
Michael Lambert95cbbd22010-07-23 14:43:04 -040014738DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
14739 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
14740 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14741 SHOW_STR
14742 BGP_STR
14743 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014744 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014745 "Address family\n"
14746 "Address Family modifier\n"
14747 "Address Family modifier\n"
14748 "Information about Route Server Client\n"
14749 NEIGHBOR_ADDR_STR
14750 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14751{
14752 struct bgp *bgp;
14753 struct peer *peer;
14754 safi_t safi;
14755
14756 /* BGP structure lookup. */
14757 if (argc == 4)
14758 {
14759 bgp = bgp_lookup_by_name (argv[0]);
14760 if (bgp == NULL)
14761 {
14762 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14763 return CMD_WARNING;
14764 }
14765 }
14766 else
14767 {
14768 bgp = bgp_get_default ();
14769 if (bgp == NULL)
14770 {
14771 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14772 return CMD_WARNING;
14773 }
14774 }
14775
14776 if (argc == 4) {
14777 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14778 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14779 } else {
14780 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14781 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14782 }
14783
14784 if (! peer)
14785 return CMD_WARNING;
14786
14787 if (! peer->afc[AFI_IP6][safi])
14788 {
14789 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14790 VTY_NEWLINE);
14791 return CMD_WARNING;
14792}
14793
14794 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14795 PEER_FLAG_RSERVER_CLIENT))
14796{
14797 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14798 VTY_NEWLINE);
14799 return CMD_WARNING;
14800 }
14801
14802 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14803 (argc == 4) ? argv[3] : argv[2],
14804 AFI_IP6, safi, NULL, 1);
14805}
14806
14807ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
14808 show_bgp_ipv6_safi_rsclient_prefix_cmd,
14809 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14810 SHOW_STR
14811 BGP_STR
14812 "Address family\n"
14813 "Address Family modifier\n"
14814 "Address Family modifier\n"
14815 "Information about Route Server Client\n"
14816 NEIGHBOR_ADDR_STR
14817 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14818
paul718e3742002-12-13 20:15:29 +000014819struct bgp_table *bgp_distance_table;
14820
14821struct bgp_distance
14822{
14823 /* Distance value for the IP source prefix. */
14824 u_char distance;
14825
14826 /* Name of the access-list to be matched. */
14827 char *access_list;
14828};
14829
paul94f2b392005-06-28 12:44:16 +000014830static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080014831bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000014832{
Stephen Hemminger393deb92008-08-18 14:13:29 -070014833 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000014834}
14835
paul94f2b392005-06-28 12:44:16 +000014836static void
paul718e3742002-12-13 20:15:29 +000014837bgp_distance_free (struct bgp_distance *bdistance)
14838{
14839 XFREE (MTYPE_BGP_DISTANCE, bdistance);
14840}
14841
paul94f2b392005-06-28 12:44:16 +000014842static int
paulfd79ac92004-10-13 05:06:08 +000014843bgp_distance_set (struct vty *vty, const char *distance_str,
14844 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014845{
14846 int ret;
14847 struct prefix_ipv4 p;
14848 u_char distance;
14849 struct bgp_node *rn;
14850 struct bgp_distance *bdistance;
14851
14852 ret = str2prefix_ipv4 (ip_str, &p);
14853 if (ret == 0)
14854 {
14855 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14856 return CMD_WARNING;
14857 }
14858
14859 distance = atoi (distance_str);
14860
14861 /* Get BGP distance node. */
14862 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
14863 if (rn->info)
14864 {
14865 bdistance = rn->info;
14866 bgp_unlock_node (rn);
14867 }
14868 else
14869 {
14870 bdistance = bgp_distance_new ();
14871 rn->info = bdistance;
14872 }
14873
14874 /* Set distance value. */
14875 bdistance->distance = distance;
14876
14877 /* Reset access-list configuration. */
14878 if (bdistance->access_list)
14879 {
14880 free (bdistance->access_list);
14881 bdistance->access_list = NULL;
14882 }
14883 if (access_list_str)
14884 bdistance->access_list = strdup (access_list_str);
14885
14886 return CMD_SUCCESS;
14887}
14888
paul94f2b392005-06-28 12:44:16 +000014889static int
paulfd79ac92004-10-13 05:06:08 +000014890bgp_distance_unset (struct vty *vty, const char *distance_str,
14891 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014892{
14893 int ret;
14894 struct prefix_ipv4 p;
14895 u_char distance;
14896 struct bgp_node *rn;
14897 struct bgp_distance *bdistance;
14898
14899 ret = str2prefix_ipv4 (ip_str, &p);
14900 if (ret == 0)
14901 {
14902 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14903 return CMD_WARNING;
14904 }
14905
14906 distance = atoi (distance_str);
14907
14908 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
14909 if (! rn)
14910 {
14911 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
14912 return CMD_WARNING;
14913 }
14914
14915 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010014916
14917 if (bdistance->distance != distance)
14918 {
14919 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
14920 return CMD_WARNING;
14921 }
14922
paul718e3742002-12-13 20:15:29 +000014923 if (bdistance->access_list)
14924 free (bdistance->access_list);
14925 bgp_distance_free (bdistance);
14926
14927 rn->info = NULL;
14928 bgp_unlock_node (rn);
14929 bgp_unlock_node (rn);
14930
14931 return CMD_SUCCESS;
14932}
14933
paul718e3742002-12-13 20:15:29 +000014934/* Apply BGP information to distance method. */
14935u_char
14936bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
14937{
14938 struct bgp_node *rn;
14939 struct prefix_ipv4 q;
14940 struct peer *peer;
14941 struct bgp_distance *bdistance;
14942 struct access_list *alist;
14943 struct bgp_static *bgp_static;
14944
14945 if (! bgp)
14946 return 0;
14947
14948 if (p->family != AF_INET)
14949 return 0;
14950
14951 peer = rinfo->peer;
14952
14953 if (peer->su.sa.sa_family != AF_INET)
14954 return 0;
14955
14956 memset (&q, 0, sizeof (struct prefix_ipv4));
14957 q.family = AF_INET;
14958 q.prefix = peer->su.sin.sin_addr;
14959 q.prefixlen = IPV4_MAX_BITLEN;
14960
14961 /* Check source address. */
14962 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
14963 if (rn)
14964 {
14965 bdistance = rn->info;
14966 bgp_unlock_node (rn);
14967
14968 if (bdistance->access_list)
14969 {
14970 alist = access_list_lookup (AFI_IP, bdistance->access_list);
14971 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
14972 return bdistance->distance;
14973 }
14974 else
14975 return bdistance->distance;
14976 }
14977
14978 /* Backdoor check. */
14979 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
14980 if (rn)
14981 {
14982 bgp_static = rn->info;
14983 bgp_unlock_node (rn);
14984
14985 if (bgp_static->backdoor)
14986 {
14987 if (bgp->distance_local)
14988 return bgp->distance_local;
14989 else
14990 return ZEBRA_IBGP_DISTANCE_DEFAULT;
14991 }
14992 }
14993
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000014994 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000014995 {
14996 if (bgp->distance_ebgp)
14997 return bgp->distance_ebgp;
14998 return ZEBRA_EBGP_DISTANCE_DEFAULT;
14999 }
15000 else
15001 {
15002 if (bgp->distance_ibgp)
15003 return bgp->distance_ibgp;
15004 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15005 }
15006}
15007
15008DEFUN (bgp_distance,
15009 bgp_distance_cmd,
15010 "distance bgp <1-255> <1-255> <1-255>",
15011 "Define an administrative distance\n"
15012 "BGP distance\n"
15013 "Distance for routes external to the AS\n"
15014 "Distance for routes internal to the AS\n"
15015 "Distance for local routes\n")
15016{
15017 struct bgp *bgp;
15018
15019 bgp = vty->index;
15020
15021 bgp->distance_ebgp = atoi (argv[0]);
15022 bgp->distance_ibgp = atoi (argv[1]);
15023 bgp->distance_local = atoi (argv[2]);
15024 return CMD_SUCCESS;
15025}
15026
15027DEFUN (no_bgp_distance,
15028 no_bgp_distance_cmd,
15029 "no distance bgp <1-255> <1-255> <1-255>",
15030 NO_STR
15031 "Define an administrative distance\n"
15032 "BGP distance\n"
15033 "Distance for routes external to the AS\n"
15034 "Distance for routes internal to the AS\n"
15035 "Distance for local routes\n")
15036{
15037 struct bgp *bgp;
15038
15039 bgp = vty->index;
15040
15041 bgp->distance_ebgp= 0;
15042 bgp->distance_ibgp = 0;
15043 bgp->distance_local = 0;
15044 return CMD_SUCCESS;
15045}
15046
15047ALIAS (no_bgp_distance,
15048 no_bgp_distance2_cmd,
15049 "no distance bgp",
15050 NO_STR
15051 "Define an administrative distance\n"
15052 "BGP distance\n")
15053
15054DEFUN (bgp_distance_source,
15055 bgp_distance_source_cmd,
15056 "distance <1-255> A.B.C.D/M",
15057 "Define an administrative distance\n"
15058 "Administrative distance\n"
15059 "IP source prefix\n")
15060{
15061 bgp_distance_set (vty, argv[0], argv[1], NULL);
15062 return CMD_SUCCESS;
15063}
15064
15065DEFUN (no_bgp_distance_source,
15066 no_bgp_distance_source_cmd,
15067 "no distance <1-255> A.B.C.D/M",
15068 NO_STR
15069 "Define an administrative distance\n"
15070 "Administrative distance\n"
15071 "IP source prefix\n")
15072{
15073 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15074 return CMD_SUCCESS;
15075}
15076
15077DEFUN (bgp_distance_source_access_list,
15078 bgp_distance_source_access_list_cmd,
15079 "distance <1-255> A.B.C.D/M WORD",
15080 "Define an administrative distance\n"
15081 "Administrative distance\n"
15082 "IP source prefix\n"
15083 "Access list name\n")
15084{
15085 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15086 return CMD_SUCCESS;
15087}
15088
15089DEFUN (no_bgp_distance_source_access_list,
15090 no_bgp_distance_source_access_list_cmd,
15091 "no distance <1-255> A.B.C.D/M WORD",
15092 NO_STR
15093 "Define an administrative distance\n"
15094 "Administrative distance\n"
15095 "IP source prefix\n"
15096 "Access list name\n")
15097{
15098 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15099 return CMD_SUCCESS;
15100}
David Lamparter6b0655a2014-06-04 06:53:35 +020015101
paul718e3742002-12-13 20:15:29 +000015102DEFUN (bgp_damp_set,
15103 bgp_damp_set_cmd,
15104 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15105 "BGP Specific commands\n"
15106 "Enable route-flap dampening\n"
15107 "Half-life time for the penalty\n"
15108 "Value to start reusing a route\n"
15109 "Value to start suppressing a route\n"
15110 "Maximum duration to suppress a stable route\n")
15111{
15112 struct bgp *bgp;
15113 int half = DEFAULT_HALF_LIFE * 60;
15114 int reuse = DEFAULT_REUSE;
15115 int suppress = DEFAULT_SUPPRESS;
15116 int max = 4 * half;
15117
15118 if (argc == 4)
15119 {
15120 half = atoi (argv[0]) * 60;
15121 reuse = atoi (argv[1]);
15122 suppress = atoi (argv[2]);
15123 max = atoi (argv[3]) * 60;
15124 }
15125 else if (argc == 1)
15126 {
15127 half = atoi (argv[0]) * 60;
15128 max = 4 * half;
15129 }
15130
15131 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000015132
15133 if (suppress < reuse)
15134 {
15135 vty_out (vty, "Suppress value cannot be less than reuse value %s",
15136 VTY_NEWLINE);
15137 return 0;
15138 }
15139
paul718e3742002-12-13 20:15:29 +000015140 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
15141 half, reuse, suppress, max);
15142}
15143
15144ALIAS (bgp_damp_set,
15145 bgp_damp_set2_cmd,
15146 "bgp dampening <1-45>",
15147 "BGP Specific commands\n"
15148 "Enable route-flap dampening\n"
15149 "Half-life time for the penalty\n")
15150
15151ALIAS (bgp_damp_set,
15152 bgp_damp_set3_cmd,
15153 "bgp dampening",
15154 "BGP Specific commands\n"
15155 "Enable route-flap dampening\n")
15156
15157DEFUN (bgp_damp_unset,
15158 bgp_damp_unset_cmd,
15159 "no bgp dampening",
15160 NO_STR
15161 "BGP Specific commands\n"
15162 "Enable route-flap dampening\n")
15163{
15164 struct bgp *bgp;
15165
15166 bgp = vty->index;
15167 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
15168}
15169
15170ALIAS (bgp_damp_unset,
15171 bgp_damp_unset2_cmd,
15172 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15173 NO_STR
15174 "BGP Specific commands\n"
15175 "Enable route-flap dampening\n"
15176 "Half-life time for the penalty\n"
15177 "Value to start reusing a route\n"
15178 "Value to start suppressing a route\n"
15179 "Maximum duration to suppress a stable route\n")
15180
Lou Bergerf9b6c392016-01-12 13:42:09 -050015181DEFUN (show_ip_bgp_dampened_paths,
15182 show_ip_bgp_dampened_paths_cmd,
15183 "show ip bgp dampened-paths",
15184 SHOW_STR
15185 IP_STR
15186 BGP_STR
15187 "Display paths suppressed due to dampening\n")
15188{
15189 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
15190 NULL);
15191}
15192
15193ALIAS (show_ip_bgp_dampened_paths,
15194 show_ip_bgp_damp_dampened_paths_cmd,
15195 "show ip bgp dampening dampened-paths",
15196 SHOW_STR
15197 IP_STR
15198 BGP_STR
15199 "Display detailed information about dampening\n"
15200 "Display paths suppressed due to dampening\n")
15201
15202DEFUN (show_ip_bgp_flap_statistics,
15203 show_ip_bgp_flap_statistics_cmd,
15204 "show ip bgp flap-statistics",
15205 SHOW_STR
15206 IP_STR
15207 BGP_STR
15208 "Display flap statistics of routes\n")
15209{
15210 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
15211 bgp_show_type_flap_statistics, NULL);
15212}
15213
15214ALIAS (show_ip_bgp_flap_statistics,
15215 show_ip_bgp_damp_flap_statistics_cmd,
15216 "show ip bgp dampening flap-statistics",
15217 SHOW_STR
15218 IP_STR
15219 BGP_STR
15220 "Display detailed information about dampening\n"
15221 "Display flap statistics of routes\n")
15222
Lou Berger651b4022016-01-12 13:42:07 -050015223DEFUN (show_bgp_ipv4_safi_dampened_paths,
15224 show_bgp_ipv4_safi_dampened_paths_cmd,
15225 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015226 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015227 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015228 IP_STR
15229 "Address Family modifier\n"
15230 "Address Family modifier\n"
15231 "Address Family modifier\n"
15232 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015233 "Display paths suppressed due to dampening\n")
15234{
Lou Berger651b4022016-01-12 13:42:07 -050015235 safi_t safi;
paul718e3742002-12-13 20:15:29 +000015236
Lou Berger651b4022016-01-12 13:42:07 -050015237 if (bgp_parse_safi(argv[0], &safi)) {
15238 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15239 return CMD_WARNING;
15240 }
15241
15242 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
15243}
15244ALIAS (show_bgp_ipv4_safi_dampened_paths,
15245 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
15246 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053015247 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015248 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015249 IP_STR
15250 "Address Family modifier\n"
15251 "Address Family modifier\n"
15252 "Address Family modifier\n"
15253 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015254 "Display detailed information about dampening\n"
15255 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050015256
Lou Berger651b4022016-01-12 13:42:07 -050015257DEFUN (show_bgp_ipv6_safi_dampened_paths,
15258 show_bgp_ipv6_safi_dampened_paths_cmd,
15259 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015260 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015261 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015262 IPV6_STR
15263 "Address Family modifier\n"
15264 "Address Family modifier\n"
15265 "Address Family modifier\n"
15266 "Address Family modifier\n"
15267 "Display paths suppressed due to dampening\n")
15268{
15269 safi_t safi;
15270
15271 if (bgp_parse_safi(argv[0], &safi)) {
15272 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15273 return CMD_WARNING;
15274 }
15275
15276 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
15277}
15278ALIAS (show_bgp_ipv6_safi_dampened_paths,
15279 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
15280 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
15281 SHOW_STR
15282 BGP_STR
15283 IPV6_STR
15284 "Address Family modifier\n"
15285 "Address Family modifier\n"
15286 "Address Family modifier\n"
15287 "Address Family modifier\n"
15288 "Display detailed information about dampening\n"
15289 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050015290
15291DEFUN (show_bgp_ipv4_safi_flap_statistics,
15292 show_bgp_ipv4_safi_flap_statistics_cmd,
15293 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
15294 SHOW_STR
15295 BGP_STR
15296 "Address Family\n"
15297 "Address Family modifier\n"
15298 "Address Family modifier\n"
15299 "Address Family modifier\n"
15300 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015301 "Display flap statistics of routes\n")
15302{
Lou Berger651b4022016-01-12 13:42:07 -050015303 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020015304
Lou Berger651b4022016-01-12 13:42:07 -050015305 if (bgp_parse_safi(argv[0], &safi)) {
15306 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15307 return CMD_WARNING;
15308 }
15309
15310 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
15311}
15312ALIAS (show_bgp_ipv4_safi_flap_statistics,
15313 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
15314 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053015315 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015316 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015317 "Address Family\n"
15318 "Address Family modifier\n"
15319 "Address Family modifier\n"
15320 "Address Family modifier\n"
15321 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015322 "Display detailed information about dampening\n"
15323 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050015324
Lou Berger651b4022016-01-12 13:42:07 -050015325DEFUN (show_bgp_ipv6_safi_flap_statistics,
15326 show_bgp_ipv6_safi_flap_statistics_cmd,
15327 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
15328 SHOW_STR
15329 BGP_STR
15330 "Address Family\n"
15331 "Address Family modifier\n"
15332 "Address Family modifier\n"
15333 "Address Family modifier\n"
15334 "Address Family modifier\n"
15335 "Display flap statistics of routes\n")
15336{
15337 safi_t safi;
15338
15339 if (bgp_parse_safi(argv[0], &safi)) {
15340 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15341 return CMD_WARNING;
15342 }
15343
15344 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
15345}
15346ALIAS (show_bgp_ipv6_safi_flap_statistics,
15347 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
15348 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
15349 SHOW_STR
15350 BGP_STR
15351 "Address Family\n"
15352 "Address Family modifier\n"
15353 "Address Family modifier\n"
15354 "Address Family modifier\n"
15355 "Address Family modifier\n"
15356 "Display detailed information about dampening\n"
15357 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053015358
paul718e3742002-12-13 20:15:29 +000015359/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000015360static int
paulfd79ac92004-10-13 05:06:08 +000015361bgp_clear_damp_route (struct vty *vty, const char *view_name,
15362 const char *ip_str, afi_t afi, safi_t safi,
15363 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000015364{
15365 int ret;
15366 struct prefix match;
15367 struct bgp_node *rn;
15368 struct bgp_node *rm;
15369 struct bgp_info *ri;
15370 struct bgp_info *ri_temp;
15371 struct bgp *bgp;
15372 struct bgp_table *table;
15373
15374 /* BGP structure lookup. */
15375 if (view_name)
15376 {
15377 bgp = bgp_lookup_by_name (view_name);
15378 if (bgp == NULL)
15379 {
15380 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
15381 return CMD_WARNING;
15382 }
15383 }
15384 else
15385 {
15386 bgp = bgp_get_default ();
15387 if (bgp == NULL)
15388 {
15389 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
15390 return CMD_WARNING;
15391 }
15392 }
15393
15394 /* Check IP address argument. */
15395 ret = str2prefix (ip_str, &match);
15396 if (! ret)
15397 {
15398 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
15399 return CMD_WARNING;
15400 }
15401
15402 match.family = afi2family (afi);
15403
Lou Berger298cc2f2016-01-12 13:42:02 -050015404 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000015405 {
Lou Berger298cc2f2016-01-12 13:42:02 -050015406 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000015407 {
15408 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
15409 continue;
15410
15411 if ((table = rn->info) != NULL)
15412 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015413 {
15414 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
15415 {
15416 ri = rm->info;
15417 while (ri)
15418 {
15419 if (ri->extra && ri->extra->damp_info)
15420 {
15421 ri_temp = ri->next;
15422 bgp_damp_info_free (ri->extra->damp_info, 1);
15423 ri = ri_temp;
15424 }
15425 else
15426 ri = ri->next;
15427 }
15428 }
15429
15430 bgp_unlock_node (rm);
15431 }
paul718e3742002-12-13 20:15:29 +000015432 }
15433 }
15434 else
15435 {
15436 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015437 {
15438 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
15439 {
15440 ri = rn->info;
15441 while (ri)
15442 {
15443 if (ri->extra && ri->extra->damp_info)
15444 {
15445 ri_temp = ri->next;
15446 bgp_damp_info_free (ri->extra->damp_info, 1);
15447 ri = ri_temp;
15448 }
15449 else
15450 ri = ri->next;
15451 }
15452 }
15453
15454 bgp_unlock_node (rn);
15455 }
paul718e3742002-12-13 20:15:29 +000015456 }
15457
15458 return CMD_SUCCESS;
15459}
15460
15461DEFUN (clear_ip_bgp_dampening,
15462 clear_ip_bgp_dampening_cmd,
15463 "clear ip bgp dampening",
15464 CLEAR_STR
15465 IP_STR
15466 BGP_STR
15467 "Clear route flap dampening information\n")
15468{
15469 bgp_damp_info_clean ();
15470 return CMD_SUCCESS;
15471}
15472
15473DEFUN (clear_ip_bgp_dampening_prefix,
15474 clear_ip_bgp_dampening_prefix_cmd,
15475 "clear ip bgp dampening A.B.C.D/M",
15476 CLEAR_STR
15477 IP_STR
15478 BGP_STR
15479 "Clear route flap dampening information\n"
15480 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15481{
15482 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15483 SAFI_UNICAST, NULL, 1);
15484}
15485
15486DEFUN (clear_ip_bgp_dampening_address,
15487 clear_ip_bgp_dampening_address_cmd,
15488 "clear ip bgp dampening A.B.C.D",
15489 CLEAR_STR
15490 IP_STR
15491 BGP_STR
15492 "Clear route flap dampening information\n"
15493 "Network to clear damping information\n")
15494{
15495 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15496 SAFI_UNICAST, NULL, 0);
15497}
15498
15499DEFUN (clear_ip_bgp_dampening_address_mask,
15500 clear_ip_bgp_dampening_address_mask_cmd,
15501 "clear ip bgp dampening A.B.C.D A.B.C.D",
15502 CLEAR_STR
15503 IP_STR
15504 BGP_STR
15505 "Clear route flap dampening information\n"
15506 "Network to clear damping information\n"
15507 "Network mask\n")
15508{
15509 int ret;
15510 char prefix_str[BUFSIZ];
15511
15512 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
15513 if (! ret)
15514 {
15515 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
15516 return CMD_WARNING;
15517 }
15518
15519 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
15520 SAFI_UNICAST, NULL, 0);
15521}
David Lamparter6b0655a2014-06-04 06:53:35 +020015522
Lou Berger298cc2f2016-01-12 13:42:02 -050015523/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000015524static int
paul718e3742002-12-13 20:15:29 +000015525bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
15526 afi_t afi, safi_t safi, int *write)
15527{
15528 struct bgp_node *prn;
15529 struct bgp_node *rn;
15530 struct bgp_table *table;
15531 struct prefix *p;
15532 struct prefix_rd *prd;
15533 struct bgp_static *bgp_static;
15534 u_int32_t label;
15535 char buf[SU_ADDRSTRLEN];
15536 char rdbuf[RD_ADDRSTRLEN];
15537
15538 /* Network configuration. */
15539 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
15540 if ((table = prn->info) != NULL)
15541 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
15542 if ((bgp_static = rn->info) != NULL)
15543 {
15544 p = &rn->p;
15545 prd = (struct prefix_rd *) &prn->p;
15546
15547 /* "address-family" display. */
15548 bgp_config_write_family_header (vty, afi, safi, write);
15549
15550 /* "network" configuration display. */
15551 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
15552 label = decode_label (bgp_static->tag);
15553
15554 vty_out (vty, " network %s/%d rd %s tag %d",
15555 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15556 p->prefixlen,
15557 rdbuf, label);
15558 vty_out (vty, "%s", VTY_NEWLINE);
15559 }
15560 return 0;
15561}
15562
15563/* Configuration of static route announcement and aggregate
15564 information. */
15565int
15566bgp_config_write_network (struct vty *vty, struct bgp *bgp,
15567 afi_t afi, safi_t safi, int *write)
15568{
15569 struct bgp_node *rn;
15570 struct prefix *p;
15571 struct bgp_static *bgp_static;
15572 struct bgp_aggregate *bgp_aggregate;
15573 char buf[SU_ADDRSTRLEN];
15574
Lou Berger298cc2f2016-01-12 13:42:02 -050015575 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000015576 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
15577
15578 /* Network configuration. */
15579 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
15580 if ((bgp_static = rn->info) != NULL)
15581 {
15582 p = &rn->p;
15583
15584 /* "address-family" display. */
15585 bgp_config_write_family_header (vty, afi, safi, write);
15586
15587 /* "network" configuration display. */
15588 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15589 {
15590 u_int32_t destination;
15591 struct in_addr netmask;
15592
15593 destination = ntohl (p->u.prefix4.s_addr);
15594 masklen2ip (p->prefixlen, &netmask);
15595 vty_out (vty, " network %s",
15596 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
15597
15598 if ((IN_CLASSC (destination) && p->prefixlen == 24)
15599 || (IN_CLASSB (destination) && p->prefixlen == 16)
15600 || (IN_CLASSA (destination) && p->prefixlen == 8)
15601 || p->u.prefix4.s_addr == 0)
15602 {
15603 /* Natural mask is not display. */
15604 }
15605 else
15606 vty_out (vty, " mask %s", inet_ntoa (netmask));
15607 }
15608 else
15609 {
15610 vty_out (vty, " network %s/%d",
15611 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15612 p->prefixlen);
15613 }
15614
15615 if (bgp_static->rmap.name)
15616 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000015617 else
15618 {
15619 if (bgp_static->backdoor)
15620 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000015621 }
paul718e3742002-12-13 20:15:29 +000015622
15623 vty_out (vty, "%s", VTY_NEWLINE);
15624 }
15625
15626 /* Aggregate-address configuration. */
15627 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
15628 if ((bgp_aggregate = rn->info) != NULL)
15629 {
15630 p = &rn->p;
15631
15632 /* "address-family" display. */
15633 bgp_config_write_family_header (vty, afi, safi, write);
15634
15635 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15636 {
15637 struct in_addr netmask;
15638
15639 masklen2ip (p->prefixlen, &netmask);
15640 vty_out (vty, " aggregate-address %s %s",
15641 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15642 inet_ntoa (netmask));
15643 }
15644 else
15645 {
15646 vty_out (vty, " aggregate-address %s/%d",
15647 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15648 p->prefixlen);
15649 }
15650
15651 if (bgp_aggregate->as_set)
15652 vty_out (vty, " as-set");
15653
15654 if (bgp_aggregate->summary_only)
15655 vty_out (vty, " summary-only");
15656
15657 vty_out (vty, "%s", VTY_NEWLINE);
15658 }
15659
15660 return 0;
15661}
15662
15663int
15664bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
15665{
15666 struct bgp_node *rn;
15667 struct bgp_distance *bdistance;
15668
15669 /* Distance configuration. */
15670 if (bgp->distance_ebgp
15671 && bgp->distance_ibgp
15672 && bgp->distance_local
15673 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
15674 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
15675 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
15676 vty_out (vty, " distance bgp %d %d %d%s",
15677 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
15678 VTY_NEWLINE);
15679
15680 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
15681 if ((bdistance = rn->info) != NULL)
15682 {
15683 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
15684 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
15685 bdistance->access_list ? bdistance->access_list : "",
15686 VTY_NEWLINE);
15687 }
15688
15689 return 0;
15690}
15691
15692/* Allocate routing table structure and install commands. */
15693void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080015694bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000015695{
15696 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000015697 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000015698
15699 /* IPv4 BGP commands. */
15700 install_element (BGP_NODE, &bgp_network_cmd);
15701 install_element (BGP_NODE, &bgp_network_mask_cmd);
15702 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
15703 install_element (BGP_NODE, &bgp_network_route_map_cmd);
15704 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
15705 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
15706 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
15707 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
15708 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
15709 install_element (BGP_NODE, &no_bgp_network_cmd);
15710 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
15711 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
15712 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
15713 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
15714 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15715 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
15716 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
15717 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
15718
15719 install_element (BGP_NODE, &aggregate_address_cmd);
15720 install_element (BGP_NODE, &aggregate_address_mask_cmd);
15721 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
15722 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
15723 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
15724 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
15725 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
15726 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
15727 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
15728 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
15729 install_element (BGP_NODE, &no_aggregate_address_cmd);
15730 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
15731 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
15732 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
15733 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
15734 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
15735 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
15736 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
15737 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15738 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15739
15740 /* IPv4 unicast configuration. */
15741 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
15742 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
15743 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
15744 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
15745 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
15746 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015747 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000015748 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
15749 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
15750 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
15751 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
15752 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015753
paul718e3742002-12-13 20:15:29 +000015754 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
15755 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
15756 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
15757 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
15758 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
15759 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
15760 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
15761 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
15762 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
15763 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
15764 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
15765 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
15766 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
15767 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
15768 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
15769 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
15770 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
15771 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
15772 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15773 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15774
15775 /* IPv4 multicast configuration. */
15776 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
15777 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
15778 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
15779 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
15780 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
15781 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
15782 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
15783 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
15784 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
15785 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
15786 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
15787 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15788 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
15789 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
15790 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
15791 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
15792 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
15793 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
15794 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
15795 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
15796 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
15797 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
15798 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
15799 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
15800 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
15801 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
15802 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
15803 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
15804 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
15805 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
15806 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15807 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15808
Michael Lambert95cbbd22010-07-23 14:43:04 -040015809 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015810 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015811 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
15812 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
15813 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15814 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15815 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
15816 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
15817 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15818 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15819 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015820 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015821 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15822 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15823 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15824 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15825 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15826 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15827 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
15828 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
15829 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15830 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
15831 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
15832 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
15833 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
15834 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
15835 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
15836 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
15837 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
15838 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
15839 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
15840 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
15841 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
15842 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
15843 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
15844 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
15845 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
15846 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
15847 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
15848 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015849 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15850 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
15851 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
15852 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
15853 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015854 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
15855 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
15856 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
15857 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
15858 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
15859 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
15860 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
15861 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
15862 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
15863 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
15864 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
15865 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
15866 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
15867 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
15868 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
15869 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
15870 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
15871 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
15872 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015873 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015874 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
15875 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
15876 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
15877 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
15878 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
15879 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
15880 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
15881 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
15882 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
15883 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
15884 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
15885 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
15886 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
15887 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
15888 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
15889 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
15890 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
15891 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
15892 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
15893 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
15894 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
15895 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
15896 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
15897 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
15898 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
15899 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
15900 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
15901 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
15902 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
15903 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
15904 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
15905 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
15906 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
15907 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
15908 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
15909 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
15910 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
15911 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
15912 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
15913 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
15914 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
15915 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
15916 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
15917 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
15918 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015919 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015920 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015921 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015922 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015923 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015924 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010015925
15926 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040015927 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015928 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15929 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15930 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15931 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15932 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015933 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015934 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15935 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15936 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15937 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15938 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15939 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15940 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
15941 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15942 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
15943 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
15944 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
15945 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
15946 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
15947 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
15948 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
15949 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015950 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15951 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
15952 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
15953 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
15954 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015955 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
15956 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
15957 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
15958 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
15959 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
15960 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
15961 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
15962 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015963 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015964 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015965 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015966 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000015967
Michael Lambert95cbbd22010-07-23 14:43:04 -040015968 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015969 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015970 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd);
15971 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd);
15972 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15973 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15974 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_route_cmd);
15975 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_route_cmd);
15976 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15977 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15978 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015979 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015980 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15981 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15982 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15983 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15984 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15985 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15986 install_element (ENABLE_NODE, &show_bgp_afi_safi_view_cmd);
15987 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_route_cmd);
15988 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15989 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_regexp_cmd);
15990 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_regexp_cmd);
15991 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_list_cmd);
15992 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
15993 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
15994 install_element (ENABLE_NODE, &show_bgp_ipv4_filter_list_cmd);
15995 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
15996 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
15997 install_element (ENABLE_NODE, &show_bgp_ipv4_route_map_cmd);
15998 install_element (ENABLE_NODE, &show_bgp_ipv4_cidr_only_cmd);
15999 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
16000 install_element (ENABLE_NODE, &show_bgp_ipv4_community_cmd);
16001 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_cmd);
16002 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_cmd);
16003 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_cmd);
16004 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_cmd);
16005 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_cmd);
16006 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_cmd);
16007 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016008 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16009 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd);
16010 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd);
16011 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd);
16012 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016013 install_element (ENABLE_NODE, &show_bgp_ipv4_community_exact_cmd);
16014 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_exact_cmd);
16015 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_exact_cmd);
16016 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_exact_cmd);
16017 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16018 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16019 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16020 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16021 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_cmd);
16022 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16023 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16024 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16025 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16026 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16027 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16028 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16029 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16030 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16031 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016032 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016033 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16034 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16035 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16036 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16037 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16038 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16039 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16040 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16041 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16042 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16043 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16044 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16045 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16046 install_element (ENABLE_NODE, &show_bgp_ipv6_flap_address_cmd);
16047 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16048 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16049 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16050 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16051 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16052 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16053 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16054 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16055 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16056 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16057 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16058 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16059 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16060 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16061 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16062 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16063 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16064 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16065 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16066 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16067 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16068 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16069 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16070 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16071 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16072 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16073 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16074 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16075 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16076 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16077 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016078 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016079 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016080 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016081 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016082 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016083 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016084
16085 /* BGP dampening clear commands */
16086 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
16087 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
16088 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
16089 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
16090
Paul Jakmaff7924f2006-09-04 01:10:36 +000016091 /* prefix count */
Lou Berger651b4022016-01-12 13:42:07 -050016092 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_prefix_counts_cmd);
16093 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_prefix_counts_cmd);
Paul Jakmaff7924f2006-09-04 01:10:36 +000016094 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd);
16095
paul718e3742002-12-13 20:15:29 +000016096 /* New config IPv6 BGP commands. */
16097 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
16098 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
16099 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
16100 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
16101
16102 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
16103 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
16104 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
16105 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
16106
G.Balaji73bfe0b2011-09-23 22:36:20 +053016107 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
16108 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
16109
paul718e3742002-12-13 20:15:29 +000016110 /* Old config IPv6 BGP commands. */
16111 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
16112 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
16113
16114 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
16115 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
16116 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
16117 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
16118
Michael Lambert95cbbd22010-07-23 14:43:04 -040016119 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016120 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016121 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016122 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016123 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016124 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016125 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016126 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016127 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016128 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
16129 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
16130 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
16131 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
16132 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16133 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16134 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16135 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016136 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
paul718e3742002-12-13 20:15:29 +000016137 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016138 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016139 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016140 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016141 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016142 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016143 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016144 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
16145 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016146 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016147 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016148 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016149 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016150 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016151 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016152 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016153 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016154 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016155 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016156 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016157 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016158 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016159 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016160 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16161 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016162 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016163 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016164 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016165 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016166 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016167
16168 /* Restricted:
16169 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
16170 */
Paul Jakma62687ff2008-08-23 14:27:06 +010016171 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016172 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016173 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016174 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016175 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
16176 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
16177 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
16178 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
16179 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16180 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16181 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16182 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
16183 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016184 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016185 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016186 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016187 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016188 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016189 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016190 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016191 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016192 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016193 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016194
Michael Lambert95cbbd22010-07-23 14:43:04 -040016195 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016196 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016197 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016198 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016199 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016200 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016201 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016202 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016203 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016204 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_cmd);
16205 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_cmd);
16206 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_cmd);
16207 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_cmd);
16208 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16209 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16210 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16211 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016212 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016213 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016214 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016215 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016216 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016217 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016218 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016219 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016220 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016221 install_element (ENABLE_NODE, &show_bgp_ipv4_rsclient_cmd);
16222 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016223 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016224 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016225 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016226 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016227 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016228 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016229 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016230 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016231 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016232 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016233 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016234 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016235 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016236 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016237 install_element (ENABLE_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16238 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016239 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016240 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016241 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016242 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016243 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma2815e612006-09-14 02:56:07 +000016244
16245 /* Statistics */
16246 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016247 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000016248
16249 install_element (BGP_NODE, &bgp_distance_cmd);
16250 install_element (BGP_NODE, &no_bgp_distance_cmd);
16251 install_element (BGP_NODE, &no_bgp_distance2_cmd);
16252 install_element (BGP_NODE, &bgp_distance_source_cmd);
16253 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
16254 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
16255 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
16256
16257 install_element (BGP_NODE, &bgp_damp_set_cmd);
16258 install_element (BGP_NODE, &bgp_damp_set2_cmd);
16259 install_element (BGP_NODE, &bgp_damp_set3_cmd);
16260 install_element (BGP_NODE, &bgp_damp_unset_cmd);
16261 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
16262 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
16263 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
16264 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
16265 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
16266 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016267
16268 /* Deprecated AS-Pathlimit commands */
16269 install_element (BGP_NODE, &bgp_network_ttl_cmd);
16270 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
16271 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
16272 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
16273 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16274 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16275
16276 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
16277 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
16278 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16279 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
16280 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16281 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16282
16283 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
16284 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
16285 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
16286 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
16287 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16288 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16289
16290 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
16291 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
16292 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16293 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
16294 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16295 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16296
16297 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
16298 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
16299 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
16300 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
16301 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16302 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16303
16304 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
16305 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
16306 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16307 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
16308 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16309 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000016310
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016311 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
16312 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016313
16314 /* old style commands */
16315 install_element (VIEW_NODE, &show_ip_bgp_cmd);
16316 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
16317 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
16318 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
16319 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16320 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16321 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
16322 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16323 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16324 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16325 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
16326 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
16327 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
16328 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
16329 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16330 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
16331 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16332 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
16333 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16334 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
16335 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16336 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
16337 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16338 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
16339 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16340 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
16341 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
16342 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
16343 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
16344 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
16345 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
16346 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
16347 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
16348 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
16349 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
16350 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
16351 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
16352 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16353 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16354 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16355 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16356 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
16357 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16358 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
16359 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16360 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
16361 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16362 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16363 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16364 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16365 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16366 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
16367 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16368 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16369 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16370 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
16371 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
16372 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16373 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
16374 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16375 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
16376 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
16377 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
16378 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16379 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16380 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
16381 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
16382 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16383 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16384 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16385 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16386 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16387 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
16388 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16389 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
16390 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
16391 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
16392 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
16393 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16394 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16395 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16396 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
16397 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16398 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16399 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
16400 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
16401 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16402 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
16403 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16404 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16405 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16406 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
16407 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
16408 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
16409 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
16410 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
16411 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
16412 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
16413 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
16414 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
16415 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
16416 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
16417 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
16418 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
16419 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
16420 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16421 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16422 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16423 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16424 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
16425 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16426 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16427 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16428 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
16429 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
16430 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
16431 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
16432 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16433 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16434 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
16435 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16436 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16437 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16438 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
16439 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
16440 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
16441 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
16442 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16443 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
16444 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16445 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
16446 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16447 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
16448 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16449 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
16450 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16451 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
16452 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16453 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
16454 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
16455 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
16456 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
16457 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
16458 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
16459 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
16460 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
16461 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
16462 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
16463 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
16464 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
16465 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16466 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16467 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16468 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16469 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
16470 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16471 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
16472 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16473 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
16474 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16475 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16476 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16477 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16478 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16479 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
16480 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16481 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16482 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16483 install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd);
16484 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
16485 install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16486 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
16487 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16488 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
16489 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd);
16490 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
16491 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16492 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16493 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
16494 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd);
16495 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
16496 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16497 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16498 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16499 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16500 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16501 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
16502 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16503 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
16504 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
16505 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
16506 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
16507 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16508 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16509 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16510 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
16511 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16512 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16513 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
16514 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
16515 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
16516 install_element (VIEW_NODE, &show_bgp_cmd);
16517 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
16518 install_element (VIEW_NODE, &show_bgp_route_cmd);
16519 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
16520 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
16521 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
16522 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
16523 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
16524 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
16525 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
16526 install_element (VIEW_NODE, &show_bgp_community_cmd);
16527 install_element (VIEW_NODE, &show_bgp_community2_cmd);
16528 install_element (VIEW_NODE, &show_bgp_community3_cmd);
16529 install_element (VIEW_NODE, &show_bgp_community4_cmd);
16530 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
16531 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
16532 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
16533 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
16534 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16535 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
16536 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
16537 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
16538 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
16539 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
16540 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
16541 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16542 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
16543 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
16544 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
16545 install_element (VIEW_NODE, &show_bgp_view_cmd);
16546 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
16547 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
16548 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16549 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16550 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
16551 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16552 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
16553 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
16554 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
16555 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
16556 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
16557 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
16558 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
16559 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
16560 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
16561 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
16562 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
16563 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
16564 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
16565 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
16566 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
16567 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16568 install_element (ENABLE_NODE, &show_bgp_cmd);
16569 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
16570 install_element (ENABLE_NODE, &show_bgp_route_cmd);
16571 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
16572 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
16573 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
16574 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
16575 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
16576 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
16577 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
16578 install_element (ENABLE_NODE, &show_bgp_community_cmd);
16579 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
16580 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
16581 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
16582 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
16583 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
16584 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
16585 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
16586 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16587 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
16588 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
16589 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
16590 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
16591 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
16592 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16593 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
16594 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
16595 install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
16596 install_element (ENABLE_NODE, &show_bgp_view_cmd);
16597 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
16598 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
16599 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16600 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16601 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
16602 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16603 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
16604 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
16605 install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
16606 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
16607 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
16608 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
16609 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
16610 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
16611 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
16612 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
16613 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
16614 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
16615 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
16616 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
16617 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
16618 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
16619 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
16620 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
16621 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
16622 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
16623 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
16624 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16625 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16626 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
16627 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
16628 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
16629 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
16630 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16631 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
16632 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
16633 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
16634 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
16635 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
16636 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
16637 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
16638 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16639 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16640 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16641 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
16642 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16643 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16644 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
16645 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
16646 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
16647 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
16648 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
16649 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
16650 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
16651 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
16652 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
16653 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
16654 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
16655 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
16656 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
16657 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
16658 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
16659 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
16660 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16661 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16662 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
16663 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
16664 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
16665 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
16666 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16667 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
16668 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
16669 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
16670 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
16671 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
16672 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
16673 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
16674 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16675 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16676 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16677 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
16678 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16679 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16680 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16681 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16682 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16683 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16684 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16685 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16686 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16687 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16688 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
16689 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
16690 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16691 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16692 /* old with name safi collision */
16693 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
16694 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
16695 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
16696 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
16697 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
16698 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
16699 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
16700 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
16701 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
16702 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
16703 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
16704 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
16705 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
16706 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
16707 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
16708 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
16709 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
16710 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
16711 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
16712 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
16713 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
16714 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
16715 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
16716 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
16717 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16718 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
16719 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16720 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
16721
16722 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
16723 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
16724 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
16725 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
16726 install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
16727 install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
16728
16729 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
16730 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
16731 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
16732 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
16733 install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
16734 install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016735}
Chris Caputo228da422009-07-18 05:44:03 +000016736
16737void
16738bgp_route_finish (void)
16739{
16740 bgp_table_unlock (bgp_distance_table);
16741 bgp_distance_table = NULL;
16742}