blob: 0dcae61ea559dc4e3dc49bdc64909300e06fd983 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
23#include "prefix.h"
24#include "linklist.h"
25#include "memory.h"
26#include "command.h"
27#include "stream.h"
28#include "filter.h"
29#include "str.h"
30#include "log.h"
31#include "routemap.h"
32#include "buffer.h"
33#include "sockunion.h"
34#include "plist.h"
35#include "thread.h"
paul200df112005-06-01 11:17:05 +000036#include "workqueue.h"
paul718e3742002-12-13 20:15:29 +000037
38#include "bgpd/bgpd.h"
39#include "bgpd/bgp_table.h"
40#include "bgpd/bgp_route.h"
41#include "bgpd/bgp_attr.h"
42#include "bgpd/bgp_debug.h"
43#include "bgpd/bgp_aspath.h"
44#include "bgpd/bgp_regex.h"
45#include "bgpd/bgp_community.h"
46#include "bgpd/bgp_ecommunity.h"
47#include "bgpd/bgp_clist.h"
48#include "bgpd/bgp_packet.h"
49#include "bgpd/bgp_filter.h"
50#include "bgpd/bgp_fsm.h"
51#include "bgpd/bgp_mplsvpn.h"
52#include "bgpd/bgp_nexthop.h"
53#include "bgpd/bgp_damp.h"
54#include "bgpd/bgp_advertise.h"
55#include "bgpd/bgp_zebra.h"
hasso0a486e52005-02-01 20:57:17 +000056#include "bgpd/bgp_vty.h"
Josh Bailey96450fa2011-07-20 20:45:12 -070057#include "bgpd/bgp_mpath.h"
paul718e3742002-12-13 20:15:29 +000058
59/* Extern from bgp_dump.c */
Stephen Hemmingerdde72582009-05-08 15:19:07 -070060extern const char *bgp_origin_str[];
61extern const char *bgp_origin_long_str[];
David Lamparter6b0655a2014-06-04 06:53:35 +020062
paul94f2b392005-06-28 12:44:16 +000063static struct bgp_node *
paulfee0f4c2004-09-13 05:12:46 +000064bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
paul718e3742002-12-13 20:15:29 +000065 struct prefix_rd *prd)
66{
67 struct bgp_node *rn;
68 struct bgp_node *prn = NULL;
Paul Jakmada5b30f2006-05-08 14:37:17 +000069
70 assert (table);
71 if (!table)
72 return NULL;
73
Lou Berger298cc2f2016-01-12 13:42:02 -050074 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000075 {
paulfee0f4c2004-09-13 05:12:46 +000076 prn = bgp_node_get (table, (struct prefix *) prd);
paul718e3742002-12-13 20:15:29 +000077
78 if (prn->info == NULL)
Paul Jakma64e580a2006-02-21 01:09:01 +000079 prn->info = bgp_table_init (afi, safi);
paul718e3742002-12-13 20:15:29 +000080 else
81 bgp_unlock_node (prn);
82 table = prn->info;
83 }
paul718e3742002-12-13 20:15:29 +000084
85 rn = bgp_node_get (table, p);
86
Lou Berger298cc2f2016-01-12 13:42:02 -050087 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000088 rn->prn = prn;
89
90 return rn;
91}
David Lamparter6b0655a2014-06-04 06:53:35 +020092
Paul Jakmafb982c22007-05-04 20:15:47 +000093/* Allocate bgp_info_extra */
94static struct bgp_info_extra *
95bgp_info_extra_new (void)
96{
97 struct bgp_info_extra *new;
98 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra));
99 return new;
100}
101
102static void
103bgp_info_extra_free (struct bgp_info_extra **extra)
104{
105 if (extra && *extra)
106 {
107 if ((*extra)->damp_info)
108 bgp_damp_info_free ((*extra)->damp_info, 0);
109
110 (*extra)->damp_info = NULL;
111
112 XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra);
113
114 *extra = NULL;
115 }
116}
117
118/* Get bgp_info extra information for the given bgp_info, lazy allocated
119 * if required.
120 */
121struct bgp_info_extra *
122bgp_info_extra_get (struct bgp_info *ri)
123{
124 if (!ri->extra)
125 ri->extra = bgp_info_extra_new();
126 return ri->extra;
127}
128
paul718e3742002-12-13 20:15:29 +0000129/* Allocate new bgp info structure. */
paul200df112005-06-01 11:17:05 +0000130static struct bgp_info *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -0800131bgp_info_new (void)
paul718e3742002-12-13 20:15:29 +0000132{
Stephen Hemminger393deb92008-08-18 14:13:29 -0700133 return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
paul718e3742002-12-13 20:15:29 +0000134}
135
136/* Free bgp route information. */
paul200df112005-06-01 11:17:05 +0000137static void
paul718e3742002-12-13 20:15:29 +0000138bgp_info_free (struct bgp_info *binfo)
139{
140 if (binfo->attr)
Paul Jakmaf6f434b2010-11-23 21:28:03 +0000141 bgp_attr_unintern (&binfo->attr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000142
143 bgp_info_extra_free (&binfo->extra);
Josh Baileyde8d5df2011-07-20 20:46:01 -0700144 bgp_info_mpath_free (&binfo->mpath);
paul718e3742002-12-13 20:15:29 +0000145
paul200df112005-06-01 11:17:05 +0000146 peer_unlock (binfo->peer); /* bgp_info peer reference */
147
paul718e3742002-12-13 20:15:29 +0000148 XFREE (MTYPE_BGP_ROUTE, binfo);
149}
150
paul200df112005-06-01 11:17:05 +0000151struct bgp_info *
152bgp_info_lock (struct bgp_info *binfo)
153{
154 binfo->lock++;
155 return binfo;
156}
157
158struct bgp_info *
159bgp_info_unlock (struct bgp_info *binfo)
160{
161 assert (binfo && binfo->lock > 0);
162 binfo->lock--;
163
164 if (binfo->lock == 0)
165 {
166#if 0
167 zlog_debug ("%s: unlocked and freeing", __func__);
168 zlog_backtrace (LOG_DEBUG);
169#endif
170 bgp_info_free (binfo);
171 return NULL;
172 }
173
174#if 0
175 if (binfo->lock == 1)
176 {
177 zlog_debug ("%s: unlocked to 1", __func__);
178 zlog_backtrace (LOG_DEBUG);
179 }
180#endif
181
182 return binfo;
183}
184
paul718e3742002-12-13 20:15:29 +0000185void
186bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
187{
188 struct bgp_info *top;
189
190 top = rn->info;
paul200df112005-06-01 11:17:05 +0000191
paul718e3742002-12-13 20:15:29 +0000192 ri->next = rn->info;
193 ri->prev = NULL;
194 if (top)
195 top->prev = ri;
196 rn->info = ri;
paul200df112005-06-01 11:17:05 +0000197
198 bgp_info_lock (ri);
199 bgp_lock_node (rn);
200 peer_lock (ri->peer); /* bgp_info peer reference */
paul718e3742002-12-13 20:15:29 +0000201}
202
paulb40d9392005-08-22 22:34:41 +0000203/* Do the actual removal of info from RIB, for use by bgp_process
204 completion callback *only* */
205static void
206bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri)
paul718e3742002-12-13 20:15:29 +0000207{
208 if (ri->next)
209 ri->next->prev = ri->prev;
210 if (ri->prev)
211 ri->prev->next = ri->next;
212 else
213 rn->info = ri->next;
paul200df112005-06-01 11:17:05 +0000214
Josh Baileyde8d5df2011-07-20 20:46:01 -0700215 bgp_info_mpath_dequeue (ri);
paul200df112005-06-01 11:17:05 +0000216 bgp_info_unlock (ri);
217 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +0000218}
219
paulb40d9392005-08-22 22:34:41 +0000220void
221bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
222{
Paul Jakma1a392d42006-09-07 00:24:49 +0000223 bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED);
224 /* set of previous already took care of pcount */
paulb40d9392005-08-22 22:34:41 +0000225 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
226}
227
Andrew J. Schorr8d452102006-11-28 19:50:46 +0000228/* undo the effects of a previous call to bgp_info_delete; typically
229 called when a route is deleted and then quickly re-added before the
230 deletion has been processed */
231static void
232bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri)
233{
234 bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED);
235 /* unset of previous already took care of pcount */
236 SET_FLAG (ri->flags, BGP_INFO_VALID);
237}
238
Paul Jakma1a392d42006-09-07 00:24:49 +0000239/* Adjust pcount as required */
240static void
241bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri)
242{
Avneesh Sachdev67174042012-08-17 08:19:49 -0700243 struct bgp_table *table;
244
245 assert (rn && bgp_node_table (rn));
Paul Jakma6f585442006-10-22 19:13:07 +0000246 assert (ri && ri->peer && ri->peer->bgp);
247
Avneesh Sachdev67174042012-08-17 08:19:49 -0700248 table = bgp_node_table (rn);
249
Paul Jakma1a392d42006-09-07 00:24:49 +0000250 /* Ignore 'pcount' for RS-client tables */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700251 if (table->type != BGP_TABLE_MAIN
Paul Jakma1a392d42006-09-07 00:24:49 +0000252 || ri->peer == ri->peer->bgp->peer_self)
253 return;
254
255 if (BGP_INFO_HOLDDOWN (ri)
256 && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
257 {
258
259 UNSET_FLAG (ri->flags, BGP_INFO_COUNTED);
260
261 /* slight hack, but more robust against errors. */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700262 if (ri->peer->pcount[table->afi][table->safi])
263 ri->peer->pcount[table->afi][table->safi]--;
Paul Jakma1a392d42006-09-07 00:24:49 +0000264 else
265 {
266 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
267 __func__, ri->peer->host);
268 zlog_backtrace (LOG_WARNING);
269 zlog_warn ("%s: Please report to Quagga bugzilla", __func__);
270 }
271 }
272 else if (!BGP_INFO_HOLDDOWN (ri)
273 && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
274 {
275 SET_FLAG (ri->flags, BGP_INFO_COUNTED);
Avneesh Sachdev67174042012-08-17 08:19:49 -0700276 ri->peer->pcount[table->afi][table->safi]++;
Paul Jakma1a392d42006-09-07 00:24:49 +0000277 }
278}
279
280
281/* Set/unset bgp_info flags, adjusting any other state as needed.
282 * This is here primarily to keep prefix-count in check.
283 */
284void
285bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
286{
287 SET_FLAG (ri->flags, flag);
288
289 /* early bath if we know it's not a flag that changes useability state */
290 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
291 return;
292
293 bgp_pcount_adjust (rn, ri);
294}
295
296void
297bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
298{
299 UNSET_FLAG (ri->flags, flag);
300
301 /* early bath if we know it's not a flag that changes useability state */
302 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
303 return;
304
305 bgp_pcount_adjust (rn, ri);
306}
307
paul718e3742002-12-13 20:15:29 +0000308/* Get MED value. If MED value is missing and "bgp bestpath
309 missing-as-worst" is specified, treat it as the worst value. */
paul94f2b392005-06-28 12:44:16 +0000310static u_int32_t
paul718e3742002-12-13 20:15:29 +0000311bgp_med_value (struct attr *attr, struct bgp *bgp)
312{
313 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
314 return attr->med;
315 else
316 {
317 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
paul3b424972003-10-13 09:47:32 +0000318 return BGP_MED_MAX;
paul718e3742002-12-13 20:15:29 +0000319 else
320 return 0;
321 }
322}
323
Paul Jakma6d4742b2015-11-25 17:14:37 +0000324/* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
325 * is preferred, or 0 if they are the same (usually will only occur if
326 * multipath is enabled */
paul94f2b392005-06-28 12:44:16 +0000327static int
Josh Bailey96450fa2011-07-20 20:45:12 -0700328bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
Paul Jakma6d4742b2015-11-25 17:14:37 +0000329 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +0000330{
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000331 struct attr *newattr, *existattr;
332 struct attr_extra *newattre, *existattre;
333 bgp_peer_sort_t new_sort;
334 bgp_peer_sort_t exist_sort;
paul718e3742002-12-13 20:15:29 +0000335 u_int32_t new_pref;
336 u_int32_t exist_pref;
337 u_int32_t new_med;
338 u_int32_t exist_med;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000339 u_int32_t new_weight;
340 u_int32_t exist_weight;
341 uint32_t newm, existm;
paul718e3742002-12-13 20:15:29 +0000342 struct in_addr new_id;
343 struct in_addr exist_id;
344 int new_cluster;
345 int exist_cluster;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000346 int internal_as_route;
347 int confed_as_route;
paul718e3742002-12-13 20:15:29 +0000348 int ret;
Josh Bailey96450fa2011-07-20 20:45:12 -0700349
paul718e3742002-12-13 20:15:29 +0000350 /* 0. Null check. */
351 if (new == NULL)
paul718e3742002-12-13 20:15:29 +0000352 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000353 if (exist == NULL)
354 return -1;
paul718e3742002-12-13 20:15:29 +0000355
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000356 newattr = new->attr;
357 existattr = exist->attr;
358 newattre = newattr->extra;
359 existattre = existattr->extra;
360
paul718e3742002-12-13 20:15:29 +0000361 /* 1. Weight check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000362 new_weight = exist_weight = 0;
363
364 if (newattre)
365 new_weight = newattre->weight;
366 if (existattre)
367 exist_weight = existattre->weight;
368
Paul Jakmafb982c22007-05-04 20:15:47 +0000369 if (new_weight > exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000370 return -1;
Paul Jakmafb982c22007-05-04 20:15:47 +0000371 if (new_weight < exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000372 return 1;
paul718e3742002-12-13 20:15:29 +0000373
374 /* 2. Local preference check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000375 new_pref = exist_pref = bgp->default_local_pref;
paul718e3742002-12-13 20:15:29 +0000376
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000377 if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
378 new_pref = newattr->local_pref;
379 if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
380 exist_pref = existattr->local_pref;
381
paul718e3742002-12-13 20:15:29 +0000382 if (new_pref > exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000383 return -1;
paul718e3742002-12-13 20:15:29 +0000384 if (new_pref < exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000385 return 1;
paul718e3742002-12-13 20:15:29 +0000386
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000387 /* 3. Local route check. We prefer:
388 * - BGP_ROUTE_STATIC
389 * - BGP_ROUTE_AGGREGATE
390 * - BGP_ROUTE_REDISTRIBUTE
391 */
392 if (! (new->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000393 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000394 if (! (exist->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000395 return 1;
paul718e3742002-12-13 20:15:29 +0000396
397 /* 4. AS path length check. */
398 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
399 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000400 int exist_hops = aspath_count_hops (existattr->aspath);
401 int exist_confeds = aspath_count_confeds (existattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000402
hasso68118452005-04-08 15:40:36 +0000403 if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
404 {
paulfe69a502005-09-10 16:55:02 +0000405 int aspath_hops;
406
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000407 aspath_hops = aspath_count_hops (newattr->aspath);
408 aspath_hops += aspath_count_confeds (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000409
410 if ( aspath_hops < (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000411 return -1;
paulfe69a502005-09-10 16:55:02 +0000412 if ( aspath_hops > (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000413 return 1;
hasso68118452005-04-08 15:40:36 +0000414 }
415 else
416 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000417 int newhops = aspath_count_hops (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000418
419 if (newhops < exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000420 return -1;
paulfe69a502005-09-10 16:55:02 +0000421 if (newhops > exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000422 return 1;
hasso68118452005-04-08 15:40:36 +0000423 }
paul718e3742002-12-13 20:15:29 +0000424 }
425
426 /* 5. Origin check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000427 if (newattr->origin < existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000428 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000429 if (newattr->origin > existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000430 return 1;
paul718e3742002-12-13 20:15:29 +0000431
432 /* 6. MED check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000433 internal_as_route = (aspath_count_hops (newattr->aspath) == 0
434 && aspath_count_hops (existattr->aspath) == 0);
435 confed_as_route = (aspath_count_confeds (newattr->aspath) > 0
436 && aspath_count_confeds (existattr->aspath) > 0
437 && aspath_count_hops (newattr->aspath) == 0
438 && aspath_count_hops (existattr->aspath) == 0);
paul718e3742002-12-13 20:15:29 +0000439
440 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
441 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
442 && confed_as_route)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000443 || aspath_cmp_left (newattr->aspath, existattr->aspath)
444 || aspath_cmp_left_confed (newattr->aspath, existattr->aspath)
paul718e3742002-12-13 20:15:29 +0000445 || internal_as_route)
446 {
447 new_med = bgp_med_value (new->attr, bgp);
448 exist_med = bgp_med_value (exist->attr, bgp);
449
450 if (new_med < exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000451 return -1;
paul718e3742002-12-13 20:15:29 +0000452 if (new_med > exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000453 return 1;
paul718e3742002-12-13 20:15:29 +0000454 }
455
456 /* 7. Peer type check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000457 new_sort = new->peer->sort;
458 exist_sort = exist->peer->sort;
459
460 if (new_sort == BGP_PEER_EBGP
461 && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000462 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000463 if (exist_sort == BGP_PEER_EBGP
464 && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000465 return 1;
paul718e3742002-12-13 20:15:29 +0000466
467 /* 8. IGP metric check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000468 newm = existm = 0;
469
470 if (new->extra)
471 newm = new->extra->igpmetric;
472 if (exist->extra)
473 existm = exist->extra->igpmetric;
474
Josh Bailey96450fa2011-07-20 20:45:12 -0700475 if (newm < existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000476 return -1;
Josh Bailey96450fa2011-07-20 20:45:12 -0700477 if (newm > existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000478 return 1;
paul718e3742002-12-13 20:15:29 +0000479
480 /* 9. Maximum path check. */
Paul Jakma6d4742b2015-11-25 17:14:37 +0000481 if (bgp_mpath_is_configured (bgp, afi, safi))
Josh Bailey96450fa2011-07-20 20:45:12 -0700482 {
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000483 if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX))
484 {
Paul Jakma6d4742b2015-11-25 17:14:37 +0000485 /*
486 * For the two paths, all comparison steps till IGP metric
487 * have succeeded - including AS_PATH hop count. Since 'bgp
488 * bestpath as-path multipath-relax' knob is on, we don't need
489 * an exact match of AS_PATH. Thus, mark the paths are equal.
490 * That will trigger both these paths to get into the multipath
491 * array.
492 */
493 return 0;
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000494 }
495 else if (new->peer->sort == BGP_PEER_IBGP)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000496 {
497 if (aspath_cmp (new->attr->aspath, exist->attr->aspath))
498 return 0;
499 }
Josh Bailey96450fa2011-07-20 20:45:12 -0700500 else if (new->peer->as == exist->peer->as)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000501 return 0;
Josh Bailey96450fa2011-07-20 20:45:12 -0700502 }
paul718e3742002-12-13 20:15:29 +0000503
504 /* 10. If both paths are external, prefer the path that was received
505 first (the oldest one). This step minimizes route-flap, since a
506 newer path won't displace an older one, even if it was the
507 preferred route based on the additional decision criteria below. */
508 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000509 && new_sort == BGP_PEER_EBGP
510 && exist_sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +0000511 {
512 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000513 return -1;
paul718e3742002-12-13 20:15:29 +0000514 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000515 return 1;
paul718e3742002-12-13 20:15:29 +0000516 }
517
vivekbd4b7f12014-09-30 15:54:45 -0700518 /* 11. Router-ID comparision. */
519 /* If one of the paths is "stale", the corresponding peer router-id will
520 * be 0 and would always win over the other path. If originator id is
521 * used for the comparision, it will decide which path is better.
522 */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000523 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
524 new_id.s_addr = newattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000525 else
526 new_id.s_addr = new->peer->remote_id.s_addr;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000527 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
528 exist_id.s_addr = existattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000529 else
530 exist_id.s_addr = exist->peer->remote_id.s_addr;
531
532 if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000533 return -1;
paul718e3742002-12-13 20:15:29 +0000534 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000535 return 1;
paul718e3742002-12-13 20:15:29 +0000536
537 /* 12. Cluster length comparision. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000538 new_cluster = exist_cluster = 0;
539
540 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
541 new_cluster = newattre->cluster->length;
542 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
543 exist_cluster = existattre->cluster->length;
paul718e3742002-12-13 20:15:29 +0000544
545 if (new_cluster < exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000546 return -1;
paul718e3742002-12-13 20:15:29 +0000547 if (new_cluster > exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000548 return 1;
paul718e3742002-12-13 20:15:29 +0000549
550 /* 13. Neighbor address comparision. */
vivekbd4b7f12014-09-30 15:54:45 -0700551 /* Do this only if neither path is "stale" as stale paths do not have
552 * valid peer information (as the connection may or may not be up).
553 */
554 if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000555 return -1;
vivekbd4b7f12014-09-30 15:54:45 -0700556 if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000557 return 1;
Timo Teräs2820a012015-06-24 15:27:21 +0300558 /* locally configured routes to advertise do not have su_remote */
559 if (new->peer->su_remote == NULL)
Timo Teräs2820a012015-06-24 15:27:21 +0300560 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000561 if (exist->peer->su_remote == NULL)
562 return -1;
Timo Teräs2820a012015-06-24 15:27:21 +0300563
paul718e3742002-12-13 20:15:29 +0000564 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
565
566 if (ret == 1)
paul718e3742002-12-13 20:15:29 +0000567 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000568 if (ret == -1)
569 return -1;
paul718e3742002-12-13 20:15:29 +0000570
Paul Jakma6d4742b2015-11-25 17:14:37 +0000571 return -1;
paul718e3742002-12-13 20:15:29 +0000572}
573
paul94f2b392005-06-28 12:44:16 +0000574static enum filter_type
paul718e3742002-12-13 20:15:29 +0000575bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
576 afi_t afi, safi_t safi)
577{
578 struct bgp_filter *filter;
579
580 filter = &peer->filter[afi][safi];
581
Paul Jakma650f76c2009-06-25 18:06:31 +0100582#define FILTER_EXIST_WARN(F,f,filter) \
583 if (BGP_DEBUG (update, UPDATE_IN) \
584 && !(F ## _IN (filter))) \
585 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
586 peer->host, #f, F ## _IN_NAME(filter));
587
588 if (DISTRIBUTE_IN_NAME (filter)) {
589 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
590
paul718e3742002-12-13 20:15:29 +0000591 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
592 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100593 }
paul718e3742002-12-13 20:15:29 +0000594
Paul Jakma650f76c2009-06-25 18:06:31 +0100595 if (PREFIX_LIST_IN_NAME (filter)) {
596 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
597
paul718e3742002-12-13 20:15:29 +0000598 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
599 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100600 }
paul718e3742002-12-13 20:15:29 +0000601
Paul Jakma650f76c2009-06-25 18:06:31 +0100602 if (FILTER_LIST_IN_NAME (filter)) {
603 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
604
paul718e3742002-12-13 20:15:29 +0000605 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
606 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100607 }
608
paul718e3742002-12-13 20:15:29 +0000609 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100610#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000611}
612
paul94f2b392005-06-28 12:44:16 +0000613static enum filter_type
paul718e3742002-12-13 20:15:29 +0000614bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
615 afi_t afi, safi_t safi)
616{
617 struct bgp_filter *filter;
618
619 filter = &peer->filter[afi][safi];
620
Paul Jakma650f76c2009-06-25 18:06:31 +0100621#define FILTER_EXIST_WARN(F,f,filter) \
622 if (BGP_DEBUG (update, UPDATE_OUT) \
623 && !(F ## _OUT (filter))) \
624 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
625 peer->host, #f, F ## _OUT_NAME(filter));
626
627 if (DISTRIBUTE_OUT_NAME (filter)) {
628 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
629
paul718e3742002-12-13 20:15:29 +0000630 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
631 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100632 }
paul718e3742002-12-13 20:15:29 +0000633
Paul Jakma650f76c2009-06-25 18:06:31 +0100634 if (PREFIX_LIST_OUT_NAME (filter)) {
635 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
636
paul718e3742002-12-13 20:15:29 +0000637 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
638 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100639 }
paul718e3742002-12-13 20:15:29 +0000640
Paul Jakma650f76c2009-06-25 18:06:31 +0100641 if (FILTER_LIST_OUT_NAME (filter)) {
642 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
643
paul718e3742002-12-13 20:15:29 +0000644 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
645 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100646 }
paul718e3742002-12-13 20:15:29 +0000647
648 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100649#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000650}
651
652/* If community attribute includes no_export then return 1. */
paul94f2b392005-06-28 12:44:16 +0000653static int
paul718e3742002-12-13 20:15:29 +0000654bgp_community_filter (struct peer *peer, struct attr *attr)
655{
656 if (attr->community)
657 {
658 /* NO_ADVERTISE check. */
659 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
660 return 1;
661
662 /* NO_EXPORT check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000663 if (peer->sort == BGP_PEER_EBGP &&
paul718e3742002-12-13 20:15:29 +0000664 community_include (attr->community, COMMUNITY_NO_EXPORT))
665 return 1;
666
667 /* NO_EXPORT_SUBCONFED check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000668 if (peer->sort == BGP_PEER_EBGP
669 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000670 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
671 return 1;
672 }
673 return 0;
674}
675
676/* Route reflection loop check. */
677static int
678bgp_cluster_filter (struct peer *peer, struct attr *attr)
679{
680 struct in_addr cluster_id;
681
Paul Jakmafb982c22007-05-04 20:15:47 +0000682 if (attr->extra && attr->extra->cluster)
paul718e3742002-12-13 20:15:29 +0000683 {
684 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
685 cluster_id = peer->bgp->cluster_id;
686 else
687 cluster_id = peer->bgp->router_id;
688
Paul Jakmafb982c22007-05-04 20:15:47 +0000689 if (cluster_loop_check (attr->extra->cluster, cluster_id))
paul718e3742002-12-13 20:15:29 +0000690 return 1;
691 }
692 return 0;
693}
David Lamparter6b0655a2014-06-04 06:53:35 +0200694
paul94f2b392005-06-28 12:44:16 +0000695static int
paul718e3742002-12-13 20:15:29 +0000696bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
697 afi_t afi, safi_t safi)
698{
699 struct bgp_filter *filter;
700 struct bgp_info info;
701 route_map_result_t ret;
702
703 filter = &peer->filter[afi][safi];
704
705 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000706 if (peer->weight)
707 (bgp_attr_extra_get (attr))->weight = peer->weight;
paul718e3742002-12-13 20:15:29 +0000708
709 /* Route map apply. */
710 if (ROUTE_MAP_IN_NAME (filter))
711 {
712 /* Duplicate current value to new strucutre for modification. */
713 info.peer = peer;
714 info.attr = attr;
715
paulac41b2a2003-08-12 05:32:27 +0000716 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
717
paul718e3742002-12-13 20:15:29 +0000718 /* Apply BGP route map to the attribute. */
719 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
paulac41b2a2003-08-12 05:32:27 +0000720
721 peer->rmap_type = 0;
722
paul718e3742002-12-13 20:15:29 +0000723 if (ret == RMAP_DENYMATCH)
David Lamparterc460e572014-06-04 00:54:58 +0200724 /* caller has multiple error paths with bgp_attr_flush() */
725 return RMAP_DENY;
paul718e3742002-12-13 20:15:29 +0000726 }
727 return RMAP_PERMIT;
728}
David Lamparter6b0655a2014-06-04 06:53:35 +0200729
paul94f2b392005-06-28 12:44:16 +0000730static int
paulfee0f4c2004-09-13 05:12:46 +0000731bgp_export_modifier (struct peer *rsclient, struct peer *peer,
732 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
733{
734 struct bgp_filter *filter;
735 struct bgp_info info;
736 route_map_result_t ret;
737
738 filter = &peer->filter[afi][safi];
739
740 /* Route map apply. */
741 if (ROUTE_MAP_EXPORT_NAME (filter))
742 {
743 /* Duplicate current value to new strucutre for modification. */
744 info.peer = rsclient;
745 info.attr = attr;
746
747 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
748
749 /* Apply BGP route map to the attribute. */
750 ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
751
752 rsclient->rmap_type = 0;
753
754 if (ret == RMAP_DENYMATCH)
755 {
756 /* Free newly generated AS path and community by route-map. */
757 bgp_attr_flush (attr);
758 return RMAP_DENY;
759 }
760 }
761 return RMAP_PERMIT;
762}
763
paul94f2b392005-06-28 12:44:16 +0000764static int
paulfee0f4c2004-09-13 05:12:46 +0000765bgp_import_modifier (struct peer *rsclient, struct peer *peer,
766 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
767{
768 struct bgp_filter *filter;
769 struct bgp_info info;
770 route_map_result_t ret;
771
772 filter = &rsclient->filter[afi][safi];
773
774 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000775 if (peer->weight)
776 (bgp_attr_extra_get (attr))->weight = peer->weight;
paulfee0f4c2004-09-13 05:12:46 +0000777
778 /* Route map apply. */
779 if (ROUTE_MAP_IMPORT_NAME (filter))
780 {
781 /* Duplicate current value to new strucutre for modification. */
782 info.peer = peer;
783 info.attr = attr;
784
785 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
786
787 /* Apply BGP route map to the attribute. */
788 ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
789
790 peer->rmap_type = 0;
791
792 if (ret == RMAP_DENYMATCH)
793 {
794 /* Free newly generated AS path and community by route-map. */
795 bgp_attr_flush (attr);
796 return RMAP_DENY;
797 }
798 }
799 return RMAP_PERMIT;
800}
David Lamparter6b0655a2014-06-04 06:53:35 +0200801
paul94f2b392005-06-28 12:44:16 +0000802static int
paul718e3742002-12-13 20:15:29 +0000803bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
804 struct attr *attr, afi_t afi, safi_t safi)
805{
806 int ret;
807 char buf[SU_ADDRSTRLEN];
808 struct bgp_filter *filter;
paul718e3742002-12-13 20:15:29 +0000809 struct peer *from;
810 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +0000811 int transparent;
812 int reflect;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700813 struct attr *riattr;
paul718e3742002-12-13 20:15:29 +0000814
815 from = ri->peer;
816 filter = &peer->filter[afi][safi];
817 bgp = peer->bgp;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700818 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paul718e3742002-12-13 20:15:29 +0000819
Paul Jakma750e8142008-07-22 21:11:48 +0000820 if (DISABLE_BGP_ANNOUNCE)
821 return 0;
paul718e3742002-12-13 20:15:29 +0000822
paulfee0f4c2004-09-13 05:12:46 +0000823 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
824 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
825 return 0;
826
paul718e3742002-12-13 20:15:29 +0000827 /* Do not send back route to sender. */
828 if (from == peer)
829 return 0;
830
831 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000832 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +0000833 if (! UNSUPPRESS_MAP_NAME (filter))
834 return 0;
835
836 /* Default route check. */
837 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
838 {
839 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
840 return 0;
paul718e3742002-12-13 20:15:29 +0000841 else if (p->family == AF_INET6 && p->prefixlen == 0)
842 return 0;
paul718e3742002-12-13 20:15:29 +0000843 }
844
paul286e1e72003-08-08 00:24:31 +0000845 /* Transparency check. */
846 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
847 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
848 transparent = 1;
849 else
850 transparent = 0;
851
paul718e3742002-12-13 20:15:29 +0000852 /* If community is not disabled check the no-export and local. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700853 if (! transparent && bgp_community_filter (peer, riattr))
paul718e3742002-12-13 20:15:29 +0000854 return 0;
855
856 /* If the attribute has originator-id and it is same as remote
857 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700858 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paul718e3742002-12-13 20:15:29 +0000859 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700860 if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +0000861 {
862 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000863 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000864 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
865 peer->host,
866 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
867 p->prefixlen);
868 return 0;
869 }
870 }
871
872 /* ORF prefix-list filter check */
873 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
874 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
875 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
876 if (peer->orf_plist[afi][safi])
877 {
878 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
879 return 0;
880 }
881
882 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700883 if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
paul718e3742002-12-13 20:15:29 +0000884 {
885 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000886 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000887 "%s [Update:SEND] %s/%d is filtered",
888 peer->host,
889 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
890 p->prefixlen);
891 return 0;
892 }
893
894#ifdef BGP_SEND_ASPATH_CHECK
895 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700896 if (aspath_loop_check (riattr->aspath, peer->as))
paul718e3742002-12-13 20:15:29 +0000897 {
898 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000899 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400900 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000901 peer->host, peer->as);
902 return 0;
903 }
904#endif /* BGP_SEND_ASPATH_CHECK */
905
906 /* If we're a CONFED we need to loop check the CONFED ID too */
907 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
908 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700909 if (aspath_loop_check(riattr->aspath, bgp->confed_id))
paul718e3742002-12-13 20:15:29 +0000910 {
911 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000912 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400913 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000914 peer->host,
915 bgp->confed_id);
916 return 0;
917 }
918 }
919
920 /* Route-Reflect check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000921 if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +0000922 reflect = 1;
923 else
924 reflect = 0;
925
926 /* IBGP reflection check. */
927 if (reflect)
928 {
929 /* A route from a Client peer. */
930 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
931 {
932 /* Reflect to all the Non-Client peers and also to the
933 Client peers other than the originator. Originator check
934 is already done. So there is noting to do. */
935 /* no bgp client-to-client reflection check. */
936 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
937 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
938 return 0;
939 }
940 else
941 {
942 /* A route from a Non-client peer. Reflect to all other
943 clients. */
944 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
945 return 0;
946 }
947 }
Paul Jakma41367172007-08-06 15:24:51 +0000948
paul718e3742002-12-13 20:15:29 +0000949 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700950 bgp_attr_dup (attr, riattr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000951
paul718e3742002-12-13 20:15:29 +0000952 /* If local-preference is not set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000953 if ((peer->sort == BGP_PEER_IBGP
954 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000955 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
956 {
957 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
958 attr->local_pref = bgp->default_local_pref;
959 }
960
Pradosh Mohapatra689bb662013-09-07 07:13:37 +0000961 /* If originator-id is not set and the route is to be reflected,
962 set the originator id */
963 if (peer && from && peer->sort == BGP_PEER_IBGP &&
964 from->sort == BGP_PEER_IBGP &&
965 (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))))
966 {
967 attr->extra = bgp_attr_extra_get(attr);
968 IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id));
969 SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
970 }
971
paul718e3742002-12-13 20:15:29 +0000972 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000973 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +0000974 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
975 {
976 if (ri->peer != bgp->peer_self && ! transparent
977 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
978 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
979 }
980
Lou Berger298cc2f2016-01-12 13:42:02 -0500981
982#define NEXTHOP_IS_V4 (\
983 (safi != SAFI_ENCAP && p->family == AF_INET) || \
984 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4))
985
Lou Berger298cc2f2016-01-12 13:42:02 -0500986#define NEXTHOP_IS_V6 (\
987 (safi != SAFI_ENCAP && p->family == AF_INET6) || \
988 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
Lou Berger298cc2f2016-01-12 13:42:02 -0500989
paul718e3742002-12-13 20:15:29 +0000990 /* next-hop-set */
Timo Teräs9e7a53c2014-04-24 10:22:37 +0300991 if (transparent
992 || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
paul718e3742002-12-13 20:15:29 +0000993 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
Lou Berger298cc2f2016-01-12 13:42:02 -0500994 && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr)
Lou Berger298cc2f2016-01-12 13:42:02 -0500995 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +0000996 ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paul286e1e72003-08-08 00:24:31 +0000997 )))
paul718e3742002-12-13 20:15:29 +0000998 {
999 /* NEXT-HOP Unchanged. */
1000 }
1001 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
Lou Berger298cc2f2016-01-12 13:42:02 -05001002 || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0)
Lou Berger298cc2f2016-01-12 13:42:02 -05001003 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001004 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001005 || (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001006 && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0))
1007 {
1008 /* Set IPv4 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001009 if (NEXTHOP_IS_V4)
paul718e3742002-12-13 20:15:29 +00001010 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001011 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001012 memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4,
1013 IPV4_MAX_BYTELEN);
paul718e3742002-12-13 20:15:29 +00001014 else
1015 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
1016 }
paul718e3742002-12-13 20:15:29 +00001017 /* Set IPv6 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001018 if (NEXTHOP_IS_V6)
paul718e3742002-12-13 20:15:29 +00001019 {
1020 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001021 memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00001022 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001023 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001024 }
paul718e3742002-12-13 20:15:29 +00001025 }
1026
Lou Berger298cc2f2016-01-12 13:42:02 -05001027 if (p->family == AF_INET6 && safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00001028 {
paulfee0f4c2004-09-13 05:12:46 +00001029 /* Left nexthop_local unchanged if so configured. */
1030 if ( CHECK_FLAG (peer->af_flags[afi][safi],
1031 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1032 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001033 if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) )
1034 attr->extra->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001035 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001036 attr->extra->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001037 }
1038
1039 /* Default nexthop_local treatment for non-RS-Clients */
1040 else
1041 {
paul718e3742002-12-13 20:15:29 +00001042 /* Link-local address should not be transit to different peer. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001043 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001044
1045 /* Set link-local address for shared network peer. */
1046 if (peer->shared_network
1047 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
1048 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001049 memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00001050 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001051 attr->extra->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00001052 }
1053
1054 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1055 address.*/
1056 if (reflect)
Paul Jakmafb982c22007-05-04 20:15:47 +00001057 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001058
1059 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1060 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
Paul Jakmafb982c22007-05-04 20:15:47 +00001061 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001062 }
paulfee0f4c2004-09-13 05:12:46 +00001063
1064 }
paul718e3742002-12-13 20:15:29 +00001065
1066 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001067 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001068 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1069 && aspath_private_as_check (attr->aspath))
1070 attr->aspath = aspath_empty_get ();
1071
1072 /* Route map & unsuppress-map apply. */
1073 if (ROUTE_MAP_OUT_NAME (filter)
Paul Jakmafb982c22007-05-04 20:15:47 +00001074 || (ri->extra && ri->extra->suppress) )
paul718e3742002-12-13 20:15:29 +00001075 {
Paul Jakma7c7fa1b2006-02-18 10:52:09 +00001076 struct bgp_info info;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001077 struct attr dummy_attr;
1078 struct attr_extra dummy_extra;
1079
1080 dummy_attr.extra = &dummy_extra;
1081
paul718e3742002-12-13 20:15:29 +00001082 info.peer = peer;
1083 info.attr = attr;
1084
1085 /* The route reflector is not allowed to modify the attributes
1086 of the reflected IBGP routes. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001087 if (from->sort == BGP_PEER_IBGP
1088 && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +00001089 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001090 bgp_attr_dup (&dummy_attr, attr);
Paul Jakma9eda90c2007-08-30 13:36:17 +00001091 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00001092 }
paulac41b2a2003-08-12 05:32:27 +00001093
1094 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
1095
Paul Jakmafb982c22007-05-04 20:15:47 +00001096 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00001097 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1098 else
1099 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1100
paulac41b2a2003-08-12 05:32:27 +00001101 peer->rmap_type = 0;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001102
paul718e3742002-12-13 20:15:29 +00001103 if (ret == RMAP_DENYMATCH)
1104 {
1105 bgp_attr_flush (attr);
1106 return 0;
1107 }
1108 }
1109 return 1;
1110}
1111
paul94f2b392005-06-28 12:44:16 +00001112static int
paulfee0f4c2004-09-13 05:12:46 +00001113bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
1114 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001115{
paulfee0f4c2004-09-13 05:12:46 +00001116 int ret;
1117 char buf[SU_ADDRSTRLEN];
1118 struct bgp_filter *filter;
1119 struct bgp_info info;
1120 struct peer *from;
Josh Bailey0b597ef2011-07-20 20:49:11 -07001121 struct attr *riattr;
paulfee0f4c2004-09-13 05:12:46 +00001122
1123 from = ri->peer;
1124 filter = &rsclient->filter[afi][safi];
Josh Bailey0b597ef2011-07-20 20:49:11 -07001125 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paulfee0f4c2004-09-13 05:12:46 +00001126
Paul Jakma750e8142008-07-22 21:11:48 +00001127 if (DISABLE_BGP_ANNOUNCE)
1128 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001129
1130 /* Do not send back route to sender. */
1131 if (from == rsclient)
1132 return 0;
1133
1134 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001135 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001136 if (! UNSUPPRESS_MAP_NAME (filter))
1137 return 0;
1138
1139 /* Default route check. */
1140 if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
1141 PEER_STATUS_DEFAULT_ORIGINATE))
1142 {
1143 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
1144 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001145 else if (p->family == AF_INET6 && p->prefixlen == 0)
1146 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001147 }
1148
1149 /* If the attribute has originator-id and it is same as remote
1150 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001151 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paulfee0f4c2004-09-13 05:12:46 +00001152 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001153 if (IPV4_ADDR_SAME (&rsclient->remote_id,
Josh Bailey0b597ef2011-07-20 20:49:11 -07001154 &riattr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001155 {
1156 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001157 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001158 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1159 rsclient->host,
1160 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1161 p->prefixlen);
1162 return 0;
1163 }
1164 }
1165
1166 /* ORF prefix-list filter check */
1167 if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
1168 && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
1169 || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
1170 if (rsclient->orf_plist[afi][safi])
1171 {
1172 if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
1173 return 0;
1174 }
1175
1176 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001177 if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
paulfee0f4c2004-09-13 05:12:46 +00001178 {
1179 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001180 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001181 "%s [Update:SEND] %s/%d is filtered",
1182 rsclient->host,
1183 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1184 p->prefixlen);
1185 return 0;
1186 }
1187
1188#ifdef BGP_SEND_ASPATH_CHECK
1189 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001190 if (aspath_loop_check (riattr->aspath, rsclient->as))
paulfee0f4c2004-09-13 05:12:46 +00001191 {
1192 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001193 zlog (rsclient->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001194 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paulfee0f4c2004-09-13 05:12:46 +00001195 rsclient->host, rsclient->as);
1196 return 0;
1197 }
1198#endif /* BGP_SEND_ASPATH_CHECK */
1199
1200 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001201 bgp_attr_dup (attr, riattr);
paulfee0f4c2004-09-13 05:12:46 +00001202
1203 /* next-hop-set */
1204 if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
paulfee0f4c2004-09-13 05:12:46 +00001205 || (p->family == AF_INET6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001206 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paulfee0f4c2004-09-13 05:12:46 +00001207 )
1208 {
1209 /* Set IPv4 nexthop. */
1210 if (p->family == AF_INET)
1211 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001212 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001213 memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4,
paulfee0f4c2004-09-13 05:12:46 +00001214 IPV4_MAX_BYTELEN);
1215 else
1216 memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
1217 }
paulfee0f4c2004-09-13 05:12:46 +00001218 /* Set IPv6 nexthop. */
1219 if (p->family == AF_INET6)
1220 {
1221 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001222 memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global,
paulfee0f4c2004-09-13 05:12:46 +00001223 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001224 attr->extra->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001225 }
paulfee0f4c2004-09-13 05:12:46 +00001226 }
1227
paulfee0f4c2004-09-13 05:12:46 +00001228 if (p->family == AF_INET6)
1229 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001230 struct attr_extra *attre = attr->extra;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001231
paulfee0f4c2004-09-13 05:12:46 +00001232 /* Left nexthop_local unchanged if so configured. */
1233 if ( CHECK_FLAG (rsclient->af_flags[afi][safi],
1234 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1235 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001236 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1237 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001238 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001239 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001240 }
1241
1242 /* Default nexthop_local treatment for RS-Clients */
1243 else
1244 {
1245 /* Announcer and RS-Client are both in the same network */
1246 if (rsclient->shared_network && from->shared_network &&
1247 (rsclient->ifindex == from->ifindex))
1248 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001249 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1250 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001251 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001252 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001253 }
1254
1255 /* Set link-local address for shared network peer. */
1256 else if (rsclient->shared_network
1257 && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
1258 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001259 memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local,
paulfee0f4c2004-09-13 05:12:46 +00001260 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001261 attre->mp_nexthop_len = 32;
paulfee0f4c2004-09-13 05:12:46 +00001262 }
1263
1264 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001265 attre->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001266 }
1267
1268 }
paulfee0f4c2004-09-13 05:12:46 +00001269
1270 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001271 if (rsclient->sort == BGP_PEER_EBGP
paulfee0f4c2004-09-13 05:12:46 +00001272 && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1273 && aspath_private_as_check (attr->aspath))
1274 attr->aspath = aspath_empty_get ();
1275
1276 /* Route map & unsuppress-map apply. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001277 if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) )
paulfee0f4c2004-09-13 05:12:46 +00001278 {
1279 info.peer = rsclient;
1280 info.attr = attr;
1281
1282 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
1283
Paul Jakmafb982c22007-05-04 20:15:47 +00001284 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001285 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1286 else
1287 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1288
1289 rsclient->rmap_type = 0;
1290
1291 if (ret == RMAP_DENYMATCH)
1292 {
1293 bgp_attr_flush (attr);
1294 return 0;
1295 }
1296 }
1297
1298 return 1;
1299}
1300
1301struct bgp_info_pair
1302{
1303 struct bgp_info *old;
1304 struct bgp_info *new;
1305};
1306
paul94f2b392005-06-28 12:44:16 +00001307static void
Josh Bailey96450fa2011-07-20 20:45:12 -07001308bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
Paul Jakma6d4742b2015-11-25 17:14:37 +00001309 struct bgp_info_pair *result,
1310 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00001311{
paul718e3742002-12-13 20:15:29 +00001312 struct bgp_info *new_select;
1313 struct bgp_info *old_select;
paulfee0f4c2004-09-13 05:12:46 +00001314 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00001315 struct bgp_info *ri1;
1316 struct bgp_info *ri2;
paulb40d9392005-08-22 22:34:41 +00001317 struct bgp_info *nextri = NULL;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001318 int cmpret, do_mpath;
Josh Bailey96450fa2011-07-20 20:45:12 -07001319 struct list mp_list;
Paul Jakma91b9e852015-12-01 14:32:11 +00001320
1321 result->old = result->new = NULL;
1322
1323 if (rn->info == NULL)
1324 {
1325 char buf[PREFIX_STRLEN];
1326 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1327 __func__,
1328 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1329 return;
1330 }
1331
Josh Bailey96450fa2011-07-20 20:45:12 -07001332 bgp_mp_list_init (&mp_list);
Paul Jakma6d4742b2015-11-25 17:14:37 +00001333 do_mpath = bgp_mpath_is_configured (bgp, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001334
paul718e3742002-12-13 20:15:29 +00001335 /* bgp deterministic-med */
1336 new_select = NULL;
1337 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1338 for (ri1 = rn->info; ri1; ri1 = ri1->next)
1339 {
1340 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
1341 continue;
1342 if (BGP_INFO_HOLDDOWN (ri1))
1343 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001344 if (ri1->peer && ri1->peer != bgp->peer_self)
1345 if (ri1->peer->status != Established)
1346 continue;
paul718e3742002-12-13 20:15:29 +00001347
1348 new_select = ri1;
Josh Bailey6918e742011-07-20 20:48:20 -07001349 if (do_mpath)
1350 bgp_mp_list_add (&mp_list, ri1);
1351 old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
paul718e3742002-12-13 20:15:29 +00001352 if (ri1->next)
1353 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
1354 {
1355 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
1356 continue;
1357 if (BGP_INFO_HOLDDOWN (ri2))
1358 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001359 if (ri2->peer &&
1360 ri2->peer != bgp->peer_self &&
1361 !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
1362 if (ri2->peer->status != Established)
1363 continue;
paul718e3742002-12-13 20:15:29 +00001364
1365 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
1366 || aspath_cmp_left_confed (ri1->attr->aspath,
1367 ri2->attr->aspath))
1368 {
Josh Bailey6918e742011-07-20 20:48:20 -07001369 if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED))
1370 old_select = ri2;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001371 if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi))
1372 == -1)
paul718e3742002-12-13 20:15:29 +00001373 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001374 bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001375 new_select = ri2;
1376 }
1377
Paul Jakma6d4742b2015-11-25 17:14:37 +00001378 if (do_mpath)
1379 {
1380 if (cmpret != 0)
1381 bgp_mp_list_clear (&mp_list);
1382
1383 if (cmpret == 0 || cmpret == -1)
1384 bgp_mp_list_add (&mp_list, ri2);
1385 }
Josh Bailey6918e742011-07-20 20:48:20 -07001386
Paul Jakma1a392d42006-09-07 00:24:49 +00001387 bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001388 }
1389 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001390 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
1391 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
Josh Bailey6918e742011-07-20 20:48:20 -07001392
Paul Jakma6d4742b2015-11-25 17:14:37 +00001393 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey6918e742011-07-20 20:48:20 -07001394 bgp_mp_list_clear (&mp_list);
paul718e3742002-12-13 20:15:29 +00001395 }
1396
1397 /* Check old selected route and new selected route. */
1398 old_select = NULL;
1399 new_select = NULL;
paulb40d9392005-08-22 22:34:41 +00001400 for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
paul718e3742002-12-13 20:15:29 +00001401 {
1402 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
1403 old_select = ri;
1404
1405 if (BGP_INFO_HOLDDOWN (ri))
paulb40d9392005-08-22 22:34:41 +00001406 {
1407 /* reap REMOVED routes, if needs be
1408 * selected route must stay for a while longer though
1409 */
1410 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
1411 && (ri != old_select))
1412 bgp_info_reap (rn, ri);
1413
1414 continue;
1415 }
paul718e3742002-12-13 20:15:29 +00001416
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001417 if (ri->peer &&
1418 ri->peer != bgp->peer_self &&
1419 !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
1420 if (ri->peer->status != Established)
1421 continue;
1422
paul718e3742002-12-13 20:15:29 +00001423 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
1424 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
1425 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001426 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001427 continue;
1428 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001429 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
1430 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001431
Paul Jakma6d4742b2015-11-25 17:14:37 +00001432 if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1)
Josh Bailey96450fa2011-07-20 20:45:12 -07001433 {
Josh Bailey6918e742011-07-20 20:48:20 -07001434 if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1435 bgp_mp_dmed_deselect (new_select);
1436
Josh Bailey96450fa2011-07-20 20:45:12 -07001437 new_select = ri;
Josh Bailey96450fa2011-07-20 20:45:12 -07001438 }
Paul Jakma6d4742b2015-11-25 17:14:37 +00001439 else if (cmpret == 1 && do_mpath
1440 && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Josh Bailey6918e742011-07-20 20:48:20 -07001441 bgp_mp_dmed_deselect (ri);
Josh Bailey96450fa2011-07-20 20:45:12 -07001442
Paul Jakma6d4742b2015-11-25 17:14:37 +00001443 if (do_mpath)
1444 {
1445 if (cmpret != 0)
1446 bgp_mp_list_clear (&mp_list);
1447
1448 if (cmpret == 0 || cmpret == -1)
1449 bgp_mp_list_add (&mp_list, ri);
1450 }
paul718e3742002-12-13 20:15:29 +00001451 }
paulfee0f4c2004-09-13 05:12:46 +00001452
Josh Bailey6918e742011-07-20 20:48:20 -07001453 if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Paul Jakma6d4742b2015-11-25 17:14:37 +00001454 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001455
Josh Bailey0b597ef2011-07-20 20:49:11 -07001456 bgp_info_mpath_aggregate_update (new_select, old_select);
Josh Bailey96450fa2011-07-20 20:45:12 -07001457 bgp_mp_list_clear (&mp_list);
1458
1459 result->old = old_select;
1460 result->new = new_select;
1461
1462 return;
paulfee0f4c2004-09-13 05:12:46 +00001463}
1464
paul94f2b392005-06-28 12:44:16 +00001465static int
paulfee0f4c2004-09-13 05:12:46 +00001466bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
Paul Jakma9eda90c2007-08-30 13:36:17 +00001467 struct bgp_node *rn, afi_t afi, safi_t safi)
1468{
paulfee0f4c2004-09-13 05:12:46 +00001469 struct prefix *p;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001470 struct attr attr;
1471 struct attr_extra extra;
paulfee0f4c2004-09-13 05:12:46 +00001472
Lou Berger050defe2016-01-12 13:41:59 -05001473 memset (&attr, 0, sizeof(struct attr));
1474 memset (&extra, 0, sizeof(struct attr_extra));
1475
paulfee0f4c2004-09-13 05:12:46 +00001476 p = &rn->p;
1477
Paul Jakma9eda90c2007-08-30 13:36:17 +00001478 /* Announce route to Established peer. */
1479 if (peer->status != Established)
paulfee0f4c2004-09-13 05:12:46 +00001480 return 0;
1481
Paul Jakma9eda90c2007-08-30 13:36:17 +00001482 /* Address family configuration check. */
1483 if (! peer->afc_nego[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001484 return 0;
1485
Paul Jakma9eda90c2007-08-30 13:36:17 +00001486 /* First update is deferred until ORF or ROUTE-REFRESH is received */
paulfee0f4c2004-09-13 05:12:46 +00001487 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1488 PEER_STATUS_ORF_WAIT_REFRESH))
1489 return 0;
1490
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001491 /* It's initialized in bgp_announce_[check|check_rsclient]() */
1492 attr.extra = &extra;
1493
Avneesh Sachdev67174042012-08-17 08:19:49 -07001494 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001495 {
1496 case BGP_TABLE_MAIN:
1497 /* Announcement to peer->conf. If the route is filtered,
1498 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001499 if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
1500 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
paulfee0f4c2004-09-13 05:12:46 +00001501 else
1502 bgp_adj_out_unset (rn, peer, p, afi, safi);
1503 break;
1504 case BGP_TABLE_RSCLIENT:
1505 /* Announcement to peer->conf. If the route is filtered,
1506 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001507 if (selected &&
1508 bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
1509 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
1510 else
1511 bgp_adj_out_unset (rn, peer, p, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001512 break;
1513 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001514
Lou Berger050defe2016-01-12 13:41:59 -05001515 bgp_attr_flush (&attr);
paulfee0f4c2004-09-13 05:12:46 +00001516 return 0;
paul200df112005-06-01 11:17:05 +00001517}
paulfee0f4c2004-09-13 05:12:46 +00001518
paul200df112005-06-01 11:17:05 +00001519struct bgp_process_queue
paulfee0f4c2004-09-13 05:12:46 +00001520{
paul200df112005-06-01 11:17:05 +00001521 struct bgp *bgp;
1522 struct bgp_node *rn;
1523 afi_t afi;
1524 safi_t safi;
1525};
1526
1527static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001528bgp_process_rsclient (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001529{
paul0fb58d52005-11-14 14:31:49 +00001530 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001531 struct bgp *bgp = pq->bgp;
1532 struct bgp_node *rn = pq->rn;
1533 afi_t afi = pq->afi;
1534 safi_t safi = pq->safi;
paulfee0f4c2004-09-13 05:12:46 +00001535 struct bgp_info *new_select;
1536 struct bgp_info *old_select;
1537 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001538 struct listnode *node, *nnode;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001539 struct peer *rsclient = bgp_node_table (rn)->owner;
paul200df112005-06-01 11:17:05 +00001540
paulfee0f4c2004-09-13 05:12:46 +00001541 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001542 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001543 new_select = old_and_new.new;
1544 old_select = old_and_new.old;
1545
paul200df112005-06-01 11:17:05 +00001546 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
1547 {
Chris Caputo228da422009-07-18 05:44:03 +00001548 if (rsclient->group)
1549 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient))
1550 {
1551 /* Nothing to do. */
1552 if (old_select && old_select == new_select)
1553 if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1554 continue;
paulfee0f4c2004-09-13 05:12:46 +00001555
Chris Caputo228da422009-07-18 05:44:03 +00001556 if (old_select)
1557 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1558 if (new_select)
1559 {
1560 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1561 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001562 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1563 }
paulfee0f4c2004-09-13 05:12:46 +00001564
Chris Caputo228da422009-07-18 05:44:03 +00001565 bgp_process_announce_selected (rsclient, new_select, rn,
1566 afi, safi);
1567 }
paul200df112005-06-01 11:17:05 +00001568 }
1569 else
1570 {
hassob7395792005-08-26 12:58:38 +00001571 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001572 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hassob7395792005-08-26 12:58:38 +00001573 if (new_select)
1574 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001575 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1576 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001577 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hassob7395792005-08-26 12:58:38 +00001578 }
Paul Jakma9eda90c2007-08-30 13:36:17 +00001579 bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
paul200df112005-06-01 11:17:05 +00001580 }
paulfee0f4c2004-09-13 05:12:46 +00001581
paulb40d9392005-08-22 22:34:41 +00001582 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1583 bgp_info_reap (rn, old_select);
1584
paul200df112005-06-01 11:17:05 +00001585 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1586 return WQ_SUCCESS;
paulfee0f4c2004-09-13 05:12:46 +00001587}
1588
paul200df112005-06-01 11:17:05 +00001589static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001590bgp_process_main (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001591{
paul0fb58d52005-11-14 14:31:49 +00001592 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001593 struct bgp *bgp = pq->bgp;
1594 struct bgp_node *rn = pq->rn;
1595 afi_t afi = pq->afi;
1596 safi_t safi = pq->safi;
1597 struct prefix *p = &rn->p;
paulfee0f4c2004-09-13 05:12:46 +00001598 struct bgp_info *new_select;
1599 struct bgp_info *old_select;
1600 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001601 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00001602 struct peer *peer;
Paul Jakmafb982c22007-05-04 20:15:47 +00001603
paulfee0f4c2004-09-13 05:12:46 +00001604 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001605 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001606 old_select = old_and_new.old;
1607 new_select = old_and_new.new;
1608
1609 /* Nothing to do. */
1610 if (old_select && old_select == new_select)
1611 {
1612 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
paul200df112005-06-01 11:17:05 +00001613 {
Josh Bailey8196f132011-07-20 20:47:07 -07001614 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) ||
1615 CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG))
G.Balaji5a616c02011-11-26 21:58:42 +04001616 bgp_zebra_announce (p, old_select, bgp, safi);
paul200df112005-06-01 11:17:05 +00001617
Josh Bailey8196f132011-07-20 20:47:07 -07001618 UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
paul200df112005-06-01 11:17:05 +00001619 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1620 return WQ_SUCCESS;
1621 }
paulfee0f4c2004-09-13 05:12:46 +00001622 }
paul718e3742002-12-13 20:15:29 +00001623
hasso338b3422005-02-23 14:27:24 +00001624 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001625 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hasso338b3422005-02-23 14:27:24 +00001626 if (new_select)
1627 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001628 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1629 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001630 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hasso338b3422005-02-23 14:27:24 +00001631 }
1632
1633
paul718e3742002-12-13 20:15:29 +00001634 /* Check each BGP peer. */
paul1eb8ef22005-04-07 07:30:20 +00001635 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00001636 {
Paul Jakma9eda90c2007-08-30 13:36:17 +00001637 bgp_process_announce_selected (peer, new_select, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001638 }
1639
1640 /* FIB update. */
G.Balaji5a616c02011-11-26 21:58:42 +04001641 if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
1642 ! bgp_option_check (BGP_OPT_NO_FIB)))
paul718e3742002-12-13 20:15:29 +00001643 {
1644 if (new_select
1645 && new_select->type == ZEBRA_ROUTE_BGP
1646 && new_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001647 bgp_zebra_announce (p, new_select, bgp, safi);
paul718e3742002-12-13 20:15:29 +00001648 else
1649 {
1650 /* Withdraw the route from the kernel. */
1651 if (old_select
1652 && old_select->type == ZEBRA_ROUTE_BGP
1653 && old_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001654 bgp_zebra_withdraw (p, old_select, safi);
paul718e3742002-12-13 20:15:29 +00001655 }
1656 }
paulb40d9392005-08-22 22:34:41 +00001657
Lou Berger050defe2016-01-12 13:41:59 -05001658 /* Reap old select bgp_info, if it has been removed */
paulb40d9392005-08-22 22:34:41 +00001659 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1660 bgp_info_reap (rn, old_select);
1661
paul200df112005-06-01 11:17:05 +00001662 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1663 return WQ_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001664}
1665
paul200df112005-06-01 11:17:05 +00001666static void
paul0fb58d52005-11-14 14:31:49 +00001667bgp_processq_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001668{
paul0fb58d52005-11-14 14:31:49 +00001669 struct bgp_process_queue *pq = data;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001670 struct bgp_table *table = bgp_node_table (pq->rn);
paul0fb58d52005-11-14 14:31:49 +00001671
Chris Caputo228da422009-07-18 05:44:03 +00001672 bgp_unlock (pq->bgp);
paul200df112005-06-01 11:17:05 +00001673 bgp_unlock_node (pq->rn);
Chris Caputo228da422009-07-18 05:44:03 +00001674 bgp_table_unlock (table);
paul200df112005-06-01 11:17:05 +00001675 XFREE (MTYPE_BGP_PROCESS_QUEUE, pq);
1676}
1677
1678static void
1679bgp_process_queue_init (void)
1680{
1681 bm->process_main_queue
1682 = work_queue_new (bm->master, "process_main_queue");
1683 bm->process_rsclient_queue
1684 = work_queue_new (bm->master, "process_rsclient_queue");
1685
1686 if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
1687 {
1688 zlog_err ("%s: Failed to allocate work queue", __func__);
1689 exit (1);
1690 }
1691
1692 bm->process_main_queue->spec.workfunc = &bgp_process_main;
paul200df112005-06-01 11:17:05 +00001693 bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
Paul Jakma838bbde2010-01-08 14:05:32 +00001694 bm->process_main_queue->spec.max_retries = 0;
1695 bm->process_main_queue->spec.hold = 50;
1696
Paul Jakma838bbde2010-01-08 14:05:32 +00001697 bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient;
David Lamparterd43f8b32015-03-03 08:54:54 +01001698 bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del;
1699 bm->process_rsclient_queue->spec.max_retries = 0;
1700 bm->process_rsclient_queue->spec.hold = 50;
paul200df112005-06-01 11:17:05 +00001701}
1702
1703void
paulfee0f4c2004-09-13 05:12:46 +00001704bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1705{
paul200df112005-06-01 11:17:05 +00001706 struct bgp_process_queue *pqnode;
1707
1708 /* already scheduled for processing? */
1709 if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
1710 return;
1711
Paul Jakma91b9e852015-12-01 14:32:11 +00001712 if (rn->info == NULL)
1713 {
1714 /* XXX: Perhaps remove before next release, after we've flushed out
1715 * any obvious cases
1716 */
1717 assert (rn->info != NULL);
1718 char buf[PREFIX_STRLEN];
1719 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1720 __func__,
1721 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1722 return;
1723 }
1724
paul200df112005-06-01 11:17:05 +00001725 if ( (bm->process_main_queue == NULL) ||
1726 (bm->process_rsclient_queue == NULL) )
1727 bgp_process_queue_init ();
1728
1729 pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
1730 sizeof (struct bgp_process_queue));
1731 if (!pqnode)
1732 return;
Chris Caputo228da422009-07-18 05:44:03 +00001733
1734 /* all unlocked in bgp_processq_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07001735 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00001736 pqnode->rn = bgp_lock_node (rn);
paul200df112005-06-01 11:17:05 +00001737 pqnode->bgp = bgp;
Chris Caputo228da422009-07-18 05:44:03 +00001738 bgp_lock (bgp);
paul200df112005-06-01 11:17:05 +00001739 pqnode->afi = afi;
1740 pqnode->safi = safi;
1741
Avneesh Sachdev67174042012-08-17 08:19:49 -07001742 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001743 {
paul200df112005-06-01 11:17:05 +00001744 case BGP_TABLE_MAIN:
1745 work_queue_add (bm->process_main_queue, pqnode);
1746 break;
1747 case BGP_TABLE_RSCLIENT:
1748 work_queue_add (bm->process_rsclient_queue, pqnode);
1749 break;
paulfee0f4c2004-09-13 05:12:46 +00001750 }
paul200df112005-06-01 11:17:05 +00001751
Stephen Hemminger07ff4dc2013-01-04 22:29:20 +00001752 SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
paul200df112005-06-01 11:17:05 +00001753 return;
paulfee0f4c2004-09-13 05:12:46 +00001754}
hasso0a486e52005-02-01 20:57:17 +00001755
paul94f2b392005-06-28 12:44:16 +00001756static int
hasso0a486e52005-02-01 20:57:17 +00001757bgp_maximum_prefix_restart_timer (struct thread *thread)
1758{
1759 struct peer *peer;
1760
1761 peer = THREAD_ARG (thread);
1762 peer->t_pmax_restart = NULL;
1763
1764 if (BGP_DEBUG (events, EVENTS))
1765 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1766 peer->host);
1767
1768 peer_clear (peer);
1769
1770 return 0;
1771}
1772
paulfee0f4c2004-09-13 05:12:46 +00001773int
paul5228ad22004-06-04 17:58:18 +00001774bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1775 safi_t safi, int always)
paul718e3742002-12-13 20:15:29 +00001776{
hassoe0701b72004-05-20 09:19:34 +00001777 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1778 return 0;
1779
1780 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +00001781 {
hassoe0701b72004-05-20 09:19:34 +00001782 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1783 && ! always)
1784 return 0;
paul718e3742002-12-13 20:15:29 +00001785
hassoe0701b72004-05-20 09:19:34 +00001786 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001787 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1788 "limit %ld", afi_safi_print (afi, safi), peer->host,
1789 peer->pcount[afi][safi], peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001790 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
paul718e3742002-12-13 20:15:29 +00001791
hassoe0701b72004-05-20 09:19:34 +00001792 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1793 return 0;
paul718e3742002-12-13 20:15:29 +00001794
hassoe0701b72004-05-20 09:19:34 +00001795 {
paul5228ad22004-06-04 17:58:18 +00001796 u_int8_t ndata[7];
hassoe0701b72004-05-20 09:19:34 +00001797
1798 if (safi == SAFI_MPLS_VPN)
Denis Ovsienko42e6d742011-07-14 12:36:19 +04001799 safi = SAFI_MPLS_LABELED_VPN;
paul5228ad22004-06-04 17:58:18 +00001800
1801 ndata[0] = (afi >> 8);
1802 ndata[1] = afi;
1803 ndata[2] = safi;
1804 ndata[3] = (peer->pmax[afi][safi] >> 24);
1805 ndata[4] = (peer->pmax[afi][safi] >> 16);
1806 ndata[5] = (peer->pmax[afi][safi] >> 8);
1807 ndata[6] = (peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001808
1809 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1810 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1811 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1812 }
hasso0a486e52005-02-01 20:57:17 +00001813
1814 /* restart timer start */
1815 if (peer->pmax_restart[afi][safi])
1816 {
1817 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1818
1819 if (BGP_DEBUG (events, EVENTS))
1820 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1821 peer->host, peer->v_pmax_restart);
1822
1823 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1824 peer->v_pmax_restart);
1825 }
1826
hassoe0701b72004-05-20 09:19:34 +00001827 return 1;
paul718e3742002-12-13 20:15:29 +00001828 }
hassoe0701b72004-05-20 09:19:34 +00001829 else
1830 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1831
1832 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1833 {
1834 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1835 && ! always)
1836 return 0;
1837
1838 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001839 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1840 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1841 peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001842 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1843 }
1844 else
1845 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
paul718e3742002-12-13 20:15:29 +00001846 return 0;
1847}
1848
paulb40d9392005-08-22 22:34:41 +00001849/* Unconditionally remove the route from the RIB, without taking
1850 * damping into consideration (eg, because the session went down)
1851 */
paul94f2b392005-06-28 12:44:16 +00001852static void
paul718e3742002-12-13 20:15:29 +00001853bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1854 afi_t afi, safi_t safi)
1855{
paul902212c2006-02-05 17:51:19 +00001856 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1857
1858 if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1859 bgp_info_delete (rn, ri); /* keep historical info */
1860
paulb40d9392005-08-22 22:34:41 +00001861 bgp_process (peer->bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001862}
1863
paul94f2b392005-06-28 12:44:16 +00001864static void
paul718e3742002-12-13 20:15:29 +00001865bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
Lou Berger050defe2016-01-12 13:41:59 -05001866 afi_t afi, safi_t safi, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00001867{
paul718e3742002-12-13 20:15:29 +00001868 int status = BGP_DAMP_NONE;
1869
paulb40d9392005-08-22 22:34:41 +00001870 /* apply dampening, if result is suppressed, we'll be retaining
1871 * the bgp_info in the RIB for historical reference.
1872 */
1873 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001874 && peer->sort == BGP_PEER_EBGP)
paulb40d9392005-08-22 22:34:41 +00001875 if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0))
1876 == BGP_DAMP_SUPPRESSED)
paul902212c2006-02-05 17:51:19 +00001877 {
paul902212c2006-02-05 17:51:19 +00001878 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1879 return;
1880 }
1881
1882 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00001883}
1884
paul94f2b392005-06-28 12:44:16 +00001885static void
paulfee0f4c2004-09-13 05:12:46 +00001886bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1887 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1888 int sub_type, struct prefix_rd *prd, u_char *tag)
1889{
1890 struct bgp_node *rn;
1891 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001892 struct attr new_attr;
1893 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00001894 struct attr *attr_new;
1895 struct attr *attr_new2;
1896 struct bgp_info *ri;
1897 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001898 const char *reason;
paulfee0f4c2004-09-13 05:12:46 +00001899 char buf[SU_ADDRSTRLEN];
1900
1901 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1902 if (peer == rsclient)
1903 return;
1904
1905 bgp = peer->bgp;
1906 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1907
1908 /* Check previously received route. */
1909 for (ri = rn->info; ri; ri = ri->next)
1910 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1911 break;
1912
1913 /* AS path loop check. */
Milan Kocian000e1572013-10-18 07:59:38 +00001914 if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001915 {
1916 reason = "as-path contains our own AS;";
1917 goto filtered;
1918 }
1919
1920 /* Route reflector originator ID check. */
1921 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00001922 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001923 {
1924 reason = "originator is us;";
1925 goto filtered;
1926 }
Paul Jakmafb982c22007-05-04 20:15:47 +00001927
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001928 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00001929 bgp_attr_dup (&new_attr, attr);
paulfee0f4c2004-09-13 05:12:46 +00001930
1931 /* Apply export policy. */
1932 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1933 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1934 {
1935 reason = "export-policy;";
1936 goto filtered;
1937 }
1938
1939 attr_new2 = bgp_attr_intern (&new_attr);
Paul Jakmafb982c22007-05-04 20:15:47 +00001940
paulfee0f4c2004-09-13 05:12:46 +00001941 /* Apply import policy. */
1942 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1943 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001944 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001945
1946 reason = "import-policy;";
1947 goto filtered;
1948 }
1949
1950 attr_new = bgp_attr_intern (&new_attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001951 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001952
1953 /* IPv4 unicast next hop check. */
G.Balaji5a616c02011-11-26 21:58:42 +04001954 if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
paulfee0f4c2004-09-13 05:12:46 +00001955 {
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001956 /* Next hop must not be 0.0.0.0 nor Class D/E address. */
paulfee0f4c2004-09-13 05:12:46 +00001957 if (new_attr.nexthop.s_addr == 0
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001958 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
paulfee0f4c2004-09-13 05:12:46 +00001959 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001960 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00001961
1962 reason = "martian next-hop;";
1963 goto filtered;
1964 }
1965 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001966
paulfee0f4c2004-09-13 05:12:46 +00001967 /* If the update is implicit withdraw. */
1968 if (ri)
1969 {
Stephen Hemminger65957882010-01-15 16:22:10 +03001970 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00001971
1972 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00001973 if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
1974 && attrhash_cmp (ri->attr, attr_new))
paulfee0f4c2004-09-13 05:12:46 +00001975 {
1976
Paul Jakma1a392d42006-09-07 00:24:49 +00001977 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00001978
1979 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001980 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001981 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1982 peer->host,
1983 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1984 p->prefixlen, rsclient->host);
1985
Chris Caputo228da422009-07-18 05:44:03 +00001986 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001987 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05001988 bgp_attr_flush(&new_attr);
Chris Caputo228da422009-07-18 05:44:03 +00001989 return;
paulfee0f4c2004-09-13 05:12:46 +00001990 }
1991
Paul Jakma16d2e242007-04-10 19:32:10 +00001992 /* Withdraw/Announce before we fully processed the withdraw */
1993 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
1994 bgp_info_restore (rn, ri);
1995
paulfee0f4c2004-09-13 05:12:46 +00001996 /* Received Logging. */
1997 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001998 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00001999 peer->host,
2000 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2001 p->prefixlen, rsclient->host);
2002
2003 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002004 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00002005
2006 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002007 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00002008 ri->attr = attr_new;
2009
2010 /* Update MPLS tag. */
2011 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002012 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002013
Paul Jakma1a392d42006-09-07 00:24:49 +00002014 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002015
2016 /* Process change. */
2017 bgp_process (bgp, rn, afi, safi);
2018 bgp_unlock_node (rn);
2019
2020 return;
2021 }
2022
2023 /* Received Logging. */
2024 if (BGP_DEBUG (update, UPDATE_IN))
2025 {
ajsd2c1f162004-12-08 21:10:20 +00002026 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00002027 peer->host,
2028 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2029 p->prefixlen, rsclient->host);
2030 }
2031
2032 /* Make new BGP info. */
2033 new = bgp_info_new ();
2034 new->type = type;
2035 new->sub_type = sub_type;
2036 new->peer = peer;
2037 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002038 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00002039
2040 /* Update MPLS tag. */
2041 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002042 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002043
Paul Jakma1a392d42006-09-07 00:24:49 +00002044 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002045
2046 /* Register new BGP information. */
2047 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002048
2049 /* route_node_get lock */
2050 bgp_unlock_node (rn);
2051
paulfee0f4c2004-09-13 05:12:46 +00002052 /* Process change. */
2053 bgp_process (bgp, rn, afi, safi);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002054
paulfee0f4c2004-09-13 05:12:46 +00002055 return;
2056
2057 filtered:
2058
2059 /* This BGP update is filtered. Log the reason then update BGP entry. */
2060 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002061 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002062 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
2063 peer->host,
2064 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2065 p->prefixlen, rsclient->host, reason);
2066
2067 if (ri)
paulb40d9392005-08-22 22:34:41 +00002068 bgp_rib_remove (rn, ri, peer, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002069
2070 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002071
paulfee0f4c2004-09-13 05:12:46 +00002072 return;
2073}
2074
paul94f2b392005-06-28 12:44:16 +00002075static void
paulfee0f4c2004-09-13 05:12:46 +00002076bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
2077 struct peer *peer, struct prefix *p, int type, int sub_type,
2078 struct prefix_rd *prd, u_char *tag)
Chris Caputo228da422009-07-18 05:44:03 +00002079{
paulfee0f4c2004-09-13 05:12:46 +00002080 struct bgp_node *rn;
2081 struct bgp_info *ri;
2082 char buf[SU_ADDRSTRLEN];
2083
2084 if (rsclient == peer)
Chris Caputo228da422009-07-18 05:44:03 +00002085 return;
paulfee0f4c2004-09-13 05:12:46 +00002086
2087 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
2088
2089 /* Lookup withdrawn route. */
2090 for (ri = rn->info; ri; ri = ri->next)
2091 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2092 break;
2093
2094 /* Withdraw specified route from routing table. */
2095 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002096 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paulfee0f4c2004-09-13 05:12:46 +00002097 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002098 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002099 "%s Can't find the route %s/%d", peer->host,
2100 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2101 p->prefixlen);
2102
2103 /* Unlock bgp_node_get() lock. */
Chris Caputo228da422009-07-18 05:44:03 +00002104 bgp_unlock_node (rn);
2105}
paulfee0f4c2004-09-13 05:12:46 +00002106
paul94f2b392005-06-28 12:44:16 +00002107static int
paulfee0f4c2004-09-13 05:12:46 +00002108bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
paul718e3742002-12-13 20:15:29 +00002109 afi_t afi, safi_t safi, int type, int sub_type,
2110 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2111{
2112 int ret;
2113 int aspath_loop_count = 0;
2114 struct bgp_node *rn;
2115 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002116 struct attr new_attr;
2117 struct attr_extra new_extra;
paul718e3742002-12-13 20:15:29 +00002118 struct attr *attr_new;
2119 struct bgp_info *ri;
2120 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00002121 const char *reason;
paul718e3742002-12-13 20:15:29 +00002122 char buf[SU_ADDRSTRLEN];
2123
2124 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00002125 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
Paul Jakmafb982c22007-05-04 20:15:47 +00002126
paul718e3742002-12-13 20:15:29 +00002127 /* When peer's soft reconfiguration enabled. Record input packet in
2128 Adj-RIBs-In. */
Jorge Boncompte [DTI2]343aa822012-05-07 16:53:08 +00002129 if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2130 && peer != bgp->peer_self)
paul718e3742002-12-13 20:15:29 +00002131 bgp_adj_in_set (rn, peer, attr);
2132
2133 /* Check previously received route. */
2134 for (ri = rn->info; ri; ri = ri->next)
2135 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2136 break;
2137
2138 /* AS path local-as loop check. */
2139 if (peer->change_local_as)
2140 {
2141 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
2142 aspath_loop_count = 1;
2143
2144 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
2145 {
2146 reason = "as-path contains our own AS;";
2147 goto filtered;
2148 }
2149 }
2150
2151 /* AS path loop check. */
2152 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
2153 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
2154 && aspath_loop_check(attr->aspath, bgp->confed_id)
2155 > peer->allowas_in[afi][safi]))
2156 {
2157 reason = "as-path contains our own AS;";
2158 goto filtered;
2159 }
2160
2161 /* Route reflector originator ID check. */
2162 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00002163 && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +00002164 {
2165 reason = "originator is us;";
2166 goto filtered;
2167 }
2168
2169 /* Route reflector cluster ID check. */
2170 if (bgp_cluster_filter (peer, attr))
2171 {
2172 reason = "reflected from the same cluster;";
2173 goto filtered;
2174 }
2175
2176 /* Apply incoming filter. */
2177 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
2178 {
2179 reason = "filter;";
2180 goto filtered;
2181 }
2182
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002183 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00002184 bgp_attr_dup (&new_attr, attr);
paul718e3742002-12-13 20:15:29 +00002185
David Lamparterc460e572014-06-04 00:54:58 +02002186 /* Apply incoming route-map.
2187 * NB: new_attr may now contain newly allocated values from route-map "set"
2188 * commands, so we need bgp_attr_flush in the error paths, until we intern
2189 * the attr (which takes over the memory references) */
paul718e3742002-12-13 20:15:29 +00002190 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
2191 {
2192 reason = "route-map;";
David Lamparterc460e572014-06-04 00:54:58 +02002193 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002194 goto filtered;
2195 }
2196
2197 /* IPv4 unicast next hop check. */
2198 if (afi == AFI_IP && safi == SAFI_UNICAST)
2199 {
2200 /* If the peer is EBGP and nexthop is not on connected route,
2201 discard it. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002202 if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1
Denis Ovsienko8e80bdf2011-08-05 18:52:52 +04002203 && ! bgp_nexthop_onlink (afi, &new_attr)
hasso6ffd2072005-02-02 14:50:11 +00002204 && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
paul718e3742002-12-13 20:15:29 +00002205 {
2206 reason = "non-connected next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002207 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002208 goto filtered;
2209 }
2210
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04002211 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
paul718e3742002-12-13 20:15:29 +00002212 must not be my own address. */
Jorge Boncompte [DTI2]10f9bf32012-05-07 16:52:52 +00002213 if (new_attr.nexthop.s_addr == 0
2214 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
2215 || bgp_nexthop_self (&new_attr))
paul718e3742002-12-13 20:15:29 +00002216 {
2217 reason = "martian next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002218 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002219 goto filtered;
2220 }
2221 }
2222
2223 attr_new = bgp_attr_intern (&new_attr);
2224
2225 /* If the update is implicit withdraw. */
2226 if (ri)
2227 {
Stephen Hemminger65957882010-01-15 16:22:10 +03002228 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002229
2230 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00002231 if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
2232 && attrhash_cmp (ri->attr, attr_new))
paul718e3742002-12-13 20:15:29 +00002233 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002234 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00002235
2236 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002237 && peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00002238 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2239 {
2240 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002241 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002242 peer->host,
2243 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2244 p->prefixlen);
2245
paul902212c2006-02-05 17:51:19 +00002246 if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
2247 {
2248 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2249 bgp_process (bgp, rn, afi, safi);
2250 }
paul718e3742002-12-13 20:15:29 +00002251 }
Paul Jakma16d2e242007-04-10 19:32:10 +00002252 else /* Duplicate - odd */
paul718e3742002-12-13 20:15:29 +00002253 {
2254 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002255 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002256 "%s rcvd %s/%d...duplicate ignored",
2257 peer->host,
2258 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2259 p->prefixlen);
hasso93406d82005-02-02 14:40:33 +00002260
2261 /* graceful restart STALE flag unset. */
2262 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2263 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002264 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
paul902212c2006-02-05 17:51:19 +00002265 bgp_process (bgp, rn, afi, safi);
hasso93406d82005-02-02 14:40:33 +00002266 }
paul718e3742002-12-13 20:15:29 +00002267 }
2268
2269 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002270 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05002271 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002272
paul718e3742002-12-13 20:15:29 +00002273 return 0;
2274 }
2275
Paul Jakma16d2e242007-04-10 19:32:10 +00002276 /* Withdraw/Announce before we fully processed the withdraw */
2277 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2278 {
2279 if (BGP_DEBUG (update, UPDATE_IN))
2280 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
2281 peer->host,
2282 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2283 p->prefixlen);
2284 bgp_info_restore (rn, ri);
2285 }
2286
paul718e3742002-12-13 20:15:29 +00002287 /* Received Logging. */
2288 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002289 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002290 peer->host,
2291 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2292 p->prefixlen);
2293
hasso93406d82005-02-02 14:40:33 +00002294 /* graceful restart STALE flag unset. */
2295 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma1a392d42006-09-07 00:24:49 +00002296 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
hasso93406d82005-02-02 14:40:33 +00002297
paul718e3742002-12-13 20:15:29 +00002298 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002299 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul902212c2006-02-05 17:51:19 +00002300
2301 /* implicit withdraw, decrement aggregate and pcount here.
2302 * only if update is accepted, they'll increment below.
2303 */
paul902212c2006-02-05 17:51:19 +00002304 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2305
paul718e3742002-12-13 20:15:29 +00002306 /* Update bgp route dampening information. */
2307 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002308 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002309 {
2310 /* This is implicit withdraw so we should update dampening
2311 information. */
2312 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2313 bgp_damp_withdraw (ri, rn, afi, safi, 1);
paul718e3742002-12-13 20:15:29 +00002314 }
2315
paul718e3742002-12-13 20:15:29 +00002316 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002317 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00002318 ri->attr = attr_new;
2319
2320 /* Update MPLS tag. */
2321 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002322 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002323
Lou Berger050defe2016-01-12 13:41:59 -05002324 bgp_attr_flush (&new_attr);
2325
paul718e3742002-12-13 20:15:29 +00002326 /* Update bgp route dampening information. */
2327 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002328 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002329 {
2330 /* Now we do normal update dampening. */
2331 ret = bgp_damp_update (ri, rn, afi, safi);
2332 if (ret == BGP_DAMP_SUPPRESSED)
2333 {
2334 bgp_unlock_node (rn);
2335 return 0;
2336 }
2337 }
2338
2339 /* Nexthop reachability check. */
2340 if ((afi == AFI_IP || afi == AFI_IP6)
2341 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002342 && (peer->sort == BGP_PEER_IBGP
2343 || peer->sort == BGP_PEER_CONFED
2344 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002345 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002346 {
2347 if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002348 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002349 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002350 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002351 }
2352 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002353 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002354
Lou Berger050defe2016-01-12 13:41:59 -05002355 bgp_attr_flush (&new_attr);
2356
paul718e3742002-12-13 20:15:29 +00002357 /* Process change. */
2358 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2359
2360 bgp_process (bgp, rn, afi, safi);
2361 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002362
paul718e3742002-12-13 20:15:29 +00002363 return 0;
2364 }
2365
2366 /* Received Logging. */
2367 if (BGP_DEBUG (update, UPDATE_IN))
2368 {
ajsd2c1f162004-12-08 21:10:20 +00002369 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002370 peer->host,
2371 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2372 p->prefixlen);
2373 }
2374
paul718e3742002-12-13 20:15:29 +00002375 /* Make new BGP info. */
2376 new = bgp_info_new ();
2377 new->type = type;
2378 new->sub_type = sub_type;
2379 new->peer = peer;
2380 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002381 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002382
2383 /* Update MPLS tag. */
2384 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002385 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002386
2387 /* Nexthop reachability check. */
2388 if ((afi == AFI_IP || afi == AFI_IP6)
2389 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002390 && (peer->sort == BGP_PEER_IBGP
2391 || peer->sort == BGP_PEER_CONFED
2392 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002393 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002394 {
2395 if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002396 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002397 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002398 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002399 }
2400 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002401 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002402
paul902212c2006-02-05 17:51:19 +00002403 /* Increment prefix */
paul718e3742002-12-13 20:15:29 +00002404 bgp_aggregate_increment (bgp, p, new, afi, safi);
2405
2406 /* Register new BGP information. */
2407 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002408
2409 /* route_node_get lock */
2410 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002411
Lou Berger050defe2016-01-12 13:41:59 -05002412 bgp_attr_flush (&new_attr);
2413
paul718e3742002-12-13 20:15:29 +00002414 /* If maximum prefix count is configured and current prefix
2415 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00002416 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
2417 return -1;
paul718e3742002-12-13 20:15:29 +00002418
2419 /* Process change. */
2420 bgp_process (bgp, rn, afi, safi);
2421
2422 return 0;
2423
2424 /* This BGP update is filtered. Log the reason then update BGP
2425 entry. */
2426 filtered:
2427 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002428 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002429 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2430 peer->host,
2431 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2432 p->prefixlen, reason);
2433
2434 if (ri)
paulb40d9392005-08-22 22:34:41 +00002435 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002436
2437 bgp_unlock_node (rn);
Lou Berger050defe2016-01-12 13:41:59 -05002438 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002439
paul718e3742002-12-13 20:15:29 +00002440 return 0;
2441}
2442
2443int
paulfee0f4c2004-09-13 05:12:46 +00002444bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
2445 afi_t afi, safi_t safi, int type, int sub_type,
2446 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2447{
2448 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002449 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002450 struct bgp *bgp;
2451 int ret;
2452
2453 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
2454 soft_reconfig);
2455
2456 bgp = peer->bgp;
2457
2458 /* Process the update for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002459 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002460 {
2461 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2462 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
2463 sub_type, prd, tag);
2464 }
2465
2466 return ret;
2467}
2468
2469int
paul718e3742002-12-13 20:15:29 +00002470bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
paul94f2b392005-06-28 12:44:16 +00002471 afi_t afi, safi_t safi, int type, int sub_type,
2472 struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00002473{
2474 struct bgp *bgp;
2475 char buf[SU_ADDRSTRLEN];
2476 struct bgp_node *rn;
2477 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00002478 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002479 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002480
2481 bgp = peer->bgp;
2482
David Lamparter4584c232015-04-13 09:50:00 +02002483 /* Lookup node. */
2484 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2485
2486 /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2487 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2488 * the iteration over all RS clients.
2489 * Since we need to remove the entry from adj_in anyway, do that first and
2490 * if there was no entry, we don't need to do anything more. */
2491 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2492 && peer != bgp->peer_self)
2493 if (!bgp_adj_in_unset (rn, peer))
2494 {
2495 if (BGP_DEBUG (update, UPDATE_IN))
2496 zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
2497 "not in adj-in", peer->host,
2498 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2499 p->prefixlen);
2500 bgp_unlock_node (rn);
2501 return 0;
2502 }
2503
paulfee0f4c2004-09-13 05:12:46 +00002504 /* Process the withdraw for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002505 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002506 {
2507 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2508 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
2509 }
2510
paul718e3742002-12-13 20:15:29 +00002511 /* Logging. */
2512 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002513 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00002514 peer->host,
2515 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2516 p->prefixlen);
2517
paul718e3742002-12-13 20:15:29 +00002518 /* Lookup withdrawn route. */
2519 for (ri = rn->info; ri; ri = ri->next)
2520 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2521 break;
2522
2523 /* Withdraw specified route from routing table. */
2524 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002525 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paul718e3742002-12-13 20:15:29 +00002526 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002527 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002528 "%s Can't find the route %s/%d", peer->host,
2529 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2530 p->prefixlen);
2531
2532 /* Unlock bgp_node_get() lock. */
2533 bgp_unlock_node (rn);
2534
2535 return 0;
2536}
David Lamparter6b0655a2014-06-04 06:53:35 +02002537
paul718e3742002-12-13 20:15:29 +00002538void
2539bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2540{
2541 struct bgp *bgp;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00002542 struct attr attr;
Jorge Boncompte [DTI2]577ac572012-05-07 16:53:06 +00002543 struct aspath *aspath;
paul718e3742002-12-13 20:15:29 +00002544 struct prefix p;
paul718e3742002-12-13 20:15:29 +00002545 struct peer *from;
Christian Frankedcab1bb2012-12-07 16:45:52 +00002546 struct bgp_node *rn;
2547 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00002548 int ret = RMAP_DENYMATCH;
Paul Jakmafb982c22007-05-04 20:15:47 +00002549
Paul Jakmab2497022007-06-14 11:17:58 +00002550 if (!(afi == AFI_IP || afi == AFI_IP6))
Paul Jakmafb982c22007-05-04 20:15:47 +00002551 return;
2552
paul718e3742002-12-13 20:15:29 +00002553 bgp = peer->bgp;
2554 from = bgp->peer_self;
Paul Jakmafb982c22007-05-04 20:15:47 +00002555
paul718e3742002-12-13 20:15:29 +00002556 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2557 aspath = attr.aspath;
2558 attr.local_pref = bgp->default_local_pref;
2559 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2560
2561 if (afi == AFI_IP)
2562 str2prefix ("0.0.0.0/0", &p);
paul718e3742002-12-13 20:15:29 +00002563 else if (afi == AFI_IP6)
2564 {
Jorge Boncompte [DTI2]6182d652012-05-07 16:53:02 +00002565 struct attr_extra *ae = attr.extra;
2566
paul718e3742002-12-13 20:15:29 +00002567 str2prefix ("::/0", &p);
2568
2569 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00002570 memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00002571 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002572 ae->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00002573
2574 /* If the peer is on shared nextwork and we have link-local
2575 nexthop set it. */
2576 if (peer->shared_network
2577 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2578 {
Paul Jakmafb982c22007-05-04 20:15:47 +00002579 memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00002580 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002581 ae->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00002582 }
2583 }
paul718e3742002-12-13 20:15:29 +00002584
2585 if (peer->default_rmap[afi][safi].name)
2586 {
paulfee0f4c2004-09-13 05:12:46 +00002587 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
Christian Frankedcab1bb2012-12-07 16:45:52 +00002588 for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
2589 {
2590 for (ri = rn->info; ri; ri = ri->next)
2591 {
2592 struct attr dummy_attr;
2593 struct attr_extra dummy_extra;
2594 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00002595
Christian Frankedcab1bb2012-12-07 16:45:52 +00002596 /* Provide dummy so the route-map can't modify the attributes */
2597 dummy_attr.extra = &dummy_extra;
2598 bgp_attr_dup(&dummy_attr, ri->attr);
2599 info.peer = ri->peer;
2600 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00002601
Christian Frankedcab1bb2012-12-07 16:45:52 +00002602 ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
2603 RMAP_BGP, &info);
2604
2605 /* The route map might have set attributes. If we don't flush them
2606 * here, they will be leaked. */
2607 bgp_attr_flush(&dummy_attr);
2608 if (ret != RMAP_DENYMATCH)
2609 break;
2610 }
2611 if (ret != RMAP_DENYMATCH)
2612 break;
2613 }
paulfee0f4c2004-09-13 05:12:46 +00002614 bgp->peer_self->rmap_type = 0;
2615
paul718e3742002-12-13 20:15:29 +00002616 if (ret == RMAP_DENYMATCH)
Christian Frankedcab1bb2012-12-07 16:45:52 +00002617 withdraw = 1;
paul718e3742002-12-13 20:15:29 +00002618 }
2619
2620 if (withdraw)
2621 {
2622 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2623 bgp_default_withdraw_send (peer, afi, safi);
2624 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2625 }
2626 else
2627 {
Christian Frankedcab1bb2012-12-07 16:45:52 +00002628 if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2629 {
2630 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2631 bgp_default_update_send (peer, &attr, afi, safi, from);
2632 }
paul718e3742002-12-13 20:15:29 +00002633 }
Paul Jakmafb982c22007-05-04 20:15:47 +00002634
2635 bgp_attr_extra_free (&attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002636 aspath_unintern (&aspath);
paul718e3742002-12-13 20:15:29 +00002637}
David Lamparter6b0655a2014-06-04 06:53:35 +02002638
paul718e3742002-12-13 20:15:29 +00002639static void
2640bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002641 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002642{
2643 struct bgp_node *rn;
2644 struct bgp_info *ri;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002645 struct attr attr;
2646 struct attr_extra extra;
2647
Lou Berger298cc2f2016-01-12 13:42:02 -05002648 memset(&extra, 0, sizeof(extra));
2649
paul718e3742002-12-13 20:15:29 +00002650 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002651 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002652
Lou Berger298cc2f2016-01-12 13:42:02 -05002653 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00002654 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2655 bgp_default_originate (peer, afi, safi, 0);
2656
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002657 /* It's initialized in bgp_announce_[check|check_rsclient]() */
2658 attr.extra = &extra;
2659
paul718e3742002-12-13 20:15:29 +00002660 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2661 for (ri = rn->info; ri; ri = ri->next)
2662 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2663 {
paulfee0f4c2004-09-13 05:12:46 +00002664 if ( (rsclient) ?
2665 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2666 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002667 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2668 else
2669 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2670 }
Lou Berger298cc2f2016-01-12 13:42:02 -05002671
2672 bgp_attr_flush_encap(&attr);
paul718e3742002-12-13 20:15:29 +00002673}
2674
2675void
2676bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2677{
2678 struct bgp_node *rn;
2679 struct bgp_table *table;
2680
2681 if (peer->status != Established)
2682 return;
2683
2684 if (! peer->afc_nego[afi][safi])
2685 return;
2686
2687 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2688 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2689 return;
2690
Lou Berger298cc2f2016-01-12 13:42:02 -05002691 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
paulfee0f4c2004-09-13 05:12:46 +00002692 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002693 else
2694 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2695 rn = bgp_route_next(rn))
2696 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002697 bgp_announce_table (peer, afi, safi, table, 0);
2698
2699 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2700 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002701}
2702
2703void
2704bgp_announce_route_all (struct peer *peer)
2705{
2706 afi_t afi;
2707 safi_t safi;
2708
2709 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2710 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2711 bgp_announce_route (peer, afi, safi);
2712}
David Lamparter6b0655a2014-06-04 06:53:35 +02002713
paul718e3742002-12-13 20:15:29 +00002714static void
paulfee0f4c2004-09-13 05:12:46 +00002715bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002716 safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
paulfee0f4c2004-09-13 05:12:46 +00002717{
2718 struct bgp_node *rn;
2719 struct bgp_adj_in *ain;
2720
2721 if (! table)
2722 table = rsclient->bgp->rib[afi][safi];
2723
2724 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2725 for (ain = rn->adj_in; ain; ain = ain->next)
2726 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002727 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002728 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002729
paulfee0f4c2004-09-13 05:12:46 +00002730 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
Christian Franked53d8fd2013-01-28 07:14:43 +01002731 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
paulfee0f4c2004-09-13 05:12:46 +00002732 }
2733}
2734
2735void
2736bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2737{
2738 struct bgp_table *table;
2739 struct bgp_node *rn;
2740
Lou Berger298cc2f2016-01-12 13:42:02 -05002741 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002742 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
paulfee0f4c2004-09-13 05:12:46 +00002743
2744 else
2745 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2746 rn = bgp_route_next (rn))
2747 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002748 {
2749 struct prefix_rd prd;
2750 prd.family = AF_UNSPEC;
2751 prd.prefixlen = 64;
2752 memcpy(&prd.val, rn->p.u.val, 8);
2753
2754 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
2755 }
paulfee0f4c2004-09-13 05:12:46 +00002756}
David Lamparter6b0655a2014-06-04 06:53:35 +02002757
paulfee0f4c2004-09-13 05:12:46 +00002758static void
paul718e3742002-12-13 20:15:29 +00002759bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002760 struct bgp_table *table, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00002761{
2762 int ret;
2763 struct bgp_node *rn;
2764 struct bgp_adj_in *ain;
2765
2766 if (! table)
2767 table = peer->bgp->rib[afi][safi];
2768
2769 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2770 for (ain = rn->adj_in; ain; ain = ain->next)
2771 {
2772 if (ain->peer == peer)
2773 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002774 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002775 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002776
paul718e3742002-12-13 20:15:29 +00002777 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2778 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
Christian Franked53d8fd2013-01-28 07:14:43 +01002779 prd, tag, 1);
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002780
paul718e3742002-12-13 20:15:29 +00002781 if (ret < 0)
2782 {
2783 bgp_unlock_node (rn);
2784 return;
2785 }
2786 continue;
2787 }
2788 }
2789}
2790
2791void
2792bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2793{
2794 struct bgp_node *rn;
2795 struct bgp_table *table;
2796
2797 if (peer->status != Established)
2798 return;
2799
Lou Berger298cc2f2016-01-12 13:42:02 -05002800 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002801 bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002802 else
2803 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2804 rn = bgp_route_next (rn))
2805 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002806 {
2807 struct prefix_rd prd;
2808 prd.family = AF_UNSPEC;
2809 prd.prefixlen = 64;
2810 memcpy(&prd.val, rn->p.u.val, 8);
2811
2812 bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
2813 }
paul718e3742002-12-13 20:15:29 +00002814}
David Lamparter6b0655a2014-06-04 06:53:35 +02002815
Chris Caputo228da422009-07-18 05:44:03 +00002816
2817struct bgp_clear_node_queue
2818{
2819 struct bgp_node *rn;
2820 enum bgp_clear_route_type purpose;
2821};
2822
paul200df112005-06-01 11:17:05 +00002823static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00002824bgp_clear_route_node (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002825{
Chris Caputo228da422009-07-18 05:44:03 +00002826 struct bgp_clear_node_queue *cnq = data;
2827 struct bgp_node *rn = cnq->rn;
Paul Jakma64e580a2006-02-21 01:09:01 +00002828 struct peer *peer = wq->spec.data;
paul200df112005-06-01 11:17:05 +00002829 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002830 afi_t afi = bgp_node_table (rn)->afi;
2831 safi_t safi = bgp_node_table (rn)->safi;
paul200df112005-06-01 11:17:05 +00002832
Paul Jakma64e580a2006-02-21 01:09:01 +00002833 assert (rn && peer);
paul200df112005-06-01 11:17:05 +00002834
Paul Jakma64e580a2006-02-21 01:09:01 +00002835 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002836 if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
paul200df112005-06-01 11:17:05 +00002837 {
2838 /* graceful restart STALE flag set. */
Paul Jakma64e580a2006-02-21 01:09:01 +00002839 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2840 && peer->nsf[afi][safi]
paul200df112005-06-01 11:17:05 +00002841 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
Paul Jakma1a392d42006-09-07 00:24:49 +00002842 && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
2843 bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
paul200df112005-06-01 11:17:05 +00002844 else
Paul Jakma64e580a2006-02-21 01:09:01 +00002845 bgp_rib_remove (rn, ri, peer, afi, safi);
paul200df112005-06-01 11:17:05 +00002846 break;
2847 }
paul200df112005-06-01 11:17:05 +00002848 return WQ_SUCCESS;
2849}
2850
2851static void
paul0fb58d52005-11-14 14:31:49 +00002852bgp_clear_node_queue_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002853{
Chris Caputo228da422009-07-18 05:44:03 +00002854 struct bgp_clear_node_queue *cnq = data;
2855 struct bgp_node *rn = cnq->rn;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002856 struct bgp_table *table = bgp_node_table (rn);
Paul Jakma64e580a2006-02-21 01:09:01 +00002857
2858 bgp_unlock_node (rn);
Chris Caputo228da422009-07-18 05:44:03 +00002859 bgp_table_unlock (table);
2860 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
paul200df112005-06-01 11:17:05 +00002861}
2862
2863static void
paul94f2b392005-06-28 12:44:16 +00002864bgp_clear_node_complete (struct work_queue *wq)
paul200df112005-06-01 11:17:05 +00002865{
Paul Jakma64e580a2006-02-21 01:09:01 +00002866 struct peer *peer = wq->spec.data;
2867
Paul Jakma3e0c78e2006-03-06 18:06:53 +00002868 /* Tickle FSM to start moving again */
Paul Jakmaca058a32006-09-14 02:58:49 +00002869 BGP_EVENT_ADD (peer, Clearing_Completed);
Chris Caputo228da422009-07-18 05:44:03 +00002870
2871 peer_unlock (peer); /* bgp_clear_route */
paul200df112005-06-01 11:17:05 +00002872}
2873
2874static void
Paul Jakma64e580a2006-02-21 01:09:01 +00002875bgp_clear_node_queue_init (struct peer *peer)
paul200df112005-06-01 11:17:05 +00002876{
Paul Jakmaa2943652009-07-21 14:02:04 +01002877 char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
Paul Jakma64e580a2006-02-21 01:09:01 +00002878
Paul Jakmaa2943652009-07-21 14:02:04 +01002879 snprintf (wname, sizeof(wname), "clear %s", peer->host);
Paul Jakma64e580a2006-02-21 01:09:01 +00002880#undef CLEAR_QUEUE_NAME_LEN
2881
2882 if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
paul200df112005-06-01 11:17:05 +00002883 {
2884 zlog_err ("%s: Failed to allocate work queue", __func__);
2885 exit (1);
2886 }
Paul Jakma64e580a2006-02-21 01:09:01 +00002887 peer->clear_node_queue->spec.hold = 10;
2888 peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
2889 peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
2890 peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
2891 peer->clear_node_queue->spec.max_retries = 0;
2892
2893 /* we only 'lock' this peer reference when the queue is actually active */
2894 peer->clear_node_queue->spec.data = peer;
paul200df112005-06-01 11:17:05 +00002895}
2896
paul718e3742002-12-13 20:15:29 +00002897static void
2898bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
Chris Caputo228da422009-07-18 05:44:03 +00002899 struct bgp_table *table, struct peer *rsclient,
2900 enum bgp_clear_route_type purpose)
paul718e3742002-12-13 20:15:29 +00002901{
2902 struct bgp_node *rn;
paul200df112005-06-01 11:17:05 +00002903
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002904
paul718e3742002-12-13 20:15:29 +00002905 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002906 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
Paul Jakma64e580a2006-02-21 01:09:01 +00002907
hasso6cf159b2005-03-21 10:28:14 +00002908 /* If still no table => afi/safi isn't configured at all or smth. */
2909 if (! table)
2910 return;
Paul Jakma65ca75e2006-05-04 08:08:15 +00002911
2912 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2913 {
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002914 struct bgp_info *ri;
2915 struct bgp_adj_in *ain;
2916 struct bgp_adj_out *aout;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002917
2918 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2919 * queued for every clearing peer, regardless of whether it is
2920 * relevant to the peer at hand.
2921 *
2922 * Overview: There are 3 different indices which need to be
2923 * scrubbed, potentially, when a peer is removed:
2924 *
2925 * 1 peer's routes visible via the RIB (ie accepted routes)
2926 * 2 peer's routes visible by the (optional) peer's adj-in index
2927 * 3 other routes visible by the peer's adj-out index
2928 *
2929 * 3 there is no hurry in scrubbing, once the struct peer is
2930 * removed from bgp->peer, we could just GC such deleted peer's
2931 * adj-outs at our leisure.
2932 *
2933 * 1 and 2 must be 'scrubbed' in some way, at least made
2934 * invisible via RIB index before peer session is allowed to be
2935 * brought back up. So one needs to know when such a 'search' is
2936 * complete.
2937 *
2938 * Ideally:
2939 *
2940 * - there'd be a single global queue or a single RIB walker
2941 * - rather than tracking which route_nodes still need to be
2942 * examined on a peer basis, we'd track which peers still
2943 * aren't cleared
2944 *
2945 * Given that our per-peer prefix-counts now should be reliable,
2946 * this may actually be achievable. It doesn't seem to be a huge
2947 * problem at this time,
2948 */
Jorge Boncompte [DTI2]24e50f22012-05-07 15:17:33 +00002949 for (ain = rn->adj_in; ain; ain = ain->next)
2950 if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2951 {
2952 bgp_adj_in_remove (rn, ain);
2953 bgp_unlock_node (rn);
2954 break;
2955 }
2956 for (aout = rn->adj_out; aout; aout = aout->next)
2957 if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2958 {
2959 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2960 bgp_unlock_node (rn);
2961 break;
2962 }
2963
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002964 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002965 if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002966 {
Chris Caputo228da422009-07-18 05:44:03 +00002967 struct bgp_clear_node_queue *cnq;
2968
2969 /* both unlocked in bgp_clear_node_queue_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07002970 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00002971 bgp_lock_node (rn);
2972 cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
2973 sizeof (struct bgp_clear_node_queue));
2974 cnq->rn = rn;
2975 cnq->purpose = purpose;
2976 work_queue_add (peer->clear_node_queue, cnq);
2977 break;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002978 }
Paul Jakma65ca75e2006-05-04 08:08:15 +00002979 }
2980 return;
2981}
2982
2983void
Chris Caputo228da422009-07-18 05:44:03 +00002984bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
2985 enum bgp_clear_route_type purpose)
Paul Jakma65ca75e2006-05-04 08:08:15 +00002986{
2987 struct bgp_node *rn;
2988 struct bgp_table *table;
2989 struct peer *rsclient;
2990 struct listnode *node, *nnode;
hasso6cf159b2005-03-21 10:28:14 +00002991
Paul Jakma64e580a2006-02-21 01:09:01 +00002992 if (peer->clear_node_queue == NULL)
2993 bgp_clear_node_queue_init (peer);
paul200df112005-06-01 11:17:05 +00002994
Paul Jakmaca058a32006-09-14 02:58:49 +00002995 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2996 * Idle until it receives a Clearing_Completed event. This protects
2997 * against peers which flap faster than we can we clear, which could
2998 * lead to:
Paul Jakma64e580a2006-02-21 01:09:01 +00002999 *
3000 * a) race with routes from the new session being installed before
3001 * clear_route_node visits the node (to delete the route of that
3002 * peer)
3003 * b) resource exhaustion, clear_route_node likely leads to an entry
3004 * on the process_main queue. Fast-flapping could cause that queue
3005 * to grow and grow.
paul200df112005-06-01 11:17:05 +00003006 */
Donald Sharp7ef42212015-03-30 06:32:52 -07003007
3008 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3009 * the unlock will happen upon work-queue completion; other wise, the
3010 * unlock happens at the end of this function.
3011 */
Paul Jakmaca058a32006-09-14 02:58:49 +00003012 if (!peer->clear_node_queue->thread)
Lou Berger050defe2016-01-12 13:41:59 -05003013 peer_lock (peer); /* bgp_clear_node_complete */
Chris Caputo228da422009-07-18 05:44:03 +00003014 switch (purpose)
paulfee0f4c2004-09-13 05:12:46 +00003015 {
Chris Caputo228da422009-07-18 05:44:03 +00003016 case BGP_CLEAR_ROUTE_NORMAL:
Lou Berger298cc2f2016-01-12 13:42:02 -05003017 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Chris Caputo228da422009-07-18 05:44:03 +00003018 bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
3019 else
3020 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
3021 rn = bgp_route_next (rn))
3022 if ((table = rn->info) != NULL)
3023 bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
3024
3025 for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
3026 if (CHECK_FLAG(rsclient->af_flags[afi][safi],
3027 PEER_FLAG_RSERVER_CLIENT))
3028 bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
3029 break;
3030
3031 case BGP_CLEAR_ROUTE_MY_RSCLIENT:
Lou Berger050defe2016-01-12 13:41:59 -05003032 /*
3033 * gpz 091009: TBD why don't we have special handling for
3034 * SAFI_MPLS_VPN here in the original quagga code?
3035 * (and, by extension, for SAFI_ENCAP)
3036 */
Chris Caputo228da422009-07-18 05:44:03 +00003037 bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
3038 break;
3039
3040 default:
3041 assert (0);
3042 break;
paulfee0f4c2004-09-13 05:12:46 +00003043 }
Donald Sharp7ef42212015-03-30 06:32:52 -07003044
3045 /* unlock if no nodes got added to the clear-node-queue. */
Paul Jakma65ca75e2006-05-04 08:08:15 +00003046 if (!peer->clear_node_queue->thread)
Donald Sharp7ef42212015-03-30 06:32:52 -07003047 peer_unlock (peer);
3048
paul718e3742002-12-13 20:15:29 +00003049}
3050
3051void
3052bgp_clear_route_all (struct peer *peer)
3053{
3054 afi_t afi;
3055 safi_t safi;
3056
3057 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3058 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
Chris Caputo228da422009-07-18 05:44:03 +00003059 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
paul718e3742002-12-13 20:15:29 +00003060}
3061
Lou Berger82dd7072016-01-12 13:41:57 -05003062/*
3063 * Finish freeing things when exiting
3064 */
3065static void
3066bgp_drain_workqueue_immediate (struct work_queue *wq)
3067{
3068 if (!wq)
3069 return;
3070
3071 if (!wq->thread)
3072 {
3073 /*
3074 * no thread implies no queued items
3075 */
3076 assert(!wq->items->count);
3077 return;
3078 }
3079
3080 while (wq->items->count)
3081 {
3082 if (wq->thread)
3083 thread_cancel(wq->thread);
3084 work_queue_run(wq->thread);
3085 }
3086}
3087
3088/*
3089 * Special function to process clear node queue when bgpd is exiting
3090 * and the thread scheduler is no longer running.
3091 */
3092void
3093bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
3094{
3095 if (!peer)
3096 return;
3097
3098 bgp_drain_workqueue_immediate(peer->clear_node_queue);
3099}
3100
3101/*
3102 * The work queues are not specific to a BGP instance, but the
3103 * items in them refer to BGP instances, so this should be called
3104 * before each BGP instance is deleted.
3105 */
3106void
3107bgp_process_queues_drain_immediate(void)
3108{
3109 bgp_drain_workqueue_immediate(bm->process_main_queue);
3110 bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
3111}
3112
paul718e3742002-12-13 20:15:29 +00003113void
3114bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
3115{
3116 struct bgp_table *table;
3117 struct bgp_node *rn;
3118 struct bgp_adj_in *ain;
3119
3120 table = peer->bgp->rib[afi][safi];
3121
3122 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3123 for (ain = rn->adj_in; ain ; ain = ain->next)
3124 if (ain->peer == peer)
3125 {
3126 bgp_adj_in_remove (rn, ain);
3127 bgp_unlock_node (rn);
3128 break;
3129 }
3130}
hasso93406d82005-02-02 14:40:33 +00003131
3132void
3133bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
3134{
3135 struct bgp_node *rn;
3136 struct bgp_info *ri;
3137 struct bgp_table *table;
3138
3139 table = peer->bgp->rib[afi][safi];
3140
3141 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3142 {
3143 for (ri = rn->info; ri; ri = ri->next)
3144 if (ri->peer == peer)
3145 {
3146 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
3147 bgp_rib_remove (rn, ri, peer, afi, safi);
3148 break;
3149 }
3150 }
3151}
David Lamparter6b0655a2014-06-04 06:53:35 +02003152
Lou Berger82dd7072016-01-12 13:41:57 -05003153static void
3154bgp_cleanup_table(struct bgp_table *table, safi_t safi)
3155{
3156 struct bgp_node *rn;
3157 struct bgp_info *ri;
3158 struct bgp_info *next;
3159
3160 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3161 for (ri = rn->info; ri; ri = next)
3162 {
3163 next = ri->next;
3164 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
3165 && ri->type == ZEBRA_ROUTE_BGP
3166 && ri->sub_type == BGP_ROUTE_NORMAL)
3167 bgp_zebra_withdraw (&rn->p, ri, safi);
3168 }
3169}
3170
paul718e3742002-12-13 20:15:29 +00003171/* Delete all kernel routes. */
3172void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003173bgp_cleanup_routes (void)
paul718e3742002-12-13 20:15:29 +00003174{
3175 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00003176 struct listnode *node, *nnode;
Lou Berger82dd7072016-01-12 13:41:57 -05003177 afi_t afi;
paul718e3742002-12-13 20:15:29 +00003178
paul1eb8ef22005-04-07 07:30:20 +00003179 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00003180 {
Lou Berger82dd7072016-01-12 13:41:57 -05003181 for (afi = AFI_IP; afi < AFI_MAX; ++afi)
3182 {
3183 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00003184
Lou Berger82dd7072016-01-12 13:41:57 -05003185 bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00003186
Lou Berger82dd7072016-01-12 13:41:57 -05003187 /*
3188 * VPN and ENCAP tables are two-level (RD is top level)
3189 */
3190 for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
3191 rn = bgp_route_next (rn))
Lou Berger298cc2f2016-01-12 13:42:02 -05003192 {
3193 if (rn->info)
Lou Berger82dd7072016-01-12 13:41:57 -05003194 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003195 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
3196 bgp_table_finish ((struct bgp_table **)&(rn->info));
3197 rn->info = NULL;
3198 bgp_unlock_node(rn);
Lou Berger82dd7072016-01-12 13:41:57 -05003199 }
Lou Berger298cc2f2016-01-12 13:42:02 -05003200 }
3201
3202 for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
3203 rn = bgp_route_next (rn))
3204 {
3205 if (rn->info)
3206 {
3207 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
3208 bgp_table_finish ((struct bgp_table **)&(rn->info));
3209 rn->info = NULL;
3210 bgp_unlock_node(rn);
3211 }
3212 }
Lou Berger82dd7072016-01-12 13:41:57 -05003213 }
paul718e3742002-12-13 20:15:29 +00003214 }
3215}
3216
3217void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003218bgp_reset (void)
paul718e3742002-12-13 20:15:29 +00003219{
3220 vty_reset ();
3221 bgp_zclient_reset ();
3222 access_list_reset ();
3223 prefix_list_reset ();
3224}
David Lamparter6b0655a2014-06-04 06:53:35 +02003225
paul718e3742002-12-13 20:15:29 +00003226/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3227 value. */
3228int
3229bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
3230{
3231 u_char *pnt;
3232 u_char *lim;
3233 struct prefix p;
3234 int psize;
3235 int ret;
3236
3237 /* Check peer status. */
3238 if (peer->status != Established)
3239 return 0;
3240
3241 pnt = packet->nlri;
3242 lim = pnt + packet->length;
3243
3244 for (; pnt < lim; pnt += psize)
3245 {
3246 /* Clear prefix structure. */
3247 memset (&p, 0, sizeof (struct prefix));
3248
3249 /* Fetch prefix length. */
3250 p.prefixlen = *pnt++;
3251 p.family = afi2family (packet->afi);
3252
3253 /* Already checked in nlri_sanity_check(). We do double check
3254 here. */
3255 if ((packet->afi == AFI_IP && p.prefixlen > 32)
3256 || (packet->afi == AFI_IP6 && p.prefixlen > 128))
3257 return -1;
3258
3259 /* Packet size overflow check. */
3260 psize = PSIZE (p.prefixlen);
3261
3262 /* When packet overflow occur return immediately. */
3263 if (pnt + psize > lim)
3264 return -1;
3265
3266 /* Fetch prefix from NLRI packet. */
3267 memcpy (&p.u.prefix, pnt, psize);
3268
3269 /* Check address. */
3270 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
3271 {
3272 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
3273 {
paulf5ba3872004-07-09 12:11:31 +00003274 /*
3275 * From draft-ietf-idr-bgp4-22, Section 6.3:
3276 * If a BGP router receives an UPDATE message with a
3277 * semantically incorrect NLRI field, in which a prefix is
3278 * semantically incorrect (eg. an unexpected multicast IP
3279 * address), it should ignore the prefix.
3280 */
paul718e3742002-12-13 20:15:29 +00003281 zlog (peer->log, LOG_ERR,
3282 "IPv4 unicast NLRI is multicast address %s",
3283 inet_ntoa (p.u.prefix4));
paulf5ba3872004-07-09 12:11:31 +00003284
paul718e3742002-12-13 20:15:29 +00003285 return -1;
3286 }
3287 }
3288
paul718e3742002-12-13 20:15:29 +00003289 /* Check address. */
3290 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
3291 {
3292 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3293 {
3294 char buf[BUFSIZ];
3295
3296 zlog (peer->log, LOG_WARNING,
3297 "IPv6 link-local NLRI received %s ignore this NLRI",
3298 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3299
3300 continue;
3301 }
3302 }
paul718e3742002-12-13 20:15:29 +00003303
3304 /* Normal process. */
3305 if (attr)
3306 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
3307 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
3308 else
3309 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
3310 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
3311
3312 /* Address family configuration mismatch or maximum-prefix count
3313 overflow. */
3314 if (ret < 0)
3315 return -1;
3316 }
3317
3318 /* Packet length consistency check. */
3319 if (pnt != lim)
3320 return -1;
3321
3322 return 0;
3323}
3324
3325/* NLRI encode syntax check routine. */
3326int
Lou Berger050defe2016-01-12 13:41:59 -05003327bgp_nlri_sanity_check (struct peer *peer, int afi, safi_t safi,
3328 u_char *pnt, bgp_size_t length)
paul718e3742002-12-13 20:15:29 +00003329{
3330 u_char *end;
3331 u_char prefixlen;
3332 int psize;
3333
3334 end = pnt + length;
3335
3336 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3337 syntactic validity. If the field is syntactically incorrect,
3338 then the Error Subcode is set to Invalid Network Field. */
3339
3340 while (pnt < end)
3341 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003342 int badlength;
paul718e3742002-12-13 20:15:29 +00003343 prefixlen = *pnt++;
3344
3345 /* Prefix length check. */
Lou Berger298cc2f2016-01-12 13:42:02 -05003346 badlength = 0;
3347 if (safi == SAFI_ENCAP) {
3348 if (prefixlen > 128)
3349 badlength = 1;
3350 } else {
3351 if ((afi == AFI_IP && prefixlen > 32) ||
3352 (afi == AFI_IP6 && prefixlen > 128)) {
3353
3354 badlength = 1;
3355 }
3356 }
3357 if (badlength)
paul718e3742002-12-13 20:15:29 +00003358 {
3359 plog_err (peer->log,
3360 "%s [Error] Update packet error (wrong prefix length %d)",
3361 peer->host, prefixlen);
3362 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
3363 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
3364 return -1;
3365 }
3366
3367 /* Packet size overflow check. */
3368 psize = PSIZE (prefixlen);
3369
3370 if (pnt + psize > end)
3371 {
3372 plog_err (peer->log,
3373 "%s [Error] Update packet error"
3374 " (prefix data overflow prefix size is %d)",
3375 peer->host, psize);
3376 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
3377 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
3378 return -1;
3379 }
3380
3381 pnt += psize;
3382 }
3383
3384 /* Packet length consistency check. */
3385 if (pnt != end)
3386 {
3387 plog_err (peer->log,
3388 "%s [Error] Update packet error"
3389 " (prefix length mismatch with total length)",
3390 peer->host);
3391 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
3392 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
3393 return -1;
3394 }
3395 return 0;
3396}
David Lamparter6b0655a2014-06-04 06:53:35 +02003397
paul94f2b392005-06-28 12:44:16 +00003398static struct bgp_static *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003399bgp_static_new (void)
paul718e3742002-12-13 20:15:29 +00003400{
Stephen Hemminger393deb92008-08-18 14:13:29 -07003401 return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
paul718e3742002-12-13 20:15:29 +00003402}
3403
paul94f2b392005-06-28 12:44:16 +00003404static void
paul718e3742002-12-13 20:15:29 +00003405bgp_static_free (struct bgp_static *bgp_static)
3406{
3407 if (bgp_static->rmap.name)
3408 free (bgp_static->rmap.name);
3409 XFREE (MTYPE_BGP_STATIC, bgp_static);
3410}
3411
paul94f2b392005-06-28 12:44:16 +00003412static void
paulfee0f4c2004-09-13 05:12:46 +00003413bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
3414 struct prefix *p, afi_t afi, safi_t safi)
3415{
3416 struct bgp_node *rn;
3417 struct bgp_info *ri;
3418
3419 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3420
3421 /* Check selected route and self inserted route. */
3422 for (ri = rn->info; ri; ri = ri->next)
3423 if (ri->peer == bgp->peer_self
3424 && ri->type == ZEBRA_ROUTE_BGP
3425 && ri->sub_type == BGP_ROUTE_STATIC)
3426 break;
3427
3428 /* Withdraw static BGP route from routing table. */
3429 if (ri)
3430 {
paulfee0f4c2004-09-13 05:12:46 +00003431 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003432 bgp_process (bgp, rn, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003433 }
3434
3435 /* Unlock bgp_node_lookup. */
3436 bgp_unlock_node (rn);
3437}
3438
paul94f2b392005-06-28 12:44:16 +00003439static void
paulfee0f4c2004-09-13 05:12:46 +00003440bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
Paul Jakmafb982c22007-05-04 20:15:47 +00003441 struct bgp_static *bgp_static,
3442 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00003443{
3444 struct bgp_node *rn;
3445 struct bgp_info *ri;
3446 struct bgp_info *new;
3447 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00003448 struct attr *attr_new;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003449 struct attr attr;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003450 struct attr new_attr;
3451 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00003452 struct bgp *bgp;
3453 int ret;
3454 char buf[SU_ADDRSTRLEN];
3455
3456 bgp = rsclient->bgp;
3457
Paul Jakma06e110f2006-05-12 23:29:22 +00003458 assert (bgp_static);
3459 if (!bgp_static)
3460 return;
3461
paulfee0f4c2004-09-13 05:12:46 +00003462 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3463
3464 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakma06e110f2006-05-12 23:29:22 +00003465
3466 attr.nexthop = bgp_static->igpnexthop;
3467 attr.med = bgp_static->igpmetric;
3468 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Paul Jakma41367172007-08-06 15:24:51 +00003469
Paul Jakma41367172007-08-06 15:24:51 +00003470 if (bgp_static->atomic)
3471 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3472
paulfee0f4c2004-09-13 05:12:46 +00003473 /* Apply network route-map for export to this rsclient. */
3474 if (bgp_static->rmap.name)
3475 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003476 struct attr attr_tmp = attr;
paulfee0f4c2004-09-13 05:12:46 +00003477 info.peer = rsclient;
Paul Jakmafb982c22007-05-04 20:15:47 +00003478 info.attr = &attr_tmp;
3479
paulfee0f4c2004-09-13 05:12:46 +00003480 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
3481 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
3482
3483 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3484
3485 rsclient->rmap_type = 0;
3486
3487 if (ret == RMAP_DENYMATCH)
3488 {
3489 /* Free uninterned attribute. */
Paul Jakmafb982c22007-05-04 20:15:47 +00003490 bgp_attr_flush (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003491
3492 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003493 aspath_unintern (&attr.aspath);
paulfee0f4c2004-09-13 05:12:46 +00003494 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
Paul Jakmafb982c22007-05-04 20:15:47 +00003495 bgp_attr_extra_free (&attr);
3496
paulfee0f4c2004-09-13 05:12:46 +00003497 return;
3498 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003499 attr_new = bgp_attr_intern (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003500 }
3501 else
3502 attr_new = bgp_attr_intern (&attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003503
3504 new_attr.extra = &new_extra;
Stephen Hemminger7badc262010-08-05 10:26:31 -07003505 bgp_attr_dup(&new_attr, attr_new);
Paul Jakmafb982c22007-05-04 20:15:47 +00003506
paulfee0f4c2004-09-13 05:12:46 +00003507 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3508
Paul Jakmafb982c22007-05-04 20:15:47 +00003509 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi)
3510 == RMAP_DENY)
3511 {
paulfee0f4c2004-09-13 05:12:46 +00003512 /* This BGP update is filtered. Log the reason then update BGP entry. */
3513 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00003514 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00003515 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3516 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
3517 p->prefixlen, rsclient->host);
3518
3519 bgp->peer_self->rmap_type = 0;
3520
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003521 bgp_attr_unintern (&attr_new);
3522 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003523 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003524
3525 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3526
3527 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003528 }
paulfee0f4c2004-09-13 05:12:46 +00003529
3530 bgp->peer_self->rmap_type = 0;
3531
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003532 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00003533 attr_new = bgp_attr_intern (&new_attr);
3534
3535 for (ri = rn->info; ri; ri = ri->next)
3536 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3537 && ri->sub_type == BGP_ROUTE_STATIC)
3538 break;
3539
3540 if (ri)
3541 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003542 if (attrhash_cmp (ri->attr, attr_new) &&
3543 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paulfee0f4c2004-09-13 05:12:46 +00003544 {
3545 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003546 bgp_attr_unintern (&attr_new);
3547 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003548 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003549 return;
3550 }
3551 else
3552 {
3553 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003554 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00003555
3556 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003557 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3558 bgp_info_restore(rn, ri);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003559 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00003560 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003561 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003562
3563 /* Process change. */
3564 bgp_process (bgp, rn, afi, safi);
3565 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003566 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003567 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003568 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003569 }
paulfee0f4c2004-09-13 05:12:46 +00003570 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003571
paulfee0f4c2004-09-13 05:12:46 +00003572 /* Make new BGP info. */
3573 new = bgp_info_new ();
3574 new->type = ZEBRA_ROUTE_BGP;
3575 new->sub_type = BGP_ROUTE_STATIC;
3576 new->peer = bgp->peer_self;
3577 SET_FLAG (new->flags, BGP_INFO_VALID);
3578 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003579 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003580
3581 /* Register new BGP information. */
3582 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003583
3584 /* route_node_get lock */
3585 bgp_unlock_node (rn);
3586
paulfee0f4c2004-09-13 05:12:46 +00003587 /* Process change. */
3588 bgp_process (bgp, rn, afi, safi);
3589
3590 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003591 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003592 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003593}
3594
paul94f2b392005-06-28 12:44:16 +00003595static void
paulfee0f4c2004-09-13 05:12:46 +00003596bgp_static_update_main (struct bgp *bgp, struct prefix *p,
paul718e3742002-12-13 20:15:29 +00003597 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3598{
3599 struct bgp_node *rn;
3600 struct bgp_info *ri;
3601 struct bgp_info *new;
3602 struct bgp_info info;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003603 struct attr attr;
paul718e3742002-12-13 20:15:29 +00003604 struct attr *attr_new;
3605 int ret;
3606
Paul Jakmadd8103a2006-05-12 23:27:30 +00003607 assert (bgp_static);
3608 if (!bgp_static)
3609 return;
3610
paulfee0f4c2004-09-13 05:12:46 +00003611 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003612
3613 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakmadd8103a2006-05-12 23:27:30 +00003614
3615 attr.nexthop = bgp_static->igpnexthop;
3616 attr.med = bgp_static->igpmetric;
3617 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
paul718e3742002-12-13 20:15:29 +00003618
Paul Jakma41367172007-08-06 15:24:51 +00003619 if (bgp_static->atomic)
3620 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3621
paul718e3742002-12-13 20:15:29 +00003622 /* Apply route-map. */
3623 if (bgp_static->rmap.name)
3624 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003625 struct attr attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00003626 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00003627 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00003628
paulfee0f4c2004-09-13 05:12:46 +00003629 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3630
paul718e3742002-12-13 20:15:29 +00003631 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00003632
paulfee0f4c2004-09-13 05:12:46 +00003633 bgp->peer_self->rmap_type = 0;
3634
paul718e3742002-12-13 20:15:29 +00003635 if (ret == RMAP_DENYMATCH)
3636 {
3637 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00003638 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003639
3640 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003641 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003642 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003643 bgp_static_withdraw (bgp, p, afi, safi);
3644 return;
3645 }
paul286e1e72003-08-08 00:24:31 +00003646 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003647 }
paul286e1e72003-08-08 00:24:31 +00003648 else
3649 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00003650
3651 for (ri = rn->info; ri; ri = ri->next)
3652 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3653 && ri->sub_type == BGP_ROUTE_STATIC)
3654 break;
3655
3656 if (ri)
3657 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003658 if (attrhash_cmp (ri->attr, attr_new) &&
3659 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00003660 {
3661 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003662 bgp_attr_unintern (&attr_new);
3663 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003664 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003665 return;
3666 }
3667 else
3668 {
3669 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003670 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00003671
3672 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003673 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3674 bgp_info_restore(rn, ri);
3675 else
3676 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003677 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00003678 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003679 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003680
3681 /* Process change. */
3682 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3683 bgp_process (bgp, rn, afi, safi);
3684 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003685 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003686 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003687 return;
3688 }
3689 }
3690
3691 /* Make new BGP info. */
3692 new = bgp_info_new ();
3693 new->type = ZEBRA_ROUTE_BGP;
3694 new->sub_type = BGP_ROUTE_STATIC;
3695 new->peer = bgp->peer_self;
3696 SET_FLAG (new->flags, BGP_INFO_VALID);
3697 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003698 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003699
3700 /* Aggregate address increment. */
3701 bgp_aggregate_increment (bgp, p, new, afi, safi);
3702
3703 /* Register new BGP information. */
3704 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003705
3706 /* route_node_get lock */
3707 bgp_unlock_node (rn);
3708
paul718e3742002-12-13 20:15:29 +00003709 /* Process change. */
3710 bgp_process (bgp, rn, afi, safi);
3711
3712 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003713 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003714 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003715}
3716
3717void
paulfee0f4c2004-09-13 05:12:46 +00003718bgp_static_update (struct bgp *bgp, struct prefix *p,
3719 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3720{
3721 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00003722 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00003723
3724 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
3725
paul1eb8ef22005-04-07 07:30:20 +00003726 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00003727 {
Paul Jakmada5b30f2006-05-08 14:37:17 +00003728 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
3729 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003730 }
3731}
3732
paul718e3742002-12-13 20:15:29 +00003733void
3734bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
3735 safi_t safi)
3736{
3737 struct bgp_node *rn;
3738 struct bgp_info *ri;
3739
paulfee0f4c2004-09-13 05:12:46 +00003740 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003741
3742 /* Check selected route and self inserted route. */
3743 for (ri = rn->info; ri; ri = ri->next)
3744 if (ri->peer == bgp->peer_self
3745 && ri->type == ZEBRA_ROUTE_BGP
3746 && ri->sub_type == BGP_ROUTE_STATIC)
3747 break;
3748
3749 /* Withdraw static BGP route from routing table. */
3750 if (ri)
3751 {
3752 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003753 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003754 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003755 }
3756
3757 /* Unlock bgp_node_lookup. */
3758 bgp_unlock_node (rn);
3759}
3760
3761void
paulfee0f4c2004-09-13 05:12:46 +00003762bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3763{
3764 struct bgp_static *bgp_static;
3765 struct bgp *bgp;
3766 struct bgp_node *rn;
3767 struct prefix *p;
3768
3769 bgp = rsclient->bgp;
3770
3771 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3772 if ((bgp_static = rn->info) != NULL)
3773 {
3774 p = &rn->p;
3775
3776 bgp_static_update_rsclient (rsclient, p, bgp_static,
3777 afi, safi);
3778 }
3779}
3780
Lou Bergera76d9ca2016-01-12 13:41:53 -05003781/*
3782 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3783 */
paul94f2b392005-06-28 12:44:16 +00003784static void
Lou Bergera76d9ca2016-01-12 13:41:53 -05003785bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3786 safi_t safi, struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00003787{
3788 struct bgp_node *rn;
3789 struct bgp_info *ri;
3790
paulfee0f4c2004-09-13 05:12:46 +00003791 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00003792
3793 /* Check selected route and self inserted route. */
3794 for (ri = rn->info; ri; ri = ri->next)
3795 if (ri->peer == bgp->peer_self
3796 && ri->type == ZEBRA_ROUTE_BGP
3797 && ri->sub_type == BGP_ROUTE_STATIC)
3798 break;
3799
3800 /* Withdraw static BGP route from routing table. */
3801 if (ri)
3802 {
3803 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003804 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003805 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003806 }
3807
3808 /* Unlock bgp_node_lookup. */
3809 bgp_unlock_node (rn);
3810}
3811
Lou Bergera76d9ca2016-01-12 13:41:53 -05003812static void
3813bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3814 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3815{
3816 struct bgp_node *rn;
3817 struct bgp_info *new;
3818 struct attr *attr_new;
3819 struct attr attr = { 0 };
3820 struct bgp_info *ri;
3821
3822 assert (bgp_static);
3823
3824 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3825
3826 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3827
3828 attr.nexthop = bgp_static->igpnexthop;
3829 attr.med = bgp_static->igpmetric;
3830 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3831
3832 /* Apply route-map. */
3833 if (bgp_static->rmap.name)
3834 {
3835 struct attr attr_tmp = attr;
3836 struct bgp_info info;
3837 int ret;
3838
3839 info.peer = bgp->peer_self;
3840 info.attr = &attr_tmp;
3841
3842 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3843
3844 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3845
3846 bgp->peer_self->rmap_type = 0;
3847
3848 if (ret == RMAP_DENYMATCH)
3849 {
3850 /* Free uninterned attribute. */
3851 bgp_attr_flush (&attr_tmp);
3852
3853 /* Unintern original. */
3854 aspath_unintern (&attr.aspath);
3855 bgp_attr_extra_free (&attr);
3856 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3857 bgp_static->tag);
3858 return;
3859 }
3860
3861 attr_new = bgp_attr_intern (&attr_tmp);
3862 }
3863 else
3864 {
3865 attr_new = bgp_attr_intern (&attr);
3866 }
3867
3868 for (ri = rn->info; ri; ri = ri->next)
3869 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3870 && ri->sub_type == BGP_ROUTE_STATIC)
3871 break;
3872
3873 if (ri)
3874 {
3875 if (attrhash_cmp (ri->attr, attr_new) &&
3876 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3877 {
3878 bgp_unlock_node (rn);
3879 bgp_attr_unintern (&attr_new);
3880 aspath_unintern (&attr.aspath);
3881 bgp_attr_extra_free (&attr);
3882 return;
3883 }
3884 else
3885 {
3886 /* The attribute is changed. */
3887 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3888
3889 /* Rewrite BGP route information. */
3890 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3891 bgp_info_restore(rn, ri);
3892 else
3893 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3894 bgp_attr_unintern (&ri->attr);
3895 ri->attr = attr_new;
3896 ri->uptime = bgp_clock ();
3897
3898 /* Process change. */
3899 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3900 bgp_process (bgp, rn, afi, safi);
3901 bgp_unlock_node (rn);
3902 aspath_unintern (&attr.aspath);
3903 bgp_attr_extra_free (&attr);
3904 return;
3905 }
3906 }
3907
3908
3909 /* Make new BGP info. */
3910 new = bgp_info_new ();
3911 new->type = ZEBRA_ROUTE_BGP;
3912 new->sub_type = BGP_ROUTE_STATIC;
3913 new->peer = bgp->peer_self;
3914 new->attr = attr_new;
3915 SET_FLAG (new->flags, BGP_INFO_VALID);
3916 new->uptime = bgp_clock ();
3917 new->extra = bgp_info_extra_new();
3918 memcpy (new->extra->tag, bgp_static->tag, 3);
3919
3920 /* Aggregate address increment. */
3921 bgp_aggregate_increment (bgp, p, new, afi, safi);
3922
3923 /* Register new BGP information. */
3924 bgp_info_add (rn, new);
3925
3926 /* route_node_get lock */
3927 bgp_unlock_node (rn);
3928
3929 /* Process change. */
3930 bgp_process (bgp, rn, afi, safi);
3931
3932 /* Unintern original. */
3933 aspath_unintern (&attr.aspath);
3934 bgp_attr_extra_free (&attr);
3935}
3936
paul718e3742002-12-13 20:15:29 +00003937/* Configure static BGP network. When user don't run zebra, static
3938 route should be installed as valid. */
paul94f2b392005-06-28 12:44:16 +00003939static int
paulfd79ac92004-10-13 05:06:08 +00003940bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003941 afi_t afi, safi_t safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003942{
3943 int ret;
3944 struct prefix p;
3945 struct bgp_static *bgp_static;
3946 struct bgp_node *rn;
Paul Jakma41367172007-08-06 15:24:51 +00003947 u_char need_update = 0;
paul718e3742002-12-13 20:15:29 +00003948
3949 /* Convert IP prefix string to struct prefix. */
3950 ret = str2prefix (ip_str, &p);
3951 if (! ret)
3952 {
3953 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3954 return CMD_WARNING;
3955 }
paul718e3742002-12-13 20:15:29 +00003956 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3957 {
3958 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3959 VTY_NEWLINE);
3960 return CMD_WARNING;
3961 }
paul718e3742002-12-13 20:15:29 +00003962
3963 apply_mask (&p);
3964
3965 /* Set BGP static route configuration. */
3966 rn = bgp_node_get (bgp->route[afi][safi], &p);
3967
3968 if (rn->info)
3969 {
3970 /* Configuration change. */
3971 bgp_static = rn->info;
3972
3973 /* Check previous routes are installed into BGP. */
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003974 if (bgp_static->valid && bgp_static->backdoor != backdoor)
3975 need_update = 1;
Paul Jakma41367172007-08-06 15:24:51 +00003976
paul718e3742002-12-13 20:15:29 +00003977 bgp_static->backdoor = backdoor;
Paul Jakma41367172007-08-06 15:24:51 +00003978
paul718e3742002-12-13 20:15:29 +00003979 if (rmap)
3980 {
3981 if (bgp_static->rmap.name)
3982 free (bgp_static->rmap.name);
3983 bgp_static->rmap.name = strdup (rmap);
3984 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3985 }
3986 else
3987 {
3988 if (bgp_static->rmap.name)
3989 free (bgp_static->rmap.name);
3990 bgp_static->rmap.name = NULL;
3991 bgp_static->rmap.map = NULL;
3992 bgp_static->valid = 0;
3993 }
3994 bgp_unlock_node (rn);
3995 }
3996 else
3997 {
3998 /* New configuration. */
3999 bgp_static = bgp_static_new ();
4000 bgp_static->backdoor = backdoor;
4001 bgp_static->valid = 0;
4002 bgp_static->igpmetric = 0;
4003 bgp_static->igpnexthop.s_addr = 0;
Paul Jakma41367172007-08-06 15:24:51 +00004004
paul718e3742002-12-13 20:15:29 +00004005 if (rmap)
4006 {
4007 if (bgp_static->rmap.name)
4008 free (bgp_static->rmap.name);
4009 bgp_static->rmap.name = strdup (rmap);
4010 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4011 }
4012 rn->info = bgp_static;
4013 }
4014
4015 /* If BGP scan is not enabled, we should install this route here. */
4016 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
4017 {
4018 bgp_static->valid = 1;
4019
4020 if (need_update)
4021 bgp_static_withdraw (bgp, &p, afi, safi);
4022
4023 if (! bgp_static->backdoor)
4024 bgp_static_update (bgp, &p, bgp_static, afi, safi);
4025 }
4026
4027 return CMD_SUCCESS;
4028}
4029
4030/* Configure static BGP network. */
paul94f2b392005-06-28 12:44:16 +00004031static int
paulfd79ac92004-10-13 05:06:08 +00004032bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
Michael Lambert4c9641b2010-07-22 13:20:55 -04004033 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004034{
4035 int ret;
4036 struct prefix p;
4037 struct bgp_static *bgp_static;
4038 struct bgp_node *rn;
4039
4040 /* Convert IP prefix string to struct prefix. */
4041 ret = str2prefix (ip_str, &p);
4042 if (! ret)
4043 {
4044 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4045 return CMD_WARNING;
4046 }
paul718e3742002-12-13 20:15:29 +00004047 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4048 {
4049 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4050 VTY_NEWLINE);
4051 return CMD_WARNING;
4052 }
paul718e3742002-12-13 20:15:29 +00004053
4054 apply_mask (&p);
4055
4056 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4057 if (! rn)
4058 {
4059 vty_out (vty, "%% Can't find specified static route configuration.%s",
4060 VTY_NEWLINE);
4061 return CMD_WARNING;
4062 }
4063
4064 bgp_static = rn->info;
Paul Jakma41367172007-08-06 15:24:51 +00004065
paul718e3742002-12-13 20:15:29 +00004066 /* Update BGP RIB. */
4067 if (! bgp_static->backdoor)
4068 bgp_static_withdraw (bgp, &p, afi, safi);
4069
4070 /* Clear configuration. */
4071 bgp_static_free (bgp_static);
4072 rn->info = NULL;
4073 bgp_unlock_node (rn);
4074 bgp_unlock_node (rn);
4075
4076 return CMD_SUCCESS;
4077}
4078
4079/* Called from bgp_delete(). Delete all static routes from the BGP
4080 instance. */
4081void
4082bgp_static_delete (struct bgp *bgp)
4083{
4084 afi_t afi;
4085 safi_t safi;
4086 struct bgp_node *rn;
4087 struct bgp_node *rm;
4088 struct bgp_table *table;
4089 struct bgp_static *bgp_static;
4090
4091 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4092 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4093 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4094 if (rn->info != NULL)
4095 {
Lou Berger298cc2f2016-01-12 13:42:02 -05004096 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004097 {
4098 table = rn->info;
4099
4100 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4101 {
4102 bgp_static = rn->info;
Lou Bergera76d9ca2016-01-12 13:41:53 -05004103 bgp_static_withdraw_safi (bgp, &rm->p,
4104 AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00004105 (struct prefix_rd *)&rn->p,
4106 bgp_static->tag);
4107 bgp_static_free (bgp_static);
4108 rn->info = NULL;
4109 bgp_unlock_node (rn);
4110 }
4111 }
4112 else
4113 {
4114 bgp_static = rn->info;
4115 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4116 bgp_static_free (bgp_static);
4117 rn->info = NULL;
4118 bgp_unlock_node (rn);
4119 }
4120 }
4121}
4122
Lou Bergera76d9ca2016-01-12 13:41:53 -05004123/*
4124 * gpz 110624
4125 * Currently this is used to set static routes for VPN and ENCAP.
4126 * I think it can probably be factored with bgp_static_set.
4127 */
paul718e3742002-12-13 20:15:29 +00004128int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004129bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4130 const char *rd_str, const char *tag_str,
4131 const char *rmap_str)
paul718e3742002-12-13 20:15:29 +00004132{
4133 int ret;
4134 struct prefix p;
4135 struct prefix_rd prd;
4136 struct bgp *bgp;
4137 struct bgp_node *prn;
4138 struct bgp_node *rn;
4139 struct bgp_table *table;
4140 struct bgp_static *bgp_static;
4141 u_char tag[3];
4142
4143 bgp = vty->index;
4144
4145 ret = str2prefix (ip_str, &p);
4146 if (! ret)
4147 {
4148 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4149 return CMD_WARNING;
4150 }
4151 apply_mask (&p);
4152
4153 ret = str2prefix_rd (rd_str, &prd);
4154 if (! ret)
4155 {
4156 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4157 return CMD_WARNING;
4158 }
4159
4160 ret = str2tag (tag_str, tag);
4161 if (! ret)
4162 {
4163 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4164 return CMD_WARNING;
4165 }
4166
Lou Bergera76d9ca2016-01-12 13:41:53 -05004167 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004168 (struct prefix *)&prd);
4169 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004170 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004171 else
4172 bgp_unlock_node (prn);
4173 table = prn->info;
4174
4175 rn = bgp_node_get (table, &p);
4176
4177 if (rn->info)
4178 {
4179 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4180 bgp_unlock_node (rn);
4181 }
4182 else
4183 {
4184 /* New configuration. */
4185 bgp_static = bgp_static_new ();
Lou Bergera76d9ca2016-01-12 13:41:53 -05004186 bgp_static->backdoor = 0;
4187 bgp_static->valid = 0;
4188 bgp_static->igpmetric = 0;
4189 bgp_static->igpnexthop.s_addr = 0;
4190 memcpy(bgp_static->tag, tag, 3);
4191 bgp_static->prd = prd;
4192
4193 if (rmap_str)
4194 {
4195 if (bgp_static->rmap.name)
4196 free (bgp_static->rmap.name);
4197 bgp_static->rmap.name = strdup (rmap_str);
4198 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4199 }
paul718e3742002-12-13 20:15:29 +00004200 rn->info = bgp_static;
4201
Lou Bergera76d9ca2016-01-12 13:41:53 -05004202 bgp_static->valid = 1;
4203 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004204 }
4205
4206 return CMD_SUCCESS;
4207}
4208
4209/* Configure static BGP network. */
4210int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004211bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4212 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00004213{
4214 int ret;
4215 struct bgp *bgp;
4216 struct prefix p;
4217 struct prefix_rd prd;
4218 struct bgp_node *prn;
4219 struct bgp_node *rn;
4220 struct bgp_table *table;
4221 struct bgp_static *bgp_static;
4222 u_char tag[3];
4223
4224 bgp = vty->index;
4225
4226 /* Convert IP prefix string to struct prefix. */
4227 ret = str2prefix (ip_str, &p);
4228 if (! ret)
4229 {
4230 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4231 return CMD_WARNING;
4232 }
4233 apply_mask (&p);
4234
4235 ret = str2prefix_rd (rd_str, &prd);
4236 if (! ret)
4237 {
4238 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4239 return CMD_WARNING;
4240 }
4241
4242 ret = str2tag (tag_str, tag);
4243 if (! ret)
4244 {
4245 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4246 return CMD_WARNING;
4247 }
4248
Lou Bergera76d9ca2016-01-12 13:41:53 -05004249 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004250 (struct prefix *)&prd);
4251 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004252 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004253 else
4254 bgp_unlock_node (prn);
4255 table = prn->info;
4256
4257 rn = bgp_node_lookup (table, &p);
4258
4259 if (rn)
4260 {
Lou Bergera76d9ca2016-01-12 13:41:53 -05004261 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
paul718e3742002-12-13 20:15:29 +00004262
4263 bgp_static = rn->info;
4264 bgp_static_free (bgp_static);
4265 rn->info = NULL;
4266 bgp_unlock_node (rn);
4267 bgp_unlock_node (rn);
4268 }
4269 else
4270 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4271
4272 return CMD_SUCCESS;
4273}
David Lamparter6b0655a2014-06-04 06:53:35 +02004274
paul718e3742002-12-13 20:15:29 +00004275DEFUN (bgp_network,
4276 bgp_network_cmd,
4277 "network A.B.C.D/M",
4278 "Specify a network to announce via BGP\n"
4279 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4280{
4281 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004282 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004283}
4284
4285DEFUN (bgp_network_route_map,
4286 bgp_network_route_map_cmd,
4287 "network A.B.C.D/M route-map WORD",
4288 "Specify a network to announce via BGP\n"
4289 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4290 "Route-map to modify the attributes\n"
4291 "Name of the route map\n")
4292{
4293 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004294 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004295}
4296
4297DEFUN (bgp_network_backdoor,
4298 bgp_network_backdoor_cmd,
4299 "network A.B.C.D/M backdoor",
4300 "Specify a network to announce via BGP\n"
4301 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4302 "Specify a BGP backdoor route\n")
4303{
Paul Jakma41367172007-08-06 15:24:51 +00004304 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004305 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004306}
4307
4308DEFUN (bgp_network_mask,
4309 bgp_network_mask_cmd,
4310 "network A.B.C.D mask A.B.C.D",
4311 "Specify a network to announce via BGP\n"
4312 "Network number\n"
4313 "Network mask\n"
4314 "Network mask\n")
4315{
4316 int ret;
4317 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004318
paul718e3742002-12-13 20:15:29 +00004319 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4320 if (! ret)
4321 {
4322 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4323 return CMD_WARNING;
4324 }
4325
4326 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004327 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004328}
4329
4330DEFUN (bgp_network_mask_route_map,
4331 bgp_network_mask_route_map_cmd,
4332 "network A.B.C.D mask A.B.C.D route-map WORD",
4333 "Specify a network to announce via BGP\n"
4334 "Network number\n"
4335 "Network mask\n"
4336 "Network mask\n"
4337 "Route-map to modify the attributes\n"
4338 "Name of the route map\n")
4339{
4340 int ret;
4341 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004342
paul718e3742002-12-13 20:15:29 +00004343 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4344 if (! ret)
4345 {
4346 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4347 return CMD_WARNING;
4348 }
4349
4350 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004351 AFI_IP, bgp_node_safi (vty), argv[2], 0);
paul718e3742002-12-13 20:15:29 +00004352}
4353
4354DEFUN (bgp_network_mask_backdoor,
4355 bgp_network_mask_backdoor_cmd,
4356 "network A.B.C.D mask A.B.C.D backdoor",
4357 "Specify a network to announce via BGP\n"
4358 "Network number\n"
4359 "Network mask\n"
4360 "Network mask\n"
4361 "Specify a BGP backdoor route\n")
4362{
4363 int ret;
4364 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004365
paul718e3742002-12-13 20:15:29 +00004366 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4367 if (! ret)
4368 {
4369 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4370 return CMD_WARNING;
4371 }
4372
Paul Jakma41367172007-08-06 15:24:51 +00004373 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004374 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004375}
4376
4377DEFUN (bgp_network_mask_natural,
4378 bgp_network_mask_natural_cmd,
4379 "network A.B.C.D",
4380 "Specify a network to announce via BGP\n"
4381 "Network number\n")
4382{
4383 int ret;
4384 char prefix_str[BUFSIZ];
4385
4386 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4387 if (! ret)
4388 {
4389 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4390 return CMD_WARNING;
4391 }
4392
4393 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004394 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004395}
4396
4397DEFUN (bgp_network_mask_natural_route_map,
4398 bgp_network_mask_natural_route_map_cmd,
4399 "network A.B.C.D route-map WORD",
4400 "Specify a network to announce via BGP\n"
4401 "Network number\n"
4402 "Route-map to modify the attributes\n"
4403 "Name of the route map\n")
4404{
4405 int ret;
4406 char prefix_str[BUFSIZ];
4407
4408 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4409 if (! ret)
4410 {
4411 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4412 return CMD_WARNING;
4413 }
4414
4415 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004416 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004417}
4418
4419DEFUN (bgp_network_mask_natural_backdoor,
4420 bgp_network_mask_natural_backdoor_cmd,
4421 "network A.B.C.D backdoor",
4422 "Specify a network to announce via BGP\n"
4423 "Network number\n"
4424 "Specify a BGP backdoor route\n")
4425{
4426 int ret;
4427 char prefix_str[BUFSIZ];
4428
4429 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4430 if (! ret)
4431 {
4432 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4433 return CMD_WARNING;
4434 }
4435
Paul Jakma41367172007-08-06 15:24:51 +00004436 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004437 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004438}
4439
4440DEFUN (no_bgp_network,
4441 no_bgp_network_cmd,
4442 "no network A.B.C.D/M",
4443 NO_STR
4444 "Specify a network to announce via BGP\n"
4445 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4446{
4447 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4448 bgp_node_safi (vty));
4449}
4450
4451ALIAS (no_bgp_network,
4452 no_bgp_network_route_map_cmd,
4453 "no network A.B.C.D/M route-map WORD",
4454 NO_STR
4455 "Specify a network to announce via BGP\n"
4456 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4457 "Route-map to modify the attributes\n"
4458 "Name of the route map\n")
4459
4460ALIAS (no_bgp_network,
4461 no_bgp_network_backdoor_cmd,
4462 "no network A.B.C.D/M backdoor",
4463 NO_STR
4464 "Specify a network to announce via BGP\n"
4465 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4466 "Specify a BGP backdoor route\n")
4467
4468DEFUN (no_bgp_network_mask,
4469 no_bgp_network_mask_cmd,
4470 "no network A.B.C.D mask A.B.C.D",
4471 NO_STR
4472 "Specify a network to announce via BGP\n"
4473 "Network number\n"
4474 "Network mask\n"
4475 "Network mask\n")
4476{
4477 int ret;
4478 char prefix_str[BUFSIZ];
4479
4480 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4481 if (! ret)
4482 {
4483 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4484 return CMD_WARNING;
4485 }
4486
4487 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4488 bgp_node_safi (vty));
4489}
4490
4491ALIAS (no_bgp_network_mask,
4492 no_bgp_network_mask_route_map_cmd,
4493 "no network A.B.C.D mask A.B.C.D route-map WORD",
4494 NO_STR
4495 "Specify a network to announce via BGP\n"
4496 "Network number\n"
4497 "Network mask\n"
4498 "Network mask\n"
4499 "Route-map to modify the attributes\n"
4500 "Name of the route map\n")
4501
4502ALIAS (no_bgp_network_mask,
4503 no_bgp_network_mask_backdoor_cmd,
4504 "no network A.B.C.D mask A.B.C.D backdoor",
4505 NO_STR
4506 "Specify a network to announce via BGP\n"
4507 "Network number\n"
4508 "Network mask\n"
4509 "Network mask\n"
4510 "Specify a BGP backdoor route\n")
4511
4512DEFUN (no_bgp_network_mask_natural,
4513 no_bgp_network_mask_natural_cmd,
4514 "no network A.B.C.D",
4515 NO_STR
4516 "Specify a network to announce via BGP\n"
4517 "Network number\n")
4518{
4519 int ret;
4520 char prefix_str[BUFSIZ];
4521
4522 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4523 if (! ret)
4524 {
4525 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4526 return CMD_WARNING;
4527 }
4528
4529 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4530 bgp_node_safi (vty));
4531}
4532
4533ALIAS (no_bgp_network_mask_natural,
4534 no_bgp_network_mask_natural_route_map_cmd,
4535 "no network A.B.C.D route-map WORD",
4536 NO_STR
4537 "Specify a network to announce via BGP\n"
4538 "Network number\n"
4539 "Route-map to modify the attributes\n"
4540 "Name of the route map\n")
4541
4542ALIAS (no_bgp_network_mask_natural,
4543 no_bgp_network_mask_natural_backdoor_cmd,
4544 "no network A.B.C.D backdoor",
4545 NO_STR
4546 "Specify a network to announce via BGP\n"
4547 "Network number\n"
4548 "Specify a BGP backdoor route\n")
4549
paul718e3742002-12-13 20:15:29 +00004550DEFUN (ipv6_bgp_network,
4551 ipv6_bgp_network_cmd,
4552 "network X:X::X:X/M",
4553 "Specify a network to announce via BGP\n"
4554 "IPv6 prefix <network>/<length>\n")
4555{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304556 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004557 NULL, 0);
paul718e3742002-12-13 20:15:29 +00004558}
4559
4560DEFUN (ipv6_bgp_network_route_map,
4561 ipv6_bgp_network_route_map_cmd,
4562 "network X:X::X:X/M route-map WORD",
4563 "Specify a network to announce via BGP\n"
4564 "IPv6 prefix <network>/<length>\n"
4565 "Route-map to modify the attributes\n"
4566 "Name of the route map\n")
4567{
4568 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004569 bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004570}
4571
4572DEFUN (no_ipv6_bgp_network,
4573 no_ipv6_bgp_network_cmd,
4574 "no network X:X::X:X/M",
4575 NO_STR
4576 "Specify a network to announce via BGP\n"
4577 "IPv6 prefix <network>/<length>\n")
4578{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304579 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00004580}
4581
4582ALIAS (no_ipv6_bgp_network,
4583 no_ipv6_bgp_network_route_map_cmd,
4584 "no network X:X::X:X/M route-map WORD",
4585 NO_STR
4586 "Specify a network to announce via BGP\n"
4587 "IPv6 prefix <network>/<length>\n"
4588 "Route-map to modify the attributes\n"
4589 "Name of the route map\n")
4590
4591ALIAS (ipv6_bgp_network,
4592 old_ipv6_bgp_network_cmd,
4593 "ipv6 bgp network X:X::X:X/M",
4594 IPV6_STR
4595 BGP_STR
4596 "Specify a network to announce via BGP\n"
4597 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4598
4599ALIAS (no_ipv6_bgp_network,
4600 old_no_ipv6_bgp_network_cmd,
4601 "no ipv6 bgp network X:X::X:X/M",
4602 NO_STR
4603 IPV6_STR
4604 BGP_STR
4605 "Specify a network to announce via BGP\n"
4606 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004607
4608/* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4609ALIAS_DEPRECATED (bgp_network,
4610 bgp_network_ttl_cmd,
4611 "network A.B.C.D/M pathlimit <0-255>",
4612 "Specify a network to announce via BGP\n"
4613 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4614 "AS-Path hopcount limit attribute\n"
4615 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4616ALIAS_DEPRECATED (bgp_network_backdoor,
4617 bgp_network_backdoor_ttl_cmd,
4618 "network A.B.C.D/M backdoor pathlimit <0-255>",
4619 "Specify a network to announce via BGP\n"
4620 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4621 "Specify a BGP backdoor route\n"
4622 "AS-Path hopcount limit attribute\n"
4623 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4624ALIAS_DEPRECATED (bgp_network_mask,
4625 bgp_network_mask_ttl_cmd,
4626 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4627 "Specify a network to announce via BGP\n"
4628 "Network number\n"
4629 "Network mask\n"
4630 "Network mask\n"
4631 "AS-Path hopcount limit attribute\n"
4632 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4633ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4634 bgp_network_mask_backdoor_ttl_cmd,
4635 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4636 "Specify a network to announce via BGP\n"
4637 "Network number\n"
4638 "Network mask\n"
4639 "Network mask\n"
4640 "Specify a BGP backdoor route\n"
4641 "AS-Path hopcount limit attribute\n"
4642 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4643ALIAS_DEPRECATED (bgp_network_mask_natural,
4644 bgp_network_mask_natural_ttl_cmd,
4645 "network A.B.C.D pathlimit <0-255>",
4646 "Specify a network to announce via BGP\n"
4647 "Network number\n"
4648 "AS-Path hopcount limit attribute\n"
4649 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4650ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4651 bgp_network_mask_natural_backdoor_ttl_cmd,
Christian Franke2b005152013-09-30 12:27:49 +00004652 "network A.B.C.D backdoor pathlimit <1-255>",
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004653 "Specify a network to announce via BGP\n"
4654 "Network number\n"
4655 "Specify a BGP backdoor route\n"
4656 "AS-Path hopcount limit attribute\n"
4657 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4658ALIAS_DEPRECATED (no_bgp_network,
4659 no_bgp_network_ttl_cmd,
4660 "no network A.B.C.D/M pathlimit <0-255>",
4661 NO_STR
4662 "Specify a network to announce via BGP\n"
4663 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4664 "AS-Path hopcount limit attribute\n"
4665 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4666ALIAS_DEPRECATED (no_bgp_network,
4667 no_bgp_network_backdoor_ttl_cmd,
4668 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4669 NO_STR
4670 "Specify a network to announce via BGP\n"
4671 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4672 "Specify a BGP backdoor route\n"
4673 "AS-Path hopcount limit attribute\n"
4674 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4675ALIAS_DEPRECATED (no_bgp_network,
4676 no_bgp_network_mask_ttl_cmd,
4677 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4678 NO_STR
4679 "Specify a network to announce via BGP\n"
4680 "Network number\n"
4681 "Network mask\n"
4682 "Network mask\n"
4683 "AS-Path hopcount limit attribute\n"
4684 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4685ALIAS_DEPRECATED (no_bgp_network_mask,
4686 no_bgp_network_mask_backdoor_ttl_cmd,
4687 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4688 NO_STR
4689 "Specify a network to announce via BGP\n"
4690 "Network number\n"
4691 "Network mask\n"
4692 "Network mask\n"
4693 "Specify a BGP backdoor route\n"
4694 "AS-Path hopcount limit attribute\n"
4695 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4696ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4697 no_bgp_network_mask_natural_ttl_cmd,
4698 "no network A.B.C.D pathlimit <0-255>",
4699 NO_STR
4700 "Specify a network to announce via BGP\n"
4701 "Network number\n"
4702 "AS-Path hopcount limit attribute\n"
4703 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4704ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4705 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4706 "no network A.B.C.D backdoor pathlimit <0-255>",
4707 NO_STR
4708 "Specify a network to announce via BGP\n"
4709 "Network number\n"
4710 "Specify a BGP backdoor route\n"
4711 "AS-Path hopcount limit attribute\n"
4712 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4713ALIAS_DEPRECATED (ipv6_bgp_network,
4714 ipv6_bgp_network_ttl_cmd,
4715 "network X:X::X:X/M pathlimit <0-255>",
4716 "Specify a network to announce via BGP\n"
4717 "IPv6 prefix <network>/<length>\n"
4718 "AS-Path hopcount limit attribute\n"
4719 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4720ALIAS_DEPRECATED (no_ipv6_bgp_network,
4721 no_ipv6_bgp_network_ttl_cmd,
4722 "no network X:X::X:X/M pathlimit <0-255>",
4723 NO_STR
4724 "Specify a network to announce via BGP\n"
4725 "IPv6 prefix <network>/<length>\n"
4726 "AS-Path hopcount limit attribute\n"
4727 "AS-Pathlimit TTL, in number of AS-Path hops\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02004728
paul718e3742002-12-13 20:15:29 +00004729/* Aggreagete address:
4730
4731 advertise-map Set condition to advertise attribute
4732 as-set Generate AS set path information
4733 attribute-map Set attributes of aggregate
4734 route-map Set parameters of aggregate
4735 summary-only Filter more specific routes from updates
4736 suppress-map Conditionally filter more specific routes from updates
4737 <cr>
4738 */
4739struct bgp_aggregate
4740{
4741 /* Summary-only flag. */
4742 u_char summary_only;
4743
4744 /* AS set generation. */
4745 u_char as_set;
4746
4747 /* Route-map for aggregated route. */
4748 struct route_map *map;
4749
4750 /* Suppress-count. */
4751 unsigned long count;
4752
4753 /* SAFI configuration. */
4754 safi_t safi;
4755};
4756
paul94f2b392005-06-28 12:44:16 +00004757static struct bgp_aggregate *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08004758bgp_aggregate_new (void)
paul718e3742002-12-13 20:15:29 +00004759{
Stephen Hemminger393deb92008-08-18 14:13:29 -07004760 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
paul718e3742002-12-13 20:15:29 +00004761}
4762
paul94f2b392005-06-28 12:44:16 +00004763static void
paul718e3742002-12-13 20:15:29 +00004764bgp_aggregate_free (struct bgp_aggregate *aggregate)
4765{
4766 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4767}
4768
paul94f2b392005-06-28 12:44:16 +00004769static void
paul718e3742002-12-13 20:15:29 +00004770bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4771 afi_t afi, safi_t safi, struct bgp_info *del,
4772 struct bgp_aggregate *aggregate)
4773{
4774 struct bgp_table *table;
4775 struct bgp_node *top;
4776 struct bgp_node *rn;
4777 u_char origin;
4778 struct aspath *aspath = NULL;
4779 struct aspath *asmerge = NULL;
4780 struct community *community = NULL;
4781 struct community *commerge = NULL;
paul718e3742002-12-13 20:15:29 +00004782 struct bgp_info *ri;
4783 struct bgp_info *new;
4784 int first = 1;
4785 unsigned long match = 0;
4786
paul718e3742002-12-13 20:15:29 +00004787 /* ORIGIN attribute: If at least one route among routes that are
4788 aggregated has ORIGIN with the value INCOMPLETE, then the
4789 aggregated route must have the ORIGIN attribute with the value
4790 INCOMPLETE. Otherwise, if at least one route among routes that
4791 are aggregated has ORIGIN with the value EGP, then the aggregated
4792 route must have the origin attribute with the value EGP. In all
4793 other case the value of the ORIGIN attribute of the aggregated
4794 route is INTERNAL. */
4795 origin = BGP_ORIGIN_IGP;
4796
4797 table = bgp->rib[afi][safi];
4798
4799 top = bgp_node_get (table, p);
4800 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4801 if (rn->p.prefixlen > p->prefixlen)
4802 {
4803 match = 0;
4804
4805 for (ri = rn->info; ri; ri = ri->next)
4806 {
4807 if (BGP_INFO_HOLDDOWN (ri))
4808 continue;
4809
4810 if (del && ri == del)
4811 continue;
4812
4813 if (! rinew && first)
Paul Jakma7aa9dce2014-09-19 14:42:23 +01004814 first = 0;
paul718e3742002-12-13 20:15:29 +00004815
4816#ifdef AGGREGATE_NEXTHOP_CHECK
4817 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4818 || ri->attr->med != med)
4819 {
4820 if (aspath)
4821 aspath_free (aspath);
4822 if (community)
4823 community_free (community);
4824 bgp_unlock_node (rn);
4825 bgp_unlock_node (top);
4826 return;
4827 }
4828#endif /* AGGREGATE_NEXTHOP_CHECK */
4829
4830 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4831 {
4832 if (aggregate->summary_only)
4833 {
Paul Jakmafb982c22007-05-04 20:15:47 +00004834 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00004835 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00004836 match++;
4837 }
4838
4839 aggregate->count++;
4840
4841 if (aggregate->as_set)
4842 {
4843 if (origin < ri->attr->origin)
4844 origin = ri->attr->origin;
4845
4846 if (aspath)
4847 {
4848 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4849 aspath_free (aspath);
4850 aspath = asmerge;
4851 }
4852 else
4853 aspath = aspath_dup (ri->attr->aspath);
4854
4855 if (ri->attr->community)
4856 {
4857 if (community)
4858 {
4859 commerge = community_merge (community,
4860 ri->attr->community);
4861 community = community_uniq_sort (commerge);
4862 community_free (commerge);
4863 }
4864 else
4865 community = community_dup (ri->attr->community);
4866 }
4867 }
4868 }
4869 }
4870 if (match)
4871 bgp_process (bgp, rn, afi, safi);
4872 }
4873 bgp_unlock_node (top);
4874
4875 if (rinew)
4876 {
4877 aggregate->count++;
4878
4879 if (aggregate->summary_only)
Paul Jakmafb982c22007-05-04 20:15:47 +00004880 (bgp_info_extra_get (rinew))->suppress++;
paul718e3742002-12-13 20:15:29 +00004881
4882 if (aggregate->as_set)
4883 {
4884 if (origin < rinew->attr->origin)
4885 origin = rinew->attr->origin;
4886
4887 if (aspath)
4888 {
4889 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4890 aspath_free (aspath);
4891 aspath = asmerge;
4892 }
4893 else
4894 aspath = aspath_dup (rinew->attr->aspath);
4895
4896 if (rinew->attr->community)
4897 {
4898 if (community)
4899 {
4900 commerge = community_merge (community,
4901 rinew->attr->community);
4902 community = community_uniq_sort (commerge);
4903 community_free (commerge);
4904 }
4905 else
4906 community = community_dup (rinew->attr->community);
4907 }
4908 }
4909 }
4910
4911 if (aggregate->count > 0)
4912 {
4913 rn = bgp_node_get (table, p);
4914 new = bgp_info_new ();
4915 new->type = ZEBRA_ROUTE_BGP;
4916 new->sub_type = BGP_ROUTE_AGGREGATE;
4917 new->peer = bgp->peer_self;
4918 SET_FLAG (new->flags, BGP_INFO_VALID);
4919 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03004920 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00004921
4922 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00004923 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00004924 bgp_process (bgp, rn, afi, safi);
4925 }
4926 else
4927 {
4928 if (aspath)
4929 aspath_free (aspath);
4930 if (community)
4931 community_free (community);
4932 }
4933}
4934
4935void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4936 struct bgp_aggregate *);
4937
4938void
4939bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4940 struct bgp_info *ri, afi_t afi, safi_t safi)
4941{
4942 struct bgp_node *child;
4943 struct bgp_node *rn;
4944 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004945 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004946
4947 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004948 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004949 return;
4950
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004951 table = bgp->aggregate[afi][safi];
4952
4953 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004954 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004955 return;
4956
paul718e3742002-12-13 20:15:29 +00004957 if (p->prefixlen == 0)
4958 return;
4959
4960 if (BGP_INFO_HOLDDOWN (ri))
4961 return;
4962
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004963 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004964
4965 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004966 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00004967 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
4968 {
4969 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00004970 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00004971 }
4972 bgp_unlock_node (child);
4973}
4974
4975void
4976bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
4977 struct bgp_info *del, afi_t afi, safi_t safi)
4978{
4979 struct bgp_node *child;
4980 struct bgp_node *rn;
4981 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004982 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004983
4984 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004985 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004986 return;
4987
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004988 table = bgp->aggregate[afi][safi];
4989
4990 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004991 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004992 return;
4993
paul718e3742002-12-13 20:15:29 +00004994 if (p->prefixlen == 0)
4995 return;
4996
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004997 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004998
4999 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005000 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00005001 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5002 {
5003 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00005004 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00005005 }
5006 bgp_unlock_node (child);
5007}
5008
paul94f2b392005-06-28 12:44:16 +00005009static void
paul718e3742002-12-13 20:15:29 +00005010bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
5011 struct bgp_aggregate *aggregate)
5012{
5013 struct bgp_table *table;
5014 struct bgp_node *top;
5015 struct bgp_node *rn;
5016 struct bgp_info *new;
5017 struct bgp_info *ri;
5018 unsigned long match;
5019 u_char origin = BGP_ORIGIN_IGP;
5020 struct aspath *aspath = NULL;
5021 struct aspath *asmerge = NULL;
5022 struct community *community = NULL;
5023 struct community *commerge = NULL;
5024
5025 table = bgp->rib[afi][safi];
5026
5027 /* Sanity check. */
5028 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5029 return;
5030 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5031 return;
5032
5033 /* If routes exists below this node, generate aggregate routes. */
5034 top = bgp_node_get (table, p);
5035 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5036 if (rn->p.prefixlen > p->prefixlen)
5037 {
5038 match = 0;
5039
5040 for (ri = rn->info; ri; ri = ri->next)
5041 {
5042 if (BGP_INFO_HOLDDOWN (ri))
5043 continue;
5044
5045 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5046 {
5047 /* summary-only aggregate route suppress aggregated
5048 route announcement. */
5049 if (aggregate->summary_only)
5050 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005051 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00005052 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005053 match++;
5054 }
5055 /* as-set aggregate route generate origin, as path,
5056 community aggregation. */
5057 if (aggregate->as_set)
5058 {
5059 if (origin < ri->attr->origin)
5060 origin = ri->attr->origin;
5061
5062 if (aspath)
5063 {
5064 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5065 aspath_free (aspath);
5066 aspath = asmerge;
5067 }
5068 else
5069 aspath = aspath_dup (ri->attr->aspath);
5070
5071 if (ri->attr->community)
5072 {
5073 if (community)
5074 {
5075 commerge = community_merge (community,
5076 ri->attr->community);
5077 community = community_uniq_sort (commerge);
5078 community_free (commerge);
5079 }
5080 else
5081 community = community_dup (ri->attr->community);
5082 }
5083 }
5084 aggregate->count++;
5085 }
5086 }
5087
5088 /* If this node is suppressed, process the change. */
5089 if (match)
5090 bgp_process (bgp, rn, afi, safi);
5091 }
5092 bgp_unlock_node (top);
5093
5094 /* Add aggregate route to BGP table. */
5095 if (aggregate->count)
5096 {
5097 rn = bgp_node_get (table, p);
5098
5099 new = bgp_info_new ();
5100 new->type = ZEBRA_ROUTE_BGP;
5101 new->sub_type = BGP_ROUTE_AGGREGATE;
5102 new->peer = bgp->peer_self;
5103 SET_FLAG (new->flags, BGP_INFO_VALID);
5104 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03005105 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005106
5107 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00005108 bgp_unlock_node (rn);
5109
paul718e3742002-12-13 20:15:29 +00005110 /* Process change. */
5111 bgp_process (bgp, rn, afi, safi);
5112 }
Denil Virae2a92582015-08-11 13:34:59 -07005113 else
5114 {
5115 if (aspath)
5116 aspath_free (aspath);
5117 if (community)
5118 community_free (community);
5119 }
paul718e3742002-12-13 20:15:29 +00005120}
5121
5122void
5123bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5124 safi_t safi, struct bgp_aggregate *aggregate)
5125{
5126 struct bgp_table *table;
5127 struct bgp_node *top;
5128 struct bgp_node *rn;
5129 struct bgp_info *ri;
5130 unsigned long match;
5131
5132 table = bgp->rib[afi][safi];
5133
5134 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5135 return;
5136 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5137 return;
5138
5139 /* If routes exists below this node, generate aggregate routes. */
5140 top = bgp_node_get (table, p);
5141 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5142 if (rn->p.prefixlen > p->prefixlen)
5143 {
5144 match = 0;
5145
5146 for (ri = rn->info; ri; ri = ri->next)
5147 {
5148 if (BGP_INFO_HOLDDOWN (ri))
5149 continue;
5150
5151 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5152 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005153 if (aggregate->summary_only && ri->extra)
paul718e3742002-12-13 20:15:29 +00005154 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005155 ri->extra->suppress--;
paul718e3742002-12-13 20:15:29 +00005156
Paul Jakmafb982c22007-05-04 20:15:47 +00005157 if (ri->extra->suppress == 0)
paul718e3742002-12-13 20:15:29 +00005158 {
Paul Jakma1a392d42006-09-07 00:24:49 +00005159 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005160 match++;
5161 }
5162 }
5163 aggregate->count--;
5164 }
5165 }
5166
Paul Jakmafb982c22007-05-04 20:15:47 +00005167 /* If this node was suppressed, process the change. */
paul718e3742002-12-13 20:15:29 +00005168 if (match)
5169 bgp_process (bgp, rn, afi, safi);
5170 }
5171 bgp_unlock_node (top);
5172
5173 /* Delete aggregate route from BGP table. */
5174 rn = bgp_node_get (table, p);
5175
5176 for (ri = rn->info; ri; ri = ri->next)
5177 if (ri->peer == bgp->peer_self
5178 && ri->type == ZEBRA_ROUTE_BGP
5179 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5180 break;
5181
5182 /* Withdraw static BGP route from routing table. */
5183 if (ri)
5184 {
paul718e3742002-12-13 20:15:29 +00005185 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005186 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00005187 }
5188
5189 /* Unlock bgp_node_lookup. */
5190 bgp_unlock_node (rn);
5191}
5192
5193/* Aggregate route attribute. */
5194#define AGGREGATE_SUMMARY_ONLY 1
5195#define AGGREGATE_AS_SET 1
5196
paul94f2b392005-06-28 12:44:16 +00005197static int
Robert Baysf6269b42010-08-05 10:26:28 -07005198bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5199 afi_t afi, safi_t safi)
5200{
5201 int ret;
5202 struct prefix p;
5203 struct bgp_node *rn;
5204 struct bgp *bgp;
5205 struct bgp_aggregate *aggregate;
5206
5207 /* Convert string to prefix structure. */
5208 ret = str2prefix (prefix_str, &p);
5209 if (!ret)
5210 {
5211 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5212 return CMD_WARNING;
5213 }
5214 apply_mask (&p);
5215
5216 /* Get BGP structure. */
5217 bgp = vty->index;
5218
5219 /* Old configuration check. */
5220 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
5221 if (! rn)
5222 {
5223 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5224 VTY_NEWLINE);
5225 return CMD_WARNING;
5226 }
5227
5228 aggregate = rn->info;
5229 if (aggregate->safi & SAFI_UNICAST)
5230 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5231 if (aggregate->safi & SAFI_MULTICAST)
5232 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5233
5234 /* Unlock aggregate address configuration. */
5235 rn->info = NULL;
5236 bgp_aggregate_free (aggregate);
5237 bgp_unlock_node (rn);
5238 bgp_unlock_node (rn);
5239
5240 return CMD_SUCCESS;
5241}
5242
5243static int
5244bgp_aggregate_set (struct vty *vty, const char *prefix_str,
paulfd79ac92004-10-13 05:06:08 +00005245 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00005246 u_char summary_only, u_char as_set)
5247{
5248 int ret;
5249 struct prefix p;
5250 struct bgp_node *rn;
5251 struct bgp *bgp;
5252 struct bgp_aggregate *aggregate;
5253
5254 /* Convert string to prefix structure. */
5255 ret = str2prefix (prefix_str, &p);
5256 if (!ret)
5257 {
5258 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5259 return CMD_WARNING;
5260 }
5261 apply_mask (&p);
5262
5263 /* Get BGP structure. */
5264 bgp = vty->index;
5265
5266 /* Old configuration check. */
5267 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5268
5269 if (rn->info)
5270 {
5271 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
Robert Bays368473f2010-08-05 10:26:29 -07005272 /* try to remove the old entry */
Robert Baysf6269b42010-08-05 10:26:28 -07005273 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5274 if (ret)
5275 {
Robert Bays368473f2010-08-05 10:26:29 -07005276 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5277 bgp_unlock_node (rn);
Robert Baysf6269b42010-08-05 10:26:28 -07005278 return CMD_WARNING;
5279 }
paul718e3742002-12-13 20:15:29 +00005280 }
5281
5282 /* Make aggregate address structure. */
5283 aggregate = bgp_aggregate_new ();
5284 aggregate->summary_only = summary_only;
5285 aggregate->as_set = as_set;
5286 aggregate->safi = safi;
5287 rn->info = aggregate;
5288
5289 /* Aggregate address insert into BGP routing table. */
5290 if (safi & SAFI_UNICAST)
5291 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5292 if (safi & SAFI_MULTICAST)
5293 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5294
5295 return CMD_SUCCESS;
5296}
5297
paul718e3742002-12-13 20:15:29 +00005298DEFUN (aggregate_address,
5299 aggregate_address_cmd,
5300 "aggregate-address A.B.C.D/M",
5301 "Configure BGP aggregate entries\n"
5302 "Aggregate prefix\n")
5303{
5304 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5305}
5306
5307DEFUN (aggregate_address_mask,
5308 aggregate_address_mask_cmd,
5309 "aggregate-address A.B.C.D A.B.C.D",
5310 "Configure BGP aggregate entries\n"
5311 "Aggregate address\n"
5312 "Aggregate mask\n")
5313{
5314 int ret;
5315 char prefix_str[BUFSIZ];
5316
5317 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5318
5319 if (! ret)
5320 {
5321 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5322 return CMD_WARNING;
5323 }
5324
5325 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5326 0, 0);
5327}
5328
5329DEFUN (aggregate_address_summary_only,
5330 aggregate_address_summary_only_cmd,
5331 "aggregate-address A.B.C.D/M summary-only",
5332 "Configure BGP aggregate entries\n"
5333 "Aggregate prefix\n"
5334 "Filter more specific routes from updates\n")
5335{
5336 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5337 AGGREGATE_SUMMARY_ONLY, 0);
5338}
5339
5340DEFUN (aggregate_address_mask_summary_only,
5341 aggregate_address_mask_summary_only_cmd,
5342 "aggregate-address A.B.C.D A.B.C.D summary-only",
5343 "Configure BGP aggregate entries\n"
5344 "Aggregate address\n"
5345 "Aggregate mask\n"
5346 "Filter more specific routes from updates\n")
5347{
5348 int ret;
5349 char prefix_str[BUFSIZ];
5350
5351 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5352
5353 if (! ret)
5354 {
5355 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5356 return CMD_WARNING;
5357 }
5358
5359 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5360 AGGREGATE_SUMMARY_ONLY, 0);
5361}
5362
5363DEFUN (aggregate_address_as_set,
5364 aggregate_address_as_set_cmd,
5365 "aggregate-address A.B.C.D/M as-set",
5366 "Configure BGP aggregate entries\n"
5367 "Aggregate prefix\n"
5368 "Generate AS set path information\n")
5369{
5370 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5371 0, AGGREGATE_AS_SET);
5372}
5373
5374DEFUN (aggregate_address_mask_as_set,
5375 aggregate_address_mask_as_set_cmd,
5376 "aggregate-address A.B.C.D A.B.C.D as-set",
5377 "Configure BGP aggregate entries\n"
5378 "Aggregate address\n"
5379 "Aggregate mask\n"
5380 "Generate AS set path information\n")
5381{
5382 int ret;
5383 char prefix_str[BUFSIZ];
5384
5385 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5386
5387 if (! ret)
5388 {
5389 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5390 return CMD_WARNING;
5391 }
5392
5393 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5394 0, AGGREGATE_AS_SET);
5395}
5396
5397
5398DEFUN (aggregate_address_as_set_summary,
5399 aggregate_address_as_set_summary_cmd,
5400 "aggregate-address A.B.C.D/M as-set summary-only",
5401 "Configure BGP aggregate entries\n"
5402 "Aggregate prefix\n"
5403 "Generate AS set path information\n"
5404 "Filter more specific routes from updates\n")
5405{
5406 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5407 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5408}
5409
5410ALIAS (aggregate_address_as_set_summary,
5411 aggregate_address_summary_as_set_cmd,
5412 "aggregate-address A.B.C.D/M summary-only as-set",
5413 "Configure BGP aggregate entries\n"
5414 "Aggregate prefix\n"
5415 "Filter more specific routes from updates\n"
5416 "Generate AS set path information\n")
5417
5418DEFUN (aggregate_address_mask_as_set_summary,
5419 aggregate_address_mask_as_set_summary_cmd,
5420 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5421 "Configure BGP aggregate entries\n"
5422 "Aggregate address\n"
5423 "Aggregate mask\n"
5424 "Generate AS set path information\n"
5425 "Filter more specific routes from updates\n")
5426{
5427 int ret;
5428 char prefix_str[BUFSIZ];
5429
5430 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5431
5432 if (! ret)
5433 {
5434 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5435 return CMD_WARNING;
5436 }
5437
5438 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5439 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5440}
5441
5442ALIAS (aggregate_address_mask_as_set_summary,
5443 aggregate_address_mask_summary_as_set_cmd,
5444 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5445 "Configure BGP aggregate entries\n"
5446 "Aggregate address\n"
5447 "Aggregate mask\n"
5448 "Filter more specific routes from updates\n"
5449 "Generate AS set path information\n")
5450
5451DEFUN (no_aggregate_address,
5452 no_aggregate_address_cmd,
5453 "no aggregate-address A.B.C.D/M",
5454 NO_STR
5455 "Configure BGP aggregate entries\n"
5456 "Aggregate prefix\n")
5457{
5458 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5459}
5460
5461ALIAS (no_aggregate_address,
5462 no_aggregate_address_summary_only_cmd,
5463 "no aggregate-address A.B.C.D/M summary-only",
5464 NO_STR
5465 "Configure BGP aggregate entries\n"
5466 "Aggregate prefix\n"
5467 "Filter more specific routes from updates\n")
5468
5469ALIAS (no_aggregate_address,
5470 no_aggregate_address_as_set_cmd,
5471 "no aggregate-address A.B.C.D/M as-set",
5472 NO_STR
5473 "Configure BGP aggregate entries\n"
5474 "Aggregate prefix\n"
5475 "Generate AS set path information\n")
5476
5477ALIAS (no_aggregate_address,
5478 no_aggregate_address_as_set_summary_cmd,
5479 "no aggregate-address A.B.C.D/M as-set summary-only",
5480 NO_STR
5481 "Configure BGP aggregate entries\n"
5482 "Aggregate prefix\n"
5483 "Generate AS set path information\n"
5484 "Filter more specific routes from updates\n")
5485
5486ALIAS (no_aggregate_address,
5487 no_aggregate_address_summary_as_set_cmd,
5488 "no aggregate-address A.B.C.D/M summary-only as-set",
5489 NO_STR
5490 "Configure BGP aggregate entries\n"
5491 "Aggregate prefix\n"
5492 "Filter more specific routes from updates\n"
5493 "Generate AS set path information\n")
5494
5495DEFUN (no_aggregate_address_mask,
5496 no_aggregate_address_mask_cmd,
5497 "no aggregate-address A.B.C.D A.B.C.D",
5498 NO_STR
5499 "Configure BGP aggregate entries\n"
5500 "Aggregate address\n"
5501 "Aggregate mask\n")
5502{
5503 int ret;
5504 char prefix_str[BUFSIZ];
5505
5506 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5507
5508 if (! ret)
5509 {
5510 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5511 return CMD_WARNING;
5512 }
5513
5514 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5515}
5516
5517ALIAS (no_aggregate_address_mask,
5518 no_aggregate_address_mask_summary_only_cmd,
5519 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5520 NO_STR
5521 "Configure BGP aggregate entries\n"
5522 "Aggregate address\n"
5523 "Aggregate mask\n"
5524 "Filter more specific routes from updates\n")
5525
5526ALIAS (no_aggregate_address_mask,
5527 no_aggregate_address_mask_as_set_cmd,
5528 "no aggregate-address A.B.C.D A.B.C.D as-set",
5529 NO_STR
5530 "Configure BGP aggregate entries\n"
5531 "Aggregate address\n"
5532 "Aggregate mask\n"
5533 "Generate AS set path information\n")
5534
5535ALIAS (no_aggregate_address_mask,
5536 no_aggregate_address_mask_as_set_summary_cmd,
5537 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5538 NO_STR
5539 "Configure BGP aggregate entries\n"
5540 "Aggregate address\n"
5541 "Aggregate mask\n"
5542 "Generate AS set path information\n"
5543 "Filter more specific routes from updates\n")
5544
5545ALIAS (no_aggregate_address_mask,
5546 no_aggregate_address_mask_summary_as_set_cmd,
5547 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5548 NO_STR
5549 "Configure BGP aggregate entries\n"
5550 "Aggregate address\n"
5551 "Aggregate mask\n"
5552 "Filter more specific routes from updates\n"
5553 "Generate AS set path information\n")
5554
paul718e3742002-12-13 20:15:29 +00005555DEFUN (ipv6_aggregate_address,
5556 ipv6_aggregate_address_cmd,
5557 "aggregate-address X:X::X:X/M",
5558 "Configure BGP aggregate entries\n"
5559 "Aggregate prefix\n")
5560{
5561 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5562}
5563
5564DEFUN (ipv6_aggregate_address_summary_only,
5565 ipv6_aggregate_address_summary_only_cmd,
5566 "aggregate-address X:X::X:X/M summary-only",
5567 "Configure BGP aggregate entries\n"
5568 "Aggregate prefix\n"
5569 "Filter more specific routes from updates\n")
5570{
5571 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5572 AGGREGATE_SUMMARY_ONLY, 0);
5573}
5574
5575DEFUN (no_ipv6_aggregate_address,
5576 no_ipv6_aggregate_address_cmd,
5577 "no aggregate-address X:X::X:X/M",
5578 NO_STR
5579 "Configure BGP aggregate entries\n"
5580 "Aggregate prefix\n")
5581{
5582 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5583}
5584
5585DEFUN (no_ipv6_aggregate_address_summary_only,
5586 no_ipv6_aggregate_address_summary_only_cmd,
5587 "no aggregate-address X:X::X:X/M summary-only",
5588 NO_STR
5589 "Configure BGP aggregate entries\n"
5590 "Aggregate prefix\n"
5591 "Filter more specific routes from updates\n")
5592{
5593 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5594}
5595
5596ALIAS (ipv6_aggregate_address,
5597 old_ipv6_aggregate_address_cmd,
5598 "ipv6 bgp aggregate-address X:X::X:X/M",
5599 IPV6_STR
5600 BGP_STR
5601 "Configure BGP aggregate entries\n"
5602 "Aggregate prefix\n")
5603
5604ALIAS (ipv6_aggregate_address_summary_only,
5605 old_ipv6_aggregate_address_summary_only_cmd,
5606 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5607 IPV6_STR
5608 BGP_STR
5609 "Configure BGP aggregate entries\n"
5610 "Aggregate prefix\n"
5611 "Filter more specific routes from updates\n")
5612
5613ALIAS (no_ipv6_aggregate_address,
5614 old_no_ipv6_aggregate_address_cmd,
5615 "no ipv6 bgp aggregate-address X:X::X:X/M",
5616 NO_STR
5617 IPV6_STR
5618 BGP_STR
5619 "Configure BGP aggregate entries\n"
5620 "Aggregate prefix\n")
5621
5622ALIAS (no_ipv6_aggregate_address_summary_only,
5623 old_no_ipv6_aggregate_address_summary_only_cmd,
5624 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5625 NO_STR
5626 IPV6_STR
5627 BGP_STR
5628 "Configure BGP aggregate entries\n"
5629 "Aggregate prefix\n"
5630 "Filter more specific routes from updates\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02005631
paul718e3742002-12-13 20:15:29 +00005632/* Redistribute route treatment. */
5633void
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005634bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5635 const struct in6_addr *nexthop6,
paul718e3742002-12-13 20:15:29 +00005636 u_int32_t metric, u_char type)
5637{
5638 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005639 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005640 struct bgp_info *new;
5641 struct bgp_info *bi;
5642 struct bgp_info info;
5643 struct bgp_node *bn;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00005644 struct attr attr;
paul718e3742002-12-13 20:15:29 +00005645 struct attr *new_attr;
5646 afi_t afi;
5647 int ret;
5648
5649 /* Make default attribute. */
5650 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5651 if (nexthop)
5652 attr.nexthop = *nexthop;
5653
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005654 if (nexthop6)
5655 {
5656 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5657 extra->mp_nexthop_global = *nexthop6;
5658 extra->mp_nexthop_len = 16;
5659 }
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005660
paul718e3742002-12-13 20:15:29 +00005661 attr.med = metric;
5662 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
5663
paul1eb8ef22005-04-07 07:30:20 +00005664 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005665 {
5666 afi = family2afi (p->family);
5667
5668 if (bgp->redist[afi][type])
5669 {
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005670 struct attr attr_new;
5671 struct attr_extra extra_new;
5672
paul718e3742002-12-13 20:15:29 +00005673 /* Copy attribute for modification. */
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005674 attr_new.extra = &extra_new;
Paul Jakmafb982c22007-05-04 20:15:47 +00005675 bgp_attr_dup (&attr_new, &attr);
paul718e3742002-12-13 20:15:29 +00005676
5677 if (bgp->redist_metric_flag[afi][type])
5678 attr_new.med = bgp->redist_metric[afi][type];
5679
5680 /* Apply route-map. */
Daniel Walton1994dc82015-09-17 10:15:59 -04005681 if (bgp->rmap[afi][type].name)
paul718e3742002-12-13 20:15:29 +00005682 {
5683 info.peer = bgp->peer_self;
5684 info.attr = &attr_new;
5685
paulfee0f4c2004-09-13 05:12:46 +00005686 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5687
paul718e3742002-12-13 20:15:29 +00005688 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5689 &info);
paulfee0f4c2004-09-13 05:12:46 +00005690
5691 bgp->peer_self->rmap_type = 0;
5692
paul718e3742002-12-13 20:15:29 +00005693 if (ret == RMAP_DENYMATCH)
5694 {
5695 /* Free uninterned attribute. */
5696 bgp_attr_flush (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005697
paul718e3742002-12-13 20:15:29 +00005698 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005699 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005700 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005701 bgp_redistribute_delete (p, type);
5702 return;
5703 }
5704 }
5705
Paul Jakmafb982c22007-05-04 20:15:47 +00005706 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5707 afi, SAFI_UNICAST, p, NULL);
5708
paul718e3742002-12-13 20:15:29 +00005709 new_attr = bgp_attr_intern (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005710
paul718e3742002-12-13 20:15:29 +00005711 for (bi = bn->info; bi; bi = bi->next)
5712 if (bi->peer == bgp->peer_self
5713 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5714 break;
5715
5716 if (bi)
5717 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005718 if (attrhash_cmp (bi->attr, new_attr) &&
5719 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00005720 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005721 bgp_attr_unintern (&new_attr);
5722 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005723 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005724 bgp_unlock_node (bn);
5725 return;
5726 }
5727 else
5728 {
5729 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00005730 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005731
5732 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005733 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5734 bgp_info_restore(bn, bi);
5735 else
5736 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005737 bgp_attr_unintern (&bi->attr);
paul718e3742002-12-13 20:15:29 +00005738 bi->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005739 bi->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005740
5741 /* Process change. */
5742 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5743 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5744 bgp_unlock_node (bn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005745 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005746 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005747 return;
5748 }
5749 }
5750
5751 new = bgp_info_new ();
5752 new->type = type;
5753 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
5754 new->peer = bgp->peer_self;
5755 SET_FLAG (new->flags, BGP_INFO_VALID);
5756 new->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005757 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005758
5759 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5760 bgp_info_add (bn, new);
paul200df112005-06-01 11:17:05 +00005761 bgp_unlock_node (bn);
paul718e3742002-12-13 20:15:29 +00005762 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5763 }
5764 }
5765
5766 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005767 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005768 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005769}
5770
5771void
5772bgp_redistribute_delete (struct prefix *p, u_char type)
5773{
5774 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005775 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005776 afi_t afi;
5777 struct bgp_node *rn;
5778 struct bgp_info *ri;
5779
paul1eb8ef22005-04-07 07:30:20 +00005780 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005781 {
5782 afi = family2afi (p->family);
5783
5784 if (bgp->redist[afi][type])
5785 {
paulfee0f4c2004-09-13 05:12:46 +00005786 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00005787
5788 for (ri = rn->info; ri; ri = ri->next)
5789 if (ri->peer == bgp->peer_self
5790 && ri->type == type)
5791 break;
5792
5793 if (ri)
5794 {
5795 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005796 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005797 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005798 }
5799 bgp_unlock_node (rn);
5800 }
5801 }
5802}
5803
5804/* Withdraw specified route type's route. */
5805void
5806bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5807{
5808 struct bgp_node *rn;
5809 struct bgp_info *ri;
5810 struct bgp_table *table;
5811
5812 table = bgp->rib[afi][SAFI_UNICAST];
5813
5814 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5815 {
5816 for (ri = rn->info; ri; ri = ri->next)
5817 if (ri->peer == bgp->peer_self
5818 && ri->type == type)
5819 break;
5820
5821 if (ri)
5822 {
5823 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005824 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005825 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005826 }
5827 }
5828}
David Lamparter6b0655a2014-06-04 06:53:35 +02005829
paul718e3742002-12-13 20:15:29 +00005830/* Static function to display route. */
paul94f2b392005-06-28 12:44:16 +00005831static void
paul718e3742002-12-13 20:15:29 +00005832route_vty_out_route (struct prefix *p, struct vty *vty)
5833{
5834 int len;
5835 u_int32_t destination;
5836 char buf[BUFSIZ];
5837
5838 if (p->family == AF_INET)
5839 {
5840 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5841 destination = ntohl (p->u.prefix4.s_addr);
5842
5843 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5844 || (IN_CLASSB (destination) && p->prefixlen == 16)
5845 || (IN_CLASSA (destination) && p->prefixlen == 8)
5846 || p->u.prefix4.s_addr == 0)
5847 {
5848 /* When mask is natural, mask is not displayed. */
5849 }
5850 else
5851 len += vty_out (vty, "/%d", p->prefixlen);
5852 }
5853 else
5854 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5855 p->prefixlen);
5856
5857 len = 17 - len;
5858 if (len < 1)
5859 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5860 else
5861 vty_out (vty, "%*s", len, " ");
5862}
5863
paul718e3742002-12-13 20:15:29 +00005864enum bgp_display_type
5865{
5866 normal_list,
5867};
5868
paulb40d9392005-08-22 22:34:41 +00005869/* Print the short form route status for a bgp_info */
5870static void
5871route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
paul718e3742002-12-13 20:15:29 +00005872{
paulb40d9392005-08-22 22:34:41 +00005873 /* Route status display. */
5874 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5875 vty_out (vty, "R");
5876 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
hasso93406d82005-02-02 14:40:33 +00005877 vty_out (vty, "S");
Paul Jakmafb982c22007-05-04 20:15:47 +00005878 else if (binfo->extra && binfo->extra->suppress)
paul718e3742002-12-13 20:15:29 +00005879 vty_out (vty, "s");
5880 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5881 vty_out (vty, "*");
5882 else
5883 vty_out (vty, " ");
5884
5885 /* Selected */
5886 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5887 vty_out (vty, "h");
5888 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5889 vty_out (vty, "d");
5890 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5891 vty_out (vty, ">");
Boian Bonevb366b512013-09-09 16:41:35 +00005892 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5893 vty_out (vty, "=");
paul718e3742002-12-13 20:15:29 +00005894 else
5895 vty_out (vty, " ");
5896
5897 /* Internal route. */
5898 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5899 vty_out (vty, "i");
5900 else
paulb40d9392005-08-22 22:34:41 +00005901 vty_out (vty, " ");
5902}
5903
5904/* called from terminal list command */
5905void
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005906route_vty_out(
5907 struct vty *vty,
5908 struct prefix *p,
5909 struct bgp_info *binfo,
5910 int display,
5911 safi_t safi)
paulb40d9392005-08-22 22:34:41 +00005912{
5913 struct attr *attr;
5914
5915 /* short status lead text */
5916 route_vty_short_status_out (vty, binfo);
paul718e3742002-12-13 20:15:29 +00005917
5918 /* print prefix and mask */
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005919 if (!display)
paul718e3742002-12-13 20:15:29 +00005920 route_vty_out_route (p, vty);
5921 else
5922 vty_out (vty, "%*s", 17, " ");
5923
5924 /* Print attribute */
5925 attr = binfo->attr;
5926 if (attr)
5927 {
paul718e3742002-12-13 20:15:29 +00005928
Lou Berger298cc2f2016-01-12 13:42:02 -05005929 /*
5930 * NEXTHOP start
5931 */
5932
5933 /*
5934 * For ENCAP routes, nexthop address family is not
5935 * neccessarily the same as the prefix address family.
5936 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5937 */
5938 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5939 if (attr->extra) {
5940 char buf[BUFSIZ];
5941 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5942
5943 switch (af) {
5944 case AF_INET:
5945 vty_out (vty, "%s", inet_ntop(af,
5946 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5947 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005948 case AF_INET6:
5949 vty_out (vty, "%s", inet_ntop(af,
5950 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
5951 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005952 default:
5953 vty_out(vty, "?");
5954 }
5955 } else {
5956 vty_out(vty, "?");
paul718e3742002-12-13 20:15:29 +00005957 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005958 } else {
5959
5960 if (p->family == AF_INET)
5961 {
5962 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
5963 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005964 else if (p->family == AF_INET6)
5965 {
5966 int len;
5967 char buf[BUFSIZ];
5968
5969 len = vty_out (vty, "%s",
5970 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
5971 buf, BUFSIZ));
5972 len = 16 - len;
5973 if (len < 1)
5974 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
5975 else
5976 vty_out (vty, "%*s", len, " ");
5977 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005978 else
5979 {
5980 vty_out(vty, "?");
5981 }
5982 }
5983
5984 /*
5985 * NEXTHOP end
5986 */
5987
paul718e3742002-12-13 20:15:29 +00005988
5989 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005990 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00005991 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005992 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00005993
5994 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005995 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00005996 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005997 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00005998
Paul Jakmafb982c22007-05-04 20:15:47 +00005999 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
paul718e3742002-12-13 20:15:29 +00006000
Paul Jakmab2518c12006-05-12 23:48:40 +00006001 /* Print aspath */
6002 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006003 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006004
Paul Jakmab2518c12006-05-12 23:48:40 +00006005 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006006 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006007 }
paul718e3742002-12-13 20:15:29 +00006008 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006009}
6010
6011/* called from terminal list command */
6012void
6013route_vty_out_tmp (struct vty *vty, struct prefix *p,
6014 struct attr *attr, safi_t safi)
6015{
6016 /* Route status display. */
6017 vty_out (vty, "*");
6018 vty_out (vty, ">");
6019 vty_out (vty, " ");
6020
6021 /* print prefix and mask */
6022 route_vty_out_route (p, vty);
6023
6024 /* Print attribute */
6025 if (attr)
6026 {
6027 if (p->family == AF_INET)
6028 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006029 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006030 vty_out (vty, "%-16s",
6031 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006032 else
6033 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6034 }
paul718e3742002-12-13 20:15:29 +00006035 else if (p->family == AF_INET6)
6036 {
6037 int len;
6038 char buf[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006039
6040 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006041
6042 len = vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006043 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6044 buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006045 len = 16 - len;
6046 if (len < 1)
6047 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6048 else
6049 vty_out (vty, "%*s", len, " ");
6050 }
paul718e3742002-12-13 20:15:29 +00006051
6052 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006053 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006054 else
6055 vty_out (vty, " ");
6056
6057 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006058 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006059 else
6060 vty_out (vty, " ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006061
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006062 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
Paul Jakmafb982c22007-05-04 20:15:47 +00006063
Paul Jakmab2518c12006-05-12 23:48:40 +00006064 /* Print aspath */
6065 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006066 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006067
Paul Jakmab2518c12006-05-12 23:48:40 +00006068 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006069 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006070 }
paul718e3742002-12-13 20:15:29 +00006071
6072 vty_out (vty, "%s", VTY_NEWLINE);
6073}
6074
ajs5a646652004-11-05 01:25:55 +00006075void
paul718e3742002-12-13 20:15:29 +00006076route_vty_out_tag (struct vty *vty, struct prefix *p,
6077 struct bgp_info *binfo, int display, safi_t safi)
6078{
6079 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006080 u_int32_t label = 0;
Paul Jakmafb982c22007-05-04 20:15:47 +00006081
6082 if (!binfo->extra)
6083 return;
6084
paulb40d9392005-08-22 22:34:41 +00006085 /* short status lead text */
6086 route_vty_short_status_out (vty, binfo);
6087
paul718e3742002-12-13 20:15:29 +00006088 /* print prefix and mask */
6089 if (! display)
6090 route_vty_out_route (p, vty);
6091 else
6092 vty_out (vty, "%*s", 17, " ");
6093
6094 /* Print attribute */
6095 attr = binfo->attr;
6096 if (attr)
6097 {
6098 if (p->family == AF_INET)
6099 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006100 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006101 vty_out (vty, "%-16s",
6102 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006103 else
6104 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6105 }
paul718e3742002-12-13 20:15:29 +00006106 else if (p->family == AF_INET6)
6107 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006108 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006109 char buf[BUFSIZ];
6110 char buf1[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006111 if (attr->extra->mp_nexthop_len == 16)
paul718e3742002-12-13 20:15:29 +00006112 vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006113 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6114 buf, BUFSIZ));
6115 else if (attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006116 vty_out (vty, "%s(%s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006117 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6118 buf, BUFSIZ),
6119 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6120 buf1, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006121
6122 }
paul718e3742002-12-13 20:15:29 +00006123 }
6124
Paul Jakmafb982c22007-05-04 20:15:47 +00006125 label = decode_label (binfo->extra->tag);
paul718e3742002-12-13 20:15:29 +00006126
6127 vty_out (vty, "notag/%d", label);
6128
6129 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006130}
6131
6132/* dampening route */
ajs5a646652004-11-05 01:25:55 +00006133static void
paul718e3742002-12-13 20:15:29 +00006134damp_route_vty_out (struct vty *vty, struct prefix *p,
6135 struct bgp_info *binfo, int display, safi_t safi)
6136{
6137 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006138 int len;
Chris Caputo50aef6f2009-06-23 06:06:49 +00006139 char timebuf[BGP_UPTIME_LEN];
paul718e3742002-12-13 20:15:29 +00006140
paulb40d9392005-08-22 22:34:41 +00006141 /* short status lead text */
6142 route_vty_short_status_out (vty, binfo);
6143
paul718e3742002-12-13 20:15:29 +00006144 /* print prefix and mask */
6145 if (! display)
6146 route_vty_out_route (p, vty);
6147 else
6148 vty_out (vty, "%*s", 17, " ");
6149
6150 len = vty_out (vty, "%s", binfo->peer->host);
6151 len = 17 - len;
6152 if (len < 1)
6153 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6154 else
6155 vty_out (vty, "%*s", len, " ");
6156
Chris Caputo50aef6f2009-06-23 06:06:49 +00006157 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006158
6159 /* Print attribute */
6160 attr = binfo->attr;
6161 if (attr)
6162 {
6163 /* Print aspath */
6164 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006165 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006166
6167 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006168 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006169 }
6170 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006171}
6172
paul718e3742002-12-13 20:15:29 +00006173/* flap route */
ajs5a646652004-11-05 01:25:55 +00006174static void
paul718e3742002-12-13 20:15:29 +00006175flap_route_vty_out (struct vty *vty, struct prefix *p,
6176 struct bgp_info *binfo, int display, safi_t safi)
6177{
6178 struct attr *attr;
6179 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00006180 char timebuf[BGP_UPTIME_LEN];
6181 int len;
Paul Jakmafb982c22007-05-04 20:15:47 +00006182
6183 if (!binfo->extra)
6184 return;
6185
6186 bdi = binfo->extra->damp_info;
paul718e3742002-12-13 20:15:29 +00006187
paulb40d9392005-08-22 22:34:41 +00006188 /* short status lead text */
6189 route_vty_short_status_out (vty, binfo);
6190
paul718e3742002-12-13 20:15:29 +00006191 /* print prefix and mask */
6192 if (! display)
6193 route_vty_out_route (p, vty);
6194 else
6195 vty_out (vty, "%*s", 17, " ");
6196
6197 len = vty_out (vty, "%s", binfo->peer->host);
6198 len = 16 - len;
6199 if (len < 1)
6200 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6201 else
6202 vty_out (vty, "%*s", len, " ");
6203
6204 len = vty_out (vty, "%d", bdi->flap);
6205 len = 5 - len;
6206 if (len < 1)
6207 vty_out (vty, " ");
6208 else
6209 vty_out (vty, "%*s ", len, " ");
6210
6211 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6212 timebuf, BGP_UPTIME_LEN));
6213
6214 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6215 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
Chris Caputo50aef6f2009-06-23 06:06:49 +00006216 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006217 else
6218 vty_out (vty, "%*s ", 8, " ");
6219
6220 /* Print attribute */
6221 attr = binfo->attr;
6222 if (attr)
6223 {
6224 /* Print aspath */
6225 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006226 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006227
6228 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006229 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006230 }
6231 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006232}
6233
paul94f2b392005-06-28 12:44:16 +00006234static void
paul718e3742002-12-13 20:15:29 +00006235route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6236 struct bgp_info *binfo, afi_t afi, safi_t safi)
6237{
6238 char buf[INET6_ADDRSTRLEN];
6239 char buf1[BUFSIZ];
6240 struct attr *attr;
6241 int sockunion_vty_out (struct vty *, union sockunion *);
John Kemp30b00172011-03-18 17:52:18 +03006242#ifdef HAVE_CLOCK_MONOTONIC
6243 time_t tbuf;
6244#endif
paul718e3742002-12-13 20:15:29 +00006245
6246 attr = binfo->attr;
6247
6248 if (attr)
6249 {
6250 /* Line1 display AS-path, Aggregator */
6251 if (attr->aspath)
6252 {
6253 vty_out (vty, " ");
paulfe69a502005-09-10 16:55:02 +00006254 if (aspath_count_hops (attr->aspath) == 0)
paul718e3742002-12-13 20:15:29 +00006255 vty_out (vty, "Local");
6256 else
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006257 aspath_print_vty (vty, "%s", attr->aspath, "");
paul718e3742002-12-13 20:15:29 +00006258 }
6259
paulb40d9392005-08-22 22:34:41 +00006260 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6261 vty_out (vty, ", (removed)");
hasso93406d82005-02-02 14:40:33 +00006262 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6263 vty_out (vty, ", (stale)");
6264 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006265 vty_out (vty, ", (aggregated by %u %s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006266 attr->extra->aggregator_as,
6267 inet_ntoa (attr->extra->aggregator_addr));
hasso93406d82005-02-02 14:40:33 +00006268 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6269 vty_out (vty, ", (Received from a RR-client)");
6270 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6271 vty_out (vty, ", (Received from a RS-client)");
6272 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6273 vty_out (vty, ", (history entry)");
6274 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6275 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00006276 vty_out (vty, "%s", VTY_NEWLINE);
6277
6278 /* Line2 display Next-hop, Neighbor, Router-id */
6279 if (p->family == AF_INET)
6280 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006281 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
Paul Jakmafb982c22007-05-04 20:15:47 +00006282 inet_ntoa (attr->extra->mp_nexthop_global_in) :
paul718e3742002-12-13 20:15:29 +00006283 inet_ntoa (attr->nexthop));
6284 }
paul718e3742002-12-13 20:15:29 +00006285 else
6286 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006287 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006288 vty_out (vty, " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006289 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
paul718e3742002-12-13 20:15:29 +00006290 buf, INET6_ADDRSTRLEN));
6291 }
paul718e3742002-12-13 20:15:29 +00006292
6293 if (binfo->peer == bgp->peer_self)
6294 {
6295 vty_out (vty, " from %s ",
6296 p->family == AF_INET ? "0.0.0.0" : "::");
6297 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6298 }
6299 else
6300 {
6301 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6302 vty_out (vty, " (inaccessible)");
Paul Jakmafb982c22007-05-04 20:15:47 +00006303 else if (binfo->extra && binfo->extra->igpmetric)
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02006304 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006305 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6306 buf[0] = '?';
6307 buf[1] = 0;
6308 }
6309 vty_out (vty, " from %s", buf);
paul718e3742002-12-13 20:15:29 +00006310 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006311 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006312 else
6313 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6314 }
6315 vty_out (vty, "%s", VTY_NEWLINE);
6316
paul718e3742002-12-13 20:15:29 +00006317 /* display nexthop local */
Paul Jakmafb982c22007-05-04 20:15:47 +00006318 if (attr->extra && attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006319 {
6320 vty_out (vty, " (%s)%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006321 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
paul718e3742002-12-13 20:15:29 +00006322 buf, INET6_ADDRSTRLEN),
6323 VTY_NEWLINE);
6324 }
paul718e3742002-12-13 20:15:29 +00006325
6326 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
6327 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6328
6329 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006330 vty_out (vty, ", metric %u", attr->med);
paul718e3742002-12-13 20:15:29 +00006331
6332 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006333 vty_out (vty, ", localpref %u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006334 else
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006335 vty_out (vty, ", localpref %u", bgp->default_local_pref);
paul718e3742002-12-13 20:15:29 +00006336
Paul Jakmafb982c22007-05-04 20:15:47 +00006337 if (attr->extra && attr->extra->weight != 0)
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006338 vty_out (vty, ", weight %u", attr->extra->weight);
paul718e3742002-12-13 20:15:29 +00006339
6340 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6341 vty_out (vty, ", valid");
6342
6343 if (binfo->peer != bgp->peer_self)
6344 {
6345 if (binfo->peer->as == binfo->peer->local_as)
6346 vty_out (vty, ", internal");
6347 else
6348 vty_out (vty, ", %s",
6349 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6350 }
6351 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6352 vty_out (vty, ", aggregated, local");
6353 else if (binfo->type != ZEBRA_ROUTE_BGP)
6354 vty_out (vty, ", sourced");
6355 else
6356 vty_out (vty, ", sourced, local");
6357
6358 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6359 vty_out (vty, ", atomic-aggregate");
6360
Josh Baileyde8d5df2011-07-20 20:46:01 -07006361 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6362 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6363 bgp_info_mpath_count (binfo)))
6364 vty_out (vty, ", multipath");
6365
paul718e3742002-12-13 20:15:29 +00006366 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6367 vty_out (vty, ", best");
6368
6369 vty_out (vty, "%s", VTY_NEWLINE);
6370
6371 /* Line 4 display Community */
6372 if (attr->community)
6373 vty_out (vty, " Community: %s%s", attr->community->str,
6374 VTY_NEWLINE);
6375
6376 /* Line 5 display Extended-community */
6377 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
Paul Jakmafb982c22007-05-04 20:15:47 +00006378 vty_out (vty, " Extended Community: %s%s",
6379 attr->extra->ecommunity->str, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006380
6381 /* Line 6 display Originator, Cluster-id */
6382 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6383 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6384 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006385 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006386 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006387 vty_out (vty, " Originator: %s",
6388 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006389
6390 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6391 {
6392 int i;
6393 vty_out (vty, ", Cluster list: ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006394 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6395 vty_out (vty, "%s ",
6396 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +00006397 }
6398 vty_out (vty, "%s", VTY_NEWLINE);
6399 }
Paul Jakma41367172007-08-06 15:24:51 +00006400
Paul Jakmafb982c22007-05-04 20:15:47 +00006401 if (binfo->extra && binfo->extra->damp_info)
paul718e3742002-12-13 20:15:29 +00006402 bgp_damp_info_vty (vty, binfo);
6403
6404 /* Line 7 display Uptime */
John Kemp30b00172011-03-18 17:52:18 +03006405#ifdef HAVE_CLOCK_MONOTONIC
6406 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
Vladimir L Ivanov213b6cd2010-10-21 14:59:54 +04006407 vty_out (vty, " Last update: %s", ctime(&tbuf));
John Kemp30b00172011-03-18 17:52:18 +03006408#else
6409 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6410#endif /* HAVE_CLOCK_MONOTONIC */
paul718e3742002-12-13 20:15:29 +00006411 }
6412 vty_out (vty, "%s", VTY_NEWLINE);
Boian Bonevb366b512013-09-09 16:41:35 +00006413}
6414
6415#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6416 "h history, * valid, > best, = multipath,%s"\
6417 " i internal, r RIB-failure, S Stale, R Removed%s"
hasso93406d82005-02-02 14:40:33 +00006418#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00006419#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6420#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6421#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6422
6423enum bgp_show_type
6424{
6425 bgp_show_type_normal,
6426 bgp_show_type_regexp,
6427 bgp_show_type_prefix_list,
6428 bgp_show_type_filter_list,
6429 bgp_show_type_route_map,
6430 bgp_show_type_neighbor,
6431 bgp_show_type_cidr_only,
6432 bgp_show_type_prefix_longer,
6433 bgp_show_type_community_all,
6434 bgp_show_type_community,
6435 bgp_show_type_community_exact,
6436 bgp_show_type_community_list,
6437 bgp_show_type_community_list_exact,
6438 bgp_show_type_flap_statistics,
6439 bgp_show_type_flap_address,
6440 bgp_show_type_flap_prefix,
6441 bgp_show_type_flap_cidr_only,
6442 bgp_show_type_flap_regexp,
6443 bgp_show_type_flap_filter_list,
6444 bgp_show_type_flap_prefix_list,
6445 bgp_show_type_flap_prefix_longer,
6446 bgp_show_type_flap_route_map,
6447 bgp_show_type_flap_neighbor,
6448 bgp_show_type_dampend_paths,
6449 bgp_show_type_damp_neighbor
6450};
6451
ajs5a646652004-11-05 01:25:55 +00006452static int
paulfee0f4c2004-09-13 05:12:46 +00006453bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00006454 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00006455{
paul718e3742002-12-13 20:15:29 +00006456 struct bgp_info *ri;
6457 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00006458 int header = 1;
paul718e3742002-12-13 20:15:29 +00006459 int display;
ajs5a646652004-11-05 01:25:55 +00006460 unsigned long output_count;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006461 unsigned long total_count;
paul718e3742002-12-13 20:15:29 +00006462
6463 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00006464 output_count = 0;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006465 total_count = 0;
paul718e3742002-12-13 20:15:29 +00006466
paul718e3742002-12-13 20:15:29 +00006467 /* Start processing of routes. */
6468 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6469 if (rn->info != NULL)
6470 {
6471 display = 0;
6472
6473 for (ri = rn->info; ri; ri = ri->next)
6474 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006475 total_count++;
ajs5a646652004-11-05 01:25:55 +00006476 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00006477 || type == bgp_show_type_flap_address
6478 || type == bgp_show_type_flap_prefix
6479 || type == bgp_show_type_flap_cidr_only
6480 || type == bgp_show_type_flap_regexp
6481 || type == bgp_show_type_flap_filter_list
6482 || type == bgp_show_type_flap_prefix_list
6483 || type == bgp_show_type_flap_prefix_longer
6484 || type == bgp_show_type_flap_route_map
6485 || type == bgp_show_type_flap_neighbor
6486 || type == bgp_show_type_dampend_paths
6487 || type == bgp_show_type_damp_neighbor)
6488 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006489 if (!(ri->extra && ri->extra->damp_info))
paul718e3742002-12-13 20:15:29 +00006490 continue;
6491 }
6492 if (type == bgp_show_type_regexp
6493 || type == bgp_show_type_flap_regexp)
6494 {
ajs5a646652004-11-05 01:25:55 +00006495 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00006496
6497 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6498 continue;
6499 }
6500 if (type == bgp_show_type_prefix_list
6501 || type == bgp_show_type_flap_prefix_list)
6502 {
ajs5a646652004-11-05 01:25:55 +00006503 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00006504
6505 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6506 continue;
6507 }
6508 if (type == bgp_show_type_filter_list
6509 || type == bgp_show_type_flap_filter_list)
6510 {
ajs5a646652004-11-05 01:25:55 +00006511 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00006512
6513 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6514 continue;
6515 }
6516 if (type == bgp_show_type_route_map
6517 || type == bgp_show_type_flap_route_map)
6518 {
ajs5a646652004-11-05 01:25:55 +00006519 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00006520 struct bgp_info binfo;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006521 struct attr dummy_attr;
6522 struct attr_extra dummy_extra;
paul718e3742002-12-13 20:15:29 +00006523 int ret;
6524
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006525 dummy_attr.extra = &dummy_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00006526 bgp_attr_dup (&dummy_attr, ri->attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006527
paul718e3742002-12-13 20:15:29 +00006528 binfo.peer = ri->peer;
6529 binfo.attr = &dummy_attr;
6530
6531 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
paul718e3742002-12-13 20:15:29 +00006532 if (ret == RMAP_DENYMATCH)
6533 continue;
6534 }
6535 if (type == bgp_show_type_neighbor
6536 || type == bgp_show_type_flap_neighbor
6537 || type == bgp_show_type_damp_neighbor)
6538 {
ajs5a646652004-11-05 01:25:55 +00006539 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00006540
6541 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6542 continue;
6543 }
6544 if (type == bgp_show_type_cidr_only
6545 || type == bgp_show_type_flap_cidr_only)
6546 {
6547 u_int32_t destination;
6548
6549 destination = ntohl (rn->p.u.prefix4.s_addr);
6550 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6551 continue;
6552 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6553 continue;
6554 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6555 continue;
6556 }
6557 if (type == bgp_show_type_prefix_longer
6558 || type == bgp_show_type_flap_prefix_longer)
6559 {
ajs5a646652004-11-05 01:25:55 +00006560 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006561
6562 if (! prefix_match (p, &rn->p))
6563 continue;
6564 }
6565 if (type == bgp_show_type_community_all)
6566 {
6567 if (! ri->attr->community)
6568 continue;
6569 }
6570 if (type == bgp_show_type_community)
6571 {
ajs5a646652004-11-05 01:25:55 +00006572 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006573
6574 if (! ri->attr->community ||
6575 ! community_match (ri->attr->community, com))
6576 continue;
6577 }
6578 if (type == bgp_show_type_community_exact)
6579 {
ajs5a646652004-11-05 01:25:55 +00006580 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006581
6582 if (! ri->attr->community ||
6583 ! community_cmp (ri->attr->community, com))
6584 continue;
6585 }
6586 if (type == bgp_show_type_community_list)
6587 {
ajs5a646652004-11-05 01:25:55 +00006588 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006589
6590 if (! community_list_match (ri->attr->community, list))
6591 continue;
6592 }
6593 if (type == bgp_show_type_community_list_exact)
6594 {
ajs5a646652004-11-05 01:25:55 +00006595 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006596
6597 if (! community_list_exact_match (ri->attr->community, list))
6598 continue;
6599 }
6600 if (type == bgp_show_type_flap_address
6601 || type == bgp_show_type_flap_prefix)
6602 {
ajs5a646652004-11-05 01:25:55 +00006603 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006604
6605 if (! prefix_match (&rn->p, p))
6606 continue;
6607
6608 if (type == bgp_show_type_flap_prefix)
6609 if (p->prefixlen != rn->p.prefixlen)
6610 continue;
6611 }
6612 if (type == bgp_show_type_dampend_paths
6613 || type == bgp_show_type_damp_neighbor)
6614 {
6615 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6616 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6617 continue;
6618 }
6619
6620 if (header)
6621 {
hasso93406d82005-02-02 14:40:33 +00006622 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6623 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6624 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006625 if (type == bgp_show_type_dampend_paths
6626 || type == bgp_show_type_damp_neighbor)
6627 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6628 else if (type == bgp_show_type_flap_statistics
6629 || type == bgp_show_type_flap_address
6630 || type == bgp_show_type_flap_prefix
6631 || type == bgp_show_type_flap_cidr_only
6632 || type == bgp_show_type_flap_regexp
6633 || type == bgp_show_type_flap_filter_list
6634 || type == bgp_show_type_flap_prefix_list
6635 || type == bgp_show_type_flap_prefix_longer
6636 || type == bgp_show_type_flap_route_map
6637 || type == bgp_show_type_flap_neighbor)
6638 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6639 else
6640 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006641 header = 0;
6642 }
6643
6644 if (type == bgp_show_type_dampend_paths
6645 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00006646 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006647 else if (type == bgp_show_type_flap_statistics
6648 || type == bgp_show_type_flap_address
6649 || type == bgp_show_type_flap_prefix
6650 || type == bgp_show_type_flap_cidr_only
6651 || type == bgp_show_type_flap_regexp
6652 || type == bgp_show_type_flap_filter_list
6653 || type == bgp_show_type_flap_prefix_list
6654 || type == bgp_show_type_flap_prefix_longer
6655 || type == bgp_show_type_flap_route_map
6656 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00006657 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006658 else
ajs5a646652004-11-05 01:25:55 +00006659 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006660 display++;
6661 }
6662 if (display)
ajs5a646652004-11-05 01:25:55 +00006663 output_count++;
paul718e3742002-12-13 20:15:29 +00006664 }
6665
6666 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00006667 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00006668 {
6669 if (type == bgp_show_type_normal)
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006670 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006671 }
6672 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006673 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6674 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006675
6676 return CMD_SUCCESS;
6677}
6678
ajs5a646652004-11-05 01:25:55 +00006679static int
paulfee0f4c2004-09-13 05:12:46 +00006680bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00006681 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00006682{
6683 struct bgp_table *table;
6684
6685 if (bgp == NULL) {
6686 bgp = bgp_get_default ();
6687 }
6688
6689 if (bgp == NULL)
6690 {
6691 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6692 return CMD_WARNING;
6693 }
6694
6695
6696 table = bgp->rib[afi][safi];
6697
ajs5a646652004-11-05 01:25:55 +00006698 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00006699}
6700
paul718e3742002-12-13 20:15:29 +00006701/* Header of detailed BGP route information */
paul94f2b392005-06-28 12:44:16 +00006702static void
paul718e3742002-12-13 20:15:29 +00006703route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6704 struct bgp_node *rn,
6705 struct prefix_rd *prd, afi_t afi, safi_t safi)
6706{
6707 struct bgp_info *ri;
6708 struct prefix *p;
6709 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006710 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00006711 char buf1[INET6_ADDRSTRLEN];
6712 char buf2[INET6_ADDRSTRLEN];
6713 int count = 0;
6714 int best = 0;
6715 int suppress = 0;
6716 int no_export = 0;
6717 int no_advertise = 0;
6718 int local_as = 0;
6719 int first = 0;
Lou Berger298cc2f2016-01-12 13:42:02 -05006720 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
paul718e3742002-12-13 20:15:29 +00006721
6722 p = &rn->p;
6723 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
Lou Berger298cc2f2016-01-12 13:42:02 -05006724 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6725 printrd ? ":" : "",
paul718e3742002-12-13 20:15:29 +00006726 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6727 p->prefixlen, VTY_NEWLINE);
6728
6729 for (ri = rn->info; ri; ri = ri->next)
6730 {
6731 count++;
6732 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6733 {
6734 best = count;
Paul Jakmafb982c22007-05-04 20:15:47 +00006735 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00006736 suppress = 1;
6737 if (ri->attr->community != NULL)
6738 {
6739 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6740 no_advertise = 1;
6741 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6742 no_export = 1;
6743 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6744 local_as = 1;
6745 }
6746 }
6747 }
6748
6749 vty_out (vty, "Paths: (%d available", count);
6750 if (best)
6751 {
6752 vty_out (vty, ", best #%d", best);
6753 if (safi == SAFI_UNICAST)
6754 vty_out (vty, ", table Default-IP-Routing-Table");
6755 }
6756 else
6757 vty_out (vty, ", no best path");
6758 if (no_advertise)
6759 vty_out (vty, ", not advertised to any peer");
6760 else if (no_export)
6761 vty_out (vty, ", not advertised to EBGP peer");
6762 else if (local_as)
6763 vty_out (vty, ", not advertised outside local AS");
6764 if (suppress)
6765 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6766 vty_out (vty, ")%s", VTY_NEWLINE);
6767
6768 /* advertised peer */
paul1eb8ef22005-04-07 07:30:20 +00006769 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006770 {
6771 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6772 {
6773 if (! first)
6774 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6775 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6776 first = 1;
6777 }
6778 }
6779 if (! first)
6780 vty_out (vty, " Not advertised to any peer");
6781 vty_out (vty, "%s", VTY_NEWLINE);
6782}
6783
6784/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +00006785static int
paulfee0f4c2004-09-13 05:12:46 +00006786bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00006787 struct bgp_table *rib, const char *ip_str,
6788 afi_t afi, safi_t safi, struct prefix_rd *prd,
6789 int prefix_check)
paul718e3742002-12-13 20:15:29 +00006790{
6791 int ret;
6792 int header;
6793 int display = 0;
6794 struct prefix match;
6795 struct bgp_node *rn;
6796 struct bgp_node *rm;
6797 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00006798 struct bgp_table *table;
6799
Lou Berger050defe2016-01-12 13:41:59 -05006800 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
paul718e3742002-12-13 20:15:29 +00006801 /* Check IP address argument. */
6802 ret = str2prefix (ip_str, &match);
6803 if (! ret)
6804 {
6805 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6806 return CMD_WARNING;
6807 }
6808
6809 match.family = afi2family (afi);
6810
Lou Berger298cc2f2016-01-12 13:42:02 -05006811 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00006812 {
paulfee0f4c2004-09-13 05:12:46 +00006813 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00006814 {
6815 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6816 continue;
6817
6818 if ((table = rn->info) != NULL)
6819 {
6820 header = 1;
6821
6822 if ((rm = bgp_node_match (table, &match)) != NULL)
6823 {
6824 if (prefix_check && rm->p.prefixlen != match.prefixlen)
Chris Caputo6c88b442010-07-27 16:28:55 +00006825 {
6826 bgp_unlock_node (rm);
6827 continue;
6828 }
paul718e3742002-12-13 20:15:29 +00006829
6830 for (ri = rm->info; ri; ri = ri->next)
6831 {
6832 if (header)
6833 {
6834 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
Lou Berger298cc2f2016-01-12 13:42:02 -05006835 AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006836
6837 header = 0;
6838 }
6839 display++;
Lou Berger298cc2f2016-01-12 13:42:02 -05006840 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006841 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006842
6843 bgp_unlock_node (rm);
paul718e3742002-12-13 20:15:29 +00006844 }
6845 }
6846 }
6847 }
6848 else
6849 {
6850 header = 1;
6851
paulfee0f4c2004-09-13 05:12:46 +00006852 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00006853 {
6854 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6855 {
6856 for (ri = rn->info; ri; ri = ri->next)
6857 {
6858 if (header)
6859 {
6860 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6861 header = 0;
6862 }
6863 display++;
6864 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
6865 }
6866 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006867
6868 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00006869 }
6870 }
6871
6872 if (! display)
6873 {
6874 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6875 return CMD_WARNING;
6876 }
6877
6878 return CMD_SUCCESS;
6879}
6880
paulfee0f4c2004-09-13 05:12:46 +00006881/* Display specified route of Main RIB */
paul94f2b392005-06-28 12:44:16 +00006882static int
paulfd79ac92004-10-13 05:06:08 +00006883bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00006884 afi_t afi, safi_t safi, struct prefix_rd *prd,
6885 int prefix_check)
6886{
6887 struct bgp *bgp;
6888
6889 /* BGP structure lookup. */
6890 if (view_name)
6891 {
6892 bgp = bgp_lookup_by_name (view_name);
6893 if (bgp == NULL)
6894 {
6895 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6896 return CMD_WARNING;
6897 }
6898 }
6899 else
6900 {
6901 bgp = bgp_get_default ();
6902 if (bgp == NULL)
6903 {
6904 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6905 return CMD_WARNING;
6906 }
6907 }
6908
6909 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
6910 afi, safi, prd, prefix_check);
6911}
6912
paul718e3742002-12-13 20:15:29 +00006913/* BGP route print out function. */
Lou Bergerf9b6c392016-01-12 13:42:09 -05006914DEFUN (show_ip_bgp,
6915 show_ip_bgp_cmd,
6916 "show ip bgp",
6917 SHOW_STR
6918 IP_STR
6919 BGP_STR)
6920{
6921 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6922}
6923
6924DEFUN (show_ip_bgp_ipv4,
6925 show_ip_bgp_ipv4_cmd,
6926 "show ip bgp ipv4 (unicast|multicast)",
6927 SHOW_STR
6928 IP_STR
6929 BGP_STR
6930 "Address family\n"
6931 "Address Family modifier\n"
6932 "Address Family modifier\n")
6933{
6934 if (strncmp (argv[0], "m", 1) == 0)
6935 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
6936 NULL);
6937
6938 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6939}
6940
6941DEFUN (show_ip_bgp_route,
6942 show_ip_bgp_route_cmd,
6943 "show ip bgp A.B.C.D",
6944 SHOW_STR
6945 IP_STR
6946 BGP_STR
6947 "Network in the BGP routing table to display\n")
6948{
6949 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
6950}
6951
6952DEFUN (show_ip_bgp_ipv4_route,
6953 show_ip_bgp_ipv4_route_cmd,
6954 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6955 SHOW_STR
6956 IP_STR
6957 BGP_STR
6958 "Address family\n"
6959 "Address Family modifier\n"
6960 "Address Family modifier\n"
6961 "Network in the BGP routing table to display\n")
6962{
6963 if (strncmp (argv[0], "m", 1) == 0)
6964 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
6965
6966 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
6967}
6968
6969DEFUN (show_ip_bgp_vpnv4_all_route,
6970 show_ip_bgp_vpnv4_all_route_cmd,
6971 "show ip bgp vpnv4 all A.B.C.D",
6972 SHOW_STR
6973 IP_STR
6974 BGP_STR
6975 "Display VPNv4 NLRI specific information\n"
6976 "Display information about all VPNv4 NLRIs\n"
6977 "Network in the BGP routing table to display\n")
6978{
6979 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
6980}
6981
6982DEFUN (show_ip_bgp_vpnv4_rd_route,
6983 show_ip_bgp_vpnv4_rd_route_cmd,
6984 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6985 SHOW_STR
6986 IP_STR
6987 BGP_STR
6988 "Display VPNv4 NLRI specific information\n"
6989 "Display information for a route distinguisher\n"
6990 "VPN Route Distinguisher\n"
6991 "Network in the BGP routing table to display\n")
6992{
6993 int ret;
6994 struct prefix_rd prd;
6995
6996 ret = str2prefix_rd (argv[0], &prd);
6997 if (! ret)
6998 {
6999 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7000 return CMD_WARNING;
7001 }
7002 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
7003}
7004
7005DEFUN (show_ip_bgp_prefix,
7006 show_ip_bgp_prefix_cmd,
7007 "show ip bgp A.B.C.D/M",
7008 SHOW_STR
7009 IP_STR
7010 BGP_STR
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_UNICAST, NULL, 1);
7014}
7015
7016DEFUN (show_ip_bgp_ipv4_prefix,
7017 show_ip_bgp_ipv4_prefix_cmd,
7018 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
7019 SHOW_STR
7020 IP_STR
7021 BGP_STR
7022 "Address family\n"
7023 "Address Family modifier\n"
7024 "Address Family modifier\n"
7025 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7026{
7027 if (strncmp (argv[0], "m", 1) == 0)
7028 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
7029
7030 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7031}
7032
7033DEFUN (show_ip_bgp_vpnv4_all_prefix,
7034 show_ip_bgp_vpnv4_all_prefix_cmd,
7035 "show ip bgp vpnv4 all A.B.C.D/M",
7036 SHOW_STR
7037 IP_STR
7038 BGP_STR
7039 "Display VPNv4 NLRI specific information\n"
7040 "Display information about all VPNv4 NLRIs\n"
7041 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7042{
7043 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
7044}
7045
7046DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7047 show_ip_bgp_vpnv4_rd_prefix_cmd,
7048 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7049 SHOW_STR
7050 IP_STR
7051 BGP_STR
7052 "Display VPNv4 NLRI specific information\n"
7053 "Display information for a route distinguisher\n"
7054 "VPN Route Distinguisher\n"
7055 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7056{
7057 int ret;
7058 struct prefix_rd prd;
7059
7060 ret = str2prefix_rd (argv[0], &prd);
7061 if (! ret)
7062 {
7063 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7064 return CMD_WARNING;
7065 }
7066 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
7067}
7068
7069DEFUN (show_ip_bgp_view,
7070 show_ip_bgp_view_cmd,
7071 "show ip bgp view WORD",
7072 SHOW_STR
7073 IP_STR
7074 BGP_STR
7075 "BGP view\n"
7076 "View name\n")
7077{
7078 struct bgp *bgp;
7079
7080 /* BGP structure lookup. */
7081 bgp = bgp_lookup_by_name (argv[0]);
7082 if (bgp == NULL)
7083 {
7084 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7085 return CMD_WARNING;
7086 }
7087
7088 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7089}
7090
7091DEFUN (show_ip_bgp_view_route,
7092 show_ip_bgp_view_route_cmd,
7093 "show ip bgp view WORD A.B.C.D",
7094 SHOW_STR
7095 IP_STR
7096 BGP_STR
7097 "BGP view\n"
7098 "View name\n"
7099 "Network in the BGP routing table to display\n")
7100{
7101 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7102}
7103
7104DEFUN (show_ip_bgp_view_prefix,
7105 show_ip_bgp_view_prefix_cmd,
7106 "show ip bgp view WORD A.B.C.D/M",
7107 SHOW_STR
7108 IP_STR
7109 BGP_STR
7110 "BGP view\n"
7111 "View name\n"
7112 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7113{
7114 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7115}
7116
7117DEFUN (show_bgp,
7118 show_bgp_cmd,
7119 "show bgp",
7120 SHOW_STR
7121 BGP_STR)
7122{
7123 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7124 NULL);
7125}
7126
7127ALIAS (show_bgp,
7128 show_bgp_ipv6_cmd,
7129 "show bgp ipv6",
7130 SHOW_STR
7131 BGP_STR
7132 "Address family\n")
7133
7134/* old command */
7135DEFUN (show_ipv6_bgp,
7136 show_ipv6_bgp_cmd,
7137 "show ipv6 bgp",
7138 SHOW_STR
7139 IP_STR
7140 BGP_STR)
7141{
7142 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7143 NULL);
7144}
7145
7146DEFUN (show_bgp_route,
7147 show_bgp_route_cmd,
7148 "show bgp X:X::X:X",
7149 SHOW_STR
7150 BGP_STR
7151 "Network in the BGP routing table to display\n")
7152{
7153 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7154}
7155
Lou Berger35c36862016-01-12 13:42:06 -05007156DEFUN (show_bgp_ipv4_safi,
7157 show_bgp_ipv4_safi_cmd,
7158 "show bgp ipv4 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00007159 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007160 BGP_STR
7161 "Address family\n"
7162 "Address Family modifier\n"
7163 "Address Family modifier\n")
7164{
7165 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00007166 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7167 NULL);
paul718e3742002-12-13 20:15:29 +00007168
ajs5a646652004-11-05 01:25:55 +00007169 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00007170}
7171
Lou Berger35c36862016-01-12 13:42:06 -05007172DEFUN (show_bgp_ipv4_safi_route,
7173 show_bgp_ipv4_safi_route_cmd,
7174 "show bgp ipv4 (unicast|multicast) A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007175 SHOW_STR
7176 BGP_STR
7177 "Address family\n"
7178 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00007179 "Address Family modifier\n"
7180 "Network in the BGP routing table to display\n")
7181{
7182 if (strncmp (argv[0], "m", 1) == 0)
7183 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
7184
7185 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7186}
7187
Lou Berger35c36862016-01-12 13:42:06 -05007188DEFUN (show_bgp_ipv4_vpn_route,
7189 show_bgp_ipv4_vpn_route_cmd,
7190 "show bgp ipv4 vpn A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007191 SHOW_STR
7192 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007193 "Address Family\n"
7194 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007195 "Network in the BGP routing table to display\n")
7196{
7197 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
7198}
7199
Lou Berger35c36862016-01-12 13:42:06 -05007200DEFUN (show_bgp_ipv6_vpn_route,
7201 show_bgp_ipv6_vpn_route_cmd,
7202 "show bgp ipv6 vpn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007203 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007204 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007205 "Address Family\n"
7206 "Display VPN NLRI specific information\n"
7207 "Network in the BGP routing table to display\n")
7208{
7209 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0);
7210}
Lou Berger35c36862016-01-12 13:42:06 -05007211
7212DEFUN (show_bgp_ipv4_vpn_rd_route,
7213 show_bgp_ipv4_vpn_rd_route_cmd,
7214 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7215 SHOW_STR
7216 BGP_STR
7217 IP_STR
7218 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007219 "Display information for a route distinguisher\n"
7220 "VPN Route Distinguisher\n"
7221 "Network in the BGP routing table to display\n")
7222{
7223 int ret;
7224 struct prefix_rd prd;
7225
7226 ret = str2prefix_rd (argv[0], &prd);
7227 if (! ret)
7228 {
7229 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7230 return CMD_WARNING;
7231 }
7232 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
7233}
7234
Lou Berger35c36862016-01-12 13:42:06 -05007235DEFUN (show_bgp_ipv6_vpn_rd_route,
7236 show_bgp_ipv6_vpn_rd_route_cmd,
7237 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007238 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007239 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007240 "Address Family\n"
7241 "Display VPN NLRI specific information\n"
7242 "Display information for a route distinguisher\n"
7243 "VPN Route Distinguisher\n"
7244 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007245{
Lou Berger35c36862016-01-12 13:42:06 -05007246 int ret;
7247 struct prefix_rd prd;
7248
7249 ret = str2prefix_rd (argv[0], &prd);
7250 if (! ret)
7251 {
7252 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7253 return CMD_WARNING;
7254 }
7255 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007256}
7257
Lou Berger651b4022016-01-12 13:42:07 -05007258DEFUN (show_bgp_ipv4_encap_route,
7259 show_bgp_ipv4_encap_route_cmd,
7260 "show bgp ipv4 encap A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007261 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007262 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007263 IP_STR
7264 "Display ENCAP NLRI specific information\n"
7265 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007266{
Lou Berger651b4022016-01-12 13:42:07 -05007267 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007268}
7269
Lou Berger651b4022016-01-12 13:42:07 -05007270DEFUN (show_bgp_ipv6_encap_route,
7271 show_bgp_ipv6_encap_route_cmd,
7272 "show bgp ipv6 encap X:X::X:X",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007273 SHOW_STR
7274 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007275 IP6_STR
7276 "Display ENCAP NLRI specific information\n"
7277 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007278{
Lou Berger651b4022016-01-12 13:42:07 -05007279 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007280}
7281
Lou Berger651b4022016-01-12 13:42:07 -05007282DEFUN (show_bgp_ipv4_safi_rd_route,
7283 show_bgp_ipv4_safi_rd_route_cmd,
7284 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007285 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007286 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007287 "Address Family\n"
7288 "Address Family Modifier\n"
7289 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007290 "Display information for a route distinguisher\n"
Lou Berger651b4022016-01-12 13:42:07 -05007291 "ENCAP Route Distinguisher\n"
7292 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007293{
7294 int ret;
7295 struct prefix_rd prd;
Lou Berger651b4022016-01-12 13:42:07 -05007296 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007297
Lou Berger651b4022016-01-12 13:42:07 -05007298 if (bgp_parse_safi(argv[0], &safi)) {
7299 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7300 return CMD_WARNING;
7301 }
7302 ret = str2prefix_rd (argv[1], &prd);
paul718e3742002-12-13 20:15:29 +00007303 if (! ret)
7304 {
7305 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7306 return CMD_WARNING;
7307 }
Lou Berger651b4022016-01-12 13:42:07 -05007308 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007309}
7310
Lou Berger651b4022016-01-12 13:42:07 -05007311DEFUN (show_bgp_ipv6_safi_rd_route,
7312 show_bgp_ipv6_safi_rd_route_cmd,
7313 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007314 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007315 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007316 "Address Family\n"
7317 "Address Family Modifier\n"
7318 "Address Family Modifier\n"
7319 "Display information for a route distinguisher\n"
7320 "ENCAP Route Distinguisher\n"
7321 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007322{
Lou Berger651b4022016-01-12 13:42:07 -05007323 int ret;
7324 struct prefix_rd prd;
7325 safi_t safi;
paulbb46e942003-10-24 19:02:03 +00007326
Lou Berger651b4022016-01-12 13:42:07 -05007327 if (bgp_parse_safi(argv[0], &safi)) {
7328 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7329 return CMD_WARNING;
7330 }
7331 ret = str2prefix_rd (argv[1], &prd);
7332 if (! ret)
7333 {
7334 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7335 return CMD_WARNING;
7336 }
7337 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007338}
7339
Lou Berger35c36862016-01-12 13:42:06 -05007340DEFUN (show_bgp_ipv4_prefix,
7341 show_bgp_ipv4_prefix_cmd,
7342 "show bgp ipv4 A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007343 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007344 BGP_STR
paul718e3742002-12-13 20:15:29 +00007345 IP_STR
paul718e3742002-12-13 20:15:29 +00007346 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7347{
Lou Berger35c36862016-01-12 13:42:06 -05007348 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007349}
7350
Lou Berger35c36862016-01-12 13:42:06 -05007351DEFUN (show_bgp_ipv4_safi_prefix,
7352 show_bgp_ipv4_safi_prefix_cmd,
7353 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007354 SHOW_STR
7355 BGP_STR
7356 "Address family\n"
7357 "Address Family modifier\n"
Lou Berger35c36862016-01-12 13:42:06 -05007358 "Address Family modifier\n"
7359 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04007360{
7361 if (strncmp (argv[0], "m", 1) == 0)
Lou Berger35c36862016-01-12 13:42:06 -05007362 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007363
Lou Berger35c36862016-01-12 13:42:06 -05007364 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007365}
7366
Lou Berger35c36862016-01-12 13:42:06 -05007367DEFUN (show_bgp_ipv4_vpn_prefix,
7368 show_bgp_ipv4_vpn_prefix_cmd,
7369 "show bgp ipv4 vpn A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007370 SHOW_STR
7371 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007372 IP_STR
7373 "Display VPN NLRI specific information\n"
7374 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +00007375{
Lou Berger35c36862016-01-12 13:42:06 -05007376 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007377}
7378
Lou Berger35c36862016-01-12 13:42:06 -05007379DEFUN (show_bgp_ipv6_vpn_prefix,
7380 show_bgp_ipv6_vpn_prefix_cmd,
7381 "show bgp ipv6 vpn X:X::X:X/M",
7382 SHOW_STR
7383 BGP_STR
7384 "Address Family\n"
7385 "Display VPN NLRI specific information\n"
7386 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7387{
7388 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1);
7389}
Lou Berger35c36862016-01-12 13:42:06 -05007390
Lou Berger651b4022016-01-12 13:42:07 -05007391DEFUN (show_bgp_ipv4_encap_prefix,
7392 show_bgp_ipv4_encap_prefix_cmd,
7393 "show bgp ipv4 encap A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007394 SHOW_STR
7395 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007396 IP_STR
7397 "Display ENCAP NLRI specific information\n"
7398 "Display information about ENCAP NLRIs\n"
7399 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7400{
7401 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1);
7402}
paul718e3742002-12-13 20:15:29 +00007403
Lou Berger651b4022016-01-12 13:42:07 -05007404DEFUN (show_bgp_ipv6_encap_prefix,
7405 show_bgp_ipv6_encap_prefix_cmd,
7406 "show bgp ipv6 encap X:X::X:X/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007407 SHOW_STR
7408 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007409 IP_STR
7410 "Display ENCAP NLRI specific information\n"
7411 "Display information about ENCAP NLRIs\n"
7412 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7413{
7414 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1);
7415}
Lou Berger651b4022016-01-12 13:42:07 -05007416
7417DEFUN (show_bgp_ipv4_safi_rd_prefix,
7418 show_bgp_ipv4_safi_rd_prefix_cmd,
7419 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/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_IP, safi, &prd, 1);
7445}
7446
Lou Berger651b4022016-01-12 13:42:07 -05007447DEFUN (show_bgp_ipv6_safi_rd_prefix,
7448 show_bgp_ipv6_safi_rd_prefix_cmd,
7449 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7450 SHOW_STR
7451 BGP_STR
7452 "Address Family\n"
7453 "Address Family Modifier\n"
7454 "Address Family Modifier\n"
7455 "Display information for a route distinguisher\n"
7456 "ENCAP Route Distinguisher\n"
7457 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7458{
7459 int ret;
7460 struct prefix_rd prd;
7461 safi_t safi;
7462
7463 if (bgp_parse_safi(argv[0], &safi)) {
7464 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7465 return CMD_WARNING;
7466 }
7467
7468 ret = str2prefix_rd (argv[1], &prd);
7469 if (! ret)
7470 {
7471 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7472 return CMD_WARNING;
7473 }
7474 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1);
7475}
Lou Berger651b4022016-01-12 13:42:07 -05007476
7477DEFUN (show_bgp_afi_safi_view,
7478 show_bgp_afi_safi_view_cmd,
7479 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7480 SHOW_STR
7481 BGP_STR
7482 "BGP view\n"
7483 "BGP view name\n"
7484 "Address Family\n"
7485 "Address Family\n"
7486 "Address Family Modifier\n"
7487 "Address Family Modifier\n"
7488 "Address Family Modifier\n"
7489 "Address Family Modifier\n"
7490 )
7491{
7492 struct bgp *bgp;
7493 safi_t safi;
7494 afi_t afi;
7495
7496 if (bgp_parse_afi(argv[1], &afi)) {
7497 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7498 return CMD_WARNING;
7499 }
7500 if (bgp_parse_safi(argv[2], &safi)) {
7501 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7502 return CMD_WARNING;
7503 }
7504
7505 /* BGP structure lookup. */
7506 bgp = bgp_lookup_by_name (argv[0]);
7507 if (bgp == NULL)
7508 {
7509 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7510 return CMD_WARNING;
7511 }
7512
7513 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7514}
7515
7516DEFUN (show_bgp_view_afi_safi_route,
7517 show_bgp_view_afi_safi_route_cmd,
7518 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7519 SHOW_STR
7520 BGP_STR
7521 "BGP view\n"
7522 "View name\n"
7523 "Address Family\n"
7524 "Address Family\n"
7525 "Address Family Modifier\n"
7526 "Address Family Modifier\n"
7527 "Address Family Modifier\n"
7528 "Address Family Modifier\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -04007529 "Network in the BGP routing table to display\n")
7530{
Lou Berger651b4022016-01-12 13:42:07 -05007531 safi_t safi;
7532 afi_t afi;
Michael Lambert95cbbd22010-07-23 14:43:04 -04007533
Lou Berger651b4022016-01-12 13:42:07 -05007534 if (bgp_parse_afi(argv[1], &afi)) {
7535 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7536 return CMD_WARNING;
7537 }
7538 if (bgp_parse_safi(argv[2], &safi)) {
7539 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7540 return CMD_WARNING;
7541 }
7542 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0);
7543}
7544
7545DEFUN (show_bgp_view_afi_safi_prefix,
7546 show_bgp_view_afi_safi_prefix_cmd,
7547 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7548 SHOW_STR
7549 BGP_STR
7550 "BGP view\n"
7551 "View name\n"
7552 "Address Family\n"
7553 "Address Family\n"
7554 "Address Family Modifier\n"
7555 "Address Family Modifier\n"
7556 "Address Family Modifier\n"
7557 "Address Family Modifier\n"
7558 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7559{
7560 safi_t safi;
7561 afi_t afi;
7562
7563 if (bgp_parse_afi(argv[1], &afi)) {
7564 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7565 return CMD_WARNING;
7566 }
7567 if (bgp_parse_safi(argv[2], &safi)) {
7568 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7569 return CMD_WARNING;
7570 }
7571 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1);
7572}
7573
7574/* new001 */
7575DEFUN (show_bgp_afi,
7576 show_bgp_afi_cmd,
7577 "show bgp (ipv4|ipv6)",
7578 SHOW_STR
7579 BGP_STR
7580 "Address family\n"
7581 "Address family\n")
7582{
7583 afi_t afi;
7584
7585 if (bgp_parse_afi(argv[0], &afi)) {
7586 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7587 return CMD_WARNING;
7588 }
7589 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7590 NULL);
7591}
7592
Lou Berger651b4022016-01-12 13:42:07 -05007593DEFUN (show_bgp_ipv6_safi,
7594 show_bgp_ipv6_safi_cmd,
7595 "show bgp ipv6 (unicast|multicast)",
7596 SHOW_STR
7597 BGP_STR
7598 "Address family\n"
7599 "Address Family modifier\n"
7600 "Address Family modifier\n")
7601{
7602 if (strncmp (argv[0], "m", 1) == 0)
7603 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7604 NULL);
7605
7606 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007607}
7608
Lou Berger35c36862016-01-12 13:42:06 -05007609DEFUN (show_bgp_ipv6_route,
7610 show_bgp_ipv6_route_cmd,
7611 "show bgp ipv6 X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007612 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007613 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007614 "Address family\n"
paul718e3742002-12-13 20:15:29 +00007615 "Network in the BGP routing table to display\n")
7616{
7617 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7618}
7619
Lou Berger35c36862016-01-12 13:42:06 -05007620DEFUN (show_bgp_ipv6_safi_route,
7621 show_bgp_ipv6_safi_route_cmd,
7622 "show bgp ipv6 (unicast|multicast) X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007623 SHOW_STR
7624 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007625 "Address family\n"
7626 "Address Family modifier\n"
7627 "Address Family modifier\n"
7628 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007629{
Lou Berger35c36862016-01-12 13:42:06 -05007630 if (strncmp (argv[0], "m", 1) == 0)
7631 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7632
7633 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007634}
7635
Lou Bergerf9b6c392016-01-12 13:42:09 -05007636/* old command */
7637DEFUN (show_ipv6_bgp_route,
7638 show_ipv6_bgp_route_cmd,
7639 "show ipv6 bgp X:X::X:X",
7640 SHOW_STR
7641 IP_STR
7642 BGP_STR
7643 "Network in the BGP routing table to display\n")
7644{
7645 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7646}
7647
7648DEFUN (show_bgp_prefix,
7649 show_bgp_prefix_cmd,
7650 "show bgp X:X::X:X/M",
7651 SHOW_STR
7652 BGP_STR
7653 "IPv6 prefix <network>/<length>\n")
7654{
7655 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7656}
7657
7658
Lou Berger35c36862016-01-12 13:42:06 -05007659/* new002 */
7660DEFUN (show_bgp_ipv6_prefix,
paul718e3742002-12-13 20:15:29 +00007661 show_bgp_ipv6_prefix_cmd,
7662 "show bgp ipv6 X:X::X:X/M",
7663 SHOW_STR
7664 BGP_STR
7665 "Address family\n"
Lou Berger35c36862016-01-12 13:42:06 -05007666 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7667{
7668 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7669}
Michael Lambert95cbbd22010-07-23 14:43:04 -04007670DEFUN (show_bgp_ipv6_safi_prefix,
7671 show_bgp_ipv6_safi_prefix_cmd,
7672 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7673 SHOW_STR
7674 BGP_STR
7675 "Address family\n"
7676 "Address Family modifier\n"
7677 "Address Family modifier\n"
7678 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7679{
7680 if (strncmp (argv[0], "m", 1) == 0)
7681 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7682
7683 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7684}
7685
Lou Bergerf9b6c392016-01-12 13:42:09 -05007686/* old command */
7687DEFUN (show_ipv6_bgp_prefix,
7688 show_ipv6_bgp_prefix_cmd,
7689 "show ipv6 bgp X:X::X:X/M",
7690 SHOW_STR
7691 IP_STR
7692 BGP_STR
7693 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7694{
7695 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7696}
7697
paulbb46e942003-10-24 19:02:03 +00007698DEFUN (show_bgp_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007699 show_bgp_view_cmd,
7700 "show bgp view WORD",
7701 SHOW_STR
7702 BGP_STR
7703 "BGP view\n"
7704 "View name\n")
7705{
7706 struct bgp *bgp;
7707
7708 /* BGP structure lookup. */
7709 bgp = bgp_lookup_by_name (argv[0]);
7710 if (bgp == NULL)
7711 {
7712 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7713 return CMD_WARNING;
7714 }
7715
7716 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
7717}
7718
7719DEFUN (show_bgp_view_ipv6,
Lou Berger35c36862016-01-12 13:42:06 -05007720 show_bgp_view_ipv6_cmd,
7721 "show bgp view WORD ipv6",
paulbb46e942003-10-24 19:02:03 +00007722 SHOW_STR
Lou Berger35c36862016-01-12 13:42:06 -05007723 BGP_STR
paulbb46e942003-10-24 19:02:03 +00007724 "BGP view\n"
Lou Berger35c36862016-01-12 13:42:06 -05007725 "View name\n"
7726 "Address family\n")
paulbb46e942003-10-24 19:02:03 +00007727{
7728 struct bgp *bgp;
7729
7730 /* BGP structure lookup. */
7731 bgp = bgp_lookup_by_name (argv[0]);
7732 if (bgp == NULL)
7733 {
7734 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7735 return CMD_WARNING;
7736 }
7737
ajs5a646652004-11-05 01:25:55 +00007738 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00007739}
paulbb46e942003-10-24 19:02:03 +00007740
7741DEFUN (show_bgp_view_route,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007742 show_bgp_view_route_cmd,
7743 "show bgp view WORD X:X::X:X",
7744 SHOW_STR
7745 BGP_STR
7746 "BGP view\n"
7747 "View name\n"
7748 "Network in the BGP routing table to display\n")
7749{
7750 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
7751}
7752
7753DEFUN (show_bgp_view_ipv6_route,
paulbb46e942003-10-24 19:02:03 +00007754 show_bgp_view_ipv6_route_cmd,
7755 "show bgp view WORD ipv6 X:X::X:X",
7756 SHOW_STR
7757 BGP_STR
7758 "BGP view\n"
7759 "View name\n"
7760 "Address family\n"
7761 "Network in the BGP routing table to display\n")
paulbb46e942003-10-24 19:02:03 +00007762{
Lou Berger35c36862016-01-12 13:42:06 -05007763 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paulbb46e942003-10-24 19:02:03 +00007764}
7765
Lou Bergerf9b6c392016-01-12 13:42:09 -05007766/* old command */
7767DEFUN (show_ipv6_mbgp,
7768 show_ipv6_mbgp_cmd,
7769 "show ipv6 mbgp",
7770 SHOW_STR
7771 IP_STR
7772 MBGP_STR)
7773{
7774 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7775 NULL);
7776}
7777
7778/* old command */
7779DEFUN (show_ipv6_mbgp_route,
7780 show_ipv6_mbgp_route_cmd,
7781 "show ipv6 mbgp X:X::X:X",
7782 SHOW_STR
7783 IP_STR
7784 MBGP_STR
7785 "Network in the MBGP routing table to display\n")
7786{
7787 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7788}
7789
7790/* old command */
7791DEFUN (show_ipv6_mbgp_prefix,
7792 show_ipv6_mbgp_prefix_cmd,
7793 "show ipv6 mbgp X:X::X:X/M",
7794 SHOW_STR
7795 IP_STR
7796 MBGP_STR
7797 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7798{
7799 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7800}
7801
Lou Berger35c36862016-01-12 13:42:06 -05007802DEFUN (show_bgp_view_prefix,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007803 show_bgp_view_prefix_cmd,
7804 "show bgp view WORD X:X::X:X/M",
7805 SHOW_STR
7806 BGP_STR
7807 "BGP view\n"
7808 "View name\n"
7809 "IPv6 prefix <network>/<length>\n")
7810{
7811 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7812}
7813
7814DEFUN (show_bgp_view_ipv6_prefix,
paulbb46e942003-10-24 19:02:03 +00007815 show_bgp_view_ipv6_prefix_cmd,
7816 "show bgp view WORD ipv6 X:X::X:X/M",
7817 SHOW_STR
7818 BGP_STR
7819 "BGP view\n"
7820 "View name\n"
7821 "Address family\n"
7822 "IPv6 prefix <network>/<length>\n")
paul718e3742002-12-13 20:15:29 +00007823{
Lou Berger35c36862016-01-12 13:42:06 -05007824 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007825}
7826
paul94f2b392005-06-28 12:44:16 +00007827static int
paulfd79ac92004-10-13 05:06:08 +00007828bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00007829 safi_t safi, enum bgp_show_type type)
7830{
7831 int i;
7832 struct buffer *b;
7833 char *regstr;
7834 int first;
7835 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00007836 int rc;
paul718e3742002-12-13 20:15:29 +00007837
7838 first = 0;
7839 b = buffer_new (1024);
7840 for (i = 0; i < argc; i++)
7841 {
7842 if (first)
7843 buffer_putc (b, ' ');
7844 else
7845 {
7846 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
7847 continue;
7848 first = 1;
7849 }
7850
7851 buffer_putstr (b, argv[i]);
7852 }
7853 buffer_putc (b, '\0');
7854
7855 regstr = buffer_getstr (b);
7856 buffer_free (b);
7857
7858 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00007859 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00007860 if (! regex)
7861 {
7862 vty_out (vty, "Can't compile regexp %s%s", argv[0],
7863 VTY_NEWLINE);
7864 return CMD_WARNING;
7865 }
7866
ajs5a646652004-11-05 01:25:55 +00007867 rc = bgp_show (vty, NULL, afi, safi, type, regex);
7868 bgp_regex_free (regex);
7869 return rc;
paul718e3742002-12-13 20:15:29 +00007870}
7871
Lou Bergerf9b6c392016-01-12 13:42:09 -05007872
7873DEFUN (show_ip_bgp_regexp,
7874 show_ip_bgp_regexp_cmd,
7875 "show ip bgp regexp .LINE",
7876 SHOW_STR
7877 IP_STR
7878 BGP_STR
7879 "Display routes matching the AS path regular expression\n"
7880 "A regular-expression to match the BGP AS paths\n")
7881{
7882 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7883 bgp_show_type_regexp);
7884}
7885
7886DEFUN (show_ip_bgp_flap_regexp,
7887 show_ip_bgp_flap_regexp_cmd,
7888 "show ip bgp flap-statistics regexp .LINE",
7889 SHOW_STR
7890 IP_STR
7891 BGP_STR
7892 "Display flap statistics of routes\n"
7893 "Display routes matching the AS path regular expression\n"
7894 "A regular-expression to match the BGP AS paths\n")
7895{
7896 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7897 bgp_show_type_flap_regexp);
7898}
7899
7900ALIAS (show_ip_bgp_flap_regexp,
7901 show_ip_bgp_damp_flap_regexp_cmd,
7902 "show ip bgp dampening flap-statistics regexp .LINE",
7903 SHOW_STR
7904 IP_STR
7905 BGP_STR
7906 "Display detailed information about dampening\n"
7907 "Display flap statistics of routes\n"
7908 "Display routes matching the AS path regular expression\n"
7909 "A regular-expression to match the BGP AS paths\n")
7910
7911DEFUN (show_ip_bgp_ipv4_regexp,
7912 show_ip_bgp_ipv4_regexp_cmd,
7913 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7914 SHOW_STR
7915 IP_STR
7916 BGP_STR
7917 "Address family\n"
7918 "Address Family modifier\n"
7919 "Address Family modifier\n"
7920 "Display routes matching the AS path regular expression\n"
7921 "A regular-expression to match the BGP AS paths\n")
7922{
7923 if (strncmp (argv[0], "m", 1) == 0)
7924 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
7925 bgp_show_type_regexp);
7926
7927 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7928 bgp_show_type_regexp);
7929}
7930
Lou Bergerf9b6c392016-01-12 13:42:09 -05007931DEFUN (show_bgp_regexp,
7932 show_bgp_regexp_cmd,
7933 "show bgp regexp .LINE",
7934 SHOW_STR
7935 BGP_STR
7936 "Display routes matching the AS path regular expression\n"
7937 "A regular-expression to match the BGP AS paths\n")
7938{
7939 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7940 bgp_show_type_regexp);
7941}
7942
7943/* old command */
7944DEFUN (show_ipv6_bgp_regexp,
7945 show_ipv6_bgp_regexp_cmd,
7946 "show ipv6 bgp regexp .LINE",
7947 SHOW_STR
7948 IP_STR
7949 BGP_STR
7950 "Display routes matching the AS path regular expression\n"
7951 "A regular-expression to match the BGP AS paths\n")
7952{
7953 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7954 bgp_show_type_regexp);
7955}
7956
7957/* old command */
7958DEFUN (show_ipv6_mbgp_regexp,
7959 show_ipv6_mbgp_regexp_cmd,
7960 "show ipv6 mbgp regexp .LINE",
7961 SHOW_STR
7962 IP_STR
7963 BGP_STR
7964 "Display routes matching the AS path regular expression\n"
7965 "A regular-expression to match the MBGP AS paths\n")
7966{
7967 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
7968 bgp_show_type_regexp);
7969}
Lou Bergerf9b6c392016-01-12 13:42:09 -05007970
Lou Berger651b4022016-01-12 13:42:07 -05007971DEFUN (show_bgp_ipv4_safi_flap_regexp,
7972 show_bgp_ipv4_safi_flap_regexp_cmd,
7973 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00007974 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007975 BGP_STR
paul718e3742002-12-13 20:15:29 +00007976 IP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007977 "Address Family Modifier\n"
7978 "Address Family Modifier\n"
7979 "Address Family Modifier\n"
7980 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007981 "Display flap statistics of routes\n"
7982 "Display routes matching the AS path regular expression\n"
7983 "A regular-expression to match the BGP AS paths\n")
7984{
Lou Berger651b4022016-01-12 13:42:07 -05007985 safi_t safi;
7986
7987 if (bgp_parse_safi(argv[0], &safi)) {
7988 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7989 return CMD_WARNING;
7990 }
7991 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
7992 bgp_show_type_flap_regexp);
paul718e3742002-12-13 20:15:29 +00007993}
7994
Lou Berger651b4022016-01-12 13:42:07 -05007995ALIAS (show_bgp_ipv4_safi_flap_regexp,
7996 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
7997 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
Balaji3921cc52015-05-16 23:12:17 +05307998 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05307999 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008000 IP_STR
8001 "Address Family Modifier\n"
8002 "Address Family Modifier\n"
8003 "Address Family Modifier\n"
8004 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308005 "Display detailed information about dampening\n"
8006 "Display flap statistics of routes\n"
8007 "Display routes matching the AS path regular expression\n"
8008 "A regular-expression to match the BGP AS paths\n")
8009
Lou Berger651b4022016-01-12 13:42:07 -05008010DEFUN (show_bgp_ipv6_safi_flap_regexp,
8011 show_bgp_ipv6_safi_flap_regexp_cmd,
8012 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008013 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008014 BGP_STR
8015 IPV6_STR
8016 "Address Family Modifier\n"
8017 "Address Family Modifier\n"
8018 "Address Family Modifier\n"
8019 "Address Family Modifier\n"
8020 "Display flap statistics of routes\n"
8021 "Display routes matching the AS path regular expression\n"
8022 "A regular-expression to match the BGP AS paths\n")
8023{
8024 safi_t safi;
8025
8026 if (bgp_parse_safi(argv[0], &safi)) {
8027 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8028 return CMD_WARNING;
8029 }
8030 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8031 bgp_show_type_flap_regexp);
8032}
8033
8034ALIAS (show_bgp_ipv6_safi_flap_regexp,
8035 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8036 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8037 SHOW_STR
8038 BGP_STR
8039 IPV6_STR
8040 "Address Family Modifier\n"
8041 "Address Family Modifier\n"
8042 "Address Family Modifier\n"
8043 "Address Family Modifier\n"
8044 "Display detailed information about dampening\n"
8045 "Display flap statistics of routes\n"
8046 "Display routes matching the AS path regular expression\n"
8047 "A regular-expression to match the BGP AS paths\n")
Lou Berger651b4022016-01-12 13:42:07 -05008048
8049DEFUN (show_bgp_ipv4_safi_regexp,
8050 show_bgp_ipv4_safi_regexp_cmd,
8051 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8052 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008053 BGP_STR
8054 "Address family\n"
8055 "Address Family modifier\n"
8056 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008057 "Address Family modifier\n"
8058 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008059 "Display routes matching the AS path regular expression\n"
8060 "A regular-expression to match the BGP AS paths\n")
8061{
Lou Berger651b4022016-01-12 13:42:07 -05008062 safi_t safi;
8063 if (bgp_parse_safi(argv[0], &safi)) {
8064 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8065 return CMD_WARNING;
8066 }
paul718e3742002-12-13 20:15:29 +00008067
Lou Berger651b4022016-01-12 13:42:07 -05008068 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008069 bgp_show_type_regexp);
8070}
Lou Berger205e6742016-01-12 13:42:11 -05008071
Lou Berger651b4022016-01-12 13:42:07 -05008072DEFUN (show_bgp_ipv6_safi_regexp,
8073 show_bgp_ipv6_safi_regexp_cmd,
8074 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008075 SHOW_STR
8076 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008077 "Address family\n"
8078 "Address Family modifier\n"
8079 "Address Family modifier\n"
8080 "Address Family modifier\n"
8081 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008082 "Display routes matching the AS path regular expression\n"
8083 "A regular-expression to match the BGP AS paths\n")
8084{
Lou Berger651b4022016-01-12 13:42:07 -05008085 safi_t safi;
8086 if (bgp_parse_safi(argv[0], &safi)) {
8087 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8088 return CMD_WARNING;
8089 }
8090
8091 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008092 bgp_show_type_regexp);
8093}
8094
Lou Berger651b4022016-01-12 13:42:07 -05008095DEFUN (show_bgp_ipv6_regexp,
paul718e3742002-12-13 20:15:29 +00008096 show_bgp_ipv6_regexp_cmd,
8097 "show bgp ipv6 regexp .LINE",
8098 SHOW_STR
8099 BGP_STR
8100 "Address family\n"
8101 "Display routes matching the AS path regular expression\n"
8102 "A regular-expression to match the BGP AS paths\n")
paul718e3742002-12-13 20:15:29 +00008103{
8104 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8105 bgp_show_type_regexp);
8106}
8107
paul94f2b392005-06-28 12:44:16 +00008108static int
paulfd79ac92004-10-13 05:06:08 +00008109bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008110 safi_t safi, enum bgp_show_type type)
8111{
8112 struct prefix_list *plist;
8113
8114 plist = prefix_list_lookup (afi, prefix_list_str);
8115 if (plist == NULL)
8116 {
8117 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8118 prefix_list_str, VTY_NEWLINE);
8119 return CMD_WARNING;
8120 }
8121
ajs5a646652004-11-05 01:25:55 +00008122 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00008123}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008124DEFUN (show_ip_bgp_prefix_list,
8125 show_ip_bgp_prefix_list_cmd,
8126 "show ip bgp prefix-list WORD",
8127 SHOW_STR
8128 IP_STR
8129 BGP_STR
8130 "Display routes conforming to the prefix-list\n"
8131 "IP prefix-list name\n")
8132{
8133 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8134 bgp_show_type_prefix_list);
8135}
8136
8137DEFUN (show_ip_bgp_flap_prefix_list,
8138 show_ip_bgp_flap_prefix_list_cmd,
8139 "show ip bgp flap-statistics prefix-list WORD",
8140 SHOW_STR
8141 IP_STR
8142 BGP_STR
8143 "Display flap statistics of routes\n"
8144 "Display routes conforming to the prefix-list\n"
8145 "IP prefix-list name\n")
8146{
8147 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8148 bgp_show_type_flap_prefix_list);
8149}
8150
8151ALIAS (show_ip_bgp_flap_prefix_list,
8152 show_ip_bgp_damp_flap_prefix_list_cmd,
8153 "show ip bgp dampening flap-statistics prefix-list WORD",
8154 SHOW_STR
8155 IP_STR
8156 BGP_STR
8157 "Display detailed information about dampening\n"
8158 "Display flap statistics of routes\n"
8159 "Display routes conforming to the prefix-list\n"
8160 "IP prefix-list name\n")
8161
8162DEFUN (show_ip_bgp_ipv4_prefix_list,
8163 show_ip_bgp_ipv4_prefix_list_cmd,
8164 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8165 SHOW_STR
8166 IP_STR
8167 BGP_STR
8168 "Address family\n"
8169 "Address Family modifier\n"
8170 "Address Family modifier\n"
8171 "Display routes conforming to the prefix-list\n"
8172 "IP prefix-list name\n")
8173{
8174 if (strncmp (argv[0], "m", 1) == 0)
8175 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8176 bgp_show_type_prefix_list);
8177
8178 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8179 bgp_show_type_prefix_list);
8180}
8181
Lou Bergerf9b6c392016-01-12 13:42:09 -05008182DEFUN (show_bgp_prefix_list,
8183 show_bgp_prefix_list_cmd,
8184 "show bgp prefix-list WORD",
8185 SHOW_STR
8186 BGP_STR
8187 "Display routes conforming to the prefix-list\n"
8188 "IPv6 prefix-list name\n")
8189{
8190 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8191 bgp_show_type_prefix_list);
8192}
8193
8194ALIAS (show_bgp_prefix_list,
8195 show_bgp_ipv6_prefix_list_cmd,
8196 "show bgp ipv6 prefix-list WORD",
8197 SHOW_STR
8198 BGP_STR
8199 "Address family\n"
8200 "Display routes conforming to the prefix-list\n"
8201 "IPv6 prefix-list name\n")
8202
8203/* old command */
8204DEFUN (show_ipv6_bgp_prefix_list,
8205 show_ipv6_bgp_prefix_list_cmd,
8206 "show ipv6 bgp prefix-list WORD",
8207 SHOW_STR
8208 IPV6_STR
8209 BGP_STR
8210 "Display routes matching the prefix-list\n"
8211 "IPv6 prefix-list name\n")
8212{
8213 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8214 bgp_show_type_prefix_list);
8215}
8216
8217/* old command */
8218DEFUN (show_ipv6_mbgp_prefix_list,
8219 show_ipv6_mbgp_prefix_list_cmd,
8220 "show ipv6 mbgp prefix-list WORD",
8221 SHOW_STR
8222 IPV6_STR
8223 MBGP_STR
8224 "Display routes matching the prefix-list\n"
8225 "IPv6 prefix-list name\n")
8226{
8227 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8228 bgp_show_type_prefix_list);
8229}
paul718e3742002-12-13 20:15:29 +00008230
Lou Berger35c36862016-01-12 13:42:06 -05008231DEFUN (show_bgp_ipv4_prefix_list,
8232 show_bgp_ipv4_prefix_list_cmd,
8233 "show bgp ipv4 prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008234 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008235 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05008236 IP_STR
paul718e3742002-12-13 20:15:29 +00008237 "Display routes conforming to the prefix-list\n"
8238 "IP prefix-list name\n")
8239{
8240 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8241 bgp_show_type_prefix_list);
8242}
8243
Lou Berger651b4022016-01-12 13:42:07 -05008244DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8245 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8246 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008247 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008248 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008249 IP_STR
8250 "Address Family Modifier\n"
8251 "Address Family Modifier\n"
8252 "Address Family Modifier\n"
8253 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008254 "Display flap statistics of routes\n"
8255 "Display routes conforming to the prefix-list\n"
8256 "IP prefix-list name\n")
8257{
Lou Berger651b4022016-01-12 13:42:07 -05008258 safi_t safi;
8259 if (bgp_parse_safi(argv[0], &safi)) {
8260 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8261 return CMD_WARNING;
8262 }
8263 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008264 bgp_show_type_flap_prefix_list);
8265}
8266
Lou Berger651b4022016-01-12 13:42:07 -05008267ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8268 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8269 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308270 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308271 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008272 IP_STR
8273 "Address Family Modifier\n"
8274 "Address Family Modifier\n"
8275 "Address Family Modifier\n"
8276 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308277 "Display detailed information about dampening\n"
8278 "Display flap statistics of routes\n"
8279 "Display routes conforming to the prefix-list\n"
8280 "IP prefix-list name\n")
8281
Lou Berger651b4022016-01-12 13:42:07 -05008282DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8283 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8284 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008285 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008286 BGP_STR
8287 IPV6_STR
8288 "Address Family Modifier\n"
8289 "Address Family Modifier\n"
8290 "Address Family Modifier\n"
8291 "Address Family Modifier\n"
8292 "Display flap statistics of routes\n"
8293 "Display routes conforming to the prefix-list\n"
8294 "IP prefix-list name\n")
8295{
8296 safi_t safi;
8297 if (bgp_parse_safi(argv[0], &safi)) {
8298 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8299 return CMD_WARNING;
8300 }
8301 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8302 bgp_show_type_flap_prefix_list);
8303}
8304ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8305 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8306 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8307 SHOW_STR
8308 BGP_STR
8309 IPV6_STR
8310 "Address Family Modifier\n"
8311 "Address Family Modifier\n"
8312 "Address Family Modifier\n"
8313 "Address Family Modifier\n"
8314 "Display detailed information about dampening\n"
8315 "Display flap statistics of routes\n"
8316 "Display routes conforming to the prefix-list\n"
8317 "IP prefix-list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008318
8319DEFUN (show_bgp_ipv4_safi_prefix_list,
8320 show_bgp_ipv4_safi_prefix_list_cmd,
8321 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8322 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008323 BGP_STR
8324 "Address family\n"
8325 "Address Family modifier\n"
8326 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008327 "Address Family modifier\n"
8328 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008329 "Display routes conforming to the prefix-list\n"
8330 "IP prefix-list name\n")
8331{
Lou Berger651b4022016-01-12 13:42:07 -05008332 safi_t safi;
8333 if (bgp_parse_safi(argv[0], &safi)) {
8334 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8335 return CMD_WARNING;
8336 }
8337 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008338 bgp_show_type_prefix_list);
8339}
Lou Berger205e6742016-01-12 13:42:11 -05008340
Lou Berger651b4022016-01-12 13:42:07 -05008341DEFUN (show_bgp_ipv6_safi_prefix_list,
8342 show_bgp_ipv6_safi_prefix_list_cmd,
8343 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008344 SHOW_STR
8345 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008346 "Address family\n"
8347 "Address Family modifier\n"
8348 "Address Family modifier\n"
8349 "Address Family modifier\n"
8350 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008351 "Display routes conforming to the prefix-list\n"
Lou Berger651b4022016-01-12 13:42:07 -05008352 "IP prefix-list name\n")
paul718e3742002-12-13 20:15:29 +00008353{
Lou Berger651b4022016-01-12 13:42:07 -05008354 safi_t safi;
8355 if (bgp_parse_safi(argv[0], &safi)) {
8356 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8357 return CMD_WARNING;
8358 }
8359 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008360 bgp_show_type_prefix_list);
8361}
8362
paul94f2b392005-06-28 12:44:16 +00008363static int
paulfd79ac92004-10-13 05:06:08 +00008364bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008365 safi_t safi, enum bgp_show_type type)
8366{
8367 struct as_list *as_list;
8368
8369 as_list = as_list_lookup (filter);
8370 if (as_list == NULL)
8371 {
8372 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8373 return CMD_WARNING;
8374 }
8375
ajs5a646652004-11-05 01:25:55 +00008376 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00008377}
8378
Lou Bergerf9b6c392016-01-12 13:42:09 -05008379DEFUN (show_ip_bgp_filter_list,
8380 show_ip_bgp_filter_list_cmd,
8381 "show ip bgp filter-list WORD",
8382 SHOW_STR
8383 IP_STR
8384 BGP_STR
8385 "Display routes conforming to the filter-list\n"
8386 "Regular expression access list name\n")
8387{
8388 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8389 bgp_show_type_filter_list);
8390}
8391
8392DEFUN (show_ip_bgp_flap_filter_list,
8393 show_ip_bgp_flap_filter_list_cmd,
8394 "show ip bgp flap-statistics filter-list WORD",
8395 SHOW_STR
8396 IP_STR
8397 BGP_STR
8398 "Display flap statistics of routes\n"
8399 "Display routes conforming to the filter-list\n"
8400 "Regular expression access list name\n")
8401{
8402 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8403 bgp_show_type_flap_filter_list);
8404}
8405
8406ALIAS (show_ip_bgp_flap_filter_list,
8407 show_ip_bgp_damp_flap_filter_list_cmd,
8408 "show ip bgp dampening flap-statistics filter-list WORD",
8409 SHOW_STR
8410 IP_STR
8411 BGP_STR
8412 "Display detailed information about dampening\n"
8413 "Display flap statistics of routes\n"
8414 "Display routes conforming to the filter-list\n"
8415 "Regular expression access list name\n")
8416
8417DEFUN (show_ip_bgp_ipv4_filter_list,
8418 show_ip_bgp_ipv4_filter_list_cmd,
8419 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8420 SHOW_STR
8421 IP_STR
8422 BGP_STR
8423 "Address family\n"
8424 "Address Family modifier\n"
8425 "Address Family modifier\n"
8426 "Display routes conforming to the filter-list\n"
8427 "Regular expression access list name\n")
8428{
8429 if (strncmp (argv[0], "m", 1) == 0)
8430 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8431 bgp_show_type_filter_list);
8432
8433 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8434 bgp_show_type_filter_list);
8435}
8436
Lou Bergerf9b6c392016-01-12 13:42:09 -05008437DEFUN (show_bgp_filter_list,
8438 show_bgp_filter_list_cmd,
8439 "show bgp filter-list WORD",
8440 SHOW_STR
8441 BGP_STR
8442 "Display routes conforming to the filter-list\n"
8443 "Regular expression access list name\n")
8444{
8445 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8446 bgp_show_type_filter_list);
8447}
8448
8449/* old command */
8450DEFUN (show_ipv6_bgp_filter_list,
8451 show_ipv6_bgp_filter_list_cmd,
8452 "show ipv6 bgp filter-list WORD",
8453 SHOW_STR
8454 IPV6_STR
8455 BGP_STR
8456 "Display routes conforming to the filter-list\n"
8457 "Regular expression access list name\n")
8458{
8459 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8460 bgp_show_type_filter_list);
8461}
8462
8463/* old command */
8464DEFUN (show_ipv6_mbgp_filter_list,
8465 show_ipv6_mbgp_filter_list_cmd,
8466 "show ipv6 mbgp filter-list WORD",
8467 SHOW_STR
8468 IPV6_STR
8469 MBGP_STR
8470 "Display routes conforming to the filter-list\n"
8471 "Regular expression access list name\n")
8472{
8473 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8474 bgp_show_type_filter_list);
8475}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008476
8477DEFUN (show_ip_bgp_dampening_info,
8478 show_ip_bgp_dampening_params_cmd,
8479 "show ip bgp dampening parameters",
8480 SHOW_STR
8481 IP_STR
8482 BGP_STR
8483 "Display detailed information about dampening\n"
8484 "Display detail of configured dampening parameters\n")
8485{
8486 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8487}
8488
Lou Berger651b4022016-01-12 13:42:07 -05008489DEFUN (show_bgp_ipv4_filter_list,
8490 show_bgp_ipv4_filter_list_cmd,
8491 "show bgp ipv4 filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008492 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008493 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008494 IP_STR
paul718e3742002-12-13 20:15:29 +00008495 "Display routes conforming to the filter-list\n"
8496 "Regular expression access list name\n")
8497{
8498 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8499 bgp_show_type_filter_list);
8500}
8501
Lou Berger651b4022016-01-12 13:42:07 -05008502DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8503 show_bgp_ipv4_safi_flap_filter_list_cmd,
8504 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008505 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008506 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008507 IP_STR
8508 "Address Family modifier\n"
8509 "Address Family modifier\n"
8510 "Address Family modifier\n"
8511 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008512 "Display flap statistics of routes\n"
8513 "Display routes conforming to the filter-list\n"
8514 "Regular expression access list name\n")
8515{
Lou Berger651b4022016-01-12 13:42:07 -05008516 safi_t safi;
8517
8518 if (bgp_parse_safi(argv[0], &safi)) {
8519 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8520 return CMD_WARNING;
8521 }
8522 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008523 bgp_show_type_flap_filter_list);
8524}
8525
Lou Berger651b4022016-01-12 13:42:07 -05008526ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8527 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8528 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308529 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308530 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008531 IP_STR
8532 "Address Family modifier\n"
8533 "Address Family modifier\n"
8534 "Address Family modifier\n"
8535 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308536 "Display detailed information about dampening\n"
8537 "Display flap statistics of routes\n"
8538 "Display routes conforming to the filter-list\n"
8539 "Regular expression access list name\n")
8540
Lou Berger651b4022016-01-12 13:42:07 -05008541DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8542 show_bgp_ipv6_safi_flap_filter_list_cmd,
8543 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008544 SHOW_STR
8545 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008546 IPV6_STR
8547 "Address Family modifier\n"
8548 "Address Family modifier\n"
8549 "Address Family modifier\n"
8550 "Address Family modifier\n"
8551 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +00008552 "Display routes conforming to the filter-list\n"
8553 "Regular expression access list name\n")
8554{
Lou Berger651b4022016-01-12 13:42:07 -05008555 safi_t safi;
8556
8557 if (bgp_parse_safi(argv[0], &safi)) {
8558 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8559 return CMD_WARNING;
8560 }
8561 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8562 bgp_show_type_flap_filter_list);
8563}
8564ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8565 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8566 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8567 SHOW_STR
8568 BGP_STR
8569 IPV6_STR
8570 "Address Family modifier\n"
8571 "Address Family modifier\n"
8572 "Address Family modifier\n"
8573 "Address Family modifier\n"
8574 "Display detailed information about dampening\n"
8575 "Display flap statistics of routes\n"
8576 "Display routes conforming to the filter-list\n"
8577 "Regular expression access list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008578
8579DEFUN (show_bgp_ipv4_safi_filter_list,
8580 show_bgp_ipv4_safi_filter_list_cmd,
8581 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8582 SHOW_STR
8583 BGP_STR
8584 "Address Family modifier\n"
8585 "Address Family modifier\n"
8586 "Address Family modifier\n"
8587 "Address Family modifier\n"
8588 "Display routes conforming to the filter-list\n"
8589 "Regular expression access list name\n")
8590{
8591 safi_t safi;
8592
8593 if (bgp_parse_safi(argv[0], &safi)) {
8594 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8595 return CMD_WARNING;
8596 }
8597 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8598 bgp_show_type_filter_list);
8599}
Lou Berger205e6742016-01-12 13:42:11 -05008600
Lou Berger651b4022016-01-12 13:42:07 -05008601DEFUN (show_bgp_ipv6_safi_filter_list,
8602 show_bgp_ipv6_safi_filter_list_cmd,
8603 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8604 SHOW_STR
8605 BGP_STR
8606 "Address Family modifier\n"
8607 "Address Family modifier\n"
8608 "Address Family modifier\n"
8609 "Address Family modifier\n"
8610 "Display routes conforming to the filter-list\n"
8611 "Regular expression access list name\n")
8612{
8613 safi_t safi;
8614
8615 if (bgp_parse_safi(argv[0], &safi)) {
8616 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8617 return CMD_WARNING;
8618 }
8619 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8620 bgp_show_type_filter_list);
paul718e3742002-12-13 20:15:29 +00008621}
8622
Lou Bergerf9b6c392016-01-12 13:42:09 -05008623DEFUN (show_bgp_ipv6_filter_list,
paul718e3742002-12-13 20:15:29 +00008624 show_bgp_ipv6_filter_list_cmd,
8625 "show bgp ipv6 filter-list WORD",
8626 SHOW_STR
8627 BGP_STR
8628 "Address family\n"
8629 "Display routes conforming to the filter-list\n"
8630 "Regular expression access list name\n")
paul718e3742002-12-13 20:15:29 +00008631{
8632 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8633 bgp_show_type_filter_list);
8634}
8635
paul94f2b392005-06-28 12:44:16 +00008636static int
paulfd79ac92004-10-13 05:06:08 +00008637bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008638 safi_t safi, enum bgp_show_type type)
8639{
8640 struct route_map *rmap;
8641
8642 rmap = route_map_lookup_by_name (rmap_str);
8643 if (! rmap)
8644 {
8645 vty_out (vty, "%% %s is not a valid route-map name%s",
8646 rmap_str, VTY_NEWLINE);
8647 return CMD_WARNING;
8648 }
8649
ajs5a646652004-11-05 01:25:55 +00008650 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00008651}
8652
Lou Bergerf9b6c392016-01-12 13:42:09 -05008653DEFUN (show_ip_bgp_route_map,
8654 show_ip_bgp_route_map_cmd,
8655 "show ip bgp route-map WORD",
8656 SHOW_STR
8657 IP_STR
8658 BGP_STR
8659 "Display routes matching the route-map\n"
8660 "A route-map to match on\n")
8661{
8662 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8663 bgp_show_type_route_map);
8664}
8665
8666DEFUN (show_ip_bgp_flap_route_map,
8667 show_ip_bgp_flap_route_map_cmd,
8668 "show ip bgp flap-statistics route-map WORD",
8669 SHOW_STR
8670 IP_STR
8671 BGP_STR
8672 "Display flap statistics of routes\n"
8673 "Display routes matching the route-map\n"
8674 "A route-map to match on\n")
8675{
8676 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8677 bgp_show_type_flap_route_map);
8678}
8679
8680ALIAS (show_ip_bgp_flap_route_map,
8681 show_ip_bgp_damp_flap_route_map_cmd,
8682 "show ip bgp dampening flap-statistics route-map WORD",
8683 SHOW_STR
8684 IP_STR
8685 BGP_STR
8686 "Display detailed information about dampening\n"
8687 "Display flap statistics of routes\n"
8688 "Display routes matching the route-map\n"
8689 "A route-map to match on\n")
8690
8691DEFUN (show_ip_bgp_ipv4_route_map,
8692 show_ip_bgp_ipv4_route_map_cmd,
8693 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
8694 SHOW_STR
8695 IP_STR
8696 BGP_STR
8697 "Address family\n"
8698 "Address Family modifier\n"
8699 "Address Family modifier\n"
8700 "Display routes matching the route-map\n"
8701 "A route-map to match on\n")
8702{
8703 if (strncmp (argv[0], "m", 1) == 0)
8704 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8705 bgp_show_type_route_map);
8706
8707 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
8708 bgp_show_type_route_map);
8709}
8710
8711DEFUN (show_bgp_route_map,
8712 show_bgp_route_map_cmd,
8713 "show bgp route-map WORD",
8714 SHOW_STR
8715 BGP_STR
8716 "Display routes matching the route-map\n"
8717 "A route-map to match on\n")
8718{
8719 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8720 bgp_show_type_route_map);
8721}
8722
8723DEFUN (show_ip_bgp_cidr_only,
8724 show_ip_bgp_cidr_only_cmd,
8725 "show ip bgp cidr-only",
8726 SHOW_STR
8727 IP_STR
8728 BGP_STR
8729 "Display only routes with non-natural netmasks\n")
8730{
8731 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8732 bgp_show_type_cidr_only, NULL);
8733}
8734
8735DEFUN (show_ip_bgp_flap_cidr_only,
8736 show_ip_bgp_flap_cidr_only_cmd,
8737 "show ip bgp flap-statistics cidr-only",
8738 SHOW_STR
8739 IP_STR
8740 BGP_STR
8741 "Display flap statistics of routes\n"
8742 "Display only routes with non-natural netmasks\n")
8743{
8744 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8745 bgp_show_type_flap_cidr_only, NULL);
8746}
8747
8748ALIAS (show_ip_bgp_flap_cidr_only,
8749 show_ip_bgp_damp_flap_cidr_only_cmd,
8750 "show ip bgp dampening flap-statistics cidr-only",
8751 SHOW_STR
8752 IP_STR
8753 BGP_STR
8754 "Display detailed information about dampening\n"
8755 "Display flap statistics of routes\n"
8756 "Display only routes with non-natural netmasks\n")
8757
8758DEFUN (show_ip_bgp_ipv4_cidr_only,
8759 show_ip_bgp_ipv4_cidr_only_cmd,
8760 "show ip bgp ipv4 (unicast|multicast) cidr-only",
8761 SHOW_STR
8762 IP_STR
8763 BGP_STR
8764 "Address family\n"
8765 "Address Family modifier\n"
8766 "Address Family modifier\n"
8767 "Display only routes with non-natural netmasks\n")
8768{
8769 if (strncmp (argv[0], "m", 1) == 0)
8770 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8771 bgp_show_type_cidr_only, NULL);
8772
8773 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8774 bgp_show_type_cidr_only, NULL);
8775}
8776
8777DEFUN (show_ip_bgp_community_all,
8778 show_ip_bgp_community_all_cmd,
8779 "show ip bgp community",
8780 SHOW_STR
8781 IP_STR
8782 BGP_STR
8783 "Display routes matching the communities\n")
8784{
8785 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8786 bgp_show_type_community_all, NULL);
8787}
8788
8789DEFUN (show_ip_bgp_ipv4_community_all,
8790 show_ip_bgp_ipv4_community_all_cmd,
8791 "show ip bgp ipv4 (unicast|multicast) community",
8792 SHOW_STR
8793 IP_STR
8794 BGP_STR
8795 "Address family\n"
8796 "Address Family modifier\n"
8797 "Address Family modifier\n"
8798 "Display routes matching the communities\n")
8799{
8800 if (strncmp (argv[0], "m", 1) == 0)
8801 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8802 bgp_show_type_community_all, NULL);
8803
8804 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8805 bgp_show_type_community_all, NULL);
8806}
8807
Lou Bergerf9b6c392016-01-12 13:42:09 -05008808DEFUN (show_bgp_community_all,
8809 show_bgp_community_all_cmd,
8810 "show bgp community",
8811 SHOW_STR
8812 BGP_STR
8813 "Display routes matching the communities\n")
8814{
8815 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8816 bgp_show_type_community_all, NULL);
8817}
8818
8819ALIAS (show_bgp_community_all,
8820 show_bgp_ipv6_community_all_cmd,
8821 "show bgp ipv6 community",
8822 SHOW_STR
8823 BGP_STR
8824 "Address family\n"
8825 "Display routes matching the communities\n")
8826
8827/* old command */
8828DEFUN (show_ipv6_bgp_community_all,
8829 show_ipv6_bgp_community_all_cmd,
8830 "show ipv6 bgp community",
8831 SHOW_STR
8832 IPV6_STR
8833 BGP_STR
8834 "Display routes matching the communities\n")
8835{
8836 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8837 bgp_show_type_community_all, NULL);
8838}
8839
8840/* old command */
8841DEFUN (show_ipv6_mbgp_community_all,
8842 show_ipv6_mbgp_community_all_cmd,
8843 "show ipv6 mbgp community",
8844 SHOW_STR
8845 IPV6_STR
8846 MBGP_STR
8847 "Display routes matching the communities\n")
8848{
8849 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
8850 bgp_show_type_community_all, NULL);
8851}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008852
Lou Berger651b4022016-01-12 13:42:07 -05008853DEFUN (show_bgp_ipv4_route_map,
8854 show_bgp_ipv4_route_map_cmd,
8855 "show bgp ipv4 route-map WORD",
paul718e3742002-12-13 20:15:29 +00008856 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008857 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008858 IP_STR
paul718e3742002-12-13 20:15:29 +00008859 "Display routes matching the route-map\n"
8860 "A route-map to match on\n")
8861{
8862 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8863 bgp_show_type_route_map);
8864}
8865
Lou Berger651b4022016-01-12 13:42:07 -05008866DEFUN (show_bgp_ipv4_safi_flap_route_map,
8867 show_bgp_ipv4_safi_flap_route_map_cmd,
8868 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008869 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008870 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008871 IP_STR
8872 "Address Family Modifier\n"
8873 "Address Family Modifier\n"
8874 "Address Family Modifier\n"
8875 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008876 "Display flap statistics of routes\n"
8877 "Display routes matching the route-map\n"
8878 "A route-map to match on\n")
8879{
Lou Berger651b4022016-01-12 13:42:07 -05008880 safi_t safi;
8881 if (bgp_parse_safi(argv[0], &safi)) {
8882 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8883 return CMD_WARNING;
8884 }
8885 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008886 bgp_show_type_flap_route_map);
8887}
8888
Lou Berger651b4022016-01-12 13:42:07 -05008889ALIAS (show_bgp_ipv4_safi_flap_route_map,
8890 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
8891 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
Balaji3921cc52015-05-16 23:12:17 +05308892 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308893 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008894 IP_STR
8895 "Address Family Modifier\n"
8896 "Address Family Modifier\n"
8897 "Address Family Modifier\n"
8898 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308899 "Display detailed information about dampening\n"
8900 "Display flap statistics of routes\n"
8901 "Display routes matching the route-map\n"
8902 "A route-map to match on\n")
Lou Berger205e6742016-01-12 13:42:11 -05008903
Lou Berger651b4022016-01-12 13:42:07 -05008904DEFUN (show_bgp_ipv6_safi_flap_route_map,
8905 show_bgp_ipv6_safi_flap_route_map_cmd,
8906 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008907 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008908 BGP_STR
8909 IPV6_STR
8910 "Address Family Modifier\n"
8911 "Address Family Modifier\n"
8912 "Address Family Modifier\n"
8913 "Address Family Modifier\n"
8914 "Display flap statistics of routes\n"
8915 "Display routes matching the route-map\n"
8916 "A route-map to match on\n")
8917{
8918 safi_t safi;
8919 if (bgp_parse_safi(argv[0], &safi)) {
8920 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8921 return CMD_WARNING;
8922 }
8923 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
8924 bgp_show_type_flap_route_map);
8925}
8926ALIAS (show_bgp_ipv6_safi_flap_route_map,
8927 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
8928 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
8929 SHOW_STR
8930 BGP_STR
8931 IPV6_STR
8932 "Address Family Modifier\n"
8933 "Address Family Modifier\n"
8934 "Address Family Modifier\n"
8935 "Address Family Modifier\n"
8936 "Display detailed information about dampening\n"
8937 "Display flap statistics of routes\n"
8938 "Display routes matching the route-map\n"
8939 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05008940
8941DEFUN (show_bgp_ipv4_safi_route_map,
8942 show_bgp_ipv4_safi_route_map_cmd,
8943 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
8944 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008945 BGP_STR
8946 "Address family\n"
8947 "Address Family modifier\n"
8948 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008949 "Address Family modifier\n"
8950 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008951 "Display routes matching the route-map\n"
8952 "A route-map to match on\n")
8953{
Lou Berger651b4022016-01-12 13:42:07 -05008954 safi_t safi;
8955 if (bgp_parse_safi(argv[0], &safi)) {
8956 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8957 return CMD_WARNING;
8958 }
8959 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008960 bgp_show_type_route_map);
8961}
Lou Berger205e6742016-01-12 13:42:11 -05008962
Lou Berger651b4022016-01-12 13:42:07 -05008963DEFUN (show_bgp_ipv6_safi_route_map,
8964 show_bgp_ipv6_safi_route_map_cmd,
8965 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
paul718e3742002-12-13 20:15:29 +00008966 SHOW_STR
8967 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008968 "Address family\n"
8969 "Address Family modifier\n"
8970 "Address Family modifier\n"
8971 "Address Family modifier\n"
8972 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008973 "Display routes matching the route-map\n"
8974 "A route-map to match on\n")
8975{
Lou Berger651b4022016-01-12 13:42:07 -05008976 safi_t safi;
8977 if (bgp_parse_safi(argv[0], &safi)) {
8978 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8979 return CMD_WARNING;
8980 }
8981 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008982 bgp_show_type_route_map);
8983}
8984
Lou Berger651b4022016-01-12 13:42:07 -05008985DEFUN (show_bgp_ipv6_route_map,
paul718e3742002-12-13 20:15:29 +00008986 show_bgp_ipv6_route_map_cmd,
8987 "show bgp ipv6 route-map WORD",
8988 SHOW_STR
8989 BGP_STR
8990 "Address family\n"
8991 "Display routes matching the route-map\n"
8992 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05008993{
8994 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8995 bgp_show_type_route_map);
8996}
David Lamparter6b0655a2014-06-04 06:53:35 +02008997
Lou Berger651b4022016-01-12 13:42:07 -05008998DEFUN (show_bgp_ipv4_cidr_only,
8999 show_bgp_ipv4_cidr_only_cmd,
9000 "show bgp ipv4 cidr-only",
paul718e3742002-12-13 20:15:29 +00009001 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009002 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009003 IP_STR
paul718e3742002-12-13 20:15:29 +00009004 "Display only routes with non-natural netmasks\n")
9005{
9006 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009007 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009008}
9009
Lou Berger651b4022016-01-12 13:42:07 -05009010DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
9011 show_bgp_ipv4_safi_flap_cidr_only_cmd,
9012 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
paul718e3742002-12-13 20:15:29 +00009013 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009014 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009015 "Address Family\n"
9016 "Address Family Modifier\n"
9017 "Address Family Modifier\n"
9018 "Address Family Modifier\n"
9019 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009020 "Display flap statistics of routes\n"
9021 "Display only routes with non-natural netmasks\n")
9022{
Lou Berger651b4022016-01-12 13:42:07 -05009023 safi_t safi;
9024
9025 if (bgp_parse_safi(argv[0], &safi)) {
9026 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9027 return CMD_WARNING;
9028 }
9029 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009030}
9031
Lou Berger651b4022016-01-12 13:42:07 -05009032ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9033 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9034 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
Balaji3921cc52015-05-16 23:12:17 +05309035 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309036 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009037 "Address Family\n"
9038 "Address Family Modifier\n"
9039 "Address Family Modifier\n"
9040 "Address Family Modifier\n"
9041 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309042 "Display detailed information about dampening\n"
9043 "Display flap statistics of routes\n"
9044 "Display only routes with non-natural netmasks\n")
9045
Lou Berger651b4022016-01-12 13:42:07 -05009046DEFUN (show_bgp_ipv4_safi_cidr_only,
9047 show_bgp_ipv4_safi_cidr_only_cmd,
9048 "show bgp ipv4 (unicast|multicast) cidr-only",
paul718e3742002-12-13 20:15:29 +00009049 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009050 BGP_STR
9051 "Address family\n"
9052 "Address Family modifier\n"
9053 "Address Family modifier\n"
9054 "Display only routes with non-natural netmasks\n")
9055{
9056 if (strncmp (argv[0], "m", 1) == 0)
9057 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00009058 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009059
9060 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009061 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009062}
David Lamparter6b0655a2014-06-04 06:53:35 +02009063
Lou Berger651b4022016-01-12 13:42:07 -05009064/* new046 */
9065DEFUN (show_bgp_afi_safi_community_all,
9066 show_bgp_afi_safi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009067 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
paul718e3742002-12-13 20:15:29 +00009068 SHOW_STR
9069 BGP_STR
9070 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009071 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009072 "Address Family modifier\n"
9073 "Address Family modifier\n"
9074 "Address Family modifier\n"
9075 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009076 "Display routes matching the communities\n")
Lou Berger651b4022016-01-12 13:42:07 -05009077{
9078 safi_t safi;
9079 afi_t afi;
paul718e3742002-12-13 20:15:29 +00009080
Lou Berger651b4022016-01-12 13:42:07 -05009081 if (bgp_parse_afi(argv[0], &afi)) {
9082 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9083 return CMD_WARNING;
9084 }
9085 if (bgp_parse_safi(argv[1], &safi)) {
9086 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9087 return CMD_WARNING;
9088 }
9089
9090 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9091}
9092DEFUN (show_bgp_afi_community_all,
9093 show_bgp_afi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009094 "show bgp (ipv4|ipv6) community",
paul718e3742002-12-13 20:15:29 +00009095 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009096 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009097 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009098 "Address family\n"
paul718e3742002-12-13 20:15:29 +00009099 "Display routes matching the communities\n")
9100{
Lou Berger651b4022016-01-12 13:42:07 -05009101 afi_t afi;
9102 safi_t safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +00009103
Lou Berger651b4022016-01-12 13:42:07 -05009104 if (bgp_parse_afi(argv[0], &afi)) {
9105 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9106 return CMD_WARNING;
9107 }
9108 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00009109}
David Lamparter6b0655a2014-06-04 06:53:35 +02009110
paul94f2b392005-06-28 12:44:16 +00009111static int
Michael Lambert95cbbd22010-07-23 14:43:04 -04009112bgp_show_community (struct vty *vty, const char *view_name, int argc,
9113 const char **argv, int exact, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00009114{
9115 struct community *com;
9116 struct buffer *b;
Michael Lambert95cbbd22010-07-23 14:43:04 -04009117 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +00009118 int i;
9119 char *str;
9120 int first = 0;
9121
Michael Lambert95cbbd22010-07-23 14:43:04 -04009122 /* BGP structure lookup */
9123 if (view_name)
9124 {
9125 bgp = bgp_lookup_by_name (view_name);
9126 if (bgp == NULL)
9127 {
9128 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9129 return CMD_WARNING;
9130 }
9131 }
9132 else
9133 {
9134 bgp = bgp_get_default ();
9135 if (bgp == NULL)
9136 {
9137 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9138 return CMD_WARNING;
9139 }
9140 }
9141
paul718e3742002-12-13 20:15:29 +00009142 b = buffer_new (1024);
9143 for (i = 0; i < argc; i++)
9144 {
9145 if (first)
9146 buffer_putc (b, ' ');
9147 else
9148 {
9149 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9150 continue;
9151 first = 1;
9152 }
9153
9154 buffer_putstr (b, argv[i]);
9155 }
9156 buffer_putc (b, '\0');
9157
9158 str = buffer_getstr (b);
9159 buffer_free (b);
9160
9161 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00009162 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009163 if (! com)
9164 {
9165 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9166 return CMD_WARNING;
9167 }
9168
Michael Lambert95cbbd22010-07-23 14:43:04 -04009169 return bgp_show (vty, bgp, afi, safi,
ajs5a646652004-11-05 01:25:55 +00009170 (exact ? bgp_show_type_community_exact :
9171 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00009172}
9173
Lou Bergerf9b6c392016-01-12 13:42:09 -05009174DEFUN (show_ip_bgp_community,
9175 show_ip_bgp_community_cmd,
9176 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9177 SHOW_STR
9178 IP_STR
9179 BGP_STR
9180 "Display routes matching the communities\n"
9181 "community number\n"
9182 "Do not send outside local AS (well-known community)\n"
9183 "Do not advertise to any peer (well-known community)\n"
9184 "Do not export to next AS (well-known community)\n")
9185{
9186 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9187}
9188
9189ALIAS (show_ip_bgp_community,
9190 show_ip_bgp_community2_cmd,
9191 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9192 SHOW_STR
9193 IP_STR
9194 BGP_STR
9195 "Display routes matching the communities\n"
9196 "community number\n"
9197 "Do not send outside local AS (well-known community)\n"
9198 "Do not advertise to any peer (well-known community)\n"
9199 "Do not export to next AS (well-known community)\n"
9200 "community number\n"
9201 "Do not send outside local AS (well-known community)\n"
9202 "Do not advertise to any peer (well-known community)\n"
9203 "Do not export to next AS (well-known community)\n")
9204
9205ALIAS (show_ip_bgp_community,
9206 show_ip_bgp_community3_cmd,
9207 "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)",
9208 SHOW_STR
9209 IP_STR
9210 BGP_STR
9211 "Display routes matching the communities\n"
9212 "community number\n"
9213 "Do not send outside local AS (well-known community)\n"
9214 "Do not advertise to any peer (well-known community)\n"
9215 "Do not export to next AS (well-known community)\n"
9216 "community number\n"
9217 "Do not send outside local AS (well-known community)\n"
9218 "Do not advertise to any peer (well-known community)\n"
9219 "Do not export to next AS (well-known community)\n"
9220 "community number\n"
9221 "Do not send outside local AS (well-known community)\n"
9222 "Do not advertise to any peer (well-known community)\n"
9223 "Do not export to next AS (well-known community)\n")
9224
9225ALIAS (show_ip_bgp_community,
9226 show_ip_bgp_community4_cmd,
9227 "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)",
9228 SHOW_STR
9229 IP_STR
9230 BGP_STR
9231 "Display routes matching the communities\n"
9232 "community number\n"
9233 "Do not send outside local AS (well-known community)\n"
9234 "Do not advertise to any peer (well-known community)\n"
9235 "Do not export to next AS (well-known community)\n"
9236 "community number\n"
9237 "Do not send outside local AS (well-known community)\n"
9238 "Do not advertise to any peer (well-known community)\n"
9239 "Do not export to next AS (well-known community)\n"
9240 "community number\n"
9241 "Do not send outside local AS (well-known community)\n"
9242 "Do not advertise to any peer (well-known community)\n"
9243 "Do not export to next AS (well-known community)\n"
9244 "community number\n"
9245 "Do not send outside local AS (well-known community)\n"
9246 "Do not advertise to any peer (well-known community)\n"
9247 "Do not export to next AS (well-known community)\n")
9248
9249DEFUN (show_ip_bgp_ipv4_community,
9250 show_ip_bgp_ipv4_community_cmd,
9251 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9252 SHOW_STR
9253 IP_STR
9254 BGP_STR
9255 "Address family\n"
9256 "Address Family modifier\n"
9257 "Address Family modifier\n"
9258 "Display routes matching the communities\n"
9259 "community number\n"
9260 "Do not send outside local AS (well-known community)\n"
9261 "Do not advertise to any peer (well-known community)\n"
9262 "Do not export to next AS (well-known community)\n")
9263{
9264 if (strncmp (argv[0], "m", 1) == 0)
9265 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9266
9267 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9268}
9269
9270ALIAS (show_ip_bgp_ipv4_community,
9271 show_ip_bgp_ipv4_community2_cmd,
9272 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9273 SHOW_STR
9274 IP_STR
9275 BGP_STR
9276 "Address family\n"
9277 "Address Family modifier\n"
9278 "Address Family modifier\n"
9279 "Display routes matching the communities\n"
9280 "community number\n"
9281 "Do not send outside local AS (well-known community)\n"
9282 "Do not advertise to any peer (well-known community)\n"
9283 "Do not export to next AS (well-known community)\n"
9284 "community number\n"
9285 "Do not send outside local AS (well-known community)\n"
9286 "Do not advertise to any peer (well-known community)\n"
9287 "Do not export to next AS (well-known community)\n")
9288
9289ALIAS (show_ip_bgp_ipv4_community,
9290 show_ip_bgp_ipv4_community3_cmd,
9291 "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)",
9292 SHOW_STR
9293 IP_STR
9294 BGP_STR
9295 "Address family\n"
9296 "Address Family modifier\n"
9297 "Address Family modifier\n"
9298 "Display routes matching the communities\n"
9299 "community number\n"
9300 "Do not send outside local AS (well-known community)\n"
9301 "Do not advertise to any peer (well-known community)\n"
9302 "Do not export to next AS (well-known community)\n"
9303 "community number\n"
9304 "Do not send outside local AS (well-known community)\n"
9305 "Do not advertise to any peer (well-known community)\n"
9306 "Do not export to next AS (well-known community)\n"
9307 "community number\n"
9308 "Do not send outside local AS (well-known community)\n"
9309 "Do not advertise to any peer (well-known community)\n"
9310 "Do not export to next AS (well-known community)\n")
9311
9312ALIAS (show_ip_bgp_ipv4_community,
9313 show_ip_bgp_ipv4_community4_cmd,
9314 "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)",
9315 SHOW_STR
9316 IP_STR
9317 BGP_STR
9318 "Address family\n"
9319 "Address Family modifier\n"
9320 "Address Family modifier\n"
9321 "Display routes matching the communities\n"
9322 "community number\n"
9323 "Do not send outside local AS (well-known community)\n"
9324 "Do not advertise to any peer (well-known community)\n"
9325 "Do not export to next AS (well-known community)\n"
9326 "community number\n"
9327 "Do not send outside local AS (well-known community)\n"
9328 "Do not advertise to any peer (well-known community)\n"
9329 "Do not export to next AS (well-known community)\n"
9330 "community number\n"
9331 "Do not send outside local AS (well-known community)\n"
9332 "Do not advertise to any peer (well-known community)\n"
9333 "Do not export to next AS (well-known community)\n"
9334 "community number\n"
9335 "Do not send outside local AS (well-known community)\n"
9336 "Do not advertise to any peer (well-known community)\n"
9337 "Do not export to next AS (well-known community)\n")
9338
9339DEFUN (show_ip_bgp_community_exact,
9340 show_ip_bgp_community_exact_cmd,
9341 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9342 SHOW_STR
9343 IP_STR
9344 BGP_STR
9345 "Display routes matching the communities\n"
9346 "community number\n"
9347 "Do not send outside local AS (well-known community)\n"
9348 "Do not advertise to any peer (well-known community)\n"
9349 "Do not export to next AS (well-known community)\n"
9350 "Exact match of the communities")
9351{
9352 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9353}
9354
9355ALIAS (show_ip_bgp_community_exact,
9356 show_ip_bgp_community2_exact_cmd,
9357 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9358 SHOW_STR
9359 IP_STR
9360 BGP_STR
9361 "Display routes matching the communities\n"
9362 "community number\n"
9363 "Do not send outside local AS (well-known community)\n"
9364 "Do not advertise to any peer (well-known community)\n"
9365 "Do not export to next AS (well-known community)\n"
9366 "community number\n"
9367 "Do not send outside local AS (well-known community)\n"
9368 "Do not advertise to any peer (well-known community)\n"
9369 "Do not export to next AS (well-known community)\n"
9370 "Exact match of the communities")
9371
9372ALIAS (show_ip_bgp_community_exact,
9373 show_ip_bgp_community3_exact_cmd,
9374 "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",
9375 SHOW_STR
9376 IP_STR
9377 BGP_STR
9378 "Display routes matching the communities\n"
9379 "community number\n"
9380 "Do not send outside local AS (well-known community)\n"
9381 "Do not advertise to any peer (well-known community)\n"
9382 "Do not export to next AS (well-known community)\n"
9383 "community number\n"
9384 "Do not send outside local AS (well-known community)\n"
9385 "Do not advertise to any peer (well-known community)\n"
9386 "Do not export to next AS (well-known community)\n"
9387 "community number\n"
9388 "Do not send outside local AS (well-known community)\n"
9389 "Do not advertise to any peer (well-known community)\n"
9390 "Do not export to next AS (well-known community)\n"
9391 "Exact match of the communities")
9392
9393ALIAS (show_ip_bgp_community_exact,
9394 show_ip_bgp_community4_exact_cmd,
9395 "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",
9396 SHOW_STR
9397 IP_STR
9398 BGP_STR
9399 "Display routes matching the communities\n"
9400 "community number\n"
9401 "Do not send outside local AS (well-known community)\n"
9402 "Do not advertise to any peer (well-known community)\n"
9403 "Do not export to next AS (well-known community)\n"
9404 "community number\n"
9405 "Do not send outside local AS (well-known community)\n"
9406 "Do not advertise to any peer (well-known community)\n"
9407 "Do not export to next AS (well-known community)\n"
9408 "community number\n"
9409 "Do not send outside local AS (well-known community)\n"
9410 "Do not advertise to any peer (well-known community)\n"
9411 "Do not export to next AS (well-known community)\n"
9412 "community number\n"
9413 "Do not send outside local AS (well-known community)\n"
9414 "Do not advertise to any peer (well-known community)\n"
9415 "Do not export to next AS (well-known community)\n"
9416 "Exact match of the communities")
9417
9418DEFUN (show_ip_bgp_ipv4_community_exact,
9419 show_ip_bgp_ipv4_community_exact_cmd,
9420 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9421 SHOW_STR
9422 IP_STR
9423 BGP_STR
9424 "Address family\n"
9425 "Address Family modifier\n"
9426 "Address Family modifier\n"
9427 "Display routes matching the communities\n"
9428 "community number\n"
9429 "Do not send outside local AS (well-known community)\n"
9430 "Do not advertise to any peer (well-known community)\n"
9431 "Do not export to next AS (well-known community)\n"
9432 "Exact match of the communities")
9433{
9434 if (strncmp (argv[0], "m", 1) == 0)
9435 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9436
9437 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9438}
9439
9440ALIAS (show_ip_bgp_ipv4_community_exact,
9441 show_ip_bgp_ipv4_community2_exact_cmd,
9442 "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",
9443 SHOW_STR
9444 IP_STR
9445 BGP_STR
9446 "Address family\n"
9447 "Address Family modifier\n"
9448 "Address Family modifier\n"
9449 "Display routes matching the communities\n"
9450 "community number\n"
9451 "Do not send outside local AS (well-known community)\n"
9452 "Do not advertise to any peer (well-known community)\n"
9453 "Do not export to next AS (well-known community)\n"
9454 "community number\n"
9455 "Do not send outside local AS (well-known community)\n"
9456 "Do not advertise to any peer (well-known community)\n"
9457 "Do not export to next AS (well-known community)\n"
9458 "Exact match of the communities")
9459
9460ALIAS (show_ip_bgp_ipv4_community_exact,
9461 show_ip_bgp_ipv4_community3_exact_cmd,
9462 "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",
9463 SHOW_STR
9464 IP_STR
9465 BGP_STR
9466 "Address family\n"
9467 "Address Family modifier\n"
9468 "Address Family modifier\n"
9469 "Display routes matching the communities\n"
9470 "community number\n"
9471 "Do not send outside local AS (well-known community)\n"
9472 "Do not advertise to any peer (well-known community)\n"
9473 "Do not export to next AS (well-known community)\n"
9474 "community number\n"
9475 "Do not send outside local AS (well-known community)\n"
9476 "Do not advertise to any peer (well-known community)\n"
9477 "Do not export to next AS (well-known community)\n"
9478 "community number\n"
9479 "Do not send outside local AS (well-known community)\n"
9480 "Do not advertise to any peer (well-known community)\n"
9481 "Do not export to next AS (well-known community)\n"
9482 "Exact match of the communities")
9483
9484ALIAS (show_ip_bgp_ipv4_community_exact,
9485 show_ip_bgp_ipv4_community4_exact_cmd,
9486 "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",
9487 SHOW_STR
9488 IP_STR
9489 BGP_STR
9490 "Address family\n"
9491 "Address Family modifier\n"
9492 "Address Family modifier\n"
9493 "Display routes matching the communities\n"
9494 "community number\n"
9495 "Do not send outside local AS (well-known community)\n"
9496 "Do not advertise to any peer (well-known community)\n"
9497 "Do not export to next AS (well-known community)\n"
9498 "community number\n"
9499 "Do not send outside local AS (well-known community)\n"
9500 "Do not advertise to any peer (well-known community)\n"
9501 "Do not export to next AS (well-known community)\n"
9502 "community number\n"
9503 "Do not send outside local AS (well-known community)\n"
9504 "Do not advertise to any peer (well-known community)\n"
9505 "Do not export to next AS (well-known community)\n"
9506 "community number\n"
9507 "Do not send outside local AS (well-known community)\n"
9508 "Do not advertise to any peer (well-known community)\n"
9509 "Do not export to next AS (well-known community)\n"
9510 "Exact match of the communities")
9511
Lou Bergerf9b6c392016-01-12 13:42:09 -05009512DEFUN (show_bgp_community,
9513 show_bgp_community_cmd,
9514 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9515 SHOW_STR
9516 BGP_STR
9517 "Display routes matching the communities\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{
9523 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9524}
9525
9526ALIAS (show_bgp_community,
9527 show_bgp_ipv6_community_cmd,
9528 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9529 SHOW_STR
9530 BGP_STR
9531 "Address family\n"
9532 "Display routes matching the communities\n"
9533 "community number\n"
9534 "Do not send outside local AS (well-known community)\n"
9535 "Do not advertise to any peer (well-known community)\n"
9536 "Do not export to next AS (well-known community)\n")
9537
9538ALIAS (show_bgp_community,
9539 show_bgp_community2_cmd,
9540 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9541 SHOW_STR
9542 BGP_STR
9543 "Display routes matching the communities\n"
9544 "community number\n"
9545 "Do not send outside local AS (well-known community)\n"
9546 "Do not advertise to any peer (well-known community)\n"
9547 "Do not export to next AS (well-known community)\n"
9548 "community number\n"
9549 "Do not send outside local AS (well-known community)\n"
9550 "Do not advertise to any peer (well-known community)\n"
9551 "Do not export to next AS (well-known community)\n")
9552
9553ALIAS (show_bgp_community,
9554 show_bgp_ipv6_community2_cmd,
9555 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9556 SHOW_STR
9557 BGP_STR
9558 "Address family\n"
9559 "Display routes matching the communities\n"
9560 "community number\n"
9561 "Do not send outside local AS (well-known community)\n"
9562 "Do not advertise to any peer (well-known community)\n"
9563 "Do not export to next AS (well-known community)\n"
9564 "community number\n"
9565 "Do not send outside local AS (well-known community)\n"
9566 "Do not advertise to any peer (well-known community)\n"
9567 "Do not export to next AS (well-known community)\n")
9568
9569ALIAS (show_bgp_community,
9570 show_bgp_community3_cmd,
9571 "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)",
9572 SHOW_STR
9573 BGP_STR
9574 "Display routes matching the communities\n"
9575 "community number\n"
9576 "Do not send outside local AS (well-known community)\n"
9577 "Do not advertise to any peer (well-known community)\n"
9578 "Do not export to next AS (well-known community)\n"
9579 "community number\n"
9580 "Do not send outside local AS (well-known community)\n"
9581 "Do not advertise to any peer (well-known community)\n"
9582 "Do not export to next AS (well-known community)\n"
9583 "community number\n"
9584 "Do not send outside local AS (well-known community)\n"
9585 "Do not advertise to any peer (well-known community)\n"
9586 "Do not export to next AS (well-known community)\n")
9587
9588ALIAS (show_bgp_community,
9589 show_bgp_ipv6_community3_cmd,
9590 "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)",
9591 SHOW_STR
9592 BGP_STR
9593 "Address family\n"
9594 "Display routes matching the communities\n"
9595 "community number\n"
9596 "Do not send outside local AS (well-known community)\n"
9597 "Do not advertise to any peer (well-known community)\n"
9598 "Do not export to next AS (well-known community)\n"
9599 "community number\n"
9600 "Do not send outside local AS (well-known community)\n"
9601 "Do not advertise to any peer (well-known community)\n"
9602 "Do not export to next AS (well-known community)\n"
9603 "community number\n"
9604 "Do not send outside local AS (well-known community)\n"
9605 "Do not advertise to any peer (well-known community)\n"
9606 "Do not export to next AS (well-known community)\n")
9607
9608ALIAS (show_bgp_community,
9609 show_bgp_community4_cmd,
9610 "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)",
9611 SHOW_STR
9612 BGP_STR
9613 "Display routes matching the communities\n"
9614 "community number\n"
9615 "Do not send outside local AS (well-known community)\n"
9616 "Do not advertise to any peer (well-known community)\n"
9617 "Do not export to next AS (well-known community)\n"
9618 "community number\n"
9619 "Do not send outside local AS (well-known community)\n"
9620 "Do not advertise to any peer (well-known community)\n"
9621 "Do not export to next AS (well-known community)\n"
9622 "community number\n"
9623 "Do not send outside local AS (well-known community)\n"
9624 "Do not advertise to any peer (well-known community)\n"
9625 "Do not export to next AS (well-known community)\n"
9626 "community number\n"
9627 "Do not send outside local AS (well-known community)\n"
9628 "Do not advertise to any peer (well-known community)\n"
9629 "Do not export to next AS (well-known community)\n")
9630
9631ALIAS (show_bgp_community,
9632 show_bgp_ipv6_community4_cmd,
9633 "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)",
9634 SHOW_STR
9635 BGP_STR
9636 "Address family\n"
9637 "Display routes matching the communities\n"
9638 "community number\n"
9639 "Do not send outside local AS (well-known community)\n"
9640 "Do not advertise to any peer (well-known community)\n"
9641 "Do not export to next AS (well-known community)\n"
9642 "community number\n"
9643 "Do not send outside local AS (well-known community)\n"
9644 "Do not advertise to any peer (well-known community)\n"
9645 "Do not export to next AS (well-known community)\n"
9646 "community number\n"
9647 "Do not send outside local AS (well-known community)\n"
9648 "Do not advertise to any peer (well-known community)\n"
9649 "Do not export to next AS (well-known community)\n"
9650 "community number\n"
9651 "Do not send outside local AS (well-known community)\n"
9652 "Do not advertise to any peer (well-known community)\n"
9653 "Do not export to next AS (well-known community)\n")
9654
9655/* old command */
9656DEFUN (show_ipv6_bgp_community,
9657 show_ipv6_bgp_community_cmd,
9658 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9659 SHOW_STR
9660 IPV6_STR
9661 BGP_STR
9662 "Display routes matching the communities\n"
9663 "community number\n"
9664 "Do not send outside local AS (well-known community)\n"
9665 "Do not advertise to any peer (well-known community)\n"
9666 "Do not export to next AS (well-known community)\n")
9667{
9668 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9669}
9670
9671/* old command */
9672ALIAS (show_ipv6_bgp_community,
9673 show_ipv6_bgp_community2_cmd,
9674 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9675 SHOW_STR
9676 IPV6_STR
9677 BGP_STR
9678 "Display routes matching the communities\n"
9679 "community number\n"
9680 "Do not send outside local AS (well-known community)\n"
9681 "Do not advertise to any peer (well-known community)\n"
9682 "Do not export to next AS (well-known community)\n"
9683 "community number\n"
9684 "Do not send outside local AS (well-known community)\n"
9685 "Do not advertise to any peer (well-known community)\n"
9686 "Do not export to next AS (well-known community)\n")
9687
9688/* old command */
9689ALIAS (show_ipv6_bgp_community,
9690 show_ipv6_bgp_community3_cmd,
9691 "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)",
9692 SHOW_STR
9693 IPV6_STR
9694 BGP_STR
9695 "Display routes matching the communities\n"
9696 "community number\n"
9697 "Do not send outside local AS (well-known community)\n"
9698 "Do not advertise to any peer (well-known community)\n"
9699 "Do not export to next AS (well-known community)\n"
9700 "community number\n"
9701 "Do not send outside local AS (well-known community)\n"
9702 "Do not advertise to any peer (well-known community)\n"
9703 "Do not export to next AS (well-known community)\n"
9704 "community number\n"
9705 "Do not send outside local AS (well-known community)\n"
9706 "Do not advertise to any peer (well-known community)\n"
9707 "Do not export to next AS (well-known community)\n")
9708
9709/* old command */
9710ALIAS (show_ipv6_bgp_community,
9711 show_ipv6_bgp_community4_cmd,
9712 "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)",
9713 SHOW_STR
9714 IPV6_STR
9715 BGP_STR
9716 "Display routes matching the communities\n"
9717 "community number\n"
9718 "Do not send outside local AS (well-known community)\n"
9719 "Do not advertise to any peer (well-known community)\n"
9720 "Do not export to next AS (well-known community)\n"
9721 "community number\n"
9722 "Do not send outside local AS (well-known community)\n"
9723 "Do not advertise to any peer (well-known community)\n"
9724 "Do not export to next AS (well-known community)\n"
9725 "community number\n"
9726 "Do not send outside local AS (well-known community)\n"
9727 "Do not advertise to any peer (well-known community)\n"
9728 "Do not export to next AS (well-known community)\n"
9729 "community number\n"
9730 "Do not send outside local AS (well-known community)\n"
9731 "Do not advertise to any peer (well-known community)\n"
9732 "Do not export to next AS (well-known community)\n")
9733
9734DEFUN (show_bgp_community_exact,
9735 show_bgp_community_exact_cmd,
9736 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9737 SHOW_STR
9738 BGP_STR
9739 "Display routes matching the communities\n"
9740 "community number\n"
9741 "Do not send outside local AS (well-known community)\n"
9742 "Do not advertise to any peer (well-known community)\n"
9743 "Do not export to next AS (well-known community)\n"
9744 "Exact match of the communities")
9745{
9746 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9747}
9748
9749ALIAS (show_bgp_community_exact,
9750 show_bgp_ipv6_community_exact_cmd,
9751 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9752 SHOW_STR
9753 BGP_STR
9754 "Address family\n"
9755 "Display routes matching the communities\n"
9756 "community number\n"
9757 "Do not send outside local AS (well-known community)\n"
9758 "Do not advertise to any peer (well-known community)\n"
9759 "Do not export to next AS (well-known community)\n"
9760 "Exact match of the communities")
9761
9762ALIAS (show_bgp_community_exact,
9763 show_bgp_community2_exact_cmd,
9764 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9765 SHOW_STR
9766 BGP_STR
9767 "Display routes matching the communities\n"
9768 "community number\n"
9769 "Do not send outside local AS (well-known community)\n"
9770 "Do not advertise to any peer (well-known community)\n"
9771 "Do not export to next AS (well-known community)\n"
9772 "community number\n"
9773 "Do not send outside local AS (well-known community)\n"
9774 "Do not advertise to any peer (well-known community)\n"
9775 "Do not export to next AS (well-known community)\n"
9776 "Exact match of the communities")
9777
9778ALIAS (show_bgp_community_exact,
9779 show_bgp_ipv6_community2_exact_cmd,
9780 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9781 SHOW_STR
9782 BGP_STR
9783 "Address family\n"
9784 "Display routes matching the communities\n"
9785 "community number\n"
9786 "Do not send outside local AS (well-known community)\n"
9787 "Do not advertise to any peer (well-known community)\n"
9788 "Do not export to next AS (well-known community)\n"
9789 "community number\n"
9790 "Do not send outside local AS (well-known community)\n"
9791 "Do not advertise to any peer (well-known community)\n"
9792 "Do not export to next AS (well-known community)\n"
9793 "Exact match of the communities")
9794
9795ALIAS (show_bgp_community_exact,
9796 show_bgp_community3_exact_cmd,
9797 "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",
9798 SHOW_STR
9799 BGP_STR
9800 "Display routes matching the communities\n"
9801 "community number\n"
9802 "Do not send outside local AS (well-known community)\n"
9803 "Do not advertise to any peer (well-known community)\n"
9804 "Do not export to next AS (well-known community)\n"
9805 "community number\n"
9806 "Do not send outside local AS (well-known community)\n"
9807 "Do not advertise to any peer (well-known community)\n"
9808 "Do not export to next AS (well-known community)\n"
9809 "community number\n"
9810 "Do not send outside local AS (well-known community)\n"
9811 "Do not advertise to any peer (well-known community)\n"
9812 "Do not export to next AS (well-known community)\n"
9813 "Exact match of the communities")
9814
9815ALIAS (show_bgp_community_exact,
9816 show_bgp_ipv6_community3_exact_cmd,
9817 "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",
9818 SHOW_STR
9819 BGP_STR
9820 "Address family\n"
9821 "Display routes matching the communities\n"
9822 "community number\n"
9823 "Do not send outside local AS (well-known community)\n"
9824 "Do not advertise to any peer (well-known community)\n"
9825 "Do not export to next AS (well-known community)\n"
9826 "community number\n"
9827 "Do not send outside local AS (well-known community)\n"
9828 "Do not advertise to any peer (well-known community)\n"
9829 "Do not export to next AS (well-known community)\n"
9830 "community number\n"
9831 "Do not send outside local AS (well-known community)\n"
9832 "Do not advertise to any peer (well-known community)\n"
9833 "Do not export to next AS (well-known community)\n"
9834 "Exact match of the communities")
9835
9836ALIAS (show_bgp_community_exact,
9837 show_bgp_community4_exact_cmd,
9838 "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",
9839 SHOW_STR
9840 BGP_STR
9841 "Display routes matching the communities\n"
9842 "community number\n"
9843 "Do not send outside local AS (well-known community)\n"
9844 "Do not advertise to any peer (well-known community)\n"
9845 "Do not export to next AS (well-known community)\n"
9846 "community number\n"
9847 "Do not send outside local AS (well-known community)\n"
9848 "Do not advertise to any peer (well-known community)\n"
9849 "Do not export to next AS (well-known community)\n"
9850 "community number\n"
9851 "Do not send outside local AS (well-known community)\n"
9852 "Do not advertise to any peer (well-known community)\n"
9853 "Do not export to next AS (well-known community)\n"
9854 "community number\n"
9855 "Do not send outside local AS (well-known community)\n"
9856 "Do not advertise to any peer (well-known community)\n"
9857 "Do not export to next AS (well-known community)\n"
9858 "Exact match of the communities")
9859
9860ALIAS (show_bgp_community_exact,
9861 show_bgp_ipv6_community4_exact_cmd,
9862 "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",
9863 SHOW_STR
9864 BGP_STR
9865 "Address family\n"
9866 "Display routes matching the communities\n"
9867 "community number\n"
9868 "Do not send outside local AS (well-known community)\n"
9869 "Do not advertise to any peer (well-known community)\n"
9870 "Do not export to next AS (well-known community)\n"
9871 "community number\n"
9872 "Do not send outside local AS (well-known community)\n"
9873 "Do not advertise to any peer (well-known community)\n"
9874 "Do not export to next AS (well-known community)\n"
9875 "community number\n"
9876 "Do not send outside local AS (well-known community)\n"
9877 "Do not advertise to any peer (well-known community)\n"
9878 "Do not export to next AS (well-known community)\n"
9879 "community number\n"
9880 "Do not send outside local AS (well-known community)\n"
9881 "Do not advertise to any peer (well-known community)\n"
9882 "Do not export to next AS (well-known community)\n"
9883 "Exact match of the communities")
9884
9885/* old command */
9886DEFUN (show_ipv6_bgp_community_exact,
9887 show_ipv6_bgp_community_exact_cmd,
9888 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9889 SHOW_STR
9890 IPV6_STR
9891 BGP_STR
9892 "Display routes matching the communities\n"
9893 "community number\n"
9894 "Do not send outside local AS (well-known community)\n"
9895 "Do not advertise to any peer (well-known community)\n"
9896 "Do not export to next AS (well-known community)\n"
9897 "Exact match of the communities")
9898{
9899 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9900}
9901
9902/* old command */
9903ALIAS (show_ipv6_bgp_community_exact,
9904 show_ipv6_bgp_community2_exact_cmd,
9905 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9906 SHOW_STR
9907 IPV6_STR
9908 BGP_STR
9909 "Display routes matching the communities\n"
9910 "community number\n"
9911 "Do not send outside local AS (well-known community)\n"
9912 "Do not advertise to any peer (well-known community)\n"
9913 "Do not export to next AS (well-known community)\n"
9914 "community number\n"
9915 "Do not send outside local AS (well-known community)\n"
9916 "Do not advertise to any peer (well-known community)\n"
9917 "Do not export to next AS (well-known community)\n"
9918 "Exact match of the communities")
9919
9920/* old command */
9921ALIAS (show_ipv6_bgp_community_exact,
9922 show_ipv6_bgp_community3_exact_cmd,
9923 "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",
9924 SHOW_STR
9925 IPV6_STR
9926 BGP_STR
9927 "Display routes matching the communities\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 "community number\n"
9937 "Do not send outside local AS (well-known community)\n"
9938 "Do not advertise to any peer (well-known community)\n"
9939 "Do not export to next AS (well-known community)\n"
9940 "Exact match of the communities")
9941
9942/* old command */
9943ALIAS (show_ipv6_bgp_community_exact,
9944 show_ipv6_bgp_community4_exact_cmd,
9945 "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",
9946 SHOW_STR
9947 IPV6_STR
9948 BGP_STR
9949 "Display routes matching the communities\n"
9950 "community number\n"
9951 "Do not send outside local AS (well-known community)\n"
9952 "Do not advertise to any peer (well-known community)\n"
9953 "Do not export to next AS (well-known community)\n"
9954 "community number\n"
9955 "Do not send outside local AS (well-known community)\n"
9956 "Do not advertise to any peer (well-known community)\n"
9957 "Do not export to next AS (well-known community)\n"
9958 "community number\n"
9959 "Do not send outside local AS (well-known community)\n"
9960 "Do not advertise to any peer (well-known community)\n"
9961 "Do not export to next AS (well-known community)\n"
9962 "community number\n"
9963 "Do not send outside local AS (well-known community)\n"
9964 "Do not advertise to any peer (well-known community)\n"
9965 "Do not export to next AS (well-known community)\n"
9966 "Exact match of the communities")
9967
9968/* old command */
9969DEFUN (show_ipv6_mbgp_community,
9970 show_ipv6_mbgp_community_cmd,
9971 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
9972 SHOW_STR
9973 IPV6_STR
9974 MBGP_STR
9975 "Display routes matching the communities\n"
9976 "community number\n"
9977 "Do not send outside local AS (well-known community)\n"
9978 "Do not advertise to any peer (well-known community)\n"
9979 "Do not export to next AS (well-known community)\n")
9980{
9981 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
9982}
9983
9984/* old command */
9985ALIAS (show_ipv6_mbgp_community,
9986 show_ipv6_mbgp_community2_cmd,
9987 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9988 SHOW_STR
9989 IPV6_STR
9990 MBGP_STR
9991 "Display routes matching the communities\n"
9992 "community number\n"
9993 "Do not send outside local AS (well-known community)\n"
9994 "Do not advertise to any peer (well-known community)\n"
9995 "Do not export to next AS (well-known community)\n"
9996 "community number\n"
9997 "Do not send outside local AS (well-known community)\n"
9998 "Do not advertise to any peer (well-known community)\n"
9999 "Do not export to next AS (well-known community)\n")
10000
10001/* old command */
10002ALIAS (show_ipv6_mbgp_community,
10003 show_ipv6_mbgp_community3_cmd,
10004 "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)",
10005 SHOW_STR
10006 IPV6_STR
10007 MBGP_STR
10008 "Display routes matching the communities\n"
10009 "community number\n"
10010 "Do not send outside local AS (well-known community)\n"
10011 "Do not advertise to any peer (well-known community)\n"
10012 "Do not export to next AS (well-known community)\n"
10013 "community number\n"
10014 "Do not send outside local AS (well-known community)\n"
10015 "Do not advertise to any peer (well-known community)\n"
10016 "Do not export to next AS (well-known community)\n"
10017 "community number\n"
10018 "Do not send outside local AS (well-known community)\n"
10019 "Do not advertise to any peer (well-known community)\n"
10020 "Do not export to next AS (well-known community)\n")
10021
10022/* old command */
10023ALIAS (show_ipv6_mbgp_community,
10024 show_ipv6_mbgp_community4_cmd,
10025 "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)",
10026 SHOW_STR
10027 IPV6_STR
10028 MBGP_STR
10029 "Display routes matching the communities\n"
10030 "community number\n"
10031 "Do not send outside local AS (well-known community)\n"
10032 "Do not advertise to any peer (well-known community)\n"
10033 "Do not export to next AS (well-known community)\n"
10034 "community number\n"
10035 "Do not send outside local AS (well-known community)\n"
10036 "Do not advertise to any peer (well-known community)\n"
10037 "Do not export to next AS (well-known community)\n"
10038 "community number\n"
10039 "Do not send outside local AS (well-known community)\n"
10040 "Do not advertise to any peer (well-known community)\n"
10041 "Do not export to next AS (well-known community)\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
10047/* old command */
10048DEFUN (show_ipv6_mbgp_community_exact,
10049 show_ipv6_mbgp_community_exact_cmd,
10050 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10051 SHOW_STR
10052 IPV6_STR
10053 MBGP_STR
10054 "Display routes matching the communities\n"
10055 "community number\n"
10056 "Do not send outside local AS (well-known community)\n"
10057 "Do not advertise to any peer (well-known community)\n"
10058 "Do not export to next AS (well-known community)\n"
10059 "Exact match of the communities")
10060{
10061 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10062}
10063
10064/* old command */
10065ALIAS (show_ipv6_mbgp_community_exact,
10066 show_ipv6_mbgp_community2_exact_cmd,
10067 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10068 SHOW_STR
10069 IPV6_STR
10070 MBGP_STR
10071 "Display routes matching the communities\n"
10072 "community number\n"
10073 "Do not send outside local AS (well-known community)\n"
10074 "Do not advertise to any peer (well-known community)\n"
10075 "Do not export to next AS (well-known community)\n"
10076 "community number\n"
10077 "Do not send outside local AS (well-known community)\n"
10078 "Do not advertise to any peer (well-known community)\n"
10079 "Do not export to next AS (well-known community)\n"
10080 "Exact match of the communities")
10081
10082/* old command */
10083ALIAS (show_ipv6_mbgp_community_exact,
10084 show_ipv6_mbgp_community3_exact_cmd,
10085 "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",
10086 SHOW_STR
10087 IPV6_STR
10088 MBGP_STR
10089 "Display routes matching the communities\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 "community number\n"
10099 "Do not send outside local AS (well-known community)\n"
10100 "Do not advertise to any peer (well-known community)\n"
10101 "Do not export to next AS (well-known community)\n"
10102 "Exact match of the communities")
10103
10104/* old command */
10105ALIAS (show_ipv6_mbgp_community_exact,
10106 show_ipv6_mbgp_community4_exact_cmd,
10107 "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",
10108 SHOW_STR
10109 IPV6_STR
10110 MBGP_STR
10111 "Display routes matching the communities\n"
10112 "community number\n"
10113 "Do not send outside local AS (well-known community)\n"
10114 "Do not advertise to any peer (well-known community)\n"
10115 "Do not export to next AS (well-known community)\n"
10116 "community number\n"
10117 "Do not send outside local AS (well-known community)\n"
10118 "Do not advertise to any peer (well-known community)\n"
10119 "Do not export to next AS (well-known community)\n"
10120 "community number\n"
10121 "Do not send outside local AS (well-known community)\n"
10122 "Do not advertise to any peer (well-known community)\n"
10123 "Do not export to next AS (well-known community)\n"
10124 "community number\n"
10125 "Do not send outside local AS (well-known community)\n"
10126 "Do not advertise to any peer (well-known community)\n"
10127 "Do not export to next AS (well-known community)\n"
10128 "Exact match of the communities")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010129
Lou Berger651b4022016-01-12 13:42:07 -050010130DEFUN (show_bgp_ipv4_community,
10131 show_bgp_ipv4_community_cmd,
10132 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010133 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010134 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010135 IP_STR
paul718e3742002-12-13 20:15:29 +000010136 "Display routes matching the communities\n"
10137 "community number\n"
10138 "Do not send outside local AS (well-known community)\n"
10139 "Do not advertise to any peer (well-known community)\n"
10140 "Do not export to next AS (well-known community)\n")
10141{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010142 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010143}
10144
Lou Berger651b4022016-01-12 13:42:07 -050010145ALIAS (show_bgp_ipv4_community,
10146 show_bgp_ipv4_community2_cmd,
10147 "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 +000010148 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010149 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010150 IP_STR
paul718e3742002-12-13 20:15:29 +000010151 "Display routes matching the communities\n"
10152 "community number\n"
10153 "Do not send outside local AS (well-known community)\n"
10154 "Do not advertise to any peer (well-known community)\n"
10155 "Do not export to next AS (well-known community)\n"
10156 "community number\n"
10157 "Do not send outside local AS (well-known community)\n"
10158 "Do not advertise to any peer (well-known community)\n"
10159 "Do not export to next AS (well-known community)\n")
10160
Lou Berger651b4022016-01-12 13:42:07 -050010161ALIAS (show_bgp_ipv4_community,
10162 show_bgp_ipv4_community3_cmd,
10163 "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 +000010164 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010165 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010166 IP_STR
paul718e3742002-12-13 20:15:29 +000010167 "Display routes matching the communities\n"
10168 "community number\n"
10169 "Do not send outside local AS (well-known community)\n"
10170 "Do not advertise to any peer (well-known community)\n"
10171 "Do not export to next AS (well-known community)\n"
10172 "community number\n"
10173 "Do not send outside local AS (well-known community)\n"
10174 "Do not advertise to any peer (well-known community)\n"
10175 "Do not export to next AS (well-known community)\n"
10176 "community number\n"
10177 "Do not send outside local AS (well-known community)\n"
10178 "Do not advertise to any peer (well-known community)\n"
10179 "Do not export to next AS (well-known community)\n")
10180
Lou Berger651b4022016-01-12 13:42:07 -050010181ALIAS (show_bgp_ipv4_community,
10182 show_bgp_ipv4_community4_cmd,
10183 "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 +000010184 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010185 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010186 IP_STR
paul718e3742002-12-13 20:15:29 +000010187 "Display routes matching the communities\n"
10188 "community number\n"
10189 "Do not send outside local AS (well-known community)\n"
10190 "Do not advertise to any peer (well-known community)\n"
10191 "Do not export to next AS (well-known community)\n"
10192 "community number\n"
10193 "Do not send outside local AS (well-known community)\n"
10194 "Do not advertise to any peer (well-known community)\n"
10195 "Do not export to next AS (well-known community)\n"
10196 "community number\n"
10197 "Do not send outside local AS (well-known community)\n"
10198 "Do not advertise to any peer (well-known community)\n"
10199 "Do not export to next AS (well-known community)\n"
10200 "community number\n"
10201 "Do not send outside local AS (well-known community)\n"
10202 "Do not advertise to any peer (well-known community)\n"
10203 "Do not export to next AS (well-known community)\n")
10204
Lou Berger651b4022016-01-12 13:42:07 -050010205DEFUN (show_bgp_ipv4_safi_community,
10206 show_bgp_ipv4_safi_community_cmd,
10207 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010208 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010209 BGP_STR
10210 "Address family\n"
10211 "Address Family modifier\n"
10212 "Address Family modifier\n"
10213 "Display routes matching the communities\n"
10214 "community number\n"
10215 "Do not send outside local AS (well-known community)\n"
10216 "Do not advertise to any peer (well-known community)\n"
10217 "Do not export to next AS (well-known community)\n")
10218{
10219 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010220 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010221
Michael Lambert95cbbd22010-07-23 14:43:04 -040010222 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010223}
10224
Lou Berger651b4022016-01-12 13:42:07 -050010225ALIAS (show_bgp_ipv4_safi_community,
10226 show_bgp_ipv4_safi_community2_cmd,
10227 "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 +000010228 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010229 BGP_STR
10230 "Address family\n"
10231 "Address Family modifier\n"
10232 "Address Family modifier\n"
10233 "Display routes matching the communities\n"
10234 "community number\n"
10235 "Do not send outside local AS (well-known community)\n"
10236 "Do not advertise to any peer (well-known community)\n"
10237 "Do not export to next AS (well-known community)\n"
10238 "community number\n"
10239 "Do not send outside local AS (well-known community)\n"
10240 "Do not advertise to any peer (well-known community)\n"
10241 "Do not export to next AS (well-known community)\n")
10242
Lou Berger651b4022016-01-12 13:42:07 -050010243ALIAS (show_bgp_ipv4_safi_community,
10244 show_bgp_ipv4_safi_community3_cmd,
10245 "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 +000010246 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010247 BGP_STR
10248 "Address family\n"
10249 "Address Family modifier\n"
10250 "Address Family modifier\n"
10251 "Display routes matching the communities\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 "community number\n"
10261 "Do not send outside local AS (well-known community)\n"
10262 "Do not advertise to any peer (well-known community)\n"
10263 "Do not export to next AS (well-known community)\n")
10264
Lou Berger651b4022016-01-12 13:42:07 -050010265ALIAS (show_bgp_ipv4_safi_community,
10266 show_bgp_ipv4_safi_community4_cmd,
10267 "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 +000010268 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010269 BGP_STR
10270 "Address family\n"
10271 "Address Family modifier\n"
10272 "Address Family modifier\n"
10273 "Display routes matching the communities\n"
10274 "community number\n"
10275 "Do not send outside local AS (well-known community)\n"
10276 "Do not advertise to any peer (well-known community)\n"
10277 "Do not export to next AS (well-known community)\n"
10278 "community number\n"
10279 "Do not send outside local AS (well-known community)\n"
10280 "Do not advertise to any peer (well-known community)\n"
10281 "Do not export to next AS (well-known community)\n"
10282 "community number\n"
10283 "Do not send outside local AS (well-known community)\n"
10284 "Do not advertise to any peer (well-known community)\n"
10285 "Do not export to next AS (well-known community)\n"
10286 "community number\n"
10287 "Do not send outside local AS (well-known community)\n"
10288 "Do not advertise to any peer (well-known community)\n"
10289 "Do not export to next AS (well-known community)\n")
10290
Michael Lambert95cbbd22010-07-23 14:43:04 -040010291DEFUN (show_bgp_view_afi_safi_community_all,
10292 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010293 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
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"
Christian Franke2b005152013-09-30 12:27:49 +000010302 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010303{
10304 int afi;
10305 int safi;
10306 struct bgp *bgp;
10307
10308 /* BGP structure lookup. */
10309 bgp = bgp_lookup_by_name (argv[0]);
10310 if (bgp == NULL)
10311 {
10312 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10313 return CMD_WARNING;
10314 }
10315
Michael Lambert95cbbd22010-07-23 14:43:04 -040010316 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10317 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010318 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10319}
10320
10321DEFUN (show_bgp_view_afi_safi_community,
10322 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010323 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010324 SHOW_STR
10325 BGP_STR
10326 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010327 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010328 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010329 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010330 "Address family modifier\n"
10331 "Address family modifier\n"
10332 "Display routes matching the communities\n"
10333 "community number\n"
10334 "Do not send outside local AS (well-known community)\n"
10335 "Do not advertise to any peer (well-known community)\n"
10336 "Do not export to next AS (well-known community)\n")
10337{
10338 int afi;
10339 int safi;
10340
Michael Lambert95cbbd22010-07-23 14:43:04 -040010341 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10342 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10343 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010344}
10345
10346ALIAS (show_bgp_view_afi_safi_community,
10347 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010348 "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 -040010349 SHOW_STR
10350 BGP_STR
10351 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010352 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010353 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010354 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010355 "Address family modifier\n"
10356 "Address family modifier\n"
10357 "Display routes matching the communities\n"
10358 "community number\n"
10359 "Do not send outside local AS (well-known community)\n"
10360 "Do not advertise to any peer (well-known community)\n"
10361 "Do not export to next AS (well-known community)\n"
10362 "community number\n"
10363 "Do not send outside local AS (well-known community)\n"
10364 "Do not advertise to any peer (well-known community)\n"
10365 "Do not export to next AS (well-known community)\n")
10366
10367ALIAS (show_bgp_view_afi_safi_community,
10368 show_bgp_view_afi_safi_community3_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010369 "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 -040010370 SHOW_STR
10371 BGP_STR
10372 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010373 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010374 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010375 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010376 "Address family modifier\n"
10377 "Address family modifier\n"
10378 "Display routes matching the communities\n"
10379 "community number\n"
10380 "Do not send outside local AS (well-known community)\n"
10381 "Do not advertise to any peer (well-known community)\n"
10382 "Do not export to next AS (well-known community)\n"
10383 "community number\n"
10384 "Do not send outside local AS (well-known community)\n"
10385 "Do not advertise to any peer (well-known community)\n"
10386 "Do not export to next AS (well-known community)\n"
10387 "community number\n"
10388 "Do not send outside local AS (well-known community)\n"
10389 "Do not advertise to any peer (well-known community)\n"
10390 "Do not export to next AS (well-known community)\n")
10391
10392ALIAS (show_bgp_view_afi_safi_community,
10393 show_bgp_view_afi_safi_community4_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010394 "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 -040010395 SHOW_STR
10396 BGP_STR
10397 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010398 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010399 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010400 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010401 "Address family modifier\n"
10402 "Address family modifier\n"
10403 "Display routes matching the communities\n"
10404 "community number\n"
10405 "Do not send outside local AS (well-known community)\n"
10406 "Do not advertise to any peer (well-known community)\n"
10407 "Do not export to next AS (well-known community)\n"
10408 "community number\n"
10409 "Do not send outside local AS (well-known community)\n"
10410 "Do not advertise to any peer (well-known community)\n"
10411 "Do not export to next AS (well-known community)\n"
10412 "community number\n"
10413 "Do not send outside local AS (well-known community)\n"
10414 "Do not advertise to any peer (well-known community)\n"
10415 "Do not export to next AS (well-known community)\n"
10416 "community number\n"
10417 "Do not send outside local AS (well-known community)\n"
10418 "Do not advertise to any peer (well-known community)\n"
10419 "Do not export to next AS (well-known community)\n")
10420
Lou Berger651b4022016-01-12 13:42:07 -050010421DEFUN (show_bgp_ipv4_community_exact,
10422 show_bgp_ipv4_community_exact_cmd,
10423 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010424 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010425 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010426 IP_STR
paul718e3742002-12-13 20:15:29 +000010427 "Display routes matching the communities\n"
10428 "community number\n"
10429 "Do not send outside local AS (well-known community)\n"
10430 "Do not advertise to any peer (well-known community)\n"
10431 "Do not export to next AS (well-known community)\n"
10432 "Exact match of the communities")
10433{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010434 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010435}
10436
Lou Berger651b4022016-01-12 13:42:07 -050010437ALIAS (show_bgp_ipv4_community_exact,
10438 show_bgp_ipv4_community2_exact_cmd,
10439 "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 +000010440 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010441 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010442 IP_STR
paul718e3742002-12-13 20:15:29 +000010443 "Display routes matching the communities\n"
10444 "community number\n"
10445 "Do not send outside local AS (well-known community)\n"
10446 "Do not advertise to any peer (well-known community)\n"
10447 "Do not export to next AS (well-known community)\n"
10448 "community number\n"
10449 "Do not send outside local AS (well-known community)\n"
10450 "Do not advertise to any peer (well-known community)\n"
10451 "Do not export to next AS (well-known community)\n"
10452 "Exact match of the communities")
10453
Lou Berger651b4022016-01-12 13:42:07 -050010454ALIAS (show_bgp_ipv4_community_exact,
10455 show_bgp_ipv4_community3_exact_cmd,
10456 "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 +000010457 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010458 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010459 IP_STR
paul718e3742002-12-13 20:15:29 +000010460 "Display routes matching the communities\n"
10461 "community number\n"
10462 "Do not send outside local AS (well-known community)\n"
10463 "Do not advertise to any peer (well-known community)\n"
10464 "Do not export to next AS (well-known community)\n"
10465 "community number\n"
10466 "Do not send outside local AS (well-known community)\n"
10467 "Do not advertise to any peer (well-known community)\n"
10468 "Do not export to next AS (well-known community)\n"
10469 "community number\n"
10470 "Do not send outside local AS (well-known community)\n"
10471 "Do not advertise to any peer (well-known community)\n"
10472 "Do not export to next AS (well-known community)\n"
10473 "Exact match of the communities")
10474
Lou Berger651b4022016-01-12 13:42:07 -050010475ALIAS (show_bgp_ipv4_community_exact,
10476 show_bgp_ipv4_community4_exact_cmd,
10477 "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 +000010478 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010479 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010480 IP_STR
paul718e3742002-12-13 20:15:29 +000010481 "Display routes matching the communities\n"
10482 "community number\n"
10483 "Do not send outside local AS (well-known community)\n"
10484 "Do not advertise to any peer (well-known community)\n"
10485 "Do not export to next AS (well-known community)\n"
10486 "community number\n"
10487 "Do not send outside local AS (well-known community)\n"
10488 "Do not advertise to any peer (well-known community)\n"
10489 "Do not export to next AS (well-known community)\n"
10490 "community number\n"
10491 "Do not send outside local AS (well-known community)\n"
10492 "Do not advertise to any peer (well-known community)\n"
10493 "Do not export to next AS (well-known community)\n"
10494 "community number\n"
10495 "Do not send outside local AS (well-known community)\n"
10496 "Do not advertise to any peer (well-known community)\n"
10497 "Do not export to next AS (well-known community)\n"
10498 "Exact match of the communities")
10499
Lou Berger651b4022016-01-12 13:42:07 -050010500DEFUN (show_bgp_ipv4_safi_community4_exact,
10501 show_bgp_ipv4_safi_community_exact_cmd,
10502 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010503 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010504 BGP_STR
10505 "Address family\n"
10506 "Address Family modifier\n"
10507 "Address Family modifier\n"
10508 "Display routes matching the communities\n"
10509 "community number\n"
10510 "Do not send outside local AS (well-known community)\n"
10511 "Do not advertise to any peer (well-known community)\n"
10512 "Do not export to next AS (well-known community)\n"
10513 "Exact match of the communities")
10514{
10515 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010516 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010517
Michael Lambert95cbbd22010-07-23 14:43:04 -040010518 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010519}
10520
Lou Berger651b4022016-01-12 13:42:07 -050010521ALIAS (show_bgp_ipv4_safi_community4_exact,
10522 show_bgp_ipv4_safi_community2_exact_cmd,
10523 "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 +000010524 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010525 BGP_STR
10526 "Address family\n"
10527 "Address Family modifier\n"
10528 "Address Family modifier\n"
10529 "Display routes matching the communities\n"
10530 "community number\n"
10531 "Do not send outside local AS (well-known community)\n"
10532 "Do not advertise to any peer (well-known community)\n"
10533 "Do not export to next AS (well-known community)\n"
10534 "community number\n"
10535 "Do not send outside local AS (well-known community)\n"
10536 "Do not advertise to any peer (well-known community)\n"
10537 "Do not export to next AS (well-known community)\n"
10538 "Exact match of the communities")
10539
Lou Berger651b4022016-01-12 13:42:07 -050010540ALIAS (show_bgp_ipv4_safi_community4_exact,
10541 show_bgp_ipv4_safi_community3_exact_cmd,
10542 "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 +000010543 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010544 BGP_STR
10545 "Address family\n"
10546 "Address Family modifier\n"
10547 "Address Family modifier\n"
10548 "Display routes matching the communities\n"
10549 "community number\n"
10550 "Do not send outside local AS (well-known community)\n"
10551 "Do not advertise to any peer (well-known community)\n"
10552 "Do not export to next AS (well-known community)\n"
10553 "community number\n"
10554 "Do not send outside local AS (well-known community)\n"
10555 "Do not advertise to any peer (well-known community)\n"
10556 "Do not export to next AS (well-known community)\n"
10557 "community number\n"
10558 "Do not send outside local AS (well-known community)\n"
10559 "Do not advertise to any peer (well-known community)\n"
10560 "Do not export to next AS (well-known community)\n"
10561 "Exact match of the communities")
10562
Lou Berger651b4022016-01-12 13:42:07 -050010563ALIAS (show_bgp_ipv4_safi_community4_exact,
10564 show_bgp_ipv4_safi_community4_exact_cmd,
10565 "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 +000010566 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010567 BGP_STR
10568 "Address family\n"
10569 "Address Family modifier\n"
10570 "Address Family modifier\n"
10571 "Display routes matching the communities\n"
10572 "community number\n"
10573 "Do not send outside local AS (well-known community)\n"
10574 "Do not advertise to any peer (well-known community)\n"
10575 "Do not export to next AS (well-known community)\n"
10576 "community number\n"
10577 "Do not send outside local AS (well-known community)\n"
10578 "Do not advertise to any peer (well-known community)\n"
10579 "Do not export to next AS (well-known community)\n"
10580 "community number\n"
10581 "Do not send outside local AS (well-known community)\n"
10582 "Do not advertise to any peer (well-known community)\n"
10583 "Do not export to next AS (well-known community)\n"
10584 "community number\n"
10585 "Do not send outside local AS (well-known community)\n"
10586 "Do not advertise to any peer (well-known community)\n"
10587 "Do not export to next AS (well-known community)\n"
10588 "Exact match of the communities")
10589
Lou Bergerf9b6c392016-01-12 13:42:09 -050010590DEFUN (show_bgp_ipv6_safi_community,
10591 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010592 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010593 SHOW_STR
10594 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010595 "Address family\n"
10596 "Address family modifier\n"
10597 "Address family modifier\n"
10598 "Address family modifier\n"
10599 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010600 "Display routes matching the communities\n"
10601 "community number\n"
10602 "Do not send outside local AS (well-known community)\n"
10603 "Do not advertise to any peer (well-known community)\n"
10604 "Do not export to next AS (well-known community)\n")
10605{
Lou Berger651b4022016-01-12 13:42:07 -050010606 safi_t safi;
10607
10608 if (bgp_parse_safi(argv[0], &safi)) {
10609 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10610 return CMD_WARNING;
10611 }
10612 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010613}
10614
Lou Bergerf9b6c392016-01-12 13:42:09 -050010615ALIAS (show_bgp_ipv6_safi_community,
10616 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010617 "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 +000010618 SHOW_STR
10619 BGP_STR
10620 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010621 "Address family modifier\n"
10622 "Address family modifier\n"
10623 "Address family modifier\n"
10624 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010625 "Display routes matching the communities\n"
10626 "community number\n"
10627 "Do not send outside local AS (well-known community)\n"
10628 "Do not advertise to any peer (well-known community)\n"
10629 "Do not export to next AS (well-known community)\n"
10630 "community number\n"
10631 "Do not send outside local AS (well-known community)\n"
10632 "Do not advertise to any peer (well-known community)\n"
10633 "Do not export to next AS (well-known community)\n")
10634
Lou Bergerf9b6c392016-01-12 13:42:09 -050010635ALIAS (show_bgp_ipv6_safi_community,
10636 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010637 "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 +000010638 SHOW_STR
10639 BGP_STR
10640 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010641 "Address family modifier\n"
10642 "Address family modifier\n"
10643 "Address family modifier\n"
10644 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010645 "Display routes matching the communities\n"
10646 "community number\n"
10647 "Do not send outside local AS (well-known community)\n"
10648 "Do not advertise to any peer (well-known community)\n"
10649 "Do not export to next AS (well-known community)\n"
10650 "community number\n"
10651 "Do not send outside local AS (well-known community)\n"
10652 "Do not advertise to any peer (well-known community)\n"
10653 "Do not export to next AS (well-known community)\n"
10654 "community number\n"
10655 "Do not send outside local AS (well-known community)\n"
10656 "Do not advertise to any peer (well-known community)\n"
10657 "Do not export to next AS (well-known community)\n")
10658
Lou Bergerf9b6c392016-01-12 13:42:09 -050010659ALIAS (show_bgp_ipv6_safi_community,
10660 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010661 "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 +000010662 SHOW_STR
10663 BGP_STR
10664 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010665 "Address family modifier\n"
10666 "Address family modifier\n"
10667 "Address family modifier\n"
10668 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010669 "Display routes matching the communities\n"
10670 "community number\n"
10671 "Do not send outside local AS (well-known community)\n"
10672 "Do not advertise to any peer (well-known community)\n"
10673 "Do not export to next AS (well-known community)\n"
10674 "community number\n"
10675 "Do not send outside local AS (well-known community)\n"
10676 "Do not advertise to any peer (well-known community)\n"
10677 "Do not export to next AS (well-known community)\n"
10678 "community number\n"
10679 "Do not send outside local AS (well-known community)\n"
10680 "Do not advertise to any peer (well-known community)\n"
10681 "Do not export to next AS (well-known community)\n"
10682 "community number\n"
10683 "Do not send outside local AS (well-known community)\n"
10684 "Do not advertise to any peer (well-known community)\n"
10685 "Do not export to next AS (well-known community)\n")
10686
paul718e3742002-12-13 20:15:29 +000010687
Lou Bergerf9b6c392016-01-12 13:42:09 -050010688DEFUN (show_bgp_ipv6_safi_community_exact,
10689 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010690 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010691 SHOW_STR
10692 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010693 "Address family\n"
10694 "Address family modifier\n"
10695 "Address family modifier\n"
10696 "Address family modifier\n"
10697 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010698 "Display routes matching the communities\n"
10699 "community number\n"
10700 "Do not send outside local AS (well-known community)\n"
10701 "Do not advertise to any peer (well-known community)\n"
10702 "Do not export to next AS (well-known community)\n"
10703 "Exact match of the communities")
10704{
Lou Berger651b4022016-01-12 13:42:07 -050010705 safi_t safi;
10706
10707 if (bgp_parse_safi(argv[0], &safi)) {
10708 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10709 return CMD_WARNING;
10710 }
10711 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010712}
10713
paul718e3742002-12-13 20:15:29 +000010714
10715ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010716 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010717 "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 +000010718 SHOW_STR
10719 BGP_STR
10720 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010721 "Address family modifier\n"
10722 "Address family modifier\n"
10723 "Address family modifier\n"
10724 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010725 "Display routes matching the communities\n"
10726 "community number\n"
10727 "Do not send outside local AS (well-known community)\n"
10728 "Do not advertise to any peer (well-known community)\n"
10729 "Do not export to next AS (well-known community)\n"
10730 "community number\n"
10731 "Do not send outside local AS (well-known community)\n"
10732 "Do not advertise to any peer (well-known community)\n"
10733 "Do not export to next AS (well-known community)\n"
10734 "Exact match of the communities")
10735
10736ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010737 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010738 "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 +000010739 SHOW_STR
10740 BGP_STR
10741 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010742 "Address family modifier\n"
10743 "Address family modifier\n"
10744 "Address family modifier\n"
10745 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010746 "Display routes matching the communities\n"
10747 "community number\n"
10748 "Do not send outside local AS (well-known community)\n"
10749 "Do not advertise to any peer (well-known community)\n"
10750 "Do not export to next AS (well-known community)\n"
10751 "community number\n"
10752 "Do not send outside local AS (well-known community)\n"
10753 "Do not advertise to any peer (well-known community)\n"
10754 "Do not export to next AS (well-known community)\n"
10755 "community number\n"
10756 "Do not send outside local AS (well-known community)\n"
10757 "Do not advertise to any peer (well-known community)\n"
10758 "Do not export to next AS (well-known community)\n"
10759 "Exact match of the communities")
10760
10761ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010762 show_bgp_ipv6_safi_community4_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010763 "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 +000010764 SHOW_STR
10765 BGP_STR
10766 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010767 "Address family modifier\n"
10768 "Address family modifier\n"
10769 "Address family modifier\n"
10770 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010771 "Display routes matching the communities\n"
10772 "community number\n"
10773 "Do not send outside local AS (well-known community)\n"
10774 "Do not advertise to any peer (well-known community)\n"
10775 "Do not export to next AS (well-known community)\n"
10776 "community number\n"
10777 "Do not send outside local AS (well-known community)\n"
10778 "Do not advertise to any peer (well-known community)\n"
10779 "Do not export to next AS (well-known community)\n"
10780 "community number\n"
10781 "Do not send outside local AS (well-known community)\n"
10782 "Do not advertise to any peer (well-known community)\n"
10783 "Do not export to next AS (well-known community)\n"
10784 "community number\n"
10785 "Do not send outside local AS (well-known community)\n"
10786 "Do not advertise to any peer (well-known community)\n"
10787 "Do not export to next AS (well-known community)\n"
10788 "Exact match of the communities")
10789
paul94f2b392005-06-28 12:44:16 +000010790static int
paulfd79ac92004-10-13 05:06:08 +000010791bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040010792 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000010793{
10794 struct community_list *list;
10795
hassofee6e4e2005-02-02 16:29:31 +000010796 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010797 if (list == NULL)
10798 {
10799 vty_out (vty, "%% %s is not a valid community-list name%s", com,
10800 VTY_NEWLINE);
10801 return CMD_WARNING;
10802 }
10803
ajs5a646652004-11-05 01:25:55 +000010804 return bgp_show (vty, NULL, afi, safi,
10805 (exact ? bgp_show_type_community_list_exact :
10806 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000010807}
10808
Lou Bergerf9b6c392016-01-12 13:42:09 -050010809DEFUN (show_ip_bgp_community_list,
10810 show_ip_bgp_community_list_cmd,
10811 "show ip bgp community-list (<1-500>|WORD)",
10812 SHOW_STR
10813 IP_STR
10814 BGP_STR
10815 "Display routes matching the community-list\n"
10816 "community-list number\n"
10817 "community-list name\n")
10818{
10819 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
10820}
10821
10822DEFUN (show_ip_bgp_ipv4_community_list,
10823 show_ip_bgp_ipv4_community_list_cmd,
10824 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10825 SHOW_STR
10826 IP_STR
10827 BGP_STR
10828 "Address family\n"
10829 "Address Family modifier\n"
10830 "Address Family modifier\n"
10831 "Display routes matching the community-list\n"
10832 "community-list number\n"
10833 "community-list name\n")
10834{
10835 if (strncmp (argv[0], "m", 1) == 0)
10836 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
10837
10838 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
10839}
10840
10841DEFUN (show_ip_bgp_community_list_exact,
10842 show_ip_bgp_community_list_exact_cmd,
10843 "show ip bgp community-list (<1-500>|WORD) exact-match",
10844 SHOW_STR
10845 IP_STR
10846 BGP_STR
10847 "Display routes matching the community-list\n"
10848 "community-list number\n"
10849 "community-list name\n"
10850 "Exact match of the communities\n")
10851{
10852 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
10853}
10854
10855DEFUN (show_ip_bgp_ipv4_community_list_exact,
10856 show_ip_bgp_ipv4_community_list_exact_cmd,
10857 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10858 SHOW_STR
10859 IP_STR
10860 BGP_STR
10861 "Address family\n"
10862 "Address Family modifier\n"
10863 "Address Family modifier\n"
10864 "Display routes matching the community-list\n"
10865 "community-list number\n"
10866 "community-list name\n"
10867 "Exact match of the communities\n")
10868{
10869 if (strncmp (argv[0], "m", 1) == 0)
10870 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
10871
10872 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
10873}
10874
Lou Bergerf9b6c392016-01-12 13:42:09 -050010875DEFUN (show_bgp_community_list,
10876 show_bgp_community_list_cmd,
10877 "show bgp community-list (<1-500>|WORD)",
10878 SHOW_STR
10879 BGP_STR
10880 "Display routes matching the community-list\n"
10881 "community-list number\n"
10882 "community-list name\n")
10883{
10884 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10885}
10886
10887ALIAS (show_bgp_community_list,
10888 show_bgp_ipv6_community_list_cmd,
10889 "show bgp ipv6 community-list (<1-500>|WORD)",
10890 SHOW_STR
10891 BGP_STR
10892 "Address family\n"
10893 "Display routes matching the community-list\n"
10894 "community-list number\n"
10895 "community-list name\n")
10896
10897/* old command */
10898DEFUN (show_ipv6_bgp_community_list,
10899 show_ipv6_bgp_community_list_cmd,
10900 "show ipv6 bgp community-list WORD",
10901 SHOW_STR
10902 IPV6_STR
10903 BGP_STR
10904 "Display routes matching the community-list\n"
10905 "community-list name\n")
10906{
10907 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10908}
10909
10910/* old command */
10911DEFUN (show_ipv6_mbgp_community_list,
10912 show_ipv6_mbgp_community_list_cmd,
10913 "show ipv6 mbgp community-list WORD",
10914 SHOW_STR
10915 IPV6_STR
10916 MBGP_STR
10917 "Display routes matching the community-list\n"
10918 "community-list name\n")
10919{
10920 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
10921}
10922
10923DEFUN (show_bgp_community_list_exact,
10924 show_bgp_community_list_exact_cmd,
10925 "show bgp community-list (<1-500>|WORD) exact-match",
10926 SHOW_STR
10927 BGP_STR
10928 "Display routes matching the community-list\n"
10929 "community-list number\n"
10930 "community-list name\n"
10931 "Exact match of the communities\n")
10932{
10933 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10934}
10935
10936ALIAS (show_bgp_community_list_exact,
10937 show_bgp_ipv6_community_list_exact_cmd,
10938 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10939 SHOW_STR
10940 BGP_STR
10941 "Address family\n"
10942 "Display routes matching the community-list\n"
10943 "community-list number\n"
10944 "community-list name\n"
10945 "Exact match of the communities\n")
10946
10947/* old command */
10948DEFUN (show_ipv6_bgp_community_list_exact,
10949 show_ipv6_bgp_community_list_exact_cmd,
10950 "show ipv6 bgp community-list WORD exact-match",
10951 SHOW_STR
10952 IPV6_STR
10953 BGP_STR
10954 "Display routes matching the community-list\n"
10955 "community-list name\n"
10956 "Exact match of the communities\n")
10957{
10958 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10959}
10960
10961/* old command */
10962DEFUN (show_ipv6_mbgp_community_list_exact,
10963 show_ipv6_mbgp_community_list_exact_cmd,
10964 "show ipv6 mbgp community-list WORD exact-match",
10965 SHOW_STR
10966 IPV6_STR
10967 MBGP_STR
10968 "Display routes matching the community-list\n"
10969 "community-list name\n"
10970 "Exact match of the communities\n")
10971{
10972 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
10973}
Lou Bergerf9b6c392016-01-12 13:42:09 -050010974
Lou Berger651b4022016-01-12 13:42:07 -050010975DEFUN (show_bgp_ipv4_community_list,
10976 show_bgp_ipv4_community_list_cmd,
10977 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010978 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010979 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010980 IP_STR
paul718e3742002-12-13 20:15:29 +000010981 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010982 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010983 "community-list name\n")
10984{
10985 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
10986}
10987
Lou Berger651b4022016-01-12 13:42:07 -050010988DEFUN (show_bgp_ipv4_safi_community_list,
10989 show_bgp_ipv4_safi_community_list_cmd,
10990 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010991 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010992 BGP_STR
10993 "Address family\n"
10994 "Address Family modifier\n"
10995 "Address Family modifier\n"
10996 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010997 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010998 "community-list name\n")
10999{
11000 if (strncmp (argv[0], "m", 1) == 0)
11001 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11002
11003 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11004}
11005
Lou Berger651b4022016-01-12 13:42:07 -050011006DEFUN (show_bgp_ipv4_community_list_exact,
11007 show_bgp_ipv4_community_list_exact_cmd,
11008 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011009 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011010 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011011 IP_STR
paul718e3742002-12-13 20:15:29 +000011012 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011013 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011014 "community-list name\n"
11015 "Exact match of the communities\n")
11016{
11017 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11018}
11019
Lou Berger651b4022016-01-12 13:42:07 -050011020DEFUN (show_bgp_ipv4_safi_community_list_exact,
11021 show_bgp_ipv4_safi_community_list_exact_cmd,
11022 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011023 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011024 BGP_STR
11025 "Address family\n"
11026 "Address Family modifier\n"
11027 "Address Family modifier\n"
11028 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011029 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011030 "community-list name\n"
11031 "Exact match of the communities\n")
11032{
11033 if (strncmp (argv[0], "m", 1) == 0)
11034 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11035
11036 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11037}
11038
Lou Bergerf9b6c392016-01-12 13:42:09 -050011039DEFUN (show_bgp_ipv6_safi_community_list,
11040 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011041 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011042 SHOW_STR
11043 BGP_STR
11044 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011045 "Address family modifier\n"
11046 "Address family modifier\n"
11047 "Address family modifier\n"
11048 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011049 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011050 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011051 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011052{
Lou Berger651b4022016-01-12 13:42:07 -050011053 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011054
Lou Berger651b4022016-01-12 13:42:07 -050011055 if (bgp_parse_safi(argv[0], &safi)) {
11056 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11057 return CMD_WARNING;
11058 }
11059 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011060}
11061
Lou Bergerf9b6c392016-01-12 13:42:09 -050011062DEFUN (show_bgp_ipv6_safi_community_list_exact,
11063 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011064 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011065 SHOW_STR
11066 BGP_STR
11067 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011068 "Address family modifier\n"
11069 "Address family modifier\n"
11070 "Address family modifier\n"
11071 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011072 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011073 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011074 "community-list name\n"
11075 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011076{
Lou Berger651b4022016-01-12 13:42:07 -050011077 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011078
Lou Berger651b4022016-01-12 13:42:07 -050011079 if (bgp_parse_safi(argv[0], &safi)) {
11080 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11081 return CMD_WARNING;
11082 }
11083 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011084}
David Lamparter6b0655a2014-06-04 06:53:35 +020011085
paul94f2b392005-06-28 12:44:16 +000011086static int
paulfd79ac92004-10-13 05:06:08 +000011087bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000011088 safi_t safi, enum bgp_show_type type)
11089{
11090 int ret;
11091 struct prefix *p;
11092
11093 p = prefix_new();
11094
11095 ret = str2prefix (prefix, p);
11096 if (! ret)
11097 {
11098 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
11099 return CMD_WARNING;
11100 }
11101
ajs5a646652004-11-05 01:25:55 +000011102 ret = bgp_show (vty, NULL, afi, safi, type, p);
11103 prefix_free(p);
11104 return ret;
paul718e3742002-12-13 20:15:29 +000011105}
11106
Lou Bergerf9b6c392016-01-12 13:42:09 -050011107DEFUN (show_ip_bgp_prefix_longer,
11108 show_ip_bgp_prefix_longer_cmd,
11109 "show ip bgp A.B.C.D/M longer-prefixes",
11110 SHOW_STR
11111 IP_STR
11112 BGP_STR
11113 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11114 "Display route and more specific routes\n")
11115{
11116 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11117 bgp_show_type_prefix_longer);
11118}
11119
11120DEFUN (show_ip_bgp_flap_prefix_longer,
11121 show_ip_bgp_flap_prefix_longer_cmd,
11122 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11123 SHOW_STR
11124 IP_STR
11125 BGP_STR
11126 "Display flap statistics of routes\n"
11127 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11128 "Display route and more specific routes\n")
11129{
11130 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11131 bgp_show_type_flap_prefix_longer);
11132}
11133
11134ALIAS (show_ip_bgp_flap_prefix_longer,
11135 show_ip_bgp_damp_flap_prefix_longer_cmd,
11136 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11137 SHOW_STR
11138 IP_STR
11139 BGP_STR
11140 "Display detailed information about dampening\n"
11141 "Display flap statistics of routes\n"
11142 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11143 "Display route and more specific routes\n")
11144
11145DEFUN (show_ip_bgp_ipv4_prefix_longer,
11146 show_ip_bgp_ipv4_prefix_longer_cmd,
11147 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11148 SHOW_STR
11149 IP_STR
11150 BGP_STR
11151 "Address family\n"
11152 "Address Family modifier\n"
11153 "Address Family modifier\n"
11154 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11155 "Display route and more specific routes\n")
11156{
11157 if (strncmp (argv[0], "m", 1) == 0)
11158 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
11159 bgp_show_type_prefix_longer);
11160
11161 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
11162 bgp_show_type_prefix_longer);
11163}
11164
11165DEFUN (show_ip_bgp_flap_address,
11166 show_ip_bgp_flap_address_cmd,
11167 "show ip bgp flap-statistics A.B.C.D",
11168 SHOW_STR
11169 IP_STR
11170 BGP_STR
11171 "Display flap statistics of routes\n"
11172 "Network in the BGP routing table to display\n")
11173{
11174 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11175 bgp_show_type_flap_address);
11176}
11177
11178ALIAS (show_ip_bgp_flap_address,
11179 show_ip_bgp_damp_flap_address_cmd,
11180 "show ip bgp dampening flap-statistics A.B.C.D",
11181 SHOW_STR
11182 IP_STR
11183 BGP_STR
11184 "Display detailed information about dampening\n"
11185 "Display flap statistics of routes\n"
11186 "Network in the BGP routing table to display\n")
11187
11188DEFUN (show_ip_bgp_flap_prefix,
11189 show_ip_bgp_flap_prefix_cmd,
11190 "show ip bgp flap-statistics A.B.C.D/M",
11191 SHOW_STR
11192 IP_STR
11193 BGP_STR
11194 "Display flap statistics of routes\n"
11195 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11196{
11197 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11198 bgp_show_type_flap_prefix);
11199}
11200
11201ALIAS (show_ip_bgp_flap_prefix,
11202 show_ip_bgp_damp_flap_prefix_cmd,
11203 "show ip bgp dampening flap-statistics A.B.C.D/M",
11204 SHOW_STR
11205 IP_STR
11206 BGP_STR
11207 "Display detailed information about dampening\n"
11208 "Display flap statistics of routes\n"
11209 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11210
Lou Bergerf9b6c392016-01-12 13:42:09 -050011211DEFUN (show_bgp_prefix_longer,
11212 show_bgp_prefix_longer_cmd,
11213 "show bgp X:X::X:X/M longer-prefixes",
11214 SHOW_STR
11215 BGP_STR
11216 "IPv6 prefix <network>/<length>\n"
11217 "Display route and more specific routes\n")
11218{
11219 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11220 bgp_show_type_prefix_longer);
11221}
11222
11223/* old command */
11224DEFUN (show_ipv6_bgp_prefix_longer,
11225 show_ipv6_bgp_prefix_longer_cmd,
11226 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11227 SHOW_STR
11228 IPV6_STR
11229 BGP_STR
11230 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11231 "Display route and more specific routes\n")
11232{
11233 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11234 bgp_show_type_prefix_longer);
11235}
11236
11237/* old command */
11238DEFUN (show_ipv6_mbgp_prefix_longer,
11239 show_ipv6_mbgp_prefix_longer_cmd,
11240 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11241 SHOW_STR
11242 IPV6_STR
11243 MBGP_STR
11244 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11245 "Display route and more specific routes\n")
11246{
11247 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
11248 bgp_show_type_prefix_longer);
11249}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011250
Lou Berger651b4022016-01-12 13:42:07 -050011251DEFUN (show_bgp_ipv4_prefix_longer,
11252 show_bgp_ipv4_prefix_longer_cmd,
11253 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011254 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011255 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011256 IP_STR
paul718e3742002-12-13 20:15:29 +000011257 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11258 "Display route and more specific routes\n")
11259{
11260 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11261 bgp_show_type_prefix_longer);
11262}
11263
Lou Berger651b4022016-01-12 13:42:07 -050011264DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
11265 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
11266 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011267 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011268 BGP_STR
11269 "Address family\n"
11270 "Address Family modifier\n"
11271 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050011272 "Address Family modifier\n"
11273 "Address Family modifier\n"
11274 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000011275 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11276 "Display route and more specific routes\n")
11277{
Lou Berger651b4022016-01-12 13:42:07 -050011278 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011279
Lou Berger651b4022016-01-12 13:42:07 -050011280 if (bgp_parse_safi(argv[0], &safi)) {
11281 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11282 return CMD_WARNING;
11283 }
11284 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11285 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000011286}
11287
Lou Berger651b4022016-01-12 13:42:07 -050011288ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
11289 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
11290 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011291 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011292 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011293 "Address family\n"
11294 "Address Family modifier\n"
11295 "Address Family modifier\n"
11296 "Address Family modifier\n"
11297 "Address Family modifier\n"
11298 "Display detailed information about dampening\n"
11299 "Display flap statistics of routes\n"
11300 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11301 "Display route and more specific routes\n")
11302
Lou Berger651b4022016-01-12 13:42:07 -050011303DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
11304 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
11305 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
11306 SHOW_STR
11307 BGP_STR
11308 "Address family\n"
11309 "Address Family modifier\n"
11310 "Address Family modifier\n"
11311 "Address Family modifier\n"
11312 "Address Family modifier\n"
11313 "Display flap statistics of routes\n"
11314 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11315 "Display route and more specific routes\n")
11316{
11317 safi_t safi;
11318
11319 if (bgp_parse_safi(argv[0], &safi)) {
11320 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11321 return CMD_WARNING;
11322 }
11323 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11324 bgp_show_type_flap_prefix_longer);
11325}
11326ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
11327 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
11328 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
11329 SHOW_STR
11330 BGP_STR
11331 "Address family\n"
11332 "Address Family modifier\n"
11333 "Address Family modifier\n"
11334 "Address Family modifier\n"
11335 "Address Family modifier\n"
11336 "Display detailed information about dampening\n"
11337 "Display flap statistics of routes\n"
11338 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11339 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050011340
11341DEFUN (show_bgp_ipv4_safi_prefix_longer,
11342 show_bgp_ipv4_safi_prefix_longer_cmd,
11343 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
11344 SHOW_STR
11345 BGP_STR
11346 "Address family\n"
11347 "Address Family modifier\n"
11348 "Address Family modifier\n"
11349 "Address Family modifier\n"
11350 "Address Family modifier\n"
11351 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11352 "Display route and more specific routes\n")
11353{
11354 safi_t safi;
11355
11356 if (bgp_parse_safi(argv[0], &safi)) {
11357 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11358 return CMD_WARNING;
11359 }
11360
11361 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11362 bgp_show_type_prefix_longer);
11363}
11364
Lou Berger651b4022016-01-12 13:42:07 -050011365DEFUN (show_bgp_ipv6_safi_prefix_longer,
11366 show_bgp_ipv6_safi_prefix_longer_cmd,
11367 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
11368 SHOW_STR
11369 BGP_STR
11370 "Address family\n"
11371 "Address Family modifier\n"
11372 "Address Family modifier\n"
11373 "Address Family modifier\n"
11374 "Address Family modifier\n"
11375 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11376 "Display route and more specific routes\n")
11377{
11378 safi_t safi;
11379
11380 if (bgp_parse_safi(argv[0], &safi)) {
11381 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11382 return CMD_WARNING;
11383 }
11384
11385 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11386 bgp_show_type_prefix_longer);
11387}
Lou Berger651b4022016-01-12 13:42:07 -050011388
11389DEFUN (show_bgp_ipv4_safi_flap_address,
11390 show_bgp_ipv4_safi_flap_address_cmd,
11391 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
11392 SHOW_STR
11393 BGP_STR
11394 "Address family\n"
11395 "Address Family modifier\n"
11396 "Address Family modifier\n"
11397 "Address Family modifier\n"
11398 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011399 "Display flap statistics of routes\n"
11400 "Network in the BGP routing table to display\n")
11401{
Lou Berger651b4022016-01-12 13:42:07 -050011402 safi_t safi;
11403
11404 if (bgp_parse_safi(argv[0], &safi)) {
11405 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11406 return CMD_WARNING;
11407 }
11408 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011409 bgp_show_type_flap_address);
11410}
Lou Berger651b4022016-01-12 13:42:07 -050011411ALIAS (show_bgp_ipv4_safi_flap_address,
11412 show_bgp_ipv4_safi_damp_flap_address_cmd,
11413 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053011414 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011415 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011416 "Address family\n"
11417 "Address Family modifier\n"
11418 "Address Family modifier\n"
11419 "Address Family modifier\n"
11420 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011421 "Display detailed information about dampening\n"
11422 "Display flap statistics of routes\n"
11423 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050011424
Lou Berger651b4022016-01-12 13:42:07 -050011425DEFUN (show_bgp_ipv6_flap_address,
11426 show_bgp_ipv6_flap_address_cmd,
11427 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000011428 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011429 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011430 "Address family\n"
11431 "Address Family modifier\n"
11432 "Address Family modifier\n"
11433 "Address Family modifier\n"
11434 "Address Family modifier\n"
11435 "Display flap statistics of routes\n"
11436 "Network in the BGP routing table to display\n")
11437{
11438 safi_t safi;
11439
11440 if (bgp_parse_safi(argv[0], &safi)) {
11441 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11442 return CMD_WARNING;
11443 }
11444 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11445 bgp_show_type_flap_address);
11446}
11447ALIAS (show_bgp_ipv6_flap_address,
11448 show_bgp_ipv6_damp_flap_address_cmd,
11449 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
11450 SHOW_STR
11451 BGP_STR
11452 "Address family\n"
11453 "Address Family modifier\n"
11454 "Address Family modifier\n"
11455 "Address Family modifier\n"
11456 "Address Family modifier\n"
11457 "Display detailed information about dampening\n"
11458 "Display flap statistics of routes\n"
11459 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050011460
11461DEFUN (show_bgp_ipv4_safi_flap_prefix,
11462 show_bgp_ipv4_safi_flap_prefix_cmd,
11463 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
11464 SHOW_STR
11465 BGP_STR
11466 "Address family\n"
11467 "Address Family modifier\n"
11468 "Address Family modifier\n"
11469 "Address Family modifier\n"
11470 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011471 "Display flap statistics of routes\n"
11472 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11473{
Lou Berger651b4022016-01-12 13:42:07 -050011474 safi_t safi;
11475
11476 if (bgp_parse_safi(argv[0], &safi)) {
11477 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11478 return CMD_WARNING;
11479 }
11480 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011481 bgp_show_type_flap_prefix);
11482}
Balaji3921cc52015-05-16 23:12:17 +053011483
Lou Berger651b4022016-01-12 13:42:07 -050011484ALIAS (show_bgp_ipv4_safi_flap_prefix,
11485 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
11486 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053011487 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011488 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011489 "Address family\n"
11490 "Address Family modifier\n"
11491 "Address Family modifier\n"
11492 "Address Family modifier\n"
11493 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011494 "Display detailed information about dampening\n"
11495 "Display flap statistics of routes\n"
11496 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11497
Lou Berger651b4022016-01-12 13:42:07 -050011498DEFUN (show_bgp_ipv6_safi_flap_prefix,
11499 show_bgp_ipv6_safi_flap_prefix_cmd,
11500 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000011501 SHOW_STR
11502 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011503 "Address family\n"
11504 "Address Family modifier\n"
11505 "Address Family modifier\n"
11506 "Address Family modifier\n"
11507 "Address Family modifier\n"
11508 "Display flap statistics of routes\n"
11509 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000011510{
Lou Berger651b4022016-01-12 13:42:07 -050011511 safi_t safi;
11512
11513 if (bgp_parse_safi(argv[0], &safi)) {
11514 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11515 return CMD_WARNING;
11516 }
11517 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
11518 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000011519}
11520
Lou Berger651b4022016-01-12 13:42:07 -050011521ALIAS (show_bgp_ipv6_safi_flap_prefix,
11522 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
11523 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
11524 SHOW_STR
11525 BGP_STR
11526 "Address family\n"
11527 "Address Family modifier\n"
11528 "Address Family modifier\n"
11529 "Address Family modifier\n"
11530 "Address Family modifier\n"
11531 "Display detailed information about dampening\n"
11532 "Display flap statistics of routes\n"
11533 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11534
11535DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000011536 show_bgp_ipv6_prefix_longer_cmd,
11537 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11538 SHOW_STR
11539 BGP_STR
11540 "Address family\n"
11541 "IPv6 prefix <network>/<length>\n"
11542 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000011543{
11544 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11545 bgp_show_type_prefix_longer);
11546}
11547
paul94f2b392005-06-28 12:44:16 +000011548static struct peer *
paulfd79ac92004-10-13 05:06:08 +000011549peer_lookup_in_view (struct vty *vty, const char *view_name,
11550 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000011551{
11552 int ret;
11553 struct bgp *bgp;
11554 struct peer *peer;
11555 union sockunion su;
11556
11557 /* BGP structure lookup. */
11558 if (view_name)
11559 {
11560 bgp = bgp_lookup_by_name (view_name);
11561 if (! bgp)
11562 {
11563 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11564 return NULL;
11565 }
11566 }
paul5228ad22004-06-04 17:58:18 +000011567 else
paulbb46e942003-10-24 19:02:03 +000011568 {
11569 bgp = bgp_get_default ();
11570 if (! bgp)
11571 {
11572 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11573 return NULL;
11574 }
11575 }
11576
11577 /* Get peer sockunion. */
11578 ret = str2sockunion (ip_str, &su);
11579 if (ret < 0)
11580 {
11581 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
11582 return NULL;
11583 }
11584
11585 /* Peer structure lookup. */
11586 peer = peer_lookup (bgp, &su);
11587 if (! peer)
11588 {
11589 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
11590 return NULL;
11591 }
11592
11593 return peer;
11594}
David Lamparter6b0655a2014-06-04 06:53:35 +020011595
Paul Jakma2815e612006-09-14 02:56:07 +000011596enum bgp_stats
11597{
11598 BGP_STATS_MAXBITLEN = 0,
11599 BGP_STATS_RIB,
11600 BGP_STATS_PREFIXES,
11601 BGP_STATS_TOTPLEN,
11602 BGP_STATS_UNAGGREGATEABLE,
11603 BGP_STATS_MAX_AGGREGATEABLE,
11604 BGP_STATS_AGGREGATES,
11605 BGP_STATS_SPACE,
11606 BGP_STATS_ASPATH_COUNT,
11607 BGP_STATS_ASPATH_MAXHOPS,
11608 BGP_STATS_ASPATH_TOTHOPS,
11609 BGP_STATS_ASPATH_MAXSIZE,
11610 BGP_STATS_ASPATH_TOTSIZE,
11611 BGP_STATS_ASN_HIGHEST,
11612 BGP_STATS_MAX,
11613};
paulbb46e942003-10-24 19:02:03 +000011614
Paul Jakma2815e612006-09-14 02:56:07 +000011615static const char *table_stats_strs[] =
11616{
11617 [BGP_STATS_PREFIXES] = "Total Prefixes",
11618 [BGP_STATS_TOTPLEN] = "Average prefix length",
11619 [BGP_STATS_RIB] = "Total Advertisements",
11620 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
11621 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
11622 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
11623 [BGP_STATS_SPACE] = "Address space advertised",
11624 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
11625 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
11626 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
11627 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
11628 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
11629 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
11630 [BGP_STATS_MAX] = NULL,
11631};
11632
11633struct bgp_table_stats
11634{
11635 struct bgp_table *table;
11636 unsigned long long counts[BGP_STATS_MAX];
11637};
11638
11639#if 0
11640#define TALLY_SIGFIG 100000
11641static unsigned long
11642ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
11643{
11644 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
11645 unsigned long res = (newtot * TALLY_SIGFIG) / count;
11646 unsigned long ret = newtot / count;
11647
11648 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
11649 return ret + 1;
11650 else
11651 return ret;
11652}
11653#endif
11654
11655static int
11656bgp_table_stats_walker (struct thread *t)
11657{
11658 struct bgp_node *rn;
11659 struct bgp_node *top;
11660 struct bgp_table_stats *ts = THREAD_ARG (t);
11661 unsigned int space = 0;
11662
Paul Jakma53d9f672006-10-15 23:41:16 +000011663 if (!(top = bgp_table_top (ts->table)))
11664 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000011665
11666 switch (top->p.family)
11667 {
11668 case AF_INET:
11669 space = IPV4_MAX_BITLEN;
11670 break;
11671 case AF_INET6:
11672 space = IPV6_MAX_BITLEN;
11673 break;
11674 }
11675
11676 ts->counts[BGP_STATS_MAXBITLEN] = space;
11677
11678 for (rn = top; rn; rn = bgp_route_next (rn))
11679 {
11680 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070011681 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000011682 unsigned int rinum = 0;
11683
11684 if (rn == top)
11685 continue;
11686
11687 if (!rn->info)
11688 continue;
11689
11690 ts->counts[BGP_STATS_PREFIXES]++;
11691 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
11692
11693#if 0
11694 ts->counts[BGP_STATS_AVGPLEN]
11695 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
11696 ts->counts[BGP_STATS_AVGPLEN],
11697 rn->p.prefixlen);
11698#endif
11699
11700 /* check if the prefix is included by any other announcements */
11701 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070011702 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000011703
11704 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000011705 {
11706 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
11707 /* announced address space */
11708 if (space)
11709 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
11710 }
Paul Jakma2815e612006-09-14 02:56:07 +000011711 else if (prn->info)
11712 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
11713
Paul Jakma2815e612006-09-14 02:56:07 +000011714 for (ri = rn->info; ri; ri = ri->next)
11715 {
11716 rinum++;
11717 ts->counts[BGP_STATS_RIB]++;
11718
11719 if (ri->attr &&
11720 (CHECK_FLAG (ri->attr->flag,
11721 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
11722 ts->counts[BGP_STATS_AGGREGATES]++;
11723
11724 /* as-path stats */
11725 if (ri->attr && ri->attr->aspath)
11726 {
11727 unsigned int hops = aspath_count_hops (ri->attr->aspath);
11728 unsigned int size = aspath_size (ri->attr->aspath);
11729 as_t highest = aspath_highest (ri->attr->aspath);
11730
11731 ts->counts[BGP_STATS_ASPATH_COUNT]++;
11732
11733 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
11734 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
11735
11736 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
11737 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
11738
11739 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
11740 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
11741#if 0
11742 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
11743 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11744 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
11745 hops);
11746 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
11747 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11748 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
11749 size);
11750#endif
11751 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
11752 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
11753 }
11754 }
11755 }
11756 return 0;
11757}
11758
11759static int
11760bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
11761{
11762 struct bgp_table_stats ts;
11763 unsigned int i;
11764
11765 if (!bgp->rib[afi][safi])
11766 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011767 vty_out (vty, "%% No RIB exists for the AFI/SAFI%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011768 return CMD_WARNING;
11769 }
11770
11771 memset (&ts, 0, sizeof (ts));
11772 ts.table = bgp->rib[afi][safi];
11773 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
11774
11775 vty_out (vty, "BGP %s RIB statistics%s%s",
11776 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
11777
11778 for (i = 0; i < BGP_STATS_MAX; i++)
11779 {
11780 if (!table_stats_strs[i])
11781 continue;
11782
11783 switch (i)
11784 {
11785#if 0
11786 case BGP_STATS_ASPATH_AVGHOPS:
11787 case BGP_STATS_ASPATH_AVGSIZE:
11788 case BGP_STATS_AVGPLEN:
11789 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11790 vty_out (vty, "%12.2f",
11791 (float)ts.counts[i] / (float)TALLY_SIGFIG);
11792 break;
11793#endif
11794 case BGP_STATS_ASPATH_TOTHOPS:
11795 case BGP_STATS_ASPATH_TOTSIZE:
11796 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11797 vty_out (vty, "%12.2f",
11798 ts.counts[i] ?
11799 (float)ts.counts[i] /
11800 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
11801 : 0);
11802 break;
11803 case BGP_STATS_TOTPLEN:
11804 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11805 vty_out (vty, "%12.2f",
11806 ts.counts[i] ?
11807 (float)ts.counts[i] /
11808 (float)ts.counts[BGP_STATS_PREFIXES]
11809 : 0);
11810 break;
11811 case BGP_STATS_SPACE:
11812 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11813 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
11814 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
11815 break;
Paul Jakma30a22312008-08-15 14:05:22 +010011816 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000011817 vty_out (vty, "%12.2f%s",
11818 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000011819 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000011820 VTY_NEWLINE);
11821 vty_out (vty, "%30s: ", "/8 equivalent ");
11822 vty_out (vty, "%12.2f%s",
11823 (float)ts.counts[BGP_STATS_SPACE] /
11824 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
11825 VTY_NEWLINE);
11826 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
11827 break;
11828 vty_out (vty, "%30s: ", "/24 equivalent ");
11829 vty_out (vty, "%12.2f",
11830 (float)ts.counts[BGP_STATS_SPACE] /
11831 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
11832 break;
11833 default:
11834 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11835 vty_out (vty, "%12llu", ts.counts[i]);
11836 }
11837
11838 vty_out (vty, "%s", VTY_NEWLINE);
11839 }
11840 return CMD_SUCCESS;
11841}
11842
11843static int
11844bgp_table_stats_vty (struct vty *vty, const char *name,
11845 const char *afi_str, const char *safi_str)
11846{
11847 struct bgp *bgp;
11848 afi_t afi;
11849 safi_t safi;
11850
11851 if (name)
11852 bgp = bgp_lookup_by_name (name);
11853 else
11854 bgp = bgp_get_default ();
11855
11856 if (!bgp)
11857 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011858 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011859 return CMD_WARNING;
11860 }
11861 if (strncmp (afi_str, "ipv", 3) == 0)
11862 {
11863 if (strncmp (afi_str, "ipv4", 4) == 0)
11864 afi = AFI_IP;
11865 else if (strncmp (afi_str, "ipv6", 4) == 0)
11866 afi = AFI_IP6;
11867 else
11868 {
11869 vty_out (vty, "%% Invalid address family %s%s",
11870 afi_str, VTY_NEWLINE);
11871 return CMD_WARNING;
11872 }
Lou Berger298cc2f2016-01-12 13:42:02 -050011873 switch (safi_str[0]) {
11874 case 'm':
11875 safi = SAFI_MULTICAST;
11876 break;
11877 case 'u':
11878 safi = SAFI_UNICAST;
11879 break;
11880 case 'v':
11881 safi = SAFI_MPLS_LABELED_VPN;
11882 break;
11883 case 'e':
11884 safi = SAFI_ENCAP;
11885 break;
11886 default:
11887 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011888 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050011889 return CMD_WARNING;
11890 }
Paul Jakma2815e612006-09-14 02:56:07 +000011891 }
11892 else
11893 {
Lou Berger298cc2f2016-01-12 13:42:02 -050011894 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011895 afi_str, VTY_NEWLINE);
11896 return CMD_WARNING;
11897 }
11898
Paul Jakma2815e612006-09-14 02:56:07 +000011899 return bgp_table_stats (vty, bgp, afi, safi);
11900}
11901
11902DEFUN (show_bgp_statistics,
11903 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011904 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011905 SHOW_STR
11906 BGP_STR
11907 "Address family\n"
11908 "Address family\n"
11909 "Address Family modifier\n"
11910 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011911 "Address Family modifier\n"
11912 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011913 "BGP RIB advertisement statistics\n")
11914{
11915 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11916}
11917
Lou Bergerf9b6c392016-01-12 13:42:09 -050011918ALIAS (show_bgp_statistics,
11919 show_bgp_statistics_vpnv4_cmd,
11920 "show bgp (ipv4) (vpnv4) statistics",
11921 SHOW_STR
11922 BGP_STR
11923 "Address family\n"
11924 "Address Family modifier\n"
11925 "BGP RIB advertisement statistics\n")
11926
Paul Jakma2815e612006-09-14 02:56:07 +000011927DEFUN (show_bgp_statistics_view,
11928 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011929 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011930 SHOW_STR
11931 BGP_STR
11932 "BGP view\n"
11933 "Address family\n"
11934 "Address family\n"
11935 "Address Family modifier\n"
11936 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011937 "Address Family modifier\n"
11938 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011939 "BGP RIB advertisement statistics\n")
11940{
11941 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11942}
11943
11944ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011945 show_bgp_statistics_view_vpnv4_cmd,
11946 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011947 SHOW_STR
11948 BGP_STR
11949 "BGP view\n"
11950 "Address family\n"
11951 "Address Family modifier\n"
11952 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020011953
Paul Jakmaff7924f2006-09-04 01:10:36 +000011954enum bgp_pcounts
11955{
11956 PCOUNT_ADJ_IN = 0,
11957 PCOUNT_DAMPED,
11958 PCOUNT_REMOVED,
11959 PCOUNT_HISTORY,
11960 PCOUNT_STALE,
11961 PCOUNT_VALID,
11962 PCOUNT_ALL,
11963 PCOUNT_COUNTED,
11964 PCOUNT_PFCNT, /* the figure we display to users */
11965 PCOUNT_MAX,
11966};
11967
11968static const char *pcount_strs[] =
11969{
11970 [PCOUNT_ADJ_IN] = "Adj-in",
11971 [PCOUNT_DAMPED] = "Damped",
11972 [PCOUNT_REMOVED] = "Removed",
11973 [PCOUNT_HISTORY] = "History",
11974 [PCOUNT_STALE] = "Stale",
11975 [PCOUNT_VALID] = "Valid",
11976 [PCOUNT_ALL] = "All RIB",
11977 [PCOUNT_COUNTED] = "PfxCt counted",
11978 [PCOUNT_PFCNT] = "Useable",
11979 [PCOUNT_MAX] = NULL,
11980};
11981
Paul Jakma2815e612006-09-14 02:56:07 +000011982struct peer_pcounts
11983{
11984 unsigned int count[PCOUNT_MAX];
11985 const struct peer *peer;
11986 const struct bgp_table *table;
11987};
11988
Paul Jakmaff7924f2006-09-04 01:10:36 +000011989static int
Paul Jakma2815e612006-09-14 02:56:07 +000011990bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000011991{
11992 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000011993 struct peer_pcounts *pc = THREAD_ARG (t);
11994 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011995
Paul Jakma2815e612006-09-14 02:56:07 +000011996 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000011997 {
11998 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000011999 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012000
12001 for (ain = rn->adj_in; ain; ain = ain->next)
12002 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000012003 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012004
Paul Jakmaff7924f2006-09-04 01:10:36 +000012005 for (ri = rn->info; ri; ri = ri->next)
12006 {
12007 char buf[SU_ADDRSTRLEN];
12008
12009 if (ri->peer != peer)
12010 continue;
12011
Paul Jakma2815e612006-09-14 02:56:07 +000012012 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012013
12014 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000012015 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012016 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000012017 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012018 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000012019 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012020 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000012021 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012022 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000012023 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012024 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000012025 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012026
12027 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
12028 {
Paul Jakma2815e612006-09-14 02:56:07 +000012029 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012030 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012031 plog_warn (peer->log,
12032 "%s [pcount] %s/%d is counted but flags 0x%x",
12033 peer->host,
12034 inet_ntop(rn->p.family, &rn->p.u.prefix,
12035 buf, SU_ADDRSTRLEN),
12036 rn->p.prefixlen,
12037 ri->flags);
12038 }
12039 else
12040 {
Paul Jakma1a392d42006-09-07 00:24:49 +000012041 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012042 plog_warn (peer->log,
12043 "%s [pcount] %s/%d not counted but flags 0x%x",
12044 peer->host,
12045 inet_ntop(rn->p.family, &rn->p.u.prefix,
12046 buf, SU_ADDRSTRLEN),
12047 rn->p.prefixlen,
12048 ri->flags);
12049 }
12050 }
12051 }
Paul Jakma2815e612006-09-14 02:56:07 +000012052 return 0;
12053}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012054
Paul Jakma2815e612006-09-14 02:56:07 +000012055static int
12056bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
12057{
12058 struct peer_pcounts pcounts = { .peer = peer };
12059 unsigned int i;
12060
12061 if (!peer || !peer->bgp || !peer->afc[afi][safi]
12062 || !peer->bgp->rib[afi][safi])
12063 {
12064 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12065 return CMD_WARNING;
12066 }
12067
12068 memset (&pcounts, 0, sizeof(pcounts));
12069 pcounts.peer = peer;
12070 pcounts.table = peer->bgp->rib[afi][safi];
12071
12072 /* in-place call via thread subsystem so as to record execution time
12073 * stats for the thread-walk (i.e. ensure this can't be blamed on
12074 * on just vty_read()).
12075 */
12076 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
12077
Paul Jakmaff7924f2006-09-04 01:10:36 +000012078 vty_out (vty, "Prefix counts for %s, %s%s",
12079 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
12080 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
12081 vty_out (vty, "%sCounts from RIB table walk:%s%s",
12082 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12083
12084 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000012085 vty_out (vty, "%20s: %-10d%s",
12086 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012087
Paul Jakma2815e612006-09-14 02:56:07 +000012088 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000012089 {
12090 vty_out (vty, "%s [pcount] PfxCt drift!%s",
12091 peer->host, VTY_NEWLINE);
12092 vty_out (vty, "Please report this bug, with the above command output%s",
12093 VTY_NEWLINE);
12094 }
12095
12096 return CMD_SUCCESS;
12097}
12098
Lou Bergerf9b6c392016-01-12 13:42:09 -050012099DEFUN (show_ip_bgp_neighbor_prefix_counts,
12100 show_ip_bgp_neighbor_prefix_counts_cmd,
12101 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12102 SHOW_STR
12103 IP_STR
12104 BGP_STR
12105 "Detailed information on TCP and BGP neighbor connections\n"
12106 "Neighbor to display information about\n"
12107 "Neighbor to display information about\n"
12108 "Display detailed prefix count information\n")
12109{
12110 struct peer *peer;
12111
12112 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12113 if (! peer)
12114 return CMD_WARNING;
12115
12116 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12117}
12118
Paul Jakmaff7924f2006-09-04 01:10:36 +000012119DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
12120 show_bgp_ipv6_neighbor_prefix_counts_cmd,
12121 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12122 SHOW_STR
12123 BGP_STR
12124 "Address family\n"
12125 "Detailed information on TCP and BGP neighbor connections\n"
12126 "Neighbor to display information about\n"
12127 "Neighbor to display information about\n"
12128 "Display detailed prefix count information\n")
12129{
12130 struct peer *peer;
12131
12132 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12133 if (! peer)
12134 return CMD_WARNING;
12135
12136 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
12137}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012138
12139DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
12140 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
12141 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12142 SHOW_STR
12143 IP_STR
12144 BGP_STR
12145 "Address family\n"
12146 "Address Family modifier\n"
12147 "Address Family modifier\n"
12148 "Detailed information on TCP and BGP neighbor connections\n"
12149 "Neighbor to display information about\n"
12150 "Neighbor to display information about\n"
12151 "Display detailed prefix count information\n")
12152{
12153 struct peer *peer;
12154
12155 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12156 if (! peer)
12157 return CMD_WARNING;
12158
12159 if (strncmp (argv[0], "m", 1) == 0)
12160 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
12161
12162 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12163}
12164
12165DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
12166 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
12167 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12168 SHOW_STR
12169 IP_STR
12170 BGP_STR
12171 "Address family\n"
12172 "Address Family modifier\n"
12173 "Address Family modifier\n"
12174 "Detailed information on TCP and BGP neighbor connections\n"
12175 "Neighbor to display information about\n"
12176 "Neighbor to display information about\n"
12177 "Display detailed prefix count information\n")
12178{
12179 struct peer *peer;
12180
12181 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12182 if (! peer)
12183 return CMD_WARNING;
12184
12185 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
12186}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012187
Lou Berger651b4022016-01-12 13:42:07 -050012188DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
12189 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
12190 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012191 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000012192 BGP_STR
12193 "Address family\n"
12194 "Address Family modifier\n"
12195 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012196 "Address Family modifier\n"
12197 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000012198 "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;
Lou Berger651b4022016-01-12 13:42:07 -050012204 safi_t safi;
12205
12206 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 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000012210
12211 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12212 if (! peer)
12213 return CMD_WARNING;
12214
Lou Berger651b4022016-01-12 13:42:07 -050012215 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012216}
Lou Berger205e6742016-01-12 13:42:11 -050012217
Lou Berger651b4022016-01-12 13:42:07 -050012218DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
12219 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
12220 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12221 SHOW_STR
12222 BGP_STR
12223 "Address family\n"
12224 "Address Family modifier\n"
12225 "Address Family modifier\n"
12226 "Address Family modifier\n"
12227 "Address Family modifier\n"
12228 "Detailed information on TCP and BGP neighbor connections\n"
12229 "Neighbor to display information about\n"
12230 "Neighbor to display information about\n"
12231 "Display detailed prefix count information\n")
12232{
12233 struct peer *peer;
12234 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012235
Lou Berger651b4022016-01-12 13:42:07 -050012236 if (bgp_parse_safi(argv[0], &safi)) {
12237 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12238 return CMD_WARNING;
12239 }
12240
12241 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12242 if (! peer)
12243 return CMD_WARNING;
12244
12245 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
12246}
Lou Berger651b4022016-01-12 13:42:07 -050012247
12248DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
12249 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
12250 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012251 SHOW_STR
12252 IP_STR
12253 BGP_STR
12254 "Address family\n"
12255 "Address Family modifier\n"
12256 "Address Family modifier\n"
12257 "Detailed information on TCP and BGP neighbor connections\n"
12258 "Neighbor to display information about\n"
12259 "Neighbor to display information about\n"
12260 "Display detailed prefix count information\n")
12261{
12262 struct peer *peer;
12263
12264 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12265 if (! peer)
12266 return CMD_WARNING;
12267
Lou Berger651b4022016-01-12 13:42:07 -050012268 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012269}
12270
12271
paul94f2b392005-06-28 12:44:16 +000012272static void
paul718e3742002-12-13 20:15:29 +000012273show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
12274 int in)
12275{
12276 struct bgp_table *table;
12277 struct bgp_adj_in *ain;
12278 struct bgp_adj_out *adj;
12279 unsigned long output_count;
12280 struct bgp_node *rn;
12281 int header1 = 1;
12282 struct bgp *bgp;
12283 int header2 = 1;
12284
paulbb46e942003-10-24 19:02:03 +000012285 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000012286
12287 if (! bgp)
12288 return;
12289
12290 table = bgp->rib[afi][safi];
12291
12292 output_count = 0;
12293
12294 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
12295 PEER_STATUS_DEFAULT_ORIGINATE))
12296 {
12297 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 +000012298 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12299 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012300
12301 vty_out (vty, "Originating default network 0.0.0.0%s%s",
12302 VTY_NEWLINE, VTY_NEWLINE);
12303 header1 = 0;
12304 }
12305
12306 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
12307 if (in)
12308 {
12309 for (ain = rn->adj_in; ain; ain = ain->next)
12310 if (ain->peer == peer)
12311 {
12312 if (header1)
12313 {
12314 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 +000012315 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12316 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012317 header1 = 0;
12318 }
12319 if (header2)
12320 {
12321 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12322 header2 = 0;
12323 }
12324 if (ain->attr)
12325 {
12326 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
12327 output_count++;
12328 }
12329 }
12330 }
12331 else
12332 {
12333 for (adj = rn->adj_out; adj; adj = adj->next)
12334 if (adj->peer == peer)
12335 {
12336 if (header1)
12337 {
12338 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 +000012339 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12340 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012341 header1 = 0;
12342 }
12343 if (header2)
12344 {
12345 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12346 header2 = 0;
12347 }
12348 if (adj->attr)
12349 {
12350 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
12351 output_count++;
12352 }
12353 }
12354 }
12355
12356 if (output_count != 0)
12357 vty_out (vty, "%sTotal number of prefixes %ld%s",
12358 VTY_NEWLINE, output_count, VTY_NEWLINE);
12359}
12360
paul94f2b392005-06-28 12:44:16 +000012361static int
paulbb46e942003-10-24 19:02:03 +000012362peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
12363{
paul718e3742002-12-13 20:15:29 +000012364 if (! peer || ! peer->afc[afi][safi])
12365 {
12366 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12367 return CMD_WARNING;
12368 }
12369
12370 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
12371 {
12372 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
12373 VTY_NEWLINE);
12374 return CMD_WARNING;
12375 }
12376
12377 show_adj_route (vty, peer, afi, safi, in);
12378
12379 return CMD_SUCCESS;
12380}
12381
Lou Bergerf9b6c392016-01-12 13:42:09 -050012382DEFUN (show_ip_bgp_view_neighbor_advertised_route,
12383 show_ip_bgp_view_neighbor_advertised_route_cmd,
12384 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12385 SHOW_STR
12386 IP_STR
12387 BGP_STR
12388 "BGP view\n"
12389 "View name\n"
12390 "Detailed information on TCP and BGP neighbor connections\n"
12391 "Neighbor to display information about\n"
12392 "Neighbor to display information about\n"
12393 "Display the routes advertised to a BGP neighbor\n")
12394{
12395 struct peer *peer;
12396
12397 if (argc == 2)
12398 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12399 else
12400 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12401
12402 if (! peer)
12403 return CMD_WARNING;
12404
12405 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12406}
12407
12408ALIAS (show_ip_bgp_view_neighbor_advertised_route,
12409 show_ip_bgp_neighbor_advertised_route_cmd,
12410 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12411 SHOW_STR
12412 IP_STR
12413 BGP_STR
12414 "Detailed information on TCP and BGP neighbor connections\n"
12415 "Neighbor to display information about\n"
12416 "Neighbor to display information about\n"
12417 "Display the routes advertised to a BGP neighbor\n")
12418
12419DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
12420 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
12421 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12422 SHOW_STR
12423 IP_STR
12424 BGP_STR
12425 "Address family\n"
12426 "Address Family modifier\n"
12427 "Address Family modifier\n"
12428 "Detailed information on TCP and BGP neighbor connections\n"
12429 "Neighbor to display information about\n"
12430 "Neighbor to display information about\n"
12431 "Display the routes advertised to a BGP neighbor\n")
12432{
12433 struct peer *peer;
12434
12435 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12436 if (! peer)
12437 return CMD_WARNING;
12438
12439 if (strncmp (argv[0], "m", 1) == 0)
12440 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
12441
12442 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12443}
12444
Lou Bergerf9b6c392016-01-12 13:42:09 -050012445DEFUN (show_bgp_view_neighbor_advertised_route,
12446 show_bgp_view_neighbor_advertised_route_cmd,
12447 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12448 SHOW_STR
12449 BGP_STR
12450 "BGP view\n"
12451 "View name\n"
12452 "Detailed information on TCP and BGP neighbor connections\n"
12453 "Neighbor to display information about\n"
12454 "Neighbor to display information about\n"
12455 "Display the routes advertised to a BGP neighbor\n")
12456{
12457 struct peer *peer;
12458
12459 if (argc == 2)
12460 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12461 else
12462 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12463
12464 if (! peer)
12465 return CMD_WARNING;
12466
12467 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12468}
12469
12470DEFUN (show_bgp_view_neighbor_received_routes,
12471 show_bgp_view_neighbor_received_routes_cmd,
12472 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12473 SHOW_STR
12474 BGP_STR
12475 "BGP view\n"
12476 "View name\n"
12477 "Detailed information on TCP and BGP neighbor connections\n"
12478 "Neighbor to display information about\n"
12479 "Neighbor to display information about\n"
12480 "Display the received routes from neighbor\n")
12481{
12482 struct peer *peer;
12483
12484 if (argc == 2)
12485 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12486 else
12487 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12488
12489 if (! peer)
12490 return CMD_WARNING;
12491
12492 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12493}
12494
12495ALIAS (show_bgp_view_neighbor_advertised_route,
12496 show_bgp_neighbor_advertised_route_cmd,
12497 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12498 SHOW_STR
12499 BGP_STR
12500 "Detailed information on TCP and BGP neighbor connections\n"
12501 "Neighbor to display information about\n"
12502 "Neighbor to display information about\n"
12503 "Display the routes advertised to a BGP neighbor\n")
12504
12505ALIAS (show_bgp_view_neighbor_advertised_route,
12506 show_bgp_ipv6_neighbor_advertised_route_cmd,
12507 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12508 SHOW_STR
12509 BGP_STR
12510 "Address family\n"
12511 "Detailed information on TCP and BGP neighbor connections\n"
12512 "Neighbor to display information about\n"
12513 "Neighbor to display information about\n"
12514 "Display the routes advertised to a BGP neighbor\n")
12515
12516/* old command */
12517ALIAS (show_bgp_view_neighbor_advertised_route,
12518 ipv6_bgp_neighbor_advertised_route_cmd,
12519 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12520 SHOW_STR
12521 IPV6_STR
12522 BGP_STR
12523 "Detailed information on TCP and BGP neighbor connections\n"
12524 "Neighbor to display information about\n"
12525 "Neighbor to display information about\n"
12526 "Display the routes advertised to a BGP neighbor\n")
12527
12528/* old command */
12529DEFUN (ipv6_mbgp_neighbor_advertised_route,
12530 ipv6_mbgp_neighbor_advertised_route_cmd,
12531 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12532 SHOW_STR
12533 IPV6_STR
12534 MBGP_STR
12535 "Detailed information on TCP and BGP neighbor connections\n"
12536 "Neighbor to display information about\n"
12537 "Neighbor to display information about\n"
12538 "Display the routes advertised to a BGP neighbor\n")
12539{
12540 struct peer *peer;
12541
12542 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12543 if (! peer)
12544 return CMD_WARNING;
12545
12546 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
12547}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012548
12549DEFUN (show_ip_bgp_view_neighbor_received_routes,
12550 show_ip_bgp_view_neighbor_received_routes_cmd,
12551 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12552 SHOW_STR
12553 IP_STR
12554 BGP_STR
12555 "BGP view\n"
12556 "View name\n"
12557 "Detailed information on TCP and BGP neighbor connections\n"
12558 "Neighbor to display information about\n"
12559 "Neighbor to display information about\n"
12560 "Display the received routes from neighbor\n")
12561{
12562 struct peer *peer;
12563
12564 if (argc == 2)
12565 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12566 else
12567 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12568
12569 if (! peer)
12570 return CMD_WARNING;
12571
12572 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12573}
12574
12575ALIAS (show_ip_bgp_view_neighbor_received_routes,
12576 show_ip_bgp_neighbor_received_routes_cmd,
12577 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12578 SHOW_STR
12579 IP_STR
12580 BGP_STR
12581 "Detailed information on TCP and BGP neighbor connections\n"
12582 "Neighbor to display information about\n"
12583 "Neighbor to display information about\n"
12584 "Display the received routes from neighbor\n")
12585
12586ALIAS (show_bgp_view_neighbor_received_routes,
12587 show_bgp_ipv6_neighbor_received_routes_cmd,
12588 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
12589 SHOW_STR
12590 BGP_STR
12591 "Address family\n"
12592 "Detailed information on TCP and BGP neighbor connections\n"
12593 "Neighbor to display information about\n"
12594 "Neighbor to display information about\n"
12595 "Display the received routes from neighbor\n")
12596
12597DEFUN (show_bgp_neighbor_received_prefix_filter,
12598 show_bgp_neighbor_received_prefix_filter_cmd,
12599 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12600 SHOW_STR
12601 BGP_STR
12602 "Detailed information on TCP and BGP neighbor connections\n"
12603 "Neighbor to display information about\n"
12604 "Neighbor to display information about\n"
12605 "Display information received from a BGP neighbor\n"
12606 "Display the prefixlist filter\n")
12607{
12608 char name[BUFSIZ];
12609 union sockunion su;
12610 struct peer *peer;
12611 int count, ret;
12612
12613 ret = str2sockunion (argv[0], &su);
12614 if (ret < 0)
12615 {
12616 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12617 return CMD_WARNING;
12618 }
12619
12620 peer = peer_lookup (NULL, &su);
12621 if (! peer)
12622 return CMD_WARNING;
12623
12624 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12625 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12626 if (count)
12627 {
12628 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12629 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12630 }
12631
12632 return CMD_SUCCESS;
12633}
12634
12635/* old command */
12636ALIAS (show_bgp_view_neighbor_received_routes,
12637 ipv6_bgp_neighbor_received_routes_cmd,
12638 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12639 SHOW_STR
12640 IPV6_STR
12641 BGP_STR
12642 "Detailed information on TCP and BGP neighbor connections\n"
12643 "Neighbor to display information about\n"
12644 "Neighbor to display information about\n"
12645 "Display the received routes from neighbor\n")
12646
12647/* old command */
12648DEFUN (ipv6_mbgp_neighbor_received_routes,
12649 ipv6_mbgp_neighbor_received_routes_cmd,
12650 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12651 SHOW_STR
12652 IPV6_STR
12653 MBGP_STR
12654 "Detailed information on TCP and BGP neighbor connections\n"
12655 "Neighbor to display information about\n"
12656 "Neighbor to display information about\n"
12657 "Display the received routes from neighbor\n")
12658{
12659 struct peer *peer;
12660
12661 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12662 if (! peer)
12663 return CMD_WARNING;
12664
12665 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
12666}
12667
12668DEFUN (show_bgp_view_neighbor_received_prefix_filter,
12669 show_bgp_view_neighbor_received_prefix_filter_cmd,
12670 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12671 SHOW_STR
12672 BGP_STR
12673 "BGP view\n"
12674 "View name\n"
12675 "Detailed information on TCP and BGP neighbor connections\n"
12676 "Neighbor to display information about\n"
12677 "Neighbor to display information about\n"
12678 "Display information received from a BGP neighbor\n"
12679 "Display the prefixlist filter\n")
12680{
12681 char name[BUFSIZ];
12682 union sockunion su;
12683 struct peer *peer;
12684 struct bgp *bgp;
12685 int count, ret;
12686
12687 /* BGP structure lookup. */
12688 bgp = bgp_lookup_by_name (argv[0]);
12689 if (bgp == NULL)
12690 {
12691 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
12692 return CMD_WARNING;
12693 }
12694
12695 ret = str2sockunion (argv[1], &su);
12696 if (ret < 0)
12697 {
12698 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
12699 return CMD_WARNING;
12700 }
12701
12702 peer = peer_lookup (bgp, &su);
12703 if (! peer)
12704 return CMD_WARNING;
12705
12706 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12707 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12708 if (count)
12709 {
12710 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12711 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12712 }
12713
12714 return CMD_SUCCESS;
12715}
12716
12717
12718DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
12719 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
12720 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
12721 SHOW_STR
12722 IP_STR
12723 BGP_STR
12724 "Address family\n"
12725 "Address Family modifier\n"
12726 "Address Family modifier\n"
12727 "Detailed information on TCP and BGP neighbor connections\n"
12728 "Neighbor to display information about\n"
12729 "Neighbor to display information about\n"
12730 "Display the received routes from neighbor\n")
12731{
12732 struct peer *peer;
12733
12734 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12735 if (! peer)
12736 return CMD_WARNING;
12737
12738 if (strncmp (argv[0], "m", 1) == 0)
12739 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
12740
12741 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12742}
12743
Lou Berger651b4022016-01-12 13:42:07 -050012744DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
12745 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
12746 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012747 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012748 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012749 "Address Family modifier\n"
12750 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012751 "Detailed information on TCP and BGP neighbor connections\n"
12752 "Neighbor to display information about\n"
12753 "Neighbor to display information about\n"
12754 "Display the routes advertised to a BGP neighbor\n")
12755{
12756 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012757 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012758
Lou Berger651b4022016-01-12 13:42:07 -050012759 if (bgp_parse_safi(argv[0], &safi)) {
12760 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012761 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050012762 }
paul718e3742002-12-13 20:15:29 +000012763
paulbb46e942003-10-24 19:02:03 +000012764 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12765 if (! peer)
12766 return CMD_WARNING;
12767
Lou Berger651b4022016-01-12 13:42:07 -050012768 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
12769}
Lou Berger205e6742016-01-12 13:42:11 -050012770
Lou Berger651b4022016-01-12 13:42:07 -050012771DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
12772 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
12773 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12774 SHOW_STR
12775 BGP_STR
12776 "Address Family modifier\n"
12777 "Address Family modifier\n"
12778 "Address Family modifier\n"
12779 "Detailed information on TCP and BGP neighbor connections\n"
12780 "Neighbor to display information about\n"
12781 "Neighbor to display information about\n"
12782 "Display the routes advertised to a BGP neighbor\n")
12783{
12784 struct peer *peer;
12785 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000012786
Lou Berger651b4022016-01-12 13:42:07 -050012787 if (bgp_parse_safi(argv[0], &safi)) {
12788 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12789 return CMD_WARNING;
12790 }
12791
12792 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12793 if (! peer)
12794 return CMD_WARNING;
12795
12796 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000012797}
12798
Lou Bergerf9b6c392016-01-12 13:42:09 -050012799DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050012800 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
12801 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000012802 SHOW_STR
12803 BGP_STR
12804 "BGP view\n"
12805 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050012806 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000012807 "Detailed information on TCP and BGP neighbor connections\n"
12808 "Neighbor to display information about\n"
12809 "Neighbor to display information about\n"
12810 "Display the routes advertised to a BGP neighbor\n")
12811{
12812 struct peer *peer;
12813
12814 if (argc == 2)
12815 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12816 else
12817 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12818
12819 if (! peer)
12820 return CMD_WARNING;
12821
12822 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12823}
12824
Lou Bergerf9b6c392016-01-12 13:42:09 -050012825DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050012826 show_bgp_view_ipv6_neighbor_received_routes_cmd,
12827 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000012828 SHOW_STR
12829 BGP_STR
12830 "BGP view\n"
12831 "View name\n"
12832 "Address family\n"
12833 "Detailed information on TCP and BGP neighbor connections\n"
12834 "Neighbor to display information about\n"
12835 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000012836 "Display the received routes from neighbor\n")
12837{
12838 struct peer *peer;
12839
12840 if (argc == 2)
12841 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12842 else
12843 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12844
12845 if (! peer)
12846 return CMD_WARNING;
12847
12848 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12849}
Lou Berger651b4022016-01-12 13:42:07 -050012850
12851DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
12852 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
12853 "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 +010012854 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012855 BGP_STR
12856 "Address family\n"
12857 "Address Family modifier\n"
12858 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012859 "Address Family modifier\n"
12860 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000012861 "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{
paulbb46e942003-10-24 19:02:03 +000012866 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012867 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 }
paul718e3742002-12-13 20:15:29 +000012873
paulbb46e942003-10-24 19:02:03 +000012874 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12875 if (! peer)
12876 return CMD_WARNING;
12877
Lou Berger651b4022016-01-12 13:42:07 -050012878 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000012879}
Lou Berger205e6742016-01-12 13:42:11 -050012880
Lou Berger651b4022016-01-12 13:42:07 -050012881DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
12882 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
12883 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
12884 SHOW_STR
12885 BGP_STR
12886 "Address family\n"
12887 "Address Family modifier\n"
12888 "Address Family modifier\n"
12889 "Address Family modifier\n"
12890 "Address Family modifier\n"
12891 "Detailed information on TCP and BGP neighbor connections\n"
12892 "Neighbor to display information about\n"
12893 "Neighbor to display information about\n"
12894 "Display the received routes from neighbor\n")
12895{
12896 struct peer *peer;
12897 safi_t safi;
12898
12899 if (bgp_parse_safi(argv[0], &safi)) {
12900 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12901 return CMD_WARNING;
12902 }
12903
12904 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12905 if (! peer)
12906 return CMD_WARNING;
12907
12908 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
12909}
paul718e3742002-12-13 20:15:29 +000012910
Michael Lambert95cbbd22010-07-23 14:43:04 -040012911DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
12912 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040012913 "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 -040012914 SHOW_STR
12915 BGP_STR
12916 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000012917 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012918 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012919 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012920 "Address family modifier\n"
12921 "Address family modifier\n"
12922 "Detailed information on TCP and BGP neighbor connections\n"
12923 "Neighbor to display information about\n"
12924 "Neighbor to display information about\n"
12925 "Display the advertised routes to neighbor\n"
12926 "Display the received routes from neighbor\n")
12927{
12928 int afi;
12929 int safi;
12930 int in;
12931 struct peer *peer;
12932
David Lamparter94bad672015-03-03 08:52:22 +010012933 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040012934
12935 if (! peer)
12936 return CMD_WARNING;
12937
Michael Lambert95cbbd22010-07-23 14:43:04 -040012938 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12939 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12940 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040012941
12942 return peer_adj_routes (vty, peer, afi, safi, in);
12943}
12944
Lou Bergerf9b6c392016-01-12 13:42:09 -050012945DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
12946 show_ip_bgp_neighbor_received_prefix_filter_cmd,
12947 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12948 SHOW_STR
12949 IP_STR
12950 BGP_STR
12951 "Detailed information on TCP and BGP neighbor connections\n"
12952 "Neighbor to display information about\n"
12953 "Neighbor to display information about\n"
12954 "Display information received from a BGP neighbor\n"
12955 "Display the prefixlist filter\n")
12956{
12957 char name[BUFSIZ];
12958 union sockunion su;
12959 struct peer *peer;
12960 int count, ret;
12961
12962 ret = str2sockunion (argv[0], &su);
12963 if (ret < 0)
12964 {
12965 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12966 return CMD_WARNING;
12967 }
12968
12969 peer = peer_lookup (NULL, &su);
12970 if (! peer)
12971 return CMD_WARNING;
12972
12973 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
12974 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
12975 if (count)
12976 {
12977 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
12978 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
12979 }
12980
12981 return CMD_SUCCESS;
12982}
12983
12984DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
12985 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
12986 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12987 SHOW_STR
12988 IP_STR
12989 BGP_STR
12990 "Address family\n"
12991 "Address Family modifier\n"
12992 "Address Family modifier\n"
12993 "Detailed information on TCP and BGP neighbor connections\n"
12994 "Neighbor to display information about\n"
12995 "Neighbor to display information about\n"
12996 "Display information received from a BGP neighbor\n"
12997 "Display the prefixlist filter\n")
12998{
12999 char name[BUFSIZ];
13000 union sockunion su;
13001 struct peer *peer;
13002 int count, ret;
13003
13004 ret = str2sockunion (argv[1], &su);
13005 if (ret < 0)
13006 {
13007 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13008 return CMD_WARNING;
13009 }
13010
13011 peer = peer_lookup (NULL, &su);
13012 if (! peer)
13013 return CMD_WARNING;
13014
13015 if (strncmp (argv[0], "m", 1) == 0)
13016 {
13017 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
13018 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13019 if (count)
13020 {
13021 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
13022 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13023 }
13024 }
13025 else
13026 {
13027 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13028 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13029 if (count)
13030 {
13031 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13032 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13033 }
13034 }
13035
13036 return CMD_SUCCESS;
13037}
13038
13039ALIAS (show_bgp_view_neighbor_received_routes,
13040 show_bgp_neighbor_received_routes_cmd,
13041 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13042 SHOW_STR
13043 BGP_STR
13044 "Detailed information on TCP and BGP neighbor connections\n"
13045 "Neighbor to display information about\n"
13046 "Neighbor to display information about\n"
13047 "Display the received routes from neighbor\n")
13048
Lou Berger651b4022016-01-12 13:42:07 -050013049DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
13050 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
13051 "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 +000013052 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013053 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013054 IP_STR
13055 "Address Family modifier\n"
13056 "Address Family modifier\n"
13057 "Address Family modifier\n"
13058 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013059 "Detailed information on TCP and BGP neighbor connections\n"
13060 "Neighbor to display information about\n"
13061 "Neighbor to display information about\n"
13062 "Display information received from a BGP neighbor\n"
13063 "Display the prefixlist filter\n")
13064{
13065 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013066 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013067 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013068 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050013069 safi_t safi;
paul718e3742002-12-13 20:15:29 +000013070
Lou Berger651b4022016-01-12 13:42:07 -050013071 if (bgp_parse_safi(argv[0], &safi)) {
13072 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013073 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013074 }
paul718e3742002-12-13 20:15:29 +000013075
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013076 ret = str2sockunion (argv[1], &su);
13077 if (ret < 0)
13078 {
13079 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13080 return CMD_WARNING;
13081 }
paul718e3742002-12-13 20:15:29 +000013082
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013083 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013084 if (! peer)
13085 return CMD_WARNING;
13086
Lou Berger651b4022016-01-12 13:42:07 -050013087 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
13088 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13089 if (count) {
13090 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
13091 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13092 }
paul718e3742002-12-13 20:15:29 +000013093
13094 return CMD_SUCCESS;
13095}
Lou Berger205e6742016-01-12 13:42:11 -050013096
Lou Berger651b4022016-01-12 13:42:07 -050013097DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
13098 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
13099 "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 +000013100 SHOW_STR
13101 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013102 IP_STR
13103 "Address Family modifier\n"
13104 "Address Family modifier\n"
13105 "Address Family modifier\n"
13106 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013107 "Detailed information on TCP and BGP neighbor connections\n"
13108 "Neighbor to display information about\n"
13109 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050013110 "Display information received from a BGP neighbor\n"
13111 "Display the prefixlist filter\n")
13112{
13113 char name[BUFSIZ];
13114 union sockunion su;
13115 struct peer *peer;
13116 int count, ret;
13117 safi_t safi;
13118
13119 if (bgp_parse_safi(argv[0], &safi)) {
13120 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13121 return CMD_WARNING;
13122 }
13123
13124 ret = str2sockunion (argv[1], &su);
13125 if (ret < 0)
13126 {
13127 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13128 return CMD_WARNING;
13129 }
13130
13131 peer = peer_lookup (NULL, &su);
13132 if (! peer)
13133 return CMD_WARNING;
13134
13135 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
13136 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13137 if (count) {
13138 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
13139 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13140 }
13141
13142 return CMD_SUCCESS;
13143}
paul718e3742002-12-13 20:15:29 +000013144
Lou Bergerf9b6c392016-01-12 13:42:09 -050013145DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013146 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
13147 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013148 SHOW_STR
13149 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013150 "Address family\n"
paul718e3742002-12-13 20:15:29 +000013151 "Detailed information on TCP and BGP neighbor connections\n"
13152 "Neighbor to display information about\n"
13153 "Neighbor to display information about\n"
13154 "Display information received from a BGP neighbor\n"
13155 "Display the prefixlist filter\n")
13156{
13157 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013158 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013159 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013160 int count, ret;
paul718e3742002-12-13 20:15:29 +000013161
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013162 ret = str2sockunion (argv[0], &su);
13163 if (ret < 0)
13164 {
13165 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13166 return CMD_WARNING;
13167 }
paul718e3742002-12-13 20:15:29 +000013168
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013169 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013170 if (! peer)
13171 return CMD_WARNING;
13172
13173 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13174 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13175 if (count)
13176 {
13177 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13178 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13179 }
13180
13181 return CMD_SUCCESS;
13182}
13183
Lou Bergerf9b6c392016-01-12 13:42:09 -050013184DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013185 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
13186 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000013187 SHOW_STR
13188 BGP_STR
13189 "BGP view\n"
13190 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013191 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013192 "Detailed information on TCP and BGP neighbor connections\n"
13193 "Neighbor to display information about\n"
13194 "Neighbor to display information about\n"
13195 "Display information received from a BGP neighbor\n"
13196 "Display the prefixlist filter\n")
13197{
13198 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013199 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000013200 struct peer *peer;
13201 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013202 int count, ret;
paulbb46e942003-10-24 19:02:03 +000013203
13204 /* BGP structure lookup. */
13205 bgp = bgp_lookup_by_name (argv[0]);
13206 if (bgp == NULL)
13207 {
13208 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13209 return CMD_WARNING;
13210 }
13211
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013212 ret = str2sockunion (argv[1], &su);
13213 if (ret < 0)
13214 {
13215 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13216 return CMD_WARNING;
13217 }
paulbb46e942003-10-24 19:02:03 +000013218
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013219 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000013220 if (! peer)
13221 return CMD_WARNING;
13222
13223 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13224 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13225 if (count)
13226 {
13227 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13228 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13229 }
13230
13231 return CMD_SUCCESS;
13232}
David Lamparter6b0655a2014-06-04 06:53:35 +020013233
paul94f2b392005-06-28 12:44:16 +000013234static int
paulbb46e942003-10-24 19:02:03 +000013235bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000013236 safi_t safi, enum bgp_show_type type)
13237{
paul718e3742002-12-13 20:15:29 +000013238 if (! peer || ! peer->afc[afi][safi])
13239 {
13240 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013241 return CMD_WARNING;
13242 }
13243
ajs5a646652004-11-05 01:25:55 +000013244 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000013245}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013246DEFUN (show_ip_bgp_neighbor_routes,
13247 show_ip_bgp_neighbor_routes_cmd,
13248 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
13249 SHOW_STR
13250 IP_STR
13251 BGP_STR
13252 "Detailed information on TCP and BGP neighbor connections\n"
13253 "Neighbor to display information about\n"
13254 "Neighbor to display information about\n"
13255 "Display routes learned from neighbor\n")
13256{
13257 struct peer *peer;
13258
13259 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13260 if (! peer)
13261 return CMD_WARNING;
13262
13263 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13264 bgp_show_type_neighbor);
13265}
13266
13267DEFUN (show_ip_bgp_neighbor_flap,
13268 show_ip_bgp_neighbor_flap_cmd,
13269 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
13270 SHOW_STR
13271 IP_STR
13272 BGP_STR
13273 "Detailed information on TCP and BGP neighbor connections\n"
13274 "Neighbor to display information about\n"
13275 "Neighbor to display information about\n"
13276 "Display flap statistics of the routes learned from neighbor\n")
13277{
13278 struct peer *peer;
13279
13280 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13281 if (! peer)
13282 return CMD_WARNING;
13283
13284 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13285 bgp_show_type_flap_neighbor);
13286}
13287
13288DEFUN (show_ip_bgp_neighbor_damp,
13289 show_ip_bgp_neighbor_damp_cmd,
13290 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13291 SHOW_STR
13292 IP_STR
13293 BGP_STR
13294 "Detailed information on TCP and BGP neighbor connections\n"
13295 "Neighbor to display information about\n"
13296 "Neighbor to display information about\n"
13297 "Display the dampened routes received from neighbor\n")
13298{
13299 struct peer *peer;
13300
13301 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13302 if (! peer)
13303 return CMD_WARNING;
13304
13305 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13306 bgp_show_type_damp_neighbor);
13307}
13308
13309DEFUN (show_ip_bgp_ipv4_neighbor_routes,
13310 show_ip_bgp_ipv4_neighbor_routes_cmd,
13311 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
13312 SHOW_STR
13313 IP_STR
13314 BGP_STR
13315 "Address family\n"
13316 "Address Family modifier\n"
13317 "Address Family modifier\n"
13318 "Detailed information on TCP and BGP neighbor connections\n"
13319 "Neighbor to display information about\n"
13320 "Neighbor to display information about\n"
13321 "Display routes learned from neighbor\n")
13322{
13323 struct peer *peer;
13324
13325 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13326 if (! peer)
13327 return CMD_WARNING;
13328
13329 if (strncmp (argv[0], "m", 1) == 0)
13330 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
13331 bgp_show_type_neighbor);
13332
13333 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13334 bgp_show_type_neighbor);
13335}
13336
13337DEFUN (show_ip_bgp_view_rsclient,
13338 show_ip_bgp_view_rsclient_cmd,
13339 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
13340 SHOW_STR
13341 IP_STR
13342 BGP_STR
13343 "BGP view\n"
13344 "View name\n"
13345 "Information about Route Server Client\n"
13346 NEIGHBOR_ADDR_STR)
13347{
13348 struct bgp_table *table;
13349 struct peer *peer;
13350
13351 if (argc == 2)
13352 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13353 else
13354 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13355
13356 if (! peer)
13357 return CMD_WARNING;
13358
13359 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13360 {
13361 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13362 VTY_NEWLINE);
13363 return CMD_WARNING;
13364 }
13365
13366 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13367 PEER_FLAG_RSERVER_CLIENT))
13368 {
13369 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13370 VTY_NEWLINE);
13371 return CMD_WARNING;
13372 }
13373
13374 table = peer->rib[AFI_IP][SAFI_UNICAST];
13375
13376 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13377}
13378
13379ALIAS (show_ip_bgp_view_rsclient,
13380 show_ip_bgp_rsclient_cmd,
13381 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
13382 SHOW_STR
13383 IP_STR
13384 BGP_STR
13385 "Information about Route Server Client\n"
13386 NEIGHBOR_ADDR_STR)
13387
13388DEFUN (show_bgp_view_ipv4_safi_rsclient,
13389 show_bgp_view_ipv4_safi_rsclient_cmd,
13390 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13391 SHOW_STR
13392 BGP_STR
13393 "BGP view\n"
13394 "View name\n"
13395 "Address family\n"
13396 "Address Family modifier\n"
13397 "Address Family modifier\n"
13398 "Information about Route Server Client\n"
13399 NEIGHBOR_ADDR_STR)
13400{
13401 struct bgp_table *table;
13402 struct peer *peer;
13403 safi_t safi;
13404
13405 if (argc == 3) {
13406 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13407 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13408 } else {
13409 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13410 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13411 }
13412
13413 if (! peer)
13414 return CMD_WARNING;
13415
13416 if (! peer->afc[AFI_IP][safi])
13417 {
13418 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13419 VTY_NEWLINE);
13420 return CMD_WARNING;
13421 }
13422
13423 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13424 PEER_FLAG_RSERVER_CLIENT))
13425 {
13426 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13427 VTY_NEWLINE);
13428 return CMD_WARNING;
13429 }
13430
13431 table = peer->rib[AFI_IP][safi];
13432
13433 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13434}
13435
13436ALIAS (show_bgp_view_ipv4_safi_rsclient,
13437 show_bgp_ipv4_safi_rsclient_cmd,
13438 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13439 SHOW_STR
13440 BGP_STR
13441 "Address family\n"
13442 "Address Family modifier\n"
13443 "Address Family modifier\n"
13444 "Information about Route Server Client\n"
13445 NEIGHBOR_ADDR_STR)
13446
13447DEFUN (show_ip_bgp_view_rsclient_route,
13448 show_ip_bgp_view_rsclient_route_cmd,
13449 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13450 SHOW_STR
13451 IP_STR
13452 BGP_STR
13453 "BGP view\n"
13454 "View name\n"
13455 "Information about Route Server Client\n"
13456 NEIGHBOR_ADDR_STR
13457 "Network in the BGP routing table to display\n")
13458{
13459 struct bgp *bgp;
13460 struct peer *peer;
13461
13462 /* BGP structure lookup. */
13463 if (argc == 3)
13464 {
13465 bgp = bgp_lookup_by_name (argv[0]);
13466 if (bgp == NULL)
13467 {
13468 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13469 return CMD_WARNING;
13470 }
13471 }
13472 else
13473 {
13474 bgp = bgp_get_default ();
13475 if (bgp == NULL)
13476 {
13477 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13478 return CMD_WARNING;
13479 }
13480 }
13481
13482 if (argc == 3)
13483 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13484 else
13485 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13486
13487 if (! peer)
13488 return CMD_WARNING;
13489
13490 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13491 {
13492 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13493 VTY_NEWLINE);
13494 return CMD_WARNING;
13495}
13496
13497 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13498 PEER_FLAG_RSERVER_CLIENT))
13499 {
13500 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13501 VTY_NEWLINE);
13502 return CMD_WARNING;
13503 }
13504
13505 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13506 (argc == 3) ? argv[2] : argv[1],
13507 AFI_IP, SAFI_UNICAST, NULL, 0);
13508}
13509
13510ALIAS (show_ip_bgp_view_rsclient_route,
13511 show_ip_bgp_rsclient_route_cmd,
13512 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13513 SHOW_STR
13514 IP_STR
13515 BGP_STR
13516 "Information about Route Server Client\n"
13517 NEIGHBOR_ADDR_STR
13518 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000013519
Lou Berger651b4022016-01-12 13:42:07 -050013520DEFUN (show_bgp_ipv4_safi_neighbor_flap,
13521 show_bgp_ipv4_safi_neighbor_flap_cmd,
13522 "show bgp ipv4 (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"
paul718e3742002-12-13 20:15:29 +000013529 "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{
paulbb46e942003-10-24 19:02:03 +000013534 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013535 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013536
Lou Berger651b4022016-01-12 13:42:07 -050013537 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]);
paulbb46e942003-10-24 19:02:03 +000013543 if (! peer)
13544 return CMD_WARNING;
13545
Lou Berger651b4022016-01-12 13:42:07 -050013546 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013547 bgp_show_type_flap_neighbor);
13548}
Lou Berger205e6742016-01-12 13:42:11 -050013549
Lou Berger651b4022016-01-12 13:42:07 -050013550DEFUN (show_bgp_ipv6_safi_neighbor_flap,
13551 show_bgp_ipv6_safi_neighbor_flap_cmd,
13552 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013553 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013554 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013555 "Address Family Modifier\n"
13556 "Address Family Modifier\n"
13557 "Address Family Modifier\n"
13558 "Address Family Modifier\n"
13559 "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 flap statistics of the routes learned from neighbor\n")
13563{
13564 struct peer *peer;
13565 safi_t safi;
13566
13567 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]);
13573 if (! peer)
13574 return CMD_WARNING;
13575
13576 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13577 bgp_show_type_flap_neighbor);
13578}
Lou Berger651b4022016-01-12 13:42:07 -050013579
13580DEFUN (show_bgp_ipv4_safi_neighbor_damp,
13581 show_bgp_ipv4_safi_neighbor_damp_cmd,
13582 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13583 SHOW_STR
13584 BGP_STR
13585 "Address Family Modifier\n"
13586 "Address Family Modifier\n"
13587 "Address Family Modifier\n"
13588 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013589 "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{
paulbb46e942003-10-24 19:02:03 +000013594 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013595 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013596
Lou Berger651b4022016-01-12 13:42:07 -050013597 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]);
paulbb46e942003-10-24 19:02:03 +000013603 if (! peer)
13604 return CMD_WARNING;
13605
Lou Berger651b4022016-01-12 13:42:07 -050013606 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013607 bgp_show_type_damp_neighbor);
13608}
Lou Berger205e6742016-01-12 13:42:11 -050013609
Lou Berger651b4022016-01-12 13:42:07 -050013610DEFUN (show_bgp_ipv6_safi_neighbor_damp,
13611 show_bgp_ipv6_safi_neighbor_damp_cmd,
13612 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000013613 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050013614 BGP_STR
13615 "Address Family Modifier\n"
13616 "Address Family Modifier\n"
13617 "Address Family Modifier\n"
13618 "Address Family Modifier\n"
13619 "Detailed information on TCP and BGP neighbor connections\n"
13620 "Neighbor to display information about\n"
13621 "Neighbor to display information about\n"
13622 "Display the dampened routes received from neighbor\n")
13623{
13624 struct peer *peer;
13625 safi_t safi;
13626
13627 if (bgp_parse_safi(argv[0], &safi)) {
13628 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13629 return CMD_WARNING;
13630 }
13631
13632 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13633 if (! peer)
13634 return CMD_WARNING;
13635
13636 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13637 bgp_show_type_damp_neighbor);
13638}
Lou Berger651b4022016-01-12 13:42:07 -050013639
13640DEFUN (show_bgp_ipv4_safi_neighbor_routes,
13641 show_bgp_ipv4_safi_neighbor_routes_cmd,
13642 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
13643 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013644 BGP_STR
13645 "Address family\n"
13646 "Address Family modifier\n"
13647 "Address Family modifier\n"
13648 "Detailed information on TCP and BGP neighbor connections\n"
13649 "Neighbor to display information about\n"
13650 "Neighbor to display information about\n"
13651 "Display routes learned from neighbor\n")
13652{
paulbb46e942003-10-24 19:02:03 +000013653 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013654 safi_t safi;
13655
13656 if (bgp_parse_safi(argv[0], &safi)) {
13657 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13658 return CMD_WARNING;
13659 }
paulbb46e942003-10-24 19:02:03 +000013660
13661 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13662 if (! peer)
13663 return CMD_WARNING;
13664
Lou Berger651b4022016-01-12 13:42:07 -050013665 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013666 bgp_show_type_neighbor);
13667}
Lou Berger205e6742016-01-12 13:42:11 -050013668
Lou Berger651b4022016-01-12 13:42:07 -050013669DEFUN (show_bgp_ipv6_safi_neighbor_routes,
13670 show_bgp_ipv6_safi_neighbor_routes_cmd,
13671 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000013672 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000013673 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013674 "Address family\n"
13675 "Address Family modifier\n"
13676 "Address Family modifier\n"
13677 "Detailed information on TCP and BGP neighbor connections\n"
13678 NEIGHBOR_ADDR_STR
13679 NEIGHBOR_ADDR_STR
13680 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000013681{
paulfee0f4c2004-09-13 05:12:46 +000013682 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013683 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000013684
Lou Berger651b4022016-01-12 13:42:07 -050013685 if (bgp_parse_safi(argv[0], &safi)) {
13686 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13687 return CMD_WARNING;
13688 }
paulfee0f4c2004-09-13 05:12:46 +000013689
Lou Berger651b4022016-01-12 13:42:07 -050013690 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000013691 if (! peer)
13692 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013693
13694 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13695 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000013696}
paulfee0f4c2004-09-13 05:12:46 +000013697
Michael Lambert95cbbd22010-07-23 14:43:04 -040013698DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
13699 show_bgp_view_ipv4_safi_rsclient_route_cmd,
13700 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13701 SHOW_STR
13702 BGP_STR
13703 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013704 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013705 "Address family\n"
13706 "Address Family modifier\n"
13707 "Address Family modifier\n"
13708 "Information about Route Server Client\n"
13709 NEIGHBOR_ADDR_STR
13710 "Network in the BGP routing table to display\n")
13711{
13712 struct bgp *bgp;
13713 struct peer *peer;
13714 safi_t safi;
13715
13716 /* BGP structure lookup. */
13717 if (argc == 4)
13718 {
13719 bgp = bgp_lookup_by_name (argv[0]);
13720 if (bgp == NULL)
13721 {
13722 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13723 return CMD_WARNING;
13724 }
13725 }
13726 else
13727 {
13728 bgp = bgp_get_default ();
13729 if (bgp == NULL)
13730 {
13731 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13732 return CMD_WARNING;
13733 }
13734 }
13735
13736 if (argc == 4) {
13737 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13738 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13739 } else {
13740 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13741 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13742 }
13743
13744 if (! peer)
13745 return CMD_WARNING;
13746
13747 if (! peer->afc[AFI_IP][safi])
13748 {
13749 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13750 VTY_NEWLINE);
13751 return CMD_WARNING;
13752}
13753
13754 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13755 PEER_FLAG_RSERVER_CLIENT))
13756 {
13757 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13758 VTY_NEWLINE);
13759 return CMD_WARNING;
13760 }
13761
13762 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13763 (argc == 4) ? argv[3] : argv[2],
13764 AFI_IP, safi, NULL, 0);
13765}
13766
13767ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
13768 show_bgp_ipv4_safi_rsclient_route_cmd,
13769 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13770 SHOW_STR
13771 BGP_STR
13772 "Address family\n"
13773 "Address Family modifier\n"
13774 "Address Family modifier\n"
13775 "Information about Route Server Client\n"
13776 NEIGHBOR_ADDR_STR
13777 "Network in the BGP routing table to display\n")
13778
paulfee0f4c2004-09-13 05:12:46 +000013779
Michael Lambert95cbbd22010-07-23 14:43:04 -040013780DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
13781 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
13782 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13783 SHOW_STR
13784 BGP_STR
13785 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013786 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013787 "Address family\n"
13788 "Address Family modifier\n"
13789 "Address Family modifier\n"
13790 "Information about Route Server Client\n"
13791 NEIGHBOR_ADDR_STR
13792 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13793{
13794 struct bgp *bgp;
13795 struct peer *peer;
13796 safi_t safi;
13797
13798 /* BGP structure lookup. */
13799 if (argc == 4)
13800 {
13801 bgp = bgp_lookup_by_name (argv[0]);
13802 if (bgp == NULL)
13803 {
13804 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13805 return CMD_WARNING;
13806 }
13807 }
13808 else
13809 {
13810 bgp = bgp_get_default ();
13811 if (bgp == NULL)
13812 {
13813 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13814 return CMD_WARNING;
13815 }
13816 }
13817
13818 if (argc == 4) {
13819 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13820 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13821 } else {
13822 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13823 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13824 }
13825
13826 if (! peer)
13827 return CMD_WARNING;
13828
13829 if (! peer->afc[AFI_IP][safi])
13830 {
13831 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13832 VTY_NEWLINE);
13833 return CMD_WARNING;
13834}
13835
13836 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13837 PEER_FLAG_RSERVER_CLIENT))
13838{
13839 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13840 VTY_NEWLINE);
13841 return CMD_WARNING;
13842 }
13843
13844 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13845 (argc == 4) ? argv[3] : argv[2],
13846 AFI_IP, safi, NULL, 1);
13847}
13848
Lou Bergerf9b6c392016-01-12 13:42:09 -050013849DEFUN (show_ip_bgp_view_rsclient_prefix,
13850 show_ip_bgp_view_rsclient_prefix_cmd,
13851 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13852 SHOW_STR
13853 IP_STR
13854 BGP_STR
13855 "BGP view\n"
13856 "View name\n"
13857 "Information about Route Server Client\n"
13858 NEIGHBOR_ADDR_STR
13859 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13860{
13861 struct bgp *bgp;
13862 struct peer *peer;
13863
13864 /* BGP structure lookup. */
13865 if (argc == 3)
13866 {
13867 bgp = bgp_lookup_by_name (argv[0]);
13868 if (bgp == NULL)
13869 {
13870 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13871 return CMD_WARNING;
13872 }
13873 }
13874 else
13875 {
13876 bgp = bgp_get_default ();
13877 if (bgp == NULL)
13878 {
13879 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13880 return CMD_WARNING;
13881 }
13882 }
13883
13884 if (argc == 3)
13885 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13886 else
13887 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13888
13889 if (! peer)
13890 return CMD_WARNING;
13891
13892 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13893 {
13894 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13895 VTY_NEWLINE);
13896 return CMD_WARNING;
13897}
13898
13899 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13900 PEER_FLAG_RSERVER_CLIENT))
13901{
13902 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13903 VTY_NEWLINE);
13904 return CMD_WARNING;
13905 }
13906
13907 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13908 (argc == 3) ? argv[2] : argv[1],
13909 AFI_IP, SAFI_UNICAST, NULL, 1);
13910}
13911
13912ALIAS (show_ip_bgp_view_rsclient_prefix,
13913 show_ip_bgp_rsclient_prefix_cmd,
13914 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13915 SHOW_STR
13916 IP_STR
13917 BGP_STR
13918 "Information about Route Server Client\n"
13919 NEIGHBOR_ADDR_STR
13920 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13921
Michael Lambert95cbbd22010-07-23 14:43:04 -040013922ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
13923 show_bgp_ipv4_safi_rsclient_prefix_cmd,
13924 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13925 SHOW_STR
13926 BGP_STR
13927 "Address family\n"
13928 "Address Family modifier\n"
13929 "Address Family modifier\n"
13930 "Information about Route Server Client\n"
13931 NEIGHBOR_ADDR_STR
13932 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000013933
Lou Bergerf9b6c392016-01-12 13:42:09 -050013934DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050013935 show_bgp_view_ipv6_neighbor_routes_cmd,
13936 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +000013937 SHOW_STR
13938 BGP_STR
13939 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013940 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013941 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013942 "Detailed information on TCP and BGP neighbor connections\n"
13943 "Neighbor to display information about\n"
13944 "Neighbor to display information about\n"
13945 "Display routes learned from neighbor\n")
13946{
13947 struct peer *peer;
13948
13949 if (argc == 2)
13950 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13951 else
13952 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13953
13954 if (! peer)
13955 return CMD_WARNING;
13956
13957 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13958 bgp_show_type_neighbor);
13959}
13960
Lou Berger651b4022016-01-12 13:42:07 -050013961DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050013962 show_bgp_view_neighbor_damp_cmd,
13963 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13964 SHOW_STR
13965 BGP_STR
13966 "BGP view\n"
13967 "View name\n"
13968 "Detailed information on TCP and BGP neighbor connections\n"
13969 "Neighbor to display information about\n"
13970 "Neighbor to display information about\n"
13971 "Display the dampened routes received from neighbor\n")
13972{
13973 struct peer *peer;
13974
13975 if (argc == 2)
13976 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13977 else
13978 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13979
13980 if (! peer)
13981 return CMD_WARNING;
13982
13983 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13984 bgp_show_type_damp_neighbor);
13985}
13986
13987DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050013988 show_bgp_view_ipv6_neighbor_damp_cmd,
13989 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000013990 SHOW_STR
13991 BGP_STR
13992 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013993 "View name\n"
paulbb46e942003-10-24 19:02:03 +000013994 "Address family\n"
13995 "Detailed information on TCP and BGP neighbor connections\n"
13996 "Neighbor to display information about\n"
13997 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000013998 "Display the dampened routes received from neighbor\n")
13999{
14000 struct peer *peer;
14001
14002 if (argc == 2)
14003 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14004 else
14005 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14006
14007 if (! peer)
14008 return CMD_WARNING;
14009
14010 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14011 bgp_show_type_damp_neighbor);
14012}
14013
Lou Bergerf9b6c392016-01-12 13:42:09 -050014014DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050014015 show_bgp_view_ipv6_neighbor_flap_cmd,
14016 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000014017 SHOW_STR
14018 BGP_STR
14019 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014020 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014021 "Address family\n"
14022 "Detailed information on TCP and BGP neighbor connections\n"
14023 "Neighbor to display information about\n"
14024 "Neighbor to display information about\n"
14025 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000014026{
14027 struct peer *peer;
14028
14029 if (argc == 2)
14030 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14031 else
14032 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14033
14034 if (! peer)
14035 return CMD_WARNING;
14036
14037 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14038 bgp_show_type_flap_neighbor);
14039}
14040
Lou Bergerf9b6c392016-01-12 13:42:09 -050014041DEFUN (show_bgp_view_neighbor_flap,
14042 show_bgp_view_neighbor_flap_cmd,
14043 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14044 SHOW_STR
14045 BGP_STR
14046 "BGP view\n"
14047 "View name\n"
14048 "Detailed information on TCP and BGP neighbor connections\n"
14049 "Neighbor to display information about\n"
14050 "Neighbor to display information about\n"
14051 "Display flap statistics of the routes learned from neighbor\n")
14052{
14053 struct peer *peer;
14054
14055 if (argc == 2)
14056 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14057 else
14058 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14059
14060 if (! peer)
14061 return CMD_WARNING;
14062
14063 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14064 bgp_show_type_flap_neighbor);
14065}
14066
14067ALIAS (show_bgp_view_neighbor_flap,
14068 show_bgp_neighbor_flap_cmd,
14069 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14070 SHOW_STR
14071 BGP_STR
14072 "Detailed information on TCP and BGP neighbor connections\n"
14073 "Neighbor to display information about\n"
14074 "Neighbor to display information about\n"
14075 "Display flap statistics of the routes learned from neighbor\n")
14076
14077ALIAS (show_bgp_view_neighbor_damp,
14078 show_bgp_neighbor_damp_cmd,
14079 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14080 SHOW_STR
14081 BGP_STR
14082 "Detailed information on TCP and BGP neighbor connections\n"
14083 "Neighbor to display information about\n"
14084 "Neighbor to display information about\n"
14085 "Display the dampened routes received from neighbor\n")
14086
14087DEFUN (show_bgp_view_neighbor_routes,
14088 show_bgp_view_neighbor_routes_cmd,
14089 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
14090 SHOW_STR
14091 BGP_STR
14092 "BGP view\n"
14093 "View name\n"
14094 "Detailed information on TCP and BGP neighbor connections\n"
14095 "Neighbor to display information about\n"
14096 "Neighbor to display information about\n"
14097 "Display routes learned from neighbor\n")
14098{
14099 struct peer *peer;
14100
14101 if (argc == 2)
14102 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14103 else
14104 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14105
14106 if (! peer)
14107 return CMD_WARNING;
14108
14109 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14110 bgp_show_type_neighbor);
14111}
14112
14113ALIAS (show_bgp_view_neighbor_routes,
14114 show_bgp_neighbor_routes_cmd,
14115 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
14116 SHOW_STR
14117 BGP_STR
14118 "Detailed information on TCP and BGP neighbor connections\n"
14119 "Neighbor to display information about\n"
14120 "Neighbor to display information about\n"
14121 "Display routes learned from neighbor\n")
14122
paulbb46e942003-10-24 19:02:03 +000014123ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000014124 show_bgp_ipv6_neighbor_routes_cmd,
14125 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
14126 SHOW_STR
14127 BGP_STR
14128 "Address family\n"
14129 "Detailed information on TCP and BGP neighbor connections\n"
14130 "Neighbor to display information about\n"
14131 "Neighbor to display information about\n"
14132 "Display routes learned from neighbor\n")
14133
Lou Bergerf9b6c392016-01-12 13:42:09 -050014134/* old command */
14135ALIAS (show_bgp_view_neighbor_routes,
14136 ipv6_bgp_neighbor_routes_cmd,
14137 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
14138 SHOW_STR
14139 IPV6_STR
14140 BGP_STR
14141 "Detailed information on TCP and BGP neighbor connections\n"
14142 "Neighbor to display information about\n"
14143 "Neighbor to display information about\n"
14144 "Display routes learned from neighbor\n")
14145
14146/* old command */
14147DEFUN (ipv6_mbgp_neighbor_routes,
14148 ipv6_mbgp_neighbor_routes_cmd,
14149 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
14150 SHOW_STR
14151 IPV6_STR
14152 MBGP_STR
14153 "Detailed information on TCP and BGP neighbor connections\n"
14154 "Neighbor to display information about\n"
14155 "Neighbor to display information about\n"
14156 "Display routes learned from neighbor\n")
14157{
14158 struct peer *peer;
14159
14160 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14161 if (! peer)
14162 return CMD_WARNING;
14163
14164 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
14165 bgp_show_type_neighbor);
14166}
14167
paulbb46e942003-10-24 19:02:03 +000014168ALIAS (show_bgp_view_neighbor_flap,
14169 show_bgp_ipv6_neighbor_flap_cmd,
14170 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14171 SHOW_STR
14172 BGP_STR
14173 "Address family\n"
14174 "Detailed information on TCP and BGP neighbor connections\n"
14175 "Neighbor to display information about\n"
14176 "Neighbor to display information about\n"
14177 "Display flap statistics of the routes learned from neighbor\n")
14178
14179ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000014180 show_bgp_ipv6_neighbor_damp_cmd,
14181 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14182 SHOW_STR
14183 BGP_STR
14184 "Address family\n"
14185 "Detailed information on TCP and BGP neighbor connections\n"
14186 "Neighbor to display information about\n"
14187 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000014188 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014189
Lou Bergerf9b6c392016-01-12 13:42:09 -050014190DEFUN (show_bgp_view_rsclient,
14191 show_bgp_view_rsclient_cmd,
14192 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14193 SHOW_STR
14194 BGP_STR
14195 "BGP view\n"
14196 "View name\n"
14197 "Information about Route Server Client\n"
14198 NEIGHBOR_ADDR_STR)
14199{
14200 struct bgp_table *table;
14201 struct peer *peer;
14202
14203 if (argc == 2)
14204 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14205 else
14206 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14207
14208 if (! peer)
14209 return CMD_WARNING;
14210
14211 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14212 {
14213 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14214 VTY_NEWLINE);
14215 return CMD_WARNING;
14216 }
14217
14218 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14219 PEER_FLAG_RSERVER_CLIENT))
14220 {
14221 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14222 VTY_NEWLINE);
14223 return CMD_WARNING;
14224 }
14225
14226 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14227
14228 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14229}
14230
14231ALIAS (show_bgp_view_rsclient,
14232 show_bgp_rsclient_cmd,
14233 "show bgp rsclient (A.B.C.D|X:X::X:X)",
14234 SHOW_STR
14235 BGP_STR
14236 "Information about Route Server Client\n"
14237 NEIGHBOR_ADDR_STR)
14238
Lou Berger651b4022016-01-12 13:42:07 -050014239DEFUN (show_bgp_view_ipv4_rsclient,
14240 show_bgp_view_ipv4_rsclient_cmd,
14241 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014242 SHOW_STR
14243 BGP_STR
14244 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014245 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014246 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014247 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014248 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014249{
Lou Berger651b4022016-01-12 13:42:07 -050014250 struct bgp_table *table;
14251 struct peer *peer;
14252
14253 if (argc == 2)
14254 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14255 else
14256 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14257
14258 if (! peer)
14259 return CMD_WARNING;
14260
14261 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14262 {
14263 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14264 VTY_NEWLINE);
14265 return CMD_WARNING;
14266 }
14267
14268 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14269 PEER_FLAG_RSERVER_CLIENT))
14270 {
14271 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14272 VTY_NEWLINE);
14273 return CMD_WARNING;
14274 }
14275
14276 table = peer->rib[AFI_IP][SAFI_UNICAST];
14277
14278 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14279}
14280DEFUN (show_bgp_view_ipv6_rsclient,
14281 show_bgp_view_ipv6_rsclient_cmd,
14282 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
14283 SHOW_STR
14284 BGP_STR
14285 "BGP view\n"
14286 "BGP view name\n"
14287 "Address Family\n"
14288 "Information about Route Server Client\n"
14289 NEIGHBOR_ADDR_STR2)
14290{
14291 struct bgp_table *table;
14292 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000014293
14294 if (argc == 2)
14295 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14296 else
14297 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14298
14299 if (! peer)
14300 return CMD_WARNING;
14301
14302 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14303 {
14304 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14305 VTY_NEWLINE);
14306 return CMD_WARNING;
14307 }
14308
14309 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14310 PEER_FLAG_RSERVER_CLIENT))
14311 {
14312 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14313 VTY_NEWLINE);
14314 return CMD_WARNING;
14315 }
14316
14317 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14318
ajs5a646652004-11-05 01:25:55 +000014319 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000014320}
14321
Lou Berger651b4022016-01-12 13:42:07 -050014322ALIAS (show_bgp_view_ipv4_rsclient,
14323 show_bgp_ipv4_rsclient_cmd,
14324 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014325 SHOW_STR
14326 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014327 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014328 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014329 NEIGHBOR_ADDR_STR2)
14330
Lou Berger651b4022016-01-12 13:42:07 -050014331ALIAS (show_bgp_view_ipv6_rsclient,
14332 show_bgp_ipv6_rsclient_cmd,
14333 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
14334 SHOW_STR
14335 BGP_STR
14336 "Address Family\n"
14337 "Information about Route Server Client\n"
14338 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014339
Michael Lambert95cbbd22010-07-23 14:43:04 -040014340DEFUN (show_bgp_view_ipv6_safi_rsclient,
14341 show_bgp_view_ipv6_safi_rsclient_cmd,
14342 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14343 SHOW_STR
14344 BGP_STR
14345 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014346 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014347 "Address family\n"
14348 "Address Family modifier\n"
14349 "Address Family modifier\n"
14350 "Information about Route Server Client\n"
14351 NEIGHBOR_ADDR_STR)
14352{
14353 struct bgp_table *table;
14354 struct peer *peer;
14355 safi_t safi;
14356
14357 if (argc == 3) {
14358 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14359 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14360 } else {
14361 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14362 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14363 }
14364
14365 if (! peer)
14366 return CMD_WARNING;
14367
14368 if (! peer->afc[AFI_IP6][safi])
14369 {
14370 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14371 VTY_NEWLINE);
14372 return CMD_WARNING;
14373 }
14374
14375 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14376 PEER_FLAG_RSERVER_CLIENT))
14377 {
14378 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14379 VTY_NEWLINE);
14380 return CMD_WARNING;
14381 }
14382
14383 table = peer->rib[AFI_IP6][safi];
14384
14385 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14386}
14387
14388ALIAS (show_bgp_view_ipv6_safi_rsclient,
14389 show_bgp_ipv6_safi_rsclient_cmd,
14390 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14391 SHOW_STR
14392 BGP_STR
14393 "Address family\n"
14394 "Address Family modifier\n"
14395 "Address Family modifier\n"
14396 "Information about Route Server Client\n"
14397 NEIGHBOR_ADDR_STR)
14398
paulfee0f4c2004-09-13 05:12:46 +000014399DEFUN (show_bgp_view_rsclient_route,
14400 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014401 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14402 SHOW_STR
14403 BGP_STR
14404 "BGP view\n"
14405 "View name\n"
14406 "Information about Route Server Client\n"
14407 NEIGHBOR_ADDR_STR
14408 "Network in the BGP routing table to display\n")
14409{
14410 struct bgp *bgp;
14411 struct peer *peer;
14412
14413 /* BGP structure lookup. */
14414 if (argc == 3)
14415 {
14416 bgp = bgp_lookup_by_name (argv[0]);
14417 if (bgp == NULL)
14418 {
14419 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14420 return CMD_WARNING;
14421 }
14422 }
14423 else
14424 {
14425 bgp = bgp_get_default ();
14426 if (bgp == NULL)
14427 {
14428 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14429 return CMD_WARNING;
14430 }
14431 }
14432
14433 if (argc == 3)
14434 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14435 else
14436 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14437
14438 if (! peer)
14439 return CMD_WARNING;
14440
14441 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14442 {
14443 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14444 VTY_NEWLINE);
14445 return CMD_WARNING;
14446 }
14447
14448 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14449 PEER_FLAG_RSERVER_CLIENT))
14450 {
14451 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14452 VTY_NEWLINE);
14453 return CMD_WARNING;
14454 }
14455
14456 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14457 (argc == 3) ? argv[2] : argv[1],
14458 AFI_IP6, SAFI_UNICAST, NULL, 0);
14459}
14460
14461DEFUN (show_bgp_view_ipv6_rsclient_route,
14462 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014463 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014464 SHOW_STR
14465 BGP_STR
14466 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050014467 "BGP view name\n"
14468 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000014469 "Information about Route Server Client\n"
14470 NEIGHBOR_ADDR_STR
14471 "Network in the BGP routing table to display\n")
14472{
14473 struct bgp *bgp;
14474 struct peer *peer;
14475
14476 /* BGP structure lookup. */
14477 if (argc == 3)
14478 {
14479 bgp = bgp_lookup_by_name (argv[0]);
14480 if (bgp == NULL)
14481 {
14482 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14483 return CMD_WARNING;
14484 }
14485 }
14486 else
14487 {
14488 bgp = bgp_get_default ();
14489 if (bgp == NULL)
14490 {
14491 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14492 return CMD_WARNING;
14493 }
14494 }
14495
14496 if (argc == 3)
14497 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14498 else
14499 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14500
14501 if (! peer)
14502 return CMD_WARNING;
14503
14504 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14505 {
14506 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14507 VTY_NEWLINE);
14508 return CMD_WARNING;
14509 }
14510
14511 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14512 PEER_FLAG_RSERVER_CLIENT))
14513 {
14514 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14515 VTY_NEWLINE);
14516 return CMD_WARNING;
14517 }
14518
14519 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14520 (argc == 3) ? argv[2] : argv[1],
14521 AFI_IP6, SAFI_UNICAST, NULL, 0);
14522}
14523
Lou Bergerf9b6c392016-01-12 13:42:09 -050014524ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000014525 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014526 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14527 SHOW_STR
14528 BGP_STR
14529 "Information about Route Server Client\n"
14530 NEIGHBOR_ADDR_STR
14531 "Network in the BGP routing table to display\n")
14532
14533ALIAS (show_bgp_view_ipv6_rsclient_route,
14534 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014535 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014536 SHOW_STR
14537 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014538 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014539 "Information about Route Server Client\n"
14540 NEIGHBOR_ADDR_STR
14541 "Network in the BGP routing table to display\n")
14542
Michael Lambert95cbbd22010-07-23 14:43:04 -040014543DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
14544 show_bgp_view_ipv6_safi_rsclient_route_cmd,
14545 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14546 SHOW_STR
14547 BGP_STR
14548 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014549 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014550 "Address family\n"
14551 "Address Family modifier\n"
14552 "Address Family modifier\n"
14553 "Information about Route Server Client\n"
14554 NEIGHBOR_ADDR_STR
14555 "Network in the BGP routing table to display\n")
14556{
14557 struct bgp *bgp;
14558 struct peer *peer;
14559 safi_t safi;
14560
14561 /* BGP structure lookup. */
14562 if (argc == 4)
14563 {
14564 bgp = bgp_lookup_by_name (argv[0]);
14565 if (bgp == NULL)
14566 {
14567 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14568 return CMD_WARNING;
14569 }
14570 }
14571 else
14572 {
14573 bgp = bgp_get_default ();
14574 if (bgp == NULL)
14575 {
14576 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14577 return CMD_WARNING;
14578 }
14579 }
14580
14581 if (argc == 4) {
14582 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14583 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14584 } else {
14585 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14586 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14587 }
14588
14589 if (! peer)
14590 return CMD_WARNING;
14591
14592 if (! peer->afc[AFI_IP6][safi])
14593 {
14594 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14595 VTY_NEWLINE);
14596 return CMD_WARNING;
14597}
14598
14599 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14600 PEER_FLAG_RSERVER_CLIENT))
14601 {
14602 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14603 VTY_NEWLINE);
14604 return CMD_WARNING;
14605 }
14606
14607 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14608 (argc == 4) ? argv[3] : argv[2],
14609 AFI_IP6, safi, NULL, 0);
14610}
14611
14612ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
14613 show_bgp_ipv6_safi_rsclient_route_cmd,
14614 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14615 SHOW_STR
14616 BGP_STR
14617 "Address family\n"
14618 "Address Family modifier\n"
14619 "Address Family modifier\n"
14620 "Information about Route Server Client\n"
14621 NEIGHBOR_ADDR_STR
14622 "Network in the BGP routing table to display\n")
14623
Lou Berger651b4022016-01-12 13:42:07 -050014624
paulfee0f4c2004-09-13 05:12:46 +000014625DEFUN (show_bgp_view_rsclient_prefix,
14626 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014627 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14628 SHOW_STR
14629 BGP_STR
14630 "BGP view\n"
14631 "View name\n"
14632 "Information about Route Server Client\n"
14633 NEIGHBOR_ADDR_STR
14634 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14635{
14636 struct bgp *bgp;
14637 struct peer *peer;
14638
14639 /* BGP structure lookup. */
14640 if (argc == 3)
14641 {
14642 bgp = bgp_lookup_by_name (argv[0]);
14643 if (bgp == NULL)
14644 {
14645 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14646 return CMD_WARNING;
14647 }
14648 }
14649 else
14650 {
14651 bgp = bgp_get_default ();
14652 if (bgp == NULL)
14653 {
14654 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14655 return CMD_WARNING;
14656 }
14657 }
14658
14659 if (argc == 3)
14660 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14661 else
14662 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14663
14664 if (! peer)
14665 return CMD_WARNING;
14666
14667 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14668 {
14669 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14670 VTY_NEWLINE);
14671 return CMD_WARNING;
14672 }
14673
14674 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14675 PEER_FLAG_RSERVER_CLIENT))
14676 {
14677 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14678 VTY_NEWLINE);
14679 return CMD_WARNING;
14680 }
14681
14682 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14683 (argc == 3) ? argv[2] : argv[1],
14684 AFI_IP6, SAFI_UNICAST, NULL, 1);
14685}
14686
14687DEFUN (show_bgp_view_ipv6_rsclient_prefix,
14688 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014689 "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 +000014690 SHOW_STR
14691 BGP_STR
14692 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014693 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014694 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014695 "Information about Route Server Client\n"
14696 NEIGHBOR_ADDR_STR
14697 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14698{
14699 struct bgp *bgp;
14700 struct peer *peer;
14701
14702 /* BGP structure lookup. */
14703 if (argc == 3)
14704 {
14705 bgp = bgp_lookup_by_name (argv[0]);
14706 if (bgp == NULL)
14707 {
14708 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14709 return CMD_WARNING;
14710 }
14711 }
14712 else
14713 {
14714 bgp = bgp_get_default ();
14715 if (bgp == NULL)
14716 {
14717 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14718 return CMD_WARNING;
14719 }
14720 }
14721
14722 if (argc == 3)
14723 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14724 else
14725 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14726
14727 if (! peer)
14728 return CMD_WARNING;
14729
14730 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14731 {
14732 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14733 VTY_NEWLINE);
14734 return CMD_WARNING;
14735 }
14736
14737 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14738 PEER_FLAG_RSERVER_CLIENT))
14739 {
14740 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14741 VTY_NEWLINE);
14742 return CMD_WARNING;
14743 }
14744
14745 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14746 (argc == 3) ? argv[2] : argv[1],
14747 AFI_IP6, SAFI_UNICAST, NULL, 1);
14748}
14749
Lou Bergerf9b6c392016-01-12 13:42:09 -050014750ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000014751 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014752 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14753 SHOW_STR
14754 BGP_STR
14755 "Information about Route Server Client\n"
14756 NEIGHBOR_ADDR_STR
14757 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14758
14759ALIAS (show_bgp_view_ipv6_rsclient_prefix,
14760 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014761 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000014762 SHOW_STR
14763 BGP_STR
14764 "Information about Route Server Client\n"
14765 NEIGHBOR_ADDR_STR
14766 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14767
Michael Lambert95cbbd22010-07-23 14:43:04 -040014768DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
14769 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
14770 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14771 SHOW_STR
14772 BGP_STR
14773 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014774 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014775 "Address family\n"
14776 "Address Family modifier\n"
14777 "Address Family modifier\n"
14778 "Information about Route Server Client\n"
14779 NEIGHBOR_ADDR_STR
14780 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14781{
14782 struct bgp *bgp;
14783 struct peer *peer;
14784 safi_t safi;
14785
14786 /* BGP structure lookup. */
14787 if (argc == 4)
14788 {
14789 bgp = bgp_lookup_by_name (argv[0]);
14790 if (bgp == NULL)
14791 {
14792 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14793 return CMD_WARNING;
14794 }
14795 }
14796 else
14797 {
14798 bgp = bgp_get_default ();
14799 if (bgp == NULL)
14800 {
14801 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14802 return CMD_WARNING;
14803 }
14804 }
14805
14806 if (argc == 4) {
14807 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14808 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14809 } else {
14810 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14811 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14812 }
14813
14814 if (! peer)
14815 return CMD_WARNING;
14816
14817 if (! peer->afc[AFI_IP6][safi])
14818 {
14819 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14820 VTY_NEWLINE);
14821 return CMD_WARNING;
14822}
14823
14824 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14825 PEER_FLAG_RSERVER_CLIENT))
14826{
14827 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14828 VTY_NEWLINE);
14829 return CMD_WARNING;
14830 }
14831
14832 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14833 (argc == 4) ? argv[3] : argv[2],
14834 AFI_IP6, safi, NULL, 1);
14835}
14836
14837ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
14838 show_bgp_ipv6_safi_rsclient_prefix_cmd,
14839 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14840 SHOW_STR
14841 BGP_STR
14842 "Address family\n"
14843 "Address Family modifier\n"
14844 "Address Family modifier\n"
14845 "Information about Route Server Client\n"
14846 NEIGHBOR_ADDR_STR
14847 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14848
paul718e3742002-12-13 20:15:29 +000014849struct bgp_table *bgp_distance_table;
14850
14851struct bgp_distance
14852{
14853 /* Distance value for the IP source prefix. */
14854 u_char distance;
14855
14856 /* Name of the access-list to be matched. */
14857 char *access_list;
14858};
14859
paul94f2b392005-06-28 12:44:16 +000014860static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080014861bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000014862{
Stephen Hemminger393deb92008-08-18 14:13:29 -070014863 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000014864}
14865
paul94f2b392005-06-28 12:44:16 +000014866static void
paul718e3742002-12-13 20:15:29 +000014867bgp_distance_free (struct bgp_distance *bdistance)
14868{
14869 XFREE (MTYPE_BGP_DISTANCE, bdistance);
14870}
14871
paul94f2b392005-06-28 12:44:16 +000014872static int
paulfd79ac92004-10-13 05:06:08 +000014873bgp_distance_set (struct vty *vty, const char *distance_str,
14874 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014875{
14876 int ret;
14877 struct prefix_ipv4 p;
14878 u_char distance;
14879 struct bgp_node *rn;
14880 struct bgp_distance *bdistance;
14881
14882 ret = str2prefix_ipv4 (ip_str, &p);
14883 if (ret == 0)
14884 {
14885 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14886 return CMD_WARNING;
14887 }
14888
14889 distance = atoi (distance_str);
14890
14891 /* Get BGP distance node. */
14892 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
14893 if (rn->info)
14894 {
14895 bdistance = rn->info;
14896 bgp_unlock_node (rn);
14897 }
14898 else
14899 {
14900 bdistance = bgp_distance_new ();
14901 rn->info = bdistance;
14902 }
14903
14904 /* Set distance value. */
14905 bdistance->distance = distance;
14906
14907 /* Reset access-list configuration. */
14908 if (bdistance->access_list)
14909 {
14910 free (bdistance->access_list);
14911 bdistance->access_list = NULL;
14912 }
14913 if (access_list_str)
14914 bdistance->access_list = strdup (access_list_str);
14915
14916 return CMD_SUCCESS;
14917}
14918
paul94f2b392005-06-28 12:44:16 +000014919static int
paulfd79ac92004-10-13 05:06:08 +000014920bgp_distance_unset (struct vty *vty, const char *distance_str,
14921 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014922{
14923 int ret;
14924 struct prefix_ipv4 p;
14925 u_char distance;
14926 struct bgp_node *rn;
14927 struct bgp_distance *bdistance;
14928
14929 ret = str2prefix_ipv4 (ip_str, &p);
14930 if (ret == 0)
14931 {
14932 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14933 return CMD_WARNING;
14934 }
14935
14936 distance = atoi (distance_str);
14937
14938 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
14939 if (! rn)
14940 {
14941 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
14942 return CMD_WARNING;
14943 }
14944
14945 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010014946
14947 if (bdistance->distance != distance)
14948 {
14949 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
14950 return CMD_WARNING;
14951 }
14952
paul718e3742002-12-13 20:15:29 +000014953 if (bdistance->access_list)
14954 free (bdistance->access_list);
14955 bgp_distance_free (bdistance);
14956
14957 rn->info = NULL;
14958 bgp_unlock_node (rn);
14959 bgp_unlock_node (rn);
14960
14961 return CMD_SUCCESS;
14962}
14963
paul718e3742002-12-13 20:15:29 +000014964/* Apply BGP information to distance method. */
14965u_char
14966bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
14967{
14968 struct bgp_node *rn;
14969 struct prefix_ipv4 q;
14970 struct peer *peer;
14971 struct bgp_distance *bdistance;
14972 struct access_list *alist;
14973 struct bgp_static *bgp_static;
14974
14975 if (! bgp)
14976 return 0;
14977
14978 if (p->family != AF_INET)
14979 return 0;
14980
14981 peer = rinfo->peer;
14982
14983 if (peer->su.sa.sa_family != AF_INET)
14984 return 0;
14985
14986 memset (&q, 0, sizeof (struct prefix_ipv4));
14987 q.family = AF_INET;
14988 q.prefix = peer->su.sin.sin_addr;
14989 q.prefixlen = IPV4_MAX_BITLEN;
14990
14991 /* Check source address. */
14992 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
14993 if (rn)
14994 {
14995 bdistance = rn->info;
14996 bgp_unlock_node (rn);
14997
14998 if (bdistance->access_list)
14999 {
15000 alist = access_list_lookup (AFI_IP, bdistance->access_list);
15001 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15002 return bdistance->distance;
15003 }
15004 else
15005 return bdistance->distance;
15006 }
15007
15008 /* Backdoor check. */
15009 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
15010 if (rn)
15011 {
15012 bgp_static = rn->info;
15013 bgp_unlock_node (rn);
15014
15015 if (bgp_static->backdoor)
15016 {
15017 if (bgp->distance_local)
15018 return bgp->distance_local;
15019 else
15020 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15021 }
15022 }
15023
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000015024 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000015025 {
15026 if (bgp->distance_ebgp)
15027 return bgp->distance_ebgp;
15028 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15029 }
15030 else
15031 {
15032 if (bgp->distance_ibgp)
15033 return bgp->distance_ibgp;
15034 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15035 }
15036}
15037
15038DEFUN (bgp_distance,
15039 bgp_distance_cmd,
15040 "distance bgp <1-255> <1-255> <1-255>",
15041 "Define an administrative distance\n"
15042 "BGP distance\n"
15043 "Distance for routes external to the AS\n"
15044 "Distance for routes internal to the AS\n"
15045 "Distance for local routes\n")
15046{
15047 struct bgp *bgp;
15048
15049 bgp = vty->index;
15050
15051 bgp->distance_ebgp = atoi (argv[0]);
15052 bgp->distance_ibgp = atoi (argv[1]);
15053 bgp->distance_local = atoi (argv[2]);
15054 return CMD_SUCCESS;
15055}
15056
15057DEFUN (no_bgp_distance,
15058 no_bgp_distance_cmd,
15059 "no distance bgp <1-255> <1-255> <1-255>",
15060 NO_STR
15061 "Define an administrative distance\n"
15062 "BGP distance\n"
15063 "Distance for routes external to the AS\n"
15064 "Distance for routes internal to the AS\n"
15065 "Distance for local routes\n")
15066{
15067 struct bgp *bgp;
15068
15069 bgp = vty->index;
15070
15071 bgp->distance_ebgp= 0;
15072 bgp->distance_ibgp = 0;
15073 bgp->distance_local = 0;
15074 return CMD_SUCCESS;
15075}
15076
15077ALIAS (no_bgp_distance,
15078 no_bgp_distance2_cmd,
15079 "no distance bgp",
15080 NO_STR
15081 "Define an administrative distance\n"
15082 "BGP distance\n")
15083
15084DEFUN (bgp_distance_source,
15085 bgp_distance_source_cmd,
15086 "distance <1-255> A.B.C.D/M",
15087 "Define an administrative distance\n"
15088 "Administrative distance\n"
15089 "IP source prefix\n")
15090{
15091 bgp_distance_set (vty, argv[0], argv[1], NULL);
15092 return CMD_SUCCESS;
15093}
15094
15095DEFUN (no_bgp_distance_source,
15096 no_bgp_distance_source_cmd,
15097 "no distance <1-255> A.B.C.D/M",
15098 NO_STR
15099 "Define an administrative distance\n"
15100 "Administrative distance\n"
15101 "IP source prefix\n")
15102{
15103 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15104 return CMD_SUCCESS;
15105}
15106
15107DEFUN (bgp_distance_source_access_list,
15108 bgp_distance_source_access_list_cmd,
15109 "distance <1-255> A.B.C.D/M WORD",
15110 "Define an administrative distance\n"
15111 "Administrative distance\n"
15112 "IP source prefix\n"
15113 "Access list name\n")
15114{
15115 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15116 return CMD_SUCCESS;
15117}
15118
15119DEFUN (no_bgp_distance_source_access_list,
15120 no_bgp_distance_source_access_list_cmd,
15121 "no distance <1-255> A.B.C.D/M WORD",
15122 NO_STR
15123 "Define an administrative distance\n"
15124 "Administrative distance\n"
15125 "IP source prefix\n"
15126 "Access list name\n")
15127{
15128 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15129 return CMD_SUCCESS;
15130}
David Lamparter6b0655a2014-06-04 06:53:35 +020015131
paul718e3742002-12-13 20:15:29 +000015132DEFUN (bgp_damp_set,
15133 bgp_damp_set_cmd,
15134 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15135 "BGP Specific commands\n"
15136 "Enable route-flap dampening\n"
15137 "Half-life time for the penalty\n"
15138 "Value to start reusing a route\n"
15139 "Value to start suppressing a route\n"
15140 "Maximum duration to suppress a stable route\n")
15141{
15142 struct bgp *bgp;
15143 int half = DEFAULT_HALF_LIFE * 60;
15144 int reuse = DEFAULT_REUSE;
15145 int suppress = DEFAULT_SUPPRESS;
15146 int max = 4 * half;
15147
15148 if (argc == 4)
15149 {
15150 half = atoi (argv[0]) * 60;
15151 reuse = atoi (argv[1]);
15152 suppress = atoi (argv[2]);
15153 max = atoi (argv[3]) * 60;
15154 }
15155 else if (argc == 1)
15156 {
15157 half = atoi (argv[0]) * 60;
15158 max = 4 * half;
15159 }
15160
15161 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000015162
15163 if (suppress < reuse)
15164 {
15165 vty_out (vty, "Suppress value cannot be less than reuse value %s",
15166 VTY_NEWLINE);
15167 return 0;
15168 }
15169
paul718e3742002-12-13 20:15:29 +000015170 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
15171 half, reuse, suppress, max);
15172}
15173
15174ALIAS (bgp_damp_set,
15175 bgp_damp_set2_cmd,
15176 "bgp dampening <1-45>",
15177 "BGP Specific commands\n"
15178 "Enable route-flap dampening\n"
15179 "Half-life time for the penalty\n")
15180
15181ALIAS (bgp_damp_set,
15182 bgp_damp_set3_cmd,
15183 "bgp dampening",
15184 "BGP Specific commands\n"
15185 "Enable route-flap dampening\n")
15186
15187DEFUN (bgp_damp_unset,
15188 bgp_damp_unset_cmd,
15189 "no bgp dampening",
15190 NO_STR
15191 "BGP Specific commands\n"
15192 "Enable route-flap dampening\n")
15193{
15194 struct bgp *bgp;
15195
15196 bgp = vty->index;
15197 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
15198}
15199
15200ALIAS (bgp_damp_unset,
15201 bgp_damp_unset2_cmd,
15202 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15203 NO_STR
15204 "BGP Specific commands\n"
15205 "Enable route-flap dampening\n"
15206 "Half-life time for the penalty\n"
15207 "Value to start reusing a route\n"
15208 "Value to start suppressing a route\n"
15209 "Maximum duration to suppress a stable route\n")
15210
Lou Bergerf9b6c392016-01-12 13:42:09 -050015211DEFUN (show_ip_bgp_dampened_paths,
15212 show_ip_bgp_dampened_paths_cmd,
15213 "show ip bgp dampened-paths",
15214 SHOW_STR
15215 IP_STR
15216 BGP_STR
15217 "Display paths suppressed due to dampening\n")
15218{
15219 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
15220 NULL);
15221}
15222
15223ALIAS (show_ip_bgp_dampened_paths,
15224 show_ip_bgp_damp_dampened_paths_cmd,
15225 "show ip bgp dampening dampened-paths",
15226 SHOW_STR
15227 IP_STR
15228 BGP_STR
15229 "Display detailed information about dampening\n"
15230 "Display paths suppressed due to dampening\n")
15231
15232DEFUN (show_ip_bgp_flap_statistics,
15233 show_ip_bgp_flap_statistics_cmd,
15234 "show ip bgp flap-statistics",
15235 SHOW_STR
15236 IP_STR
15237 BGP_STR
15238 "Display flap statistics of routes\n")
15239{
15240 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
15241 bgp_show_type_flap_statistics, NULL);
15242}
15243
15244ALIAS (show_ip_bgp_flap_statistics,
15245 show_ip_bgp_damp_flap_statistics_cmd,
15246 "show ip bgp dampening flap-statistics",
15247 SHOW_STR
15248 IP_STR
15249 BGP_STR
15250 "Display detailed information about dampening\n"
15251 "Display flap statistics of routes\n")
15252
Lou Berger651b4022016-01-12 13:42:07 -050015253DEFUN (show_bgp_ipv4_safi_dampened_paths,
15254 show_bgp_ipv4_safi_dampened_paths_cmd,
15255 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015256 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015257 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015258 IP_STR
15259 "Address Family modifier\n"
15260 "Address Family modifier\n"
15261 "Address Family modifier\n"
15262 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015263 "Display paths suppressed due to dampening\n")
15264{
Lou Berger651b4022016-01-12 13:42:07 -050015265 safi_t safi;
paul718e3742002-12-13 20:15:29 +000015266
Lou Berger651b4022016-01-12 13:42:07 -050015267 if (bgp_parse_safi(argv[0], &safi)) {
15268 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15269 return CMD_WARNING;
15270 }
15271
15272 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
15273}
15274ALIAS (show_bgp_ipv4_safi_dampened_paths,
15275 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
15276 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053015277 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015278 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015279 IP_STR
15280 "Address Family modifier\n"
15281 "Address Family modifier\n"
15282 "Address Family modifier\n"
15283 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015284 "Display detailed information about dampening\n"
15285 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050015286
Lou Berger651b4022016-01-12 13:42:07 -050015287DEFUN (show_bgp_ipv6_safi_dampened_paths,
15288 show_bgp_ipv6_safi_dampened_paths_cmd,
15289 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015290 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015291 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015292 IPV6_STR
15293 "Address Family modifier\n"
15294 "Address Family modifier\n"
15295 "Address Family modifier\n"
15296 "Address Family modifier\n"
15297 "Display paths suppressed due to dampening\n")
15298{
15299 safi_t safi;
15300
15301 if (bgp_parse_safi(argv[0], &safi)) {
15302 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15303 return CMD_WARNING;
15304 }
15305
15306 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
15307}
15308ALIAS (show_bgp_ipv6_safi_dampened_paths,
15309 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
15310 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
15311 SHOW_STR
15312 BGP_STR
15313 IPV6_STR
15314 "Address Family modifier\n"
15315 "Address Family modifier\n"
15316 "Address Family modifier\n"
15317 "Address Family modifier\n"
15318 "Display detailed information about dampening\n"
15319 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050015320
15321DEFUN (show_bgp_ipv4_safi_flap_statistics,
15322 show_bgp_ipv4_safi_flap_statistics_cmd,
15323 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
15324 SHOW_STR
15325 BGP_STR
15326 "Address Family\n"
15327 "Address Family modifier\n"
15328 "Address Family modifier\n"
15329 "Address Family modifier\n"
15330 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015331 "Display flap statistics of routes\n")
15332{
Lou Berger651b4022016-01-12 13:42:07 -050015333 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020015334
Lou Berger651b4022016-01-12 13:42:07 -050015335 if (bgp_parse_safi(argv[0], &safi)) {
15336 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15337 return CMD_WARNING;
15338 }
15339
15340 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
15341}
15342ALIAS (show_bgp_ipv4_safi_flap_statistics,
15343 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
15344 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053015345 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015346 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015347 "Address Family\n"
15348 "Address Family modifier\n"
15349 "Address Family modifier\n"
15350 "Address Family modifier\n"
15351 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015352 "Display detailed information about dampening\n"
15353 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050015354
Lou Berger651b4022016-01-12 13:42:07 -050015355DEFUN (show_bgp_ipv6_safi_flap_statistics,
15356 show_bgp_ipv6_safi_flap_statistics_cmd,
15357 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
15358 SHOW_STR
15359 BGP_STR
15360 "Address Family\n"
15361 "Address Family modifier\n"
15362 "Address Family modifier\n"
15363 "Address Family modifier\n"
15364 "Address Family modifier\n"
15365 "Display flap statistics of routes\n")
15366{
15367 safi_t safi;
15368
15369 if (bgp_parse_safi(argv[0], &safi)) {
15370 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15371 return CMD_WARNING;
15372 }
15373
15374 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
15375}
15376ALIAS (show_bgp_ipv6_safi_flap_statistics,
15377 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
15378 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
15379 SHOW_STR
15380 BGP_STR
15381 "Address Family\n"
15382 "Address Family modifier\n"
15383 "Address Family modifier\n"
15384 "Address Family modifier\n"
15385 "Address Family modifier\n"
15386 "Display detailed information about dampening\n"
15387 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053015388
paul718e3742002-12-13 20:15:29 +000015389/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000015390static int
paulfd79ac92004-10-13 05:06:08 +000015391bgp_clear_damp_route (struct vty *vty, const char *view_name,
15392 const char *ip_str, afi_t afi, safi_t safi,
15393 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000015394{
15395 int ret;
15396 struct prefix match;
15397 struct bgp_node *rn;
15398 struct bgp_node *rm;
15399 struct bgp_info *ri;
15400 struct bgp_info *ri_temp;
15401 struct bgp *bgp;
15402 struct bgp_table *table;
15403
15404 /* BGP structure lookup. */
15405 if (view_name)
15406 {
15407 bgp = bgp_lookup_by_name (view_name);
15408 if (bgp == NULL)
15409 {
15410 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
15411 return CMD_WARNING;
15412 }
15413 }
15414 else
15415 {
15416 bgp = bgp_get_default ();
15417 if (bgp == NULL)
15418 {
15419 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
15420 return CMD_WARNING;
15421 }
15422 }
15423
15424 /* Check IP address argument. */
15425 ret = str2prefix (ip_str, &match);
15426 if (! ret)
15427 {
15428 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
15429 return CMD_WARNING;
15430 }
15431
15432 match.family = afi2family (afi);
15433
Lou Berger298cc2f2016-01-12 13:42:02 -050015434 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000015435 {
Lou Berger298cc2f2016-01-12 13:42:02 -050015436 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000015437 {
15438 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
15439 continue;
15440
15441 if ((table = rn->info) != NULL)
15442 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015443 {
15444 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
15445 {
15446 ri = rm->info;
15447 while (ri)
15448 {
15449 if (ri->extra && ri->extra->damp_info)
15450 {
15451 ri_temp = ri->next;
15452 bgp_damp_info_free (ri->extra->damp_info, 1);
15453 ri = ri_temp;
15454 }
15455 else
15456 ri = ri->next;
15457 }
15458 }
15459
15460 bgp_unlock_node (rm);
15461 }
paul718e3742002-12-13 20:15:29 +000015462 }
15463 }
15464 else
15465 {
15466 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015467 {
15468 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
15469 {
15470 ri = rn->info;
15471 while (ri)
15472 {
15473 if (ri->extra && ri->extra->damp_info)
15474 {
15475 ri_temp = ri->next;
15476 bgp_damp_info_free (ri->extra->damp_info, 1);
15477 ri = ri_temp;
15478 }
15479 else
15480 ri = ri->next;
15481 }
15482 }
15483
15484 bgp_unlock_node (rn);
15485 }
paul718e3742002-12-13 20:15:29 +000015486 }
15487
15488 return CMD_SUCCESS;
15489}
15490
15491DEFUN (clear_ip_bgp_dampening,
15492 clear_ip_bgp_dampening_cmd,
15493 "clear ip bgp dampening",
15494 CLEAR_STR
15495 IP_STR
15496 BGP_STR
15497 "Clear route flap dampening information\n")
15498{
15499 bgp_damp_info_clean ();
15500 return CMD_SUCCESS;
15501}
15502
15503DEFUN (clear_ip_bgp_dampening_prefix,
15504 clear_ip_bgp_dampening_prefix_cmd,
15505 "clear ip bgp dampening A.B.C.D/M",
15506 CLEAR_STR
15507 IP_STR
15508 BGP_STR
15509 "Clear route flap dampening information\n"
15510 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15511{
15512 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15513 SAFI_UNICAST, NULL, 1);
15514}
15515
15516DEFUN (clear_ip_bgp_dampening_address,
15517 clear_ip_bgp_dampening_address_cmd,
15518 "clear ip bgp dampening A.B.C.D",
15519 CLEAR_STR
15520 IP_STR
15521 BGP_STR
15522 "Clear route flap dampening information\n"
15523 "Network to clear damping information\n")
15524{
15525 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15526 SAFI_UNICAST, NULL, 0);
15527}
15528
15529DEFUN (clear_ip_bgp_dampening_address_mask,
15530 clear_ip_bgp_dampening_address_mask_cmd,
15531 "clear ip bgp dampening A.B.C.D A.B.C.D",
15532 CLEAR_STR
15533 IP_STR
15534 BGP_STR
15535 "Clear route flap dampening information\n"
15536 "Network to clear damping information\n"
15537 "Network mask\n")
15538{
15539 int ret;
15540 char prefix_str[BUFSIZ];
15541
15542 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
15543 if (! ret)
15544 {
15545 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
15546 return CMD_WARNING;
15547 }
15548
15549 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
15550 SAFI_UNICAST, NULL, 0);
15551}
David Lamparter6b0655a2014-06-04 06:53:35 +020015552
Lou Berger298cc2f2016-01-12 13:42:02 -050015553/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000015554static int
paul718e3742002-12-13 20:15:29 +000015555bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
15556 afi_t afi, safi_t safi, int *write)
15557{
15558 struct bgp_node *prn;
15559 struct bgp_node *rn;
15560 struct bgp_table *table;
15561 struct prefix *p;
15562 struct prefix_rd *prd;
15563 struct bgp_static *bgp_static;
15564 u_int32_t label;
15565 char buf[SU_ADDRSTRLEN];
15566 char rdbuf[RD_ADDRSTRLEN];
15567
15568 /* Network configuration. */
15569 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
15570 if ((table = prn->info) != NULL)
15571 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
15572 if ((bgp_static = rn->info) != NULL)
15573 {
15574 p = &rn->p;
15575 prd = (struct prefix_rd *) &prn->p;
15576
15577 /* "address-family" display. */
15578 bgp_config_write_family_header (vty, afi, safi, write);
15579
15580 /* "network" configuration display. */
15581 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
15582 label = decode_label (bgp_static->tag);
15583
15584 vty_out (vty, " network %s/%d rd %s tag %d",
15585 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15586 p->prefixlen,
15587 rdbuf, label);
15588 vty_out (vty, "%s", VTY_NEWLINE);
15589 }
15590 return 0;
15591}
15592
15593/* Configuration of static route announcement and aggregate
15594 information. */
15595int
15596bgp_config_write_network (struct vty *vty, struct bgp *bgp,
15597 afi_t afi, safi_t safi, int *write)
15598{
15599 struct bgp_node *rn;
15600 struct prefix *p;
15601 struct bgp_static *bgp_static;
15602 struct bgp_aggregate *bgp_aggregate;
15603 char buf[SU_ADDRSTRLEN];
15604
Lou Berger298cc2f2016-01-12 13:42:02 -050015605 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000015606 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
15607
15608 /* Network configuration. */
15609 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
15610 if ((bgp_static = rn->info) != NULL)
15611 {
15612 p = &rn->p;
15613
15614 /* "address-family" display. */
15615 bgp_config_write_family_header (vty, afi, safi, write);
15616
15617 /* "network" configuration display. */
15618 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15619 {
15620 u_int32_t destination;
15621 struct in_addr netmask;
15622
15623 destination = ntohl (p->u.prefix4.s_addr);
15624 masklen2ip (p->prefixlen, &netmask);
15625 vty_out (vty, " network %s",
15626 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
15627
15628 if ((IN_CLASSC (destination) && p->prefixlen == 24)
15629 || (IN_CLASSB (destination) && p->prefixlen == 16)
15630 || (IN_CLASSA (destination) && p->prefixlen == 8)
15631 || p->u.prefix4.s_addr == 0)
15632 {
15633 /* Natural mask is not display. */
15634 }
15635 else
15636 vty_out (vty, " mask %s", inet_ntoa (netmask));
15637 }
15638 else
15639 {
15640 vty_out (vty, " network %s/%d",
15641 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15642 p->prefixlen);
15643 }
15644
15645 if (bgp_static->rmap.name)
15646 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000015647 else
15648 {
15649 if (bgp_static->backdoor)
15650 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000015651 }
paul718e3742002-12-13 20:15:29 +000015652
15653 vty_out (vty, "%s", VTY_NEWLINE);
15654 }
15655
15656 /* Aggregate-address configuration. */
15657 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
15658 if ((bgp_aggregate = rn->info) != NULL)
15659 {
15660 p = &rn->p;
15661
15662 /* "address-family" display. */
15663 bgp_config_write_family_header (vty, afi, safi, write);
15664
15665 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15666 {
15667 struct in_addr netmask;
15668
15669 masklen2ip (p->prefixlen, &netmask);
15670 vty_out (vty, " aggregate-address %s %s",
15671 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15672 inet_ntoa (netmask));
15673 }
15674 else
15675 {
15676 vty_out (vty, " aggregate-address %s/%d",
15677 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15678 p->prefixlen);
15679 }
15680
15681 if (bgp_aggregate->as_set)
15682 vty_out (vty, " as-set");
15683
15684 if (bgp_aggregate->summary_only)
15685 vty_out (vty, " summary-only");
15686
15687 vty_out (vty, "%s", VTY_NEWLINE);
15688 }
15689
15690 return 0;
15691}
15692
15693int
15694bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
15695{
15696 struct bgp_node *rn;
15697 struct bgp_distance *bdistance;
15698
15699 /* Distance configuration. */
15700 if (bgp->distance_ebgp
15701 && bgp->distance_ibgp
15702 && bgp->distance_local
15703 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
15704 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
15705 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
15706 vty_out (vty, " distance bgp %d %d %d%s",
15707 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
15708 VTY_NEWLINE);
15709
15710 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
15711 if ((bdistance = rn->info) != NULL)
15712 {
15713 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
15714 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
15715 bdistance->access_list ? bdistance->access_list : "",
15716 VTY_NEWLINE);
15717 }
15718
15719 return 0;
15720}
15721
15722/* Allocate routing table structure and install commands. */
15723void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080015724bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000015725{
15726 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000015727 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000015728
15729 /* IPv4 BGP commands. */
15730 install_element (BGP_NODE, &bgp_network_cmd);
15731 install_element (BGP_NODE, &bgp_network_mask_cmd);
15732 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
15733 install_element (BGP_NODE, &bgp_network_route_map_cmd);
15734 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
15735 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
15736 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
15737 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
15738 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
15739 install_element (BGP_NODE, &no_bgp_network_cmd);
15740 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
15741 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
15742 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
15743 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
15744 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15745 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
15746 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
15747 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
15748
15749 install_element (BGP_NODE, &aggregate_address_cmd);
15750 install_element (BGP_NODE, &aggregate_address_mask_cmd);
15751 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
15752 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
15753 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
15754 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
15755 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
15756 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
15757 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
15758 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
15759 install_element (BGP_NODE, &no_aggregate_address_cmd);
15760 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
15761 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
15762 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
15763 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
15764 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
15765 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
15766 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
15767 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15768 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15769
15770 /* IPv4 unicast configuration. */
15771 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
15772 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
15773 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
15774 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
15775 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
15776 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015777 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000015778 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
15779 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
15780 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
15781 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
15782 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015783
paul718e3742002-12-13 20:15:29 +000015784 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
15785 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
15786 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
15787 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
15788 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
15789 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
15790 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
15791 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
15792 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
15793 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
15794 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
15795 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
15796 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
15797 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
15798 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
15799 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
15800 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
15801 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
15802 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15803 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15804
15805 /* IPv4 multicast configuration. */
15806 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
15807 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
15808 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
15809 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
15810 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
15811 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
15812 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
15813 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
15814 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
15815 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
15816 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
15817 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15818 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
15819 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
15820 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
15821 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
15822 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
15823 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
15824 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
15825 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
15826 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
15827 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
15828 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
15829 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
15830 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
15831 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
15832 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
15833 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
15834 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
15835 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
15836 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15837 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15838
Michael Lambert95cbbd22010-07-23 14:43:04 -040015839 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015840 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015841 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
15842 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
15843 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15844 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15845 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
15846 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
15847 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15848 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15849 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015850 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015851 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15852 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15853 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15854 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15855 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15856 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15857 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
15858 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
15859 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15860 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
15861 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
15862 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
15863 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
15864 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
15865 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
15866 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
15867 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
15868 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
15869 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
15870 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
15871 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
15872 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
15873 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
15874 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
15875 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
15876 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
15877 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
15878 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015879 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15880 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
15881 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
15882 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
15883 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015884 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
15885 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
15886 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
15887 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
15888 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
15889 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
15890 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
15891 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
15892 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
15893 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
15894 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
15895 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
15896 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
15897 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
15898 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
15899 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
15900 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
15901 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
15902 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015903 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015904 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
15905 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
15906 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
15907 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
15908 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
15909 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
15910 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
15911 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
15912 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
15913 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
15914 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
15915 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
15916 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
15917 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
15918 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
15919 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
15920 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
15921 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
15922 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
15923 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
15924 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
15925 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
15926 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
15927 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
15928 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
15929 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
15930 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
15931 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
15932 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
15933 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
15934 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
15935 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
15936 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
15937 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
15938 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
15939 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
15940 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
15941 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
15942 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
15943 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
15944 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
15945 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
15946 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
15947 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
15948 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015949 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015950 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015951 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015952 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015953 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015954 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010015955
15956 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040015957 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015958 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15959 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15960 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15961 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15962 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015963 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015964 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15965 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15966 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15967 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15968 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15969 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15970 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
15971 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15972 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
15973 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
15974 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
15975 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
15976 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
15977 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
15978 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
15979 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015980 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15981 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
15982 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
15983 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
15984 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015985 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
15986 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
15987 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
15988 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
15989 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
15990 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
15991 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
15992 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015993 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015994 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015995 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015996 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000015997
Michael Lambert95cbbd22010-07-23 14:43:04 -040015998 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015999 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016000 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd);
16001 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd);
16002 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16003 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16004 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_route_cmd);
16005 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_route_cmd);
16006 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16007 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16008 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016009 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016010 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16011 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16012 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16013 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16014 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16015 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16016 install_element (ENABLE_NODE, &show_bgp_afi_safi_view_cmd);
16017 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_route_cmd);
16018 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16019 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_regexp_cmd);
16020 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_regexp_cmd);
16021 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_list_cmd);
16022 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
16023 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
16024 install_element (ENABLE_NODE, &show_bgp_ipv4_filter_list_cmd);
16025 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
16026 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
16027 install_element (ENABLE_NODE, &show_bgp_ipv4_route_map_cmd);
16028 install_element (ENABLE_NODE, &show_bgp_ipv4_cidr_only_cmd);
16029 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
16030 install_element (ENABLE_NODE, &show_bgp_ipv4_community_cmd);
16031 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_cmd);
16032 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_cmd);
16033 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_cmd);
16034 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_cmd);
16035 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_cmd);
16036 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_cmd);
16037 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016038 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16039 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd);
16040 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd);
16041 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd);
16042 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016043 install_element (ENABLE_NODE, &show_bgp_ipv4_community_exact_cmd);
16044 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_exact_cmd);
16045 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_exact_cmd);
16046 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_exact_cmd);
16047 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16048 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16049 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16050 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16051 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_cmd);
16052 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16053 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16054 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16055 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16056 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16057 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16058 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16059 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16060 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16061 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016062 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016063 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16064 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16065 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16066 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16067 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16068 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16069 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16070 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16071 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16072 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16073 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16074 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16075 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16076 install_element (ENABLE_NODE, &show_bgp_ipv6_flap_address_cmd);
16077 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16078 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16079 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16080 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16081 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16082 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16083 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16084 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16085 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16086 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16087 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16088 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16089 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16090 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16091 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16092 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16093 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16094 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16095 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16096 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16097 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16098 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16099 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16100 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16101 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16102 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16103 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16104 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16105 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16106 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16107 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016108 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016109 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016110 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016111 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016112 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016113 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016114
16115 /* BGP dampening clear commands */
16116 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
16117 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
16118 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
16119 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
16120
Paul Jakmaff7924f2006-09-04 01:10:36 +000016121 /* prefix count */
Lou Berger651b4022016-01-12 13:42:07 -050016122 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_prefix_counts_cmd);
16123 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_prefix_counts_cmd);
Paul Jakmaff7924f2006-09-04 01:10:36 +000016124 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd);
16125
paul718e3742002-12-13 20:15:29 +000016126 /* New config IPv6 BGP commands. */
16127 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
16128 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
16129 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
16130 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
16131
16132 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
16133 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
16134 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
16135 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
16136
G.Balaji73bfe0b2011-09-23 22:36:20 +053016137 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
16138 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
16139
paul718e3742002-12-13 20:15:29 +000016140 /* Old config IPv6 BGP commands. */
16141 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
16142 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
16143
16144 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
16145 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
16146 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
16147 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
16148
Michael Lambert95cbbd22010-07-23 14:43:04 -040016149 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016150 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016151 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016152 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016153 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016154 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016155 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016156 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016157 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016158 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
16159 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
16160 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
16161 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
16162 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16163 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16164 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16165 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016166 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
paul718e3742002-12-13 20:15:29 +000016167 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016168 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016169 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016170 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016171 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016172 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016173 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016174 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
16175 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016176 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016177 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016178 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016179 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016180 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016181 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016182 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016183 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016184 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016185 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016186 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016187 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016188 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016189 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016190 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16191 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016192 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016193 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016194 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016195 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016196 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016197
16198 /* Restricted:
16199 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
16200 */
Paul Jakma62687ff2008-08-23 14:27:06 +010016201 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016202 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016203 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016204 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016205 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
16206 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
16207 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
16208 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
16209 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16210 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16211 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16212 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
16213 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016214 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016215 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016216 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016217 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016218 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016219 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016220 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016221 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016222 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016223 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016224
Michael Lambert95cbbd22010-07-23 14:43:04 -040016225 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016226 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016227 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016228 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016229 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016230 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016231 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016232 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016233 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016234 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_cmd);
16235 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_cmd);
16236 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_cmd);
16237 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_cmd);
16238 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16239 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16240 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16241 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016242 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016243 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016244 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016245 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016246 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016247 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016248 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016249 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016250 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016251 install_element (ENABLE_NODE, &show_bgp_ipv4_rsclient_cmd);
16252 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016253 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016254 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016255 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016256 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016257 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016258 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016259 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016260 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016261 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016262 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016263 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016264 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016265 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016266 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016267 install_element (ENABLE_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16268 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016269 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016270 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016271 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016272 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016273 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma2815e612006-09-14 02:56:07 +000016274
16275 /* Statistics */
16276 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016277 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000016278
16279 install_element (BGP_NODE, &bgp_distance_cmd);
16280 install_element (BGP_NODE, &no_bgp_distance_cmd);
16281 install_element (BGP_NODE, &no_bgp_distance2_cmd);
16282 install_element (BGP_NODE, &bgp_distance_source_cmd);
16283 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
16284 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
16285 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
16286
16287 install_element (BGP_NODE, &bgp_damp_set_cmd);
16288 install_element (BGP_NODE, &bgp_damp_set2_cmd);
16289 install_element (BGP_NODE, &bgp_damp_set3_cmd);
16290 install_element (BGP_NODE, &bgp_damp_unset_cmd);
16291 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
16292 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
16293 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
16294 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
16295 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
16296 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016297
16298 /* Deprecated AS-Pathlimit commands */
16299 install_element (BGP_NODE, &bgp_network_ttl_cmd);
16300 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
16301 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
16302 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
16303 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16304 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16305
16306 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
16307 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
16308 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16309 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
16310 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16311 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16312
16313 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
16314 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
16315 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
16316 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
16317 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16318 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16319
16320 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
16321 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
16322 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16323 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
16324 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16325 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16326
16327 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
16328 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
16329 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
16330 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
16331 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16332 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16333
16334 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
16335 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
16336 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16337 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
16338 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16339 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000016340
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016341 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
16342 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016343
16344 /* old style commands */
16345 install_element (VIEW_NODE, &show_ip_bgp_cmd);
16346 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
16347 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
16348 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
16349 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16350 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16351 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
16352 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16353 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16354 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16355 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
16356 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
16357 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
16358 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
16359 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16360 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
16361 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16362 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
16363 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16364 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
16365 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16366 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
16367 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16368 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
16369 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16370 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
16371 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
16372 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
16373 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
16374 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
16375 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
16376 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
16377 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
16378 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
16379 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
16380 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
16381 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
16382 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16383 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16384 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16385 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16386 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
16387 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16388 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
16389 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16390 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
16391 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16392 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16393 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16394 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16395 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16396 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
16397 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16398 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16399 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16400 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
16401 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
16402 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16403 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
16404 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16405 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
16406 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
16407 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
16408 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16409 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16410 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
16411 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
16412 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16413 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16414 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16415 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16416 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16417 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
16418 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16419 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
16420 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
16421 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
16422 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
16423 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16424 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16425 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16426 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
16427 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16428 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16429 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
16430 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
16431 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16432 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
16433 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16434 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16435 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16436 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
16437 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
16438 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
16439 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
16440 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
16441 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
16442 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
16443 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
16444 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
16445 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
16446 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
16447 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
16448 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
16449 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
16450 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16451 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16452 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16453 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16454 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
16455 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16456 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16457 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16458 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
16459 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
16460 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
16461 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
16462 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16463 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16464 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
16465 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16466 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16467 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16468 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
16469 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
16470 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
16471 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
16472 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16473 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
16474 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16475 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
16476 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16477 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
16478 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16479 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
16480 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16481 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
16482 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16483 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
16484 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
16485 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
16486 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
16487 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
16488 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
16489 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
16490 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
16491 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
16492 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
16493 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
16494 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
16495 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16496 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16497 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16498 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16499 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
16500 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16501 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
16502 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16503 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
16504 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16505 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16506 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16507 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16508 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16509 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
16510 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16511 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16512 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16513 install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd);
16514 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
16515 install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16516 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
16517 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16518 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
16519 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd);
16520 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
16521 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16522 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16523 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
16524 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd);
16525 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
16526 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16527 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16528 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16529 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16530 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16531 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
16532 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16533 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
16534 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
16535 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
16536 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
16537 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16538 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16539 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16540 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
16541 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16542 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16543 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
16544 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
16545 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
16546 install_element (VIEW_NODE, &show_bgp_cmd);
16547 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
16548 install_element (VIEW_NODE, &show_bgp_route_cmd);
16549 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
16550 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
16551 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
16552 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
16553 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
16554 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
16555 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
16556 install_element (VIEW_NODE, &show_bgp_community_cmd);
16557 install_element (VIEW_NODE, &show_bgp_community2_cmd);
16558 install_element (VIEW_NODE, &show_bgp_community3_cmd);
16559 install_element (VIEW_NODE, &show_bgp_community4_cmd);
16560 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
16561 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
16562 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
16563 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
16564 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16565 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
16566 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
16567 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
16568 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
16569 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
16570 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
16571 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16572 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
16573 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
16574 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
16575 install_element (VIEW_NODE, &show_bgp_view_cmd);
16576 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
16577 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
16578 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16579 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16580 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
16581 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16582 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
16583 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
16584 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
16585 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
16586 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
16587 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
16588 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
16589 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
16590 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
16591 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
16592 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
16593 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
16594 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
16595 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
16596 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
16597 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16598 install_element (ENABLE_NODE, &show_bgp_cmd);
16599 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
16600 install_element (ENABLE_NODE, &show_bgp_route_cmd);
16601 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
16602 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
16603 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
16604 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
16605 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
16606 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
16607 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
16608 install_element (ENABLE_NODE, &show_bgp_community_cmd);
16609 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
16610 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
16611 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
16612 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
16613 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
16614 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
16615 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
16616 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16617 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
16618 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
16619 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
16620 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
16621 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
16622 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16623 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
16624 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
16625 install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
16626 install_element (ENABLE_NODE, &show_bgp_view_cmd);
16627 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
16628 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
16629 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16630 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16631 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
16632 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16633 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
16634 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
16635 install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
16636 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
16637 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
16638 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
16639 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
16640 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
16641 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
16642 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
16643 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
16644 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
16645 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
16646 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
16647 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
16648 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
16649 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
16650 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
16651 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
16652 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
16653 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
16654 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16655 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16656 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
16657 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
16658 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
16659 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
16660 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16661 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
16662 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
16663 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
16664 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
16665 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
16666 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
16667 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
16668 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16669 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16670 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16671 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
16672 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16673 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16674 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
16675 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
16676 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
16677 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
16678 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
16679 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
16680 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
16681 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
16682 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
16683 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
16684 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
16685 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
16686 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
16687 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
16688 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
16689 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
16690 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16691 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16692 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
16693 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
16694 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
16695 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
16696 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16697 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
16698 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
16699 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
16700 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
16701 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
16702 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
16703 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
16704 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16705 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16706 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16707 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
16708 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16709 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16710 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16711 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16712 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16713 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16714 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16715 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16716 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16717 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16718 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
16719 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
16720 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16721 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16722 /* old with name safi collision */
16723 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
16724 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
16725 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
16726 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
16727 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
16728 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
16729 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
16730 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
16731 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
16732 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
16733 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
16734 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
16735 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
16736 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
16737 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
16738 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
16739 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
16740 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
16741 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
16742 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
16743 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
16744 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
16745 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
16746 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
16747 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16748 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
16749 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16750 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
16751
16752 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
16753 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
16754 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
16755 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
16756 install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
16757 install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
16758
16759 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
16760 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
16761 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
16762 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
16763 install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
16764 install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016765}
Chris Caputo228da422009-07-18 05:44:03 +000016766
16767void
16768bgp_route_finish (void)
16769{
16770 bgp_table_unlock (bgp_distance_table);
16771 bgp_distance_table = NULL;
16772}