blob: 2728b10311117eddf30aca4a29a68e9bc13c1eb8 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
23#include "prefix.h"
24#include "linklist.h"
25#include "memory.h"
26#include "command.h"
27#include "stream.h"
28#include "filter.h"
29#include "str.h"
30#include "log.h"
31#include "routemap.h"
32#include "buffer.h"
33#include "sockunion.h"
34#include "plist.h"
35#include "thread.h"
paul200df112005-06-01 11:17:05 +000036#include "workqueue.h"
paul718e3742002-12-13 20:15:29 +000037
38#include "bgpd/bgpd.h"
39#include "bgpd/bgp_table.h"
40#include "bgpd/bgp_route.h"
41#include "bgpd/bgp_attr.h"
42#include "bgpd/bgp_debug.h"
43#include "bgpd/bgp_aspath.h"
44#include "bgpd/bgp_regex.h"
45#include "bgpd/bgp_community.h"
46#include "bgpd/bgp_ecommunity.h"
47#include "bgpd/bgp_clist.h"
48#include "bgpd/bgp_packet.h"
49#include "bgpd/bgp_filter.h"
50#include "bgpd/bgp_fsm.h"
51#include "bgpd/bgp_mplsvpn.h"
52#include "bgpd/bgp_nexthop.h"
53#include "bgpd/bgp_damp.h"
54#include "bgpd/bgp_advertise.h"
55#include "bgpd/bgp_zebra.h"
hasso0a486e52005-02-01 20:57:17 +000056#include "bgpd/bgp_vty.h"
Josh Bailey96450fa2011-07-20 20:45:12 -070057#include "bgpd/bgp_mpath.h"
paul718e3742002-12-13 20:15:29 +000058
59/* Extern from bgp_dump.c */
Stephen Hemmingerdde72582009-05-08 15:19:07 -070060extern const char *bgp_origin_str[];
61extern const char *bgp_origin_long_str[];
David Lamparter6b0655a2014-06-04 06:53:35 +020062
paul94f2b392005-06-28 12:44:16 +000063static struct bgp_node *
paulfee0f4c2004-09-13 05:12:46 +000064bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
paul718e3742002-12-13 20:15:29 +000065 struct prefix_rd *prd)
66{
67 struct bgp_node *rn;
68 struct bgp_node *prn = NULL;
Paul Jakmada5b30f2006-05-08 14:37:17 +000069
70 assert (table);
71 if (!table)
72 return NULL;
73
Lou Berger298cc2f2016-01-12 13:42:02 -050074 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000075 {
paulfee0f4c2004-09-13 05:12:46 +000076 prn = bgp_node_get (table, (struct prefix *) prd);
paul718e3742002-12-13 20:15:29 +000077
78 if (prn->info == NULL)
Paul Jakma64e580a2006-02-21 01:09:01 +000079 prn->info = bgp_table_init (afi, safi);
paul718e3742002-12-13 20:15:29 +000080 else
81 bgp_unlock_node (prn);
82 table = prn->info;
83 }
paul718e3742002-12-13 20:15:29 +000084
85 rn = bgp_node_get (table, p);
86
Lou Berger298cc2f2016-01-12 13:42:02 -050087 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000088 rn->prn = prn;
89
90 return rn;
91}
David Lamparter6b0655a2014-06-04 06:53:35 +020092
Paul Jakmafb982c22007-05-04 20:15:47 +000093/* Allocate bgp_info_extra */
94static struct bgp_info_extra *
95bgp_info_extra_new (void)
96{
97 struct bgp_info_extra *new;
98 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra));
99 return new;
100}
101
102static void
103bgp_info_extra_free (struct bgp_info_extra **extra)
104{
105 if (extra && *extra)
106 {
107 if ((*extra)->damp_info)
108 bgp_damp_info_free ((*extra)->damp_info, 0);
109
110 (*extra)->damp_info = NULL;
111
112 XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra);
113
114 *extra = NULL;
115 }
116}
117
118/* Get bgp_info extra information for the given bgp_info, lazy allocated
119 * if required.
120 */
121struct bgp_info_extra *
122bgp_info_extra_get (struct bgp_info *ri)
123{
124 if (!ri->extra)
125 ri->extra = bgp_info_extra_new();
126 return ri->extra;
127}
128
paul718e3742002-12-13 20:15:29 +0000129/* Allocate new bgp info structure. */
paul200df112005-06-01 11:17:05 +0000130static struct bgp_info *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -0800131bgp_info_new (void)
paul718e3742002-12-13 20:15:29 +0000132{
Stephen Hemminger393deb92008-08-18 14:13:29 -0700133 return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
paul718e3742002-12-13 20:15:29 +0000134}
135
136/* Free bgp route information. */
paul200df112005-06-01 11:17:05 +0000137static void
paul718e3742002-12-13 20:15:29 +0000138bgp_info_free (struct bgp_info *binfo)
139{
140 if (binfo->attr)
Paul Jakmaf6f434b2010-11-23 21:28:03 +0000141 bgp_attr_unintern (&binfo->attr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000142
143 bgp_info_extra_free (&binfo->extra);
Josh Baileyde8d5df2011-07-20 20:46:01 -0700144 bgp_info_mpath_free (&binfo->mpath);
paul718e3742002-12-13 20:15:29 +0000145
paul200df112005-06-01 11:17:05 +0000146 peer_unlock (binfo->peer); /* bgp_info peer reference */
147
paul718e3742002-12-13 20:15:29 +0000148 XFREE (MTYPE_BGP_ROUTE, binfo);
149}
150
paul200df112005-06-01 11:17:05 +0000151struct bgp_info *
152bgp_info_lock (struct bgp_info *binfo)
153{
154 binfo->lock++;
155 return binfo;
156}
157
158struct bgp_info *
159bgp_info_unlock (struct bgp_info *binfo)
160{
161 assert (binfo && binfo->lock > 0);
162 binfo->lock--;
163
164 if (binfo->lock == 0)
165 {
166#if 0
167 zlog_debug ("%s: unlocked and freeing", __func__);
168 zlog_backtrace (LOG_DEBUG);
169#endif
170 bgp_info_free (binfo);
171 return NULL;
172 }
173
174#if 0
175 if (binfo->lock == 1)
176 {
177 zlog_debug ("%s: unlocked to 1", __func__);
178 zlog_backtrace (LOG_DEBUG);
179 }
180#endif
181
182 return binfo;
183}
184
paul718e3742002-12-13 20:15:29 +0000185void
186bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
187{
188 struct bgp_info *top;
189
190 top = rn->info;
paul200df112005-06-01 11:17:05 +0000191
paul718e3742002-12-13 20:15:29 +0000192 ri->next = rn->info;
193 ri->prev = NULL;
194 if (top)
195 top->prev = ri;
196 rn->info = ri;
paul200df112005-06-01 11:17:05 +0000197
198 bgp_info_lock (ri);
199 bgp_lock_node (rn);
200 peer_lock (ri->peer); /* bgp_info peer reference */
paul718e3742002-12-13 20:15:29 +0000201}
202
paulb40d9392005-08-22 22:34:41 +0000203/* Do the actual removal of info from RIB, for use by bgp_process
204 completion callback *only* */
205static void
206bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri)
paul718e3742002-12-13 20:15:29 +0000207{
208 if (ri->next)
209 ri->next->prev = ri->prev;
210 if (ri->prev)
211 ri->prev->next = ri->next;
212 else
213 rn->info = ri->next;
paul200df112005-06-01 11:17:05 +0000214
Josh Baileyde8d5df2011-07-20 20:46:01 -0700215 bgp_info_mpath_dequeue (ri);
paul200df112005-06-01 11:17:05 +0000216 bgp_info_unlock (ri);
217 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +0000218}
219
paulb40d9392005-08-22 22:34:41 +0000220void
221bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
222{
Paul Jakma1a392d42006-09-07 00:24:49 +0000223 bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED);
224 /* set of previous already took care of pcount */
paulb40d9392005-08-22 22:34:41 +0000225 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
226}
227
Andrew J. Schorr8d452102006-11-28 19:50:46 +0000228/* undo the effects of a previous call to bgp_info_delete; typically
229 called when a route is deleted and then quickly re-added before the
230 deletion has been processed */
231static void
232bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri)
233{
234 bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED);
235 /* unset of previous already took care of pcount */
236 SET_FLAG (ri->flags, BGP_INFO_VALID);
237}
238
Paul Jakma1a392d42006-09-07 00:24:49 +0000239/* Adjust pcount as required */
240static void
241bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri)
242{
Avneesh Sachdev67174042012-08-17 08:19:49 -0700243 struct bgp_table *table;
244
245 assert (rn && bgp_node_table (rn));
Paul Jakma6f585442006-10-22 19:13:07 +0000246 assert (ri && ri->peer && ri->peer->bgp);
247
Avneesh Sachdev67174042012-08-17 08:19:49 -0700248 table = bgp_node_table (rn);
249
Paul Jakma1a392d42006-09-07 00:24:49 +0000250 /* Ignore 'pcount' for RS-client tables */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700251 if (table->type != BGP_TABLE_MAIN
Paul Jakma1a392d42006-09-07 00:24:49 +0000252 || ri->peer == ri->peer->bgp->peer_self)
253 return;
254
255 if (BGP_INFO_HOLDDOWN (ri)
256 && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
257 {
258
259 UNSET_FLAG (ri->flags, BGP_INFO_COUNTED);
260
261 /* slight hack, but more robust against errors. */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700262 if (ri->peer->pcount[table->afi][table->safi])
263 ri->peer->pcount[table->afi][table->safi]--;
Paul Jakma1a392d42006-09-07 00:24:49 +0000264 else
265 {
266 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
267 __func__, ri->peer->host);
268 zlog_backtrace (LOG_WARNING);
269 zlog_warn ("%s: Please report to Quagga bugzilla", __func__);
270 }
271 }
272 else if (!BGP_INFO_HOLDDOWN (ri)
273 && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
274 {
275 SET_FLAG (ri->flags, BGP_INFO_COUNTED);
Avneesh Sachdev67174042012-08-17 08:19:49 -0700276 ri->peer->pcount[table->afi][table->safi]++;
Paul Jakma1a392d42006-09-07 00:24:49 +0000277 }
278}
279
280
281/* Set/unset bgp_info flags, adjusting any other state as needed.
282 * This is here primarily to keep prefix-count in check.
283 */
284void
285bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
286{
287 SET_FLAG (ri->flags, flag);
288
289 /* early bath if we know it's not a flag that changes useability state */
290 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
291 return;
292
293 bgp_pcount_adjust (rn, ri);
294}
295
296void
297bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
298{
299 UNSET_FLAG (ri->flags, flag);
300
301 /* early bath if we know it's not a flag that changes useability state */
302 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
303 return;
304
305 bgp_pcount_adjust (rn, ri);
306}
307
paul718e3742002-12-13 20:15:29 +0000308/* Get MED value. If MED value is missing and "bgp bestpath
309 missing-as-worst" is specified, treat it as the worst value. */
paul94f2b392005-06-28 12:44:16 +0000310static u_int32_t
paul718e3742002-12-13 20:15:29 +0000311bgp_med_value (struct attr *attr, struct bgp *bgp)
312{
313 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
314 return attr->med;
315 else
316 {
317 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
paul3b424972003-10-13 09:47:32 +0000318 return BGP_MED_MAX;
paul718e3742002-12-13 20:15:29 +0000319 else
320 return 0;
321 }
322}
323
Paul Jakma6d4742b2015-11-25 17:14:37 +0000324/* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
325 * is preferred, or 0 if they are the same (usually will only occur if
326 * multipath is enabled */
paul94f2b392005-06-28 12:44:16 +0000327static int
Josh Bailey96450fa2011-07-20 20:45:12 -0700328bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
Paul Jakma6d4742b2015-11-25 17:14:37 +0000329 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +0000330{
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000331 struct attr *newattr, *existattr;
332 struct attr_extra *newattre, *existattre;
333 bgp_peer_sort_t new_sort;
334 bgp_peer_sort_t exist_sort;
paul718e3742002-12-13 20:15:29 +0000335 u_int32_t new_pref;
336 u_int32_t exist_pref;
337 u_int32_t new_med;
338 u_int32_t exist_med;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000339 u_int32_t new_weight;
340 u_int32_t exist_weight;
341 uint32_t newm, existm;
paul718e3742002-12-13 20:15:29 +0000342 struct in_addr new_id;
343 struct in_addr exist_id;
344 int new_cluster;
345 int exist_cluster;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000346 int internal_as_route;
347 int confed_as_route;
paul718e3742002-12-13 20:15:29 +0000348 int ret;
Josh Bailey96450fa2011-07-20 20:45:12 -0700349
paul718e3742002-12-13 20:15:29 +0000350 /* 0. Null check. */
351 if (new == NULL)
paul718e3742002-12-13 20:15:29 +0000352 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000353 if (exist == NULL)
354 return -1;
paul718e3742002-12-13 20:15:29 +0000355
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000356 newattr = new->attr;
357 existattr = exist->attr;
358 newattre = newattr->extra;
359 existattre = existattr->extra;
360
paul718e3742002-12-13 20:15:29 +0000361 /* 1. Weight check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000362 new_weight = exist_weight = 0;
363
364 if (newattre)
365 new_weight = newattre->weight;
366 if (existattre)
367 exist_weight = existattre->weight;
368
Paul Jakmafb982c22007-05-04 20:15:47 +0000369 if (new_weight > exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000370 return -1;
Paul Jakmafb982c22007-05-04 20:15:47 +0000371 if (new_weight < exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000372 return 1;
paul718e3742002-12-13 20:15:29 +0000373
374 /* 2. Local preference check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000375 new_pref = exist_pref = bgp->default_local_pref;
paul718e3742002-12-13 20:15:29 +0000376
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000377 if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
378 new_pref = newattr->local_pref;
379 if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
380 exist_pref = existattr->local_pref;
381
paul718e3742002-12-13 20:15:29 +0000382 if (new_pref > exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000383 return -1;
paul718e3742002-12-13 20:15:29 +0000384 if (new_pref < exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000385 return 1;
paul718e3742002-12-13 20:15:29 +0000386
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000387 /* 3. Local route check. We prefer:
388 * - BGP_ROUTE_STATIC
389 * - BGP_ROUTE_AGGREGATE
390 * - BGP_ROUTE_REDISTRIBUTE
391 */
392 if (! (new->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000393 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000394 if (! (exist->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000395 return 1;
paul718e3742002-12-13 20:15:29 +0000396
397 /* 4. AS path length check. */
398 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
399 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000400 int exist_hops = aspath_count_hops (existattr->aspath);
401 int exist_confeds = aspath_count_confeds (existattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000402
hasso68118452005-04-08 15:40:36 +0000403 if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
404 {
paulfe69a502005-09-10 16:55:02 +0000405 int aspath_hops;
406
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000407 aspath_hops = aspath_count_hops (newattr->aspath);
408 aspath_hops += aspath_count_confeds (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000409
410 if ( aspath_hops < (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000411 return -1;
paulfe69a502005-09-10 16:55:02 +0000412 if ( aspath_hops > (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000413 return 1;
hasso68118452005-04-08 15:40:36 +0000414 }
415 else
416 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000417 int newhops = aspath_count_hops (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000418
419 if (newhops < exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000420 return -1;
paulfe69a502005-09-10 16:55:02 +0000421 if (newhops > exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000422 return 1;
hasso68118452005-04-08 15:40:36 +0000423 }
paul718e3742002-12-13 20:15:29 +0000424 }
425
426 /* 5. Origin check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000427 if (newattr->origin < existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000428 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000429 if (newattr->origin > existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000430 return 1;
paul718e3742002-12-13 20:15:29 +0000431
432 /* 6. MED check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000433 internal_as_route = (aspath_count_hops (newattr->aspath) == 0
434 && aspath_count_hops (existattr->aspath) == 0);
435 confed_as_route = (aspath_count_confeds (newattr->aspath) > 0
436 && aspath_count_confeds (existattr->aspath) > 0
437 && aspath_count_hops (newattr->aspath) == 0
438 && aspath_count_hops (existattr->aspath) == 0);
paul718e3742002-12-13 20:15:29 +0000439
440 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
441 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
442 && confed_as_route)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000443 || aspath_cmp_left (newattr->aspath, existattr->aspath)
444 || aspath_cmp_left_confed (newattr->aspath, existattr->aspath)
paul718e3742002-12-13 20:15:29 +0000445 || internal_as_route)
446 {
447 new_med = bgp_med_value (new->attr, bgp);
448 exist_med = bgp_med_value (exist->attr, bgp);
449
450 if (new_med < exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000451 return -1;
paul718e3742002-12-13 20:15:29 +0000452 if (new_med > exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000453 return 1;
paul718e3742002-12-13 20:15:29 +0000454 }
455
456 /* 7. Peer type check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000457 new_sort = new->peer->sort;
458 exist_sort = exist->peer->sort;
459
460 if (new_sort == BGP_PEER_EBGP
461 && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000462 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000463 if (exist_sort == BGP_PEER_EBGP
464 && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000465 return 1;
paul718e3742002-12-13 20:15:29 +0000466
467 /* 8. IGP metric check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000468 newm = existm = 0;
469
470 if (new->extra)
471 newm = new->extra->igpmetric;
472 if (exist->extra)
473 existm = exist->extra->igpmetric;
474
Josh Bailey96450fa2011-07-20 20:45:12 -0700475 if (newm < existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000476 return -1;
Josh Bailey96450fa2011-07-20 20:45:12 -0700477 if (newm > existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000478 return 1;
paul718e3742002-12-13 20:15:29 +0000479
480 /* 9. Maximum path check. */
Paul Jakma6d4742b2015-11-25 17:14:37 +0000481 if (bgp_mpath_is_configured (bgp, afi, safi))
Josh Bailey96450fa2011-07-20 20:45:12 -0700482 {
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000483 if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX))
484 {
Paul Jakma6d4742b2015-11-25 17:14:37 +0000485 /*
486 * For the two paths, all comparison steps till IGP metric
487 * have succeeded - including AS_PATH hop count. Since 'bgp
488 * bestpath as-path multipath-relax' knob is on, we don't need
489 * an exact match of AS_PATH. Thus, mark the paths are equal.
490 * That will trigger both these paths to get into the multipath
491 * array.
492 */
493 return 0;
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000494 }
495 else if (new->peer->sort == BGP_PEER_IBGP)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000496 {
497 if (aspath_cmp (new->attr->aspath, exist->attr->aspath))
498 return 0;
499 }
Josh Bailey96450fa2011-07-20 20:45:12 -0700500 else if (new->peer->as == exist->peer->as)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000501 return 0;
Josh Bailey96450fa2011-07-20 20:45:12 -0700502 }
paul718e3742002-12-13 20:15:29 +0000503
504 /* 10. If both paths are external, prefer the path that was received
505 first (the oldest one). This step minimizes route-flap, since a
506 newer path won't displace an older one, even if it was the
507 preferred route based on the additional decision criteria below. */
508 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000509 && new_sort == BGP_PEER_EBGP
510 && exist_sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +0000511 {
512 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000513 return -1;
paul718e3742002-12-13 20:15:29 +0000514 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000515 return 1;
paul718e3742002-12-13 20:15:29 +0000516 }
517
vivekbd4b7f12014-09-30 15:54:45 -0700518 /* 11. Router-ID comparision. */
519 /* If one of the paths is "stale", the corresponding peer router-id will
520 * be 0 and would always win over the other path. If originator id is
521 * used for the comparision, it will decide which path is better.
522 */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000523 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
524 new_id.s_addr = newattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000525 else
526 new_id.s_addr = new->peer->remote_id.s_addr;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000527 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
528 exist_id.s_addr = existattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000529 else
530 exist_id.s_addr = exist->peer->remote_id.s_addr;
531
532 if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000533 return -1;
paul718e3742002-12-13 20:15:29 +0000534 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000535 return 1;
paul718e3742002-12-13 20:15:29 +0000536
537 /* 12. Cluster length comparision. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000538 new_cluster = exist_cluster = 0;
539
540 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
541 new_cluster = newattre->cluster->length;
542 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
543 exist_cluster = existattre->cluster->length;
paul718e3742002-12-13 20:15:29 +0000544
545 if (new_cluster < exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000546 return -1;
paul718e3742002-12-13 20:15:29 +0000547 if (new_cluster > exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000548 return 1;
paul718e3742002-12-13 20:15:29 +0000549
550 /* 13. Neighbor address comparision. */
vivekbd4b7f12014-09-30 15:54:45 -0700551 /* Do this only if neither path is "stale" as stale paths do not have
552 * valid peer information (as the connection may or may not be up).
553 */
554 if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000555 return -1;
vivekbd4b7f12014-09-30 15:54:45 -0700556 if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000557 return 1;
Timo Teräs2820a012015-06-24 15:27:21 +0300558 /* locally configured routes to advertise do not have su_remote */
559 if (new->peer->su_remote == NULL)
Timo Teräs2820a012015-06-24 15:27:21 +0300560 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000561 if (exist->peer->su_remote == NULL)
562 return -1;
Timo Teräs2820a012015-06-24 15:27:21 +0300563
paul718e3742002-12-13 20:15:29 +0000564 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
565
566 if (ret == 1)
paul718e3742002-12-13 20:15:29 +0000567 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000568 if (ret == -1)
569 return -1;
paul718e3742002-12-13 20:15:29 +0000570
Paul Jakma6d4742b2015-11-25 17:14:37 +0000571 return -1;
paul718e3742002-12-13 20:15:29 +0000572}
573
paul94f2b392005-06-28 12:44:16 +0000574static enum filter_type
paul718e3742002-12-13 20:15:29 +0000575bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
576 afi_t afi, safi_t safi)
577{
578 struct bgp_filter *filter;
579
580 filter = &peer->filter[afi][safi];
581
Paul Jakma650f76c2009-06-25 18:06:31 +0100582#define FILTER_EXIST_WARN(F,f,filter) \
583 if (BGP_DEBUG (update, UPDATE_IN) \
584 && !(F ## _IN (filter))) \
585 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
586 peer->host, #f, F ## _IN_NAME(filter));
587
588 if (DISTRIBUTE_IN_NAME (filter)) {
589 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
590
paul718e3742002-12-13 20:15:29 +0000591 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
592 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100593 }
paul718e3742002-12-13 20:15:29 +0000594
Paul Jakma650f76c2009-06-25 18:06:31 +0100595 if (PREFIX_LIST_IN_NAME (filter)) {
596 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
597
paul718e3742002-12-13 20:15:29 +0000598 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
599 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100600 }
paul718e3742002-12-13 20:15:29 +0000601
Paul Jakma650f76c2009-06-25 18:06:31 +0100602 if (FILTER_LIST_IN_NAME (filter)) {
603 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
604
paul718e3742002-12-13 20:15:29 +0000605 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
606 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100607 }
608
paul718e3742002-12-13 20:15:29 +0000609 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100610#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000611}
612
paul94f2b392005-06-28 12:44:16 +0000613static enum filter_type
paul718e3742002-12-13 20:15:29 +0000614bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
615 afi_t afi, safi_t safi)
616{
617 struct bgp_filter *filter;
618
619 filter = &peer->filter[afi][safi];
620
Paul Jakma650f76c2009-06-25 18:06:31 +0100621#define FILTER_EXIST_WARN(F,f,filter) \
622 if (BGP_DEBUG (update, UPDATE_OUT) \
623 && !(F ## _OUT (filter))) \
624 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
625 peer->host, #f, F ## _OUT_NAME(filter));
626
627 if (DISTRIBUTE_OUT_NAME (filter)) {
628 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
629
paul718e3742002-12-13 20:15:29 +0000630 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
631 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100632 }
paul718e3742002-12-13 20:15:29 +0000633
Paul Jakma650f76c2009-06-25 18:06:31 +0100634 if (PREFIX_LIST_OUT_NAME (filter)) {
635 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
636
paul718e3742002-12-13 20:15:29 +0000637 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
638 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100639 }
paul718e3742002-12-13 20:15:29 +0000640
Paul Jakma650f76c2009-06-25 18:06:31 +0100641 if (FILTER_LIST_OUT_NAME (filter)) {
642 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
643
paul718e3742002-12-13 20:15:29 +0000644 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
645 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100646 }
paul718e3742002-12-13 20:15:29 +0000647
648 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100649#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000650}
651
652/* If community attribute includes no_export then return 1. */
paul94f2b392005-06-28 12:44:16 +0000653static int
paul718e3742002-12-13 20:15:29 +0000654bgp_community_filter (struct peer *peer, struct attr *attr)
655{
656 if (attr->community)
657 {
658 /* NO_ADVERTISE check. */
659 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
660 return 1;
661
662 /* NO_EXPORT check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000663 if (peer->sort == BGP_PEER_EBGP &&
paul718e3742002-12-13 20:15:29 +0000664 community_include (attr->community, COMMUNITY_NO_EXPORT))
665 return 1;
666
667 /* NO_EXPORT_SUBCONFED check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000668 if (peer->sort == BGP_PEER_EBGP
669 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000670 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
671 return 1;
672 }
673 return 0;
674}
675
676/* Route reflection loop check. */
677static int
678bgp_cluster_filter (struct peer *peer, struct attr *attr)
679{
680 struct in_addr cluster_id;
681
Paul Jakmafb982c22007-05-04 20:15:47 +0000682 if (attr->extra && attr->extra->cluster)
paul718e3742002-12-13 20:15:29 +0000683 {
684 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
685 cluster_id = peer->bgp->cluster_id;
686 else
687 cluster_id = peer->bgp->router_id;
688
Paul Jakmafb982c22007-05-04 20:15:47 +0000689 if (cluster_loop_check (attr->extra->cluster, cluster_id))
paul718e3742002-12-13 20:15:29 +0000690 return 1;
691 }
692 return 0;
693}
David Lamparter6b0655a2014-06-04 06:53:35 +0200694
paul94f2b392005-06-28 12:44:16 +0000695static int
paul718e3742002-12-13 20:15:29 +0000696bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
697 afi_t afi, safi_t safi)
698{
699 struct bgp_filter *filter;
700 struct bgp_info info;
701 route_map_result_t ret;
702
703 filter = &peer->filter[afi][safi];
704
705 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000706 if (peer->weight)
707 (bgp_attr_extra_get (attr))->weight = peer->weight;
paul718e3742002-12-13 20:15:29 +0000708
709 /* Route map apply. */
710 if (ROUTE_MAP_IN_NAME (filter))
711 {
712 /* Duplicate current value to new strucutre for modification. */
713 info.peer = peer;
714 info.attr = attr;
715
paulac41b2a2003-08-12 05:32:27 +0000716 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
717
paul718e3742002-12-13 20:15:29 +0000718 /* Apply BGP route map to the attribute. */
719 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
paulac41b2a2003-08-12 05:32:27 +0000720
721 peer->rmap_type = 0;
722
paul718e3742002-12-13 20:15:29 +0000723 if (ret == RMAP_DENYMATCH)
David Lamparterc460e572014-06-04 00:54:58 +0200724 /* caller has multiple error paths with bgp_attr_flush() */
725 return RMAP_DENY;
paul718e3742002-12-13 20:15:29 +0000726 }
727 return RMAP_PERMIT;
728}
David Lamparter6b0655a2014-06-04 06:53:35 +0200729
paul94f2b392005-06-28 12:44:16 +0000730static int
paulfee0f4c2004-09-13 05:12:46 +0000731bgp_export_modifier (struct peer *rsclient, struct peer *peer,
732 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
733{
734 struct bgp_filter *filter;
735 struct bgp_info info;
736 route_map_result_t ret;
737
738 filter = &peer->filter[afi][safi];
739
740 /* Route map apply. */
741 if (ROUTE_MAP_EXPORT_NAME (filter))
742 {
743 /* Duplicate current value to new strucutre for modification. */
744 info.peer = rsclient;
745 info.attr = attr;
746
747 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
748
749 /* Apply BGP route map to the attribute. */
750 ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
751
752 rsclient->rmap_type = 0;
753
754 if (ret == RMAP_DENYMATCH)
755 {
756 /* Free newly generated AS path and community by route-map. */
757 bgp_attr_flush (attr);
758 return RMAP_DENY;
759 }
760 }
761 return RMAP_PERMIT;
762}
763
paul94f2b392005-06-28 12:44:16 +0000764static int
paulfee0f4c2004-09-13 05:12:46 +0000765bgp_import_modifier (struct peer *rsclient, struct peer *peer,
766 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
767{
768 struct bgp_filter *filter;
769 struct bgp_info info;
770 route_map_result_t ret;
771
772 filter = &rsclient->filter[afi][safi];
773
774 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000775 if (peer->weight)
776 (bgp_attr_extra_get (attr))->weight = peer->weight;
paulfee0f4c2004-09-13 05:12:46 +0000777
778 /* Route map apply. */
779 if (ROUTE_MAP_IMPORT_NAME (filter))
780 {
781 /* Duplicate current value to new strucutre for modification. */
782 info.peer = peer;
783 info.attr = attr;
784
785 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
786
787 /* Apply BGP route map to the attribute. */
788 ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
789
790 peer->rmap_type = 0;
791
792 if (ret == RMAP_DENYMATCH)
793 {
794 /* Free newly generated AS path and community by route-map. */
795 bgp_attr_flush (attr);
796 return RMAP_DENY;
797 }
798 }
799 return RMAP_PERMIT;
800}
David Lamparter6b0655a2014-06-04 06:53:35 +0200801
paul94f2b392005-06-28 12:44:16 +0000802static int
paul718e3742002-12-13 20:15:29 +0000803bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
804 struct attr *attr, afi_t afi, safi_t safi)
805{
806 int ret;
807 char buf[SU_ADDRSTRLEN];
808 struct bgp_filter *filter;
paul718e3742002-12-13 20:15:29 +0000809 struct peer *from;
810 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +0000811 int transparent;
812 int reflect;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700813 struct attr *riattr;
paul718e3742002-12-13 20:15:29 +0000814
815 from = ri->peer;
816 filter = &peer->filter[afi][safi];
817 bgp = peer->bgp;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700818 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paul718e3742002-12-13 20:15:29 +0000819
Paul Jakma750e8142008-07-22 21:11:48 +0000820 if (DISABLE_BGP_ANNOUNCE)
821 return 0;
paul718e3742002-12-13 20:15:29 +0000822
paulfee0f4c2004-09-13 05:12:46 +0000823 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
824 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
825 return 0;
826
paul718e3742002-12-13 20:15:29 +0000827 /* Do not send back route to sender. */
828 if (from == peer)
829 return 0;
830
831 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000832 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +0000833 if (! UNSUPPRESS_MAP_NAME (filter))
834 return 0;
835
836 /* Default route check. */
837 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
838 {
839 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
840 return 0;
paul718e3742002-12-13 20:15:29 +0000841 else if (p->family == AF_INET6 && p->prefixlen == 0)
842 return 0;
paul718e3742002-12-13 20:15:29 +0000843 }
844
paul286e1e72003-08-08 00:24:31 +0000845 /* Transparency check. */
846 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
847 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
848 transparent = 1;
849 else
850 transparent = 0;
851
paul718e3742002-12-13 20:15:29 +0000852 /* If community is not disabled check the no-export and local. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700853 if (! transparent && bgp_community_filter (peer, riattr))
paul718e3742002-12-13 20:15:29 +0000854 return 0;
855
856 /* If the attribute has originator-id and it is same as remote
857 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700858 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paul718e3742002-12-13 20:15:29 +0000859 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700860 if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +0000861 {
862 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000863 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000864 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
865 peer->host,
866 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
867 p->prefixlen);
868 return 0;
869 }
870 }
871
872 /* ORF prefix-list filter check */
873 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
874 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
875 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
876 if (peer->orf_plist[afi][safi])
877 {
878 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
879 return 0;
880 }
881
882 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700883 if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
paul718e3742002-12-13 20:15:29 +0000884 {
885 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000886 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000887 "%s [Update:SEND] %s/%d is filtered",
888 peer->host,
889 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
890 p->prefixlen);
891 return 0;
892 }
893
894#ifdef BGP_SEND_ASPATH_CHECK
895 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700896 if (aspath_loop_check (riattr->aspath, peer->as))
paul718e3742002-12-13 20:15:29 +0000897 {
898 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000899 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400900 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000901 peer->host, peer->as);
902 return 0;
903 }
904#endif /* BGP_SEND_ASPATH_CHECK */
905
906 /* If we're a CONFED we need to loop check the CONFED ID too */
907 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
908 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700909 if (aspath_loop_check(riattr->aspath, bgp->confed_id))
paul718e3742002-12-13 20:15:29 +0000910 {
911 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000912 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400913 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000914 peer->host,
915 bgp->confed_id);
916 return 0;
917 }
918 }
919
920 /* Route-Reflect check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000921 if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +0000922 reflect = 1;
923 else
924 reflect = 0;
925
926 /* IBGP reflection check. */
927 if (reflect)
928 {
929 /* A route from a Client peer. */
930 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
931 {
932 /* Reflect to all the Non-Client peers and also to the
933 Client peers other than the originator. Originator check
934 is already done. So there is noting to do. */
935 /* no bgp client-to-client reflection check. */
936 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
937 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
938 return 0;
939 }
940 else
941 {
942 /* A route from a Non-client peer. Reflect to all other
943 clients. */
944 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
945 return 0;
946 }
947 }
Paul Jakma41367172007-08-06 15:24:51 +0000948
paul718e3742002-12-13 20:15:29 +0000949 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700950 bgp_attr_dup (attr, riattr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000951
paul718e3742002-12-13 20:15:29 +0000952 /* If local-preference is not set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000953 if ((peer->sort == BGP_PEER_IBGP
954 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000955 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
956 {
957 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
958 attr->local_pref = bgp->default_local_pref;
959 }
960
Pradosh Mohapatra689bb662013-09-07 07:13:37 +0000961 /* If originator-id is not set and the route is to be reflected,
962 set the originator id */
963 if (peer && from && peer->sort == BGP_PEER_IBGP &&
964 from->sort == BGP_PEER_IBGP &&
965 (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))))
966 {
967 attr->extra = bgp_attr_extra_get(attr);
968 IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id));
969 SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
970 }
971
paul718e3742002-12-13 20:15:29 +0000972 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000973 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +0000974 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
975 {
976 if (ri->peer != bgp->peer_self && ! transparent
977 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
978 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
979 }
980
Lou Berger298cc2f2016-01-12 13:42:02 -0500981
982#define NEXTHOP_IS_V4 (\
983 (safi != SAFI_ENCAP && p->family == AF_INET) || \
984 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4))
985
Lou Berger298cc2f2016-01-12 13:42:02 -0500986#define NEXTHOP_IS_V6 (\
987 (safi != SAFI_ENCAP && p->family == AF_INET6) || \
988 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
Lou Berger298cc2f2016-01-12 13:42:02 -0500989
paul718e3742002-12-13 20:15:29 +0000990 /* next-hop-set */
Timo Teräs9e7a53c2014-04-24 10:22:37 +0300991 if (transparent
992 || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
paul718e3742002-12-13 20:15:29 +0000993 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
Lou Berger298cc2f2016-01-12 13:42:02 -0500994 && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr)
Lou Berger298cc2f2016-01-12 13:42:02 -0500995 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +0000996 ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paul286e1e72003-08-08 00:24:31 +0000997 )))
paul718e3742002-12-13 20:15:29 +0000998 {
999 /* NEXT-HOP Unchanged. */
1000 }
1001 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
Lou Berger298cc2f2016-01-12 13:42:02 -05001002 || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0)
Lou Berger298cc2f2016-01-12 13:42:02 -05001003 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001004 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001005 || (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001006 && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0))
1007 {
1008 /* Set IPv4 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001009 if (NEXTHOP_IS_V4)
paul718e3742002-12-13 20:15:29 +00001010 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001011 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001012 memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4,
1013 IPV4_MAX_BYTELEN);
paul718e3742002-12-13 20:15:29 +00001014 else
1015 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
1016 }
paul718e3742002-12-13 20:15:29 +00001017 /* Set IPv6 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001018 if (NEXTHOP_IS_V6)
paul718e3742002-12-13 20:15:29 +00001019 {
1020 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001021 memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00001022 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001023 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001024 }
paul718e3742002-12-13 20:15:29 +00001025 }
1026
Lou Berger298cc2f2016-01-12 13:42:02 -05001027 if (p->family == AF_INET6 && safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00001028 {
paulfee0f4c2004-09-13 05:12:46 +00001029 /* Left nexthop_local unchanged if so configured. */
1030 if ( CHECK_FLAG (peer->af_flags[afi][safi],
1031 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1032 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001033 if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) )
1034 attr->extra->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001035 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001036 attr->extra->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001037 }
1038
1039 /* Default nexthop_local treatment for non-RS-Clients */
1040 else
1041 {
paul718e3742002-12-13 20:15:29 +00001042 /* Link-local address should not be transit to different peer. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001043 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001044
1045 /* Set link-local address for shared network peer. */
1046 if (peer->shared_network
1047 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
1048 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001049 memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00001050 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001051 attr->extra->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00001052 }
1053
1054 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1055 address.*/
1056 if (reflect)
Paul Jakmafb982c22007-05-04 20:15:47 +00001057 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001058
1059 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1060 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
Paul Jakmafb982c22007-05-04 20:15:47 +00001061 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001062 }
paulfee0f4c2004-09-13 05:12:46 +00001063
1064 }
paul718e3742002-12-13 20:15:29 +00001065
1066 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001067 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001068 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1069 && aspath_private_as_check (attr->aspath))
1070 attr->aspath = aspath_empty_get ();
1071
1072 /* Route map & unsuppress-map apply. */
1073 if (ROUTE_MAP_OUT_NAME (filter)
Paul Jakmafb982c22007-05-04 20:15:47 +00001074 || (ri->extra && ri->extra->suppress) )
paul718e3742002-12-13 20:15:29 +00001075 {
Paul Jakma7c7fa1b2006-02-18 10:52:09 +00001076 struct bgp_info info;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001077 struct attr dummy_attr;
1078 struct attr_extra dummy_extra;
1079
1080 dummy_attr.extra = &dummy_extra;
1081
paul718e3742002-12-13 20:15:29 +00001082 info.peer = peer;
1083 info.attr = attr;
1084
1085 /* The route reflector is not allowed to modify the attributes
1086 of the reflected IBGP routes. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001087 if (from->sort == BGP_PEER_IBGP
1088 && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +00001089 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001090 bgp_attr_dup (&dummy_attr, attr);
Paul Jakma9eda90c2007-08-30 13:36:17 +00001091 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00001092 }
paulac41b2a2003-08-12 05:32:27 +00001093
1094 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
1095
Paul Jakmafb982c22007-05-04 20:15:47 +00001096 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00001097 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1098 else
1099 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1100
paulac41b2a2003-08-12 05:32:27 +00001101 peer->rmap_type = 0;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001102
paul718e3742002-12-13 20:15:29 +00001103 if (ret == RMAP_DENYMATCH)
1104 {
1105 bgp_attr_flush (attr);
1106 return 0;
1107 }
1108 }
1109 return 1;
1110}
1111
paul94f2b392005-06-28 12:44:16 +00001112static int
paulfee0f4c2004-09-13 05:12:46 +00001113bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
1114 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001115{
paulfee0f4c2004-09-13 05:12:46 +00001116 int ret;
1117 char buf[SU_ADDRSTRLEN];
1118 struct bgp_filter *filter;
1119 struct bgp_info info;
1120 struct peer *from;
Josh Bailey0b597ef2011-07-20 20:49:11 -07001121 struct attr *riattr;
paulfee0f4c2004-09-13 05:12:46 +00001122
1123 from = ri->peer;
1124 filter = &rsclient->filter[afi][safi];
Josh Bailey0b597ef2011-07-20 20:49:11 -07001125 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paulfee0f4c2004-09-13 05:12:46 +00001126
Paul Jakma750e8142008-07-22 21:11:48 +00001127 if (DISABLE_BGP_ANNOUNCE)
1128 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001129
1130 /* Do not send back route to sender. */
1131 if (from == rsclient)
1132 return 0;
1133
1134 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001135 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001136 if (! UNSUPPRESS_MAP_NAME (filter))
1137 return 0;
1138
1139 /* Default route check. */
1140 if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
1141 PEER_STATUS_DEFAULT_ORIGINATE))
1142 {
1143 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
1144 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001145 else if (p->family == AF_INET6 && p->prefixlen == 0)
1146 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001147 }
1148
1149 /* If the attribute has originator-id and it is same as remote
1150 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001151 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paulfee0f4c2004-09-13 05:12:46 +00001152 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001153 if (IPV4_ADDR_SAME (&rsclient->remote_id,
Josh Bailey0b597ef2011-07-20 20:49:11 -07001154 &riattr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001155 {
1156 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001157 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001158 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1159 rsclient->host,
1160 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1161 p->prefixlen);
1162 return 0;
1163 }
1164 }
1165
1166 /* ORF prefix-list filter check */
1167 if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
1168 && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
1169 || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
1170 if (rsclient->orf_plist[afi][safi])
1171 {
1172 if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
1173 return 0;
1174 }
1175
1176 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001177 if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
paulfee0f4c2004-09-13 05:12:46 +00001178 {
1179 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001180 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001181 "%s [Update:SEND] %s/%d is filtered",
1182 rsclient->host,
1183 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1184 p->prefixlen);
1185 return 0;
1186 }
1187
1188#ifdef BGP_SEND_ASPATH_CHECK
1189 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001190 if (aspath_loop_check (riattr->aspath, rsclient->as))
paulfee0f4c2004-09-13 05:12:46 +00001191 {
1192 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001193 zlog (rsclient->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001194 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paulfee0f4c2004-09-13 05:12:46 +00001195 rsclient->host, rsclient->as);
1196 return 0;
1197 }
1198#endif /* BGP_SEND_ASPATH_CHECK */
1199
1200 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001201 bgp_attr_dup (attr, riattr);
paulfee0f4c2004-09-13 05:12:46 +00001202
1203 /* next-hop-set */
1204 if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
paulfee0f4c2004-09-13 05:12:46 +00001205 || (p->family == AF_INET6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001206 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paulfee0f4c2004-09-13 05:12:46 +00001207 )
1208 {
1209 /* Set IPv4 nexthop. */
1210 if (p->family == AF_INET)
1211 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001212 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001213 memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4,
paulfee0f4c2004-09-13 05:12:46 +00001214 IPV4_MAX_BYTELEN);
1215 else
1216 memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
1217 }
paulfee0f4c2004-09-13 05:12:46 +00001218 /* Set IPv6 nexthop. */
1219 if (p->family == AF_INET6)
1220 {
1221 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001222 memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global,
paulfee0f4c2004-09-13 05:12:46 +00001223 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001224 attr->extra->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001225 }
paulfee0f4c2004-09-13 05:12:46 +00001226 }
1227
paulfee0f4c2004-09-13 05:12:46 +00001228 if (p->family == AF_INET6)
1229 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001230 struct attr_extra *attre = attr->extra;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001231
paulfee0f4c2004-09-13 05:12:46 +00001232 /* Left nexthop_local unchanged if so configured. */
1233 if ( CHECK_FLAG (rsclient->af_flags[afi][safi],
1234 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1235 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001236 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1237 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001238 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001239 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001240 }
1241
1242 /* Default nexthop_local treatment for RS-Clients */
1243 else
1244 {
1245 /* Announcer and RS-Client are both in the same network */
1246 if (rsclient->shared_network && from->shared_network &&
1247 (rsclient->ifindex == from->ifindex))
1248 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001249 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1250 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001251 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001252 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001253 }
1254
1255 /* Set link-local address for shared network peer. */
1256 else if (rsclient->shared_network
1257 && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
1258 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001259 memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local,
paulfee0f4c2004-09-13 05:12:46 +00001260 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001261 attre->mp_nexthop_len = 32;
paulfee0f4c2004-09-13 05:12:46 +00001262 }
1263
1264 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001265 attre->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001266 }
1267
1268 }
paulfee0f4c2004-09-13 05:12:46 +00001269
1270 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001271 if (rsclient->sort == BGP_PEER_EBGP
paulfee0f4c2004-09-13 05:12:46 +00001272 && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1273 && aspath_private_as_check (attr->aspath))
1274 attr->aspath = aspath_empty_get ();
1275
1276 /* Route map & unsuppress-map apply. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001277 if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) )
paulfee0f4c2004-09-13 05:12:46 +00001278 {
1279 info.peer = rsclient;
1280 info.attr = attr;
1281
1282 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
1283
Paul Jakmafb982c22007-05-04 20:15:47 +00001284 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001285 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1286 else
1287 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1288
1289 rsclient->rmap_type = 0;
1290
1291 if (ret == RMAP_DENYMATCH)
1292 {
1293 bgp_attr_flush (attr);
1294 return 0;
1295 }
1296 }
1297
1298 return 1;
1299}
1300
1301struct bgp_info_pair
1302{
1303 struct bgp_info *old;
1304 struct bgp_info *new;
1305};
1306
paul94f2b392005-06-28 12:44:16 +00001307static void
Josh Bailey96450fa2011-07-20 20:45:12 -07001308bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
Paul Jakma6d4742b2015-11-25 17:14:37 +00001309 struct bgp_info_pair *result,
1310 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00001311{
paul718e3742002-12-13 20:15:29 +00001312 struct bgp_info *new_select;
1313 struct bgp_info *old_select;
paulfee0f4c2004-09-13 05:12:46 +00001314 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00001315 struct bgp_info *ri1;
1316 struct bgp_info *ri2;
paulb40d9392005-08-22 22:34:41 +00001317 struct bgp_info *nextri = NULL;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001318 int cmpret, do_mpath;
Josh Bailey96450fa2011-07-20 20:45:12 -07001319 struct list mp_list;
Paul Jakma91b9e852015-12-01 14:32:11 +00001320
1321 result->old = result->new = NULL;
1322
1323 if (rn->info == NULL)
1324 {
1325 char buf[PREFIX_STRLEN];
1326 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1327 __func__,
1328 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1329 return;
1330 }
1331
Josh Bailey96450fa2011-07-20 20:45:12 -07001332 bgp_mp_list_init (&mp_list);
Paul Jakma6d4742b2015-11-25 17:14:37 +00001333 do_mpath = bgp_mpath_is_configured (bgp, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001334
paul718e3742002-12-13 20:15:29 +00001335 /* bgp deterministic-med */
1336 new_select = NULL;
1337 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1338 for (ri1 = rn->info; ri1; ri1 = ri1->next)
1339 {
1340 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
1341 continue;
1342 if (BGP_INFO_HOLDDOWN (ri1))
1343 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001344 if (ri1->peer && ri1->peer != bgp->peer_self)
1345 if (ri1->peer->status != Established)
1346 continue;
paul718e3742002-12-13 20:15:29 +00001347
1348 new_select = ri1;
Josh Bailey6918e742011-07-20 20:48:20 -07001349 if (do_mpath)
1350 bgp_mp_list_add (&mp_list, ri1);
1351 old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
paul718e3742002-12-13 20:15:29 +00001352 if (ri1->next)
1353 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
1354 {
1355 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
1356 continue;
1357 if (BGP_INFO_HOLDDOWN (ri2))
1358 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001359 if (ri2->peer &&
1360 ri2->peer != bgp->peer_self &&
1361 !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
1362 if (ri2->peer->status != Established)
1363 continue;
paul718e3742002-12-13 20:15:29 +00001364
1365 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
1366 || aspath_cmp_left_confed (ri1->attr->aspath,
1367 ri2->attr->aspath))
1368 {
Josh Bailey6918e742011-07-20 20:48:20 -07001369 if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED))
1370 old_select = ri2;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001371 if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi))
1372 == -1)
paul718e3742002-12-13 20:15:29 +00001373 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001374 bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001375 new_select = ri2;
1376 }
1377
Paul Jakma6d4742b2015-11-25 17:14:37 +00001378 if (do_mpath)
1379 {
1380 if (cmpret != 0)
1381 bgp_mp_list_clear (&mp_list);
1382
1383 if (cmpret == 0 || cmpret == -1)
1384 bgp_mp_list_add (&mp_list, ri2);
1385 }
Josh Bailey6918e742011-07-20 20:48:20 -07001386
Paul Jakma1a392d42006-09-07 00:24:49 +00001387 bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001388 }
1389 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001390 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
1391 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
Josh Bailey6918e742011-07-20 20:48:20 -07001392
Paul Jakma6d4742b2015-11-25 17:14:37 +00001393 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey6918e742011-07-20 20:48:20 -07001394 bgp_mp_list_clear (&mp_list);
paul718e3742002-12-13 20:15:29 +00001395 }
1396
1397 /* Check old selected route and new selected route. */
1398 old_select = NULL;
1399 new_select = NULL;
paulb40d9392005-08-22 22:34:41 +00001400 for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
paul718e3742002-12-13 20:15:29 +00001401 {
1402 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
1403 old_select = ri;
1404
1405 if (BGP_INFO_HOLDDOWN (ri))
paulb40d9392005-08-22 22:34:41 +00001406 {
1407 /* reap REMOVED routes, if needs be
1408 * selected route must stay for a while longer though
1409 */
1410 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
1411 && (ri != old_select))
1412 bgp_info_reap (rn, ri);
1413
1414 continue;
1415 }
paul718e3742002-12-13 20:15:29 +00001416
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001417 if (ri->peer &&
1418 ri->peer != bgp->peer_self &&
1419 !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
1420 if (ri->peer->status != Established)
1421 continue;
1422
paul718e3742002-12-13 20:15:29 +00001423 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
1424 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
1425 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001426 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001427 continue;
1428 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001429 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
1430 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001431
Paul Jakma6d4742b2015-11-25 17:14:37 +00001432 if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1)
Josh Bailey96450fa2011-07-20 20:45:12 -07001433 {
Josh Bailey6918e742011-07-20 20:48:20 -07001434 if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1435 bgp_mp_dmed_deselect (new_select);
1436
Josh Bailey96450fa2011-07-20 20:45:12 -07001437 new_select = ri;
Josh Bailey96450fa2011-07-20 20:45:12 -07001438 }
Paul Jakma6d4742b2015-11-25 17:14:37 +00001439 else if (cmpret == 1 && do_mpath
1440 && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Josh Bailey6918e742011-07-20 20:48:20 -07001441 bgp_mp_dmed_deselect (ri);
Josh Bailey96450fa2011-07-20 20:45:12 -07001442
Paul Jakma6d4742b2015-11-25 17:14:37 +00001443 if (do_mpath)
1444 {
1445 if (cmpret != 0)
1446 bgp_mp_list_clear (&mp_list);
1447
1448 if (cmpret == 0 || cmpret == -1)
1449 bgp_mp_list_add (&mp_list, ri);
1450 }
paul718e3742002-12-13 20:15:29 +00001451 }
paulfee0f4c2004-09-13 05:12:46 +00001452
Josh Bailey6918e742011-07-20 20:48:20 -07001453 if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Paul Jakma6d4742b2015-11-25 17:14:37 +00001454 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001455
Josh Bailey0b597ef2011-07-20 20:49:11 -07001456 bgp_info_mpath_aggregate_update (new_select, old_select);
Josh Bailey96450fa2011-07-20 20:45:12 -07001457 bgp_mp_list_clear (&mp_list);
1458
1459 result->old = old_select;
1460 result->new = new_select;
1461
1462 return;
paulfee0f4c2004-09-13 05:12:46 +00001463}
1464
paul94f2b392005-06-28 12:44:16 +00001465static int
paulfee0f4c2004-09-13 05:12:46 +00001466bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
Paul Jakma9eda90c2007-08-30 13:36:17 +00001467 struct bgp_node *rn, afi_t afi, safi_t safi)
1468{
paulfee0f4c2004-09-13 05:12:46 +00001469 struct prefix *p;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001470 struct attr attr;
1471 struct attr_extra extra;
paulfee0f4c2004-09-13 05:12:46 +00001472
Lou Berger050defe2016-01-12 13:41:59 -05001473 memset (&attr, 0, sizeof(struct attr));
1474 memset (&extra, 0, sizeof(struct attr_extra));
1475
paulfee0f4c2004-09-13 05:12:46 +00001476 p = &rn->p;
1477
Paul Jakma9eda90c2007-08-30 13:36:17 +00001478 /* Announce route to Established peer. */
1479 if (peer->status != Established)
paulfee0f4c2004-09-13 05:12:46 +00001480 return 0;
1481
Paul Jakma9eda90c2007-08-30 13:36:17 +00001482 /* Address family configuration check. */
1483 if (! peer->afc_nego[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001484 return 0;
1485
Paul Jakma9eda90c2007-08-30 13:36:17 +00001486 /* First update is deferred until ORF or ROUTE-REFRESH is received */
paulfee0f4c2004-09-13 05:12:46 +00001487 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1488 PEER_STATUS_ORF_WAIT_REFRESH))
1489 return 0;
1490
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001491 /* It's initialized in bgp_announce_[check|check_rsclient]() */
1492 attr.extra = &extra;
1493
Avneesh Sachdev67174042012-08-17 08:19:49 -07001494 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001495 {
1496 case BGP_TABLE_MAIN:
1497 /* Announcement to peer->conf. If the route is filtered,
1498 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001499 if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
1500 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
paulfee0f4c2004-09-13 05:12:46 +00001501 else
1502 bgp_adj_out_unset (rn, peer, p, afi, safi);
1503 break;
1504 case BGP_TABLE_RSCLIENT:
1505 /* Announcement to peer->conf. If the route is filtered,
1506 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001507 if (selected &&
1508 bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
1509 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
1510 else
1511 bgp_adj_out_unset (rn, peer, p, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001512 break;
1513 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001514
Lou Berger050defe2016-01-12 13:41:59 -05001515 bgp_attr_flush (&attr);
paulfee0f4c2004-09-13 05:12:46 +00001516 return 0;
paul200df112005-06-01 11:17:05 +00001517}
paulfee0f4c2004-09-13 05:12:46 +00001518
paul200df112005-06-01 11:17:05 +00001519struct bgp_process_queue
paulfee0f4c2004-09-13 05:12:46 +00001520{
paul200df112005-06-01 11:17:05 +00001521 struct bgp *bgp;
1522 struct bgp_node *rn;
1523 afi_t afi;
1524 safi_t safi;
1525};
1526
1527static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001528bgp_process_rsclient (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001529{
paul0fb58d52005-11-14 14:31:49 +00001530 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001531 struct bgp *bgp = pq->bgp;
1532 struct bgp_node *rn = pq->rn;
1533 afi_t afi = pq->afi;
1534 safi_t safi = pq->safi;
paulfee0f4c2004-09-13 05:12:46 +00001535 struct bgp_info *new_select;
1536 struct bgp_info *old_select;
1537 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001538 struct listnode *node, *nnode;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001539 struct peer *rsclient = bgp_node_table (rn)->owner;
paul200df112005-06-01 11:17:05 +00001540
paulfee0f4c2004-09-13 05:12:46 +00001541 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001542 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001543 new_select = old_and_new.new;
1544 old_select = old_and_new.old;
1545
paul200df112005-06-01 11:17:05 +00001546 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
1547 {
Chris Caputo228da422009-07-18 05:44:03 +00001548 if (rsclient->group)
1549 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient))
1550 {
1551 /* Nothing to do. */
1552 if (old_select && old_select == new_select)
1553 if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1554 continue;
paulfee0f4c2004-09-13 05:12:46 +00001555
Chris Caputo228da422009-07-18 05:44:03 +00001556 if (old_select)
1557 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1558 if (new_select)
1559 {
1560 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1561 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001562 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1563 }
paulfee0f4c2004-09-13 05:12:46 +00001564
Chris Caputo228da422009-07-18 05:44:03 +00001565 bgp_process_announce_selected (rsclient, new_select, rn,
1566 afi, safi);
1567 }
paul200df112005-06-01 11:17:05 +00001568 }
1569 else
1570 {
hassob7395792005-08-26 12:58:38 +00001571 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001572 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hassob7395792005-08-26 12:58:38 +00001573 if (new_select)
1574 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001575 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1576 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001577 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hassob7395792005-08-26 12:58:38 +00001578 }
Paul Jakma9eda90c2007-08-30 13:36:17 +00001579 bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
paul200df112005-06-01 11:17:05 +00001580 }
paulfee0f4c2004-09-13 05:12:46 +00001581
paulb40d9392005-08-22 22:34:41 +00001582 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1583 bgp_info_reap (rn, old_select);
1584
paul200df112005-06-01 11:17:05 +00001585 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1586 return WQ_SUCCESS;
paulfee0f4c2004-09-13 05:12:46 +00001587}
1588
paul200df112005-06-01 11:17:05 +00001589static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001590bgp_process_main (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001591{
paul0fb58d52005-11-14 14:31:49 +00001592 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001593 struct bgp *bgp = pq->bgp;
1594 struct bgp_node *rn = pq->rn;
1595 afi_t afi = pq->afi;
1596 safi_t safi = pq->safi;
1597 struct prefix *p = &rn->p;
paulfee0f4c2004-09-13 05:12:46 +00001598 struct bgp_info *new_select;
1599 struct bgp_info *old_select;
1600 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001601 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00001602 struct peer *peer;
Paul Jakmafb982c22007-05-04 20:15:47 +00001603
paulfee0f4c2004-09-13 05:12:46 +00001604 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001605 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001606 old_select = old_and_new.old;
1607 new_select = old_and_new.new;
1608
1609 /* Nothing to do. */
1610 if (old_select && old_select == new_select)
1611 {
1612 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
paul200df112005-06-01 11:17:05 +00001613 {
Josh Bailey8196f132011-07-20 20:47:07 -07001614 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) ||
1615 CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG))
G.Balaji5a616c02011-11-26 21:58:42 +04001616 bgp_zebra_announce (p, old_select, bgp, safi);
paul200df112005-06-01 11:17:05 +00001617
Josh Bailey8196f132011-07-20 20:47:07 -07001618 UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
paul200df112005-06-01 11:17:05 +00001619 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1620 return WQ_SUCCESS;
1621 }
paulfee0f4c2004-09-13 05:12:46 +00001622 }
paul718e3742002-12-13 20:15:29 +00001623
hasso338b3422005-02-23 14:27:24 +00001624 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001625 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hasso338b3422005-02-23 14:27:24 +00001626 if (new_select)
1627 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001628 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1629 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001630 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hasso338b3422005-02-23 14:27:24 +00001631 }
1632
1633
paul718e3742002-12-13 20:15:29 +00001634 /* Check each BGP peer. */
paul1eb8ef22005-04-07 07:30:20 +00001635 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00001636 {
Paul Jakma9eda90c2007-08-30 13:36:17 +00001637 bgp_process_announce_selected (peer, new_select, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001638 }
1639
1640 /* FIB update. */
G.Balaji5a616c02011-11-26 21:58:42 +04001641 if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
1642 ! bgp_option_check (BGP_OPT_NO_FIB)))
paul718e3742002-12-13 20:15:29 +00001643 {
1644 if (new_select
1645 && new_select->type == ZEBRA_ROUTE_BGP
1646 && new_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001647 bgp_zebra_announce (p, new_select, bgp, safi);
paul718e3742002-12-13 20:15:29 +00001648 else
1649 {
1650 /* Withdraw the route from the kernel. */
1651 if (old_select
1652 && old_select->type == ZEBRA_ROUTE_BGP
1653 && old_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001654 bgp_zebra_withdraw (p, old_select, safi);
paul718e3742002-12-13 20:15:29 +00001655 }
1656 }
paulb40d9392005-08-22 22:34:41 +00001657
Lou Berger050defe2016-01-12 13:41:59 -05001658 /* Reap old select bgp_info, if it has been removed */
paulb40d9392005-08-22 22:34:41 +00001659 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1660 bgp_info_reap (rn, old_select);
1661
paul200df112005-06-01 11:17:05 +00001662 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1663 return WQ_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001664}
1665
paul200df112005-06-01 11:17:05 +00001666static void
paul0fb58d52005-11-14 14:31:49 +00001667bgp_processq_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001668{
paul0fb58d52005-11-14 14:31:49 +00001669 struct bgp_process_queue *pq = data;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001670 struct bgp_table *table = bgp_node_table (pq->rn);
paul0fb58d52005-11-14 14:31:49 +00001671
Chris Caputo228da422009-07-18 05:44:03 +00001672 bgp_unlock (pq->bgp);
paul200df112005-06-01 11:17:05 +00001673 bgp_unlock_node (pq->rn);
Chris Caputo228da422009-07-18 05:44:03 +00001674 bgp_table_unlock (table);
paul200df112005-06-01 11:17:05 +00001675 XFREE (MTYPE_BGP_PROCESS_QUEUE, pq);
1676}
1677
1678static void
1679bgp_process_queue_init (void)
1680{
1681 bm->process_main_queue
1682 = work_queue_new (bm->master, "process_main_queue");
1683 bm->process_rsclient_queue
1684 = work_queue_new (bm->master, "process_rsclient_queue");
1685
1686 if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
1687 {
1688 zlog_err ("%s: Failed to allocate work queue", __func__);
1689 exit (1);
1690 }
1691
1692 bm->process_main_queue->spec.workfunc = &bgp_process_main;
paul200df112005-06-01 11:17:05 +00001693 bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
Paul Jakma838bbde2010-01-08 14:05:32 +00001694 bm->process_main_queue->spec.max_retries = 0;
1695 bm->process_main_queue->spec.hold = 50;
1696
Paul Jakma838bbde2010-01-08 14:05:32 +00001697 bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient;
David Lamparterd43f8b32015-03-03 08:54:54 +01001698 bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del;
1699 bm->process_rsclient_queue->spec.max_retries = 0;
1700 bm->process_rsclient_queue->spec.hold = 50;
paul200df112005-06-01 11:17:05 +00001701}
1702
1703void
paulfee0f4c2004-09-13 05:12:46 +00001704bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1705{
paul200df112005-06-01 11:17:05 +00001706 struct bgp_process_queue *pqnode;
1707
1708 /* already scheduled for processing? */
1709 if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
1710 return;
1711
Paul Jakma91b9e852015-12-01 14:32:11 +00001712 if (rn->info == NULL)
1713 {
1714 /* XXX: Perhaps remove before next release, after we've flushed out
1715 * any obvious cases
1716 */
1717 assert (rn->info != NULL);
1718 char buf[PREFIX_STRLEN];
1719 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1720 __func__,
1721 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1722 return;
1723 }
1724
paul200df112005-06-01 11:17:05 +00001725 if ( (bm->process_main_queue == NULL) ||
1726 (bm->process_rsclient_queue == NULL) )
1727 bgp_process_queue_init ();
1728
1729 pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
1730 sizeof (struct bgp_process_queue));
1731 if (!pqnode)
1732 return;
Chris Caputo228da422009-07-18 05:44:03 +00001733
1734 /* all unlocked in bgp_processq_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07001735 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00001736 pqnode->rn = bgp_lock_node (rn);
paul200df112005-06-01 11:17:05 +00001737 pqnode->bgp = bgp;
Chris Caputo228da422009-07-18 05:44:03 +00001738 bgp_lock (bgp);
paul200df112005-06-01 11:17:05 +00001739 pqnode->afi = afi;
1740 pqnode->safi = safi;
1741
Avneesh Sachdev67174042012-08-17 08:19:49 -07001742 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001743 {
paul200df112005-06-01 11:17:05 +00001744 case BGP_TABLE_MAIN:
1745 work_queue_add (bm->process_main_queue, pqnode);
1746 break;
1747 case BGP_TABLE_RSCLIENT:
1748 work_queue_add (bm->process_rsclient_queue, pqnode);
1749 break;
paulfee0f4c2004-09-13 05:12:46 +00001750 }
paul200df112005-06-01 11:17:05 +00001751
Stephen Hemminger07ff4dc2013-01-04 22:29:20 +00001752 SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
paul200df112005-06-01 11:17:05 +00001753 return;
paulfee0f4c2004-09-13 05:12:46 +00001754}
hasso0a486e52005-02-01 20:57:17 +00001755
paul94f2b392005-06-28 12:44:16 +00001756static int
hasso0a486e52005-02-01 20:57:17 +00001757bgp_maximum_prefix_restart_timer (struct thread *thread)
1758{
1759 struct peer *peer;
1760
1761 peer = THREAD_ARG (thread);
1762 peer->t_pmax_restart = NULL;
1763
1764 if (BGP_DEBUG (events, EVENTS))
1765 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1766 peer->host);
1767
1768 peer_clear (peer);
1769
1770 return 0;
1771}
1772
paulfee0f4c2004-09-13 05:12:46 +00001773int
paul5228ad22004-06-04 17:58:18 +00001774bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1775 safi_t safi, int always)
paul718e3742002-12-13 20:15:29 +00001776{
hassoe0701b72004-05-20 09:19:34 +00001777 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1778 return 0;
1779
1780 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +00001781 {
hassoe0701b72004-05-20 09:19:34 +00001782 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1783 && ! always)
1784 return 0;
paul718e3742002-12-13 20:15:29 +00001785
hassoe0701b72004-05-20 09:19:34 +00001786 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001787 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1788 "limit %ld", afi_safi_print (afi, safi), peer->host,
1789 peer->pcount[afi][safi], peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001790 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
paul718e3742002-12-13 20:15:29 +00001791
hassoe0701b72004-05-20 09:19:34 +00001792 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1793 return 0;
paul718e3742002-12-13 20:15:29 +00001794
hassoe0701b72004-05-20 09:19:34 +00001795 {
paul5228ad22004-06-04 17:58:18 +00001796 u_int8_t ndata[7];
hassoe0701b72004-05-20 09:19:34 +00001797
1798 if (safi == SAFI_MPLS_VPN)
Denis Ovsienko42e6d742011-07-14 12:36:19 +04001799 safi = SAFI_MPLS_LABELED_VPN;
paul5228ad22004-06-04 17:58:18 +00001800
1801 ndata[0] = (afi >> 8);
1802 ndata[1] = afi;
1803 ndata[2] = safi;
1804 ndata[3] = (peer->pmax[afi][safi] >> 24);
1805 ndata[4] = (peer->pmax[afi][safi] >> 16);
1806 ndata[5] = (peer->pmax[afi][safi] >> 8);
1807 ndata[6] = (peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001808
1809 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1810 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1811 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1812 }
hasso0a486e52005-02-01 20:57:17 +00001813
1814 /* restart timer start */
1815 if (peer->pmax_restart[afi][safi])
1816 {
1817 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1818
1819 if (BGP_DEBUG (events, EVENTS))
1820 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1821 peer->host, peer->v_pmax_restart);
1822
1823 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1824 peer->v_pmax_restart);
1825 }
1826
hassoe0701b72004-05-20 09:19:34 +00001827 return 1;
paul718e3742002-12-13 20:15:29 +00001828 }
hassoe0701b72004-05-20 09:19:34 +00001829 else
1830 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1831
1832 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1833 {
1834 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1835 && ! always)
1836 return 0;
1837
1838 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001839 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1840 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1841 peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001842 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1843 }
1844 else
1845 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
paul718e3742002-12-13 20:15:29 +00001846 return 0;
1847}
1848
paulb40d9392005-08-22 22:34:41 +00001849/* Unconditionally remove the route from the RIB, without taking
1850 * damping into consideration (eg, because the session went down)
1851 */
paul94f2b392005-06-28 12:44:16 +00001852static void
paul718e3742002-12-13 20:15:29 +00001853bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1854 afi_t afi, safi_t safi)
1855{
paul902212c2006-02-05 17:51:19 +00001856 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1857
1858 if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1859 bgp_info_delete (rn, ri); /* keep historical info */
1860
paulb40d9392005-08-22 22:34:41 +00001861 bgp_process (peer->bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001862}
1863
paul94f2b392005-06-28 12:44:16 +00001864static void
paul718e3742002-12-13 20:15:29 +00001865bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
Lou Berger050defe2016-01-12 13:41:59 -05001866 afi_t afi, safi_t safi, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00001867{
paul718e3742002-12-13 20:15:29 +00001868 int status = BGP_DAMP_NONE;
1869
paulb40d9392005-08-22 22:34:41 +00001870 /* apply dampening, if result is suppressed, we'll be retaining
1871 * the bgp_info in the RIB for historical reference.
1872 */
1873 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001874 && peer->sort == BGP_PEER_EBGP)
paulb40d9392005-08-22 22:34:41 +00001875 if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0))
1876 == BGP_DAMP_SUPPRESSED)
paul902212c2006-02-05 17:51:19 +00001877 {
paul902212c2006-02-05 17:51:19 +00001878 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1879 return;
1880 }
1881
1882 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00001883}
1884
paul94f2b392005-06-28 12:44:16 +00001885static void
paulfee0f4c2004-09-13 05:12:46 +00001886bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1887 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1888 int sub_type, struct prefix_rd *prd, u_char *tag)
1889{
1890 struct bgp_node *rn;
1891 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001892 struct attr new_attr;
1893 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00001894 struct attr *attr_new;
1895 struct attr *attr_new2;
1896 struct bgp_info *ri;
1897 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001898 const char *reason;
paulfee0f4c2004-09-13 05:12:46 +00001899 char buf[SU_ADDRSTRLEN];
1900
1901 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1902 if (peer == rsclient)
1903 return;
1904
1905 bgp = peer->bgp;
1906 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1907
1908 /* Check previously received route. */
1909 for (ri = rn->info; ri; ri = ri->next)
1910 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1911 break;
1912
1913 /* AS path loop check. */
Milan Kocian000e1572013-10-18 07:59:38 +00001914 if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001915 {
1916 reason = "as-path contains our own AS;";
1917 goto filtered;
1918 }
1919
1920 /* Route reflector originator ID check. */
1921 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00001922 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001923 {
1924 reason = "originator is us;";
1925 goto filtered;
1926 }
Paul Jakmafb982c22007-05-04 20:15:47 +00001927
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001928 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00001929 bgp_attr_dup (&new_attr, attr);
paulfee0f4c2004-09-13 05:12:46 +00001930
1931 /* Apply export policy. */
1932 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1933 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1934 {
1935 reason = "export-policy;";
1936 goto filtered;
1937 }
1938
1939 attr_new2 = bgp_attr_intern (&new_attr);
Paul Jakmafb982c22007-05-04 20:15:47 +00001940
paulfee0f4c2004-09-13 05:12:46 +00001941 /* Apply import policy. */
1942 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1943 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001944 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001945
1946 reason = "import-policy;";
1947 goto filtered;
1948 }
1949
1950 attr_new = bgp_attr_intern (&new_attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001951 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001952
1953 /* IPv4 unicast next hop check. */
G.Balaji5a616c02011-11-26 21:58:42 +04001954 if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
paulfee0f4c2004-09-13 05:12:46 +00001955 {
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001956 /* Next hop must not be 0.0.0.0 nor Class D/E address. */
paulfee0f4c2004-09-13 05:12:46 +00001957 if (new_attr.nexthop.s_addr == 0
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001958 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
paulfee0f4c2004-09-13 05:12:46 +00001959 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001960 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00001961
1962 reason = "martian next-hop;";
1963 goto filtered;
1964 }
1965 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001966
paulfee0f4c2004-09-13 05:12:46 +00001967 /* If the update is implicit withdraw. */
1968 if (ri)
1969 {
Stephen Hemminger65957882010-01-15 16:22:10 +03001970 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00001971
1972 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00001973 if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
1974 && attrhash_cmp (ri->attr, attr_new))
paulfee0f4c2004-09-13 05:12:46 +00001975 {
1976
Paul Jakma1a392d42006-09-07 00:24:49 +00001977 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00001978
1979 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001980 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001981 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1982 peer->host,
1983 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1984 p->prefixlen, rsclient->host);
1985
Chris Caputo228da422009-07-18 05:44:03 +00001986 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001987 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05001988 bgp_attr_flush(&new_attr);
Chris Caputo228da422009-07-18 05:44:03 +00001989 return;
paulfee0f4c2004-09-13 05:12:46 +00001990 }
1991
Paul Jakma16d2e242007-04-10 19:32:10 +00001992 /* Withdraw/Announce before we fully processed the withdraw */
1993 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
1994 bgp_info_restore (rn, ri);
1995
paulfee0f4c2004-09-13 05:12:46 +00001996 /* Received Logging. */
1997 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001998 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00001999 peer->host,
2000 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2001 p->prefixlen, rsclient->host);
2002
2003 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002004 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00002005
2006 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002007 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00002008 ri->attr = attr_new;
2009
2010 /* Update MPLS tag. */
2011 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002012 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002013
Paul Jakma1a392d42006-09-07 00:24:49 +00002014 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002015
2016 /* Process change. */
2017 bgp_process (bgp, rn, afi, safi);
2018 bgp_unlock_node (rn);
2019
2020 return;
2021 }
2022
2023 /* Received Logging. */
2024 if (BGP_DEBUG (update, UPDATE_IN))
2025 {
ajsd2c1f162004-12-08 21:10:20 +00002026 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00002027 peer->host,
2028 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2029 p->prefixlen, rsclient->host);
2030 }
2031
2032 /* Make new BGP info. */
2033 new = bgp_info_new ();
2034 new->type = type;
2035 new->sub_type = sub_type;
2036 new->peer = peer;
2037 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002038 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00002039
2040 /* Update MPLS tag. */
2041 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002042 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002043
Paul Jakma1a392d42006-09-07 00:24:49 +00002044 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002045
2046 /* Register new BGP information. */
2047 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002048
2049 /* route_node_get lock */
2050 bgp_unlock_node (rn);
2051
paulfee0f4c2004-09-13 05:12:46 +00002052 /* Process change. */
2053 bgp_process (bgp, rn, afi, safi);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002054
paulfee0f4c2004-09-13 05:12:46 +00002055 return;
2056
2057 filtered:
2058
2059 /* This BGP update is filtered. Log the reason then update BGP entry. */
2060 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002061 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002062 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
2063 peer->host,
2064 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2065 p->prefixlen, rsclient->host, reason);
2066
2067 if (ri)
paulb40d9392005-08-22 22:34:41 +00002068 bgp_rib_remove (rn, ri, peer, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002069
2070 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002071
paulfee0f4c2004-09-13 05:12:46 +00002072 return;
2073}
2074
paul94f2b392005-06-28 12:44:16 +00002075static void
paulfee0f4c2004-09-13 05:12:46 +00002076bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
2077 struct peer *peer, struct prefix *p, int type, int sub_type,
2078 struct prefix_rd *prd, u_char *tag)
Chris Caputo228da422009-07-18 05:44:03 +00002079{
paulfee0f4c2004-09-13 05:12:46 +00002080 struct bgp_node *rn;
2081 struct bgp_info *ri;
2082 char buf[SU_ADDRSTRLEN];
2083
2084 if (rsclient == peer)
Chris Caputo228da422009-07-18 05:44:03 +00002085 return;
paulfee0f4c2004-09-13 05:12:46 +00002086
2087 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
2088
2089 /* Lookup withdrawn route. */
2090 for (ri = rn->info; ri; ri = ri->next)
2091 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2092 break;
2093
2094 /* Withdraw specified route from routing table. */
2095 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002096 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paulfee0f4c2004-09-13 05:12:46 +00002097 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002098 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002099 "%s Can't find the route %s/%d", peer->host,
2100 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2101 p->prefixlen);
2102
2103 /* Unlock bgp_node_get() lock. */
Chris Caputo228da422009-07-18 05:44:03 +00002104 bgp_unlock_node (rn);
2105}
paulfee0f4c2004-09-13 05:12:46 +00002106
paul94f2b392005-06-28 12:44:16 +00002107static int
paulfee0f4c2004-09-13 05:12:46 +00002108bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
paul718e3742002-12-13 20:15:29 +00002109 afi_t afi, safi_t safi, int type, int sub_type,
2110 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2111{
2112 int ret;
2113 int aspath_loop_count = 0;
2114 struct bgp_node *rn;
2115 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002116 struct attr new_attr;
2117 struct attr_extra new_extra;
paul718e3742002-12-13 20:15:29 +00002118 struct attr *attr_new;
2119 struct bgp_info *ri;
2120 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00002121 const char *reason;
paul718e3742002-12-13 20:15:29 +00002122 char buf[SU_ADDRSTRLEN];
2123
2124 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00002125 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
Paul Jakmafb982c22007-05-04 20:15:47 +00002126
paul718e3742002-12-13 20:15:29 +00002127 /* When peer's soft reconfiguration enabled. Record input packet in
2128 Adj-RIBs-In. */
Jorge Boncompte [DTI2]343aa822012-05-07 16:53:08 +00002129 if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2130 && peer != bgp->peer_self)
paul718e3742002-12-13 20:15:29 +00002131 bgp_adj_in_set (rn, peer, attr);
2132
2133 /* Check previously received route. */
2134 for (ri = rn->info; ri; ri = ri->next)
2135 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2136 break;
2137
2138 /* AS path local-as loop check. */
2139 if (peer->change_local_as)
2140 {
2141 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
2142 aspath_loop_count = 1;
2143
2144 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
2145 {
2146 reason = "as-path contains our own AS;";
2147 goto filtered;
2148 }
2149 }
2150
2151 /* AS path loop check. */
2152 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
2153 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
2154 && aspath_loop_check(attr->aspath, bgp->confed_id)
2155 > peer->allowas_in[afi][safi]))
2156 {
2157 reason = "as-path contains our own AS;";
2158 goto filtered;
2159 }
2160
2161 /* Route reflector originator ID check. */
2162 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00002163 && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +00002164 {
2165 reason = "originator is us;";
2166 goto filtered;
2167 }
2168
2169 /* Route reflector cluster ID check. */
2170 if (bgp_cluster_filter (peer, attr))
2171 {
2172 reason = "reflected from the same cluster;";
2173 goto filtered;
2174 }
2175
2176 /* Apply incoming filter. */
2177 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
2178 {
2179 reason = "filter;";
2180 goto filtered;
2181 }
2182
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002183 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00002184 bgp_attr_dup (&new_attr, attr);
paul718e3742002-12-13 20:15:29 +00002185
David Lamparterc460e572014-06-04 00:54:58 +02002186 /* Apply incoming route-map.
2187 * NB: new_attr may now contain newly allocated values from route-map "set"
2188 * commands, so we need bgp_attr_flush in the error paths, until we intern
2189 * the attr (which takes over the memory references) */
paul718e3742002-12-13 20:15:29 +00002190 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
2191 {
2192 reason = "route-map;";
David Lamparterc460e572014-06-04 00:54:58 +02002193 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002194 goto filtered;
2195 }
2196
2197 /* IPv4 unicast next hop check. */
2198 if (afi == AFI_IP && safi == SAFI_UNICAST)
2199 {
2200 /* If the peer is EBGP and nexthop is not on connected route,
2201 discard it. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002202 if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1
Denis Ovsienko8e80bdf2011-08-05 18:52:52 +04002203 && ! bgp_nexthop_onlink (afi, &new_attr)
hasso6ffd2072005-02-02 14:50:11 +00002204 && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
paul718e3742002-12-13 20:15:29 +00002205 {
2206 reason = "non-connected next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002207 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002208 goto filtered;
2209 }
2210
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04002211 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
paul718e3742002-12-13 20:15:29 +00002212 must not be my own address. */
Jorge Boncompte [DTI2]10f9bf32012-05-07 16:52:52 +00002213 if (new_attr.nexthop.s_addr == 0
2214 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
2215 || bgp_nexthop_self (&new_attr))
paul718e3742002-12-13 20:15:29 +00002216 {
2217 reason = "martian next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002218 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002219 goto filtered;
2220 }
2221 }
2222
2223 attr_new = bgp_attr_intern (&new_attr);
2224
2225 /* If the update is implicit withdraw. */
2226 if (ri)
2227 {
Stephen Hemminger65957882010-01-15 16:22:10 +03002228 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002229
2230 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00002231 if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
2232 && attrhash_cmp (ri->attr, attr_new))
paul718e3742002-12-13 20:15:29 +00002233 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002234 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00002235
2236 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002237 && peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00002238 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2239 {
2240 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002241 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002242 peer->host,
2243 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2244 p->prefixlen);
2245
paul902212c2006-02-05 17:51:19 +00002246 if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
2247 {
2248 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2249 bgp_process (bgp, rn, afi, safi);
2250 }
paul718e3742002-12-13 20:15:29 +00002251 }
Paul Jakma16d2e242007-04-10 19:32:10 +00002252 else /* Duplicate - odd */
paul718e3742002-12-13 20:15:29 +00002253 {
2254 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002255 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002256 "%s rcvd %s/%d...duplicate ignored",
2257 peer->host,
2258 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2259 p->prefixlen);
hasso93406d82005-02-02 14:40:33 +00002260
2261 /* graceful restart STALE flag unset. */
2262 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2263 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002264 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
paul902212c2006-02-05 17:51:19 +00002265 bgp_process (bgp, rn, afi, safi);
hasso93406d82005-02-02 14:40:33 +00002266 }
paul718e3742002-12-13 20:15:29 +00002267 }
2268
2269 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002270 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05002271 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002272
paul718e3742002-12-13 20:15:29 +00002273 return 0;
2274 }
2275
Paul Jakma16d2e242007-04-10 19:32:10 +00002276 /* Withdraw/Announce before we fully processed the withdraw */
2277 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2278 {
2279 if (BGP_DEBUG (update, UPDATE_IN))
2280 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
2281 peer->host,
2282 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2283 p->prefixlen);
2284 bgp_info_restore (rn, ri);
2285 }
2286
paul718e3742002-12-13 20:15:29 +00002287 /* Received Logging. */
2288 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002289 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002290 peer->host,
2291 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2292 p->prefixlen);
2293
hasso93406d82005-02-02 14:40:33 +00002294 /* graceful restart STALE flag unset. */
2295 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma1a392d42006-09-07 00:24:49 +00002296 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
hasso93406d82005-02-02 14:40:33 +00002297
paul718e3742002-12-13 20:15:29 +00002298 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002299 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul902212c2006-02-05 17:51:19 +00002300
2301 /* implicit withdraw, decrement aggregate and pcount here.
2302 * only if update is accepted, they'll increment below.
2303 */
paul902212c2006-02-05 17:51:19 +00002304 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2305
paul718e3742002-12-13 20:15:29 +00002306 /* Update bgp route dampening information. */
2307 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002308 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002309 {
2310 /* This is implicit withdraw so we should update dampening
2311 information. */
2312 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2313 bgp_damp_withdraw (ri, rn, afi, safi, 1);
paul718e3742002-12-13 20:15:29 +00002314 }
2315
paul718e3742002-12-13 20:15:29 +00002316 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002317 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00002318 ri->attr = attr_new;
2319
2320 /* Update MPLS tag. */
2321 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002322 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002323
Lou Berger050defe2016-01-12 13:41:59 -05002324 bgp_attr_flush (&new_attr);
2325
paul718e3742002-12-13 20:15:29 +00002326 /* Update bgp route dampening information. */
2327 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002328 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002329 {
2330 /* Now we do normal update dampening. */
2331 ret = bgp_damp_update (ri, rn, afi, safi);
2332 if (ret == BGP_DAMP_SUPPRESSED)
2333 {
2334 bgp_unlock_node (rn);
2335 return 0;
2336 }
2337 }
2338
2339 /* Nexthop reachability check. */
2340 if ((afi == AFI_IP || afi == AFI_IP6)
2341 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002342 && (peer->sort == BGP_PEER_IBGP
2343 || peer->sort == BGP_PEER_CONFED
2344 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002345 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002346 {
2347 if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002348 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002349 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002350 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002351 }
2352 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002353 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002354
Lou Berger050defe2016-01-12 13:41:59 -05002355 bgp_attr_flush (&new_attr);
2356
paul718e3742002-12-13 20:15:29 +00002357 /* Process change. */
2358 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2359
2360 bgp_process (bgp, rn, afi, safi);
2361 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002362
paul718e3742002-12-13 20:15:29 +00002363 return 0;
2364 }
2365
2366 /* Received Logging. */
2367 if (BGP_DEBUG (update, UPDATE_IN))
2368 {
ajsd2c1f162004-12-08 21:10:20 +00002369 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002370 peer->host,
2371 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2372 p->prefixlen);
2373 }
2374
paul718e3742002-12-13 20:15:29 +00002375 /* Make new BGP info. */
2376 new = bgp_info_new ();
2377 new->type = type;
2378 new->sub_type = sub_type;
2379 new->peer = peer;
2380 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002381 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002382
2383 /* Update MPLS tag. */
2384 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002385 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002386
2387 /* Nexthop reachability check. */
2388 if ((afi == AFI_IP || afi == AFI_IP6)
2389 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002390 && (peer->sort == BGP_PEER_IBGP
2391 || peer->sort == BGP_PEER_CONFED
2392 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002393 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002394 {
2395 if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002396 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002397 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002398 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002399 }
2400 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002401 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002402
paul902212c2006-02-05 17:51:19 +00002403 /* Increment prefix */
paul718e3742002-12-13 20:15:29 +00002404 bgp_aggregate_increment (bgp, p, new, afi, safi);
2405
2406 /* Register new BGP information. */
2407 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002408
2409 /* route_node_get lock */
2410 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002411
Lou Berger050defe2016-01-12 13:41:59 -05002412 bgp_attr_flush (&new_attr);
2413
paul718e3742002-12-13 20:15:29 +00002414 /* If maximum prefix count is configured and current prefix
2415 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00002416 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
2417 return -1;
paul718e3742002-12-13 20:15:29 +00002418
2419 /* Process change. */
2420 bgp_process (bgp, rn, afi, safi);
2421
2422 return 0;
2423
2424 /* This BGP update is filtered. Log the reason then update BGP
2425 entry. */
2426 filtered:
2427 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002428 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002429 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2430 peer->host,
2431 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2432 p->prefixlen, reason);
2433
2434 if (ri)
paulb40d9392005-08-22 22:34:41 +00002435 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002436
2437 bgp_unlock_node (rn);
Lou Berger050defe2016-01-12 13:41:59 -05002438 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002439
paul718e3742002-12-13 20:15:29 +00002440 return 0;
2441}
2442
2443int
paulfee0f4c2004-09-13 05:12:46 +00002444bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
2445 afi_t afi, safi_t safi, int type, int sub_type,
2446 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2447{
2448 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002449 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002450 struct bgp *bgp;
2451 int ret;
2452
2453 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
2454 soft_reconfig);
2455
2456 bgp = peer->bgp;
2457
2458 /* Process the update for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002459 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002460 {
2461 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2462 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
2463 sub_type, prd, tag);
2464 }
2465
2466 return ret;
2467}
2468
2469int
paul718e3742002-12-13 20:15:29 +00002470bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
paul94f2b392005-06-28 12:44:16 +00002471 afi_t afi, safi_t safi, int type, int sub_type,
2472 struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00002473{
2474 struct bgp *bgp;
2475 char buf[SU_ADDRSTRLEN];
2476 struct bgp_node *rn;
2477 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00002478 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002479 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002480
2481 bgp = peer->bgp;
2482
David Lamparter4584c232015-04-13 09:50:00 +02002483 /* Lookup node. */
2484 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2485
2486 /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2487 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2488 * the iteration over all RS clients.
2489 * Since we need to remove the entry from adj_in anyway, do that first and
2490 * if there was no entry, we don't need to do anything more. */
2491 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2492 && peer != bgp->peer_self)
2493 if (!bgp_adj_in_unset (rn, peer))
2494 {
2495 if (BGP_DEBUG (update, UPDATE_IN))
2496 zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
2497 "not in adj-in", peer->host,
2498 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2499 p->prefixlen);
2500 bgp_unlock_node (rn);
2501 return 0;
2502 }
2503
paulfee0f4c2004-09-13 05:12:46 +00002504 /* Process the withdraw for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002505 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002506 {
2507 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2508 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
2509 }
2510
paul718e3742002-12-13 20:15:29 +00002511 /* Logging. */
2512 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002513 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00002514 peer->host,
2515 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2516 p->prefixlen);
2517
paul718e3742002-12-13 20:15:29 +00002518 /* Lookup withdrawn route. */
2519 for (ri = rn->info; ri; ri = ri->next)
2520 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2521 break;
2522
2523 /* Withdraw specified route from routing table. */
2524 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002525 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paul718e3742002-12-13 20:15:29 +00002526 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002527 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002528 "%s Can't find the route %s/%d", peer->host,
2529 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2530 p->prefixlen);
2531
2532 /* Unlock bgp_node_get() lock. */
2533 bgp_unlock_node (rn);
2534
2535 return 0;
2536}
David Lamparter6b0655a2014-06-04 06:53:35 +02002537
paul718e3742002-12-13 20:15:29 +00002538void
2539bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2540{
2541 struct bgp *bgp;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00002542 struct attr attr;
Jorge Boncompte [DTI2]577ac572012-05-07 16:53:06 +00002543 struct aspath *aspath;
paul718e3742002-12-13 20:15:29 +00002544 struct prefix p;
paul718e3742002-12-13 20:15:29 +00002545 struct peer *from;
Christian Frankedcab1bb2012-12-07 16:45:52 +00002546 struct bgp_node *rn;
2547 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00002548 int ret = RMAP_DENYMATCH;
Paul Jakmafb982c22007-05-04 20:15:47 +00002549
Paul Jakmab2497022007-06-14 11:17:58 +00002550 if (!(afi == AFI_IP || afi == AFI_IP6))
Paul Jakmafb982c22007-05-04 20:15:47 +00002551 return;
2552
paul718e3742002-12-13 20:15:29 +00002553 bgp = peer->bgp;
2554 from = bgp->peer_self;
Paul Jakmafb982c22007-05-04 20:15:47 +00002555
paul718e3742002-12-13 20:15:29 +00002556 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2557 aspath = attr.aspath;
2558 attr.local_pref = bgp->default_local_pref;
2559 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2560
2561 if (afi == AFI_IP)
2562 str2prefix ("0.0.0.0/0", &p);
paul718e3742002-12-13 20:15:29 +00002563 else if (afi == AFI_IP6)
2564 {
Jorge Boncompte [DTI2]6182d652012-05-07 16:53:02 +00002565 struct attr_extra *ae = attr.extra;
2566
paul718e3742002-12-13 20:15:29 +00002567 str2prefix ("::/0", &p);
2568
2569 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00002570 memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00002571 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002572 ae->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00002573
2574 /* If the peer is on shared nextwork and we have link-local
2575 nexthop set it. */
2576 if (peer->shared_network
2577 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2578 {
Paul Jakmafb982c22007-05-04 20:15:47 +00002579 memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00002580 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002581 ae->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00002582 }
2583 }
paul718e3742002-12-13 20:15:29 +00002584
2585 if (peer->default_rmap[afi][safi].name)
2586 {
paulfee0f4c2004-09-13 05:12:46 +00002587 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
Christian Frankedcab1bb2012-12-07 16:45:52 +00002588 for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
2589 {
2590 for (ri = rn->info; ri; ri = ri->next)
2591 {
2592 struct attr dummy_attr;
2593 struct attr_extra dummy_extra;
2594 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00002595
Christian Frankedcab1bb2012-12-07 16:45:52 +00002596 /* Provide dummy so the route-map can't modify the attributes */
2597 dummy_attr.extra = &dummy_extra;
2598 bgp_attr_dup(&dummy_attr, ri->attr);
2599 info.peer = ri->peer;
2600 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00002601
Christian Frankedcab1bb2012-12-07 16:45:52 +00002602 ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
2603 RMAP_BGP, &info);
2604
2605 /* The route map might have set attributes. If we don't flush them
2606 * here, they will be leaked. */
2607 bgp_attr_flush(&dummy_attr);
2608 if (ret != RMAP_DENYMATCH)
2609 break;
2610 }
2611 if (ret != RMAP_DENYMATCH)
2612 break;
2613 }
paulfee0f4c2004-09-13 05:12:46 +00002614 bgp->peer_self->rmap_type = 0;
2615
paul718e3742002-12-13 20:15:29 +00002616 if (ret == RMAP_DENYMATCH)
Christian Frankedcab1bb2012-12-07 16:45:52 +00002617 withdraw = 1;
paul718e3742002-12-13 20:15:29 +00002618 }
2619
2620 if (withdraw)
2621 {
2622 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2623 bgp_default_withdraw_send (peer, afi, safi);
2624 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2625 }
2626 else
2627 {
Christian Frankedcab1bb2012-12-07 16:45:52 +00002628 if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2629 {
2630 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2631 bgp_default_update_send (peer, &attr, afi, safi, from);
2632 }
paul718e3742002-12-13 20:15:29 +00002633 }
Paul Jakmafb982c22007-05-04 20:15:47 +00002634
2635 bgp_attr_extra_free (&attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002636 aspath_unintern (&aspath);
paul718e3742002-12-13 20:15:29 +00002637}
David Lamparter6b0655a2014-06-04 06:53:35 +02002638
paul718e3742002-12-13 20:15:29 +00002639static void
2640bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002641 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002642{
2643 struct bgp_node *rn;
2644 struct bgp_info *ri;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002645 struct attr attr;
2646 struct attr_extra extra;
2647
Lou Berger298cc2f2016-01-12 13:42:02 -05002648 memset(&extra, 0, sizeof(extra));
2649
paul718e3742002-12-13 20:15:29 +00002650 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002651 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002652
Lou Berger298cc2f2016-01-12 13:42:02 -05002653 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00002654 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2655 bgp_default_originate (peer, afi, safi, 0);
2656
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002657 /* It's initialized in bgp_announce_[check|check_rsclient]() */
2658 attr.extra = &extra;
2659
paul718e3742002-12-13 20:15:29 +00002660 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2661 for (ri = rn->info; ri; ri = ri->next)
2662 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2663 {
paulfee0f4c2004-09-13 05:12:46 +00002664 if ( (rsclient) ?
2665 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2666 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002667 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2668 else
2669 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2670 }
Lou Berger298cc2f2016-01-12 13:42:02 -05002671
2672 bgp_attr_flush_encap(&attr);
paul718e3742002-12-13 20:15:29 +00002673}
2674
2675void
2676bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2677{
2678 struct bgp_node *rn;
2679 struct bgp_table *table;
2680
2681 if (peer->status != Established)
2682 return;
2683
2684 if (! peer->afc_nego[afi][safi])
2685 return;
2686
2687 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2688 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2689 return;
2690
Lou Berger298cc2f2016-01-12 13:42:02 -05002691 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
paulfee0f4c2004-09-13 05:12:46 +00002692 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002693 else
2694 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2695 rn = bgp_route_next(rn))
2696 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002697 bgp_announce_table (peer, afi, safi, table, 0);
2698
2699 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2700 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002701}
2702
2703void
2704bgp_announce_route_all (struct peer *peer)
2705{
2706 afi_t afi;
2707 safi_t safi;
2708
2709 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2710 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2711 bgp_announce_route (peer, afi, safi);
2712}
David Lamparter6b0655a2014-06-04 06:53:35 +02002713
paul718e3742002-12-13 20:15:29 +00002714static void
paulfee0f4c2004-09-13 05:12:46 +00002715bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002716 safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
paulfee0f4c2004-09-13 05:12:46 +00002717{
2718 struct bgp_node *rn;
2719 struct bgp_adj_in *ain;
2720
2721 if (! table)
2722 table = rsclient->bgp->rib[afi][safi];
2723
2724 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2725 for (ain = rn->adj_in; ain; ain = ain->next)
2726 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002727 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002728 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002729
paulfee0f4c2004-09-13 05:12:46 +00002730 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
Christian Franked53d8fd2013-01-28 07:14:43 +01002731 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
paulfee0f4c2004-09-13 05:12:46 +00002732 }
2733}
2734
2735void
2736bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2737{
2738 struct bgp_table *table;
2739 struct bgp_node *rn;
2740
Lou Berger298cc2f2016-01-12 13:42:02 -05002741 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002742 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
paulfee0f4c2004-09-13 05:12:46 +00002743
2744 else
2745 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2746 rn = bgp_route_next (rn))
2747 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002748 {
2749 struct prefix_rd prd;
2750 prd.family = AF_UNSPEC;
2751 prd.prefixlen = 64;
2752 memcpy(&prd.val, rn->p.u.val, 8);
2753
2754 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
2755 }
paulfee0f4c2004-09-13 05:12:46 +00002756}
David Lamparter6b0655a2014-06-04 06:53:35 +02002757
paulfee0f4c2004-09-13 05:12:46 +00002758static void
paul718e3742002-12-13 20:15:29 +00002759bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002760 struct bgp_table *table, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00002761{
2762 int ret;
2763 struct bgp_node *rn;
2764 struct bgp_adj_in *ain;
2765
2766 if (! table)
2767 table = peer->bgp->rib[afi][safi];
2768
2769 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2770 for (ain = rn->adj_in; ain; ain = ain->next)
2771 {
2772 if (ain->peer == peer)
2773 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002774 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002775 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002776
paul718e3742002-12-13 20:15:29 +00002777 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2778 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
Christian Franked53d8fd2013-01-28 07:14:43 +01002779 prd, tag, 1);
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002780
paul718e3742002-12-13 20:15:29 +00002781 if (ret < 0)
2782 {
2783 bgp_unlock_node (rn);
2784 return;
2785 }
2786 continue;
2787 }
2788 }
2789}
2790
2791void
2792bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2793{
2794 struct bgp_node *rn;
2795 struct bgp_table *table;
2796
2797 if (peer->status != Established)
2798 return;
2799
Lou Berger298cc2f2016-01-12 13:42:02 -05002800 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002801 bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002802 else
2803 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2804 rn = bgp_route_next (rn))
2805 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002806 {
2807 struct prefix_rd prd;
2808 prd.family = AF_UNSPEC;
2809 prd.prefixlen = 64;
2810 memcpy(&prd.val, rn->p.u.val, 8);
2811
2812 bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
2813 }
paul718e3742002-12-13 20:15:29 +00002814}
David Lamparter6b0655a2014-06-04 06:53:35 +02002815
Chris Caputo228da422009-07-18 05:44:03 +00002816
2817struct bgp_clear_node_queue
2818{
2819 struct bgp_node *rn;
2820 enum bgp_clear_route_type purpose;
2821};
2822
paul200df112005-06-01 11:17:05 +00002823static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00002824bgp_clear_route_node (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002825{
Chris Caputo228da422009-07-18 05:44:03 +00002826 struct bgp_clear_node_queue *cnq = data;
2827 struct bgp_node *rn = cnq->rn;
Paul Jakma64e580a2006-02-21 01:09:01 +00002828 struct peer *peer = wq->spec.data;
paul200df112005-06-01 11:17:05 +00002829 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002830 afi_t afi = bgp_node_table (rn)->afi;
2831 safi_t safi = bgp_node_table (rn)->safi;
paul200df112005-06-01 11:17:05 +00002832
Paul Jakma64e580a2006-02-21 01:09:01 +00002833 assert (rn && peer);
paul200df112005-06-01 11:17:05 +00002834
Paul Jakma64e580a2006-02-21 01:09:01 +00002835 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002836 if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
paul200df112005-06-01 11:17:05 +00002837 {
2838 /* graceful restart STALE flag set. */
Paul Jakma64e580a2006-02-21 01:09:01 +00002839 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2840 && peer->nsf[afi][safi]
paul200df112005-06-01 11:17:05 +00002841 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
Paul Jakma1a392d42006-09-07 00:24:49 +00002842 && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
2843 bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
paul200df112005-06-01 11:17:05 +00002844 else
Paul Jakma64e580a2006-02-21 01:09:01 +00002845 bgp_rib_remove (rn, ri, peer, afi, safi);
paul200df112005-06-01 11:17:05 +00002846 break;
2847 }
paul200df112005-06-01 11:17:05 +00002848 return WQ_SUCCESS;
2849}
2850
2851static void
paul0fb58d52005-11-14 14:31:49 +00002852bgp_clear_node_queue_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002853{
Chris Caputo228da422009-07-18 05:44:03 +00002854 struct bgp_clear_node_queue *cnq = data;
2855 struct bgp_node *rn = cnq->rn;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002856 struct bgp_table *table = bgp_node_table (rn);
Paul Jakma64e580a2006-02-21 01:09:01 +00002857
2858 bgp_unlock_node (rn);
Chris Caputo228da422009-07-18 05:44:03 +00002859 bgp_table_unlock (table);
2860 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
paul200df112005-06-01 11:17:05 +00002861}
2862
2863static void
paul94f2b392005-06-28 12:44:16 +00002864bgp_clear_node_complete (struct work_queue *wq)
paul200df112005-06-01 11:17:05 +00002865{
Paul Jakma64e580a2006-02-21 01:09:01 +00002866 struct peer *peer = wq->spec.data;
2867
Paul Jakma3e0c78e2006-03-06 18:06:53 +00002868 /* Tickle FSM to start moving again */
Paul Jakmaca058a32006-09-14 02:58:49 +00002869 BGP_EVENT_ADD (peer, Clearing_Completed);
Chris Caputo228da422009-07-18 05:44:03 +00002870
2871 peer_unlock (peer); /* bgp_clear_route */
paul200df112005-06-01 11:17:05 +00002872}
2873
2874static void
Paul Jakma64e580a2006-02-21 01:09:01 +00002875bgp_clear_node_queue_init (struct peer *peer)
paul200df112005-06-01 11:17:05 +00002876{
Paul Jakmaa2943652009-07-21 14:02:04 +01002877 char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
Paul Jakma64e580a2006-02-21 01:09:01 +00002878
Paul Jakmaa2943652009-07-21 14:02:04 +01002879 snprintf (wname, sizeof(wname), "clear %s", peer->host);
Paul Jakma64e580a2006-02-21 01:09:01 +00002880#undef CLEAR_QUEUE_NAME_LEN
2881
2882 if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
paul200df112005-06-01 11:17:05 +00002883 {
2884 zlog_err ("%s: Failed to allocate work queue", __func__);
2885 exit (1);
2886 }
Paul Jakma64e580a2006-02-21 01:09:01 +00002887 peer->clear_node_queue->spec.hold = 10;
2888 peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
2889 peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
2890 peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
2891 peer->clear_node_queue->spec.max_retries = 0;
2892
2893 /* we only 'lock' this peer reference when the queue is actually active */
2894 peer->clear_node_queue->spec.data = peer;
paul200df112005-06-01 11:17:05 +00002895}
2896
paul718e3742002-12-13 20:15:29 +00002897static void
2898bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
Chris Caputo228da422009-07-18 05:44:03 +00002899 struct bgp_table *table, struct peer *rsclient,
2900 enum bgp_clear_route_type purpose)
paul718e3742002-12-13 20:15:29 +00002901{
2902 struct bgp_node *rn;
paul200df112005-06-01 11:17:05 +00002903
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002904
paul718e3742002-12-13 20:15:29 +00002905 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002906 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
Paul Jakma64e580a2006-02-21 01:09:01 +00002907
hasso6cf159b2005-03-21 10:28:14 +00002908 /* If still no table => afi/safi isn't configured at all or smth. */
2909 if (! table)
2910 return;
Paul Jakma65ca75e2006-05-04 08:08:15 +00002911
2912 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2913 {
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002914 struct bgp_info *ri;
2915 struct bgp_adj_in *ain;
2916 struct bgp_adj_out *aout;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002917
2918 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2919 * queued for every clearing peer, regardless of whether it is
2920 * relevant to the peer at hand.
2921 *
2922 * Overview: There are 3 different indices which need to be
2923 * scrubbed, potentially, when a peer is removed:
2924 *
2925 * 1 peer's routes visible via the RIB (ie accepted routes)
2926 * 2 peer's routes visible by the (optional) peer's adj-in index
2927 * 3 other routes visible by the peer's adj-out index
2928 *
2929 * 3 there is no hurry in scrubbing, once the struct peer is
2930 * removed from bgp->peer, we could just GC such deleted peer's
2931 * adj-outs at our leisure.
2932 *
2933 * 1 and 2 must be 'scrubbed' in some way, at least made
2934 * invisible via RIB index before peer session is allowed to be
2935 * brought back up. So one needs to know when such a 'search' is
2936 * complete.
2937 *
2938 * Ideally:
2939 *
2940 * - there'd be a single global queue or a single RIB walker
2941 * - rather than tracking which route_nodes still need to be
2942 * examined on a peer basis, we'd track which peers still
2943 * aren't cleared
2944 *
2945 * Given that our per-peer prefix-counts now should be reliable,
2946 * this may actually be achievable. It doesn't seem to be a huge
2947 * problem at this time,
2948 */
Jorge Boncompte [DTI2]24e50f22012-05-07 15:17:33 +00002949 for (ain = rn->adj_in; ain; ain = ain->next)
2950 if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2951 {
2952 bgp_adj_in_remove (rn, ain);
2953 bgp_unlock_node (rn);
2954 break;
2955 }
2956 for (aout = rn->adj_out; aout; aout = aout->next)
2957 if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2958 {
2959 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2960 bgp_unlock_node (rn);
2961 break;
2962 }
2963
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002964 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002965 if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002966 {
Chris Caputo228da422009-07-18 05:44:03 +00002967 struct bgp_clear_node_queue *cnq;
2968
2969 /* both unlocked in bgp_clear_node_queue_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07002970 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00002971 bgp_lock_node (rn);
2972 cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
2973 sizeof (struct bgp_clear_node_queue));
2974 cnq->rn = rn;
2975 cnq->purpose = purpose;
2976 work_queue_add (peer->clear_node_queue, cnq);
2977 break;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002978 }
Paul Jakma65ca75e2006-05-04 08:08:15 +00002979 }
2980 return;
2981}
2982
2983void
Chris Caputo228da422009-07-18 05:44:03 +00002984bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
2985 enum bgp_clear_route_type purpose)
Paul Jakma65ca75e2006-05-04 08:08:15 +00002986{
2987 struct bgp_node *rn;
2988 struct bgp_table *table;
2989 struct peer *rsclient;
2990 struct listnode *node, *nnode;
hasso6cf159b2005-03-21 10:28:14 +00002991
Paul Jakma64e580a2006-02-21 01:09:01 +00002992 if (peer->clear_node_queue == NULL)
2993 bgp_clear_node_queue_init (peer);
paul200df112005-06-01 11:17:05 +00002994
Paul Jakmaca058a32006-09-14 02:58:49 +00002995 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2996 * Idle until it receives a Clearing_Completed event. This protects
2997 * against peers which flap faster than we can we clear, which could
2998 * lead to:
Paul Jakma64e580a2006-02-21 01:09:01 +00002999 *
3000 * a) race with routes from the new session being installed before
3001 * clear_route_node visits the node (to delete the route of that
3002 * peer)
3003 * b) resource exhaustion, clear_route_node likely leads to an entry
3004 * on the process_main queue. Fast-flapping could cause that queue
3005 * to grow and grow.
paul200df112005-06-01 11:17:05 +00003006 */
Donald Sharp7ef42212015-03-30 06:32:52 -07003007
3008 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3009 * the unlock will happen upon work-queue completion; other wise, the
3010 * unlock happens at the end of this function.
3011 */
Paul Jakmaca058a32006-09-14 02:58:49 +00003012 if (!peer->clear_node_queue->thread)
Lou Berger050defe2016-01-12 13:41:59 -05003013 peer_lock (peer); /* bgp_clear_node_complete */
Chris Caputo228da422009-07-18 05:44:03 +00003014 switch (purpose)
paulfee0f4c2004-09-13 05:12:46 +00003015 {
Chris Caputo228da422009-07-18 05:44:03 +00003016 case BGP_CLEAR_ROUTE_NORMAL:
Lou Berger298cc2f2016-01-12 13:42:02 -05003017 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Chris Caputo228da422009-07-18 05:44:03 +00003018 bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
3019 else
3020 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
3021 rn = bgp_route_next (rn))
3022 if ((table = rn->info) != NULL)
3023 bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
3024
3025 for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
3026 if (CHECK_FLAG(rsclient->af_flags[afi][safi],
3027 PEER_FLAG_RSERVER_CLIENT))
3028 bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
3029 break;
3030
3031 case BGP_CLEAR_ROUTE_MY_RSCLIENT:
Lou Berger050defe2016-01-12 13:41:59 -05003032 /*
3033 * gpz 091009: TBD why don't we have special handling for
3034 * SAFI_MPLS_VPN here in the original quagga code?
3035 * (and, by extension, for SAFI_ENCAP)
3036 */
Chris Caputo228da422009-07-18 05:44:03 +00003037 bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
3038 break;
3039
3040 default:
3041 assert (0);
3042 break;
paulfee0f4c2004-09-13 05:12:46 +00003043 }
Donald Sharp7ef42212015-03-30 06:32:52 -07003044
3045 /* unlock if no nodes got added to the clear-node-queue. */
Paul Jakma65ca75e2006-05-04 08:08:15 +00003046 if (!peer->clear_node_queue->thread)
Donald Sharp7ef42212015-03-30 06:32:52 -07003047 peer_unlock (peer);
3048
paul718e3742002-12-13 20:15:29 +00003049}
3050
3051void
3052bgp_clear_route_all (struct peer *peer)
3053{
3054 afi_t afi;
3055 safi_t safi;
3056
3057 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3058 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
Chris Caputo228da422009-07-18 05:44:03 +00003059 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
paul718e3742002-12-13 20:15:29 +00003060}
3061
Lou Berger82dd7072016-01-12 13:41:57 -05003062/*
3063 * Finish freeing things when exiting
3064 */
3065static void
3066bgp_drain_workqueue_immediate (struct work_queue *wq)
3067{
3068 if (!wq)
3069 return;
3070
3071 if (!wq->thread)
3072 {
3073 /*
3074 * no thread implies no queued items
3075 */
3076 assert(!wq->items->count);
3077 return;
3078 }
3079
3080 while (wq->items->count)
3081 {
3082 if (wq->thread)
3083 thread_cancel(wq->thread);
3084 work_queue_run(wq->thread);
3085 }
3086}
3087
3088/*
3089 * Special function to process clear node queue when bgpd is exiting
3090 * and the thread scheduler is no longer running.
3091 */
3092void
3093bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
3094{
3095 if (!peer)
3096 return;
3097
3098 bgp_drain_workqueue_immediate(peer->clear_node_queue);
3099}
3100
3101/*
3102 * The work queues are not specific to a BGP instance, but the
3103 * items in them refer to BGP instances, so this should be called
3104 * before each BGP instance is deleted.
3105 */
3106void
3107bgp_process_queues_drain_immediate(void)
3108{
3109 bgp_drain_workqueue_immediate(bm->process_main_queue);
3110 bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
3111}
3112
paul718e3742002-12-13 20:15:29 +00003113void
3114bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
3115{
3116 struct bgp_table *table;
3117 struct bgp_node *rn;
3118 struct bgp_adj_in *ain;
3119
3120 table = peer->bgp->rib[afi][safi];
3121
3122 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3123 for (ain = rn->adj_in; ain ; ain = ain->next)
3124 if (ain->peer == peer)
3125 {
3126 bgp_adj_in_remove (rn, ain);
3127 bgp_unlock_node (rn);
3128 break;
3129 }
3130}
hasso93406d82005-02-02 14:40:33 +00003131
3132void
3133bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
3134{
3135 struct bgp_node *rn;
3136 struct bgp_info *ri;
3137 struct bgp_table *table;
3138
3139 table = peer->bgp->rib[afi][safi];
3140
3141 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3142 {
3143 for (ri = rn->info; ri; ri = ri->next)
3144 if (ri->peer == peer)
3145 {
3146 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
3147 bgp_rib_remove (rn, ri, peer, afi, safi);
3148 break;
3149 }
3150 }
3151}
David Lamparter6b0655a2014-06-04 06:53:35 +02003152
Lou Berger82dd7072016-01-12 13:41:57 -05003153static void
3154bgp_cleanup_table(struct bgp_table *table, safi_t safi)
3155{
3156 struct bgp_node *rn;
3157 struct bgp_info *ri;
3158 struct bgp_info *next;
3159
3160 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3161 for (ri = rn->info; ri; ri = next)
3162 {
3163 next = ri->next;
3164 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
3165 && ri->type == ZEBRA_ROUTE_BGP
3166 && ri->sub_type == BGP_ROUTE_NORMAL)
3167 bgp_zebra_withdraw (&rn->p, ri, safi);
3168 }
3169}
3170
paul718e3742002-12-13 20:15:29 +00003171/* Delete all kernel routes. */
3172void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003173bgp_cleanup_routes (void)
paul718e3742002-12-13 20:15:29 +00003174{
3175 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00003176 struct listnode *node, *nnode;
Lou Berger82dd7072016-01-12 13:41:57 -05003177 afi_t afi;
paul718e3742002-12-13 20:15:29 +00003178
paul1eb8ef22005-04-07 07:30:20 +00003179 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00003180 {
Lou Berger82dd7072016-01-12 13:41:57 -05003181 for (afi = AFI_IP; afi < AFI_MAX; ++afi)
3182 {
3183 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00003184
Lou Berger82dd7072016-01-12 13:41:57 -05003185 bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00003186
Lou Berger82dd7072016-01-12 13:41:57 -05003187 /*
3188 * VPN and ENCAP tables are two-level (RD is top level)
3189 */
3190 for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
3191 rn = bgp_route_next (rn))
Lou Berger298cc2f2016-01-12 13:42:02 -05003192 {
3193 if (rn->info)
Lou Berger82dd7072016-01-12 13:41:57 -05003194 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003195 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
3196 bgp_table_finish ((struct bgp_table **)&(rn->info));
3197 rn->info = NULL;
3198 bgp_unlock_node(rn);
Lou Berger82dd7072016-01-12 13:41:57 -05003199 }
Lou Berger298cc2f2016-01-12 13:42:02 -05003200 }
3201
3202 for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
3203 rn = bgp_route_next (rn))
3204 {
3205 if (rn->info)
3206 {
3207 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
3208 bgp_table_finish ((struct bgp_table **)&(rn->info));
3209 rn->info = NULL;
3210 bgp_unlock_node(rn);
3211 }
3212 }
Lou Berger82dd7072016-01-12 13:41:57 -05003213 }
paul718e3742002-12-13 20:15:29 +00003214 }
3215}
3216
3217void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003218bgp_reset (void)
paul718e3742002-12-13 20:15:29 +00003219{
3220 vty_reset ();
3221 bgp_zclient_reset ();
3222 access_list_reset ();
3223 prefix_list_reset ();
3224}
David Lamparter6b0655a2014-06-04 06:53:35 +02003225
paul718e3742002-12-13 20:15:29 +00003226/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3227 value. */
3228int
Paul Jakma518a4b72016-02-04 13:27:04 +00003229bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
3230 struct bgp_nlri *packet)
paul718e3742002-12-13 20:15:29 +00003231{
3232 u_char *pnt;
3233 u_char *lim;
3234 struct prefix p;
3235 int psize;
3236 int ret;
3237
3238 /* Check peer status. */
3239 if (peer->status != Established)
3240 return 0;
3241
3242 pnt = packet->nlri;
3243 lim = pnt + packet->length;
3244
Paul Jakma405e9e12016-02-04 17:00:18 +00003245 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3246 syntactic validity. If the field is syntactically incorrect,
3247 then the Error Subcode is set to Invalid Network Field. */
paul718e3742002-12-13 20:15:29 +00003248 for (; pnt < lim; pnt += psize)
3249 {
3250 /* Clear prefix structure. */
3251 memset (&p, 0, sizeof (struct prefix));
3252
3253 /* Fetch prefix length. */
3254 p.prefixlen = *pnt++;
Paul Jakma405e9e12016-02-04 17:00:18 +00003255 /* afi/safi validity already verified by caller, bgp_update_receive */
paul718e3742002-12-13 20:15:29 +00003256 p.family = afi2family (packet->afi);
3257
Paul Jakma405e9e12016-02-04 17:00:18 +00003258 /* Prefix length check. */
3259 if (p.prefixlen > prefix_blen (&p) * 8)
3260 {
3261 plog_err (peer->log,
3262 "%s [Error] Update packet error"
3263 " (wrong prefix length %u for afi %u)",
3264 peer->host, p.prefixlen, packet->afi);
3265 return -1;
3266 }
3267
paul718e3742002-12-13 20:15:29 +00003268 /* Packet size overflow check. */
3269 psize = PSIZE (p.prefixlen);
3270
3271 /* When packet overflow occur return immediately. */
3272 if (pnt + psize > lim)
Paul Jakma405e9e12016-02-04 17:00:18 +00003273 {
3274 plog_err (peer->log,
3275 "%s [Error] Update packet error"
3276 " (prefix length %u overflows packet)",
3277 peer->host, p.prefixlen);
3278 return -1;
3279 }
3280
3281 /* Defensive coding, double-check the psize fits in a struct prefix */
3282 if (psize > (ssize_t) sizeof(p.u))
3283 {
3284 plog_err (peer->log,
3285 "%s [Error] Update packet error"
3286 " (prefix length %u too large for prefix storage %zu!?!!",
3287 peer->host, p.prefixlen, sizeof(p.u));
3288 return -1;
3289 }
paul718e3742002-12-13 20:15:29 +00003290
3291 /* Fetch prefix from NLRI packet. */
3292 memcpy (&p.u.prefix, pnt, psize);
3293
3294 /* Check address. */
3295 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
3296 {
3297 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
3298 {
paulf5ba3872004-07-09 12:11:31 +00003299 /*
Paul Jakma405e9e12016-02-04 17:00:18 +00003300 * From RFC4271 Section 6.3:
3301 *
3302 * If a prefix in the NLRI field is semantically incorrect
3303 * (e.g., an unexpected multicast IP address), an error SHOULD
3304 * be logged locally, and the prefix SHOULD be ignored.
paulf5ba3872004-07-09 12:11:31 +00003305 */
paul718e3742002-12-13 20:15:29 +00003306 zlog (peer->log, LOG_ERR,
Paul Jakma405e9e12016-02-04 17:00:18 +00003307 "%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3308 peer->host, inet_ntoa (p.u.prefix4));
3309 continue;
paul718e3742002-12-13 20:15:29 +00003310 }
3311 }
3312
paul718e3742002-12-13 20:15:29 +00003313 /* Check address. */
3314 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
3315 {
3316 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3317 {
3318 char buf[BUFSIZ];
3319
Paul Jakma405e9e12016-02-04 17:00:18 +00003320 zlog (peer->log, LOG_ERR,
3321 "%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3322 peer->host,
paul718e3742002-12-13 20:15:29 +00003323 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00003324 continue;
3325 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003326 if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6))
3327 {
3328 char buf[BUFSIZ];
3329
3330 zlog (peer->log, LOG_ERR,
3331 "%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3332 peer->host,
3333 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3334 continue;
3335 }
3336 }
paul718e3742002-12-13 20:15:29 +00003337
3338 /* Normal process. */
3339 if (attr)
3340 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
3341 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
3342 else
3343 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
3344 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
3345
3346 /* Address family configuration mismatch or maximum-prefix count
3347 overflow. */
3348 if (ret < 0)
3349 return -1;
3350 }
3351
3352 /* Packet length consistency check. */
3353 if (pnt != lim)
paul718e3742002-12-13 20:15:29 +00003354 {
3355 plog_err (peer->log,
Paul Jakma405e9e12016-02-04 17:00:18 +00003356 "%s [Error] Update packet error"
3357 " (prefix length mismatch with total length)",
3358 peer->host);
paul718e3742002-12-13 20:15:29 +00003359 return -1;
3360 }
Paul Jakma405e9e12016-02-04 17:00:18 +00003361
paul718e3742002-12-13 20:15:29 +00003362 return 0;
3363}
David Lamparter6b0655a2014-06-04 06:53:35 +02003364
paul94f2b392005-06-28 12:44:16 +00003365static struct bgp_static *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003366bgp_static_new (void)
paul718e3742002-12-13 20:15:29 +00003367{
Stephen Hemminger393deb92008-08-18 14:13:29 -07003368 return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
paul718e3742002-12-13 20:15:29 +00003369}
3370
paul94f2b392005-06-28 12:44:16 +00003371static void
paul718e3742002-12-13 20:15:29 +00003372bgp_static_free (struct bgp_static *bgp_static)
3373{
3374 if (bgp_static->rmap.name)
3375 free (bgp_static->rmap.name);
3376 XFREE (MTYPE_BGP_STATIC, bgp_static);
3377}
3378
paul94f2b392005-06-28 12:44:16 +00003379static void
paulfee0f4c2004-09-13 05:12:46 +00003380bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
3381 struct prefix *p, afi_t afi, safi_t safi)
3382{
3383 struct bgp_node *rn;
3384 struct bgp_info *ri;
3385
3386 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3387
3388 /* Check selected route and self inserted route. */
3389 for (ri = rn->info; ri; ri = ri->next)
3390 if (ri->peer == bgp->peer_self
3391 && ri->type == ZEBRA_ROUTE_BGP
3392 && ri->sub_type == BGP_ROUTE_STATIC)
3393 break;
3394
3395 /* Withdraw static BGP route from routing table. */
3396 if (ri)
3397 {
paulfee0f4c2004-09-13 05:12:46 +00003398 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003399 bgp_process (bgp, rn, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003400 }
3401
3402 /* Unlock bgp_node_lookup. */
3403 bgp_unlock_node (rn);
3404}
3405
paul94f2b392005-06-28 12:44:16 +00003406static void
paulfee0f4c2004-09-13 05:12:46 +00003407bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
Paul Jakmafb982c22007-05-04 20:15:47 +00003408 struct bgp_static *bgp_static,
3409 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00003410{
3411 struct bgp_node *rn;
3412 struct bgp_info *ri;
3413 struct bgp_info *new;
3414 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00003415 struct attr *attr_new;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003416 struct attr attr;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003417 struct attr new_attr;
3418 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00003419 struct bgp *bgp;
3420 int ret;
3421 char buf[SU_ADDRSTRLEN];
3422
3423 bgp = rsclient->bgp;
3424
Paul Jakma06e110f2006-05-12 23:29:22 +00003425 assert (bgp_static);
3426 if (!bgp_static)
3427 return;
3428
paulfee0f4c2004-09-13 05:12:46 +00003429 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3430
3431 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakma06e110f2006-05-12 23:29:22 +00003432
3433 attr.nexthop = bgp_static->igpnexthop;
3434 attr.med = bgp_static->igpmetric;
3435 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Paul Jakma41367172007-08-06 15:24:51 +00003436
Paul Jakma41367172007-08-06 15:24:51 +00003437 if (bgp_static->atomic)
3438 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3439
paulfee0f4c2004-09-13 05:12:46 +00003440 /* Apply network route-map for export to this rsclient. */
3441 if (bgp_static->rmap.name)
3442 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003443 struct attr attr_tmp = attr;
paulfee0f4c2004-09-13 05:12:46 +00003444 info.peer = rsclient;
Paul Jakmafb982c22007-05-04 20:15:47 +00003445 info.attr = &attr_tmp;
3446
paulfee0f4c2004-09-13 05:12:46 +00003447 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
3448 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
3449
3450 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3451
3452 rsclient->rmap_type = 0;
3453
3454 if (ret == RMAP_DENYMATCH)
3455 {
3456 /* Free uninterned attribute. */
Paul Jakmafb982c22007-05-04 20:15:47 +00003457 bgp_attr_flush (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003458
3459 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003460 aspath_unintern (&attr.aspath);
paulfee0f4c2004-09-13 05:12:46 +00003461 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
Paul Jakmafb982c22007-05-04 20:15:47 +00003462 bgp_attr_extra_free (&attr);
3463
paulfee0f4c2004-09-13 05:12:46 +00003464 return;
3465 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003466 attr_new = bgp_attr_intern (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003467 }
3468 else
3469 attr_new = bgp_attr_intern (&attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003470
3471 new_attr.extra = &new_extra;
Stephen Hemminger7badc262010-08-05 10:26:31 -07003472 bgp_attr_dup(&new_attr, attr_new);
Paul Jakmafb982c22007-05-04 20:15:47 +00003473
paulfee0f4c2004-09-13 05:12:46 +00003474 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3475
Paul Jakmafb982c22007-05-04 20:15:47 +00003476 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi)
3477 == RMAP_DENY)
3478 {
paulfee0f4c2004-09-13 05:12:46 +00003479 /* This BGP update is filtered. Log the reason then update BGP entry. */
3480 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00003481 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00003482 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3483 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
3484 p->prefixlen, rsclient->host);
3485
3486 bgp->peer_self->rmap_type = 0;
3487
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003488 bgp_attr_unintern (&attr_new);
3489 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003490 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003491
3492 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3493
3494 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003495 }
paulfee0f4c2004-09-13 05:12:46 +00003496
3497 bgp->peer_self->rmap_type = 0;
3498
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003499 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00003500 attr_new = bgp_attr_intern (&new_attr);
3501
3502 for (ri = rn->info; ri; ri = ri->next)
3503 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3504 && ri->sub_type == BGP_ROUTE_STATIC)
3505 break;
3506
3507 if (ri)
3508 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003509 if (attrhash_cmp (ri->attr, attr_new) &&
3510 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paulfee0f4c2004-09-13 05:12:46 +00003511 {
3512 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003513 bgp_attr_unintern (&attr_new);
3514 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003515 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003516 return;
3517 }
3518 else
3519 {
3520 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003521 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00003522
3523 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003524 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3525 bgp_info_restore(rn, ri);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003526 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00003527 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003528 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003529
3530 /* Process change. */
3531 bgp_process (bgp, rn, afi, safi);
3532 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003533 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003534 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003535 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003536 }
paulfee0f4c2004-09-13 05:12:46 +00003537 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003538
paulfee0f4c2004-09-13 05:12:46 +00003539 /* Make new BGP info. */
3540 new = bgp_info_new ();
3541 new->type = ZEBRA_ROUTE_BGP;
3542 new->sub_type = BGP_ROUTE_STATIC;
3543 new->peer = bgp->peer_self;
3544 SET_FLAG (new->flags, BGP_INFO_VALID);
3545 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003546 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003547
3548 /* Register new BGP information. */
3549 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003550
3551 /* route_node_get lock */
3552 bgp_unlock_node (rn);
3553
paulfee0f4c2004-09-13 05:12:46 +00003554 /* Process change. */
3555 bgp_process (bgp, rn, afi, safi);
3556
3557 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003558 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003559 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003560}
3561
paul94f2b392005-06-28 12:44:16 +00003562static void
paulfee0f4c2004-09-13 05:12:46 +00003563bgp_static_update_main (struct bgp *bgp, struct prefix *p,
paul718e3742002-12-13 20:15:29 +00003564 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3565{
3566 struct bgp_node *rn;
3567 struct bgp_info *ri;
3568 struct bgp_info *new;
3569 struct bgp_info info;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003570 struct attr attr;
paul718e3742002-12-13 20:15:29 +00003571 struct attr *attr_new;
3572 int ret;
3573
Paul Jakmadd8103a2006-05-12 23:27:30 +00003574 assert (bgp_static);
3575 if (!bgp_static)
3576 return;
3577
paulfee0f4c2004-09-13 05:12:46 +00003578 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003579
3580 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakmadd8103a2006-05-12 23:27:30 +00003581
3582 attr.nexthop = bgp_static->igpnexthop;
3583 attr.med = bgp_static->igpmetric;
3584 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
paul718e3742002-12-13 20:15:29 +00003585
Paul Jakma41367172007-08-06 15:24:51 +00003586 if (bgp_static->atomic)
3587 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3588
paul718e3742002-12-13 20:15:29 +00003589 /* Apply route-map. */
3590 if (bgp_static->rmap.name)
3591 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003592 struct attr attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00003593 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00003594 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00003595
paulfee0f4c2004-09-13 05:12:46 +00003596 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3597
paul718e3742002-12-13 20:15:29 +00003598 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00003599
paulfee0f4c2004-09-13 05:12:46 +00003600 bgp->peer_self->rmap_type = 0;
3601
paul718e3742002-12-13 20:15:29 +00003602 if (ret == RMAP_DENYMATCH)
3603 {
3604 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00003605 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003606
3607 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003608 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003609 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003610 bgp_static_withdraw (bgp, p, afi, safi);
3611 return;
3612 }
paul286e1e72003-08-08 00:24:31 +00003613 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003614 }
paul286e1e72003-08-08 00:24:31 +00003615 else
3616 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00003617
3618 for (ri = rn->info; ri; ri = ri->next)
3619 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3620 && ri->sub_type == BGP_ROUTE_STATIC)
3621 break;
3622
3623 if (ri)
3624 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003625 if (attrhash_cmp (ri->attr, attr_new) &&
3626 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00003627 {
3628 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003629 bgp_attr_unintern (&attr_new);
3630 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003631 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003632 return;
3633 }
3634 else
3635 {
3636 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003637 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00003638
3639 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003640 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3641 bgp_info_restore(rn, ri);
3642 else
3643 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003644 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00003645 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003646 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003647
3648 /* Process change. */
3649 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3650 bgp_process (bgp, rn, afi, safi);
3651 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003652 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003653 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003654 return;
3655 }
3656 }
3657
3658 /* Make new BGP info. */
3659 new = bgp_info_new ();
3660 new->type = ZEBRA_ROUTE_BGP;
3661 new->sub_type = BGP_ROUTE_STATIC;
3662 new->peer = bgp->peer_self;
3663 SET_FLAG (new->flags, BGP_INFO_VALID);
3664 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003665 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003666
3667 /* Aggregate address increment. */
3668 bgp_aggregate_increment (bgp, p, new, afi, safi);
3669
3670 /* Register new BGP information. */
3671 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003672
3673 /* route_node_get lock */
3674 bgp_unlock_node (rn);
3675
paul718e3742002-12-13 20:15:29 +00003676 /* Process change. */
3677 bgp_process (bgp, rn, afi, safi);
3678
3679 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003680 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003681 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003682}
3683
3684void
paulfee0f4c2004-09-13 05:12:46 +00003685bgp_static_update (struct bgp *bgp, struct prefix *p,
3686 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3687{
3688 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00003689 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00003690
3691 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
3692
paul1eb8ef22005-04-07 07:30:20 +00003693 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00003694 {
Paul Jakmada5b30f2006-05-08 14:37:17 +00003695 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
3696 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003697 }
3698}
3699
paul718e3742002-12-13 20:15:29 +00003700void
3701bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
3702 safi_t safi)
3703{
3704 struct bgp_node *rn;
3705 struct bgp_info *ri;
3706
paulfee0f4c2004-09-13 05:12:46 +00003707 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003708
3709 /* Check selected route and self inserted route. */
3710 for (ri = rn->info; ri; ri = ri->next)
3711 if (ri->peer == bgp->peer_self
3712 && ri->type == ZEBRA_ROUTE_BGP
3713 && ri->sub_type == BGP_ROUTE_STATIC)
3714 break;
3715
3716 /* Withdraw static BGP route from routing table. */
3717 if (ri)
3718 {
3719 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003720 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003721 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003722 }
3723
3724 /* Unlock bgp_node_lookup. */
3725 bgp_unlock_node (rn);
3726}
3727
3728void
paulfee0f4c2004-09-13 05:12:46 +00003729bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3730{
3731 struct bgp_static *bgp_static;
3732 struct bgp *bgp;
3733 struct bgp_node *rn;
3734 struct prefix *p;
3735
3736 bgp = rsclient->bgp;
3737
3738 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3739 if ((bgp_static = rn->info) != NULL)
3740 {
3741 p = &rn->p;
3742
3743 bgp_static_update_rsclient (rsclient, p, bgp_static,
3744 afi, safi);
3745 }
3746}
3747
Lou Bergera76d9ca2016-01-12 13:41:53 -05003748/*
3749 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3750 */
paul94f2b392005-06-28 12:44:16 +00003751static void
Lou Bergera76d9ca2016-01-12 13:41:53 -05003752bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3753 safi_t safi, struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00003754{
3755 struct bgp_node *rn;
3756 struct bgp_info *ri;
3757
paulfee0f4c2004-09-13 05:12:46 +00003758 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00003759
3760 /* Check selected route and self inserted route. */
3761 for (ri = rn->info; ri; ri = ri->next)
3762 if (ri->peer == bgp->peer_self
3763 && ri->type == ZEBRA_ROUTE_BGP
3764 && ri->sub_type == BGP_ROUTE_STATIC)
3765 break;
3766
3767 /* Withdraw static BGP route from routing table. */
3768 if (ri)
3769 {
3770 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003771 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003772 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003773 }
3774
3775 /* Unlock bgp_node_lookup. */
3776 bgp_unlock_node (rn);
3777}
3778
Lou Bergera76d9ca2016-01-12 13:41:53 -05003779static void
3780bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3781 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3782{
3783 struct bgp_node *rn;
3784 struct bgp_info *new;
3785 struct attr *attr_new;
3786 struct attr attr = { 0 };
3787 struct bgp_info *ri;
3788
3789 assert (bgp_static);
3790
3791 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3792
3793 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3794
3795 attr.nexthop = bgp_static->igpnexthop;
3796 attr.med = bgp_static->igpmetric;
3797 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3798
3799 /* Apply route-map. */
3800 if (bgp_static->rmap.name)
3801 {
3802 struct attr attr_tmp = attr;
3803 struct bgp_info info;
3804 int ret;
3805
3806 info.peer = bgp->peer_self;
3807 info.attr = &attr_tmp;
3808
3809 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3810
3811 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3812
3813 bgp->peer_self->rmap_type = 0;
3814
3815 if (ret == RMAP_DENYMATCH)
3816 {
3817 /* Free uninterned attribute. */
3818 bgp_attr_flush (&attr_tmp);
3819
3820 /* Unintern original. */
3821 aspath_unintern (&attr.aspath);
3822 bgp_attr_extra_free (&attr);
3823 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3824 bgp_static->tag);
3825 return;
3826 }
3827
3828 attr_new = bgp_attr_intern (&attr_tmp);
3829 }
3830 else
3831 {
3832 attr_new = bgp_attr_intern (&attr);
3833 }
3834
3835 for (ri = rn->info; ri; ri = ri->next)
3836 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3837 && ri->sub_type == BGP_ROUTE_STATIC)
3838 break;
3839
3840 if (ri)
3841 {
3842 if (attrhash_cmp (ri->attr, attr_new) &&
3843 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3844 {
3845 bgp_unlock_node (rn);
3846 bgp_attr_unintern (&attr_new);
3847 aspath_unintern (&attr.aspath);
3848 bgp_attr_extra_free (&attr);
3849 return;
3850 }
3851 else
3852 {
3853 /* The attribute is changed. */
3854 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3855
3856 /* Rewrite BGP route information. */
3857 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3858 bgp_info_restore(rn, ri);
3859 else
3860 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3861 bgp_attr_unintern (&ri->attr);
3862 ri->attr = attr_new;
3863 ri->uptime = bgp_clock ();
3864
3865 /* Process change. */
3866 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3867 bgp_process (bgp, rn, afi, safi);
3868 bgp_unlock_node (rn);
3869 aspath_unintern (&attr.aspath);
3870 bgp_attr_extra_free (&attr);
3871 return;
3872 }
3873 }
3874
3875
3876 /* Make new BGP info. */
3877 new = bgp_info_new ();
3878 new->type = ZEBRA_ROUTE_BGP;
3879 new->sub_type = BGP_ROUTE_STATIC;
3880 new->peer = bgp->peer_self;
3881 new->attr = attr_new;
3882 SET_FLAG (new->flags, BGP_INFO_VALID);
3883 new->uptime = bgp_clock ();
3884 new->extra = bgp_info_extra_new();
3885 memcpy (new->extra->tag, bgp_static->tag, 3);
3886
3887 /* Aggregate address increment. */
3888 bgp_aggregate_increment (bgp, p, new, afi, safi);
3889
3890 /* Register new BGP information. */
3891 bgp_info_add (rn, new);
3892
3893 /* route_node_get lock */
3894 bgp_unlock_node (rn);
3895
3896 /* Process change. */
3897 bgp_process (bgp, rn, afi, safi);
3898
3899 /* Unintern original. */
3900 aspath_unintern (&attr.aspath);
3901 bgp_attr_extra_free (&attr);
3902}
3903
paul718e3742002-12-13 20:15:29 +00003904/* Configure static BGP network. When user don't run zebra, static
3905 route should be installed as valid. */
paul94f2b392005-06-28 12:44:16 +00003906static int
paulfd79ac92004-10-13 05:06:08 +00003907bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003908 afi_t afi, safi_t safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003909{
3910 int ret;
3911 struct prefix p;
3912 struct bgp_static *bgp_static;
3913 struct bgp_node *rn;
Paul Jakma41367172007-08-06 15:24:51 +00003914 u_char need_update = 0;
paul718e3742002-12-13 20:15:29 +00003915
3916 /* Convert IP prefix string to struct prefix. */
3917 ret = str2prefix (ip_str, &p);
3918 if (! ret)
3919 {
3920 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3921 return CMD_WARNING;
3922 }
paul718e3742002-12-13 20:15:29 +00003923 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3924 {
3925 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3926 VTY_NEWLINE);
3927 return CMD_WARNING;
3928 }
paul718e3742002-12-13 20:15:29 +00003929
3930 apply_mask (&p);
3931
3932 /* Set BGP static route configuration. */
3933 rn = bgp_node_get (bgp->route[afi][safi], &p);
3934
3935 if (rn->info)
3936 {
3937 /* Configuration change. */
3938 bgp_static = rn->info;
3939
3940 /* Check previous routes are installed into BGP. */
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003941 if (bgp_static->valid && bgp_static->backdoor != backdoor)
3942 need_update = 1;
Paul Jakma41367172007-08-06 15:24:51 +00003943
paul718e3742002-12-13 20:15:29 +00003944 bgp_static->backdoor = backdoor;
Paul Jakma41367172007-08-06 15:24:51 +00003945
paul718e3742002-12-13 20:15:29 +00003946 if (rmap)
3947 {
3948 if (bgp_static->rmap.name)
3949 free (bgp_static->rmap.name);
3950 bgp_static->rmap.name = strdup (rmap);
3951 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3952 }
3953 else
3954 {
3955 if (bgp_static->rmap.name)
3956 free (bgp_static->rmap.name);
3957 bgp_static->rmap.name = NULL;
3958 bgp_static->rmap.map = NULL;
3959 bgp_static->valid = 0;
3960 }
3961 bgp_unlock_node (rn);
3962 }
3963 else
3964 {
3965 /* New configuration. */
3966 bgp_static = bgp_static_new ();
3967 bgp_static->backdoor = backdoor;
3968 bgp_static->valid = 0;
3969 bgp_static->igpmetric = 0;
3970 bgp_static->igpnexthop.s_addr = 0;
Paul Jakma41367172007-08-06 15:24:51 +00003971
paul718e3742002-12-13 20:15:29 +00003972 if (rmap)
3973 {
3974 if (bgp_static->rmap.name)
3975 free (bgp_static->rmap.name);
3976 bgp_static->rmap.name = strdup (rmap);
3977 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3978 }
3979 rn->info = bgp_static;
3980 }
3981
3982 /* If BGP scan is not enabled, we should install this route here. */
3983 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
3984 {
3985 bgp_static->valid = 1;
3986
3987 if (need_update)
3988 bgp_static_withdraw (bgp, &p, afi, safi);
3989
3990 if (! bgp_static->backdoor)
3991 bgp_static_update (bgp, &p, bgp_static, afi, safi);
3992 }
3993
3994 return CMD_SUCCESS;
3995}
3996
3997/* Configure static BGP network. */
paul94f2b392005-06-28 12:44:16 +00003998static int
paulfd79ac92004-10-13 05:06:08 +00003999bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
Michael Lambert4c9641b2010-07-22 13:20:55 -04004000 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004001{
4002 int ret;
4003 struct prefix p;
4004 struct bgp_static *bgp_static;
4005 struct bgp_node *rn;
4006
4007 /* Convert IP prefix string to struct prefix. */
4008 ret = str2prefix (ip_str, &p);
4009 if (! ret)
4010 {
4011 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4012 return CMD_WARNING;
4013 }
paul718e3742002-12-13 20:15:29 +00004014 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4015 {
4016 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4017 VTY_NEWLINE);
4018 return CMD_WARNING;
4019 }
paul718e3742002-12-13 20:15:29 +00004020
4021 apply_mask (&p);
4022
4023 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4024 if (! rn)
4025 {
4026 vty_out (vty, "%% Can't find specified static route configuration.%s",
4027 VTY_NEWLINE);
4028 return CMD_WARNING;
4029 }
4030
4031 bgp_static = rn->info;
Paul Jakma41367172007-08-06 15:24:51 +00004032
paul718e3742002-12-13 20:15:29 +00004033 /* Update BGP RIB. */
4034 if (! bgp_static->backdoor)
4035 bgp_static_withdraw (bgp, &p, afi, safi);
4036
4037 /* Clear configuration. */
4038 bgp_static_free (bgp_static);
4039 rn->info = NULL;
4040 bgp_unlock_node (rn);
4041 bgp_unlock_node (rn);
4042
4043 return CMD_SUCCESS;
4044}
4045
4046/* Called from bgp_delete(). Delete all static routes from the BGP
4047 instance. */
4048void
4049bgp_static_delete (struct bgp *bgp)
4050{
4051 afi_t afi;
4052 safi_t safi;
4053 struct bgp_node *rn;
4054 struct bgp_node *rm;
4055 struct bgp_table *table;
4056 struct bgp_static *bgp_static;
4057
4058 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4059 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4060 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4061 if (rn->info != NULL)
4062 {
Lou Berger298cc2f2016-01-12 13:42:02 -05004063 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004064 {
4065 table = rn->info;
4066
4067 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4068 {
4069 bgp_static = rn->info;
Lou Bergera76d9ca2016-01-12 13:41:53 -05004070 bgp_static_withdraw_safi (bgp, &rm->p,
4071 AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00004072 (struct prefix_rd *)&rn->p,
4073 bgp_static->tag);
4074 bgp_static_free (bgp_static);
4075 rn->info = NULL;
4076 bgp_unlock_node (rn);
4077 }
4078 }
4079 else
4080 {
4081 bgp_static = rn->info;
4082 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4083 bgp_static_free (bgp_static);
4084 rn->info = NULL;
4085 bgp_unlock_node (rn);
4086 }
4087 }
4088}
4089
Lou Bergera76d9ca2016-01-12 13:41:53 -05004090/*
4091 * gpz 110624
4092 * Currently this is used to set static routes for VPN and ENCAP.
4093 * I think it can probably be factored with bgp_static_set.
4094 */
paul718e3742002-12-13 20:15:29 +00004095int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004096bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4097 const char *rd_str, const char *tag_str,
4098 const char *rmap_str)
paul718e3742002-12-13 20:15:29 +00004099{
4100 int ret;
4101 struct prefix p;
4102 struct prefix_rd prd;
4103 struct bgp *bgp;
4104 struct bgp_node *prn;
4105 struct bgp_node *rn;
4106 struct bgp_table *table;
4107 struct bgp_static *bgp_static;
4108 u_char tag[3];
4109
4110 bgp = vty->index;
4111
4112 ret = str2prefix (ip_str, &p);
4113 if (! ret)
4114 {
4115 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4116 return CMD_WARNING;
4117 }
4118 apply_mask (&p);
4119
4120 ret = str2prefix_rd (rd_str, &prd);
4121 if (! ret)
4122 {
4123 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4124 return CMD_WARNING;
4125 }
4126
4127 ret = str2tag (tag_str, tag);
4128 if (! ret)
4129 {
4130 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4131 return CMD_WARNING;
4132 }
4133
Lou Bergera76d9ca2016-01-12 13:41:53 -05004134 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004135 (struct prefix *)&prd);
4136 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004137 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004138 else
4139 bgp_unlock_node (prn);
4140 table = prn->info;
4141
4142 rn = bgp_node_get (table, &p);
4143
4144 if (rn->info)
4145 {
4146 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4147 bgp_unlock_node (rn);
4148 }
4149 else
4150 {
4151 /* New configuration. */
4152 bgp_static = bgp_static_new ();
Lou Bergera76d9ca2016-01-12 13:41:53 -05004153 bgp_static->backdoor = 0;
4154 bgp_static->valid = 0;
4155 bgp_static->igpmetric = 0;
4156 bgp_static->igpnexthop.s_addr = 0;
4157 memcpy(bgp_static->tag, tag, 3);
4158 bgp_static->prd = prd;
4159
4160 if (rmap_str)
4161 {
4162 if (bgp_static->rmap.name)
4163 free (bgp_static->rmap.name);
4164 bgp_static->rmap.name = strdup (rmap_str);
4165 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4166 }
paul718e3742002-12-13 20:15:29 +00004167 rn->info = bgp_static;
4168
Lou Bergera76d9ca2016-01-12 13:41:53 -05004169 bgp_static->valid = 1;
4170 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004171 }
4172
4173 return CMD_SUCCESS;
4174}
4175
4176/* Configure static BGP network. */
4177int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004178bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4179 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00004180{
4181 int ret;
4182 struct bgp *bgp;
4183 struct prefix p;
4184 struct prefix_rd prd;
4185 struct bgp_node *prn;
4186 struct bgp_node *rn;
4187 struct bgp_table *table;
4188 struct bgp_static *bgp_static;
4189 u_char tag[3];
4190
4191 bgp = vty->index;
4192
4193 /* Convert IP prefix string to struct prefix. */
4194 ret = str2prefix (ip_str, &p);
4195 if (! ret)
4196 {
4197 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4198 return CMD_WARNING;
4199 }
4200 apply_mask (&p);
4201
4202 ret = str2prefix_rd (rd_str, &prd);
4203 if (! ret)
4204 {
4205 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4206 return CMD_WARNING;
4207 }
4208
4209 ret = str2tag (tag_str, tag);
4210 if (! ret)
4211 {
4212 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4213 return CMD_WARNING;
4214 }
4215
Lou Bergera76d9ca2016-01-12 13:41:53 -05004216 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004217 (struct prefix *)&prd);
4218 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004219 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004220 else
4221 bgp_unlock_node (prn);
4222 table = prn->info;
4223
4224 rn = bgp_node_lookup (table, &p);
4225
4226 if (rn)
4227 {
Lou Bergera76d9ca2016-01-12 13:41:53 -05004228 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
paul718e3742002-12-13 20:15:29 +00004229
4230 bgp_static = rn->info;
4231 bgp_static_free (bgp_static);
4232 rn->info = NULL;
4233 bgp_unlock_node (rn);
4234 bgp_unlock_node (rn);
4235 }
4236 else
4237 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4238
4239 return CMD_SUCCESS;
4240}
David Lamparter6b0655a2014-06-04 06:53:35 +02004241
paul718e3742002-12-13 20:15:29 +00004242DEFUN (bgp_network,
4243 bgp_network_cmd,
4244 "network A.B.C.D/M",
4245 "Specify a network to announce via BGP\n"
4246 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4247{
4248 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004249 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004250}
4251
4252DEFUN (bgp_network_route_map,
4253 bgp_network_route_map_cmd,
4254 "network A.B.C.D/M route-map WORD",
4255 "Specify a network to announce via BGP\n"
4256 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4257 "Route-map to modify the attributes\n"
4258 "Name of the route map\n")
4259{
4260 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004261 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004262}
4263
4264DEFUN (bgp_network_backdoor,
4265 bgp_network_backdoor_cmd,
4266 "network A.B.C.D/M backdoor",
4267 "Specify a network to announce via BGP\n"
4268 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4269 "Specify a BGP backdoor route\n")
4270{
Paul Jakma41367172007-08-06 15:24:51 +00004271 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004272 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004273}
4274
4275DEFUN (bgp_network_mask,
4276 bgp_network_mask_cmd,
4277 "network A.B.C.D mask A.B.C.D",
4278 "Specify a network to announce via BGP\n"
4279 "Network number\n"
4280 "Network mask\n"
4281 "Network mask\n")
4282{
4283 int ret;
4284 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004285
paul718e3742002-12-13 20:15:29 +00004286 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4287 if (! ret)
4288 {
4289 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4290 return CMD_WARNING;
4291 }
4292
4293 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004294 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004295}
4296
4297DEFUN (bgp_network_mask_route_map,
4298 bgp_network_mask_route_map_cmd,
4299 "network A.B.C.D mask A.B.C.D route-map WORD",
4300 "Specify a network to announce via BGP\n"
4301 "Network number\n"
4302 "Network mask\n"
4303 "Network mask\n"
4304 "Route-map to modify the attributes\n"
4305 "Name of the route map\n")
4306{
4307 int ret;
4308 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004309
paul718e3742002-12-13 20:15:29 +00004310 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4311 if (! ret)
4312 {
4313 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4314 return CMD_WARNING;
4315 }
4316
4317 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004318 AFI_IP, bgp_node_safi (vty), argv[2], 0);
paul718e3742002-12-13 20:15:29 +00004319}
4320
4321DEFUN (bgp_network_mask_backdoor,
4322 bgp_network_mask_backdoor_cmd,
4323 "network A.B.C.D mask A.B.C.D backdoor",
4324 "Specify a network to announce via BGP\n"
4325 "Network number\n"
4326 "Network mask\n"
4327 "Network mask\n"
4328 "Specify a BGP backdoor route\n")
4329{
4330 int ret;
4331 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004332
paul718e3742002-12-13 20:15:29 +00004333 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4334 if (! ret)
4335 {
4336 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4337 return CMD_WARNING;
4338 }
4339
Paul Jakma41367172007-08-06 15:24:51 +00004340 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004341 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004342}
4343
4344DEFUN (bgp_network_mask_natural,
4345 bgp_network_mask_natural_cmd,
4346 "network A.B.C.D",
4347 "Specify a network to announce via BGP\n"
4348 "Network number\n")
4349{
4350 int ret;
4351 char prefix_str[BUFSIZ];
4352
4353 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4354 if (! ret)
4355 {
4356 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4357 return CMD_WARNING;
4358 }
4359
4360 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004361 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004362}
4363
4364DEFUN (bgp_network_mask_natural_route_map,
4365 bgp_network_mask_natural_route_map_cmd,
4366 "network A.B.C.D route-map WORD",
4367 "Specify a network to announce via BGP\n"
4368 "Network number\n"
4369 "Route-map to modify the attributes\n"
4370 "Name of the route map\n")
4371{
4372 int ret;
4373 char prefix_str[BUFSIZ];
4374
4375 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4376 if (! ret)
4377 {
4378 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4379 return CMD_WARNING;
4380 }
4381
4382 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004383 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004384}
4385
4386DEFUN (bgp_network_mask_natural_backdoor,
4387 bgp_network_mask_natural_backdoor_cmd,
4388 "network A.B.C.D backdoor",
4389 "Specify a network to announce via BGP\n"
4390 "Network number\n"
4391 "Specify a BGP backdoor route\n")
4392{
4393 int ret;
4394 char prefix_str[BUFSIZ];
4395
4396 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4397 if (! ret)
4398 {
4399 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4400 return CMD_WARNING;
4401 }
4402
Paul Jakma41367172007-08-06 15:24:51 +00004403 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004404 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004405}
4406
4407DEFUN (no_bgp_network,
4408 no_bgp_network_cmd,
4409 "no network A.B.C.D/M",
4410 NO_STR
4411 "Specify a network to announce via BGP\n"
4412 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4413{
4414 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4415 bgp_node_safi (vty));
4416}
4417
4418ALIAS (no_bgp_network,
4419 no_bgp_network_route_map_cmd,
4420 "no network A.B.C.D/M route-map WORD",
4421 NO_STR
4422 "Specify a network to announce via BGP\n"
4423 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4424 "Route-map to modify the attributes\n"
4425 "Name of the route map\n")
4426
4427ALIAS (no_bgp_network,
4428 no_bgp_network_backdoor_cmd,
4429 "no network A.B.C.D/M backdoor",
4430 NO_STR
4431 "Specify a network to announce via BGP\n"
4432 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4433 "Specify a BGP backdoor route\n")
4434
4435DEFUN (no_bgp_network_mask,
4436 no_bgp_network_mask_cmd,
4437 "no network A.B.C.D mask A.B.C.D",
4438 NO_STR
4439 "Specify a network to announce via BGP\n"
4440 "Network number\n"
4441 "Network mask\n"
4442 "Network mask\n")
4443{
4444 int ret;
4445 char prefix_str[BUFSIZ];
4446
4447 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4448 if (! ret)
4449 {
4450 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4451 return CMD_WARNING;
4452 }
4453
4454 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4455 bgp_node_safi (vty));
4456}
4457
4458ALIAS (no_bgp_network_mask,
4459 no_bgp_network_mask_route_map_cmd,
4460 "no network A.B.C.D mask A.B.C.D route-map WORD",
4461 NO_STR
4462 "Specify a network to announce via BGP\n"
4463 "Network number\n"
4464 "Network mask\n"
4465 "Network mask\n"
4466 "Route-map to modify the attributes\n"
4467 "Name of the route map\n")
4468
4469ALIAS (no_bgp_network_mask,
4470 no_bgp_network_mask_backdoor_cmd,
4471 "no network A.B.C.D mask A.B.C.D backdoor",
4472 NO_STR
4473 "Specify a network to announce via BGP\n"
4474 "Network number\n"
4475 "Network mask\n"
4476 "Network mask\n"
4477 "Specify a BGP backdoor route\n")
4478
4479DEFUN (no_bgp_network_mask_natural,
4480 no_bgp_network_mask_natural_cmd,
4481 "no network A.B.C.D",
4482 NO_STR
4483 "Specify a network to announce via BGP\n"
4484 "Network number\n")
4485{
4486 int ret;
4487 char prefix_str[BUFSIZ];
4488
4489 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4490 if (! ret)
4491 {
4492 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4493 return CMD_WARNING;
4494 }
4495
4496 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4497 bgp_node_safi (vty));
4498}
4499
4500ALIAS (no_bgp_network_mask_natural,
4501 no_bgp_network_mask_natural_route_map_cmd,
4502 "no network A.B.C.D route-map WORD",
4503 NO_STR
4504 "Specify a network to announce via BGP\n"
4505 "Network number\n"
4506 "Route-map to modify the attributes\n"
4507 "Name of the route map\n")
4508
4509ALIAS (no_bgp_network_mask_natural,
4510 no_bgp_network_mask_natural_backdoor_cmd,
4511 "no network A.B.C.D backdoor",
4512 NO_STR
4513 "Specify a network to announce via BGP\n"
4514 "Network number\n"
4515 "Specify a BGP backdoor route\n")
4516
paul718e3742002-12-13 20:15:29 +00004517DEFUN (ipv6_bgp_network,
4518 ipv6_bgp_network_cmd,
4519 "network X:X::X:X/M",
4520 "Specify a network to announce via BGP\n"
4521 "IPv6 prefix <network>/<length>\n")
4522{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304523 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004524 NULL, 0);
paul718e3742002-12-13 20:15:29 +00004525}
4526
4527DEFUN (ipv6_bgp_network_route_map,
4528 ipv6_bgp_network_route_map_cmd,
4529 "network X:X::X:X/M route-map WORD",
4530 "Specify a network to announce via BGP\n"
4531 "IPv6 prefix <network>/<length>\n"
4532 "Route-map to modify the attributes\n"
4533 "Name of the route map\n")
4534{
4535 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004536 bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004537}
4538
4539DEFUN (no_ipv6_bgp_network,
4540 no_ipv6_bgp_network_cmd,
4541 "no network X:X::X:X/M",
4542 NO_STR
4543 "Specify a network to announce via BGP\n"
4544 "IPv6 prefix <network>/<length>\n")
4545{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304546 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00004547}
4548
4549ALIAS (no_ipv6_bgp_network,
4550 no_ipv6_bgp_network_route_map_cmd,
4551 "no network X:X::X:X/M route-map WORD",
4552 NO_STR
4553 "Specify a network to announce via BGP\n"
4554 "IPv6 prefix <network>/<length>\n"
4555 "Route-map to modify the attributes\n"
4556 "Name of the route map\n")
4557
4558ALIAS (ipv6_bgp_network,
4559 old_ipv6_bgp_network_cmd,
4560 "ipv6 bgp network X:X::X:X/M",
4561 IPV6_STR
4562 BGP_STR
4563 "Specify a network to announce via BGP\n"
4564 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4565
4566ALIAS (no_ipv6_bgp_network,
4567 old_no_ipv6_bgp_network_cmd,
4568 "no ipv6 bgp network X:X::X:X/M",
4569 NO_STR
4570 IPV6_STR
4571 BGP_STR
4572 "Specify a network to announce via BGP\n"
4573 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004574
4575/* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4576ALIAS_DEPRECATED (bgp_network,
4577 bgp_network_ttl_cmd,
4578 "network A.B.C.D/M pathlimit <0-255>",
4579 "Specify a network to announce via BGP\n"
4580 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4581 "AS-Path hopcount limit attribute\n"
4582 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4583ALIAS_DEPRECATED (bgp_network_backdoor,
4584 bgp_network_backdoor_ttl_cmd,
4585 "network A.B.C.D/M backdoor pathlimit <0-255>",
4586 "Specify a network to announce via BGP\n"
4587 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4588 "Specify a BGP backdoor route\n"
4589 "AS-Path hopcount limit attribute\n"
4590 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4591ALIAS_DEPRECATED (bgp_network_mask,
4592 bgp_network_mask_ttl_cmd,
4593 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4594 "Specify a network to announce via BGP\n"
4595 "Network number\n"
4596 "Network mask\n"
4597 "Network mask\n"
4598 "AS-Path hopcount limit attribute\n"
4599 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4600ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4601 bgp_network_mask_backdoor_ttl_cmd,
4602 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4603 "Specify a network to announce via BGP\n"
4604 "Network number\n"
4605 "Network mask\n"
4606 "Network mask\n"
4607 "Specify a BGP backdoor route\n"
4608 "AS-Path hopcount limit attribute\n"
4609 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4610ALIAS_DEPRECATED (bgp_network_mask_natural,
4611 bgp_network_mask_natural_ttl_cmd,
4612 "network A.B.C.D pathlimit <0-255>",
4613 "Specify a network to announce via BGP\n"
4614 "Network number\n"
4615 "AS-Path hopcount limit attribute\n"
4616 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4617ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4618 bgp_network_mask_natural_backdoor_ttl_cmd,
Christian Franke2b005152013-09-30 12:27:49 +00004619 "network A.B.C.D backdoor pathlimit <1-255>",
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004620 "Specify a network to announce via BGP\n"
4621 "Network number\n"
4622 "Specify a BGP backdoor route\n"
4623 "AS-Path hopcount limit attribute\n"
4624 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4625ALIAS_DEPRECATED (no_bgp_network,
4626 no_bgp_network_ttl_cmd,
4627 "no network A.B.C.D/M pathlimit <0-255>",
4628 NO_STR
4629 "Specify a network to announce via BGP\n"
4630 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4631 "AS-Path hopcount limit attribute\n"
4632 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4633ALIAS_DEPRECATED (no_bgp_network,
4634 no_bgp_network_backdoor_ttl_cmd,
4635 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4636 NO_STR
4637 "Specify a network to announce via BGP\n"
4638 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4639 "Specify a BGP backdoor route\n"
4640 "AS-Path hopcount limit attribute\n"
4641 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4642ALIAS_DEPRECATED (no_bgp_network,
4643 no_bgp_network_mask_ttl_cmd,
4644 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4645 NO_STR
4646 "Specify a network to announce via BGP\n"
4647 "Network number\n"
4648 "Network mask\n"
4649 "Network mask\n"
4650 "AS-Path hopcount limit attribute\n"
4651 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4652ALIAS_DEPRECATED (no_bgp_network_mask,
4653 no_bgp_network_mask_backdoor_ttl_cmd,
4654 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4655 NO_STR
4656 "Specify a network to announce via BGP\n"
4657 "Network number\n"
4658 "Network mask\n"
4659 "Network mask\n"
4660 "Specify a BGP backdoor route\n"
4661 "AS-Path hopcount limit attribute\n"
4662 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4663ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4664 no_bgp_network_mask_natural_ttl_cmd,
4665 "no network A.B.C.D pathlimit <0-255>",
4666 NO_STR
4667 "Specify a network to announce via BGP\n"
4668 "Network number\n"
4669 "AS-Path hopcount limit attribute\n"
4670 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4671ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4672 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4673 "no network A.B.C.D backdoor pathlimit <0-255>",
4674 NO_STR
4675 "Specify a network to announce via BGP\n"
4676 "Network number\n"
4677 "Specify a BGP backdoor route\n"
4678 "AS-Path hopcount limit attribute\n"
4679 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4680ALIAS_DEPRECATED (ipv6_bgp_network,
4681 ipv6_bgp_network_ttl_cmd,
4682 "network X:X::X:X/M pathlimit <0-255>",
4683 "Specify a network to announce via BGP\n"
4684 "IPv6 prefix <network>/<length>\n"
4685 "AS-Path hopcount limit attribute\n"
4686 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4687ALIAS_DEPRECATED (no_ipv6_bgp_network,
4688 no_ipv6_bgp_network_ttl_cmd,
4689 "no network X:X::X:X/M pathlimit <0-255>",
4690 NO_STR
4691 "Specify a network to announce via BGP\n"
4692 "IPv6 prefix <network>/<length>\n"
4693 "AS-Path hopcount limit attribute\n"
4694 "AS-Pathlimit TTL, in number of AS-Path hops\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02004695
paul718e3742002-12-13 20:15:29 +00004696/* Aggreagete address:
4697
4698 advertise-map Set condition to advertise attribute
4699 as-set Generate AS set path information
4700 attribute-map Set attributes of aggregate
4701 route-map Set parameters of aggregate
4702 summary-only Filter more specific routes from updates
4703 suppress-map Conditionally filter more specific routes from updates
4704 <cr>
4705 */
4706struct bgp_aggregate
4707{
4708 /* Summary-only flag. */
4709 u_char summary_only;
4710
4711 /* AS set generation. */
4712 u_char as_set;
4713
4714 /* Route-map for aggregated route. */
4715 struct route_map *map;
4716
4717 /* Suppress-count. */
4718 unsigned long count;
4719
4720 /* SAFI configuration. */
4721 safi_t safi;
4722};
4723
paul94f2b392005-06-28 12:44:16 +00004724static struct bgp_aggregate *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08004725bgp_aggregate_new (void)
paul718e3742002-12-13 20:15:29 +00004726{
Stephen Hemminger393deb92008-08-18 14:13:29 -07004727 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
paul718e3742002-12-13 20:15:29 +00004728}
4729
paul94f2b392005-06-28 12:44:16 +00004730static void
paul718e3742002-12-13 20:15:29 +00004731bgp_aggregate_free (struct bgp_aggregate *aggregate)
4732{
4733 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4734}
4735
paul94f2b392005-06-28 12:44:16 +00004736static void
paul718e3742002-12-13 20:15:29 +00004737bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4738 afi_t afi, safi_t safi, struct bgp_info *del,
4739 struct bgp_aggregate *aggregate)
4740{
4741 struct bgp_table *table;
4742 struct bgp_node *top;
4743 struct bgp_node *rn;
4744 u_char origin;
4745 struct aspath *aspath = NULL;
4746 struct aspath *asmerge = NULL;
4747 struct community *community = NULL;
4748 struct community *commerge = NULL;
paul718e3742002-12-13 20:15:29 +00004749 struct bgp_info *ri;
4750 struct bgp_info *new;
4751 int first = 1;
4752 unsigned long match = 0;
4753
paul718e3742002-12-13 20:15:29 +00004754 /* ORIGIN attribute: If at least one route among routes that are
4755 aggregated has ORIGIN with the value INCOMPLETE, then the
4756 aggregated route must have the ORIGIN attribute with the value
4757 INCOMPLETE. Otherwise, if at least one route among routes that
4758 are aggregated has ORIGIN with the value EGP, then the aggregated
4759 route must have the origin attribute with the value EGP. In all
4760 other case the value of the ORIGIN attribute of the aggregated
4761 route is INTERNAL. */
4762 origin = BGP_ORIGIN_IGP;
4763
4764 table = bgp->rib[afi][safi];
4765
4766 top = bgp_node_get (table, p);
4767 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4768 if (rn->p.prefixlen > p->prefixlen)
4769 {
4770 match = 0;
4771
4772 for (ri = rn->info; ri; ri = ri->next)
4773 {
4774 if (BGP_INFO_HOLDDOWN (ri))
4775 continue;
4776
4777 if (del && ri == del)
4778 continue;
4779
4780 if (! rinew && first)
Paul Jakma7aa9dce2014-09-19 14:42:23 +01004781 first = 0;
paul718e3742002-12-13 20:15:29 +00004782
4783#ifdef AGGREGATE_NEXTHOP_CHECK
4784 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4785 || ri->attr->med != med)
4786 {
4787 if (aspath)
4788 aspath_free (aspath);
4789 if (community)
4790 community_free (community);
4791 bgp_unlock_node (rn);
4792 bgp_unlock_node (top);
4793 return;
4794 }
4795#endif /* AGGREGATE_NEXTHOP_CHECK */
4796
4797 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4798 {
4799 if (aggregate->summary_only)
4800 {
Paul Jakmafb982c22007-05-04 20:15:47 +00004801 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00004802 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00004803 match++;
4804 }
4805
4806 aggregate->count++;
4807
4808 if (aggregate->as_set)
4809 {
4810 if (origin < ri->attr->origin)
4811 origin = ri->attr->origin;
4812
4813 if (aspath)
4814 {
4815 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4816 aspath_free (aspath);
4817 aspath = asmerge;
4818 }
4819 else
4820 aspath = aspath_dup (ri->attr->aspath);
4821
4822 if (ri->attr->community)
4823 {
4824 if (community)
4825 {
4826 commerge = community_merge (community,
4827 ri->attr->community);
4828 community = community_uniq_sort (commerge);
4829 community_free (commerge);
4830 }
4831 else
4832 community = community_dup (ri->attr->community);
4833 }
4834 }
4835 }
4836 }
4837 if (match)
4838 bgp_process (bgp, rn, afi, safi);
4839 }
4840 bgp_unlock_node (top);
4841
4842 if (rinew)
4843 {
4844 aggregate->count++;
4845
4846 if (aggregate->summary_only)
Paul Jakmafb982c22007-05-04 20:15:47 +00004847 (bgp_info_extra_get (rinew))->suppress++;
paul718e3742002-12-13 20:15:29 +00004848
4849 if (aggregate->as_set)
4850 {
4851 if (origin < rinew->attr->origin)
4852 origin = rinew->attr->origin;
4853
4854 if (aspath)
4855 {
4856 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4857 aspath_free (aspath);
4858 aspath = asmerge;
4859 }
4860 else
4861 aspath = aspath_dup (rinew->attr->aspath);
4862
4863 if (rinew->attr->community)
4864 {
4865 if (community)
4866 {
4867 commerge = community_merge (community,
4868 rinew->attr->community);
4869 community = community_uniq_sort (commerge);
4870 community_free (commerge);
4871 }
4872 else
4873 community = community_dup (rinew->attr->community);
4874 }
4875 }
4876 }
4877
4878 if (aggregate->count > 0)
4879 {
4880 rn = bgp_node_get (table, p);
4881 new = bgp_info_new ();
4882 new->type = ZEBRA_ROUTE_BGP;
4883 new->sub_type = BGP_ROUTE_AGGREGATE;
4884 new->peer = bgp->peer_self;
4885 SET_FLAG (new->flags, BGP_INFO_VALID);
4886 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03004887 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00004888
4889 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00004890 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00004891 bgp_process (bgp, rn, afi, safi);
4892 }
4893 else
4894 {
4895 if (aspath)
4896 aspath_free (aspath);
4897 if (community)
4898 community_free (community);
4899 }
4900}
4901
4902void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4903 struct bgp_aggregate *);
4904
4905void
4906bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4907 struct bgp_info *ri, afi_t afi, safi_t safi)
4908{
4909 struct bgp_node *child;
4910 struct bgp_node *rn;
4911 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004912 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004913
4914 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004915 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004916 return;
4917
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004918 table = bgp->aggregate[afi][safi];
4919
4920 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004921 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004922 return;
4923
paul718e3742002-12-13 20:15:29 +00004924 if (p->prefixlen == 0)
4925 return;
4926
4927 if (BGP_INFO_HOLDDOWN (ri))
4928 return;
4929
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004930 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004931
4932 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004933 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00004934 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
4935 {
4936 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00004937 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00004938 }
4939 bgp_unlock_node (child);
4940}
4941
4942void
4943bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
4944 struct bgp_info *del, afi_t afi, safi_t safi)
4945{
4946 struct bgp_node *child;
4947 struct bgp_node *rn;
4948 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004949 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004950
4951 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004952 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004953 return;
4954
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004955 table = bgp->aggregate[afi][safi];
4956
4957 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004958 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004959 return;
4960
paul718e3742002-12-13 20:15:29 +00004961 if (p->prefixlen == 0)
4962 return;
4963
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004964 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004965
4966 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004967 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00004968 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
4969 {
4970 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00004971 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00004972 }
4973 bgp_unlock_node (child);
4974}
4975
paul94f2b392005-06-28 12:44:16 +00004976static void
paul718e3742002-12-13 20:15:29 +00004977bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
4978 struct bgp_aggregate *aggregate)
4979{
4980 struct bgp_table *table;
4981 struct bgp_node *top;
4982 struct bgp_node *rn;
4983 struct bgp_info *new;
4984 struct bgp_info *ri;
4985 unsigned long match;
4986 u_char origin = BGP_ORIGIN_IGP;
4987 struct aspath *aspath = NULL;
4988 struct aspath *asmerge = NULL;
4989 struct community *community = NULL;
4990 struct community *commerge = NULL;
4991
4992 table = bgp->rib[afi][safi];
4993
4994 /* Sanity check. */
4995 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
4996 return;
4997 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
4998 return;
4999
5000 /* If routes exists below this node, generate aggregate routes. */
5001 top = bgp_node_get (table, p);
5002 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5003 if (rn->p.prefixlen > p->prefixlen)
5004 {
5005 match = 0;
5006
5007 for (ri = rn->info; ri; ri = ri->next)
5008 {
5009 if (BGP_INFO_HOLDDOWN (ri))
5010 continue;
5011
5012 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5013 {
5014 /* summary-only aggregate route suppress aggregated
5015 route announcement. */
5016 if (aggregate->summary_only)
5017 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005018 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00005019 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005020 match++;
5021 }
5022 /* as-set aggregate route generate origin, as path,
5023 community aggregation. */
5024 if (aggregate->as_set)
5025 {
5026 if (origin < ri->attr->origin)
5027 origin = ri->attr->origin;
5028
5029 if (aspath)
5030 {
5031 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5032 aspath_free (aspath);
5033 aspath = asmerge;
5034 }
5035 else
5036 aspath = aspath_dup (ri->attr->aspath);
5037
5038 if (ri->attr->community)
5039 {
5040 if (community)
5041 {
5042 commerge = community_merge (community,
5043 ri->attr->community);
5044 community = community_uniq_sort (commerge);
5045 community_free (commerge);
5046 }
5047 else
5048 community = community_dup (ri->attr->community);
5049 }
5050 }
5051 aggregate->count++;
5052 }
5053 }
5054
5055 /* If this node is suppressed, process the change. */
5056 if (match)
5057 bgp_process (bgp, rn, afi, safi);
5058 }
5059 bgp_unlock_node (top);
5060
5061 /* Add aggregate route to BGP table. */
5062 if (aggregate->count)
5063 {
5064 rn = bgp_node_get (table, p);
5065
5066 new = bgp_info_new ();
5067 new->type = ZEBRA_ROUTE_BGP;
5068 new->sub_type = BGP_ROUTE_AGGREGATE;
5069 new->peer = bgp->peer_self;
5070 SET_FLAG (new->flags, BGP_INFO_VALID);
5071 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03005072 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005073
5074 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00005075 bgp_unlock_node (rn);
5076
paul718e3742002-12-13 20:15:29 +00005077 /* Process change. */
5078 bgp_process (bgp, rn, afi, safi);
5079 }
Denil Virae2a92582015-08-11 13:34:59 -07005080 else
5081 {
5082 if (aspath)
5083 aspath_free (aspath);
5084 if (community)
5085 community_free (community);
5086 }
paul718e3742002-12-13 20:15:29 +00005087}
5088
5089void
5090bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5091 safi_t safi, struct bgp_aggregate *aggregate)
5092{
5093 struct bgp_table *table;
5094 struct bgp_node *top;
5095 struct bgp_node *rn;
5096 struct bgp_info *ri;
5097 unsigned long match;
5098
5099 table = bgp->rib[afi][safi];
5100
5101 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5102 return;
5103 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5104 return;
5105
5106 /* If routes exists below this node, generate aggregate routes. */
5107 top = bgp_node_get (table, p);
5108 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5109 if (rn->p.prefixlen > p->prefixlen)
5110 {
5111 match = 0;
5112
5113 for (ri = rn->info; ri; ri = ri->next)
5114 {
5115 if (BGP_INFO_HOLDDOWN (ri))
5116 continue;
5117
5118 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5119 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005120 if (aggregate->summary_only && ri->extra)
paul718e3742002-12-13 20:15:29 +00005121 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005122 ri->extra->suppress--;
paul718e3742002-12-13 20:15:29 +00005123
Paul Jakmafb982c22007-05-04 20:15:47 +00005124 if (ri->extra->suppress == 0)
paul718e3742002-12-13 20:15:29 +00005125 {
Paul Jakma1a392d42006-09-07 00:24:49 +00005126 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005127 match++;
5128 }
5129 }
5130 aggregate->count--;
5131 }
5132 }
5133
Paul Jakmafb982c22007-05-04 20:15:47 +00005134 /* If this node was suppressed, process the change. */
paul718e3742002-12-13 20:15:29 +00005135 if (match)
5136 bgp_process (bgp, rn, afi, safi);
5137 }
5138 bgp_unlock_node (top);
5139
5140 /* Delete aggregate route from BGP table. */
5141 rn = bgp_node_get (table, p);
5142
5143 for (ri = rn->info; ri; ri = ri->next)
5144 if (ri->peer == bgp->peer_self
5145 && ri->type == ZEBRA_ROUTE_BGP
5146 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5147 break;
5148
5149 /* Withdraw static BGP route from routing table. */
5150 if (ri)
5151 {
paul718e3742002-12-13 20:15:29 +00005152 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005153 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00005154 }
5155
5156 /* Unlock bgp_node_lookup. */
5157 bgp_unlock_node (rn);
5158}
5159
5160/* Aggregate route attribute. */
5161#define AGGREGATE_SUMMARY_ONLY 1
5162#define AGGREGATE_AS_SET 1
5163
paul94f2b392005-06-28 12:44:16 +00005164static int
Robert Baysf6269b42010-08-05 10:26:28 -07005165bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5166 afi_t afi, safi_t safi)
5167{
5168 int ret;
5169 struct prefix p;
5170 struct bgp_node *rn;
5171 struct bgp *bgp;
5172 struct bgp_aggregate *aggregate;
5173
5174 /* Convert string to prefix structure. */
5175 ret = str2prefix (prefix_str, &p);
5176 if (!ret)
5177 {
5178 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5179 return CMD_WARNING;
5180 }
5181 apply_mask (&p);
5182
5183 /* Get BGP structure. */
5184 bgp = vty->index;
5185
5186 /* Old configuration check. */
5187 rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
5188 if (! rn)
5189 {
5190 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5191 VTY_NEWLINE);
5192 return CMD_WARNING;
5193 }
5194
5195 aggregate = rn->info;
5196 if (aggregate->safi & SAFI_UNICAST)
5197 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5198 if (aggregate->safi & SAFI_MULTICAST)
5199 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5200
5201 /* Unlock aggregate address configuration. */
5202 rn->info = NULL;
5203 bgp_aggregate_free (aggregate);
5204 bgp_unlock_node (rn);
5205 bgp_unlock_node (rn);
5206
5207 return CMD_SUCCESS;
5208}
5209
5210static int
5211bgp_aggregate_set (struct vty *vty, const char *prefix_str,
paulfd79ac92004-10-13 05:06:08 +00005212 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00005213 u_char summary_only, u_char as_set)
5214{
5215 int ret;
5216 struct prefix p;
5217 struct bgp_node *rn;
5218 struct bgp *bgp;
5219 struct bgp_aggregate *aggregate;
5220
5221 /* Convert string to prefix structure. */
5222 ret = str2prefix (prefix_str, &p);
5223 if (!ret)
5224 {
5225 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5226 return CMD_WARNING;
5227 }
5228 apply_mask (&p);
5229
5230 /* Get BGP structure. */
5231 bgp = vty->index;
5232
5233 /* Old configuration check. */
5234 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5235
5236 if (rn->info)
5237 {
5238 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
Robert Bays368473f2010-08-05 10:26:29 -07005239 /* try to remove the old entry */
Robert Baysf6269b42010-08-05 10:26:28 -07005240 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5241 if (ret)
5242 {
Robert Bays368473f2010-08-05 10:26:29 -07005243 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5244 bgp_unlock_node (rn);
Robert Baysf6269b42010-08-05 10:26:28 -07005245 return CMD_WARNING;
5246 }
paul718e3742002-12-13 20:15:29 +00005247 }
5248
5249 /* Make aggregate address structure. */
5250 aggregate = bgp_aggregate_new ();
5251 aggregate->summary_only = summary_only;
5252 aggregate->as_set = as_set;
5253 aggregate->safi = safi;
5254 rn->info = aggregate;
5255
5256 /* Aggregate address insert into BGP routing table. */
5257 if (safi & SAFI_UNICAST)
5258 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5259 if (safi & SAFI_MULTICAST)
5260 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5261
5262 return CMD_SUCCESS;
5263}
5264
paul718e3742002-12-13 20:15:29 +00005265DEFUN (aggregate_address,
5266 aggregate_address_cmd,
5267 "aggregate-address A.B.C.D/M",
5268 "Configure BGP aggregate entries\n"
5269 "Aggregate prefix\n")
5270{
5271 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5272}
5273
5274DEFUN (aggregate_address_mask,
5275 aggregate_address_mask_cmd,
5276 "aggregate-address A.B.C.D A.B.C.D",
5277 "Configure BGP aggregate entries\n"
5278 "Aggregate address\n"
5279 "Aggregate mask\n")
5280{
5281 int ret;
5282 char prefix_str[BUFSIZ];
5283
5284 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5285
5286 if (! ret)
5287 {
5288 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5289 return CMD_WARNING;
5290 }
5291
5292 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5293 0, 0);
5294}
5295
5296DEFUN (aggregate_address_summary_only,
5297 aggregate_address_summary_only_cmd,
5298 "aggregate-address A.B.C.D/M summary-only",
5299 "Configure BGP aggregate entries\n"
5300 "Aggregate prefix\n"
5301 "Filter more specific routes from updates\n")
5302{
5303 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5304 AGGREGATE_SUMMARY_ONLY, 0);
5305}
5306
5307DEFUN (aggregate_address_mask_summary_only,
5308 aggregate_address_mask_summary_only_cmd,
5309 "aggregate-address A.B.C.D A.B.C.D summary-only",
5310 "Configure BGP aggregate entries\n"
5311 "Aggregate address\n"
5312 "Aggregate mask\n"
5313 "Filter more specific routes from updates\n")
5314{
5315 int ret;
5316 char prefix_str[BUFSIZ];
5317
5318 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5319
5320 if (! ret)
5321 {
5322 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5323 return CMD_WARNING;
5324 }
5325
5326 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5327 AGGREGATE_SUMMARY_ONLY, 0);
5328}
5329
5330DEFUN (aggregate_address_as_set,
5331 aggregate_address_as_set_cmd,
5332 "aggregate-address A.B.C.D/M as-set",
5333 "Configure BGP aggregate entries\n"
5334 "Aggregate prefix\n"
5335 "Generate AS set path information\n")
5336{
5337 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5338 0, AGGREGATE_AS_SET);
5339}
5340
5341DEFUN (aggregate_address_mask_as_set,
5342 aggregate_address_mask_as_set_cmd,
5343 "aggregate-address A.B.C.D A.B.C.D as-set",
5344 "Configure BGP aggregate entries\n"
5345 "Aggregate address\n"
5346 "Aggregate mask\n"
5347 "Generate AS set path information\n")
5348{
5349 int ret;
5350 char prefix_str[BUFSIZ];
5351
5352 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5353
5354 if (! ret)
5355 {
5356 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5357 return CMD_WARNING;
5358 }
5359
5360 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5361 0, AGGREGATE_AS_SET);
5362}
5363
5364
5365DEFUN (aggregate_address_as_set_summary,
5366 aggregate_address_as_set_summary_cmd,
5367 "aggregate-address A.B.C.D/M as-set summary-only",
5368 "Configure BGP aggregate entries\n"
5369 "Aggregate prefix\n"
5370 "Generate AS set path information\n"
5371 "Filter more specific routes from updates\n")
5372{
5373 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5374 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5375}
5376
5377ALIAS (aggregate_address_as_set_summary,
5378 aggregate_address_summary_as_set_cmd,
5379 "aggregate-address A.B.C.D/M summary-only as-set",
5380 "Configure BGP aggregate entries\n"
5381 "Aggregate prefix\n"
5382 "Filter more specific routes from updates\n"
5383 "Generate AS set path information\n")
5384
5385DEFUN (aggregate_address_mask_as_set_summary,
5386 aggregate_address_mask_as_set_summary_cmd,
5387 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5388 "Configure BGP aggregate entries\n"
5389 "Aggregate address\n"
5390 "Aggregate mask\n"
5391 "Generate AS set path information\n"
5392 "Filter more specific routes from updates\n")
5393{
5394 int ret;
5395 char prefix_str[BUFSIZ];
5396
5397 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5398
5399 if (! ret)
5400 {
5401 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5402 return CMD_WARNING;
5403 }
5404
5405 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5406 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5407}
5408
5409ALIAS (aggregate_address_mask_as_set_summary,
5410 aggregate_address_mask_summary_as_set_cmd,
5411 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5412 "Configure BGP aggregate entries\n"
5413 "Aggregate address\n"
5414 "Aggregate mask\n"
5415 "Filter more specific routes from updates\n"
5416 "Generate AS set path information\n")
5417
5418DEFUN (no_aggregate_address,
5419 no_aggregate_address_cmd,
5420 "no aggregate-address A.B.C.D/M",
5421 NO_STR
5422 "Configure BGP aggregate entries\n"
5423 "Aggregate prefix\n")
5424{
5425 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5426}
5427
5428ALIAS (no_aggregate_address,
5429 no_aggregate_address_summary_only_cmd,
5430 "no aggregate-address A.B.C.D/M summary-only",
5431 NO_STR
5432 "Configure BGP aggregate entries\n"
5433 "Aggregate prefix\n"
5434 "Filter more specific routes from updates\n")
5435
5436ALIAS (no_aggregate_address,
5437 no_aggregate_address_as_set_cmd,
5438 "no aggregate-address A.B.C.D/M as-set",
5439 NO_STR
5440 "Configure BGP aggregate entries\n"
5441 "Aggregate prefix\n"
5442 "Generate AS set path information\n")
5443
5444ALIAS (no_aggregate_address,
5445 no_aggregate_address_as_set_summary_cmd,
5446 "no aggregate-address A.B.C.D/M as-set summary-only",
5447 NO_STR
5448 "Configure BGP aggregate entries\n"
5449 "Aggregate prefix\n"
5450 "Generate AS set path information\n"
5451 "Filter more specific routes from updates\n")
5452
5453ALIAS (no_aggregate_address,
5454 no_aggregate_address_summary_as_set_cmd,
5455 "no aggregate-address A.B.C.D/M summary-only as-set",
5456 NO_STR
5457 "Configure BGP aggregate entries\n"
5458 "Aggregate prefix\n"
5459 "Filter more specific routes from updates\n"
5460 "Generate AS set path information\n")
5461
5462DEFUN (no_aggregate_address_mask,
5463 no_aggregate_address_mask_cmd,
5464 "no aggregate-address A.B.C.D A.B.C.D",
5465 NO_STR
5466 "Configure BGP aggregate entries\n"
5467 "Aggregate address\n"
5468 "Aggregate mask\n")
5469{
5470 int ret;
5471 char prefix_str[BUFSIZ];
5472
5473 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5474
5475 if (! ret)
5476 {
5477 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5478 return CMD_WARNING;
5479 }
5480
5481 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5482}
5483
5484ALIAS (no_aggregate_address_mask,
5485 no_aggregate_address_mask_summary_only_cmd,
5486 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5487 NO_STR
5488 "Configure BGP aggregate entries\n"
5489 "Aggregate address\n"
5490 "Aggregate mask\n"
5491 "Filter more specific routes from updates\n")
5492
5493ALIAS (no_aggregate_address_mask,
5494 no_aggregate_address_mask_as_set_cmd,
5495 "no aggregate-address A.B.C.D A.B.C.D as-set",
5496 NO_STR
5497 "Configure BGP aggregate entries\n"
5498 "Aggregate address\n"
5499 "Aggregate mask\n"
5500 "Generate AS set path information\n")
5501
5502ALIAS (no_aggregate_address_mask,
5503 no_aggregate_address_mask_as_set_summary_cmd,
5504 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5505 NO_STR
5506 "Configure BGP aggregate entries\n"
5507 "Aggregate address\n"
5508 "Aggregate mask\n"
5509 "Generate AS set path information\n"
5510 "Filter more specific routes from updates\n")
5511
5512ALIAS (no_aggregate_address_mask,
5513 no_aggregate_address_mask_summary_as_set_cmd,
5514 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5515 NO_STR
5516 "Configure BGP aggregate entries\n"
5517 "Aggregate address\n"
5518 "Aggregate mask\n"
5519 "Filter more specific routes from updates\n"
5520 "Generate AS set path information\n")
5521
paul718e3742002-12-13 20:15:29 +00005522DEFUN (ipv6_aggregate_address,
5523 ipv6_aggregate_address_cmd,
5524 "aggregate-address X:X::X:X/M",
5525 "Configure BGP aggregate entries\n"
5526 "Aggregate prefix\n")
5527{
5528 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5529}
5530
5531DEFUN (ipv6_aggregate_address_summary_only,
5532 ipv6_aggregate_address_summary_only_cmd,
5533 "aggregate-address X:X::X:X/M summary-only",
5534 "Configure BGP aggregate entries\n"
5535 "Aggregate prefix\n"
5536 "Filter more specific routes from updates\n")
5537{
5538 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5539 AGGREGATE_SUMMARY_ONLY, 0);
5540}
5541
5542DEFUN (no_ipv6_aggregate_address,
5543 no_ipv6_aggregate_address_cmd,
5544 "no aggregate-address X:X::X:X/M",
5545 NO_STR
5546 "Configure BGP aggregate entries\n"
5547 "Aggregate prefix\n")
5548{
5549 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5550}
5551
5552DEFUN (no_ipv6_aggregate_address_summary_only,
5553 no_ipv6_aggregate_address_summary_only_cmd,
5554 "no aggregate-address X:X::X:X/M summary-only",
5555 NO_STR
5556 "Configure BGP aggregate entries\n"
5557 "Aggregate prefix\n"
5558 "Filter more specific routes from updates\n")
5559{
5560 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5561}
5562
5563ALIAS (ipv6_aggregate_address,
5564 old_ipv6_aggregate_address_cmd,
5565 "ipv6 bgp aggregate-address X:X::X:X/M",
5566 IPV6_STR
5567 BGP_STR
5568 "Configure BGP aggregate entries\n"
5569 "Aggregate prefix\n")
5570
5571ALIAS (ipv6_aggregate_address_summary_only,
5572 old_ipv6_aggregate_address_summary_only_cmd,
5573 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5574 IPV6_STR
5575 BGP_STR
5576 "Configure BGP aggregate entries\n"
5577 "Aggregate prefix\n"
5578 "Filter more specific routes from updates\n")
5579
5580ALIAS (no_ipv6_aggregate_address,
5581 old_no_ipv6_aggregate_address_cmd,
5582 "no ipv6 bgp aggregate-address X:X::X:X/M",
5583 NO_STR
5584 IPV6_STR
5585 BGP_STR
5586 "Configure BGP aggregate entries\n"
5587 "Aggregate prefix\n")
5588
5589ALIAS (no_ipv6_aggregate_address_summary_only,
5590 old_no_ipv6_aggregate_address_summary_only_cmd,
5591 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5592 NO_STR
5593 IPV6_STR
5594 BGP_STR
5595 "Configure BGP aggregate entries\n"
5596 "Aggregate prefix\n"
5597 "Filter more specific routes from updates\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02005598
paul718e3742002-12-13 20:15:29 +00005599/* Redistribute route treatment. */
5600void
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005601bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5602 const struct in6_addr *nexthop6,
paul718e3742002-12-13 20:15:29 +00005603 u_int32_t metric, u_char type)
5604{
5605 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005606 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005607 struct bgp_info *new;
5608 struct bgp_info *bi;
5609 struct bgp_info info;
5610 struct bgp_node *bn;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00005611 struct attr attr;
paul718e3742002-12-13 20:15:29 +00005612 struct attr *new_attr;
5613 afi_t afi;
5614 int ret;
5615
5616 /* Make default attribute. */
5617 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5618 if (nexthop)
5619 attr.nexthop = *nexthop;
5620
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005621 if (nexthop6)
5622 {
5623 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5624 extra->mp_nexthop_global = *nexthop6;
5625 extra->mp_nexthop_len = 16;
5626 }
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005627
paul718e3742002-12-13 20:15:29 +00005628 attr.med = metric;
5629 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
5630
paul1eb8ef22005-04-07 07:30:20 +00005631 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005632 {
5633 afi = family2afi (p->family);
5634
5635 if (bgp->redist[afi][type])
5636 {
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005637 struct attr attr_new;
5638 struct attr_extra extra_new;
5639
paul718e3742002-12-13 20:15:29 +00005640 /* Copy attribute for modification. */
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005641 attr_new.extra = &extra_new;
Paul Jakmafb982c22007-05-04 20:15:47 +00005642 bgp_attr_dup (&attr_new, &attr);
paul718e3742002-12-13 20:15:29 +00005643
5644 if (bgp->redist_metric_flag[afi][type])
5645 attr_new.med = bgp->redist_metric[afi][type];
5646
5647 /* Apply route-map. */
Daniel Walton1994dc82015-09-17 10:15:59 -04005648 if (bgp->rmap[afi][type].name)
paul718e3742002-12-13 20:15:29 +00005649 {
5650 info.peer = bgp->peer_self;
5651 info.attr = &attr_new;
5652
paulfee0f4c2004-09-13 05:12:46 +00005653 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5654
paul718e3742002-12-13 20:15:29 +00005655 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5656 &info);
paulfee0f4c2004-09-13 05:12:46 +00005657
5658 bgp->peer_self->rmap_type = 0;
5659
paul718e3742002-12-13 20:15:29 +00005660 if (ret == RMAP_DENYMATCH)
5661 {
5662 /* Free uninterned attribute. */
5663 bgp_attr_flush (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005664
paul718e3742002-12-13 20:15:29 +00005665 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005666 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005667 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005668 bgp_redistribute_delete (p, type);
5669 return;
5670 }
5671 }
5672
Paul Jakmafb982c22007-05-04 20:15:47 +00005673 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5674 afi, SAFI_UNICAST, p, NULL);
5675
paul718e3742002-12-13 20:15:29 +00005676 new_attr = bgp_attr_intern (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005677
paul718e3742002-12-13 20:15:29 +00005678 for (bi = bn->info; bi; bi = bi->next)
5679 if (bi->peer == bgp->peer_self
5680 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5681 break;
5682
5683 if (bi)
5684 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005685 if (attrhash_cmp (bi->attr, new_attr) &&
5686 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00005687 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005688 bgp_attr_unintern (&new_attr);
5689 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005690 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005691 bgp_unlock_node (bn);
5692 return;
5693 }
5694 else
5695 {
5696 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00005697 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005698
5699 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005700 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5701 bgp_info_restore(bn, bi);
5702 else
5703 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005704 bgp_attr_unintern (&bi->attr);
paul718e3742002-12-13 20:15:29 +00005705 bi->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005706 bi->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005707
5708 /* Process change. */
5709 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5710 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5711 bgp_unlock_node (bn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005712 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005713 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005714 return;
5715 }
5716 }
5717
5718 new = bgp_info_new ();
5719 new->type = type;
5720 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
5721 new->peer = bgp->peer_self;
5722 SET_FLAG (new->flags, BGP_INFO_VALID);
5723 new->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005724 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005725
5726 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5727 bgp_info_add (bn, new);
paul200df112005-06-01 11:17:05 +00005728 bgp_unlock_node (bn);
paul718e3742002-12-13 20:15:29 +00005729 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5730 }
5731 }
5732
5733 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005734 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005735 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005736}
5737
5738void
5739bgp_redistribute_delete (struct prefix *p, u_char type)
5740{
5741 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005742 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005743 afi_t afi;
5744 struct bgp_node *rn;
5745 struct bgp_info *ri;
5746
paul1eb8ef22005-04-07 07:30:20 +00005747 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005748 {
5749 afi = family2afi (p->family);
5750
5751 if (bgp->redist[afi][type])
5752 {
paulfee0f4c2004-09-13 05:12:46 +00005753 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00005754
5755 for (ri = rn->info; ri; ri = ri->next)
5756 if (ri->peer == bgp->peer_self
5757 && ri->type == type)
5758 break;
5759
5760 if (ri)
5761 {
5762 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005763 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005764 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005765 }
5766 bgp_unlock_node (rn);
5767 }
5768 }
5769}
5770
5771/* Withdraw specified route type's route. */
5772void
5773bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5774{
5775 struct bgp_node *rn;
5776 struct bgp_info *ri;
5777 struct bgp_table *table;
5778
5779 table = bgp->rib[afi][SAFI_UNICAST];
5780
5781 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5782 {
5783 for (ri = rn->info; ri; ri = ri->next)
5784 if (ri->peer == bgp->peer_self
5785 && ri->type == type)
5786 break;
5787
5788 if (ri)
5789 {
5790 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005791 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005792 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005793 }
5794 }
5795}
David Lamparter6b0655a2014-06-04 06:53:35 +02005796
paul718e3742002-12-13 20:15:29 +00005797/* Static function to display route. */
paul94f2b392005-06-28 12:44:16 +00005798static void
paul718e3742002-12-13 20:15:29 +00005799route_vty_out_route (struct prefix *p, struct vty *vty)
5800{
5801 int len;
5802 u_int32_t destination;
5803 char buf[BUFSIZ];
5804
5805 if (p->family == AF_INET)
5806 {
5807 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5808 destination = ntohl (p->u.prefix4.s_addr);
5809
5810 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5811 || (IN_CLASSB (destination) && p->prefixlen == 16)
5812 || (IN_CLASSA (destination) && p->prefixlen == 8)
5813 || p->u.prefix4.s_addr == 0)
5814 {
5815 /* When mask is natural, mask is not displayed. */
5816 }
5817 else
5818 len += vty_out (vty, "/%d", p->prefixlen);
5819 }
5820 else
5821 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5822 p->prefixlen);
5823
5824 len = 17 - len;
5825 if (len < 1)
5826 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5827 else
5828 vty_out (vty, "%*s", len, " ");
5829}
5830
paul718e3742002-12-13 20:15:29 +00005831enum bgp_display_type
5832{
5833 normal_list,
5834};
5835
paulb40d9392005-08-22 22:34:41 +00005836/* Print the short form route status for a bgp_info */
5837static void
5838route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
paul718e3742002-12-13 20:15:29 +00005839{
paulb40d9392005-08-22 22:34:41 +00005840 /* Route status display. */
5841 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5842 vty_out (vty, "R");
5843 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
hasso93406d82005-02-02 14:40:33 +00005844 vty_out (vty, "S");
Paul Jakmafb982c22007-05-04 20:15:47 +00005845 else if (binfo->extra && binfo->extra->suppress)
paul718e3742002-12-13 20:15:29 +00005846 vty_out (vty, "s");
5847 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5848 vty_out (vty, "*");
5849 else
5850 vty_out (vty, " ");
5851
5852 /* Selected */
5853 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5854 vty_out (vty, "h");
5855 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5856 vty_out (vty, "d");
5857 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5858 vty_out (vty, ">");
Boian Bonevb366b512013-09-09 16:41:35 +00005859 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5860 vty_out (vty, "=");
paul718e3742002-12-13 20:15:29 +00005861 else
5862 vty_out (vty, " ");
5863
5864 /* Internal route. */
5865 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5866 vty_out (vty, "i");
5867 else
paulb40d9392005-08-22 22:34:41 +00005868 vty_out (vty, " ");
5869}
5870
5871/* called from terminal list command */
5872void
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005873route_vty_out(
5874 struct vty *vty,
5875 struct prefix *p,
5876 struct bgp_info *binfo,
5877 int display,
5878 safi_t safi)
paulb40d9392005-08-22 22:34:41 +00005879{
5880 struct attr *attr;
5881
5882 /* short status lead text */
5883 route_vty_short_status_out (vty, binfo);
paul718e3742002-12-13 20:15:29 +00005884
5885 /* print prefix and mask */
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005886 if (!display)
paul718e3742002-12-13 20:15:29 +00005887 route_vty_out_route (p, vty);
5888 else
5889 vty_out (vty, "%*s", 17, " ");
5890
5891 /* Print attribute */
5892 attr = binfo->attr;
5893 if (attr)
5894 {
paul718e3742002-12-13 20:15:29 +00005895
Lou Berger298cc2f2016-01-12 13:42:02 -05005896 /*
5897 * NEXTHOP start
5898 */
5899
5900 /*
5901 * For ENCAP routes, nexthop address family is not
5902 * neccessarily the same as the prefix address family.
5903 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5904 */
5905 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5906 if (attr->extra) {
5907 char buf[BUFSIZ];
5908 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5909
5910 switch (af) {
5911 case AF_INET:
5912 vty_out (vty, "%s", inet_ntop(af,
5913 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5914 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005915 case AF_INET6:
5916 vty_out (vty, "%s", inet_ntop(af,
5917 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
5918 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005919 default:
5920 vty_out(vty, "?");
5921 }
5922 } else {
5923 vty_out(vty, "?");
paul718e3742002-12-13 20:15:29 +00005924 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005925 } else {
5926
5927 if (p->family == AF_INET)
5928 {
5929 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
5930 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005931 else if (p->family == AF_INET6)
5932 {
5933 int len;
5934 char buf[BUFSIZ];
5935
5936 len = vty_out (vty, "%s",
5937 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
5938 buf, BUFSIZ));
5939 len = 16 - len;
5940 if (len < 1)
5941 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
5942 else
5943 vty_out (vty, "%*s", len, " ");
5944 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005945 else
5946 {
5947 vty_out(vty, "?");
5948 }
5949 }
5950
5951 /*
5952 * NEXTHOP end
5953 */
5954
paul718e3742002-12-13 20:15:29 +00005955
5956 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005957 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00005958 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005959 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00005960
5961 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005962 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00005963 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005964 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00005965
Paul Jakmafb982c22007-05-04 20:15:47 +00005966 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
paul718e3742002-12-13 20:15:29 +00005967
Paul Jakmab2518c12006-05-12 23:48:40 +00005968 /* Print aspath */
5969 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00005970 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00005971
Paul Jakmab2518c12006-05-12 23:48:40 +00005972 /* Print origin */
paul718e3742002-12-13 20:15:29 +00005973 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00005974 }
paul718e3742002-12-13 20:15:29 +00005975 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00005976}
5977
5978/* called from terminal list command */
5979void
5980route_vty_out_tmp (struct vty *vty, struct prefix *p,
5981 struct attr *attr, safi_t safi)
5982{
5983 /* Route status display. */
5984 vty_out (vty, "*");
5985 vty_out (vty, ">");
5986 vty_out (vty, " ");
5987
5988 /* print prefix and mask */
5989 route_vty_out_route (p, vty);
5990
5991 /* Print attribute */
5992 if (attr)
5993 {
5994 if (p->family == AF_INET)
5995 {
Lou Berger298cc2f2016-01-12 13:42:02 -05005996 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00005997 vty_out (vty, "%-16s",
5998 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00005999 else
6000 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6001 }
paul718e3742002-12-13 20:15:29 +00006002 else if (p->family == AF_INET6)
6003 {
6004 int len;
6005 char buf[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006006
6007 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006008
6009 len = vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006010 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6011 buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006012 len = 16 - len;
6013 if (len < 1)
6014 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6015 else
6016 vty_out (vty, "%*s", len, " ");
6017 }
paul718e3742002-12-13 20:15:29 +00006018
6019 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006020 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006021 else
6022 vty_out (vty, " ");
6023
6024 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006025 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006026 else
6027 vty_out (vty, " ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006028
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006029 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
Paul Jakmafb982c22007-05-04 20:15:47 +00006030
Paul Jakmab2518c12006-05-12 23:48:40 +00006031 /* Print aspath */
6032 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006033 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006034
Paul Jakmab2518c12006-05-12 23:48:40 +00006035 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006036 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006037 }
paul718e3742002-12-13 20:15:29 +00006038
6039 vty_out (vty, "%s", VTY_NEWLINE);
6040}
6041
ajs5a646652004-11-05 01:25:55 +00006042void
paul718e3742002-12-13 20:15:29 +00006043route_vty_out_tag (struct vty *vty, struct prefix *p,
6044 struct bgp_info *binfo, int display, safi_t safi)
6045{
6046 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006047 u_int32_t label = 0;
Paul Jakmafb982c22007-05-04 20:15:47 +00006048
6049 if (!binfo->extra)
6050 return;
6051
paulb40d9392005-08-22 22:34:41 +00006052 /* short status lead text */
6053 route_vty_short_status_out (vty, binfo);
6054
paul718e3742002-12-13 20:15:29 +00006055 /* print prefix and mask */
6056 if (! display)
6057 route_vty_out_route (p, vty);
6058 else
6059 vty_out (vty, "%*s", 17, " ");
6060
6061 /* Print attribute */
6062 attr = binfo->attr;
6063 if (attr)
6064 {
6065 if (p->family == AF_INET)
6066 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006067 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006068 vty_out (vty, "%-16s",
6069 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006070 else
6071 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6072 }
paul718e3742002-12-13 20:15:29 +00006073 else if (p->family == AF_INET6)
6074 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006075 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006076 char buf[BUFSIZ];
6077 char buf1[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006078 if (attr->extra->mp_nexthop_len == 16)
paul718e3742002-12-13 20:15:29 +00006079 vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006080 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6081 buf, BUFSIZ));
6082 else if (attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006083 vty_out (vty, "%s(%s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006084 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6085 buf, BUFSIZ),
6086 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6087 buf1, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006088
6089 }
paul718e3742002-12-13 20:15:29 +00006090 }
6091
Paul Jakmafb982c22007-05-04 20:15:47 +00006092 label = decode_label (binfo->extra->tag);
paul718e3742002-12-13 20:15:29 +00006093
6094 vty_out (vty, "notag/%d", label);
6095
6096 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006097}
6098
6099/* dampening route */
ajs5a646652004-11-05 01:25:55 +00006100static void
paul718e3742002-12-13 20:15:29 +00006101damp_route_vty_out (struct vty *vty, struct prefix *p,
6102 struct bgp_info *binfo, int display, safi_t safi)
6103{
6104 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006105 int len;
Chris Caputo50aef6f2009-06-23 06:06:49 +00006106 char timebuf[BGP_UPTIME_LEN];
paul718e3742002-12-13 20:15:29 +00006107
paulb40d9392005-08-22 22:34:41 +00006108 /* short status lead text */
6109 route_vty_short_status_out (vty, binfo);
6110
paul718e3742002-12-13 20:15:29 +00006111 /* print prefix and mask */
6112 if (! display)
6113 route_vty_out_route (p, vty);
6114 else
6115 vty_out (vty, "%*s", 17, " ");
6116
6117 len = vty_out (vty, "%s", binfo->peer->host);
6118 len = 17 - len;
6119 if (len < 1)
6120 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6121 else
6122 vty_out (vty, "%*s", len, " ");
6123
Chris Caputo50aef6f2009-06-23 06:06:49 +00006124 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006125
6126 /* Print attribute */
6127 attr = binfo->attr;
6128 if (attr)
6129 {
6130 /* Print aspath */
6131 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006132 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006133
6134 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006135 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006136 }
6137 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006138}
6139
paul718e3742002-12-13 20:15:29 +00006140/* flap route */
ajs5a646652004-11-05 01:25:55 +00006141static void
paul718e3742002-12-13 20:15:29 +00006142flap_route_vty_out (struct vty *vty, struct prefix *p,
6143 struct bgp_info *binfo, int display, safi_t safi)
6144{
6145 struct attr *attr;
6146 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00006147 char timebuf[BGP_UPTIME_LEN];
6148 int len;
Paul Jakmafb982c22007-05-04 20:15:47 +00006149
6150 if (!binfo->extra)
6151 return;
6152
6153 bdi = binfo->extra->damp_info;
paul718e3742002-12-13 20:15:29 +00006154
paulb40d9392005-08-22 22:34:41 +00006155 /* short status lead text */
6156 route_vty_short_status_out (vty, binfo);
6157
paul718e3742002-12-13 20:15:29 +00006158 /* print prefix and mask */
6159 if (! display)
6160 route_vty_out_route (p, vty);
6161 else
6162 vty_out (vty, "%*s", 17, " ");
6163
6164 len = vty_out (vty, "%s", binfo->peer->host);
6165 len = 16 - len;
6166 if (len < 1)
6167 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6168 else
6169 vty_out (vty, "%*s", len, " ");
6170
6171 len = vty_out (vty, "%d", bdi->flap);
6172 len = 5 - len;
6173 if (len < 1)
6174 vty_out (vty, " ");
6175 else
6176 vty_out (vty, "%*s ", len, " ");
6177
6178 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6179 timebuf, BGP_UPTIME_LEN));
6180
6181 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6182 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
Chris Caputo50aef6f2009-06-23 06:06:49 +00006183 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006184 else
6185 vty_out (vty, "%*s ", 8, " ");
6186
6187 /* Print attribute */
6188 attr = binfo->attr;
6189 if (attr)
6190 {
6191 /* Print aspath */
6192 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006193 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006194
6195 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006196 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006197 }
6198 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006199}
6200
paul94f2b392005-06-28 12:44:16 +00006201static void
paul718e3742002-12-13 20:15:29 +00006202route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6203 struct bgp_info *binfo, afi_t afi, safi_t safi)
6204{
6205 char buf[INET6_ADDRSTRLEN];
6206 char buf1[BUFSIZ];
6207 struct attr *attr;
6208 int sockunion_vty_out (struct vty *, union sockunion *);
John Kemp30b00172011-03-18 17:52:18 +03006209#ifdef HAVE_CLOCK_MONOTONIC
6210 time_t tbuf;
6211#endif
paul718e3742002-12-13 20:15:29 +00006212
6213 attr = binfo->attr;
6214
6215 if (attr)
6216 {
6217 /* Line1 display AS-path, Aggregator */
6218 if (attr->aspath)
6219 {
6220 vty_out (vty, " ");
paulfe69a502005-09-10 16:55:02 +00006221 if (aspath_count_hops (attr->aspath) == 0)
paul718e3742002-12-13 20:15:29 +00006222 vty_out (vty, "Local");
6223 else
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006224 aspath_print_vty (vty, "%s", attr->aspath, "");
paul718e3742002-12-13 20:15:29 +00006225 }
6226
paulb40d9392005-08-22 22:34:41 +00006227 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6228 vty_out (vty, ", (removed)");
hasso93406d82005-02-02 14:40:33 +00006229 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6230 vty_out (vty, ", (stale)");
6231 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006232 vty_out (vty, ", (aggregated by %u %s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006233 attr->extra->aggregator_as,
6234 inet_ntoa (attr->extra->aggregator_addr));
hasso93406d82005-02-02 14:40:33 +00006235 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6236 vty_out (vty, ", (Received from a RR-client)");
6237 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6238 vty_out (vty, ", (Received from a RS-client)");
6239 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6240 vty_out (vty, ", (history entry)");
6241 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6242 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00006243 vty_out (vty, "%s", VTY_NEWLINE);
6244
6245 /* Line2 display Next-hop, Neighbor, Router-id */
6246 if (p->family == AF_INET)
6247 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006248 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
Paul Jakmafb982c22007-05-04 20:15:47 +00006249 inet_ntoa (attr->extra->mp_nexthop_global_in) :
paul718e3742002-12-13 20:15:29 +00006250 inet_ntoa (attr->nexthop));
6251 }
paul718e3742002-12-13 20:15:29 +00006252 else
6253 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006254 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006255 vty_out (vty, " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006256 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
paul718e3742002-12-13 20:15:29 +00006257 buf, INET6_ADDRSTRLEN));
6258 }
paul718e3742002-12-13 20:15:29 +00006259
6260 if (binfo->peer == bgp->peer_self)
6261 {
6262 vty_out (vty, " from %s ",
6263 p->family == AF_INET ? "0.0.0.0" : "::");
6264 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6265 }
6266 else
6267 {
6268 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6269 vty_out (vty, " (inaccessible)");
Paul Jakmafb982c22007-05-04 20:15:47 +00006270 else if (binfo->extra && binfo->extra->igpmetric)
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02006271 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006272 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6273 buf[0] = '?';
6274 buf[1] = 0;
6275 }
6276 vty_out (vty, " from %s", buf);
paul718e3742002-12-13 20:15:29 +00006277 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006278 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006279 else
6280 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6281 }
6282 vty_out (vty, "%s", VTY_NEWLINE);
6283
paul718e3742002-12-13 20:15:29 +00006284 /* display nexthop local */
Paul Jakmafb982c22007-05-04 20:15:47 +00006285 if (attr->extra && attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006286 {
6287 vty_out (vty, " (%s)%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006288 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
paul718e3742002-12-13 20:15:29 +00006289 buf, INET6_ADDRSTRLEN),
6290 VTY_NEWLINE);
6291 }
paul718e3742002-12-13 20:15:29 +00006292
6293 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
6294 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6295
6296 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006297 vty_out (vty, ", metric %u", attr->med);
paul718e3742002-12-13 20:15:29 +00006298
6299 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006300 vty_out (vty, ", localpref %u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006301 else
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006302 vty_out (vty, ", localpref %u", bgp->default_local_pref);
paul718e3742002-12-13 20:15:29 +00006303
Paul Jakmafb982c22007-05-04 20:15:47 +00006304 if (attr->extra && attr->extra->weight != 0)
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006305 vty_out (vty, ", weight %u", attr->extra->weight);
paul718e3742002-12-13 20:15:29 +00006306
6307 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6308 vty_out (vty, ", valid");
6309
6310 if (binfo->peer != bgp->peer_self)
6311 {
6312 if (binfo->peer->as == binfo->peer->local_as)
6313 vty_out (vty, ", internal");
6314 else
6315 vty_out (vty, ", %s",
6316 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6317 }
6318 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6319 vty_out (vty, ", aggregated, local");
6320 else if (binfo->type != ZEBRA_ROUTE_BGP)
6321 vty_out (vty, ", sourced");
6322 else
6323 vty_out (vty, ", sourced, local");
6324
6325 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6326 vty_out (vty, ", atomic-aggregate");
6327
Josh Baileyde8d5df2011-07-20 20:46:01 -07006328 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6329 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6330 bgp_info_mpath_count (binfo)))
6331 vty_out (vty, ", multipath");
6332
paul718e3742002-12-13 20:15:29 +00006333 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6334 vty_out (vty, ", best");
6335
6336 vty_out (vty, "%s", VTY_NEWLINE);
6337
6338 /* Line 4 display Community */
6339 if (attr->community)
6340 vty_out (vty, " Community: %s%s", attr->community->str,
6341 VTY_NEWLINE);
6342
6343 /* Line 5 display Extended-community */
6344 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
Paul Jakmafb982c22007-05-04 20:15:47 +00006345 vty_out (vty, " Extended Community: %s%s",
6346 attr->extra->ecommunity->str, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006347
6348 /* Line 6 display Originator, Cluster-id */
6349 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6350 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6351 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006352 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006353 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006354 vty_out (vty, " Originator: %s",
6355 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006356
6357 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6358 {
6359 int i;
6360 vty_out (vty, ", Cluster list: ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006361 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6362 vty_out (vty, "%s ",
6363 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +00006364 }
6365 vty_out (vty, "%s", VTY_NEWLINE);
6366 }
Paul Jakma41367172007-08-06 15:24:51 +00006367
Paul Jakmafb982c22007-05-04 20:15:47 +00006368 if (binfo->extra && binfo->extra->damp_info)
paul718e3742002-12-13 20:15:29 +00006369 bgp_damp_info_vty (vty, binfo);
6370
6371 /* Line 7 display Uptime */
John Kemp30b00172011-03-18 17:52:18 +03006372#ifdef HAVE_CLOCK_MONOTONIC
6373 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
Vladimir L Ivanov213b6cd2010-10-21 14:59:54 +04006374 vty_out (vty, " Last update: %s", ctime(&tbuf));
John Kemp30b00172011-03-18 17:52:18 +03006375#else
6376 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6377#endif /* HAVE_CLOCK_MONOTONIC */
paul718e3742002-12-13 20:15:29 +00006378 }
6379 vty_out (vty, "%s", VTY_NEWLINE);
Boian Bonevb366b512013-09-09 16:41:35 +00006380}
6381
6382#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6383 "h history, * valid, > best, = multipath,%s"\
6384 " i internal, r RIB-failure, S Stale, R Removed%s"
hasso93406d82005-02-02 14:40:33 +00006385#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00006386#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6387#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6388#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6389
6390enum bgp_show_type
6391{
6392 bgp_show_type_normal,
6393 bgp_show_type_regexp,
6394 bgp_show_type_prefix_list,
6395 bgp_show_type_filter_list,
6396 bgp_show_type_route_map,
6397 bgp_show_type_neighbor,
6398 bgp_show_type_cidr_only,
6399 bgp_show_type_prefix_longer,
6400 bgp_show_type_community_all,
6401 bgp_show_type_community,
6402 bgp_show_type_community_exact,
6403 bgp_show_type_community_list,
6404 bgp_show_type_community_list_exact,
6405 bgp_show_type_flap_statistics,
6406 bgp_show_type_flap_address,
6407 bgp_show_type_flap_prefix,
6408 bgp_show_type_flap_cidr_only,
6409 bgp_show_type_flap_regexp,
6410 bgp_show_type_flap_filter_list,
6411 bgp_show_type_flap_prefix_list,
6412 bgp_show_type_flap_prefix_longer,
6413 bgp_show_type_flap_route_map,
6414 bgp_show_type_flap_neighbor,
6415 bgp_show_type_dampend_paths,
6416 bgp_show_type_damp_neighbor
6417};
6418
ajs5a646652004-11-05 01:25:55 +00006419static int
paulfee0f4c2004-09-13 05:12:46 +00006420bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00006421 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00006422{
paul718e3742002-12-13 20:15:29 +00006423 struct bgp_info *ri;
6424 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00006425 int header = 1;
paul718e3742002-12-13 20:15:29 +00006426 int display;
ajs5a646652004-11-05 01:25:55 +00006427 unsigned long output_count;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006428 unsigned long total_count;
paul718e3742002-12-13 20:15:29 +00006429
6430 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00006431 output_count = 0;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006432 total_count = 0;
paul718e3742002-12-13 20:15:29 +00006433
paul718e3742002-12-13 20:15:29 +00006434 /* Start processing of routes. */
6435 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6436 if (rn->info != NULL)
6437 {
6438 display = 0;
6439
6440 for (ri = rn->info; ri; ri = ri->next)
6441 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006442 total_count++;
ajs5a646652004-11-05 01:25:55 +00006443 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00006444 || type == bgp_show_type_flap_address
6445 || type == bgp_show_type_flap_prefix
6446 || type == bgp_show_type_flap_cidr_only
6447 || type == bgp_show_type_flap_regexp
6448 || type == bgp_show_type_flap_filter_list
6449 || type == bgp_show_type_flap_prefix_list
6450 || type == bgp_show_type_flap_prefix_longer
6451 || type == bgp_show_type_flap_route_map
6452 || type == bgp_show_type_flap_neighbor
6453 || type == bgp_show_type_dampend_paths
6454 || type == bgp_show_type_damp_neighbor)
6455 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006456 if (!(ri->extra && ri->extra->damp_info))
paul718e3742002-12-13 20:15:29 +00006457 continue;
6458 }
6459 if (type == bgp_show_type_regexp
6460 || type == bgp_show_type_flap_regexp)
6461 {
ajs5a646652004-11-05 01:25:55 +00006462 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00006463
6464 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6465 continue;
6466 }
6467 if (type == bgp_show_type_prefix_list
6468 || type == bgp_show_type_flap_prefix_list)
6469 {
ajs5a646652004-11-05 01:25:55 +00006470 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00006471
6472 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6473 continue;
6474 }
6475 if (type == bgp_show_type_filter_list
6476 || type == bgp_show_type_flap_filter_list)
6477 {
ajs5a646652004-11-05 01:25:55 +00006478 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00006479
6480 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6481 continue;
6482 }
6483 if (type == bgp_show_type_route_map
6484 || type == bgp_show_type_flap_route_map)
6485 {
ajs5a646652004-11-05 01:25:55 +00006486 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00006487 struct bgp_info binfo;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006488 struct attr dummy_attr;
6489 struct attr_extra dummy_extra;
paul718e3742002-12-13 20:15:29 +00006490 int ret;
6491
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006492 dummy_attr.extra = &dummy_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00006493 bgp_attr_dup (&dummy_attr, ri->attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006494
paul718e3742002-12-13 20:15:29 +00006495 binfo.peer = ri->peer;
6496 binfo.attr = &dummy_attr;
6497
6498 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
paul718e3742002-12-13 20:15:29 +00006499 if (ret == RMAP_DENYMATCH)
6500 continue;
6501 }
6502 if (type == bgp_show_type_neighbor
6503 || type == bgp_show_type_flap_neighbor
6504 || type == bgp_show_type_damp_neighbor)
6505 {
ajs5a646652004-11-05 01:25:55 +00006506 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00006507
6508 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6509 continue;
6510 }
6511 if (type == bgp_show_type_cidr_only
6512 || type == bgp_show_type_flap_cidr_only)
6513 {
6514 u_int32_t destination;
6515
6516 destination = ntohl (rn->p.u.prefix4.s_addr);
6517 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6518 continue;
6519 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6520 continue;
6521 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6522 continue;
6523 }
6524 if (type == bgp_show_type_prefix_longer
6525 || type == bgp_show_type_flap_prefix_longer)
6526 {
ajs5a646652004-11-05 01:25:55 +00006527 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006528
6529 if (! prefix_match (p, &rn->p))
6530 continue;
6531 }
6532 if (type == bgp_show_type_community_all)
6533 {
6534 if (! ri->attr->community)
6535 continue;
6536 }
6537 if (type == bgp_show_type_community)
6538 {
ajs5a646652004-11-05 01:25:55 +00006539 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006540
6541 if (! ri->attr->community ||
6542 ! community_match (ri->attr->community, com))
6543 continue;
6544 }
6545 if (type == bgp_show_type_community_exact)
6546 {
ajs5a646652004-11-05 01:25:55 +00006547 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006548
6549 if (! ri->attr->community ||
6550 ! community_cmp (ri->attr->community, com))
6551 continue;
6552 }
6553 if (type == bgp_show_type_community_list)
6554 {
ajs5a646652004-11-05 01:25:55 +00006555 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006556
6557 if (! community_list_match (ri->attr->community, list))
6558 continue;
6559 }
6560 if (type == bgp_show_type_community_list_exact)
6561 {
ajs5a646652004-11-05 01:25:55 +00006562 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006563
6564 if (! community_list_exact_match (ri->attr->community, list))
6565 continue;
6566 }
6567 if (type == bgp_show_type_flap_address
6568 || type == bgp_show_type_flap_prefix)
6569 {
ajs5a646652004-11-05 01:25:55 +00006570 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006571
6572 if (! prefix_match (&rn->p, p))
6573 continue;
6574
6575 if (type == bgp_show_type_flap_prefix)
6576 if (p->prefixlen != rn->p.prefixlen)
6577 continue;
6578 }
6579 if (type == bgp_show_type_dampend_paths
6580 || type == bgp_show_type_damp_neighbor)
6581 {
6582 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6583 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6584 continue;
6585 }
6586
6587 if (header)
6588 {
hasso93406d82005-02-02 14:40:33 +00006589 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6590 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6591 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006592 if (type == bgp_show_type_dampend_paths
6593 || type == bgp_show_type_damp_neighbor)
6594 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6595 else if (type == bgp_show_type_flap_statistics
6596 || type == bgp_show_type_flap_address
6597 || type == bgp_show_type_flap_prefix
6598 || type == bgp_show_type_flap_cidr_only
6599 || type == bgp_show_type_flap_regexp
6600 || type == bgp_show_type_flap_filter_list
6601 || type == bgp_show_type_flap_prefix_list
6602 || type == bgp_show_type_flap_prefix_longer
6603 || type == bgp_show_type_flap_route_map
6604 || type == bgp_show_type_flap_neighbor)
6605 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6606 else
6607 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006608 header = 0;
6609 }
6610
6611 if (type == bgp_show_type_dampend_paths
6612 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00006613 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006614 else if (type == bgp_show_type_flap_statistics
6615 || type == bgp_show_type_flap_address
6616 || type == bgp_show_type_flap_prefix
6617 || type == bgp_show_type_flap_cidr_only
6618 || type == bgp_show_type_flap_regexp
6619 || type == bgp_show_type_flap_filter_list
6620 || type == bgp_show_type_flap_prefix_list
6621 || type == bgp_show_type_flap_prefix_longer
6622 || type == bgp_show_type_flap_route_map
6623 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00006624 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006625 else
ajs5a646652004-11-05 01:25:55 +00006626 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006627 display++;
6628 }
6629 if (display)
ajs5a646652004-11-05 01:25:55 +00006630 output_count++;
paul718e3742002-12-13 20:15:29 +00006631 }
6632
6633 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00006634 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00006635 {
6636 if (type == bgp_show_type_normal)
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006637 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006638 }
6639 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006640 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6641 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006642
6643 return CMD_SUCCESS;
6644}
6645
ajs5a646652004-11-05 01:25:55 +00006646static int
paulfee0f4c2004-09-13 05:12:46 +00006647bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00006648 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00006649{
6650 struct bgp_table *table;
6651
6652 if (bgp == NULL) {
6653 bgp = bgp_get_default ();
6654 }
6655
6656 if (bgp == NULL)
6657 {
6658 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6659 return CMD_WARNING;
6660 }
6661
6662
6663 table = bgp->rib[afi][safi];
6664
ajs5a646652004-11-05 01:25:55 +00006665 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00006666}
6667
paul718e3742002-12-13 20:15:29 +00006668/* Header of detailed BGP route information */
paul94f2b392005-06-28 12:44:16 +00006669static void
paul718e3742002-12-13 20:15:29 +00006670route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6671 struct bgp_node *rn,
6672 struct prefix_rd *prd, afi_t afi, safi_t safi)
6673{
6674 struct bgp_info *ri;
6675 struct prefix *p;
6676 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006677 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00006678 char buf1[INET6_ADDRSTRLEN];
6679 char buf2[INET6_ADDRSTRLEN];
6680 int count = 0;
6681 int best = 0;
6682 int suppress = 0;
6683 int no_export = 0;
6684 int no_advertise = 0;
6685 int local_as = 0;
6686 int first = 0;
Lou Berger298cc2f2016-01-12 13:42:02 -05006687 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
paul718e3742002-12-13 20:15:29 +00006688
6689 p = &rn->p;
6690 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
Lou Berger298cc2f2016-01-12 13:42:02 -05006691 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6692 printrd ? ":" : "",
paul718e3742002-12-13 20:15:29 +00006693 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6694 p->prefixlen, VTY_NEWLINE);
6695
6696 for (ri = rn->info; ri; ri = ri->next)
6697 {
6698 count++;
6699 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6700 {
6701 best = count;
Paul Jakmafb982c22007-05-04 20:15:47 +00006702 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00006703 suppress = 1;
6704 if (ri->attr->community != NULL)
6705 {
6706 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6707 no_advertise = 1;
6708 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6709 no_export = 1;
6710 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6711 local_as = 1;
6712 }
6713 }
6714 }
6715
6716 vty_out (vty, "Paths: (%d available", count);
6717 if (best)
6718 {
6719 vty_out (vty, ", best #%d", best);
6720 if (safi == SAFI_UNICAST)
6721 vty_out (vty, ", table Default-IP-Routing-Table");
6722 }
6723 else
6724 vty_out (vty, ", no best path");
6725 if (no_advertise)
6726 vty_out (vty, ", not advertised to any peer");
6727 else if (no_export)
6728 vty_out (vty, ", not advertised to EBGP peer");
6729 else if (local_as)
6730 vty_out (vty, ", not advertised outside local AS");
6731 if (suppress)
6732 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6733 vty_out (vty, ")%s", VTY_NEWLINE);
6734
6735 /* advertised peer */
paul1eb8ef22005-04-07 07:30:20 +00006736 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006737 {
6738 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6739 {
6740 if (! first)
6741 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6742 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6743 first = 1;
6744 }
6745 }
6746 if (! first)
6747 vty_out (vty, " Not advertised to any peer");
6748 vty_out (vty, "%s", VTY_NEWLINE);
6749}
6750
6751/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +00006752static int
paulfee0f4c2004-09-13 05:12:46 +00006753bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00006754 struct bgp_table *rib, const char *ip_str,
6755 afi_t afi, safi_t safi, struct prefix_rd *prd,
6756 int prefix_check)
paul718e3742002-12-13 20:15:29 +00006757{
6758 int ret;
6759 int header;
6760 int display = 0;
6761 struct prefix match;
6762 struct bgp_node *rn;
6763 struct bgp_node *rm;
6764 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00006765 struct bgp_table *table;
6766
Lou Berger050defe2016-01-12 13:41:59 -05006767 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
paul718e3742002-12-13 20:15:29 +00006768 /* Check IP address argument. */
6769 ret = str2prefix (ip_str, &match);
6770 if (! ret)
6771 {
6772 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6773 return CMD_WARNING;
6774 }
6775
6776 match.family = afi2family (afi);
6777
Lou Berger298cc2f2016-01-12 13:42:02 -05006778 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00006779 {
paulfee0f4c2004-09-13 05:12:46 +00006780 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00006781 {
6782 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6783 continue;
6784
6785 if ((table = rn->info) != NULL)
6786 {
6787 header = 1;
6788
6789 if ((rm = bgp_node_match (table, &match)) != NULL)
6790 {
6791 if (prefix_check && rm->p.prefixlen != match.prefixlen)
Chris Caputo6c88b442010-07-27 16:28:55 +00006792 {
6793 bgp_unlock_node (rm);
6794 continue;
6795 }
paul718e3742002-12-13 20:15:29 +00006796
6797 for (ri = rm->info; ri; ri = ri->next)
6798 {
6799 if (header)
6800 {
6801 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
Lou Berger298cc2f2016-01-12 13:42:02 -05006802 AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006803
6804 header = 0;
6805 }
6806 display++;
Lou Berger298cc2f2016-01-12 13:42:02 -05006807 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006808 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006809
6810 bgp_unlock_node (rm);
paul718e3742002-12-13 20:15:29 +00006811 }
6812 }
6813 }
6814 }
6815 else
6816 {
6817 header = 1;
6818
paulfee0f4c2004-09-13 05:12:46 +00006819 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00006820 {
6821 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6822 {
6823 for (ri = rn->info; ri; ri = ri->next)
6824 {
6825 if (header)
6826 {
6827 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6828 header = 0;
6829 }
6830 display++;
6831 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
6832 }
6833 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006834
6835 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00006836 }
6837 }
6838
6839 if (! display)
6840 {
6841 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6842 return CMD_WARNING;
6843 }
6844
6845 return CMD_SUCCESS;
6846}
6847
paulfee0f4c2004-09-13 05:12:46 +00006848/* Display specified route of Main RIB */
paul94f2b392005-06-28 12:44:16 +00006849static int
paulfd79ac92004-10-13 05:06:08 +00006850bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00006851 afi_t afi, safi_t safi, struct prefix_rd *prd,
6852 int prefix_check)
6853{
6854 struct bgp *bgp;
6855
6856 /* BGP structure lookup. */
6857 if (view_name)
6858 {
6859 bgp = bgp_lookup_by_name (view_name);
6860 if (bgp == NULL)
6861 {
6862 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6863 return CMD_WARNING;
6864 }
6865 }
6866 else
6867 {
6868 bgp = bgp_get_default ();
6869 if (bgp == NULL)
6870 {
6871 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6872 return CMD_WARNING;
6873 }
6874 }
6875
6876 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
6877 afi, safi, prd, prefix_check);
6878}
6879
paul718e3742002-12-13 20:15:29 +00006880/* BGP route print out function. */
Lou Bergerf9b6c392016-01-12 13:42:09 -05006881DEFUN (show_ip_bgp,
6882 show_ip_bgp_cmd,
6883 "show ip bgp",
6884 SHOW_STR
6885 IP_STR
6886 BGP_STR)
6887{
6888 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6889}
6890
6891DEFUN (show_ip_bgp_ipv4,
6892 show_ip_bgp_ipv4_cmd,
6893 "show ip bgp ipv4 (unicast|multicast)",
6894 SHOW_STR
6895 IP_STR
6896 BGP_STR
6897 "Address family\n"
6898 "Address Family modifier\n"
6899 "Address Family modifier\n")
6900{
6901 if (strncmp (argv[0], "m", 1) == 0)
6902 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
6903 NULL);
6904
6905 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6906}
6907
6908DEFUN (show_ip_bgp_route,
6909 show_ip_bgp_route_cmd,
6910 "show ip bgp A.B.C.D",
6911 SHOW_STR
6912 IP_STR
6913 BGP_STR
6914 "Network in the BGP routing table to display\n")
6915{
6916 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
6917}
6918
6919DEFUN (show_ip_bgp_ipv4_route,
6920 show_ip_bgp_ipv4_route_cmd,
6921 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6922 SHOW_STR
6923 IP_STR
6924 BGP_STR
6925 "Address family\n"
6926 "Address Family modifier\n"
6927 "Address Family modifier\n"
6928 "Network in the BGP routing table to display\n")
6929{
6930 if (strncmp (argv[0], "m", 1) == 0)
6931 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
6932
6933 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
6934}
6935
6936DEFUN (show_ip_bgp_vpnv4_all_route,
6937 show_ip_bgp_vpnv4_all_route_cmd,
6938 "show ip bgp vpnv4 all A.B.C.D",
6939 SHOW_STR
6940 IP_STR
6941 BGP_STR
6942 "Display VPNv4 NLRI specific information\n"
6943 "Display information about all VPNv4 NLRIs\n"
6944 "Network in the BGP routing table to display\n")
6945{
6946 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
6947}
6948
6949DEFUN (show_ip_bgp_vpnv4_rd_route,
6950 show_ip_bgp_vpnv4_rd_route_cmd,
6951 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6952 SHOW_STR
6953 IP_STR
6954 BGP_STR
6955 "Display VPNv4 NLRI specific information\n"
6956 "Display information for a route distinguisher\n"
6957 "VPN Route Distinguisher\n"
6958 "Network in the BGP routing table to display\n")
6959{
6960 int ret;
6961 struct prefix_rd prd;
6962
6963 ret = str2prefix_rd (argv[0], &prd);
6964 if (! ret)
6965 {
6966 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
6967 return CMD_WARNING;
6968 }
6969 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
6970}
6971
6972DEFUN (show_ip_bgp_prefix,
6973 show_ip_bgp_prefix_cmd,
6974 "show ip bgp A.B.C.D/M",
6975 SHOW_STR
6976 IP_STR
6977 BGP_STR
6978 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6979{
6980 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
6981}
6982
6983DEFUN (show_ip_bgp_ipv4_prefix,
6984 show_ip_bgp_ipv4_prefix_cmd,
6985 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6986 SHOW_STR
6987 IP_STR
6988 BGP_STR
6989 "Address family\n"
6990 "Address Family modifier\n"
6991 "Address Family modifier\n"
6992 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6993{
6994 if (strncmp (argv[0], "m", 1) == 0)
6995 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
6996
6997 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
6998}
6999
7000DEFUN (show_ip_bgp_vpnv4_all_prefix,
7001 show_ip_bgp_vpnv4_all_prefix_cmd,
7002 "show ip bgp vpnv4 all A.B.C.D/M",
7003 SHOW_STR
7004 IP_STR
7005 BGP_STR
7006 "Display VPNv4 NLRI specific information\n"
7007 "Display information about all VPNv4 NLRIs\n"
7008 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7009{
7010 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
7011}
7012
7013DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7014 show_ip_bgp_vpnv4_rd_prefix_cmd,
7015 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7016 SHOW_STR
7017 IP_STR
7018 BGP_STR
7019 "Display VPNv4 NLRI specific information\n"
7020 "Display information for a route distinguisher\n"
7021 "VPN Route Distinguisher\n"
7022 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7023{
7024 int ret;
7025 struct prefix_rd prd;
7026
7027 ret = str2prefix_rd (argv[0], &prd);
7028 if (! ret)
7029 {
7030 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7031 return CMD_WARNING;
7032 }
7033 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
7034}
7035
7036DEFUN (show_ip_bgp_view,
7037 show_ip_bgp_view_cmd,
7038 "show ip bgp view WORD",
7039 SHOW_STR
7040 IP_STR
7041 BGP_STR
7042 "BGP view\n"
7043 "View name\n")
7044{
7045 struct bgp *bgp;
7046
7047 /* BGP structure lookup. */
7048 bgp = bgp_lookup_by_name (argv[0]);
7049 if (bgp == NULL)
7050 {
7051 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7052 return CMD_WARNING;
7053 }
7054
7055 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7056}
7057
7058DEFUN (show_ip_bgp_view_route,
7059 show_ip_bgp_view_route_cmd,
7060 "show ip bgp view WORD A.B.C.D",
7061 SHOW_STR
7062 IP_STR
7063 BGP_STR
7064 "BGP view\n"
7065 "View name\n"
7066 "Network in the BGP routing table to display\n")
7067{
7068 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7069}
7070
7071DEFUN (show_ip_bgp_view_prefix,
7072 show_ip_bgp_view_prefix_cmd,
7073 "show ip bgp view WORD A.B.C.D/M",
7074 SHOW_STR
7075 IP_STR
7076 BGP_STR
7077 "BGP view\n"
7078 "View name\n"
7079 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7080{
7081 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7082}
7083
7084DEFUN (show_bgp,
7085 show_bgp_cmd,
7086 "show bgp",
7087 SHOW_STR
7088 BGP_STR)
7089{
7090 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7091 NULL);
7092}
7093
7094ALIAS (show_bgp,
7095 show_bgp_ipv6_cmd,
7096 "show bgp ipv6",
7097 SHOW_STR
7098 BGP_STR
7099 "Address family\n")
7100
7101/* old command */
7102DEFUN (show_ipv6_bgp,
7103 show_ipv6_bgp_cmd,
7104 "show ipv6 bgp",
7105 SHOW_STR
7106 IP_STR
7107 BGP_STR)
7108{
7109 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7110 NULL);
7111}
7112
7113DEFUN (show_bgp_route,
7114 show_bgp_route_cmd,
7115 "show bgp X:X::X:X",
7116 SHOW_STR
7117 BGP_STR
7118 "Network in the BGP routing table to display\n")
7119{
7120 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7121}
7122
Lou Berger35c36862016-01-12 13:42:06 -05007123DEFUN (show_bgp_ipv4_safi,
7124 show_bgp_ipv4_safi_cmd,
7125 "show bgp ipv4 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00007126 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007127 BGP_STR
7128 "Address family\n"
7129 "Address Family modifier\n"
7130 "Address Family modifier\n")
7131{
7132 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00007133 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7134 NULL);
paul718e3742002-12-13 20:15:29 +00007135
ajs5a646652004-11-05 01:25:55 +00007136 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00007137}
7138
Lou Berger35c36862016-01-12 13:42:06 -05007139DEFUN (show_bgp_ipv4_safi_route,
7140 show_bgp_ipv4_safi_route_cmd,
7141 "show bgp ipv4 (unicast|multicast) A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007142 SHOW_STR
7143 BGP_STR
7144 "Address family\n"
7145 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00007146 "Address Family modifier\n"
7147 "Network in the BGP routing table to display\n")
7148{
7149 if (strncmp (argv[0], "m", 1) == 0)
7150 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
7151
7152 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7153}
7154
Lou Berger35c36862016-01-12 13:42:06 -05007155DEFUN (show_bgp_ipv4_vpn_route,
7156 show_bgp_ipv4_vpn_route_cmd,
7157 "show bgp ipv4 vpn A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007158 SHOW_STR
7159 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007160 "Address Family\n"
7161 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007162 "Network in the BGP routing table to display\n")
7163{
7164 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
7165}
7166
Lou Berger35c36862016-01-12 13:42:06 -05007167DEFUN (show_bgp_ipv6_vpn_route,
7168 show_bgp_ipv6_vpn_route_cmd,
7169 "show bgp ipv6 vpn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007170 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007171 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007172 "Address Family\n"
7173 "Display VPN NLRI specific information\n"
7174 "Network in the BGP routing table to display\n")
7175{
7176 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0);
7177}
Lou Berger35c36862016-01-12 13:42:06 -05007178
7179DEFUN (show_bgp_ipv4_vpn_rd_route,
7180 show_bgp_ipv4_vpn_rd_route_cmd,
7181 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7182 SHOW_STR
7183 BGP_STR
7184 IP_STR
7185 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007186 "Display information for a route distinguisher\n"
7187 "VPN Route Distinguisher\n"
7188 "Network in the BGP routing table to display\n")
7189{
7190 int ret;
7191 struct prefix_rd prd;
7192
7193 ret = str2prefix_rd (argv[0], &prd);
7194 if (! ret)
7195 {
7196 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7197 return CMD_WARNING;
7198 }
7199 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
7200}
7201
Lou Berger35c36862016-01-12 13:42:06 -05007202DEFUN (show_bgp_ipv6_vpn_rd_route,
7203 show_bgp_ipv6_vpn_rd_route_cmd,
7204 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007205 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007206 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007207 "Address Family\n"
7208 "Display VPN NLRI specific information\n"
7209 "Display information for a route distinguisher\n"
7210 "VPN Route Distinguisher\n"
7211 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007212{
Lou Berger35c36862016-01-12 13:42:06 -05007213 int ret;
7214 struct prefix_rd prd;
7215
7216 ret = str2prefix_rd (argv[0], &prd);
7217 if (! ret)
7218 {
7219 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7220 return CMD_WARNING;
7221 }
7222 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007223}
7224
Lou Berger651b4022016-01-12 13:42:07 -05007225DEFUN (show_bgp_ipv4_encap_route,
7226 show_bgp_ipv4_encap_route_cmd,
7227 "show bgp ipv4 encap A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007228 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007229 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007230 IP_STR
7231 "Display ENCAP NLRI specific information\n"
7232 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007233{
Lou Berger651b4022016-01-12 13:42:07 -05007234 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007235}
7236
Lou Berger651b4022016-01-12 13:42:07 -05007237DEFUN (show_bgp_ipv6_encap_route,
7238 show_bgp_ipv6_encap_route_cmd,
7239 "show bgp ipv6 encap X:X::X:X",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007240 SHOW_STR
7241 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007242 IP6_STR
7243 "Display ENCAP NLRI specific information\n"
7244 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007245{
Lou Berger651b4022016-01-12 13:42:07 -05007246 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007247}
7248
Lou Berger651b4022016-01-12 13:42:07 -05007249DEFUN (show_bgp_ipv4_safi_rd_route,
7250 show_bgp_ipv4_safi_rd_route_cmd,
7251 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007252 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007253 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007254 "Address Family\n"
7255 "Address Family Modifier\n"
7256 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007257 "Display information for a route distinguisher\n"
Lou Berger651b4022016-01-12 13:42:07 -05007258 "ENCAP Route Distinguisher\n"
7259 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007260{
7261 int ret;
7262 struct prefix_rd prd;
Lou Berger651b4022016-01-12 13:42:07 -05007263 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007264
Lou Berger651b4022016-01-12 13:42:07 -05007265 if (bgp_parse_safi(argv[0], &safi)) {
7266 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7267 return CMD_WARNING;
7268 }
7269 ret = str2prefix_rd (argv[1], &prd);
paul718e3742002-12-13 20:15:29 +00007270 if (! ret)
7271 {
7272 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7273 return CMD_WARNING;
7274 }
Lou Berger651b4022016-01-12 13:42:07 -05007275 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007276}
7277
Lou Berger651b4022016-01-12 13:42:07 -05007278DEFUN (show_bgp_ipv6_safi_rd_route,
7279 show_bgp_ipv6_safi_rd_route_cmd,
7280 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007281 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007282 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007283 "Address Family\n"
7284 "Address Family Modifier\n"
7285 "Address Family Modifier\n"
7286 "Display information for a route distinguisher\n"
7287 "ENCAP Route Distinguisher\n"
7288 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007289{
Lou Berger651b4022016-01-12 13:42:07 -05007290 int ret;
7291 struct prefix_rd prd;
7292 safi_t safi;
paulbb46e942003-10-24 19:02:03 +00007293
Lou Berger651b4022016-01-12 13:42:07 -05007294 if (bgp_parse_safi(argv[0], &safi)) {
7295 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7296 return CMD_WARNING;
7297 }
7298 ret = str2prefix_rd (argv[1], &prd);
7299 if (! ret)
7300 {
7301 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7302 return CMD_WARNING;
7303 }
7304 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007305}
7306
Lou Berger35c36862016-01-12 13:42:06 -05007307DEFUN (show_bgp_ipv4_prefix,
7308 show_bgp_ipv4_prefix_cmd,
7309 "show bgp ipv4 A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007310 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007311 BGP_STR
paul718e3742002-12-13 20:15:29 +00007312 IP_STR
paul718e3742002-12-13 20:15:29 +00007313 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7314{
Lou Berger35c36862016-01-12 13:42:06 -05007315 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007316}
7317
Lou Berger35c36862016-01-12 13:42:06 -05007318DEFUN (show_bgp_ipv4_safi_prefix,
7319 show_bgp_ipv4_safi_prefix_cmd,
7320 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007321 SHOW_STR
7322 BGP_STR
7323 "Address family\n"
7324 "Address Family modifier\n"
Lou Berger35c36862016-01-12 13:42:06 -05007325 "Address Family modifier\n"
7326 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04007327{
7328 if (strncmp (argv[0], "m", 1) == 0)
Lou Berger35c36862016-01-12 13:42:06 -05007329 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007330
Lou Berger35c36862016-01-12 13:42:06 -05007331 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007332}
7333
Lou Berger35c36862016-01-12 13:42:06 -05007334DEFUN (show_bgp_ipv4_vpn_prefix,
7335 show_bgp_ipv4_vpn_prefix_cmd,
7336 "show bgp ipv4 vpn A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007337 SHOW_STR
7338 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007339 IP_STR
7340 "Display VPN NLRI specific information\n"
7341 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +00007342{
Lou Berger35c36862016-01-12 13:42:06 -05007343 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007344}
7345
Lou Berger35c36862016-01-12 13:42:06 -05007346DEFUN (show_bgp_ipv6_vpn_prefix,
7347 show_bgp_ipv6_vpn_prefix_cmd,
7348 "show bgp ipv6 vpn X:X::X:X/M",
7349 SHOW_STR
7350 BGP_STR
7351 "Address Family\n"
7352 "Display VPN NLRI specific information\n"
7353 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7354{
7355 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1);
7356}
Lou Berger35c36862016-01-12 13:42:06 -05007357
Lou Berger651b4022016-01-12 13:42:07 -05007358DEFUN (show_bgp_ipv4_encap_prefix,
7359 show_bgp_ipv4_encap_prefix_cmd,
7360 "show bgp ipv4 encap A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007361 SHOW_STR
7362 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007363 IP_STR
7364 "Display ENCAP NLRI specific information\n"
7365 "Display information about ENCAP NLRIs\n"
7366 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7367{
7368 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1);
7369}
paul718e3742002-12-13 20:15:29 +00007370
Lou Berger651b4022016-01-12 13:42:07 -05007371DEFUN (show_bgp_ipv6_encap_prefix,
7372 show_bgp_ipv6_encap_prefix_cmd,
7373 "show bgp ipv6 encap X:X::X:X/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007374 SHOW_STR
7375 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007376 IP_STR
7377 "Display ENCAP NLRI specific information\n"
7378 "Display information about ENCAP NLRIs\n"
7379 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7380{
7381 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1);
7382}
Lou Berger651b4022016-01-12 13:42:07 -05007383
7384DEFUN (show_bgp_ipv4_safi_rd_prefix,
7385 show_bgp_ipv4_safi_rd_prefix_cmd,
7386 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7387 SHOW_STR
7388 BGP_STR
7389 "Address Family\n"
7390 "Address Family Modifier\n"
7391 "Address Family Modifier\n"
7392 "Display information for a route distinguisher\n"
7393 "ENCAP Route Distinguisher\n"
7394 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7395{
7396 int ret;
7397 struct prefix_rd prd;
7398 safi_t safi;
7399
7400 if (bgp_parse_safi(argv[0], &safi)) {
7401 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7402 return CMD_WARNING;
7403 }
7404
7405 ret = str2prefix_rd (argv[1], &prd);
7406 if (! ret)
7407 {
7408 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7409 return CMD_WARNING;
7410 }
7411 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1);
7412}
7413
Lou Berger651b4022016-01-12 13:42:07 -05007414DEFUN (show_bgp_ipv6_safi_rd_prefix,
7415 show_bgp_ipv6_safi_rd_prefix_cmd,
7416 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7417 SHOW_STR
7418 BGP_STR
7419 "Address Family\n"
7420 "Address Family Modifier\n"
7421 "Address Family Modifier\n"
7422 "Display information for a route distinguisher\n"
7423 "ENCAP Route Distinguisher\n"
7424 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7425{
7426 int ret;
7427 struct prefix_rd prd;
7428 safi_t safi;
7429
7430 if (bgp_parse_safi(argv[0], &safi)) {
7431 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7432 return CMD_WARNING;
7433 }
7434
7435 ret = str2prefix_rd (argv[1], &prd);
7436 if (! ret)
7437 {
7438 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7439 return CMD_WARNING;
7440 }
7441 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1);
7442}
Lou Berger651b4022016-01-12 13:42:07 -05007443
7444DEFUN (show_bgp_afi_safi_view,
7445 show_bgp_afi_safi_view_cmd,
7446 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7447 SHOW_STR
7448 BGP_STR
7449 "BGP view\n"
7450 "BGP view name\n"
7451 "Address Family\n"
7452 "Address Family\n"
7453 "Address Family Modifier\n"
7454 "Address Family Modifier\n"
7455 "Address Family Modifier\n"
7456 "Address Family Modifier\n"
7457 )
7458{
7459 struct bgp *bgp;
7460 safi_t safi;
7461 afi_t afi;
7462
7463 if (bgp_parse_afi(argv[1], &afi)) {
7464 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7465 return CMD_WARNING;
7466 }
7467 if (bgp_parse_safi(argv[2], &safi)) {
7468 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7469 return CMD_WARNING;
7470 }
7471
7472 /* BGP structure lookup. */
7473 bgp = bgp_lookup_by_name (argv[0]);
7474 if (bgp == NULL)
7475 {
7476 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7477 return CMD_WARNING;
7478 }
7479
7480 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7481}
7482
7483DEFUN (show_bgp_view_afi_safi_route,
7484 show_bgp_view_afi_safi_route_cmd,
7485 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7486 SHOW_STR
7487 BGP_STR
7488 "BGP view\n"
7489 "View name\n"
7490 "Address Family\n"
7491 "Address Family\n"
7492 "Address Family Modifier\n"
7493 "Address Family Modifier\n"
7494 "Address Family Modifier\n"
7495 "Address Family Modifier\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -04007496 "Network in the BGP routing table to display\n")
7497{
Lou Berger651b4022016-01-12 13:42:07 -05007498 safi_t safi;
7499 afi_t afi;
Michael Lambert95cbbd22010-07-23 14:43:04 -04007500
Lou Berger651b4022016-01-12 13:42:07 -05007501 if (bgp_parse_afi(argv[1], &afi)) {
7502 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7503 return CMD_WARNING;
7504 }
7505 if (bgp_parse_safi(argv[2], &safi)) {
7506 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7507 return CMD_WARNING;
7508 }
7509 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0);
7510}
7511
7512DEFUN (show_bgp_view_afi_safi_prefix,
7513 show_bgp_view_afi_safi_prefix_cmd,
7514 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7515 SHOW_STR
7516 BGP_STR
7517 "BGP view\n"
7518 "View name\n"
7519 "Address Family\n"
7520 "Address Family\n"
7521 "Address Family Modifier\n"
7522 "Address Family Modifier\n"
7523 "Address Family Modifier\n"
7524 "Address Family Modifier\n"
7525 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7526{
7527 safi_t safi;
7528 afi_t afi;
7529
7530 if (bgp_parse_afi(argv[1], &afi)) {
7531 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7532 return CMD_WARNING;
7533 }
7534 if (bgp_parse_safi(argv[2], &safi)) {
7535 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7536 return CMD_WARNING;
7537 }
7538 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1);
7539}
7540
7541/* new001 */
7542DEFUN (show_bgp_afi,
7543 show_bgp_afi_cmd,
7544 "show bgp (ipv4|ipv6)",
7545 SHOW_STR
7546 BGP_STR
7547 "Address family\n"
7548 "Address family\n")
7549{
7550 afi_t afi;
7551
7552 if (bgp_parse_afi(argv[0], &afi)) {
7553 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7554 return CMD_WARNING;
7555 }
7556 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7557 NULL);
7558}
7559
Lou Berger651b4022016-01-12 13:42:07 -05007560DEFUN (show_bgp_ipv6_safi,
7561 show_bgp_ipv6_safi_cmd,
7562 "show bgp ipv6 (unicast|multicast)",
7563 SHOW_STR
7564 BGP_STR
7565 "Address family\n"
7566 "Address Family modifier\n"
7567 "Address Family modifier\n")
7568{
7569 if (strncmp (argv[0], "m", 1) == 0)
7570 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7571 NULL);
7572
7573 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007574}
7575
Lou Berger35c36862016-01-12 13:42:06 -05007576DEFUN (show_bgp_ipv6_route,
7577 show_bgp_ipv6_route_cmd,
7578 "show bgp ipv6 X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007579 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007580 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007581 "Address family\n"
paul718e3742002-12-13 20:15:29 +00007582 "Network in the BGP routing table to display\n")
7583{
7584 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7585}
7586
Lou Berger35c36862016-01-12 13:42:06 -05007587DEFUN (show_bgp_ipv6_safi_route,
7588 show_bgp_ipv6_safi_route_cmd,
7589 "show bgp ipv6 (unicast|multicast) X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007590 SHOW_STR
7591 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007592 "Address family\n"
7593 "Address Family modifier\n"
7594 "Address Family modifier\n"
7595 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007596{
Lou Berger35c36862016-01-12 13:42:06 -05007597 if (strncmp (argv[0], "m", 1) == 0)
7598 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7599
7600 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007601}
7602
Lou Bergerf9b6c392016-01-12 13:42:09 -05007603/* old command */
7604DEFUN (show_ipv6_bgp_route,
7605 show_ipv6_bgp_route_cmd,
7606 "show ipv6 bgp X:X::X:X",
7607 SHOW_STR
7608 IP_STR
7609 BGP_STR
7610 "Network in the BGP routing table to display\n")
7611{
7612 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7613}
7614
7615DEFUN (show_bgp_prefix,
7616 show_bgp_prefix_cmd,
7617 "show bgp X:X::X:X/M",
7618 SHOW_STR
7619 BGP_STR
7620 "IPv6 prefix <network>/<length>\n")
7621{
7622 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7623}
7624
7625
Lou Berger35c36862016-01-12 13:42:06 -05007626/* new002 */
7627DEFUN (show_bgp_ipv6_prefix,
paul718e3742002-12-13 20:15:29 +00007628 show_bgp_ipv6_prefix_cmd,
7629 "show bgp ipv6 X:X::X:X/M",
7630 SHOW_STR
7631 BGP_STR
7632 "Address family\n"
Lou Berger35c36862016-01-12 13:42:06 -05007633 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7634{
7635 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7636}
Michael Lambert95cbbd22010-07-23 14:43:04 -04007637DEFUN (show_bgp_ipv6_safi_prefix,
7638 show_bgp_ipv6_safi_prefix_cmd,
7639 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7640 SHOW_STR
7641 BGP_STR
7642 "Address family\n"
7643 "Address Family modifier\n"
7644 "Address Family modifier\n"
7645 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7646{
7647 if (strncmp (argv[0], "m", 1) == 0)
7648 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7649
7650 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7651}
7652
Lou Bergerf9b6c392016-01-12 13:42:09 -05007653/* old command */
7654DEFUN (show_ipv6_bgp_prefix,
7655 show_ipv6_bgp_prefix_cmd,
7656 "show ipv6 bgp X:X::X:X/M",
7657 SHOW_STR
7658 IP_STR
7659 BGP_STR
7660 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7661{
7662 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7663}
7664
paulbb46e942003-10-24 19:02:03 +00007665DEFUN (show_bgp_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007666 show_bgp_view_cmd,
7667 "show bgp view WORD",
7668 SHOW_STR
7669 BGP_STR
7670 "BGP view\n"
7671 "View name\n")
7672{
7673 struct bgp *bgp;
7674
7675 /* BGP structure lookup. */
7676 bgp = bgp_lookup_by_name (argv[0]);
7677 if (bgp == NULL)
7678 {
7679 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7680 return CMD_WARNING;
7681 }
7682
7683 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
7684}
7685
7686DEFUN (show_bgp_view_ipv6,
Lou Berger35c36862016-01-12 13:42:06 -05007687 show_bgp_view_ipv6_cmd,
7688 "show bgp view WORD ipv6",
paulbb46e942003-10-24 19:02:03 +00007689 SHOW_STR
Lou Berger35c36862016-01-12 13:42:06 -05007690 BGP_STR
paulbb46e942003-10-24 19:02:03 +00007691 "BGP view\n"
Lou Berger35c36862016-01-12 13:42:06 -05007692 "View name\n"
7693 "Address family\n")
paulbb46e942003-10-24 19:02:03 +00007694{
7695 struct bgp *bgp;
7696
7697 /* BGP structure lookup. */
7698 bgp = bgp_lookup_by_name (argv[0]);
7699 if (bgp == NULL)
7700 {
7701 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7702 return CMD_WARNING;
7703 }
7704
ajs5a646652004-11-05 01:25:55 +00007705 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00007706}
paulbb46e942003-10-24 19:02:03 +00007707
7708DEFUN (show_bgp_view_route,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007709 show_bgp_view_route_cmd,
7710 "show bgp view WORD X:X::X:X",
7711 SHOW_STR
7712 BGP_STR
7713 "BGP view\n"
7714 "View name\n"
7715 "Network in the BGP routing table to display\n")
7716{
7717 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
7718}
7719
7720DEFUN (show_bgp_view_ipv6_route,
paulbb46e942003-10-24 19:02:03 +00007721 show_bgp_view_ipv6_route_cmd,
7722 "show bgp view WORD ipv6 X:X::X:X",
7723 SHOW_STR
7724 BGP_STR
7725 "BGP view\n"
7726 "View name\n"
7727 "Address family\n"
7728 "Network in the BGP routing table to display\n")
paulbb46e942003-10-24 19:02:03 +00007729{
Lou Berger35c36862016-01-12 13:42:06 -05007730 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paulbb46e942003-10-24 19:02:03 +00007731}
7732
Lou Bergerf9b6c392016-01-12 13:42:09 -05007733/* old command */
7734DEFUN (show_ipv6_mbgp,
7735 show_ipv6_mbgp_cmd,
7736 "show ipv6 mbgp",
7737 SHOW_STR
7738 IP_STR
7739 MBGP_STR)
7740{
7741 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7742 NULL);
7743}
7744
7745/* old command */
7746DEFUN (show_ipv6_mbgp_route,
7747 show_ipv6_mbgp_route_cmd,
7748 "show ipv6 mbgp X:X::X:X",
7749 SHOW_STR
7750 IP_STR
7751 MBGP_STR
7752 "Network in the MBGP routing table to display\n")
7753{
7754 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7755}
7756
7757/* old command */
7758DEFUN (show_ipv6_mbgp_prefix,
7759 show_ipv6_mbgp_prefix_cmd,
7760 "show ipv6 mbgp X:X::X:X/M",
7761 SHOW_STR
7762 IP_STR
7763 MBGP_STR
7764 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7765{
7766 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7767}
7768
Lou Berger35c36862016-01-12 13:42:06 -05007769DEFUN (show_bgp_view_prefix,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007770 show_bgp_view_prefix_cmd,
7771 "show bgp view WORD X:X::X:X/M",
7772 SHOW_STR
7773 BGP_STR
7774 "BGP view\n"
7775 "View name\n"
7776 "IPv6 prefix <network>/<length>\n")
7777{
7778 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7779}
7780
7781DEFUN (show_bgp_view_ipv6_prefix,
paulbb46e942003-10-24 19:02:03 +00007782 show_bgp_view_ipv6_prefix_cmd,
7783 "show bgp view WORD ipv6 X:X::X:X/M",
7784 SHOW_STR
7785 BGP_STR
7786 "BGP view\n"
7787 "View name\n"
7788 "Address family\n"
7789 "IPv6 prefix <network>/<length>\n")
paul718e3742002-12-13 20:15:29 +00007790{
Lou Berger35c36862016-01-12 13:42:06 -05007791 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007792}
7793
paul94f2b392005-06-28 12:44:16 +00007794static int
paulfd79ac92004-10-13 05:06:08 +00007795bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00007796 safi_t safi, enum bgp_show_type type)
7797{
7798 int i;
7799 struct buffer *b;
7800 char *regstr;
7801 int first;
7802 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00007803 int rc;
paul718e3742002-12-13 20:15:29 +00007804
7805 first = 0;
7806 b = buffer_new (1024);
7807 for (i = 0; i < argc; i++)
7808 {
7809 if (first)
7810 buffer_putc (b, ' ');
7811 else
7812 {
7813 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
7814 continue;
7815 first = 1;
7816 }
7817
7818 buffer_putstr (b, argv[i]);
7819 }
7820 buffer_putc (b, '\0');
7821
7822 regstr = buffer_getstr (b);
7823 buffer_free (b);
7824
7825 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00007826 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00007827 if (! regex)
7828 {
7829 vty_out (vty, "Can't compile regexp %s%s", argv[0],
7830 VTY_NEWLINE);
7831 return CMD_WARNING;
7832 }
7833
ajs5a646652004-11-05 01:25:55 +00007834 rc = bgp_show (vty, NULL, afi, safi, type, regex);
7835 bgp_regex_free (regex);
7836 return rc;
paul718e3742002-12-13 20:15:29 +00007837}
7838
Lou Bergerf9b6c392016-01-12 13:42:09 -05007839
7840DEFUN (show_ip_bgp_regexp,
7841 show_ip_bgp_regexp_cmd,
7842 "show ip bgp regexp .LINE",
7843 SHOW_STR
7844 IP_STR
7845 BGP_STR
7846 "Display routes matching the AS path regular expression\n"
7847 "A regular-expression to match the BGP AS paths\n")
7848{
7849 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7850 bgp_show_type_regexp);
7851}
7852
7853DEFUN (show_ip_bgp_flap_regexp,
7854 show_ip_bgp_flap_regexp_cmd,
7855 "show ip bgp flap-statistics regexp .LINE",
7856 SHOW_STR
7857 IP_STR
7858 BGP_STR
7859 "Display flap statistics of routes\n"
7860 "Display routes matching the AS path regular expression\n"
7861 "A regular-expression to match the BGP AS paths\n")
7862{
7863 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7864 bgp_show_type_flap_regexp);
7865}
7866
7867ALIAS (show_ip_bgp_flap_regexp,
7868 show_ip_bgp_damp_flap_regexp_cmd,
7869 "show ip bgp dampening flap-statistics regexp .LINE",
7870 SHOW_STR
7871 IP_STR
7872 BGP_STR
7873 "Display detailed information about dampening\n"
7874 "Display flap statistics of routes\n"
7875 "Display routes matching the AS path regular expression\n"
7876 "A regular-expression to match the BGP AS paths\n")
7877
7878DEFUN (show_ip_bgp_ipv4_regexp,
7879 show_ip_bgp_ipv4_regexp_cmd,
7880 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7881 SHOW_STR
7882 IP_STR
7883 BGP_STR
7884 "Address family\n"
7885 "Address Family modifier\n"
7886 "Address Family modifier\n"
7887 "Display routes matching the AS path regular expression\n"
7888 "A regular-expression to match the BGP AS paths\n")
7889{
7890 if (strncmp (argv[0], "m", 1) == 0)
7891 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
7892 bgp_show_type_regexp);
7893
7894 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7895 bgp_show_type_regexp);
7896}
7897
Lou Bergerf9b6c392016-01-12 13:42:09 -05007898DEFUN (show_bgp_regexp,
7899 show_bgp_regexp_cmd,
7900 "show bgp regexp .LINE",
7901 SHOW_STR
7902 BGP_STR
7903 "Display routes matching the AS path regular expression\n"
7904 "A regular-expression to match the BGP AS paths\n")
7905{
7906 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7907 bgp_show_type_regexp);
7908}
7909
7910/* old command */
7911DEFUN (show_ipv6_bgp_regexp,
7912 show_ipv6_bgp_regexp_cmd,
7913 "show ipv6 bgp regexp .LINE",
7914 SHOW_STR
7915 IP_STR
7916 BGP_STR
7917 "Display routes matching the AS path regular expression\n"
7918 "A regular-expression to match the BGP AS paths\n")
7919{
7920 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7921 bgp_show_type_regexp);
7922}
7923
7924/* old command */
7925DEFUN (show_ipv6_mbgp_regexp,
7926 show_ipv6_mbgp_regexp_cmd,
7927 "show ipv6 mbgp regexp .LINE",
7928 SHOW_STR
7929 IP_STR
7930 BGP_STR
7931 "Display routes matching the AS path regular expression\n"
7932 "A regular-expression to match the MBGP AS paths\n")
7933{
7934 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
7935 bgp_show_type_regexp);
7936}
Lou Bergerf9b6c392016-01-12 13:42:09 -05007937
Lou Berger651b4022016-01-12 13:42:07 -05007938DEFUN (show_bgp_ipv4_safi_flap_regexp,
7939 show_bgp_ipv4_safi_flap_regexp_cmd,
7940 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00007941 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007942 BGP_STR
paul718e3742002-12-13 20:15:29 +00007943 IP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007944 "Address Family Modifier\n"
7945 "Address Family Modifier\n"
7946 "Address Family Modifier\n"
7947 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007948 "Display flap statistics of routes\n"
7949 "Display routes matching the AS path regular expression\n"
7950 "A regular-expression to match the BGP AS paths\n")
7951{
Lou Berger651b4022016-01-12 13:42:07 -05007952 safi_t safi;
7953
7954 if (bgp_parse_safi(argv[0], &safi)) {
7955 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7956 return CMD_WARNING;
7957 }
7958 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
7959 bgp_show_type_flap_regexp);
paul718e3742002-12-13 20:15:29 +00007960}
7961
Lou Berger651b4022016-01-12 13:42:07 -05007962ALIAS (show_bgp_ipv4_safi_flap_regexp,
7963 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
7964 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
Balaji3921cc52015-05-16 23:12:17 +05307965 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05307966 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007967 IP_STR
7968 "Address Family Modifier\n"
7969 "Address Family Modifier\n"
7970 "Address Family Modifier\n"
7971 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05307972 "Display detailed information about dampening\n"
7973 "Display flap statistics of routes\n"
7974 "Display routes matching the AS path regular expression\n"
7975 "A regular-expression to match the BGP AS paths\n")
7976
Lou Berger651b4022016-01-12 13:42:07 -05007977DEFUN (show_bgp_ipv6_safi_flap_regexp,
7978 show_bgp_ipv6_safi_flap_regexp_cmd,
7979 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00007980 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05007981 BGP_STR
7982 IPV6_STR
7983 "Address Family Modifier\n"
7984 "Address Family Modifier\n"
7985 "Address Family Modifier\n"
7986 "Address Family Modifier\n"
7987 "Display flap statistics of routes\n"
7988 "Display routes matching the AS path regular expression\n"
7989 "A regular-expression to match the BGP AS paths\n")
7990{
7991 safi_t safi;
7992
7993 if (bgp_parse_safi(argv[0], &safi)) {
7994 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7995 return CMD_WARNING;
7996 }
7997 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
7998 bgp_show_type_flap_regexp);
7999}
8000
8001ALIAS (show_bgp_ipv6_safi_flap_regexp,
8002 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8003 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8004 SHOW_STR
8005 BGP_STR
8006 IPV6_STR
8007 "Address Family Modifier\n"
8008 "Address Family Modifier\n"
8009 "Address Family Modifier\n"
8010 "Address Family Modifier\n"
8011 "Display detailed information about dampening\n"
8012 "Display flap statistics of routes\n"
8013 "Display routes matching the AS path regular expression\n"
8014 "A regular-expression to match the BGP AS paths\n")
Lou Berger651b4022016-01-12 13:42:07 -05008015
8016DEFUN (show_bgp_ipv4_safi_regexp,
8017 show_bgp_ipv4_safi_regexp_cmd,
8018 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8019 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008020 BGP_STR
8021 "Address family\n"
8022 "Address Family modifier\n"
8023 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008024 "Address Family modifier\n"
8025 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008026 "Display routes matching the AS path regular expression\n"
8027 "A regular-expression to match the BGP AS paths\n")
8028{
Lou Berger651b4022016-01-12 13:42:07 -05008029 safi_t safi;
8030 if (bgp_parse_safi(argv[0], &safi)) {
8031 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8032 return CMD_WARNING;
8033 }
paul718e3742002-12-13 20:15:29 +00008034
Lou Berger651b4022016-01-12 13:42:07 -05008035 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008036 bgp_show_type_regexp);
8037}
Lou Berger205e6742016-01-12 13:42:11 -05008038
Lou Berger651b4022016-01-12 13:42:07 -05008039DEFUN (show_bgp_ipv6_safi_regexp,
8040 show_bgp_ipv6_safi_regexp_cmd,
8041 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008042 SHOW_STR
8043 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008044 "Address family\n"
8045 "Address Family modifier\n"
8046 "Address Family modifier\n"
8047 "Address Family modifier\n"
8048 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008049 "Display routes matching the AS path regular expression\n"
8050 "A regular-expression to match the BGP AS paths\n")
8051{
Lou Berger651b4022016-01-12 13:42:07 -05008052 safi_t safi;
8053 if (bgp_parse_safi(argv[0], &safi)) {
8054 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8055 return CMD_WARNING;
8056 }
8057
8058 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008059 bgp_show_type_regexp);
8060}
8061
Lou Berger651b4022016-01-12 13:42:07 -05008062DEFUN (show_bgp_ipv6_regexp,
paul718e3742002-12-13 20:15:29 +00008063 show_bgp_ipv6_regexp_cmd,
8064 "show bgp ipv6 regexp .LINE",
8065 SHOW_STR
8066 BGP_STR
8067 "Address family\n"
8068 "Display routes matching the AS path regular expression\n"
8069 "A regular-expression to match the BGP AS paths\n")
paul718e3742002-12-13 20:15:29 +00008070{
8071 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8072 bgp_show_type_regexp);
8073}
8074
paul94f2b392005-06-28 12:44:16 +00008075static int
paulfd79ac92004-10-13 05:06:08 +00008076bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008077 safi_t safi, enum bgp_show_type type)
8078{
8079 struct prefix_list *plist;
8080
8081 plist = prefix_list_lookup (afi, prefix_list_str);
8082 if (plist == NULL)
8083 {
8084 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8085 prefix_list_str, VTY_NEWLINE);
8086 return CMD_WARNING;
8087 }
8088
ajs5a646652004-11-05 01:25:55 +00008089 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00008090}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008091DEFUN (show_ip_bgp_prefix_list,
8092 show_ip_bgp_prefix_list_cmd,
8093 "show ip bgp prefix-list WORD",
8094 SHOW_STR
8095 IP_STR
8096 BGP_STR
8097 "Display routes conforming to the prefix-list\n"
8098 "IP prefix-list name\n")
8099{
8100 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8101 bgp_show_type_prefix_list);
8102}
8103
8104DEFUN (show_ip_bgp_flap_prefix_list,
8105 show_ip_bgp_flap_prefix_list_cmd,
8106 "show ip bgp flap-statistics prefix-list WORD",
8107 SHOW_STR
8108 IP_STR
8109 BGP_STR
8110 "Display flap statistics of routes\n"
8111 "Display routes conforming to the prefix-list\n"
8112 "IP prefix-list name\n")
8113{
8114 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8115 bgp_show_type_flap_prefix_list);
8116}
8117
8118ALIAS (show_ip_bgp_flap_prefix_list,
8119 show_ip_bgp_damp_flap_prefix_list_cmd,
8120 "show ip bgp dampening flap-statistics prefix-list WORD",
8121 SHOW_STR
8122 IP_STR
8123 BGP_STR
8124 "Display detailed information about dampening\n"
8125 "Display flap statistics of routes\n"
8126 "Display routes conforming to the prefix-list\n"
8127 "IP prefix-list name\n")
8128
8129DEFUN (show_ip_bgp_ipv4_prefix_list,
8130 show_ip_bgp_ipv4_prefix_list_cmd,
8131 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8132 SHOW_STR
8133 IP_STR
8134 BGP_STR
8135 "Address family\n"
8136 "Address Family modifier\n"
8137 "Address Family modifier\n"
8138 "Display routes conforming to the prefix-list\n"
8139 "IP prefix-list name\n")
8140{
8141 if (strncmp (argv[0], "m", 1) == 0)
8142 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8143 bgp_show_type_prefix_list);
8144
8145 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8146 bgp_show_type_prefix_list);
8147}
8148
Lou Bergerf9b6c392016-01-12 13:42:09 -05008149DEFUN (show_bgp_prefix_list,
8150 show_bgp_prefix_list_cmd,
8151 "show bgp prefix-list WORD",
8152 SHOW_STR
8153 BGP_STR
8154 "Display routes conforming to the prefix-list\n"
8155 "IPv6 prefix-list name\n")
8156{
8157 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8158 bgp_show_type_prefix_list);
8159}
8160
8161ALIAS (show_bgp_prefix_list,
8162 show_bgp_ipv6_prefix_list_cmd,
8163 "show bgp ipv6 prefix-list WORD",
8164 SHOW_STR
8165 BGP_STR
8166 "Address family\n"
8167 "Display routes conforming to the prefix-list\n"
8168 "IPv6 prefix-list name\n")
8169
8170/* old command */
8171DEFUN (show_ipv6_bgp_prefix_list,
8172 show_ipv6_bgp_prefix_list_cmd,
8173 "show ipv6 bgp prefix-list WORD",
8174 SHOW_STR
8175 IPV6_STR
8176 BGP_STR
8177 "Display routes matching the prefix-list\n"
8178 "IPv6 prefix-list name\n")
8179{
8180 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8181 bgp_show_type_prefix_list);
8182}
8183
8184/* old command */
8185DEFUN (show_ipv6_mbgp_prefix_list,
8186 show_ipv6_mbgp_prefix_list_cmd,
8187 "show ipv6 mbgp prefix-list WORD",
8188 SHOW_STR
8189 IPV6_STR
8190 MBGP_STR
8191 "Display routes matching the prefix-list\n"
8192 "IPv6 prefix-list name\n")
8193{
8194 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8195 bgp_show_type_prefix_list);
8196}
paul718e3742002-12-13 20:15:29 +00008197
Lou Berger35c36862016-01-12 13:42:06 -05008198DEFUN (show_bgp_ipv4_prefix_list,
8199 show_bgp_ipv4_prefix_list_cmd,
8200 "show bgp ipv4 prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008201 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008202 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05008203 IP_STR
paul718e3742002-12-13 20:15:29 +00008204 "Display routes conforming to the prefix-list\n"
8205 "IP prefix-list name\n")
8206{
8207 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8208 bgp_show_type_prefix_list);
8209}
8210
Lou Berger651b4022016-01-12 13:42:07 -05008211DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8212 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8213 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008214 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008215 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008216 IP_STR
8217 "Address Family Modifier\n"
8218 "Address Family Modifier\n"
8219 "Address Family Modifier\n"
8220 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008221 "Display flap statistics of routes\n"
8222 "Display routes conforming to the prefix-list\n"
8223 "IP prefix-list name\n")
8224{
Lou Berger651b4022016-01-12 13:42:07 -05008225 safi_t safi;
8226 if (bgp_parse_safi(argv[0], &safi)) {
8227 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8228 return CMD_WARNING;
8229 }
8230 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008231 bgp_show_type_flap_prefix_list);
8232}
8233
Lou Berger651b4022016-01-12 13:42:07 -05008234ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8235 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8236 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308237 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308238 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008239 IP_STR
8240 "Address Family Modifier\n"
8241 "Address Family Modifier\n"
8242 "Address Family Modifier\n"
8243 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308244 "Display detailed information about dampening\n"
8245 "Display flap statistics of routes\n"
8246 "Display routes conforming to the prefix-list\n"
8247 "IP prefix-list name\n")
8248
Lou Berger651b4022016-01-12 13:42:07 -05008249DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8250 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8251 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008252 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008253 BGP_STR
8254 IPV6_STR
8255 "Address Family Modifier\n"
8256 "Address Family Modifier\n"
8257 "Address Family Modifier\n"
8258 "Address Family Modifier\n"
8259 "Display flap statistics of routes\n"
8260 "Display routes conforming to the prefix-list\n"
8261 "IP prefix-list name\n")
8262{
8263 safi_t safi;
8264 if (bgp_parse_safi(argv[0], &safi)) {
8265 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8266 return CMD_WARNING;
8267 }
8268 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8269 bgp_show_type_flap_prefix_list);
8270}
8271ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8272 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8273 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8274 SHOW_STR
8275 BGP_STR
8276 IPV6_STR
8277 "Address Family Modifier\n"
8278 "Address Family Modifier\n"
8279 "Address Family Modifier\n"
8280 "Address Family Modifier\n"
8281 "Display detailed information about dampening\n"
8282 "Display flap statistics of routes\n"
8283 "Display routes conforming to the prefix-list\n"
8284 "IP prefix-list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008285
8286DEFUN (show_bgp_ipv4_safi_prefix_list,
8287 show_bgp_ipv4_safi_prefix_list_cmd,
8288 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8289 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008290 BGP_STR
8291 "Address family\n"
8292 "Address Family modifier\n"
8293 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008294 "Address Family modifier\n"
8295 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008296 "Display routes conforming to the prefix-list\n"
8297 "IP prefix-list name\n")
8298{
Lou Berger651b4022016-01-12 13:42:07 -05008299 safi_t safi;
8300 if (bgp_parse_safi(argv[0], &safi)) {
8301 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8302 return CMD_WARNING;
8303 }
8304 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008305 bgp_show_type_prefix_list);
8306}
Lou Berger205e6742016-01-12 13:42:11 -05008307
Lou Berger651b4022016-01-12 13:42:07 -05008308DEFUN (show_bgp_ipv6_safi_prefix_list,
8309 show_bgp_ipv6_safi_prefix_list_cmd,
8310 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008311 SHOW_STR
8312 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008313 "Address family\n"
8314 "Address Family modifier\n"
8315 "Address Family modifier\n"
8316 "Address Family modifier\n"
8317 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008318 "Display routes conforming to the prefix-list\n"
Lou Berger651b4022016-01-12 13:42:07 -05008319 "IP prefix-list name\n")
paul718e3742002-12-13 20:15:29 +00008320{
Lou Berger651b4022016-01-12 13:42:07 -05008321 safi_t safi;
8322 if (bgp_parse_safi(argv[0], &safi)) {
8323 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8324 return CMD_WARNING;
8325 }
8326 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008327 bgp_show_type_prefix_list);
8328}
8329
paul94f2b392005-06-28 12:44:16 +00008330static int
paulfd79ac92004-10-13 05:06:08 +00008331bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008332 safi_t safi, enum bgp_show_type type)
8333{
8334 struct as_list *as_list;
8335
8336 as_list = as_list_lookup (filter);
8337 if (as_list == NULL)
8338 {
8339 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8340 return CMD_WARNING;
8341 }
8342
ajs5a646652004-11-05 01:25:55 +00008343 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00008344}
8345
Lou Bergerf9b6c392016-01-12 13:42:09 -05008346DEFUN (show_ip_bgp_filter_list,
8347 show_ip_bgp_filter_list_cmd,
8348 "show ip bgp filter-list WORD",
8349 SHOW_STR
8350 IP_STR
8351 BGP_STR
8352 "Display routes conforming to the filter-list\n"
8353 "Regular expression access list name\n")
8354{
8355 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8356 bgp_show_type_filter_list);
8357}
8358
8359DEFUN (show_ip_bgp_flap_filter_list,
8360 show_ip_bgp_flap_filter_list_cmd,
8361 "show ip bgp flap-statistics filter-list WORD",
8362 SHOW_STR
8363 IP_STR
8364 BGP_STR
8365 "Display flap statistics of routes\n"
8366 "Display routes conforming to the filter-list\n"
8367 "Regular expression access list name\n")
8368{
8369 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8370 bgp_show_type_flap_filter_list);
8371}
8372
8373ALIAS (show_ip_bgp_flap_filter_list,
8374 show_ip_bgp_damp_flap_filter_list_cmd,
8375 "show ip bgp dampening flap-statistics filter-list WORD",
8376 SHOW_STR
8377 IP_STR
8378 BGP_STR
8379 "Display detailed information about dampening\n"
8380 "Display flap statistics of routes\n"
8381 "Display routes conforming to the filter-list\n"
8382 "Regular expression access list name\n")
8383
8384DEFUN (show_ip_bgp_ipv4_filter_list,
8385 show_ip_bgp_ipv4_filter_list_cmd,
8386 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8387 SHOW_STR
8388 IP_STR
8389 BGP_STR
8390 "Address family\n"
8391 "Address Family modifier\n"
8392 "Address Family modifier\n"
8393 "Display routes conforming to the filter-list\n"
8394 "Regular expression access list name\n")
8395{
8396 if (strncmp (argv[0], "m", 1) == 0)
8397 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8398 bgp_show_type_filter_list);
8399
8400 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8401 bgp_show_type_filter_list);
8402}
8403
Lou Bergerf9b6c392016-01-12 13:42:09 -05008404DEFUN (show_bgp_filter_list,
8405 show_bgp_filter_list_cmd,
8406 "show bgp filter-list WORD",
8407 SHOW_STR
8408 BGP_STR
8409 "Display routes conforming to the filter-list\n"
8410 "Regular expression access list name\n")
8411{
8412 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8413 bgp_show_type_filter_list);
8414}
8415
8416/* old command */
8417DEFUN (show_ipv6_bgp_filter_list,
8418 show_ipv6_bgp_filter_list_cmd,
8419 "show ipv6 bgp filter-list WORD",
8420 SHOW_STR
8421 IPV6_STR
8422 BGP_STR
8423 "Display routes conforming to the filter-list\n"
8424 "Regular expression access list name\n")
8425{
8426 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8427 bgp_show_type_filter_list);
8428}
8429
8430/* old command */
8431DEFUN (show_ipv6_mbgp_filter_list,
8432 show_ipv6_mbgp_filter_list_cmd,
8433 "show ipv6 mbgp filter-list WORD",
8434 SHOW_STR
8435 IPV6_STR
8436 MBGP_STR
8437 "Display routes conforming to the filter-list\n"
8438 "Regular expression access list name\n")
8439{
8440 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8441 bgp_show_type_filter_list);
8442}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008443
8444DEFUN (show_ip_bgp_dampening_info,
8445 show_ip_bgp_dampening_params_cmd,
8446 "show ip bgp dampening parameters",
8447 SHOW_STR
8448 IP_STR
8449 BGP_STR
8450 "Display detailed information about dampening\n"
8451 "Display detail of configured dampening parameters\n")
8452{
8453 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8454}
8455
Lou Berger651b4022016-01-12 13:42:07 -05008456DEFUN (show_bgp_ipv4_filter_list,
8457 show_bgp_ipv4_filter_list_cmd,
8458 "show bgp ipv4 filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008459 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008460 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008461 IP_STR
paul718e3742002-12-13 20:15:29 +00008462 "Display routes conforming to the filter-list\n"
8463 "Regular expression access list name\n")
8464{
8465 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8466 bgp_show_type_filter_list);
8467}
8468
Lou Berger651b4022016-01-12 13:42:07 -05008469DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8470 show_bgp_ipv4_safi_flap_filter_list_cmd,
8471 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008472 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008473 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008474 IP_STR
8475 "Address Family modifier\n"
8476 "Address Family modifier\n"
8477 "Address Family modifier\n"
8478 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008479 "Display flap statistics of routes\n"
8480 "Display routes conforming to the filter-list\n"
8481 "Regular expression access list name\n")
8482{
Lou Berger651b4022016-01-12 13:42:07 -05008483 safi_t safi;
8484
8485 if (bgp_parse_safi(argv[0], &safi)) {
8486 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8487 return CMD_WARNING;
8488 }
8489 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008490 bgp_show_type_flap_filter_list);
8491}
8492
Lou Berger651b4022016-01-12 13:42:07 -05008493ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8494 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8495 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308496 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308497 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008498 IP_STR
8499 "Address Family modifier\n"
8500 "Address Family modifier\n"
8501 "Address Family modifier\n"
8502 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308503 "Display detailed information about dampening\n"
8504 "Display flap statistics of routes\n"
8505 "Display routes conforming to the filter-list\n"
8506 "Regular expression access list name\n")
8507
Lou Berger651b4022016-01-12 13:42:07 -05008508DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8509 show_bgp_ipv6_safi_flap_filter_list_cmd,
8510 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008511 SHOW_STR
8512 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008513 IPV6_STR
8514 "Address Family modifier\n"
8515 "Address Family modifier\n"
8516 "Address Family modifier\n"
8517 "Address Family modifier\n"
8518 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +00008519 "Display routes conforming to the filter-list\n"
8520 "Regular expression access list name\n")
8521{
Lou Berger651b4022016-01-12 13:42:07 -05008522 safi_t safi;
8523
8524 if (bgp_parse_safi(argv[0], &safi)) {
8525 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8526 return CMD_WARNING;
8527 }
8528 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8529 bgp_show_type_flap_filter_list);
8530}
8531ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8532 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8533 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8534 SHOW_STR
8535 BGP_STR
8536 IPV6_STR
8537 "Address Family modifier\n"
8538 "Address Family modifier\n"
8539 "Address Family modifier\n"
8540 "Address Family modifier\n"
8541 "Display detailed information about dampening\n"
8542 "Display flap statistics of routes\n"
8543 "Display routes conforming to the filter-list\n"
8544 "Regular expression access list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008545
8546DEFUN (show_bgp_ipv4_safi_filter_list,
8547 show_bgp_ipv4_safi_filter_list_cmd,
8548 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8549 SHOW_STR
8550 BGP_STR
8551 "Address Family modifier\n"
8552 "Address Family modifier\n"
8553 "Address Family modifier\n"
8554 "Address Family modifier\n"
8555 "Display routes conforming to the filter-list\n"
8556 "Regular expression access list name\n")
8557{
8558 safi_t safi;
8559
8560 if (bgp_parse_safi(argv[0], &safi)) {
8561 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8562 return CMD_WARNING;
8563 }
8564 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8565 bgp_show_type_filter_list);
8566}
Lou Berger205e6742016-01-12 13:42:11 -05008567
Lou Berger651b4022016-01-12 13:42:07 -05008568DEFUN (show_bgp_ipv6_safi_filter_list,
8569 show_bgp_ipv6_safi_filter_list_cmd,
8570 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8571 SHOW_STR
8572 BGP_STR
8573 "Address Family modifier\n"
8574 "Address Family modifier\n"
8575 "Address Family modifier\n"
8576 "Address Family modifier\n"
8577 "Display routes conforming to the filter-list\n"
8578 "Regular expression access list name\n")
8579{
8580 safi_t safi;
8581
8582 if (bgp_parse_safi(argv[0], &safi)) {
8583 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8584 return CMD_WARNING;
8585 }
8586 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8587 bgp_show_type_filter_list);
paul718e3742002-12-13 20:15:29 +00008588}
8589
Lou Bergerf9b6c392016-01-12 13:42:09 -05008590DEFUN (show_bgp_ipv6_filter_list,
paul718e3742002-12-13 20:15:29 +00008591 show_bgp_ipv6_filter_list_cmd,
8592 "show bgp ipv6 filter-list WORD",
8593 SHOW_STR
8594 BGP_STR
8595 "Address family\n"
8596 "Display routes conforming to the filter-list\n"
8597 "Regular expression access list name\n")
paul718e3742002-12-13 20:15:29 +00008598{
8599 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8600 bgp_show_type_filter_list);
8601}
8602
paul94f2b392005-06-28 12:44:16 +00008603static int
paulfd79ac92004-10-13 05:06:08 +00008604bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008605 safi_t safi, enum bgp_show_type type)
8606{
8607 struct route_map *rmap;
8608
8609 rmap = route_map_lookup_by_name (rmap_str);
8610 if (! rmap)
8611 {
8612 vty_out (vty, "%% %s is not a valid route-map name%s",
8613 rmap_str, VTY_NEWLINE);
8614 return CMD_WARNING;
8615 }
8616
ajs5a646652004-11-05 01:25:55 +00008617 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00008618}
8619
Lou Bergerf9b6c392016-01-12 13:42:09 -05008620DEFUN (show_ip_bgp_route_map,
8621 show_ip_bgp_route_map_cmd,
8622 "show ip bgp route-map WORD",
8623 SHOW_STR
8624 IP_STR
8625 BGP_STR
8626 "Display routes matching the route-map\n"
8627 "A route-map to match on\n")
8628{
8629 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8630 bgp_show_type_route_map);
8631}
8632
8633DEFUN (show_ip_bgp_flap_route_map,
8634 show_ip_bgp_flap_route_map_cmd,
8635 "show ip bgp flap-statistics route-map WORD",
8636 SHOW_STR
8637 IP_STR
8638 BGP_STR
8639 "Display flap statistics of routes\n"
8640 "Display routes matching the route-map\n"
8641 "A route-map to match on\n")
8642{
8643 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8644 bgp_show_type_flap_route_map);
8645}
8646
8647ALIAS (show_ip_bgp_flap_route_map,
8648 show_ip_bgp_damp_flap_route_map_cmd,
8649 "show ip bgp dampening flap-statistics route-map WORD",
8650 SHOW_STR
8651 IP_STR
8652 BGP_STR
8653 "Display detailed information about dampening\n"
8654 "Display flap statistics of routes\n"
8655 "Display routes matching the route-map\n"
8656 "A route-map to match on\n")
8657
8658DEFUN (show_ip_bgp_ipv4_route_map,
8659 show_ip_bgp_ipv4_route_map_cmd,
8660 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
8661 SHOW_STR
8662 IP_STR
8663 BGP_STR
8664 "Address family\n"
8665 "Address Family modifier\n"
8666 "Address Family modifier\n"
8667 "Display routes matching the route-map\n"
8668 "A route-map to match on\n")
8669{
8670 if (strncmp (argv[0], "m", 1) == 0)
8671 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8672 bgp_show_type_route_map);
8673
8674 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
8675 bgp_show_type_route_map);
8676}
8677
8678DEFUN (show_bgp_route_map,
8679 show_bgp_route_map_cmd,
8680 "show bgp route-map WORD",
8681 SHOW_STR
8682 BGP_STR
8683 "Display routes matching the route-map\n"
8684 "A route-map to match on\n")
8685{
8686 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8687 bgp_show_type_route_map);
8688}
8689
8690DEFUN (show_ip_bgp_cidr_only,
8691 show_ip_bgp_cidr_only_cmd,
8692 "show ip bgp cidr-only",
8693 SHOW_STR
8694 IP_STR
8695 BGP_STR
8696 "Display only routes with non-natural netmasks\n")
8697{
8698 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8699 bgp_show_type_cidr_only, NULL);
8700}
8701
8702DEFUN (show_ip_bgp_flap_cidr_only,
8703 show_ip_bgp_flap_cidr_only_cmd,
8704 "show ip bgp flap-statistics cidr-only",
8705 SHOW_STR
8706 IP_STR
8707 BGP_STR
8708 "Display flap statistics of routes\n"
8709 "Display only routes with non-natural netmasks\n")
8710{
8711 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8712 bgp_show_type_flap_cidr_only, NULL);
8713}
8714
8715ALIAS (show_ip_bgp_flap_cidr_only,
8716 show_ip_bgp_damp_flap_cidr_only_cmd,
8717 "show ip bgp dampening flap-statistics cidr-only",
8718 SHOW_STR
8719 IP_STR
8720 BGP_STR
8721 "Display detailed information about dampening\n"
8722 "Display flap statistics of routes\n"
8723 "Display only routes with non-natural netmasks\n")
8724
8725DEFUN (show_ip_bgp_ipv4_cidr_only,
8726 show_ip_bgp_ipv4_cidr_only_cmd,
8727 "show ip bgp ipv4 (unicast|multicast) cidr-only",
8728 SHOW_STR
8729 IP_STR
8730 BGP_STR
8731 "Address family\n"
8732 "Address Family modifier\n"
8733 "Address Family modifier\n"
8734 "Display only routes with non-natural netmasks\n")
8735{
8736 if (strncmp (argv[0], "m", 1) == 0)
8737 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8738 bgp_show_type_cidr_only, NULL);
8739
8740 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8741 bgp_show_type_cidr_only, NULL);
8742}
8743
8744DEFUN (show_ip_bgp_community_all,
8745 show_ip_bgp_community_all_cmd,
8746 "show ip bgp community",
8747 SHOW_STR
8748 IP_STR
8749 BGP_STR
8750 "Display routes matching the communities\n")
8751{
8752 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8753 bgp_show_type_community_all, NULL);
8754}
8755
8756DEFUN (show_ip_bgp_ipv4_community_all,
8757 show_ip_bgp_ipv4_community_all_cmd,
8758 "show ip bgp ipv4 (unicast|multicast) community",
8759 SHOW_STR
8760 IP_STR
8761 BGP_STR
8762 "Address family\n"
8763 "Address Family modifier\n"
8764 "Address Family modifier\n"
8765 "Display routes matching the communities\n")
8766{
8767 if (strncmp (argv[0], "m", 1) == 0)
8768 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8769 bgp_show_type_community_all, NULL);
8770
8771 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8772 bgp_show_type_community_all, NULL);
8773}
8774
Lou Bergerf9b6c392016-01-12 13:42:09 -05008775DEFUN (show_bgp_community_all,
8776 show_bgp_community_all_cmd,
8777 "show bgp community",
8778 SHOW_STR
8779 BGP_STR
8780 "Display routes matching the communities\n")
8781{
8782 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8783 bgp_show_type_community_all, NULL);
8784}
8785
8786ALIAS (show_bgp_community_all,
8787 show_bgp_ipv6_community_all_cmd,
8788 "show bgp ipv6 community",
8789 SHOW_STR
8790 BGP_STR
8791 "Address family\n"
8792 "Display routes matching the communities\n")
8793
8794/* old command */
8795DEFUN (show_ipv6_bgp_community_all,
8796 show_ipv6_bgp_community_all_cmd,
8797 "show ipv6 bgp community",
8798 SHOW_STR
8799 IPV6_STR
8800 BGP_STR
8801 "Display routes matching the communities\n")
8802{
8803 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8804 bgp_show_type_community_all, NULL);
8805}
8806
8807/* old command */
8808DEFUN (show_ipv6_mbgp_community_all,
8809 show_ipv6_mbgp_community_all_cmd,
8810 "show ipv6 mbgp community",
8811 SHOW_STR
8812 IPV6_STR
8813 MBGP_STR
8814 "Display routes matching the communities\n")
8815{
8816 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
8817 bgp_show_type_community_all, NULL);
8818}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008819
Lou Berger651b4022016-01-12 13:42:07 -05008820DEFUN (show_bgp_ipv4_route_map,
8821 show_bgp_ipv4_route_map_cmd,
8822 "show bgp ipv4 route-map WORD",
paul718e3742002-12-13 20:15:29 +00008823 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008824 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008825 IP_STR
paul718e3742002-12-13 20:15:29 +00008826 "Display routes matching the route-map\n"
8827 "A route-map to match on\n")
8828{
8829 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8830 bgp_show_type_route_map);
8831}
8832
Lou Berger651b4022016-01-12 13:42:07 -05008833DEFUN (show_bgp_ipv4_safi_flap_route_map,
8834 show_bgp_ipv4_safi_flap_route_map_cmd,
8835 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008836 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008837 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008838 IP_STR
8839 "Address Family Modifier\n"
8840 "Address Family Modifier\n"
8841 "Address Family Modifier\n"
8842 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008843 "Display flap statistics of routes\n"
8844 "Display routes matching the route-map\n"
8845 "A route-map to match on\n")
8846{
Lou Berger651b4022016-01-12 13:42:07 -05008847 safi_t safi;
8848 if (bgp_parse_safi(argv[0], &safi)) {
8849 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8850 return CMD_WARNING;
8851 }
8852 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008853 bgp_show_type_flap_route_map);
8854}
8855
Lou Berger651b4022016-01-12 13:42:07 -05008856ALIAS (show_bgp_ipv4_safi_flap_route_map,
8857 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
8858 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
Balaji3921cc52015-05-16 23:12:17 +05308859 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308860 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008861 IP_STR
8862 "Address Family Modifier\n"
8863 "Address Family Modifier\n"
8864 "Address Family Modifier\n"
8865 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308866 "Display detailed information about dampening\n"
8867 "Display flap statistics of routes\n"
8868 "Display routes matching the route-map\n"
8869 "A route-map to match on\n")
Lou Berger205e6742016-01-12 13:42:11 -05008870
Lou Berger651b4022016-01-12 13:42:07 -05008871DEFUN (show_bgp_ipv6_safi_flap_route_map,
8872 show_bgp_ipv6_safi_flap_route_map_cmd,
8873 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008874 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008875 BGP_STR
8876 IPV6_STR
8877 "Address Family Modifier\n"
8878 "Address Family Modifier\n"
8879 "Address Family Modifier\n"
8880 "Address Family Modifier\n"
8881 "Display flap statistics of routes\n"
8882 "Display routes matching the route-map\n"
8883 "A route-map to match on\n")
8884{
8885 safi_t safi;
8886 if (bgp_parse_safi(argv[0], &safi)) {
8887 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8888 return CMD_WARNING;
8889 }
8890 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
8891 bgp_show_type_flap_route_map);
8892}
8893ALIAS (show_bgp_ipv6_safi_flap_route_map,
8894 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
8895 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
8896 SHOW_STR
8897 BGP_STR
8898 IPV6_STR
8899 "Address Family Modifier\n"
8900 "Address Family Modifier\n"
8901 "Address Family Modifier\n"
8902 "Address Family Modifier\n"
8903 "Display detailed information about dampening\n"
8904 "Display flap statistics of routes\n"
8905 "Display routes matching the route-map\n"
8906 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05008907
8908DEFUN (show_bgp_ipv4_safi_route_map,
8909 show_bgp_ipv4_safi_route_map_cmd,
8910 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
8911 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008912 BGP_STR
8913 "Address family\n"
8914 "Address Family modifier\n"
8915 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008916 "Address Family modifier\n"
8917 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008918 "Display routes matching the route-map\n"
8919 "A route-map to match on\n")
8920{
Lou Berger651b4022016-01-12 13:42:07 -05008921 safi_t safi;
8922 if (bgp_parse_safi(argv[0], &safi)) {
8923 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8924 return CMD_WARNING;
8925 }
8926 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008927 bgp_show_type_route_map);
8928}
Lou Berger205e6742016-01-12 13:42:11 -05008929
Lou Berger651b4022016-01-12 13:42:07 -05008930DEFUN (show_bgp_ipv6_safi_route_map,
8931 show_bgp_ipv6_safi_route_map_cmd,
8932 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
paul718e3742002-12-13 20:15:29 +00008933 SHOW_STR
8934 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008935 "Address family\n"
8936 "Address Family modifier\n"
8937 "Address Family modifier\n"
8938 "Address Family modifier\n"
8939 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008940 "Display routes matching the route-map\n"
8941 "A route-map to match on\n")
8942{
Lou Berger651b4022016-01-12 13:42:07 -05008943 safi_t safi;
8944 if (bgp_parse_safi(argv[0], &safi)) {
8945 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8946 return CMD_WARNING;
8947 }
8948 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008949 bgp_show_type_route_map);
8950}
8951
Lou Berger651b4022016-01-12 13:42:07 -05008952DEFUN (show_bgp_ipv6_route_map,
paul718e3742002-12-13 20:15:29 +00008953 show_bgp_ipv6_route_map_cmd,
8954 "show bgp ipv6 route-map WORD",
8955 SHOW_STR
8956 BGP_STR
8957 "Address family\n"
8958 "Display routes matching the route-map\n"
8959 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05008960{
8961 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8962 bgp_show_type_route_map);
8963}
David Lamparter6b0655a2014-06-04 06:53:35 +02008964
Lou Berger651b4022016-01-12 13:42:07 -05008965DEFUN (show_bgp_ipv4_cidr_only,
8966 show_bgp_ipv4_cidr_only_cmd,
8967 "show bgp ipv4 cidr-only",
paul718e3742002-12-13 20:15:29 +00008968 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008969 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008970 IP_STR
paul718e3742002-12-13 20:15:29 +00008971 "Display only routes with non-natural netmasks\n")
8972{
8973 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00008974 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00008975}
8976
Lou Berger651b4022016-01-12 13:42:07 -05008977DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
8978 show_bgp_ipv4_safi_flap_cidr_only_cmd,
8979 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
paul718e3742002-12-13 20:15:29 +00008980 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008981 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008982 "Address Family\n"
8983 "Address Family Modifier\n"
8984 "Address Family Modifier\n"
8985 "Address Family Modifier\n"
8986 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008987 "Display flap statistics of routes\n"
8988 "Display only routes with non-natural netmasks\n")
8989{
Lou Berger651b4022016-01-12 13:42:07 -05008990 safi_t safi;
8991
8992 if (bgp_parse_safi(argv[0], &safi)) {
8993 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8994 return CMD_WARNING;
8995 }
8996 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00008997}
8998
Lou Berger651b4022016-01-12 13:42:07 -05008999ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9000 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9001 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
Balaji3921cc52015-05-16 23:12:17 +05309002 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309003 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009004 "Address Family\n"
9005 "Address Family Modifier\n"
9006 "Address Family Modifier\n"
9007 "Address Family Modifier\n"
9008 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309009 "Display detailed information about dampening\n"
9010 "Display flap statistics of routes\n"
9011 "Display only routes with non-natural netmasks\n")
9012
Lou Berger651b4022016-01-12 13:42:07 -05009013DEFUN (show_bgp_ipv4_safi_cidr_only,
9014 show_bgp_ipv4_safi_cidr_only_cmd,
9015 "show bgp ipv4 (unicast|multicast) cidr-only",
paul718e3742002-12-13 20:15:29 +00009016 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009017 BGP_STR
9018 "Address family\n"
9019 "Address Family modifier\n"
9020 "Address Family modifier\n"
9021 "Display only routes with non-natural netmasks\n")
9022{
9023 if (strncmp (argv[0], "m", 1) == 0)
9024 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00009025 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009026
9027 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009028 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009029}
David Lamparter6b0655a2014-06-04 06:53:35 +02009030
Lou Berger651b4022016-01-12 13:42:07 -05009031/* new046 */
9032DEFUN (show_bgp_afi_safi_community_all,
9033 show_bgp_afi_safi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009034 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
paul718e3742002-12-13 20:15:29 +00009035 SHOW_STR
9036 BGP_STR
9037 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009038 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009039 "Address Family modifier\n"
9040 "Address Family modifier\n"
9041 "Address Family modifier\n"
9042 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009043 "Display routes matching the communities\n")
Lou Berger651b4022016-01-12 13:42:07 -05009044{
9045 safi_t safi;
9046 afi_t afi;
paul718e3742002-12-13 20:15:29 +00009047
Lou Berger651b4022016-01-12 13:42:07 -05009048 if (bgp_parse_afi(argv[0], &afi)) {
9049 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9050 return CMD_WARNING;
9051 }
9052 if (bgp_parse_safi(argv[1], &safi)) {
9053 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9054 return CMD_WARNING;
9055 }
9056
9057 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9058}
9059DEFUN (show_bgp_afi_community_all,
9060 show_bgp_afi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009061 "show bgp (ipv4|ipv6) community",
paul718e3742002-12-13 20:15:29 +00009062 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009063 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009064 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009065 "Address family\n"
paul718e3742002-12-13 20:15:29 +00009066 "Display routes matching the communities\n")
9067{
Lou Berger651b4022016-01-12 13:42:07 -05009068 afi_t afi;
9069 safi_t safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +00009070
Lou Berger651b4022016-01-12 13:42:07 -05009071 if (bgp_parse_afi(argv[0], &afi)) {
9072 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9073 return CMD_WARNING;
9074 }
9075 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00009076}
David Lamparter6b0655a2014-06-04 06:53:35 +02009077
paul94f2b392005-06-28 12:44:16 +00009078static int
Michael Lambert95cbbd22010-07-23 14:43:04 -04009079bgp_show_community (struct vty *vty, const char *view_name, int argc,
9080 const char **argv, int exact, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00009081{
9082 struct community *com;
9083 struct buffer *b;
Michael Lambert95cbbd22010-07-23 14:43:04 -04009084 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +00009085 int i;
9086 char *str;
9087 int first = 0;
9088
Michael Lambert95cbbd22010-07-23 14:43:04 -04009089 /* BGP structure lookup */
9090 if (view_name)
9091 {
9092 bgp = bgp_lookup_by_name (view_name);
9093 if (bgp == NULL)
9094 {
9095 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9096 return CMD_WARNING;
9097 }
9098 }
9099 else
9100 {
9101 bgp = bgp_get_default ();
9102 if (bgp == NULL)
9103 {
9104 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9105 return CMD_WARNING;
9106 }
9107 }
9108
paul718e3742002-12-13 20:15:29 +00009109 b = buffer_new (1024);
9110 for (i = 0; i < argc; i++)
9111 {
9112 if (first)
9113 buffer_putc (b, ' ');
9114 else
9115 {
9116 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9117 continue;
9118 first = 1;
9119 }
9120
9121 buffer_putstr (b, argv[i]);
9122 }
9123 buffer_putc (b, '\0');
9124
9125 str = buffer_getstr (b);
9126 buffer_free (b);
9127
9128 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00009129 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009130 if (! com)
9131 {
9132 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9133 return CMD_WARNING;
9134 }
9135
Michael Lambert95cbbd22010-07-23 14:43:04 -04009136 return bgp_show (vty, bgp, afi, safi,
ajs5a646652004-11-05 01:25:55 +00009137 (exact ? bgp_show_type_community_exact :
9138 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00009139}
9140
Lou Bergerf9b6c392016-01-12 13:42:09 -05009141DEFUN (show_ip_bgp_community,
9142 show_ip_bgp_community_cmd,
9143 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9144 SHOW_STR
9145 IP_STR
9146 BGP_STR
9147 "Display routes matching the communities\n"
9148 "community number\n"
9149 "Do not send outside local AS (well-known community)\n"
9150 "Do not advertise to any peer (well-known community)\n"
9151 "Do not export to next AS (well-known community)\n")
9152{
9153 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9154}
9155
9156ALIAS (show_ip_bgp_community,
9157 show_ip_bgp_community2_cmd,
9158 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9159 SHOW_STR
9160 IP_STR
9161 BGP_STR
9162 "Display routes matching the communities\n"
9163 "community number\n"
9164 "Do not send outside local AS (well-known community)\n"
9165 "Do not advertise to any peer (well-known community)\n"
9166 "Do not export to next AS (well-known community)\n"
9167 "community number\n"
9168 "Do not send outside local AS (well-known community)\n"
9169 "Do not advertise to any peer (well-known community)\n"
9170 "Do not export to next AS (well-known community)\n")
9171
9172ALIAS (show_ip_bgp_community,
9173 show_ip_bgp_community3_cmd,
9174 "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)",
9175 SHOW_STR
9176 IP_STR
9177 BGP_STR
9178 "Display routes matching the communities\n"
9179 "community number\n"
9180 "Do not send outside local AS (well-known community)\n"
9181 "Do not advertise to any peer (well-known community)\n"
9182 "Do not export to next AS (well-known community)\n"
9183 "community number\n"
9184 "Do not send outside local AS (well-known community)\n"
9185 "Do not advertise to any peer (well-known community)\n"
9186 "Do not export to next AS (well-known community)\n"
9187 "community number\n"
9188 "Do not send outside local AS (well-known community)\n"
9189 "Do not advertise to any peer (well-known community)\n"
9190 "Do not export to next AS (well-known community)\n")
9191
9192ALIAS (show_ip_bgp_community,
9193 show_ip_bgp_community4_cmd,
9194 "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)",
9195 SHOW_STR
9196 IP_STR
9197 BGP_STR
9198 "Display routes matching the communities\n"
9199 "community number\n"
9200 "Do not send outside local AS (well-known community)\n"
9201 "Do not advertise to any peer (well-known community)\n"
9202 "Do not export to next AS (well-known community)\n"
9203 "community number\n"
9204 "Do not send outside local AS (well-known community)\n"
9205 "Do not advertise to any peer (well-known community)\n"
9206 "Do not export to next AS (well-known community)\n"
9207 "community number\n"
9208 "Do not send outside local AS (well-known community)\n"
9209 "Do not advertise to any peer (well-known community)\n"
9210 "Do not export to next AS (well-known community)\n"
9211 "community number\n"
9212 "Do not send outside local AS (well-known community)\n"
9213 "Do not advertise to any peer (well-known community)\n"
9214 "Do not export to next AS (well-known community)\n")
9215
9216DEFUN (show_ip_bgp_ipv4_community,
9217 show_ip_bgp_ipv4_community_cmd,
9218 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9219 SHOW_STR
9220 IP_STR
9221 BGP_STR
9222 "Address family\n"
9223 "Address Family modifier\n"
9224 "Address Family modifier\n"
9225 "Display routes matching the communities\n"
9226 "community number\n"
9227 "Do not send outside local AS (well-known community)\n"
9228 "Do not advertise to any peer (well-known community)\n"
9229 "Do not export to next AS (well-known community)\n")
9230{
9231 if (strncmp (argv[0], "m", 1) == 0)
9232 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9233
9234 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9235}
9236
9237ALIAS (show_ip_bgp_ipv4_community,
9238 show_ip_bgp_ipv4_community2_cmd,
9239 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9240 SHOW_STR
9241 IP_STR
9242 BGP_STR
9243 "Address family\n"
9244 "Address Family modifier\n"
9245 "Address Family modifier\n"
9246 "Display routes matching the communities\n"
9247 "community number\n"
9248 "Do not send outside local AS (well-known community)\n"
9249 "Do not advertise to any peer (well-known community)\n"
9250 "Do not export to next AS (well-known community)\n"
9251 "community number\n"
9252 "Do not send outside local AS (well-known community)\n"
9253 "Do not advertise to any peer (well-known community)\n"
9254 "Do not export to next AS (well-known community)\n")
9255
9256ALIAS (show_ip_bgp_ipv4_community,
9257 show_ip_bgp_ipv4_community3_cmd,
9258 "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)",
9259 SHOW_STR
9260 IP_STR
9261 BGP_STR
9262 "Address family\n"
9263 "Address Family modifier\n"
9264 "Address Family modifier\n"
9265 "Display routes matching the communities\n"
9266 "community number\n"
9267 "Do not send outside local AS (well-known community)\n"
9268 "Do not advertise to any peer (well-known community)\n"
9269 "Do not export to next AS (well-known community)\n"
9270 "community number\n"
9271 "Do not send outside local AS (well-known community)\n"
9272 "Do not advertise to any peer (well-known community)\n"
9273 "Do not export to next AS (well-known community)\n"
9274 "community number\n"
9275 "Do not send outside local AS (well-known community)\n"
9276 "Do not advertise to any peer (well-known community)\n"
9277 "Do not export to next AS (well-known community)\n")
9278
9279ALIAS (show_ip_bgp_ipv4_community,
9280 show_ip_bgp_ipv4_community4_cmd,
9281 "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)",
9282 SHOW_STR
9283 IP_STR
9284 BGP_STR
9285 "Address family\n"
9286 "Address Family modifier\n"
9287 "Address Family modifier\n"
9288 "Display routes matching the communities\n"
9289 "community number\n"
9290 "Do not send outside local AS (well-known community)\n"
9291 "Do not advertise to any peer (well-known community)\n"
9292 "Do not export to next AS (well-known community)\n"
9293 "community number\n"
9294 "Do not send outside local AS (well-known community)\n"
9295 "Do not advertise to any peer (well-known community)\n"
9296 "Do not export to next AS (well-known community)\n"
9297 "community number\n"
9298 "Do not send outside local AS (well-known community)\n"
9299 "Do not advertise to any peer (well-known community)\n"
9300 "Do not export to next AS (well-known community)\n"
9301 "community number\n"
9302 "Do not send outside local AS (well-known community)\n"
9303 "Do not advertise to any peer (well-known community)\n"
9304 "Do not export to next AS (well-known community)\n")
9305
9306DEFUN (show_ip_bgp_community_exact,
9307 show_ip_bgp_community_exact_cmd,
9308 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9309 SHOW_STR
9310 IP_STR
9311 BGP_STR
9312 "Display routes matching the communities\n"
9313 "community number\n"
9314 "Do not send outside local AS (well-known community)\n"
9315 "Do not advertise to any peer (well-known community)\n"
9316 "Do not export to next AS (well-known community)\n"
9317 "Exact match of the communities")
9318{
9319 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9320}
9321
9322ALIAS (show_ip_bgp_community_exact,
9323 show_ip_bgp_community2_exact_cmd,
9324 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9325 SHOW_STR
9326 IP_STR
9327 BGP_STR
9328 "Display routes matching the communities\n"
9329 "community number\n"
9330 "Do not send outside local AS (well-known community)\n"
9331 "Do not advertise to any peer (well-known community)\n"
9332 "Do not export to next AS (well-known community)\n"
9333 "community number\n"
9334 "Do not send outside local AS (well-known community)\n"
9335 "Do not advertise to any peer (well-known community)\n"
9336 "Do not export to next AS (well-known community)\n"
9337 "Exact match of the communities")
9338
9339ALIAS (show_ip_bgp_community_exact,
9340 show_ip_bgp_community3_exact_cmd,
9341 "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",
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 "community number\n"
9351 "Do not send outside local AS (well-known community)\n"
9352 "Do not advertise to any peer (well-known community)\n"
9353 "Do not export to next AS (well-known community)\n"
9354 "community number\n"
9355 "Do not send outside local AS (well-known community)\n"
9356 "Do not advertise to any peer (well-known community)\n"
9357 "Do not export to next AS (well-known community)\n"
9358 "Exact match of the communities")
9359
9360ALIAS (show_ip_bgp_community_exact,
9361 show_ip_bgp_community4_exact_cmd,
9362 "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",
9363 SHOW_STR
9364 IP_STR
9365 BGP_STR
9366 "Display routes matching the communities\n"
9367 "community number\n"
9368 "Do not send outside local AS (well-known community)\n"
9369 "Do not advertise to any peer (well-known community)\n"
9370 "Do not export to next AS (well-known community)\n"
9371 "community number\n"
9372 "Do not send outside local AS (well-known community)\n"
9373 "Do not advertise to any peer (well-known community)\n"
9374 "Do not export to next AS (well-known community)\n"
9375 "community number\n"
9376 "Do not send outside local AS (well-known community)\n"
9377 "Do not advertise to any peer (well-known community)\n"
9378 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
9384
9385DEFUN (show_ip_bgp_ipv4_community_exact,
9386 show_ip_bgp_ipv4_community_exact_cmd,
9387 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9388 SHOW_STR
9389 IP_STR
9390 BGP_STR
9391 "Address family\n"
9392 "Address Family modifier\n"
9393 "Address Family modifier\n"
9394 "Display routes matching the communities\n"
9395 "community number\n"
9396 "Do not send outside local AS (well-known community)\n"
9397 "Do not advertise to any peer (well-known community)\n"
9398 "Do not export to next AS (well-known community)\n"
9399 "Exact match of the communities")
9400{
9401 if (strncmp (argv[0], "m", 1) == 0)
9402 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9403
9404 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9405}
9406
9407ALIAS (show_ip_bgp_ipv4_community_exact,
9408 show_ip_bgp_ipv4_community2_exact_cmd,
9409 "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",
9410 SHOW_STR
9411 IP_STR
9412 BGP_STR
9413 "Address family\n"
9414 "Address Family modifier\n"
9415 "Address Family modifier\n"
9416 "Display routes matching the communities\n"
9417 "community number\n"
9418 "Do not send outside local AS (well-known community)\n"
9419 "Do not advertise to any peer (well-known community)\n"
9420 "Do not export to next AS (well-known community)\n"
9421 "community number\n"
9422 "Do not send outside local AS (well-known community)\n"
9423 "Do not advertise to any peer (well-known community)\n"
9424 "Do not export to next AS (well-known community)\n"
9425 "Exact match of the communities")
9426
9427ALIAS (show_ip_bgp_ipv4_community_exact,
9428 show_ip_bgp_ipv4_community3_exact_cmd,
9429 "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",
9430 SHOW_STR
9431 IP_STR
9432 BGP_STR
9433 "Address family\n"
9434 "Address Family modifier\n"
9435 "Address Family modifier\n"
9436 "Display routes matching the communities\n"
9437 "community number\n"
9438 "Do not send outside local AS (well-known community)\n"
9439 "Do not advertise to any peer (well-known community)\n"
9440 "Do not export to next AS (well-known community)\n"
9441 "community number\n"
9442 "Do not send outside local AS (well-known community)\n"
9443 "Do not advertise to any peer (well-known community)\n"
9444 "Do not export to next AS (well-known community)\n"
9445 "community number\n"
9446 "Do not send outside local AS (well-known community)\n"
9447 "Do not advertise to any peer (well-known community)\n"
9448 "Do not export to next AS (well-known community)\n"
9449 "Exact match of the communities")
9450
9451ALIAS (show_ip_bgp_ipv4_community_exact,
9452 show_ip_bgp_ipv4_community4_exact_cmd,
9453 "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",
9454 SHOW_STR
9455 IP_STR
9456 BGP_STR
9457 "Address family\n"
9458 "Address Family modifier\n"
9459 "Address Family modifier\n"
9460 "Display routes matching the communities\n"
9461 "community number\n"
9462 "Do not send outside local AS (well-known community)\n"
9463 "Do not advertise to any peer (well-known community)\n"
9464 "Do not export to next AS (well-known community)\n"
9465 "community number\n"
9466 "Do not send outside local AS (well-known community)\n"
9467 "Do not advertise to any peer (well-known community)\n"
9468 "Do not export to next AS (well-known community)\n"
9469 "community number\n"
9470 "Do not send outside local AS (well-known community)\n"
9471 "Do not advertise to any peer (well-known community)\n"
9472 "Do not export to next AS (well-known community)\n"
9473 "community number\n"
9474 "Do not send outside local AS (well-known community)\n"
9475 "Do not advertise to any peer (well-known community)\n"
9476 "Do not export to next AS (well-known community)\n"
9477 "Exact match of the communities")
9478
Lou Bergerf9b6c392016-01-12 13:42:09 -05009479DEFUN (show_bgp_community,
9480 show_bgp_community_cmd,
9481 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9482 SHOW_STR
9483 BGP_STR
9484 "Display routes matching the communities\n"
9485 "community number\n"
9486 "Do not send outside local AS (well-known community)\n"
9487 "Do not advertise to any peer (well-known community)\n"
9488 "Do not export to next AS (well-known community)\n")
9489{
9490 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9491}
9492
9493ALIAS (show_bgp_community,
9494 show_bgp_ipv6_community_cmd,
9495 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9496 SHOW_STR
9497 BGP_STR
9498 "Address family\n"
9499 "Display routes matching the communities\n"
9500 "community number\n"
9501 "Do not send outside local AS (well-known community)\n"
9502 "Do not advertise to any peer (well-known community)\n"
9503 "Do not export to next AS (well-known community)\n")
9504
9505ALIAS (show_bgp_community,
9506 show_bgp_community2_cmd,
9507 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9508 SHOW_STR
9509 BGP_STR
9510 "Display routes matching the communities\n"
9511 "community number\n"
9512 "Do not send outside local AS (well-known community)\n"
9513 "Do not advertise to any peer (well-known community)\n"
9514 "Do not export to next AS (well-known community)\n"
9515 "community number\n"
9516 "Do not send outside local AS (well-known community)\n"
9517 "Do not advertise to any peer (well-known community)\n"
9518 "Do not export to next AS (well-known community)\n")
9519
9520ALIAS (show_bgp_community,
9521 show_bgp_ipv6_community2_cmd,
9522 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9523 SHOW_STR
9524 BGP_STR
9525 "Address family\n"
9526 "Display routes matching the communities\n"
9527 "community number\n"
9528 "Do not send outside local AS (well-known community)\n"
9529 "Do not advertise to any peer (well-known community)\n"
9530 "Do not export to next AS (well-known community)\n"
9531 "community number\n"
9532 "Do not send outside local AS (well-known community)\n"
9533 "Do not advertise to any peer (well-known community)\n"
9534 "Do not export to next AS (well-known community)\n")
9535
9536ALIAS (show_bgp_community,
9537 show_bgp_community3_cmd,
9538 "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)",
9539 SHOW_STR
9540 BGP_STR
9541 "Display routes matching the communities\n"
9542 "community number\n"
9543 "Do not send outside local AS (well-known community)\n"
9544 "Do not advertise to any peer (well-known community)\n"
9545 "Do not export to next AS (well-known community)\n"
9546 "community number\n"
9547 "Do not send outside local AS (well-known community)\n"
9548 "Do not advertise to any peer (well-known community)\n"
9549 "Do not export to next AS (well-known community)\n"
9550 "community number\n"
9551 "Do not send outside local AS (well-known community)\n"
9552 "Do not advertise to any peer (well-known community)\n"
9553 "Do not export to next AS (well-known community)\n")
9554
9555ALIAS (show_bgp_community,
9556 show_bgp_ipv6_community3_cmd,
9557 "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)",
9558 SHOW_STR
9559 BGP_STR
9560 "Address family\n"
9561 "Display routes matching the communities\n"
9562 "community number\n"
9563 "Do not send outside local AS (well-known community)\n"
9564 "Do not advertise to any peer (well-known community)\n"
9565 "Do not export to next AS (well-known community)\n"
9566 "community number\n"
9567 "Do not send outside local AS (well-known community)\n"
9568 "Do not advertise to any peer (well-known community)\n"
9569 "Do not export to next AS (well-known community)\n"
9570 "community number\n"
9571 "Do not send outside local AS (well-known community)\n"
9572 "Do not advertise to any peer (well-known community)\n"
9573 "Do not export to next AS (well-known community)\n")
9574
9575ALIAS (show_bgp_community,
9576 show_bgp_community4_cmd,
9577 "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)",
9578 SHOW_STR
9579 BGP_STR
9580 "Display routes matching the communities\n"
9581 "community number\n"
9582 "Do not send outside local AS (well-known community)\n"
9583 "Do not advertise to any peer (well-known community)\n"
9584 "Do not export to next AS (well-known community)\n"
9585 "community number\n"
9586 "Do not send outside local AS (well-known community)\n"
9587 "Do not advertise to any peer (well-known community)\n"
9588 "Do not export to next AS (well-known community)\n"
9589 "community number\n"
9590 "Do not send outside local AS (well-known community)\n"
9591 "Do not advertise to any peer (well-known community)\n"
9592 "Do not export to next AS (well-known community)\n"
9593 "community number\n"
9594 "Do not send outside local AS (well-known community)\n"
9595 "Do not advertise to any peer (well-known community)\n"
9596 "Do not export to next AS (well-known community)\n")
9597
9598ALIAS (show_bgp_community,
9599 show_bgp_ipv6_community4_cmd,
9600 "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)",
9601 SHOW_STR
9602 BGP_STR
9603 "Address family\n"
9604 "Display routes matching the communities\n"
9605 "community number\n"
9606 "Do not send outside local AS (well-known community)\n"
9607 "Do not advertise to any peer (well-known community)\n"
9608 "Do not export to next AS (well-known community)\n"
9609 "community number\n"
9610 "Do not send outside local AS (well-known community)\n"
9611 "Do not advertise to any peer (well-known community)\n"
9612 "Do not export to next AS (well-known community)\n"
9613 "community number\n"
9614 "Do not send outside local AS (well-known community)\n"
9615 "Do not advertise to any peer (well-known community)\n"
9616 "Do not export to next AS (well-known community)\n"
9617 "community number\n"
9618 "Do not send outside local AS (well-known community)\n"
9619 "Do not advertise to any peer (well-known community)\n"
9620 "Do not export to next AS (well-known community)\n")
9621
9622/* old command */
9623DEFUN (show_ipv6_bgp_community,
9624 show_ipv6_bgp_community_cmd,
9625 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9626 SHOW_STR
9627 IPV6_STR
9628 BGP_STR
9629 "Display routes matching the communities\n"
9630 "community number\n"
9631 "Do not send outside local AS (well-known community)\n"
9632 "Do not advertise to any peer (well-known community)\n"
9633 "Do not export to next AS (well-known community)\n")
9634{
9635 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9636}
9637
9638/* old command */
9639ALIAS (show_ipv6_bgp_community,
9640 show_ipv6_bgp_community2_cmd,
9641 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9642 SHOW_STR
9643 IPV6_STR
9644 BGP_STR
9645 "Display routes matching the communities\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 */
9656ALIAS (show_ipv6_bgp_community,
9657 show_ipv6_bgp_community3_cmd,
9658 "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)",
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 "community number\n"
9668 "Do not send outside local AS (well-known community)\n"
9669 "Do not advertise to any peer (well-known community)\n"
9670 "Do not export to next AS (well-known community)\n"
9671 "community number\n"
9672 "Do not send outside local AS (well-known community)\n"
9673 "Do not advertise to any peer (well-known community)\n"
9674 "Do not export to next AS (well-known community)\n")
9675
9676/* old command */
9677ALIAS (show_ipv6_bgp_community,
9678 show_ipv6_bgp_community4_cmd,
9679 "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)",
9680 SHOW_STR
9681 IPV6_STR
9682 BGP_STR
9683 "Display routes matching the communities\n"
9684 "community number\n"
9685 "Do not send outside local AS (well-known community)\n"
9686 "Do not advertise to any peer (well-known community)\n"
9687 "Do not export to next AS (well-known community)\n"
9688 "community number\n"
9689 "Do not send outside local AS (well-known community)\n"
9690 "Do not advertise to any peer (well-known community)\n"
9691 "Do not export to next AS (well-known community)\n"
9692 "community number\n"
9693 "Do not send outside local AS (well-known community)\n"
9694 "Do not advertise to any peer (well-known community)\n"
9695 "Do not export to next AS (well-known community)\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
9701DEFUN (show_bgp_community_exact,
9702 show_bgp_community_exact_cmd,
9703 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9704 SHOW_STR
9705 BGP_STR
9706 "Display routes matching the communities\n"
9707 "community number\n"
9708 "Do not send outside local AS (well-known community)\n"
9709 "Do not advertise to any peer (well-known community)\n"
9710 "Do not export to next AS (well-known community)\n"
9711 "Exact match of the communities")
9712{
9713 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9714}
9715
9716ALIAS (show_bgp_community_exact,
9717 show_bgp_ipv6_community_exact_cmd,
9718 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9719 SHOW_STR
9720 BGP_STR
9721 "Address family\n"
9722 "Display routes matching the communities\n"
9723 "community number\n"
9724 "Do not send outside local AS (well-known community)\n"
9725 "Do not advertise to any peer (well-known community)\n"
9726 "Do not export to next AS (well-known community)\n"
9727 "Exact match of the communities")
9728
9729ALIAS (show_bgp_community_exact,
9730 show_bgp_community2_exact_cmd,
9731 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9732 SHOW_STR
9733 BGP_STR
9734 "Display routes matching the communities\n"
9735 "community number\n"
9736 "Do not send outside local AS (well-known community)\n"
9737 "Do not advertise to any peer (well-known community)\n"
9738 "Do not export to next AS (well-known community)\n"
9739 "community number\n"
9740 "Do not send outside local AS (well-known community)\n"
9741 "Do not advertise to any peer (well-known community)\n"
9742 "Do not export to next AS (well-known community)\n"
9743 "Exact match of the communities")
9744
9745ALIAS (show_bgp_community_exact,
9746 show_bgp_ipv6_community2_exact_cmd,
9747 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9748 SHOW_STR
9749 BGP_STR
9750 "Address family\n"
9751 "Display routes matching the communities\n"
9752 "community number\n"
9753 "Do not send outside local AS (well-known community)\n"
9754 "Do not advertise to any peer (well-known community)\n"
9755 "Do not export to next AS (well-known community)\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_community3_exact_cmd,
9764 "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",
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 "community number\n"
9777 "Do not send outside local AS (well-known community)\n"
9778 "Do not advertise to any peer (well-known community)\n"
9779 "Do not export to next AS (well-known community)\n"
9780 "Exact match of the communities")
9781
9782ALIAS (show_bgp_community_exact,
9783 show_bgp_ipv6_community3_exact_cmd,
9784 "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",
9785 SHOW_STR
9786 BGP_STR
9787 "Address family\n"
9788 "Display routes matching the communities\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 "community number\n"
9794 "Do not send outside local AS (well-known community)\n"
9795 "Do not advertise to any peer (well-known community)\n"
9796 "Do not export to next AS (well-known community)\n"
9797 "community number\n"
9798 "Do not send outside local AS (well-known community)\n"
9799 "Do not advertise to any peer (well-known community)\n"
9800 "Do not export to next AS (well-known community)\n"
9801 "Exact match of the communities")
9802
9803ALIAS (show_bgp_community_exact,
9804 show_bgp_community4_exact_cmd,
9805 "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",
9806 SHOW_STR
9807 BGP_STR
9808 "Display routes matching the communities\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 "community number\n"
9814 "Do not send outside local AS (well-known community)\n"
9815 "Do not advertise to any peer (well-known community)\n"
9816 "Do not export to next AS (well-known community)\n"
9817 "community number\n"
9818 "Do not send outside local AS (well-known community)\n"
9819 "Do not advertise to any peer (well-known community)\n"
9820 "Do not export to next AS (well-known community)\n"
9821 "community number\n"
9822 "Do not send outside local AS (well-known community)\n"
9823 "Do not advertise to any peer (well-known community)\n"
9824 "Do not export to next AS (well-known community)\n"
9825 "Exact match of the communities")
9826
9827ALIAS (show_bgp_community_exact,
9828 show_bgp_ipv6_community4_exact_cmd,
9829 "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",
9830 SHOW_STR
9831 BGP_STR
9832 "Address family\n"
9833 "Display routes matching the communities\n"
9834 "community number\n"
9835 "Do not send outside local AS (well-known community)\n"
9836 "Do not advertise to any peer (well-known community)\n"
9837 "Do not export to next AS (well-known community)\n"
9838 "community number\n"
9839 "Do not send outside local AS (well-known community)\n"
9840 "Do not advertise to any peer (well-known community)\n"
9841 "Do not export to next AS (well-known community)\n"
9842 "community number\n"
9843 "Do not send outside local AS (well-known community)\n"
9844 "Do not advertise to any peer (well-known community)\n"
9845 "Do not export to next AS (well-known community)\n"
9846 "community number\n"
9847 "Do not send outside local AS (well-known community)\n"
9848 "Do not advertise to any peer (well-known community)\n"
9849 "Do not export to next AS (well-known community)\n"
9850 "Exact match of the communities")
9851
9852/* old command */
9853DEFUN (show_ipv6_bgp_community_exact,
9854 show_ipv6_bgp_community_exact_cmd,
9855 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9856 SHOW_STR
9857 IPV6_STR
9858 BGP_STR
9859 "Display routes matching the communities\n"
9860 "community number\n"
9861 "Do not send outside local AS (well-known community)\n"
9862 "Do not advertise to any peer (well-known community)\n"
9863 "Do not export to next AS (well-known community)\n"
9864 "Exact match of the communities")
9865{
9866 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9867}
9868
9869/* old command */
9870ALIAS (show_ipv6_bgp_community_exact,
9871 show_ipv6_bgp_community2_exact_cmd,
9872 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9873 SHOW_STR
9874 IPV6_STR
9875 BGP_STR
9876 "Display routes matching the communities\n"
9877 "community number\n"
9878 "Do not send outside local AS (well-known community)\n"
9879 "Do not advertise to any peer (well-known community)\n"
9880 "Do not export to next AS (well-known community)\n"
9881 "community number\n"
9882 "Do not send outside local AS (well-known community)\n"
9883 "Do not advertise to any peer (well-known community)\n"
9884 "Do not export to next AS (well-known community)\n"
9885 "Exact match of the communities")
9886
9887/* old command */
9888ALIAS (show_ipv6_bgp_community_exact,
9889 show_ipv6_bgp_community3_exact_cmd,
9890 "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",
9891 SHOW_STR
9892 IPV6_STR
9893 BGP_STR
9894 "Display routes matching the communities\n"
9895 "community number\n"
9896 "Do not send outside local AS (well-known community)\n"
9897 "Do not advertise to any peer (well-known community)\n"
9898 "Do not export to next AS (well-known community)\n"
9899 "community number\n"
9900 "Do not send outside local AS (well-known community)\n"
9901 "Do not advertise to any peer (well-known community)\n"
9902 "Do not export to next AS (well-known community)\n"
9903 "community number\n"
9904 "Do not send outside local AS (well-known community)\n"
9905 "Do not advertise to any peer (well-known community)\n"
9906 "Do not export to next AS (well-known community)\n"
9907 "Exact match of the communities")
9908
9909/* old command */
9910ALIAS (show_ipv6_bgp_community_exact,
9911 show_ipv6_bgp_community4_exact_cmd,
9912 "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",
9913 SHOW_STR
9914 IPV6_STR
9915 BGP_STR
9916 "Display routes matching the communities\n"
9917 "community number\n"
9918 "Do not send outside local AS (well-known community)\n"
9919 "Do not advertise to any peer (well-known community)\n"
9920 "Do not export to next AS (well-known community)\n"
9921 "community number\n"
9922 "Do not send outside local AS (well-known community)\n"
9923 "Do not advertise to any peer (well-known community)\n"
9924 "Do not export to next AS (well-known community)\n"
9925 "community number\n"
9926 "Do not send outside local AS (well-known community)\n"
9927 "Do not advertise to any peer (well-known community)\n"
9928 "Do not export to next AS (well-known community)\n"
9929 "community number\n"
9930 "Do not send outside local AS (well-known community)\n"
9931 "Do not advertise to any peer (well-known community)\n"
9932 "Do not export to next AS (well-known community)\n"
9933 "Exact match of the communities")
9934
9935/* old command */
9936DEFUN (show_ipv6_mbgp_community,
9937 show_ipv6_mbgp_community_cmd,
9938 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
9939 SHOW_STR
9940 IPV6_STR
9941 MBGP_STR
9942 "Display routes matching the communities\n"
9943 "community number\n"
9944 "Do not send outside local AS (well-known community)\n"
9945 "Do not advertise to any peer (well-known community)\n"
9946 "Do not export to next AS (well-known community)\n")
9947{
9948 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
9949}
9950
9951/* old command */
9952ALIAS (show_ipv6_mbgp_community,
9953 show_ipv6_mbgp_community2_cmd,
9954 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9955 SHOW_STR
9956 IPV6_STR
9957 MBGP_STR
9958 "Display routes matching the communities\n"
9959 "community number\n"
9960 "Do not send outside local AS (well-known community)\n"
9961 "Do not advertise to any peer (well-known community)\n"
9962 "Do not export to next AS (well-known community)\n"
9963 "community number\n"
9964 "Do not send outside local AS (well-known community)\n"
9965 "Do not advertise to any peer (well-known community)\n"
9966 "Do not export to next AS (well-known community)\n")
9967
9968/* old command */
9969ALIAS (show_ipv6_mbgp_community,
9970 show_ipv6_mbgp_community3_cmd,
9971 "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)",
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 "community number\n"
9981 "Do not send outside local AS (well-known community)\n"
9982 "Do not advertise to any peer (well-known community)\n"
9983 "Do not export to next AS (well-known community)\n"
9984 "community number\n"
9985 "Do not send outside local AS (well-known community)\n"
9986 "Do not advertise to any peer (well-known community)\n"
9987 "Do not export to next AS (well-known community)\n")
9988
9989/* old command */
9990ALIAS (show_ipv6_mbgp_community,
9991 show_ipv6_mbgp_community4_cmd,
9992 "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)",
9993 SHOW_STR
9994 IPV6_STR
9995 MBGP_STR
9996 "Display routes matching the communities\n"
9997 "community number\n"
9998 "Do not send outside local AS (well-known community)\n"
9999 "Do not advertise to any peer (well-known community)\n"
10000 "Do not export to next AS (well-known community)\n"
10001 "community number\n"
10002 "Do not send outside local AS (well-known community)\n"
10003 "Do not advertise to any peer (well-known community)\n"
10004 "Do not export to next AS (well-known community)\n"
10005 "community number\n"
10006 "Do not send outside local AS (well-known community)\n"
10007 "Do not advertise to any peer (well-known community)\n"
10008 "Do not export to next AS (well-known community)\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
10014/* old command */
10015DEFUN (show_ipv6_mbgp_community_exact,
10016 show_ipv6_mbgp_community_exact_cmd,
10017 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10018 SHOW_STR
10019 IPV6_STR
10020 MBGP_STR
10021 "Display routes matching the communities\n"
10022 "community number\n"
10023 "Do not send outside local AS (well-known community)\n"
10024 "Do not advertise to any peer (well-known community)\n"
10025 "Do not export to next AS (well-known community)\n"
10026 "Exact match of the communities")
10027{
10028 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10029}
10030
10031/* old command */
10032ALIAS (show_ipv6_mbgp_community_exact,
10033 show_ipv6_mbgp_community2_exact_cmd,
10034 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10035 SHOW_STR
10036 IPV6_STR
10037 MBGP_STR
10038 "Display routes matching the communities\n"
10039 "community number\n"
10040 "Do not send outside local AS (well-known community)\n"
10041 "Do not advertise to any peer (well-known community)\n"
10042 "Do not export to next AS (well-known community)\n"
10043 "community number\n"
10044 "Do not send outside local AS (well-known community)\n"
10045 "Do not advertise to any peer (well-known community)\n"
10046 "Do not export to next AS (well-known community)\n"
10047 "Exact match of the communities")
10048
10049/* old command */
10050ALIAS (show_ipv6_mbgp_community_exact,
10051 show_ipv6_mbgp_community3_exact_cmd,
10052 "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",
10053 SHOW_STR
10054 IPV6_STR
10055 MBGP_STR
10056 "Display routes matching the communities\n"
10057 "community number\n"
10058 "Do not send outside local AS (well-known community)\n"
10059 "Do not advertise to any peer (well-known community)\n"
10060 "Do not export to next AS (well-known community)\n"
10061 "community number\n"
10062 "Do not send outside local AS (well-known community)\n"
10063 "Do not advertise to any peer (well-known community)\n"
10064 "Do not export to next AS (well-known community)\n"
10065 "community number\n"
10066 "Do not send outside local AS (well-known community)\n"
10067 "Do not advertise to any peer (well-known community)\n"
10068 "Do not export to next AS (well-known community)\n"
10069 "Exact match of the communities")
10070
10071/* old command */
10072ALIAS (show_ipv6_mbgp_community_exact,
10073 show_ipv6_mbgp_community4_exact_cmd,
10074 "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",
10075 SHOW_STR
10076 IPV6_STR
10077 MBGP_STR
10078 "Display routes matching the communities\n"
10079 "community number\n"
10080 "Do not send outside local AS (well-known community)\n"
10081 "Do not advertise to any peer (well-known community)\n"
10082 "Do not export to next AS (well-known community)\n"
10083 "community number\n"
10084 "Do not send outside local AS (well-known community)\n"
10085 "Do not advertise to any peer (well-known community)\n"
10086 "Do not export to next AS (well-known community)\n"
10087 "community number\n"
10088 "Do not send outside local AS (well-known community)\n"
10089 "Do not advertise to any peer (well-known community)\n"
10090 "Do not export to next AS (well-known community)\n"
10091 "community number\n"
10092 "Do not send outside local AS (well-known community)\n"
10093 "Do not advertise to any peer (well-known community)\n"
10094 "Do not export to next AS (well-known community)\n"
10095 "Exact match of the communities")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010096
Lou Berger651b4022016-01-12 13:42:07 -050010097DEFUN (show_bgp_ipv4_community,
10098 show_bgp_ipv4_community_cmd,
10099 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010100 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010101 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010102 IP_STR
paul718e3742002-12-13 20:15:29 +000010103 "Display routes matching the communities\n"
10104 "community number\n"
10105 "Do not send outside local AS (well-known community)\n"
10106 "Do not advertise to any peer (well-known community)\n"
10107 "Do not export to next AS (well-known community)\n")
10108{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010109 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010110}
10111
Lou Berger651b4022016-01-12 13:42:07 -050010112ALIAS (show_bgp_ipv4_community,
10113 show_bgp_ipv4_community2_cmd,
10114 "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 +000010115 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010116 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010117 IP_STR
paul718e3742002-12-13 20:15:29 +000010118 "Display routes matching the communities\n"
10119 "community number\n"
10120 "Do not send outside local AS (well-known community)\n"
10121 "Do not advertise to any peer (well-known community)\n"
10122 "Do not export to next AS (well-known community)\n"
10123 "community number\n"
10124 "Do not send outside local AS (well-known community)\n"
10125 "Do not advertise to any peer (well-known community)\n"
10126 "Do not export to next AS (well-known community)\n")
10127
Lou Berger651b4022016-01-12 13:42:07 -050010128ALIAS (show_bgp_ipv4_community,
10129 show_bgp_ipv4_community3_cmd,
10130 "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 +000010131 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010132 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010133 IP_STR
paul718e3742002-12-13 20:15:29 +000010134 "Display routes matching the communities\n"
10135 "community number\n"
10136 "Do not send outside local AS (well-known community)\n"
10137 "Do not advertise to any peer (well-known community)\n"
10138 "Do not export to next AS (well-known community)\n"
10139 "community number\n"
10140 "Do not send outside local AS (well-known community)\n"
10141 "Do not advertise to any peer (well-known community)\n"
10142 "Do not export to next AS (well-known community)\n"
10143 "community number\n"
10144 "Do not send outside local AS (well-known community)\n"
10145 "Do not advertise to any peer (well-known community)\n"
10146 "Do not export to next AS (well-known community)\n")
10147
Lou Berger651b4022016-01-12 13:42:07 -050010148ALIAS (show_bgp_ipv4_community,
10149 show_bgp_ipv4_community4_cmd,
10150 "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 +000010151 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010152 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010153 IP_STR
paul718e3742002-12-13 20:15:29 +000010154 "Display routes matching the communities\n"
10155 "community number\n"
10156 "Do not send outside local AS (well-known community)\n"
10157 "Do not advertise to any peer (well-known community)\n"
10158 "Do not export to next AS (well-known community)\n"
10159 "community number\n"
10160 "Do not send outside local AS (well-known community)\n"
10161 "Do not advertise to any peer (well-known community)\n"
10162 "Do not export to next AS (well-known community)\n"
10163 "community number\n"
10164 "Do not send outside local AS (well-known community)\n"
10165 "Do not advertise to any peer (well-known community)\n"
10166 "Do not export to next AS (well-known community)\n"
10167 "community number\n"
10168 "Do not send outside local AS (well-known community)\n"
10169 "Do not advertise to any peer (well-known community)\n"
10170 "Do not export to next AS (well-known community)\n")
10171
Lou Berger651b4022016-01-12 13:42:07 -050010172DEFUN (show_bgp_ipv4_safi_community,
10173 show_bgp_ipv4_safi_community_cmd,
10174 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010175 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010176 BGP_STR
10177 "Address family\n"
10178 "Address Family modifier\n"
10179 "Address Family modifier\n"
10180 "Display routes matching the communities\n"
10181 "community number\n"
10182 "Do not send outside local AS (well-known community)\n"
10183 "Do not advertise to any peer (well-known community)\n"
10184 "Do not export to next AS (well-known community)\n")
10185{
10186 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010187 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010188
Michael Lambert95cbbd22010-07-23 14:43:04 -040010189 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010190}
10191
Lou Berger651b4022016-01-12 13:42:07 -050010192ALIAS (show_bgp_ipv4_safi_community,
10193 show_bgp_ipv4_safi_community2_cmd,
10194 "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 +000010195 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010196 BGP_STR
10197 "Address family\n"
10198 "Address Family modifier\n"
10199 "Address Family modifier\n"
10200 "Display routes matching the communities\n"
10201 "community number\n"
10202 "Do not send outside local AS (well-known community)\n"
10203 "Do not advertise to any peer (well-known community)\n"
10204 "Do not export to next AS (well-known community)\n"
10205 "community number\n"
10206 "Do not send outside local AS (well-known community)\n"
10207 "Do not advertise to any peer (well-known community)\n"
10208 "Do not export to next AS (well-known community)\n")
10209
Lou Berger651b4022016-01-12 13:42:07 -050010210ALIAS (show_bgp_ipv4_safi_community,
10211 show_bgp_ipv4_safi_community3_cmd,
10212 "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 +000010213 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010214 BGP_STR
10215 "Address family\n"
10216 "Address Family modifier\n"
10217 "Address Family modifier\n"
10218 "Display routes matching the communities\n"
10219 "community number\n"
10220 "Do not send outside local AS (well-known community)\n"
10221 "Do not advertise to any peer (well-known community)\n"
10222 "Do not export to next AS (well-known community)\n"
10223 "community number\n"
10224 "Do not send outside local AS (well-known community)\n"
10225 "Do not advertise to any peer (well-known community)\n"
10226 "Do not export to next AS (well-known community)\n"
10227 "community number\n"
10228 "Do not send outside local AS (well-known community)\n"
10229 "Do not advertise to any peer (well-known community)\n"
10230 "Do not export to next AS (well-known community)\n")
10231
Lou Berger651b4022016-01-12 13:42:07 -050010232ALIAS (show_bgp_ipv4_safi_community,
10233 show_bgp_ipv4_safi_community4_cmd,
10234 "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 +000010235 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010236 BGP_STR
10237 "Address family\n"
10238 "Address Family modifier\n"
10239 "Address Family modifier\n"
10240 "Display routes matching the communities\n"
10241 "community number\n"
10242 "Do not send outside local AS (well-known community)\n"
10243 "Do not advertise to any peer (well-known community)\n"
10244 "Do not export to next AS (well-known community)\n"
10245 "community number\n"
10246 "Do not send outside local AS (well-known community)\n"
10247 "Do not advertise to any peer (well-known community)\n"
10248 "Do not export to next AS (well-known community)\n"
10249 "community number\n"
10250 "Do not send outside local AS (well-known community)\n"
10251 "Do not advertise to any peer (well-known community)\n"
10252 "Do not export to next AS (well-known community)\n"
10253 "community number\n"
10254 "Do not send outside local AS (well-known community)\n"
10255 "Do not advertise to any peer (well-known community)\n"
10256 "Do not export to next AS (well-known community)\n")
10257
Michael Lambert95cbbd22010-07-23 14:43:04 -040010258DEFUN (show_bgp_view_afi_safi_community_all,
10259 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010260 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010261 SHOW_STR
10262 BGP_STR
10263 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010264 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010265 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010266 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010267 "Address Family modifier\n"
10268 "Address Family modifier\n"
Christian Franke2b005152013-09-30 12:27:49 +000010269 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010270{
10271 int afi;
10272 int safi;
10273 struct bgp *bgp;
10274
10275 /* BGP structure lookup. */
10276 bgp = bgp_lookup_by_name (argv[0]);
10277 if (bgp == NULL)
10278 {
10279 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10280 return CMD_WARNING;
10281 }
10282
Michael Lambert95cbbd22010-07-23 14:43:04 -040010283 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10284 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010285 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10286}
10287
10288DEFUN (show_bgp_view_afi_safi_community,
10289 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010290 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010291 SHOW_STR
10292 BGP_STR
10293 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010294 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010295 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010296 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010297 "Address family modifier\n"
10298 "Address family modifier\n"
10299 "Display routes matching the communities\n"
10300 "community number\n"
10301 "Do not send outside local AS (well-known community)\n"
10302 "Do not advertise to any peer (well-known community)\n"
10303 "Do not export to next AS (well-known community)\n")
10304{
10305 int afi;
10306 int safi;
10307
Michael Lambert95cbbd22010-07-23 14:43:04 -040010308 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10309 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10310 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010311}
10312
10313ALIAS (show_bgp_view_afi_safi_community,
10314 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010315 "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 -040010316 SHOW_STR
10317 BGP_STR
10318 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010319 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010320 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010321 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010322 "Address family modifier\n"
10323 "Address family modifier\n"
10324 "Display routes matching the communities\n"
10325 "community number\n"
10326 "Do not send outside local AS (well-known community)\n"
10327 "Do not advertise to any peer (well-known community)\n"
10328 "Do not export to next AS (well-known community)\n"
10329 "community number\n"
10330 "Do not send outside local AS (well-known community)\n"
10331 "Do not advertise to any peer (well-known community)\n"
10332 "Do not export to next AS (well-known community)\n")
10333
10334ALIAS (show_bgp_view_afi_safi_community,
10335 show_bgp_view_afi_safi_community3_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010336 "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 -040010337 SHOW_STR
10338 BGP_STR
10339 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010340 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010341 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010342 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010343 "Address family modifier\n"
10344 "Address family modifier\n"
10345 "Display routes matching the communities\n"
10346 "community number\n"
10347 "Do not send outside local AS (well-known community)\n"
10348 "Do not advertise to any peer (well-known community)\n"
10349 "Do not export to next AS (well-known community)\n"
10350 "community number\n"
10351 "Do not send outside local AS (well-known community)\n"
10352 "Do not advertise to any peer (well-known community)\n"
10353 "Do not export to next AS (well-known community)\n"
10354 "community number\n"
10355 "Do not send outside local AS (well-known community)\n"
10356 "Do not advertise to any peer (well-known community)\n"
10357 "Do not export to next AS (well-known community)\n")
10358
10359ALIAS (show_bgp_view_afi_safi_community,
10360 show_bgp_view_afi_safi_community4_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010361 "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 -040010362 SHOW_STR
10363 BGP_STR
10364 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010365 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010366 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010367 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010368 "Address family modifier\n"
10369 "Address family modifier\n"
10370 "Display routes matching the communities\n"
10371 "community number\n"
10372 "Do not send outside local AS (well-known community)\n"
10373 "Do not advertise to any peer (well-known community)\n"
10374 "Do not export to next AS (well-known community)\n"
10375 "community number\n"
10376 "Do not send outside local AS (well-known community)\n"
10377 "Do not advertise to any peer (well-known community)\n"
10378 "Do not export to next AS (well-known community)\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
Lou Berger651b4022016-01-12 13:42:07 -050010388DEFUN (show_bgp_ipv4_community_exact,
10389 show_bgp_ipv4_community_exact_cmd,
10390 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010391 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010392 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010393 IP_STR
paul718e3742002-12-13 20:15:29 +000010394 "Display routes matching the communities\n"
10395 "community number\n"
10396 "Do not send outside local AS (well-known community)\n"
10397 "Do not advertise to any peer (well-known community)\n"
10398 "Do not export to next AS (well-known community)\n"
10399 "Exact match of the communities")
10400{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010401 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010402}
10403
Lou Berger651b4022016-01-12 13:42:07 -050010404ALIAS (show_bgp_ipv4_community_exact,
10405 show_bgp_ipv4_community2_exact_cmd,
10406 "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 +000010407 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010408 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010409 IP_STR
paul718e3742002-12-13 20:15:29 +000010410 "Display routes matching the communities\n"
10411 "community number\n"
10412 "Do not send outside local AS (well-known community)\n"
10413 "Do not advertise to any peer (well-known community)\n"
10414 "Do not export to next AS (well-known community)\n"
10415 "community number\n"
10416 "Do not send outside local AS (well-known community)\n"
10417 "Do not advertise to any peer (well-known community)\n"
10418 "Do not export to next AS (well-known community)\n"
10419 "Exact match of the communities")
10420
Lou Berger651b4022016-01-12 13:42:07 -050010421ALIAS (show_bgp_ipv4_community_exact,
10422 show_bgp_ipv4_community3_exact_cmd,
10423 "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 +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 "community number\n"
10433 "Do not send outside local AS (well-known community)\n"
10434 "Do not advertise to any peer (well-known community)\n"
10435 "Do not export to next AS (well-known community)\n"
10436 "community number\n"
10437 "Do not send outside local AS (well-known community)\n"
10438 "Do not advertise to any peer (well-known community)\n"
10439 "Do not export to next AS (well-known community)\n"
10440 "Exact match of the communities")
10441
Lou Berger651b4022016-01-12 13:42:07 -050010442ALIAS (show_bgp_ipv4_community_exact,
10443 show_bgp_ipv4_community4_exact_cmd,
10444 "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 +000010445 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010446 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010447 IP_STR
paul718e3742002-12-13 20:15:29 +000010448 "Display routes matching the communities\n"
10449 "community number\n"
10450 "Do not send outside local AS (well-known community)\n"
10451 "Do not advertise to any peer (well-known community)\n"
10452 "Do not export to next AS (well-known community)\n"
10453 "community number\n"
10454 "Do not send outside local AS (well-known community)\n"
10455 "Do not advertise to any peer (well-known community)\n"
10456 "Do not export to next AS (well-known community)\n"
10457 "community number\n"
10458 "Do not send outside local AS (well-known community)\n"
10459 "Do not advertise to any peer (well-known community)\n"
10460 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
10466
Lou Berger651b4022016-01-12 13:42:07 -050010467DEFUN (show_bgp_ipv4_safi_community4_exact,
10468 show_bgp_ipv4_safi_community_exact_cmd,
10469 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010470 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010471 BGP_STR
10472 "Address family\n"
10473 "Address Family modifier\n"
10474 "Address Family modifier\n"
10475 "Display routes matching the communities\n"
10476 "community number\n"
10477 "Do not send outside local AS (well-known community)\n"
10478 "Do not advertise to any peer (well-known community)\n"
10479 "Do not export to next AS (well-known community)\n"
10480 "Exact match of the communities")
10481{
10482 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010483 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010484
Michael Lambert95cbbd22010-07-23 14:43:04 -040010485 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010486}
10487
Lou Berger651b4022016-01-12 13:42:07 -050010488ALIAS (show_bgp_ipv4_safi_community4_exact,
10489 show_bgp_ipv4_safi_community2_exact_cmd,
10490 "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 +000010491 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010492 BGP_STR
10493 "Address family\n"
10494 "Address Family modifier\n"
10495 "Address Family modifier\n"
10496 "Display routes matching the communities\n"
10497 "community number\n"
10498 "Do not send outside local AS (well-known community)\n"
10499 "Do not advertise to any peer (well-known community)\n"
10500 "Do not export to next AS (well-known community)\n"
10501 "community number\n"
10502 "Do not send outside local AS (well-known community)\n"
10503 "Do not advertise to any peer (well-known community)\n"
10504 "Do not export to next AS (well-known community)\n"
10505 "Exact match of the communities")
10506
Lou Berger651b4022016-01-12 13:42:07 -050010507ALIAS (show_bgp_ipv4_safi_community4_exact,
10508 show_bgp_ipv4_safi_community3_exact_cmd,
10509 "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 +000010510 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010511 BGP_STR
10512 "Address family\n"
10513 "Address Family modifier\n"
10514 "Address Family modifier\n"
10515 "Display routes matching the communities\n"
10516 "community number\n"
10517 "Do not send outside local AS (well-known community)\n"
10518 "Do not advertise to any peer (well-known community)\n"
10519 "Do not export to next AS (well-known community)\n"
10520 "community number\n"
10521 "Do not send outside local AS (well-known community)\n"
10522 "Do not advertise to any peer (well-known community)\n"
10523 "Do not export to next AS (well-known community)\n"
10524 "community number\n"
10525 "Do not send outside local AS (well-known community)\n"
10526 "Do not advertise to any peer (well-known community)\n"
10527 "Do not export to next AS (well-known community)\n"
10528 "Exact match of the communities")
10529
Lou Berger651b4022016-01-12 13:42:07 -050010530ALIAS (show_bgp_ipv4_safi_community4_exact,
10531 show_bgp_ipv4_safi_community4_exact_cmd,
10532 "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 +000010533 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010534 BGP_STR
10535 "Address family\n"
10536 "Address Family modifier\n"
10537 "Address Family modifier\n"
10538 "Display routes matching the communities\n"
10539 "community number\n"
10540 "Do not send outside local AS (well-known community)\n"
10541 "Do not advertise to any peer (well-known community)\n"
10542 "Do not export to next AS (well-known community)\n"
10543 "community number\n"
10544 "Do not send outside local AS (well-known community)\n"
10545 "Do not advertise to any peer (well-known community)\n"
10546 "Do not export to next AS (well-known community)\n"
10547 "community number\n"
10548 "Do not send outside local AS (well-known community)\n"
10549 "Do not advertise to any peer (well-known community)\n"
10550 "Do not export to next AS (well-known community)\n"
10551 "community number\n"
10552 "Do not send outside local AS (well-known community)\n"
10553 "Do not advertise to any peer (well-known community)\n"
10554 "Do not export to next AS (well-known community)\n"
10555 "Exact match of the communities")
10556
Lou Bergerf9b6c392016-01-12 13:42:09 -050010557DEFUN (show_bgp_ipv6_safi_community,
10558 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010559 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010560 SHOW_STR
10561 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010562 "Address family\n"
10563 "Address family modifier\n"
10564 "Address family modifier\n"
10565 "Address family modifier\n"
10566 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010567 "Display routes matching the communities\n"
10568 "community number\n"
10569 "Do not send outside local AS (well-known community)\n"
10570 "Do not advertise to any peer (well-known community)\n"
10571 "Do not export to next AS (well-known community)\n")
10572{
Lou Berger651b4022016-01-12 13:42:07 -050010573 safi_t safi;
10574
10575 if (bgp_parse_safi(argv[0], &safi)) {
10576 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10577 return CMD_WARNING;
10578 }
10579 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010580}
10581
Lou Bergerf9b6c392016-01-12 13:42:09 -050010582ALIAS (show_bgp_ipv6_safi_community,
10583 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010584 "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 +000010585 SHOW_STR
10586 BGP_STR
10587 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010588 "Address family modifier\n"
10589 "Address family modifier\n"
10590 "Address family modifier\n"
10591 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010592 "Display routes matching the communities\n"
10593 "community number\n"
10594 "Do not send outside local AS (well-known community)\n"
10595 "Do not advertise to any peer (well-known community)\n"
10596 "Do not export to next AS (well-known community)\n"
10597 "community number\n"
10598 "Do not send outside local AS (well-known community)\n"
10599 "Do not advertise to any peer (well-known community)\n"
10600 "Do not export to next AS (well-known community)\n")
10601
Lou Bergerf9b6c392016-01-12 13:42:09 -050010602ALIAS (show_bgp_ipv6_safi_community,
10603 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010604 "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 +000010605 SHOW_STR
10606 BGP_STR
10607 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010608 "Address family modifier\n"
10609 "Address family modifier\n"
10610 "Address family modifier\n"
10611 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010612 "Display routes matching the communities\n"
10613 "community number\n"
10614 "Do not send outside local AS (well-known community)\n"
10615 "Do not advertise to any peer (well-known community)\n"
10616 "Do not export to next AS (well-known community)\n"
10617 "community number\n"
10618 "Do not send outside local AS (well-known community)\n"
10619 "Do not advertise to any peer (well-known community)\n"
10620 "Do not export to next AS (well-known community)\n"
10621 "community number\n"
10622 "Do not send outside local AS (well-known community)\n"
10623 "Do not advertise to any peer (well-known community)\n"
10624 "Do not export to next AS (well-known community)\n")
10625
Lou Bergerf9b6c392016-01-12 13:42:09 -050010626ALIAS (show_bgp_ipv6_safi_community,
10627 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010628 "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 +000010629 SHOW_STR
10630 BGP_STR
10631 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010632 "Address family modifier\n"
10633 "Address family modifier\n"
10634 "Address family modifier\n"
10635 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010636 "Display routes matching the communities\n"
10637 "community number\n"
10638 "Do not send outside local AS (well-known community)\n"
10639 "Do not advertise to any peer (well-known community)\n"
10640 "Do not export to next AS (well-known community)\n"
10641 "community number\n"
10642 "Do not send outside local AS (well-known community)\n"
10643 "Do not advertise to any peer (well-known community)\n"
10644 "Do not export to next AS (well-known community)\n"
10645 "community number\n"
10646 "Do not send outside local AS (well-known community)\n"
10647 "Do not advertise to any peer (well-known community)\n"
10648 "Do not export to next AS (well-known community)\n"
10649 "community number\n"
10650 "Do not send outside local AS (well-known community)\n"
10651 "Do not advertise to any peer (well-known community)\n"
10652 "Do not export to next AS (well-known community)\n")
10653
paul718e3742002-12-13 20:15:29 +000010654
Lou Bergerf9b6c392016-01-12 13:42:09 -050010655DEFUN (show_bgp_ipv6_safi_community_exact,
10656 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010657 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010658 SHOW_STR
10659 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010660 "Address family\n"
10661 "Address family modifier\n"
10662 "Address family modifier\n"
10663 "Address family modifier\n"
10664 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010665 "Display routes matching the communities\n"
10666 "community number\n"
10667 "Do not send outside local AS (well-known community)\n"
10668 "Do not advertise to any peer (well-known community)\n"
10669 "Do not export to next AS (well-known community)\n"
10670 "Exact match of the communities")
10671{
Lou Berger651b4022016-01-12 13:42:07 -050010672 safi_t safi;
10673
10674 if (bgp_parse_safi(argv[0], &safi)) {
10675 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10676 return CMD_WARNING;
10677 }
10678 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010679}
10680
paul718e3742002-12-13 20:15:29 +000010681
10682ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010683 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010684 "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 +000010685 SHOW_STR
10686 BGP_STR
10687 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010688 "Address family modifier\n"
10689 "Address family modifier\n"
10690 "Address family modifier\n"
10691 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010692 "Display routes matching the communities\n"
10693 "community number\n"
10694 "Do not send outside local AS (well-known community)\n"
10695 "Do not advertise to any peer (well-known community)\n"
10696 "Do not export to next AS (well-known community)\n"
10697 "community number\n"
10698 "Do not send outside local AS (well-known community)\n"
10699 "Do not advertise to any peer (well-known community)\n"
10700 "Do not export to next AS (well-known community)\n"
10701 "Exact match of the communities")
10702
10703ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010704 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010705 "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 +000010706 SHOW_STR
10707 BGP_STR
10708 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010709 "Address family modifier\n"
10710 "Address family modifier\n"
10711 "Address family modifier\n"
10712 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010713 "Display routes matching the communities\n"
10714 "community number\n"
10715 "Do not send outside local AS (well-known community)\n"
10716 "Do not advertise to any peer (well-known community)\n"
10717 "Do not export to next AS (well-known community)\n"
10718 "community number\n"
10719 "Do not send outside local AS (well-known community)\n"
10720 "Do not advertise to any peer (well-known community)\n"
10721 "Do not export to next AS (well-known community)\n"
10722 "community number\n"
10723 "Do not send outside local AS (well-known community)\n"
10724 "Do not advertise to any peer (well-known community)\n"
10725 "Do not export to next AS (well-known community)\n"
10726 "Exact match of the communities")
10727
10728ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010729 show_bgp_ipv6_safi_community4_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010730 "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 +000010731 SHOW_STR
10732 BGP_STR
10733 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010734 "Address family modifier\n"
10735 "Address family modifier\n"
10736 "Address family modifier\n"
10737 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010738 "Display routes matching the communities\n"
10739 "community number\n"
10740 "Do not send outside local AS (well-known community)\n"
10741 "Do not advertise to any peer (well-known community)\n"
10742 "Do not export to next AS (well-known community)\n"
10743 "community number\n"
10744 "Do not send outside local AS (well-known community)\n"
10745 "Do not advertise to any peer (well-known community)\n"
10746 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
10756
paul94f2b392005-06-28 12:44:16 +000010757static int
paulfd79ac92004-10-13 05:06:08 +000010758bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040010759 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000010760{
10761 struct community_list *list;
10762
hassofee6e4e2005-02-02 16:29:31 +000010763 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010764 if (list == NULL)
10765 {
10766 vty_out (vty, "%% %s is not a valid community-list name%s", com,
10767 VTY_NEWLINE);
10768 return CMD_WARNING;
10769 }
10770
ajs5a646652004-11-05 01:25:55 +000010771 return bgp_show (vty, NULL, afi, safi,
10772 (exact ? bgp_show_type_community_list_exact :
10773 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000010774}
10775
Lou Bergerf9b6c392016-01-12 13:42:09 -050010776DEFUN (show_ip_bgp_community_list,
10777 show_ip_bgp_community_list_cmd,
10778 "show ip bgp community-list (<1-500>|WORD)",
10779 SHOW_STR
10780 IP_STR
10781 BGP_STR
10782 "Display routes matching the community-list\n"
10783 "community-list number\n"
10784 "community-list name\n")
10785{
10786 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
10787}
10788
10789DEFUN (show_ip_bgp_ipv4_community_list,
10790 show_ip_bgp_ipv4_community_list_cmd,
10791 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10792 SHOW_STR
10793 IP_STR
10794 BGP_STR
10795 "Address family\n"
10796 "Address Family modifier\n"
10797 "Address Family modifier\n"
10798 "Display routes matching the community-list\n"
10799 "community-list number\n"
10800 "community-list name\n")
10801{
10802 if (strncmp (argv[0], "m", 1) == 0)
10803 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
10804
10805 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
10806}
10807
10808DEFUN (show_ip_bgp_community_list_exact,
10809 show_ip_bgp_community_list_exact_cmd,
10810 "show ip bgp community-list (<1-500>|WORD) exact-match",
10811 SHOW_STR
10812 IP_STR
10813 BGP_STR
10814 "Display routes matching the community-list\n"
10815 "community-list number\n"
10816 "community-list name\n"
10817 "Exact match of the communities\n")
10818{
10819 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
10820}
10821
10822DEFUN (show_ip_bgp_ipv4_community_list_exact,
10823 show_ip_bgp_ipv4_community_list_exact_cmd,
10824 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
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 "Exact match of the communities\n")
10835{
10836 if (strncmp (argv[0], "m", 1) == 0)
10837 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
10838
10839 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
10840}
10841
Lou Bergerf9b6c392016-01-12 13:42:09 -050010842DEFUN (show_bgp_community_list,
10843 show_bgp_community_list_cmd,
10844 "show bgp community-list (<1-500>|WORD)",
10845 SHOW_STR
10846 BGP_STR
10847 "Display routes matching the community-list\n"
10848 "community-list number\n"
10849 "community-list name\n")
10850{
10851 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10852}
10853
10854ALIAS (show_bgp_community_list,
10855 show_bgp_ipv6_community_list_cmd,
10856 "show bgp ipv6 community-list (<1-500>|WORD)",
10857 SHOW_STR
10858 BGP_STR
10859 "Address family\n"
10860 "Display routes matching the community-list\n"
10861 "community-list number\n"
10862 "community-list name\n")
10863
10864/* old command */
10865DEFUN (show_ipv6_bgp_community_list,
10866 show_ipv6_bgp_community_list_cmd,
10867 "show ipv6 bgp community-list WORD",
10868 SHOW_STR
10869 IPV6_STR
10870 BGP_STR
10871 "Display routes matching the community-list\n"
10872 "community-list name\n")
10873{
10874 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10875}
10876
10877/* old command */
10878DEFUN (show_ipv6_mbgp_community_list,
10879 show_ipv6_mbgp_community_list_cmd,
10880 "show ipv6 mbgp community-list WORD",
10881 SHOW_STR
10882 IPV6_STR
10883 MBGP_STR
10884 "Display routes matching the community-list\n"
10885 "community-list name\n")
10886{
10887 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
10888}
10889
10890DEFUN (show_bgp_community_list_exact,
10891 show_bgp_community_list_exact_cmd,
10892 "show bgp community-list (<1-500>|WORD) exact-match",
10893 SHOW_STR
10894 BGP_STR
10895 "Display routes matching the community-list\n"
10896 "community-list number\n"
10897 "community-list name\n"
10898 "Exact match of the communities\n")
10899{
10900 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10901}
10902
10903ALIAS (show_bgp_community_list_exact,
10904 show_bgp_ipv6_community_list_exact_cmd,
10905 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10906 SHOW_STR
10907 BGP_STR
10908 "Address family\n"
10909 "Display routes matching the community-list\n"
10910 "community-list number\n"
10911 "community-list name\n"
10912 "Exact match of the communities\n")
10913
10914/* old command */
10915DEFUN (show_ipv6_bgp_community_list_exact,
10916 show_ipv6_bgp_community_list_exact_cmd,
10917 "show ipv6 bgp community-list WORD exact-match",
10918 SHOW_STR
10919 IPV6_STR
10920 BGP_STR
10921 "Display routes matching the community-list\n"
10922 "community-list name\n"
10923 "Exact match of the communities\n")
10924{
10925 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10926}
10927
10928/* old command */
10929DEFUN (show_ipv6_mbgp_community_list_exact,
10930 show_ipv6_mbgp_community_list_exact_cmd,
10931 "show ipv6 mbgp community-list WORD exact-match",
10932 SHOW_STR
10933 IPV6_STR
10934 MBGP_STR
10935 "Display routes matching the community-list\n"
10936 "community-list name\n"
10937 "Exact match of the communities\n")
10938{
10939 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
10940}
Lou Bergerf9b6c392016-01-12 13:42:09 -050010941
Lou Berger651b4022016-01-12 13:42:07 -050010942DEFUN (show_bgp_ipv4_community_list,
10943 show_bgp_ipv4_community_list_cmd,
10944 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010945 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010946 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010947 IP_STR
paul718e3742002-12-13 20:15:29 +000010948 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010949 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010950 "community-list name\n")
10951{
10952 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
10953}
10954
Lou Berger651b4022016-01-12 13:42:07 -050010955DEFUN (show_bgp_ipv4_safi_community_list,
10956 show_bgp_ipv4_safi_community_list_cmd,
10957 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010958 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010959 BGP_STR
10960 "Address family\n"
10961 "Address Family modifier\n"
10962 "Address Family modifier\n"
10963 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010964 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010965 "community-list name\n")
10966{
10967 if (strncmp (argv[0], "m", 1) == 0)
10968 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
10969
10970 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
10971}
10972
Lou Berger651b4022016-01-12 13:42:07 -050010973DEFUN (show_bgp_ipv4_community_list_exact,
10974 show_bgp_ipv4_community_list_exact_cmd,
10975 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000010976 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010977 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010978 IP_STR
paul718e3742002-12-13 20:15:29 +000010979 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010980 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010981 "community-list name\n"
10982 "Exact match of the communities\n")
10983{
10984 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
10985}
10986
Lou Berger651b4022016-01-12 13:42:07 -050010987DEFUN (show_bgp_ipv4_safi_community_list_exact,
10988 show_bgp_ipv4_safi_community_list_exact_cmd,
10989 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000010990 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010991 BGP_STR
10992 "Address family\n"
10993 "Address Family modifier\n"
10994 "Address Family modifier\n"
10995 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000010996 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000010997 "community-list name\n"
10998 "Exact match of the communities\n")
10999{
11000 if (strncmp (argv[0], "m", 1) == 0)
11001 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11002
11003 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11004}
11005
Lou Bergerf9b6c392016-01-12 13:42:09 -050011006DEFUN (show_bgp_ipv6_safi_community_list,
11007 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011008 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011009 SHOW_STR
11010 BGP_STR
11011 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011012 "Address family modifier\n"
11013 "Address family modifier\n"
11014 "Address family modifier\n"
11015 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011016 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011017 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011018 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011019{
Lou Berger651b4022016-01-12 13:42:07 -050011020 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011021
Lou Berger651b4022016-01-12 13:42:07 -050011022 if (bgp_parse_safi(argv[0], &safi)) {
11023 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11024 return CMD_WARNING;
11025 }
11026 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011027}
11028
Lou Bergerf9b6c392016-01-12 13:42:09 -050011029DEFUN (show_bgp_ipv6_safi_community_list_exact,
11030 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011031 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011032 SHOW_STR
11033 BGP_STR
11034 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011035 "Address family modifier\n"
11036 "Address family modifier\n"
11037 "Address family modifier\n"
11038 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011039 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011040 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011041 "community-list name\n"
11042 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011043{
Lou Berger651b4022016-01-12 13:42:07 -050011044 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011045
Lou Berger651b4022016-01-12 13:42:07 -050011046 if (bgp_parse_safi(argv[0], &safi)) {
11047 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11048 return CMD_WARNING;
11049 }
11050 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011051}
David Lamparter6b0655a2014-06-04 06:53:35 +020011052
paul94f2b392005-06-28 12:44:16 +000011053static int
paulfd79ac92004-10-13 05:06:08 +000011054bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000011055 safi_t safi, enum bgp_show_type type)
11056{
11057 int ret;
11058 struct prefix *p;
11059
11060 p = prefix_new();
11061
11062 ret = str2prefix (prefix, p);
11063 if (! ret)
11064 {
11065 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
11066 return CMD_WARNING;
11067 }
11068
ajs5a646652004-11-05 01:25:55 +000011069 ret = bgp_show (vty, NULL, afi, safi, type, p);
11070 prefix_free(p);
11071 return ret;
paul718e3742002-12-13 20:15:29 +000011072}
11073
Lou Bergerf9b6c392016-01-12 13:42:09 -050011074DEFUN (show_ip_bgp_prefix_longer,
11075 show_ip_bgp_prefix_longer_cmd,
11076 "show ip bgp A.B.C.D/M longer-prefixes",
11077 SHOW_STR
11078 IP_STR
11079 BGP_STR
11080 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11081 "Display route and more specific routes\n")
11082{
11083 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11084 bgp_show_type_prefix_longer);
11085}
11086
11087DEFUN (show_ip_bgp_flap_prefix_longer,
11088 show_ip_bgp_flap_prefix_longer_cmd,
11089 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11090 SHOW_STR
11091 IP_STR
11092 BGP_STR
11093 "Display flap statistics of routes\n"
11094 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11095 "Display route and more specific routes\n")
11096{
11097 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11098 bgp_show_type_flap_prefix_longer);
11099}
11100
11101ALIAS (show_ip_bgp_flap_prefix_longer,
11102 show_ip_bgp_damp_flap_prefix_longer_cmd,
11103 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11104 SHOW_STR
11105 IP_STR
11106 BGP_STR
11107 "Display detailed information about dampening\n"
11108 "Display flap statistics of routes\n"
11109 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11110 "Display route and more specific routes\n")
11111
11112DEFUN (show_ip_bgp_ipv4_prefix_longer,
11113 show_ip_bgp_ipv4_prefix_longer_cmd,
11114 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11115 SHOW_STR
11116 IP_STR
11117 BGP_STR
11118 "Address family\n"
11119 "Address Family modifier\n"
11120 "Address Family modifier\n"
11121 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11122 "Display route and more specific routes\n")
11123{
11124 if (strncmp (argv[0], "m", 1) == 0)
11125 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
11126 bgp_show_type_prefix_longer);
11127
11128 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
11129 bgp_show_type_prefix_longer);
11130}
11131
11132DEFUN (show_ip_bgp_flap_address,
11133 show_ip_bgp_flap_address_cmd,
11134 "show ip bgp flap-statistics A.B.C.D",
11135 SHOW_STR
11136 IP_STR
11137 BGP_STR
11138 "Display flap statistics of routes\n"
11139 "Network in the BGP routing table to display\n")
11140{
11141 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11142 bgp_show_type_flap_address);
11143}
11144
11145ALIAS (show_ip_bgp_flap_address,
11146 show_ip_bgp_damp_flap_address_cmd,
11147 "show ip bgp dampening flap-statistics A.B.C.D",
11148 SHOW_STR
11149 IP_STR
11150 BGP_STR
11151 "Display detailed information about dampening\n"
11152 "Display flap statistics of routes\n"
11153 "Network in the BGP routing table to display\n")
11154
11155DEFUN (show_ip_bgp_flap_prefix,
11156 show_ip_bgp_flap_prefix_cmd,
11157 "show ip bgp flap-statistics A.B.C.D/M",
11158 SHOW_STR
11159 IP_STR
11160 BGP_STR
11161 "Display flap statistics of routes\n"
11162 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11163{
11164 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11165 bgp_show_type_flap_prefix);
11166}
11167
11168ALIAS (show_ip_bgp_flap_prefix,
11169 show_ip_bgp_damp_flap_prefix_cmd,
11170 "show ip bgp dampening flap-statistics A.B.C.D/M",
11171 SHOW_STR
11172 IP_STR
11173 BGP_STR
11174 "Display detailed information about dampening\n"
11175 "Display flap statistics of routes\n"
11176 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11177
Lou Bergerf9b6c392016-01-12 13:42:09 -050011178DEFUN (show_bgp_prefix_longer,
11179 show_bgp_prefix_longer_cmd,
11180 "show bgp X:X::X:X/M longer-prefixes",
11181 SHOW_STR
11182 BGP_STR
11183 "IPv6 prefix <network>/<length>\n"
11184 "Display route and more specific routes\n")
11185{
11186 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11187 bgp_show_type_prefix_longer);
11188}
11189
11190/* old command */
11191DEFUN (show_ipv6_bgp_prefix_longer,
11192 show_ipv6_bgp_prefix_longer_cmd,
11193 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11194 SHOW_STR
11195 IPV6_STR
11196 BGP_STR
11197 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11198 "Display route and more specific routes\n")
11199{
11200 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11201 bgp_show_type_prefix_longer);
11202}
11203
11204/* old command */
11205DEFUN (show_ipv6_mbgp_prefix_longer,
11206 show_ipv6_mbgp_prefix_longer_cmd,
11207 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11208 SHOW_STR
11209 IPV6_STR
11210 MBGP_STR
11211 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11212 "Display route and more specific routes\n")
11213{
11214 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
11215 bgp_show_type_prefix_longer);
11216}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011217
Lou Berger651b4022016-01-12 13:42:07 -050011218DEFUN (show_bgp_ipv4_prefix_longer,
11219 show_bgp_ipv4_prefix_longer_cmd,
11220 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011221 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011222 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011223 IP_STR
paul718e3742002-12-13 20:15:29 +000011224 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11225 "Display route and more specific routes\n")
11226{
11227 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11228 bgp_show_type_prefix_longer);
11229}
11230
Lou Berger651b4022016-01-12 13:42:07 -050011231DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
11232 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
11233 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011234 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011235 BGP_STR
11236 "Address family\n"
11237 "Address Family modifier\n"
11238 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050011239 "Address Family modifier\n"
11240 "Address Family modifier\n"
11241 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000011242 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11243 "Display route and more specific routes\n")
11244{
Lou Berger651b4022016-01-12 13:42:07 -050011245 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011246
Lou Berger651b4022016-01-12 13:42:07 -050011247 if (bgp_parse_safi(argv[0], &safi)) {
11248 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11249 return CMD_WARNING;
11250 }
11251 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11252 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000011253}
11254
Lou Berger651b4022016-01-12 13:42:07 -050011255ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
11256 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
11257 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011258 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011259 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011260 "Address family\n"
11261 "Address Family modifier\n"
11262 "Address Family modifier\n"
11263 "Address Family modifier\n"
11264 "Address Family modifier\n"
11265 "Display detailed information about dampening\n"
11266 "Display flap statistics of routes\n"
11267 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11268 "Display route and more specific routes\n")
11269
Lou Berger651b4022016-01-12 13:42:07 -050011270DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
11271 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
11272 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
11273 SHOW_STR
11274 BGP_STR
11275 "Address family\n"
11276 "Address Family modifier\n"
11277 "Address Family modifier\n"
11278 "Address Family modifier\n"
11279 "Address Family modifier\n"
11280 "Display flap statistics of routes\n"
11281 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11282 "Display route and more specific routes\n")
11283{
11284 safi_t safi;
11285
11286 if (bgp_parse_safi(argv[0], &safi)) {
11287 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11288 return CMD_WARNING;
11289 }
11290 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11291 bgp_show_type_flap_prefix_longer);
11292}
11293ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
11294 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
11295 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
11296 SHOW_STR
11297 BGP_STR
11298 "Address family\n"
11299 "Address Family modifier\n"
11300 "Address Family modifier\n"
11301 "Address Family modifier\n"
11302 "Address Family modifier\n"
11303 "Display detailed information about dampening\n"
11304 "Display flap statistics of routes\n"
11305 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11306 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050011307
11308DEFUN (show_bgp_ipv4_safi_prefix_longer,
11309 show_bgp_ipv4_safi_prefix_longer_cmd,
11310 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
11311 SHOW_STR
11312 BGP_STR
11313 "Address family\n"
11314 "Address Family modifier\n"
11315 "Address Family modifier\n"
11316 "Address Family modifier\n"
11317 "Address Family modifier\n"
11318 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11319 "Display route and more specific routes\n")
11320{
11321 safi_t safi;
11322
11323 if (bgp_parse_safi(argv[0], &safi)) {
11324 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11325 return CMD_WARNING;
11326 }
11327
11328 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11329 bgp_show_type_prefix_longer);
11330}
11331
Lou Berger651b4022016-01-12 13:42:07 -050011332DEFUN (show_bgp_ipv6_safi_prefix_longer,
11333 show_bgp_ipv6_safi_prefix_longer_cmd,
11334 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
11335 SHOW_STR
11336 BGP_STR
11337 "Address family\n"
11338 "Address Family modifier\n"
11339 "Address Family modifier\n"
11340 "Address Family modifier\n"
11341 "Address Family modifier\n"
11342 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11343 "Display route and more specific routes\n")
11344{
11345 safi_t safi;
11346
11347 if (bgp_parse_safi(argv[0], &safi)) {
11348 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11349 return CMD_WARNING;
11350 }
11351
11352 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11353 bgp_show_type_prefix_longer);
11354}
Lou Berger651b4022016-01-12 13:42:07 -050011355
11356DEFUN (show_bgp_ipv4_safi_flap_address,
11357 show_bgp_ipv4_safi_flap_address_cmd,
11358 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
11359 SHOW_STR
11360 BGP_STR
11361 "Address family\n"
11362 "Address Family modifier\n"
11363 "Address Family modifier\n"
11364 "Address Family modifier\n"
11365 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011366 "Display flap statistics of routes\n"
11367 "Network in the BGP routing table to display\n")
11368{
Lou Berger651b4022016-01-12 13:42:07 -050011369 safi_t safi;
11370
11371 if (bgp_parse_safi(argv[0], &safi)) {
11372 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11373 return CMD_WARNING;
11374 }
11375 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011376 bgp_show_type_flap_address);
11377}
Lou Berger651b4022016-01-12 13:42:07 -050011378ALIAS (show_bgp_ipv4_safi_flap_address,
11379 show_bgp_ipv4_safi_damp_flap_address_cmd,
11380 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053011381 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011382 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011383 "Address family\n"
11384 "Address Family modifier\n"
11385 "Address Family modifier\n"
11386 "Address Family modifier\n"
11387 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011388 "Display detailed information about dampening\n"
11389 "Display flap statistics of routes\n"
11390 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050011391
Lou Berger651b4022016-01-12 13:42:07 -050011392DEFUN (show_bgp_ipv6_flap_address,
11393 show_bgp_ipv6_flap_address_cmd,
11394 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000011395 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011396 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011397 "Address family\n"
11398 "Address Family modifier\n"
11399 "Address Family modifier\n"
11400 "Address Family modifier\n"
11401 "Address Family modifier\n"
11402 "Display flap statistics of routes\n"
11403 "Network in the BGP routing table to display\n")
11404{
11405 safi_t safi;
11406
11407 if (bgp_parse_safi(argv[0], &safi)) {
11408 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11409 return CMD_WARNING;
11410 }
11411 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11412 bgp_show_type_flap_address);
11413}
11414ALIAS (show_bgp_ipv6_flap_address,
11415 show_bgp_ipv6_damp_flap_address_cmd,
11416 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
11417 SHOW_STR
11418 BGP_STR
11419 "Address family\n"
11420 "Address Family modifier\n"
11421 "Address Family modifier\n"
11422 "Address Family modifier\n"
11423 "Address Family modifier\n"
11424 "Display detailed information about dampening\n"
11425 "Display flap statistics of routes\n"
11426 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050011427
11428DEFUN (show_bgp_ipv4_safi_flap_prefix,
11429 show_bgp_ipv4_safi_flap_prefix_cmd,
11430 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
11431 SHOW_STR
11432 BGP_STR
11433 "Address family\n"
11434 "Address Family modifier\n"
11435 "Address Family modifier\n"
11436 "Address Family modifier\n"
11437 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011438 "Display flap statistics of routes\n"
11439 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11440{
Lou Berger651b4022016-01-12 13:42:07 -050011441 safi_t safi;
11442
11443 if (bgp_parse_safi(argv[0], &safi)) {
11444 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11445 return CMD_WARNING;
11446 }
11447 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011448 bgp_show_type_flap_prefix);
11449}
Balaji3921cc52015-05-16 23:12:17 +053011450
Lou Berger651b4022016-01-12 13:42:07 -050011451ALIAS (show_bgp_ipv4_safi_flap_prefix,
11452 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
11453 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053011454 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011455 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011456 "Address family\n"
11457 "Address Family modifier\n"
11458 "Address Family modifier\n"
11459 "Address Family modifier\n"
11460 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011461 "Display detailed information about dampening\n"
11462 "Display flap statistics of routes\n"
11463 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11464
Lou Berger651b4022016-01-12 13:42:07 -050011465DEFUN (show_bgp_ipv6_safi_flap_prefix,
11466 show_bgp_ipv6_safi_flap_prefix_cmd,
11467 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000011468 SHOW_STR
11469 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011470 "Address family\n"
11471 "Address Family modifier\n"
11472 "Address Family modifier\n"
11473 "Address Family modifier\n"
11474 "Address Family modifier\n"
11475 "Display flap statistics of routes\n"
11476 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000011477{
Lou Berger651b4022016-01-12 13:42:07 -050011478 safi_t safi;
11479
11480 if (bgp_parse_safi(argv[0], &safi)) {
11481 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11482 return CMD_WARNING;
11483 }
11484 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
11485 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000011486}
11487
Lou Berger651b4022016-01-12 13:42:07 -050011488ALIAS (show_bgp_ipv6_safi_flap_prefix,
11489 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
11490 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
11491 SHOW_STR
11492 BGP_STR
11493 "Address family\n"
11494 "Address Family modifier\n"
11495 "Address Family modifier\n"
11496 "Address Family modifier\n"
11497 "Address Family modifier\n"
11498 "Display detailed information about dampening\n"
11499 "Display flap statistics of routes\n"
11500 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11501
11502DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000011503 show_bgp_ipv6_prefix_longer_cmd,
11504 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11505 SHOW_STR
11506 BGP_STR
11507 "Address family\n"
11508 "IPv6 prefix <network>/<length>\n"
11509 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000011510{
11511 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11512 bgp_show_type_prefix_longer);
11513}
11514
paul94f2b392005-06-28 12:44:16 +000011515static struct peer *
paulfd79ac92004-10-13 05:06:08 +000011516peer_lookup_in_view (struct vty *vty, const char *view_name,
11517 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000011518{
11519 int ret;
11520 struct bgp *bgp;
11521 struct peer *peer;
11522 union sockunion su;
11523
11524 /* BGP structure lookup. */
11525 if (view_name)
11526 {
11527 bgp = bgp_lookup_by_name (view_name);
11528 if (! bgp)
11529 {
11530 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11531 return NULL;
11532 }
11533 }
paul5228ad22004-06-04 17:58:18 +000011534 else
paulbb46e942003-10-24 19:02:03 +000011535 {
11536 bgp = bgp_get_default ();
11537 if (! bgp)
11538 {
11539 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11540 return NULL;
11541 }
11542 }
11543
11544 /* Get peer sockunion. */
11545 ret = str2sockunion (ip_str, &su);
11546 if (ret < 0)
11547 {
11548 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
11549 return NULL;
11550 }
11551
11552 /* Peer structure lookup. */
11553 peer = peer_lookup (bgp, &su);
11554 if (! peer)
11555 {
11556 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
11557 return NULL;
11558 }
11559
11560 return peer;
11561}
David Lamparter6b0655a2014-06-04 06:53:35 +020011562
Paul Jakma2815e612006-09-14 02:56:07 +000011563enum bgp_stats
11564{
11565 BGP_STATS_MAXBITLEN = 0,
11566 BGP_STATS_RIB,
11567 BGP_STATS_PREFIXES,
11568 BGP_STATS_TOTPLEN,
11569 BGP_STATS_UNAGGREGATEABLE,
11570 BGP_STATS_MAX_AGGREGATEABLE,
11571 BGP_STATS_AGGREGATES,
11572 BGP_STATS_SPACE,
11573 BGP_STATS_ASPATH_COUNT,
11574 BGP_STATS_ASPATH_MAXHOPS,
11575 BGP_STATS_ASPATH_TOTHOPS,
11576 BGP_STATS_ASPATH_MAXSIZE,
11577 BGP_STATS_ASPATH_TOTSIZE,
11578 BGP_STATS_ASN_HIGHEST,
11579 BGP_STATS_MAX,
11580};
paulbb46e942003-10-24 19:02:03 +000011581
Paul Jakma2815e612006-09-14 02:56:07 +000011582static const char *table_stats_strs[] =
11583{
11584 [BGP_STATS_PREFIXES] = "Total Prefixes",
11585 [BGP_STATS_TOTPLEN] = "Average prefix length",
11586 [BGP_STATS_RIB] = "Total Advertisements",
11587 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
11588 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
11589 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
11590 [BGP_STATS_SPACE] = "Address space advertised",
11591 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
11592 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
11593 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
11594 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
11595 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
11596 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
11597 [BGP_STATS_MAX] = NULL,
11598};
11599
11600struct bgp_table_stats
11601{
11602 struct bgp_table *table;
11603 unsigned long long counts[BGP_STATS_MAX];
11604};
11605
11606#if 0
11607#define TALLY_SIGFIG 100000
11608static unsigned long
11609ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
11610{
11611 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
11612 unsigned long res = (newtot * TALLY_SIGFIG) / count;
11613 unsigned long ret = newtot / count;
11614
11615 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
11616 return ret + 1;
11617 else
11618 return ret;
11619}
11620#endif
11621
11622static int
11623bgp_table_stats_walker (struct thread *t)
11624{
11625 struct bgp_node *rn;
11626 struct bgp_node *top;
11627 struct bgp_table_stats *ts = THREAD_ARG (t);
11628 unsigned int space = 0;
11629
Paul Jakma53d9f672006-10-15 23:41:16 +000011630 if (!(top = bgp_table_top (ts->table)))
11631 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000011632
11633 switch (top->p.family)
11634 {
11635 case AF_INET:
11636 space = IPV4_MAX_BITLEN;
11637 break;
11638 case AF_INET6:
11639 space = IPV6_MAX_BITLEN;
11640 break;
11641 }
11642
11643 ts->counts[BGP_STATS_MAXBITLEN] = space;
11644
11645 for (rn = top; rn; rn = bgp_route_next (rn))
11646 {
11647 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070011648 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000011649 unsigned int rinum = 0;
11650
11651 if (rn == top)
11652 continue;
11653
11654 if (!rn->info)
11655 continue;
11656
11657 ts->counts[BGP_STATS_PREFIXES]++;
11658 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
11659
11660#if 0
11661 ts->counts[BGP_STATS_AVGPLEN]
11662 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
11663 ts->counts[BGP_STATS_AVGPLEN],
11664 rn->p.prefixlen);
11665#endif
11666
11667 /* check if the prefix is included by any other announcements */
11668 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070011669 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000011670
11671 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000011672 {
11673 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
11674 /* announced address space */
11675 if (space)
11676 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
11677 }
Paul Jakma2815e612006-09-14 02:56:07 +000011678 else if (prn->info)
11679 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
11680
Paul Jakma2815e612006-09-14 02:56:07 +000011681 for (ri = rn->info; ri; ri = ri->next)
11682 {
11683 rinum++;
11684 ts->counts[BGP_STATS_RIB]++;
11685
11686 if (ri->attr &&
11687 (CHECK_FLAG (ri->attr->flag,
11688 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
11689 ts->counts[BGP_STATS_AGGREGATES]++;
11690
11691 /* as-path stats */
11692 if (ri->attr && ri->attr->aspath)
11693 {
11694 unsigned int hops = aspath_count_hops (ri->attr->aspath);
11695 unsigned int size = aspath_size (ri->attr->aspath);
11696 as_t highest = aspath_highest (ri->attr->aspath);
11697
11698 ts->counts[BGP_STATS_ASPATH_COUNT]++;
11699
11700 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
11701 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
11702
11703 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
11704 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
11705
11706 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
11707 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
11708#if 0
11709 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
11710 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11711 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
11712 hops);
11713 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
11714 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11715 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
11716 size);
11717#endif
11718 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
11719 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
11720 }
11721 }
11722 }
11723 return 0;
11724}
11725
11726static int
11727bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
11728{
11729 struct bgp_table_stats ts;
11730 unsigned int i;
11731
11732 if (!bgp->rib[afi][safi])
11733 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011734 vty_out (vty, "%% No RIB exists for the AFI/SAFI%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011735 return CMD_WARNING;
11736 }
11737
11738 memset (&ts, 0, sizeof (ts));
11739 ts.table = bgp->rib[afi][safi];
11740 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
11741
11742 vty_out (vty, "BGP %s RIB statistics%s%s",
11743 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
11744
11745 for (i = 0; i < BGP_STATS_MAX; i++)
11746 {
11747 if (!table_stats_strs[i])
11748 continue;
11749
11750 switch (i)
11751 {
11752#if 0
11753 case BGP_STATS_ASPATH_AVGHOPS:
11754 case BGP_STATS_ASPATH_AVGSIZE:
11755 case BGP_STATS_AVGPLEN:
11756 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11757 vty_out (vty, "%12.2f",
11758 (float)ts.counts[i] / (float)TALLY_SIGFIG);
11759 break;
11760#endif
11761 case BGP_STATS_ASPATH_TOTHOPS:
11762 case BGP_STATS_ASPATH_TOTSIZE:
11763 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11764 vty_out (vty, "%12.2f",
11765 ts.counts[i] ?
11766 (float)ts.counts[i] /
11767 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
11768 : 0);
11769 break;
11770 case BGP_STATS_TOTPLEN:
11771 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11772 vty_out (vty, "%12.2f",
11773 ts.counts[i] ?
11774 (float)ts.counts[i] /
11775 (float)ts.counts[BGP_STATS_PREFIXES]
11776 : 0);
11777 break;
11778 case BGP_STATS_SPACE:
11779 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11780 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
11781 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
11782 break;
Paul Jakma30a22312008-08-15 14:05:22 +010011783 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000011784 vty_out (vty, "%12.2f%s",
11785 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000011786 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000011787 VTY_NEWLINE);
11788 vty_out (vty, "%30s: ", "/8 equivalent ");
11789 vty_out (vty, "%12.2f%s",
11790 (float)ts.counts[BGP_STATS_SPACE] /
11791 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
11792 VTY_NEWLINE);
11793 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
11794 break;
11795 vty_out (vty, "%30s: ", "/24 equivalent ");
11796 vty_out (vty, "%12.2f",
11797 (float)ts.counts[BGP_STATS_SPACE] /
11798 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
11799 break;
11800 default:
11801 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11802 vty_out (vty, "%12llu", ts.counts[i]);
11803 }
11804
11805 vty_out (vty, "%s", VTY_NEWLINE);
11806 }
11807 return CMD_SUCCESS;
11808}
11809
11810static int
11811bgp_table_stats_vty (struct vty *vty, const char *name,
11812 const char *afi_str, const char *safi_str)
11813{
11814 struct bgp *bgp;
11815 afi_t afi;
11816 safi_t safi;
11817
11818 if (name)
11819 bgp = bgp_lookup_by_name (name);
11820 else
11821 bgp = bgp_get_default ();
11822
11823 if (!bgp)
11824 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011825 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011826 return CMD_WARNING;
11827 }
11828 if (strncmp (afi_str, "ipv", 3) == 0)
11829 {
11830 if (strncmp (afi_str, "ipv4", 4) == 0)
11831 afi = AFI_IP;
11832 else if (strncmp (afi_str, "ipv6", 4) == 0)
11833 afi = AFI_IP6;
11834 else
11835 {
11836 vty_out (vty, "%% Invalid address family %s%s",
11837 afi_str, VTY_NEWLINE);
11838 return CMD_WARNING;
11839 }
Lou Berger298cc2f2016-01-12 13:42:02 -050011840 switch (safi_str[0]) {
11841 case 'm':
11842 safi = SAFI_MULTICAST;
11843 break;
11844 case 'u':
11845 safi = SAFI_UNICAST;
11846 break;
11847 case 'v':
11848 safi = SAFI_MPLS_LABELED_VPN;
11849 break;
11850 case 'e':
11851 safi = SAFI_ENCAP;
11852 break;
11853 default:
11854 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011855 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050011856 return CMD_WARNING;
11857 }
Paul Jakma2815e612006-09-14 02:56:07 +000011858 }
11859 else
11860 {
Lou Berger298cc2f2016-01-12 13:42:02 -050011861 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011862 afi_str, VTY_NEWLINE);
11863 return CMD_WARNING;
11864 }
11865
Paul Jakma2815e612006-09-14 02:56:07 +000011866 return bgp_table_stats (vty, bgp, afi, safi);
11867}
11868
11869DEFUN (show_bgp_statistics,
11870 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011871 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011872 SHOW_STR
11873 BGP_STR
11874 "Address family\n"
11875 "Address family\n"
11876 "Address Family modifier\n"
11877 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011878 "Address Family modifier\n"
11879 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011880 "BGP RIB advertisement statistics\n")
11881{
11882 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11883}
11884
Lou Bergerf9b6c392016-01-12 13:42:09 -050011885ALIAS (show_bgp_statistics,
11886 show_bgp_statistics_vpnv4_cmd,
11887 "show bgp (ipv4) (vpnv4) statistics",
11888 SHOW_STR
11889 BGP_STR
11890 "Address family\n"
11891 "Address Family modifier\n"
11892 "BGP RIB advertisement statistics\n")
11893
Paul Jakma2815e612006-09-14 02:56:07 +000011894DEFUN (show_bgp_statistics_view,
11895 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011896 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011897 SHOW_STR
11898 BGP_STR
11899 "BGP view\n"
11900 "Address family\n"
11901 "Address family\n"
11902 "Address Family modifier\n"
11903 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011904 "Address Family modifier\n"
11905 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011906 "BGP RIB advertisement statistics\n")
11907{
11908 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11909}
11910
11911ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011912 show_bgp_statistics_view_vpnv4_cmd,
11913 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011914 SHOW_STR
11915 BGP_STR
11916 "BGP view\n"
11917 "Address family\n"
11918 "Address Family modifier\n"
11919 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020011920
Paul Jakmaff7924f2006-09-04 01:10:36 +000011921enum bgp_pcounts
11922{
11923 PCOUNT_ADJ_IN = 0,
11924 PCOUNT_DAMPED,
11925 PCOUNT_REMOVED,
11926 PCOUNT_HISTORY,
11927 PCOUNT_STALE,
11928 PCOUNT_VALID,
11929 PCOUNT_ALL,
11930 PCOUNT_COUNTED,
11931 PCOUNT_PFCNT, /* the figure we display to users */
11932 PCOUNT_MAX,
11933};
11934
11935static const char *pcount_strs[] =
11936{
11937 [PCOUNT_ADJ_IN] = "Adj-in",
11938 [PCOUNT_DAMPED] = "Damped",
11939 [PCOUNT_REMOVED] = "Removed",
11940 [PCOUNT_HISTORY] = "History",
11941 [PCOUNT_STALE] = "Stale",
11942 [PCOUNT_VALID] = "Valid",
11943 [PCOUNT_ALL] = "All RIB",
11944 [PCOUNT_COUNTED] = "PfxCt counted",
11945 [PCOUNT_PFCNT] = "Useable",
11946 [PCOUNT_MAX] = NULL,
11947};
11948
Paul Jakma2815e612006-09-14 02:56:07 +000011949struct peer_pcounts
11950{
11951 unsigned int count[PCOUNT_MAX];
11952 const struct peer *peer;
11953 const struct bgp_table *table;
11954};
11955
Paul Jakmaff7924f2006-09-04 01:10:36 +000011956static int
Paul Jakma2815e612006-09-14 02:56:07 +000011957bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000011958{
11959 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000011960 struct peer_pcounts *pc = THREAD_ARG (t);
11961 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011962
Paul Jakma2815e612006-09-14 02:56:07 +000011963 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000011964 {
11965 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000011966 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011967
11968 for (ain = rn->adj_in; ain; ain = ain->next)
11969 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000011970 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011971
Paul Jakmaff7924f2006-09-04 01:10:36 +000011972 for (ri = rn->info; ri; ri = ri->next)
11973 {
11974 char buf[SU_ADDRSTRLEN];
11975
11976 if (ri->peer != peer)
11977 continue;
11978
Paul Jakma2815e612006-09-14 02:56:07 +000011979 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011980
11981 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000011982 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011983 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000011984 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011985 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000011986 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011987 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000011988 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011989 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000011990 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000011991 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000011992 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000011993
11994 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
11995 {
Paul Jakma2815e612006-09-14 02:56:07 +000011996 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000011997 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000011998 plog_warn (peer->log,
11999 "%s [pcount] %s/%d is counted but flags 0x%x",
12000 peer->host,
12001 inet_ntop(rn->p.family, &rn->p.u.prefix,
12002 buf, SU_ADDRSTRLEN),
12003 rn->p.prefixlen,
12004 ri->flags);
12005 }
12006 else
12007 {
Paul Jakma1a392d42006-09-07 00:24:49 +000012008 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012009 plog_warn (peer->log,
12010 "%s [pcount] %s/%d not counted but flags 0x%x",
12011 peer->host,
12012 inet_ntop(rn->p.family, &rn->p.u.prefix,
12013 buf, SU_ADDRSTRLEN),
12014 rn->p.prefixlen,
12015 ri->flags);
12016 }
12017 }
12018 }
Paul Jakma2815e612006-09-14 02:56:07 +000012019 return 0;
12020}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012021
Paul Jakma2815e612006-09-14 02:56:07 +000012022static int
12023bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
12024{
12025 struct peer_pcounts pcounts = { .peer = peer };
12026 unsigned int i;
12027
12028 if (!peer || !peer->bgp || !peer->afc[afi][safi]
12029 || !peer->bgp->rib[afi][safi])
12030 {
12031 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12032 return CMD_WARNING;
12033 }
12034
12035 memset (&pcounts, 0, sizeof(pcounts));
12036 pcounts.peer = peer;
12037 pcounts.table = peer->bgp->rib[afi][safi];
12038
12039 /* in-place call via thread subsystem so as to record execution time
12040 * stats for the thread-walk (i.e. ensure this can't be blamed on
12041 * on just vty_read()).
12042 */
12043 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
12044
Paul Jakmaff7924f2006-09-04 01:10:36 +000012045 vty_out (vty, "Prefix counts for %s, %s%s",
12046 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
12047 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
12048 vty_out (vty, "%sCounts from RIB table walk:%s%s",
12049 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12050
12051 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000012052 vty_out (vty, "%20s: %-10d%s",
12053 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012054
Paul Jakma2815e612006-09-14 02:56:07 +000012055 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000012056 {
12057 vty_out (vty, "%s [pcount] PfxCt drift!%s",
12058 peer->host, VTY_NEWLINE);
12059 vty_out (vty, "Please report this bug, with the above command output%s",
12060 VTY_NEWLINE);
12061 }
12062
12063 return CMD_SUCCESS;
12064}
12065
Lou Bergerf9b6c392016-01-12 13:42:09 -050012066DEFUN (show_ip_bgp_neighbor_prefix_counts,
12067 show_ip_bgp_neighbor_prefix_counts_cmd,
12068 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12069 SHOW_STR
12070 IP_STR
12071 BGP_STR
12072 "Detailed information on TCP and BGP neighbor connections\n"
12073 "Neighbor to display information about\n"
12074 "Neighbor to display information about\n"
12075 "Display detailed prefix count information\n")
12076{
12077 struct peer *peer;
12078
12079 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12080 if (! peer)
12081 return CMD_WARNING;
12082
12083 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12084}
12085
Paul Jakmaff7924f2006-09-04 01:10:36 +000012086DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
12087 show_bgp_ipv6_neighbor_prefix_counts_cmd,
12088 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12089 SHOW_STR
12090 BGP_STR
12091 "Address family\n"
12092 "Detailed information on TCP and BGP neighbor connections\n"
12093 "Neighbor to display information about\n"
12094 "Neighbor to display information about\n"
12095 "Display detailed prefix count information\n")
12096{
12097 struct peer *peer;
12098
12099 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12100 if (! peer)
12101 return CMD_WARNING;
12102
12103 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
12104}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012105
12106DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
12107 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
12108 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12109 SHOW_STR
12110 IP_STR
12111 BGP_STR
12112 "Address family\n"
12113 "Address Family modifier\n"
12114 "Address Family modifier\n"
12115 "Detailed information on TCP and BGP neighbor connections\n"
12116 "Neighbor to display information about\n"
12117 "Neighbor to display information about\n"
12118 "Display detailed prefix count information\n")
12119{
12120 struct peer *peer;
12121
12122 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12123 if (! peer)
12124 return CMD_WARNING;
12125
12126 if (strncmp (argv[0], "m", 1) == 0)
12127 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
12128
12129 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12130}
12131
12132DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
12133 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
12134 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12135 SHOW_STR
12136 IP_STR
12137 BGP_STR
12138 "Address family\n"
12139 "Address Family modifier\n"
12140 "Address Family modifier\n"
12141 "Detailed information on TCP and BGP neighbor connections\n"
12142 "Neighbor to display information about\n"
12143 "Neighbor to display information about\n"
12144 "Display detailed prefix count information\n")
12145{
12146 struct peer *peer;
12147
12148 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12149 if (! peer)
12150 return CMD_WARNING;
12151
12152 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
12153}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012154
Lou Berger651b4022016-01-12 13:42:07 -050012155DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
12156 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
12157 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012158 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000012159 BGP_STR
12160 "Address family\n"
12161 "Address Family modifier\n"
12162 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012163 "Address Family modifier\n"
12164 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000012165 "Detailed information on TCP and BGP neighbor connections\n"
12166 "Neighbor to display information about\n"
12167 "Neighbor to display information about\n"
12168 "Display detailed prefix count information\n")
12169{
12170 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012171 safi_t safi;
12172
12173 if (bgp_parse_safi(argv[0], &safi)) {
12174 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12175 return CMD_WARNING;
12176 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000012177
12178 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12179 if (! peer)
12180 return CMD_WARNING;
12181
Lou Berger651b4022016-01-12 13:42:07 -050012182 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012183}
Lou Berger205e6742016-01-12 13:42:11 -050012184
Lou Berger651b4022016-01-12 13:42:07 -050012185DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
12186 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
12187 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12188 SHOW_STR
12189 BGP_STR
12190 "Address family\n"
12191 "Address Family modifier\n"
12192 "Address Family modifier\n"
12193 "Address Family modifier\n"
12194 "Address Family modifier\n"
12195 "Detailed information on TCP and BGP neighbor connections\n"
12196 "Neighbor to display information about\n"
12197 "Neighbor to display information about\n"
12198 "Display detailed prefix count information\n")
12199{
12200 struct peer *peer;
12201 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012202
Lou Berger651b4022016-01-12 13:42:07 -050012203 if (bgp_parse_safi(argv[0], &safi)) {
12204 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12205 return CMD_WARNING;
12206 }
12207
12208 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12209 if (! peer)
12210 return CMD_WARNING;
12211
12212 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
12213}
Lou Berger651b4022016-01-12 13:42:07 -050012214
12215DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
12216 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
12217 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012218 SHOW_STR
12219 IP_STR
12220 BGP_STR
12221 "Address family\n"
12222 "Address Family modifier\n"
12223 "Address Family modifier\n"
12224 "Detailed information on TCP and BGP neighbor connections\n"
12225 "Neighbor to display information about\n"
12226 "Neighbor to display information about\n"
12227 "Display detailed prefix count information\n")
12228{
12229 struct peer *peer;
12230
12231 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12232 if (! peer)
12233 return CMD_WARNING;
12234
Lou Berger651b4022016-01-12 13:42:07 -050012235 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012236}
12237
12238
paul94f2b392005-06-28 12:44:16 +000012239static void
paul718e3742002-12-13 20:15:29 +000012240show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
12241 int in)
12242{
12243 struct bgp_table *table;
12244 struct bgp_adj_in *ain;
12245 struct bgp_adj_out *adj;
12246 unsigned long output_count;
12247 struct bgp_node *rn;
12248 int header1 = 1;
12249 struct bgp *bgp;
12250 int header2 = 1;
12251
paulbb46e942003-10-24 19:02:03 +000012252 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000012253
12254 if (! bgp)
12255 return;
12256
12257 table = bgp->rib[afi][safi];
12258
12259 output_count = 0;
12260
12261 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
12262 PEER_STATUS_DEFAULT_ORIGINATE))
12263 {
12264 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 +000012265 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12266 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012267
12268 vty_out (vty, "Originating default network 0.0.0.0%s%s",
12269 VTY_NEWLINE, VTY_NEWLINE);
12270 header1 = 0;
12271 }
12272
12273 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
12274 if (in)
12275 {
12276 for (ain = rn->adj_in; ain; ain = ain->next)
12277 if (ain->peer == peer)
12278 {
12279 if (header1)
12280 {
12281 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 +000012282 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12283 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012284 header1 = 0;
12285 }
12286 if (header2)
12287 {
12288 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12289 header2 = 0;
12290 }
12291 if (ain->attr)
12292 {
12293 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
12294 output_count++;
12295 }
12296 }
12297 }
12298 else
12299 {
12300 for (adj = rn->adj_out; adj; adj = adj->next)
12301 if (adj->peer == peer)
12302 {
12303 if (header1)
12304 {
12305 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 +000012306 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12307 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012308 header1 = 0;
12309 }
12310 if (header2)
12311 {
12312 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12313 header2 = 0;
12314 }
12315 if (adj->attr)
12316 {
12317 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
12318 output_count++;
12319 }
12320 }
12321 }
12322
12323 if (output_count != 0)
12324 vty_out (vty, "%sTotal number of prefixes %ld%s",
12325 VTY_NEWLINE, output_count, VTY_NEWLINE);
12326}
12327
paul94f2b392005-06-28 12:44:16 +000012328static int
paulbb46e942003-10-24 19:02:03 +000012329peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
12330{
paul718e3742002-12-13 20:15:29 +000012331 if (! peer || ! peer->afc[afi][safi])
12332 {
12333 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12334 return CMD_WARNING;
12335 }
12336
12337 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
12338 {
12339 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
12340 VTY_NEWLINE);
12341 return CMD_WARNING;
12342 }
12343
12344 show_adj_route (vty, peer, afi, safi, in);
12345
12346 return CMD_SUCCESS;
12347}
12348
Lou Bergerf9b6c392016-01-12 13:42:09 -050012349DEFUN (show_ip_bgp_view_neighbor_advertised_route,
12350 show_ip_bgp_view_neighbor_advertised_route_cmd,
12351 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12352 SHOW_STR
12353 IP_STR
12354 BGP_STR
12355 "BGP view\n"
12356 "View name\n"
12357 "Detailed information on TCP and BGP neighbor connections\n"
12358 "Neighbor to display information about\n"
12359 "Neighbor to display information about\n"
12360 "Display the routes advertised to a BGP neighbor\n")
12361{
12362 struct peer *peer;
12363
12364 if (argc == 2)
12365 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12366 else
12367 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12368
12369 if (! peer)
12370 return CMD_WARNING;
12371
12372 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12373}
12374
12375ALIAS (show_ip_bgp_view_neighbor_advertised_route,
12376 show_ip_bgp_neighbor_advertised_route_cmd,
12377 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12378 SHOW_STR
12379 IP_STR
12380 BGP_STR
12381 "Detailed information on TCP and BGP neighbor connections\n"
12382 "Neighbor to display information about\n"
12383 "Neighbor to display information about\n"
12384 "Display the routes advertised to a BGP neighbor\n")
12385
12386DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
12387 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
12388 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12389 SHOW_STR
12390 IP_STR
12391 BGP_STR
12392 "Address family\n"
12393 "Address Family modifier\n"
12394 "Address Family modifier\n"
12395 "Detailed information on TCP and BGP neighbor connections\n"
12396 "Neighbor to display information about\n"
12397 "Neighbor to display information about\n"
12398 "Display the routes advertised to a BGP neighbor\n")
12399{
12400 struct peer *peer;
12401
12402 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12403 if (! peer)
12404 return CMD_WARNING;
12405
12406 if (strncmp (argv[0], "m", 1) == 0)
12407 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
12408
12409 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12410}
12411
Lou Bergerf9b6c392016-01-12 13:42:09 -050012412DEFUN (show_bgp_view_neighbor_advertised_route,
12413 show_bgp_view_neighbor_advertised_route_cmd,
12414 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12415 SHOW_STR
12416 BGP_STR
12417 "BGP view\n"
12418 "View name\n"
12419 "Detailed information on TCP and BGP neighbor connections\n"
12420 "Neighbor to display information about\n"
12421 "Neighbor to display information about\n"
12422 "Display the routes advertised to a BGP neighbor\n")
12423{
12424 struct peer *peer;
12425
12426 if (argc == 2)
12427 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12428 else
12429 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12430
12431 if (! peer)
12432 return CMD_WARNING;
12433
12434 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12435}
12436
12437DEFUN (show_bgp_view_neighbor_received_routes,
12438 show_bgp_view_neighbor_received_routes_cmd,
12439 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12440 SHOW_STR
12441 BGP_STR
12442 "BGP view\n"
12443 "View name\n"
12444 "Detailed information on TCP and BGP neighbor connections\n"
12445 "Neighbor to display information about\n"
12446 "Neighbor to display information about\n"
12447 "Display the received routes from neighbor\n")
12448{
12449 struct peer *peer;
12450
12451 if (argc == 2)
12452 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12453 else
12454 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12455
12456 if (! peer)
12457 return CMD_WARNING;
12458
12459 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12460}
12461
12462ALIAS (show_bgp_view_neighbor_advertised_route,
12463 show_bgp_neighbor_advertised_route_cmd,
12464 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12465 SHOW_STR
12466 BGP_STR
12467 "Detailed information on TCP and BGP neighbor connections\n"
12468 "Neighbor to display information about\n"
12469 "Neighbor to display information about\n"
12470 "Display the routes advertised to a BGP neighbor\n")
12471
12472ALIAS (show_bgp_view_neighbor_advertised_route,
12473 show_bgp_ipv6_neighbor_advertised_route_cmd,
12474 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12475 SHOW_STR
12476 BGP_STR
12477 "Address family\n"
12478 "Detailed information on TCP and BGP neighbor connections\n"
12479 "Neighbor to display information about\n"
12480 "Neighbor to display information about\n"
12481 "Display the routes advertised to a BGP neighbor\n")
12482
12483/* old command */
12484ALIAS (show_bgp_view_neighbor_advertised_route,
12485 ipv6_bgp_neighbor_advertised_route_cmd,
12486 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12487 SHOW_STR
12488 IPV6_STR
12489 BGP_STR
12490 "Detailed information on TCP and BGP neighbor connections\n"
12491 "Neighbor to display information about\n"
12492 "Neighbor to display information about\n"
12493 "Display the routes advertised to a BGP neighbor\n")
12494
12495/* old command */
12496DEFUN (ipv6_mbgp_neighbor_advertised_route,
12497 ipv6_mbgp_neighbor_advertised_route_cmd,
12498 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12499 SHOW_STR
12500 IPV6_STR
12501 MBGP_STR
12502 "Detailed information on TCP and BGP neighbor connections\n"
12503 "Neighbor to display information about\n"
12504 "Neighbor to display information about\n"
12505 "Display the routes advertised to a BGP neighbor\n")
12506{
12507 struct peer *peer;
12508
12509 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12510 if (! peer)
12511 return CMD_WARNING;
12512
12513 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
12514}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012515
12516DEFUN (show_ip_bgp_view_neighbor_received_routes,
12517 show_ip_bgp_view_neighbor_received_routes_cmd,
12518 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12519 SHOW_STR
12520 IP_STR
12521 BGP_STR
12522 "BGP view\n"
12523 "View name\n"
12524 "Detailed information on TCP and BGP neighbor connections\n"
12525 "Neighbor to display information about\n"
12526 "Neighbor to display information about\n"
12527 "Display the received routes from neighbor\n")
12528{
12529 struct peer *peer;
12530
12531 if (argc == 2)
12532 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12533 else
12534 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12535
12536 if (! peer)
12537 return CMD_WARNING;
12538
12539 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12540}
12541
12542ALIAS (show_ip_bgp_view_neighbor_received_routes,
12543 show_ip_bgp_neighbor_received_routes_cmd,
12544 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12545 SHOW_STR
12546 IP_STR
12547 BGP_STR
12548 "Detailed information on TCP and BGP neighbor connections\n"
12549 "Neighbor to display information about\n"
12550 "Neighbor to display information about\n"
12551 "Display the received routes from neighbor\n")
12552
12553ALIAS (show_bgp_view_neighbor_received_routes,
12554 show_bgp_ipv6_neighbor_received_routes_cmd,
12555 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
12556 SHOW_STR
12557 BGP_STR
12558 "Address family\n"
12559 "Detailed information on TCP and BGP neighbor connections\n"
12560 "Neighbor to display information about\n"
12561 "Neighbor to display information about\n"
12562 "Display the received routes from neighbor\n")
12563
12564DEFUN (show_bgp_neighbor_received_prefix_filter,
12565 show_bgp_neighbor_received_prefix_filter_cmd,
12566 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12567 SHOW_STR
12568 BGP_STR
12569 "Detailed information on TCP and BGP neighbor connections\n"
12570 "Neighbor to display information about\n"
12571 "Neighbor to display information about\n"
12572 "Display information received from a BGP neighbor\n"
12573 "Display the prefixlist filter\n")
12574{
12575 char name[BUFSIZ];
12576 union sockunion su;
12577 struct peer *peer;
12578 int count, ret;
12579
12580 ret = str2sockunion (argv[0], &su);
12581 if (ret < 0)
12582 {
12583 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12584 return CMD_WARNING;
12585 }
12586
12587 peer = peer_lookup (NULL, &su);
12588 if (! peer)
12589 return CMD_WARNING;
12590
12591 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12592 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12593 if (count)
12594 {
12595 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12596 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12597 }
12598
12599 return CMD_SUCCESS;
12600}
12601
12602/* old command */
12603ALIAS (show_bgp_view_neighbor_received_routes,
12604 ipv6_bgp_neighbor_received_routes_cmd,
12605 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12606 SHOW_STR
12607 IPV6_STR
12608 BGP_STR
12609 "Detailed information on TCP and BGP neighbor connections\n"
12610 "Neighbor to display information about\n"
12611 "Neighbor to display information about\n"
12612 "Display the received routes from neighbor\n")
12613
12614/* old command */
12615DEFUN (ipv6_mbgp_neighbor_received_routes,
12616 ipv6_mbgp_neighbor_received_routes_cmd,
12617 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12618 SHOW_STR
12619 IPV6_STR
12620 MBGP_STR
12621 "Detailed information on TCP and BGP neighbor connections\n"
12622 "Neighbor to display information about\n"
12623 "Neighbor to display information about\n"
12624 "Display the received routes from neighbor\n")
12625{
12626 struct peer *peer;
12627
12628 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12629 if (! peer)
12630 return CMD_WARNING;
12631
12632 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
12633}
12634
12635DEFUN (show_bgp_view_neighbor_received_prefix_filter,
12636 show_bgp_view_neighbor_received_prefix_filter_cmd,
12637 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12638 SHOW_STR
12639 BGP_STR
12640 "BGP view\n"
12641 "View name\n"
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 information received from a BGP neighbor\n"
12646 "Display the prefixlist filter\n")
12647{
12648 char name[BUFSIZ];
12649 union sockunion su;
12650 struct peer *peer;
12651 struct bgp *bgp;
12652 int count, ret;
12653
12654 /* BGP structure lookup. */
12655 bgp = bgp_lookup_by_name (argv[0]);
12656 if (bgp == NULL)
12657 {
12658 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
12659 return CMD_WARNING;
12660 }
12661
12662 ret = str2sockunion (argv[1], &su);
12663 if (ret < 0)
12664 {
12665 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
12666 return CMD_WARNING;
12667 }
12668
12669 peer = peer_lookup (bgp, &su);
12670 if (! peer)
12671 return CMD_WARNING;
12672
12673 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12674 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12675 if (count)
12676 {
12677 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12678 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12679 }
12680
12681 return CMD_SUCCESS;
12682}
12683
12684
12685DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
12686 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
12687 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
12688 SHOW_STR
12689 IP_STR
12690 BGP_STR
12691 "Address family\n"
12692 "Address Family modifier\n"
12693 "Address Family modifier\n"
12694 "Detailed information on TCP and BGP neighbor connections\n"
12695 "Neighbor to display information about\n"
12696 "Neighbor to display information about\n"
12697 "Display the received routes from neighbor\n")
12698{
12699 struct peer *peer;
12700
12701 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12702 if (! peer)
12703 return CMD_WARNING;
12704
12705 if (strncmp (argv[0], "m", 1) == 0)
12706 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
12707
12708 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12709}
12710
Lou Berger651b4022016-01-12 13:42:07 -050012711DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
12712 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
12713 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012714 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012715 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012716 "Address Family modifier\n"
12717 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012718 "Detailed information on TCP and BGP neighbor connections\n"
12719 "Neighbor to display information about\n"
12720 "Neighbor to display information about\n"
12721 "Display the routes advertised to a BGP neighbor\n")
12722{
12723 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012724 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012725
Lou Berger651b4022016-01-12 13:42:07 -050012726 if (bgp_parse_safi(argv[0], &safi)) {
12727 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012728 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050012729 }
paul718e3742002-12-13 20:15:29 +000012730
paulbb46e942003-10-24 19:02:03 +000012731 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12732 if (! peer)
12733 return CMD_WARNING;
12734
Lou Berger651b4022016-01-12 13:42:07 -050012735 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
12736}
Lou Berger205e6742016-01-12 13:42:11 -050012737
Lou Berger651b4022016-01-12 13:42:07 -050012738DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
12739 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
12740 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12741 SHOW_STR
12742 BGP_STR
12743 "Address Family modifier\n"
12744 "Address Family modifier\n"
12745 "Address Family modifier\n"
12746 "Detailed information on TCP and BGP neighbor connections\n"
12747 "Neighbor to display information about\n"
12748 "Neighbor to display information about\n"
12749 "Display the routes advertised to a BGP neighbor\n")
12750{
12751 struct peer *peer;
12752 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000012753
Lou Berger651b4022016-01-12 13:42:07 -050012754 if (bgp_parse_safi(argv[0], &safi)) {
12755 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12756 return CMD_WARNING;
12757 }
12758
12759 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12760 if (! peer)
12761 return CMD_WARNING;
12762
12763 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000012764}
12765
Lou Bergerf9b6c392016-01-12 13:42:09 -050012766DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050012767 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
12768 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000012769 SHOW_STR
12770 BGP_STR
12771 "BGP view\n"
12772 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050012773 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000012774 "Detailed information on TCP and BGP neighbor connections\n"
12775 "Neighbor to display information about\n"
12776 "Neighbor to display information about\n"
12777 "Display the routes advertised to a BGP neighbor\n")
12778{
12779 struct peer *peer;
12780
12781 if (argc == 2)
12782 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12783 else
12784 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12785
12786 if (! peer)
12787 return CMD_WARNING;
12788
12789 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12790}
12791
Lou Bergerf9b6c392016-01-12 13:42:09 -050012792DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050012793 show_bgp_view_ipv6_neighbor_received_routes_cmd,
12794 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000012795 SHOW_STR
12796 BGP_STR
12797 "BGP view\n"
12798 "View name\n"
12799 "Address family\n"
12800 "Detailed information on TCP and BGP neighbor connections\n"
12801 "Neighbor to display information about\n"
12802 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000012803 "Display the received routes from neighbor\n")
12804{
12805 struct peer *peer;
12806
12807 if (argc == 2)
12808 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12809 else
12810 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12811
12812 if (! peer)
12813 return CMD_WARNING;
12814
12815 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12816}
Lou Berger651b4022016-01-12 13:42:07 -050012817
12818DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
12819 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
12820 "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 +010012821 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012822 BGP_STR
12823 "Address family\n"
12824 "Address Family modifier\n"
12825 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012826 "Address Family modifier\n"
12827 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000012828 "Detailed information on TCP and BGP neighbor connections\n"
12829 "Neighbor to display information about\n"
12830 "Neighbor to display information about\n"
12831 "Display the received routes from neighbor\n")
12832{
paulbb46e942003-10-24 19:02:03 +000012833 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012834 safi_t safi;
12835
12836 if (bgp_parse_safi(argv[0], &safi)) {
12837 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12838 return CMD_WARNING;
12839 }
paul718e3742002-12-13 20:15:29 +000012840
paulbb46e942003-10-24 19:02:03 +000012841 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12842 if (! peer)
12843 return CMD_WARNING;
12844
Lou Berger651b4022016-01-12 13:42:07 -050012845 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000012846}
Lou Berger205e6742016-01-12 13:42:11 -050012847
Lou Berger651b4022016-01-12 13:42:07 -050012848DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
12849 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
12850 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
12851 SHOW_STR
12852 BGP_STR
12853 "Address family\n"
12854 "Address Family modifier\n"
12855 "Address Family modifier\n"
12856 "Address Family modifier\n"
12857 "Address Family modifier\n"
12858 "Detailed information on TCP and BGP neighbor connections\n"
12859 "Neighbor to display information about\n"
12860 "Neighbor to display information about\n"
12861 "Display the received routes from neighbor\n")
12862{
12863 struct peer *peer;
12864 safi_t safi;
12865
12866 if (bgp_parse_safi(argv[0], &safi)) {
12867 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12868 return CMD_WARNING;
12869 }
12870
12871 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12872 if (! peer)
12873 return CMD_WARNING;
12874
12875 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
12876}
paul718e3742002-12-13 20:15:29 +000012877
Michael Lambert95cbbd22010-07-23 14:43:04 -040012878DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
12879 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040012880 "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 -040012881 SHOW_STR
12882 BGP_STR
12883 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000012884 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012885 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012886 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012887 "Address family modifier\n"
12888 "Address family modifier\n"
12889 "Detailed information on TCP and BGP neighbor connections\n"
12890 "Neighbor to display information about\n"
12891 "Neighbor to display information about\n"
12892 "Display the advertised routes to neighbor\n"
12893 "Display the received routes from neighbor\n")
12894{
12895 int afi;
12896 int safi;
12897 int in;
12898 struct peer *peer;
12899
David Lamparter94bad672015-03-03 08:52:22 +010012900 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040012901
12902 if (! peer)
12903 return CMD_WARNING;
12904
Michael Lambert95cbbd22010-07-23 14:43:04 -040012905 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12906 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12907 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040012908
12909 return peer_adj_routes (vty, peer, afi, safi, in);
12910}
12911
Lou Bergerf9b6c392016-01-12 13:42:09 -050012912DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
12913 show_ip_bgp_neighbor_received_prefix_filter_cmd,
12914 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12915 SHOW_STR
12916 IP_STR
12917 BGP_STR
12918 "Detailed information on TCP and BGP neighbor connections\n"
12919 "Neighbor to display information about\n"
12920 "Neighbor to display information about\n"
12921 "Display information received from a BGP neighbor\n"
12922 "Display the prefixlist filter\n")
12923{
12924 char name[BUFSIZ];
12925 union sockunion su;
12926 struct peer *peer;
12927 int count, ret;
12928
12929 ret = str2sockunion (argv[0], &su);
12930 if (ret < 0)
12931 {
12932 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12933 return CMD_WARNING;
12934 }
12935
12936 peer = peer_lookup (NULL, &su);
12937 if (! peer)
12938 return CMD_WARNING;
12939
12940 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
12941 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
12942 if (count)
12943 {
12944 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
12945 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
12946 }
12947
12948 return CMD_SUCCESS;
12949}
12950
12951DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
12952 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
12953 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12954 SHOW_STR
12955 IP_STR
12956 BGP_STR
12957 "Address family\n"
12958 "Address Family modifier\n"
12959 "Address Family modifier\n"
12960 "Detailed information on TCP and BGP neighbor connections\n"
12961 "Neighbor to display information about\n"
12962 "Neighbor to display information about\n"
12963 "Display information received from a BGP neighbor\n"
12964 "Display the prefixlist filter\n")
12965{
12966 char name[BUFSIZ];
12967 union sockunion su;
12968 struct peer *peer;
12969 int count, ret;
12970
12971 ret = str2sockunion (argv[1], &su);
12972 if (ret < 0)
12973 {
12974 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
12975 return CMD_WARNING;
12976 }
12977
12978 peer = peer_lookup (NULL, &su);
12979 if (! peer)
12980 return CMD_WARNING;
12981
12982 if (strncmp (argv[0], "m", 1) == 0)
12983 {
12984 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
12985 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
12986 if (count)
12987 {
12988 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
12989 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
12990 }
12991 }
12992 else
12993 {
12994 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
12995 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
12996 if (count)
12997 {
12998 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
12999 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13000 }
13001 }
13002
13003 return CMD_SUCCESS;
13004}
13005
13006ALIAS (show_bgp_view_neighbor_received_routes,
13007 show_bgp_neighbor_received_routes_cmd,
13008 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13009 SHOW_STR
13010 BGP_STR
13011 "Detailed information on TCP and BGP neighbor connections\n"
13012 "Neighbor to display information about\n"
13013 "Neighbor to display information about\n"
13014 "Display the received routes from neighbor\n")
13015
Lou Berger651b4022016-01-12 13:42:07 -050013016DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
13017 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
13018 "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 +000013019 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013020 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013021 IP_STR
13022 "Address Family modifier\n"
13023 "Address Family modifier\n"
13024 "Address Family modifier\n"
13025 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013026 "Detailed information on TCP and BGP neighbor connections\n"
13027 "Neighbor to display information about\n"
13028 "Neighbor to display information about\n"
13029 "Display information received from a BGP neighbor\n"
13030 "Display the prefixlist filter\n")
13031{
13032 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013033 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013034 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013035 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050013036 safi_t safi;
paul718e3742002-12-13 20:15:29 +000013037
Lou Berger651b4022016-01-12 13:42:07 -050013038 if (bgp_parse_safi(argv[0], &safi)) {
13039 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013040 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013041 }
paul718e3742002-12-13 20:15:29 +000013042
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013043 ret = str2sockunion (argv[1], &su);
13044 if (ret < 0)
13045 {
13046 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13047 return CMD_WARNING;
13048 }
paul718e3742002-12-13 20:15:29 +000013049
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013050 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013051 if (! peer)
13052 return CMD_WARNING;
13053
Lou Berger651b4022016-01-12 13:42:07 -050013054 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
13055 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13056 if (count) {
13057 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
13058 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13059 }
paul718e3742002-12-13 20:15:29 +000013060
13061 return CMD_SUCCESS;
13062}
Lou Berger205e6742016-01-12 13:42:11 -050013063
Lou Berger651b4022016-01-12 13:42:07 -050013064DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
13065 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
13066 "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 +000013067 SHOW_STR
13068 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013069 IP_STR
13070 "Address Family modifier\n"
13071 "Address Family modifier\n"
13072 "Address Family modifier\n"
13073 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013074 "Detailed information on TCP and BGP neighbor connections\n"
13075 "Neighbor to display information about\n"
13076 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050013077 "Display information received from a BGP neighbor\n"
13078 "Display the prefixlist filter\n")
13079{
13080 char name[BUFSIZ];
13081 union sockunion su;
13082 struct peer *peer;
13083 int count, ret;
13084 safi_t safi;
13085
13086 if (bgp_parse_safi(argv[0], &safi)) {
13087 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13088 return CMD_WARNING;
13089 }
13090
13091 ret = str2sockunion (argv[1], &su);
13092 if (ret < 0)
13093 {
13094 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13095 return CMD_WARNING;
13096 }
13097
13098 peer = peer_lookup (NULL, &su);
13099 if (! peer)
13100 return CMD_WARNING;
13101
13102 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
13103 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13104 if (count) {
13105 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
13106 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13107 }
13108
13109 return CMD_SUCCESS;
13110}
paul718e3742002-12-13 20:15:29 +000013111
Lou Bergerf9b6c392016-01-12 13:42:09 -050013112DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013113 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
13114 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013115 SHOW_STR
13116 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013117 "Address family\n"
paul718e3742002-12-13 20:15:29 +000013118 "Detailed information on TCP and BGP neighbor connections\n"
13119 "Neighbor to display information about\n"
13120 "Neighbor to display information about\n"
13121 "Display information received from a BGP neighbor\n"
13122 "Display the prefixlist filter\n")
13123{
13124 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013125 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013126 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013127 int count, ret;
paul718e3742002-12-13 20:15:29 +000013128
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013129 ret = str2sockunion (argv[0], &su);
13130 if (ret < 0)
13131 {
13132 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13133 return CMD_WARNING;
13134 }
paul718e3742002-12-13 20:15:29 +000013135
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013136 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013137 if (! peer)
13138 return CMD_WARNING;
13139
13140 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13141 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13142 if (count)
13143 {
13144 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13145 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13146 }
13147
13148 return CMD_SUCCESS;
13149}
13150
Lou Bergerf9b6c392016-01-12 13:42:09 -050013151DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013152 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
13153 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000013154 SHOW_STR
13155 BGP_STR
13156 "BGP view\n"
13157 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013158 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013159 "Detailed information on TCP and BGP neighbor connections\n"
13160 "Neighbor to display information about\n"
13161 "Neighbor to display information about\n"
13162 "Display information received from a BGP neighbor\n"
13163 "Display the prefixlist filter\n")
13164{
13165 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013166 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000013167 struct peer *peer;
13168 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013169 int count, ret;
paulbb46e942003-10-24 19:02:03 +000013170
13171 /* BGP structure lookup. */
13172 bgp = bgp_lookup_by_name (argv[0]);
13173 if (bgp == NULL)
13174 {
13175 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13176 return CMD_WARNING;
13177 }
13178
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013179 ret = str2sockunion (argv[1], &su);
13180 if (ret < 0)
13181 {
13182 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13183 return CMD_WARNING;
13184 }
paulbb46e942003-10-24 19:02:03 +000013185
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013186 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000013187 if (! peer)
13188 return CMD_WARNING;
13189
13190 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13191 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13192 if (count)
13193 {
13194 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13195 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13196 }
13197
13198 return CMD_SUCCESS;
13199}
David Lamparter6b0655a2014-06-04 06:53:35 +020013200
paul94f2b392005-06-28 12:44:16 +000013201static int
paulbb46e942003-10-24 19:02:03 +000013202bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000013203 safi_t safi, enum bgp_show_type type)
13204{
paul718e3742002-12-13 20:15:29 +000013205 if (! peer || ! peer->afc[afi][safi])
13206 {
13207 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013208 return CMD_WARNING;
13209 }
13210
ajs5a646652004-11-05 01:25:55 +000013211 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000013212}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013213DEFUN (show_ip_bgp_neighbor_routes,
13214 show_ip_bgp_neighbor_routes_cmd,
13215 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
13216 SHOW_STR
13217 IP_STR
13218 BGP_STR
13219 "Detailed information on TCP and BGP neighbor connections\n"
13220 "Neighbor to display information about\n"
13221 "Neighbor to display information about\n"
13222 "Display routes learned from neighbor\n")
13223{
13224 struct peer *peer;
13225
13226 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13227 if (! peer)
13228 return CMD_WARNING;
13229
13230 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13231 bgp_show_type_neighbor);
13232}
13233
13234DEFUN (show_ip_bgp_neighbor_flap,
13235 show_ip_bgp_neighbor_flap_cmd,
13236 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
13237 SHOW_STR
13238 IP_STR
13239 BGP_STR
13240 "Detailed information on TCP and BGP neighbor connections\n"
13241 "Neighbor to display information about\n"
13242 "Neighbor to display information about\n"
13243 "Display flap statistics of the routes learned from neighbor\n")
13244{
13245 struct peer *peer;
13246
13247 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13248 if (! peer)
13249 return CMD_WARNING;
13250
13251 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13252 bgp_show_type_flap_neighbor);
13253}
13254
13255DEFUN (show_ip_bgp_neighbor_damp,
13256 show_ip_bgp_neighbor_damp_cmd,
13257 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13258 SHOW_STR
13259 IP_STR
13260 BGP_STR
13261 "Detailed information on TCP and BGP neighbor connections\n"
13262 "Neighbor to display information about\n"
13263 "Neighbor to display information about\n"
13264 "Display the dampened routes received from neighbor\n")
13265{
13266 struct peer *peer;
13267
13268 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13269 if (! peer)
13270 return CMD_WARNING;
13271
13272 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13273 bgp_show_type_damp_neighbor);
13274}
13275
13276DEFUN (show_ip_bgp_ipv4_neighbor_routes,
13277 show_ip_bgp_ipv4_neighbor_routes_cmd,
13278 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
13279 SHOW_STR
13280 IP_STR
13281 BGP_STR
13282 "Address family\n"
13283 "Address Family modifier\n"
13284 "Address Family modifier\n"
13285 "Detailed information on TCP and BGP neighbor connections\n"
13286 "Neighbor to display information about\n"
13287 "Neighbor to display information about\n"
13288 "Display routes learned from neighbor\n")
13289{
13290 struct peer *peer;
13291
13292 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13293 if (! peer)
13294 return CMD_WARNING;
13295
13296 if (strncmp (argv[0], "m", 1) == 0)
13297 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
13298 bgp_show_type_neighbor);
13299
13300 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13301 bgp_show_type_neighbor);
13302}
13303
13304DEFUN (show_ip_bgp_view_rsclient,
13305 show_ip_bgp_view_rsclient_cmd,
13306 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
13307 SHOW_STR
13308 IP_STR
13309 BGP_STR
13310 "BGP view\n"
13311 "View name\n"
13312 "Information about Route Server Client\n"
13313 NEIGHBOR_ADDR_STR)
13314{
13315 struct bgp_table *table;
13316 struct peer *peer;
13317
13318 if (argc == 2)
13319 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13320 else
13321 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13322
13323 if (! peer)
13324 return CMD_WARNING;
13325
13326 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13327 {
13328 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13329 VTY_NEWLINE);
13330 return CMD_WARNING;
13331 }
13332
13333 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13334 PEER_FLAG_RSERVER_CLIENT))
13335 {
13336 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13337 VTY_NEWLINE);
13338 return CMD_WARNING;
13339 }
13340
13341 table = peer->rib[AFI_IP][SAFI_UNICAST];
13342
13343 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13344}
13345
13346ALIAS (show_ip_bgp_view_rsclient,
13347 show_ip_bgp_rsclient_cmd,
13348 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
13349 SHOW_STR
13350 IP_STR
13351 BGP_STR
13352 "Information about Route Server Client\n"
13353 NEIGHBOR_ADDR_STR)
13354
13355DEFUN (show_bgp_view_ipv4_safi_rsclient,
13356 show_bgp_view_ipv4_safi_rsclient_cmd,
13357 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13358 SHOW_STR
13359 BGP_STR
13360 "BGP view\n"
13361 "View name\n"
13362 "Address family\n"
13363 "Address Family modifier\n"
13364 "Address Family modifier\n"
13365 "Information about Route Server Client\n"
13366 NEIGHBOR_ADDR_STR)
13367{
13368 struct bgp_table *table;
13369 struct peer *peer;
13370 safi_t safi;
13371
13372 if (argc == 3) {
13373 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13374 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13375 } else {
13376 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13377 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13378 }
13379
13380 if (! peer)
13381 return CMD_WARNING;
13382
13383 if (! peer->afc[AFI_IP][safi])
13384 {
13385 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13386 VTY_NEWLINE);
13387 return CMD_WARNING;
13388 }
13389
13390 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13391 PEER_FLAG_RSERVER_CLIENT))
13392 {
13393 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13394 VTY_NEWLINE);
13395 return CMD_WARNING;
13396 }
13397
13398 table = peer->rib[AFI_IP][safi];
13399
13400 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13401}
13402
13403ALIAS (show_bgp_view_ipv4_safi_rsclient,
13404 show_bgp_ipv4_safi_rsclient_cmd,
13405 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13406 SHOW_STR
13407 BGP_STR
13408 "Address family\n"
13409 "Address Family modifier\n"
13410 "Address Family modifier\n"
13411 "Information about Route Server Client\n"
13412 NEIGHBOR_ADDR_STR)
13413
13414DEFUN (show_ip_bgp_view_rsclient_route,
13415 show_ip_bgp_view_rsclient_route_cmd,
13416 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13417 SHOW_STR
13418 IP_STR
13419 BGP_STR
13420 "BGP view\n"
13421 "View name\n"
13422 "Information about Route Server Client\n"
13423 NEIGHBOR_ADDR_STR
13424 "Network in the BGP routing table to display\n")
13425{
13426 struct bgp *bgp;
13427 struct peer *peer;
13428
13429 /* BGP structure lookup. */
13430 if (argc == 3)
13431 {
13432 bgp = bgp_lookup_by_name (argv[0]);
13433 if (bgp == NULL)
13434 {
13435 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13436 return CMD_WARNING;
13437 }
13438 }
13439 else
13440 {
13441 bgp = bgp_get_default ();
13442 if (bgp == NULL)
13443 {
13444 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13445 return CMD_WARNING;
13446 }
13447 }
13448
13449 if (argc == 3)
13450 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13451 else
13452 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13453
13454 if (! peer)
13455 return CMD_WARNING;
13456
13457 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13458 {
13459 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13460 VTY_NEWLINE);
13461 return CMD_WARNING;
13462}
13463
13464 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13465 PEER_FLAG_RSERVER_CLIENT))
13466 {
13467 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13468 VTY_NEWLINE);
13469 return CMD_WARNING;
13470 }
13471
13472 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13473 (argc == 3) ? argv[2] : argv[1],
13474 AFI_IP, SAFI_UNICAST, NULL, 0);
13475}
13476
13477ALIAS (show_ip_bgp_view_rsclient_route,
13478 show_ip_bgp_rsclient_route_cmd,
13479 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13480 SHOW_STR
13481 IP_STR
13482 BGP_STR
13483 "Information about Route Server Client\n"
13484 NEIGHBOR_ADDR_STR
13485 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000013486
Lou Berger651b4022016-01-12 13:42:07 -050013487DEFUN (show_bgp_ipv4_safi_neighbor_flap,
13488 show_bgp_ipv4_safi_neighbor_flap_cmd,
13489 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013490 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013491 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013492 "Address Family Modifier\n"
13493 "Address Family Modifier\n"
13494 "Address Family Modifier\n"
13495 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013496 "Detailed information on TCP and BGP neighbor connections\n"
13497 "Neighbor to display information about\n"
13498 "Neighbor to display information about\n"
13499 "Display flap statistics of the routes learned from neighbor\n")
13500{
paulbb46e942003-10-24 19:02:03 +000013501 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013502 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013503
Lou Berger651b4022016-01-12 13:42:07 -050013504 if (bgp_parse_safi(argv[0], &safi)) {
13505 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13506 return CMD_WARNING;
13507 }
13508
13509 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013510 if (! peer)
13511 return CMD_WARNING;
13512
Lou Berger651b4022016-01-12 13:42:07 -050013513 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013514 bgp_show_type_flap_neighbor);
13515}
Lou Berger205e6742016-01-12 13:42:11 -050013516
Lou Berger651b4022016-01-12 13:42:07 -050013517DEFUN (show_bgp_ipv6_safi_neighbor_flap,
13518 show_bgp_ipv6_safi_neighbor_flap_cmd,
13519 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013520 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013521 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013522 "Address Family Modifier\n"
13523 "Address Family Modifier\n"
13524 "Address Family Modifier\n"
13525 "Address Family Modifier\n"
13526 "Detailed information on TCP and BGP neighbor connections\n"
13527 "Neighbor to display information about\n"
13528 "Neighbor to display information about\n"
13529 "Display flap statistics of the routes learned from neighbor\n")
13530{
13531 struct peer *peer;
13532 safi_t safi;
13533
13534 if (bgp_parse_safi(argv[0], &safi)) {
13535 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13536 return CMD_WARNING;
13537 }
13538
13539 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13540 if (! peer)
13541 return CMD_WARNING;
13542
13543 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13544 bgp_show_type_flap_neighbor);
13545}
Lou Berger651b4022016-01-12 13:42:07 -050013546
13547DEFUN (show_bgp_ipv4_safi_neighbor_damp,
13548 show_bgp_ipv4_safi_neighbor_damp_cmd,
13549 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13550 SHOW_STR
13551 BGP_STR
13552 "Address Family Modifier\n"
13553 "Address Family Modifier\n"
13554 "Address Family Modifier\n"
13555 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013556 "Detailed information on TCP and BGP neighbor connections\n"
13557 "Neighbor to display information about\n"
13558 "Neighbor to display information about\n"
13559 "Display the dampened routes received from neighbor\n")
13560{
paulbb46e942003-10-24 19:02:03 +000013561 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013562 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013563
Lou Berger651b4022016-01-12 13:42:07 -050013564 if (bgp_parse_safi(argv[0], &safi)) {
13565 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13566 return CMD_WARNING;
13567 }
13568
13569 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013570 if (! peer)
13571 return CMD_WARNING;
13572
Lou Berger651b4022016-01-12 13:42:07 -050013573 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013574 bgp_show_type_damp_neighbor);
13575}
Lou Berger205e6742016-01-12 13:42:11 -050013576
Lou Berger651b4022016-01-12 13:42:07 -050013577DEFUN (show_bgp_ipv6_safi_neighbor_damp,
13578 show_bgp_ipv6_safi_neighbor_damp_cmd,
13579 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000013580 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050013581 BGP_STR
13582 "Address Family Modifier\n"
13583 "Address Family Modifier\n"
13584 "Address Family Modifier\n"
13585 "Address Family Modifier\n"
13586 "Detailed information on TCP and BGP neighbor connections\n"
13587 "Neighbor to display information about\n"
13588 "Neighbor to display information about\n"
13589 "Display the dampened routes received from neighbor\n")
13590{
13591 struct peer *peer;
13592 safi_t safi;
13593
13594 if (bgp_parse_safi(argv[0], &safi)) {
13595 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13596 return CMD_WARNING;
13597 }
13598
13599 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13600 if (! peer)
13601 return CMD_WARNING;
13602
13603 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13604 bgp_show_type_damp_neighbor);
13605}
Lou Berger651b4022016-01-12 13:42:07 -050013606
13607DEFUN (show_bgp_ipv4_safi_neighbor_routes,
13608 show_bgp_ipv4_safi_neighbor_routes_cmd,
13609 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
13610 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013611 BGP_STR
13612 "Address family\n"
13613 "Address Family modifier\n"
13614 "Address Family modifier\n"
13615 "Detailed information on TCP and BGP neighbor connections\n"
13616 "Neighbor to display information about\n"
13617 "Neighbor to display information about\n"
13618 "Display routes learned from neighbor\n")
13619{
paulbb46e942003-10-24 19:02:03 +000013620 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013621 safi_t safi;
13622
13623 if (bgp_parse_safi(argv[0], &safi)) {
13624 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13625 return CMD_WARNING;
13626 }
paulbb46e942003-10-24 19:02:03 +000013627
13628 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13629 if (! peer)
13630 return CMD_WARNING;
13631
Lou Berger651b4022016-01-12 13:42:07 -050013632 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013633 bgp_show_type_neighbor);
13634}
Lou Berger205e6742016-01-12 13:42:11 -050013635
Lou Berger651b4022016-01-12 13:42:07 -050013636DEFUN (show_bgp_ipv6_safi_neighbor_routes,
13637 show_bgp_ipv6_safi_neighbor_routes_cmd,
13638 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000013639 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000013640 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013641 "Address family\n"
13642 "Address Family modifier\n"
13643 "Address Family modifier\n"
13644 "Detailed information on TCP and BGP neighbor connections\n"
13645 NEIGHBOR_ADDR_STR
13646 NEIGHBOR_ADDR_STR
13647 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000013648{
paulfee0f4c2004-09-13 05:12:46 +000013649 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013650 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000013651
Lou Berger651b4022016-01-12 13:42:07 -050013652 if (bgp_parse_safi(argv[0], &safi)) {
13653 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13654 return CMD_WARNING;
13655 }
paulfee0f4c2004-09-13 05:12:46 +000013656
Lou Berger651b4022016-01-12 13:42:07 -050013657 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000013658 if (! peer)
13659 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013660
13661 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13662 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000013663}
paulfee0f4c2004-09-13 05:12:46 +000013664
Michael Lambert95cbbd22010-07-23 14:43:04 -040013665DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
13666 show_bgp_view_ipv4_safi_rsclient_route_cmd,
13667 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13668 SHOW_STR
13669 BGP_STR
13670 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013671 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013672 "Address family\n"
13673 "Address Family modifier\n"
13674 "Address Family modifier\n"
13675 "Information about Route Server Client\n"
13676 NEIGHBOR_ADDR_STR
13677 "Network in the BGP routing table to display\n")
13678{
13679 struct bgp *bgp;
13680 struct peer *peer;
13681 safi_t safi;
13682
13683 /* BGP structure lookup. */
13684 if (argc == 4)
13685 {
13686 bgp = bgp_lookup_by_name (argv[0]);
13687 if (bgp == NULL)
13688 {
13689 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13690 return CMD_WARNING;
13691 }
13692 }
13693 else
13694 {
13695 bgp = bgp_get_default ();
13696 if (bgp == NULL)
13697 {
13698 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13699 return CMD_WARNING;
13700 }
13701 }
13702
13703 if (argc == 4) {
13704 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13705 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13706 } else {
13707 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13708 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13709 }
13710
13711 if (! peer)
13712 return CMD_WARNING;
13713
13714 if (! peer->afc[AFI_IP][safi])
13715 {
13716 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13717 VTY_NEWLINE);
13718 return CMD_WARNING;
13719}
13720
13721 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13722 PEER_FLAG_RSERVER_CLIENT))
13723 {
13724 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13725 VTY_NEWLINE);
13726 return CMD_WARNING;
13727 }
13728
13729 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13730 (argc == 4) ? argv[3] : argv[2],
13731 AFI_IP, safi, NULL, 0);
13732}
13733
13734ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
13735 show_bgp_ipv4_safi_rsclient_route_cmd,
13736 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13737 SHOW_STR
13738 BGP_STR
13739 "Address family\n"
13740 "Address Family modifier\n"
13741 "Address Family modifier\n"
13742 "Information about Route Server Client\n"
13743 NEIGHBOR_ADDR_STR
13744 "Network in the BGP routing table to display\n")
13745
paulfee0f4c2004-09-13 05:12:46 +000013746
Michael Lambert95cbbd22010-07-23 14:43:04 -040013747DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
13748 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
13749 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13750 SHOW_STR
13751 BGP_STR
13752 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013753 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013754 "Address family\n"
13755 "Address Family modifier\n"
13756 "Address Family modifier\n"
13757 "Information about Route Server Client\n"
13758 NEIGHBOR_ADDR_STR
13759 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13760{
13761 struct bgp *bgp;
13762 struct peer *peer;
13763 safi_t safi;
13764
13765 /* BGP structure lookup. */
13766 if (argc == 4)
13767 {
13768 bgp = bgp_lookup_by_name (argv[0]);
13769 if (bgp == NULL)
13770 {
13771 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13772 return CMD_WARNING;
13773 }
13774 }
13775 else
13776 {
13777 bgp = bgp_get_default ();
13778 if (bgp == NULL)
13779 {
13780 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13781 return CMD_WARNING;
13782 }
13783 }
13784
13785 if (argc == 4) {
13786 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13787 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13788 } else {
13789 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13790 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13791 }
13792
13793 if (! peer)
13794 return CMD_WARNING;
13795
13796 if (! peer->afc[AFI_IP][safi])
13797 {
13798 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13799 VTY_NEWLINE);
13800 return CMD_WARNING;
13801}
13802
13803 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13804 PEER_FLAG_RSERVER_CLIENT))
13805{
13806 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13807 VTY_NEWLINE);
13808 return CMD_WARNING;
13809 }
13810
13811 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13812 (argc == 4) ? argv[3] : argv[2],
13813 AFI_IP, safi, NULL, 1);
13814}
13815
Lou Bergerf9b6c392016-01-12 13:42:09 -050013816DEFUN (show_ip_bgp_view_rsclient_prefix,
13817 show_ip_bgp_view_rsclient_prefix_cmd,
13818 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13819 SHOW_STR
13820 IP_STR
13821 BGP_STR
13822 "BGP view\n"
13823 "View name\n"
13824 "Information about Route Server Client\n"
13825 NEIGHBOR_ADDR_STR
13826 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13827{
13828 struct bgp *bgp;
13829 struct peer *peer;
13830
13831 /* BGP structure lookup. */
13832 if (argc == 3)
13833 {
13834 bgp = bgp_lookup_by_name (argv[0]);
13835 if (bgp == NULL)
13836 {
13837 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13838 return CMD_WARNING;
13839 }
13840 }
13841 else
13842 {
13843 bgp = bgp_get_default ();
13844 if (bgp == NULL)
13845 {
13846 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13847 return CMD_WARNING;
13848 }
13849 }
13850
13851 if (argc == 3)
13852 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13853 else
13854 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13855
13856 if (! peer)
13857 return CMD_WARNING;
13858
13859 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13860 {
13861 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13862 VTY_NEWLINE);
13863 return CMD_WARNING;
13864}
13865
13866 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13867 PEER_FLAG_RSERVER_CLIENT))
13868{
13869 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13870 VTY_NEWLINE);
13871 return CMD_WARNING;
13872 }
13873
13874 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13875 (argc == 3) ? argv[2] : argv[1],
13876 AFI_IP, SAFI_UNICAST, NULL, 1);
13877}
13878
13879ALIAS (show_ip_bgp_view_rsclient_prefix,
13880 show_ip_bgp_rsclient_prefix_cmd,
13881 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13882 SHOW_STR
13883 IP_STR
13884 BGP_STR
13885 "Information about Route Server Client\n"
13886 NEIGHBOR_ADDR_STR
13887 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13888
Michael Lambert95cbbd22010-07-23 14:43:04 -040013889ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
13890 show_bgp_ipv4_safi_rsclient_prefix_cmd,
13891 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13892 SHOW_STR
13893 BGP_STR
13894 "Address family\n"
13895 "Address Family modifier\n"
13896 "Address Family modifier\n"
13897 "Information about Route Server Client\n"
13898 NEIGHBOR_ADDR_STR
13899 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000013900
Lou Bergerf9b6c392016-01-12 13:42:09 -050013901DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050013902 show_bgp_view_ipv6_neighbor_routes_cmd,
13903 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +000013904 SHOW_STR
13905 BGP_STR
13906 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013907 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013908 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013909 "Detailed information on TCP and BGP neighbor connections\n"
13910 "Neighbor to display information about\n"
13911 "Neighbor to display information about\n"
13912 "Display routes learned from neighbor\n")
13913{
13914 struct peer *peer;
13915
13916 if (argc == 2)
13917 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13918 else
13919 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13920
13921 if (! peer)
13922 return CMD_WARNING;
13923
13924 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13925 bgp_show_type_neighbor);
13926}
13927
Lou Berger651b4022016-01-12 13:42:07 -050013928DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050013929 show_bgp_view_neighbor_damp_cmd,
13930 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13931 SHOW_STR
13932 BGP_STR
13933 "BGP view\n"
13934 "View name\n"
13935 "Detailed information on TCP and BGP neighbor connections\n"
13936 "Neighbor to display information about\n"
13937 "Neighbor to display information about\n"
13938 "Display the dampened routes received from neighbor\n")
13939{
13940 struct peer *peer;
13941
13942 if (argc == 2)
13943 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13944 else
13945 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13946
13947 if (! peer)
13948 return CMD_WARNING;
13949
13950 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13951 bgp_show_type_damp_neighbor);
13952}
13953
13954DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050013955 show_bgp_view_ipv6_neighbor_damp_cmd,
13956 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000013957 SHOW_STR
13958 BGP_STR
13959 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013960 "View name\n"
paulbb46e942003-10-24 19:02:03 +000013961 "Address family\n"
13962 "Detailed information on TCP and BGP neighbor connections\n"
13963 "Neighbor to display information about\n"
13964 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000013965 "Display the dampened routes received from neighbor\n")
13966{
13967 struct peer *peer;
13968
13969 if (argc == 2)
13970 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13971 else
13972 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13973
13974 if (! peer)
13975 return CMD_WARNING;
13976
13977 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13978 bgp_show_type_damp_neighbor);
13979}
13980
Lou Bergerf9b6c392016-01-12 13:42:09 -050013981DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050013982 show_bgp_view_ipv6_neighbor_flap_cmd,
13983 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000013984 SHOW_STR
13985 BGP_STR
13986 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013987 "View name\n"
paulbb46e942003-10-24 19:02:03 +000013988 "Address family\n"
13989 "Detailed information on TCP and BGP neighbor connections\n"
13990 "Neighbor to display information about\n"
13991 "Neighbor to display information about\n"
13992 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000013993{
13994 struct peer *peer;
13995
13996 if (argc == 2)
13997 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13998 else
13999 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14000
14001 if (! peer)
14002 return CMD_WARNING;
14003
14004 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14005 bgp_show_type_flap_neighbor);
14006}
14007
Lou Bergerf9b6c392016-01-12 13:42:09 -050014008DEFUN (show_bgp_view_neighbor_flap,
14009 show_bgp_view_neighbor_flap_cmd,
14010 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14011 SHOW_STR
14012 BGP_STR
14013 "BGP view\n"
14014 "View name\n"
14015 "Detailed information on TCP and BGP neighbor connections\n"
14016 "Neighbor to display information about\n"
14017 "Neighbor to display information about\n"
14018 "Display flap statistics of the routes learned from neighbor\n")
14019{
14020 struct peer *peer;
14021
14022 if (argc == 2)
14023 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14024 else
14025 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14026
14027 if (! peer)
14028 return CMD_WARNING;
14029
14030 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14031 bgp_show_type_flap_neighbor);
14032}
14033
14034ALIAS (show_bgp_view_neighbor_flap,
14035 show_bgp_neighbor_flap_cmd,
14036 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14037 SHOW_STR
14038 BGP_STR
14039 "Detailed information on TCP and BGP neighbor connections\n"
14040 "Neighbor to display information about\n"
14041 "Neighbor to display information about\n"
14042 "Display flap statistics of the routes learned from neighbor\n")
14043
14044ALIAS (show_bgp_view_neighbor_damp,
14045 show_bgp_neighbor_damp_cmd,
14046 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14047 SHOW_STR
14048 BGP_STR
14049 "Detailed information on TCP and BGP neighbor connections\n"
14050 "Neighbor to display information about\n"
14051 "Neighbor to display information about\n"
14052 "Display the dampened routes received from neighbor\n")
14053
14054DEFUN (show_bgp_view_neighbor_routes,
14055 show_bgp_view_neighbor_routes_cmd,
14056 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
14057 SHOW_STR
14058 BGP_STR
14059 "BGP view\n"
14060 "View name\n"
14061 "Detailed information on TCP and BGP neighbor connections\n"
14062 "Neighbor to display information about\n"
14063 "Neighbor to display information about\n"
14064 "Display routes learned from neighbor\n")
14065{
14066 struct peer *peer;
14067
14068 if (argc == 2)
14069 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14070 else
14071 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14072
14073 if (! peer)
14074 return CMD_WARNING;
14075
14076 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14077 bgp_show_type_neighbor);
14078}
14079
14080ALIAS (show_bgp_view_neighbor_routes,
14081 show_bgp_neighbor_routes_cmd,
14082 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
14083 SHOW_STR
14084 BGP_STR
14085 "Detailed information on TCP and BGP neighbor connections\n"
14086 "Neighbor to display information about\n"
14087 "Neighbor to display information about\n"
14088 "Display routes learned from neighbor\n")
14089
paulbb46e942003-10-24 19:02:03 +000014090ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000014091 show_bgp_ipv6_neighbor_routes_cmd,
14092 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
14093 SHOW_STR
14094 BGP_STR
14095 "Address family\n"
14096 "Detailed information on TCP and BGP neighbor connections\n"
14097 "Neighbor to display information about\n"
14098 "Neighbor to display information about\n"
14099 "Display routes learned from neighbor\n")
14100
Lou Bergerf9b6c392016-01-12 13:42:09 -050014101/* old command */
14102ALIAS (show_bgp_view_neighbor_routes,
14103 ipv6_bgp_neighbor_routes_cmd,
14104 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
14105 SHOW_STR
14106 IPV6_STR
14107 BGP_STR
14108 "Detailed information on TCP and BGP neighbor connections\n"
14109 "Neighbor to display information about\n"
14110 "Neighbor to display information about\n"
14111 "Display routes learned from neighbor\n")
14112
14113/* old command */
14114DEFUN (ipv6_mbgp_neighbor_routes,
14115 ipv6_mbgp_neighbor_routes_cmd,
14116 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
14117 SHOW_STR
14118 IPV6_STR
14119 MBGP_STR
14120 "Detailed information on TCP and BGP neighbor connections\n"
14121 "Neighbor to display information about\n"
14122 "Neighbor to display information about\n"
14123 "Display routes learned from neighbor\n")
14124{
14125 struct peer *peer;
14126
14127 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14128 if (! peer)
14129 return CMD_WARNING;
14130
14131 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
14132 bgp_show_type_neighbor);
14133}
14134
paulbb46e942003-10-24 19:02:03 +000014135ALIAS (show_bgp_view_neighbor_flap,
14136 show_bgp_ipv6_neighbor_flap_cmd,
14137 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14138 SHOW_STR
14139 BGP_STR
14140 "Address family\n"
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 flap statistics of the routes learned from neighbor\n")
14145
14146ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000014147 show_bgp_ipv6_neighbor_damp_cmd,
14148 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14149 SHOW_STR
14150 BGP_STR
14151 "Address family\n"
14152 "Detailed information on TCP and BGP neighbor connections\n"
14153 "Neighbor to display information about\n"
14154 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000014155 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014156
Lou Bergerf9b6c392016-01-12 13:42:09 -050014157DEFUN (show_bgp_view_rsclient,
14158 show_bgp_view_rsclient_cmd,
14159 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14160 SHOW_STR
14161 BGP_STR
14162 "BGP view\n"
14163 "View name\n"
14164 "Information about Route Server Client\n"
14165 NEIGHBOR_ADDR_STR)
14166{
14167 struct bgp_table *table;
14168 struct peer *peer;
14169
14170 if (argc == 2)
14171 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14172 else
14173 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14174
14175 if (! peer)
14176 return CMD_WARNING;
14177
14178 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14179 {
14180 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14181 VTY_NEWLINE);
14182 return CMD_WARNING;
14183 }
14184
14185 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14186 PEER_FLAG_RSERVER_CLIENT))
14187 {
14188 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14189 VTY_NEWLINE);
14190 return CMD_WARNING;
14191 }
14192
14193 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14194
14195 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14196}
14197
14198ALIAS (show_bgp_view_rsclient,
14199 show_bgp_rsclient_cmd,
14200 "show bgp rsclient (A.B.C.D|X:X::X:X)",
14201 SHOW_STR
14202 BGP_STR
14203 "Information about Route Server Client\n"
14204 NEIGHBOR_ADDR_STR)
14205
Lou Berger651b4022016-01-12 13:42:07 -050014206DEFUN (show_bgp_view_ipv4_rsclient,
14207 show_bgp_view_ipv4_rsclient_cmd,
14208 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014209 SHOW_STR
14210 BGP_STR
14211 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014212 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014213 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014214 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014215 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014216{
Lou Berger651b4022016-01-12 13:42:07 -050014217 struct bgp_table *table;
14218 struct peer *peer;
14219
14220 if (argc == 2)
14221 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14222 else
14223 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14224
14225 if (! peer)
14226 return CMD_WARNING;
14227
14228 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14229 {
14230 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14231 VTY_NEWLINE);
14232 return CMD_WARNING;
14233 }
14234
14235 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14236 PEER_FLAG_RSERVER_CLIENT))
14237 {
14238 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14239 VTY_NEWLINE);
14240 return CMD_WARNING;
14241 }
14242
14243 table = peer->rib[AFI_IP][SAFI_UNICAST];
14244
14245 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14246}
14247DEFUN (show_bgp_view_ipv6_rsclient,
14248 show_bgp_view_ipv6_rsclient_cmd,
14249 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
14250 SHOW_STR
14251 BGP_STR
14252 "BGP view\n"
14253 "BGP view name\n"
14254 "Address Family\n"
14255 "Information about Route Server Client\n"
14256 NEIGHBOR_ADDR_STR2)
14257{
14258 struct bgp_table *table;
14259 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000014260
14261 if (argc == 2)
14262 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14263 else
14264 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14265
14266 if (! peer)
14267 return CMD_WARNING;
14268
14269 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14270 {
14271 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14272 VTY_NEWLINE);
14273 return CMD_WARNING;
14274 }
14275
14276 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14277 PEER_FLAG_RSERVER_CLIENT))
14278 {
14279 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14280 VTY_NEWLINE);
14281 return CMD_WARNING;
14282 }
14283
14284 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14285
ajs5a646652004-11-05 01:25:55 +000014286 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000014287}
14288
Lou Berger651b4022016-01-12 13:42:07 -050014289ALIAS (show_bgp_view_ipv4_rsclient,
14290 show_bgp_ipv4_rsclient_cmd,
14291 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014292 SHOW_STR
14293 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014294 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014295 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014296 NEIGHBOR_ADDR_STR2)
14297
Lou Berger651b4022016-01-12 13:42:07 -050014298ALIAS (show_bgp_view_ipv6_rsclient,
14299 show_bgp_ipv6_rsclient_cmd,
14300 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
14301 SHOW_STR
14302 BGP_STR
14303 "Address Family\n"
14304 "Information about Route Server Client\n"
14305 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014306
Michael Lambert95cbbd22010-07-23 14:43:04 -040014307DEFUN (show_bgp_view_ipv6_safi_rsclient,
14308 show_bgp_view_ipv6_safi_rsclient_cmd,
14309 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14310 SHOW_STR
14311 BGP_STR
14312 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014313 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014314 "Address family\n"
14315 "Address Family modifier\n"
14316 "Address Family modifier\n"
14317 "Information about Route Server Client\n"
14318 NEIGHBOR_ADDR_STR)
14319{
14320 struct bgp_table *table;
14321 struct peer *peer;
14322 safi_t safi;
14323
14324 if (argc == 3) {
14325 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14326 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14327 } else {
14328 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14329 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14330 }
14331
14332 if (! peer)
14333 return CMD_WARNING;
14334
14335 if (! peer->afc[AFI_IP6][safi])
14336 {
14337 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14338 VTY_NEWLINE);
14339 return CMD_WARNING;
14340 }
14341
14342 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14343 PEER_FLAG_RSERVER_CLIENT))
14344 {
14345 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14346 VTY_NEWLINE);
14347 return CMD_WARNING;
14348 }
14349
14350 table = peer->rib[AFI_IP6][safi];
14351
14352 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14353}
14354
14355ALIAS (show_bgp_view_ipv6_safi_rsclient,
14356 show_bgp_ipv6_safi_rsclient_cmd,
14357 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14358 SHOW_STR
14359 BGP_STR
14360 "Address family\n"
14361 "Address Family modifier\n"
14362 "Address Family modifier\n"
14363 "Information about Route Server Client\n"
14364 NEIGHBOR_ADDR_STR)
14365
paulfee0f4c2004-09-13 05:12:46 +000014366DEFUN (show_bgp_view_rsclient_route,
14367 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014368 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14369 SHOW_STR
14370 BGP_STR
14371 "BGP view\n"
14372 "View name\n"
14373 "Information about Route Server Client\n"
14374 NEIGHBOR_ADDR_STR
14375 "Network in the BGP routing table to display\n")
14376{
14377 struct bgp *bgp;
14378 struct peer *peer;
14379
14380 /* BGP structure lookup. */
14381 if (argc == 3)
14382 {
14383 bgp = bgp_lookup_by_name (argv[0]);
14384 if (bgp == NULL)
14385 {
14386 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14387 return CMD_WARNING;
14388 }
14389 }
14390 else
14391 {
14392 bgp = bgp_get_default ();
14393 if (bgp == NULL)
14394 {
14395 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14396 return CMD_WARNING;
14397 }
14398 }
14399
14400 if (argc == 3)
14401 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14402 else
14403 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14404
14405 if (! peer)
14406 return CMD_WARNING;
14407
14408 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14409 {
14410 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14411 VTY_NEWLINE);
14412 return CMD_WARNING;
14413 }
14414
14415 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14416 PEER_FLAG_RSERVER_CLIENT))
14417 {
14418 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14419 VTY_NEWLINE);
14420 return CMD_WARNING;
14421 }
14422
14423 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14424 (argc == 3) ? argv[2] : argv[1],
14425 AFI_IP6, SAFI_UNICAST, NULL, 0);
14426}
14427
14428DEFUN (show_bgp_view_ipv6_rsclient_route,
14429 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014430 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014431 SHOW_STR
14432 BGP_STR
14433 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050014434 "BGP view name\n"
14435 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000014436 "Information about Route Server Client\n"
14437 NEIGHBOR_ADDR_STR
14438 "Network in the BGP routing table to display\n")
14439{
14440 struct bgp *bgp;
14441 struct peer *peer;
14442
14443 /* BGP structure lookup. */
14444 if (argc == 3)
14445 {
14446 bgp = bgp_lookup_by_name (argv[0]);
14447 if (bgp == NULL)
14448 {
14449 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14450 return CMD_WARNING;
14451 }
14452 }
14453 else
14454 {
14455 bgp = bgp_get_default ();
14456 if (bgp == NULL)
14457 {
14458 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14459 return CMD_WARNING;
14460 }
14461 }
14462
14463 if (argc == 3)
14464 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14465 else
14466 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14467
14468 if (! peer)
14469 return CMD_WARNING;
14470
14471 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14472 {
14473 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14474 VTY_NEWLINE);
14475 return CMD_WARNING;
14476 }
14477
14478 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14479 PEER_FLAG_RSERVER_CLIENT))
14480 {
14481 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14482 VTY_NEWLINE);
14483 return CMD_WARNING;
14484 }
14485
14486 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14487 (argc == 3) ? argv[2] : argv[1],
14488 AFI_IP6, SAFI_UNICAST, NULL, 0);
14489}
14490
Lou Bergerf9b6c392016-01-12 13:42:09 -050014491ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000014492 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014493 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14494 SHOW_STR
14495 BGP_STR
14496 "Information about Route Server Client\n"
14497 NEIGHBOR_ADDR_STR
14498 "Network in the BGP routing table to display\n")
14499
14500ALIAS (show_bgp_view_ipv6_rsclient_route,
14501 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014502 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014503 SHOW_STR
14504 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014505 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014506 "Information about Route Server Client\n"
14507 NEIGHBOR_ADDR_STR
14508 "Network in the BGP routing table to display\n")
14509
Michael Lambert95cbbd22010-07-23 14:43:04 -040014510DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
14511 show_bgp_view_ipv6_safi_rsclient_route_cmd,
14512 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14513 SHOW_STR
14514 BGP_STR
14515 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014516 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014517 "Address family\n"
14518 "Address Family modifier\n"
14519 "Address Family modifier\n"
14520 "Information about Route Server Client\n"
14521 NEIGHBOR_ADDR_STR
14522 "Network in the BGP routing table to display\n")
14523{
14524 struct bgp *bgp;
14525 struct peer *peer;
14526 safi_t safi;
14527
14528 /* BGP structure lookup. */
14529 if (argc == 4)
14530 {
14531 bgp = bgp_lookup_by_name (argv[0]);
14532 if (bgp == NULL)
14533 {
14534 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14535 return CMD_WARNING;
14536 }
14537 }
14538 else
14539 {
14540 bgp = bgp_get_default ();
14541 if (bgp == NULL)
14542 {
14543 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14544 return CMD_WARNING;
14545 }
14546 }
14547
14548 if (argc == 4) {
14549 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14550 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14551 } else {
14552 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14553 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14554 }
14555
14556 if (! peer)
14557 return CMD_WARNING;
14558
14559 if (! peer->afc[AFI_IP6][safi])
14560 {
14561 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14562 VTY_NEWLINE);
14563 return CMD_WARNING;
14564}
14565
14566 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14567 PEER_FLAG_RSERVER_CLIENT))
14568 {
14569 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14570 VTY_NEWLINE);
14571 return CMD_WARNING;
14572 }
14573
14574 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14575 (argc == 4) ? argv[3] : argv[2],
14576 AFI_IP6, safi, NULL, 0);
14577}
14578
14579ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
14580 show_bgp_ipv6_safi_rsclient_route_cmd,
14581 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14582 SHOW_STR
14583 BGP_STR
14584 "Address family\n"
14585 "Address Family modifier\n"
14586 "Address Family modifier\n"
14587 "Information about Route Server Client\n"
14588 NEIGHBOR_ADDR_STR
14589 "Network in the BGP routing table to display\n")
14590
Lou Berger651b4022016-01-12 13:42:07 -050014591
paulfee0f4c2004-09-13 05:12:46 +000014592DEFUN (show_bgp_view_rsclient_prefix,
14593 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014594 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14595 SHOW_STR
14596 BGP_STR
14597 "BGP view\n"
14598 "View name\n"
14599 "Information about Route Server Client\n"
14600 NEIGHBOR_ADDR_STR
14601 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14602{
14603 struct bgp *bgp;
14604 struct peer *peer;
14605
14606 /* BGP structure lookup. */
14607 if (argc == 3)
14608 {
14609 bgp = bgp_lookup_by_name (argv[0]);
14610 if (bgp == NULL)
14611 {
14612 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14613 return CMD_WARNING;
14614 }
14615 }
14616 else
14617 {
14618 bgp = bgp_get_default ();
14619 if (bgp == NULL)
14620 {
14621 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14622 return CMD_WARNING;
14623 }
14624 }
14625
14626 if (argc == 3)
14627 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14628 else
14629 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14630
14631 if (! peer)
14632 return CMD_WARNING;
14633
14634 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14635 {
14636 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14637 VTY_NEWLINE);
14638 return CMD_WARNING;
14639 }
14640
14641 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14642 PEER_FLAG_RSERVER_CLIENT))
14643 {
14644 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14645 VTY_NEWLINE);
14646 return CMD_WARNING;
14647 }
14648
14649 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14650 (argc == 3) ? argv[2] : argv[1],
14651 AFI_IP6, SAFI_UNICAST, NULL, 1);
14652}
14653
14654DEFUN (show_bgp_view_ipv6_rsclient_prefix,
14655 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014656 "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 +000014657 SHOW_STR
14658 BGP_STR
14659 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014660 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014661 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014662 "Information about Route Server Client\n"
14663 NEIGHBOR_ADDR_STR
14664 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14665{
14666 struct bgp *bgp;
14667 struct peer *peer;
14668
14669 /* BGP structure lookup. */
14670 if (argc == 3)
14671 {
14672 bgp = bgp_lookup_by_name (argv[0]);
14673 if (bgp == NULL)
14674 {
14675 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14676 return CMD_WARNING;
14677 }
14678 }
14679 else
14680 {
14681 bgp = bgp_get_default ();
14682 if (bgp == NULL)
14683 {
14684 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14685 return CMD_WARNING;
14686 }
14687 }
14688
14689 if (argc == 3)
14690 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14691 else
14692 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14693
14694 if (! peer)
14695 return CMD_WARNING;
14696
14697 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14698 {
14699 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14700 VTY_NEWLINE);
14701 return CMD_WARNING;
14702 }
14703
14704 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14705 PEER_FLAG_RSERVER_CLIENT))
14706 {
14707 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14708 VTY_NEWLINE);
14709 return CMD_WARNING;
14710 }
14711
14712 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14713 (argc == 3) ? argv[2] : argv[1],
14714 AFI_IP6, SAFI_UNICAST, NULL, 1);
14715}
14716
Lou Bergerf9b6c392016-01-12 13:42:09 -050014717ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000014718 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014719 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14720 SHOW_STR
14721 BGP_STR
14722 "Information about Route Server Client\n"
14723 NEIGHBOR_ADDR_STR
14724 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14725
14726ALIAS (show_bgp_view_ipv6_rsclient_prefix,
14727 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014728 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000014729 SHOW_STR
14730 BGP_STR
14731 "Information about Route Server Client\n"
14732 NEIGHBOR_ADDR_STR
14733 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14734
Michael Lambert95cbbd22010-07-23 14:43:04 -040014735DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
14736 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
14737 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14738 SHOW_STR
14739 BGP_STR
14740 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014741 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014742 "Address family\n"
14743 "Address Family modifier\n"
14744 "Address Family modifier\n"
14745 "Information about Route Server Client\n"
14746 NEIGHBOR_ADDR_STR
14747 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14748{
14749 struct bgp *bgp;
14750 struct peer *peer;
14751 safi_t safi;
14752
14753 /* BGP structure lookup. */
14754 if (argc == 4)
14755 {
14756 bgp = bgp_lookup_by_name (argv[0]);
14757 if (bgp == NULL)
14758 {
14759 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14760 return CMD_WARNING;
14761 }
14762 }
14763 else
14764 {
14765 bgp = bgp_get_default ();
14766 if (bgp == NULL)
14767 {
14768 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14769 return CMD_WARNING;
14770 }
14771 }
14772
14773 if (argc == 4) {
14774 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14775 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14776 } else {
14777 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14778 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14779 }
14780
14781 if (! peer)
14782 return CMD_WARNING;
14783
14784 if (! peer->afc[AFI_IP6][safi])
14785 {
14786 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14787 VTY_NEWLINE);
14788 return CMD_WARNING;
14789}
14790
14791 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14792 PEER_FLAG_RSERVER_CLIENT))
14793{
14794 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14795 VTY_NEWLINE);
14796 return CMD_WARNING;
14797 }
14798
14799 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14800 (argc == 4) ? argv[3] : argv[2],
14801 AFI_IP6, safi, NULL, 1);
14802}
14803
14804ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
14805 show_bgp_ipv6_safi_rsclient_prefix_cmd,
14806 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14807 SHOW_STR
14808 BGP_STR
14809 "Address family\n"
14810 "Address Family modifier\n"
14811 "Address Family modifier\n"
14812 "Information about Route Server Client\n"
14813 NEIGHBOR_ADDR_STR
14814 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14815
paul718e3742002-12-13 20:15:29 +000014816struct bgp_table *bgp_distance_table;
14817
14818struct bgp_distance
14819{
14820 /* Distance value for the IP source prefix. */
14821 u_char distance;
14822
14823 /* Name of the access-list to be matched. */
14824 char *access_list;
14825};
14826
paul94f2b392005-06-28 12:44:16 +000014827static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080014828bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000014829{
Stephen Hemminger393deb92008-08-18 14:13:29 -070014830 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000014831}
14832
paul94f2b392005-06-28 12:44:16 +000014833static void
paul718e3742002-12-13 20:15:29 +000014834bgp_distance_free (struct bgp_distance *bdistance)
14835{
14836 XFREE (MTYPE_BGP_DISTANCE, bdistance);
14837}
14838
paul94f2b392005-06-28 12:44:16 +000014839static int
paulfd79ac92004-10-13 05:06:08 +000014840bgp_distance_set (struct vty *vty, const char *distance_str,
14841 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014842{
14843 int ret;
14844 struct prefix_ipv4 p;
14845 u_char distance;
14846 struct bgp_node *rn;
14847 struct bgp_distance *bdistance;
14848
14849 ret = str2prefix_ipv4 (ip_str, &p);
14850 if (ret == 0)
14851 {
14852 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14853 return CMD_WARNING;
14854 }
14855
14856 distance = atoi (distance_str);
14857
14858 /* Get BGP distance node. */
14859 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
14860 if (rn->info)
14861 {
14862 bdistance = rn->info;
14863 bgp_unlock_node (rn);
14864 }
14865 else
14866 {
14867 bdistance = bgp_distance_new ();
14868 rn->info = bdistance;
14869 }
14870
14871 /* Set distance value. */
14872 bdistance->distance = distance;
14873
14874 /* Reset access-list configuration. */
14875 if (bdistance->access_list)
14876 {
14877 free (bdistance->access_list);
14878 bdistance->access_list = NULL;
14879 }
14880 if (access_list_str)
14881 bdistance->access_list = strdup (access_list_str);
14882
14883 return CMD_SUCCESS;
14884}
14885
paul94f2b392005-06-28 12:44:16 +000014886static int
paulfd79ac92004-10-13 05:06:08 +000014887bgp_distance_unset (struct vty *vty, const char *distance_str,
14888 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014889{
14890 int ret;
14891 struct prefix_ipv4 p;
14892 u_char distance;
14893 struct bgp_node *rn;
14894 struct bgp_distance *bdistance;
14895
14896 ret = str2prefix_ipv4 (ip_str, &p);
14897 if (ret == 0)
14898 {
14899 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14900 return CMD_WARNING;
14901 }
14902
14903 distance = atoi (distance_str);
14904
14905 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
14906 if (! rn)
14907 {
14908 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
14909 return CMD_WARNING;
14910 }
14911
14912 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010014913
14914 if (bdistance->distance != distance)
14915 {
14916 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
14917 return CMD_WARNING;
14918 }
14919
paul718e3742002-12-13 20:15:29 +000014920 if (bdistance->access_list)
14921 free (bdistance->access_list);
14922 bgp_distance_free (bdistance);
14923
14924 rn->info = NULL;
14925 bgp_unlock_node (rn);
14926 bgp_unlock_node (rn);
14927
14928 return CMD_SUCCESS;
14929}
14930
paul718e3742002-12-13 20:15:29 +000014931/* Apply BGP information to distance method. */
14932u_char
14933bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
14934{
14935 struct bgp_node *rn;
14936 struct prefix_ipv4 q;
14937 struct peer *peer;
14938 struct bgp_distance *bdistance;
14939 struct access_list *alist;
14940 struct bgp_static *bgp_static;
14941
14942 if (! bgp)
14943 return 0;
14944
14945 if (p->family != AF_INET)
14946 return 0;
14947
14948 peer = rinfo->peer;
14949
14950 if (peer->su.sa.sa_family != AF_INET)
14951 return 0;
14952
14953 memset (&q, 0, sizeof (struct prefix_ipv4));
14954 q.family = AF_INET;
14955 q.prefix = peer->su.sin.sin_addr;
14956 q.prefixlen = IPV4_MAX_BITLEN;
14957
14958 /* Check source address. */
14959 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
14960 if (rn)
14961 {
14962 bdistance = rn->info;
14963 bgp_unlock_node (rn);
14964
14965 if (bdistance->access_list)
14966 {
14967 alist = access_list_lookup (AFI_IP, bdistance->access_list);
14968 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
14969 return bdistance->distance;
14970 }
14971 else
14972 return bdistance->distance;
14973 }
14974
14975 /* Backdoor check. */
14976 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
14977 if (rn)
14978 {
14979 bgp_static = rn->info;
14980 bgp_unlock_node (rn);
14981
14982 if (bgp_static->backdoor)
14983 {
14984 if (bgp->distance_local)
14985 return bgp->distance_local;
14986 else
14987 return ZEBRA_IBGP_DISTANCE_DEFAULT;
14988 }
14989 }
14990
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000014991 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000014992 {
14993 if (bgp->distance_ebgp)
14994 return bgp->distance_ebgp;
14995 return ZEBRA_EBGP_DISTANCE_DEFAULT;
14996 }
14997 else
14998 {
14999 if (bgp->distance_ibgp)
15000 return bgp->distance_ibgp;
15001 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15002 }
15003}
15004
15005DEFUN (bgp_distance,
15006 bgp_distance_cmd,
15007 "distance bgp <1-255> <1-255> <1-255>",
15008 "Define an administrative distance\n"
15009 "BGP distance\n"
15010 "Distance for routes external to the AS\n"
15011 "Distance for routes internal to the AS\n"
15012 "Distance for local routes\n")
15013{
15014 struct bgp *bgp;
15015
15016 bgp = vty->index;
15017
15018 bgp->distance_ebgp = atoi (argv[0]);
15019 bgp->distance_ibgp = atoi (argv[1]);
15020 bgp->distance_local = atoi (argv[2]);
15021 return CMD_SUCCESS;
15022}
15023
15024DEFUN (no_bgp_distance,
15025 no_bgp_distance_cmd,
15026 "no distance bgp <1-255> <1-255> <1-255>",
15027 NO_STR
15028 "Define an administrative distance\n"
15029 "BGP distance\n"
15030 "Distance for routes external to the AS\n"
15031 "Distance for routes internal to the AS\n"
15032 "Distance for local routes\n")
15033{
15034 struct bgp *bgp;
15035
15036 bgp = vty->index;
15037
15038 bgp->distance_ebgp= 0;
15039 bgp->distance_ibgp = 0;
15040 bgp->distance_local = 0;
15041 return CMD_SUCCESS;
15042}
15043
15044ALIAS (no_bgp_distance,
15045 no_bgp_distance2_cmd,
15046 "no distance bgp",
15047 NO_STR
15048 "Define an administrative distance\n"
15049 "BGP distance\n")
15050
15051DEFUN (bgp_distance_source,
15052 bgp_distance_source_cmd,
15053 "distance <1-255> A.B.C.D/M",
15054 "Define an administrative distance\n"
15055 "Administrative distance\n"
15056 "IP source prefix\n")
15057{
15058 bgp_distance_set (vty, argv[0], argv[1], NULL);
15059 return CMD_SUCCESS;
15060}
15061
15062DEFUN (no_bgp_distance_source,
15063 no_bgp_distance_source_cmd,
15064 "no distance <1-255> A.B.C.D/M",
15065 NO_STR
15066 "Define an administrative distance\n"
15067 "Administrative distance\n"
15068 "IP source prefix\n")
15069{
15070 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15071 return CMD_SUCCESS;
15072}
15073
15074DEFUN (bgp_distance_source_access_list,
15075 bgp_distance_source_access_list_cmd,
15076 "distance <1-255> A.B.C.D/M WORD",
15077 "Define an administrative distance\n"
15078 "Administrative distance\n"
15079 "IP source prefix\n"
15080 "Access list name\n")
15081{
15082 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15083 return CMD_SUCCESS;
15084}
15085
15086DEFUN (no_bgp_distance_source_access_list,
15087 no_bgp_distance_source_access_list_cmd,
15088 "no distance <1-255> A.B.C.D/M WORD",
15089 NO_STR
15090 "Define an administrative distance\n"
15091 "Administrative distance\n"
15092 "IP source prefix\n"
15093 "Access list name\n")
15094{
15095 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15096 return CMD_SUCCESS;
15097}
David Lamparter6b0655a2014-06-04 06:53:35 +020015098
paul718e3742002-12-13 20:15:29 +000015099DEFUN (bgp_damp_set,
15100 bgp_damp_set_cmd,
15101 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15102 "BGP Specific commands\n"
15103 "Enable route-flap dampening\n"
15104 "Half-life time for the penalty\n"
15105 "Value to start reusing a route\n"
15106 "Value to start suppressing a route\n"
15107 "Maximum duration to suppress a stable route\n")
15108{
15109 struct bgp *bgp;
15110 int half = DEFAULT_HALF_LIFE * 60;
15111 int reuse = DEFAULT_REUSE;
15112 int suppress = DEFAULT_SUPPRESS;
15113 int max = 4 * half;
15114
15115 if (argc == 4)
15116 {
15117 half = atoi (argv[0]) * 60;
15118 reuse = atoi (argv[1]);
15119 suppress = atoi (argv[2]);
15120 max = atoi (argv[3]) * 60;
15121 }
15122 else if (argc == 1)
15123 {
15124 half = atoi (argv[0]) * 60;
15125 max = 4 * half;
15126 }
15127
15128 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000015129
15130 if (suppress < reuse)
15131 {
15132 vty_out (vty, "Suppress value cannot be less than reuse value %s",
15133 VTY_NEWLINE);
15134 return 0;
15135 }
15136
paul718e3742002-12-13 20:15:29 +000015137 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
15138 half, reuse, suppress, max);
15139}
15140
15141ALIAS (bgp_damp_set,
15142 bgp_damp_set2_cmd,
15143 "bgp dampening <1-45>",
15144 "BGP Specific commands\n"
15145 "Enable route-flap dampening\n"
15146 "Half-life time for the penalty\n")
15147
15148ALIAS (bgp_damp_set,
15149 bgp_damp_set3_cmd,
15150 "bgp dampening",
15151 "BGP Specific commands\n"
15152 "Enable route-flap dampening\n")
15153
15154DEFUN (bgp_damp_unset,
15155 bgp_damp_unset_cmd,
15156 "no bgp dampening",
15157 NO_STR
15158 "BGP Specific commands\n"
15159 "Enable route-flap dampening\n")
15160{
15161 struct bgp *bgp;
15162
15163 bgp = vty->index;
15164 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
15165}
15166
15167ALIAS (bgp_damp_unset,
15168 bgp_damp_unset2_cmd,
15169 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15170 NO_STR
15171 "BGP Specific commands\n"
15172 "Enable route-flap dampening\n"
15173 "Half-life time for the penalty\n"
15174 "Value to start reusing a route\n"
15175 "Value to start suppressing a route\n"
15176 "Maximum duration to suppress a stable route\n")
15177
Lou Bergerf9b6c392016-01-12 13:42:09 -050015178DEFUN (show_ip_bgp_dampened_paths,
15179 show_ip_bgp_dampened_paths_cmd,
15180 "show ip bgp dampened-paths",
15181 SHOW_STR
15182 IP_STR
15183 BGP_STR
15184 "Display paths suppressed due to dampening\n")
15185{
15186 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
15187 NULL);
15188}
15189
15190ALIAS (show_ip_bgp_dampened_paths,
15191 show_ip_bgp_damp_dampened_paths_cmd,
15192 "show ip bgp dampening dampened-paths",
15193 SHOW_STR
15194 IP_STR
15195 BGP_STR
15196 "Display detailed information about dampening\n"
15197 "Display paths suppressed due to dampening\n")
15198
15199DEFUN (show_ip_bgp_flap_statistics,
15200 show_ip_bgp_flap_statistics_cmd,
15201 "show ip bgp flap-statistics",
15202 SHOW_STR
15203 IP_STR
15204 BGP_STR
15205 "Display flap statistics of routes\n")
15206{
15207 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
15208 bgp_show_type_flap_statistics, NULL);
15209}
15210
15211ALIAS (show_ip_bgp_flap_statistics,
15212 show_ip_bgp_damp_flap_statistics_cmd,
15213 "show ip bgp dampening flap-statistics",
15214 SHOW_STR
15215 IP_STR
15216 BGP_STR
15217 "Display detailed information about dampening\n"
15218 "Display flap statistics of routes\n")
15219
Lou Berger651b4022016-01-12 13:42:07 -050015220DEFUN (show_bgp_ipv4_safi_dampened_paths,
15221 show_bgp_ipv4_safi_dampened_paths_cmd,
15222 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015223 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015224 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015225 IP_STR
15226 "Address Family modifier\n"
15227 "Address Family modifier\n"
15228 "Address Family modifier\n"
15229 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015230 "Display paths suppressed due to dampening\n")
15231{
Lou Berger651b4022016-01-12 13:42:07 -050015232 safi_t safi;
paul718e3742002-12-13 20:15:29 +000015233
Lou Berger651b4022016-01-12 13:42:07 -050015234 if (bgp_parse_safi(argv[0], &safi)) {
15235 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15236 return CMD_WARNING;
15237 }
15238
15239 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
15240}
15241ALIAS (show_bgp_ipv4_safi_dampened_paths,
15242 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
15243 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053015244 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015245 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015246 IP_STR
15247 "Address Family modifier\n"
15248 "Address Family modifier\n"
15249 "Address Family modifier\n"
15250 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015251 "Display detailed information about dampening\n"
15252 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050015253
Lou Berger651b4022016-01-12 13:42:07 -050015254DEFUN (show_bgp_ipv6_safi_dampened_paths,
15255 show_bgp_ipv6_safi_dampened_paths_cmd,
15256 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015257 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015258 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015259 IPV6_STR
15260 "Address Family modifier\n"
15261 "Address Family modifier\n"
15262 "Address Family modifier\n"
15263 "Address Family modifier\n"
15264 "Display paths suppressed due to dampening\n")
15265{
15266 safi_t safi;
15267
15268 if (bgp_parse_safi(argv[0], &safi)) {
15269 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15270 return CMD_WARNING;
15271 }
15272
15273 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
15274}
15275ALIAS (show_bgp_ipv6_safi_dampened_paths,
15276 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
15277 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
15278 SHOW_STR
15279 BGP_STR
15280 IPV6_STR
15281 "Address Family modifier\n"
15282 "Address Family modifier\n"
15283 "Address Family modifier\n"
15284 "Address Family modifier\n"
15285 "Display detailed information about dampening\n"
15286 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050015287
15288DEFUN (show_bgp_ipv4_safi_flap_statistics,
15289 show_bgp_ipv4_safi_flap_statistics_cmd,
15290 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
15291 SHOW_STR
15292 BGP_STR
15293 "Address Family\n"
15294 "Address Family modifier\n"
15295 "Address Family modifier\n"
15296 "Address Family modifier\n"
15297 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015298 "Display flap statistics of routes\n")
15299{
Lou Berger651b4022016-01-12 13:42:07 -050015300 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020015301
Lou Berger651b4022016-01-12 13:42:07 -050015302 if (bgp_parse_safi(argv[0], &safi)) {
15303 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15304 return CMD_WARNING;
15305 }
15306
15307 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
15308}
15309ALIAS (show_bgp_ipv4_safi_flap_statistics,
15310 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
15311 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053015312 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015313 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015314 "Address Family\n"
15315 "Address Family modifier\n"
15316 "Address Family modifier\n"
15317 "Address Family modifier\n"
15318 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015319 "Display detailed information about dampening\n"
15320 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050015321
Lou Berger651b4022016-01-12 13:42:07 -050015322DEFUN (show_bgp_ipv6_safi_flap_statistics,
15323 show_bgp_ipv6_safi_flap_statistics_cmd,
15324 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
15325 SHOW_STR
15326 BGP_STR
15327 "Address Family\n"
15328 "Address Family modifier\n"
15329 "Address Family modifier\n"
15330 "Address Family modifier\n"
15331 "Address Family modifier\n"
15332 "Display flap statistics of routes\n")
15333{
15334 safi_t safi;
15335
15336 if (bgp_parse_safi(argv[0], &safi)) {
15337 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15338 return CMD_WARNING;
15339 }
15340
15341 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
15342}
15343ALIAS (show_bgp_ipv6_safi_flap_statistics,
15344 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
15345 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
15346 SHOW_STR
15347 BGP_STR
15348 "Address Family\n"
15349 "Address Family modifier\n"
15350 "Address Family modifier\n"
15351 "Address Family modifier\n"
15352 "Address Family modifier\n"
15353 "Display detailed information about dampening\n"
15354 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053015355
paul718e3742002-12-13 20:15:29 +000015356/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000015357static int
paulfd79ac92004-10-13 05:06:08 +000015358bgp_clear_damp_route (struct vty *vty, const char *view_name,
15359 const char *ip_str, afi_t afi, safi_t safi,
15360 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000015361{
15362 int ret;
15363 struct prefix match;
15364 struct bgp_node *rn;
15365 struct bgp_node *rm;
15366 struct bgp_info *ri;
15367 struct bgp_info *ri_temp;
15368 struct bgp *bgp;
15369 struct bgp_table *table;
15370
15371 /* BGP structure lookup. */
15372 if (view_name)
15373 {
15374 bgp = bgp_lookup_by_name (view_name);
15375 if (bgp == NULL)
15376 {
15377 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
15378 return CMD_WARNING;
15379 }
15380 }
15381 else
15382 {
15383 bgp = bgp_get_default ();
15384 if (bgp == NULL)
15385 {
15386 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
15387 return CMD_WARNING;
15388 }
15389 }
15390
15391 /* Check IP address argument. */
15392 ret = str2prefix (ip_str, &match);
15393 if (! ret)
15394 {
15395 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
15396 return CMD_WARNING;
15397 }
15398
15399 match.family = afi2family (afi);
15400
Lou Berger298cc2f2016-01-12 13:42:02 -050015401 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000015402 {
Lou Berger298cc2f2016-01-12 13:42:02 -050015403 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000015404 {
15405 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
15406 continue;
15407
15408 if ((table = rn->info) != NULL)
15409 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015410 {
15411 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
15412 {
15413 ri = rm->info;
15414 while (ri)
15415 {
15416 if (ri->extra && ri->extra->damp_info)
15417 {
15418 ri_temp = ri->next;
15419 bgp_damp_info_free (ri->extra->damp_info, 1);
15420 ri = ri_temp;
15421 }
15422 else
15423 ri = ri->next;
15424 }
15425 }
15426
15427 bgp_unlock_node (rm);
15428 }
paul718e3742002-12-13 20:15:29 +000015429 }
15430 }
15431 else
15432 {
15433 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015434 {
15435 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
15436 {
15437 ri = rn->info;
15438 while (ri)
15439 {
15440 if (ri->extra && ri->extra->damp_info)
15441 {
15442 ri_temp = ri->next;
15443 bgp_damp_info_free (ri->extra->damp_info, 1);
15444 ri = ri_temp;
15445 }
15446 else
15447 ri = ri->next;
15448 }
15449 }
15450
15451 bgp_unlock_node (rn);
15452 }
paul718e3742002-12-13 20:15:29 +000015453 }
15454
15455 return CMD_SUCCESS;
15456}
15457
15458DEFUN (clear_ip_bgp_dampening,
15459 clear_ip_bgp_dampening_cmd,
15460 "clear ip bgp dampening",
15461 CLEAR_STR
15462 IP_STR
15463 BGP_STR
15464 "Clear route flap dampening information\n")
15465{
15466 bgp_damp_info_clean ();
15467 return CMD_SUCCESS;
15468}
15469
15470DEFUN (clear_ip_bgp_dampening_prefix,
15471 clear_ip_bgp_dampening_prefix_cmd,
15472 "clear ip bgp dampening A.B.C.D/M",
15473 CLEAR_STR
15474 IP_STR
15475 BGP_STR
15476 "Clear route flap dampening information\n"
15477 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15478{
15479 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15480 SAFI_UNICAST, NULL, 1);
15481}
15482
15483DEFUN (clear_ip_bgp_dampening_address,
15484 clear_ip_bgp_dampening_address_cmd,
15485 "clear ip bgp dampening A.B.C.D",
15486 CLEAR_STR
15487 IP_STR
15488 BGP_STR
15489 "Clear route flap dampening information\n"
15490 "Network to clear damping information\n")
15491{
15492 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15493 SAFI_UNICAST, NULL, 0);
15494}
15495
15496DEFUN (clear_ip_bgp_dampening_address_mask,
15497 clear_ip_bgp_dampening_address_mask_cmd,
15498 "clear ip bgp dampening A.B.C.D A.B.C.D",
15499 CLEAR_STR
15500 IP_STR
15501 BGP_STR
15502 "Clear route flap dampening information\n"
15503 "Network to clear damping information\n"
15504 "Network mask\n")
15505{
15506 int ret;
15507 char prefix_str[BUFSIZ];
15508
15509 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
15510 if (! ret)
15511 {
15512 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
15513 return CMD_WARNING;
15514 }
15515
15516 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
15517 SAFI_UNICAST, NULL, 0);
15518}
David Lamparter6b0655a2014-06-04 06:53:35 +020015519
Lou Berger298cc2f2016-01-12 13:42:02 -050015520/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000015521static int
paul718e3742002-12-13 20:15:29 +000015522bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
15523 afi_t afi, safi_t safi, int *write)
15524{
15525 struct bgp_node *prn;
15526 struct bgp_node *rn;
15527 struct bgp_table *table;
15528 struct prefix *p;
15529 struct prefix_rd *prd;
15530 struct bgp_static *bgp_static;
15531 u_int32_t label;
15532 char buf[SU_ADDRSTRLEN];
15533 char rdbuf[RD_ADDRSTRLEN];
15534
15535 /* Network configuration. */
15536 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
15537 if ((table = prn->info) != NULL)
15538 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
15539 if ((bgp_static = rn->info) != NULL)
15540 {
15541 p = &rn->p;
15542 prd = (struct prefix_rd *) &prn->p;
15543
15544 /* "address-family" display. */
15545 bgp_config_write_family_header (vty, afi, safi, write);
15546
15547 /* "network" configuration display. */
15548 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
15549 label = decode_label (bgp_static->tag);
15550
15551 vty_out (vty, " network %s/%d rd %s tag %d",
15552 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15553 p->prefixlen,
15554 rdbuf, label);
15555 vty_out (vty, "%s", VTY_NEWLINE);
15556 }
15557 return 0;
15558}
15559
15560/* Configuration of static route announcement and aggregate
15561 information. */
15562int
15563bgp_config_write_network (struct vty *vty, struct bgp *bgp,
15564 afi_t afi, safi_t safi, int *write)
15565{
15566 struct bgp_node *rn;
15567 struct prefix *p;
15568 struct bgp_static *bgp_static;
15569 struct bgp_aggregate *bgp_aggregate;
15570 char buf[SU_ADDRSTRLEN];
15571
Lou Berger298cc2f2016-01-12 13:42:02 -050015572 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000015573 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
15574
15575 /* Network configuration. */
15576 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
15577 if ((bgp_static = rn->info) != NULL)
15578 {
15579 p = &rn->p;
15580
15581 /* "address-family" display. */
15582 bgp_config_write_family_header (vty, afi, safi, write);
15583
15584 /* "network" configuration display. */
15585 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15586 {
15587 u_int32_t destination;
15588 struct in_addr netmask;
15589
15590 destination = ntohl (p->u.prefix4.s_addr);
15591 masklen2ip (p->prefixlen, &netmask);
15592 vty_out (vty, " network %s",
15593 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
15594
15595 if ((IN_CLASSC (destination) && p->prefixlen == 24)
15596 || (IN_CLASSB (destination) && p->prefixlen == 16)
15597 || (IN_CLASSA (destination) && p->prefixlen == 8)
15598 || p->u.prefix4.s_addr == 0)
15599 {
15600 /* Natural mask is not display. */
15601 }
15602 else
15603 vty_out (vty, " mask %s", inet_ntoa (netmask));
15604 }
15605 else
15606 {
15607 vty_out (vty, " network %s/%d",
15608 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15609 p->prefixlen);
15610 }
15611
15612 if (bgp_static->rmap.name)
15613 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000015614 else
15615 {
15616 if (bgp_static->backdoor)
15617 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000015618 }
paul718e3742002-12-13 20:15:29 +000015619
15620 vty_out (vty, "%s", VTY_NEWLINE);
15621 }
15622
15623 /* Aggregate-address configuration. */
15624 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
15625 if ((bgp_aggregate = rn->info) != NULL)
15626 {
15627 p = &rn->p;
15628
15629 /* "address-family" display. */
15630 bgp_config_write_family_header (vty, afi, safi, write);
15631
15632 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15633 {
15634 struct in_addr netmask;
15635
15636 masklen2ip (p->prefixlen, &netmask);
15637 vty_out (vty, " aggregate-address %s %s",
15638 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15639 inet_ntoa (netmask));
15640 }
15641 else
15642 {
15643 vty_out (vty, " aggregate-address %s/%d",
15644 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15645 p->prefixlen);
15646 }
15647
15648 if (bgp_aggregate->as_set)
15649 vty_out (vty, " as-set");
15650
15651 if (bgp_aggregate->summary_only)
15652 vty_out (vty, " summary-only");
15653
15654 vty_out (vty, "%s", VTY_NEWLINE);
15655 }
15656
15657 return 0;
15658}
15659
15660int
15661bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
15662{
15663 struct bgp_node *rn;
15664 struct bgp_distance *bdistance;
15665
15666 /* Distance configuration. */
15667 if (bgp->distance_ebgp
15668 && bgp->distance_ibgp
15669 && bgp->distance_local
15670 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
15671 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
15672 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
15673 vty_out (vty, " distance bgp %d %d %d%s",
15674 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
15675 VTY_NEWLINE);
15676
15677 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
15678 if ((bdistance = rn->info) != NULL)
15679 {
15680 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
15681 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
15682 bdistance->access_list ? bdistance->access_list : "",
15683 VTY_NEWLINE);
15684 }
15685
15686 return 0;
15687}
15688
15689/* Allocate routing table structure and install commands. */
15690void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080015691bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000015692{
15693 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000015694 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000015695
15696 /* IPv4 BGP commands. */
15697 install_element (BGP_NODE, &bgp_network_cmd);
15698 install_element (BGP_NODE, &bgp_network_mask_cmd);
15699 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
15700 install_element (BGP_NODE, &bgp_network_route_map_cmd);
15701 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
15702 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
15703 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
15704 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
15705 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
15706 install_element (BGP_NODE, &no_bgp_network_cmd);
15707 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
15708 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
15709 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
15710 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
15711 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15712 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
15713 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
15714 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
15715
15716 install_element (BGP_NODE, &aggregate_address_cmd);
15717 install_element (BGP_NODE, &aggregate_address_mask_cmd);
15718 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
15719 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
15720 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
15721 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
15722 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
15723 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
15724 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
15725 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
15726 install_element (BGP_NODE, &no_aggregate_address_cmd);
15727 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
15728 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
15729 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
15730 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
15731 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
15732 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
15733 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
15734 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15735 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15736
15737 /* IPv4 unicast configuration. */
15738 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
15739 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
15740 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
15741 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
15742 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
15743 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015744 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000015745 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
15746 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
15747 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
15748 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
15749 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015750
paul718e3742002-12-13 20:15:29 +000015751 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
15752 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
15753 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
15754 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
15755 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
15756 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
15757 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
15758 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
15759 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
15760 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
15761 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
15762 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
15763 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
15764 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
15765 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
15766 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
15767 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
15768 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
15769 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15770 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15771
15772 /* IPv4 multicast configuration. */
15773 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
15774 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
15775 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
15776 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
15777 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
15778 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
15779 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
15780 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
15781 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
15782 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
15783 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
15784 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15785 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
15786 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
15787 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
15788 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
15789 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
15790 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
15791 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
15792 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
15793 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
15794 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
15795 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
15796 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
15797 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
15798 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
15799 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
15800 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
15801 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
15802 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
15803 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15804 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15805
Michael Lambert95cbbd22010-07-23 14:43:04 -040015806 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015807 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015808 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
15809 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
15810 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15811 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15812 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
15813 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
15814 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15815 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15816 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015817 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015818 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15819 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15820 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15821 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15822 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15823 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15824 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
15825 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
15826 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15827 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
15828 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
15829 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
15830 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
15831 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
15832 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
15833 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
15834 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
15835 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
15836 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
15837 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
15838 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
15839 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
15840 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
15841 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
15842 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
15843 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
15844 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
15845 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015846 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15847 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
15848 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
15849 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
15850 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015851 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
15852 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
15853 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
15854 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
15855 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
15856 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
15857 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
15858 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
15859 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
15860 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
15861 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
15862 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
15863 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
15864 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
15865 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
15866 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
15867 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
15868 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
15869 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015870 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015871 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
15872 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
15873 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
15874 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
15875 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
15876 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
15877 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
15878 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
15879 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
15880 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
15881 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
15882 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
15883 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
15884 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
15885 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
15886 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
15887 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
15888 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
15889 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
15890 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
15891 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
15892 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
15893 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
15894 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
15895 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
15896 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
15897 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
15898 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
15899 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
15900 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
15901 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
15902 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
15903 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
15904 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
15905 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
15906 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
15907 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
15908 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
15909 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
15910 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
15911 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
15912 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
15913 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
15914 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
15915 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015916 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015917 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015918 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015919 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015920 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015921 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010015922
15923 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040015924 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015925 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15926 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15927 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15928 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15929 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015930 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015931 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15932 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15933 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15934 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15935 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15936 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15937 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
15938 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15939 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
15940 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
15941 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
15942 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
15943 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
15944 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
15945 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
15946 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015947 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15948 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
15949 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
15950 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
15951 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015952 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
15953 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
15954 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
15955 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
15956 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
15957 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
15958 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
15959 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015960 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015961 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015962 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015963 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000015964
Michael Lambert95cbbd22010-07-23 14:43:04 -040015965 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015966 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015967 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd);
15968 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd);
15969 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15970 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15971 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_route_cmd);
15972 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_route_cmd);
15973 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15974 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15975 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015976 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015977 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15978 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15979 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15980 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15981 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15982 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15983 install_element (ENABLE_NODE, &show_bgp_afi_safi_view_cmd);
15984 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_route_cmd);
15985 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15986 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_regexp_cmd);
15987 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_regexp_cmd);
15988 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_list_cmd);
15989 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
15990 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
15991 install_element (ENABLE_NODE, &show_bgp_ipv4_filter_list_cmd);
15992 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
15993 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
15994 install_element (ENABLE_NODE, &show_bgp_ipv4_route_map_cmd);
15995 install_element (ENABLE_NODE, &show_bgp_ipv4_cidr_only_cmd);
15996 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
15997 install_element (ENABLE_NODE, &show_bgp_ipv4_community_cmd);
15998 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_cmd);
15999 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_cmd);
16000 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_cmd);
16001 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_cmd);
16002 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_cmd);
16003 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_cmd);
16004 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016005 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16006 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd);
16007 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd);
16008 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd);
16009 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016010 install_element (ENABLE_NODE, &show_bgp_ipv4_community_exact_cmd);
16011 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_exact_cmd);
16012 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_exact_cmd);
16013 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_exact_cmd);
16014 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16015 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16016 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16017 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16018 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_cmd);
16019 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16020 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16021 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16022 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16023 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16024 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16025 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16026 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16027 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16028 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016029 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016030 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16031 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16032 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16033 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16034 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16035 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16036 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16037 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16038 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16039 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16040 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16041 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16042 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16043 install_element (ENABLE_NODE, &show_bgp_ipv6_flap_address_cmd);
16044 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16045 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16046 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16047 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16048 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16049 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16050 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16051 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16052 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16053 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16054 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16055 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16056 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16057 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16058 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16059 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16060 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16061 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16062 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16063 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16064 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16065 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16066 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16067 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16068 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16069 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16070 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16071 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16072 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16073 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16074 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016075 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016076 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016077 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016078 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016079 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016080 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016081
16082 /* BGP dampening clear commands */
16083 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
16084 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
16085 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
16086 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
16087
Paul Jakmaff7924f2006-09-04 01:10:36 +000016088 /* prefix count */
Lou Berger651b4022016-01-12 13:42:07 -050016089 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_prefix_counts_cmd);
16090 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_prefix_counts_cmd);
Paul Jakmaff7924f2006-09-04 01:10:36 +000016091 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd);
16092
paul718e3742002-12-13 20:15:29 +000016093 /* New config IPv6 BGP commands. */
16094 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
16095 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
16096 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
16097 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
16098
16099 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
16100 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
16101 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
16102 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
16103
G.Balaji73bfe0b2011-09-23 22:36:20 +053016104 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
16105 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
16106
paul718e3742002-12-13 20:15:29 +000016107 /* Old config IPv6 BGP commands. */
16108 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
16109 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
16110
16111 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
16112 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
16113 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
16114 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
16115
Michael Lambert95cbbd22010-07-23 14:43:04 -040016116 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016117 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016118 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016119 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016120 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016121 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016122 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016123 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016124 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016125 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
16126 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
16127 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
16128 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
16129 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16130 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16131 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16132 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016133 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
paul718e3742002-12-13 20:15:29 +000016134 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016135 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016136 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016137 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016138 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016139 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016140 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016141 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
16142 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016143 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016144 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016145 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016146 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016147 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016148 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016149 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016150 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016151 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016152 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016153 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016154 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016155 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016156 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016157 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16158 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016159 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016160 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016161 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016162 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016163 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016164
16165 /* Restricted:
16166 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
16167 */
Paul Jakma62687ff2008-08-23 14:27:06 +010016168 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016169 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016170 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016171 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016172 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
16173 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
16174 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
16175 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
16176 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16177 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16178 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16179 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
16180 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016181 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016182 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016183 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016184 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016185 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016186 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016187 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016188 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016189 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016190 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016191
Michael Lambert95cbbd22010-07-23 14:43:04 -040016192 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016193 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016194 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016195 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016196 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016197 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016198 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016199 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016200 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016201 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_cmd);
16202 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_cmd);
16203 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_cmd);
16204 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_cmd);
16205 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16206 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16207 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16208 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016209 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016210 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016211 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016212 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016213 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016214 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016215 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016216 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016217 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016218 install_element (ENABLE_NODE, &show_bgp_ipv4_rsclient_cmd);
16219 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016220 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016221 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016222 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016223 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016224 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016225 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016226 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016227 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016228 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016229 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016230 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016231 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016232 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016233 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016234 install_element (ENABLE_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16235 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016236 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016237 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016238 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016239 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016240 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma2815e612006-09-14 02:56:07 +000016241
16242 /* Statistics */
16243 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016244 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000016245
16246 install_element (BGP_NODE, &bgp_distance_cmd);
16247 install_element (BGP_NODE, &no_bgp_distance_cmd);
16248 install_element (BGP_NODE, &no_bgp_distance2_cmd);
16249 install_element (BGP_NODE, &bgp_distance_source_cmd);
16250 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
16251 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
16252 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
16253
16254 install_element (BGP_NODE, &bgp_damp_set_cmd);
16255 install_element (BGP_NODE, &bgp_damp_set2_cmd);
16256 install_element (BGP_NODE, &bgp_damp_set3_cmd);
16257 install_element (BGP_NODE, &bgp_damp_unset_cmd);
16258 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
16259 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
16260 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
16261 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
16262 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
16263 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016264
16265 /* Deprecated AS-Pathlimit commands */
16266 install_element (BGP_NODE, &bgp_network_ttl_cmd);
16267 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
16268 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
16269 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
16270 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16271 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16272
16273 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
16274 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
16275 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16276 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
16277 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16278 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16279
16280 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
16281 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
16282 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
16283 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
16284 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16285 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16286
16287 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
16288 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
16289 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16290 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
16291 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16292 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16293
16294 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
16295 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
16296 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
16297 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
16298 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16299 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16300
16301 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
16302 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
16303 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16304 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
16305 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16306 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000016307
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016308 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
16309 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016310
16311 /* old style commands */
16312 install_element (VIEW_NODE, &show_ip_bgp_cmd);
16313 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
16314 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
16315 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
16316 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16317 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16318 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
16319 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16320 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16321 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16322 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
16323 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
16324 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
16325 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
16326 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16327 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
16328 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16329 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
16330 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16331 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
16332 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16333 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
16334 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16335 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
16336 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16337 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
16338 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
16339 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
16340 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
16341 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
16342 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
16343 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
16344 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
16345 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
16346 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
16347 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
16348 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
16349 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16350 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16351 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16352 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16353 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
16354 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16355 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
16356 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16357 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
16358 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16359 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16360 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16361 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16362 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16363 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
16364 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16365 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16366 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16367 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
16368 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
16369 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16370 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
16371 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16372 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
16373 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
16374 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
16375 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16376 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16377 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
16378 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
16379 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16380 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16381 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16382 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16383 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16384 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
16385 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16386 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
16387 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
16388 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
16389 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
16390 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16391 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16392 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16393 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
16394 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16395 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16396 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
16397 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
16398 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16399 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
16400 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16401 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16402 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16403 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
16404 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
16405 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
16406 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
16407 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
16408 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
16409 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
16410 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
16411 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
16412 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
16413 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
16414 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
16415 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
16416 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
16417 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16418 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16419 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16420 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16421 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
16422 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16423 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16424 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16425 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
16426 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
16427 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
16428 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
16429 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16430 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16431 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
16432 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16433 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16434 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16435 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
16436 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
16437 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
16438 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
16439 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16440 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
16441 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16442 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
16443 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16444 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
16445 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16446 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
16447 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16448 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
16449 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16450 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
16451 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
16452 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
16453 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
16454 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
16455 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
16456 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
16457 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
16458 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
16459 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
16460 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
16461 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
16462 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16463 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16464 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16465 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16466 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
16467 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16468 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
16469 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16470 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
16471 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16472 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16473 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16474 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16475 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16476 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
16477 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16478 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16479 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16480 install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd);
16481 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
16482 install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16483 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
16484 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16485 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
16486 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd);
16487 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
16488 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16489 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16490 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
16491 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd);
16492 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
16493 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16494 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16495 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16496 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16497 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16498 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
16499 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16500 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
16501 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
16502 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
16503 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
16504 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16505 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16506 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16507 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
16508 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16509 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16510 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
16511 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
16512 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
16513 install_element (VIEW_NODE, &show_bgp_cmd);
16514 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
16515 install_element (VIEW_NODE, &show_bgp_route_cmd);
16516 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
16517 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
16518 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
16519 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
16520 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
16521 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
16522 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
16523 install_element (VIEW_NODE, &show_bgp_community_cmd);
16524 install_element (VIEW_NODE, &show_bgp_community2_cmd);
16525 install_element (VIEW_NODE, &show_bgp_community3_cmd);
16526 install_element (VIEW_NODE, &show_bgp_community4_cmd);
16527 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
16528 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
16529 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
16530 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
16531 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16532 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
16533 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
16534 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
16535 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
16536 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
16537 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
16538 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16539 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
16540 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
16541 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
16542 install_element (VIEW_NODE, &show_bgp_view_cmd);
16543 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
16544 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
16545 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16546 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16547 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
16548 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16549 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
16550 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
16551 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
16552 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
16553 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
16554 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
16555 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
16556 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
16557 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
16558 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
16559 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
16560 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
16561 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
16562 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
16563 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
16564 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16565 install_element (ENABLE_NODE, &show_bgp_cmd);
16566 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
16567 install_element (ENABLE_NODE, &show_bgp_route_cmd);
16568 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
16569 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
16570 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
16571 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
16572 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
16573 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
16574 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
16575 install_element (ENABLE_NODE, &show_bgp_community_cmd);
16576 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
16577 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
16578 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
16579 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
16580 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
16581 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
16582 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
16583 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16584 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
16585 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
16586 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
16587 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
16588 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
16589 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16590 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
16591 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
16592 install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
16593 install_element (ENABLE_NODE, &show_bgp_view_cmd);
16594 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
16595 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
16596 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16597 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16598 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
16599 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16600 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
16601 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
16602 install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
16603 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
16604 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
16605 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
16606 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
16607 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
16608 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
16609 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
16610 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
16611 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
16612 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
16613 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
16614 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
16615 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
16616 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
16617 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
16618 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
16619 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
16620 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
16621 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16622 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16623 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
16624 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
16625 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
16626 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
16627 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16628 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
16629 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
16630 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
16631 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
16632 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
16633 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
16634 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
16635 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16636 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16637 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16638 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
16639 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16640 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16641 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
16642 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
16643 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
16644 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
16645 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
16646 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
16647 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
16648 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
16649 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
16650 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
16651 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
16652 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
16653 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
16654 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
16655 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
16656 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
16657 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16658 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16659 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
16660 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
16661 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
16662 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
16663 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16664 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
16665 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
16666 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
16667 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
16668 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
16669 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
16670 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
16671 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16672 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16673 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16674 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
16675 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16676 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16677 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16678 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16679 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16680 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16681 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16682 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16683 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16684 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16685 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
16686 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
16687 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16688 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16689 /* old with name safi collision */
16690 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
16691 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
16692 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
16693 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
16694 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
16695 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
16696 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
16697 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
16698 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
16699 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
16700 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
16701 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
16702 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
16703 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
16704 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
16705 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
16706 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
16707 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
16708 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
16709 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
16710 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
16711 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
16712 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
16713 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
16714 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16715 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
16716 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16717 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
16718
16719 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
16720 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
16721 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
16722 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
16723 install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
16724 install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
16725
16726 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
16727 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
16728 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
16729 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
16730 install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
16731 install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016732}
Chris Caputo228da422009-07-18 05:44:03 +000016733
16734void
16735bgp_route_finish (void)
16736{
16737 bgp_table_unlock (bgp_distance_table);
16738 bgp_distance_table = NULL;
16739}