blob: c1e5e59b12232d5ab92487ca1e44e4c4cd9daa07 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
21#include <zebra.h>
22
23#include "prefix.h"
24#include "linklist.h"
25#include "memory.h"
26#include "command.h"
27#include "stream.h"
28#include "filter.h"
29#include "str.h"
30#include "log.h"
31#include "routemap.h"
32#include "buffer.h"
33#include "sockunion.h"
34#include "plist.h"
35#include "thread.h"
paul200df112005-06-01 11:17:05 +000036#include "workqueue.h"
paul718e3742002-12-13 20:15:29 +000037
38#include "bgpd/bgpd.h"
39#include "bgpd/bgp_table.h"
40#include "bgpd/bgp_route.h"
41#include "bgpd/bgp_attr.h"
42#include "bgpd/bgp_debug.h"
43#include "bgpd/bgp_aspath.h"
44#include "bgpd/bgp_regex.h"
45#include "bgpd/bgp_community.h"
46#include "bgpd/bgp_ecommunity.h"
47#include "bgpd/bgp_clist.h"
48#include "bgpd/bgp_packet.h"
49#include "bgpd/bgp_filter.h"
50#include "bgpd/bgp_fsm.h"
51#include "bgpd/bgp_mplsvpn.h"
52#include "bgpd/bgp_nexthop.h"
53#include "bgpd/bgp_damp.h"
54#include "bgpd/bgp_advertise.h"
55#include "bgpd/bgp_zebra.h"
hasso0a486e52005-02-01 20:57:17 +000056#include "bgpd/bgp_vty.h"
Josh Bailey96450fa2011-07-20 20:45:12 -070057#include "bgpd/bgp_mpath.h"
paul718e3742002-12-13 20:15:29 +000058
59/* Extern from bgp_dump.c */
Stephen Hemmingerdde72582009-05-08 15:19:07 -070060extern const char *bgp_origin_str[];
61extern const char *bgp_origin_long_str[];
David Lamparter6b0655a2014-06-04 06:53:35 +020062
paul94f2b392005-06-28 12:44:16 +000063static struct bgp_node *
paulfee0f4c2004-09-13 05:12:46 +000064bgp_afi_node_get (struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p,
paul718e3742002-12-13 20:15:29 +000065 struct prefix_rd *prd)
66{
67 struct bgp_node *rn;
68 struct bgp_node *prn = NULL;
Paul Jakmada5b30f2006-05-08 14:37:17 +000069
70 assert (table);
71 if (!table)
72 return NULL;
73
Lou Berger298cc2f2016-01-12 13:42:02 -050074 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000075 {
paulfee0f4c2004-09-13 05:12:46 +000076 prn = bgp_node_get (table, (struct prefix *) prd);
paul718e3742002-12-13 20:15:29 +000077
78 if (prn->info == NULL)
Paul Jakma64e580a2006-02-21 01:09:01 +000079 prn->info = bgp_table_init (afi, safi);
paul718e3742002-12-13 20:15:29 +000080 else
81 bgp_unlock_node (prn);
82 table = prn->info;
83 }
paul718e3742002-12-13 20:15:29 +000084
85 rn = bgp_node_get (table, p);
86
Lou Berger298cc2f2016-01-12 13:42:02 -050087 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000088 rn->prn = prn;
89
90 return rn;
91}
David Lamparter6b0655a2014-06-04 06:53:35 +020092
Paul Jakmafb982c22007-05-04 20:15:47 +000093/* Allocate bgp_info_extra */
94static struct bgp_info_extra *
95bgp_info_extra_new (void)
96{
97 struct bgp_info_extra *new;
98 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA, sizeof (struct bgp_info_extra));
99 return new;
100}
101
102static void
103bgp_info_extra_free (struct bgp_info_extra **extra)
104{
105 if (extra && *extra)
106 {
107 if ((*extra)->damp_info)
108 bgp_damp_info_free ((*extra)->damp_info, 0);
109
110 (*extra)->damp_info = NULL;
111
112 XFREE (MTYPE_BGP_ROUTE_EXTRA, *extra);
113
114 *extra = NULL;
115 }
116}
117
118/* Get bgp_info extra information for the given bgp_info, lazy allocated
119 * if required.
120 */
121struct bgp_info_extra *
122bgp_info_extra_get (struct bgp_info *ri)
123{
124 if (!ri->extra)
125 ri->extra = bgp_info_extra_new();
126 return ri->extra;
127}
128
paul718e3742002-12-13 20:15:29 +0000129/* Allocate new bgp info structure. */
paul200df112005-06-01 11:17:05 +0000130static struct bgp_info *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -0800131bgp_info_new (void)
paul718e3742002-12-13 20:15:29 +0000132{
Stephen Hemminger393deb92008-08-18 14:13:29 -0700133 return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
paul718e3742002-12-13 20:15:29 +0000134}
135
136/* Free bgp route information. */
paul200df112005-06-01 11:17:05 +0000137static void
paul718e3742002-12-13 20:15:29 +0000138bgp_info_free (struct bgp_info *binfo)
139{
140 if (binfo->attr)
Paul Jakmaf6f434b2010-11-23 21:28:03 +0000141 bgp_attr_unintern (&binfo->attr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000142
143 bgp_info_extra_free (&binfo->extra);
Josh Baileyde8d5df2011-07-20 20:46:01 -0700144 bgp_info_mpath_free (&binfo->mpath);
paul718e3742002-12-13 20:15:29 +0000145
paul200df112005-06-01 11:17:05 +0000146 peer_unlock (binfo->peer); /* bgp_info peer reference */
147
paul718e3742002-12-13 20:15:29 +0000148 XFREE (MTYPE_BGP_ROUTE, binfo);
149}
150
paul200df112005-06-01 11:17:05 +0000151struct bgp_info *
152bgp_info_lock (struct bgp_info *binfo)
153{
154 binfo->lock++;
155 return binfo;
156}
157
158struct bgp_info *
159bgp_info_unlock (struct bgp_info *binfo)
160{
161 assert (binfo && binfo->lock > 0);
162 binfo->lock--;
163
164 if (binfo->lock == 0)
165 {
166#if 0
167 zlog_debug ("%s: unlocked and freeing", __func__);
168 zlog_backtrace (LOG_DEBUG);
169#endif
170 bgp_info_free (binfo);
171 return NULL;
172 }
173
174#if 0
175 if (binfo->lock == 1)
176 {
177 zlog_debug ("%s: unlocked to 1", __func__);
178 zlog_backtrace (LOG_DEBUG);
179 }
180#endif
181
182 return binfo;
183}
184
paul718e3742002-12-13 20:15:29 +0000185void
186bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
187{
188 struct bgp_info *top;
189
190 top = rn->info;
paul200df112005-06-01 11:17:05 +0000191
paul718e3742002-12-13 20:15:29 +0000192 ri->next = rn->info;
193 ri->prev = NULL;
194 if (top)
195 top->prev = ri;
196 rn->info = ri;
paul200df112005-06-01 11:17:05 +0000197
198 bgp_info_lock (ri);
199 bgp_lock_node (rn);
200 peer_lock (ri->peer); /* bgp_info peer reference */
paul718e3742002-12-13 20:15:29 +0000201}
202
paulb40d9392005-08-22 22:34:41 +0000203/* Do the actual removal of info from RIB, for use by bgp_process
204 completion callback *only* */
205static void
206bgp_info_reap (struct bgp_node *rn, struct bgp_info *ri)
paul718e3742002-12-13 20:15:29 +0000207{
208 if (ri->next)
209 ri->next->prev = ri->prev;
210 if (ri->prev)
211 ri->prev->next = ri->next;
212 else
213 rn->info = ri->next;
paul200df112005-06-01 11:17:05 +0000214
Josh Baileyde8d5df2011-07-20 20:46:01 -0700215 bgp_info_mpath_dequeue (ri);
paul200df112005-06-01 11:17:05 +0000216 bgp_info_unlock (ri);
217 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +0000218}
219
paulb40d9392005-08-22 22:34:41 +0000220void
221bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri)
222{
Paul Jakma1a392d42006-09-07 00:24:49 +0000223 bgp_info_set_flag (rn, ri, BGP_INFO_REMOVED);
224 /* set of previous already took care of pcount */
paulb40d9392005-08-22 22:34:41 +0000225 UNSET_FLAG (ri->flags, BGP_INFO_VALID);
226}
227
Andrew J. Schorr8d452102006-11-28 19:50:46 +0000228/* undo the effects of a previous call to bgp_info_delete; typically
229 called when a route is deleted and then quickly re-added before the
230 deletion has been processed */
231static void
232bgp_info_restore (struct bgp_node *rn, struct bgp_info *ri)
233{
234 bgp_info_unset_flag (rn, ri, BGP_INFO_REMOVED);
235 /* unset of previous already took care of pcount */
236 SET_FLAG (ri->flags, BGP_INFO_VALID);
237}
238
Paul Jakma1a392d42006-09-07 00:24:49 +0000239/* Adjust pcount as required */
240static void
241bgp_pcount_adjust (struct bgp_node *rn, struct bgp_info *ri)
242{
Avneesh Sachdev67174042012-08-17 08:19:49 -0700243 struct bgp_table *table;
244
245 assert (rn && bgp_node_table (rn));
Paul Jakma6f585442006-10-22 19:13:07 +0000246 assert (ri && ri->peer && ri->peer->bgp);
247
Avneesh Sachdev67174042012-08-17 08:19:49 -0700248 table = bgp_node_table (rn);
249
Paul Jakma1a392d42006-09-07 00:24:49 +0000250 /* Ignore 'pcount' for RS-client tables */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700251 if (table->type != BGP_TABLE_MAIN
Paul Jakma1a392d42006-09-07 00:24:49 +0000252 || ri->peer == ri->peer->bgp->peer_self)
253 return;
254
255 if (BGP_INFO_HOLDDOWN (ri)
256 && CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
257 {
258
259 UNSET_FLAG (ri->flags, BGP_INFO_COUNTED);
260
261 /* slight hack, but more robust against errors. */
Avneesh Sachdev67174042012-08-17 08:19:49 -0700262 if (ri->peer->pcount[table->afi][table->safi])
263 ri->peer->pcount[table->afi][table->safi]--;
Paul Jakma1a392d42006-09-07 00:24:49 +0000264 else
265 {
266 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
267 __func__, ri->peer->host);
268 zlog_backtrace (LOG_WARNING);
269 zlog_warn ("%s: Please report to Quagga bugzilla", __func__);
270 }
271 }
272 else if (!BGP_INFO_HOLDDOWN (ri)
273 && !CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
274 {
275 SET_FLAG (ri->flags, BGP_INFO_COUNTED);
Avneesh Sachdev67174042012-08-17 08:19:49 -0700276 ri->peer->pcount[table->afi][table->safi]++;
Paul Jakma1a392d42006-09-07 00:24:49 +0000277 }
278}
279
280
281/* Set/unset bgp_info flags, adjusting any other state as needed.
282 * This is here primarily to keep prefix-count in check.
283 */
284void
285bgp_info_set_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
286{
287 SET_FLAG (ri->flags, flag);
288
289 /* early bath if we know it's not a flag that changes useability state */
290 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
291 return;
292
293 bgp_pcount_adjust (rn, ri);
294}
295
296void
297bgp_info_unset_flag (struct bgp_node *rn, struct bgp_info *ri, u_int32_t flag)
298{
299 UNSET_FLAG (ri->flags, flag);
300
301 /* early bath if we know it's not a flag that changes useability state */
302 if (!CHECK_FLAG (flag, BGP_INFO_VALID|BGP_INFO_UNUSEABLE))
303 return;
304
305 bgp_pcount_adjust (rn, ri);
306}
307
paul718e3742002-12-13 20:15:29 +0000308/* Get MED value. If MED value is missing and "bgp bestpath
309 missing-as-worst" is specified, treat it as the worst value. */
paul94f2b392005-06-28 12:44:16 +0000310static u_int32_t
paul718e3742002-12-13 20:15:29 +0000311bgp_med_value (struct attr *attr, struct bgp *bgp)
312{
313 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
314 return attr->med;
315 else
316 {
317 if (bgp_flag_check (bgp, BGP_FLAG_MED_MISSING_AS_WORST))
paul3b424972003-10-13 09:47:32 +0000318 return BGP_MED_MAX;
paul718e3742002-12-13 20:15:29 +0000319 else
320 return 0;
321 }
322}
323
Paul Jakma6d4742b2015-11-25 17:14:37 +0000324/* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
325 * is preferred, or 0 if they are the same (usually will only occur if
326 * multipath is enabled */
paul94f2b392005-06-28 12:44:16 +0000327static int
Josh Bailey96450fa2011-07-20 20:45:12 -0700328bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist,
Paul Jakma6d4742b2015-11-25 17:14:37 +0000329 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +0000330{
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000331 struct attr *newattr, *existattr;
332 struct attr_extra *newattre, *existattre;
333 bgp_peer_sort_t new_sort;
334 bgp_peer_sort_t exist_sort;
paul718e3742002-12-13 20:15:29 +0000335 u_int32_t new_pref;
336 u_int32_t exist_pref;
337 u_int32_t new_med;
338 u_int32_t exist_med;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000339 u_int32_t new_weight;
340 u_int32_t exist_weight;
341 uint32_t newm, existm;
paul718e3742002-12-13 20:15:29 +0000342 struct in_addr new_id;
343 struct in_addr exist_id;
344 int new_cluster;
345 int exist_cluster;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000346 int internal_as_route;
347 int confed_as_route;
paul718e3742002-12-13 20:15:29 +0000348 int ret;
Josh Bailey96450fa2011-07-20 20:45:12 -0700349
paul718e3742002-12-13 20:15:29 +0000350 /* 0. Null check. */
351 if (new == NULL)
paul718e3742002-12-13 20:15:29 +0000352 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000353 if (exist == NULL)
354 return -1;
paul718e3742002-12-13 20:15:29 +0000355
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000356 newattr = new->attr;
357 existattr = exist->attr;
358 newattre = newattr->extra;
359 existattre = existattr->extra;
360
paul718e3742002-12-13 20:15:29 +0000361 /* 1. Weight check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000362 new_weight = exist_weight = 0;
363
364 if (newattre)
365 new_weight = newattre->weight;
366 if (existattre)
367 exist_weight = existattre->weight;
368
Paul Jakmafb982c22007-05-04 20:15:47 +0000369 if (new_weight > exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000370 return -1;
Paul Jakmafb982c22007-05-04 20:15:47 +0000371 if (new_weight < exist_weight)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000372 return 1;
paul718e3742002-12-13 20:15:29 +0000373
374 /* 2. Local preference check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000375 new_pref = exist_pref = bgp->default_local_pref;
paul718e3742002-12-13 20:15:29 +0000376
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000377 if (newattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
378 new_pref = newattr->local_pref;
379 if (existattr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
380 exist_pref = existattr->local_pref;
381
paul718e3742002-12-13 20:15:29 +0000382 if (new_pref > exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000383 return -1;
paul718e3742002-12-13 20:15:29 +0000384 if (new_pref < exist_pref)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000385 return 1;
paul718e3742002-12-13 20:15:29 +0000386
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000387 /* 3. Local route check. We prefer:
388 * - BGP_ROUTE_STATIC
389 * - BGP_ROUTE_AGGREGATE
390 * - BGP_ROUTE_REDISTRIBUTE
391 */
392 if (! (new->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000393 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000394 if (! (exist->sub_type == BGP_ROUTE_NORMAL))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000395 return 1;
paul718e3742002-12-13 20:15:29 +0000396
397 /* 4. AS path length check. */
398 if (! bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
399 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000400 int exist_hops = aspath_count_hops (existattr->aspath);
401 int exist_confeds = aspath_count_confeds (existattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000402
hasso68118452005-04-08 15:40:36 +0000403 if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_CONFED))
404 {
paulfe69a502005-09-10 16:55:02 +0000405 int aspath_hops;
406
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000407 aspath_hops = aspath_count_hops (newattr->aspath);
408 aspath_hops += aspath_count_confeds (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000409
410 if ( aspath_hops < (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000411 return -1;
paulfe69a502005-09-10 16:55:02 +0000412 if ( aspath_hops > (exist_hops + exist_confeds))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000413 return 1;
hasso68118452005-04-08 15:40:36 +0000414 }
415 else
416 {
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000417 int newhops = aspath_count_hops (newattr->aspath);
paulfe69a502005-09-10 16:55:02 +0000418
419 if (newhops < exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000420 return -1;
paulfe69a502005-09-10 16:55:02 +0000421 if (newhops > exist_hops)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000422 return 1;
hasso68118452005-04-08 15:40:36 +0000423 }
paul718e3742002-12-13 20:15:29 +0000424 }
425
426 /* 5. Origin check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000427 if (newattr->origin < existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000428 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000429 if (newattr->origin > existattr->origin)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000430 return 1;
paul718e3742002-12-13 20:15:29 +0000431
432 /* 6. MED check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000433 internal_as_route = (aspath_count_hops (newattr->aspath) == 0
434 && aspath_count_hops (existattr->aspath) == 0);
435 confed_as_route = (aspath_count_confeds (newattr->aspath) > 0
436 && aspath_count_confeds (existattr->aspath) > 0
437 && aspath_count_hops (newattr->aspath) == 0
438 && aspath_count_hops (existattr->aspath) == 0);
paul718e3742002-12-13 20:15:29 +0000439
440 if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED)
441 || (bgp_flag_check (bgp, BGP_FLAG_MED_CONFED)
442 && confed_as_route)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000443 || aspath_cmp_left (newattr->aspath, existattr->aspath)
444 || aspath_cmp_left_confed (newattr->aspath, existattr->aspath)
paul718e3742002-12-13 20:15:29 +0000445 || internal_as_route)
446 {
447 new_med = bgp_med_value (new->attr, bgp);
448 exist_med = bgp_med_value (exist->attr, bgp);
449
450 if (new_med < exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000451 return -1;
paul718e3742002-12-13 20:15:29 +0000452 if (new_med > exist_med)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000453 return 1;
paul718e3742002-12-13 20:15:29 +0000454 }
455
456 /* 7. Peer type check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000457 new_sort = new->peer->sort;
458 exist_sort = exist->peer->sort;
459
460 if (new_sort == BGP_PEER_EBGP
461 && (exist_sort == BGP_PEER_IBGP || exist_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000462 return -1;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000463 if (exist_sort == BGP_PEER_EBGP
464 && (new_sort == BGP_PEER_IBGP || new_sort == BGP_PEER_CONFED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000465 return 1;
paul718e3742002-12-13 20:15:29 +0000466
467 /* 8. IGP metric check. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000468 newm = existm = 0;
469
470 if (new->extra)
471 newm = new->extra->igpmetric;
472 if (exist->extra)
473 existm = exist->extra->igpmetric;
474
Josh Bailey96450fa2011-07-20 20:45:12 -0700475 if (newm < existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000476 return -1;
Josh Bailey96450fa2011-07-20 20:45:12 -0700477 if (newm > existm)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000478 return 1;
paul718e3742002-12-13 20:15:29 +0000479
480 /* 9. Maximum path check. */
Paul Jakma6d4742b2015-11-25 17:14:37 +0000481 if (bgp_mpath_is_configured (bgp, afi, safi))
Josh Bailey96450fa2011-07-20 20:45:12 -0700482 {
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000483 if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX))
484 {
Paul Jakma6d4742b2015-11-25 17:14:37 +0000485 /*
486 * For the two paths, all comparison steps till IGP metric
487 * have succeeded - including AS_PATH hop count. Since 'bgp
488 * bestpath as-path multipath-relax' knob is on, we don't need
489 * an exact match of AS_PATH. Thus, mark the paths are equal.
490 * That will trigger both these paths to get into the multipath
491 * array.
492 */
493 return 0;
Pradosh Mohapatra2fdd4552013-09-07 07:02:36 +0000494 }
495 else if (new->peer->sort == BGP_PEER_IBGP)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000496 {
497 if (aspath_cmp (new->attr->aspath, exist->attr->aspath))
498 return 0;
499 }
Josh Bailey96450fa2011-07-20 20:45:12 -0700500 else if (new->peer->as == exist->peer->as)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000501 return 0;
Josh Bailey96450fa2011-07-20 20:45:12 -0700502 }
paul718e3742002-12-13 20:15:29 +0000503
504 /* 10. If both paths are external, prefer the path that was received
505 first (the oldest one). This step minimizes route-flap, since a
506 newer path won't displace an older one, even if it was the
507 preferred route based on the additional decision criteria below. */
508 if (! bgp_flag_check (bgp, BGP_FLAG_COMPARE_ROUTER_ID)
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000509 && new_sort == BGP_PEER_EBGP
510 && exist_sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +0000511 {
512 if (CHECK_FLAG (new->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000513 return -1;
paul718e3742002-12-13 20:15:29 +0000514 if (CHECK_FLAG (exist->flags, BGP_INFO_SELECTED))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000515 return 1;
paul718e3742002-12-13 20:15:29 +0000516 }
517
vivekbd4b7f12014-09-30 15:54:45 -0700518 /* 11. Router-ID comparision. */
519 /* If one of the paths is "stale", the corresponding peer router-id will
520 * be 0 and would always win over the other path. If originator id is
521 * used for the comparision, it will decide which path is better.
522 */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000523 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
524 new_id.s_addr = newattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000525 else
526 new_id.s_addr = new->peer->remote_id.s_addr;
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000527 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
528 exist_id.s_addr = existattre->originator_id.s_addr;
paul718e3742002-12-13 20:15:29 +0000529 else
530 exist_id.s_addr = exist->peer->remote_id.s_addr;
531
532 if (ntohl (new_id.s_addr) < ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000533 return -1;
paul718e3742002-12-13 20:15:29 +0000534 if (ntohl (new_id.s_addr) > ntohl (exist_id.s_addr))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000535 return 1;
paul718e3742002-12-13 20:15:29 +0000536
537 /* 12. Cluster length comparision. */
Jorge Boncompte [DTI2]8ff56312012-05-07 16:52:56 +0000538 new_cluster = exist_cluster = 0;
539
540 if (newattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
541 new_cluster = newattre->cluster->length;
542 if (existattr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
543 exist_cluster = existattre->cluster->length;
paul718e3742002-12-13 20:15:29 +0000544
545 if (new_cluster < exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000546 return -1;
paul718e3742002-12-13 20:15:29 +0000547 if (new_cluster > exist_cluster)
Paul Jakma6d4742b2015-11-25 17:14:37 +0000548 return 1;
paul718e3742002-12-13 20:15:29 +0000549
550 /* 13. Neighbor address comparision. */
vivekbd4b7f12014-09-30 15:54:45 -0700551 /* Do this only if neither path is "stale" as stale paths do not have
552 * valid peer information (as the connection may or may not be up).
553 */
554 if (CHECK_FLAG (exist->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000555 return -1;
vivekbd4b7f12014-09-30 15:54:45 -0700556 if (CHECK_FLAG (new->flags, BGP_INFO_STALE))
Paul Jakma6d4742b2015-11-25 17:14:37 +0000557 return 1;
Timo Teräs2820a012015-06-24 15:27:21 +0300558 /* locally configured routes to advertise do not have su_remote */
559 if (new->peer->su_remote == NULL)
Timo Teräs2820a012015-06-24 15:27:21 +0300560 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000561 if (exist->peer->su_remote == NULL)
562 return -1;
Timo Teräs2820a012015-06-24 15:27:21 +0300563
paul718e3742002-12-13 20:15:29 +0000564 ret = sockunion_cmp (new->peer->su_remote, exist->peer->su_remote);
565
566 if (ret == 1)
paul718e3742002-12-13 20:15:29 +0000567 return 1;
Paul Jakma6d4742b2015-11-25 17:14:37 +0000568 if (ret == -1)
569 return -1;
paul718e3742002-12-13 20:15:29 +0000570
Paul Jakma6d4742b2015-11-25 17:14:37 +0000571 return -1;
paul718e3742002-12-13 20:15:29 +0000572}
573
paul94f2b392005-06-28 12:44:16 +0000574static enum filter_type
paul718e3742002-12-13 20:15:29 +0000575bgp_input_filter (struct peer *peer, struct prefix *p, struct attr *attr,
576 afi_t afi, safi_t safi)
577{
578 struct bgp_filter *filter;
579
580 filter = &peer->filter[afi][safi];
581
Paul Jakma650f76c2009-06-25 18:06:31 +0100582#define FILTER_EXIST_WARN(F,f,filter) \
583 if (BGP_DEBUG (update, UPDATE_IN) \
584 && !(F ## _IN (filter))) \
585 plog_warn (peer->log, "%s: Could not find configured input %s-list %s!", \
586 peer->host, #f, F ## _IN_NAME(filter));
587
588 if (DISTRIBUTE_IN_NAME (filter)) {
589 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
590
paul718e3742002-12-13 20:15:29 +0000591 if (access_list_apply (DISTRIBUTE_IN (filter), p) == FILTER_DENY)
592 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100593 }
paul718e3742002-12-13 20:15:29 +0000594
Paul Jakma650f76c2009-06-25 18:06:31 +0100595 if (PREFIX_LIST_IN_NAME (filter)) {
596 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
597
paul718e3742002-12-13 20:15:29 +0000598 if (prefix_list_apply (PREFIX_LIST_IN (filter), p) == PREFIX_DENY)
599 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100600 }
paul718e3742002-12-13 20:15:29 +0000601
Paul Jakma650f76c2009-06-25 18:06:31 +0100602 if (FILTER_LIST_IN_NAME (filter)) {
603 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
604
paul718e3742002-12-13 20:15:29 +0000605 if (as_list_apply (FILTER_LIST_IN (filter), attr->aspath)== AS_FILTER_DENY)
606 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100607 }
608
paul718e3742002-12-13 20:15:29 +0000609 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100610#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000611}
612
paul94f2b392005-06-28 12:44:16 +0000613static enum filter_type
paul718e3742002-12-13 20:15:29 +0000614bgp_output_filter (struct peer *peer, struct prefix *p, struct attr *attr,
615 afi_t afi, safi_t safi)
616{
617 struct bgp_filter *filter;
618
619 filter = &peer->filter[afi][safi];
620
Paul Jakma650f76c2009-06-25 18:06:31 +0100621#define FILTER_EXIST_WARN(F,f,filter) \
622 if (BGP_DEBUG (update, UPDATE_OUT) \
623 && !(F ## _OUT (filter))) \
624 plog_warn (peer->log, "%s: Could not find configured output %s-list %s!", \
625 peer->host, #f, F ## _OUT_NAME(filter));
626
627 if (DISTRIBUTE_OUT_NAME (filter)) {
628 FILTER_EXIST_WARN(DISTRIBUTE, distribute, filter);
629
paul718e3742002-12-13 20:15:29 +0000630 if (access_list_apply (DISTRIBUTE_OUT (filter), p) == FILTER_DENY)
631 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100632 }
paul718e3742002-12-13 20:15:29 +0000633
Paul Jakma650f76c2009-06-25 18:06:31 +0100634 if (PREFIX_LIST_OUT_NAME (filter)) {
635 FILTER_EXIST_WARN(PREFIX_LIST, prefix, filter);
636
paul718e3742002-12-13 20:15:29 +0000637 if (prefix_list_apply (PREFIX_LIST_OUT (filter), p) == PREFIX_DENY)
638 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100639 }
paul718e3742002-12-13 20:15:29 +0000640
Paul Jakma650f76c2009-06-25 18:06:31 +0100641 if (FILTER_LIST_OUT_NAME (filter)) {
642 FILTER_EXIST_WARN(FILTER_LIST, as, filter);
643
paul718e3742002-12-13 20:15:29 +0000644 if (as_list_apply (FILTER_LIST_OUT (filter), attr->aspath) == AS_FILTER_DENY)
645 return FILTER_DENY;
Paul Jakma650f76c2009-06-25 18:06:31 +0100646 }
paul718e3742002-12-13 20:15:29 +0000647
648 return FILTER_PERMIT;
Paul Jakma650f76c2009-06-25 18:06:31 +0100649#undef FILTER_EXIST_WARN
paul718e3742002-12-13 20:15:29 +0000650}
651
652/* If community attribute includes no_export then return 1. */
paul94f2b392005-06-28 12:44:16 +0000653static int
paul718e3742002-12-13 20:15:29 +0000654bgp_community_filter (struct peer *peer, struct attr *attr)
655{
656 if (attr->community)
657 {
658 /* NO_ADVERTISE check. */
659 if (community_include (attr->community, COMMUNITY_NO_ADVERTISE))
660 return 1;
661
662 /* NO_EXPORT check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000663 if (peer->sort == BGP_PEER_EBGP &&
paul718e3742002-12-13 20:15:29 +0000664 community_include (attr->community, COMMUNITY_NO_EXPORT))
665 return 1;
666
667 /* NO_EXPORT_SUBCONFED check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000668 if (peer->sort == BGP_PEER_EBGP
669 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000670 if (community_include (attr->community, COMMUNITY_NO_EXPORT_SUBCONFED))
671 return 1;
672 }
673 return 0;
674}
675
676/* Route reflection loop check. */
677static int
678bgp_cluster_filter (struct peer *peer, struct attr *attr)
679{
680 struct in_addr cluster_id;
681
Paul Jakmafb982c22007-05-04 20:15:47 +0000682 if (attr->extra && attr->extra->cluster)
paul718e3742002-12-13 20:15:29 +0000683 {
684 if (peer->bgp->config & BGP_CONFIG_CLUSTER_ID)
685 cluster_id = peer->bgp->cluster_id;
686 else
687 cluster_id = peer->bgp->router_id;
688
Paul Jakmafb982c22007-05-04 20:15:47 +0000689 if (cluster_loop_check (attr->extra->cluster, cluster_id))
paul718e3742002-12-13 20:15:29 +0000690 return 1;
691 }
692 return 0;
693}
David Lamparter6b0655a2014-06-04 06:53:35 +0200694
paul94f2b392005-06-28 12:44:16 +0000695static int
paul718e3742002-12-13 20:15:29 +0000696bgp_input_modifier (struct peer *peer, struct prefix *p, struct attr *attr,
697 afi_t afi, safi_t safi)
698{
699 struct bgp_filter *filter;
700 struct bgp_info info;
701 route_map_result_t ret;
702
703 filter = &peer->filter[afi][safi];
704
705 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000706 if (peer->weight)
707 (bgp_attr_extra_get (attr))->weight = peer->weight;
paul718e3742002-12-13 20:15:29 +0000708
709 /* Route map apply. */
710 if (ROUTE_MAP_IN_NAME (filter))
711 {
712 /* Duplicate current value to new strucutre for modification. */
713 info.peer = peer;
714 info.attr = attr;
715
paulac41b2a2003-08-12 05:32:27 +0000716 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN);
717
paul718e3742002-12-13 20:15:29 +0000718 /* Apply BGP route map to the attribute. */
719 ret = route_map_apply (ROUTE_MAP_IN (filter), p, RMAP_BGP, &info);
paulac41b2a2003-08-12 05:32:27 +0000720
721 peer->rmap_type = 0;
722
paul718e3742002-12-13 20:15:29 +0000723 if (ret == RMAP_DENYMATCH)
David Lamparterc460e572014-06-04 00:54:58 +0200724 /* caller has multiple error paths with bgp_attr_flush() */
725 return RMAP_DENY;
paul718e3742002-12-13 20:15:29 +0000726 }
727 return RMAP_PERMIT;
728}
David Lamparter6b0655a2014-06-04 06:53:35 +0200729
paul94f2b392005-06-28 12:44:16 +0000730static int
paulfee0f4c2004-09-13 05:12:46 +0000731bgp_export_modifier (struct peer *rsclient, struct peer *peer,
732 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
733{
734 struct bgp_filter *filter;
735 struct bgp_info info;
736 route_map_result_t ret;
737
738 filter = &peer->filter[afi][safi];
739
740 /* Route map apply. */
741 if (ROUTE_MAP_EXPORT_NAME (filter))
742 {
743 /* Duplicate current value to new strucutre for modification. */
744 info.peer = rsclient;
745 info.attr = attr;
746
747 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
748
749 /* Apply BGP route map to the attribute. */
750 ret = route_map_apply (ROUTE_MAP_EXPORT (filter), p, RMAP_BGP, &info);
751
752 rsclient->rmap_type = 0;
753
754 if (ret == RMAP_DENYMATCH)
755 {
756 /* Free newly generated AS path and community by route-map. */
757 bgp_attr_flush (attr);
758 return RMAP_DENY;
759 }
760 }
761 return RMAP_PERMIT;
762}
763
paul94f2b392005-06-28 12:44:16 +0000764static int
paulfee0f4c2004-09-13 05:12:46 +0000765bgp_import_modifier (struct peer *rsclient, struct peer *peer,
766 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
767{
768 struct bgp_filter *filter;
769 struct bgp_info info;
770 route_map_result_t ret;
771
772 filter = &rsclient->filter[afi][safi];
773
774 /* Apply default weight value. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000775 if (peer->weight)
776 (bgp_attr_extra_get (attr))->weight = peer->weight;
paulfee0f4c2004-09-13 05:12:46 +0000777
778 /* Route map apply. */
779 if (ROUTE_MAP_IMPORT_NAME (filter))
780 {
781 /* Duplicate current value to new strucutre for modification. */
782 info.peer = peer;
783 info.attr = attr;
784
785 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT);
786
787 /* Apply BGP route map to the attribute. */
788 ret = route_map_apply (ROUTE_MAP_IMPORT (filter), p, RMAP_BGP, &info);
789
790 peer->rmap_type = 0;
791
792 if (ret == RMAP_DENYMATCH)
793 {
794 /* Free newly generated AS path and community by route-map. */
795 bgp_attr_flush (attr);
796 return RMAP_DENY;
797 }
798 }
799 return RMAP_PERMIT;
800}
David Lamparter6b0655a2014-06-04 06:53:35 +0200801
paul94f2b392005-06-28 12:44:16 +0000802static int
paul718e3742002-12-13 20:15:29 +0000803bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
804 struct attr *attr, afi_t afi, safi_t safi)
805{
806 int ret;
807 char buf[SU_ADDRSTRLEN];
808 struct bgp_filter *filter;
paul718e3742002-12-13 20:15:29 +0000809 struct peer *from;
810 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +0000811 int transparent;
812 int reflect;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700813 struct attr *riattr;
paul718e3742002-12-13 20:15:29 +0000814
815 from = ri->peer;
816 filter = &peer->filter[afi][safi];
817 bgp = peer->bgp;
Josh Bailey0b597ef2011-07-20 20:49:11 -0700818 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paul718e3742002-12-13 20:15:29 +0000819
Paul Jakma750e8142008-07-22 21:11:48 +0000820 if (DISABLE_BGP_ANNOUNCE)
821 return 0;
paul718e3742002-12-13 20:15:29 +0000822
paulfee0f4c2004-09-13 05:12:46 +0000823 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
824 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
825 return 0;
826
paul718e3742002-12-13 20:15:29 +0000827 /* Do not send back route to sender. */
828 if (from == peer)
829 return 0;
830
831 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +0000832 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +0000833 if (! UNSUPPRESS_MAP_NAME (filter))
834 return 0;
835
836 /* Default route check. */
837 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
838 {
839 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
840 return 0;
paul718e3742002-12-13 20:15:29 +0000841 else if (p->family == AF_INET6 && p->prefixlen == 0)
842 return 0;
paul718e3742002-12-13 20:15:29 +0000843 }
844
paul286e1e72003-08-08 00:24:31 +0000845 /* Transparency check. */
846 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)
847 && CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
848 transparent = 1;
849 else
850 transparent = 0;
851
paul718e3742002-12-13 20:15:29 +0000852 /* If community is not disabled check the no-export and local. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700853 if (! transparent && bgp_community_filter (peer, riattr))
paul718e3742002-12-13 20:15:29 +0000854 return 0;
855
856 /* If the attribute has originator-id and it is same as remote
857 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700858 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paul718e3742002-12-13 20:15:29 +0000859 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700860 if (IPV4_ADDR_SAME (&peer->remote_id, &riattr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +0000861 {
862 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000863 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000864 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
865 peer->host,
866 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
867 p->prefixlen);
868 return 0;
869 }
870 }
871
872 /* ORF prefix-list filter check */
873 if (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
874 && (CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
875 || CHECK_FLAG (peer->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
876 if (peer->orf_plist[afi][safi])
877 {
878 if (prefix_list_apply (peer->orf_plist[afi][safi], p) == PREFIX_DENY)
879 return 0;
880 }
881
882 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700883 if (bgp_output_filter (peer, p, riattr, afi, safi) == FILTER_DENY)
paul718e3742002-12-13 20:15:29 +0000884 {
885 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000886 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +0000887 "%s [Update:SEND] %s/%d is filtered",
888 peer->host,
889 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
890 p->prefixlen);
891 return 0;
892 }
893
894#ifdef BGP_SEND_ASPATH_CHECK
895 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700896 if (aspath_loop_check (riattr->aspath, peer->as))
paul718e3742002-12-13 20:15:29 +0000897 {
898 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000899 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400900 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000901 peer->host, peer->as);
902 return 0;
903 }
904#endif /* BGP_SEND_ASPATH_CHECK */
905
906 /* If we're a CONFED we need to loop check the CONFED ID too */
907 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
908 {
Josh Bailey0b597ef2011-07-20 20:49:11 -0700909 if (aspath_loop_check(riattr->aspath, bgp->confed_id))
paul718e3742002-12-13 20:15:29 +0000910 {
911 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +0000912 zlog (peer->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +0400913 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paul718e3742002-12-13 20:15:29 +0000914 peer->host,
915 bgp->confed_id);
916 return 0;
917 }
918 }
919
920 /* Route-Reflect check. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000921 if (from->sort == BGP_PEER_IBGP && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +0000922 reflect = 1;
923 else
924 reflect = 0;
925
926 /* IBGP reflection check. */
927 if (reflect)
928 {
929 /* A route from a Client peer. */
930 if (CHECK_FLAG (from->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
931 {
932 /* Reflect to all the Non-Client peers and also to the
933 Client peers other than the originator. Originator check
934 is already done. So there is noting to do. */
935 /* no bgp client-to-client reflection check. */
936 if (bgp_flag_check (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT))
937 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
938 return 0;
939 }
940 else
941 {
942 /* A route from a Non-client peer. Reflect to all other
943 clients. */
944 if (! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
945 return 0;
946 }
947 }
Paul Jakma41367172007-08-06 15:24:51 +0000948
paul718e3742002-12-13 20:15:29 +0000949 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -0700950 bgp_attr_dup (attr, riattr);
Paul Jakmafb982c22007-05-04 20:15:47 +0000951
paul718e3742002-12-13 20:15:29 +0000952 /* If local-preference is not set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000953 if ((peer->sort == BGP_PEER_IBGP
954 || peer->sort == BGP_PEER_CONFED)
paul718e3742002-12-13 20:15:29 +0000955 && (! (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))))
956 {
957 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
958 attr->local_pref = bgp->default_local_pref;
959 }
960
Pradosh Mohapatra689bb662013-09-07 07:13:37 +0000961 /* If originator-id is not set and the route is to be reflected,
962 set the originator id */
963 if (peer && from && peer->sort == BGP_PEER_IBGP &&
964 from->sort == BGP_PEER_IBGP &&
965 (! (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))))
966 {
967 attr->extra = bgp_attr_extra_get(attr);
968 IPV4_ADDR_COPY(&(attr->extra->originator_id), &(from->remote_id));
969 SET_FLAG(attr->flag, BGP_ATTR_ORIGINATOR_ID);
970 }
971
paul718e3742002-12-13 20:15:29 +0000972 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +0000973 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +0000974 && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
975 {
976 if (ri->peer != bgp->peer_self && ! transparent
977 && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
978 attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC));
979 }
980
Lou Berger298cc2f2016-01-12 13:42:02 -0500981
982#define NEXTHOP_IS_V4 (\
983 (safi != SAFI_ENCAP && p->family == AF_INET) || \
984 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 4))
985
Lou Berger298cc2f2016-01-12 13:42:02 -0500986#define NEXTHOP_IS_V6 (\
987 (safi != SAFI_ENCAP && p->family == AF_INET6) || \
988 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
Lou Berger298cc2f2016-01-12 13:42:02 -0500989
paul718e3742002-12-13 20:15:29 +0000990 /* next-hop-set */
Timo Teräs9e7a53c2014-04-24 10:22:37 +0300991 if (transparent
992 || (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
paul718e3742002-12-13 20:15:29 +0000993 || (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
Lou Berger298cc2f2016-01-12 13:42:02 -0500994 && ((NEXTHOP_IS_V4 && attr->nexthop.s_addr)
Lou Berger298cc2f2016-01-12 13:42:02 -0500995 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +0000996 ! IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paul286e1e72003-08-08 00:24:31 +0000997 )))
paul718e3742002-12-13 20:15:29 +0000998 {
999 /* NEXT-HOP Unchanged. */
1000 }
1001 else if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF)
Lou Berger298cc2f2016-01-12 13:42:02 -05001002 || (NEXTHOP_IS_V4 && attr->nexthop.s_addr == 0)
Lou Berger298cc2f2016-01-12 13:42:02 -05001003 || (NEXTHOP_IS_V6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001004 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001005 || (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001006 && bgp_multiaccess_check_v4 (attr->nexthop, peer->host) == 0))
1007 {
1008 /* Set IPv4 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001009 if (NEXTHOP_IS_V4)
paul718e3742002-12-13 20:15:29 +00001010 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001011 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001012 memcpy (&attr->extra->mp_nexthop_global_in, &peer->nexthop.v4,
1013 IPV4_MAX_BYTELEN);
paul718e3742002-12-13 20:15:29 +00001014 else
1015 memcpy (&attr->nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
1016 }
paul718e3742002-12-13 20:15:29 +00001017 /* Set IPv6 nexthop. */
Lou Berger298cc2f2016-01-12 13:42:02 -05001018 if (NEXTHOP_IS_V6)
paul718e3742002-12-13 20:15:29 +00001019 {
1020 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001021 memcpy (&attr->extra->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00001022 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001023 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001024 }
paul718e3742002-12-13 20:15:29 +00001025 }
1026
Lou Berger298cc2f2016-01-12 13:42:02 -05001027 if (p->family == AF_INET6 && safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00001028 {
paulfee0f4c2004-09-13 05:12:46 +00001029 /* Left nexthop_local unchanged if so configured. */
1030 if ( CHECK_FLAG (peer->af_flags[afi][safi],
1031 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1032 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001033 if ( IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_local) )
1034 attr->extra->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001035 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001036 attr->extra->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001037 }
1038
1039 /* Default nexthop_local treatment for non-RS-Clients */
1040 else
1041 {
paul718e3742002-12-13 20:15:29 +00001042 /* Link-local address should not be transit to different peer. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001043 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001044
1045 /* Set link-local address for shared network peer. */
1046 if (peer->shared_network
1047 && ! IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
1048 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001049 memcpy (&attr->extra->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00001050 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001051 attr->extra->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00001052 }
1053
1054 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
1055 address.*/
1056 if (reflect)
Paul Jakmafb982c22007-05-04 20:15:47 +00001057 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001058
1059 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
1060 if (! IN6_IS_ADDR_LINKLOCAL (&peer->nexthop.v6_local))
Paul Jakmafb982c22007-05-04 20:15:47 +00001061 attr->extra->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00001062 }
paulfee0f4c2004-09-13 05:12:46 +00001063
1064 }
paul718e3742002-12-13 20:15:29 +00001065
1066 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001067 if (peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00001068 && peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1069 && aspath_private_as_check (attr->aspath))
1070 attr->aspath = aspath_empty_get ();
1071
1072 /* Route map & unsuppress-map apply. */
1073 if (ROUTE_MAP_OUT_NAME (filter)
Paul Jakmafb982c22007-05-04 20:15:47 +00001074 || (ri->extra && ri->extra->suppress) )
paul718e3742002-12-13 20:15:29 +00001075 {
Paul Jakma7c7fa1b2006-02-18 10:52:09 +00001076 struct bgp_info info;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001077 struct attr dummy_attr;
1078 struct attr_extra dummy_extra;
1079
1080 dummy_attr.extra = &dummy_extra;
1081
paul718e3742002-12-13 20:15:29 +00001082 info.peer = peer;
1083 info.attr = attr;
1084
1085 /* The route reflector is not allowed to modify the attributes
1086 of the reflected IBGP routes. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001087 if (from->sort == BGP_PEER_IBGP
1088 && peer->sort == BGP_PEER_IBGP)
paul718e3742002-12-13 20:15:29 +00001089 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001090 bgp_attr_dup (&dummy_attr, attr);
Paul Jakma9eda90c2007-08-30 13:36:17 +00001091 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00001092 }
paulac41b2a2003-08-12 05:32:27 +00001093
1094 SET_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT);
1095
Paul Jakmafb982c22007-05-04 20:15:47 +00001096 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00001097 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1098 else
1099 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1100
paulac41b2a2003-08-12 05:32:27 +00001101 peer->rmap_type = 0;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001102
paul718e3742002-12-13 20:15:29 +00001103 if (ret == RMAP_DENYMATCH)
1104 {
1105 bgp_attr_flush (attr);
1106 return 0;
1107 }
1108 }
1109 return 1;
1110}
1111
paul94f2b392005-06-28 12:44:16 +00001112static int
paulfee0f4c2004-09-13 05:12:46 +00001113bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
1114 struct prefix *p, struct attr *attr, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00001115{
paulfee0f4c2004-09-13 05:12:46 +00001116 int ret;
1117 char buf[SU_ADDRSTRLEN];
1118 struct bgp_filter *filter;
1119 struct bgp_info info;
1120 struct peer *from;
Josh Bailey0b597ef2011-07-20 20:49:11 -07001121 struct attr *riattr;
paulfee0f4c2004-09-13 05:12:46 +00001122
1123 from = ri->peer;
1124 filter = &rsclient->filter[afi][safi];
Josh Bailey0b597ef2011-07-20 20:49:11 -07001125 riattr = bgp_info_mpath_count (ri) ? bgp_info_mpath_attr (ri) : ri->attr;
paulfee0f4c2004-09-13 05:12:46 +00001126
Paul Jakma750e8142008-07-22 21:11:48 +00001127 if (DISABLE_BGP_ANNOUNCE)
1128 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001129
1130 /* Do not send back route to sender. */
1131 if (from == rsclient)
1132 return 0;
1133
1134 /* Aggregate-address suppress check. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001135 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001136 if (! UNSUPPRESS_MAP_NAME (filter))
1137 return 0;
1138
1139 /* Default route check. */
1140 if (CHECK_FLAG (rsclient->af_sflags[afi][safi],
1141 PEER_STATUS_DEFAULT_ORIGINATE))
1142 {
1143 if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY)
1144 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001145 else if (p->family == AF_INET6 && p->prefixlen == 0)
1146 return 0;
paulfee0f4c2004-09-13 05:12:46 +00001147 }
1148
1149 /* If the attribute has originator-id and it is same as remote
1150 peer's id. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001151 if (riattr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID))
paulfee0f4c2004-09-13 05:12:46 +00001152 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001153 if (IPV4_ADDR_SAME (&rsclient->remote_id,
Josh Bailey0b597ef2011-07-20 20:49:11 -07001154 &riattr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001155 {
1156 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001157 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001158 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1159 rsclient->host,
1160 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1161 p->prefixlen);
1162 return 0;
1163 }
1164 }
1165
1166 /* ORF prefix-list filter check */
1167 if (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
1168 && (CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
1169 || CHECK_FLAG (rsclient->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)))
1170 if (rsclient->orf_plist[afi][safi])
1171 {
1172 if (prefix_list_apply (rsclient->orf_plist[afi][safi], p) == PREFIX_DENY)
1173 return 0;
1174 }
1175
1176 /* Output filter check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001177 if (bgp_output_filter (rsclient, p, riattr, afi, safi) == FILTER_DENY)
paulfee0f4c2004-09-13 05:12:46 +00001178 {
1179 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001180 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001181 "%s [Update:SEND] %s/%d is filtered",
1182 rsclient->host,
1183 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1184 p->prefixlen);
1185 return 0;
1186 }
1187
1188#ifdef BGP_SEND_ASPATH_CHECK
1189 /* AS path loop check. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001190 if (aspath_loop_check (riattr->aspath, rsclient->as))
paulfee0f4c2004-09-13 05:12:46 +00001191 {
1192 if (BGP_DEBUG (filter, FILTER))
ajsd2c1f162004-12-08 21:10:20 +00001193 zlog (rsclient->log, LOG_DEBUG,
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04001194 "%s [Update:SEND] suppress announcement to peer AS %u is AS path.",
paulfee0f4c2004-09-13 05:12:46 +00001195 rsclient->host, rsclient->as);
1196 return 0;
1197 }
1198#endif /* BGP_SEND_ASPATH_CHECK */
1199
1200 /* For modify attribute, copy it to temporary structure. */
Josh Bailey0b597ef2011-07-20 20:49:11 -07001201 bgp_attr_dup (attr, riattr);
paulfee0f4c2004-09-13 05:12:46 +00001202
1203 /* next-hop-set */
1204 if ((p->family == AF_INET && attr->nexthop.s_addr == 0)
paulfee0f4c2004-09-13 05:12:46 +00001205 || (p->family == AF_INET6 &&
Paul Jakmafb982c22007-05-04 20:15:47 +00001206 IN6_IS_ADDR_UNSPECIFIED(&attr->extra->mp_nexthop_global))
paulfee0f4c2004-09-13 05:12:46 +00001207 )
1208 {
1209 /* Set IPv4 nexthop. */
1210 if (p->family == AF_INET)
1211 {
Lou Berger298cc2f2016-01-12 13:42:02 -05001212 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00001213 memcpy (&attr->extra->mp_nexthop_global_in, &rsclient->nexthop.v4,
paulfee0f4c2004-09-13 05:12:46 +00001214 IPV4_MAX_BYTELEN);
1215 else
1216 memcpy (&attr->nexthop, &rsclient->nexthop.v4, IPV4_MAX_BYTELEN);
1217 }
paulfee0f4c2004-09-13 05:12:46 +00001218 /* Set IPv6 nexthop. */
1219 if (p->family == AF_INET6)
1220 {
1221 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001222 memcpy (&attr->extra->mp_nexthop_global, &rsclient->nexthop.v6_global,
paulfee0f4c2004-09-13 05:12:46 +00001223 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001224 attr->extra->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001225 }
paulfee0f4c2004-09-13 05:12:46 +00001226 }
1227
paulfee0f4c2004-09-13 05:12:46 +00001228 if (p->family == AF_INET6)
1229 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001230 struct attr_extra *attre = attr->extra;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001231
paulfee0f4c2004-09-13 05:12:46 +00001232 /* Left nexthop_local unchanged if so configured. */
1233 if ( CHECK_FLAG (rsclient->af_flags[afi][safi],
1234 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED) )
1235 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001236 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1237 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001238 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001239 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001240 }
1241
1242 /* Default nexthop_local treatment for RS-Clients */
1243 else
1244 {
1245 /* Announcer and RS-Client are both in the same network */
1246 if (rsclient->shared_network && from->shared_network &&
1247 (rsclient->ifindex == from->ifindex))
1248 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001249 if ( IN6_IS_ADDR_LINKLOCAL (&attre->mp_nexthop_local) )
1250 attre->mp_nexthop_len=32;
paulfee0f4c2004-09-13 05:12:46 +00001251 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001252 attre->mp_nexthop_len=16;
paulfee0f4c2004-09-13 05:12:46 +00001253 }
1254
1255 /* Set link-local address for shared network peer. */
1256 else if (rsclient->shared_network
1257 && IN6_IS_ADDR_LINKLOCAL (&rsclient->nexthop.v6_local))
1258 {
Paul Jakmafb982c22007-05-04 20:15:47 +00001259 memcpy (&attre->mp_nexthop_local, &rsclient->nexthop.v6_local,
paulfee0f4c2004-09-13 05:12:46 +00001260 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00001261 attre->mp_nexthop_len = 32;
paulfee0f4c2004-09-13 05:12:46 +00001262 }
1263
1264 else
Paul Jakmafb982c22007-05-04 20:15:47 +00001265 attre->mp_nexthop_len = 16;
paulfee0f4c2004-09-13 05:12:46 +00001266 }
1267
1268 }
paulfee0f4c2004-09-13 05:12:46 +00001269
1270 /* If this is EBGP peer and remove-private-AS is set. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001271 if (rsclient->sort == BGP_PEER_EBGP
paulfee0f4c2004-09-13 05:12:46 +00001272 && peer_af_flag_check (rsclient, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
1273 && aspath_private_as_check (attr->aspath))
1274 attr->aspath = aspath_empty_get ();
1275
1276 /* Route map & unsuppress-map apply. */
Paul Jakmafb982c22007-05-04 20:15:47 +00001277 if (ROUTE_MAP_OUT_NAME (filter) || (ri->extra && ri->extra->suppress) )
paulfee0f4c2004-09-13 05:12:46 +00001278 {
1279 info.peer = rsclient;
1280 info.attr = attr;
1281
1282 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_OUT);
1283
Paul Jakmafb982c22007-05-04 20:15:47 +00001284 if (ri->extra && ri->extra->suppress)
paulfee0f4c2004-09-13 05:12:46 +00001285 ret = route_map_apply (UNSUPPRESS_MAP (filter), p, RMAP_BGP, &info);
1286 else
1287 ret = route_map_apply (ROUTE_MAP_OUT (filter), p, RMAP_BGP, &info);
1288
1289 rsclient->rmap_type = 0;
1290
1291 if (ret == RMAP_DENYMATCH)
1292 {
1293 bgp_attr_flush (attr);
1294 return 0;
1295 }
1296 }
1297
1298 return 1;
1299}
1300
1301struct bgp_info_pair
1302{
1303 struct bgp_info *old;
1304 struct bgp_info *new;
1305};
1306
paul94f2b392005-06-28 12:44:16 +00001307static void
Josh Bailey96450fa2011-07-20 20:45:12 -07001308bgp_best_selection (struct bgp *bgp, struct bgp_node *rn,
Paul Jakma6d4742b2015-11-25 17:14:37 +00001309 struct bgp_info_pair *result,
1310 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00001311{
paul718e3742002-12-13 20:15:29 +00001312 struct bgp_info *new_select;
1313 struct bgp_info *old_select;
paulfee0f4c2004-09-13 05:12:46 +00001314 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00001315 struct bgp_info *ri1;
1316 struct bgp_info *ri2;
paulb40d9392005-08-22 22:34:41 +00001317 struct bgp_info *nextri = NULL;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001318 int cmpret, do_mpath;
Josh Bailey96450fa2011-07-20 20:45:12 -07001319 struct list mp_list;
Paul Jakma91b9e852015-12-01 14:32:11 +00001320
1321 result->old = result->new = NULL;
1322
1323 if (rn->info == NULL)
1324 {
1325 char buf[PREFIX_STRLEN];
1326 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1327 __func__,
1328 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1329 return;
1330 }
1331
Josh Bailey96450fa2011-07-20 20:45:12 -07001332 bgp_mp_list_init (&mp_list);
Paul Jakma6d4742b2015-11-25 17:14:37 +00001333 do_mpath = bgp_mpath_is_configured (bgp, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001334
paul718e3742002-12-13 20:15:29 +00001335 /* bgp deterministic-med */
1336 new_select = NULL;
1337 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1338 for (ri1 = rn->info; ri1; ri1 = ri1->next)
1339 {
1340 if (CHECK_FLAG (ri1->flags, BGP_INFO_DMED_CHECK))
1341 continue;
1342 if (BGP_INFO_HOLDDOWN (ri1))
1343 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001344 if (ri1->peer && ri1->peer != bgp->peer_self)
1345 if (ri1->peer->status != Established)
1346 continue;
paul718e3742002-12-13 20:15:29 +00001347
1348 new_select = ri1;
Josh Bailey6918e742011-07-20 20:48:20 -07001349 if (do_mpath)
1350 bgp_mp_list_add (&mp_list, ri1);
1351 old_select = CHECK_FLAG (ri1->flags, BGP_INFO_SELECTED) ? ri1 : NULL;
paul718e3742002-12-13 20:15:29 +00001352 if (ri1->next)
1353 for (ri2 = ri1->next; ri2; ri2 = ri2->next)
1354 {
1355 if (CHECK_FLAG (ri2->flags, BGP_INFO_DMED_CHECK))
1356 continue;
1357 if (BGP_INFO_HOLDDOWN (ri2))
1358 continue;
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001359 if (ri2->peer &&
1360 ri2->peer != bgp->peer_self &&
1361 !CHECK_FLAG (ri2->peer->sflags, PEER_STATUS_NSF_WAIT))
1362 if (ri2->peer->status != Established)
1363 continue;
paul718e3742002-12-13 20:15:29 +00001364
1365 if (aspath_cmp_left (ri1->attr->aspath, ri2->attr->aspath)
1366 || aspath_cmp_left_confed (ri1->attr->aspath,
1367 ri2->attr->aspath))
1368 {
Josh Bailey6918e742011-07-20 20:48:20 -07001369 if (CHECK_FLAG (ri2->flags, BGP_INFO_SELECTED))
1370 old_select = ri2;
Paul Jakma6d4742b2015-11-25 17:14:37 +00001371 if ((cmpret = bgp_info_cmp (bgp, ri2, new_select, afi, safi))
1372 == -1)
paul718e3742002-12-13 20:15:29 +00001373 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001374 bgp_info_unset_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001375 new_select = ri2;
1376 }
1377
Paul Jakma6d4742b2015-11-25 17:14:37 +00001378 if (do_mpath)
1379 {
1380 if (cmpret != 0)
1381 bgp_mp_list_clear (&mp_list);
1382
1383 if (cmpret == 0 || cmpret == -1)
1384 bgp_mp_list_add (&mp_list, ri2);
1385 }
Josh Bailey6918e742011-07-20 20:48:20 -07001386
Paul Jakma1a392d42006-09-07 00:24:49 +00001387 bgp_info_set_flag (rn, ri2, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001388 }
1389 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001390 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_CHECK);
1391 bgp_info_set_flag (rn, new_select, BGP_INFO_DMED_SELECTED);
Josh Bailey6918e742011-07-20 20:48:20 -07001392
Paul Jakma6d4742b2015-11-25 17:14:37 +00001393 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey6918e742011-07-20 20:48:20 -07001394 bgp_mp_list_clear (&mp_list);
paul718e3742002-12-13 20:15:29 +00001395 }
1396
1397 /* Check old selected route and new selected route. */
1398 old_select = NULL;
1399 new_select = NULL;
paulb40d9392005-08-22 22:34:41 +00001400 for (ri = rn->info; (ri != NULL) && (nextri = ri->next, 1); ri = nextri)
paul718e3742002-12-13 20:15:29 +00001401 {
1402 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
1403 old_select = ri;
1404
1405 if (BGP_INFO_HOLDDOWN (ri))
paulb40d9392005-08-22 22:34:41 +00001406 {
1407 /* reap REMOVED routes, if needs be
1408 * selected route must stay for a while longer though
1409 */
1410 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
1411 && (ri != old_select))
1412 bgp_info_reap (rn, ri);
1413
1414 continue;
1415 }
paul718e3742002-12-13 20:15:29 +00001416
Dinesh G Dutt234e5c82015-02-01 00:56:12 -08001417 if (ri->peer &&
1418 ri->peer != bgp->peer_self &&
1419 !CHECK_FLAG (ri->peer->sflags, PEER_STATUS_NSF_WAIT))
1420 if (ri->peer->status != Established)
1421 continue;
1422
paul718e3742002-12-13 20:15:29 +00001423 if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED)
1424 && (! CHECK_FLAG (ri->flags, BGP_INFO_DMED_SELECTED)))
1425 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001426 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
paul718e3742002-12-13 20:15:29 +00001427 continue;
1428 }
Paul Jakma1a392d42006-09-07 00:24:49 +00001429 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_CHECK);
1430 bgp_info_unset_flag (rn, ri, BGP_INFO_DMED_SELECTED);
paul718e3742002-12-13 20:15:29 +00001431
Paul Jakma6d4742b2015-11-25 17:14:37 +00001432 if ((cmpret = bgp_info_cmp (bgp, ri, new_select, afi, safi)) == -1)
Josh Bailey96450fa2011-07-20 20:45:12 -07001433 {
Josh Bailey6918e742011-07-20 20:48:20 -07001434 if (do_mpath && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
1435 bgp_mp_dmed_deselect (new_select);
1436
Josh Bailey96450fa2011-07-20 20:45:12 -07001437 new_select = ri;
Josh Bailey96450fa2011-07-20 20:45:12 -07001438 }
Paul Jakma6d4742b2015-11-25 17:14:37 +00001439 else if (cmpret == 1 && do_mpath
1440 && bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Josh Bailey6918e742011-07-20 20:48:20 -07001441 bgp_mp_dmed_deselect (ri);
Josh Bailey96450fa2011-07-20 20:45:12 -07001442
Paul Jakma6d4742b2015-11-25 17:14:37 +00001443 if (do_mpath)
1444 {
1445 if (cmpret != 0)
1446 bgp_mp_list_clear (&mp_list);
1447
1448 if (cmpret == 0 || cmpret == -1)
1449 bgp_mp_list_add (&mp_list, ri);
1450 }
paul718e3742002-12-13 20:15:29 +00001451 }
paulfee0f4c2004-09-13 05:12:46 +00001452
Josh Bailey6918e742011-07-20 20:48:20 -07001453 if (!bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
Paul Jakma6d4742b2015-11-25 17:14:37 +00001454 bgp_info_mpath_update (rn, new_select, old_select, &mp_list, afi, safi);
Josh Bailey96450fa2011-07-20 20:45:12 -07001455
Josh Bailey0b597ef2011-07-20 20:49:11 -07001456 bgp_info_mpath_aggregate_update (new_select, old_select);
Josh Bailey96450fa2011-07-20 20:45:12 -07001457 bgp_mp_list_clear (&mp_list);
1458
1459 result->old = old_select;
1460 result->new = new_select;
1461
1462 return;
paulfee0f4c2004-09-13 05:12:46 +00001463}
1464
paul94f2b392005-06-28 12:44:16 +00001465static int
paulfee0f4c2004-09-13 05:12:46 +00001466bgp_process_announce_selected (struct peer *peer, struct bgp_info *selected,
Paul Jakma9eda90c2007-08-30 13:36:17 +00001467 struct bgp_node *rn, afi_t afi, safi_t safi)
1468{
paulfee0f4c2004-09-13 05:12:46 +00001469 struct prefix *p;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001470 struct attr attr;
1471 struct attr_extra extra;
paulfee0f4c2004-09-13 05:12:46 +00001472
Lou Berger050defe2016-01-12 13:41:59 -05001473 memset (&attr, 0, sizeof(struct attr));
1474 memset (&extra, 0, sizeof(struct attr_extra));
1475
paulfee0f4c2004-09-13 05:12:46 +00001476 p = &rn->p;
1477
Paul Jakma9eda90c2007-08-30 13:36:17 +00001478 /* Announce route to Established peer. */
1479 if (peer->status != Established)
paulfee0f4c2004-09-13 05:12:46 +00001480 return 0;
1481
Paul Jakma9eda90c2007-08-30 13:36:17 +00001482 /* Address family configuration check. */
1483 if (! peer->afc_nego[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001484 return 0;
1485
Paul Jakma9eda90c2007-08-30 13:36:17 +00001486 /* First update is deferred until ORF or ROUTE-REFRESH is received */
paulfee0f4c2004-09-13 05:12:46 +00001487 if (CHECK_FLAG (peer->af_sflags[afi][safi],
1488 PEER_STATUS_ORF_WAIT_REFRESH))
1489 return 0;
1490
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001491 /* It's initialized in bgp_announce_[check|check_rsclient]() */
1492 attr.extra = &extra;
1493
Avneesh Sachdev67174042012-08-17 08:19:49 -07001494 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001495 {
1496 case BGP_TABLE_MAIN:
1497 /* Announcement to peer->conf. If the route is filtered,
1498 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001499 if (selected && bgp_announce_check (selected, peer, p, &attr, afi, safi))
1500 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
paulfee0f4c2004-09-13 05:12:46 +00001501 else
1502 bgp_adj_out_unset (rn, peer, p, afi, safi);
1503 break;
1504 case BGP_TABLE_RSCLIENT:
1505 /* Announcement to peer->conf. If the route is filtered,
1506 withdraw it. */
Paul Jakma9eda90c2007-08-30 13:36:17 +00001507 if (selected &&
1508 bgp_announce_check_rsclient (selected, peer, p, &attr, afi, safi))
1509 bgp_adj_out_set (rn, peer, p, &attr, afi, safi, selected);
1510 else
1511 bgp_adj_out_unset (rn, peer, p, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001512 break;
1513 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001514
Lou Berger050defe2016-01-12 13:41:59 -05001515 bgp_attr_flush (&attr);
paulfee0f4c2004-09-13 05:12:46 +00001516 return 0;
paul200df112005-06-01 11:17:05 +00001517}
paulfee0f4c2004-09-13 05:12:46 +00001518
paul200df112005-06-01 11:17:05 +00001519struct bgp_process_queue
paulfee0f4c2004-09-13 05:12:46 +00001520{
paul200df112005-06-01 11:17:05 +00001521 struct bgp *bgp;
1522 struct bgp_node *rn;
1523 afi_t afi;
1524 safi_t safi;
1525};
1526
1527static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001528bgp_process_rsclient (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001529{
paul0fb58d52005-11-14 14:31:49 +00001530 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001531 struct bgp *bgp = pq->bgp;
1532 struct bgp_node *rn = pq->rn;
1533 afi_t afi = pq->afi;
1534 safi_t safi = pq->safi;
paulfee0f4c2004-09-13 05:12:46 +00001535 struct bgp_info *new_select;
1536 struct bgp_info *old_select;
1537 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001538 struct listnode *node, *nnode;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001539 struct peer *rsclient = bgp_node_table (rn)->owner;
paul200df112005-06-01 11:17:05 +00001540
paulfee0f4c2004-09-13 05:12:46 +00001541 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001542 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001543 new_select = old_and_new.new;
1544 old_select = old_and_new.old;
1545
paul200df112005-06-01 11:17:05 +00001546 if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
1547 {
Chris Caputo228da422009-07-18 05:44:03 +00001548 if (rsclient->group)
1549 for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, rsclient))
1550 {
1551 /* Nothing to do. */
1552 if (old_select && old_select == new_select)
1553 if (!CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
1554 continue;
paulfee0f4c2004-09-13 05:12:46 +00001555
Chris Caputo228da422009-07-18 05:44:03 +00001556 if (old_select)
1557 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
1558 if (new_select)
1559 {
1560 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1561 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001562 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
1563 }
paulfee0f4c2004-09-13 05:12:46 +00001564
Chris Caputo228da422009-07-18 05:44:03 +00001565 bgp_process_announce_selected (rsclient, new_select, rn,
1566 afi, safi);
1567 }
paul200df112005-06-01 11:17:05 +00001568 }
1569 else
1570 {
hassob7395792005-08-26 12:58:38 +00001571 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001572 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hassob7395792005-08-26 12:58:38 +00001573 if (new_select)
1574 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001575 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1576 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001577 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hassob7395792005-08-26 12:58:38 +00001578 }
Paul Jakma9eda90c2007-08-30 13:36:17 +00001579 bgp_process_announce_selected (rsclient, new_select, rn, afi, safi);
paul200df112005-06-01 11:17:05 +00001580 }
paulfee0f4c2004-09-13 05:12:46 +00001581
paulb40d9392005-08-22 22:34:41 +00001582 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1583 bgp_info_reap (rn, old_select);
1584
paul200df112005-06-01 11:17:05 +00001585 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1586 return WQ_SUCCESS;
paulfee0f4c2004-09-13 05:12:46 +00001587}
1588
paul200df112005-06-01 11:17:05 +00001589static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00001590bgp_process_main (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001591{
paul0fb58d52005-11-14 14:31:49 +00001592 struct bgp_process_queue *pq = data;
paul200df112005-06-01 11:17:05 +00001593 struct bgp *bgp = pq->bgp;
1594 struct bgp_node *rn = pq->rn;
1595 afi_t afi = pq->afi;
1596 safi_t safi = pq->safi;
1597 struct prefix *p = &rn->p;
paulfee0f4c2004-09-13 05:12:46 +00001598 struct bgp_info *new_select;
1599 struct bgp_info *old_select;
1600 struct bgp_info_pair old_and_new;
paul1eb8ef22005-04-07 07:30:20 +00001601 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00001602 struct peer *peer;
Paul Jakmafb982c22007-05-04 20:15:47 +00001603
paulfee0f4c2004-09-13 05:12:46 +00001604 /* Best path selection. */
Paul Jakma6d4742b2015-11-25 17:14:37 +00001605 bgp_best_selection (bgp, rn, &old_and_new, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00001606 old_select = old_and_new.old;
1607 new_select = old_and_new.new;
1608
1609 /* Nothing to do. */
1610 if (old_select && old_select == new_select)
1611 {
1612 if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
paul200df112005-06-01 11:17:05 +00001613 {
Josh Bailey8196f132011-07-20 20:47:07 -07001614 if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED) ||
1615 CHECK_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG))
G.Balaji5a616c02011-11-26 21:58:42 +04001616 bgp_zebra_announce (p, old_select, bgp, safi);
paul200df112005-06-01 11:17:05 +00001617
Josh Bailey8196f132011-07-20 20:47:07 -07001618 UNSET_FLAG (old_select->flags, BGP_INFO_MULTIPATH_CHG);
paul200df112005-06-01 11:17:05 +00001619 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1620 return WQ_SUCCESS;
1621 }
paulfee0f4c2004-09-13 05:12:46 +00001622 }
paul718e3742002-12-13 20:15:29 +00001623
hasso338b3422005-02-23 14:27:24 +00001624 if (old_select)
Paul Jakma1a392d42006-09-07 00:24:49 +00001625 bgp_info_unset_flag (rn, old_select, BGP_INFO_SELECTED);
hasso338b3422005-02-23 14:27:24 +00001626 if (new_select)
1627 {
Paul Jakma1a392d42006-09-07 00:24:49 +00001628 bgp_info_set_flag (rn, new_select, BGP_INFO_SELECTED);
1629 bgp_info_unset_flag (rn, new_select, BGP_INFO_ATTR_CHANGED);
Josh Bailey8196f132011-07-20 20:47:07 -07001630 UNSET_FLAG (new_select->flags, BGP_INFO_MULTIPATH_CHG);
hasso338b3422005-02-23 14:27:24 +00001631 }
1632
1633
paul718e3742002-12-13 20:15:29 +00001634 /* Check each BGP peer. */
paul1eb8ef22005-04-07 07:30:20 +00001635 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00001636 {
Paul Jakma9eda90c2007-08-30 13:36:17 +00001637 bgp_process_announce_selected (peer, new_select, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001638 }
1639
1640 /* FIB update. */
G.Balaji5a616c02011-11-26 21:58:42 +04001641 if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
1642 ! bgp_option_check (BGP_OPT_NO_FIB)))
paul718e3742002-12-13 20:15:29 +00001643 {
1644 if (new_select
1645 && new_select->type == ZEBRA_ROUTE_BGP
1646 && new_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001647 bgp_zebra_announce (p, new_select, bgp, safi);
paul718e3742002-12-13 20:15:29 +00001648 else
1649 {
1650 /* Withdraw the route from the kernel. */
1651 if (old_select
1652 && old_select->type == ZEBRA_ROUTE_BGP
1653 && old_select->sub_type == BGP_ROUTE_NORMAL)
G.Balaji5a616c02011-11-26 21:58:42 +04001654 bgp_zebra_withdraw (p, old_select, safi);
paul718e3742002-12-13 20:15:29 +00001655 }
1656 }
paulb40d9392005-08-22 22:34:41 +00001657
Lou Berger050defe2016-01-12 13:41:59 -05001658 /* Reap old select bgp_info, if it has been removed */
paulb40d9392005-08-22 22:34:41 +00001659 if (old_select && CHECK_FLAG (old_select->flags, BGP_INFO_REMOVED))
1660 bgp_info_reap (rn, old_select);
1661
paul200df112005-06-01 11:17:05 +00001662 UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
1663 return WQ_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001664}
1665
paul200df112005-06-01 11:17:05 +00001666static void
paul0fb58d52005-11-14 14:31:49 +00001667bgp_processq_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00001668{
paul0fb58d52005-11-14 14:31:49 +00001669 struct bgp_process_queue *pq = data;
Avneesh Sachdev67174042012-08-17 08:19:49 -07001670 struct bgp_table *table = bgp_node_table (pq->rn);
paul0fb58d52005-11-14 14:31:49 +00001671
Chris Caputo228da422009-07-18 05:44:03 +00001672 bgp_unlock (pq->bgp);
paul200df112005-06-01 11:17:05 +00001673 bgp_unlock_node (pq->rn);
Chris Caputo228da422009-07-18 05:44:03 +00001674 bgp_table_unlock (table);
paul200df112005-06-01 11:17:05 +00001675 XFREE (MTYPE_BGP_PROCESS_QUEUE, pq);
1676}
1677
1678static void
1679bgp_process_queue_init (void)
1680{
1681 bm->process_main_queue
1682 = work_queue_new (bm->master, "process_main_queue");
1683 bm->process_rsclient_queue
1684 = work_queue_new (bm->master, "process_rsclient_queue");
1685
1686 if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
1687 {
1688 zlog_err ("%s: Failed to allocate work queue", __func__);
1689 exit (1);
1690 }
1691
1692 bm->process_main_queue->spec.workfunc = &bgp_process_main;
paul200df112005-06-01 11:17:05 +00001693 bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
Paul Jakma838bbde2010-01-08 14:05:32 +00001694 bm->process_main_queue->spec.max_retries = 0;
1695 bm->process_main_queue->spec.hold = 50;
1696
Paul Jakma838bbde2010-01-08 14:05:32 +00001697 bm->process_rsclient_queue->spec.workfunc = &bgp_process_rsclient;
David Lamparterd43f8b32015-03-03 08:54:54 +01001698 bm->process_rsclient_queue->spec.del_item_data = &bgp_processq_del;
1699 bm->process_rsclient_queue->spec.max_retries = 0;
1700 bm->process_rsclient_queue->spec.hold = 50;
paul200df112005-06-01 11:17:05 +00001701}
1702
1703void
paulfee0f4c2004-09-13 05:12:46 +00001704bgp_process (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
1705{
paul200df112005-06-01 11:17:05 +00001706 struct bgp_process_queue *pqnode;
1707
1708 /* already scheduled for processing? */
1709 if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
1710 return;
1711
Paul Jakma91b9e852015-12-01 14:32:11 +00001712 if (rn->info == NULL)
1713 {
1714 /* XXX: Perhaps remove before next release, after we've flushed out
1715 * any obvious cases
1716 */
1717 assert (rn->info != NULL);
1718 char buf[PREFIX_STRLEN];
1719 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1720 __func__,
1721 prefix2str (&(bgp_node_to_rnode (rn)->p), buf, sizeof(buf)));
1722 return;
1723 }
1724
paul200df112005-06-01 11:17:05 +00001725 if ( (bm->process_main_queue == NULL) ||
1726 (bm->process_rsclient_queue == NULL) )
1727 bgp_process_queue_init ();
1728
1729 pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
1730 sizeof (struct bgp_process_queue));
1731 if (!pqnode)
1732 return;
Chris Caputo228da422009-07-18 05:44:03 +00001733
1734 /* all unlocked in bgp_processq_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07001735 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00001736 pqnode->rn = bgp_lock_node (rn);
paul200df112005-06-01 11:17:05 +00001737 pqnode->bgp = bgp;
Chris Caputo228da422009-07-18 05:44:03 +00001738 bgp_lock (bgp);
paul200df112005-06-01 11:17:05 +00001739 pqnode->afi = afi;
1740 pqnode->safi = safi;
1741
Avneesh Sachdev67174042012-08-17 08:19:49 -07001742 switch (bgp_node_table (rn)->type)
paulfee0f4c2004-09-13 05:12:46 +00001743 {
paul200df112005-06-01 11:17:05 +00001744 case BGP_TABLE_MAIN:
1745 work_queue_add (bm->process_main_queue, pqnode);
1746 break;
1747 case BGP_TABLE_RSCLIENT:
1748 work_queue_add (bm->process_rsclient_queue, pqnode);
1749 break;
paulfee0f4c2004-09-13 05:12:46 +00001750 }
paul200df112005-06-01 11:17:05 +00001751
Stephen Hemminger07ff4dc2013-01-04 22:29:20 +00001752 SET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
paul200df112005-06-01 11:17:05 +00001753 return;
paulfee0f4c2004-09-13 05:12:46 +00001754}
hasso0a486e52005-02-01 20:57:17 +00001755
paul94f2b392005-06-28 12:44:16 +00001756static int
hasso0a486e52005-02-01 20:57:17 +00001757bgp_maximum_prefix_restart_timer (struct thread *thread)
1758{
1759 struct peer *peer;
1760
1761 peer = THREAD_ARG (thread);
1762 peer->t_pmax_restart = NULL;
1763
1764 if (BGP_DEBUG (events, EVENTS))
1765 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1766 peer->host);
1767
1768 peer_clear (peer);
1769
1770 return 0;
1771}
1772
paulfee0f4c2004-09-13 05:12:46 +00001773int
paul5228ad22004-06-04 17:58:18 +00001774bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi,
1775 safi_t safi, int always)
paul718e3742002-12-13 20:15:29 +00001776{
hassoe0701b72004-05-20 09:19:34 +00001777 if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
1778 return 0;
1779
1780 if (peer->pcount[afi][safi] > peer->pmax[afi][safi])
paul718e3742002-12-13 20:15:29 +00001781 {
hassoe0701b72004-05-20 09:19:34 +00001782 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT)
1783 && ! always)
1784 return 0;
paul718e3742002-12-13 20:15:29 +00001785
hassoe0701b72004-05-20 09:19:34 +00001786 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001787 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1788 "limit %ld", afi_safi_print (afi, safi), peer->host,
1789 peer->pcount[afi][safi], peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001790 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
paul718e3742002-12-13 20:15:29 +00001791
hassoe0701b72004-05-20 09:19:34 +00001792 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
1793 return 0;
paul718e3742002-12-13 20:15:29 +00001794
hassoe0701b72004-05-20 09:19:34 +00001795 {
paul5228ad22004-06-04 17:58:18 +00001796 u_int8_t ndata[7];
hassoe0701b72004-05-20 09:19:34 +00001797
1798 if (safi == SAFI_MPLS_VPN)
Denis Ovsienko42e6d742011-07-14 12:36:19 +04001799 safi = SAFI_MPLS_LABELED_VPN;
paul5228ad22004-06-04 17:58:18 +00001800
1801 ndata[0] = (afi >> 8);
1802 ndata[1] = afi;
1803 ndata[2] = safi;
1804 ndata[3] = (peer->pmax[afi][safi] >> 24);
1805 ndata[4] = (peer->pmax[afi][safi] >> 16);
1806 ndata[5] = (peer->pmax[afi][safi] >> 8);
1807 ndata[6] = (peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001808
1809 SET_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW);
1810 bgp_notify_send_with_data (peer, BGP_NOTIFY_CEASE,
1811 BGP_NOTIFY_CEASE_MAX_PREFIX, ndata, 7);
1812 }
hasso0a486e52005-02-01 20:57:17 +00001813
1814 /* restart timer start */
1815 if (peer->pmax_restart[afi][safi])
1816 {
1817 peer->v_pmax_restart = peer->pmax_restart[afi][safi] * 60;
1818
1819 if (BGP_DEBUG (events, EVENTS))
1820 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1821 peer->host, peer->v_pmax_restart);
1822
1823 BGP_TIMER_ON (peer->t_pmax_restart, bgp_maximum_prefix_restart_timer,
1824 peer->v_pmax_restart);
1825 }
1826
hassoe0701b72004-05-20 09:19:34 +00001827 return 1;
paul718e3742002-12-13 20:15:29 +00001828 }
hassoe0701b72004-05-20 09:19:34 +00001829 else
1830 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_LIMIT);
1831
1832 if (peer->pcount[afi][safi] > (peer->pmax[afi][safi] * peer->pmax_threshold[afi][safi] / 100))
1833 {
1834 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD)
1835 && ! always)
1836 return 0;
1837
1838 zlog (peer->log, LOG_INFO,
hasso0a486e52005-02-01 20:57:17 +00001839 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1840 afi_safi_print (afi, safi), peer->host, peer->pcount[afi][safi],
1841 peer->pmax[afi][safi]);
hassoe0701b72004-05-20 09:19:34 +00001842 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
1843 }
1844 else
1845 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_PREFIX_THRESHOLD);
paul718e3742002-12-13 20:15:29 +00001846 return 0;
1847}
1848
paulb40d9392005-08-22 22:34:41 +00001849/* Unconditionally remove the route from the RIB, without taking
1850 * damping into consideration (eg, because the session went down)
1851 */
paul94f2b392005-06-28 12:44:16 +00001852static void
paul718e3742002-12-13 20:15:29 +00001853bgp_rib_remove (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
1854 afi_t afi, safi_t safi)
1855{
paul902212c2006-02-05 17:51:19 +00001856 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1857
1858 if (!CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
1859 bgp_info_delete (rn, ri); /* keep historical info */
1860
paulb40d9392005-08-22 22:34:41 +00001861 bgp_process (peer->bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00001862}
1863
paul94f2b392005-06-28 12:44:16 +00001864static void
paul718e3742002-12-13 20:15:29 +00001865bgp_rib_withdraw (struct bgp_node *rn, struct bgp_info *ri, struct peer *peer,
Lou Berger050defe2016-01-12 13:41:59 -05001866 afi_t afi, safi_t safi, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00001867{
paul718e3742002-12-13 20:15:29 +00001868 int status = BGP_DAMP_NONE;
1869
paulb40d9392005-08-22 22:34:41 +00001870 /* apply dampening, if result is suppressed, we'll be retaining
1871 * the bgp_info in the RIB for historical reference.
1872 */
1873 if (CHECK_FLAG (peer->bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00001874 && peer->sort == BGP_PEER_EBGP)
paulb40d9392005-08-22 22:34:41 +00001875 if ( (status = bgp_damp_withdraw (ri, rn, afi, safi, 0))
1876 == BGP_DAMP_SUPPRESSED)
paul902212c2006-02-05 17:51:19 +00001877 {
paul902212c2006-02-05 17:51:19 +00001878 bgp_aggregate_decrement (peer->bgp, &rn->p, ri, afi, safi);
1879 return;
1880 }
1881
1882 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00001883}
1884
paul94f2b392005-06-28 12:44:16 +00001885static void
paulfee0f4c2004-09-13 05:12:46 +00001886bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
1887 struct attr *attr, struct peer *peer, struct prefix *p, int type,
1888 int sub_type, struct prefix_rd *prd, u_char *tag)
1889{
1890 struct bgp_node *rn;
1891 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001892 struct attr new_attr;
1893 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00001894 struct attr *attr_new;
1895 struct attr *attr_new2;
1896 struct bgp_info *ri;
1897 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00001898 const char *reason;
paulfee0f4c2004-09-13 05:12:46 +00001899 char buf[SU_ADDRSTRLEN];
1900
1901 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1902 if (peer == rsclient)
1903 return;
1904
1905 bgp = peer->bgp;
1906 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
1907
1908 /* Check previously received route. */
1909 for (ri = rn->info; ri; ri = ri->next)
1910 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
1911 break;
1912
1913 /* AS path loop check. */
Milan Kocian000e1572013-10-18 07:59:38 +00001914 if (aspath_loop_check (attr->aspath, rsclient->as) > rsclient->allowas_in[afi][safi])
paulfee0f4c2004-09-13 05:12:46 +00001915 {
1916 reason = "as-path contains our own AS;";
1917 goto filtered;
1918 }
1919
1920 /* Route reflector originator ID check. */
1921 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00001922 && IPV4_ADDR_SAME (&rsclient->remote_id, &attr->extra->originator_id))
paulfee0f4c2004-09-13 05:12:46 +00001923 {
1924 reason = "originator is us;";
1925 goto filtered;
1926 }
Paul Jakmafb982c22007-05-04 20:15:47 +00001927
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001928 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00001929 bgp_attr_dup (&new_attr, attr);
paulfee0f4c2004-09-13 05:12:46 +00001930
1931 /* Apply export policy. */
1932 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) &&
1933 bgp_export_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1934 {
1935 reason = "export-policy;";
1936 goto filtered;
1937 }
1938
1939 attr_new2 = bgp_attr_intern (&new_attr);
Paul Jakmafb982c22007-05-04 20:15:47 +00001940
paulfee0f4c2004-09-13 05:12:46 +00001941 /* Apply import policy. */
1942 if (bgp_import_modifier (rsclient, peer, p, &new_attr, afi, safi) == RMAP_DENY)
1943 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001944 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001945
1946 reason = "import-policy;";
1947 goto filtered;
1948 }
1949
1950 attr_new = bgp_attr_intern (&new_attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001951 bgp_attr_unintern (&attr_new2);
paulfee0f4c2004-09-13 05:12:46 +00001952
1953 /* IPv4 unicast next hop check. */
G.Balaji5a616c02011-11-26 21:58:42 +04001954 if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
paulfee0f4c2004-09-13 05:12:46 +00001955 {
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001956 /* Next hop must not be 0.0.0.0 nor Class D/E address. */
paulfee0f4c2004-09-13 05:12:46 +00001957 if (new_attr.nexthop.s_addr == 0
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04001958 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)))
paulfee0f4c2004-09-13 05:12:46 +00001959 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001960 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00001961
1962 reason = "martian next-hop;";
1963 goto filtered;
1964 }
1965 }
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00001966
paulfee0f4c2004-09-13 05:12:46 +00001967 /* If the update is implicit withdraw. */
1968 if (ri)
1969 {
Stephen Hemminger65957882010-01-15 16:22:10 +03001970 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00001971
1972 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00001973 if (!CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)
1974 && attrhash_cmp (ri->attr, attr_new))
paulfee0f4c2004-09-13 05:12:46 +00001975 {
1976
Paul Jakma1a392d42006-09-07 00:24:49 +00001977 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00001978
1979 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001980 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00001981 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1982 peer->host,
1983 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
1984 p->prefixlen, rsclient->host);
1985
Chris Caputo228da422009-07-18 05:44:03 +00001986 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00001987 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05001988 bgp_attr_flush(&new_attr);
Chris Caputo228da422009-07-18 05:44:03 +00001989 return;
paulfee0f4c2004-09-13 05:12:46 +00001990 }
1991
Paul Jakma16d2e242007-04-10 19:32:10 +00001992 /* Withdraw/Announce before we fully processed the withdraw */
1993 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
1994 bgp_info_restore (rn, ri);
1995
paulfee0f4c2004-09-13 05:12:46 +00001996 /* Received Logging. */
1997 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00001998 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00001999 peer->host,
2000 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2001 p->prefixlen, rsclient->host);
2002
2003 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002004 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00002005
2006 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002007 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00002008 ri->attr = attr_new;
2009
2010 /* Update MPLS tag. */
2011 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002012 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002013
Paul Jakma1a392d42006-09-07 00:24:49 +00002014 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002015
2016 /* Process change. */
2017 bgp_process (bgp, rn, afi, safi);
2018 bgp_unlock_node (rn);
2019
2020 return;
2021 }
2022
2023 /* Received Logging. */
2024 if (BGP_DEBUG (update, UPDATE_IN))
2025 {
ajsd2c1f162004-12-08 21:10:20 +00002026 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d for RS-client %s",
paulfee0f4c2004-09-13 05:12:46 +00002027 peer->host,
2028 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2029 p->prefixlen, rsclient->host);
2030 }
2031
2032 /* Make new BGP info. */
2033 new = bgp_info_new ();
2034 new->type = type;
2035 new->sub_type = sub_type;
2036 new->peer = peer;
2037 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002038 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00002039
2040 /* Update MPLS tag. */
2041 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002042 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paulfee0f4c2004-09-13 05:12:46 +00002043
Paul Jakma1a392d42006-09-07 00:24:49 +00002044 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paulfee0f4c2004-09-13 05:12:46 +00002045
2046 /* Register new BGP information. */
2047 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002048
2049 /* route_node_get lock */
2050 bgp_unlock_node (rn);
2051
paulfee0f4c2004-09-13 05:12:46 +00002052 /* Process change. */
2053 bgp_process (bgp, rn, afi, safi);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002054
paulfee0f4c2004-09-13 05:12:46 +00002055 return;
2056
2057 filtered:
2058
2059 /* This BGP update is filtered. Log the reason then update BGP entry. */
2060 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002061 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002062 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
2063 peer->host,
2064 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2065 p->prefixlen, rsclient->host, reason);
2066
2067 if (ri)
paulb40d9392005-08-22 22:34:41 +00002068 bgp_rib_remove (rn, ri, peer, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00002069
2070 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002071
paulfee0f4c2004-09-13 05:12:46 +00002072 return;
2073}
2074
paul94f2b392005-06-28 12:44:16 +00002075static void
paulfee0f4c2004-09-13 05:12:46 +00002076bgp_withdraw_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
2077 struct peer *peer, struct prefix *p, int type, int sub_type,
2078 struct prefix_rd *prd, u_char *tag)
Chris Caputo228da422009-07-18 05:44:03 +00002079{
paulfee0f4c2004-09-13 05:12:46 +00002080 struct bgp_node *rn;
2081 struct bgp_info *ri;
2082 char buf[SU_ADDRSTRLEN];
2083
2084 if (rsclient == peer)
Chris Caputo228da422009-07-18 05:44:03 +00002085 return;
paulfee0f4c2004-09-13 05:12:46 +00002086
2087 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, prd);
2088
2089 /* Lookup withdrawn route. */
2090 for (ri = rn->info; ri; ri = ri->next)
2091 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2092 break;
2093
2094 /* Withdraw specified route from routing table. */
2095 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002096 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paulfee0f4c2004-09-13 05:12:46 +00002097 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002098 zlog (peer->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00002099 "%s Can't find the route %s/%d", peer->host,
2100 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2101 p->prefixlen);
2102
2103 /* Unlock bgp_node_get() lock. */
Chris Caputo228da422009-07-18 05:44:03 +00002104 bgp_unlock_node (rn);
2105}
paulfee0f4c2004-09-13 05:12:46 +00002106
paul94f2b392005-06-28 12:44:16 +00002107static int
paulfee0f4c2004-09-13 05:12:46 +00002108bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr,
paul718e3742002-12-13 20:15:29 +00002109 afi_t afi, safi_t safi, int type, int sub_type,
2110 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2111{
2112 int ret;
2113 int aspath_loop_count = 0;
2114 struct bgp_node *rn;
2115 struct bgp *bgp;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002116 struct attr new_attr;
2117 struct attr_extra new_extra;
paul718e3742002-12-13 20:15:29 +00002118 struct attr *attr_new;
2119 struct bgp_info *ri;
2120 struct bgp_info *new;
paulfd79ac92004-10-13 05:06:08 +00002121 const char *reason;
paul718e3742002-12-13 20:15:29 +00002122 char buf[SU_ADDRSTRLEN];
2123
2124 bgp = peer->bgp;
paulfee0f4c2004-09-13 05:12:46 +00002125 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
Paul Jakmafb982c22007-05-04 20:15:47 +00002126
paul718e3742002-12-13 20:15:29 +00002127 /* When peer's soft reconfiguration enabled. Record input packet in
2128 Adj-RIBs-In. */
Jorge Boncompte [DTI2]343aa822012-05-07 16:53:08 +00002129 if (! soft_reconfig && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2130 && peer != bgp->peer_self)
paul718e3742002-12-13 20:15:29 +00002131 bgp_adj_in_set (rn, peer, attr);
2132
2133 /* Check previously received route. */
2134 for (ri = rn->info; ri; ri = ri->next)
2135 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2136 break;
2137
2138 /* AS path local-as loop check. */
2139 if (peer->change_local_as)
2140 {
2141 if (! CHECK_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
2142 aspath_loop_count = 1;
2143
2144 if (aspath_loop_check (attr->aspath, peer->change_local_as) > aspath_loop_count)
2145 {
2146 reason = "as-path contains our own AS;";
2147 goto filtered;
2148 }
2149 }
2150
2151 /* AS path loop check. */
2152 if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
2153 || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
2154 && aspath_loop_check(attr->aspath, bgp->confed_id)
2155 > peer->allowas_in[afi][safi]))
2156 {
2157 reason = "as-path contains our own AS;";
2158 goto filtered;
2159 }
2160
2161 /* Route reflector originator ID check. */
2162 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)
Paul Jakmafb982c22007-05-04 20:15:47 +00002163 && IPV4_ADDR_SAME (&bgp->router_id, &attr->extra->originator_id))
paul718e3742002-12-13 20:15:29 +00002164 {
2165 reason = "originator is us;";
2166 goto filtered;
2167 }
2168
2169 /* Route reflector cluster ID check. */
2170 if (bgp_cluster_filter (peer, attr))
2171 {
2172 reason = "reflected from the same cluster;";
2173 goto filtered;
2174 }
2175
2176 /* Apply incoming filter. */
2177 if (bgp_input_filter (peer, p, attr, afi, safi) == FILTER_DENY)
2178 {
2179 reason = "filter;";
2180 goto filtered;
2181 }
2182
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002183 new_attr.extra = &new_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00002184 bgp_attr_dup (&new_attr, attr);
paul718e3742002-12-13 20:15:29 +00002185
David Lamparterc460e572014-06-04 00:54:58 +02002186 /* Apply incoming route-map.
2187 * NB: new_attr may now contain newly allocated values from route-map "set"
2188 * commands, so we need bgp_attr_flush in the error paths, until we intern
2189 * the attr (which takes over the memory references) */
paul718e3742002-12-13 20:15:29 +00002190 if (bgp_input_modifier (peer, p, &new_attr, afi, safi) == RMAP_DENY)
2191 {
2192 reason = "route-map;";
David Lamparterc460e572014-06-04 00:54:58 +02002193 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002194 goto filtered;
2195 }
2196
2197 /* IPv4 unicast next hop check. */
2198 if (afi == AFI_IP && safi == SAFI_UNICAST)
2199 {
2200 /* If the peer is EBGP and nexthop is not on connected route,
2201 discard it. */
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002202 if (peer->sort == BGP_PEER_EBGP && peer->ttl == 1
Denis Ovsienko8e80bdf2011-08-05 18:52:52 +04002203 && ! bgp_nexthop_onlink (afi, &new_attr)
hasso6ffd2072005-02-02 14:50:11 +00002204 && ! CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
paul718e3742002-12-13 20:15:29 +00002205 {
2206 reason = "non-connected next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002207 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002208 goto filtered;
2209 }
2210
Denis Ovsienko733cd9e2011-12-17 19:39:30 +04002211 /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop
paul718e3742002-12-13 20:15:29 +00002212 must not be my own address. */
Jorge Boncompte [DTI2]10f9bf32012-05-07 16:52:52 +00002213 if (new_attr.nexthop.s_addr == 0
2214 || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))
2215 || bgp_nexthop_self (&new_attr))
paul718e3742002-12-13 20:15:29 +00002216 {
2217 reason = "martian next-hop;";
David Lamparterc460e572014-06-04 00:54:58 +02002218 bgp_attr_flush (&new_attr);
paul718e3742002-12-13 20:15:29 +00002219 goto filtered;
2220 }
2221 }
2222
2223 attr_new = bgp_attr_intern (&new_attr);
2224
2225 /* If the update is implicit withdraw. */
2226 if (ri)
2227 {
Stephen Hemminger65957882010-01-15 16:22:10 +03002228 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002229
2230 /* Same attribute comes in. */
Paul Jakma16d2e242007-04-10 19:32:10 +00002231 if (!CHECK_FLAG (ri->flags, BGP_INFO_REMOVED)
2232 && attrhash_cmp (ri->attr, attr_new))
paul718e3742002-12-13 20:15:29 +00002233 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002234 bgp_info_unset_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00002235
2236 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002237 && peer->sort == BGP_PEER_EBGP
paul718e3742002-12-13 20:15:29 +00002238 && CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2239 {
2240 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002241 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002242 peer->host,
2243 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2244 p->prefixlen);
2245
paul902212c2006-02-05 17:51:19 +00002246 if (bgp_damp_update (ri, rn, afi, safi) != BGP_DAMP_SUPPRESSED)
2247 {
2248 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2249 bgp_process (bgp, rn, afi, safi);
2250 }
paul718e3742002-12-13 20:15:29 +00002251 }
Paul Jakma16d2e242007-04-10 19:32:10 +00002252 else /* Duplicate - odd */
paul718e3742002-12-13 20:15:29 +00002253 {
2254 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002255 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002256 "%s rcvd %s/%d...duplicate ignored",
2257 peer->host,
2258 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2259 p->prefixlen);
hasso93406d82005-02-02 14:40:33 +00002260
2261 /* graceful restart STALE flag unset. */
2262 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
2263 {
Paul Jakma1a392d42006-09-07 00:24:49 +00002264 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
paul902212c2006-02-05 17:51:19 +00002265 bgp_process (bgp, rn, afi, safi);
hasso93406d82005-02-02 14:40:33 +00002266 }
paul718e3742002-12-13 20:15:29 +00002267 }
2268
2269 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002270 bgp_attr_unintern (&attr_new);
Lou Berger050defe2016-01-12 13:41:59 -05002271 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002272
paul718e3742002-12-13 20:15:29 +00002273 return 0;
2274 }
2275
Paul Jakma16d2e242007-04-10 19:32:10 +00002276 /* Withdraw/Announce before we fully processed the withdraw */
2277 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
2278 {
2279 if (BGP_DEBUG (update, UPDATE_IN))
2280 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d, flapped quicker than processing",
2281 peer->host,
2282 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2283 p->prefixlen);
2284 bgp_info_restore (rn, ri);
2285 }
2286
paul718e3742002-12-13 20:15:29 +00002287 /* Received Logging. */
2288 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002289 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002290 peer->host,
2291 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2292 p->prefixlen);
2293
hasso93406d82005-02-02 14:40:33 +00002294 /* graceful restart STALE flag unset. */
2295 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma1a392d42006-09-07 00:24:49 +00002296 bgp_info_unset_flag (rn, ri, BGP_INFO_STALE);
hasso93406d82005-02-02 14:40:33 +00002297
paul718e3742002-12-13 20:15:29 +00002298 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00002299 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul902212c2006-02-05 17:51:19 +00002300
2301 /* implicit withdraw, decrement aggregate and pcount here.
2302 * only if update is accepted, they'll increment below.
2303 */
paul902212c2006-02-05 17:51:19 +00002304 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
2305
paul718e3742002-12-13 20:15:29 +00002306 /* Update bgp route dampening information. */
2307 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002308 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002309 {
2310 /* This is implicit withdraw so we should update dampening
2311 information. */
2312 if (! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
2313 bgp_damp_withdraw (ri, rn, afi, safi, 1);
paul718e3742002-12-13 20:15:29 +00002314 }
2315
paul718e3742002-12-13 20:15:29 +00002316 /* Update to new attribute. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002317 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00002318 ri->attr = attr_new;
2319
2320 /* Update MPLS tag. */
2321 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002322 memcpy ((bgp_info_extra_get (ri))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002323
Lou Berger050defe2016-01-12 13:41:59 -05002324 bgp_attr_flush (&new_attr);
2325
paul718e3742002-12-13 20:15:29 +00002326 /* Update bgp route dampening information. */
2327 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002328 && peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +00002329 {
2330 /* Now we do normal update dampening. */
2331 ret = bgp_damp_update (ri, rn, afi, safi);
2332 if (ret == BGP_DAMP_SUPPRESSED)
2333 {
2334 bgp_unlock_node (rn);
2335 return 0;
2336 }
2337 }
2338
2339 /* Nexthop reachability check. */
2340 if ((afi == AFI_IP || afi == AFI_IP6)
2341 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002342 && (peer->sort == BGP_PEER_IBGP
2343 || peer->sort == BGP_PEER_CONFED
2344 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002345 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002346 {
2347 if (bgp_nexthop_lookup (afi, peer, ri, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002348 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002349 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002350 bgp_info_unset_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002351 }
2352 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002353 bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002354
Lou Berger050defe2016-01-12 13:41:59 -05002355 bgp_attr_flush (&new_attr);
2356
paul718e3742002-12-13 20:15:29 +00002357 /* Process change. */
2358 bgp_aggregate_increment (bgp, p, ri, afi, safi);
2359
2360 bgp_process (bgp, rn, afi, safi);
2361 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002362
paul718e3742002-12-13 20:15:29 +00002363 return 0;
2364 }
2365
2366 /* Received Logging. */
2367 if (BGP_DEBUG (update, UPDATE_IN))
2368 {
ajsd2c1f162004-12-08 21:10:20 +00002369 zlog (peer->log, LOG_DEBUG, "%s rcvd %s/%d",
paul718e3742002-12-13 20:15:29 +00002370 peer->host,
2371 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2372 p->prefixlen);
2373 }
2374
paul718e3742002-12-13 20:15:29 +00002375 /* Make new BGP info. */
2376 new = bgp_info_new ();
2377 new->type = type;
2378 new->sub_type = sub_type;
2379 new->peer = peer;
2380 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03002381 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00002382
2383 /* Update MPLS tag. */
2384 if (safi == SAFI_MPLS_VPN)
Paul Jakmafb982c22007-05-04 20:15:47 +00002385 memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
paul718e3742002-12-13 20:15:29 +00002386
2387 /* Nexthop reachability check. */
2388 if ((afi == AFI_IP || afi == AFI_IP6)
2389 && safi == SAFI_UNICAST
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +00002390 && (peer->sort == BGP_PEER_IBGP
2391 || peer->sort == BGP_PEER_CONFED
2392 || (peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
hasso6ffd2072005-02-02 14:50:11 +00002393 || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK)))
paul718e3742002-12-13 20:15:29 +00002394 {
2395 if (bgp_nexthop_lookup (afi, peer, new, NULL, NULL))
Paul Jakma1a392d42006-09-07 00:24:49 +00002396 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002397 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002398 bgp_info_unset_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002399 }
2400 else
Paul Jakma1a392d42006-09-07 00:24:49 +00002401 bgp_info_set_flag (rn, new, BGP_INFO_VALID);
paul718e3742002-12-13 20:15:29 +00002402
paul902212c2006-02-05 17:51:19 +00002403 /* Increment prefix */
paul718e3742002-12-13 20:15:29 +00002404 bgp_aggregate_increment (bgp, p, new, afi, safi);
2405
2406 /* Register new BGP information. */
2407 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00002408
2409 /* route_node_get lock */
2410 bgp_unlock_node (rn);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002411
Lou Berger050defe2016-01-12 13:41:59 -05002412 bgp_attr_flush (&new_attr);
2413
paul718e3742002-12-13 20:15:29 +00002414 /* If maximum prefix count is configured and current prefix
2415 count exeed it. */
hassoe0701b72004-05-20 09:19:34 +00002416 if (bgp_maximum_prefix_overflow (peer, afi, safi, 0))
2417 return -1;
paul718e3742002-12-13 20:15:29 +00002418
2419 /* Process change. */
2420 bgp_process (bgp, rn, afi, safi);
2421
2422 return 0;
2423
2424 /* This BGP update is filtered. Log the reason then update BGP
2425 entry. */
2426 filtered:
2427 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002428 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002429 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2430 peer->host,
2431 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2432 p->prefixlen, reason);
2433
2434 if (ri)
paulb40d9392005-08-22 22:34:41 +00002435 bgp_rib_remove (rn, ri, peer, afi, safi);
paul718e3742002-12-13 20:15:29 +00002436
2437 bgp_unlock_node (rn);
Lou Berger050defe2016-01-12 13:41:59 -05002438 bgp_attr_flush (&new_attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002439
paul718e3742002-12-13 20:15:29 +00002440 return 0;
2441}
2442
2443int
paulfee0f4c2004-09-13 05:12:46 +00002444bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
2445 afi_t afi, safi_t safi, int type, int sub_type,
2446 struct prefix_rd *prd, u_char *tag, int soft_reconfig)
2447{
2448 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002449 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00002450 struct bgp *bgp;
2451 int ret;
2452
2453 ret = bgp_update_main (peer, p, attr, afi, safi, type, sub_type, prd, tag,
2454 soft_reconfig);
2455
2456 bgp = peer->bgp;
2457
2458 /* Process the update for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002459 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002460 {
2461 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2462 bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
2463 sub_type, prd, tag);
2464 }
2465
2466 return ret;
2467}
2468
2469int
paul718e3742002-12-13 20:15:29 +00002470bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
paul94f2b392005-06-28 12:44:16 +00002471 afi_t afi, safi_t safi, int type, int sub_type,
2472 struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00002473{
2474 struct bgp *bgp;
2475 char buf[SU_ADDRSTRLEN];
2476 struct bgp_node *rn;
2477 struct bgp_info *ri;
paulfee0f4c2004-09-13 05:12:46 +00002478 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00002479 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00002480
2481 bgp = peer->bgp;
2482
David Lamparter4584c232015-04-13 09:50:00 +02002483 /* Lookup node. */
2484 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
2485
2486 /* Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2487 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2488 * the iteration over all RS clients.
2489 * Since we need to remove the entry from adj_in anyway, do that first and
2490 * if there was no entry, we don't need to do anything more. */
2491 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
2492 && peer != bgp->peer_self)
2493 if (!bgp_adj_in_unset (rn, peer))
2494 {
2495 if (BGP_DEBUG (update, UPDATE_IN))
2496 zlog (peer->log, LOG_DEBUG, "%s withdrawing route %s/%d "
2497 "not in adj-in", peer->host,
2498 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2499 p->prefixlen);
2500 bgp_unlock_node (rn);
2501 return 0;
2502 }
2503
paulfee0f4c2004-09-13 05:12:46 +00002504 /* Process the withdraw for each RS-client. */
paul1eb8ef22005-04-07 07:30:20 +00002505 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00002506 {
2507 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2508 bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
2509 }
2510
paul718e3742002-12-13 20:15:29 +00002511 /* Logging. */
2512 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002513 zlog (peer->log, LOG_DEBUG, "%s rcvd UPDATE about %s/%d -- withdrawn",
paul718e3742002-12-13 20:15:29 +00002514 peer->host,
2515 inet_ntop(p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2516 p->prefixlen);
2517
paul718e3742002-12-13 20:15:29 +00002518 /* Lookup withdrawn route. */
2519 for (ri = rn->info; ri; ri = ri->next)
2520 if (ri->peer == peer && ri->type == type && ri->sub_type == sub_type)
2521 break;
2522
2523 /* Withdraw specified route from routing table. */
2524 if (ri && ! CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Lou Berger050defe2016-01-12 13:41:59 -05002525 bgp_rib_withdraw (rn, ri, peer, afi, safi, prd);
paul718e3742002-12-13 20:15:29 +00002526 else if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00002527 zlog (peer->log, LOG_DEBUG,
paul718e3742002-12-13 20:15:29 +00002528 "%s Can't find the route %s/%d", peer->host,
2529 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
2530 p->prefixlen);
2531
2532 /* Unlock bgp_node_get() lock. */
2533 bgp_unlock_node (rn);
2534
2535 return 0;
2536}
David Lamparter6b0655a2014-06-04 06:53:35 +02002537
paul718e3742002-12-13 20:15:29 +00002538void
2539bgp_default_originate (struct peer *peer, afi_t afi, safi_t safi, int withdraw)
2540{
2541 struct bgp *bgp;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00002542 struct attr attr;
Jorge Boncompte [DTI2]577ac572012-05-07 16:53:06 +00002543 struct aspath *aspath;
paul718e3742002-12-13 20:15:29 +00002544 struct prefix p;
paul718e3742002-12-13 20:15:29 +00002545 struct peer *from;
Christian Frankedcab1bb2012-12-07 16:45:52 +00002546 struct bgp_node *rn;
2547 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00002548 int ret = RMAP_DENYMATCH;
Paul Jakmafb982c22007-05-04 20:15:47 +00002549
Paul Jakmab2497022007-06-14 11:17:58 +00002550 if (!(afi == AFI_IP || afi == AFI_IP6))
Paul Jakmafb982c22007-05-04 20:15:47 +00002551 return;
2552
paul718e3742002-12-13 20:15:29 +00002553 bgp = peer->bgp;
2554 from = bgp->peer_self;
Paul Jakmafb982c22007-05-04 20:15:47 +00002555
paul718e3742002-12-13 20:15:29 +00002556 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
2557 aspath = attr.aspath;
2558 attr.local_pref = bgp->default_local_pref;
2559 memcpy (&attr.nexthop, &peer->nexthop.v4, IPV4_MAX_BYTELEN);
2560
2561 if (afi == AFI_IP)
2562 str2prefix ("0.0.0.0/0", &p);
paul718e3742002-12-13 20:15:29 +00002563 else if (afi == AFI_IP6)
2564 {
Jorge Boncompte [DTI2]6182d652012-05-07 16:53:02 +00002565 struct attr_extra *ae = attr.extra;
2566
paul718e3742002-12-13 20:15:29 +00002567 str2prefix ("::/0", &p);
2568
2569 /* IPv6 global nexthop must be included. */
Paul Jakmafb982c22007-05-04 20:15:47 +00002570 memcpy (&ae->mp_nexthop_global, &peer->nexthop.v6_global,
paul718e3742002-12-13 20:15:29 +00002571 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002572 ae->mp_nexthop_len = 16;
paul718e3742002-12-13 20:15:29 +00002573
2574 /* If the peer is on shared nextwork and we have link-local
2575 nexthop set it. */
2576 if (peer->shared_network
2577 && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local))
2578 {
Paul Jakmafb982c22007-05-04 20:15:47 +00002579 memcpy (&ae->mp_nexthop_local, &peer->nexthop.v6_local,
paul718e3742002-12-13 20:15:29 +00002580 IPV6_MAX_BYTELEN);
Paul Jakmafb982c22007-05-04 20:15:47 +00002581 ae->mp_nexthop_len = 32;
paul718e3742002-12-13 20:15:29 +00002582 }
2583 }
paul718e3742002-12-13 20:15:29 +00002584
2585 if (peer->default_rmap[afi][safi].name)
2586 {
paulfee0f4c2004-09-13 05:12:46 +00002587 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_DEFAULT);
Christian Frankedcab1bb2012-12-07 16:45:52 +00002588 for (rn = bgp_table_top(bgp->rib[afi][safi]); rn; rn = bgp_route_next(rn))
2589 {
2590 for (ri = rn->info; ri; ri = ri->next)
2591 {
2592 struct attr dummy_attr;
2593 struct attr_extra dummy_extra;
2594 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00002595
Christian Frankedcab1bb2012-12-07 16:45:52 +00002596 /* Provide dummy so the route-map can't modify the attributes */
2597 dummy_attr.extra = &dummy_extra;
2598 bgp_attr_dup(&dummy_attr, ri->attr);
2599 info.peer = ri->peer;
2600 info.attr = &dummy_attr;
paul718e3742002-12-13 20:15:29 +00002601
Christian Frankedcab1bb2012-12-07 16:45:52 +00002602 ret = route_map_apply(peer->default_rmap[afi][safi].map, &rn->p,
2603 RMAP_BGP, &info);
2604
2605 /* The route map might have set attributes. If we don't flush them
2606 * here, they will be leaked. */
2607 bgp_attr_flush(&dummy_attr);
2608 if (ret != RMAP_DENYMATCH)
2609 break;
2610 }
2611 if (ret != RMAP_DENYMATCH)
2612 break;
2613 }
paulfee0f4c2004-09-13 05:12:46 +00002614 bgp->peer_self->rmap_type = 0;
2615
paul718e3742002-12-13 20:15:29 +00002616 if (ret == RMAP_DENYMATCH)
Christian Frankedcab1bb2012-12-07 16:45:52 +00002617 withdraw = 1;
paul718e3742002-12-13 20:15:29 +00002618 }
2619
2620 if (withdraw)
2621 {
2622 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2623 bgp_default_withdraw_send (peer, afi, safi);
2624 UNSET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2625 }
2626 else
2627 {
Christian Frankedcab1bb2012-12-07 16:45:52 +00002628 if (! CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE))
2629 {
2630 SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_DEFAULT_ORIGINATE);
2631 bgp_default_update_send (peer, &attr, afi, safi, from);
2632 }
paul718e3742002-12-13 20:15:29 +00002633 }
Paul Jakmafb982c22007-05-04 20:15:47 +00002634
2635 bgp_attr_extra_free (&attr);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00002636 aspath_unintern (&aspath);
paul718e3742002-12-13 20:15:29 +00002637}
David Lamparter6b0655a2014-06-04 06:53:35 +02002638
paul718e3742002-12-13 20:15:29 +00002639static void
2640bgp_announce_table (struct peer *peer, afi_t afi, safi_t safi,
paulfee0f4c2004-09-13 05:12:46 +00002641 struct bgp_table *table, int rsclient)
paul718e3742002-12-13 20:15:29 +00002642{
2643 struct bgp_node *rn;
2644 struct bgp_info *ri;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002645 struct attr attr;
2646 struct attr_extra extra;
2647
Lou Berger298cc2f2016-01-12 13:42:02 -05002648 memset(&extra, 0, sizeof(extra));
2649
paul718e3742002-12-13 20:15:29 +00002650 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002651 table = (rsclient) ? peer->rib[afi][safi] : peer->bgp->rib[afi][safi];
paul718e3742002-12-13 20:15:29 +00002652
Lou Berger298cc2f2016-01-12 13:42:02 -05002653 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP)
paul718e3742002-12-13 20:15:29 +00002654 && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
2655 bgp_default_originate (peer, afi, safi, 0);
2656
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00002657 /* It's initialized in bgp_announce_[check|check_rsclient]() */
2658 attr.extra = &extra;
2659
paul718e3742002-12-13 20:15:29 +00002660 for (rn = bgp_table_top (table); rn; rn = bgp_route_next(rn))
2661 for (ri = rn->info; ri; ri = ri->next)
2662 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED) && ri->peer != peer)
2663 {
paulfee0f4c2004-09-13 05:12:46 +00002664 if ( (rsclient) ?
2665 (bgp_announce_check_rsclient (ri, peer, &rn->p, &attr, afi, safi))
2666 : (bgp_announce_check (ri, peer, &rn->p, &attr, afi, safi)))
paul718e3742002-12-13 20:15:29 +00002667 bgp_adj_out_set (rn, peer, &rn->p, &attr, afi, safi, ri);
2668 else
2669 bgp_adj_out_unset (rn, peer, &rn->p, afi, safi);
2670 }
Lou Berger298cc2f2016-01-12 13:42:02 -05002671
2672 bgp_attr_flush_encap(&attr);
paul718e3742002-12-13 20:15:29 +00002673}
2674
2675void
2676bgp_announce_route (struct peer *peer, afi_t afi, safi_t safi)
2677{
2678 struct bgp_node *rn;
2679 struct bgp_table *table;
2680
2681 if (peer->status != Established)
2682 return;
2683
2684 if (! peer->afc_nego[afi][safi])
2685 return;
2686
2687 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2688 if (CHECK_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
2689 return;
2690
Lou Berger298cc2f2016-01-12 13:42:02 -05002691 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
paulfee0f4c2004-09-13 05:12:46 +00002692 bgp_announce_table (peer, afi, safi, NULL, 0);
paul718e3742002-12-13 20:15:29 +00002693 else
2694 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2695 rn = bgp_route_next(rn))
2696 if ((table = (rn->info)) != NULL)
paulfee0f4c2004-09-13 05:12:46 +00002697 bgp_announce_table (peer, afi, safi, table, 0);
2698
2699 if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
2700 bgp_announce_table (peer, afi, safi, NULL, 1);
paul718e3742002-12-13 20:15:29 +00002701}
2702
2703void
2704bgp_announce_route_all (struct peer *peer)
2705{
2706 afi_t afi;
2707 safi_t safi;
2708
2709 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2710 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
2711 bgp_announce_route (peer, afi, safi);
2712}
David Lamparter6b0655a2014-06-04 06:53:35 +02002713
paul718e3742002-12-13 20:15:29 +00002714static void
paulfee0f4c2004-09-13 05:12:46 +00002715bgp_soft_reconfig_table_rsclient (struct peer *rsclient, afi_t afi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002716 safi_t safi, struct bgp_table *table, struct prefix_rd *prd)
paulfee0f4c2004-09-13 05:12:46 +00002717{
2718 struct bgp_node *rn;
2719 struct bgp_adj_in *ain;
2720
2721 if (! table)
2722 table = rsclient->bgp->rib[afi][safi];
2723
2724 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2725 for (ain = rn->adj_in; ain; ain = ain->next)
2726 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002727 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002728 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002729
paulfee0f4c2004-09-13 05:12:46 +00002730 bgp_update_rsclient (rsclient, afi, safi, ain->attr, ain->peer,
Christian Franked53d8fd2013-01-28 07:14:43 +01002731 &rn->p, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd, tag);
paulfee0f4c2004-09-13 05:12:46 +00002732 }
2733}
2734
2735void
2736bgp_soft_reconfig_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
2737{
2738 struct bgp_table *table;
2739 struct bgp_node *rn;
2740
Lou Berger298cc2f2016-01-12 13:42:02 -05002741 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002742 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, NULL, NULL);
paulfee0f4c2004-09-13 05:12:46 +00002743
2744 else
2745 for (rn = bgp_table_top (rsclient->bgp->rib[afi][safi]); rn;
2746 rn = bgp_route_next (rn))
2747 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002748 {
2749 struct prefix_rd prd;
2750 prd.family = AF_UNSPEC;
2751 prd.prefixlen = 64;
2752 memcpy(&prd.val, rn->p.u.val, 8);
2753
2754 bgp_soft_reconfig_table_rsclient (rsclient, afi, safi, table, &prd);
2755 }
paulfee0f4c2004-09-13 05:12:46 +00002756}
David Lamparter6b0655a2014-06-04 06:53:35 +02002757
paulfee0f4c2004-09-13 05:12:46 +00002758static void
paul718e3742002-12-13 20:15:29 +00002759bgp_soft_reconfig_table (struct peer *peer, afi_t afi, safi_t safi,
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002760 struct bgp_table *table, struct prefix_rd *prd)
paul718e3742002-12-13 20:15:29 +00002761{
2762 int ret;
2763 struct bgp_node *rn;
2764 struct bgp_adj_in *ain;
2765
2766 if (! table)
2767 table = peer->bgp->rib[afi][safi];
2768
2769 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2770 for (ain = rn->adj_in; ain; ain = ain->next)
2771 {
2772 if (ain->peer == peer)
2773 {
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002774 struct bgp_info *ri = rn->info;
Christian Franked53d8fd2013-01-28 07:14:43 +01002775 u_char *tag = (ri && ri->extra) ? ri->extra->tag : NULL;
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002776
paul718e3742002-12-13 20:15:29 +00002777 ret = bgp_update (peer, &rn->p, ain->attr, afi, safi,
2778 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
Christian Franked53d8fd2013-01-28 07:14:43 +01002779 prd, tag, 1);
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002780
paul718e3742002-12-13 20:15:29 +00002781 if (ret < 0)
2782 {
2783 bgp_unlock_node (rn);
2784 return;
2785 }
2786 continue;
2787 }
2788 }
2789}
2790
2791void
2792bgp_soft_reconfig_in (struct peer *peer, afi_t afi, safi_t safi)
2793{
2794 struct bgp_node *rn;
2795 struct bgp_table *table;
2796
2797 if (peer->status != Established)
2798 return;
2799
Lou Berger298cc2f2016-01-12 13:42:02 -05002800 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002801 bgp_soft_reconfig_table (peer, afi, safi, NULL, NULL);
paul718e3742002-12-13 20:15:29 +00002802 else
2803 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
2804 rn = bgp_route_next (rn))
2805 if ((table = rn->info) != NULL)
Jorge Boncompte [DTI2]8692c502012-05-07 15:17:34 +00002806 {
2807 struct prefix_rd prd;
2808 prd.family = AF_UNSPEC;
2809 prd.prefixlen = 64;
2810 memcpy(&prd.val, rn->p.u.val, 8);
2811
2812 bgp_soft_reconfig_table (peer, afi, safi, table, &prd);
2813 }
paul718e3742002-12-13 20:15:29 +00002814}
David Lamparter6b0655a2014-06-04 06:53:35 +02002815
Chris Caputo228da422009-07-18 05:44:03 +00002816
2817struct bgp_clear_node_queue
2818{
2819 struct bgp_node *rn;
2820 enum bgp_clear_route_type purpose;
2821};
2822
paul200df112005-06-01 11:17:05 +00002823static wq_item_status
paul0fb58d52005-11-14 14:31:49 +00002824bgp_clear_route_node (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002825{
Chris Caputo228da422009-07-18 05:44:03 +00002826 struct bgp_clear_node_queue *cnq = data;
2827 struct bgp_node *rn = cnq->rn;
Paul Jakma64e580a2006-02-21 01:09:01 +00002828 struct peer *peer = wq->spec.data;
paul200df112005-06-01 11:17:05 +00002829 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002830 afi_t afi = bgp_node_table (rn)->afi;
2831 safi_t safi = bgp_node_table (rn)->safi;
paul200df112005-06-01 11:17:05 +00002832
Paul Jakma64e580a2006-02-21 01:09:01 +00002833 assert (rn && peer);
paul200df112005-06-01 11:17:05 +00002834
Paul Jakma64e580a2006-02-21 01:09:01 +00002835 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002836 if (ri->peer == peer || cnq->purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
paul200df112005-06-01 11:17:05 +00002837 {
2838 /* graceful restart STALE flag set. */
Paul Jakma64e580a2006-02-21 01:09:01 +00002839 if (CHECK_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT)
2840 && peer->nsf[afi][safi]
paul200df112005-06-01 11:17:05 +00002841 && ! CHECK_FLAG (ri->flags, BGP_INFO_STALE)
Paul Jakma1a392d42006-09-07 00:24:49 +00002842 && ! CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
2843 bgp_info_set_flag (rn, ri, BGP_INFO_STALE);
paul200df112005-06-01 11:17:05 +00002844 else
Paul Jakma64e580a2006-02-21 01:09:01 +00002845 bgp_rib_remove (rn, ri, peer, afi, safi);
paul200df112005-06-01 11:17:05 +00002846 break;
2847 }
paul200df112005-06-01 11:17:05 +00002848 return WQ_SUCCESS;
2849}
2850
2851static void
paul0fb58d52005-11-14 14:31:49 +00002852bgp_clear_node_queue_del (struct work_queue *wq, void *data)
paul200df112005-06-01 11:17:05 +00002853{
Chris Caputo228da422009-07-18 05:44:03 +00002854 struct bgp_clear_node_queue *cnq = data;
2855 struct bgp_node *rn = cnq->rn;
Avneesh Sachdev67174042012-08-17 08:19:49 -07002856 struct bgp_table *table = bgp_node_table (rn);
Paul Jakma64e580a2006-02-21 01:09:01 +00002857
2858 bgp_unlock_node (rn);
Chris Caputo228da422009-07-18 05:44:03 +00002859 bgp_table_unlock (table);
2860 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE, cnq);
paul200df112005-06-01 11:17:05 +00002861}
2862
2863static void
paul94f2b392005-06-28 12:44:16 +00002864bgp_clear_node_complete (struct work_queue *wq)
paul200df112005-06-01 11:17:05 +00002865{
Paul Jakma64e580a2006-02-21 01:09:01 +00002866 struct peer *peer = wq->spec.data;
2867
Paul Jakma3e0c78e2006-03-06 18:06:53 +00002868 /* Tickle FSM to start moving again */
Paul Jakmaca058a32006-09-14 02:58:49 +00002869 BGP_EVENT_ADD (peer, Clearing_Completed);
Chris Caputo228da422009-07-18 05:44:03 +00002870
2871 peer_unlock (peer); /* bgp_clear_route */
paul200df112005-06-01 11:17:05 +00002872}
2873
2874static void
Paul Jakma64e580a2006-02-21 01:09:01 +00002875bgp_clear_node_queue_init (struct peer *peer)
paul200df112005-06-01 11:17:05 +00002876{
Paul Jakmaa2943652009-07-21 14:02:04 +01002877 char wname[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
Paul Jakma64e580a2006-02-21 01:09:01 +00002878
Paul Jakmaa2943652009-07-21 14:02:04 +01002879 snprintf (wname, sizeof(wname), "clear %s", peer->host);
Paul Jakma64e580a2006-02-21 01:09:01 +00002880#undef CLEAR_QUEUE_NAME_LEN
2881
2882 if ( (peer->clear_node_queue = work_queue_new (bm->master, wname)) == NULL)
paul200df112005-06-01 11:17:05 +00002883 {
2884 zlog_err ("%s: Failed to allocate work queue", __func__);
2885 exit (1);
2886 }
Paul Jakma64e580a2006-02-21 01:09:01 +00002887 peer->clear_node_queue->spec.hold = 10;
2888 peer->clear_node_queue->spec.workfunc = &bgp_clear_route_node;
2889 peer->clear_node_queue->spec.del_item_data = &bgp_clear_node_queue_del;
2890 peer->clear_node_queue->spec.completion_func = &bgp_clear_node_complete;
2891 peer->clear_node_queue->spec.max_retries = 0;
2892
2893 /* we only 'lock' this peer reference when the queue is actually active */
2894 peer->clear_node_queue->spec.data = peer;
paul200df112005-06-01 11:17:05 +00002895}
2896
paul718e3742002-12-13 20:15:29 +00002897static void
2898bgp_clear_route_table (struct peer *peer, afi_t afi, safi_t safi,
Chris Caputo228da422009-07-18 05:44:03 +00002899 struct bgp_table *table, struct peer *rsclient,
2900 enum bgp_clear_route_type purpose)
paul718e3742002-12-13 20:15:29 +00002901{
2902 struct bgp_node *rn;
paul200df112005-06-01 11:17:05 +00002903
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002904
paul718e3742002-12-13 20:15:29 +00002905 if (! table)
paulfee0f4c2004-09-13 05:12:46 +00002906 table = (rsclient) ? rsclient->rib[afi][safi] : peer->bgp->rib[afi][safi];
Paul Jakma64e580a2006-02-21 01:09:01 +00002907
hasso6cf159b2005-03-21 10:28:14 +00002908 /* If still no table => afi/safi isn't configured at all or smth. */
2909 if (! table)
2910 return;
Paul Jakma65ca75e2006-05-04 08:08:15 +00002911
2912 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
2913 {
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002914 struct bgp_info *ri;
2915 struct bgp_adj_in *ain;
2916 struct bgp_adj_out *aout;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002917
2918 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2919 * queued for every clearing peer, regardless of whether it is
2920 * relevant to the peer at hand.
2921 *
2922 * Overview: There are 3 different indices which need to be
2923 * scrubbed, potentially, when a peer is removed:
2924 *
2925 * 1 peer's routes visible via the RIB (ie accepted routes)
2926 * 2 peer's routes visible by the (optional) peer's adj-in index
2927 * 3 other routes visible by the peer's adj-out index
2928 *
2929 * 3 there is no hurry in scrubbing, once the struct peer is
2930 * removed from bgp->peer, we could just GC such deleted peer's
2931 * adj-outs at our leisure.
2932 *
2933 * 1 and 2 must be 'scrubbed' in some way, at least made
2934 * invisible via RIB index before peer session is allowed to be
2935 * brought back up. So one needs to know when such a 'search' is
2936 * complete.
2937 *
2938 * Ideally:
2939 *
2940 * - there'd be a single global queue or a single RIB walker
2941 * - rather than tracking which route_nodes still need to be
2942 * examined on a peer basis, we'd track which peers still
2943 * aren't cleared
2944 *
2945 * Given that our per-peer prefix-counts now should be reliable,
2946 * this may actually be achievable. It doesn't seem to be a huge
2947 * problem at this time,
2948 */
Jorge Boncompte [DTI2]24e50f22012-05-07 15:17:33 +00002949 for (ain = rn->adj_in; ain; ain = ain->next)
2950 if (ain->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2951 {
2952 bgp_adj_in_remove (rn, ain);
2953 bgp_unlock_node (rn);
2954 break;
2955 }
2956 for (aout = rn->adj_out; aout; aout = aout->next)
2957 if (aout->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
2958 {
2959 bgp_adj_out_remove (rn, aout, peer, afi, safi);
2960 bgp_unlock_node (rn);
2961 break;
2962 }
2963
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002964 for (ri = rn->info; ri; ri = ri->next)
Chris Caputo228da422009-07-18 05:44:03 +00002965 if (ri->peer == peer || purpose == BGP_CLEAR_ROUTE_MY_RSCLIENT)
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002966 {
Chris Caputo228da422009-07-18 05:44:03 +00002967 struct bgp_clear_node_queue *cnq;
2968
2969 /* both unlocked in bgp_clear_node_queue_del */
Avneesh Sachdev67174042012-08-17 08:19:49 -07002970 bgp_table_lock (bgp_node_table (rn));
Chris Caputo228da422009-07-18 05:44:03 +00002971 bgp_lock_node (rn);
2972 cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
2973 sizeof (struct bgp_clear_node_queue));
2974 cnq->rn = rn;
2975 cnq->purpose = purpose;
2976 work_queue_add (peer->clear_node_queue, cnq);
2977 break;
Paul Jakmaf2c31ac2007-02-22 17:48:42 +00002978 }
Paul Jakma65ca75e2006-05-04 08:08:15 +00002979 }
2980 return;
2981}
2982
2983void
Chris Caputo228da422009-07-18 05:44:03 +00002984bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi,
2985 enum bgp_clear_route_type purpose)
Paul Jakma65ca75e2006-05-04 08:08:15 +00002986{
2987 struct bgp_node *rn;
2988 struct bgp_table *table;
2989 struct peer *rsclient;
2990 struct listnode *node, *nnode;
hasso6cf159b2005-03-21 10:28:14 +00002991
Paul Jakma64e580a2006-02-21 01:09:01 +00002992 if (peer->clear_node_queue == NULL)
2993 bgp_clear_node_queue_init (peer);
paul200df112005-06-01 11:17:05 +00002994
Paul Jakmaca058a32006-09-14 02:58:49 +00002995 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2996 * Idle until it receives a Clearing_Completed event. This protects
2997 * against peers which flap faster than we can we clear, which could
2998 * lead to:
Paul Jakma64e580a2006-02-21 01:09:01 +00002999 *
3000 * a) race with routes from the new session being installed before
3001 * clear_route_node visits the node (to delete the route of that
3002 * peer)
3003 * b) resource exhaustion, clear_route_node likely leads to an entry
3004 * on the process_main queue. Fast-flapping could cause that queue
3005 * to grow and grow.
paul200df112005-06-01 11:17:05 +00003006 */
Donald Sharp7ef42212015-03-30 06:32:52 -07003007
3008 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3009 * the unlock will happen upon work-queue completion; other wise, the
3010 * unlock happens at the end of this function.
3011 */
Paul Jakmaca058a32006-09-14 02:58:49 +00003012 if (!peer->clear_node_queue->thread)
Lou Berger050defe2016-01-12 13:41:59 -05003013 peer_lock (peer); /* bgp_clear_node_complete */
Chris Caputo228da422009-07-18 05:44:03 +00003014 switch (purpose)
paulfee0f4c2004-09-13 05:12:46 +00003015 {
Chris Caputo228da422009-07-18 05:44:03 +00003016 case BGP_CLEAR_ROUTE_NORMAL:
Lou Berger298cc2f2016-01-12 13:42:02 -05003017 if ((safi != SAFI_MPLS_VPN) && (safi != SAFI_ENCAP))
Chris Caputo228da422009-07-18 05:44:03 +00003018 bgp_clear_route_table (peer, afi, safi, NULL, NULL, purpose);
3019 else
3020 for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn;
3021 rn = bgp_route_next (rn))
3022 if ((table = rn->info) != NULL)
3023 bgp_clear_route_table (peer, afi, safi, table, NULL, purpose);
3024
3025 for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
3026 if (CHECK_FLAG(rsclient->af_flags[afi][safi],
3027 PEER_FLAG_RSERVER_CLIENT))
3028 bgp_clear_route_table (peer, afi, safi, NULL, rsclient, purpose);
3029 break;
3030
3031 case BGP_CLEAR_ROUTE_MY_RSCLIENT:
Lou Berger050defe2016-01-12 13:41:59 -05003032 /*
3033 * gpz 091009: TBD why don't we have special handling for
3034 * SAFI_MPLS_VPN here in the original quagga code?
3035 * (and, by extension, for SAFI_ENCAP)
3036 */
Chris Caputo228da422009-07-18 05:44:03 +00003037 bgp_clear_route_table (peer, afi, safi, NULL, peer, purpose);
3038 break;
3039
3040 default:
3041 assert (0);
3042 break;
paulfee0f4c2004-09-13 05:12:46 +00003043 }
Donald Sharp7ef42212015-03-30 06:32:52 -07003044
3045 /* unlock if no nodes got added to the clear-node-queue. */
Paul Jakma65ca75e2006-05-04 08:08:15 +00003046 if (!peer->clear_node_queue->thread)
Donald Sharp7ef42212015-03-30 06:32:52 -07003047 peer_unlock (peer);
3048
paul718e3742002-12-13 20:15:29 +00003049}
3050
3051void
3052bgp_clear_route_all (struct peer *peer)
3053{
3054 afi_t afi;
3055 safi_t safi;
3056
3057 for (afi = AFI_IP; afi < AFI_MAX; afi++)
3058 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
Chris Caputo228da422009-07-18 05:44:03 +00003059 bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_NORMAL);
paul718e3742002-12-13 20:15:29 +00003060}
3061
Lou Berger82dd7072016-01-12 13:41:57 -05003062/*
3063 * Finish freeing things when exiting
3064 */
3065static void
3066bgp_drain_workqueue_immediate (struct work_queue *wq)
3067{
3068 if (!wq)
3069 return;
3070
3071 if (!wq->thread)
3072 {
3073 /*
3074 * no thread implies no queued items
3075 */
3076 assert(!wq->items->count);
3077 return;
3078 }
3079
3080 while (wq->items->count)
3081 {
3082 if (wq->thread)
3083 thread_cancel(wq->thread);
3084 work_queue_run(wq->thread);
3085 }
3086}
3087
3088/*
3089 * Special function to process clear node queue when bgpd is exiting
3090 * and the thread scheduler is no longer running.
3091 */
3092void
3093bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
3094{
3095 if (!peer)
3096 return;
3097
3098 bgp_drain_workqueue_immediate(peer->clear_node_queue);
3099}
3100
3101/*
3102 * The work queues are not specific to a BGP instance, but the
3103 * items in them refer to BGP instances, so this should be called
3104 * before each BGP instance is deleted.
3105 */
3106void
3107bgp_process_queues_drain_immediate(void)
3108{
3109 bgp_drain_workqueue_immediate(bm->process_main_queue);
3110 bgp_drain_workqueue_immediate(bm->process_rsclient_queue);
3111}
3112
paul718e3742002-12-13 20:15:29 +00003113void
3114bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
3115{
3116 struct bgp_table *table;
3117 struct bgp_node *rn;
3118 struct bgp_adj_in *ain;
3119
3120 table = peer->bgp->rib[afi][safi];
3121
3122 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3123 for (ain = rn->adj_in; ain ; ain = ain->next)
3124 if (ain->peer == peer)
3125 {
3126 bgp_adj_in_remove (rn, ain);
3127 bgp_unlock_node (rn);
3128 break;
3129 }
3130}
hasso93406d82005-02-02 14:40:33 +00003131
3132void
3133bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi)
3134{
3135 struct bgp_node *rn;
3136 struct bgp_info *ri;
3137 struct bgp_table *table;
3138
3139 table = peer->bgp->rib[afi][safi];
3140
3141 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3142 {
3143 for (ri = rn->info; ri; ri = ri->next)
3144 if (ri->peer == peer)
3145 {
3146 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
3147 bgp_rib_remove (rn, ri, peer, afi, safi);
3148 break;
3149 }
3150 }
3151}
David Lamparter6b0655a2014-06-04 06:53:35 +02003152
Lou Berger82dd7072016-01-12 13:41:57 -05003153static void
3154bgp_cleanup_table(struct bgp_table *table, safi_t safi)
3155{
3156 struct bgp_node *rn;
3157 struct bgp_info *ri;
3158 struct bgp_info *next;
3159
3160 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
3161 for (ri = rn->info; ri; ri = next)
3162 {
3163 next = ri->next;
3164 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
3165 && ri->type == ZEBRA_ROUTE_BGP
3166 && ri->sub_type == BGP_ROUTE_NORMAL)
3167 bgp_zebra_withdraw (&rn->p, ri, safi);
3168 }
3169}
3170
paul718e3742002-12-13 20:15:29 +00003171/* Delete all kernel routes. */
3172void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003173bgp_cleanup_routes (void)
paul718e3742002-12-13 20:15:29 +00003174{
3175 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00003176 struct listnode *node, *nnode;
Lou Berger82dd7072016-01-12 13:41:57 -05003177 afi_t afi;
paul718e3742002-12-13 20:15:29 +00003178
paul1eb8ef22005-04-07 07:30:20 +00003179 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00003180 {
Lou Berger82dd7072016-01-12 13:41:57 -05003181 for (afi = AFI_IP; afi < AFI_MAX; ++afi)
3182 {
3183 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00003184
Lou Berger82dd7072016-01-12 13:41:57 -05003185 bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00003186
Lou Berger82dd7072016-01-12 13:41:57 -05003187 /*
3188 * VPN and ENCAP tables are two-level (RD is top level)
3189 */
3190 for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
3191 rn = bgp_route_next (rn))
Lou Berger298cc2f2016-01-12 13:42:02 -05003192 {
3193 if (rn->info)
Lou Berger82dd7072016-01-12 13:41:57 -05003194 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003195 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
3196 bgp_table_finish ((struct bgp_table **)&(rn->info));
3197 rn->info = NULL;
3198 bgp_unlock_node(rn);
Lou Berger82dd7072016-01-12 13:41:57 -05003199 }
Lou Berger298cc2f2016-01-12 13:42:02 -05003200 }
3201
3202 for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
3203 rn = bgp_route_next (rn))
3204 {
3205 if (rn->info)
3206 {
3207 bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
3208 bgp_table_finish ((struct bgp_table **)&(rn->info));
3209 rn->info = NULL;
3210 bgp_unlock_node(rn);
3211 }
3212 }
Lou Berger82dd7072016-01-12 13:41:57 -05003213 }
paul718e3742002-12-13 20:15:29 +00003214 }
3215}
3216
3217void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003218bgp_reset (void)
paul718e3742002-12-13 20:15:29 +00003219{
3220 vty_reset ();
3221 bgp_zclient_reset ();
3222 access_list_reset ();
3223 prefix_list_reset ();
3224}
David Lamparter6b0655a2014-06-04 06:53:35 +02003225
paul718e3742002-12-13 20:15:29 +00003226/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3227 value. */
3228int
3229bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
3230{
3231 u_char *pnt;
3232 u_char *lim;
3233 struct prefix p;
3234 int psize;
3235 int ret;
3236
3237 /* Check peer status. */
3238 if (peer->status != Established)
3239 return 0;
3240
3241 pnt = packet->nlri;
3242 lim = pnt + packet->length;
3243
3244 for (; pnt < lim; pnt += psize)
3245 {
3246 /* Clear prefix structure. */
3247 memset (&p, 0, sizeof (struct prefix));
3248
3249 /* Fetch prefix length. */
3250 p.prefixlen = *pnt++;
3251 p.family = afi2family (packet->afi);
3252
3253 /* Already checked in nlri_sanity_check(). We do double check
3254 here. */
3255 if ((packet->afi == AFI_IP && p.prefixlen > 32)
3256 || (packet->afi == AFI_IP6 && p.prefixlen > 128))
3257 return -1;
3258
3259 /* Packet size overflow check. */
3260 psize = PSIZE (p.prefixlen);
3261
3262 /* When packet overflow occur return immediately. */
3263 if (pnt + psize > lim)
3264 return -1;
3265
3266 /* Fetch prefix from NLRI packet. */
3267 memcpy (&p.u.prefix, pnt, psize);
3268
3269 /* Check address. */
3270 if (packet->afi == AFI_IP && packet->safi == SAFI_UNICAST)
3271 {
3272 if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
3273 {
paulf5ba3872004-07-09 12:11:31 +00003274 /*
3275 * From draft-ietf-idr-bgp4-22, Section 6.3:
3276 * If a BGP router receives an UPDATE message with a
3277 * semantically incorrect NLRI field, in which a prefix is
3278 * semantically incorrect (eg. an unexpected multicast IP
3279 * address), it should ignore the prefix.
3280 */
paul718e3742002-12-13 20:15:29 +00003281 zlog (peer->log, LOG_ERR,
3282 "IPv4 unicast NLRI is multicast address %s",
3283 inet_ntoa (p.u.prefix4));
paulf5ba3872004-07-09 12:11:31 +00003284
paul718e3742002-12-13 20:15:29 +00003285 return -1;
3286 }
3287 }
3288
paul718e3742002-12-13 20:15:29 +00003289 /* Check address. */
3290 if (packet->afi == AFI_IP6 && packet->safi == SAFI_UNICAST)
3291 {
3292 if (IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3293 {
3294 char buf[BUFSIZ];
3295
3296 zlog (peer->log, LOG_WARNING,
3297 "IPv6 link-local NLRI received %s ignore this NLRI",
3298 inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
3299
3300 continue;
3301 }
3302 }
paul718e3742002-12-13 20:15:29 +00003303
3304 /* Normal process. */
3305 if (attr)
3306 ret = bgp_update (peer, &p, attr, packet->afi, packet->safi,
3307 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL, 0);
3308 else
3309 ret = bgp_withdraw (peer, &p, attr, packet->afi, packet->safi,
3310 ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, NULL);
3311
3312 /* Address family configuration mismatch or maximum-prefix count
3313 overflow. */
3314 if (ret < 0)
3315 return -1;
3316 }
3317
3318 /* Packet length consistency check. */
3319 if (pnt != lim)
3320 return -1;
3321
3322 return 0;
3323}
3324
Paul Jakma18ab08b2016-01-27 16:37:33 +00003325static int
3326bgp_nlri_sanity_check_ip (struct peer *peer, struct bgp_nlri *nlri)
paul718e3742002-12-13 20:15:29 +00003327{
3328 u_char *end;
3329 u_char prefixlen;
3330 int psize;
Paul Jakma18ab08b2016-01-27 16:37:33 +00003331 u_char *pnt = nlri->nlri;
3332 afi_t afi = nlri->afi;
3333 safi_t safi = nlri->safi;
3334 end = pnt + nlri->length;
paul718e3742002-12-13 20:15:29 +00003335
3336 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3337 syntactic validity. If the field is syntactically incorrect,
3338 then the Error Subcode is set to Invalid Network Field. */
3339
3340 while (pnt < end)
3341 {
Lou Berger298cc2f2016-01-12 13:42:02 -05003342 int badlength;
paul718e3742002-12-13 20:15:29 +00003343 prefixlen = *pnt++;
3344
3345 /* Prefix length check. */
Lou Berger298cc2f2016-01-12 13:42:02 -05003346 badlength = 0;
3347 if (safi == SAFI_ENCAP) {
3348 if (prefixlen > 128)
3349 badlength = 1;
3350 } else {
3351 if ((afi == AFI_IP && prefixlen > 32) ||
3352 (afi == AFI_IP6 && prefixlen > 128)) {
3353
3354 badlength = 1;
3355 }
3356 }
3357 if (badlength)
paul718e3742002-12-13 20:15:29 +00003358 {
3359 plog_err (peer->log,
3360 "%s [Error] Update packet error (wrong prefix length %d)",
3361 peer->host, prefixlen);
3362 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
3363 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
3364 return -1;
3365 }
3366
3367 /* Packet size overflow check. */
3368 psize = PSIZE (prefixlen);
3369
3370 if (pnt + psize > end)
3371 {
3372 plog_err (peer->log,
3373 "%s [Error] Update packet error"
3374 " (prefix data overflow prefix size is %d)",
3375 peer->host, psize);
3376 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
3377 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
3378 return -1;
3379 }
3380
3381 pnt += psize;
3382 }
3383
3384 /* Packet length consistency check. */
3385 if (pnt != end)
3386 {
3387 plog_err (peer->log,
3388 "%s [Error] Update packet error"
3389 " (prefix length mismatch with total length)",
3390 peer->host);
3391 bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
3392 BGP_NOTIFY_UPDATE_INVAL_NETWORK);
3393 return -1;
3394 }
3395 return 0;
3396}
David Lamparter6b0655a2014-06-04 06:53:35 +02003397
Paul Jakma18ab08b2016-01-27 16:37:33 +00003398int
3399bgp_nlri_sanity_check (struct peer *peer, struct bgp_nlri *nlri)
3400{
3401 switch (nlri->safi)
3402 {
3403 case SAFI_MPLS_LABELED_VPN:
3404 return bgp_nlri_sanity_check_vpn (peer, nlri);
3405 case SAFI_UNICAST:
3406 case SAFI_MULTICAST:
3407 return bgp_nlri_sanity_check_ip (peer, nlri);
3408 default: return -1;
3409 }
3410}
3411
paul94f2b392005-06-28 12:44:16 +00003412static struct bgp_static *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08003413bgp_static_new (void)
paul718e3742002-12-13 20:15:29 +00003414{
Stephen Hemminger393deb92008-08-18 14:13:29 -07003415 return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
paul718e3742002-12-13 20:15:29 +00003416}
3417
paul94f2b392005-06-28 12:44:16 +00003418static void
paul718e3742002-12-13 20:15:29 +00003419bgp_static_free (struct bgp_static *bgp_static)
3420{
3421 if (bgp_static->rmap.name)
3422 free (bgp_static->rmap.name);
3423 XFREE (MTYPE_BGP_STATIC, bgp_static);
3424}
3425
paul94f2b392005-06-28 12:44:16 +00003426static void
paulfee0f4c2004-09-13 05:12:46 +00003427bgp_static_withdraw_rsclient (struct bgp *bgp, struct peer *rsclient,
3428 struct prefix *p, afi_t afi, safi_t safi)
3429{
3430 struct bgp_node *rn;
3431 struct bgp_info *ri;
3432
3433 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3434
3435 /* Check selected route and self inserted route. */
3436 for (ri = rn->info; ri; ri = ri->next)
3437 if (ri->peer == bgp->peer_self
3438 && ri->type == ZEBRA_ROUTE_BGP
3439 && ri->sub_type == BGP_ROUTE_STATIC)
3440 break;
3441
3442 /* Withdraw static BGP route from routing table. */
3443 if (ri)
3444 {
paulfee0f4c2004-09-13 05:12:46 +00003445 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003446 bgp_process (bgp, rn, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003447 }
3448
3449 /* Unlock bgp_node_lookup. */
3450 bgp_unlock_node (rn);
3451}
3452
paul94f2b392005-06-28 12:44:16 +00003453static void
paulfee0f4c2004-09-13 05:12:46 +00003454bgp_static_update_rsclient (struct peer *rsclient, struct prefix *p,
Paul Jakmafb982c22007-05-04 20:15:47 +00003455 struct bgp_static *bgp_static,
3456 afi_t afi, safi_t safi)
paulfee0f4c2004-09-13 05:12:46 +00003457{
3458 struct bgp_node *rn;
3459 struct bgp_info *ri;
3460 struct bgp_info *new;
3461 struct bgp_info info;
paulfee0f4c2004-09-13 05:12:46 +00003462 struct attr *attr_new;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003463 struct attr attr;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003464 struct attr new_attr;
3465 struct attr_extra new_extra;
paulfee0f4c2004-09-13 05:12:46 +00003466 struct bgp *bgp;
3467 int ret;
3468 char buf[SU_ADDRSTRLEN];
3469
3470 bgp = rsclient->bgp;
3471
Paul Jakma06e110f2006-05-12 23:29:22 +00003472 assert (bgp_static);
3473 if (!bgp_static)
3474 return;
3475
paulfee0f4c2004-09-13 05:12:46 +00003476 rn = bgp_afi_node_get (rsclient->rib[afi][safi], afi, safi, p, NULL);
3477
3478 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakma06e110f2006-05-12 23:29:22 +00003479
3480 attr.nexthop = bgp_static->igpnexthop;
3481 attr.med = bgp_static->igpmetric;
3482 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
Paul Jakma41367172007-08-06 15:24:51 +00003483
Paul Jakma41367172007-08-06 15:24:51 +00003484 if (bgp_static->atomic)
3485 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3486
paulfee0f4c2004-09-13 05:12:46 +00003487 /* Apply network route-map for export to this rsclient. */
3488 if (bgp_static->rmap.name)
3489 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003490 struct attr attr_tmp = attr;
paulfee0f4c2004-09-13 05:12:46 +00003491 info.peer = rsclient;
Paul Jakmafb982c22007-05-04 20:15:47 +00003492 info.attr = &attr_tmp;
3493
paulfee0f4c2004-09-13 05:12:46 +00003494 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_EXPORT);
3495 SET_FLAG (rsclient->rmap_type, PEER_RMAP_TYPE_NETWORK);
3496
3497 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3498
3499 rsclient->rmap_type = 0;
3500
3501 if (ret == RMAP_DENYMATCH)
3502 {
3503 /* Free uninterned attribute. */
Paul Jakmafb982c22007-05-04 20:15:47 +00003504 bgp_attr_flush (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003505
3506 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003507 aspath_unintern (&attr.aspath);
paulfee0f4c2004-09-13 05:12:46 +00003508 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
Paul Jakmafb982c22007-05-04 20:15:47 +00003509 bgp_attr_extra_free (&attr);
3510
paulfee0f4c2004-09-13 05:12:46 +00003511 return;
3512 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003513 attr_new = bgp_attr_intern (&attr_tmp);
paulfee0f4c2004-09-13 05:12:46 +00003514 }
3515 else
3516 attr_new = bgp_attr_intern (&attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00003517
3518 new_attr.extra = &new_extra;
Stephen Hemminger7badc262010-08-05 10:26:31 -07003519 bgp_attr_dup(&new_attr, attr_new);
Paul Jakmafb982c22007-05-04 20:15:47 +00003520
paulfee0f4c2004-09-13 05:12:46 +00003521 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3522
Paul Jakmafb982c22007-05-04 20:15:47 +00003523 if (bgp_import_modifier (rsclient, bgp->peer_self, p, &new_attr, afi, safi)
3524 == RMAP_DENY)
3525 {
paulfee0f4c2004-09-13 05:12:46 +00003526 /* This BGP update is filtered. Log the reason then update BGP entry. */
3527 if (BGP_DEBUG (update, UPDATE_IN))
ajsd2c1f162004-12-08 21:10:20 +00003528 zlog (rsclient->log, LOG_DEBUG,
paulfee0f4c2004-09-13 05:12:46 +00003529 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3530 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
3531 p->prefixlen, rsclient->host);
3532
3533 bgp->peer_self->rmap_type = 0;
3534
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003535 bgp_attr_unintern (&attr_new);
3536 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003537 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003538
3539 bgp_static_withdraw_rsclient (bgp, rsclient, p, afi, safi);
3540
3541 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003542 }
paulfee0f4c2004-09-13 05:12:46 +00003543
3544 bgp->peer_self->rmap_type = 0;
3545
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003546 bgp_attr_unintern (&attr_new);
paulfee0f4c2004-09-13 05:12:46 +00003547 attr_new = bgp_attr_intern (&new_attr);
3548
3549 for (ri = rn->info; ri; ri = ri->next)
3550 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3551 && ri->sub_type == BGP_ROUTE_STATIC)
3552 break;
3553
3554 if (ri)
3555 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003556 if (attrhash_cmp (ri->attr, attr_new) &&
3557 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paulfee0f4c2004-09-13 05:12:46 +00003558 {
3559 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003560 bgp_attr_unintern (&attr_new);
3561 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003562 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003563 return;
3564 }
3565 else
3566 {
3567 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003568 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paulfee0f4c2004-09-13 05:12:46 +00003569
3570 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003571 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3572 bgp_info_restore(rn, ri);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003573 bgp_attr_unintern (&ri->attr);
paulfee0f4c2004-09-13 05:12:46 +00003574 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003575 ri->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003576
3577 /* Process change. */
3578 bgp_process (bgp, rn, afi, safi);
3579 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003580 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003581 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003582 return;
Paul Jakmafb982c22007-05-04 20:15:47 +00003583 }
paulfee0f4c2004-09-13 05:12:46 +00003584 }
Paul Jakmafb982c22007-05-04 20:15:47 +00003585
paulfee0f4c2004-09-13 05:12:46 +00003586 /* Make new BGP info. */
3587 new = bgp_info_new ();
3588 new->type = ZEBRA_ROUTE_BGP;
3589 new->sub_type = BGP_ROUTE_STATIC;
3590 new->peer = bgp->peer_self;
3591 SET_FLAG (new->flags, BGP_INFO_VALID);
3592 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003593 new->uptime = bgp_clock ();
paulfee0f4c2004-09-13 05:12:46 +00003594
3595 /* Register new BGP information. */
3596 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003597
3598 /* route_node_get lock */
3599 bgp_unlock_node (rn);
3600
paulfee0f4c2004-09-13 05:12:46 +00003601 /* Process change. */
3602 bgp_process (bgp, rn, afi, safi);
3603
3604 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003605 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003606 bgp_attr_extra_free (&attr);
paulfee0f4c2004-09-13 05:12:46 +00003607}
3608
paul94f2b392005-06-28 12:44:16 +00003609static void
paulfee0f4c2004-09-13 05:12:46 +00003610bgp_static_update_main (struct bgp *bgp, struct prefix *p,
paul718e3742002-12-13 20:15:29 +00003611 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3612{
3613 struct bgp_node *rn;
3614 struct bgp_info *ri;
3615 struct bgp_info *new;
3616 struct bgp_info info;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00003617 struct attr attr;
paul718e3742002-12-13 20:15:29 +00003618 struct attr *attr_new;
3619 int ret;
3620
Paul Jakmadd8103a2006-05-12 23:27:30 +00003621 assert (bgp_static);
3622 if (!bgp_static)
3623 return;
3624
paulfee0f4c2004-09-13 05:12:46 +00003625 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003626
3627 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
Paul Jakmadd8103a2006-05-12 23:27:30 +00003628
3629 attr.nexthop = bgp_static->igpnexthop;
3630 attr.med = bgp_static->igpmetric;
3631 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
paul718e3742002-12-13 20:15:29 +00003632
Paul Jakma41367172007-08-06 15:24:51 +00003633 if (bgp_static->atomic)
3634 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
3635
paul718e3742002-12-13 20:15:29 +00003636 /* Apply route-map. */
3637 if (bgp_static->rmap.name)
3638 {
Paul Jakmafb982c22007-05-04 20:15:47 +00003639 struct attr attr_tmp = attr;
paul718e3742002-12-13 20:15:29 +00003640 info.peer = bgp->peer_self;
paul286e1e72003-08-08 00:24:31 +00003641 info.attr = &attr_tmp;
paul718e3742002-12-13 20:15:29 +00003642
paulfee0f4c2004-09-13 05:12:46 +00003643 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3644
paul718e3742002-12-13 20:15:29 +00003645 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
paul286e1e72003-08-08 00:24:31 +00003646
paulfee0f4c2004-09-13 05:12:46 +00003647 bgp->peer_self->rmap_type = 0;
3648
paul718e3742002-12-13 20:15:29 +00003649 if (ret == RMAP_DENYMATCH)
3650 {
3651 /* Free uninterned attribute. */
paul286e1e72003-08-08 00:24:31 +00003652 bgp_attr_flush (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003653
3654 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003655 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003656 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003657 bgp_static_withdraw (bgp, p, afi, safi);
3658 return;
3659 }
paul286e1e72003-08-08 00:24:31 +00003660 attr_new = bgp_attr_intern (&attr_tmp);
paul718e3742002-12-13 20:15:29 +00003661 }
paul286e1e72003-08-08 00:24:31 +00003662 else
3663 attr_new = bgp_attr_intern (&attr);
paul718e3742002-12-13 20:15:29 +00003664
3665 for (ri = rn->info; ri; ri = ri->next)
3666 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3667 && ri->sub_type == BGP_ROUTE_STATIC)
3668 break;
3669
3670 if (ri)
3671 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003672 if (attrhash_cmp (ri->attr, attr_new) &&
3673 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00003674 {
3675 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003676 bgp_attr_unintern (&attr_new);
3677 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003678 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003679 return;
3680 }
3681 else
3682 {
3683 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00003684 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00003685
3686 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00003687 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3688 bgp_info_restore(rn, ri);
3689 else
3690 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003691 bgp_attr_unintern (&ri->attr);
paul718e3742002-12-13 20:15:29 +00003692 ri->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003693 ri->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003694
3695 /* Process change. */
3696 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3697 bgp_process (bgp, rn, afi, safi);
3698 bgp_unlock_node (rn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003699 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003700 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003701 return;
3702 }
3703 }
3704
3705 /* Make new BGP info. */
3706 new = bgp_info_new ();
3707 new->type = ZEBRA_ROUTE_BGP;
3708 new->sub_type = BGP_ROUTE_STATIC;
3709 new->peer = bgp->peer_self;
3710 SET_FLAG (new->flags, BGP_INFO_VALID);
3711 new->attr = attr_new;
Stephen Hemminger65957882010-01-15 16:22:10 +03003712 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00003713
3714 /* Aggregate address increment. */
3715 bgp_aggregate_increment (bgp, p, new, afi, safi);
3716
3717 /* Register new BGP information. */
3718 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00003719
3720 /* route_node_get lock */
3721 bgp_unlock_node (rn);
3722
paul718e3742002-12-13 20:15:29 +00003723 /* Process change. */
3724 bgp_process (bgp, rn, afi, safi);
3725
3726 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00003727 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00003728 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00003729}
3730
3731void
paulfee0f4c2004-09-13 05:12:46 +00003732bgp_static_update (struct bgp *bgp, struct prefix *p,
3733 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3734{
3735 struct peer *rsclient;
paul1eb8ef22005-04-07 07:30:20 +00003736 struct listnode *node, *nnode;
paulfee0f4c2004-09-13 05:12:46 +00003737
3738 bgp_static_update_main (bgp, p, bgp_static, afi, safi);
3739
paul1eb8ef22005-04-07 07:30:20 +00003740 for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
paulfee0f4c2004-09-13 05:12:46 +00003741 {
Paul Jakmada5b30f2006-05-08 14:37:17 +00003742 if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
3743 bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
paulfee0f4c2004-09-13 05:12:46 +00003744 }
3745}
3746
paul718e3742002-12-13 20:15:29 +00003747void
3748bgp_static_withdraw (struct bgp *bgp, struct prefix *p, afi_t afi,
3749 safi_t safi)
3750{
3751 struct bgp_node *rn;
3752 struct bgp_info *ri;
3753
paulfee0f4c2004-09-13 05:12:46 +00003754 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, NULL);
paul718e3742002-12-13 20:15:29 +00003755
3756 /* Check selected route and self inserted route. */
3757 for (ri = rn->info; ri; ri = ri->next)
3758 if (ri->peer == bgp->peer_self
3759 && ri->type == ZEBRA_ROUTE_BGP
3760 && ri->sub_type == BGP_ROUTE_STATIC)
3761 break;
3762
3763 /* Withdraw static BGP route from routing table. */
3764 if (ri)
3765 {
3766 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003767 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003768 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003769 }
3770
3771 /* Unlock bgp_node_lookup. */
3772 bgp_unlock_node (rn);
3773}
3774
3775void
paulfee0f4c2004-09-13 05:12:46 +00003776bgp_check_local_routes_rsclient (struct peer *rsclient, afi_t afi, safi_t safi)
3777{
3778 struct bgp_static *bgp_static;
3779 struct bgp *bgp;
3780 struct bgp_node *rn;
3781 struct prefix *p;
3782
3783 bgp = rsclient->bgp;
3784
3785 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
3786 if ((bgp_static = rn->info) != NULL)
3787 {
3788 p = &rn->p;
3789
3790 bgp_static_update_rsclient (rsclient, p, bgp_static,
3791 afi, safi);
3792 }
3793}
3794
Lou Bergera76d9ca2016-01-12 13:41:53 -05003795/*
3796 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3797 */
paul94f2b392005-06-28 12:44:16 +00003798static void
Lou Bergera76d9ca2016-01-12 13:41:53 -05003799bgp_static_withdraw_safi (struct bgp *bgp, struct prefix *p, afi_t afi,
3800 safi_t safi, struct prefix_rd *prd, u_char *tag)
paul718e3742002-12-13 20:15:29 +00003801{
3802 struct bgp_node *rn;
3803 struct bgp_info *ri;
3804
paulfee0f4c2004-09-13 05:12:46 +00003805 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
paul718e3742002-12-13 20:15:29 +00003806
3807 /* Check selected route and self inserted route. */
3808 for (ri = rn->info; ri; ri = ri->next)
3809 if (ri->peer == bgp->peer_self
3810 && ri->type == ZEBRA_ROUTE_BGP
3811 && ri->sub_type == BGP_ROUTE_STATIC)
3812 break;
3813
3814 /* Withdraw static BGP route from routing table. */
3815 if (ri)
3816 {
3817 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
paul718e3742002-12-13 20:15:29 +00003818 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00003819 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00003820 }
3821
3822 /* Unlock bgp_node_lookup. */
3823 bgp_unlock_node (rn);
3824}
3825
Lou Bergera76d9ca2016-01-12 13:41:53 -05003826static void
3827bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
3828 struct bgp_static *bgp_static, afi_t afi, safi_t safi)
3829{
3830 struct bgp_node *rn;
3831 struct bgp_info *new;
3832 struct attr *attr_new;
3833 struct attr attr = { 0 };
3834 struct bgp_info *ri;
3835
3836 assert (bgp_static);
3837
3838 rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, &bgp_static->prd);
3839
3840 bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
3841
3842 attr.nexthop = bgp_static->igpnexthop;
3843 attr.med = bgp_static->igpmetric;
3844 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
3845
3846 /* Apply route-map. */
3847 if (bgp_static->rmap.name)
3848 {
3849 struct attr attr_tmp = attr;
3850 struct bgp_info info;
3851 int ret;
3852
3853 info.peer = bgp->peer_self;
3854 info.attr = &attr_tmp;
3855
3856 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_NETWORK);
3857
3858 ret = route_map_apply (bgp_static->rmap.map, p, RMAP_BGP, &info);
3859
3860 bgp->peer_self->rmap_type = 0;
3861
3862 if (ret == RMAP_DENYMATCH)
3863 {
3864 /* Free uninterned attribute. */
3865 bgp_attr_flush (&attr_tmp);
3866
3867 /* Unintern original. */
3868 aspath_unintern (&attr.aspath);
3869 bgp_attr_extra_free (&attr);
3870 bgp_static_withdraw_safi (bgp, p, afi, safi, &bgp_static->prd,
3871 bgp_static->tag);
3872 return;
3873 }
3874
3875 attr_new = bgp_attr_intern (&attr_tmp);
3876 }
3877 else
3878 {
3879 attr_new = bgp_attr_intern (&attr);
3880 }
3881
3882 for (ri = rn->info; ri; ri = ri->next)
3883 if (ri->peer == bgp->peer_self && ri->type == ZEBRA_ROUTE_BGP
3884 && ri->sub_type == BGP_ROUTE_STATIC)
3885 break;
3886
3887 if (ri)
3888 {
3889 if (attrhash_cmp (ri->attr, attr_new) &&
3890 !CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3891 {
3892 bgp_unlock_node (rn);
3893 bgp_attr_unintern (&attr_new);
3894 aspath_unintern (&attr.aspath);
3895 bgp_attr_extra_free (&attr);
3896 return;
3897 }
3898 else
3899 {
3900 /* The attribute is changed. */
3901 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
3902
3903 /* Rewrite BGP route information. */
3904 if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED))
3905 bgp_info_restore(rn, ri);
3906 else
3907 bgp_aggregate_decrement (bgp, p, ri, afi, safi);
3908 bgp_attr_unintern (&ri->attr);
3909 ri->attr = attr_new;
3910 ri->uptime = bgp_clock ();
3911
3912 /* Process change. */
3913 bgp_aggregate_increment (bgp, p, ri, afi, safi);
3914 bgp_process (bgp, rn, afi, safi);
3915 bgp_unlock_node (rn);
3916 aspath_unintern (&attr.aspath);
3917 bgp_attr_extra_free (&attr);
3918 return;
3919 }
3920 }
3921
3922
3923 /* Make new BGP info. */
3924 new = bgp_info_new ();
3925 new->type = ZEBRA_ROUTE_BGP;
3926 new->sub_type = BGP_ROUTE_STATIC;
3927 new->peer = bgp->peer_self;
3928 new->attr = attr_new;
3929 SET_FLAG (new->flags, BGP_INFO_VALID);
3930 new->uptime = bgp_clock ();
3931 new->extra = bgp_info_extra_new();
3932 memcpy (new->extra->tag, bgp_static->tag, 3);
3933
3934 /* Aggregate address increment. */
3935 bgp_aggregate_increment (bgp, p, new, afi, safi);
3936
3937 /* Register new BGP information. */
3938 bgp_info_add (rn, new);
3939
3940 /* route_node_get lock */
3941 bgp_unlock_node (rn);
3942
3943 /* Process change. */
3944 bgp_process (bgp, rn, afi, safi);
3945
3946 /* Unintern original. */
3947 aspath_unintern (&attr.aspath);
3948 bgp_attr_extra_free (&attr);
3949}
3950
paul718e3742002-12-13 20:15:29 +00003951/* Configure static BGP network. When user don't run zebra, static
3952 route should be installed as valid. */
paul94f2b392005-06-28 12:44:16 +00003953static int
paulfd79ac92004-10-13 05:06:08 +00003954bgp_static_set (struct vty *vty, struct bgp *bgp, const char *ip_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003955 afi_t afi, safi_t safi, const char *rmap, int backdoor)
paul718e3742002-12-13 20:15:29 +00003956{
3957 int ret;
3958 struct prefix p;
3959 struct bgp_static *bgp_static;
3960 struct bgp_node *rn;
Paul Jakma41367172007-08-06 15:24:51 +00003961 u_char need_update = 0;
paul718e3742002-12-13 20:15:29 +00003962
3963 /* Convert IP prefix string to struct prefix. */
3964 ret = str2prefix (ip_str, &p);
3965 if (! ret)
3966 {
3967 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
3968 return CMD_WARNING;
3969 }
paul718e3742002-12-13 20:15:29 +00003970 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
3971 {
3972 vty_out (vty, "%% Malformed prefix (link-local address)%s",
3973 VTY_NEWLINE);
3974 return CMD_WARNING;
3975 }
paul718e3742002-12-13 20:15:29 +00003976
3977 apply_mask (&p);
3978
3979 /* Set BGP static route configuration. */
3980 rn = bgp_node_get (bgp->route[afi][safi], &p);
3981
3982 if (rn->info)
3983 {
3984 /* Configuration change. */
3985 bgp_static = rn->info;
3986
3987 /* Check previous routes are installed into BGP. */
Paul Jakmac8f3fe32010-12-05 20:28:02 +00003988 if (bgp_static->valid && bgp_static->backdoor != backdoor)
3989 need_update = 1;
Paul Jakma41367172007-08-06 15:24:51 +00003990
paul718e3742002-12-13 20:15:29 +00003991 bgp_static->backdoor = backdoor;
Paul Jakma41367172007-08-06 15:24:51 +00003992
paul718e3742002-12-13 20:15:29 +00003993 if (rmap)
3994 {
3995 if (bgp_static->rmap.name)
3996 free (bgp_static->rmap.name);
3997 bgp_static->rmap.name = strdup (rmap);
3998 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
3999 }
4000 else
4001 {
4002 if (bgp_static->rmap.name)
4003 free (bgp_static->rmap.name);
4004 bgp_static->rmap.name = NULL;
4005 bgp_static->rmap.map = NULL;
4006 bgp_static->valid = 0;
4007 }
4008 bgp_unlock_node (rn);
4009 }
4010 else
4011 {
4012 /* New configuration. */
4013 bgp_static = bgp_static_new ();
4014 bgp_static->backdoor = backdoor;
4015 bgp_static->valid = 0;
4016 bgp_static->igpmetric = 0;
4017 bgp_static->igpnexthop.s_addr = 0;
Paul Jakma41367172007-08-06 15:24:51 +00004018
paul718e3742002-12-13 20:15:29 +00004019 if (rmap)
4020 {
4021 if (bgp_static->rmap.name)
4022 free (bgp_static->rmap.name);
4023 bgp_static->rmap.name = strdup (rmap);
4024 bgp_static->rmap.map = route_map_lookup_by_name (rmap);
4025 }
4026 rn->info = bgp_static;
4027 }
4028
4029 /* If BGP scan is not enabled, we should install this route here. */
4030 if (! bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
4031 {
4032 bgp_static->valid = 1;
4033
4034 if (need_update)
4035 bgp_static_withdraw (bgp, &p, afi, safi);
4036
4037 if (! bgp_static->backdoor)
4038 bgp_static_update (bgp, &p, bgp_static, afi, safi);
4039 }
4040
4041 return CMD_SUCCESS;
4042}
4043
4044/* Configure static BGP network. */
paul94f2b392005-06-28 12:44:16 +00004045static int
paulfd79ac92004-10-13 05:06:08 +00004046bgp_static_unset (struct vty *vty, struct bgp *bgp, const char *ip_str,
Michael Lambert4c9641b2010-07-22 13:20:55 -04004047 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00004048{
4049 int ret;
4050 struct prefix p;
4051 struct bgp_static *bgp_static;
4052 struct bgp_node *rn;
4053
4054 /* Convert IP prefix string to struct prefix. */
4055 ret = str2prefix (ip_str, &p);
4056 if (! ret)
4057 {
4058 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4059 return CMD_WARNING;
4060 }
paul718e3742002-12-13 20:15:29 +00004061 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6))
4062 {
4063 vty_out (vty, "%% Malformed prefix (link-local address)%s",
4064 VTY_NEWLINE);
4065 return CMD_WARNING;
4066 }
paul718e3742002-12-13 20:15:29 +00004067
4068 apply_mask (&p);
4069
4070 rn = bgp_node_lookup (bgp->route[afi][safi], &p);
4071 if (! rn)
4072 {
4073 vty_out (vty, "%% Can't find specified static route configuration.%s",
4074 VTY_NEWLINE);
4075 return CMD_WARNING;
4076 }
4077
4078 bgp_static = rn->info;
Paul Jakma41367172007-08-06 15:24:51 +00004079
paul718e3742002-12-13 20:15:29 +00004080 /* Update BGP RIB. */
4081 if (! bgp_static->backdoor)
4082 bgp_static_withdraw (bgp, &p, afi, safi);
4083
4084 /* Clear configuration. */
4085 bgp_static_free (bgp_static);
4086 rn->info = NULL;
4087 bgp_unlock_node (rn);
4088 bgp_unlock_node (rn);
4089
4090 return CMD_SUCCESS;
4091}
4092
4093/* Called from bgp_delete(). Delete all static routes from the BGP
4094 instance. */
4095void
4096bgp_static_delete (struct bgp *bgp)
4097{
4098 afi_t afi;
4099 safi_t safi;
4100 struct bgp_node *rn;
4101 struct bgp_node *rm;
4102 struct bgp_table *table;
4103 struct bgp_static *bgp_static;
4104
4105 for (afi = AFI_IP; afi < AFI_MAX; afi++)
4106 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
4107 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
4108 if (rn->info != NULL)
4109 {
Lou Berger298cc2f2016-01-12 13:42:02 -05004110 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004111 {
4112 table = rn->info;
4113
4114 for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
4115 {
4116 bgp_static = rn->info;
Lou Bergera76d9ca2016-01-12 13:41:53 -05004117 bgp_static_withdraw_safi (bgp, &rm->p,
4118 AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00004119 (struct prefix_rd *)&rn->p,
4120 bgp_static->tag);
4121 bgp_static_free (bgp_static);
4122 rn->info = NULL;
4123 bgp_unlock_node (rn);
4124 }
4125 }
4126 else
4127 {
4128 bgp_static = rn->info;
4129 bgp_static_withdraw (bgp, &rn->p, afi, safi);
4130 bgp_static_free (bgp_static);
4131 rn->info = NULL;
4132 bgp_unlock_node (rn);
4133 }
4134 }
4135}
4136
Lou Bergera76d9ca2016-01-12 13:41:53 -05004137/*
4138 * gpz 110624
4139 * Currently this is used to set static routes for VPN and ENCAP.
4140 * I think it can probably be factored with bgp_static_set.
4141 */
paul718e3742002-12-13 20:15:29 +00004142int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004143bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
4144 const char *rd_str, const char *tag_str,
4145 const char *rmap_str)
paul718e3742002-12-13 20:15:29 +00004146{
4147 int ret;
4148 struct prefix p;
4149 struct prefix_rd prd;
4150 struct bgp *bgp;
4151 struct bgp_node *prn;
4152 struct bgp_node *rn;
4153 struct bgp_table *table;
4154 struct bgp_static *bgp_static;
4155 u_char tag[3];
4156
4157 bgp = vty->index;
4158
4159 ret = str2prefix (ip_str, &p);
4160 if (! ret)
4161 {
4162 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4163 return CMD_WARNING;
4164 }
4165 apply_mask (&p);
4166
4167 ret = str2prefix_rd (rd_str, &prd);
4168 if (! ret)
4169 {
4170 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4171 return CMD_WARNING;
4172 }
4173
4174 ret = str2tag (tag_str, tag);
4175 if (! ret)
4176 {
4177 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4178 return CMD_WARNING;
4179 }
4180
Lou Bergera76d9ca2016-01-12 13:41:53 -05004181 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004182 (struct prefix *)&prd);
4183 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004184 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004185 else
4186 bgp_unlock_node (prn);
4187 table = prn->info;
4188
4189 rn = bgp_node_get (table, &p);
4190
4191 if (rn->info)
4192 {
4193 vty_out (vty, "%% Same network configuration exists%s", VTY_NEWLINE);
4194 bgp_unlock_node (rn);
4195 }
4196 else
4197 {
4198 /* New configuration. */
4199 bgp_static = bgp_static_new ();
Lou Bergera76d9ca2016-01-12 13:41:53 -05004200 bgp_static->backdoor = 0;
4201 bgp_static->valid = 0;
4202 bgp_static->igpmetric = 0;
4203 bgp_static->igpnexthop.s_addr = 0;
4204 memcpy(bgp_static->tag, tag, 3);
4205 bgp_static->prd = prd;
4206
4207 if (rmap_str)
4208 {
4209 if (bgp_static->rmap.name)
4210 free (bgp_static->rmap.name);
4211 bgp_static->rmap.name = strdup (rmap_str);
4212 bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
4213 }
paul718e3742002-12-13 20:15:29 +00004214 rn->info = bgp_static;
4215
Lou Bergera76d9ca2016-01-12 13:41:53 -05004216 bgp_static->valid = 1;
4217 bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004218 }
4219
4220 return CMD_SUCCESS;
4221}
4222
4223/* Configure static BGP network. */
4224int
Lou Bergera76d9ca2016-01-12 13:41:53 -05004225bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
4226 const char *rd_str, const char *tag_str)
paul718e3742002-12-13 20:15:29 +00004227{
4228 int ret;
4229 struct bgp *bgp;
4230 struct prefix p;
4231 struct prefix_rd prd;
4232 struct bgp_node *prn;
4233 struct bgp_node *rn;
4234 struct bgp_table *table;
4235 struct bgp_static *bgp_static;
4236 u_char tag[3];
4237
4238 bgp = vty->index;
4239
4240 /* Convert IP prefix string to struct prefix. */
4241 ret = str2prefix (ip_str, &p);
4242 if (! ret)
4243 {
4244 vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE);
4245 return CMD_WARNING;
4246 }
4247 apply_mask (&p);
4248
4249 ret = str2prefix_rd (rd_str, &prd);
4250 if (! ret)
4251 {
4252 vty_out (vty, "%% Malformed rd%s", VTY_NEWLINE);
4253 return CMD_WARNING;
4254 }
4255
4256 ret = str2tag (tag_str, tag);
4257 if (! ret)
4258 {
4259 vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
4260 return CMD_WARNING;
4261 }
4262
Lou Bergera76d9ca2016-01-12 13:41:53 -05004263 prn = bgp_node_get (bgp->route[AFI_IP][safi],
paul718e3742002-12-13 20:15:29 +00004264 (struct prefix *)&prd);
4265 if (prn->info == NULL)
Lou Bergera76d9ca2016-01-12 13:41:53 -05004266 prn->info = bgp_table_init (AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00004267 else
4268 bgp_unlock_node (prn);
4269 table = prn->info;
4270
4271 rn = bgp_node_lookup (table, &p);
4272
4273 if (rn)
4274 {
Lou Bergera76d9ca2016-01-12 13:41:53 -05004275 bgp_static_withdraw_safi (bgp, &p, AFI_IP, safi, &prd, tag);
paul718e3742002-12-13 20:15:29 +00004276
4277 bgp_static = rn->info;
4278 bgp_static_free (bgp_static);
4279 rn->info = NULL;
4280 bgp_unlock_node (rn);
4281 bgp_unlock_node (rn);
4282 }
4283 else
4284 vty_out (vty, "%% Can't find the route%s", VTY_NEWLINE);
4285
4286 return CMD_SUCCESS;
4287}
David Lamparter6b0655a2014-06-04 06:53:35 +02004288
paul718e3742002-12-13 20:15:29 +00004289DEFUN (bgp_network,
4290 bgp_network_cmd,
4291 "network A.B.C.D/M",
4292 "Specify a network to announce via BGP\n"
4293 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4294{
4295 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004296 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004297}
4298
4299DEFUN (bgp_network_route_map,
4300 bgp_network_route_map_cmd,
4301 "network A.B.C.D/M route-map WORD",
4302 "Specify a network to announce via BGP\n"
4303 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4304 "Route-map to modify the attributes\n"
4305 "Name of the route map\n")
4306{
4307 return bgp_static_set (vty, vty->index, argv[0],
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004308 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004309}
4310
4311DEFUN (bgp_network_backdoor,
4312 bgp_network_backdoor_cmd,
4313 "network A.B.C.D/M backdoor",
4314 "Specify a network to announce via BGP\n"
4315 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4316 "Specify a BGP backdoor route\n")
4317{
Paul Jakma41367172007-08-06 15:24:51 +00004318 return bgp_static_set (vty, vty->index, argv[0], AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004319 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004320}
4321
4322DEFUN (bgp_network_mask,
4323 bgp_network_mask_cmd,
4324 "network A.B.C.D mask A.B.C.D",
4325 "Specify a network to announce via BGP\n"
4326 "Network number\n"
4327 "Network mask\n"
4328 "Network mask\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
4340 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004341 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004342}
4343
4344DEFUN (bgp_network_mask_route_map,
4345 bgp_network_mask_route_map_cmd,
4346 "network A.B.C.D mask A.B.C.D route-map WORD",
4347 "Specify a network to announce via BGP\n"
4348 "Network number\n"
4349 "Network mask\n"
4350 "Network mask\n"
4351 "Route-map to modify the attributes\n"
4352 "Name of the route map\n")
4353{
4354 int ret;
4355 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004356
paul718e3742002-12-13 20:15:29 +00004357 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4358 if (! ret)
4359 {
4360 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4361 return CMD_WARNING;
4362 }
4363
4364 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004365 AFI_IP, bgp_node_safi (vty), argv[2], 0);
paul718e3742002-12-13 20:15:29 +00004366}
4367
4368DEFUN (bgp_network_mask_backdoor,
4369 bgp_network_mask_backdoor_cmd,
4370 "network A.B.C.D mask A.B.C.D backdoor",
4371 "Specify a network to announce via BGP\n"
4372 "Network number\n"
4373 "Network mask\n"
4374 "Network mask\n"
4375 "Specify a BGP backdoor route\n")
4376{
4377 int ret;
4378 char prefix_str[BUFSIZ];
Paul Jakma41367172007-08-06 15:24:51 +00004379
paul718e3742002-12-13 20:15:29 +00004380 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4381 if (! ret)
4382 {
4383 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4384 return CMD_WARNING;
4385 }
4386
Paul Jakma41367172007-08-06 15:24:51 +00004387 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004388 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004389}
4390
4391DEFUN (bgp_network_mask_natural,
4392 bgp_network_mask_natural_cmd,
4393 "network A.B.C.D",
4394 "Specify a network to announce via BGP\n"
4395 "Network number\n")
4396{
4397 int ret;
4398 char prefix_str[BUFSIZ];
4399
4400 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4401 if (! ret)
4402 {
4403 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4404 return CMD_WARNING;
4405 }
4406
4407 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004408 AFI_IP, bgp_node_safi (vty), NULL, 0);
paul718e3742002-12-13 20:15:29 +00004409}
4410
4411DEFUN (bgp_network_mask_natural_route_map,
4412 bgp_network_mask_natural_route_map_cmd,
4413 "network A.B.C.D route-map WORD",
4414 "Specify a network to announce via BGP\n"
4415 "Network number\n"
4416 "Route-map to modify the attributes\n"
4417 "Name of the route map\n")
4418{
4419 int ret;
4420 char prefix_str[BUFSIZ];
4421
4422 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4423 if (! ret)
4424 {
4425 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4426 return CMD_WARNING;
4427 }
4428
4429 return bgp_static_set (vty, vty->index, prefix_str,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004430 AFI_IP, bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004431}
4432
4433DEFUN (bgp_network_mask_natural_backdoor,
4434 bgp_network_mask_natural_backdoor_cmd,
4435 "network A.B.C.D backdoor",
4436 "Specify a network to announce via BGP\n"
4437 "Network number\n"
4438 "Specify a BGP backdoor route\n")
4439{
4440 int ret;
4441 char prefix_str[BUFSIZ];
4442
4443 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4444 if (! ret)
4445 {
4446 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4447 return CMD_WARNING;
4448 }
4449
Paul Jakma41367172007-08-06 15:24:51 +00004450 return bgp_static_set (vty, vty->index, prefix_str, AFI_IP, SAFI_UNICAST,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004451 NULL, 1);
paul718e3742002-12-13 20:15:29 +00004452}
4453
4454DEFUN (no_bgp_network,
4455 no_bgp_network_cmd,
4456 "no network A.B.C.D/M",
4457 NO_STR
4458 "Specify a network to announce via BGP\n"
4459 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4460{
4461 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP,
4462 bgp_node_safi (vty));
4463}
4464
4465ALIAS (no_bgp_network,
4466 no_bgp_network_route_map_cmd,
4467 "no network A.B.C.D/M route-map WORD",
4468 NO_STR
4469 "Specify a network to announce via BGP\n"
4470 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4471 "Route-map to modify the attributes\n"
4472 "Name of the route map\n")
4473
4474ALIAS (no_bgp_network,
4475 no_bgp_network_backdoor_cmd,
4476 "no network A.B.C.D/M backdoor",
4477 NO_STR
4478 "Specify a network to announce via BGP\n"
4479 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4480 "Specify a BGP backdoor route\n")
4481
4482DEFUN (no_bgp_network_mask,
4483 no_bgp_network_mask_cmd,
4484 "no network A.B.C.D mask A.B.C.D",
4485 NO_STR
4486 "Specify a network to announce via BGP\n"
4487 "Network number\n"
4488 "Network mask\n"
4489 "Network mask\n")
4490{
4491 int ret;
4492 char prefix_str[BUFSIZ];
4493
4494 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
4495 if (! ret)
4496 {
4497 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4498 return CMD_WARNING;
4499 }
4500
4501 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4502 bgp_node_safi (vty));
4503}
4504
4505ALIAS (no_bgp_network_mask,
4506 no_bgp_network_mask_route_map_cmd,
4507 "no network A.B.C.D mask A.B.C.D route-map WORD",
4508 NO_STR
4509 "Specify a network to announce via BGP\n"
4510 "Network number\n"
4511 "Network mask\n"
4512 "Network mask\n"
4513 "Route-map to modify the attributes\n"
4514 "Name of the route map\n")
4515
4516ALIAS (no_bgp_network_mask,
4517 no_bgp_network_mask_backdoor_cmd,
4518 "no network A.B.C.D mask A.B.C.D backdoor",
4519 NO_STR
4520 "Specify a network to announce via BGP\n"
4521 "Network number\n"
4522 "Network mask\n"
4523 "Network mask\n"
4524 "Specify a BGP backdoor route\n")
4525
4526DEFUN (no_bgp_network_mask_natural,
4527 no_bgp_network_mask_natural_cmd,
4528 "no network A.B.C.D",
4529 NO_STR
4530 "Specify a network to announce via BGP\n"
4531 "Network number\n")
4532{
4533 int ret;
4534 char prefix_str[BUFSIZ];
4535
4536 ret = netmask_str2prefix_str (argv[0], NULL, prefix_str);
4537 if (! ret)
4538 {
4539 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
4540 return CMD_WARNING;
4541 }
4542
4543 return bgp_static_unset (vty, vty->index, prefix_str, AFI_IP,
4544 bgp_node_safi (vty));
4545}
4546
4547ALIAS (no_bgp_network_mask_natural,
4548 no_bgp_network_mask_natural_route_map_cmd,
4549 "no network A.B.C.D route-map WORD",
4550 NO_STR
4551 "Specify a network to announce via BGP\n"
4552 "Network number\n"
4553 "Route-map to modify the attributes\n"
4554 "Name of the route map\n")
4555
4556ALIAS (no_bgp_network_mask_natural,
4557 no_bgp_network_mask_natural_backdoor_cmd,
4558 "no network A.B.C.D backdoor",
4559 NO_STR
4560 "Specify a network to announce via BGP\n"
4561 "Network number\n"
4562 "Specify a BGP backdoor route\n")
4563
paul718e3742002-12-13 20:15:29 +00004564DEFUN (ipv6_bgp_network,
4565 ipv6_bgp_network_cmd,
4566 "network X:X::X:X/M",
4567 "Specify a network to announce via BGP\n"
4568 "IPv6 prefix <network>/<length>\n")
4569{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304570 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty),
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004571 NULL, 0);
paul718e3742002-12-13 20:15:29 +00004572}
4573
4574DEFUN (ipv6_bgp_network_route_map,
4575 ipv6_bgp_network_route_map_cmd,
4576 "network X:X::X:X/M route-map WORD",
4577 "Specify a network to announce via BGP\n"
4578 "IPv6 prefix <network>/<length>\n"
4579 "Route-map to modify the attributes\n"
4580 "Name of the route map\n")
4581{
4582 return bgp_static_set (vty, vty->index, argv[0], AFI_IP6,
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004583 bgp_node_safi (vty), argv[1], 0);
paul718e3742002-12-13 20:15:29 +00004584}
4585
4586DEFUN (no_ipv6_bgp_network,
4587 no_ipv6_bgp_network_cmd,
4588 "no network X:X::X:X/M",
4589 NO_STR
4590 "Specify a network to announce via BGP\n"
4591 "IPv6 prefix <network>/<length>\n")
4592{
G.Balaji73bfe0b2011-09-23 22:36:20 +05304593 return bgp_static_unset (vty, vty->index, argv[0], AFI_IP6, bgp_node_safi(vty));
paul718e3742002-12-13 20:15:29 +00004594}
4595
4596ALIAS (no_ipv6_bgp_network,
4597 no_ipv6_bgp_network_route_map_cmd,
4598 "no network X:X::X:X/M route-map WORD",
4599 NO_STR
4600 "Specify a network to announce via BGP\n"
4601 "IPv6 prefix <network>/<length>\n"
4602 "Route-map to modify the attributes\n"
4603 "Name of the route map\n")
4604
4605ALIAS (ipv6_bgp_network,
4606 old_ipv6_bgp_network_cmd,
4607 "ipv6 bgp network X:X::X:X/M",
4608 IPV6_STR
4609 BGP_STR
4610 "Specify a network to announce via BGP\n"
4611 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4612
4613ALIAS (no_ipv6_bgp_network,
4614 old_no_ipv6_bgp_network_cmd,
4615 "no ipv6 bgp network X:X::X:X/M",
4616 NO_STR
4617 IPV6_STR
4618 BGP_STR
4619 "Specify a network to announce via BGP\n"
4620 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004621
4622/* stubs for removed AS-Pathlimit commands, kept for config compatibility */
4623ALIAS_DEPRECATED (bgp_network,
4624 bgp_network_ttl_cmd,
4625 "network A.B.C.D/M pathlimit <0-255>",
4626 "Specify a network to announce via BGP\n"
4627 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4628 "AS-Path hopcount limit attribute\n"
4629 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4630ALIAS_DEPRECATED (bgp_network_backdoor,
4631 bgp_network_backdoor_ttl_cmd,
4632 "network A.B.C.D/M backdoor pathlimit <0-255>",
4633 "Specify a network to announce via BGP\n"
4634 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4635 "Specify a BGP backdoor route\n"
4636 "AS-Path hopcount limit attribute\n"
4637 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4638ALIAS_DEPRECATED (bgp_network_mask,
4639 bgp_network_mask_ttl_cmd,
4640 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4641 "Specify a network to announce via BGP\n"
4642 "Network number\n"
4643 "Network mask\n"
4644 "Network mask\n"
4645 "AS-Path hopcount limit attribute\n"
4646 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4647ALIAS_DEPRECATED (bgp_network_mask_backdoor,
4648 bgp_network_mask_backdoor_ttl_cmd,
4649 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4650 "Specify a network to announce via BGP\n"
4651 "Network number\n"
4652 "Network mask\n"
4653 "Network mask\n"
4654 "Specify a BGP backdoor route\n"
4655 "AS-Path hopcount limit attribute\n"
4656 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4657ALIAS_DEPRECATED (bgp_network_mask_natural,
4658 bgp_network_mask_natural_ttl_cmd,
4659 "network A.B.C.D pathlimit <0-255>",
4660 "Specify a network to announce via BGP\n"
4661 "Network number\n"
4662 "AS-Path hopcount limit attribute\n"
4663 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4664ALIAS_DEPRECATED (bgp_network_mask_natural_backdoor,
4665 bgp_network_mask_natural_backdoor_ttl_cmd,
Christian Franke2b005152013-09-30 12:27:49 +00004666 "network A.B.C.D backdoor pathlimit <1-255>",
Paul Jakmac8f3fe32010-12-05 20:28:02 +00004667 "Specify a network to announce via BGP\n"
4668 "Network number\n"
4669 "Specify a BGP backdoor route\n"
4670 "AS-Path hopcount limit attribute\n"
4671 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4672ALIAS_DEPRECATED (no_bgp_network,
4673 no_bgp_network_ttl_cmd,
4674 "no network A.B.C.D/M pathlimit <0-255>",
4675 NO_STR
4676 "Specify a network to announce via BGP\n"
4677 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4678 "AS-Path hopcount limit attribute\n"
4679 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4680ALIAS_DEPRECATED (no_bgp_network,
4681 no_bgp_network_backdoor_ttl_cmd,
4682 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4683 NO_STR
4684 "Specify a network to announce via BGP\n"
4685 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4686 "Specify a BGP backdoor route\n"
4687 "AS-Path hopcount limit attribute\n"
4688 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4689ALIAS_DEPRECATED (no_bgp_network,
4690 no_bgp_network_mask_ttl_cmd,
4691 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4692 NO_STR
4693 "Specify a network to announce via BGP\n"
4694 "Network number\n"
4695 "Network mask\n"
4696 "Network mask\n"
4697 "AS-Path hopcount limit attribute\n"
4698 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4699ALIAS_DEPRECATED (no_bgp_network_mask,
4700 no_bgp_network_mask_backdoor_ttl_cmd,
4701 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4702 NO_STR
4703 "Specify a network to announce via BGP\n"
4704 "Network number\n"
4705 "Network mask\n"
4706 "Network mask\n"
4707 "Specify a BGP backdoor route\n"
4708 "AS-Path hopcount limit attribute\n"
4709 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4710ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4711 no_bgp_network_mask_natural_ttl_cmd,
4712 "no network A.B.C.D pathlimit <0-255>",
4713 NO_STR
4714 "Specify a network to announce via BGP\n"
4715 "Network number\n"
4716 "AS-Path hopcount limit attribute\n"
4717 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4718ALIAS_DEPRECATED (no_bgp_network_mask_natural,
4719 no_bgp_network_mask_natural_backdoor_ttl_cmd,
4720 "no network A.B.C.D backdoor pathlimit <0-255>",
4721 NO_STR
4722 "Specify a network to announce via BGP\n"
4723 "Network number\n"
4724 "Specify a BGP backdoor route\n"
4725 "AS-Path hopcount limit attribute\n"
4726 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4727ALIAS_DEPRECATED (ipv6_bgp_network,
4728 ipv6_bgp_network_ttl_cmd,
4729 "network X:X::X:X/M pathlimit <0-255>",
4730 "Specify a network to announce via BGP\n"
4731 "IPv6 prefix <network>/<length>\n"
4732 "AS-Path hopcount limit attribute\n"
4733 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4734ALIAS_DEPRECATED (no_ipv6_bgp_network,
4735 no_ipv6_bgp_network_ttl_cmd,
4736 "no network X:X::X:X/M pathlimit <0-255>",
4737 NO_STR
4738 "Specify a network to announce via BGP\n"
4739 "IPv6 prefix <network>/<length>\n"
4740 "AS-Path hopcount limit attribute\n"
4741 "AS-Pathlimit TTL, in number of AS-Path hops\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02004742
paul718e3742002-12-13 20:15:29 +00004743/* Aggreagete address:
4744
4745 advertise-map Set condition to advertise attribute
4746 as-set Generate AS set path information
4747 attribute-map Set attributes of aggregate
4748 route-map Set parameters of aggregate
4749 summary-only Filter more specific routes from updates
4750 suppress-map Conditionally filter more specific routes from updates
4751 <cr>
4752 */
4753struct bgp_aggregate
4754{
4755 /* Summary-only flag. */
4756 u_char summary_only;
4757
4758 /* AS set generation. */
4759 u_char as_set;
4760
4761 /* Route-map for aggregated route. */
4762 struct route_map *map;
4763
4764 /* Suppress-count. */
4765 unsigned long count;
4766
4767 /* SAFI configuration. */
4768 safi_t safi;
4769};
4770
paul94f2b392005-06-28 12:44:16 +00004771static struct bgp_aggregate *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -08004772bgp_aggregate_new (void)
paul718e3742002-12-13 20:15:29 +00004773{
Stephen Hemminger393deb92008-08-18 14:13:29 -07004774 return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
paul718e3742002-12-13 20:15:29 +00004775}
4776
paul94f2b392005-06-28 12:44:16 +00004777static void
paul718e3742002-12-13 20:15:29 +00004778bgp_aggregate_free (struct bgp_aggregate *aggregate)
4779{
4780 XFREE (MTYPE_BGP_AGGREGATE, aggregate);
4781}
4782
paul94f2b392005-06-28 12:44:16 +00004783static void
paul718e3742002-12-13 20:15:29 +00004784bgp_aggregate_route (struct bgp *bgp, struct prefix *p, struct bgp_info *rinew,
4785 afi_t afi, safi_t safi, struct bgp_info *del,
4786 struct bgp_aggregate *aggregate)
4787{
4788 struct bgp_table *table;
4789 struct bgp_node *top;
4790 struct bgp_node *rn;
4791 u_char origin;
4792 struct aspath *aspath = NULL;
4793 struct aspath *asmerge = NULL;
4794 struct community *community = NULL;
4795 struct community *commerge = NULL;
paul718e3742002-12-13 20:15:29 +00004796 struct bgp_info *ri;
4797 struct bgp_info *new;
4798 int first = 1;
4799 unsigned long match = 0;
4800
paul718e3742002-12-13 20:15:29 +00004801 /* ORIGIN attribute: If at least one route among routes that are
4802 aggregated has ORIGIN with the value INCOMPLETE, then the
4803 aggregated route must have the ORIGIN attribute with the value
4804 INCOMPLETE. Otherwise, if at least one route among routes that
4805 are aggregated has ORIGIN with the value EGP, then the aggregated
4806 route must have the origin attribute with the value EGP. In all
4807 other case the value of the ORIGIN attribute of the aggregated
4808 route is INTERNAL. */
4809 origin = BGP_ORIGIN_IGP;
4810
4811 table = bgp->rib[afi][safi];
4812
4813 top = bgp_node_get (table, p);
4814 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
4815 if (rn->p.prefixlen > p->prefixlen)
4816 {
4817 match = 0;
4818
4819 for (ri = rn->info; ri; ri = ri->next)
4820 {
4821 if (BGP_INFO_HOLDDOWN (ri))
4822 continue;
4823
4824 if (del && ri == del)
4825 continue;
4826
4827 if (! rinew && first)
Paul Jakma7aa9dce2014-09-19 14:42:23 +01004828 first = 0;
paul718e3742002-12-13 20:15:29 +00004829
4830#ifdef AGGREGATE_NEXTHOP_CHECK
4831 if (! IPV4_ADDR_SAME (&ri->attr->nexthop, &nexthop)
4832 || ri->attr->med != med)
4833 {
4834 if (aspath)
4835 aspath_free (aspath);
4836 if (community)
4837 community_free (community);
4838 bgp_unlock_node (rn);
4839 bgp_unlock_node (top);
4840 return;
4841 }
4842#endif /* AGGREGATE_NEXTHOP_CHECK */
4843
4844 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
4845 {
4846 if (aggregate->summary_only)
4847 {
Paul Jakmafb982c22007-05-04 20:15:47 +00004848 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00004849 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00004850 match++;
4851 }
4852
4853 aggregate->count++;
4854
4855 if (aggregate->as_set)
4856 {
4857 if (origin < ri->attr->origin)
4858 origin = ri->attr->origin;
4859
4860 if (aspath)
4861 {
4862 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
4863 aspath_free (aspath);
4864 aspath = asmerge;
4865 }
4866 else
4867 aspath = aspath_dup (ri->attr->aspath);
4868
4869 if (ri->attr->community)
4870 {
4871 if (community)
4872 {
4873 commerge = community_merge (community,
4874 ri->attr->community);
4875 community = community_uniq_sort (commerge);
4876 community_free (commerge);
4877 }
4878 else
4879 community = community_dup (ri->attr->community);
4880 }
4881 }
4882 }
4883 }
4884 if (match)
4885 bgp_process (bgp, rn, afi, safi);
4886 }
4887 bgp_unlock_node (top);
4888
4889 if (rinew)
4890 {
4891 aggregate->count++;
4892
4893 if (aggregate->summary_only)
Paul Jakmafb982c22007-05-04 20:15:47 +00004894 (bgp_info_extra_get (rinew))->suppress++;
paul718e3742002-12-13 20:15:29 +00004895
4896 if (aggregate->as_set)
4897 {
4898 if (origin < rinew->attr->origin)
4899 origin = rinew->attr->origin;
4900
4901 if (aspath)
4902 {
4903 asmerge = aspath_aggregate (aspath, rinew->attr->aspath);
4904 aspath_free (aspath);
4905 aspath = asmerge;
4906 }
4907 else
4908 aspath = aspath_dup (rinew->attr->aspath);
4909
4910 if (rinew->attr->community)
4911 {
4912 if (community)
4913 {
4914 commerge = community_merge (community,
4915 rinew->attr->community);
4916 community = community_uniq_sort (commerge);
4917 community_free (commerge);
4918 }
4919 else
4920 community = community_dup (rinew->attr->community);
4921 }
4922 }
4923 }
4924
4925 if (aggregate->count > 0)
4926 {
4927 rn = bgp_node_get (table, p);
4928 new = bgp_info_new ();
4929 new->type = ZEBRA_ROUTE_BGP;
4930 new->sub_type = BGP_ROUTE_AGGREGATE;
4931 new->peer = bgp->peer_self;
4932 SET_FLAG (new->flags, BGP_INFO_VALID);
4933 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03004934 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00004935
4936 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00004937 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00004938 bgp_process (bgp, rn, afi, safi);
4939 }
4940 else
4941 {
4942 if (aspath)
4943 aspath_free (aspath);
4944 if (community)
4945 community_free (community);
4946 }
4947}
4948
4949void bgp_aggregate_delete (struct bgp *, struct prefix *, afi_t, safi_t,
4950 struct bgp_aggregate *);
4951
4952void
4953bgp_aggregate_increment (struct bgp *bgp, struct prefix *p,
4954 struct bgp_info *ri, afi_t afi, safi_t safi)
4955{
4956 struct bgp_node *child;
4957 struct bgp_node *rn;
4958 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004959 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004960
4961 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004962 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00004963 return;
4964
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004965 table = bgp->aggregate[afi][safi];
4966
4967 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004968 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004969 return;
4970
paul718e3742002-12-13 20:15:29 +00004971 if (p->prefixlen == 0)
4972 return;
4973
4974 if (BGP_INFO_HOLDDOWN (ri))
4975 return;
4976
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02004977 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00004978
4979 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07004980 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00004981 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
4982 {
4983 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00004984 bgp_aggregate_route (bgp, &rn->p, ri, afi, safi, NULL, aggregate);
paul718e3742002-12-13 20:15:29 +00004985 }
4986 bgp_unlock_node (child);
4987}
4988
4989void
4990bgp_aggregate_decrement (struct bgp *bgp, struct prefix *p,
4991 struct bgp_info *del, afi_t afi, safi_t safi)
4992{
4993 struct bgp_node *child;
4994 struct bgp_node *rn;
4995 struct bgp_aggregate *aggregate;
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00004996 struct bgp_table *table;
paul718e3742002-12-13 20:15:29 +00004997
4998 /* MPLS-VPN aggregation is not yet supported. */
Lou Berger298cc2f2016-01-12 13:42:02 -05004999 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00005000 return;
5001
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005002 table = bgp->aggregate[afi][safi];
5003
5004 /* No aggregates configured. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005005 if (bgp_table_top_nolock (table) == NULL)
Jorge Boncompte [DTI2]f018db82012-05-07 16:53:10 +00005006 return;
5007
paul718e3742002-12-13 20:15:29 +00005008 if (p->prefixlen == 0)
5009 return;
5010
Jorge Boncompte [DTI2]bb782fb2012-06-20 16:34:01 +02005011 child = bgp_node_get (table, p);
paul718e3742002-12-13 20:15:29 +00005012
5013 /* Aggregate address configuration check. */
Avneesh Sachdev67174042012-08-17 08:19:49 -07005014 for (rn = child; rn; rn = bgp_node_parent_nolock (rn))
paul718e3742002-12-13 20:15:29 +00005015 if ((aggregate = rn->info) != NULL && rn->p.prefixlen < p->prefixlen)
5016 {
5017 bgp_aggregate_delete (bgp, &rn->p, afi, safi, aggregate);
paul286e1e72003-08-08 00:24:31 +00005018 bgp_aggregate_route (bgp, &rn->p, NULL, afi, safi, del, aggregate);
paul718e3742002-12-13 20:15:29 +00005019 }
5020 bgp_unlock_node (child);
5021}
5022
paul94f2b392005-06-28 12:44:16 +00005023static void
paul718e3742002-12-13 20:15:29 +00005024bgp_aggregate_add (struct bgp *bgp, struct prefix *p, afi_t afi, safi_t safi,
5025 struct bgp_aggregate *aggregate)
5026{
5027 struct bgp_table *table;
5028 struct bgp_node *top;
5029 struct bgp_node *rn;
5030 struct bgp_info *new;
5031 struct bgp_info *ri;
5032 unsigned long match;
5033 u_char origin = BGP_ORIGIN_IGP;
5034 struct aspath *aspath = NULL;
5035 struct aspath *asmerge = NULL;
5036 struct community *community = NULL;
5037 struct community *commerge = NULL;
5038
5039 table = bgp->rib[afi][safi];
5040
5041 /* Sanity check. */
5042 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5043 return;
5044 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5045 return;
5046
5047 /* If routes exists below this node, generate aggregate routes. */
5048 top = bgp_node_get (table, p);
5049 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5050 if (rn->p.prefixlen > p->prefixlen)
5051 {
5052 match = 0;
5053
5054 for (ri = rn->info; ri; ri = ri->next)
5055 {
5056 if (BGP_INFO_HOLDDOWN (ri))
5057 continue;
5058
5059 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5060 {
5061 /* summary-only aggregate route suppress aggregated
5062 route announcement. */
5063 if (aggregate->summary_only)
5064 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005065 (bgp_info_extra_get (ri))->suppress++;
Paul Jakma1a392d42006-09-07 00:24:49 +00005066 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005067 match++;
5068 }
5069 /* as-set aggregate route generate origin, as path,
5070 community aggregation. */
5071 if (aggregate->as_set)
5072 {
5073 if (origin < ri->attr->origin)
5074 origin = ri->attr->origin;
5075
5076 if (aspath)
5077 {
5078 asmerge = aspath_aggregate (aspath, ri->attr->aspath);
5079 aspath_free (aspath);
5080 aspath = asmerge;
5081 }
5082 else
5083 aspath = aspath_dup (ri->attr->aspath);
5084
5085 if (ri->attr->community)
5086 {
5087 if (community)
5088 {
5089 commerge = community_merge (community,
5090 ri->attr->community);
5091 community = community_uniq_sort (commerge);
5092 community_free (commerge);
5093 }
5094 else
5095 community = community_dup (ri->attr->community);
5096 }
5097 }
5098 aggregate->count++;
5099 }
5100 }
5101
5102 /* If this node is suppressed, process the change. */
5103 if (match)
5104 bgp_process (bgp, rn, afi, safi);
5105 }
5106 bgp_unlock_node (top);
5107
5108 /* Add aggregate route to BGP table. */
5109 if (aggregate->count)
5110 {
5111 rn = bgp_node_get (table, p);
5112
5113 new = bgp_info_new ();
5114 new->type = ZEBRA_ROUTE_BGP;
5115 new->sub_type = BGP_ROUTE_AGGREGATE;
5116 new->peer = bgp->peer_self;
5117 SET_FLAG (new->flags, BGP_INFO_VALID);
5118 new->attr = bgp_attr_aggregate_intern (bgp, origin, aspath, community, aggregate->as_set);
Stephen Hemminger65957882010-01-15 16:22:10 +03005119 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005120
5121 bgp_info_add (rn, new);
paul200df112005-06-01 11:17:05 +00005122 bgp_unlock_node (rn);
5123
paul718e3742002-12-13 20:15:29 +00005124 /* Process change. */
5125 bgp_process (bgp, rn, afi, safi);
5126 }
Denil Virae2a92582015-08-11 13:34:59 -07005127 else
5128 {
5129 if (aspath)
5130 aspath_free (aspath);
5131 if (community)
5132 community_free (community);
5133 }
paul718e3742002-12-13 20:15:29 +00005134}
5135
5136void
5137bgp_aggregate_delete (struct bgp *bgp, struct prefix *p, afi_t afi,
5138 safi_t safi, struct bgp_aggregate *aggregate)
5139{
5140 struct bgp_table *table;
5141 struct bgp_node *top;
5142 struct bgp_node *rn;
5143 struct bgp_info *ri;
5144 unsigned long match;
5145
5146 table = bgp->rib[afi][safi];
5147
5148 if (afi == AFI_IP && p->prefixlen == IPV4_MAX_BITLEN)
5149 return;
5150 if (afi == AFI_IP6 && p->prefixlen == IPV6_MAX_BITLEN)
5151 return;
5152
5153 /* If routes exists below this node, generate aggregate routes. */
5154 top = bgp_node_get (table, p);
5155 for (rn = bgp_node_get (table, p); rn; rn = bgp_route_next_until (rn, top))
5156 if (rn->p.prefixlen > p->prefixlen)
5157 {
5158 match = 0;
5159
5160 for (ri = rn->info; ri; ri = ri->next)
5161 {
5162 if (BGP_INFO_HOLDDOWN (ri))
5163 continue;
5164
5165 if (ri->sub_type != BGP_ROUTE_AGGREGATE)
5166 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005167 if (aggregate->summary_only && ri->extra)
paul718e3742002-12-13 20:15:29 +00005168 {
Paul Jakmafb982c22007-05-04 20:15:47 +00005169 ri->extra->suppress--;
paul718e3742002-12-13 20:15:29 +00005170
Paul Jakmafb982c22007-05-04 20:15:47 +00005171 if (ri->extra->suppress == 0)
paul718e3742002-12-13 20:15:29 +00005172 {
Paul Jakma1a392d42006-09-07 00:24:49 +00005173 bgp_info_set_flag (rn, ri, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005174 match++;
5175 }
5176 }
5177 aggregate->count--;
5178 }
5179 }
5180
Paul Jakmafb982c22007-05-04 20:15:47 +00005181 /* If this node was suppressed, process the change. */
paul718e3742002-12-13 20:15:29 +00005182 if (match)
5183 bgp_process (bgp, rn, afi, safi);
5184 }
5185 bgp_unlock_node (top);
5186
5187 /* Delete aggregate route from BGP table. */
5188 rn = bgp_node_get (table, p);
5189
5190 for (ri = rn->info; ri; ri = ri->next)
5191 if (ri->peer == bgp->peer_self
5192 && ri->type == ZEBRA_ROUTE_BGP
5193 && ri->sub_type == BGP_ROUTE_AGGREGATE)
5194 break;
5195
5196 /* Withdraw static BGP route from routing table. */
5197 if (ri)
5198 {
paul718e3742002-12-13 20:15:29 +00005199 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005200 bgp_process (bgp, rn, afi, safi);
paul718e3742002-12-13 20:15:29 +00005201 }
5202
5203 /* Unlock bgp_node_lookup. */
5204 bgp_unlock_node (rn);
5205}
5206
5207/* Aggregate route attribute. */
5208#define AGGREGATE_SUMMARY_ONLY 1
5209#define AGGREGATE_AS_SET 1
5210
paul94f2b392005-06-28 12:44:16 +00005211static int
Robert Baysf6269b42010-08-05 10:26:28 -07005212bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
5213 afi_t afi, safi_t safi)
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_lookup (bgp->aggregate[afi][safi], &p);
5235 if (! rn)
5236 {
5237 vty_out (vty, "%% There is no aggregate-address configuration.%s",
5238 VTY_NEWLINE);
5239 return CMD_WARNING;
5240 }
5241
5242 aggregate = rn->info;
5243 if (aggregate->safi & SAFI_UNICAST)
5244 bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
5245 if (aggregate->safi & SAFI_MULTICAST)
5246 bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5247
5248 /* Unlock aggregate address configuration. */
5249 rn->info = NULL;
5250 bgp_aggregate_free (aggregate);
5251 bgp_unlock_node (rn);
5252 bgp_unlock_node (rn);
5253
5254 return CMD_SUCCESS;
5255}
5256
5257static int
5258bgp_aggregate_set (struct vty *vty, const char *prefix_str,
paulfd79ac92004-10-13 05:06:08 +00005259 afi_t afi, safi_t safi,
paul718e3742002-12-13 20:15:29 +00005260 u_char summary_only, u_char as_set)
5261{
5262 int ret;
5263 struct prefix p;
5264 struct bgp_node *rn;
5265 struct bgp *bgp;
5266 struct bgp_aggregate *aggregate;
5267
5268 /* Convert string to prefix structure. */
5269 ret = str2prefix (prefix_str, &p);
5270 if (!ret)
5271 {
5272 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
5273 return CMD_WARNING;
5274 }
5275 apply_mask (&p);
5276
5277 /* Get BGP structure. */
5278 bgp = vty->index;
5279
5280 /* Old configuration check. */
5281 rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
5282
5283 if (rn->info)
5284 {
5285 vty_out (vty, "There is already same aggregate network.%s", VTY_NEWLINE);
Robert Bays368473f2010-08-05 10:26:29 -07005286 /* try to remove the old entry */
Robert Baysf6269b42010-08-05 10:26:28 -07005287 ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
5288 if (ret)
5289 {
Robert Bays368473f2010-08-05 10:26:29 -07005290 vty_out (vty, "Error deleting aggregate.%s", VTY_NEWLINE);
5291 bgp_unlock_node (rn);
Robert Baysf6269b42010-08-05 10:26:28 -07005292 return CMD_WARNING;
5293 }
paul718e3742002-12-13 20:15:29 +00005294 }
5295
5296 /* Make aggregate address structure. */
5297 aggregate = bgp_aggregate_new ();
5298 aggregate->summary_only = summary_only;
5299 aggregate->as_set = as_set;
5300 aggregate->safi = safi;
5301 rn->info = aggregate;
5302
5303 /* Aggregate address insert into BGP routing table. */
5304 if (safi & SAFI_UNICAST)
5305 bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
5306 if (safi & SAFI_MULTICAST)
5307 bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
5308
5309 return CMD_SUCCESS;
5310}
5311
paul718e3742002-12-13 20:15:29 +00005312DEFUN (aggregate_address,
5313 aggregate_address_cmd,
5314 "aggregate-address A.B.C.D/M",
5315 "Configure BGP aggregate entries\n"
5316 "Aggregate prefix\n")
5317{
5318 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty), 0, 0);
5319}
5320
5321DEFUN (aggregate_address_mask,
5322 aggregate_address_mask_cmd,
5323 "aggregate-address A.B.C.D A.B.C.D",
5324 "Configure BGP aggregate entries\n"
5325 "Aggregate address\n"
5326 "Aggregate mask\n")
5327{
5328 int ret;
5329 char prefix_str[BUFSIZ];
5330
5331 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5332
5333 if (! ret)
5334 {
5335 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5336 return CMD_WARNING;
5337 }
5338
5339 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5340 0, 0);
5341}
5342
5343DEFUN (aggregate_address_summary_only,
5344 aggregate_address_summary_only_cmd,
5345 "aggregate-address A.B.C.D/M summary-only",
5346 "Configure BGP aggregate entries\n"
5347 "Aggregate prefix\n"
5348 "Filter more specific routes from updates\n")
5349{
5350 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5351 AGGREGATE_SUMMARY_ONLY, 0);
5352}
5353
5354DEFUN (aggregate_address_mask_summary_only,
5355 aggregate_address_mask_summary_only_cmd,
5356 "aggregate-address A.B.C.D A.B.C.D summary-only",
5357 "Configure BGP aggregate entries\n"
5358 "Aggregate address\n"
5359 "Aggregate mask\n"
5360 "Filter more specific routes from updates\n")
5361{
5362 int ret;
5363 char prefix_str[BUFSIZ];
5364
5365 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5366
5367 if (! ret)
5368 {
5369 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5370 return CMD_WARNING;
5371 }
5372
5373 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5374 AGGREGATE_SUMMARY_ONLY, 0);
5375}
5376
5377DEFUN (aggregate_address_as_set,
5378 aggregate_address_as_set_cmd,
5379 "aggregate-address A.B.C.D/M as-set",
5380 "Configure BGP aggregate entries\n"
5381 "Aggregate prefix\n"
5382 "Generate AS set path information\n")
5383{
5384 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5385 0, AGGREGATE_AS_SET);
5386}
5387
5388DEFUN (aggregate_address_mask_as_set,
5389 aggregate_address_mask_as_set_cmd,
5390 "aggregate-address A.B.C.D A.B.C.D as-set",
5391 "Configure BGP aggregate entries\n"
5392 "Aggregate address\n"
5393 "Aggregate mask\n"
5394 "Generate AS set path information\n")
5395{
5396 int ret;
5397 char prefix_str[BUFSIZ];
5398
5399 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5400
5401 if (! ret)
5402 {
5403 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5404 return CMD_WARNING;
5405 }
5406
5407 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5408 0, AGGREGATE_AS_SET);
5409}
5410
5411
5412DEFUN (aggregate_address_as_set_summary,
5413 aggregate_address_as_set_summary_cmd,
5414 "aggregate-address A.B.C.D/M as-set summary-only",
5415 "Configure BGP aggregate entries\n"
5416 "Aggregate prefix\n"
5417 "Generate AS set path information\n"
5418 "Filter more specific routes from updates\n")
5419{
5420 return bgp_aggregate_set (vty, argv[0], AFI_IP, bgp_node_safi (vty),
5421 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5422}
5423
5424ALIAS (aggregate_address_as_set_summary,
5425 aggregate_address_summary_as_set_cmd,
5426 "aggregate-address A.B.C.D/M summary-only as-set",
5427 "Configure BGP aggregate entries\n"
5428 "Aggregate prefix\n"
5429 "Filter more specific routes from updates\n"
5430 "Generate AS set path information\n")
5431
5432DEFUN (aggregate_address_mask_as_set_summary,
5433 aggregate_address_mask_as_set_summary_cmd,
5434 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5435 "Configure BGP aggregate entries\n"
5436 "Aggregate address\n"
5437 "Aggregate mask\n"
5438 "Generate AS set path information\n"
5439 "Filter more specific routes from updates\n")
5440{
5441 int ret;
5442 char prefix_str[BUFSIZ];
5443
5444 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5445
5446 if (! ret)
5447 {
5448 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5449 return CMD_WARNING;
5450 }
5451
5452 return bgp_aggregate_set (vty, prefix_str, AFI_IP, bgp_node_safi (vty),
5453 AGGREGATE_SUMMARY_ONLY, AGGREGATE_AS_SET);
5454}
5455
5456ALIAS (aggregate_address_mask_as_set_summary,
5457 aggregate_address_mask_summary_as_set_cmd,
5458 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5459 "Configure BGP aggregate entries\n"
5460 "Aggregate address\n"
5461 "Aggregate mask\n"
5462 "Filter more specific routes from updates\n"
5463 "Generate AS set path information\n")
5464
5465DEFUN (no_aggregate_address,
5466 no_aggregate_address_cmd,
5467 "no aggregate-address A.B.C.D/M",
5468 NO_STR
5469 "Configure BGP aggregate entries\n"
5470 "Aggregate prefix\n")
5471{
5472 return bgp_aggregate_unset (vty, argv[0], AFI_IP, bgp_node_safi (vty));
5473}
5474
5475ALIAS (no_aggregate_address,
5476 no_aggregate_address_summary_only_cmd,
5477 "no aggregate-address A.B.C.D/M summary-only",
5478 NO_STR
5479 "Configure BGP aggregate entries\n"
5480 "Aggregate prefix\n"
5481 "Filter more specific routes from updates\n")
5482
5483ALIAS (no_aggregate_address,
5484 no_aggregate_address_as_set_cmd,
5485 "no aggregate-address A.B.C.D/M as-set",
5486 NO_STR
5487 "Configure BGP aggregate entries\n"
5488 "Aggregate prefix\n"
5489 "Generate AS set path information\n")
5490
5491ALIAS (no_aggregate_address,
5492 no_aggregate_address_as_set_summary_cmd,
5493 "no aggregate-address A.B.C.D/M as-set summary-only",
5494 NO_STR
5495 "Configure BGP aggregate entries\n"
5496 "Aggregate prefix\n"
5497 "Generate AS set path information\n"
5498 "Filter more specific routes from updates\n")
5499
5500ALIAS (no_aggregate_address,
5501 no_aggregate_address_summary_as_set_cmd,
5502 "no aggregate-address A.B.C.D/M summary-only as-set",
5503 NO_STR
5504 "Configure BGP aggregate entries\n"
5505 "Aggregate prefix\n"
5506 "Filter more specific routes from updates\n"
5507 "Generate AS set path information\n")
5508
5509DEFUN (no_aggregate_address_mask,
5510 no_aggregate_address_mask_cmd,
5511 "no aggregate-address A.B.C.D A.B.C.D",
5512 NO_STR
5513 "Configure BGP aggregate entries\n"
5514 "Aggregate address\n"
5515 "Aggregate mask\n")
5516{
5517 int ret;
5518 char prefix_str[BUFSIZ];
5519
5520 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
5521
5522 if (! ret)
5523 {
5524 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
5525 return CMD_WARNING;
5526 }
5527
5528 return bgp_aggregate_unset (vty, prefix_str, AFI_IP, bgp_node_safi (vty));
5529}
5530
5531ALIAS (no_aggregate_address_mask,
5532 no_aggregate_address_mask_summary_only_cmd,
5533 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5534 NO_STR
5535 "Configure BGP aggregate entries\n"
5536 "Aggregate address\n"
5537 "Aggregate mask\n"
5538 "Filter more specific routes from updates\n")
5539
5540ALIAS (no_aggregate_address_mask,
5541 no_aggregate_address_mask_as_set_cmd,
5542 "no aggregate-address A.B.C.D A.B.C.D as-set",
5543 NO_STR
5544 "Configure BGP aggregate entries\n"
5545 "Aggregate address\n"
5546 "Aggregate mask\n"
5547 "Generate AS set path information\n")
5548
5549ALIAS (no_aggregate_address_mask,
5550 no_aggregate_address_mask_as_set_summary_cmd,
5551 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5552 NO_STR
5553 "Configure BGP aggregate entries\n"
5554 "Aggregate address\n"
5555 "Aggregate mask\n"
5556 "Generate AS set path information\n"
5557 "Filter more specific routes from updates\n")
5558
5559ALIAS (no_aggregate_address_mask,
5560 no_aggregate_address_mask_summary_as_set_cmd,
5561 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5562 NO_STR
5563 "Configure BGP aggregate entries\n"
5564 "Aggregate address\n"
5565 "Aggregate mask\n"
5566 "Filter more specific routes from updates\n"
5567 "Generate AS set path information\n")
5568
paul718e3742002-12-13 20:15:29 +00005569DEFUN (ipv6_aggregate_address,
5570 ipv6_aggregate_address_cmd,
5571 "aggregate-address X:X::X:X/M",
5572 "Configure BGP aggregate entries\n"
5573 "Aggregate prefix\n")
5574{
5575 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0, 0);
5576}
5577
5578DEFUN (ipv6_aggregate_address_summary_only,
5579 ipv6_aggregate_address_summary_only_cmd,
5580 "aggregate-address X:X::X:X/M summary-only",
5581 "Configure BGP aggregate entries\n"
5582 "Aggregate prefix\n"
5583 "Filter more specific routes from updates\n")
5584{
5585 return bgp_aggregate_set (vty, argv[0], AFI_IP6, SAFI_UNICAST,
5586 AGGREGATE_SUMMARY_ONLY, 0);
5587}
5588
5589DEFUN (no_ipv6_aggregate_address,
5590 no_ipv6_aggregate_address_cmd,
5591 "no aggregate-address X:X::X:X/M",
5592 NO_STR
5593 "Configure BGP aggregate entries\n"
5594 "Aggregate prefix\n")
5595{
5596 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5597}
5598
5599DEFUN (no_ipv6_aggregate_address_summary_only,
5600 no_ipv6_aggregate_address_summary_only_cmd,
5601 "no aggregate-address X:X::X:X/M summary-only",
5602 NO_STR
5603 "Configure BGP aggregate entries\n"
5604 "Aggregate prefix\n"
5605 "Filter more specific routes from updates\n")
5606{
5607 return bgp_aggregate_unset (vty, argv[0], AFI_IP6, SAFI_UNICAST);
5608}
5609
5610ALIAS (ipv6_aggregate_address,
5611 old_ipv6_aggregate_address_cmd,
5612 "ipv6 bgp aggregate-address X:X::X:X/M",
5613 IPV6_STR
5614 BGP_STR
5615 "Configure BGP aggregate entries\n"
5616 "Aggregate prefix\n")
5617
5618ALIAS (ipv6_aggregate_address_summary_only,
5619 old_ipv6_aggregate_address_summary_only_cmd,
5620 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5621 IPV6_STR
5622 BGP_STR
5623 "Configure BGP aggregate entries\n"
5624 "Aggregate prefix\n"
5625 "Filter more specific routes from updates\n")
5626
5627ALIAS (no_ipv6_aggregate_address,
5628 old_no_ipv6_aggregate_address_cmd,
5629 "no ipv6 bgp aggregate-address X:X::X:X/M",
5630 NO_STR
5631 IPV6_STR
5632 BGP_STR
5633 "Configure BGP aggregate entries\n"
5634 "Aggregate prefix\n")
5635
5636ALIAS (no_ipv6_aggregate_address_summary_only,
5637 old_no_ipv6_aggregate_address_summary_only_cmd,
5638 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5639 NO_STR
5640 IPV6_STR
5641 BGP_STR
5642 "Configure BGP aggregate entries\n"
5643 "Aggregate prefix\n"
5644 "Filter more specific routes from updates\n")
David Lamparter6b0655a2014-06-04 06:53:35 +02005645
paul718e3742002-12-13 20:15:29 +00005646/* Redistribute route treatment. */
5647void
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005648bgp_redistribute_add (struct prefix *p, const struct in_addr *nexthop,
5649 const struct in6_addr *nexthop6,
paul718e3742002-12-13 20:15:29 +00005650 u_int32_t metric, u_char type)
5651{
5652 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005653 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005654 struct bgp_info *new;
5655 struct bgp_info *bi;
5656 struct bgp_info info;
5657 struct bgp_node *bn;
Jorge Boncompte [DTI2]e16a4132012-05-07 16:52:57 +00005658 struct attr attr;
paul718e3742002-12-13 20:15:29 +00005659 struct attr *new_attr;
5660 afi_t afi;
5661 int ret;
5662
5663 /* Make default attribute. */
5664 bgp_attr_default_set (&attr, BGP_ORIGIN_INCOMPLETE);
5665 if (nexthop)
5666 attr.nexthop = *nexthop;
5667
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005668 if (nexthop6)
5669 {
5670 struct attr_extra *extra = bgp_attr_extra_get(&attr);
5671 extra->mp_nexthop_global = *nexthop6;
5672 extra->mp_nexthop_len = 16;
5673 }
Stephen Hemmingerf04a80a2011-12-06 14:51:10 +04005674
paul718e3742002-12-13 20:15:29 +00005675 attr.med = metric;
5676 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
5677
paul1eb8ef22005-04-07 07:30:20 +00005678 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005679 {
5680 afi = family2afi (p->family);
5681
5682 if (bgp->redist[afi][type])
5683 {
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005684 struct attr attr_new;
5685 struct attr_extra extra_new;
5686
paul718e3742002-12-13 20:15:29 +00005687 /* Copy attribute for modification. */
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005688 attr_new.extra = &extra_new;
Paul Jakmafb982c22007-05-04 20:15:47 +00005689 bgp_attr_dup (&attr_new, &attr);
paul718e3742002-12-13 20:15:29 +00005690
5691 if (bgp->redist_metric_flag[afi][type])
5692 attr_new.med = bgp->redist_metric[afi][type];
5693
5694 /* Apply route-map. */
Daniel Walton1994dc82015-09-17 10:15:59 -04005695 if (bgp->rmap[afi][type].name)
paul718e3742002-12-13 20:15:29 +00005696 {
5697 info.peer = bgp->peer_self;
5698 info.attr = &attr_new;
5699
paulfee0f4c2004-09-13 05:12:46 +00005700 SET_FLAG (bgp->peer_self->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE);
5701
paul718e3742002-12-13 20:15:29 +00005702 ret = route_map_apply (bgp->rmap[afi][type].map, p, RMAP_BGP,
5703 &info);
paulfee0f4c2004-09-13 05:12:46 +00005704
5705 bgp->peer_self->rmap_type = 0;
5706
paul718e3742002-12-13 20:15:29 +00005707 if (ret == RMAP_DENYMATCH)
5708 {
5709 /* Free uninterned attribute. */
5710 bgp_attr_flush (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005711
paul718e3742002-12-13 20:15:29 +00005712 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005713 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005714 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005715 bgp_redistribute_delete (p, type);
5716 return;
5717 }
5718 }
5719
Paul Jakmafb982c22007-05-04 20:15:47 +00005720 bn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST],
5721 afi, SAFI_UNICAST, p, NULL);
5722
paul718e3742002-12-13 20:15:29 +00005723 new_attr = bgp_attr_intern (&attr_new);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00005724
paul718e3742002-12-13 20:15:29 +00005725 for (bi = bn->info; bi; bi = bi->next)
5726 if (bi->peer == bgp->peer_self
5727 && bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
5728 break;
5729
5730 if (bi)
5731 {
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005732 if (attrhash_cmp (bi->attr, new_attr) &&
5733 !CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
paul718e3742002-12-13 20:15:29 +00005734 {
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005735 bgp_attr_unintern (&new_attr);
5736 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005737 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005738 bgp_unlock_node (bn);
5739 return;
5740 }
5741 else
5742 {
5743 /* The attribute is changed. */
Paul Jakma1a392d42006-09-07 00:24:49 +00005744 bgp_info_set_flag (bn, bi, BGP_INFO_ATTR_CHANGED);
paul718e3742002-12-13 20:15:29 +00005745
5746 /* Rewrite BGP route information. */
Andrew J. Schorr8d452102006-11-28 19:50:46 +00005747 if (CHECK_FLAG(bi->flags, BGP_INFO_REMOVED))
5748 bgp_info_restore(bn, bi);
5749 else
5750 bgp_aggregate_decrement (bgp, p, bi, afi, SAFI_UNICAST);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005751 bgp_attr_unintern (&bi->attr);
paul718e3742002-12-13 20:15:29 +00005752 bi->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005753 bi->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005754
5755 /* Process change. */
5756 bgp_aggregate_increment (bgp, p, bi, afi, SAFI_UNICAST);
5757 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5758 bgp_unlock_node (bn);
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005759 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005760 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005761 return;
5762 }
5763 }
5764
5765 new = bgp_info_new ();
5766 new->type = type;
5767 new->sub_type = BGP_ROUTE_REDISTRIBUTE;
5768 new->peer = bgp->peer_self;
5769 SET_FLAG (new->flags, BGP_INFO_VALID);
5770 new->attr = new_attr;
Stephen Hemminger65957882010-01-15 16:22:10 +03005771 new->uptime = bgp_clock ();
paul718e3742002-12-13 20:15:29 +00005772
5773 bgp_aggregate_increment (bgp, p, new, afi, SAFI_UNICAST);
5774 bgp_info_add (bn, new);
paul200df112005-06-01 11:17:05 +00005775 bgp_unlock_node (bn);
paul718e3742002-12-13 20:15:29 +00005776 bgp_process (bgp, bn, afi, SAFI_UNICAST);
5777 }
5778 }
5779
5780 /* Unintern original. */
Paul Jakmaf6f434b2010-11-23 21:28:03 +00005781 aspath_unintern (&attr.aspath);
Paul Jakmafb982c22007-05-04 20:15:47 +00005782 bgp_attr_extra_free (&attr);
paul718e3742002-12-13 20:15:29 +00005783}
5784
5785void
5786bgp_redistribute_delete (struct prefix *p, u_char type)
5787{
5788 struct bgp *bgp;
paul1eb8ef22005-04-07 07:30:20 +00005789 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00005790 afi_t afi;
5791 struct bgp_node *rn;
5792 struct bgp_info *ri;
5793
paul1eb8ef22005-04-07 07:30:20 +00005794 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
paul718e3742002-12-13 20:15:29 +00005795 {
5796 afi = family2afi (p->family);
5797
5798 if (bgp->redist[afi][type])
5799 {
paulfee0f4c2004-09-13 05:12:46 +00005800 rn = bgp_afi_node_get (bgp->rib[afi][SAFI_UNICAST], afi, SAFI_UNICAST, p, NULL);
paul718e3742002-12-13 20:15:29 +00005801
5802 for (ri = rn->info; ri; ri = ri->next)
5803 if (ri->peer == bgp->peer_self
5804 && ri->type == type)
5805 break;
5806
5807 if (ri)
5808 {
5809 bgp_aggregate_decrement (bgp, p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005810 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005811 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005812 }
5813 bgp_unlock_node (rn);
5814 }
5815 }
5816}
5817
5818/* Withdraw specified route type's route. */
5819void
5820bgp_redistribute_withdraw (struct bgp *bgp, afi_t afi, int type)
5821{
5822 struct bgp_node *rn;
5823 struct bgp_info *ri;
5824 struct bgp_table *table;
5825
5826 table = bgp->rib[afi][SAFI_UNICAST];
5827
5828 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
5829 {
5830 for (ri = rn->info; ri; ri = ri->next)
5831 if (ri->peer == bgp->peer_self
5832 && ri->type == type)
5833 break;
5834
5835 if (ri)
5836 {
5837 bgp_aggregate_decrement (bgp, &rn->p, ri, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005838 bgp_info_delete (rn, ri);
Paul Jakma1a392d42006-09-07 00:24:49 +00005839 bgp_process (bgp, rn, afi, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00005840 }
5841 }
5842}
David Lamparter6b0655a2014-06-04 06:53:35 +02005843
paul718e3742002-12-13 20:15:29 +00005844/* Static function to display route. */
paul94f2b392005-06-28 12:44:16 +00005845static void
paul718e3742002-12-13 20:15:29 +00005846route_vty_out_route (struct prefix *p, struct vty *vty)
5847{
5848 int len;
5849 u_int32_t destination;
5850 char buf[BUFSIZ];
5851
5852 if (p->family == AF_INET)
5853 {
5854 len = vty_out (vty, "%s", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ));
5855 destination = ntohl (p->u.prefix4.s_addr);
5856
5857 if ((IN_CLASSC (destination) && p->prefixlen == 24)
5858 || (IN_CLASSB (destination) && p->prefixlen == 16)
5859 || (IN_CLASSA (destination) && p->prefixlen == 8)
5860 || p->u.prefix4.s_addr == 0)
5861 {
5862 /* When mask is natural, mask is not displayed. */
5863 }
5864 else
5865 len += vty_out (vty, "/%d", p->prefixlen);
5866 }
5867 else
5868 len = vty_out (vty, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
5869 p->prefixlen);
5870
5871 len = 17 - len;
5872 if (len < 1)
5873 vty_out (vty, "%s%*s", VTY_NEWLINE, 20, " ");
5874 else
5875 vty_out (vty, "%*s", len, " ");
5876}
5877
paul718e3742002-12-13 20:15:29 +00005878enum bgp_display_type
5879{
5880 normal_list,
5881};
5882
paulb40d9392005-08-22 22:34:41 +00005883/* Print the short form route status for a bgp_info */
5884static void
5885route_vty_short_status_out (struct vty *vty, struct bgp_info *binfo)
paul718e3742002-12-13 20:15:29 +00005886{
paulb40d9392005-08-22 22:34:41 +00005887 /* Route status display. */
5888 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
5889 vty_out (vty, "R");
5890 else if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
hasso93406d82005-02-02 14:40:33 +00005891 vty_out (vty, "S");
Paul Jakmafb982c22007-05-04 20:15:47 +00005892 else if (binfo->extra && binfo->extra->suppress)
paul718e3742002-12-13 20:15:29 +00005893 vty_out (vty, "s");
5894 else if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5895 vty_out (vty, "*");
5896 else
5897 vty_out (vty, " ");
5898
5899 /* Selected */
5900 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
5901 vty_out (vty, "h");
5902 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
5903 vty_out (vty, "d");
5904 else if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
5905 vty_out (vty, ">");
Boian Bonevb366b512013-09-09 16:41:35 +00005906 else if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH))
5907 vty_out (vty, "=");
paul718e3742002-12-13 20:15:29 +00005908 else
5909 vty_out (vty, " ");
5910
5911 /* Internal route. */
5912 if ((binfo->peer->as) && (binfo->peer->as == binfo->peer->local_as))
5913 vty_out (vty, "i");
5914 else
paulb40d9392005-08-22 22:34:41 +00005915 vty_out (vty, " ");
5916}
5917
5918/* called from terminal list command */
5919void
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005920route_vty_out(
5921 struct vty *vty,
5922 struct prefix *p,
5923 struct bgp_info *binfo,
5924 int display,
5925 safi_t safi)
paulb40d9392005-08-22 22:34:41 +00005926{
5927 struct attr *attr;
5928
5929 /* short status lead text */
5930 route_vty_short_status_out (vty, binfo);
paul718e3742002-12-13 20:15:29 +00005931
5932 /* print prefix and mask */
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05005933 if (!display)
paul718e3742002-12-13 20:15:29 +00005934 route_vty_out_route (p, vty);
5935 else
5936 vty_out (vty, "%*s", 17, " ");
5937
5938 /* Print attribute */
5939 attr = binfo->attr;
5940 if (attr)
5941 {
paul718e3742002-12-13 20:15:29 +00005942
Lou Berger298cc2f2016-01-12 13:42:02 -05005943 /*
5944 * NEXTHOP start
5945 */
5946
5947 /*
5948 * For ENCAP routes, nexthop address family is not
5949 * neccessarily the same as the prefix address family.
5950 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5951 */
5952 if ((safi == SAFI_ENCAP) || (safi == SAFI_MPLS_VPN)) {
5953 if (attr->extra) {
5954 char buf[BUFSIZ];
5955 int af = NEXTHOP_FAMILY(attr->extra->mp_nexthop_len);
5956
5957 switch (af) {
5958 case AF_INET:
5959 vty_out (vty, "%s", inet_ntop(af,
5960 &attr->extra->mp_nexthop_global_in, buf, BUFSIZ));
5961 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005962 case AF_INET6:
5963 vty_out (vty, "%s", inet_ntop(af,
5964 &attr->extra->mp_nexthop_global, buf, BUFSIZ));
5965 break;
Lou Berger298cc2f2016-01-12 13:42:02 -05005966 default:
5967 vty_out(vty, "?");
5968 }
5969 } else {
5970 vty_out(vty, "?");
paul718e3742002-12-13 20:15:29 +00005971 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005972 } else {
5973
5974 if (p->family == AF_INET)
5975 {
5976 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
5977 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005978 else if (p->family == AF_INET6)
5979 {
5980 int len;
5981 char buf[BUFSIZ];
5982
5983 len = vty_out (vty, "%s",
5984 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
5985 buf, BUFSIZ));
5986 len = 16 - len;
5987 if (len < 1)
5988 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
5989 else
5990 vty_out (vty, "%*s", len, " ");
5991 }
Lou Berger298cc2f2016-01-12 13:42:02 -05005992 else
5993 {
5994 vty_out(vty, "?");
5995 }
5996 }
5997
5998 /*
5999 * NEXTHOP end
6000 */
6001
paul718e3742002-12-13 20:15:29 +00006002
6003 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006004 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006005 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006006 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00006007
6008 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006009 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006010 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006011 vty_out (vty, " ");
paul718e3742002-12-13 20:15:29 +00006012
Paul Jakmafb982c22007-05-04 20:15:47 +00006013 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
paul718e3742002-12-13 20:15:29 +00006014
Paul Jakmab2518c12006-05-12 23:48:40 +00006015 /* Print aspath */
6016 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006017 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006018
Paul Jakmab2518c12006-05-12 23:48:40 +00006019 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006020 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006021 }
paul718e3742002-12-13 20:15:29 +00006022 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006023}
6024
6025/* called from terminal list command */
6026void
6027route_vty_out_tmp (struct vty *vty, struct prefix *p,
6028 struct attr *attr, safi_t safi)
6029{
6030 /* Route status display. */
6031 vty_out (vty, "*");
6032 vty_out (vty, ">");
6033 vty_out (vty, " ");
6034
6035 /* print prefix and mask */
6036 route_vty_out_route (p, vty);
6037
6038 /* Print attribute */
6039 if (attr)
6040 {
6041 if (p->family == AF_INET)
6042 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006043 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006044 vty_out (vty, "%-16s",
6045 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006046 else
6047 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6048 }
paul718e3742002-12-13 20:15:29 +00006049 else if (p->family == AF_INET6)
6050 {
6051 int len;
6052 char buf[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006053
6054 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006055
6056 len = vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006057 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6058 buf, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006059 len = 16 - len;
6060 if (len < 1)
6061 vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
6062 else
6063 vty_out (vty, "%*s", len, " ");
6064 }
paul718e3742002-12-13 20:15:29 +00006065
6066 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006067 vty_out (vty, "%10u ", attr->med);
paul718e3742002-12-13 20:15:29 +00006068 else
6069 vty_out (vty, " ");
6070
6071 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006072 vty_out (vty, "%7u ", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006073 else
6074 vty_out (vty, " ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006075
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006076 vty_out (vty, "%7u ", (attr->extra ? attr->extra->weight : 0));
Paul Jakmafb982c22007-05-04 20:15:47 +00006077
Paul Jakmab2518c12006-05-12 23:48:40 +00006078 /* Print aspath */
6079 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006080 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006081
Paul Jakmab2518c12006-05-12 23:48:40 +00006082 /* Print origin */
paul718e3742002-12-13 20:15:29 +00006083 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
Paul Jakmab2518c12006-05-12 23:48:40 +00006084 }
paul718e3742002-12-13 20:15:29 +00006085
6086 vty_out (vty, "%s", VTY_NEWLINE);
6087}
6088
ajs5a646652004-11-05 01:25:55 +00006089void
paul718e3742002-12-13 20:15:29 +00006090route_vty_out_tag (struct vty *vty, struct prefix *p,
6091 struct bgp_info *binfo, int display, safi_t safi)
6092{
6093 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006094 u_int32_t label = 0;
Paul Jakmafb982c22007-05-04 20:15:47 +00006095
6096 if (!binfo->extra)
6097 return;
6098
paulb40d9392005-08-22 22:34:41 +00006099 /* short status lead text */
6100 route_vty_short_status_out (vty, binfo);
6101
paul718e3742002-12-13 20:15:29 +00006102 /* print prefix and mask */
6103 if (! display)
6104 route_vty_out_route (p, vty);
6105 else
6106 vty_out (vty, "%*s", 17, " ");
6107
6108 /* Print attribute */
6109 attr = binfo->attr;
6110 if (attr)
6111 {
6112 if (p->family == AF_INET)
6113 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006114 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
Paul Jakmafb982c22007-05-04 20:15:47 +00006115 vty_out (vty, "%-16s",
6116 inet_ntoa (attr->extra->mp_nexthop_global_in));
paul718e3742002-12-13 20:15:29 +00006117 else
6118 vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
6119 }
paul718e3742002-12-13 20:15:29 +00006120 else if (p->family == AF_INET6)
6121 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006122 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006123 char buf[BUFSIZ];
6124 char buf1[BUFSIZ];
Paul Jakmafb982c22007-05-04 20:15:47 +00006125 if (attr->extra->mp_nexthop_len == 16)
paul718e3742002-12-13 20:15:29 +00006126 vty_out (vty, "%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006127 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6128 buf, BUFSIZ));
6129 else if (attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006130 vty_out (vty, "%s(%s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006131 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
6132 buf, BUFSIZ),
6133 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
6134 buf1, BUFSIZ));
paul718e3742002-12-13 20:15:29 +00006135
6136 }
paul718e3742002-12-13 20:15:29 +00006137 }
6138
Paul Jakmafb982c22007-05-04 20:15:47 +00006139 label = decode_label (binfo->extra->tag);
paul718e3742002-12-13 20:15:29 +00006140
6141 vty_out (vty, "notag/%d", label);
6142
6143 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006144}
6145
6146/* dampening route */
ajs5a646652004-11-05 01:25:55 +00006147static void
paul718e3742002-12-13 20:15:29 +00006148damp_route_vty_out (struct vty *vty, struct prefix *p,
6149 struct bgp_info *binfo, int display, safi_t safi)
6150{
6151 struct attr *attr;
paul718e3742002-12-13 20:15:29 +00006152 int len;
Chris Caputo50aef6f2009-06-23 06:06:49 +00006153 char timebuf[BGP_UPTIME_LEN];
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 = 17 - len;
6166 if (len < 1)
6167 vty_out (vty, "%s%*s", VTY_NEWLINE, 34, " ");
6168 else
6169 vty_out (vty, "%*s", len, " ");
6170
Chris Caputo50aef6f2009-06-23 06:06:49 +00006171 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006172
6173 /* Print attribute */
6174 attr = binfo->attr;
6175 if (attr)
6176 {
6177 /* Print aspath */
6178 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006179 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006180
6181 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006182 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006183 }
6184 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006185}
6186
paul718e3742002-12-13 20:15:29 +00006187/* flap route */
ajs5a646652004-11-05 01:25:55 +00006188static void
paul718e3742002-12-13 20:15:29 +00006189flap_route_vty_out (struct vty *vty, struct prefix *p,
6190 struct bgp_info *binfo, int display, safi_t safi)
6191{
6192 struct attr *attr;
6193 struct bgp_damp_info *bdi;
paul718e3742002-12-13 20:15:29 +00006194 char timebuf[BGP_UPTIME_LEN];
6195 int len;
Paul Jakmafb982c22007-05-04 20:15:47 +00006196
6197 if (!binfo->extra)
6198 return;
6199
6200 bdi = binfo->extra->damp_info;
paul718e3742002-12-13 20:15:29 +00006201
paulb40d9392005-08-22 22:34:41 +00006202 /* short status lead text */
6203 route_vty_short_status_out (vty, binfo);
6204
paul718e3742002-12-13 20:15:29 +00006205 /* print prefix and mask */
6206 if (! display)
6207 route_vty_out_route (p, vty);
6208 else
6209 vty_out (vty, "%*s", 17, " ");
6210
6211 len = vty_out (vty, "%s", binfo->peer->host);
6212 len = 16 - len;
6213 if (len < 1)
6214 vty_out (vty, "%s%*s", VTY_NEWLINE, 33, " ");
6215 else
6216 vty_out (vty, "%*s", len, " ");
6217
6218 len = vty_out (vty, "%d", bdi->flap);
6219 len = 5 - len;
6220 if (len < 1)
6221 vty_out (vty, " ");
6222 else
6223 vty_out (vty, "%*s ", len, " ");
6224
6225 vty_out (vty, "%s ", peer_uptime (bdi->start_time,
6226 timebuf, BGP_UPTIME_LEN));
6227
6228 if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
6229 && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
Chris Caputo50aef6f2009-06-23 06:06:49 +00006230 vty_out (vty, "%s ", bgp_damp_reuse_time_vty (vty, binfo, timebuf, BGP_UPTIME_LEN));
paul718e3742002-12-13 20:15:29 +00006231 else
6232 vty_out (vty, "%*s ", 8, " ");
6233
6234 /* Print attribute */
6235 attr = binfo->attr;
6236 if (attr)
6237 {
6238 /* Print aspath */
6239 if (attr->aspath)
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006240 aspath_print_vty (vty, "%s", attr->aspath, " ");
paul718e3742002-12-13 20:15:29 +00006241
6242 /* Print origin */
Paul Jakmab2518c12006-05-12 23:48:40 +00006243 vty_out (vty, "%s", bgp_origin_str[attr->origin]);
paul718e3742002-12-13 20:15:29 +00006244 }
6245 vty_out (vty, "%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006246}
6247
paul94f2b392005-06-28 12:44:16 +00006248static void
paul718e3742002-12-13 20:15:29 +00006249route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
6250 struct bgp_info *binfo, afi_t afi, safi_t safi)
6251{
6252 char buf[INET6_ADDRSTRLEN];
6253 char buf1[BUFSIZ];
6254 struct attr *attr;
6255 int sockunion_vty_out (struct vty *, union sockunion *);
John Kemp30b00172011-03-18 17:52:18 +03006256#ifdef HAVE_CLOCK_MONOTONIC
6257 time_t tbuf;
6258#endif
paul718e3742002-12-13 20:15:29 +00006259
6260 attr = binfo->attr;
6261
6262 if (attr)
6263 {
6264 /* Line1 display AS-path, Aggregator */
6265 if (attr->aspath)
6266 {
6267 vty_out (vty, " ");
paulfe69a502005-09-10 16:55:02 +00006268 if (aspath_count_hops (attr->aspath) == 0)
paul718e3742002-12-13 20:15:29 +00006269 vty_out (vty, "Local");
6270 else
Denis Ovsienko841f7a52008-04-10 11:47:45 +00006271 aspath_print_vty (vty, "%s", attr->aspath, "");
paul718e3742002-12-13 20:15:29 +00006272 }
6273
paulb40d9392005-08-22 22:34:41 +00006274 if (CHECK_FLAG (binfo->flags, BGP_INFO_REMOVED))
6275 vty_out (vty, ", (removed)");
hasso93406d82005-02-02 14:40:33 +00006276 if (CHECK_FLAG (binfo->flags, BGP_INFO_STALE))
6277 vty_out (vty, ", (stale)");
6278 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
Denis Ovsienkoaea339f2009-04-30 17:16:22 +04006279 vty_out (vty, ", (aggregated by %u %s)",
Paul Jakmafb982c22007-05-04 20:15:47 +00006280 attr->extra->aggregator_as,
6281 inet_ntoa (attr->extra->aggregator_addr));
hasso93406d82005-02-02 14:40:33 +00006282 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
6283 vty_out (vty, ", (Received from a RR-client)");
6284 if (CHECK_FLAG (binfo->peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
6285 vty_out (vty, ", (Received from a RS-client)");
6286 if (CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6287 vty_out (vty, ", (history entry)");
6288 else if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED))
6289 vty_out (vty, ", (suppressed due to dampening)");
paul718e3742002-12-13 20:15:29 +00006290 vty_out (vty, "%s", VTY_NEWLINE);
6291
6292 /* Line2 display Next-hop, Neighbor, Router-id */
6293 if (p->family == AF_INET)
6294 {
Lou Berger298cc2f2016-01-12 13:42:02 -05006295 vty_out (vty, " %s", ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) ?
Paul Jakmafb982c22007-05-04 20:15:47 +00006296 inet_ntoa (attr->extra->mp_nexthop_global_in) :
paul718e3742002-12-13 20:15:29 +00006297 inet_ntoa (attr->nexthop));
6298 }
paul718e3742002-12-13 20:15:29 +00006299 else
6300 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006301 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006302 vty_out (vty, " %s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006303 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
paul718e3742002-12-13 20:15:29 +00006304 buf, INET6_ADDRSTRLEN));
6305 }
paul718e3742002-12-13 20:15:29 +00006306
6307 if (binfo->peer == bgp->peer_self)
6308 {
6309 vty_out (vty, " from %s ",
6310 p->family == AF_INET ? "0.0.0.0" : "::");
6311 vty_out (vty, "(%s)", inet_ntoa(bgp->router_id));
6312 }
6313 else
6314 {
6315 if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
6316 vty_out (vty, " (inaccessible)");
Paul Jakmafb982c22007-05-04 20:15:47 +00006317 else if (binfo->extra && binfo->extra->igpmetric)
Jorge Boncompte [DTI2]ddc943d2012-04-13 13:46:07 +02006318 vty_out (vty, " (metric %u)", binfo->extra->igpmetric);
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006319 if (!sockunion2str (&binfo->peer->su, buf, sizeof(buf))) {
6320 buf[0] = '?';
6321 buf[1] = 0;
6322 }
6323 vty_out (vty, " from %s", buf);
paul718e3742002-12-13 20:15:29 +00006324 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006325 vty_out (vty, " (%s)", inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006326 else
6327 vty_out (vty, " (%s)", inet_ntop (AF_INET, &binfo->peer->remote_id, buf1, BUFSIZ));
6328 }
6329 vty_out (vty, "%s", VTY_NEWLINE);
6330
paul718e3742002-12-13 20:15:29 +00006331 /* display nexthop local */
Paul Jakmafb982c22007-05-04 20:15:47 +00006332 if (attr->extra && attr->extra->mp_nexthop_len == 32)
paul718e3742002-12-13 20:15:29 +00006333 {
6334 vty_out (vty, " (%s)%s",
Paul Jakmafb982c22007-05-04 20:15:47 +00006335 inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
paul718e3742002-12-13 20:15:29 +00006336 buf, INET6_ADDRSTRLEN),
6337 VTY_NEWLINE);
6338 }
paul718e3742002-12-13 20:15:29 +00006339
6340 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
6341 vty_out (vty, " Origin %s", bgp_origin_long_str[attr->origin]);
6342
6343 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006344 vty_out (vty, ", metric %u", attr->med);
paul718e3742002-12-13 20:15:29 +00006345
6346 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006347 vty_out (vty, ", localpref %u", attr->local_pref);
paul718e3742002-12-13 20:15:29 +00006348 else
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006349 vty_out (vty, ", localpref %u", bgp->default_local_pref);
paul718e3742002-12-13 20:15:29 +00006350
Paul Jakmafb982c22007-05-04 20:15:47 +00006351 if (attr->extra && attr->extra->weight != 0)
Wataru Tanitsuc099baf2010-09-10 09:47:56 -07006352 vty_out (vty, ", weight %u", attr->extra->weight);
paul718e3742002-12-13 20:15:29 +00006353
6354 if (! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
6355 vty_out (vty, ", valid");
6356
6357 if (binfo->peer != bgp->peer_self)
6358 {
6359 if (binfo->peer->as == binfo->peer->local_as)
6360 vty_out (vty, ", internal");
6361 else
6362 vty_out (vty, ", %s",
6363 (bgp_confederation_peers_check(bgp, binfo->peer->as) ? "confed-external" : "external"));
6364 }
6365 else if (binfo->sub_type == BGP_ROUTE_AGGREGATE)
6366 vty_out (vty, ", aggregated, local");
6367 else if (binfo->type != ZEBRA_ROUTE_BGP)
6368 vty_out (vty, ", sourced");
6369 else
6370 vty_out (vty, ", sourced, local");
6371
6372 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
6373 vty_out (vty, ", atomic-aggregate");
6374
Josh Baileyde8d5df2011-07-20 20:46:01 -07006375 if (CHECK_FLAG (binfo->flags, BGP_INFO_MULTIPATH) ||
6376 (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED) &&
6377 bgp_info_mpath_count (binfo)))
6378 vty_out (vty, ", multipath");
6379
paul718e3742002-12-13 20:15:29 +00006380 if (CHECK_FLAG (binfo->flags, BGP_INFO_SELECTED))
6381 vty_out (vty, ", best");
6382
6383 vty_out (vty, "%s", VTY_NEWLINE);
6384
6385 /* Line 4 display Community */
6386 if (attr->community)
6387 vty_out (vty, " Community: %s%s", attr->community->str,
6388 VTY_NEWLINE);
6389
6390 /* Line 5 display Extended-community */
6391 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))
Paul Jakmafb982c22007-05-04 20:15:47 +00006392 vty_out (vty, " Extended Community: %s%s",
6393 attr->extra->ecommunity->str, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006394
6395 /* Line 6 display Originator, Cluster-id */
6396 if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
6397 (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST)))
6398 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006399 assert (attr->extra);
paul718e3742002-12-13 20:15:29 +00006400 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
Paul Jakmafb982c22007-05-04 20:15:47 +00006401 vty_out (vty, " Originator: %s",
6402 inet_ntoa (attr->extra->originator_id));
paul718e3742002-12-13 20:15:29 +00006403
6404 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))
6405 {
6406 int i;
6407 vty_out (vty, ", Cluster list: ");
Paul Jakmafb982c22007-05-04 20:15:47 +00006408 for (i = 0; i < attr->extra->cluster->length / 4; i++)
6409 vty_out (vty, "%s ",
6410 inet_ntoa (attr->extra->cluster->list[i]));
paul718e3742002-12-13 20:15:29 +00006411 }
6412 vty_out (vty, "%s", VTY_NEWLINE);
6413 }
Paul Jakma41367172007-08-06 15:24:51 +00006414
Paul Jakmafb982c22007-05-04 20:15:47 +00006415 if (binfo->extra && binfo->extra->damp_info)
paul718e3742002-12-13 20:15:29 +00006416 bgp_damp_info_vty (vty, binfo);
6417
6418 /* Line 7 display Uptime */
John Kemp30b00172011-03-18 17:52:18 +03006419#ifdef HAVE_CLOCK_MONOTONIC
6420 tbuf = time(NULL) - (bgp_clock() - binfo->uptime);
Vladimir L Ivanov213b6cd2010-10-21 14:59:54 +04006421 vty_out (vty, " Last update: %s", ctime(&tbuf));
John Kemp30b00172011-03-18 17:52:18 +03006422#else
6423 vty_out (vty, " Last update: %s", ctime(&binfo->uptime));
6424#endif /* HAVE_CLOCK_MONOTONIC */
paul718e3742002-12-13 20:15:29 +00006425 }
6426 vty_out (vty, "%s", VTY_NEWLINE);
Boian Bonevb366b512013-09-09 16:41:35 +00006427}
6428
6429#define BGP_SHOW_SCODE_HEADER "Status codes: s suppressed, d damped, "\
6430 "h history, * valid, > best, = multipath,%s"\
6431 " i internal, r RIB-failure, S Stale, R Removed%s"
hasso93406d82005-02-02 14:40:33 +00006432#define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
paul718e3742002-12-13 20:15:29 +00006433#define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6434#define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6435#define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6436
6437enum bgp_show_type
6438{
6439 bgp_show_type_normal,
6440 bgp_show_type_regexp,
6441 bgp_show_type_prefix_list,
6442 bgp_show_type_filter_list,
6443 bgp_show_type_route_map,
6444 bgp_show_type_neighbor,
6445 bgp_show_type_cidr_only,
6446 bgp_show_type_prefix_longer,
6447 bgp_show_type_community_all,
6448 bgp_show_type_community,
6449 bgp_show_type_community_exact,
6450 bgp_show_type_community_list,
6451 bgp_show_type_community_list_exact,
6452 bgp_show_type_flap_statistics,
6453 bgp_show_type_flap_address,
6454 bgp_show_type_flap_prefix,
6455 bgp_show_type_flap_cidr_only,
6456 bgp_show_type_flap_regexp,
6457 bgp_show_type_flap_filter_list,
6458 bgp_show_type_flap_prefix_list,
6459 bgp_show_type_flap_prefix_longer,
6460 bgp_show_type_flap_route_map,
6461 bgp_show_type_flap_neighbor,
6462 bgp_show_type_dampend_paths,
6463 bgp_show_type_damp_neighbor
6464};
6465
ajs5a646652004-11-05 01:25:55 +00006466static int
paulfee0f4c2004-09-13 05:12:46 +00006467bgp_show_table (struct vty *vty, struct bgp_table *table, struct in_addr *router_id,
ajs5a646652004-11-05 01:25:55 +00006468 enum bgp_show_type type, void *output_arg)
paul718e3742002-12-13 20:15:29 +00006469{
paul718e3742002-12-13 20:15:29 +00006470 struct bgp_info *ri;
6471 struct bgp_node *rn;
paul718e3742002-12-13 20:15:29 +00006472 int header = 1;
paul718e3742002-12-13 20:15:29 +00006473 int display;
ajs5a646652004-11-05 01:25:55 +00006474 unsigned long output_count;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006475 unsigned long total_count;
paul718e3742002-12-13 20:15:29 +00006476
6477 /* This is first entry point, so reset total line. */
ajs5a646652004-11-05 01:25:55 +00006478 output_count = 0;
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006479 total_count = 0;
paul718e3742002-12-13 20:15:29 +00006480
paul718e3742002-12-13 20:15:29 +00006481 /* Start processing of routes. */
6482 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
6483 if (rn->info != NULL)
6484 {
6485 display = 0;
6486
6487 for (ri = rn->info; ri; ri = ri->next)
6488 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006489 total_count++;
ajs5a646652004-11-05 01:25:55 +00006490 if (type == bgp_show_type_flap_statistics
paul718e3742002-12-13 20:15:29 +00006491 || type == bgp_show_type_flap_address
6492 || type == bgp_show_type_flap_prefix
6493 || type == bgp_show_type_flap_cidr_only
6494 || type == bgp_show_type_flap_regexp
6495 || type == bgp_show_type_flap_filter_list
6496 || type == bgp_show_type_flap_prefix_list
6497 || type == bgp_show_type_flap_prefix_longer
6498 || type == bgp_show_type_flap_route_map
6499 || type == bgp_show_type_flap_neighbor
6500 || type == bgp_show_type_dampend_paths
6501 || type == bgp_show_type_damp_neighbor)
6502 {
Paul Jakmafb982c22007-05-04 20:15:47 +00006503 if (!(ri->extra && ri->extra->damp_info))
paul718e3742002-12-13 20:15:29 +00006504 continue;
6505 }
6506 if (type == bgp_show_type_regexp
6507 || type == bgp_show_type_flap_regexp)
6508 {
ajs5a646652004-11-05 01:25:55 +00006509 regex_t *regex = output_arg;
paul718e3742002-12-13 20:15:29 +00006510
6511 if (bgp_regexec (regex, ri->attr->aspath) == REG_NOMATCH)
6512 continue;
6513 }
6514 if (type == bgp_show_type_prefix_list
6515 || type == bgp_show_type_flap_prefix_list)
6516 {
ajs5a646652004-11-05 01:25:55 +00006517 struct prefix_list *plist = output_arg;
paul718e3742002-12-13 20:15:29 +00006518
6519 if (prefix_list_apply (plist, &rn->p) != PREFIX_PERMIT)
6520 continue;
6521 }
6522 if (type == bgp_show_type_filter_list
6523 || type == bgp_show_type_flap_filter_list)
6524 {
ajs5a646652004-11-05 01:25:55 +00006525 struct as_list *as_list = output_arg;
paul718e3742002-12-13 20:15:29 +00006526
6527 if (as_list_apply (as_list, ri->attr->aspath) != AS_FILTER_PERMIT)
6528 continue;
6529 }
6530 if (type == bgp_show_type_route_map
6531 || type == bgp_show_type_flap_route_map)
6532 {
ajs5a646652004-11-05 01:25:55 +00006533 struct route_map *rmap = output_arg;
paul718e3742002-12-13 20:15:29 +00006534 struct bgp_info binfo;
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006535 struct attr dummy_attr;
6536 struct attr_extra dummy_extra;
paul718e3742002-12-13 20:15:29 +00006537 int ret;
6538
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006539 dummy_attr.extra = &dummy_extra;
Paul Jakmafb982c22007-05-04 20:15:47 +00006540 bgp_attr_dup (&dummy_attr, ri->attr);
Jorge Boncompte [DTI2]558d1fe2012-05-07 16:53:05 +00006541
paul718e3742002-12-13 20:15:29 +00006542 binfo.peer = ri->peer;
6543 binfo.attr = &dummy_attr;
6544
6545 ret = route_map_apply (rmap, &rn->p, RMAP_BGP, &binfo);
paul718e3742002-12-13 20:15:29 +00006546 if (ret == RMAP_DENYMATCH)
6547 continue;
6548 }
6549 if (type == bgp_show_type_neighbor
6550 || type == bgp_show_type_flap_neighbor
6551 || type == bgp_show_type_damp_neighbor)
6552 {
ajs5a646652004-11-05 01:25:55 +00006553 union sockunion *su = output_arg;
paul718e3742002-12-13 20:15:29 +00006554
6555 if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
6556 continue;
6557 }
6558 if (type == bgp_show_type_cidr_only
6559 || type == bgp_show_type_flap_cidr_only)
6560 {
6561 u_int32_t destination;
6562
6563 destination = ntohl (rn->p.u.prefix4.s_addr);
6564 if (IN_CLASSC (destination) && rn->p.prefixlen == 24)
6565 continue;
6566 if (IN_CLASSB (destination) && rn->p.prefixlen == 16)
6567 continue;
6568 if (IN_CLASSA (destination) && rn->p.prefixlen == 8)
6569 continue;
6570 }
6571 if (type == bgp_show_type_prefix_longer
6572 || type == bgp_show_type_flap_prefix_longer)
6573 {
ajs5a646652004-11-05 01:25:55 +00006574 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006575
6576 if (! prefix_match (p, &rn->p))
6577 continue;
6578 }
6579 if (type == bgp_show_type_community_all)
6580 {
6581 if (! ri->attr->community)
6582 continue;
6583 }
6584 if (type == bgp_show_type_community)
6585 {
ajs5a646652004-11-05 01:25:55 +00006586 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006587
6588 if (! ri->attr->community ||
6589 ! community_match (ri->attr->community, com))
6590 continue;
6591 }
6592 if (type == bgp_show_type_community_exact)
6593 {
ajs5a646652004-11-05 01:25:55 +00006594 struct community *com = output_arg;
paul718e3742002-12-13 20:15:29 +00006595
6596 if (! ri->attr->community ||
6597 ! community_cmp (ri->attr->community, com))
6598 continue;
6599 }
6600 if (type == bgp_show_type_community_list)
6601 {
ajs5a646652004-11-05 01:25:55 +00006602 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006603
6604 if (! community_list_match (ri->attr->community, list))
6605 continue;
6606 }
6607 if (type == bgp_show_type_community_list_exact)
6608 {
ajs5a646652004-11-05 01:25:55 +00006609 struct community_list *list = output_arg;
paul718e3742002-12-13 20:15:29 +00006610
6611 if (! community_list_exact_match (ri->attr->community, list))
6612 continue;
6613 }
6614 if (type == bgp_show_type_flap_address
6615 || type == bgp_show_type_flap_prefix)
6616 {
ajs5a646652004-11-05 01:25:55 +00006617 struct prefix *p = output_arg;
paul718e3742002-12-13 20:15:29 +00006618
6619 if (! prefix_match (&rn->p, p))
6620 continue;
6621
6622 if (type == bgp_show_type_flap_prefix)
6623 if (p->prefixlen != rn->p.prefixlen)
6624 continue;
6625 }
6626 if (type == bgp_show_type_dampend_paths
6627 || type == bgp_show_type_damp_neighbor)
6628 {
6629 if (! CHECK_FLAG (ri->flags, BGP_INFO_DAMPED)
6630 || CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
6631 continue;
6632 }
6633
6634 if (header)
6635 {
hasso93406d82005-02-02 14:40:33 +00006636 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id), VTY_NEWLINE);
6637 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
6638 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006639 if (type == bgp_show_type_dampend_paths
6640 || type == bgp_show_type_damp_neighbor)
6641 vty_out (vty, BGP_SHOW_DAMP_HEADER, VTY_NEWLINE);
6642 else if (type == bgp_show_type_flap_statistics
6643 || type == bgp_show_type_flap_address
6644 || type == bgp_show_type_flap_prefix
6645 || type == bgp_show_type_flap_cidr_only
6646 || type == bgp_show_type_flap_regexp
6647 || type == bgp_show_type_flap_filter_list
6648 || type == bgp_show_type_flap_prefix_list
6649 || type == bgp_show_type_flap_prefix_longer
6650 || type == bgp_show_type_flap_route_map
6651 || type == bgp_show_type_flap_neighbor)
6652 vty_out (vty, BGP_SHOW_FLAP_HEADER, VTY_NEWLINE);
6653 else
6654 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006655 header = 0;
6656 }
6657
6658 if (type == bgp_show_type_dampend_paths
6659 || type == bgp_show_type_damp_neighbor)
ajs5a646652004-11-05 01:25:55 +00006660 damp_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006661 else if (type == bgp_show_type_flap_statistics
6662 || type == bgp_show_type_flap_address
6663 || type == bgp_show_type_flap_prefix
6664 || type == bgp_show_type_flap_cidr_only
6665 || type == bgp_show_type_flap_regexp
6666 || type == bgp_show_type_flap_filter_list
6667 || type == bgp_show_type_flap_prefix_list
6668 || type == bgp_show_type_flap_prefix_longer
6669 || type == bgp_show_type_flap_route_map
6670 || type == bgp_show_type_flap_neighbor)
ajs5a646652004-11-05 01:25:55 +00006671 flap_route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006672 else
ajs5a646652004-11-05 01:25:55 +00006673 route_vty_out (vty, &rn->p, ri, display, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +00006674 display++;
6675 }
6676 if (display)
ajs5a646652004-11-05 01:25:55 +00006677 output_count++;
paul718e3742002-12-13 20:15:29 +00006678 }
6679
6680 /* No route is displayed */
ajs5a646652004-11-05 01:25:55 +00006681 if (output_count == 0)
paul718e3742002-12-13 20:15:29 +00006682 {
6683 if (type == bgp_show_type_normal)
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006684 vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006685 }
6686 else
Lou Bergerbf1ae6c2016-01-12 13:42:08 -05006687 vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
6688 VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +00006689
6690 return CMD_SUCCESS;
6691}
6692
ajs5a646652004-11-05 01:25:55 +00006693static int
paulfee0f4c2004-09-13 05:12:46 +00006694bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
ajs5a646652004-11-05 01:25:55 +00006695 enum bgp_show_type type, void *output_arg)
paulfee0f4c2004-09-13 05:12:46 +00006696{
6697 struct bgp_table *table;
6698
6699 if (bgp == NULL) {
6700 bgp = bgp_get_default ();
6701 }
6702
6703 if (bgp == NULL)
6704 {
6705 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6706 return CMD_WARNING;
6707 }
6708
6709
6710 table = bgp->rib[afi][safi];
6711
ajs5a646652004-11-05 01:25:55 +00006712 return bgp_show_table (vty, table, &bgp->router_id, type, output_arg);
paulfee0f4c2004-09-13 05:12:46 +00006713}
6714
paul718e3742002-12-13 20:15:29 +00006715/* Header of detailed BGP route information */
paul94f2b392005-06-28 12:44:16 +00006716static void
paul718e3742002-12-13 20:15:29 +00006717route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
6718 struct bgp_node *rn,
6719 struct prefix_rd *prd, afi_t afi, safi_t safi)
6720{
6721 struct bgp_info *ri;
6722 struct prefix *p;
6723 struct peer *peer;
paul1eb8ef22005-04-07 07:30:20 +00006724 struct listnode *node, *nnode;
paul718e3742002-12-13 20:15:29 +00006725 char buf1[INET6_ADDRSTRLEN];
6726 char buf2[INET6_ADDRSTRLEN];
6727 int count = 0;
6728 int best = 0;
6729 int suppress = 0;
6730 int no_export = 0;
6731 int no_advertise = 0;
6732 int local_as = 0;
6733 int first = 0;
Lou Berger298cc2f2016-01-12 13:42:02 -05006734 int printrd = ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP));
paul718e3742002-12-13 20:15:29 +00006735
6736 p = &rn->p;
6737 vty_out (vty, "BGP routing table entry for %s%s%s/%d%s",
Lou Berger298cc2f2016-01-12 13:42:02 -05006738 (printrd ? prefix_rd2str (prd, buf1, RD_ADDRSTRLEN) : ""),
6739 printrd ? ":" : "",
paul718e3742002-12-13 20:15:29 +00006740 inet_ntop (p->family, &p->u.prefix, buf2, INET6_ADDRSTRLEN),
6741 p->prefixlen, VTY_NEWLINE);
6742
6743 for (ri = rn->info; ri; ri = ri->next)
6744 {
6745 count++;
6746 if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED))
6747 {
6748 best = count;
Paul Jakmafb982c22007-05-04 20:15:47 +00006749 if (ri->extra && ri->extra->suppress)
paul718e3742002-12-13 20:15:29 +00006750 suppress = 1;
6751 if (ri->attr->community != NULL)
6752 {
6753 if (community_include (ri->attr->community, COMMUNITY_NO_ADVERTISE))
6754 no_advertise = 1;
6755 if (community_include (ri->attr->community, COMMUNITY_NO_EXPORT))
6756 no_export = 1;
6757 if (community_include (ri->attr->community, COMMUNITY_LOCAL_AS))
6758 local_as = 1;
6759 }
6760 }
6761 }
6762
6763 vty_out (vty, "Paths: (%d available", count);
6764 if (best)
6765 {
6766 vty_out (vty, ", best #%d", best);
6767 if (safi == SAFI_UNICAST)
6768 vty_out (vty, ", table Default-IP-Routing-Table");
6769 }
6770 else
6771 vty_out (vty, ", no best path");
6772 if (no_advertise)
6773 vty_out (vty, ", not advertised to any peer");
6774 else if (no_export)
6775 vty_out (vty, ", not advertised to EBGP peer");
6776 else if (local_as)
6777 vty_out (vty, ", not advertised outside local AS");
6778 if (suppress)
6779 vty_out (vty, ", Advertisements suppressed by an aggregate.");
6780 vty_out (vty, ")%s", VTY_NEWLINE);
6781
6782 /* advertised peer */
paul1eb8ef22005-04-07 07:30:20 +00006783 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
paul718e3742002-12-13 20:15:29 +00006784 {
6785 if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
6786 {
6787 if (! first)
6788 vty_out (vty, " Advertised to non peer-group peers:%s ", VTY_NEWLINE);
6789 vty_out (vty, " %s", sockunion2str (&peer->su, buf1, SU_ADDRSTRLEN));
6790 first = 1;
6791 }
6792 }
6793 if (! first)
6794 vty_out (vty, " Not advertised to any peer");
6795 vty_out (vty, "%s", VTY_NEWLINE);
6796}
6797
6798/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +00006799static int
paulfee0f4c2004-09-13 05:12:46 +00006800bgp_show_route_in_table (struct vty *vty, struct bgp *bgp,
paulfd79ac92004-10-13 05:06:08 +00006801 struct bgp_table *rib, const char *ip_str,
6802 afi_t afi, safi_t safi, struct prefix_rd *prd,
6803 int prefix_check)
paul718e3742002-12-13 20:15:29 +00006804{
6805 int ret;
6806 int header;
6807 int display = 0;
6808 struct prefix match;
6809 struct bgp_node *rn;
6810 struct bgp_node *rm;
6811 struct bgp_info *ri;
paul718e3742002-12-13 20:15:29 +00006812 struct bgp_table *table;
6813
Lou Berger050defe2016-01-12 13:41:59 -05006814 memset (&match, 0, sizeof (struct prefix)); /* keep valgrind happy */
paul718e3742002-12-13 20:15:29 +00006815 /* Check IP address argument. */
6816 ret = str2prefix (ip_str, &match);
6817 if (! ret)
6818 {
6819 vty_out (vty, "address is malformed%s", VTY_NEWLINE);
6820 return CMD_WARNING;
6821 }
6822
6823 match.family = afi2family (afi);
6824
Lou Berger298cc2f2016-01-12 13:42:02 -05006825 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +00006826 {
paulfee0f4c2004-09-13 05:12:46 +00006827 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +00006828 {
6829 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6830 continue;
6831
6832 if ((table = rn->info) != NULL)
6833 {
6834 header = 1;
6835
6836 if ((rm = bgp_node_match (table, &match)) != NULL)
6837 {
6838 if (prefix_check && rm->p.prefixlen != match.prefixlen)
Chris Caputo6c88b442010-07-27 16:28:55 +00006839 {
6840 bgp_unlock_node (rm);
6841 continue;
6842 }
paul718e3742002-12-13 20:15:29 +00006843
6844 for (ri = rm->info; ri; ri = ri->next)
6845 {
6846 if (header)
6847 {
6848 route_vty_out_detail_header (vty, bgp, rm, (struct prefix_rd *)&rn->p,
Lou Berger298cc2f2016-01-12 13:42:02 -05006849 AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006850
6851 header = 0;
6852 }
6853 display++;
Lou Berger298cc2f2016-01-12 13:42:02 -05006854 route_vty_out_detail (vty, bgp, &rm->p, ri, AFI_IP, safi);
paul718e3742002-12-13 20:15:29 +00006855 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006856
6857 bgp_unlock_node (rm);
paul718e3742002-12-13 20:15:29 +00006858 }
6859 }
6860 }
6861 }
6862 else
6863 {
6864 header = 1;
6865
paulfee0f4c2004-09-13 05:12:46 +00006866 if ((rn = bgp_node_match (rib, &match)) != NULL)
paul718e3742002-12-13 20:15:29 +00006867 {
6868 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
6869 {
6870 for (ri = rn->info; ri; ri = ri->next)
6871 {
6872 if (header)
6873 {
6874 route_vty_out_detail_header (vty, bgp, rn, NULL, afi, safi);
6875 header = 0;
6876 }
6877 display++;
6878 route_vty_out_detail (vty, bgp, &rn->p, ri, afi, safi);
6879 }
6880 }
Chris Caputo6c88b442010-07-27 16:28:55 +00006881
6882 bgp_unlock_node (rn);
paul718e3742002-12-13 20:15:29 +00006883 }
6884 }
6885
6886 if (! display)
6887 {
6888 vty_out (vty, "%% Network not in table%s", VTY_NEWLINE);
6889 return CMD_WARNING;
6890 }
6891
6892 return CMD_SUCCESS;
6893}
6894
paulfee0f4c2004-09-13 05:12:46 +00006895/* Display specified route of Main RIB */
paul94f2b392005-06-28 12:44:16 +00006896static int
paulfd79ac92004-10-13 05:06:08 +00006897bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
paulfee0f4c2004-09-13 05:12:46 +00006898 afi_t afi, safi_t safi, struct prefix_rd *prd,
6899 int prefix_check)
6900{
6901 struct bgp *bgp;
6902
6903 /* BGP structure lookup. */
6904 if (view_name)
6905 {
6906 bgp = bgp_lookup_by_name (view_name);
6907 if (bgp == NULL)
6908 {
6909 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
6910 return CMD_WARNING;
6911 }
6912 }
6913 else
6914 {
6915 bgp = bgp_get_default ();
6916 if (bgp == NULL)
6917 {
6918 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
6919 return CMD_WARNING;
6920 }
6921 }
6922
6923 return bgp_show_route_in_table (vty, bgp, bgp->rib[afi][safi], ip_str,
6924 afi, safi, prd, prefix_check);
6925}
6926
paul718e3742002-12-13 20:15:29 +00006927/* BGP route print out function. */
Lou Bergerf9b6c392016-01-12 13:42:09 -05006928DEFUN (show_ip_bgp,
6929 show_ip_bgp_cmd,
6930 "show ip bgp",
6931 SHOW_STR
6932 IP_STR
6933 BGP_STR)
6934{
6935 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6936}
6937
6938DEFUN (show_ip_bgp_ipv4,
6939 show_ip_bgp_ipv4_cmd,
6940 "show ip bgp ipv4 (unicast|multicast)",
6941 SHOW_STR
6942 IP_STR
6943 BGP_STR
6944 "Address family\n"
6945 "Address Family modifier\n"
6946 "Address Family modifier\n")
6947{
6948 if (strncmp (argv[0], "m", 1) == 0)
6949 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
6950 NULL);
6951
6952 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
6953}
6954
6955DEFUN (show_ip_bgp_route,
6956 show_ip_bgp_route_cmd,
6957 "show ip bgp A.B.C.D",
6958 SHOW_STR
6959 IP_STR
6960 BGP_STR
6961 "Network in the BGP routing table to display\n")
6962{
6963 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0);
6964}
6965
6966DEFUN (show_ip_bgp_ipv4_route,
6967 show_ip_bgp_ipv4_route_cmd,
6968 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6969 SHOW_STR
6970 IP_STR
6971 BGP_STR
6972 "Address family\n"
6973 "Address Family modifier\n"
6974 "Address Family modifier\n"
6975 "Network in the BGP routing table to display\n")
6976{
6977 if (strncmp (argv[0], "m", 1) == 0)
6978 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
6979
6980 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
6981}
6982
6983DEFUN (show_ip_bgp_vpnv4_all_route,
6984 show_ip_bgp_vpnv4_all_route_cmd,
6985 "show ip bgp vpnv4 all A.B.C.D",
6986 SHOW_STR
6987 IP_STR
6988 BGP_STR
6989 "Display VPNv4 NLRI specific information\n"
6990 "Display information about all VPNv4 NLRIs\n"
6991 "Network in the BGP routing table to display\n")
6992{
6993 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
6994}
6995
6996DEFUN (show_ip_bgp_vpnv4_rd_route,
6997 show_ip_bgp_vpnv4_rd_route_cmd,
6998 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6999 SHOW_STR
7000 IP_STR
7001 BGP_STR
7002 "Display VPNv4 NLRI specific information\n"
7003 "Display information for a route distinguisher\n"
7004 "VPN Route Distinguisher\n"
7005 "Network in the BGP routing table to display\n")
7006{
7007 int ret;
7008 struct prefix_rd prd;
7009
7010 ret = str2prefix_rd (argv[0], &prd);
7011 if (! ret)
7012 {
7013 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7014 return CMD_WARNING;
7015 }
7016 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
7017}
7018
7019DEFUN (show_ip_bgp_prefix,
7020 show_ip_bgp_prefix_cmd,
7021 "show ip bgp A.B.C.D/M",
7022 SHOW_STR
7023 IP_STR
7024 BGP_STR
7025 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7026{
7027 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
7028}
7029
7030DEFUN (show_ip_bgp_ipv4_prefix,
7031 show_ip_bgp_ipv4_prefix_cmd,
7032 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
7033 SHOW_STR
7034 IP_STR
7035 BGP_STR
7036 "Address family\n"
7037 "Address Family modifier\n"
7038 "Address Family modifier\n"
7039 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7040{
7041 if (strncmp (argv[0], "m", 1) == 0)
7042 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
7043
7044 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7045}
7046
7047DEFUN (show_ip_bgp_vpnv4_all_prefix,
7048 show_ip_bgp_vpnv4_all_prefix_cmd,
7049 "show ip bgp vpnv4 all A.B.C.D/M",
7050 SHOW_STR
7051 IP_STR
7052 BGP_STR
7053 "Display VPNv4 NLRI specific information\n"
7054 "Display information about all VPNv4 NLRIs\n"
7055 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7056{
7057 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
7058}
7059
7060DEFUN (show_ip_bgp_vpnv4_rd_prefix,
7061 show_ip_bgp_vpnv4_rd_prefix_cmd,
7062 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7063 SHOW_STR
7064 IP_STR
7065 BGP_STR
7066 "Display VPNv4 NLRI specific information\n"
7067 "Display information for a route distinguisher\n"
7068 "VPN Route Distinguisher\n"
7069 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7070{
7071 int ret;
7072 struct prefix_rd prd;
7073
7074 ret = str2prefix_rd (argv[0], &prd);
7075 if (! ret)
7076 {
7077 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7078 return CMD_WARNING;
7079 }
7080 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 1);
7081}
7082
7083DEFUN (show_ip_bgp_view,
7084 show_ip_bgp_view_cmd,
7085 "show ip bgp view WORD",
7086 SHOW_STR
7087 IP_STR
7088 BGP_STR
7089 "BGP view\n"
7090 "View name\n")
7091{
7092 struct bgp *bgp;
7093
7094 /* BGP structure lookup. */
7095 bgp = bgp_lookup_by_name (argv[0]);
7096 if (bgp == NULL)
7097 {
7098 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7099 return CMD_WARNING;
7100 }
7101
7102 return bgp_show (vty, bgp, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
7103}
7104
7105DEFUN (show_ip_bgp_view_route,
7106 show_ip_bgp_view_route_cmd,
7107 "show ip bgp view WORD A.B.C.D",
7108 SHOW_STR
7109 IP_STR
7110 BGP_STR
7111 "BGP view\n"
7112 "View name\n"
7113 "Network in the BGP routing table to display\n")
7114{
7115 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7116}
7117
7118DEFUN (show_ip_bgp_view_prefix,
7119 show_ip_bgp_view_prefix_cmd,
7120 "show ip bgp view WORD A.B.C.D/M",
7121 SHOW_STR
7122 IP_STR
7123 BGP_STR
7124 "BGP view\n"
7125 "View name\n"
7126 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7127{
7128 return bgp_show_route (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
7129}
7130
7131DEFUN (show_bgp,
7132 show_bgp_cmd,
7133 "show bgp",
7134 SHOW_STR
7135 BGP_STR)
7136{
7137 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7138 NULL);
7139}
7140
7141ALIAS (show_bgp,
7142 show_bgp_ipv6_cmd,
7143 "show bgp ipv6",
7144 SHOW_STR
7145 BGP_STR
7146 "Address family\n")
7147
7148/* old command */
7149DEFUN (show_ipv6_bgp,
7150 show_ipv6_bgp_cmd,
7151 "show ipv6 bgp",
7152 SHOW_STR
7153 IP_STR
7154 BGP_STR)
7155{
7156 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal,
7157 NULL);
7158}
7159
7160DEFUN (show_bgp_route,
7161 show_bgp_route_cmd,
7162 "show bgp X:X::X:X",
7163 SHOW_STR
7164 BGP_STR
7165 "Network in the BGP routing table to display\n")
7166{
7167 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7168}
7169
Lou Berger35c36862016-01-12 13:42:06 -05007170DEFUN (show_bgp_ipv4_safi,
7171 show_bgp_ipv4_safi_cmd,
7172 "show bgp ipv4 (unicast|multicast)",
paul718e3742002-12-13 20:15:29 +00007173 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007174 BGP_STR
7175 "Address family\n"
7176 "Address Family modifier\n"
7177 "Address Family modifier\n")
7178{
7179 if (strncmp (argv[0], "m", 1) == 0)
ajs5a646652004-11-05 01:25:55 +00007180 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
7181 NULL);
paul718e3742002-12-13 20:15:29 +00007182
ajs5a646652004-11-05 01:25:55 +00007183 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL);
paul718e3742002-12-13 20:15:29 +00007184}
7185
Lou Berger35c36862016-01-12 13:42:06 -05007186DEFUN (show_bgp_ipv4_safi_route,
7187 show_bgp_ipv4_safi_route_cmd,
7188 "show bgp ipv4 (unicast|multicast) A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007189 SHOW_STR
7190 BGP_STR
7191 "Address family\n"
7192 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00007193 "Address Family modifier\n"
7194 "Network in the BGP routing table to display\n")
7195{
7196 if (strncmp (argv[0], "m", 1) == 0)
7197 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0);
7198
7199 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0);
7200}
7201
Lou Berger35c36862016-01-12 13:42:06 -05007202DEFUN (show_bgp_ipv4_vpn_route,
7203 show_bgp_ipv4_vpn_route_cmd,
7204 "show bgp ipv4 vpn A.B.C.D",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007205 SHOW_STR
7206 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007207 "Address Family\n"
7208 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007209 "Network in the BGP routing table to display\n")
7210{
7211 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0);
7212}
7213
Lou Berger35c36862016-01-12 13:42:06 -05007214DEFUN (show_bgp_ipv6_vpn_route,
7215 show_bgp_ipv6_vpn_route_cmd,
7216 "show bgp ipv6 vpn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007217 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007218 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007219 "Address Family\n"
7220 "Display VPN NLRI specific information\n"
7221 "Network in the BGP routing table to display\n")
7222{
7223 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0);
7224}
Lou Berger35c36862016-01-12 13:42:06 -05007225
7226DEFUN (show_bgp_ipv4_vpn_rd_route,
7227 show_bgp_ipv4_vpn_rd_route_cmd,
7228 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D",
7229 SHOW_STR
7230 BGP_STR
7231 IP_STR
7232 "Display VPN NLRI specific information\n"
paul718e3742002-12-13 20:15:29 +00007233 "Display information for a route distinguisher\n"
7234 "VPN Route Distinguisher\n"
7235 "Network in the BGP routing table to display\n")
7236{
7237 int ret;
7238 struct prefix_rd prd;
7239
7240 ret = str2prefix_rd (argv[0], &prd);
7241 if (! ret)
7242 {
7243 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7244 return CMD_WARNING;
7245 }
7246 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0);
7247}
7248
Lou Berger35c36862016-01-12 13:42:06 -05007249DEFUN (show_bgp_ipv6_vpn_rd_route,
7250 show_bgp_ipv6_vpn_rd_route_cmd,
7251 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007252 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007253 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007254 "Address Family\n"
7255 "Display VPN NLRI specific information\n"
7256 "Display information for a route distinguisher\n"
7257 "VPN Route Distinguisher\n"
7258 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007259{
Lou Berger35c36862016-01-12 13:42:06 -05007260 int ret;
7261 struct prefix_rd prd;
7262
7263 ret = str2prefix_rd (argv[0], &prd);
7264 if (! ret)
7265 {
7266 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7267 return CMD_WARNING;
7268 }
7269 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007270}
7271
Lou Berger651b4022016-01-12 13:42:07 -05007272DEFUN (show_bgp_ipv4_encap_route,
7273 show_bgp_ipv4_encap_route_cmd,
7274 "show bgp ipv4 encap A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007275 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007276 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007277 IP_STR
7278 "Display ENCAP NLRI specific information\n"
7279 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007280{
Lou Berger651b4022016-01-12 13:42:07 -05007281 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007282}
7283
Lou Berger651b4022016-01-12 13:42:07 -05007284DEFUN (show_bgp_ipv6_encap_route,
7285 show_bgp_ipv6_encap_route_cmd,
7286 "show bgp ipv6 encap X:X::X:X",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007287 SHOW_STR
7288 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007289 IP6_STR
7290 "Display ENCAP NLRI specific information\n"
7291 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007292{
Lou Berger651b4022016-01-12 13:42:07 -05007293 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007294}
7295
Lou Berger651b4022016-01-12 13:42:07 -05007296DEFUN (show_bgp_ipv4_safi_rd_route,
7297 show_bgp_ipv4_safi_rd_route_cmd,
7298 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D",
paul718e3742002-12-13 20:15:29 +00007299 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007300 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007301 "Address Family\n"
7302 "Address Family Modifier\n"
7303 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007304 "Display information for a route distinguisher\n"
Lou Berger651b4022016-01-12 13:42:07 -05007305 "ENCAP Route Distinguisher\n"
7306 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007307{
7308 int ret;
7309 struct prefix_rd prd;
Lou Berger651b4022016-01-12 13:42:07 -05007310 safi_t safi;
paul718e3742002-12-13 20:15:29 +00007311
Lou Berger651b4022016-01-12 13:42:07 -05007312 if (bgp_parse_safi(argv[0], &safi)) {
7313 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7314 return CMD_WARNING;
7315 }
7316 ret = str2prefix_rd (argv[1], &prd);
paul718e3742002-12-13 20:15:29 +00007317 if (! ret)
7318 {
7319 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7320 return CMD_WARNING;
7321 }
Lou Berger651b4022016-01-12 13:42:07 -05007322 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007323}
7324
Lou Berger651b4022016-01-12 13:42:07 -05007325DEFUN (show_bgp_ipv6_safi_rd_route,
7326 show_bgp_ipv6_safi_rd_route_cmd,
7327 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007328 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007329 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007330 "Address Family\n"
7331 "Address Family Modifier\n"
7332 "Address Family Modifier\n"
7333 "Display information for a route distinguisher\n"
7334 "ENCAP Route Distinguisher\n"
7335 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007336{
Lou Berger651b4022016-01-12 13:42:07 -05007337 int ret;
7338 struct prefix_rd prd;
7339 safi_t safi;
paulbb46e942003-10-24 19:02:03 +00007340
Lou Berger651b4022016-01-12 13:42:07 -05007341 if (bgp_parse_safi(argv[0], &safi)) {
7342 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7343 return CMD_WARNING;
7344 }
7345 ret = str2prefix_rd (argv[1], &prd);
7346 if (! ret)
7347 {
7348 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7349 return CMD_WARNING;
7350 }
7351 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0);
paul718e3742002-12-13 20:15:29 +00007352}
7353
Lou Berger35c36862016-01-12 13:42:06 -05007354DEFUN (show_bgp_ipv4_prefix,
7355 show_bgp_ipv4_prefix_cmd,
7356 "show bgp ipv4 A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007357 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007358 BGP_STR
paul718e3742002-12-13 20:15:29 +00007359 IP_STR
paul718e3742002-12-13 20:15:29 +00007360 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7361{
Lou Berger35c36862016-01-12 13:42:06 -05007362 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007363}
7364
Lou Berger35c36862016-01-12 13:42:06 -05007365DEFUN (show_bgp_ipv4_safi_prefix,
7366 show_bgp_ipv4_safi_prefix_cmd,
7367 "show bgp ipv4 (unicast|multicast) A.B.C.D/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007368 SHOW_STR
7369 BGP_STR
7370 "Address family\n"
7371 "Address Family modifier\n"
Lou Berger35c36862016-01-12 13:42:06 -05007372 "Address Family modifier\n"
7373 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -04007374{
7375 if (strncmp (argv[0], "m", 1) == 0)
Lou Berger35c36862016-01-12 13:42:06 -05007376 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007377
Lou Berger35c36862016-01-12 13:42:06 -05007378 return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007379}
7380
Lou Berger35c36862016-01-12 13:42:06 -05007381DEFUN (show_bgp_ipv4_vpn_prefix,
7382 show_bgp_ipv4_vpn_prefix_cmd,
7383 "show bgp ipv4 vpn A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007384 SHOW_STR
7385 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007386 IP_STR
7387 "Display VPN NLRI specific information\n"
7388 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +00007389{
Lou Berger35c36862016-01-12 13:42:06 -05007390 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007391}
7392
Lou Berger35c36862016-01-12 13:42:06 -05007393DEFUN (show_bgp_ipv6_vpn_prefix,
7394 show_bgp_ipv6_vpn_prefix_cmd,
7395 "show bgp ipv6 vpn X:X::X:X/M",
7396 SHOW_STR
7397 BGP_STR
7398 "Address Family\n"
7399 "Display VPN NLRI specific information\n"
7400 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7401{
7402 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 1);
7403}
Lou Berger35c36862016-01-12 13:42:06 -05007404
Lou Berger651b4022016-01-12 13:42:07 -05007405DEFUN (show_bgp_ipv4_encap_prefix,
7406 show_bgp_ipv4_encap_prefix_cmd,
7407 "show bgp ipv4 encap A.B.C.D/M",
paul718e3742002-12-13 20:15:29 +00007408 SHOW_STR
7409 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007410 IP_STR
7411 "Display ENCAP NLRI specific information\n"
7412 "Display information about ENCAP NLRIs\n"
7413 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7414{
7415 return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_ENCAP, NULL, 1);
7416}
paul718e3742002-12-13 20:15:29 +00007417
Lou Berger651b4022016-01-12 13:42:07 -05007418DEFUN (show_bgp_ipv6_encap_prefix,
7419 show_bgp_ipv6_encap_prefix_cmd,
7420 "show bgp ipv6 encap X:X::X:X/M",
Michael Lambert95cbbd22010-07-23 14:43:04 -04007421 SHOW_STR
7422 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007423 IP_STR
7424 "Display ENCAP NLRI specific information\n"
7425 "Display information about ENCAP NLRIs\n"
7426 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7427{
7428 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_ENCAP, NULL, 1);
7429}
Lou Berger651b4022016-01-12 13:42:07 -05007430
7431DEFUN (show_bgp_ipv4_safi_rd_prefix,
7432 show_bgp_ipv4_safi_rd_prefix_cmd,
7433 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M",
7434 SHOW_STR
7435 BGP_STR
7436 "Address Family\n"
7437 "Address Family Modifier\n"
7438 "Address Family Modifier\n"
7439 "Display information for a route distinguisher\n"
7440 "ENCAP Route Distinguisher\n"
7441 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7442{
7443 int ret;
7444 struct prefix_rd prd;
7445 safi_t safi;
7446
7447 if (bgp_parse_safi(argv[0], &safi)) {
7448 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7449 return CMD_WARNING;
7450 }
7451
7452 ret = str2prefix_rd (argv[1], &prd);
7453 if (! ret)
7454 {
7455 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7456 return CMD_WARNING;
7457 }
7458 return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1);
7459}
7460
Lou Berger651b4022016-01-12 13:42:07 -05007461DEFUN (show_bgp_ipv6_safi_rd_prefix,
7462 show_bgp_ipv6_safi_rd_prefix_cmd,
7463 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M",
7464 SHOW_STR
7465 BGP_STR
7466 "Address Family\n"
7467 "Address Family Modifier\n"
7468 "Address Family Modifier\n"
7469 "Display information for a route distinguisher\n"
7470 "ENCAP Route Distinguisher\n"
7471 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7472{
7473 int ret;
7474 struct prefix_rd prd;
7475 safi_t safi;
7476
7477 if (bgp_parse_safi(argv[0], &safi)) {
7478 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
7479 return CMD_WARNING;
7480 }
7481
7482 ret = str2prefix_rd (argv[1], &prd);
7483 if (! ret)
7484 {
7485 vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
7486 return CMD_WARNING;
7487 }
7488 return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1);
7489}
Lou Berger651b4022016-01-12 13:42:07 -05007490
7491DEFUN (show_bgp_afi_safi_view,
7492 show_bgp_afi_safi_view_cmd,
7493 "show bgp view WORD (ipv4|ipv6) (encap|mulicast|unicast|vpn)",
7494 SHOW_STR
7495 BGP_STR
7496 "BGP view\n"
7497 "BGP view name\n"
7498 "Address Family\n"
7499 "Address Family\n"
7500 "Address Family Modifier\n"
7501 "Address Family Modifier\n"
7502 "Address Family Modifier\n"
7503 "Address Family Modifier\n"
7504 )
7505{
7506 struct bgp *bgp;
7507 safi_t safi;
7508 afi_t afi;
7509
7510 if (bgp_parse_afi(argv[1], &afi)) {
7511 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7512 return CMD_WARNING;
7513 }
7514 if (bgp_parse_safi(argv[2], &safi)) {
7515 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7516 return CMD_WARNING;
7517 }
7518
7519 /* BGP structure lookup. */
7520 bgp = bgp_lookup_by_name (argv[0]);
7521 if (bgp == NULL)
7522 {
7523 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7524 return CMD_WARNING;
7525 }
7526
7527 return bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL);
7528}
7529
7530DEFUN (show_bgp_view_afi_safi_route,
7531 show_bgp_view_afi_safi_route_cmd,
7532 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D",
7533 SHOW_STR
7534 BGP_STR
7535 "BGP view\n"
7536 "View name\n"
7537 "Address Family\n"
7538 "Address Family\n"
7539 "Address Family Modifier\n"
7540 "Address Family Modifier\n"
7541 "Address Family Modifier\n"
7542 "Address Family Modifier\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -04007543 "Network in the BGP routing table to display\n")
7544{
Lou Berger651b4022016-01-12 13:42:07 -05007545 safi_t safi;
7546 afi_t afi;
Michael Lambert95cbbd22010-07-23 14:43:04 -04007547
Lou Berger651b4022016-01-12 13:42:07 -05007548 if (bgp_parse_afi(argv[1], &afi)) {
7549 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7550 return CMD_WARNING;
7551 }
7552 if (bgp_parse_safi(argv[2], &safi)) {
7553 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7554 return CMD_WARNING;
7555 }
7556 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 0);
7557}
7558
7559DEFUN (show_bgp_view_afi_safi_prefix,
7560 show_bgp_view_afi_safi_prefix_cmd,
7561 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) A.B.C.D/M",
7562 SHOW_STR
7563 BGP_STR
7564 "BGP view\n"
7565 "View name\n"
7566 "Address Family\n"
7567 "Address Family\n"
7568 "Address Family Modifier\n"
7569 "Address Family Modifier\n"
7570 "Address Family Modifier\n"
7571 "Address Family Modifier\n"
7572 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
7573{
7574 safi_t safi;
7575 afi_t afi;
7576
7577 if (bgp_parse_afi(argv[1], &afi)) {
7578 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7579 return CMD_WARNING;
7580 }
7581 if (bgp_parse_safi(argv[2], &safi)) {
7582 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
7583 return CMD_WARNING;
7584 }
7585 return bgp_show_route (vty, argv[0], argv[3], afi, safi, NULL, 1);
7586}
7587
7588/* new001 */
7589DEFUN (show_bgp_afi,
7590 show_bgp_afi_cmd,
7591 "show bgp (ipv4|ipv6)",
7592 SHOW_STR
7593 BGP_STR
7594 "Address family\n"
7595 "Address family\n")
7596{
7597 afi_t afi;
7598
7599 if (bgp_parse_afi(argv[0], &afi)) {
7600 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
7601 return CMD_WARNING;
7602 }
7603 return bgp_show (vty, NULL, afi, SAFI_UNICAST, bgp_show_type_normal,
7604 NULL);
7605}
7606
Lou Berger651b4022016-01-12 13:42:07 -05007607DEFUN (show_bgp_ipv6_safi,
7608 show_bgp_ipv6_safi_cmd,
7609 "show bgp ipv6 (unicast|multicast)",
7610 SHOW_STR
7611 BGP_STR
7612 "Address family\n"
7613 "Address Family modifier\n"
7614 "Address Family modifier\n")
7615{
7616 if (strncmp (argv[0], "m", 1) == 0)
7617 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7618 NULL);
7619
7620 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
Michael Lambert95cbbd22010-07-23 14:43:04 -04007621}
7622
Lou Berger35c36862016-01-12 13:42:06 -05007623DEFUN (show_bgp_ipv6_route,
7624 show_bgp_ipv6_route_cmd,
7625 "show bgp ipv6 X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007626 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007627 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007628 "Address family\n"
paul718e3742002-12-13 20:15:29 +00007629 "Network in the BGP routing table to display\n")
7630{
7631 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7632}
7633
Lou Berger35c36862016-01-12 13:42:06 -05007634DEFUN (show_bgp_ipv6_safi_route,
7635 show_bgp_ipv6_safi_route_cmd,
7636 "show bgp ipv6 (unicast|multicast) X:X::X:X",
paul718e3742002-12-13 20:15:29 +00007637 SHOW_STR
7638 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05007639 "Address family\n"
7640 "Address Family modifier\n"
7641 "Address Family modifier\n"
7642 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +00007643{
Lou Berger35c36862016-01-12 13:42:06 -05007644 if (strncmp (argv[0], "m", 1) == 0)
7645 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7646
7647 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paul718e3742002-12-13 20:15:29 +00007648}
7649
Lou Bergerf9b6c392016-01-12 13:42:09 -05007650/* old command */
7651DEFUN (show_ipv6_bgp_route,
7652 show_ipv6_bgp_route_cmd,
7653 "show ipv6 bgp X:X::X:X",
7654 SHOW_STR
7655 IP_STR
7656 BGP_STR
7657 "Network in the BGP routing table to display\n")
7658{
7659 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0);
7660}
7661
7662DEFUN (show_bgp_prefix,
7663 show_bgp_prefix_cmd,
7664 "show bgp X:X::X:X/M",
7665 SHOW_STR
7666 BGP_STR
7667 "IPv6 prefix <network>/<length>\n")
7668{
7669 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7670}
7671
7672
Lou Berger35c36862016-01-12 13:42:06 -05007673/* new002 */
7674DEFUN (show_bgp_ipv6_prefix,
paul718e3742002-12-13 20:15:29 +00007675 show_bgp_ipv6_prefix_cmd,
7676 "show bgp ipv6 X:X::X:X/M",
7677 SHOW_STR
7678 BGP_STR
7679 "Address family\n"
Lou Berger35c36862016-01-12 13:42:06 -05007680 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7681{
7682 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7683}
Michael Lambert95cbbd22010-07-23 14:43:04 -04007684DEFUN (show_bgp_ipv6_safi_prefix,
7685 show_bgp_ipv6_safi_prefix_cmd,
7686 "show bgp ipv6 (unicast|multicast) X:X::X:X/M",
7687 SHOW_STR
7688 BGP_STR
7689 "Address family\n"
7690 "Address Family modifier\n"
7691 "Address Family modifier\n"
7692 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7693{
7694 if (strncmp (argv[0], "m", 1) == 0)
7695 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7696
7697 return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7698}
7699
Lou Bergerf9b6c392016-01-12 13:42:09 -05007700/* old command */
7701DEFUN (show_ipv6_bgp_prefix,
7702 show_ipv6_bgp_prefix_cmd,
7703 "show ipv6 bgp X:X::X:X/M",
7704 SHOW_STR
7705 IP_STR
7706 BGP_STR
7707 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7708{
7709 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
7710}
7711
paulbb46e942003-10-24 19:02:03 +00007712DEFUN (show_bgp_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007713 show_bgp_view_cmd,
7714 "show bgp view WORD",
7715 SHOW_STR
7716 BGP_STR
7717 "BGP view\n"
7718 "View name\n")
7719{
7720 struct bgp *bgp;
7721
7722 /* BGP structure lookup. */
7723 bgp = bgp_lookup_by_name (argv[0]);
7724 if (bgp == NULL)
7725 {
7726 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7727 return CMD_WARNING;
7728 }
7729
7730 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
7731}
7732
7733DEFUN (show_bgp_view_ipv6,
Lou Berger35c36862016-01-12 13:42:06 -05007734 show_bgp_view_ipv6_cmd,
7735 "show bgp view WORD ipv6",
paulbb46e942003-10-24 19:02:03 +00007736 SHOW_STR
Lou Berger35c36862016-01-12 13:42:06 -05007737 BGP_STR
paulbb46e942003-10-24 19:02:03 +00007738 "BGP view\n"
Lou Berger35c36862016-01-12 13:42:06 -05007739 "View name\n"
7740 "Address family\n")
paulbb46e942003-10-24 19:02:03 +00007741{
7742 struct bgp *bgp;
7743
7744 /* BGP structure lookup. */
7745 bgp = bgp_lookup_by_name (argv[0]);
7746 if (bgp == NULL)
7747 {
7748 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
7749 return CMD_WARNING;
7750 }
7751
ajs5a646652004-11-05 01:25:55 +00007752 return bgp_show (vty, bgp, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL);
paulbb46e942003-10-24 19:02:03 +00007753}
paulbb46e942003-10-24 19:02:03 +00007754
7755DEFUN (show_bgp_view_route,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007756 show_bgp_view_route_cmd,
7757 "show bgp view WORD X:X::X:X",
7758 SHOW_STR
7759 BGP_STR
7760 "BGP view\n"
7761 "View name\n"
7762 "Network in the BGP routing table to display\n")
7763{
7764 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
7765}
7766
7767DEFUN (show_bgp_view_ipv6_route,
paulbb46e942003-10-24 19:02:03 +00007768 show_bgp_view_ipv6_route_cmd,
7769 "show bgp view WORD ipv6 X:X::X:X",
7770 SHOW_STR
7771 BGP_STR
7772 "BGP view\n"
7773 "View name\n"
7774 "Address family\n"
7775 "Network in the BGP routing table to display\n")
paulbb46e942003-10-24 19:02:03 +00007776{
Lou Berger35c36862016-01-12 13:42:06 -05007777 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0);
paulbb46e942003-10-24 19:02:03 +00007778}
7779
Lou Bergerf9b6c392016-01-12 13:42:09 -05007780/* old command */
7781DEFUN (show_ipv6_mbgp,
7782 show_ipv6_mbgp_cmd,
7783 "show ipv6 mbgp",
7784 SHOW_STR
7785 IP_STR
7786 MBGP_STR)
7787{
7788 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
7789 NULL);
7790}
7791
7792/* old command */
7793DEFUN (show_ipv6_mbgp_route,
7794 show_ipv6_mbgp_route_cmd,
7795 "show ipv6 mbgp X:X::X:X",
7796 SHOW_STR
7797 IP_STR
7798 MBGP_STR
7799 "Network in the MBGP routing table to display\n")
7800{
7801 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 0);
7802}
7803
7804/* old command */
7805DEFUN (show_ipv6_mbgp_prefix,
7806 show_ipv6_mbgp_prefix_cmd,
7807 "show ipv6 mbgp X:X::X:X/M",
7808 SHOW_STR
7809 IP_STR
7810 MBGP_STR
7811 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
7812{
7813 return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, NULL, 1);
7814}
7815
Lou Berger35c36862016-01-12 13:42:06 -05007816DEFUN (show_bgp_view_prefix,
Lou Bergerf9b6c392016-01-12 13:42:09 -05007817 show_bgp_view_prefix_cmd,
7818 "show bgp view WORD X:X::X:X/M",
7819 SHOW_STR
7820 BGP_STR
7821 "BGP view\n"
7822 "View name\n"
7823 "IPv6 prefix <network>/<length>\n")
7824{
7825 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
7826}
7827
7828DEFUN (show_bgp_view_ipv6_prefix,
paulbb46e942003-10-24 19:02:03 +00007829 show_bgp_view_ipv6_prefix_cmd,
7830 "show bgp view WORD ipv6 X:X::X:X/M",
7831 SHOW_STR
7832 BGP_STR
7833 "BGP view\n"
7834 "View name\n"
7835 "Address family\n"
7836 "IPv6 prefix <network>/<length>\n")
paul718e3742002-12-13 20:15:29 +00007837{
Lou Berger35c36862016-01-12 13:42:06 -05007838 return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1);
paul718e3742002-12-13 20:15:29 +00007839}
7840
paul94f2b392005-06-28 12:44:16 +00007841static int
paulfd79ac92004-10-13 05:06:08 +00007842bgp_show_regexp (struct vty *vty, int argc, const char **argv, afi_t afi,
paul718e3742002-12-13 20:15:29 +00007843 safi_t safi, enum bgp_show_type type)
7844{
7845 int i;
7846 struct buffer *b;
7847 char *regstr;
7848 int first;
7849 regex_t *regex;
ajs5a646652004-11-05 01:25:55 +00007850 int rc;
paul718e3742002-12-13 20:15:29 +00007851
7852 first = 0;
7853 b = buffer_new (1024);
7854 for (i = 0; i < argc; i++)
7855 {
7856 if (first)
7857 buffer_putc (b, ' ');
7858 else
7859 {
7860 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
7861 continue;
7862 first = 1;
7863 }
7864
7865 buffer_putstr (b, argv[i]);
7866 }
7867 buffer_putc (b, '\0');
7868
7869 regstr = buffer_getstr (b);
7870 buffer_free (b);
7871
7872 regex = bgp_regcomp (regstr);
ajs3b8b1852005-01-29 18:19:13 +00007873 XFREE(MTYPE_TMP, regstr);
paul718e3742002-12-13 20:15:29 +00007874 if (! regex)
7875 {
7876 vty_out (vty, "Can't compile regexp %s%s", argv[0],
7877 VTY_NEWLINE);
7878 return CMD_WARNING;
7879 }
7880
ajs5a646652004-11-05 01:25:55 +00007881 rc = bgp_show (vty, NULL, afi, safi, type, regex);
7882 bgp_regex_free (regex);
7883 return rc;
paul718e3742002-12-13 20:15:29 +00007884}
7885
Lou Bergerf9b6c392016-01-12 13:42:09 -05007886
7887DEFUN (show_ip_bgp_regexp,
7888 show_ip_bgp_regexp_cmd,
7889 "show ip bgp regexp .LINE",
7890 SHOW_STR
7891 IP_STR
7892 BGP_STR
7893 "Display routes matching the AS path regular expression\n"
7894 "A regular-expression to match the BGP AS paths\n")
7895{
7896 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7897 bgp_show_type_regexp);
7898}
7899
7900DEFUN (show_ip_bgp_flap_regexp,
7901 show_ip_bgp_flap_regexp_cmd,
7902 "show ip bgp flap-statistics regexp .LINE",
7903 SHOW_STR
7904 IP_STR
7905 BGP_STR
7906 "Display flap statistics of routes\n"
7907 "Display routes matching the AS path regular expression\n"
7908 "A regular-expression to match the BGP AS paths\n")
7909{
7910 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7911 bgp_show_type_flap_regexp);
7912}
7913
7914ALIAS (show_ip_bgp_flap_regexp,
7915 show_ip_bgp_damp_flap_regexp_cmd,
7916 "show ip bgp dampening flap-statistics regexp .LINE",
7917 SHOW_STR
7918 IP_STR
7919 BGP_STR
7920 "Display detailed information about dampening\n"
7921 "Display flap statistics of routes\n"
7922 "Display routes matching the AS path regular expression\n"
7923 "A regular-expression to match the BGP AS paths\n")
7924
7925DEFUN (show_ip_bgp_ipv4_regexp,
7926 show_ip_bgp_ipv4_regexp_cmd,
7927 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7928 SHOW_STR
7929 IP_STR
7930 BGP_STR
7931 "Address family\n"
7932 "Address Family modifier\n"
7933 "Address Family modifier\n"
7934 "Display routes matching the AS path regular expression\n"
7935 "A regular-expression to match the BGP AS paths\n")
7936{
7937 if (strncmp (argv[0], "m", 1) == 0)
7938 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
7939 bgp_show_type_regexp);
7940
7941 return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
7942 bgp_show_type_regexp);
7943}
7944
Lou Bergerf9b6c392016-01-12 13:42:09 -05007945DEFUN (show_bgp_regexp,
7946 show_bgp_regexp_cmd,
7947 "show bgp regexp .LINE",
7948 SHOW_STR
7949 BGP_STR
7950 "Display routes matching the AS path regular expression\n"
7951 "A regular-expression to match the BGP AS paths\n")
7952{
7953 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7954 bgp_show_type_regexp);
7955}
7956
7957/* old command */
7958DEFUN (show_ipv6_bgp_regexp,
7959 show_ipv6_bgp_regexp_cmd,
7960 "show ipv6 bgp regexp .LINE",
7961 SHOW_STR
7962 IP_STR
7963 BGP_STR
7964 "Display routes matching the AS path regular expression\n"
7965 "A regular-expression to match the BGP AS paths\n")
7966{
7967 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
7968 bgp_show_type_regexp);
7969}
7970
7971/* old command */
7972DEFUN (show_ipv6_mbgp_regexp,
7973 show_ipv6_mbgp_regexp_cmd,
7974 "show ipv6 mbgp regexp .LINE",
7975 SHOW_STR
7976 IP_STR
7977 BGP_STR
7978 "Display routes matching the AS path regular expression\n"
7979 "A regular-expression to match the MBGP AS paths\n")
7980{
7981 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_MULTICAST,
7982 bgp_show_type_regexp);
7983}
Lou Bergerf9b6c392016-01-12 13:42:09 -05007984
Lou Berger651b4022016-01-12 13:42:07 -05007985DEFUN (show_bgp_ipv4_safi_flap_regexp,
7986 show_bgp_ipv4_safi_flap_regexp_cmd,
7987 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00007988 SHOW_STR
paul718e3742002-12-13 20:15:29 +00007989 BGP_STR
paul718e3742002-12-13 20:15:29 +00007990 IP_STR
Lou Berger651b4022016-01-12 13:42:07 -05007991 "Address Family Modifier\n"
7992 "Address Family Modifier\n"
7993 "Address Family Modifier\n"
7994 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00007995 "Display flap statistics of routes\n"
7996 "Display routes matching the AS path regular expression\n"
7997 "A regular-expression to match the BGP AS paths\n")
7998{
Lou Berger651b4022016-01-12 13:42:07 -05007999 safi_t safi;
8000
8001 if (bgp_parse_safi(argv[0], &safi)) {
8002 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8003 return CMD_WARNING;
8004 }
8005 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
8006 bgp_show_type_flap_regexp);
paul718e3742002-12-13 20:15:29 +00008007}
8008
Lou Berger651b4022016-01-12 13:42:07 -05008009ALIAS (show_bgp_ipv4_safi_flap_regexp,
8010 show_bgp_ipv4_safi_damp_flap_regexp_cmd,
8011 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
Balaji3921cc52015-05-16 23:12:17 +05308012 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308013 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008014 IP_STR
8015 "Address Family Modifier\n"
8016 "Address Family Modifier\n"
8017 "Address Family Modifier\n"
8018 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308019 "Display detailed information about dampening\n"
8020 "Display flap statistics of routes\n"
8021 "Display routes matching the AS path regular expression\n"
8022 "A regular-expression to match the BGP AS paths\n")
8023
Lou Berger651b4022016-01-12 13:42:07 -05008024DEFUN (show_bgp_ipv6_safi_flap_regexp,
8025 show_bgp_ipv6_safi_flap_regexp_cmd,
8026 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008027 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008028 BGP_STR
8029 IPV6_STR
8030 "Address Family Modifier\n"
8031 "Address Family Modifier\n"
8032 "Address Family Modifier\n"
8033 "Address Family Modifier\n"
8034 "Display flap statistics of routes\n"
8035 "Display routes matching the AS path regular expression\n"
8036 "A regular-expression to match the BGP AS paths\n")
8037{
8038 safi_t safi;
8039
8040 if (bgp_parse_safi(argv[0], &safi)) {
8041 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
8042 return CMD_WARNING;
8043 }
8044 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
8045 bgp_show_type_flap_regexp);
8046}
8047
8048ALIAS (show_bgp_ipv6_safi_flap_regexp,
8049 show_bgp_ipv6_safi_damp_flap_regexp_cmd,
8050 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics regexp .LINE",
8051 SHOW_STR
8052 BGP_STR
8053 IPV6_STR
8054 "Address Family Modifier\n"
8055 "Address Family Modifier\n"
8056 "Address Family Modifier\n"
8057 "Address Family Modifier\n"
8058 "Display detailed information about dampening\n"
8059 "Display flap statistics of routes\n"
8060 "Display routes matching the AS path regular expression\n"
8061 "A regular-expression to match the BGP AS paths\n")
Lou Berger651b4022016-01-12 13:42:07 -05008062
8063DEFUN (show_bgp_ipv4_safi_regexp,
8064 show_bgp_ipv4_safi_regexp_cmd,
8065 "show bgp ipv4 (encap|multicast|unicast|vpn) regexp .LINE",
8066 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008067 BGP_STR
8068 "Address family\n"
8069 "Address Family modifier\n"
8070 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008071 "Address Family modifier\n"
8072 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008073 "Display routes matching the AS path regular expression\n"
8074 "A regular-expression to match the BGP AS paths\n")
8075{
Lou Berger651b4022016-01-12 13:42:07 -05008076 safi_t safi;
8077 if (bgp_parse_safi(argv[0], &safi)) {
8078 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8079 return CMD_WARNING;
8080 }
paul718e3742002-12-13 20:15:29 +00008081
Lou Berger651b4022016-01-12 13:42:07 -05008082 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008083 bgp_show_type_regexp);
8084}
Lou Berger205e6742016-01-12 13:42:11 -05008085
Lou Berger651b4022016-01-12 13:42:07 -05008086DEFUN (show_bgp_ipv6_safi_regexp,
8087 show_bgp_ipv6_safi_regexp_cmd,
8088 "show bgp ipv6 (encap|multicast|unicast|vpn) regexp .LINE",
paul718e3742002-12-13 20:15:29 +00008089 SHOW_STR
8090 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008091 "Address family\n"
8092 "Address Family modifier\n"
8093 "Address Family modifier\n"
8094 "Address Family modifier\n"
8095 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008096 "Display routes matching the AS path regular expression\n"
8097 "A regular-expression to match the BGP AS paths\n")
8098{
Lou Berger651b4022016-01-12 13:42:07 -05008099 safi_t safi;
8100 if (bgp_parse_safi(argv[0], &safi)) {
8101 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8102 return CMD_WARNING;
8103 }
8104
8105 return bgp_show_regexp (vty, argc-1, argv+1, AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008106 bgp_show_type_regexp);
8107}
8108
Lou Berger651b4022016-01-12 13:42:07 -05008109DEFUN (show_bgp_ipv6_regexp,
paul718e3742002-12-13 20:15:29 +00008110 show_bgp_ipv6_regexp_cmd,
8111 "show bgp ipv6 regexp .LINE",
8112 SHOW_STR
8113 BGP_STR
8114 "Address family\n"
8115 "Display routes matching the AS path regular expression\n"
8116 "A regular-expression to match the BGP AS paths\n")
paul718e3742002-12-13 20:15:29 +00008117{
8118 return bgp_show_regexp (vty, argc, argv, AFI_IP6, SAFI_UNICAST,
8119 bgp_show_type_regexp);
8120}
8121
paul94f2b392005-06-28 12:44:16 +00008122static int
paulfd79ac92004-10-13 05:06:08 +00008123bgp_show_prefix_list (struct vty *vty, const char *prefix_list_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008124 safi_t safi, enum bgp_show_type type)
8125{
8126 struct prefix_list *plist;
8127
8128 plist = prefix_list_lookup (afi, prefix_list_str);
8129 if (plist == NULL)
8130 {
8131 vty_out (vty, "%% %s is not a valid prefix-list name%s",
8132 prefix_list_str, VTY_NEWLINE);
8133 return CMD_WARNING;
8134 }
8135
ajs5a646652004-11-05 01:25:55 +00008136 return bgp_show (vty, NULL, afi, safi, type, plist);
paul718e3742002-12-13 20:15:29 +00008137}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008138DEFUN (show_ip_bgp_prefix_list,
8139 show_ip_bgp_prefix_list_cmd,
8140 "show ip bgp prefix-list WORD",
8141 SHOW_STR
8142 IP_STR
8143 BGP_STR
8144 "Display routes conforming to the prefix-list\n"
8145 "IP prefix-list name\n")
8146{
8147 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8148 bgp_show_type_prefix_list);
8149}
8150
8151DEFUN (show_ip_bgp_flap_prefix_list,
8152 show_ip_bgp_flap_prefix_list_cmd,
8153 "show ip bgp flap-statistics prefix-list WORD",
8154 SHOW_STR
8155 IP_STR
8156 BGP_STR
8157 "Display flap statistics of routes\n"
8158 "Display routes conforming to the prefix-list\n"
8159 "IP prefix-list name\n")
8160{
8161 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8162 bgp_show_type_flap_prefix_list);
8163}
8164
8165ALIAS (show_ip_bgp_flap_prefix_list,
8166 show_ip_bgp_damp_flap_prefix_list_cmd,
8167 "show ip bgp dampening flap-statistics prefix-list WORD",
8168 SHOW_STR
8169 IP_STR
8170 BGP_STR
8171 "Display detailed information about dampening\n"
8172 "Display flap statistics of routes\n"
8173 "Display routes conforming to the prefix-list\n"
8174 "IP prefix-list name\n")
8175
8176DEFUN (show_ip_bgp_ipv4_prefix_list,
8177 show_ip_bgp_ipv4_prefix_list_cmd,
8178 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8179 SHOW_STR
8180 IP_STR
8181 BGP_STR
8182 "Address family\n"
8183 "Address Family modifier\n"
8184 "Address Family modifier\n"
8185 "Display routes conforming to the prefix-list\n"
8186 "IP prefix-list name\n")
8187{
8188 if (strncmp (argv[0], "m", 1) == 0)
8189 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8190 bgp_show_type_prefix_list);
8191
8192 return bgp_show_prefix_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8193 bgp_show_type_prefix_list);
8194}
8195
Lou Bergerf9b6c392016-01-12 13:42:09 -05008196DEFUN (show_bgp_prefix_list,
8197 show_bgp_prefix_list_cmd,
8198 "show bgp prefix-list WORD",
8199 SHOW_STR
8200 BGP_STR
8201 "Display routes conforming to the prefix-list\n"
8202 "IPv6 prefix-list name\n")
8203{
8204 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8205 bgp_show_type_prefix_list);
8206}
8207
8208ALIAS (show_bgp_prefix_list,
8209 show_bgp_ipv6_prefix_list_cmd,
8210 "show bgp ipv6 prefix-list WORD",
8211 SHOW_STR
8212 BGP_STR
8213 "Address family\n"
8214 "Display routes conforming to the prefix-list\n"
8215 "IPv6 prefix-list name\n")
8216
8217/* old command */
8218DEFUN (show_ipv6_bgp_prefix_list,
8219 show_ipv6_bgp_prefix_list_cmd,
8220 "show ipv6 bgp prefix-list WORD",
8221 SHOW_STR
8222 IPV6_STR
8223 BGP_STR
8224 "Display routes matching the prefix-list\n"
8225 "IPv6 prefix-list name\n")
8226{
8227 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8228 bgp_show_type_prefix_list);
8229}
8230
8231/* old command */
8232DEFUN (show_ipv6_mbgp_prefix_list,
8233 show_ipv6_mbgp_prefix_list_cmd,
8234 "show ipv6 mbgp prefix-list WORD",
8235 SHOW_STR
8236 IPV6_STR
8237 MBGP_STR
8238 "Display routes matching the prefix-list\n"
8239 "IPv6 prefix-list name\n")
8240{
8241 return bgp_show_prefix_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8242 bgp_show_type_prefix_list);
8243}
paul718e3742002-12-13 20:15:29 +00008244
Lou Berger35c36862016-01-12 13:42:06 -05008245DEFUN (show_bgp_ipv4_prefix_list,
8246 show_bgp_ipv4_prefix_list_cmd,
8247 "show bgp ipv4 prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008248 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008249 BGP_STR
Lou Berger35c36862016-01-12 13:42:06 -05008250 IP_STR
paul718e3742002-12-13 20:15:29 +00008251 "Display routes conforming to the prefix-list\n"
8252 "IP prefix-list name\n")
8253{
8254 return bgp_show_prefix_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8255 bgp_show_type_prefix_list);
8256}
8257
Lou Berger651b4022016-01-12 13:42:07 -05008258DEFUN (show_bgp_ipv4_safi_flap_prefix_list,
8259 show_bgp_ipv4_safi_flap_prefix_list_cmd,
8260 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008261 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008262 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008263 IP_STR
8264 "Address Family Modifier\n"
8265 "Address Family Modifier\n"
8266 "Address Family Modifier\n"
8267 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008268 "Display flap statistics of routes\n"
8269 "Display routes conforming to the prefix-list\n"
8270 "IP prefix-list name\n")
8271{
Lou Berger651b4022016-01-12 13:42:07 -05008272 safi_t safi;
8273 if (bgp_parse_safi(argv[0], &safi)) {
8274 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8275 return CMD_WARNING;
8276 }
8277 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008278 bgp_show_type_flap_prefix_list);
8279}
8280
Lou Berger651b4022016-01-12 13:42:07 -05008281ALIAS (show_bgp_ipv4_safi_flap_prefix_list,
8282 show_bgp_ipv4_safi_damp_flap_prefix_list_cmd,
8283 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308284 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308285 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008286 IP_STR
8287 "Address Family Modifier\n"
8288 "Address Family Modifier\n"
8289 "Address Family Modifier\n"
8290 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308291 "Display detailed information about dampening\n"
8292 "Display flap statistics of routes\n"
8293 "Display routes conforming to the prefix-list\n"
8294 "IP prefix-list name\n")
8295
Lou Berger651b4022016-01-12 13:42:07 -05008296DEFUN (show_bgp_ipv6_safi_flap_prefix_list,
8297 show_bgp_ipv6_safi_flap_prefix_list_cmd,
8298 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008299 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008300 BGP_STR
8301 IPV6_STR
8302 "Address Family Modifier\n"
8303 "Address Family Modifier\n"
8304 "Address Family Modifier\n"
8305 "Address Family Modifier\n"
8306 "Display flap statistics of routes\n"
8307 "Display routes conforming to the prefix-list\n"
8308 "IP prefix-list name\n")
8309{
8310 safi_t safi;
8311 if (bgp_parse_safi(argv[0], &safi)) {
8312 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8313 return CMD_WARNING;
8314 }
8315 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
8316 bgp_show_type_flap_prefix_list);
8317}
8318ALIAS (show_bgp_ipv6_safi_flap_prefix_list,
8319 show_bgp_ipv6_safi_damp_flap_prefix_list_cmd,
8320 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics prefix-list WORD",
8321 SHOW_STR
8322 BGP_STR
8323 IPV6_STR
8324 "Address Family Modifier\n"
8325 "Address Family Modifier\n"
8326 "Address Family Modifier\n"
8327 "Address Family Modifier\n"
8328 "Display detailed information about dampening\n"
8329 "Display flap statistics of routes\n"
8330 "Display routes conforming to the prefix-list\n"
8331 "IP prefix-list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008332
8333DEFUN (show_bgp_ipv4_safi_prefix_list,
8334 show_bgp_ipv4_safi_prefix_list_cmd,
8335 "show bgp ipv4 (encap|multicast|unicast|vpn) prefix-list WORD",
8336 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008337 BGP_STR
8338 "Address family\n"
8339 "Address Family modifier\n"
8340 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008341 "Address Family modifier\n"
8342 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008343 "Display routes conforming to the prefix-list\n"
8344 "IP prefix-list name\n")
8345{
Lou Berger651b4022016-01-12 13:42:07 -05008346 safi_t safi;
8347 if (bgp_parse_safi(argv[0], &safi)) {
8348 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8349 return CMD_WARNING;
8350 }
8351 return bgp_show_prefix_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008352 bgp_show_type_prefix_list);
8353}
Lou Berger205e6742016-01-12 13:42:11 -05008354
Lou Berger651b4022016-01-12 13:42:07 -05008355DEFUN (show_bgp_ipv6_safi_prefix_list,
8356 show_bgp_ipv6_safi_prefix_list_cmd,
8357 "show bgp ipv6 (encap|multicast|unicast|vpn) prefix-list WORD",
paul718e3742002-12-13 20:15:29 +00008358 SHOW_STR
8359 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008360 "Address family\n"
8361 "Address Family modifier\n"
8362 "Address Family modifier\n"
8363 "Address Family modifier\n"
8364 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008365 "Display routes conforming to the prefix-list\n"
Lou Berger651b4022016-01-12 13:42:07 -05008366 "IP prefix-list name\n")
paul718e3742002-12-13 20:15:29 +00008367{
Lou Berger651b4022016-01-12 13:42:07 -05008368 safi_t safi;
8369 if (bgp_parse_safi(argv[0], &safi)) {
8370 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8371 return CMD_WARNING;
8372 }
8373 return bgp_show_prefix_list (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008374 bgp_show_type_prefix_list);
8375}
8376
paul94f2b392005-06-28 12:44:16 +00008377static int
paulfd79ac92004-10-13 05:06:08 +00008378bgp_show_filter_list (struct vty *vty, const char *filter, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008379 safi_t safi, enum bgp_show_type type)
8380{
8381 struct as_list *as_list;
8382
8383 as_list = as_list_lookup (filter);
8384 if (as_list == NULL)
8385 {
8386 vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
8387 return CMD_WARNING;
8388 }
8389
ajs5a646652004-11-05 01:25:55 +00008390 return bgp_show (vty, NULL, afi, safi, type, as_list);
paul718e3742002-12-13 20:15:29 +00008391}
8392
Lou Bergerf9b6c392016-01-12 13:42:09 -05008393DEFUN (show_ip_bgp_filter_list,
8394 show_ip_bgp_filter_list_cmd,
8395 "show ip bgp filter-list WORD",
8396 SHOW_STR
8397 IP_STR
8398 BGP_STR
8399 "Display routes conforming to the filter-list\n"
8400 "Regular expression access list name\n")
8401{
8402 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8403 bgp_show_type_filter_list);
8404}
8405
8406DEFUN (show_ip_bgp_flap_filter_list,
8407 show_ip_bgp_flap_filter_list_cmd,
8408 "show ip bgp flap-statistics filter-list WORD",
8409 SHOW_STR
8410 IP_STR
8411 BGP_STR
8412 "Display flap statistics of routes\n"
8413 "Display routes conforming to the filter-list\n"
8414 "Regular expression access list name\n")
8415{
8416 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8417 bgp_show_type_flap_filter_list);
8418}
8419
8420ALIAS (show_ip_bgp_flap_filter_list,
8421 show_ip_bgp_damp_flap_filter_list_cmd,
8422 "show ip bgp dampening flap-statistics filter-list WORD",
8423 SHOW_STR
8424 IP_STR
8425 BGP_STR
8426 "Display detailed information about dampening\n"
8427 "Display flap statistics of routes\n"
8428 "Display routes conforming to the filter-list\n"
8429 "Regular expression access list name\n")
8430
8431DEFUN (show_ip_bgp_ipv4_filter_list,
8432 show_ip_bgp_ipv4_filter_list_cmd,
8433 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8434 SHOW_STR
8435 IP_STR
8436 BGP_STR
8437 "Address family\n"
8438 "Address Family modifier\n"
8439 "Address Family modifier\n"
8440 "Display routes conforming to the filter-list\n"
8441 "Regular expression access list name\n")
8442{
8443 if (strncmp (argv[0], "m", 1) == 0)
8444 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8445 bgp_show_type_filter_list);
8446
8447 return bgp_show_filter_list (vty, argv[1], AFI_IP, SAFI_UNICAST,
8448 bgp_show_type_filter_list);
8449}
8450
Lou Bergerf9b6c392016-01-12 13:42:09 -05008451DEFUN (show_bgp_filter_list,
8452 show_bgp_filter_list_cmd,
8453 "show bgp filter-list WORD",
8454 SHOW_STR
8455 BGP_STR
8456 "Display routes conforming to the filter-list\n"
8457 "Regular expression access list name\n")
8458{
8459 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8460 bgp_show_type_filter_list);
8461}
8462
8463/* old command */
8464DEFUN (show_ipv6_bgp_filter_list,
8465 show_ipv6_bgp_filter_list_cmd,
8466 "show ipv6 bgp filter-list WORD",
8467 SHOW_STR
8468 IPV6_STR
8469 BGP_STR
8470 "Display routes conforming to the filter-list\n"
8471 "Regular expression access list name\n")
8472{
8473 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8474 bgp_show_type_filter_list);
8475}
8476
8477/* old command */
8478DEFUN (show_ipv6_mbgp_filter_list,
8479 show_ipv6_mbgp_filter_list_cmd,
8480 "show ipv6 mbgp filter-list WORD",
8481 SHOW_STR
8482 IPV6_STR
8483 MBGP_STR
8484 "Display routes conforming to the filter-list\n"
8485 "Regular expression access list name\n")
8486{
8487 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
8488 bgp_show_type_filter_list);
8489}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008490
8491DEFUN (show_ip_bgp_dampening_info,
8492 show_ip_bgp_dampening_params_cmd,
8493 "show ip bgp dampening parameters",
8494 SHOW_STR
8495 IP_STR
8496 BGP_STR
8497 "Display detailed information about dampening\n"
8498 "Display detail of configured dampening parameters\n")
8499{
8500 return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
8501}
8502
Lou Berger651b4022016-01-12 13:42:07 -05008503DEFUN (show_bgp_ipv4_filter_list,
8504 show_bgp_ipv4_filter_list_cmd,
8505 "show bgp ipv4 filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008506 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008507 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008508 IP_STR
paul718e3742002-12-13 20:15:29 +00008509 "Display routes conforming to the filter-list\n"
8510 "Regular expression access list name\n")
8511{
8512 return bgp_show_filter_list (vty, argv[0], AFI_IP, SAFI_UNICAST,
8513 bgp_show_type_filter_list);
8514}
8515
Lou Berger651b4022016-01-12 13:42:07 -05008516DEFUN (show_bgp_ipv4_safi_flap_filter_list,
8517 show_bgp_ipv4_safi_flap_filter_list_cmd,
8518 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008519 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008520 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008521 IP_STR
8522 "Address Family modifier\n"
8523 "Address Family modifier\n"
8524 "Address Family modifier\n"
8525 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008526 "Display flap statistics of routes\n"
8527 "Display routes conforming to the filter-list\n"
8528 "Regular expression access list name\n")
8529{
Lou Berger651b4022016-01-12 13:42:07 -05008530 safi_t safi;
8531
8532 if (bgp_parse_safi(argv[0], &safi)) {
8533 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8534 return CMD_WARNING;
8535 }
8536 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008537 bgp_show_type_flap_filter_list);
8538}
8539
Lou Berger651b4022016-01-12 13:42:07 -05008540ALIAS (show_bgp_ipv4_safi_flap_filter_list,
8541 show_bgp_ipv4_safi_damp_flap_filter_list_cmd,
8542 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
Balaji3921cc52015-05-16 23:12:17 +05308543 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308544 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008545 IP_STR
8546 "Address Family modifier\n"
8547 "Address Family modifier\n"
8548 "Address Family modifier\n"
8549 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308550 "Display detailed information about dampening\n"
8551 "Display flap statistics of routes\n"
8552 "Display routes conforming to the filter-list\n"
8553 "Regular expression access list name\n")
8554
Lou Berger651b4022016-01-12 13:42:07 -05008555DEFUN (show_bgp_ipv6_safi_flap_filter_list,
8556 show_bgp_ipv6_safi_flap_filter_list_cmd,
8557 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics filter-list WORD",
paul718e3742002-12-13 20:15:29 +00008558 SHOW_STR
8559 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008560 IPV6_STR
8561 "Address Family modifier\n"
8562 "Address Family modifier\n"
8563 "Address Family modifier\n"
8564 "Address Family modifier\n"
8565 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +00008566 "Display routes conforming to the filter-list\n"
8567 "Regular expression access list name\n")
8568{
Lou Berger651b4022016-01-12 13:42:07 -05008569 safi_t safi;
8570
8571 if (bgp_parse_safi(argv[0], &safi)) {
8572 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8573 return CMD_WARNING;
8574 }
8575 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8576 bgp_show_type_flap_filter_list);
8577}
8578ALIAS (show_bgp_ipv6_safi_flap_filter_list,
8579 show_bgp_ipv6_safi_damp_flap_filter_list_cmd,
8580 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics filter-list WORD",
8581 SHOW_STR
8582 BGP_STR
8583 IPV6_STR
8584 "Address Family modifier\n"
8585 "Address Family modifier\n"
8586 "Address Family modifier\n"
8587 "Address Family modifier\n"
8588 "Display detailed information about dampening\n"
8589 "Display flap statistics of routes\n"
8590 "Display routes conforming to the filter-list\n"
8591 "Regular expression access list name\n")
Lou Berger651b4022016-01-12 13:42:07 -05008592
8593DEFUN (show_bgp_ipv4_safi_filter_list,
8594 show_bgp_ipv4_safi_filter_list_cmd,
8595 "show bgp ipv4 (encap|multicast|unicast|vpn) filter-list WORD",
8596 SHOW_STR
8597 BGP_STR
8598 "Address Family modifier\n"
8599 "Address Family modifier\n"
8600 "Address Family modifier\n"
8601 "Address Family modifier\n"
8602 "Display routes conforming to the filter-list\n"
8603 "Regular expression access list name\n")
8604{
8605 safi_t safi;
8606
8607 if (bgp_parse_safi(argv[0], &safi)) {
8608 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8609 return CMD_WARNING;
8610 }
8611 return bgp_show_filter_list (vty, argv[1], AFI_IP, safi,
8612 bgp_show_type_filter_list);
8613}
Lou Berger205e6742016-01-12 13:42:11 -05008614
Lou Berger651b4022016-01-12 13:42:07 -05008615DEFUN (show_bgp_ipv6_safi_filter_list,
8616 show_bgp_ipv6_safi_filter_list_cmd,
8617 "show bgp ipv6 (encap|multicast|unicast|vpn) filter-list WORD",
8618 SHOW_STR
8619 BGP_STR
8620 "Address Family modifier\n"
8621 "Address Family modifier\n"
8622 "Address Family modifier\n"
8623 "Address Family modifier\n"
8624 "Display routes conforming to the filter-list\n"
8625 "Regular expression access list name\n")
8626{
8627 safi_t safi;
8628
8629 if (bgp_parse_safi(argv[0], &safi)) {
8630 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8631 return CMD_WARNING;
8632 }
8633 return bgp_show_filter_list (vty, argv[1], AFI_IP6, safi,
8634 bgp_show_type_filter_list);
paul718e3742002-12-13 20:15:29 +00008635}
8636
Lou Bergerf9b6c392016-01-12 13:42:09 -05008637DEFUN (show_bgp_ipv6_filter_list,
paul718e3742002-12-13 20:15:29 +00008638 show_bgp_ipv6_filter_list_cmd,
8639 "show bgp ipv6 filter-list WORD",
8640 SHOW_STR
8641 BGP_STR
8642 "Address family\n"
8643 "Display routes conforming to the filter-list\n"
8644 "Regular expression access list name\n")
paul718e3742002-12-13 20:15:29 +00008645{
8646 return bgp_show_filter_list (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8647 bgp_show_type_filter_list);
8648}
8649
paul94f2b392005-06-28 12:44:16 +00008650static int
paulfd79ac92004-10-13 05:06:08 +00008651bgp_show_route_map (struct vty *vty, const char *rmap_str, afi_t afi,
paul718e3742002-12-13 20:15:29 +00008652 safi_t safi, enum bgp_show_type type)
8653{
8654 struct route_map *rmap;
8655
8656 rmap = route_map_lookup_by_name (rmap_str);
8657 if (! rmap)
8658 {
8659 vty_out (vty, "%% %s is not a valid route-map name%s",
8660 rmap_str, VTY_NEWLINE);
8661 return CMD_WARNING;
8662 }
8663
ajs5a646652004-11-05 01:25:55 +00008664 return bgp_show (vty, NULL, afi, safi, type, rmap);
paul718e3742002-12-13 20:15:29 +00008665}
8666
Lou Bergerf9b6c392016-01-12 13:42:09 -05008667DEFUN (show_ip_bgp_route_map,
8668 show_ip_bgp_route_map_cmd,
8669 "show ip bgp route-map WORD",
8670 SHOW_STR
8671 IP_STR
8672 BGP_STR
8673 "Display routes matching the route-map\n"
8674 "A route-map to match on\n")
8675{
8676 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8677 bgp_show_type_route_map);
8678}
8679
8680DEFUN (show_ip_bgp_flap_route_map,
8681 show_ip_bgp_flap_route_map_cmd,
8682 "show ip bgp flap-statistics route-map WORD",
8683 SHOW_STR
8684 IP_STR
8685 BGP_STR
8686 "Display flap statistics of routes\n"
8687 "Display routes matching the route-map\n"
8688 "A route-map to match on\n")
8689{
8690 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8691 bgp_show_type_flap_route_map);
8692}
8693
8694ALIAS (show_ip_bgp_flap_route_map,
8695 show_ip_bgp_damp_flap_route_map_cmd,
8696 "show ip bgp dampening flap-statistics route-map WORD",
8697 SHOW_STR
8698 IP_STR
8699 BGP_STR
8700 "Display detailed information about dampening\n"
8701 "Display flap statistics of routes\n"
8702 "Display routes matching the route-map\n"
8703 "A route-map to match on\n")
8704
8705DEFUN (show_ip_bgp_ipv4_route_map,
8706 show_ip_bgp_ipv4_route_map_cmd,
8707 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
8708 SHOW_STR
8709 IP_STR
8710 BGP_STR
8711 "Address family\n"
8712 "Address Family modifier\n"
8713 "Address Family modifier\n"
8714 "Display routes matching the route-map\n"
8715 "A route-map to match on\n")
8716{
8717 if (strncmp (argv[0], "m", 1) == 0)
8718 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_MULTICAST,
8719 bgp_show_type_route_map);
8720
8721 return bgp_show_route_map (vty, argv[1], AFI_IP, SAFI_UNICAST,
8722 bgp_show_type_route_map);
8723}
8724
8725DEFUN (show_bgp_route_map,
8726 show_bgp_route_map_cmd,
8727 "show bgp route-map WORD",
8728 SHOW_STR
8729 BGP_STR
8730 "Display routes matching the route-map\n"
8731 "A route-map to match on\n")
8732{
8733 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
8734 bgp_show_type_route_map);
8735}
8736
8737DEFUN (show_ip_bgp_cidr_only,
8738 show_ip_bgp_cidr_only_cmd,
8739 "show ip bgp cidr-only",
8740 SHOW_STR
8741 IP_STR
8742 BGP_STR
8743 "Display only routes with non-natural netmasks\n")
8744{
8745 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8746 bgp_show_type_cidr_only, NULL);
8747}
8748
8749DEFUN (show_ip_bgp_flap_cidr_only,
8750 show_ip_bgp_flap_cidr_only_cmd,
8751 "show ip bgp flap-statistics cidr-only",
8752 SHOW_STR
8753 IP_STR
8754 BGP_STR
8755 "Display flap statistics of routes\n"
8756 "Display only routes with non-natural netmasks\n")
8757{
8758 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8759 bgp_show_type_flap_cidr_only, NULL);
8760}
8761
8762ALIAS (show_ip_bgp_flap_cidr_only,
8763 show_ip_bgp_damp_flap_cidr_only_cmd,
8764 "show ip bgp dampening flap-statistics cidr-only",
8765 SHOW_STR
8766 IP_STR
8767 BGP_STR
8768 "Display detailed information about dampening\n"
8769 "Display flap statistics of routes\n"
8770 "Display only routes with non-natural netmasks\n")
8771
8772DEFUN (show_ip_bgp_ipv4_cidr_only,
8773 show_ip_bgp_ipv4_cidr_only_cmd,
8774 "show ip bgp ipv4 (unicast|multicast) cidr-only",
8775 SHOW_STR
8776 IP_STR
8777 BGP_STR
8778 "Address family\n"
8779 "Address Family modifier\n"
8780 "Address Family modifier\n"
8781 "Display only routes with non-natural netmasks\n")
8782{
8783 if (strncmp (argv[0], "m", 1) == 0)
8784 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8785 bgp_show_type_cidr_only, NULL);
8786
8787 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8788 bgp_show_type_cidr_only, NULL);
8789}
8790
8791DEFUN (show_ip_bgp_community_all,
8792 show_ip_bgp_community_all_cmd,
8793 "show ip bgp community",
8794 SHOW_STR
8795 IP_STR
8796 BGP_STR
8797 "Display routes matching the communities\n")
8798{
8799 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8800 bgp_show_type_community_all, NULL);
8801}
8802
8803DEFUN (show_ip_bgp_ipv4_community_all,
8804 show_ip_bgp_ipv4_community_all_cmd,
8805 "show ip bgp ipv4 (unicast|multicast) community",
8806 SHOW_STR
8807 IP_STR
8808 BGP_STR
8809 "Address family\n"
8810 "Address Family modifier\n"
8811 "Address Family modifier\n"
8812 "Display routes matching the communities\n")
8813{
8814 if (strncmp (argv[0], "m", 1) == 0)
8815 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
8816 bgp_show_type_community_all, NULL);
8817
8818 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
8819 bgp_show_type_community_all, NULL);
8820}
8821
Lou Bergerf9b6c392016-01-12 13:42:09 -05008822DEFUN (show_bgp_community_all,
8823 show_bgp_community_all_cmd,
8824 "show bgp community",
8825 SHOW_STR
8826 BGP_STR
8827 "Display routes matching the communities\n")
8828{
8829 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8830 bgp_show_type_community_all, NULL);
8831}
8832
8833ALIAS (show_bgp_community_all,
8834 show_bgp_ipv6_community_all_cmd,
8835 "show bgp ipv6 community",
8836 SHOW_STR
8837 BGP_STR
8838 "Address family\n"
8839 "Display routes matching the communities\n")
8840
8841/* old command */
8842DEFUN (show_ipv6_bgp_community_all,
8843 show_ipv6_bgp_community_all_cmd,
8844 "show ipv6 bgp community",
8845 SHOW_STR
8846 IPV6_STR
8847 BGP_STR
8848 "Display routes matching the communities\n")
8849{
8850 return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST,
8851 bgp_show_type_community_all, NULL);
8852}
8853
8854/* old command */
8855DEFUN (show_ipv6_mbgp_community_all,
8856 show_ipv6_mbgp_community_all_cmd,
8857 "show ipv6 mbgp community",
8858 SHOW_STR
8859 IPV6_STR
8860 MBGP_STR
8861 "Display routes matching the communities\n")
8862{
8863 return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST,
8864 bgp_show_type_community_all, NULL);
8865}
Lou Bergerf9b6c392016-01-12 13:42:09 -05008866
Lou Berger651b4022016-01-12 13:42:07 -05008867DEFUN (show_bgp_ipv4_route_map,
8868 show_bgp_ipv4_route_map_cmd,
8869 "show bgp ipv4 route-map WORD",
paul718e3742002-12-13 20:15:29 +00008870 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008871 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008872 IP_STR
paul718e3742002-12-13 20:15:29 +00008873 "Display routes matching the route-map\n"
8874 "A route-map to match on\n")
8875{
8876 return bgp_show_route_map (vty, argv[0], AFI_IP, SAFI_UNICAST,
8877 bgp_show_type_route_map);
8878}
8879
Lou Berger651b4022016-01-12 13:42:07 -05008880DEFUN (show_bgp_ipv4_safi_flap_route_map,
8881 show_bgp_ipv4_safi_flap_route_map_cmd,
8882 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008883 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008884 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008885 IP_STR
8886 "Address Family Modifier\n"
8887 "Address Family Modifier\n"
8888 "Address Family Modifier\n"
8889 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00008890 "Display flap statistics of routes\n"
8891 "Display routes matching the route-map\n"
8892 "A route-map to match on\n")
8893{
Lou Berger651b4022016-01-12 13:42:07 -05008894 safi_t safi;
8895 if (bgp_parse_safi(argv[0], &safi)) {
8896 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8897 return CMD_WARNING;
8898 }
8899 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008900 bgp_show_type_flap_route_map);
8901}
8902
Lou Berger651b4022016-01-12 13:42:07 -05008903ALIAS (show_bgp_ipv4_safi_flap_route_map,
8904 show_bgp_ipv4_safi_damp_flap_route_map_cmd,
8905 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
Balaji3921cc52015-05-16 23:12:17 +05308906 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05308907 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05008908 IP_STR
8909 "Address Family Modifier\n"
8910 "Address Family Modifier\n"
8911 "Address Family Modifier\n"
8912 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05308913 "Display detailed information about dampening\n"
8914 "Display flap statistics of routes\n"
8915 "Display routes matching the route-map\n"
8916 "A route-map to match on\n")
Lou Berger205e6742016-01-12 13:42:11 -05008917
Lou Berger651b4022016-01-12 13:42:07 -05008918DEFUN (show_bgp_ipv6_safi_flap_route_map,
8919 show_bgp_ipv6_safi_flap_route_map_cmd,
8920 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics route-map WORD",
paul718e3742002-12-13 20:15:29 +00008921 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -05008922 BGP_STR
8923 IPV6_STR
8924 "Address Family Modifier\n"
8925 "Address Family Modifier\n"
8926 "Address Family Modifier\n"
8927 "Address Family Modifier\n"
8928 "Display flap statistics of routes\n"
8929 "Display routes matching the route-map\n"
8930 "A route-map to match on\n")
8931{
8932 safi_t safi;
8933 if (bgp_parse_safi(argv[0], &safi)) {
8934 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8935 return CMD_WARNING;
8936 }
8937 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
8938 bgp_show_type_flap_route_map);
8939}
8940ALIAS (show_bgp_ipv6_safi_flap_route_map,
8941 show_bgp_ipv6_safi_damp_flap_route_map_cmd,
8942 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics route-map WORD",
8943 SHOW_STR
8944 BGP_STR
8945 IPV6_STR
8946 "Address Family Modifier\n"
8947 "Address Family Modifier\n"
8948 "Address Family Modifier\n"
8949 "Address Family Modifier\n"
8950 "Display detailed information about dampening\n"
8951 "Display flap statistics of routes\n"
8952 "Display routes matching the route-map\n"
8953 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05008954
8955DEFUN (show_bgp_ipv4_safi_route_map,
8956 show_bgp_ipv4_safi_route_map_cmd,
8957 "show bgp ipv4 (encap|multicast|unicast|vpn) route-map WORD",
8958 SHOW_STR
paul718e3742002-12-13 20:15:29 +00008959 BGP_STR
8960 "Address family\n"
8961 "Address Family modifier\n"
8962 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -05008963 "Address Family modifier\n"
8964 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00008965 "Display routes matching the route-map\n"
8966 "A route-map to match on\n")
8967{
Lou Berger651b4022016-01-12 13:42:07 -05008968 safi_t safi;
8969 if (bgp_parse_safi(argv[0], &safi)) {
8970 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8971 return CMD_WARNING;
8972 }
8973 return bgp_show_route_map (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +00008974 bgp_show_type_route_map);
8975}
Lou Berger205e6742016-01-12 13:42:11 -05008976
Lou Berger651b4022016-01-12 13:42:07 -05008977DEFUN (show_bgp_ipv6_safi_route_map,
8978 show_bgp_ipv6_safi_route_map_cmd,
8979 "show bgp ipv6 (encap|multicast|unicast|vpn) route-map WORD",
paul718e3742002-12-13 20:15:29 +00008980 SHOW_STR
8981 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 routes matching the route-map\n"
8988 "A route-map to match on\n")
8989{
Lou Berger651b4022016-01-12 13:42:07 -05008990 safi_t safi;
8991 if (bgp_parse_safi(argv[0], &safi)) {
8992 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
8993 return CMD_WARNING;
8994 }
8995 return bgp_show_route_map (vty, argv[1], AFI_IP6, safi,
paul718e3742002-12-13 20:15:29 +00008996 bgp_show_type_route_map);
8997}
8998
Lou Berger651b4022016-01-12 13:42:07 -05008999DEFUN (show_bgp_ipv6_route_map,
paul718e3742002-12-13 20:15:29 +00009000 show_bgp_ipv6_route_map_cmd,
9001 "show bgp ipv6 route-map WORD",
9002 SHOW_STR
9003 BGP_STR
9004 "Address family\n"
9005 "Display routes matching the route-map\n"
9006 "A route-map to match on\n")
Lou Berger651b4022016-01-12 13:42:07 -05009007{
9008 return bgp_show_route_map (vty, argv[0], AFI_IP6, SAFI_UNICAST,
9009 bgp_show_type_route_map);
9010}
David Lamparter6b0655a2014-06-04 06:53:35 +02009011
Lou Berger651b4022016-01-12 13:42:07 -05009012DEFUN (show_bgp_ipv4_cidr_only,
9013 show_bgp_ipv4_cidr_only_cmd,
9014 "show bgp ipv4 cidr-only",
paul718e3742002-12-13 20:15:29 +00009015 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009016 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009017 IP_STR
paul718e3742002-12-13 20:15:29 +00009018 "Display only routes with non-natural netmasks\n")
9019{
9020 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009021 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009022}
9023
Lou Berger651b4022016-01-12 13:42:07 -05009024DEFUN (show_bgp_ipv4_safi_flap_cidr_only,
9025 show_bgp_ipv4_safi_flap_cidr_only_cmd,
9026 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics cidr-only",
paul718e3742002-12-13 20:15:29 +00009027 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009028 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009029 "Address Family\n"
9030 "Address Family Modifier\n"
9031 "Address Family Modifier\n"
9032 "Address Family Modifier\n"
9033 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +00009034 "Display flap statistics of routes\n"
9035 "Display only routes with non-natural netmasks\n")
9036{
Lou Berger651b4022016-01-12 13:42:07 -05009037 safi_t safi;
9038
9039 if (bgp_parse_safi(argv[0], &safi)) {
9040 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
9041 return CMD_WARNING;
9042 }
9043 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009044}
9045
Lou Berger651b4022016-01-12 13:42:07 -05009046ALIAS (show_bgp_ipv4_safi_flap_cidr_only,
9047 show_bgp_ipv4_safi_damp_flap_cidr_only_cmd,
9048 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics cidr-only",
Balaji3921cc52015-05-16 23:12:17 +05309049 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +05309050 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009051 "Address Family\n"
9052 "Address Family Modifier\n"
9053 "Address Family Modifier\n"
9054 "Address Family Modifier\n"
9055 "Address Family Modifier\n"
Balaji3921cc52015-05-16 23:12:17 +05309056 "Display detailed information about dampening\n"
9057 "Display flap statistics of routes\n"
9058 "Display only routes with non-natural netmasks\n")
9059
Lou Berger651b4022016-01-12 13:42:07 -05009060DEFUN (show_bgp_ipv4_safi_cidr_only,
9061 show_bgp_ipv4_safi_cidr_only_cmd,
9062 "show bgp ipv4 (unicast|multicast) cidr-only",
paul718e3742002-12-13 20:15:29 +00009063 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009064 BGP_STR
9065 "Address family\n"
9066 "Address Family modifier\n"
9067 "Address Family modifier\n"
9068 "Display only routes with non-natural netmasks\n")
9069{
9070 if (strncmp (argv[0], "m", 1) == 0)
9071 return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
ajs5a646652004-11-05 01:25:55 +00009072 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009073
9074 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
ajs5a646652004-11-05 01:25:55 +00009075 bgp_show_type_cidr_only, NULL);
paul718e3742002-12-13 20:15:29 +00009076}
David Lamparter6b0655a2014-06-04 06:53:35 +02009077
Lou Berger651b4022016-01-12 13:42:07 -05009078/* new046 */
9079DEFUN (show_bgp_afi_safi_community_all,
9080 show_bgp_afi_safi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009081 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) community",
paul718e3742002-12-13 20:15:29 +00009082 SHOW_STR
9083 BGP_STR
9084 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009085 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009086 "Address Family modifier\n"
9087 "Address Family modifier\n"
9088 "Address Family modifier\n"
9089 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +00009090 "Display routes matching the communities\n")
Lou Berger651b4022016-01-12 13:42:07 -05009091{
9092 safi_t safi;
9093 afi_t afi;
paul718e3742002-12-13 20:15:29 +00009094
Lou Berger651b4022016-01-12 13:42:07 -05009095 if (bgp_parse_afi(argv[0], &afi)) {
9096 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9097 return CMD_WARNING;
9098 }
9099 if (bgp_parse_safi(argv[1], &safi)) {
9100 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
9101 return CMD_WARNING;
9102 }
9103
9104 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
9105}
9106DEFUN (show_bgp_afi_community_all,
9107 show_bgp_afi_community_all_cmd,
Lou Berger651b4022016-01-12 13:42:07 -05009108 "show bgp (ipv4|ipv6) community",
paul718e3742002-12-13 20:15:29 +00009109 SHOW_STR
paul718e3742002-12-13 20:15:29 +00009110 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -05009111 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -05009112 "Address family\n"
paul718e3742002-12-13 20:15:29 +00009113 "Display routes matching the communities\n")
9114{
Lou Berger651b4022016-01-12 13:42:07 -05009115 afi_t afi;
9116 safi_t safi = SAFI_UNICAST;
paul718e3742002-12-13 20:15:29 +00009117
Lou Berger651b4022016-01-12 13:42:07 -05009118 if (bgp_parse_afi(argv[0], &afi)) {
9119 vty_out (vty, "Error: Bad AFI: %s%s", argv[0], VTY_NEWLINE);
9120 return CMD_WARNING;
9121 }
9122 return bgp_show (vty, NULL, afi, safi, bgp_show_type_community_all, NULL);
paul718e3742002-12-13 20:15:29 +00009123}
David Lamparter6b0655a2014-06-04 06:53:35 +02009124
paul94f2b392005-06-28 12:44:16 +00009125static int
Michael Lambert95cbbd22010-07-23 14:43:04 -04009126bgp_show_community (struct vty *vty, const char *view_name, int argc,
9127 const char **argv, int exact, afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +00009128{
9129 struct community *com;
9130 struct buffer *b;
Michael Lambert95cbbd22010-07-23 14:43:04 -04009131 struct bgp *bgp;
paul718e3742002-12-13 20:15:29 +00009132 int i;
9133 char *str;
9134 int first = 0;
9135
Michael Lambert95cbbd22010-07-23 14:43:04 -04009136 /* BGP structure lookup */
9137 if (view_name)
9138 {
9139 bgp = bgp_lookup_by_name (view_name);
9140 if (bgp == NULL)
9141 {
9142 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
9143 return CMD_WARNING;
9144 }
9145 }
9146 else
9147 {
9148 bgp = bgp_get_default ();
9149 if (bgp == NULL)
9150 {
9151 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
9152 return CMD_WARNING;
9153 }
9154 }
9155
paul718e3742002-12-13 20:15:29 +00009156 b = buffer_new (1024);
9157 for (i = 0; i < argc; i++)
9158 {
9159 if (first)
9160 buffer_putc (b, ' ');
9161 else
9162 {
9163 if ((strcmp (argv[i], "unicast") == 0) || (strcmp (argv[i], "multicast") == 0))
9164 continue;
9165 first = 1;
9166 }
9167
9168 buffer_putstr (b, argv[i]);
9169 }
9170 buffer_putc (b, '\0');
9171
9172 str = buffer_getstr (b);
9173 buffer_free (b);
9174
9175 com = community_str2com (str);
ajs3b8b1852005-01-29 18:19:13 +00009176 XFREE (MTYPE_TMP, str);
paul718e3742002-12-13 20:15:29 +00009177 if (! com)
9178 {
9179 vty_out (vty, "%% Community malformed: %s", VTY_NEWLINE);
9180 return CMD_WARNING;
9181 }
9182
Michael Lambert95cbbd22010-07-23 14:43:04 -04009183 return bgp_show (vty, bgp, afi, safi,
ajs5a646652004-11-05 01:25:55 +00009184 (exact ? bgp_show_type_community_exact :
9185 bgp_show_type_community), com);
paul718e3742002-12-13 20:15:29 +00009186}
9187
Lou Bergerf9b6c392016-01-12 13:42:09 -05009188DEFUN (show_ip_bgp_community,
9189 show_ip_bgp_community_cmd,
9190 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9191 SHOW_STR
9192 IP_STR
9193 BGP_STR
9194 "Display routes matching the communities\n"
9195 "community number\n"
9196 "Do not send outside local AS (well-known community)\n"
9197 "Do not advertise to any peer (well-known community)\n"
9198 "Do not export to next AS (well-known community)\n")
9199{
9200 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9201}
9202
9203ALIAS (show_ip_bgp_community,
9204 show_ip_bgp_community2_cmd,
9205 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9206 SHOW_STR
9207 IP_STR
9208 BGP_STR
9209 "Display routes matching the communities\n"
9210 "community number\n"
9211 "Do not send outside local AS (well-known community)\n"
9212 "Do not advertise to any peer (well-known community)\n"
9213 "Do not export to next AS (well-known community)\n"
9214 "community number\n"
9215 "Do not send outside local AS (well-known community)\n"
9216 "Do not advertise to any peer (well-known community)\n"
9217 "Do not export to next AS (well-known community)\n")
9218
9219ALIAS (show_ip_bgp_community,
9220 show_ip_bgp_community3_cmd,
9221 "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)",
9222 SHOW_STR
9223 IP_STR
9224 BGP_STR
9225 "Display routes matching the communities\n"
9226 "community number\n"
9227 "Do not send outside local AS (well-known community)\n"
9228 "Do not advertise to any peer (well-known community)\n"
9229 "Do not export to next AS (well-known community)\n"
9230 "community number\n"
9231 "Do not send outside local AS (well-known community)\n"
9232 "Do not advertise to any peer (well-known community)\n"
9233 "Do not export to next AS (well-known community)\n"
9234 "community number\n"
9235 "Do not send outside local AS (well-known community)\n"
9236 "Do not advertise to any peer (well-known community)\n"
9237 "Do not export to next AS (well-known community)\n")
9238
9239ALIAS (show_ip_bgp_community,
9240 show_ip_bgp_community4_cmd,
9241 "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)",
9242 SHOW_STR
9243 IP_STR
9244 BGP_STR
9245 "Display routes matching the communities\n"
9246 "community number\n"
9247 "Do not send outside local AS (well-known community)\n"
9248 "Do not advertise to any peer (well-known community)\n"
9249 "Do not export to next AS (well-known community)\n"
9250 "community number\n"
9251 "Do not send outside local AS (well-known community)\n"
9252 "Do not advertise to any peer (well-known community)\n"
9253 "Do not export to next AS (well-known community)\n"
9254 "community number\n"
9255 "Do not send outside local AS (well-known community)\n"
9256 "Do not advertise to any peer (well-known community)\n"
9257 "Do not export to next AS (well-known community)\n"
9258 "community number\n"
9259 "Do not send outside local AS (well-known community)\n"
9260 "Do not advertise to any peer (well-known community)\n"
9261 "Do not export to next AS (well-known community)\n")
9262
9263DEFUN (show_ip_bgp_ipv4_community,
9264 show_ip_bgp_ipv4_community_cmd,
9265 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9266 SHOW_STR
9267 IP_STR
9268 BGP_STR
9269 "Address family\n"
9270 "Address Family modifier\n"
9271 "Address Family modifier\n"
9272 "Display routes matching the communities\n"
9273 "community number\n"
9274 "Do not send outside local AS (well-known community)\n"
9275 "Do not advertise to any peer (well-known community)\n"
9276 "Do not export to next AS (well-known community)\n")
9277{
9278 if (strncmp (argv[0], "m", 1) == 0)
9279 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
9280
9281 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
9282}
9283
9284ALIAS (show_ip_bgp_ipv4_community,
9285 show_ip_bgp_ipv4_community2_cmd,
9286 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9287 SHOW_STR
9288 IP_STR
9289 BGP_STR
9290 "Address family\n"
9291 "Address Family modifier\n"
9292 "Address Family modifier\n"
9293 "Display routes matching the communities\n"
9294 "community number\n"
9295 "Do not send outside local AS (well-known community)\n"
9296 "Do not advertise to any peer (well-known community)\n"
9297 "Do not export to next AS (well-known community)\n"
9298 "community number\n"
9299 "Do not send outside local AS (well-known community)\n"
9300 "Do not advertise to any peer (well-known community)\n"
9301 "Do not export to next AS (well-known community)\n")
9302
9303ALIAS (show_ip_bgp_ipv4_community,
9304 show_ip_bgp_ipv4_community3_cmd,
9305 "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)",
9306 SHOW_STR
9307 IP_STR
9308 BGP_STR
9309 "Address family\n"
9310 "Address Family modifier\n"
9311 "Address Family modifier\n"
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 "community number\n"
9318 "Do not send outside local AS (well-known community)\n"
9319 "Do not advertise to any peer (well-known community)\n"
9320 "Do not export to next AS (well-known community)\n"
9321 "community number\n"
9322 "Do not send outside local AS (well-known community)\n"
9323 "Do not advertise to any peer (well-known community)\n"
9324 "Do not export to next AS (well-known community)\n")
9325
9326ALIAS (show_ip_bgp_ipv4_community,
9327 show_ip_bgp_ipv4_community4_cmd,
9328 "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)",
9329 SHOW_STR
9330 IP_STR
9331 BGP_STR
9332 "Address family\n"
9333 "Address Family modifier\n"
9334 "Address Family modifier\n"
9335 "Display routes matching the communities\n"
9336 "community number\n"
9337 "Do not send outside local AS (well-known community)\n"
9338 "Do not advertise to any peer (well-known community)\n"
9339 "Do not export to next AS (well-known community)\n"
9340 "community number\n"
9341 "Do not send outside local AS (well-known community)\n"
9342 "Do not advertise to any peer (well-known community)\n"
9343 "Do not export to next AS (well-known community)\n"
9344 "community number\n"
9345 "Do not send outside local AS (well-known community)\n"
9346 "Do not advertise to any peer (well-known community)\n"
9347 "Do not export to next AS (well-known community)\n"
9348 "community number\n"
9349 "Do not send outside local AS (well-known community)\n"
9350 "Do not advertise to any peer (well-known community)\n"
9351 "Do not export to next AS (well-known community)\n")
9352
9353DEFUN (show_ip_bgp_community_exact,
9354 show_ip_bgp_community_exact_cmd,
9355 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9356 SHOW_STR
9357 IP_STR
9358 BGP_STR
9359 "Display routes matching the communities\n"
9360 "community number\n"
9361 "Do not send outside local AS (well-known community)\n"
9362 "Do not advertise to any peer (well-known community)\n"
9363 "Do not export to next AS (well-known community)\n"
9364 "Exact match of the communities")
9365{
9366 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9367}
9368
9369ALIAS (show_ip_bgp_community_exact,
9370 show_ip_bgp_community2_exact_cmd,
9371 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9372 SHOW_STR
9373 IP_STR
9374 BGP_STR
9375 "Display routes matching the communities\n"
9376 "community number\n"
9377 "Do not send outside local AS (well-known community)\n"
9378 "Do not advertise to any peer (well-known community)\n"
9379 "Do not export to next AS (well-known community)\n"
9380 "community number\n"
9381 "Do not send outside local AS (well-known community)\n"
9382 "Do not advertise to any peer (well-known community)\n"
9383 "Do not export to next AS (well-known community)\n"
9384 "Exact match of the communities")
9385
9386ALIAS (show_ip_bgp_community_exact,
9387 show_ip_bgp_community3_exact_cmd,
9388 "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",
9389 SHOW_STR
9390 IP_STR
9391 BGP_STR
9392 "Display routes matching the communities\n"
9393 "community number\n"
9394 "Do not send outside local AS (well-known community)\n"
9395 "Do not advertise to any peer (well-known community)\n"
9396 "Do not export to next AS (well-known community)\n"
9397 "community number\n"
9398 "Do not send outside local AS (well-known community)\n"
9399 "Do not advertise to any peer (well-known community)\n"
9400 "Do not export to next AS (well-known community)\n"
9401 "community number\n"
9402 "Do not send outside local AS (well-known community)\n"
9403 "Do not advertise to any peer (well-known community)\n"
9404 "Do not export to next AS (well-known community)\n"
9405 "Exact match of the communities")
9406
9407ALIAS (show_ip_bgp_community_exact,
9408 show_ip_bgp_community4_exact_cmd,
9409 "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",
9410 SHOW_STR
9411 IP_STR
9412 BGP_STR
9413 "Display routes matching the communities\n"
9414 "community number\n"
9415 "Do not send outside local AS (well-known community)\n"
9416 "Do not advertise to any peer (well-known community)\n"
9417 "Do not export to next AS (well-known community)\n"
9418 "community number\n"
9419 "Do not send outside local AS (well-known community)\n"
9420 "Do not advertise to any peer (well-known community)\n"
9421 "Do not export to next AS (well-known community)\n"
9422 "community number\n"
9423 "Do not send outside local AS (well-known community)\n"
9424 "Do not advertise to any peer (well-known community)\n"
9425 "Do not export to next AS (well-known community)\n"
9426 "community number\n"
9427 "Do not send outside local AS (well-known community)\n"
9428 "Do not advertise to any peer (well-known community)\n"
9429 "Do not export to next AS (well-known community)\n"
9430 "Exact match of the communities")
9431
9432DEFUN (show_ip_bgp_ipv4_community_exact,
9433 show_ip_bgp_ipv4_community_exact_cmd,
9434 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9435 SHOW_STR
9436 IP_STR
9437 BGP_STR
9438 "Address family\n"
9439 "Address Family modifier\n"
9440 "Address Family modifier\n"
9441 "Display routes matching the communities\n"
9442 "community number\n"
9443 "Do not send outside local AS (well-known community)\n"
9444 "Do not advertise to any peer (well-known community)\n"
9445 "Do not export to next AS (well-known community)\n"
9446 "Exact match of the communities")
9447{
9448 if (strncmp (argv[0], "m", 1) == 0)
9449 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
9450
9451 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
9452}
9453
9454ALIAS (show_ip_bgp_ipv4_community_exact,
9455 show_ip_bgp_ipv4_community2_exact_cmd,
9456 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9457 SHOW_STR
9458 IP_STR
9459 BGP_STR
9460 "Address family\n"
9461 "Address Family modifier\n"
9462 "Address Family modifier\n"
9463 "Display routes matching the communities\n"
9464 "community number\n"
9465 "Do not send outside local AS (well-known community)\n"
9466 "Do not advertise to any peer (well-known community)\n"
9467 "Do not export to next AS (well-known community)\n"
9468 "community number\n"
9469 "Do not send outside local AS (well-known community)\n"
9470 "Do not advertise to any peer (well-known community)\n"
9471 "Do not export to next AS (well-known community)\n"
9472 "Exact match of the communities")
9473
9474ALIAS (show_ip_bgp_ipv4_community_exact,
9475 show_ip_bgp_ipv4_community3_exact_cmd,
9476 "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",
9477 SHOW_STR
9478 IP_STR
9479 BGP_STR
9480 "Address family\n"
9481 "Address Family modifier\n"
9482 "Address Family modifier\n"
9483 "Display routes matching the communities\n"
9484 "community number\n"
9485 "Do not send outside local AS (well-known community)\n"
9486 "Do not advertise to any peer (well-known community)\n"
9487 "Do not export to next AS (well-known community)\n"
9488 "community number\n"
9489 "Do not send outside local AS (well-known community)\n"
9490 "Do not advertise to any peer (well-known community)\n"
9491 "Do not export to next AS (well-known community)\n"
9492 "community number\n"
9493 "Do not send outside local AS (well-known community)\n"
9494 "Do not advertise to any peer (well-known community)\n"
9495 "Do not export to next AS (well-known community)\n"
9496 "Exact match of the communities")
9497
9498ALIAS (show_ip_bgp_ipv4_community_exact,
9499 show_ip_bgp_ipv4_community4_exact_cmd,
9500 "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",
9501 SHOW_STR
9502 IP_STR
9503 BGP_STR
9504 "Address family\n"
9505 "Address Family modifier\n"
9506 "Address Family modifier\n"
9507 "Display routes matching the communities\n"
9508 "community number\n"
9509 "Do not send outside local AS (well-known community)\n"
9510 "Do not advertise to any peer (well-known community)\n"
9511 "Do not export to next AS (well-known community)\n"
9512 "community number\n"
9513 "Do not send outside local AS (well-known community)\n"
9514 "Do not advertise to any peer (well-known community)\n"
9515 "Do not export to next AS (well-known community)\n"
9516 "community number\n"
9517 "Do not send outside local AS (well-known community)\n"
9518 "Do not advertise to any peer (well-known community)\n"
9519 "Do not export to next AS (well-known community)\n"
9520 "community number\n"
9521 "Do not send outside local AS (well-known community)\n"
9522 "Do not advertise to any peer (well-known community)\n"
9523 "Do not export to next AS (well-known community)\n"
9524 "Exact match of the communities")
9525
Lou Bergerf9b6c392016-01-12 13:42:09 -05009526DEFUN (show_bgp_community,
9527 show_bgp_community_cmd,
9528 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9529 SHOW_STR
9530 BGP_STR
9531 "Display routes matching the communities\n"
9532 "community number\n"
9533 "Do not send outside local AS (well-known community)\n"
9534 "Do not advertise to any peer (well-known community)\n"
9535 "Do not export to next AS (well-known community)\n")
9536{
9537 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9538}
9539
9540ALIAS (show_bgp_community,
9541 show_bgp_ipv6_community_cmd,
9542 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9543 SHOW_STR
9544 BGP_STR
9545 "Address family\n"
9546 "Display routes matching the communities\n"
9547 "community number\n"
9548 "Do not send outside local AS (well-known community)\n"
9549 "Do not advertise to any peer (well-known community)\n"
9550 "Do not export to next AS (well-known community)\n")
9551
9552ALIAS (show_bgp_community,
9553 show_bgp_community2_cmd,
9554 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9555 SHOW_STR
9556 BGP_STR
9557 "Display routes matching the communities\n"
9558 "community number\n"
9559 "Do not send outside local AS (well-known community)\n"
9560 "Do not advertise to any peer (well-known community)\n"
9561 "Do not export to next AS (well-known community)\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
9567ALIAS (show_bgp_community,
9568 show_bgp_ipv6_community2_cmd,
9569 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9570 SHOW_STR
9571 BGP_STR
9572 "Address family\n"
9573 "Display routes matching the communities\n"
9574 "community number\n"
9575 "Do not send outside local AS (well-known community)\n"
9576 "Do not advertise to any peer (well-known community)\n"
9577 "Do not export to next AS (well-known community)\n"
9578 "community number\n"
9579 "Do not send outside local AS (well-known community)\n"
9580 "Do not advertise to any peer (well-known community)\n"
9581 "Do not export to next AS (well-known community)\n")
9582
9583ALIAS (show_bgp_community,
9584 show_bgp_community3_cmd,
9585 "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)",
9586 SHOW_STR
9587 BGP_STR
9588 "Display routes matching the communities\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 "community number\n"
9598 "Do not send outside local AS (well-known community)\n"
9599 "Do not advertise to any peer (well-known community)\n"
9600 "Do not export to next AS (well-known community)\n")
9601
9602ALIAS (show_bgp_community,
9603 show_bgp_ipv6_community3_cmd,
9604 "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)",
9605 SHOW_STR
9606 BGP_STR
9607 "Address family\n"
9608 "Display routes matching the communities\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
9622ALIAS (show_bgp_community,
9623 show_bgp_community4_cmd,
9624 "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)",
9625 SHOW_STR
9626 BGP_STR
9627 "Display routes matching the communities\n"
9628 "community number\n"
9629 "Do not send outside local AS (well-known community)\n"
9630 "Do not advertise to any peer (well-known community)\n"
9631 "Do not export to next AS (well-known community)\n"
9632 "community number\n"
9633 "Do not send outside local AS (well-known community)\n"
9634 "Do not advertise to any peer (well-known community)\n"
9635 "Do not export to next AS (well-known community)\n"
9636 "community number\n"
9637 "Do not send outside local AS (well-known community)\n"
9638 "Do not advertise to any peer (well-known community)\n"
9639 "Do not export to next AS (well-known community)\n"
9640 "community number\n"
9641 "Do not send outside local AS (well-known community)\n"
9642 "Do not advertise to any peer (well-known community)\n"
9643 "Do not export to next AS (well-known community)\n")
9644
9645ALIAS (show_bgp_community,
9646 show_bgp_ipv6_community4_cmd,
9647 "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)",
9648 SHOW_STR
9649 BGP_STR
9650 "Address family\n"
9651 "Display routes matching the communities\n"
9652 "community number\n"
9653 "Do not send outside local AS (well-known community)\n"
9654 "Do not advertise to any peer (well-known community)\n"
9655 "Do not export to next AS (well-known community)\n"
9656 "community number\n"
9657 "Do not send outside local AS (well-known community)\n"
9658 "Do not advertise to any peer (well-known community)\n"
9659 "Do not export to next AS (well-known community)\n"
9660 "community number\n"
9661 "Do not send outside local AS (well-known community)\n"
9662 "Do not advertise to any peer (well-known community)\n"
9663 "Do not export to next AS (well-known community)\n"
9664 "community number\n"
9665 "Do not send outside local AS (well-known community)\n"
9666 "Do not advertise to any peer (well-known community)\n"
9667 "Do not export to next AS (well-known community)\n")
9668
9669/* old command */
9670DEFUN (show_ipv6_bgp_community,
9671 show_ipv6_bgp_community_cmd,
9672 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9673 SHOW_STR
9674 IPV6_STR
9675 BGP_STR
9676 "Display routes matching the communities\n"
9677 "community number\n"
9678 "Do not send outside local AS (well-known community)\n"
9679 "Do not advertise to any peer (well-known community)\n"
9680 "Do not export to next AS (well-known community)\n")
9681{
9682 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_UNICAST);
9683}
9684
9685/* old command */
9686ALIAS (show_ipv6_bgp_community,
9687 show_ipv6_bgp_community2_cmd,
9688 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9689 SHOW_STR
9690 IPV6_STR
9691 BGP_STR
9692 "Display routes matching the communities\n"
9693 "community number\n"
9694 "Do not send outside local AS (well-known community)\n"
9695 "Do not advertise to any peer (well-known community)\n"
9696 "Do not export to next AS (well-known community)\n"
9697 "community number\n"
9698 "Do not send outside local AS (well-known community)\n"
9699 "Do not advertise to any peer (well-known community)\n"
9700 "Do not export to next AS (well-known community)\n")
9701
9702/* old command */
9703ALIAS (show_ipv6_bgp_community,
9704 show_ipv6_bgp_community3_cmd,
9705 "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)",
9706 SHOW_STR
9707 IPV6_STR
9708 BGP_STR
9709 "Display routes matching the communities\n"
9710 "community number\n"
9711 "Do not send outside local AS (well-known community)\n"
9712 "Do not advertise to any peer (well-known community)\n"
9713 "Do not export to next AS (well-known community)\n"
9714 "community number\n"
9715 "Do not send outside local AS (well-known community)\n"
9716 "Do not advertise to any peer (well-known community)\n"
9717 "Do not export to next AS (well-known community)\n"
9718 "community number\n"
9719 "Do not send outside local AS (well-known community)\n"
9720 "Do not advertise to any peer (well-known community)\n"
9721 "Do not export to next AS (well-known community)\n")
9722
9723/* old command */
9724ALIAS (show_ipv6_bgp_community,
9725 show_ipv6_bgp_community4_cmd,
9726 "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)",
9727 SHOW_STR
9728 IPV6_STR
9729 BGP_STR
9730 "Display routes matching the communities\n"
9731 "community number\n"
9732 "Do not send outside local AS (well-known community)\n"
9733 "Do not advertise to any peer (well-known community)\n"
9734 "Do not export to next AS (well-known community)\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 "community number\n"
9744 "Do not send outside local AS (well-known community)\n"
9745 "Do not advertise to any peer (well-known community)\n"
9746 "Do not export to next AS (well-known community)\n")
9747
9748DEFUN (show_bgp_community_exact,
9749 show_bgp_community_exact_cmd,
9750 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9751 SHOW_STR
9752 BGP_STR
9753 "Display routes matching the communities\n"
9754 "community number\n"
9755 "Do not send outside local AS (well-known community)\n"
9756 "Do not advertise to any peer (well-known community)\n"
9757 "Do not export to next AS (well-known community)\n"
9758 "Exact match of the communities")
9759{
9760 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9761}
9762
9763ALIAS (show_bgp_community_exact,
9764 show_bgp_ipv6_community_exact_cmd,
9765 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9766 SHOW_STR
9767 BGP_STR
9768 "Address family\n"
9769 "Display routes matching the communities\n"
9770 "community number\n"
9771 "Do not send outside local AS (well-known community)\n"
9772 "Do not advertise to any peer (well-known community)\n"
9773 "Do not export to next AS (well-known community)\n"
9774 "Exact match of the communities")
9775
9776ALIAS (show_bgp_community_exact,
9777 show_bgp_community2_exact_cmd,
9778 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9779 SHOW_STR
9780 BGP_STR
9781 "Display routes matching the communities\n"
9782 "community number\n"
9783 "Do not send outside local AS (well-known community)\n"
9784 "Do not advertise to any peer (well-known community)\n"
9785 "Do not export to next AS (well-known community)\n"
9786 "community number\n"
9787 "Do not send outside local AS (well-known community)\n"
9788 "Do not advertise to any peer (well-known community)\n"
9789 "Do not export to next AS (well-known community)\n"
9790 "Exact match of the communities")
9791
9792ALIAS (show_bgp_community_exact,
9793 show_bgp_ipv6_community2_exact_cmd,
9794 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9795 SHOW_STR
9796 BGP_STR
9797 "Address family\n"
9798 "Display routes matching the communities\n"
9799 "community number\n"
9800 "Do not send outside local AS (well-known community)\n"
9801 "Do not advertise to any peer (well-known community)\n"
9802 "Do not export to next AS (well-known community)\n"
9803 "community number\n"
9804 "Do not send outside local AS (well-known community)\n"
9805 "Do not advertise to any peer (well-known community)\n"
9806 "Do not export to next AS (well-known community)\n"
9807 "Exact match of the communities")
9808
9809ALIAS (show_bgp_community_exact,
9810 show_bgp_community3_exact_cmd,
9811 "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",
9812 SHOW_STR
9813 BGP_STR
9814 "Display routes matching the communities\n"
9815 "community number\n"
9816 "Do not send outside local AS (well-known community)\n"
9817 "Do not advertise to any peer (well-known community)\n"
9818 "Do not export to next AS (well-known community)\n"
9819 "community number\n"
9820 "Do not send outside local AS (well-known community)\n"
9821 "Do not advertise to any peer (well-known community)\n"
9822 "Do not export to next AS (well-known community)\n"
9823 "community number\n"
9824 "Do not send outside local AS (well-known community)\n"
9825 "Do not advertise to any peer (well-known community)\n"
9826 "Do not export to next AS (well-known community)\n"
9827 "Exact match of the communities")
9828
9829ALIAS (show_bgp_community_exact,
9830 show_bgp_ipv6_community3_exact_cmd,
9831 "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",
9832 SHOW_STR
9833 BGP_STR
9834 "Address family\n"
9835 "Display routes matching the communities\n"
9836 "community number\n"
9837 "Do not send outside local AS (well-known community)\n"
9838 "Do not advertise to any peer (well-known community)\n"
9839 "Do not export to next AS (well-known community)\n"
9840 "community number\n"
9841 "Do not send outside local AS (well-known community)\n"
9842 "Do not advertise to any peer (well-known community)\n"
9843 "Do not export to next AS (well-known community)\n"
9844 "community number\n"
9845 "Do not send outside local AS (well-known community)\n"
9846 "Do not advertise to any peer (well-known community)\n"
9847 "Do not export to next AS (well-known community)\n"
9848 "Exact match of the communities")
9849
9850ALIAS (show_bgp_community_exact,
9851 show_bgp_community4_exact_cmd,
9852 "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",
9853 SHOW_STR
9854 BGP_STR
9855 "Display routes matching the communities\n"
9856 "community number\n"
9857 "Do not send outside local AS (well-known community)\n"
9858 "Do not advertise to any peer (well-known community)\n"
9859 "Do not export to next AS (well-known community)\n"
9860 "community number\n"
9861 "Do not send outside local AS (well-known community)\n"
9862 "Do not advertise to any peer (well-known community)\n"
9863 "Do not export to next AS (well-known community)\n"
9864 "community number\n"
9865 "Do not send outside local AS (well-known community)\n"
9866 "Do not advertise to any peer (well-known community)\n"
9867 "Do not export to next AS (well-known community)\n"
9868 "community number\n"
9869 "Do not send outside local AS (well-known community)\n"
9870 "Do not advertise to any peer (well-known community)\n"
9871 "Do not export to next AS (well-known community)\n"
9872 "Exact match of the communities")
9873
9874ALIAS (show_bgp_community_exact,
9875 show_bgp_ipv6_community4_exact_cmd,
9876 "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",
9877 SHOW_STR
9878 BGP_STR
9879 "Address family\n"
9880 "Display routes matching the communities\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 "community number\n"
9886 "Do not send outside local AS (well-known community)\n"
9887 "Do not advertise to any peer (well-known community)\n"
9888 "Do not export to next AS (well-known community)\n"
9889 "community number\n"
9890 "Do not send outside local AS (well-known community)\n"
9891 "Do not advertise to any peer (well-known community)\n"
9892 "Do not export to next AS (well-known community)\n"
9893 "community number\n"
9894 "Do not send outside local AS (well-known community)\n"
9895 "Do not advertise to any peer (well-known community)\n"
9896 "Do not export to next AS (well-known community)\n"
9897 "Exact match of the communities")
9898
9899/* old command */
9900DEFUN (show_ipv6_bgp_community_exact,
9901 show_ipv6_bgp_community_exact_cmd,
9902 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9903 SHOW_STR
9904 IPV6_STR
9905 BGP_STR
9906 "Display routes matching the communities\n"
9907 "community number\n"
9908 "Do not send outside local AS (well-known community)\n"
9909 "Do not advertise to any peer (well-known community)\n"
9910 "Do not export to next AS (well-known community)\n"
9911 "Exact match of the communities")
9912{
9913 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_UNICAST);
9914}
9915
9916/* old command */
9917ALIAS (show_ipv6_bgp_community_exact,
9918 show_ipv6_bgp_community2_exact_cmd,
9919 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9920 SHOW_STR
9921 IPV6_STR
9922 BGP_STR
9923 "Display routes matching the communities\n"
9924 "community number\n"
9925 "Do not send outside local AS (well-known community)\n"
9926 "Do not advertise to any peer (well-known community)\n"
9927 "Do not export to next AS (well-known community)\n"
9928 "community number\n"
9929 "Do not send outside local AS (well-known community)\n"
9930 "Do not advertise to any peer (well-known community)\n"
9931 "Do not export to next AS (well-known community)\n"
9932 "Exact match of the communities")
9933
9934/* old command */
9935ALIAS (show_ipv6_bgp_community_exact,
9936 show_ipv6_bgp_community3_exact_cmd,
9937 "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",
9938 SHOW_STR
9939 IPV6_STR
9940 BGP_STR
9941 "Display routes matching the communities\n"
9942 "community number\n"
9943 "Do not send outside local AS (well-known community)\n"
9944 "Do not advertise to any peer (well-known community)\n"
9945 "Do not export to next AS (well-known community)\n"
9946 "community number\n"
9947 "Do not send outside local AS (well-known community)\n"
9948 "Do not advertise to any peer (well-known community)\n"
9949 "Do not export to next AS (well-known community)\n"
9950 "community number\n"
9951 "Do not send outside local AS (well-known community)\n"
9952 "Do not advertise to any peer (well-known community)\n"
9953 "Do not export to next AS (well-known community)\n"
9954 "Exact match of the communities")
9955
9956/* old command */
9957ALIAS (show_ipv6_bgp_community_exact,
9958 show_ipv6_bgp_community4_exact_cmd,
9959 "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",
9960 SHOW_STR
9961 IPV6_STR
9962 BGP_STR
9963 "Display routes matching the communities\n"
9964 "community number\n"
9965 "Do not send outside local AS (well-known community)\n"
9966 "Do not advertise to any peer (well-known community)\n"
9967 "Do not export to next AS (well-known community)\n"
9968 "community number\n"
9969 "Do not send outside local AS (well-known community)\n"
9970 "Do not advertise to any peer (well-known community)\n"
9971 "Do not export to next AS (well-known community)\n"
9972 "community number\n"
9973 "Do not send outside local AS (well-known community)\n"
9974 "Do not advertise to any peer (well-known community)\n"
9975 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
9981
9982/* old command */
9983DEFUN (show_ipv6_mbgp_community,
9984 show_ipv6_mbgp_community_cmd,
9985 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
9986 SHOW_STR
9987 IPV6_STR
9988 MBGP_STR
9989 "Display routes matching the communities\n"
9990 "community number\n"
9991 "Do not send outside local AS (well-known community)\n"
9992 "Do not advertise to any peer (well-known community)\n"
9993 "Do not export to next AS (well-known community)\n")
9994{
9995 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP6, SAFI_MULTICAST);
9996}
9997
9998/* old command */
9999ALIAS (show_ipv6_mbgp_community,
10000 show_ipv6_mbgp_community2_cmd,
10001 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10002 SHOW_STR
10003 IPV6_STR
10004 MBGP_STR
10005 "Display routes matching the communities\n"
10006 "community number\n"
10007 "Do not send outside local AS (well-known community)\n"
10008 "Do not advertise to any peer (well-known community)\n"
10009 "Do not export to next AS (well-known community)\n"
10010 "community number\n"
10011 "Do not send outside local AS (well-known community)\n"
10012 "Do not advertise to any peer (well-known community)\n"
10013 "Do not export to next AS (well-known community)\n")
10014
10015/* old command */
10016ALIAS (show_ipv6_mbgp_community,
10017 show_ipv6_mbgp_community3_cmd,
10018 "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)",
10019 SHOW_STR
10020 IPV6_STR
10021 MBGP_STR
10022 "Display routes matching the communities\n"
10023 "community number\n"
10024 "Do not send outside local AS (well-known community)\n"
10025 "Do not advertise to any peer (well-known community)\n"
10026 "Do not export to next AS (well-known community)\n"
10027 "community number\n"
10028 "Do not send outside local AS (well-known community)\n"
10029 "Do not advertise to any peer (well-known community)\n"
10030 "Do not export to next AS (well-known community)\n"
10031 "community number\n"
10032 "Do not send outside local AS (well-known community)\n"
10033 "Do not advertise to any peer (well-known community)\n"
10034 "Do not export to next AS (well-known community)\n")
10035
10036/* old command */
10037ALIAS (show_ipv6_mbgp_community,
10038 show_ipv6_mbgp_community4_cmd,
10039 "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)",
10040 SHOW_STR
10041 IPV6_STR
10042 MBGP_STR
10043 "Display routes matching the communities\n"
10044 "community number\n"
10045 "Do not send outside local AS (well-known community)\n"
10046 "Do not advertise to any peer (well-known community)\n"
10047 "Do not export to next AS (well-known community)\n"
10048 "community number\n"
10049 "Do not send outside local AS (well-known community)\n"
10050 "Do not advertise to any peer (well-known community)\n"
10051 "Do not export to next AS (well-known community)\n"
10052 "community number\n"
10053 "Do not send outside local AS (well-known community)\n"
10054 "Do not advertise to any peer (well-known community)\n"
10055 "Do not export to next AS (well-known community)\n"
10056 "community number\n"
10057 "Do not send outside local AS (well-known community)\n"
10058 "Do not advertise to any peer (well-known community)\n"
10059 "Do not export to next AS (well-known community)\n")
10060
10061/* old command */
10062DEFUN (show_ipv6_mbgp_community_exact,
10063 show_ipv6_mbgp_community_exact_cmd,
10064 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10065 SHOW_STR
10066 IPV6_STR
10067 MBGP_STR
10068 "Display routes matching the communities\n"
10069 "community number\n"
10070 "Do not send outside local AS (well-known community)\n"
10071 "Do not advertise to any peer (well-known community)\n"
10072 "Do not export to next AS (well-known community)\n"
10073 "Exact match of the communities")
10074{
10075 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP6, SAFI_MULTICAST);
10076}
10077
10078/* old command */
10079ALIAS (show_ipv6_mbgp_community_exact,
10080 show_ipv6_mbgp_community2_exact_cmd,
10081 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10082 SHOW_STR
10083 IPV6_STR
10084 MBGP_STR
10085 "Display routes matching the communities\n"
10086 "community number\n"
10087 "Do not send outside local AS (well-known community)\n"
10088 "Do not advertise to any peer (well-known community)\n"
10089 "Do not export to next AS (well-known community)\n"
10090 "community number\n"
10091 "Do not send outside local AS (well-known community)\n"
10092 "Do not advertise to any peer (well-known community)\n"
10093 "Do not export to next AS (well-known community)\n"
10094 "Exact match of the communities")
10095
10096/* old command */
10097ALIAS (show_ipv6_mbgp_community_exact,
10098 show_ipv6_mbgp_community3_exact_cmd,
10099 "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",
10100 SHOW_STR
10101 IPV6_STR
10102 MBGP_STR
10103 "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 "community number\n"
10109 "Do not send outside local AS (well-known community)\n"
10110 "Do not advertise to any peer (well-known community)\n"
10111 "Do not export to next AS (well-known community)\n"
10112 "community number\n"
10113 "Do not send outside local AS (well-known community)\n"
10114 "Do not advertise to any peer (well-known community)\n"
10115 "Do not export to next AS (well-known community)\n"
10116 "Exact match of the communities")
10117
10118/* old command */
10119ALIAS (show_ipv6_mbgp_community_exact,
10120 show_ipv6_mbgp_community4_exact_cmd,
10121 "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",
10122 SHOW_STR
10123 IPV6_STR
10124 MBGP_STR
10125 "Display routes matching the communities\n"
10126 "community number\n"
10127 "Do not send outside local AS (well-known community)\n"
10128 "Do not advertise to any peer (well-known community)\n"
10129 "Do not export to next AS (well-known community)\n"
10130 "community number\n"
10131 "Do not send outside local AS (well-known community)\n"
10132 "Do not advertise to any peer (well-known community)\n"
10133 "Do not export to next AS (well-known community)\n"
10134 "community number\n"
10135 "Do not send outside local AS (well-known community)\n"
10136 "Do not advertise to any peer (well-known community)\n"
10137 "Do not export to next AS (well-known community)\n"
10138 "community number\n"
10139 "Do not send outside local AS (well-known community)\n"
10140 "Do not advertise to any peer (well-known community)\n"
10141 "Do not export to next AS (well-known community)\n"
10142 "Exact match of the communities")
Lou Bergerf9b6c392016-01-12 13:42:09 -050010143
Lou Berger651b4022016-01-12 13:42:07 -050010144DEFUN (show_bgp_ipv4_community,
10145 show_bgp_ipv4_community_cmd,
10146 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010147 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010148 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010149 IP_STR
paul718e3742002-12-13 20:15:29 +000010150 "Display routes matching the communities\n"
10151 "community number\n"
10152 "Do not send outside local AS (well-known community)\n"
10153 "Do not advertise to any peer (well-known community)\n"
10154 "Do not export to next AS (well-known community)\n")
10155{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010156 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010157}
10158
Lou Berger651b4022016-01-12 13:42:07 -050010159ALIAS (show_bgp_ipv4_community,
10160 show_bgp_ipv4_community2_cmd,
10161 "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 +000010162 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010163 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010164 IP_STR
paul718e3742002-12-13 20:15:29 +000010165 "Display routes matching the communities\n"
10166 "community number\n"
10167 "Do not send outside local AS (well-known community)\n"
10168 "Do not advertise to any peer (well-known community)\n"
10169 "Do not export to next AS (well-known community)\n"
10170 "community number\n"
10171 "Do not send outside local AS (well-known community)\n"
10172 "Do not advertise to any peer (well-known community)\n"
10173 "Do not export to next AS (well-known community)\n")
10174
Lou Berger651b4022016-01-12 13:42:07 -050010175ALIAS (show_bgp_ipv4_community,
10176 show_bgp_ipv4_community3_cmd,
10177 "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 +000010178 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010179 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010180 IP_STR
paul718e3742002-12-13 20:15:29 +000010181 "Display routes matching the communities\n"
10182 "community number\n"
10183 "Do not send outside local AS (well-known community)\n"
10184 "Do not advertise to any peer (well-known community)\n"
10185 "Do not export to next AS (well-known community)\n"
10186 "community number\n"
10187 "Do not send outside local AS (well-known community)\n"
10188 "Do not advertise to any peer (well-known community)\n"
10189 "Do not export to next AS (well-known community)\n"
10190 "community number\n"
10191 "Do not send outside local AS (well-known community)\n"
10192 "Do not advertise to any peer (well-known community)\n"
10193 "Do not export to next AS (well-known community)\n")
10194
Lou Berger651b4022016-01-12 13:42:07 -050010195ALIAS (show_bgp_ipv4_community,
10196 show_bgp_ipv4_community4_cmd,
10197 "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 +000010198 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010199 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010200 IP_STR
paul718e3742002-12-13 20:15:29 +000010201 "Display routes matching the communities\n"
10202 "community number\n"
10203 "Do not send outside local AS (well-known community)\n"
10204 "Do not advertise to any peer (well-known community)\n"
10205 "Do not export to next AS (well-known community)\n"
10206 "community number\n"
10207 "Do not send outside local AS (well-known community)\n"
10208 "Do not advertise to any peer (well-known community)\n"
10209 "Do not export to next AS (well-known community)\n"
10210 "community number\n"
10211 "Do not send outside local AS (well-known community)\n"
10212 "Do not advertise to any peer (well-known community)\n"
10213 "Do not export to next AS (well-known community)\n"
10214 "community number\n"
10215 "Do not send outside local AS (well-known community)\n"
10216 "Do not advertise to any peer (well-known community)\n"
10217 "Do not export to next AS (well-known community)\n")
10218
Lou Berger651b4022016-01-12 13:42:07 -050010219DEFUN (show_bgp_ipv4_safi_community,
10220 show_bgp_ipv4_safi_community_cmd,
10221 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010222 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010223 BGP_STR
10224 "Address family\n"
10225 "Address Family modifier\n"
10226 "Address Family modifier\n"
10227 "Display routes matching the communities\n"
10228 "community number\n"
10229 "Do not send outside local AS (well-known community)\n"
10230 "Do not advertise to any peer (well-known community)\n"
10231 "Do not export to next AS (well-known community)\n")
10232{
10233 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010234 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010235
Michael Lambert95cbbd22010-07-23 14:43:04 -040010236 return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010237}
10238
Lou Berger651b4022016-01-12 13:42:07 -050010239ALIAS (show_bgp_ipv4_safi_community,
10240 show_bgp_ipv4_safi_community2_cmd,
10241 "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 +000010242 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010243 BGP_STR
10244 "Address family\n"
10245 "Address Family modifier\n"
10246 "Address Family modifier\n"
10247 "Display routes matching the communities\n"
10248 "community number\n"
10249 "Do not send outside local AS (well-known community)\n"
10250 "Do not advertise to any peer (well-known community)\n"
10251 "Do not export to next AS (well-known community)\n"
10252 "community number\n"
10253 "Do not send outside local AS (well-known community)\n"
10254 "Do not advertise to any peer (well-known community)\n"
10255 "Do not export to next AS (well-known community)\n")
10256
Lou Berger651b4022016-01-12 13:42:07 -050010257ALIAS (show_bgp_ipv4_safi_community,
10258 show_bgp_ipv4_safi_community3_cmd,
10259 "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 +000010260 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010261 BGP_STR
10262 "Address family\n"
10263 "Address Family modifier\n"
10264 "Address Family modifier\n"
10265 "Display routes matching the communities\n"
10266 "community number\n"
10267 "Do not send outside local AS (well-known community)\n"
10268 "Do not advertise to any peer (well-known community)\n"
10269 "Do not export to next AS (well-known community)\n"
10270 "community number\n"
10271 "Do not send outside local AS (well-known community)\n"
10272 "Do not advertise to any peer (well-known community)\n"
10273 "Do not export to next AS (well-known community)\n"
10274 "community number\n"
10275 "Do not send outside local AS (well-known community)\n"
10276 "Do not advertise to any peer (well-known community)\n"
10277 "Do not export to next AS (well-known community)\n")
10278
Lou Berger651b4022016-01-12 13:42:07 -050010279ALIAS (show_bgp_ipv4_safi_community,
10280 show_bgp_ipv4_safi_community4_cmd,
10281 "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 +000010282 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010283 BGP_STR
10284 "Address family\n"
10285 "Address Family modifier\n"
10286 "Address Family modifier\n"
10287 "Display routes matching the communities\n"
10288 "community number\n"
10289 "Do not send outside local AS (well-known community)\n"
10290 "Do not advertise to any peer (well-known community)\n"
10291 "Do not export to next AS (well-known community)\n"
10292 "community number\n"
10293 "Do not send outside local AS (well-known community)\n"
10294 "Do not advertise to any peer (well-known community)\n"
10295 "Do not export to next AS (well-known community)\n"
10296 "community number\n"
10297 "Do not send outside local AS (well-known community)\n"
10298 "Do not advertise to any peer (well-known community)\n"
10299 "Do not export to next AS (well-known community)\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
Michael Lambert95cbbd22010-07-23 14:43:04 -040010305DEFUN (show_bgp_view_afi_safi_community_all,
10306 show_bgp_view_afi_safi_community_all_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010307 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010308 SHOW_STR
10309 BGP_STR
10310 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010311 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010312 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010313 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010314 "Address Family modifier\n"
10315 "Address Family modifier\n"
Christian Franke2b005152013-09-30 12:27:49 +000010316 "Display routes matching the communities\n")
Michael Lambert95cbbd22010-07-23 14:43:04 -040010317{
10318 int afi;
10319 int safi;
10320 struct bgp *bgp;
10321
10322 /* BGP structure lookup. */
10323 bgp = bgp_lookup_by_name (argv[0]);
10324 if (bgp == NULL)
10325 {
10326 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
10327 return CMD_WARNING;
10328 }
10329
Michael Lambert95cbbd22010-07-23 14:43:04 -040010330 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10331 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
Michael Lambert95cbbd22010-07-23 14:43:04 -040010332 return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL);
10333}
10334
10335DEFUN (show_bgp_view_afi_safi_community,
10336 show_bgp_view_afi_safi_community_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010337 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
Michael Lambert95cbbd22010-07-23 14:43:04 -040010338 SHOW_STR
10339 BGP_STR
10340 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010341 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010342 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010343 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010344 "Address family modifier\n"
10345 "Address family modifier\n"
10346 "Display routes matching the communities\n"
10347 "community number\n"
10348 "Do not send outside local AS (well-known community)\n"
10349 "Do not advertise to any peer (well-known community)\n"
10350 "Do not export to next AS (well-known community)\n")
10351{
10352 int afi;
10353 int safi;
10354
Michael Lambert95cbbd22010-07-23 14:43:04 -040010355 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
10356 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
10357 return bgp_show_community (vty, argv[0], argc-3, &argv[3], 0, afi, safi);
Michael Lambert95cbbd22010-07-23 14:43:04 -040010358}
10359
10360ALIAS (show_bgp_view_afi_safi_community,
10361 show_bgp_view_afi_safi_community2_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010362 "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 -040010363 SHOW_STR
10364 BGP_STR
10365 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010366 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010367 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010368 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010369 "Address family modifier\n"
10370 "Address family modifier\n"
10371 "Display routes matching the communities\n"
10372 "community number\n"
10373 "Do not send outside local AS (well-known community)\n"
10374 "Do not advertise to any peer (well-known community)\n"
10375 "Do not export to next AS (well-known community)\n"
10376 "community number\n"
10377 "Do not send outside local AS (well-known community)\n"
10378 "Do not advertise to any peer (well-known community)\n"
10379 "Do not export to next AS (well-known community)\n")
10380
10381ALIAS (show_bgp_view_afi_safi_community,
10382 show_bgp_view_afi_safi_community3_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010383 "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 -040010384 SHOW_STR
10385 BGP_STR
10386 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010387 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010388 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010389 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010390 "Address family modifier\n"
10391 "Address family modifier\n"
10392 "Display routes matching the communities\n"
10393 "community number\n"
10394 "Do not send outside local AS (well-known community)\n"
10395 "Do not advertise to any peer (well-known community)\n"
10396 "Do not export to next AS (well-known community)\n"
10397 "community number\n"
10398 "Do not send outside local AS (well-known community)\n"
10399 "Do not advertise to any peer (well-known community)\n"
10400 "Do not export to next AS (well-known community)\n"
10401 "community number\n"
10402 "Do not send outside local AS (well-known community)\n"
10403 "Do not advertise to any peer (well-known community)\n"
10404 "Do not export to next AS (well-known community)\n")
10405
10406ALIAS (show_bgp_view_afi_safi_community,
10407 show_bgp_view_afi_safi_community4_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040010408 "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 -040010409 SHOW_STR
10410 BGP_STR
10411 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000010412 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010413 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010414 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040010415 "Address family modifier\n"
10416 "Address family modifier\n"
10417 "Display routes matching the communities\n"
10418 "community number\n"
10419 "Do not send outside local AS (well-known community)\n"
10420 "Do not advertise to any peer (well-known community)\n"
10421 "Do not export to next AS (well-known community)\n"
10422 "community number\n"
10423 "Do not send outside local AS (well-known community)\n"
10424 "Do not advertise to any peer (well-known community)\n"
10425 "Do not export to next AS (well-known community)\n"
10426 "community number\n"
10427 "Do not send outside local AS (well-known community)\n"
10428 "Do not advertise to any peer (well-known community)\n"
10429 "Do not export to next AS (well-known community)\n"
10430 "community number\n"
10431 "Do not send outside local AS (well-known community)\n"
10432 "Do not advertise to any peer (well-known community)\n"
10433 "Do not export to next AS (well-known community)\n")
10434
Lou Berger651b4022016-01-12 13:42:07 -050010435DEFUN (show_bgp_ipv4_community_exact,
10436 show_bgp_ipv4_community_exact_cmd,
10437 "show bgp ipv4 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010438 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010439 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010440 IP_STR
paul718e3742002-12-13 20:15:29 +000010441 "Display routes matching the communities\n"
10442 "community number\n"
10443 "Do not send outside local AS (well-known community)\n"
10444 "Do not advertise to any peer (well-known community)\n"
10445 "Do not export to next AS (well-known community)\n"
10446 "Exact match of the communities")
10447{
Michael Lambert95cbbd22010-07-23 14:43:04 -040010448 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010449}
10450
Lou Berger651b4022016-01-12 13:42:07 -050010451ALIAS (show_bgp_ipv4_community_exact,
10452 show_bgp_ipv4_community2_exact_cmd,
10453 "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 +000010454 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010455 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010456 IP_STR
paul718e3742002-12-13 20:15:29 +000010457 "Display routes matching the communities\n"
10458 "community number\n"
10459 "Do not send outside local AS (well-known community)\n"
10460 "Do not advertise to any peer (well-known community)\n"
10461 "Do not export to next AS (well-known community)\n"
10462 "community number\n"
10463 "Do not send outside local AS (well-known community)\n"
10464 "Do not advertise to any peer (well-known community)\n"
10465 "Do not export to next AS (well-known community)\n"
10466 "Exact match of the communities")
10467
Lou Berger651b4022016-01-12 13:42:07 -050010468ALIAS (show_bgp_ipv4_community_exact,
10469 show_bgp_ipv4_community3_exact_cmd,
10470 "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 +000010471 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010472 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010473 IP_STR
paul718e3742002-12-13 20:15:29 +000010474 "Display routes matching the communities\n"
10475 "community number\n"
10476 "Do not send outside local AS (well-known community)\n"
10477 "Do not advertise to any peer (well-known community)\n"
10478 "Do not export to next AS (well-known community)\n"
10479 "community number\n"
10480 "Do not send outside local AS (well-known community)\n"
10481 "Do not advertise to any peer (well-known community)\n"
10482 "Do not export to next AS (well-known community)\n"
10483 "community number\n"
10484 "Do not send outside local AS (well-known community)\n"
10485 "Do not advertise to any peer (well-known community)\n"
10486 "Do not export to next AS (well-known community)\n"
10487 "Exact match of the communities")
10488
Lou Berger651b4022016-01-12 13:42:07 -050010489ALIAS (show_bgp_ipv4_community_exact,
10490 show_bgp_ipv4_community4_exact_cmd,
10491 "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 +000010492 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010493 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010494 IP_STR
paul718e3742002-12-13 20:15:29 +000010495 "Display routes matching the communities\n"
10496 "community number\n"
10497 "Do not send outside local AS (well-known community)\n"
10498 "Do not advertise to any peer (well-known community)\n"
10499 "Do not export to next AS (well-known community)\n"
10500 "community number\n"
10501 "Do not send outside local AS (well-known community)\n"
10502 "Do not advertise to any peer (well-known community)\n"
10503 "Do not export to next AS (well-known community)\n"
10504 "community number\n"
10505 "Do not send outside local AS (well-known community)\n"
10506 "Do not advertise to any peer (well-known community)\n"
10507 "Do not export to next AS (well-known community)\n"
10508 "community number\n"
10509 "Do not send outside local AS (well-known community)\n"
10510 "Do not advertise to any peer (well-known community)\n"
10511 "Do not export to next AS (well-known community)\n"
10512 "Exact match of the communities")
10513
Lou Berger651b4022016-01-12 13:42:07 -050010514DEFUN (show_bgp_ipv4_safi_community4_exact,
10515 show_bgp_ipv4_safi_community_exact_cmd,
10516 "show bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010517 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010518 BGP_STR
10519 "Address family\n"
10520 "Address Family modifier\n"
10521 "Address Family modifier\n"
10522 "Display routes matching the communities\n"
10523 "community number\n"
10524 "Do not send outside local AS (well-known community)\n"
10525 "Do not advertise to any peer (well-known community)\n"
10526 "Do not export to next AS (well-known community)\n"
10527 "Exact match of the communities")
10528{
10529 if (strncmp (argv[0], "m", 1) == 0)
Michael Lambert95cbbd22010-07-23 14:43:04 -040010530 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
paul718e3742002-12-13 20:15:29 +000010531
Michael Lambert95cbbd22010-07-23 14:43:04 -040010532 return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000010533}
10534
Lou Berger651b4022016-01-12 13:42:07 -050010535ALIAS (show_bgp_ipv4_safi_community4_exact,
10536 show_bgp_ipv4_safi_community2_exact_cmd,
10537 "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 +000010538 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010539 BGP_STR
10540 "Address family\n"
10541 "Address Family modifier\n"
10542 "Address Family modifier\n"
10543 "Display routes matching the communities\n"
10544 "community number\n"
10545 "Do not send outside local AS (well-known community)\n"
10546 "Do not advertise to any peer (well-known community)\n"
10547 "Do not export to next AS (well-known community)\n"
10548 "community number\n"
10549 "Do not send outside local AS (well-known community)\n"
10550 "Do not advertise to any peer (well-known community)\n"
10551 "Do not export to next AS (well-known community)\n"
10552 "Exact match of the communities")
10553
Lou Berger651b4022016-01-12 13:42:07 -050010554ALIAS (show_bgp_ipv4_safi_community4_exact,
10555 show_bgp_ipv4_safi_community3_exact_cmd,
10556 "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 +000010557 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010558 BGP_STR
10559 "Address family\n"
10560 "Address Family modifier\n"
10561 "Address Family modifier\n"
10562 "Display routes matching the communities\n"
10563 "community number\n"
10564 "Do not send outside local AS (well-known community)\n"
10565 "Do not advertise to any peer (well-known community)\n"
10566 "Do not export to next AS (well-known community)\n"
10567 "community number\n"
10568 "Do not send outside local AS (well-known community)\n"
10569 "Do not advertise to any peer (well-known community)\n"
10570 "Do not export to next AS (well-known community)\n"
10571 "community number\n"
10572 "Do not send outside local AS (well-known community)\n"
10573 "Do not advertise to any peer (well-known community)\n"
10574 "Do not export to next AS (well-known community)\n"
10575 "Exact match of the communities")
10576
Lou Berger651b4022016-01-12 13:42:07 -050010577ALIAS (show_bgp_ipv4_safi_community4_exact,
10578 show_bgp_ipv4_safi_community4_exact_cmd,
10579 "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 +000010580 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010581 BGP_STR
10582 "Address family\n"
10583 "Address Family modifier\n"
10584 "Address Family modifier\n"
10585 "Display routes matching the communities\n"
10586 "community number\n"
10587 "Do not send outside local AS (well-known community)\n"
10588 "Do not advertise to any peer (well-known community)\n"
10589 "Do not export to next AS (well-known community)\n"
10590 "community number\n"
10591 "Do not send outside local AS (well-known community)\n"
10592 "Do not advertise to any peer (well-known community)\n"
10593 "Do not export to next AS (well-known community)\n"
10594 "community number\n"
10595 "Do not send outside local AS (well-known community)\n"
10596 "Do not advertise to any peer (well-known community)\n"
10597 "Do not export to next AS (well-known community)\n"
10598 "community number\n"
10599 "Do not send outside local AS (well-known community)\n"
10600 "Do not advertise to any peer (well-known community)\n"
10601 "Do not export to next AS (well-known community)\n"
10602 "Exact match of the communities")
10603
Lou Bergerf9b6c392016-01-12 13:42:09 -050010604DEFUN (show_bgp_ipv6_safi_community,
10605 show_bgp_ipv6_safi_community_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010606 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010607 SHOW_STR
10608 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010609 "Address family\n"
10610 "Address family modifier\n"
10611 "Address family modifier\n"
10612 "Address family modifier\n"
10613 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010614 "Display routes matching the communities\n"
10615 "community number\n"
10616 "Do not send outside local AS (well-known community)\n"
10617 "Do not advertise to any peer (well-known community)\n"
10618 "Do not export to next AS (well-known community)\n")
10619{
Lou Berger651b4022016-01-12 13:42:07 -050010620 safi_t safi;
10621
10622 if (bgp_parse_safi(argv[0], &safi)) {
10623 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10624 return CMD_WARNING;
10625 }
10626 return bgp_show_community (vty, NULL, argc-1, argv+1, 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010627}
10628
Lou Bergerf9b6c392016-01-12 13:42:09 -050010629ALIAS (show_bgp_ipv6_safi_community,
10630 show_bgp_ipv6_safi_community2_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010631 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
paul718e3742002-12-13 20:15:29 +000010632 SHOW_STR
10633 BGP_STR
10634 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010635 "Address family modifier\n"
10636 "Address family modifier\n"
10637 "Address family modifier\n"
10638 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010639 "Display routes matching the communities\n"
10640 "community number\n"
10641 "Do not send outside local AS (well-known community)\n"
10642 "Do not advertise to any peer (well-known community)\n"
10643 "Do not export to next AS (well-known community)\n"
10644 "community number\n"
10645 "Do not send outside local AS (well-known community)\n"
10646 "Do not advertise to any peer (well-known community)\n"
10647 "Do not export to next AS (well-known community)\n")
10648
Lou Bergerf9b6c392016-01-12 13:42:09 -050010649ALIAS (show_bgp_ipv6_safi_community,
10650 show_bgp_ipv6_safi_community3_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010651 "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 +000010652 SHOW_STR
10653 BGP_STR
10654 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010655 "Address family modifier\n"
10656 "Address family modifier\n"
10657 "Address family modifier\n"
10658 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010659 "Display routes matching the communities\n"
10660 "community number\n"
10661 "Do not send outside local AS (well-known community)\n"
10662 "Do not advertise to any peer (well-known community)\n"
10663 "Do not export to next AS (well-known community)\n"
10664 "community number\n"
10665 "Do not send outside local AS (well-known community)\n"
10666 "Do not advertise to any peer (well-known community)\n"
10667 "Do not export to next AS (well-known community)\n"
10668 "community number\n"
10669 "Do not send outside local AS (well-known community)\n"
10670 "Do not advertise to any peer (well-known community)\n"
10671 "Do not export to next AS (well-known community)\n")
10672
Lou Bergerf9b6c392016-01-12 13:42:09 -050010673ALIAS (show_bgp_ipv6_safi_community,
10674 show_bgp_ipv6_safi_community4_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010675 "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 +000010676 SHOW_STR
10677 BGP_STR
10678 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010679 "Address family modifier\n"
10680 "Address family modifier\n"
10681 "Address family modifier\n"
10682 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010683 "Display routes matching the communities\n"
10684 "community number\n"
10685 "Do not send outside local AS (well-known community)\n"
10686 "Do not advertise to any peer (well-known community)\n"
10687 "Do not export to next AS (well-known community)\n"
10688 "community number\n"
10689 "Do not send outside local AS (well-known community)\n"
10690 "Do not advertise to any peer (well-known community)\n"
10691 "Do not export to next AS (well-known community)\n"
10692 "community number\n"
10693 "Do not send outside local AS (well-known community)\n"
10694 "Do not advertise to any peer (well-known community)\n"
10695 "Do not export to next AS (well-known community)\n"
10696 "community number\n"
10697 "Do not send outside local AS (well-known community)\n"
10698 "Do not advertise to any peer (well-known community)\n"
10699 "Do not export to next AS (well-known community)\n")
10700
paul718e3742002-12-13 20:15:29 +000010701
Lou Bergerf9b6c392016-01-12 13:42:09 -050010702DEFUN (show_bgp_ipv6_safi_community_exact,
10703 show_bgp_ipv6_safi_community_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010704 "show bgp ipv6 (encap|multicast|unicast|vpn) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
paul718e3742002-12-13 20:15:29 +000010705 SHOW_STR
10706 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010707 "Address family\n"
10708 "Address family modifier\n"
10709 "Address family modifier\n"
10710 "Address family modifier\n"
10711 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010712 "Display routes matching the communities\n"
10713 "community number\n"
10714 "Do not send outside local AS (well-known community)\n"
10715 "Do not advertise to any peer (well-known community)\n"
10716 "Do not export to next AS (well-known community)\n"
10717 "Exact match of the communities")
10718{
Lou Berger651b4022016-01-12 13:42:07 -050010719 safi_t safi;
10720
10721 if (bgp_parse_safi(argv[0], &safi)) {
10722 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
10723 return CMD_WARNING;
10724 }
10725 return bgp_show_community (vty, NULL, argc-1, argv+1, 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000010726}
10727
paul718e3742002-12-13 20:15:29 +000010728
10729ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010730 show_bgp_ipv6_safi_community2_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010731 "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 +000010732 SHOW_STR
10733 BGP_STR
10734 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010735 "Address family modifier\n"
10736 "Address family modifier\n"
10737 "Address family modifier\n"
10738 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010739 "Display routes matching the communities\n"
10740 "community number\n"
10741 "Do not send outside local AS (well-known community)\n"
10742 "Do not advertise to any peer (well-known community)\n"
10743 "Do not export to next AS (well-known community)\n"
10744 "community number\n"
10745 "Do not send outside local AS (well-known community)\n"
10746 "Do not advertise to any peer (well-known community)\n"
10747 "Do not export to next AS (well-known community)\n"
10748 "Exact match of the communities")
10749
10750ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010751 show_bgp_ipv6_safi_community3_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010752 "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 +000010753 SHOW_STR
10754 BGP_STR
10755 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010756 "Address family modifier\n"
10757 "Address family modifier\n"
10758 "Address family modifier\n"
10759 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010760 "Display routes matching the communities\n"
10761 "community number\n"
10762 "Do not send outside local AS (well-known community)\n"
10763 "Do not advertise to any peer (well-known community)\n"
10764 "Do not export to next AS (well-known community)\n"
10765 "community number\n"
10766 "Do not send outside local AS (well-known community)\n"
10767 "Do not advertise to any peer (well-known community)\n"
10768 "Do not export to next AS (well-known community)\n"
10769 "community number\n"
10770 "Do not send outside local AS (well-known community)\n"
10771 "Do not advertise to any peer (well-known community)\n"
10772 "Do not export to next AS (well-known community)\n"
10773 "Exact match of the communities")
10774
10775ALIAS (show_bgp_community_exact,
Lou Bergerf9b6c392016-01-12 13:42:09 -050010776 show_bgp_ipv6_safi_community4_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050010777 "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 +000010778 SHOW_STR
10779 BGP_STR
10780 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050010781 "Address family modifier\n"
10782 "Address family modifier\n"
10783 "Address family modifier\n"
10784 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000010785 "Display routes matching the communities\n"
10786 "community number\n"
10787 "Do not send outside local AS (well-known community)\n"
10788 "Do not advertise to any peer (well-known community)\n"
10789 "Do not export to next AS (well-known community)\n"
10790 "community number\n"
10791 "Do not send outside local AS (well-known community)\n"
10792 "Do not advertise to any peer (well-known community)\n"
10793 "Do not export to next AS (well-known community)\n"
10794 "community number\n"
10795 "Do not send outside local AS (well-known community)\n"
10796 "Do not advertise to any peer (well-known community)\n"
10797 "Do not export to next AS (well-known community)\n"
10798 "community number\n"
10799 "Do not send outside local AS (well-known community)\n"
10800 "Do not advertise to any peer (well-known community)\n"
10801 "Do not export to next AS (well-known community)\n"
10802 "Exact match of the communities")
10803
paul94f2b392005-06-28 12:44:16 +000010804static int
paulfd79ac92004-10-13 05:06:08 +000010805bgp_show_community_list (struct vty *vty, const char *com, int exact,
Michael Lambert4c9641b2010-07-22 13:20:55 -040010806 afi_t afi, safi_t safi)
paul718e3742002-12-13 20:15:29 +000010807{
10808 struct community_list *list;
10809
hassofee6e4e2005-02-02 16:29:31 +000010810 list = community_list_lookup (bgp_clist, com, COMMUNITY_LIST_MASTER);
paul718e3742002-12-13 20:15:29 +000010811 if (list == NULL)
10812 {
10813 vty_out (vty, "%% %s is not a valid community-list name%s", com,
10814 VTY_NEWLINE);
10815 return CMD_WARNING;
10816 }
10817
ajs5a646652004-11-05 01:25:55 +000010818 return bgp_show (vty, NULL, afi, safi,
10819 (exact ? bgp_show_type_community_list_exact :
10820 bgp_show_type_community_list), list);
paul718e3742002-12-13 20:15:29 +000010821}
10822
Lou Bergerf9b6c392016-01-12 13:42:09 -050010823DEFUN (show_ip_bgp_community_list,
10824 show_ip_bgp_community_list_cmd,
10825 "show ip bgp community-list (<1-500>|WORD)",
10826 SHOW_STR
10827 IP_STR
10828 BGP_STR
10829 "Display routes matching the community-list\n"
10830 "community-list number\n"
10831 "community-list name\n")
10832{
10833 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
10834}
10835
10836DEFUN (show_ip_bgp_ipv4_community_list,
10837 show_ip_bgp_ipv4_community_list_cmd,
10838 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10839 SHOW_STR
10840 IP_STR
10841 BGP_STR
10842 "Address family\n"
10843 "Address Family modifier\n"
10844 "Address Family modifier\n"
10845 "Display routes matching the community-list\n"
10846 "community-list number\n"
10847 "community-list name\n")
10848{
10849 if (strncmp (argv[0], "m", 1) == 0)
10850 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
10851
10852 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
10853}
10854
10855DEFUN (show_ip_bgp_community_list_exact,
10856 show_ip_bgp_community_list_exact_cmd,
10857 "show ip bgp community-list (<1-500>|WORD) exact-match",
10858 SHOW_STR
10859 IP_STR
10860 BGP_STR
10861 "Display routes matching the community-list\n"
10862 "community-list number\n"
10863 "community-list name\n"
10864 "Exact match of the communities\n")
10865{
10866 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
10867}
10868
10869DEFUN (show_ip_bgp_ipv4_community_list_exact,
10870 show_ip_bgp_ipv4_community_list_exact_cmd,
10871 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10872 SHOW_STR
10873 IP_STR
10874 BGP_STR
10875 "Address family\n"
10876 "Address Family modifier\n"
10877 "Address Family modifier\n"
10878 "Display routes matching the community-list\n"
10879 "community-list number\n"
10880 "community-list name\n"
10881 "Exact match of the communities\n")
10882{
10883 if (strncmp (argv[0], "m", 1) == 0)
10884 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
10885
10886 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
10887}
10888
Lou Bergerf9b6c392016-01-12 13:42:09 -050010889DEFUN (show_bgp_community_list,
10890 show_bgp_community_list_cmd,
10891 "show bgp community-list (<1-500>|WORD)",
10892 SHOW_STR
10893 BGP_STR
10894 "Display routes matching the community-list\n"
10895 "community-list number\n"
10896 "community-list name\n")
10897{
10898 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10899}
10900
10901ALIAS (show_bgp_community_list,
10902 show_bgp_ipv6_community_list_cmd,
10903 "show bgp ipv6 community-list (<1-500>|WORD)",
10904 SHOW_STR
10905 BGP_STR
10906 "Address family\n"
10907 "Display routes matching the community-list\n"
10908 "community-list number\n"
10909 "community-list name\n")
10910
10911/* old command */
10912DEFUN (show_ipv6_bgp_community_list,
10913 show_ipv6_bgp_community_list_cmd,
10914 "show ipv6 bgp community-list WORD",
10915 SHOW_STR
10916 IPV6_STR
10917 BGP_STR
10918 "Display routes matching the community-list\n"
10919 "community-list name\n")
10920{
10921 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_UNICAST);
10922}
10923
10924/* old command */
10925DEFUN (show_ipv6_mbgp_community_list,
10926 show_ipv6_mbgp_community_list_cmd,
10927 "show ipv6 mbgp community-list WORD",
10928 SHOW_STR
10929 IPV6_STR
10930 MBGP_STR
10931 "Display routes matching the community-list\n"
10932 "community-list name\n")
10933{
10934 return bgp_show_community_list (vty, argv[0], 0, AFI_IP6, SAFI_MULTICAST);
10935}
10936
10937DEFUN (show_bgp_community_list_exact,
10938 show_bgp_community_list_exact_cmd,
10939 "show bgp community-list (<1-500>|WORD) exact-match",
10940 SHOW_STR
10941 BGP_STR
10942 "Display routes matching the community-list\n"
10943 "community-list number\n"
10944 "community-list name\n"
10945 "Exact match of the communities\n")
10946{
10947 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10948}
10949
10950ALIAS (show_bgp_community_list_exact,
10951 show_bgp_ipv6_community_list_exact_cmd,
10952 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10953 SHOW_STR
10954 BGP_STR
10955 "Address family\n"
10956 "Display routes matching the community-list\n"
10957 "community-list number\n"
10958 "community-list name\n"
10959 "Exact match of the communities\n")
10960
10961/* old command */
10962DEFUN (show_ipv6_bgp_community_list_exact,
10963 show_ipv6_bgp_community_list_exact_cmd,
10964 "show ipv6 bgp community-list WORD exact-match",
10965 SHOW_STR
10966 IPV6_STR
10967 BGP_STR
10968 "Display routes matching the community-list\n"
10969 "community-list name\n"
10970 "Exact match of the communities\n")
10971{
10972 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_UNICAST);
10973}
10974
10975/* old command */
10976DEFUN (show_ipv6_mbgp_community_list_exact,
10977 show_ipv6_mbgp_community_list_exact_cmd,
10978 "show ipv6 mbgp community-list WORD exact-match",
10979 SHOW_STR
10980 IPV6_STR
10981 MBGP_STR
10982 "Display routes matching the community-list\n"
10983 "community-list name\n"
10984 "Exact match of the communities\n")
10985{
10986 return bgp_show_community_list (vty, argv[0], 1, AFI_IP6, SAFI_MULTICAST);
10987}
Lou Bergerf9b6c392016-01-12 13:42:09 -050010988
Lou Berger651b4022016-01-12 13:42:07 -050010989DEFUN (show_bgp_ipv4_community_list,
10990 show_bgp_ipv4_community_list_cmd,
10991 "show bgp ipv4 community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000010992 SHOW_STR
paul718e3742002-12-13 20:15:29 +000010993 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050010994 IP_STR
paul718e3742002-12-13 20:15:29 +000010995 "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{
10999 return bgp_show_community_list (vty, argv[0], 0, AFI_IP, SAFI_UNICAST);
11000}
11001
Lou Berger651b4022016-01-12 13:42:07 -050011002DEFUN (show_bgp_ipv4_safi_community_list,
11003 show_bgp_ipv4_safi_community_list_cmd,
11004 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011005 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011006 BGP_STR
11007 "Address family\n"
11008 "Address Family modifier\n"
11009 "Address Family modifier\n"
11010 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011011 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011012 "community-list name\n")
11013{
11014 if (strncmp (argv[0], "m", 1) == 0)
11015 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_MULTICAST);
11016
11017 return bgp_show_community_list (vty, argv[1], 0, AFI_IP, SAFI_UNICAST);
11018}
11019
Lou Berger651b4022016-01-12 13:42:07 -050011020DEFUN (show_bgp_ipv4_community_list_exact,
11021 show_bgp_ipv4_community_list_exact_cmd,
11022 "show bgp ipv4 community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011023 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011024 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011025 IP_STR
paul718e3742002-12-13 20:15:29 +000011026 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011027 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011028 "community-list name\n"
11029 "Exact match of the communities\n")
11030{
11031 return bgp_show_community_list (vty, argv[0], 1, AFI_IP, SAFI_UNICAST);
11032}
11033
Lou Berger651b4022016-01-12 13:42:07 -050011034DEFUN (show_bgp_ipv4_safi_community_list_exact,
11035 show_bgp_ipv4_safi_community_list_exact_cmd,
11036 "show bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011037 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011038 BGP_STR
11039 "Address family\n"
11040 "Address Family modifier\n"
11041 "Address Family modifier\n"
11042 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011043 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011044 "community-list name\n"
11045 "Exact match of the communities\n")
11046{
11047 if (strncmp (argv[0], "m", 1) == 0)
11048 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_MULTICAST);
11049
11050 return bgp_show_community_list (vty, argv[1], 1, AFI_IP, SAFI_UNICAST);
11051}
11052
Lou Bergerf9b6c392016-01-12 13:42:09 -050011053DEFUN (show_bgp_ipv6_safi_community_list,
11054 show_bgp_ipv6_safi_community_list_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011055 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD)",
paul718e3742002-12-13 20:15:29 +000011056 SHOW_STR
11057 BGP_STR
11058 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011059 "Address family modifier\n"
11060 "Address family modifier\n"
11061 "Address family modifier\n"
11062 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011063 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011064 "community-list number\n"
paule8e19462006-01-19 20:16:55 +000011065 "community-list name\n")
paul718e3742002-12-13 20:15:29 +000011066{
Lou Berger651b4022016-01-12 13:42:07 -050011067 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011068
Lou Berger651b4022016-01-12 13:42:07 -050011069 if (bgp_parse_safi(argv[0], &safi)) {
11070 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11071 return CMD_WARNING;
11072 }
11073 return bgp_show_community_list (vty, argv[1], 0, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011074}
11075
Lou Bergerf9b6c392016-01-12 13:42:09 -050011076DEFUN (show_bgp_ipv6_safi_community_list_exact,
11077 show_bgp_ipv6_safi_community_list_exact_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050011078 "show bgp ipv6 (encap|multicast|unicast|vpn) community-list (<1-500>|WORD) exact-match",
paul718e3742002-12-13 20:15:29 +000011079 SHOW_STR
11080 BGP_STR
11081 "Address family\n"
Lou Berger651b4022016-01-12 13:42:07 -050011082 "Address family modifier\n"
11083 "Address family modifier\n"
11084 "Address family modifier\n"
11085 "Address family modifier\n"
paul718e3742002-12-13 20:15:29 +000011086 "Display routes matching the community-list\n"
hassofee6e4e2005-02-02 16:29:31 +000011087 "community-list number\n"
paul718e3742002-12-13 20:15:29 +000011088 "community-list name\n"
11089 "Exact match of the communities\n")
paul718e3742002-12-13 20:15:29 +000011090{
Lou Berger651b4022016-01-12 13:42:07 -050011091 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011092
Lou Berger651b4022016-01-12 13:42:07 -050011093 if (bgp_parse_safi(argv[0], &safi)) {
11094 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11095 return CMD_WARNING;
11096 }
11097 return bgp_show_community_list (vty, argv[1], 1, AFI_IP6, safi);
paul718e3742002-12-13 20:15:29 +000011098}
David Lamparter6b0655a2014-06-04 06:53:35 +020011099
paul94f2b392005-06-28 12:44:16 +000011100static int
paulfd79ac92004-10-13 05:06:08 +000011101bgp_show_prefix_longer (struct vty *vty, const char *prefix, afi_t afi,
paul718e3742002-12-13 20:15:29 +000011102 safi_t safi, enum bgp_show_type type)
11103{
11104 int ret;
11105 struct prefix *p;
11106
11107 p = prefix_new();
11108
11109 ret = str2prefix (prefix, p);
11110 if (! ret)
11111 {
11112 vty_out (vty, "%% Malformed Prefix%s", VTY_NEWLINE);
11113 return CMD_WARNING;
11114 }
11115
ajs5a646652004-11-05 01:25:55 +000011116 ret = bgp_show (vty, NULL, afi, safi, type, p);
11117 prefix_free(p);
11118 return ret;
paul718e3742002-12-13 20:15:29 +000011119}
11120
Lou Bergerf9b6c392016-01-12 13:42:09 -050011121DEFUN (show_ip_bgp_prefix_longer,
11122 show_ip_bgp_prefix_longer_cmd,
11123 "show ip bgp A.B.C.D/M longer-prefixes",
11124 SHOW_STR
11125 IP_STR
11126 BGP_STR
11127 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11128 "Display route and more specific routes\n")
11129{
11130 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11131 bgp_show_type_prefix_longer);
11132}
11133
11134DEFUN (show_ip_bgp_flap_prefix_longer,
11135 show_ip_bgp_flap_prefix_longer_cmd,
11136 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11137 SHOW_STR
11138 IP_STR
11139 BGP_STR
11140 "Display flap statistics of routes\n"
11141 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11142 "Display route and more specific routes\n")
11143{
11144 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11145 bgp_show_type_flap_prefix_longer);
11146}
11147
11148ALIAS (show_ip_bgp_flap_prefix_longer,
11149 show_ip_bgp_damp_flap_prefix_longer_cmd,
11150 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11151 SHOW_STR
11152 IP_STR
11153 BGP_STR
11154 "Display detailed information about dampening\n"
11155 "Display flap statistics of routes\n"
11156 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11157 "Display route and more specific routes\n")
11158
11159DEFUN (show_ip_bgp_ipv4_prefix_longer,
11160 show_ip_bgp_ipv4_prefix_longer_cmd,
11161 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11162 SHOW_STR
11163 IP_STR
11164 BGP_STR
11165 "Address family\n"
11166 "Address Family modifier\n"
11167 "Address Family modifier\n"
11168 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11169 "Display route and more specific routes\n")
11170{
11171 if (strncmp (argv[0], "m", 1) == 0)
11172 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_MULTICAST,
11173 bgp_show_type_prefix_longer);
11174
11175 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, SAFI_UNICAST,
11176 bgp_show_type_prefix_longer);
11177}
11178
11179DEFUN (show_ip_bgp_flap_address,
11180 show_ip_bgp_flap_address_cmd,
11181 "show ip bgp flap-statistics A.B.C.D",
11182 SHOW_STR
11183 IP_STR
11184 BGP_STR
11185 "Display flap statistics of routes\n"
11186 "Network in the BGP routing table to display\n")
11187{
11188 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11189 bgp_show_type_flap_address);
11190}
11191
11192ALIAS (show_ip_bgp_flap_address,
11193 show_ip_bgp_damp_flap_address_cmd,
11194 "show ip bgp dampening flap-statistics A.B.C.D",
11195 SHOW_STR
11196 IP_STR
11197 BGP_STR
11198 "Display detailed information about dampening\n"
11199 "Display flap statistics of routes\n"
11200 "Network in the BGP routing table to display\n")
11201
11202DEFUN (show_ip_bgp_flap_prefix,
11203 show_ip_bgp_flap_prefix_cmd,
11204 "show ip bgp flap-statistics A.B.C.D/M",
11205 SHOW_STR
11206 IP_STR
11207 BGP_STR
11208 "Display flap statistics of routes\n"
11209 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11210{
11211 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11212 bgp_show_type_flap_prefix);
11213}
11214
11215ALIAS (show_ip_bgp_flap_prefix,
11216 show_ip_bgp_damp_flap_prefix_cmd,
11217 "show ip bgp dampening flap-statistics A.B.C.D/M",
11218 SHOW_STR
11219 IP_STR
11220 BGP_STR
11221 "Display detailed information about dampening\n"
11222 "Display flap statistics of routes\n"
11223 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11224
Lou Bergerf9b6c392016-01-12 13:42:09 -050011225DEFUN (show_bgp_prefix_longer,
11226 show_bgp_prefix_longer_cmd,
11227 "show bgp X:X::X:X/M longer-prefixes",
11228 SHOW_STR
11229 BGP_STR
11230 "IPv6 prefix <network>/<length>\n"
11231 "Display route and more specific routes\n")
11232{
11233 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11234 bgp_show_type_prefix_longer);
11235}
11236
11237/* old command */
11238DEFUN (show_ipv6_bgp_prefix_longer,
11239 show_ipv6_bgp_prefix_longer_cmd,
11240 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11241 SHOW_STR
11242 IPV6_STR
11243 BGP_STR
11244 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11245 "Display route and more specific routes\n")
11246{
11247 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11248 bgp_show_type_prefix_longer);
11249}
11250
11251/* old command */
11252DEFUN (show_ipv6_mbgp_prefix_longer,
11253 show_ipv6_mbgp_prefix_longer_cmd,
11254 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11255 SHOW_STR
11256 IPV6_STR
11257 MBGP_STR
11258 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11259 "Display route and more specific routes\n")
11260{
11261 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
11262 bgp_show_type_prefix_longer);
11263}
Lou Bergerf9b6c392016-01-12 13:42:09 -050011264
Lou Berger651b4022016-01-12 13:42:07 -050011265DEFUN (show_bgp_ipv4_prefix_longer,
11266 show_bgp_ipv4_prefix_longer_cmd,
11267 "show bgp ipv4 A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011268 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011269 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011270 IP_STR
paul718e3742002-12-13 20:15:29 +000011271 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11272 "Display route and more specific routes\n")
11273{
11274 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, SAFI_UNICAST,
11275 bgp_show_type_prefix_longer);
11276}
11277
Lou Berger651b4022016-01-12 13:42:07 -050011278DEFUN (show_bgp_ipv4_safi_flap_prefix_longer,
11279 show_bgp_ipv4_safi_flap_prefix_longer_cmd,
11280 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011281 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011282 BGP_STR
11283 "Address family\n"
11284 "Address Family modifier\n"
11285 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050011286 "Address Family modifier\n"
11287 "Address Family modifier\n"
11288 "Display flap statistics of routes\n"
paul718e3742002-12-13 20:15:29 +000011289 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11290 "Display route and more specific routes\n")
11291{
Lou Berger651b4022016-01-12 13:42:07 -050011292 safi_t safi;
paul718e3742002-12-13 20:15:29 +000011293
Lou Berger651b4022016-01-12 13:42:07 -050011294 if (bgp_parse_safi(argv[0], &safi)) {
11295 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11296 return CMD_WARNING;
11297 }
11298 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11299 bgp_show_type_flap_prefix_longer);
paul718e3742002-12-13 20:15:29 +000011300}
11301
Lou Berger651b4022016-01-12 13:42:07 -050011302ALIAS (show_bgp_ipv4_safi_flap_prefix_longer,
11303 show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd,
11304 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M longer-prefixes",
paul718e3742002-12-13 20:15:29 +000011305 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011306 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011307 "Address family\n"
11308 "Address Family modifier\n"
11309 "Address Family modifier\n"
11310 "Address Family modifier\n"
11311 "Address Family modifier\n"
11312 "Display detailed information about dampening\n"
11313 "Display flap statistics of routes\n"
11314 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11315 "Display route and more specific routes\n")
11316
Lou Berger651b4022016-01-12 13:42:07 -050011317DEFUN (show_bgp_ipv6_safi_flap_prefix_longer,
11318 show_bgp_ipv6_safi_flap_prefix_longer_cmd,
11319 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M longer-prefixes",
11320 SHOW_STR
11321 BGP_STR
11322 "Address family\n"
11323 "Address Family modifier\n"
11324 "Address Family modifier\n"
11325 "Address Family modifier\n"
11326 "Address Family modifier\n"
11327 "Display flap statistics of routes\n"
11328 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11329 "Display route and more specific routes\n")
11330{
11331 safi_t safi;
11332
11333 if (bgp_parse_safi(argv[0], &safi)) {
11334 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11335 return CMD_WARNING;
11336 }
11337 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11338 bgp_show_type_flap_prefix_longer);
11339}
11340ALIAS (show_bgp_ipv6_safi_flap_prefix_longer,
11341 show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd,
11342 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M longer-prefixes",
11343 SHOW_STR
11344 BGP_STR
11345 "Address family\n"
11346 "Address Family modifier\n"
11347 "Address Family modifier\n"
11348 "Address Family modifier\n"
11349 "Address Family modifier\n"
11350 "Display detailed information about dampening\n"
11351 "Display flap statistics of routes\n"
11352 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11353 "Display route and more specific routes\n")
Lou Berger651b4022016-01-12 13:42:07 -050011354
11355DEFUN (show_bgp_ipv4_safi_prefix_longer,
11356 show_bgp_ipv4_safi_prefix_longer_cmd,
11357 "show bgp ipv4 (encap|multicast|unicast|vpn) A.B.C.D/M longer-prefixes",
11358 SHOW_STR
11359 BGP_STR
11360 "Address family\n"
11361 "Address Family modifier\n"
11362 "Address Family modifier\n"
11363 "Address Family modifier\n"
11364 "Address Family modifier\n"
11365 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11366 "Display route and more specific routes\n")
11367{
11368 safi_t safi;
11369
11370 if (bgp_parse_safi(argv[0], &safi)) {
11371 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11372 return CMD_WARNING;
11373 }
11374
11375 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11376 bgp_show_type_prefix_longer);
11377}
11378
Lou Berger651b4022016-01-12 13:42:07 -050011379DEFUN (show_bgp_ipv6_safi_prefix_longer,
11380 show_bgp_ipv6_safi_prefix_longer_cmd,
11381 "show bgp ipv6 (encap|multicast|unicast|vpn) X:X::X:X/M longer-prefixes",
11382 SHOW_STR
11383 BGP_STR
11384 "Address family\n"
11385 "Address Family modifier\n"
11386 "Address Family modifier\n"
11387 "Address Family modifier\n"
11388 "Address Family modifier\n"
11389 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11390 "Display route and more specific routes\n")
11391{
11392 safi_t safi;
11393
11394 if (bgp_parse_safi(argv[0], &safi)) {
11395 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11396 return CMD_WARNING;
11397 }
11398
11399 return bgp_show_prefix_longer (vty, argv[1], AFI_IP6, safi,
11400 bgp_show_type_prefix_longer);
11401}
Lou Berger651b4022016-01-12 13:42:07 -050011402
11403DEFUN (show_bgp_ipv4_safi_flap_address,
11404 show_bgp_ipv4_safi_flap_address_cmd,
11405 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
11406 SHOW_STR
11407 BGP_STR
11408 "Address family\n"
11409 "Address Family modifier\n"
11410 "Address Family modifier\n"
11411 "Address Family modifier\n"
11412 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011413 "Display flap statistics of routes\n"
11414 "Network in the BGP routing table to display\n")
11415{
Lou Berger651b4022016-01-12 13:42:07 -050011416 safi_t safi;
11417
11418 if (bgp_parse_safi(argv[0], &safi)) {
11419 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
11420 return CMD_WARNING;
11421 }
11422 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011423 bgp_show_type_flap_address);
11424}
Lou Berger651b4022016-01-12 13:42:07 -050011425ALIAS (show_bgp_ipv4_safi_flap_address,
11426 show_bgp_ipv4_safi_damp_flap_address_cmd,
11427 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
Balaji3921cc52015-05-16 23:12:17 +053011428 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011429 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011430 "Address family\n"
11431 "Address Family modifier\n"
11432 "Address Family modifier\n"
11433 "Address Family modifier\n"
11434 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011435 "Display detailed information about dampening\n"
11436 "Display flap statistics of routes\n"
11437 "Network in the BGP routing table to display\n")
Lou Berger205e6742016-01-12 13:42:11 -050011438
Lou Berger651b4022016-01-12 13:42:07 -050011439DEFUN (show_bgp_ipv6_flap_address,
11440 show_bgp_ipv6_flap_address_cmd,
11441 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D",
paul718e3742002-12-13 20:15:29 +000011442 SHOW_STR
paul718e3742002-12-13 20:15:29 +000011443 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011444 "Address family\n"
11445 "Address Family modifier\n"
11446 "Address Family modifier\n"
11447 "Address Family modifier\n"
11448 "Address Family modifier\n"
11449 "Display flap statistics of routes\n"
11450 "Network in the BGP routing table to display\n")
11451{
11452 safi_t safi;
11453
11454 if (bgp_parse_safi(argv[0], &safi)) {
11455 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11456 return CMD_WARNING;
11457 }
11458 return bgp_show_prefix_longer (vty, argv[1], AFI_IP, safi,
11459 bgp_show_type_flap_address);
11460}
11461ALIAS (show_bgp_ipv6_flap_address,
11462 show_bgp_ipv6_damp_flap_address_cmd,
11463 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D",
11464 SHOW_STR
11465 BGP_STR
11466 "Address family\n"
11467 "Address Family modifier\n"
11468 "Address Family modifier\n"
11469 "Address Family modifier\n"
11470 "Address Family modifier\n"
11471 "Display detailed information about dampening\n"
11472 "Display flap statistics of routes\n"
11473 "Network in the BGP routing table to display\n")
Lou Berger651b4022016-01-12 13:42:07 -050011474
11475DEFUN (show_bgp_ipv4_safi_flap_prefix,
11476 show_bgp_ipv4_safi_flap_prefix_cmd,
11477 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics A.B.C.D/M",
11478 SHOW_STR
11479 BGP_STR
11480 "Address family\n"
11481 "Address Family modifier\n"
11482 "Address Family modifier\n"
11483 "Address Family modifier\n"
11484 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000011485 "Display flap statistics of routes\n"
11486 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11487{
Lou Berger651b4022016-01-12 13:42:07 -050011488 safi_t safi;
11489
11490 if (bgp_parse_safi(argv[0], &safi)) {
11491 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11492 return CMD_WARNING;
11493 }
11494 return bgp_show_prefix_longer (vty, argv[0], AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000011495 bgp_show_type_flap_prefix);
11496}
Balaji3921cc52015-05-16 23:12:17 +053011497
Lou Berger651b4022016-01-12 13:42:07 -050011498ALIAS (show_bgp_ipv4_safi_flap_prefix,
11499 show_bgp_ipv4_safi_damp_flap_prefix_cmd,
11500 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics A.B.C.D/M",
Balaji3921cc52015-05-16 23:12:17 +053011501 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053011502 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011503 "Address family\n"
11504 "Address Family modifier\n"
11505 "Address Family modifier\n"
11506 "Address Family modifier\n"
11507 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053011508 "Display detailed information about dampening\n"
11509 "Display flap statistics of routes\n"
11510 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11511
Lou Berger651b4022016-01-12 13:42:07 -050011512DEFUN (show_bgp_ipv6_safi_flap_prefix,
11513 show_bgp_ipv6_safi_flap_prefix_cmd,
11514 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics X:X::X:X/M",
paul718e3742002-12-13 20:15:29 +000011515 SHOW_STR
11516 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050011517 "Address family\n"
11518 "Address Family modifier\n"
11519 "Address Family modifier\n"
11520 "Address Family modifier\n"
11521 "Address Family modifier\n"
11522 "Display flap statistics of routes\n"
11523 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paul718e3742002-12-13 20:15:29 +000011524{
Lou Berger651b4022016-01-12 13:42:07 -050011525 safi_t safi;
11526
11527 if (bgp_parse_safi(argv[0], &safi)) {
11528 vty_out (vty, "Error: Bad SAFI: %s%s", argv[1], VTY_NEWLINE);
11529 return CMD_WARNING;
11530 }
11531 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, safi,
11532 bgp_show_type_flap_prefix);
paul718e3742002-12-13 20:15:29 +000011533}
11534
Lou Berger651b4022016-01-12 13:42:07 -050011535ALIAS (show_bgp_ipv6_safi_flap_prefix,
11536 show_bgp_ipv6_safi_damp_flap_prefix_cmd,
11537 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics X:X::X:X/M",
11538 SHOW_STR
11539 BGP_STR
11540 "Address family\n"
11541 "Address Family modifier\n"
11542 "Address Family modifier\n"
11543 "Address Family modifier\n"
11544 "Address Family modifier\n"
11545 "Display detailed information about dampening\n"
11546 "Display flap statistics of routes\n"
11547 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11548
11549DEFUN (show_bgp_ipv6_prefix_longer,
paul718e3742002-12-13 20:15:29 +000011550 show_bgp_ipv6_prefix_longer_cmd,
11551 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11552 SHOW_STR
11553 BGP_STR
11554 "Address family\n"
11555 "IPv6 prefix <network>/<length>\n"
11556 "Display route and more specific routes\n")
paul718e3742002-12-13 20:15:29 +000011557{
11558 return bgp_show_prefix_longer (vty, argv[0], AFI_IP6, SAFI_UNICAST,
11559 bgp_show_type_prefix_longer);
11560}
11561
paul94f2b392005-06-28 12:44:16 +000011562static struct peer *
paulfd79ac92004-10-13 05:06:08 +000011563peer_lookup_in_view (struct vty *vty, const char *view_name,
11564 const char *ip_str)
paulbb46e942003-10-24 19:02:03 +000011565{
11566 int ret;
11567 struct bgp *bgp;
11568 struct peer *peer;
11569 union sockunion su;
11570
11571 /* BGP structure lookup. */
11572 if (view_name)
11573 {
11574 bgp = bgp_lookup_by_name (view_name);
11575 if (! bgp)
11576 {
11577 vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
11578 return NULL;
11579 }
11580 }
paul5228ad22004-06-04 17:58:18 +000011581 else
paulbb46e942003-10-24 19:02:03 +000011582 {
11583 bgp = bgp_get_default ();
11584 if (! bgp)
11585 {
11586 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
11587 return NULL;
11588 }
11589 }
11590
11591 /* Get peer sockunion. */
11592 ret = str2sockunion (ip_str, &su);
11593 if (ret < 0)
11594 {
11595 vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
11596 return NULL;
11597 }
11598
11599 /* Peer structure lookup. */
11600 peer = peer_lookup (bgp, &su);
11601 if (! peer)
11602 {
11603 vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
11604 return NULL;
11605 }
11606
11607 return peer;
11608}
David Lamparter6b0655a2014-06-04 06:53:35 +020011609
Paul Jakma2815e612006-09-14 02:56:07 +000011610enum bgp_stats
11611{
11612 BGP_STATS_MAXBITLEN = 0,
11613 BGP_STATS_RIB,
11614 BGP_STATS_PREFIXES,
11615 BGP_STATS_TOTPLEN,
11616 BGP_STATS_UNAGGREGATEABLE,
11617 BGP_STATS_MAX_AGGREGATEABLE,
11618 BGP_STATS_AGGREGATES,
11619 BGP_STATS_SPACE,
11620 BGP_STATS_ASPATH_COUNT,
11621 BGP_STATS_ASPATH_MAXHOPS,
11622 BGP_STATS_ASPATH_TOTHOPS,
11623 BGP_STATS_ASPATH_MAXSIZE,
11624 BGP_STATS_ASPATH_TOTSIZE,
11625 BGP_STATS_ASN_HIGHEST,
11626 BGP_STATS_MAX,
11627};
paulbb46e942003-10-24 19:02:03 +000011628
Paul Jakma2815e612006-09-14 02:56:07 +000011629static const char *table_stats_strs[] =
11630{
11631 [BGP_STATS_PREFIXES] = "Total Prefixes",
11632 [BGP_STATS_TOTPLEN] = "Average prefix length",
11633 [BGP_STATS_RIB] = "Total Advertisements",
11634 [BGP_STATS_UNAGGREGATEABLE] = "Unaggregateable prefixes",
11635 [BGP_STATS_MAX_AGGREGATEABLE] = "Maximum aggregateable prefixes",
11636 [BGP_STATS_AGGREGATES] = "BGP Aggregate advertisements",
11637 [BGP_STATS_SPACE] = "Address space advertised",
11638 [BGP_STATS_ASPATH_COUNT] = "Advertisements with paths",
11639 [BGP_STATS_ASPATH_MAXHOPS] = "Longest AS-Path (hops)",
11640 [BGP_STATS_ASPATH_MAXSIZE] = "Largest AS-Path (bytes)",
11641 [BGP_STATS_ASPATH_TOTHOPS] = "Average AS-Path length (hops)",
11642 [BGP_STATS_ASPATH_TOTSIZE] = "Average AS-Path size (bytes)",
11643 [BGP_STATS_ASN_HIGHEST] = "Highest public ASN",
11644 [BGP_STATS_MAX] = NULL,
11645};
11646
11647struct bgp_table_stats
11648{
11649 struct bgp_table *table;
11650 unsigned long long counts[BGP_STATS_MAX];
11651};
11652
11653#if 0
11654#define TALLY_SIGFIG 100000
11655static unsigned long
11656ravg_tally (unsigned long count, unsigned long oldavg, unsigned long newval)
11657{
11658 unsigned long newtot = (count-1) * oldavg + (newval * TALLY_SIGFIG);
11659 unsigned long res = (newtot * TALLY_SIGFIG) / count;
11660 unsigned long ret = newtot / count;
11661
11662 if ((res % TALLY_SIGFIG) > (TALLY_SIGFIG/2))
11663 return ret + 1;
11664 else
11665 return ret;
11666}
11667#endif
11668
11669static int
11670bgp_table_stats_walker (struct thread *t)
11671{
11672 struct bgp_node *rn;
11673 struct bgp_node *top;
11674 struct bgp_table_stats *ts = THREAD_ARG (t);
11675 unsigned int space = 0;
11676
Paul Jakma53d9f672006-10-15 23:41:16 +000011677 if (!(top = bgp_table_top (ts->table)))
11678 return 0;
Paul Jakma2815e612006-09-14 02:56:07 +000011679
11680 switch (top->p.family)
11681 {
11682 case AF_INET:
11683 space = IPV4_MAX_BITLEN;
11684 break;
11685 case AF_INET6:
11686 space = IPV6_MAX_BITLEN;
11687 break;
11688 }
11689
11690 ts->counts[BGP_STATS_MAXBITLEN] = space;
11691
11692 for (rn = top; rn; rn = bgp_route_next (rn))
11693 {
11694 struct bgp_info *ri;
Avneesh Sachdev67174042012-08-17 08:19:49 -070011695 struct bgp_node *prn = bgp_node_parent_nolock (rn);
Paul Jakma2815e612006-09-14 02:56:07 +000011696 unsigned int rinum = 0;
11697
11698 if (rn == top)
11699 continue;
11700
11701 if (!rn->info)
11702 continue;
11703
11704 ts->counts[BGP_STATS_PREFIXES]++;
11705 ts->counts[BGP_STATS_TOTPLEN] += rn->p.prefixlen;
11706
11707#if 0
11708 ts->counts[BGP_STATS_AVGPLEN]
11709 = ravg_tally (ts->counts[BGP_STATS_PREFIXES],
11710 ts->counts[BGP_STATS_AVGPLEN],
11711 rn->p.prefixlen);
11712#endif
11713
11714 /* check if the prefix is included by any other announcements */
11715 while (prn && !prn->info)
Avneesh Sachdev67174042012-08-17 08:19:49 -070011716 prn = bgp_node_parent_nolock (prn);
Paul Jakma2815e612006-09-14 02:56:07 +000011717
11718 if (prn == NULL || prn == top)
Paul Jakma8383a9b2006-09-14 03:06:54 +000011719 {
11720 ts->counts[BGP_STATS_UNAGGREGATEABLE]++;
11721 /* announced address space */
11722 if (space)
11723 ts->counts[BGP_STATS_SPACE] += 1 << (space - rn->p.prefixlen);
11724 }
Paul Jakma2815e612006-09-14 02:56:07 +000011725 else if (prn->info)
11726 ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++;
11727
Paul Jakma2815e612006-09-14 02:56:07 +000011728 for (ri = rn->info; ri; ri = ri->next)
11729 {
11730 rinum++;
11731 ts->counts[BGP_STATS_RIB]++;
11732
11733 if (ri->attr &&
11734 (CHECK_FLAG (ri->attr->flag,
11735 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))))
11736 ts->counts[BGP_STATS_AGGREGATES]++;
11737
11738 /* as-path stats */
11739 if (ri->attr && ri->attr->aspath)
11740 {
11741 unsigned int hops = aspath_count_hops (ri->attr->aspath);
11742 unsigned int size = aspath_size (ri->attr->aspath);
11743 as_t highest = aspath_highest (ri->attr->aspath);
11744
11745 ts->counts[BGP_STATS_ASPATH_COUNT]++;
11746
11747 if (hops > ts->counts[BGP_STATS_ASPATH_MAXHOPS])
11748 ts->counts[BGP_STATS_ASPATH_MAXHOPS] = hops;
11749
11750 if (size > ts->counts[BGP_STATS_ASPATH_MAXSIZE])
11751 ts->counts[BGP_STATS_ASPATH_MAXSIZE] = size;
11752
11753 ts->counts[BGP_STATS_ASPATH_TOTHOPS] += hops;
11754 ts->counts[BGP_STATS_ASPATH_TOTSIZE] += size;
11755#if 0
11756 ts->counts[BGP_STATS_ASPATH_AVGHOPS]
11757 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11758 ts->counts[BGP_STATS_ASPATH_AVGHOPS],
11759 hops);
11760 ts->counts[BGP_STATS_ASPATH_AVGSIZE]
11761 = ravg_tally (ts->counts[BGP_STATS_ASPATH_COUNT],
11762 ts->counts[BGP_STATS_ASPATH_AVGSIZE],
11763 size);
11764#endif
11765 if (highest > ts->counts[BGP_STATS_ASN_HIGHEST])
11766 ts->counts[BGP_STATS_ASN_HIGHEST] = highest;
11767 }
11768 }
11769 }
11770 return 0;
11771}
11772
11773static int
11774bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi)
11775{
11776 struct bgp_table_stats ts;
11777 unsigned int i;
11778
11779 if (!bgp->rib[afi][safi])
11780 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011781 vty_out (vty, "%% No RIB exists for the AFI/SAFI%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011782 return CMD_WARNING;
11783 }
11784
11785 memset (&ts, 0, sizeof (ts));
11786 ts.table = bgp->rib[afi][safi];
11787 thread_execute (bm->master, bgp_table_stats_walker, &ts, 0);
11788
11789 vty_out (vty, "BGP %s RIB statistics%s%s",
11790 afi_safi_print (afi, safi), VTY_NEWLINE, VTY_NEWLINE);
11791
11792 for (i = 0; i < BGP_STATS_MAX; i++)
11793 {
11794 if (!table_stats_strs[i])
11795 continue;
11796
11797 switch (i)
11798 {
11799#if 0
11800 case BGP_STATS_ASPATH_AVGHOPS:
11801 case BGP_STATS_ASPATH_AVGSIZE:
11802 case BGP_STATS_AVGPLEN:
11803 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11804 vty_out (vty, "%12.2f",
11805 (float)ts.counts[i] / (float)TALLY_SIGFIG);
11806 break;
11807#endif
11808 case BGP_STATS_ASPATH_TOTHOPS:
11809 case BGP_STATS_ASPATH_TOTSIZE:
11810 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11811 vty_out (vty, "%12.2f",
11812 ts.counts[i] ?
11813 (float)ts.counts[i] /
11814 (float)ts.counts[BGP_STATS_ASPATH_COUNT]
11815 : 0);
11816 break;
11817 case BGP_STATS_TOTPLEN:
11818 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11819 vty_out (vty, "%12.2f",
11820 ts.counts[i] ?
11821 (float)ts.counts[i] /
11822 (float)ts.counts[BGP_STATS_PREFIXES]
11823 : 0);
11824 break;
11825 case BGP_STATS_SPACE:
11826 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11827 vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE);
11828 if (ts.counts[BGP_STATS_MAXBITLEN] < 9)
11829 break;
Paul Jakma30a22312008-08-15 14:05:22 +010011830 vty_out (vty, "%30s: ", "%% announced ");
Paul Jakma2815e612006-09-14 02:56:07 +000011831 vty_out (vty, "%12.2f%s",
11832 100 * (float)ts.counts[BGP_STATS_SPACE] /
Paul Jakma56395af2006-10-27 16:58:20 +000011833 (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]),
Paul Jakma2815e612006-09-14 02:56:07 +000011834 VTY_NEWLINE);
11835 vty_out (vty, "%30s: ", "/8 equivalent ");
11836 vty_out (vty, "%12.2f%s",
11837 (float)ts.counts[BGP_STATS_SPACE] /
11838 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 8)),
11839 VTY_NEWLINE);
11840 if (ts.counts[BGP_STATS_MAXBITLEN] < 25)
11841 break;
11842 vty_out (vty, "%30s: ", "/24 equivalent ");
11843 vty_out (vty, "%12.2f",
11844 (float)ts.counts[BGP_STATS_SPACE] /
11845 (float)(1UL << (ts.counts[BGP_STATS_MAXBITLEN] - 24)));
11846 break;
11847 default:
11848 vty_out (vty, "%-30s: ", table_stats_strs[i]);
11849 vty_out (vty, "%12llu", ts.counts[i]);
11850 }
11851
11852 vty_out (vty, "%s", VTY_NEWLINE);
11853 }
11854 return CMD_SUCCESS;
11855}
11856
11857static int
11858bgp_table_stats_vty (struct vty *vty, const char *name,
11859 const char *afi_str, const char *safi_str)
11860{
11861 struct bgp *bgp;
11862 afi_t afi;
11863 safi_t safi;
11864
11865 if (name)
11866 bgp = bgp_lookup_by_name (name);
11867 else
11868 bgp = bgp_get_default ();
11869
11870 if (!bgp)
11871 {
Lou Bergerbf1ae6c2016-01-12 13:42:08 -050011872 vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
Paul Jakma2815e612006-09-14 02:56:07 +000011873 return CMD_WARNING;
11874 }
11875 if (strncmp (afi_str, "ipv", 3) == 0)
11876 {
11877 if (strncmp (afi_str, "ipv4", 4) == 0)
11878 afi = AFI_IP;
11879 else if (strncmp (afi_str, "ipv6", 4) == 0)
11880 afi = AFI_IP6;
11881 else
11882 {
11883 vty_out (vty, "%% Invalid address family %s%s",
11884 afi_str, VTY_NEWLINE);
11885 return CMD_WARNING;
11886 }
Lou Berger298cc2f2016-01-12 13:42:02 -050011887 switch (safi_str[0]) {
11888 case 'm':
11889 safi = SAFI_MULTICAST;
11890 break;
11891 case 'u':
11892 safi = SAFI_UNICAST;
11893 break;
11894 case 'v':
11895 safi = SAFI_MPLS_LABELED_VPN;
11896 break;
11897 case 'e':
11898 safi = SAFI_ENCAP;
11899 break;
11900 default:
11901 vty_out (vty, "%% Invalid subsequent address family %s%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011902 safi_str, VTY_NEWLINE);
Lou Berger298cc2f2016-01-12 13:42:02 -050011903 return CMD_WARNING;
11904 }
Paul Jakma2815e612006-09-14 02:56:07 +000011905 }
11906 else
11907 {
Lou Berger298cc2f2016-01-12 13:42:02 -050011908 vty_out (vty, "%% Invalid address family \"%s\"%s",
Paul Jakma2815e612006-09-14 02:56:07 +000011909 afi_str, VTY_NEWLINE);
11910 return CMD_WARNING;
11911 }
11912
Paul Jakma2815e612006-09-14 02:56:07 +000011913 return bgp_table_stats (vty, bgp, afi, safi);
11914}
11915
11916DEFUN (show_bgp_statistics,
11917 show_bgp_statistics_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011918 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011919 SHOW_STR
11920 BGP_STR
11921 "Address family\n"
11922 "Address family\n"
11923 "Address Family modifier\n"
11924 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011925 "Address Family modifier\n"
11926 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011927 "BGP RIB advertisement statistics\n")
11928{
11929 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11930}
11931
Lou Bergerf9b6c392016-01-12 13:42:09 -050011932ALIAS (show_bgp_statistics,
11933 show_bgp_statistics_vpnv4_cmd,
11934 "show bgp (ipv4) (vpnv4) statistics",
11935 SHOW_STR
11936 BGP_STR
11937 "Address family\n"
11938 "Address Family modifier\n"
11939 "BGP RIB advertisement statistics\n")
11940
Paul Jakma2815e612006-09-14 02:56:07 +000011941DEFUN (show_bgp_statistics_view,
11942 show_bgp_statistics_view_cmd,
Lou Berger298cc2f2016-01-12 13:42:02 -050011943 "show bgp view WORD (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011944 SHOW_STR
11945 BGP_STR
11946 "BGP view\n"
11947 "Address family\n"
11948 "Address family\n"
11949 "Address Family modifier\n"
11950 "Address Family modifier\n"
Lou Berger298cc2f2016-01-12 13:42:02 -050011951 "Address Family modifier\n"
11952 "Address Family modifier\n"
Paul Jakma2815e612006-09-14 02:56:07 +000011953 "BGP RIB advertisement statistics\n")
11954{
11955 return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
11956}
11957
11958ALIAS (show_bgp_statistics_view,
Lou Bergerf9b6c392016-01-12 13:42:09 -050011959 show_bgp_statistics_view_vpnv4_cmd,
11960 "show bgp view WORD (ipv4) (vpnv4) statistics",
Paul Jakma2815e612006-09-14 02:56:07 +000011961 SHOW_STR
11962 BGP_STR
11963 "BGP view\n"
11964 "Address family\n"
11965 "Address Family modifier\n"
11966 "BGP RIB advertisement statistics\n")
David Lamparter6b0655a2014-06-04 06:53:35 +020011967
Paul Jakmaff7924f2006-09-04 01:10:36 +000011968enum bgp_pcounts
11969{
11970 PCOUNT_ADJ_IN = 0,
11971 PCOUNT_DAMPED,
11972 PCOUNT_REMOVED,
11973 PCOUNT_HISTORY,
11974 PCOUNT_STALE,
11975 PCOUNT_VALID,
11976 PCOUNT_ALL,
11977 PCOUNT_COUNTED,
11978 PCOUNT_PFCNT, /* the figure we display to users */
11979 PCOUNT_MAX,
11980};
11981
11982static const char *pcount_strs[] =
11983{
11984 [PCOUNT_ADJ_IN] = "Adj-in",
11985 [PCOUNT_DAMPED] = "Damped",
11986 [PCOUNT_REMOVED] = "Removed",
11987 [PCOUNT_HISTORY] = "History",
11988 [PCOUNT_STALE] = "Stale",
11989 [PCOUNT_VALID] = "Valid",
11990 [PCOUNT_ALL] = "All RIB",
11991 [PCOUNT_COUNTED] = "PfxCt counted",
11992 [PCOUNT_PFCNT] = "Useable",
11993 [PCOUNT_MAX] = NULL,
11994};
11995
Paul Jakma2815e612006-09-14 02:56:07 +000011996struct peer_pcounts
11997{
11998 unsigned int count[PCOUNT_MAX];
11999 const struct peer *peer;
12000 const struct bgp_table *table;
12001};
12002
Paul Jakmaff7924f2006-09-04 01:10:36 +000012003static int
Paul Jakma2815e612006-09-14 02:56:07 +000012004bgp_peer_count_walker (struct thread *t)
Paul Jakmaff7924f2006-09-04 01:10:36 +000012005{
12006 struct bgp_node *rn;
Paul Jakma2815e612006-09-14 02:56:07 +000012007 struct peer_pcounts *pc = THREAD_ARG (t);
12008 const struct peer *peer = pc->peer;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012009
Paul Jakma2815e612006-09-14 02:56:07 +000012010 for (rn = bgp_table_top (pc->table); rn; rn = bgp_route_next (rn))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012011 {
12012 struct bgp_adj_in *ain;
Paul Jakma2815e612006-09-14 02:56:07 +000012013 struct bgp_info *ri;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012014
12015 for (ain = rn->adj_in; ain; ain = ain->next)
12016 if (ain->peer == peer)
Paul Jakma2815e612006-09-14 02:56:07 +000012017 pc->count[PCOUNT_ADJ_IN]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012018
Paul Jakmaff7924f2006-09-04 01:10:36 +000012019 for (ri = rn->info; ri; ri = ri->next)
12020 {
12021 char buf[SU_ADDRSTRLEN];
12022
12023 if (ri->peer != peer)
12024 continue;
12025
Paul Jakma2815e612006-09-14 02:56:07 +000012026 pc->count[PCOUNT_ALL]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012027
12028 if (CHECK_FLAG (ri->flags, BGP_INFO_DAMPED))
Paul Jakma2815e612006-09-14 02:56:07 +000012029 pc->count[PCOUNT_DAMPED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012030 if (CHECK_FLAG (ri->flags, BGP_INFO_HISTORY))
Paul Jakma2815e612006-09-14 02:56:07 +000012031 pc->count[PCOUNT_HISTORY]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012032 if (CHECK_FLAG (ri->flags, BGP_INFO_REMOVED))
Paul Jakma2815e612006-09-14 02:56:07 +000012033 pc->count[PCOUNT_REMOVED]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012034 if (CHECK_FLAG (ri->flags, BGP_INFO_STALE))
Paul Jakma2815e612006-09-14 02:56:07 +000012035 pc->count[PCOUNT_STALE]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012036 if (CHECK_FLAG (ri->flags, BGP_INFO_VALID))
Paul Jakma2815e612006-09-14 02:56:07 +000012037 pc->count[PCOUNT_VALID]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012038 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakma2815e612006-09-14 02:56:07 +000012039 pc->count[PCOUNT_PFCNT]++;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012040
12041 if (CHECK_FLAG (ri->flags, BGP_INFO_COUNTED))
12042 {
Paul Jakma2815e612006-09-14 02:56:07 +000012043 pc->count[PCOUNT_COUNTED]++;
Paul Jakma1a392d42006-09-07 00:24:49 +000012044 if (CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012045 plog_warn (peer->log,
12046 "%s [pcount] %s/%d is counted but flags 0x%x",
12047 peer->host,
12048 inet_ntop(rn->p.family, &rn->p.u.prefix,
12049 buf, SU_ADDRSTRLEN),
12050 rn->p.prefixlen,
12051 ri->flags);
12052 }
12053 else
12054 {
Paul Jakma1a392d42006-09-07 00:24:49 +000012055 if (!CHECK_FLAG (ri->flags, BGP_INFO_UNUSEABLE))
Paul Jakmaff7924f2006-09-04 01:10:36 +000012056 plog_warn (peer->log,
12057 "%s [pcount] %s/%d not counted but flags 0x%x",
12058 peer->host,
12059 inet_ntop(rn->p.family, &rn->p.u.prefix,
12060 buf, SU_ADDRSTRLEN),
12061 rn->p.prefixlen,
12062 ri->flags);
12063 }
12064 }
12065 }
Paul Jakma2815e612006-09-14 02:56:07 +000012066 return 0;
12067}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012068
Paul Jakma2815e612006-09-14 02:56:07 +000012069static int
12070bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi)
12071{
12072 struct peer_pcounts pcounts = { .peer = peer };
12073 unsigned int i;
12074
12075 if (!peer || !peer->bgp || !peer->afc[afi][safi]
12076 || !peer->bgp->rib[afi][safi])
12077 {
12078 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12079 return CMD_WARNING;
12080 }
12081
12082 memset (&pcounts, 0, sizeof(pcounts));
12083 pcounts.peer = peer;
12084 pcounts.table = peer->bgp->rib[afi][safi];
12085
12086 /* in-place call via thread subsystem so as to record execution time
12087 * stats for the thread-walk (i.e. ensure this can't be blamed on
12088 * on just vty_read()).
12089 */
12090 thread_execute (bm->master, bgp_peer_count_walker, &pcounts, 0);
12091
Paul Jakmaff7924f2006-09-04 01:10:36 +000012092 vty_out (vty, "Prefix counts for %s, %s%s",
12093 peer->host, afi_safi_print (afi, safi), VTY_NEWLINE);
12094 vty_out (vty, "PfxCt: %ld%s", peer->pcount[afi][safi], VTY_NEWLINE);
12095 vty_out (vty, "%sCounts from RIB table walk:%s%s",
12096 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
12097
12098 for (i = 0; i < PCOUNT_MAX; i++)
Paul Jakma2815e612006-09-14 02:56:07 +000012099 vty_out (vty, "%20s: %-10d%s",
12100 pcount_strs[i], pcounts.count[i], VTY_NEWLINE);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012101
Paul Jakma2815e612006-09-14 02:56:07 +000012102 if (pcounts.count[PCOUNT_PFCNT] != peer->pcount[afi][safi])
Paul Jakmaff7924f2006-09-04 01:10:36 +000012103 {
12104 vty_out (vty, "%s [pcount] PfxCt drift!%s",
12105 peer->host, VTY_NEWLINE);
12106 vty_out (vty, "Please report this bug, with the above command output%s",
12107 VTY_NEWLINE);
12108 }
12109
12110 return CMD_SUCCESS;
12111}
12112
Lou Bergerf9b6c392016-01-12 13:42:09 -050012113DEFUN (show_ip_bgp_neighbor_prefix_counts,
12114 show_ip_bgp_neighbor_prefix_counts_cmd,
12115 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12116 SHOW_STR
12117 IP_STR
12118 BGP_STR
12119 "Detailed information on TCP and BGP neighbor connections\n"
12120 "Neighbor to display information about\n"
12121 "Neighbor to display information about\n"
12122 "Display detailed prefix count information\n")
12123{
12124 struct peer *peer;
12125
12126 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12127 if (! peer)
12128 return CMD_WARNING;
12129
12130 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12131}
12132
Paul Jakmaff7924f2006-09-04 01:10:36 +000012133DEFUN (show_bgp_ipv6_neighbor_prefix_counts,
12134 show_bgp_ipv6_neighbor_prefix_counts_cmd,
12135 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12136 SHOW_STR
12137 BGP_STR
12138 "Address family\n"
12139 "Detailed information on TCP and BGP neighbor connections\n"
12140 "Neighbor to display information about\n"
12141 "Neighbor to display information about\n"
12142 "Display detailed prefix count information\n")
12143{
12144 struct peer *peer;
12145
12146 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12147 if (! peer)
12148 return CMD_WARNING;
12149
12150 return bgp_peer_counts (vty, peer, AFI_IP6, SAFI_UNICAST);
12151}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012152
12153DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts,
12154 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd,
12155 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12156 SHOW_STR
12157 IP_STR
12158 BGP_STR
12159 "Address family\n"
12160 "Address Family modifier\n"
12161 "Address Family modifier\n"
12162 "Detailed information on TCP and BGP neighbor connections\n"
12163 "Neighbor to display information about\n"
12164 "Neighbor to display information about\n"
12165 "Display detailed prefix count information\n")
12166{
12167 struct peer *peer;
12168
12169 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12170 if (! peer)
12171 return CMD_WARNING;
12172
12173 if (strncmp (argv[0], "m", 1) == 0)
12174 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST);
12175
12176 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST);
12177}
12178
12179DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
12180 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
12181 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12182 SHOW_STR
12183 IP_STR
12184 BGP_STR
12185 "Address family\n"
12186 "Address Family modifier\n"
12187 "Address Family modifier\n"
12188 "Detailed information on TCP and BGP neighbor connections\n"
12189 "Neighbor to display information about\n"
12190 "Neighbor to display information about\n"
12191 "Display detailed prefix count information\n")
12192{
12193 struct peer *peer;
12194
12195 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12196 if (! peer)
12197 return CMD_WARNING;
12198
12199 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN);
12200}
Paul Jakmaff7924f2006-09-04 01:10:36 +000012201
Lou Berger651b4022016-01-12 13:42:07 -050012202DEFUN (show_bgp_ipv4_safi_neighbor_prefix_counts,
12203 show_bgp_ipv4_safi_neighbor_prefix_counts_cmd,
12204 "show bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012205 SHOW_STR
Paul Jakmaff7924f2006-09-04 01:10:36 +000012206 BGP_STR
12207 "Address family\n"
12208 "Address Family modifier\n"
12209 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012210 "Address Family modifier\n"
12211 "Address Family modifier\n"
Paul Jakmaff7924f2006-09-04 01:10:36 +000012212 "Detailed information on TCP and BGP neighbor connections\n"
12213 "Neighbor to display information about\n"
12214 "Neighbor to display information about\n"
12215 "Display detailed prefix count information\n")
12216{
12217 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012218 safi_t safi;
12219
12220 if (bgp_parse_safi(argv[0], &safi)) {
12221 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12222 return CMD_WARNING;
12223 }
Paul Jakmaff7924f2006-09-04 01:10:36 +000012224
12225 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12226 if (! peer)
12227 return CMD_WARNING;
12228
Lou Berger651b4022016-01-12 13:42:07 -050012229 return bgp_peer_counts (vty, peer, AFI_IP, safi);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012230}
Lou Berger205e6742016-01-12 13:42:11 -050012231
Lou Berger651b4022016-01-12 13:42:07 -050012232DEFUN (show_bgp_ipv6_safi_neighbor_prefix_counts,
12233 show_bgp_ipv6_safi_neighbor_prefix_counts_cmd,
12234 "show bgp ipv6 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
12235 SHOW_STR
12236 BGP_STR
12237 "Address family\n"
12238 "Address Family modifier\n"
12239 "Address Family modifier\n"
12240 "Address Family modifier\n"
12241 "Address Family modifier\n"
12242 "Detailed information on TCP and BGP neighbor connections\n"
12243 "Neighbor to display information about\n"
12244 "Neighbor to display information about\n"
12245 "Display detailed prefix count information\n")
12246{
12247 struct peer *peer;
12248 safi_t safi;
Paul Jakmaff7924f2006-09-04 01:10:36 +000012249
Lou Berger651b4022016-01-12 13:42:07 -050012250 if (bgp_parse_safi(argv[0], &safi)) {
12251 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12252 return CMD_WARNING;
12253 }
12254
12255 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12256 if (! peer)
12257 return CMD_WARNING;
12258
12259 return bgp_peer_counts (vty, peer, AFI_IP6, safi);
12260}
Lou Berger651b4022016-01-12 13:42:07 -050012261
12262DEFUN (show_ip_bgp_encap_neighbor_prefix_counts,
12263 show_ip_bgp_encap_neighbor_prefix_counts_cmd,
12264 "show ip bgp encap all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
Paul Jakmaff7924f2006-09-04 01:10:36 +000012265 SHOW_STR
12266 IP_STR
12267 BGP_STR
12268 "Address family\n"
12269 "Address Family modifier\n"
12270 "Address Family modifier\n"
12271 "Detailed information on TCP and BGP neighbor connections\n"
12272 "Neighbor to display information about\n"
12273 "Neighbor to display information about\n"
12274 "Display detailed prefix count information\n")
12275{
12276 struct peer *peer;
12277
12278 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12279 if (! peer)
12280 return CMD_WARNING;
12281
Lou Berger651b4022016-01-12 13:42:07 -050012282 return bgp_peer_counts (vty, peer, AFI_IP, SAFI_ENCAP);
Paul Jakmaff7924f2006-09-04 01:10:36 +000012283}
12284
12285
paul94f2b392005-06-28 12:44:16 +000012286static void
paul718e3742002-12-13 20:15:29 +000012287show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
12288 int in)
12289{
12290 struct bgp_table *table;
12291 struct bgp_adj_in *ain;
12292 struct bgp_adj_out *adj;
12293 unsigned long output_count;
12294 struct bgp_node *rn;
12295 int header1 = 1;
12296 struct bgp *bgp;
12297 int header2 = 1;
12298
paulbb46e942003-10-24 19:02:03 +000012299 bgp = peer->bgp;
paul718e3742002-12-13 20:15:29 +000012300
12301 if (! bgp)
12302 return;
12303
12304 table = bgp->rib[afi][safi];
12305
12306 output_count = 0;
12307
12308 if (! in && CHECK_FLAG (peer->af_sflags[afi][safi],
12309 PEER_STATUS_DEFAULT_ORIGINATE))
12310 {
12311 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 +000012312 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12313 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012314
12315 vty_out (vty, "Originating default network 0.0.0.0%s%s",
12316 VTY_NEWLINE, VTY_NEWLINE);
12317 header1 = 0;
12318 }
12319
12320 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
12321 if (in)
12322 {
12323 for (ain = rn->adj_in; ain; ain = ain->next)
12324 if (ain->peer == peer)
12325 {
12326 if (header1)
12327 {
12328 vty_out (vty, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE);
hasso93406d82005-02-02 14:40:33 +000012329 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12330 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012331 header1 = 0;
12332 }
12333 if (header2)
12334 {
12335 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12336 header2 = 0;
12337 }
12338 if (ain->attr)
12339 {
12340 route_vty_out_tmp (vty, &rn->p, ain->attr, safi);
12341 output_count++;
12342 }
12343 }
12344 }
12345 else
12346 {
12347 for (adj = rn->adj_out; adj; adj = adj->next)
12348 if (adj->peer == peer)
12349 {
12350 if (header1)
12351 {
12352 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 +000012353 vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
12354 vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000012355 header1 = 0;
12356 }
12357 if (header2)
12358 {
12359 vty_out (vty, BGP_SHOW_HEADER, VTY_NEWLINE);
12360 header2 = 0;
12361 }
12362 if (adj->attr)
12363 {
12364 route_vty_out_tmp (vty, &rn->p, adj->attr, safi);
12365 output_count++;
12366 }
12367 }
12368 }
12369
12370 if (output_count != 0)
12371 vty_out (vty, "%sTotal number of prefixes %ld%s",
12372 VTY_NEWLINE, output_count, VTY_NEWLINE);
12373}
12374
paul94f2b392005-06-28 12:44:16 +000012375static int
paulbb46e942003-10-24 19:02:03 +000012376peer_adj_routes (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in)
12377{
paul718e3742002-12-13 20:15:29 +000012378 if (! peer || ! peer->afc[afi][safi])
12379 {
12380 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
12381 return CMD_WARNING;
12382 }
12383
12384 if (in && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
12385 {
12386 vty_out (vty, "%% Inbound soft reconfiguration not enabled%s",
12387 VTY_NEWLINE);
12388 return CMD_WARNING;
12389 }
12390
12391 show_adj_route (vty, peer, afi, safi, in);
12392
12393 return CMD_SUCCESS;
12394}
12395
Lou Bergerf9b6c392016-01-12 13:42:09 -050012396DEFUN (show_ip_bgp_view_neighbor_advertised_route,
12397 show_ip_bgp_view_neighbor_advertised_route_cmd,
12398 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12399 SHOW_STR
12400 IP_STR
12401 BGP_STR
12402 "BGP view\n"
12403 "View name\n"
12404 "Detailed information on TCP and BGP neighbor connections\n"
12405 "Neighbor to display information about\n"
12406 "Neighbor to display information about\n"
12407 "Display the routes advertised to a BGP neighbor\n")
12408{
12409 struct peer *peer;
12410
12411 if (argc == 2)
12412 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12413 else
12414 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12415
12416 if (! peer)
12417 return CMD_WARNING;
12418
12419 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12420}
12421
12422ALIAS (show_ip_bgp_view_neighbor_advertised_route,
12423 show_ip_bgp_neighbor_advertised_route_cmd,
12424 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12425 SHOW_STR
12426 IP_STR
12427 BGP_STR
12428 "Detailed information on TCP and BGP neighbor connections\n"
12429 "Neighbor to display information about\n"
12430 "Neighbor to display information about\n"
12431 "Display the routes advertised to a BGP neighbor\n")
12432
12433DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
12434 show_ip_bgp_ipv4_neighbor_advertised_route_cmd,
12435 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12436 SHOW_STR
12437 IP_STR
12438 BGP_STR
12439 "Address family\n"
12440 "Address Family modifier\n"
12441 "Address Family modifier\n"
12442 "Detailed information on TCP and BGP neighbor connections\n"
12443 "Neighbor to display information about\n"
12444 "Neighbor to display information about\n"
12445 "Display the routes advertised to a BGP neighbor\n")
12446{
12447 struct peer *peer;
12448
12449 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12450 if (! peer)
12451 return CMD_WARNING;
12452
12453 if (strncmp (argv[0], "m", 1) == 0)
12454 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0);
12455
12456 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0);
12457}
12458
Lou Bergerf9b6c392016-01-12 13:42:09 -050012459DEFUN (show_bgp_view_neighbor_advertised_route,
12460 show_bgp_view_neighbor_advertised_route_cmd,
12461 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12462 SHOW_STR
12463 BGP_STR
12464 "BGP view\n"
12465 "View name\n"
12466 "Detailed information on TCP and BGP neighbor connections\n"
12467 "Neighbor to display information about\n"
12468 "Neighbor to display information about\n"
12469 "Display the routes advertised to a BGP neighbor\n")
12470{
12471 struct peer *peer;
12472
12473 if (argc == 2)
12474 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12475 else
12476 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12477
12478 if (! peer)
12479 return CMD_WARNING;
12480
12481 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12482}
12483
12484DEFUN (show_bgp_view_neighbor_received_routes,
12485 show_bgp_view_neighbor_received_routes_cmd,
12486 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12487 SHOW_STR
12488 BGP_STR
12489 "BGP view\n"
12490 "View name\n"
12491 "Detailed information on TCP and BGP neighbor connections\n"
12492 "Neighbor to display information about\n"
12493 "Neighbor to display information about\n"
12494 "Display the received routes from neighbor\n")
12495{
12496 struct peer *peer;
12497
12498 if (argc == 2)
12499 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12500 else
12501 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12502
12503 if (! peer)
12504 return CMD_WARNING;
12505
12506 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12507}
12508
12509ALIAS (show_bgp_view_neighbor_advertised_route,
12510 show_bgp_neighbor_advertised_route_cmd,
12511 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12512 SHOW_STR
12513 BGP_STR
12514 "Detailed information on TCP and BGP neighbor connections\n"
12515 "Neighbor to display information about\n"
12516 "Neighbor to display information about\n"
12517 "Display the routes advertised to a BGP neighbor\n")
12518
12519ALIAS (show_bgp_view_neighbor_advertised_route,
12520 show_bgp_ipv6_neighbor_advertised_route_cmd,
12521 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12522 SHOW_STR
12523 BGP_STR
12524 "Address family\n"
12525 "Detailed information on TCP and BGP neighbor connections\n"
12526 "Neighbor to display information about\n"
12527 "Neighbor to display information about\n"
12528 "Display the routes advertised to a BGP neighbor\n")
12529
12530/* old command */
12531ALIAS (show_bgp_view_neighbor_advertised_route,
12532 ipv6_bgp_neighbor_advertised_route_cmd,
12533 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12534 SHOW_STR
12535 IPV6_STR
12536 BGP_STR
12537 "Detailed information on TCP and BGP neighbor connections\n"
12538 "Neighbor to display information about\n"
12539 "Neighbor to display information about\n"
12540 "Display the routes advertised to a BGP neighbor\n")
12541
12542/* old command */
12543DEFUN (ipv6_mbgp_neighbor_advertised_route,
12544 ipv6_mbgp_neighbor_advertised_route_cmd,
12545 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12546 SHOW_STR
12547 IPV6_STR
12548 MBGP_STR
12549 "Detailed information on TCP and BGP neighbor connections\n"
12550 "Neighbor to display information about\n"
12551 "Neighbor to display information about\n"
12552 "Display the routes advertised to a BGP neighbor\n")
12553{
12554 struct peer *peer;
12555
12556 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12557 if (! peer)
12558 return CMD_WARNING;
12559
12560 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 0);
12561}
Lou Bergerf9b6c392016-01-12 13:42:09 -050012562
12563DEFUN (show_ip_bgp_view_neighbor_received_routes,
12564 show_ip_bgp_view_neighbor_received_routes_cmd,
12565 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
12566 SHOW_STR
12567 IP_STR
12568 BGP_STR
12569 "BGP view\n"
12570 "View name\n"
12571 "Detailed information on TCP and BGP neighbor connections\n"
12572 "Neighbor to display information about\n"
12573 "Neighbor to display information about\n"
12574 "Display the received routes from neighbor\n")
12575{
12576 struct peer *peer;
12577
12578 if (argc == 2)
12579 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12580 else
12581 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12582
12583 if (! peer)
12584 return CMD_WARNING;
12585
12586 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12587}
12588
12589ALIAS (show_ip_bgp_view_neighbor_received_routes,
12590 show_ip_bgp_neighbor_received_routes_cmd,
12591 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12592 SHOW_STR
12593 IP_STR
12594 BGP_STR
12595 "Detailed information on TCP and BGP neighbor connections\n"
12596 "Neighbor to display information about\n"
12597 "Neighbor to display information about\n"
12598 "Display the received routes from neighbor\n")
12599
12600ALIAS (show_bgp_view_neighbor_received_routes,
12601 show_bgp_ipv6_neighbor_received_routes_cmd,
12602 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
12603 SHOW_STR
12604 BGP_STR
12605 "Address family\n"
12606 "Detailed information on TCP and BGP neighbor connections\n"
12607 "Neighbor to display information about\n"
12608 "Neighbor to display information about\n"
12609 "Display the received routes from neighbor\n")
12610
12611DEFUN (show_bgp_neighbor_received_prefix_filter,
12612 show_bgp_neighbor_received_prefix_filter_cmd,
12613 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12614 SHOW_STR
12615 BGP_STR
12616 "Detailed information on TCP and BGP neighbor connections\n"
12617 "Neighbor to display information about\n"
12618 "Neighbor to display information about\n"
12619 "Display information received from a BGP neighbor\n"
12620 "Display the prefixlist filter\n")
12621{
12622 char name[BUFSIZ];
12623 union sockunion su;
12624 struct peer *peer;
12625 int count, ret;
12626
12627 ret = str2sockunion (argv[0], &su);
12628 if (ret < 0)
12629 {
12630 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12631 return CMD_WARNING;
12632 }
12633
12634 peer = peer_lookup (NULL, &su);
12635 if (! peer)
12636 return CMD_WARNING;
12637
12638 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12639 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12640 if (count)
12641 {
12642 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12643 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12644 }
12645
12646 return CMD_SUCCESS;
12647}
12648
12649/* old command */
12650ALIAS (show_bgp_view_neighbor_received_routes,
12651 ipv6_bgp_neighbor_received_routes_cmd,
12652 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12653 SHOW_STR
12654 IPV6_STR
12655 BGP_STR
12656 "Detailed information on TCP and BGP neighbor connections\n"
12657 "Neighbor to display information about\n"
12658 "Neighbor to display information about\n"
12659 "Display the received routes from neighbor\n")
12660
12661/* old command */
12662DEFUN (ipv6_mbgp_neighbor_received_routes,
12663 ipv6_mbgp_neighbor_received_routes_cmd,
12664 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
12665 SHOW_STR
12666 IPV6_STR
12667 MBGP_STR
12668 "Detailed information on TCP and BGP neighbor connections\n"
12669 "Neighbor to display information about\n"
12670 "Neighbor to display information about\n"
12671 "Display the received routes from neighbor\n")
12672{
12673 struct peer *peer;
12674
12675 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12676 if (! peer)
12677 return CMD_WARNING;
12678
12679 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_MULTICAST, 1);
12680}
12681
12682DEFUN (show_bgp_view_neighbor_received_prefix_filter,
12683 show_bgp_view_neighbor_received_prefix_filter_cmd,
12684 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12685 SHOW_STR
12686 BGP_STR
12687 "BGP view\n"
12688 "View name\n"
12689 "Detailed information on TCP and BGP neighbor connections\n"
12690 "Neighbor to display information about\n"
12691 "Neighbor to display information about\n"
12692 "Display information received from a BGP neighbor\n"
12693 "Display the prefixlist filter\n")
12694{
12695 char name[BUFSIZ];
12696 union sockunion su;
12697 struct peer *peer;
12698 struct bgp *bgp;
12699 int count, ret;
12700
12701 /* BGP structure lookup. */
12702 bgp = bgp_lookup_by_name (argv[0]);
12703 if (bgp == NULL)
12704 {
12705 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
12706 return CMD_WARNING;
12707 }
12708
12709 ret = str2sockunion (argv[1], &su);
12710 if (ret < 0)
12711 {
12712 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
12713 return CMD_WARNING;
12714 }
12715
12716 peer = peer_lookup (bgp, &su);
12717 if (! peer)
12718 return CMD_WARNING;
12719
12720 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
12721 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
12722 if (count)
12723 {
12724 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
12725 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
12726 }
12727
12728 return CMD_SUCCESS;
12729}
12730
12731
12732DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
12733 show_ip_bgp_ipv4_neighbor_received_routes_cmd,
12734 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
12735 SHOW_STR
12736 IP_STR
12737 BGP_STR
12738 "Address family\n"
12739 "Address Family modifier\n"
12740 "Address Family modifier\n"
12741 "Detailed information on TCP and BGP neighbor connections\n"
12742 "Neighbor to display information about\n"
12743 "Neighbor to display information about\n"
12744 "Display the received routes from neighbor\n")
12745{
12746 struct peer *peer;
12747
12748 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12749 if (! peer)
12750 return CMD_WARNING;
12751
12752 if (strncmp (argv[0], "m", 1) == 0)
12753 return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1);
12754
12755 return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1);
12756}
12757
Lou Berger651b4022016-01-12 13:42:07 -050012758DEFUN (show_bgp_ipv4_safi_neighbor_advertised_route,
12759 show_bgp_ipv4_safi_neighbor_advertised_route_cmd,
12760 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012761 SHOW_STR
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012762 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050012763 "Address Family modifier\n"
12764 "Address Family modifier\n"
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012765 "Detailed information on TCP and BGP neighbor connections\n"
12766 "Neighbor to display information about\n"
12767 "Neighbor to display information about\n"
12768 "Display the routes advertised to a BGP neighbor\n")
12769{
12770 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012771 safi_t safi;
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012772
Lou Berger651b4022016-01-12 13:42:07 -050012773 if (bgp_parse_safi(argv[0], &safi)) {
12774 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
Tomasz Pala2a71e9c2009-06-24 21:36:50 +010012775 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050012776 }
paul718e3742002-12-13 20:15:29 +000012777
paulbb46e942003-10-24 19:02:03 +000012778 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12779 if (! peer)
12780 return CMD_WARNING;
12781
Lou Berger651b4022016-01-12 13:42:07 -050012782 return peer_adj_routes (vty, peer, AFI_IP, safi, 0);
12783}
Lou Berger205e6742016-01-12 13:42:11 -050012784
Lou Berger651b4022016-01-12 13:42:07 -050012785DEFUN (show_bgp_ipv6_safi_neighbor_advertised_route,
12786 show_bgp_ipv6_safi_neighbor_advertised_route_cmd,
12787 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
12788 SHOW_STR
12789 BGP_STR
12790 "Address Family modifier\n"
12791 "Address Family modifier\n"
12792 "Address Family modifier\n"
12793 "Detailed information on TCP and BGP neighbor connections\n"
12794 "Neighbor to display information about\n"
12795 "Neighbor to display information about\n"
12796 "Display the routes advertised to a BGP neighbor\n")
12797{
12798 struct peer *peer;
12799 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000012800
Lou Berger651b4022016-01-12 13:42:07 -050012801 if (bgp_parse_safi(argv[0], &safi)) {
12802 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12803 return CMD_WARNING;
12804 }
12805
12806 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12807 if (! peer)
12808 return CMD_WARNING;
12809
12810 return peer_adj_routes (vty, peer, AFI_IP6, safi, 0);
paul718e3742002-12-13 20:15:29 +000012811}
12812
Lou Bergerf9b6c392016-01-12 13:42:09 -050012813DEFUN (show_bgp_view_ipv6_neighbor_advertised_route,
Lou Berger651b4022016-01-12 13:42:07 -050012814 show_bgp_view_ipv6_neighbor_advertised_route_cmd,
12815 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
paulbb46e942003-10-24 19:02:03 +000012816 SHOW_STR
12817 BGP_STR
12818 "BGP view\n"
12819 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050012820 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000012821 "Detailed information on TCP and BGP neighbor connections\n"
12822 "Neighbor to display information about\n"
12823 "Neighbor to display information about\n"
12824 "Display the routes advertised to a BGP neighbor\n")
12825{
12826 struct peer *peer;
12827
12828 if (argc == 2)
12829 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12830 else
12831 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12832
12833 if (! peer)
12834 return CMD_WARNING;
12835
12836 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 0);
12837}
12838
Lou Bergerf9b6c392016-01-12 13:42:09 -050012839DEFUN (show_bgp_view_ipv6_neighbor_received_routes,
Lou Berger651b4022016-01-12 13:42:07 -050012840 show_bgp_view_ipv6_neighbor_received_routes_cmd,
12841 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
paulbb46e942003-10-24 19:02:03 +000012842 SHOW_STR
12843 BGP_STR
12844 "BGP view\n"
12845 "View name\n"
12846 "Address family\n"
12847 "Detailed information on TCP and BGP neighbor connections\n"
12848 "Neighbor to display information about\n"
12849 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000012850 "Display the received routes from neighbor\n")
12851{
12852 struct peer *peer;
12853
12854 if (argc == 2)
12855 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
12856 else
12857 peer = peer_lookup_in_view (vty, NULL, argv[0]);
12858
12859 if (! peer)
12860 return CMD_WARNING;
12861
12862 return peer_adj_routes (vty, peer, AFI_IP6, SAFI_UNICAST, 1);
12863}
Lou Berger651b4022016-01-12 13:42:07 -050012864
12865DEFUN (show_bgp_ipv4_safi_neighbor_received_routes,
12866 show_bgp_ipv4_safi_neighbor_received_routes_cmd,
12867 "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 +010012868 SHOW_STR
paul718e3742002-12-13 20:15:29 +000012869 BGP_STR
12870 "Address family\n"
12871 "Address Family modifier\n"
12872 "Address Family modifier\n"
Lou Berger651b4022016-01-12 13:42:07 -050012873 "Address Family modifier\n"
12874 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000012875 "Detailed information on TCP and BGP neighbor connections\n"
12876 "Neighbor to display information about\n"
12877 "Neighbor to display information about\n"
12878 "Display the received routes from neighbor\n")
12879{
paulbb46e942003-10-24 19:02:03 +000012880 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050012881 safi_t safi;
12882
12883 if (bgp_parse_safi(argv[0], &safi)) {
12884 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12885 return CMD_WARNING;
12886 }
paul718e3742002-12-13 20:15:29 +000012887
paulbb46e942003-10-24 19:02:03 +000012888 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12889 if (! peer)
12890 return CMD_WARNING;
12891
Lou Berger651b4022016-01-12 13:42:07 -050012892 return peer_adj_routes (vty, peer, AFI_IP, safi, 1);
paul718e3742002-12-13 20:15:29 +000012893}
Lou Berger205e6742016-01-12 13:42:11 -050012894
Lou Berger651b4022016-01-12 13:42:07 -050012895DEFUN (show_bgp_ipv6_safi_neighbor_received_routes,
12896 show_bgp_ipv6_safi_neighbor_received_routes_cmd,
12897 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) received-routes",
12898 SHOW_STR
12899 BGP_STR
12900 "Address family\n"
12901 "Address Family modifier\n"
12902 "Address Family modifier\n"
12903 "Address Family modifier\n"
12904 "Address Family modifier\n"
12905 "Detailed information on TCP and BGP neighbor connections\n"
12906 "Neighbor to display information about\n"
12907 "Neighbor to display information about\n"
12908 "Display the received routes from neighbor\n")
12909{
12910 struct peer *peer;
12911 safi_t safi;
12912
12913 if (bgp_parse_safi(argv[0], &safi)) {
12914 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
12915 return CMD_WARNING;
12916 }
12917
12918 peer = peer_lookup_in_view (vty, NULL, argv[1]);
12919 if (! peer)
12920 return CMD_WARNING;
12921
12922 return peer_adj_routes (vty, peer, AFI_IP6, safi, 1);
12923}
paul718e3742002-12-13 20:15:29 +000012924
Michael Lambert95cbbd22010-07-23 14:43:04 -040012925DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes,
12926 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd,
Michael Lambert95cbbd22010-07-23 14:43:04 -040012927 "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 -040012928 SHOW_STR
12929 BGP_STR
12930 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000012931 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012932 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012933 "Address family\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040012934 "Address family modifier\n"
12935 "Address family modifier\n"
12936 "Detailed information on TCP and BGP neighbor connections\n"
12937 "Neighbor to display information about\n"
12938 "Neighbor to display information about\n"
12939 "Display the advertised routes to neighbor\n"
12940 "Display the received routes from neighbor\n")
12941{
12942 int afi;
12943 int safi;
12944 int in;
12945 struct peer *peer;
12946
David Lamparter94bad672015-03-03 08:52:22 +010012947 peer = peer_lookup_in_view (vty, argv[0], argv[3]);
Michael Lambert95cbbd22010-07-23 14:43:04 -040012948
12949 if (! peer)
12950 return CMD_WARNING;
12951
Michael Lambert95cbbd22010-07-23 14:43:04 -040012952 afi = (strncmp (argv[1], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
12953 safi = (strncmp (argv[2], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
12954 in = (strncmp (argv[4], "r", 1) == 0) ? 1 : 0;
Michael Lambert95cbbd22010-07-23 14:43:04 -040012955
12956 return peer_adj_routes (vty, peer, afi, safi, in);
12957}
12958
Lou Bergerf9b6c392016-01-12 13:42:09 -050012959DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
12960 show_ip_bgp_neighbor_received_prefix_filter_cmd,
12961 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
12962 SHOW_STR
12963 IP_STR
12964 BGP_STR
12965 "Detailed information on TCP and BGP neighbor connections\n"
12966 "Neighbor to display information about\n"
12967 "Neighbor to display information about\n"
12968 "Display information received from a BGP neighbor\n"
12969 "Display the prefixlist filter\n")
12970{
12971 char name[BUFSIZ];
12972 union sockunion su;
12973 struct peer *peer;
12974 int count, ret;
12975
12976 ret = str2sockunion (argv[0], &su);
12977 if (ret < 0)
12978 {
12979 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
12980 return CMD_WARNING;
12981 }
12982
12983 peer = peer_lookup (NULL, &su);
12984 if (! peer)
12985 return CMD_WARNING;
12986
12987 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
12988 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
12989 if (count)
12990 {
12991 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
12992 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
12993 }
12994
12995 return CMD_SUCCESS;
12996}
12997
12998DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter,
12999 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd,
13000 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
13001 SHOW_STR
13002 IP_STR
13003 BGP_STR
13004 "Address family\n"
13005 "Address Family modifier\n"
13006 "Address Family modifier\n"
13007 "Detailed information on TCP and BGP neighbor connections\n"
13008 "Neighbor to display information about\n"
13009 "Neighbor to display information about\n"
13010 "Display information received from a BGP neighbor\n"
13011 "Display the prefixlist filter\n")
13012{
13013 char name[BUFSIZ];
13014 union sockunion su;
13015 struct peer *peer;
13016 int count, ret;
13017
13018 ret = str2sockunion (argv[1], &su);
13019 if (ret < 0)
13020 {
13021 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13022 return CMD_WARNING;
13023 }
13024
13025 peer = peer_lookup (NULL, &su);
13026 if (! peer)
13027 return CMD_WARNING;
13028
13029 if (strncmp (argv[0], "m", 1) == 0)
13030 {
13031 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
13032 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13033 if (count)
13034 {
13035 vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
13036 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13037 }
13038 }
13039 else
13040 {
13041 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
13042 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13043 if (count)
13044 {
13045 vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
13046 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13047 }
13048 }
13049
13050 return CMD_SUCCESS;
13051}
13052
13053ALIAS (show_bgp_view_neighbor_received_routes,
13054 show_bgp_neighbor_received_routes_cmd,
13055 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
13056 SHOW_STR
13057 BGP_STR
13058 "Detailed information on TCP and BGP neighbor connections\n"
13059 "Neighbor to display information about\n"
13060 "Neighbor to display information about\n"
13061 "Display the received routes from neighbor\n")
13062
Lou Berger651b4022016-01-12 13:42:07 -050013063DEFUN (show_bgp_ipv4_safi_neighbor_received_prefix_filter,
13064 show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd,
13065 "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 +000013066 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013067 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013068 IP_STR
13069 "Address Family modifier\n"
13070 "Address Family modifier\n"
13071 "Address Family modifier\n"
13072 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013073 "Detailed information on TCP and BGP neighbor connections\n"
13074 "Neighbor to display information about\n"
13075 "Neighbor to display information about\n"
13076 "Display information received from a BGP neighbor\n"
13077 "Display the prefixlist filter\n")
13078{
13079 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013080 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013081 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013082 int count, ret;
Lou Berger651b4022016-01-12 13:42:07 -050013083 safi_t safi;
paul718e3742002-12-13 20:15:29 +000013084
Lou Berger651b4022016-01-12 13:42:07 -050013085 if (bgp_parse_safi(argv[0], &safi)) {
13086 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013087 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013088 }
paul718e3742002-12-13 20:15:29 +000013089
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013090 ret = str2sockunion (argv[1], &su);
13091 if (ret < 0)
13092 {
13093 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13094 return CMD_WARNING;
13095 }
paul718e3742002-12-13 20:15:29 +000013096
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013097 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013098 if (! peer)
13099 return CMD_WARNING;
13100
Lou Berger651b4022016-01-12 13:42:07 -050013101 sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
13102 count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name);
13103 if (count) {
13104 vty_out (vty, "Address family: IPv4 %s%s", safi2str(safi), VTY_NEWLINE);
13105 prefix_bgp_show_prefix_list (vty, AFI_IP, name);
13106 }
paul718e3742002-12-13 20:15:29 +000013107
13108 return CMD_SUCCESS;
13109}
Lou Berger205e6742016-01-12 13:42:11 -050013110
Lou Berger651b4022016-01-12 13:42:07 -050013111DEFUN (show_bgp_ipv6_safi_neighbor_received_prefix_filter,
13112 show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd,
13113 "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 +000013114 SHOW_STR
13115 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013116 IP_STR
13117 "Address Family modifier\n"
13118 "Address Family modifier\n"
13119 "Address Family modifier\n"
13120 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000013121 "Detailed information on TCP and BGP neighbor connections\n"
13122 "Neighbor to display information about\n"
13123 "Neighbor to display information about\n"
Lou Berger651b4022016-01-12 13:42:07 -050013124 "Display information received from a BGP neighbor\n"
13125 "Display the prefixlist filter\n")
13126{
13127 char name[BUFSIZ];
13128 union sockunion su;
13129 struct peer *peer;
13130 int count, ret;
13131 safi_t safi;
13132
13133 if (bgp_parse_safi(argv[0], &safi)) {
13134 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13135 return CMD_WARNING;
13136 }
13137
13138 ret = str2sockunion (argv[1], &su);
13139 if (ret < 0)
13140 {
13141 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13142 return CMD_WARNING;
13143 }
13144
13145 peer = peer_lookup (NULL, &su);
13146 if (! peer)
13147 return CMD_WARNING;
13148
13149 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, safi);
13150 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13151 if (count) {
13152 vty_out (vty, "Address family: IPv6 %s%s", safi2str(safi), VTY_NEWLINE);
13153 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13154 }
13155
13156 return CMD_SUCCESS;
13157}
paul718e3742002-12-13 20:15:29 +000013158
Lou Bergerf9b6c392016-01-12 13:42:09 -050013159DEFUN (show_bgp_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013160 show_bgp_ipv6_neighbor_received_prefix_filter_cmd,
13161 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paul718e3742002-12-13 20:15:29 +000013162 SHOW_STR
13163 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013164 "Address family\n"
paul718e3742002-12-13 20:15:29 +000013165 "Detailed information on TCP and BGP neighbor connections\n"
13166 "Neighbor to display information about\n"
13167 "Neighbor to display information about\n"
13168 "Display information received from a BGP neighbor\n"
13169 "Display the prefixlist filter\n")
13170{
13171 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013172 union sockunion su;
paul718e3742002-12-13 20:15:29 +000013173 struct peer *peer;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013174 int count, ret;
paul718e3742002-12-13 20:15:29 +000013175
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013176 ret = str2sockunion (argv[0], &su);
13177 if (ret < 0)
13178 {
13179 vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE);
13180 return CMD_WARNING;
13181 }
paul718e3742002-12-13 20:15:29 +000013182
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013183 peer = peer_lookup (NULL, &su);
paul718e3742002-12-13 20:15:29 +000013184 if (! peer)
13185 return CMD_WARNING;
13186
13187 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13188 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13189 if (count)
13190 {
13191 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13192 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13193 }
13194
13195 return CMD_SUCCESS;
13196}
13197
Lou Bergerf9b6c392016-01-12 13:42:09 -050013198DEFUN (show_bgp_view_ipv6_neighbor_received_prefix_filter,
Lou Berger651b4022016-01-12 13:42:07 -050013199 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
13200 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
paulbb46e942003-10-24 19:02:03 +000013201 SHOW_STR
13202 BGP_STR
13203 "BGP view\n"
13204 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013205 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013206 "Detailed information on TCP and BGP neighbor connections\n"
13207 "Neighbor to display information about\n"
13208 "Neighbor to display information about\n"
13209 "Display information received from a BGP neighbor\n"
13210 "Display the prefixlist filter\n")
13211{
13212 char name[BUFSIZ];
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013213 union sockunion su;
paulbb46e942003-10-24 19:02:03 +000013214 struct peer *peer;
13215 struct bgp *bgp;
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013216 int count, ret;
paulbb46e942003-10-24 19:02:03 +000013217
13218 /* BGP structure lookup. */
13219 bgp = bgp_lookup_by_name (argv[0]);
13220 if (bgp == NULL)
13221 {
13222 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13223 return CMD_WARNING;
13224 }
13225
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013226 ret = str2sockunion (argv[1], &su);
13227 if (ret < 0)
13228 {
13229 vty_out (vty, "Malformed address: %s%s", argv[1], VTY_NEWLINE);
13230 return CMD_WARNING;
13231 }
paulbb46e942003-10-24 19:02:03 +000013232
Jorge Boncompte [DTI2]c63b83f2012-04-10 16:57:24 +020013233 peer = peer_lookup (bgp, &su);
paulbb46e942003-10-24 19:02:03 +000013234 if (! peer)
13235 return CMD_WARNING;
13236
13237 sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
13238 count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
13239 if (count)
13240 {
13241 vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
13242 prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
13243 }
13244
13245 return CMD_SUCCESS;
13246}
David Lamparter6b0655a2014-06-04 06:53:35 +020013247
paul94f2b392005-06-28 12:44:16 +000013248static int
paulbb46e942003-10-24 19:02:03 +000013249bgp_show_neighbor_route (struct vty *vty, struct peer *peer, afi_t afi,
paul718e3742002-12-13 20:15:29 +000013250 safi_t safi, enum bgp_show_type type)
13251{
paul718e3742002-12-13 20:15:29 +000013252 if (! peer || ! peer->afc[afi][safi])
13253 {
13254 vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
paul718e3742002-12-13 20:15:29 +000013255 return CMD_WARNING;
13256 }
13257
ajs5a646652004-11-05 01:25:55 +000013258 return bgp_show (vty, peer->bgp, afi, safi, type, &peer->su);
paul718e3742002-12-13 20:15:29 +000013259}
Lou Bergerf9b6c392016-01-12 13:42:09 -050013260DEFUN (show_ip_bgp_neighbor_routes,
13261 show_ip_bgp_neighbor_routes_cmd,
13262 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
13263 SHOW_STR
13264 IP_STR
13265 BGP_STR
13266 "Detailed information on TCP and BGP neighbor connections\n"
13267 "Neighbor to display information about\n"
13268 "Neighbor to display information about\n"
13269 "Display routes learned from neighbor\n")
13270{
13271 struct peer *peer;
13272
13273 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13274 if (! peer)
13275 return CMD_WARNING;
13276
13277 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13278 bgp_show_type_neighbor);
13279}
13280
13281DEFUN (show_ip_bgp_neighbor_flap,
13282 show_ip_bgp_neighbor_flap_cmd,
13283 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
13284 SHOW_STR
13285 IP_STR
13286 BGP_STR
13287 "Detailed information on TCP and BGP neighbor connections\n"
13288 "Neighbor to display information about\n"
13289 "Neighbor to display information about\n"
13290 "Display flap statistics of the routes learned from neighbor\n")
13291{
13292 struct peer *peer;
13293
13294 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13295 if (! peer)
13296 return CMD_WARNING;
13297
13298 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13299 bgp_show_type_flap_neighbor);
13300}
13301
13302DEFUN (show_ip_bgp_neighbor_damp,
13303 show_ip_bgp_neighbor_damp_cmd,
13304 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13305 SHOW_STR
13306 IP_STR
13307 BGP_STR
13308 "Detailed information on TCP and BGP neighbor connections\n"
13309 "Neighbor to display information about\n"
13310 "Neighbor to display information about\n"
13311 "Display the dampened routes received from neighbor\n")
13312{
13313 struct peer *peer;
13314
13315 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13316 if (! peer)
13317 return CMD_WARNING;
13318
13319 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13320 bgp_show_type_damp_neighbor);
13321}
13322
13323DEFUN (show_ip_bgp_ipv4_neighbor_routes,
13324 show_ip_bgp_ipv4_neighbor_routes_cmd,
13325 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
13326 SHOW_STR
13327 IP_STR
13328 BGP_STR
13329 "Address family\n"
13330 "Address Family modifier\n"
13331 "Address Family modifier\n"
13332 "Detailed information on TCP and BGP neighbor connections\n"
13333 "Neighbor to display information about\n"
13334 "Neighbor to display information about\n"
13335 "Display routes learned from neighbor\n")
13336{
13337 struct peer *peer;
13338
13339 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13340 if (! peer)
13341 return CMD_WARNING;
13342
13343 if (strncmp (argv[0], "m", 1) == 0)
13344 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
13345 bgp_show_type_neighbor);
13346
13347 return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
13348 bgp_show_type_neighbor);
13349}
13350
13351DEFUN (show_ip_bgp_view_rsclient,
13352 show_ip_bgp_view_rsclient_cmd,
13353 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
13354 SHOW_STR
13355 IP_STR
13356 BGP_STR
13357 "BGP view\n"
13358 "View name\n"
13359 "Information about Route Server Client\n"
13360 NEIGHBOR_ADDR_STR)
13361{
13362 struct bgp_table *table;
13363 struct peer *peer;
13364
13365 if (argc == 2)
13366 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13367 else
13368 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13369
13370 if (! peer)
13371 return CMD_WARNING;
13372
13373 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13374 {
13375 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13376 VTY_NEWLINE);
13377 return CMD_WARNING;
13378 }
13379
13380 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13381 PEER_FLAG_RSERVER_CLIENT))
13382 {
13383 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13384 VTY_NEWLINE);
13385 return CMD_WARNING;
13386 }
13387
13388 table = peer->rib[AFI_IP][SAFI_UNICAST];
13389
13390 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13391}
13392
13393ALIAS (show_ip_bgp_view_rsclient,
13394 show_ip_bgp_rsclient_cmd,
13395 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
13396 SHOW_STR
13397 IP_STR
13398 BGP_STR
13399 "Information about Route Server Client\n"
13400 NEIGHBOR_ADDR_STR)
13401
13402DEFUN (show_bgp_view_ipv4_safi_rsclient,
13403 show_bgp_view_ipv4_safi_rsclient_cmd,
13404 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13405 SHOW_STR
13406 BGP_STR
13407 "BGP view\n"
13408 "View name\n"
13409 "Address family\n"
13410 "Address Family modifier\n"
13411 "Address Family modifier\n"
13412 "Information about Route Server Client\n"
13413 NEIGHBOR_ADDR_STR)
13414{
13415 struct bgp_table *table;
13416 struct peer *peer;
13417 safi_t safi;
13418
13419 if (argc == 3) {
13420 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13421 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13422 } else {
13423 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13424 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13425 }
13426
13427 if (! peer)
13428 return CMD_WARNING;
13429
13430 if (! peer->afc[AFI_IP][safi])
13431 {
13432 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13433 VTY_NEWLINE);
13434 return CMD_WARNING;
13435 }
13436
13437 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13438 PEER_FLAG_RSERVER_CLIENT))
13439 {
13440 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13441 VTY_NEWLINE);
13442 return CMD_WARNING;
13443 }
13444
13445 table = peer->rib[AFI_IP][safi];
13446
13447 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
13448}
13449
13450ALIAS (show_bgp_view_ipv4_safi_rsclient,
13451 show_bgp_ipv4_safi_rsclient_cmd,
13452 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
13453 SHOW_STR
13454 BGP_STR
13455 "Address family\n"
13456 "Address Family modifier\n"
13457 "Address Family modifier\n"
13458 "Information about Route Server Client\n"
13459 NEIGHBOR_ADDR_STR)
13460
13461DEFUN (show_ip_bgp_view_rsclient_route,
13462 show_ip_bgp_view_rsclient_route_cmd,
13463 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13464 SHOW_STR
13465 IP_STR
13466 BGP_STR
13467 "BGP view\n"
13468 "View name\n"
13469 "Information about Route Server Client\n"
13470 NEIGHBOR_ADDR_STR
13471 "Network in the BGP routing table to display\n")
13472{
13473 struct bgp *bgp;
13474 struct peer *peer;
13475
13476 /* BGP structure lookup. */
13477 if (argc == 3)
13478 {
13479 bgp = bgp_lookup_by_name (argv[0]);
13480 if (bgp == NULL)
13481 {
13482 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13483 return CMD_WARNING;
13484 }
13485 }
13486 else
13487 {
13488 bgp = bgp_get_default ();
13489 if (bgp == NULL)
13490 {
13491 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13492 return CMD_WARNING;
13493 }
13494 }
13495
13496 if (argc == 3)
13497 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13498 else
13499 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13500
13501 if (! peer)
13502 return CMD_WARNING;
13503
13504 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13505 {
13506 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13507 VTY_NEWLINE);
13508 return CMD_WARNING;
13509}
13510
13511 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13512 PEER_FLAG_RSERVER_CLIENT))
13513 {
13514 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13515 VTY_NEWLINE);
13516 return CMD_WARNING;
13517 }
13518
13519 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13520 (argc == 3) ? argv[2] : argv[1],
13521 AFI_IP, SAFI_UNICAST, NULL, 0);
13522}
13523
13524ALIAS (show_ip_bgp_view_rsclient_route,
13525 show_ip_bgp_rsclient_route_cmd,
13526 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13527 SHOW_STR
13528 IP_STR
13529 BGP_STR
13530 "Information about Route Server Client\n"
13531 NEIGHBOR_ADDR_STR
13532 "Network in the BGP routing table to display\n")
paul718e3742002-12-13 20:15:29 +000013533
Lou Berger651b4022016-01-12 13:42:07 -050013534DEFUN (show_bgp_ipv4_safi_neighbor_flap,
13535 show_bgp_ipv4_safi_neighbor_flap_cmd,
13536 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013537 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013538 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013539 "Address Family Modifier\n"
13540 "Address Family Modifier\n"
13541 "Address Family Modifier\n"
13542 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013543 "Detailed information on TCP and BGP neighbor connections\n"
13544 "Neighbor to display information about\n"
13545 "Neighbor to display information about\n"
13546 "Display flap statistics of the routes learned from neighbor\n")
13547{
paulbb46e942003-10-24 19:02:03 +000013548 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013549 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013550
Lou Berger651b4022016-01-12 13:42:07 -050013551 if (bgp_parse_safi(argv[0], &safi)) {
13552 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13553 return CMD_WARNING;
13554 }
13555
13556 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013557 if (! peer)
13558 return CMD_WARNING;
13559
Lou Berger651b4022016-01-12 13:42:07 -050013560 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013561 bgp_show_type_flap_neighbor);
13562}
Lou Berger205e6742016-01-12 13:42:11 -050013563
Lou Berger651b4022016-01-12 13:42:07 -050013564DEFUN (show_bgp_ipv6_safi_neighbor_flap,
13565 show_bgp_ipv6_safi_neighbor_flap_cmd,
13566 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paul718e3742002-12-13 20:15:29 +000013567 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013568 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013569 "Address Family Modifier\n"
13570 "Address Family Modifier\n"
13571 "Address Family Modifier\n"
13572 "Address Family Modifier\n"
13573 "Detailed information on TCP and BGP neighbor connections\n"
13574 "Neighbor to display information about\n"
13575 "Neighbor to display information about\n"
13576 "Display flap statistics of the routes learned from neighbor\n")
13577{
13578 struct peer *peer;
13579 safi_t safi;
13580
13581 if (bgp_parse_safi(argv[0], &safi)) {
13582 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13583 return CMD_WARNING;
13584 }
13585
13586 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13587 if (! peer)
13588 return CMD_WARNING;
13589
13590 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13591 bgp_show_type_flap_neighbor);
13592}
Lou Berger651b4022016-01-12 13:42:07 -050013593
13594DEFUN (show_bgp_ipv4_safi_neighbor_damp,
13595 show_bgp_ipv4_safi_neighbor_damp_cmd,
13596 "show bgp ipv4 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13597 SHOW_STR
13598 BGP_STR
13599 "Address Family Modifier\n"
13600 "Address Family Modifier\n"
13601 "Address Family Modifier\n"
13602 "Address Family Modifier\n"
paul718e3742002-12-13 20:15:29 +000013603 "Detailed information on TCP and BGP neighbor connections\n"
13604 "Neighbor to display information about\n"
13605 "Neighbor to display information about\n"
13606 "Display the dampened routes received from neighbor\n")
13607{
paulbb46e942003-10-24 19:02:03 +000013608 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013609 safi_t safi;
paulbb46e942003-10-24 19:02:03 +000013610
Lou Berger651b4022016-01-12 13:42:07 -050013611 if (bgp_parse_safi(argv[0], &safi)) {
13612 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13613 return CMD_WARNING;
13614 }
13615
13616 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulbb46e942003-10-24 19:02:03 +000013617 if (! peer)
13618 return CMD_WARNING;
13619
Lou Berger651b4022016-01-12 13:42:07 -050013620 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013621 bgp_show_type_damp_neighbor);
13622}
Lou Berger205e6742016-01-12 13:42:11 -050013623
Lou Berger651b4022016-01-12 13:42:07 -050013624DEFUN (show_bgp_ipv6_safi_neighbor_damp,
13625 show_bgp_ipv6_safi_neighbor_damp_cmd,
13626 "show bgp ipv6 (encap|multicast|unicast|vpn) neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paul718e3742002-12-13 20:15:29 +000013627 SHOW_STR
Lou Berger651b4022016-01-12 13:42:07 -050013628 BGP_STR
13629 "Address Family Modifier\n"
13630 "Address Family Modifier\n"
13631 "Address Family Modifier\n"
13632 "Address Family Modifier\n"
13633 "Detailed information on TCP and BGP neighbor connections\n"
13634 "Neighbor to display information about\n"
13635 "Neighbor to display information about\n"
13636 "Display the dampened routes received from neighbor\n")
13637{
13638 struct peer *peer;
13639 safi_t safi;
13640
13641 if (bgp_parse_safi(argv[0], &safi)) {
13642 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13643 return CMD_WARNING;
13644 }
13645
13646 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13647 if (! peer)
13648 return CMD_WARNING;
13649
13650 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13651 bgp_show_type_damp_neighbor);
13652}
Lou Berger651b4022016-01-12 13:42:07 -050013653
13654DEFUN (show_bgp_ipv4_safi_neighbor_routes,
13655 show_bgp_ipv4_safi_neighbor_routes_cmd,
13656 "show bgp ipv4 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
13657 SHOW_STR
paul718e3742002-12-13 20:15:29 +000013658 BGP_STR
13659 "Address family\n"
13660 "Address Family modifier\n"
13661 "Address Family modifier\n"
13662 "Detailed information on TCP and BGP neighbor connections\n"
13663 "Neighbor to display information about\n"
13664 "Neighbor to display information about\n"
13665 "Display routes learned from neighbor\n")
13666{
paulbb46e942003-10-24 19:02:03 +000013667 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013668 safi_t safi;
13669
13670 if (bgp_parse_safi(argv[0], &safi)) {
13671 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13672 return CMD_WARNING;
13673 }
paulbb46e942003-10-24 19:02:03 +000013674
13675 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13676 if (! peer)
13677 return CMD_WARNING;
13678
Lou Berger651b4022016-01-12 13:42:07 -050013679 return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
paul718e3742002-12-13 20:15:29 +000013680 bgp_show_type_neighbor);
13681}
Lou Berger205e6742016-01-12 13:42:11 -050013682
Lou Berger651b4022016-01-12 13:42:07 -050013683DEFUN (show_bgp_ipv6_safi_neighbor_routes,
13684 show_bgp_ipv6_safi_neighbor_routes_cmd,
13685 "show bgp ipv6 (multicast|unicast) neighbors (A.B.C.D|X:X::X:X) routes",
paulfee0f4c2004-09-13 05:12:46 +000013686 SHOW_STR
paulfee0f4c2004-09-13 05:12:46 +000013687 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050013688 "Address family\n"
13689 "Address Family modifier\n"
13690 "Address Family modifier\n"
13691 "Detailed information on TCP and BGP neighbor connections\n"
13692 NEIGHBOR_ADDR_STR
13693 NEIGHBOR_ADDR_STR
13694 "Display routes learned from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000013695{
paulfee0f4c2004-09-13 05:12:46 +000013696 struct peer *peer;
Lou Berger651b4022016-01-12 13:42:07 -050013697 safi_t safi;
paulfee0f4c2004-09-13 05:12:46 +000013698
Lou Berger651b4022016-01-12 13:42:07 -050013699 if (bgp_parse_safi(argv[0], &safi)) {
13700 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
13701 return CMD_WARNING;
13702 }
paulfee0f4c2004-09-13 05:12:46 +000013703
Lou Berger651b4022016-01-12 13:42:07 -050013704 peer = peer_lookup_in_view (vty, NULL, argv[1]);
paulfee0f4c2004-09-13 05:12:46 +000013705 if (! peer)
13706 return CMD_WARNING;
Lou Berger651b4022016-01-12 13:42:07 -050013707
13708 return bgp_show_neighbor_route (vty, peer, AFI_IP6, safi,
13709 bgp_show_type_neighbor);
paulfee0f4c2004-09-13 05:12:46 +000013710}
paulfee0f4c2004-09-13 05:12:46 +000013711
Michael Lambert95cbbd22010-07-23 14:43:04 -040013712DEFUN (show_bgp_view_ipv4_safi_rsclient_route,
13713 show_bgp_view_ipv4_safi_rsclient_route_cmd,
13714 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13715 SHOW_STR
13716 BGP_STR
13717 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013718 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013719 "Address family\n"
13720 "Address Family modifier\n"
13721 "Address Family modifier\n"
13722 "Information about Route Server Client\n"
13723 NEIGHBOR_ADDR_STR
13724 "Network in the BGP routing table to display\n")
13725{
13726 struct bgp *bgp;
13727 struct peer *peer;
13728 safi_t safi;
13729
13730 /* BGP structure lookup. */
13731 if (argc == 4)
13732 {
13733 bgp = bgp_lookup_by_name (argv[0]);
13734 if (bgp == NULL)
13735 {
13736 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13737 return CMD_WARNING;
13738 }
13739 }
13740 else
13741 {
13742 bgp = bgp_get_default ();
13743 if (bgp == NULL)
13744 {
13745 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13746 return CMD_WARNING;
13747 }
13748 }
13749
13750 if (argc == 4) {
13751 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13752 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13753 } else {
13754 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13755 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13756 }
13757
13758 if (! peer)
13759 return CMD_WARNING;
13760
13761 if (! peer->afc[AFI_IP][safi])
13762 {
13763 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13764 VTY_NEWLINE);
13765 return CMD_WARNING;
13766}
13767
13768 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13769 PEER_FLAG_RSERVER_CLIENT))
13770 {
13771 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13772 VTY_NEWLINE);
13773 return CMD_WARNING;
13774 }
13775
13776 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13777 (argc == 4) ? argv[3] : argv[2],
13778 AFI_IP, safi, NULL, 0);
13779}
13780
13781ALIAS (show_bgp_view_ipv4_safi_rsclient_route,
13782 show_bgp_ipv4_safi_rsclient_route_cmd,
13783 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
13784 SHOW_STR
13785 BGP_STR
13786 "Address family\n"
13787 "Address Family modifier\n"
13788 "Address Family modifier\n"
13789 "Information about Route Server Client\n"
13790 NEIGHBOR_ADDR_STR
13791 "Network in the BGP routing table to display\n")
13792
paulfee0f4c2004-09-13 05:12:46 +000013793
Michael Lambert95cbbd22010-07-23 14:43:04 -040013794DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix,
13795 show_bgp_view_ipv4_safi_rsclient_prefix_cmd,
13796 "show bgp view WORD ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13797 SHOW_STR
13798 BGP_STR
13799 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013800 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040013801 "Address family\n"
13802 "Address Family modifier\n"
13803 "Address Family modifier\n"
13804 "Information about Route Server Client\n"
13805 NEIGHBOR_ADDR_STR
13806 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13807{
13808 struct bgp *bgp;
13809 struct peer *peer;
13810 safi_t safi;
13811
13812 /* BGP structure lookup. */
13813 if (argc == 4)
13814 {
13815 bgp = bgp_lookup_by_name (argv[0]);
13816 if (bgp == NULL)
13817 {
13818 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13819 return CMD_WARNING;
13820 }
13821 }
13822 else
13823 {
13824 bgp = bgp_get_default ();
13825 if (bgp == NULL)
13826 {
13827 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13828 return CMD_WARNING;
13829 }
13830 }
13831
13832 if (argc == 4) {
13833 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
13834 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13835 } else {
13836 peer = peer_lookup_in_view (vty, NULL, argv[1]);
13837 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
13838 }
13839
13840 if (! peer)
13841 return CMD_WARNING;
13842
13843 if (! peer->afc[AFI_IP][safi])
13844 {
13845 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13846 VTY_NEWLINE);
13847 return CMD_WARNING;
13848}
13849
13850 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi],
13851 PEER_FLAG_RSERVER_CLIENT))
13852{
13853 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13854 VTY_NEWLINE);
13855 return CMD_WARNING;
13856 }
13857
13858 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][safi],
13859 (argc == 4) ? argv[3] : argv[2],
13860 AFI_IP, safi, NULL, 1);
13861}
13862
Lou Bergerf9b6c392016-01-12 13:42:09 -050013863DEFUN (show_ip_bgp_view_rsclient_prefix,
13864 show_ip_bgp_view_rsclient_prefix_cmd,
13865 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13866 SHOW_STR
13867 IP_STR
13868 BGP_STR
13869 "BGP view\n"
13870 "View name\n"
13871 "Information about Route Server Client\n"
13872 NEIGHBOR_ADDR_STR
13873 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13874{
13875 struct bgp *bgp;
13876 struct peer *peer;
13877
13878 /* BGP structure lookup. */
13879 if (argc == 3)
13880 {
13881 bgp = bgp_lookup_by_name (argv[0]);
13882 if (bgp == NULL)
13883 {
13884 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
13885 return CMD_WARNING;
13886 }
13887 }
13888 else
13889 {
13890 bgp = bgp_get_default ();
13891 if (bgp == NULL)
13892 {
13893 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
13894 return CMD_WARNING;
13895 }
13896 }
13897
13898 if (argc == 3)
13899 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13900 else
13901 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13902
13903 if (! peer)
13904 return CMD_WARNING;
13905
13906 if (! peer->afc[AFI_IP][SAFI_UNICAST])
13907 {
13908 vty_out (vty, "%% Activate the neighbor for the address family first%s",
13909 VTY_NEWLINE);
13910 return CMD_WARNING;
13911}
13912
13913 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
13914 PEER_FLAG_RSERVER_CLIENT))
13915{
13916 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
13917 VTY_NEWLINE);
13918 return CMD_WARNING;
13919 }
13920
13921 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP][SAFI_UNICAST],
13922 (argc == 3) ? argv[2] : argv[1],
13923 AFI_IP, SAFI_UNICAST, NULL, 1);
13924}
13925
13926ALIAS (show_ip_bgp_view_rsclient_prefix,
13927 show_ip_bgp_rsclient_prefix_cmd,
13928 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13929 SHOW_STR
13930 IP_STR
13931 BGP_STR
13932 "Information about Route Server Client\n"
13933 NEIGHBOR_ADDR_STR
13934 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13935
Michael Lambert95cbbd22010-07-23 14:43:04 -040013936ALIAS (show_bgp_view_ipv4_safi_rsclient_prefix,
13937 show_bgp_ipv4_safi_rsclient_prefix_cmd,
13938 "show bgp ipv4 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
13939 SHOW_STR
13940 BGP_STR
13941 "Address family\n"
13942 "Address Family modifier\n"
13943 "Address Family modifier\n"
13944 "Information about Route Server Client\n"
13945 NEIGHBOR_ADDR_STR
13946 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
paulfee0f4c2004-09-13 05:12:46 +000013947
Lou Bergerf9b6c392016-01-12 13:42:09 -050013948DEFUN (show_bgp_view_ipv6_neighbor_routes,
Lou Berger651b4022016-01-12 13:42:07 -050013949 show_bgp_view_ipv6_neighbor_routes_cmd,
13950 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
paulbb46e942003-10-24 19:02:03 +000013951 SHOW_STR
13952 BGP_STR
13953 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000013954 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050013955 "Address family\n"
paulbb46e942003-10-24 19:02:03 +000013956 "Detailed information on TCP and BGP neighbor connections\n"
13957 "Neighbor to display information about\n"
13958 "Neighbor to display information about\n"
13959 "Display routes learned from neighbor\n")
13960{
13961 struct peer *peer;
13962
13963 if (argc == 2)
13964 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13965 else
13966 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13967
13968 if (! peer)
13969 return CMD_WARNING;
13970
13971 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13972 bgp_show_type_neighbor);
13973}
13974
Lou Berger651b4022016-01-12 13:42:07 -050013975DEFUN (show_bgp_view_neighbor_damp,
Lou Bergerf9b6c392016-01-12 13:42:09 -050013976 show_bgp_view_neighbor_damp_cmd,
13977 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
13978 SHOW_STR
13979 BGP_STR
13980 "BGP view\n"
13981 "View name\n"
13982 "Detailed information on TCP and BGP neighbor connections\n"
13983 "Neighbor to display information about\n"
13984 "Neighbor to display information about\n"
13985 "Display the dampened routes received from neighbor\n")
13986{
13987 struct peer *peer;
13988
13989 if (argc == 2)
13990 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
13991 else
13992 peer = peer_lookup_in_view (vty, NULL, argv[0]);
13993
13994 if (! peer)
13995 return CMD_WARNING;
13996
13997 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
13998 bgp_show_type_damp_neighbor);
13999}
14000
14001DEFUN (show_bgp_view_ipv6_neighbor_damp,
Lou Berger651b4022016-01-12 13:42:07 -050014002 show_bgp_view_ipv6_neighbor_damp_cmd,
14003 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
paulbb46e942003-10-24 19:02:03 +000014004 SHOW_STR
14005 BGP_STR
14006 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014007 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014008 "Address family\n"
14009 "Detailed information on TCP and BGP neighbor connections\n"
14010 "Neighbor to display information about\n"
14011 "Neighbor to display information about\n"
paulbb46e942003-10-24 19:02:03 +000014012 "Display the dampened routes received from neighbor\n")
14013{
14014 struct peer *peer;
14015
14016 if (argc == 2)
14017 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14018 else
14019 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14020
14021 if (! peer)
14022 return CMD_WARNING;
14023
14024 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14025 bgp_show_type_damp_neighbor);
14026}
14027
Lou Bergerf9b6c392016-01-12 13:42:09 -050014028DEFUN (show_bgp_view_ipv6_neighbor_flap,
Lou Berger651b4022016-01-12 13:42:07 -050014029 show_bgp_view_ipv6_neighbor_flap_cmd,
14030 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
paulbb46e942003-10-24 19:02:03 +000014031 SHOW_STR
14032 BGP_STR
14033 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014034 "View name\n"
paulbb46e942003-10-24 19:02:03 +000014035 "Address family\n"
14036 "Detailed information on TCP and BGP neighbor connections\n"
14037 "Neighbor to display information about\n"
14038 "Neighbor to display information about\n"
14039 "Display the dampened routes received from neighbor\n")
paulbb46e942003-10-24 19:02:03 +000014040{
14041 struct peer *peer;
14042
14043 if (argc == 2)
14044 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14045 else
14046 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14047
14048 if (! peer)
14049 return CMD_WARNING;
14050
14051 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14052 bgp_show_type_flap_neighbor);
14053}
14054
Lou Bergerf9b6c392016-01-12 13:42:09 -050014055DEFUN (show_bgp_view_neighbor_flap,
14056 show_bgp_view_neighbor_flap_cmd,
14057 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14058 SHOW_STR
14059 BGP_STR
14060 "BGP view\n"
14061 "View name\n"
14062 "Detailed information on TCP and BGP neighbor connections\n"
14063 "Neighbor to display information about\n"
14064 "Neighbor to display information about\n"
14065 "Display flap statistics of the routes learned from neighbor\n")
14066{
14067 struct peer *peer;
14068
14069 if (argc == 2)
14070 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14071 else
14072 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14073
14074 if (! peer)
14075 return CMD_WARNING;
14076
14077 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14078 bgp_show_type_flap_neighbor);
14079}
14080
14081ALIAS (show_bgp_view_neighbor_flap,
14082 show_bgp_neighbor_flap_cmd,
14083 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14084 SHOW_STR
14085 BGP_STR
14086 "Detailed information on TCP and BGP neighbor connections\n"
14087 "Neighbor to display information about\n"
14088 "Neighbor to display information about\n"
14089 "Display flap statistics of the routes learned from neighbor\n")
14090
14091ALIAS (show_bgp_view_neighbor_damp,
14092 show_bgp_neighbor_damp_cmd,
14093 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14094 SHOW_STR
14095 BGP_STR
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 the dampened routes received from neighbor\n")
14100
14101DEFUN (show_bgp_view_neighbor_routes,
14102 show_bgp_view_neighbor_routes_cmd,
14103 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
14104 SHOW_STR
14105 BGP_STR
14106 "BGP view\n"
14107 "View name\n"
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 struct peer *peer;
14114
14115 if (argc == 2)
14116 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14117 else
14118 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14119
14120 if (! peer)
14121 return CMD_WARNING;
14122
14123 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_UNICAST,
14124 bgp_show_type_neighbor);
14125}
14126
14127ALIAS (show_bgp_view_neighbor_routes,
14128 show_bgp_neighbor_routes_cmd,
14129 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
14130 SHOW_STR
14131 BGP_STR
14132 "Detailed information on TCP and BGP neighbor connections\n"
14133 "Neighbor to display information about\n"
14134 "Neighbor to display information about\n"
14135 "Display routes learned from neighbor\n")
14136
paulbb46e942003-10-24 19:02:03 +000014137ALIAS (show_bgp_view_neighbor_routes,
paul718e3742002-12-13 20:15:29 +000014138 show_bgp_ipv6_neighbor_routes_cmd,
14139 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
14140 SHOW_STR
14141 BGP_STR
14142 "Address family\n"
14143 "Detailed information on TCP and BGP neighbor connections\n"
14144 "Neighbor to display information about\n"
14145 "Neighbor to display information about\n"
14146 "Display routes learned from neighbor\n")
14147
Lou Bergerf9b6c392016-01-12 13:42:09 -050014148/* old command */
14149ALIAS (show_bgp_view_neighbor_routes,
14150 ipv6_bgp_neighbor_routes_cmd,
14151 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
14152 SHOW_STR
14153 IPV6_STR
14154 BGP_STR
14155 "Detailed information on TCP and BGP neighbor connections\n"
14156 "Neighbor to display information about\n"
14157 "Neighbor to display information about\n"
14158 "Display routes learned from neighbor\n")
14159
14160/* old command */
14161DEFUN (ipv6_mbgp_neighbor_routes,
14162 ipv6_mbgp_neighbor_routes_cmd,
14163 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
14164 SHOW_STR
14165 IPV6_STR
14166 MBGP_STR
14167 "Detailed information on TCP and BGP neighbor connections\n"
14168 "Neighbor to display information about\n"
14169 "Neighbor to display information about\n"
14170 "Display routes learned from neighbor\n")
14171{
14172 struct peer *peer;
14173
14174 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14175 if (! peer)
14176 return CMD_WARNING;
14177
14178 return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
14179 bgp_show_type_neighbor);
14180}
14181
paulbb46e942003-10-24 19:02:03 +000014182ALIAS (show_bgp_view_neighbor_flap,
14183 show_bgp_ipv6_neighbor_flap_cmd,
14184 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
14185 SHOW_STR
14186 BGP_STR
14187 "Address family\n"
14188 "Detailed information on TCP and BGP neighbor connections\n"
14189 "Neighbor to display information about\n"
14190 "Neighbor to display information about\n"
14191 "Display flap statistics of the routes learned from neighbor\n")
14192
14193ALIAS (show_bgp_view_neighbor_damp,
paulbb46e942003-10-24 19:02:03 +000014194 show_bgp_ipv6_neighbor_damp_cmd,
14195 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
14196 SHOW_STR
14197 BGP_STR
14198 "Address family\n"
14199 "Detailed information on TCP and BGP neighbor connections\n"
14200 "Neighbor to display information about\n"
14201 "Neighbor to display information about\n"
paulc001ae62003-11-03 12:37:43 +000014202 "Display the dampened routes received from neighbor\n")
paulfee0f4c2004-09-13 05:12:46 +000014203
Lou Bergerf9b6c392016-01-12 13:42:09 -050014204DEFUN (show_bgp_view_rsclient,
14205 show_bgp_view_rsclient_cmd,
14206 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
14207 SHOW_STR
14208 BGP_STR
14209 "BGP view\n"
14210 "View name\n"
14211 "Information about Route Server Client\n"
14212 NEIGHBOR_ADDR_STR)
14213{
14214 struct bgp_table *table;
14215 struct peer *peer;
14216
14217 if (argc == 2)
14218 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14219 else
14220 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14221
14222 if (! peer)
14223 return CMD_WARNING;
14224
14225 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14226 {
14227 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14228 VTY_NEWLINE);
14229 return CMD_WARNING;
14230 }
14231
14232 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14233 PEER_FLAG_RSERVER_CLIENT))
14234 {
14235 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14236 VTY_NEWLINE);
14237 return CMD_WARNING;
14238 }
14239
14240 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14241
14242 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14243}
14244
14245ALIAS (show_bgp_view_rsclient,
14246 show_bgp_rsclient_cmd,
14247 "show bgp rsclient (A.B.C.D|X:X::X:X)",
14248 SHOW_STR
14249 BGP_STR
14250 "Information about Route Server Client\n"
14251 NEIGHBOR_ADDR_STR)
14252
Lou Berger651b4022016-01-12 13:42:07 -050014253DEFUN (show_bgp_view_ipv4_rsclient,
14254 show_bgp_view_ipv4_rsclient_cmd,
14255 "show bgp view WORD ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014256 SHOW_STR
14257 BGP_STR
14258 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014259 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014260 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014261 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014262 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014263{
Lou Berger651b4022016-01-12 13:42:07 -050014264 struct bgp_table *table;
14265 struct peer *peer;
14266
14267 if (argc == 2)
14268 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14269 else
14270 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14271
14272 if (! peer)
14273 return CMD_WARNING;
14274
14275 if (! peer->afc[AFI_IP][SAFI_UNICAST])
14276 {
14277 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14278 VTY_NEWLINE);
14279 return CMD_WARNING;
14280 }
14281
14282 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][SAFI_UNICAST],
14283 PEER_FLAG_RSERVER_CLIENT))
14284 {
14285 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14286 VTY_NEWLINE);
14287 return CMD_WARNING;
14288 }
14289
14290 table = peer->rib[AFI_IP][SAFI_UNICAST];
14291
14292 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14293}
14294DEFUN (show_bgp_view_ipv6_rsclient,
14295 show_bgp_view_ipv6_rsclient_cmd,
14296 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X)",
14297 SHOW_STR
14298 BGP_STR
14299 "BGP view\n"
14300 "BGP view name\n"
14301 "Address Family\n"
14302 "Information about Route Server Client\n"
14303 NEIGHBOR_ADDR_STR2)
14304{
14305 struct bgp_table *table;
14306 struct peer *peer;
paulfee0f4c2004-09-13 05:12:46 +000014307
14308 if (argc == 2)
14309 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14310 else
14311 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14312
14313 if (! peer)
14314 return CMD_WARNING;
14315
14316 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14317 {
14318 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14319 VTY_NEWLINE);
14320 return CMD_WARNING;
14321 }
14322
14323 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14324 PEER_FLAG_RSERVER_CLIENT))
14325 {
14326 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14327 VTY_NEWLINE);
14328 return CMD_WARNING;
14329 }
14330
14331 table = peer->rib[AFI_IP6][SAFI_UNICAST];
14332
ajs5a646652004-11-05 01:25:55 +000014333 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
paulfee0f4c2004-09-13 05:12:46 +000014334}
14335
Lou Berger651b4022016-01-12 13:42:07 -050014336ALIAS (show_bgp_view_ipv4_rsclient,
14337 show_bgp_ipv4_rsclient_cmd,
14338 "show bgp ipv4 rsclient (A.B.C.D|X:X::X:X)",
paulfee0f4c2004-09-13 05:12:46 +000014339 SHOW_STR
14340 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014341 "Address Family\n"
paulfee0f4c2004-09-13 05:12:46 +000014342 "Information about Route Server Client\n"
Lou Berger651b4022016-01-12 13:42:07 -050014343 NEIGHBOR_ADDR_STR2)
14344
Lou Berger651b4022016-01-12 13:42:07 -050014345ALIAS (show_bgp_view_ipv6_rsclient,
14346 show_bgp_ipv6_rsclient_cmd,
14347 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X)",
14348 SHOW_STR
14349 BGP_STR
14350 "Address Family\n"
14351 "Information about Route Server Client\n"
14352 NEIGHBOR_ADDR_STR2)
paulfee0f4c2004-09-13 05:12:46 +000014353
Michael Lambert95cbbd22010-07-23 14:43:04 -040014354DEFUN (show_bgp_view_ipv6_safi_rsclient,
14355 show_bgp_view_ipv6_safi_rsclient_cmd,
14356 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14357 SHOW_STR
14358 BGP_STR
14359 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014360 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014361 "Address family\n"
14362 "Address Family modifier\n"
14363 "Address Family modifier\n"
14364 "Information about Route Server Client\n"
14365 NEIGHBOR_ADDR_STR)
14366{
14367 struct bgp_table *table;
14368 struct peer *peer;
14369 safi_t safi;
14370
14371 if (argc == 3) {
14372 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14373 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14374 } else {
14375 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14376 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14377 }
14378
14379 if (! peer)
14380 return CMD_WARNING;
14381
14382 if (! peer->afc[AFI_IP6][safi])
14383 {
14384 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14385 VTY_NEWLINE);
14386 return CMD_WARNING;
14387 }
14388
14389 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14390 PEER_FLAG_RSERVER_CLIENT))
14391 {
14392 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14393 VTY_NEWLINE);
14394 return CMD_WARNING;
14395 }
14396
14397 table = peer->rib[AFI_IP6][safi];
14398
14399 return bgp_show_table (vty, table, &peer->remote_id, bgp_show_type_normal, NULL);
14400}
14401
14402ALIAS (show_bgp_view_ipv6_safi_rsclient,
14403 show_bgp_ipv6_safi_rsclient_cmd,
14404 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X)",
14405 SHOW_STR
14406 BGP_STR
14407 "Address family\n"
14408 "Address Family modifier\n"
14409 "Address Family modifier\n"
14410 "Information about Route Server Client\n"
14411 NEIGHBOR_ADDR_STR)
14412
paulfee0f4c2004-09-13 05:12:46 +000014413DEFUN (show_bgp_view_rsclient_route,
14414 show_bgp_view_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014415 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14416 SHOW_STR
14417 BGP_STR
14418 "BGP view\n"
14419 "View name\n"
14420 "Information about Route Server Client\n"
14421 NEIGHBOR_ADDR_STR
14422 "Network in the BGP routing table to display\n")
14423{
14424 struct bgp *bgp;
14425 struct peer *peer;
14426
14427 /* BGP structure lookup. */
14428 if (argc == 3)
14429 {
14430 bgp = bgp_lookup_by_name (argv[0]);
14431 if (bgp == NULL)
14432 {
14433 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14434 return CMD_WARNING;
14435 }
14436 }
14437 else
14438 {
14439 bgp = bgp_get_default ();
14440 if (bgp == NULL)
14441 {
14442 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14443 return CMD_WARNING;
14444 }
14445 }
14446
14447 if (argc == 3)
14448 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14449 else
14450 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14451
14452 if (! peer)
14453 return CMD_WARNING;
14454
14455 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14456 {
14457 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14458 VTY_NEWLINE);
14459 return CMD_WARNING;
14460 }
14461
14462 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14463 PEER_FLAG_RSERVER_CLIENT))
14464 {
14465 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14466 VTY_NEWLINE);
14467 return CMD_WARNING;
14468 }
14469
14470 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14471 (argc == 3) ? argv[2] : argv[1],
14472 AFI_IP6, SAFI_UNICAST, NULL, 0);
14473}
14474
14475DEFUN (show_bgp_view_ipv6_rsclient_route,
14476 show_bgp_view_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014477 "show bgp view WORD ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014478 SHOW_STR
14479 BGP_STR
14480 "BGP view\n"
Lou Berger651b4022016-01-12 13:42:07 -050014481 "BGP view name\n"
14482 "IP6_STR"
paulfee0f4c2004-09-13 05:12:46 +000014483 "Information about Route Server Client\n"
14484 NEIGHBOR_ADDR_STR
14485 "Network in the BGP routing table to display\n")
14486{
14487 struct bgp *bgp;
14488 struct peer *peer;
14489
14490 /* BGP structure lookup. */
14491 if (argc == 3)
14492 {
14493 bgp = bgp_lookup_by_name (argv[0]);
14494 if (bgp == NULL)
14495 {
14496 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14497 return CMD_WARNING;
14498 }
14499 }
14500 else
14501 {
14502 bgp = bgp_get_default ();
14503 if (bgp == NULL)
14504 {
14505 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14506 return CMD_WARNING;
14507 }
14508 }
14509
14510 if (argc == 3)
14511 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14512 else
14513 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14514
14515 if (! peer)
14516 return CMD_WARNING;
14517
14518 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14519 {
14520 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14521 VTY_NEWLINE);
14522 return CMD_WARNING;
14523 }
14524
14525 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14526 PEER_FLAG_RSERVER_CLIENT))
14527 {
14528 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14529 VTY_NEWLINE);
14530 return CMD_WARNING;
14531 }
14532
14533 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14534 (argc == 3) ? argv[2] : argv[1],
14535 AFI_IP6, SAFI_UNICAST, NULL, 0);
14536}
14537
Lou Bergerf9b6c392016-01-12 13:42:09 -050014538ALIAS (show_bgp_view_ipv6_rsclient_route,
paulfee0f4c2004-09-13 05:12:46 +000014539 show_bgp_rsclient_route_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014540 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14541 SHOW_STR
14542 BGP_STR
14543 "Information about Route Server Client\n"
14544 NEIGHBOR_ADDR_STR
14545 "Network in the BGP routing table to display\n")
14546
14547ALIAS (show_bgp_view_ipv6_rsclient_route,
14548 show_bgp_ipv6_rsclient_route_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014549 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
paulfee0f4c2004-09-13 05:12:46 +000014550 SHOW_STR
14551 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050014552 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014553 "Information about Route Server Client\n"
14554 NEIGHBOR_ADDR_STR
14555 "Network in the BGP routing table to display\n")
14556
Michael Lambert95cbbd22010-07-23 14:43:04 -040014557DEFUN (show_bgp_view_ipv6_safi_rsclient_route,
14558 show_bgp_view_ipv6_safi_rsclient_route_cmd,
14559 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14560 SHOW_STR
14561 BGP_STR
14562 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014563 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014564 "Address family\n"
14565 "Address Family modifier\n"
14566 "Address Family modifier\n"
14567 "Information about Route Server Client\n"
14568 NEIGHBOR_ADDR_STR
14569 "Network in the BGP routing table to display\n")
14570{
14571 struct bgp *bgp;
14572 struct peer *peer;
14573 safi_t safi;
14574
14575 /* BGP structure lookup. */
14576 if (argc == 4)
14577 {
14578 bgp = bgp_lookup_by_name (argv[0]);
14579 if (bgp == NULL)
14580 {
14581 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14582 return CMD_WARNING;
14583 }
14584 }
14585 else
14586 {
14587 bgp = bgp_get_default ();
14588 if (bgp == NULL)
14589 {
14590 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14591 return CMD_WARNING;
14592 }
14593 }
14594
14595 if (argc == 4) {
14596 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14597 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14598 } else {
14599 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14600 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14601 }
14602
14603 if (! peer)
14604 return CMD_WARNING;
14605
14606 if (! peer->afc[AFI_IP6][safi])
14607 {
14608 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14609 VTY_NEWLINE);
14610 return CMD_WARNING;
14611}
14612
14613 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14614 PEER_FLAG_RSERVER_CLIENT))
14615 {
14616 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14617 VTY_NEWLINE);
14618 return CMD_WARNING;
14619 }
14620
14621 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14622 (argc == 4) ? argv[3] : argv[2],
14623 AFI_IP6, safi, NULL, 0);
14624}
14625
14626ALIAS (show_bgp_view_ipv6_safi_rsclient_route,
14627 show_bgp_ipv6_safi_rsclient_route_cmd,
14628 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
14629 SHOW_STR
14630 BGP_STR
14631 "Address family\n"
14632 "Address Family modifier\n"
14633 "Address Family modifier\n"
14634 "Information about Route Server Client\n"
14635 NEIGHBOR_ADDR_STR
14636 "Network in the BGP routing table to display\n")
14637
Lou Berger651b4022016-01-12 13:42:07 -050014638
paulfee0f4c2004-09-13 05:12:46 +000014639DEFUN (show_bgp_view_rsclient_prefix,
14640 show_bgp_view_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014641 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14642 SHOW_STR
14643 BGP_STR
14644 "BGP view\n"
14645 "View name\n"
14646 "Information about Route Server Client\n"
14647 NEIGHBOR_ADDR_STR
14648 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14649{
14650 struct bgp *bgp;
14651 struct peer *peer;
14652
14653 /* BGP structure lookup. */
14654 if (argc == 3)
14655 {
14656 bgp = bgp_lookup_by_name (argv[0]);
14657 if (bgp == NULL)
14658 {
14659 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14660 return CMD_WARNING;
14661 }
14662 }
14663 else
14664 {
14665 bgp = bgp_get_default ();
14666 if (bgp == NULL)
14667 {
14668 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14669 return CMD_WARNING;
14670 }
14671 }
14672
14673 if (argc == 3)
14674 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14675 else
14676 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14677
14678 if (! peer)
14679 return CMD_WARNING;
14680
14681 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14682 {
14683 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14684 VTY_NEWLINE);
14685 return CMD_WARNING;
14686 }
14687
14688 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14689 PEER_FLAG_RSERVER_CLIENT))
14690 {
14691 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14692 VTY_NEWLINE);
14693 return CMD_WARNING;
14694 }
14695
14696 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14697 (argc == 3) ? argv[2] : argv[1],
14698 AFI_IP6, SAFI_UNICAST, NULL, 1);
14699}
14700
14701DEFUN (show_bgp_view_ipv6_rsclient_prefix,
14702 show_bgp_view_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014703 "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 +000014704 SHOW_STR
14705 BGP_STR
14706 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014707 "View name\n"
Lou Berger651b4022016-01-12 13:42:07 -050014708 IP6_STR
paulfee0f4c2004-09-13 05:12:46 +000014709 "Information about Route Server Client\n"
14710 NEIGHBOR_ADDR_STR
14711 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14712{
14713 struct bgp *bgp;
14714 struct peer *peer;
14715
14716 /* BGP structure lookup. */
14717 if (argc == 3)
14718 {
14719 bgp = bgp_lookup_by_name (argv[0]);
14720 if (bgp == NULL)
14721 {
14722 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14723 return CMD_WARNING;
14724 }
14725 }
14726 else
14727 {
14728 bgp = bgp_get_default ();
14729 if (bgp == NULL)
14730 {
14731 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14732 return CMD_WARNING;
14733 }
14734 }
14735
14736 if (argc == 3)
14737 peer = peer_lookup_in_view (vty, argv[0], argv[1]);
14738 else
14739 peer = peer_lookup_in_view (vty, NULL, argv[0]);
14740
14741 if (! peer)
14742 return CMD_WARNING;
14743
14744 if (! peer->afc[AFI_IP6][SAFI_UNICAST])
14745 {
14746 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14747 VTY_NEWLINE);
14748 return CMD_WARNING;
14749 }
14750
14751 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][SAFI_UNICAST],
14752 PEER_FLAG_RSERVER_CLIENT))
14753 {
14754 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14755 VTY_NEWLINE);
14756 return CMD_WARNING;
14757 }
14758
14759 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][SAFI_UNICAST],
14760 (argc == 3) ? argv[2] : argv[1],
14761 AFI_IP6, SAFI_UNICAST, NULL, 1);
14762}
14763
Lou Bergerf9b6c392016-01-12 13:42:09 -050014764ALIAS (show_bgp_view_ipv6_rsclient_prefix,
paulfee0f4c2004-09-13 05:12:46 +000014765 show_bgp_rsclient_prefix_cmd,
Lou Bergerf9b6c392016-01-12 13:42:09 -050014766 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14767 SHOW_STR
14768 BGP_STR
14769 "Information about Route Server Client\n"
14770 NEIGHBOR_ADDR_STR
14771 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14772
14773ALIAS (show_bgp_view_ipv6_rsclient_prefix,
14774 show_bgp_ipv6_rsclient_prefix_cmd,
Lou Berger651b4022016-01-12 13:42:07 -050014775 "show bgp ipv6 rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
paulfee0f4c2004-09-13 05:12:46 +000014776 SHOW_STR
14777 BGP_STR
14778 "Information about Route Server Client\n"
14779 NEIGHBOR_ADDR_STR
14780 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
14781
Michael Lambert95cbbd22010-07-23 14:43:04 -040014782DEFUN (show_bgp_view_ipv6_safi_rsclient_prefix,
14783 show_bgp_view_ipv6_safi_rsclient_prefix_cmd,
14784 "show bgp view WORD ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14785 SHOW_STR
14786 BGP_STR
14787 "BGP view\n"
Christian Franke2b005152013-09-30 12:27:49 +000014788 "View name\n"
Michael Lambert95cbbd22010-07-23 14:43:04 -040014789 "Address family\n"
14790 "Address Family modifier\n"
14791 "Address Family modifier\n"
14792 "Information about Route Server Client\n"
14793 NEIGHBOR_ADDR_STR
14794 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14795{
14796 struct bgp *bgp;
14797 struct peer *peer;
14798 safi_t safi;
14799
14800 /* BGP structure lookup. */
14801 if (argc == 4)
14802 {
14803 bgp = bgp_lookup_by_name (argv[0]);
14804 if (bgp == NULL)
14805 {
14806 vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
14807 return CMD_WARNING;
14808 }
14809 }
14810 else
14811 {
14812 bgp = bgp_get_default ();
14813 if (bgp == NULL)
14814 {
14815 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
14816 return CMD_WARNING;
14817 }
14818 }
14819
14820 if (argc == 4) {
14821 peer = peer_lookup_in_view (vty, argv[0], argv[2]);
14822 safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14823 } else {
14824 peer = peer_lookup_in_view (vty, NULL, argv[1]);
14825 safi = (strncmp (argv[0], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
14826 }
14827
14828 if (! peer)
14829 return CMD_WARNING;
14830
14831 if (! peer->afc[AFI_IP6][safi])
14832 {
14833 vty_out (vty, "%% Activate the neighbor for the address family first%s",
14834 VTY_NEWLINE);
14835 return CMD_WARNING;
14836}
14837
14838 if ( ! CHECK_FLAG (peer->af_flags[AFI_IP6][safi],
14839 PEER_FLAG_RSERVER_CLIENT))
14840{
14841 vty_out (vty, "%% Neighbor is not a Route-Server client%s",
14842 VTY_NEWLINE);
14843 return CMD_WARNING;
14844 }
14845
14846 return bgp_show_route_in_table (vty, bgp, peer->rib[AFI_IP6][safi],
14847 (argc == 4) ? argv[3] : argv[2],
14848 AFI_IP6, safi, NULL, 1);
14849}
14850
14851ALIAS (show_bgp_view_ipv6_safi_rsclient_prefix,
14852 show_bgp_ipv6_safi_rsclient_prefix_cmd,
14853 "show bgp ipv6 (unicast|multicast) rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
14854 SHOW_STR
14855 BGP_STR
14856 "Address family\n"
14857 "Address Family modifier\n"
14858 "Address Family modifier\n"
14859 "Information about Route Server Client\n"
14860 NEIGHBOR_ADDR_STR
14861 "IP prefix <network>/<length>, e.g., 3ffe::/16\n")
14862
paul718e3742002-12-13 20:15:29 +000014863struct bgp_table *bgp_distance_table;
14864
14865struct bgp_distance
14866{
14867 /* Distance value for the IP source prefix. */
14868 u_char distance;
14869
14870 /* Name of the access-list to be matched. */
14871 char *access_list;
14872};
14873
paul94f2b392005-06-28 12:44:16 +000014874static struct bgp_distance *
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080014875bgp_distance_new (void)
paul718e3742002-12-13 20:15:29 +000014876{
Stephen Hemminger393deb92008-08-18 14:13:29 -070014877 return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
paul718e3742002-12-13 20:15:29 +000014878}
14879
paul94f2b392005-06-28 12:44:16 +000014880static void
paul718e3742002-12-13 20:15:29 +000014881bgp_distance_free (struct bgp_distance *bdistance)
14882{
14883 XFREE (MTYPE_BGP_DISTANCE, bdistance);
14884}
14885
paul94f2b392005-06-28 12:44:16 +000014886static int
paulfd79ac92004-10-13 05:06:08 +000014887bgp_distance_set (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 /* Get BGP distance node. */
14906 rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
14907 if (rn->info)
14908 {
14909 bdistance = rn->info;
14910 bgp_unlock_node (rn);
14911 }
14912 else
14913 {
14914 bdistance = bgp_distance_new ();
14915 rn->info = bdistance;
14916 }
14917
14918 /* Set distance value. */
14919 bdistance->distance = distance;
14920
14921 /* Reset access-list configuration. */
14922 if (bdistance->access_list)
14923 {
14924 free (bdistance->access_list);
14925 bdistance->access_list = NULL;
14926 }
14927 if (access_list_str)
14928 bdistance->access_list = strdup (access_list_str);
14929
14930 return CMD_SUCCESS;
14931}
14932
paul94f2b392005-06-28 12:44:16 +000014933static int
paulfd79ac92004-10-13 05:06:08 +000014934bgp_distance_unset (struct vty *vty, const char *distance_str,
14935 const char *ip_str, const char *access_list_str)
paul718e3742002-12-13 20:15:29 +000014936{
14937 int ret;
14938 struct prefix_ipv4 p;
14939 u_char distance;
14940 struct bgp_node *rn;
14941 struct bgp_distance *bdistance;
14942
14943 ret = str2prefix_ipv4 (ip_str, &p);
14944 if (ret == 0)
14945 {
14946 vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
14947 return CMD_WARNING;
14948 }
14949
14950 distance = atoi (distance_str);
14951
14952 rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
14953 if (! rn)
14954 {
14955 vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
14956 return CMD_WARNING;
14957 }
14958
14959 bdistance = rn->info;
Paul Jakma7aa9dce2014-09-19 14:42:23 +010014960
14961 if (bdistance->distance != distance)
14962 {
14963 vty_out (vty, "Distance does not match configured%s", VTY_NEWLINE);
14964 return CMD_WARNING;
14965 }
14966
paul718e3742002-12-13 20:15:29 +000014967 if (bdistance->access_list)
14968 free (bdistance->access_list);
14969 bgp_distance_free (bdistance);
14970
14971 rn->info = NULL;
14972 bgp_unlock_node (rn);
14973 bgp_unlock_node (rn);
14974
14975 return CMD_SUCCESS;
14976}
14977
paul718e3742002-12-13 20:15:29 +000014978/* Apply BGP information to distance method. */
14979u_char
14980bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
14981{
14982 struct bgp_node *rn;
14983 struct prefix_ipv4 q;
14984 struct peer *peer;
14985 struct bgp_distance *bdistance;
14986 struct access_list *alist;
14987 struct bgp_static *bgp_static;
14988
14989 if (! bgp)
14990 return 0;
14991
14992 if (p->family != AF_INET)
14993 return 0;
14994
14995 peer = rinfo->peer;
14996
14997 if (peer->su.sa.sa_family != AF_INET)
14998 return 0;
14999
15000 memset (&q, 0, sizeof (struct prefix_ipv4));
15001 q.family = AF_INET;
15002 q.prefix = peer->su.sin.sin_addr;
15003 q.prefixlen = IPV4_MAX_BITLEN;
15004
15005 /* Check source address. */
15006 rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
15007 if (rn)
15008 {
15009 bdistance = rn->info;
15010 bgp_unlock_node (rn);
15011
15012 if (bdistance->access_list)
15013 {
15014 alist = access_list_lookup (AFI_IP, bdistance->access_list);
15015 if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
15016 return bdistance->distance;
15017 }
15018 else
15019 return bdistance->distance;
15020 }
15021
15022 /* Backdoor check. */
15023 rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
15024 if (rn)
15025 {
15026 bgp_static = rn->info;
15027 bgp_unlock_node (rn);
15028
15029 if (bgp_static->backdoor)
15030 {
15031 if (bgp->distance_local)
15032 return bgp->distance_local;
15033 else
15034 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15035 }
15036 }
15037
Jorge Boncompte [DTI2]6d85b152012-05-07 16:52:54 +000015038 if (peer->sort == BGP_PEER_EBGP)
paul718e3742002-12-13 20:15:29 +000015039 {
15040 if (bgp->distance_ebgp)
15041 return bgp->distance_ebgp;
15042 return ZEBRA_EBGP_DISTANCE_DEFAULT;
15043 }
15044 else
15045 {
15046 if (bgp->distance_ibgp)
15047 return bgp->distance_ibgp;
15048 return ZEBRA_IBGP_DISTANCE_DEFAULT;
15049 }
15050}
15051
15052DEFUN (bgp_distance,
15053 bgp_distance_cmd,
15054 "distance bgp <1-255> <1-255> <1-255>",
15055 "Define an administrative distance\n"
15056 "BGP distance\n"
15057 "Distance for routes external to the AS\n"
15058 "Distance for routes internal to the AS\n"
15059 "Distance for local routes\n")
15060{
15061 struct bgp *bgp;
15062
15063 bgp = vty->index;
15064
15065 bgp->distance_ebgp = atoi (argv[0]);
15066 bgp->distance_ibgp = atoi (argv[1]);
15067 bgp->distance_local = atoi (argv[2]);
15068 return CMD_SUCCESS;
15069}
15070
15071DEFUN (no_bgp_distance,
15072 no_bgp_distance_cmd,
15073 "no distance bgp <1-255> <1-255> <1-255>",
15074 NO_STR
15075 "Define an administrative distance\n"
15076 "BGP distance\n"
15077 "Distance for routes external to the AS\n"
15078 "Distance for routes internal to the AS\n"
15079 "Distance for local routes\n")
15080{
15081 struct bgp *bgp;
15082
15083 bgp = vty->index;
15084
15085 bgp->distance_ebgp= 0;
15086 bgp->distance_ibgp = 0;
15087 bgp->distance_local = 0;
15088 return CMD_SUCCESS;
15089}
15090
15091ALIAS (no_bgp_distance,
15092 no_bgp_distance2_cmd,
15093 "no distance bgp",
15094 NO_STR
15095 "Define an administrative distance\n"
15096 "BGP distance\n")
15097
15098DEFUN (bgp_distance_source,
15099 bgp_distance_source_cmd,
15100 "distance <1-255> A.B.C.D/M",
15101 "Define an administrative distance\n"
15102 "Administrative distance\n"
15103 "IP source prefix\n")
15104{
15105 bgp_distance_set (vty, argv[0], argv[1], NULL);
15106 return CMD_SUCCESS;
15107}
15108
15109DEFUN (no_bgp_distance_source,
15110 no_bgp_distance_source_cmd,
15111 "no distance <1-255> A.B.C.D/M",
15112 NO_STR
15113 "Define an administrative distance\n"
15114 "Administrative distance\n"
15115 "IP source prefix\n")
15116{
15117 bgp_distance_unset (vty, argv[0], argv[1], NULL);
15118 return CMD_SUCCESS;
15119}
15120
15121DEFUN (bgp_distance_source_access_list,
15122 bgp_distance_source_access_list_cmd,
15123 "distance <1-255> A.B.C.D/M WORD",
15124 "Define an administrative distance\n"
15125 "Administrative distance\n"
15126 "IP source prefix\n"
15127 "Access list name\n")
15128{
15129 bgp_distance_set (vty, argv[0], argv[1], argv[2]);
15130 return CMD_SUCCESS;
15131}
15132
15133DEFUN (no_bgp_distance_source_access_list,
15134 no_bgp_distance_source_access_list_cmd,
15135 "no distance <1-255> A.B.C.D/M WORD",
15136 NO_STR
15137 "Define an administrative distance\n"
15138 "Administrative distance\n"
15139 "IP source prefix\n"
15140 "Access list name\n")
15141{
15142 bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
15143 return CMD_SUCCESS;
15144}
David Lamparter6b0655a2014-06-04 06:53:35 +020015145
paul718e3742002-12-13 20:15:29 +000015146DEFUN (bgp_damp_set,
15147 bgp_damp_set_cmd,
15148 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15149 "BGP Specific commands\n"
15150 "Enable route-flap dampening\n"
15151 "Half-life time for the penalty\n"
15152 "Value to start reusing a route\n"
15153 "Value to start suppressing a route\n"
15154 "Maximum duration to suppress a stable route\n")
15155{
15156 struct bgp *bgp;
15157 int half = DEFAULT_HALF_LIFE * 60;
15158 int reuse = DEFAULT_REUSE;
15159 int suppress = DEFAULT_SUPPRESS;
15160 int max = 4 * half;
15161
15162 if (argc == 4)
15163 {
15164 half = atoi (argv[0]) * 60;
15165 reuse = atoi (argv[1]);
15166 suppress = atoi (argv[2]);
15167 max = atoi (argv[3]) * 60;
15168 }
15169 else if (argc == 1)
15170 {
15171 half = atoi (argv[0]) * 60;
15172 max = 4 * half;
15173 }
15174
15175 bgp = vty->index;
Balajiaa7dbb12015-03-16 16:55:26 +000015176
15177 if (suppress < reuse)
15178 {
15179 vty_out (vty, "Suppress value cannot be less than reuse value %s",
15180 VTY_NEWLINE);
15181 return 0;
15182 }
15183
paul718e3742002-12-13 20:15:29 +000015184 return bgp_damp_enable (bgp, bgp_node_afi (vty), bgp_node_safi (vty),
15185 half, reuse, suppress, max);
15186}
15187
15188ALIAS (bgp_damp_set,
15189 bgp_damp_set2_cmd,
15190 "bgp dampening <1-45>",
15191 "BGP Specific commands\n"
15192 "Enable route-flap dampening\n"
15193 "Half-life time for the penalty\n")
15194
15195ALIAS (bgp_damp_set,
15196 bgp_damp_set3_cmd,
15197 "bgp dampening",
15198 "BGP Specific commands\n"
15199 "Enable route-flap dampening\n")
15200
15201DEFUN (bgp_damp_unset,
15202 bgp_damp_unset_cmd,
15203 "no bgp dampening",
15204 NO_STR
15205 "BGP Specific commands\n"
15206 "Enable route-flap dampening\n")
15207{
15208 struct bgp *bgp;
15209
15210 bgp = vty->index;
15211 return bgp_damp_disable (bgp, bgp_node_afi (vty), bgp_node_safi (vty));
15212}
15213
15214ALIAS (bgp_damp_unset,
15215 bgp_damp_unset2_cmd,
15216 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
15217 NO_STR
15218 "BGP Specific commands\n"
15219 "Enable route-flap dampening\n"
15220 "Half-life time for the penalty\n"
15221 "Value to start reusing a route\n"
15222 "Value to start suppressing a route\n"
15223 "Maximum duration to suppress a stable route\n")
15224
Lou Bergerf9b6c392016-01-12 13:42:09 -050015225DEFUN (show_ip_bgp_dampened_paths,
15226 show_ip_bgp_dampened_paths_cmd,
15227 "show ip bgp dampened-paths",
15228 SHOW_STR
15229 IP_STR
15230 BGP_STR
15231 "Display paths suppressed due to dampening\n")
15232{
15233 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_dampend_paths,
15234 NULL);
15235}
15236
15237ALIAS (show_ip_bgp_dampened_paths,
15238 show_ip_bgp_damp_dampened_paths_cmd,
15239 "show ip bgp dampening dampened-paths",
15240 SHOW_STR
15241 IP_STR
15242 BGP_STR
15243 "Display detailed information about dampening\n"
15244 "Display paths suppressed due to dampening\n")
15245
15246DEFUN (show_ip_bgp_flap_statistics,
15247 show_ip_bgp_flap_statistics_cmd,
15248 "show ip bgp flap-statistics",
15249 SHOW_STR
15250 IP_STR
15251 BGP_STR
15252 "Display flap statistics of routes\n")
15253{
15254 return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
15255 bgp_show_type_flap_statistics, NULL);
15256}
15257
15258ALIAS (show_ip_bgp_flap_statistics,
15259 show_ip_bgp_damp_flap_statistics_cmd,
15260 "show ip bgp dampening flap-statistics",
15261 SHOW_STR
15262 IP_STR
15263 BGP_STR
15264 "Display detailed information about dampening\n"
15265 "Display flap statistics of routes\n")
15266
Lou Berger651b4022016-01-12 13:42:07 -050015267DEFUN (show_bgp_ipv4_safi_dampened_paths,
15268 show_bgp_ipv4_safi_dampened_paths_cmd,
15269 "show bgp ipv4 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015270 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015271 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015272 IP_STR
15273 "Address Family modifier\n"
15274 "Address Family modifier\n"
15275 "Address Family modifier\n"
15276 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015277 "Display paths suppressed due to dampening\n")
15278{
Lou Berger651b4022016-01-12 13:42:07 -050015279 safi_t safi;
paul718e3742002-12-13 20:15:29 +000015280
Lou Berger651b4022016-01-12 13:42:07 -050015281 if (bgp_parse_safi(argv[0], &safi)) {
15282 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15283 return CMD_WARNING;
15284 }
15285
15286 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL);
15287}
15288ALIAS (show_bgp_ipv4_safi_dampened_paths,
15289 show_bgp_ipv4_safi_damp_dampened_paths_cmd,
15290 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening dampened-paths",
Balaji3921cc52015-05-16 23:12:17 +053015291 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015292 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015293 IP_STR
15294 "Address Family modifier\n"
15295 "Address Family modifier\n"
15296 "Address Family modifier\n"
15297 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015298 "Display detailed information about dampening\n"
15299 "Display paths suppressed due to dampening\n")
Lou Berger205e6742016-01-12 13:42:11 -050015300
Lou Berger651b4022016-01-12 13:42:07 -050015301DEFUN (show_bgp_ipv6_safi_dampened_paths,
15302 show_bgp_ipv6_safi_dampened_paths_cmd,
15303 "show bgp ipv6 (encap|multicast|unicast|vpn) dampened-paths",
paul718e3742002-12-13 20:15:29 +000015304 SHOW_STR
paul718e3742002-12-13 20:15:29 +000015305 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015306 IPV6_STR
15307 "Address Family modifier\n"
15308 "Address Family modifier\n"
15309 "Address Family modifier\n"
15310 "Address Family modifier\n"
15311 "Display paths suppressed due to dampening\n")
15312{
15313 safi_t safi;
15314
15315 if (bgp_parse_safi(argv[0], &safi)) {
15316 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15317 return CMD_WARNING;
15318 }
15319
15320 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_dampend_paths, NULL);
15321}
15322ALIAS (show_bgp_ipv6_safi_dampened_paths,
15323 show_bgp_ipv6_safi_damp_dampened_paths_cmd,
15324 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening dampened-paths",
15325 SHOW_STR
15326 BGP_STR
15327 IPV6_STR
15328 "Address Family modifier\n"
15329 "Address Family modifier\n"
15330 "Address Family modifier\n"
15331 "Address Family modifier\n"
15332 "Display detailed information about dampening\n"
15333 "Display paths suppressed due to dampening\n")
Lou Berger651b4022016-01-12 13:42:07 -050015334
15335DEFUN (show_bgp_ipv4_safi_flap_statistics,
15336 show_bgp_ipv4_safi_flap_statistics_cmd,
15337 "show bgp ipv4 (encap|multicast|unicast|vpn) flap-statistics",
15338 SHOW_STR
15339 BGP_STR
15340 "Address Family\n"
15341 "Address Family modifier\n"
15342 "Address Family modifier\n"
15343 "Address Family modifier\n"
15344 "Address Family modifier\n"
paul718e3742002-12-13 20:15:29 +000015345 "Display flap statistics of routes\n")
15346{
Lou Berger651b4022016-01-12 13:42:07 -050015347 safi_t safi;
David Lamparter6b0655a2014-06-04 06:53:35 +020015348
Lou Berger651b4022016-01-12 13:42:07 -050015349 if (bgp_parse_safi(argv[0], &safi)) {
15350 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15351 return CMD_WARNING;
15352 }
15353
15354 return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL);
15355}
15356ALIAS (show_bgp_ipv4_safi_flap_statistics,
15357 show_bgp_ipv4_safi_damp_flap_statistics_cmd,
15358 "show bgp ipv4 (encap|multicast|unicast|vpn) dampening flap-statistics",
Balaji3921cc52015-05-16 23:12:17 +053015359 SHOW_STR
Balaji3921cc52015-05-16 23:12:17 +053015360 BGP_STR
Lou Berger651b4022016-01-12 13:42:07 -050015361 "Address Family\n"
15362 "Address Family modifier\n"
15363 "Address Family modifier\n"
15364 "Address Family modifier\n"
15365 "Address Family modifier\n"
Balaji3921cc52015-05-16 23:12:17 +053015366 "Display detailed information about dampening\n"
15367 "Display flap statistics of routes\n")
Lou Berger205e6742016-01-12 13:42:11 -050015368
Lou Berger651b4022016-01-12 13:42:07 -050015369DEFUN (show_bgp_ipv6_safi_flap_statistics,
15370 show_bgp_ipv6_safi_flap_statistics_cmd,
15371 "show bgp ipv6 (encap|multicast|unicast|vpn) flap-statistics",
15372 SHOW_STR
15373 BGP_STR
15374 "Address Family\n"
15375 "Address Family modifier\n"
15376 "Address Family modifier\n"
15377 "Address Family modifier\n"
15378 "Address Family modifier\n"
15379 "Display flap statistics of routes\n")
15380{
15381 safi_t safi;
15382
15383 if (bgp_parse_safi(argv[0], &safi)) {
15384 vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
15385 return CMD_WARNING;
15386 }
15387
15388 return bgp_show (vty, NULL, AFI_IP6, safi, bgp_show_type_flap_statistics, NULL);
15389}
15390ALIAS (show_bgp_ipv6_safi_flap_statistics,
15391 show_bgp_ipv6_safi_damp_flap_statistics_cmd,
15392 "show bgp ipv6 (encap|multicast|unicast|vpn) dampening flap-statistics",
15393 SHOW_STR
15394 BGP_STR
15395 "Address Family\n"
15396 "Address Family modifier\n"
15397 "Address Family modifier\n"
15398 "Address Family modifier\n"
15399 "Address Family modifier\n"
15400 "Display detailed information about dampening\n"
15401 "Display flap statistics of routes\n")
Balaji3921cc52015-05-16 23:12:17 +053015402
paul718e3742002-12-13 20:15:29 +000015403/* Display specified route of BGP table. */
paul94f2b392005-06-28 12:44:16 +000015404static int
paulfd79ac92004-10-13 05:06:08 +000015405bgp_clear_damp_route (struct vty *vty, const char *view_name,
15406 const char *ip_str, afi_t afi, safi_t safi,
15407 struct prefix_rd *prd, int prefix_check)
paul718e3742002-12-13 20:15:29 +000015408{
15409 int ret;
15410 struct prefix match;
15411 struct bgp_node *rn;
15412 struct bgp_node *rm;
15413 struct bgp_info *ri;
15414 struct bgp_info *ri_temp;
15415 struct bgp *bgp;
15416 struct bgp_table *table;
15417
15418 /* BGP structure lookup. */
15419 if (view_name)
15420 {
15421 bgp = bgp_lookup_by_name (view_name);
15422 if (bgp == NULL)
15423 {
15424 vty_out (vty, "%% Can't find BGP view %s%s", view_name, VTY_NEWLINE);
15425 return CMD_WARNING;
15426 }
15427 }
15428 else
15429 {
15430 bgp = bgp_get_default ();
15431 if (bgp == NULL)
15432 {
15433 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
15434 return CMD_WARNING;
15435 }
15436 }
15437
15438 /* Check IP address argument. */
15439 ret = str2prefix (ip_str, &match);
15440 if (! ret)
15441 {
15442 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
15443 return CMD_WARNING;
15444 }
15445
15446 match.family = afi2family (afi);
15447
Lou Berger298cc2f2016-01-12 13:42:02 -050015448 if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
paul718e3742002-12-13 20:15:29 +000015449 {
Lou Berger298cc2f2016-01-12 13:42:02 -050015450 for (rn = bgp_table_top (bgp->rib[AFI_IP][safi]); rn; rn = bgp_route_next (rn))
paul718e3742002-12-13 20:15:29 +000015451 {
15452 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
15453 continue;
15454
15455 if ((table = rn->info) != NULL)
15456 if ((rm = bgp_node_match (table, &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015457 {
15458 if (! prefix_check || rm->p.prefixlen == match.prefixlen)
15459 {
15460 ri = rm->info;
15461 while (ri)
15462 {
15463 if (ri->extra && ri->extra->damp_info)
15464 {
15465 ri_temp = ri->next;
15466 bgp_damp_info_free (ri->extra->damp_info, 1);
15467 ri = ri_temp;
15468 }
15469 else
15470 ri = ri->next;
15471 }
15472 }
15473
15474 bgp_unlock_node (rm);
15475 }
paul718e3742002-12-13 20:15:29 +000015476 }
15477 }
15478 else
15479 {
15480 if ((rn = bgp_node_match (bgp->rib[afi][safi], &match)) != NULL)
Chris Caputo6c88b442010-07-27 16:28:55 +000015481 {
15482 if (! prefix_check || rn->p.prefixlen == match.prefixlen)
15483 {
15484 ri = rn->info;
15485 while (ri)
15486 {
15487 if (ri->extra && ri->extra->damp_info)
15488 {
15489 ri_temp = ri->next;
15490 bgp_damp_info_free (ri->extra->damp_info, 1);
15491 ri = ri_temp;
15492 }
15493 else
15494 ri = ri->next;
15495 }
15496 }
15497
15498 bgp_unlock_node (rn);
15499 }
paul718e3742002-12-13 20:15:29 +000015500 }
15501
15502 return CMD_SUCCESS;
15503}
15504
15505DEFUN (clear_ip_bgp_dampening,
15506 clear_ip_bgp_dampening_cmd,
15507 "clear ip bgp dampening",
15508 CLEAR_STR
15509 IP_STR
15510 BGP_STR
15511 "Clear route flap dampening information\n")
15512{
15513 bgp_damp_info_clean ();
15514 return CMD_SUCCESS;
15515}
15516
15517DEFUN (clear_ip_bgp_dampening_prefix,
15518 clear_ip_bgp_dampening_prefix_cmd,
15519 "clear ip bgp dampening A.B.C.D/M",
15520 CLEAR_STR
15521 IP_STR
15522 BGP_STR
15523 "Clear route flap dampening information\n"
15524 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
15525{
15526 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15527 SAFI_UNICAST, NULL, 1);
15528}
15529
15530DEFUN (clear_ip_bgp_dampening_address,
15531 clear_ip_bgp_dampening_address_cmd,
15532 "clear ip bgp dampening A.B.C.D",
15533 CLEAR_STR
15534 IP_STR
15535 BGP_STR
15536 "Clear route flap dampening information\n"
15537 "Network to clear damping information\n")
15538{
15539 return bgp_clear_damp_route (vty, NULL, argv[0], AFI_IP,
15540 SAFI_UNICAST, NULL, 0);
15541}
15542
15543DEFUN (clear_ip_bgp_dampening_address_mask,
15544 clear_ip_bgp_dampening_address_mask_cmd,
15545 "clear ip bgp dampening A.B.C.D A.B.C.D",
15546 CLEAR_STR
15547 IP_STR
15548 BGP_STR
15549 "Clear route flap dampening information\n"
15550 "Network to clear damping information\n"
15551 "Network mask\n")
15552{
15553 int ret;
15554 char prefix_str[BUFSIZ];
15555
15556 ret = netmask_str2prefix_str (argv[0], argv[1], prefix_str);
15557 if (! ret)
15558 {
15559 vty_out (vty, "%% Inconsistent address and mask%s", VTY_NEWLINE);
15560 return CMD_WARNING;
15561 }
15562
15563 return bgp_clear_damp_route (vty, NULL, prefix_str, AFI_IP,
15564 SAFI_UNICAST, NULL, 0);
15565}
David Lamparter6b0655a2014-06-04 06:53:35 +020015566
Lou Berger298cc2f2016-01-12 13:42:02 -050015567/* also used for encap safi */
paul94f2b392005-06-28 12:44:16 +000015568static int
paul718e3742002-12-13 20:15:29 +000015569bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp,
15570 afi_t afi, safi_t safi, int *write)
15571{
15572 struct bgp_node *prn;
15573 struct bgp_node *rn;
15574 struct bgp_table *table;
15575 struct prefix *p;
15576 struct prefix_rd *prd;
15577 struct bgp_static *bgp_static;
15578 u_int32_t label;
15579 char buf[SU_ADDRSTRLEN];
15580 char rdbuf[RD_ADDRSTRLEN];
15581
15582 /* Network configuration. */
15583 for (prn = bgp_table_top (bgp->route[afi][safi]); prn; prn = bgp_route_next (prn))
15584 if ((table = prn->info) != NULL)
15585 for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
15586 if ((bgp_static = rn->info) != NULL)
15587 {
15588 p = &rn->p;
15589 prd = (struct prefix_rd *) &prn->p;
15590
15591 /* "address-family" display. */
15592 bgp_config_write_family_header (vty, afi, safi, write);
15593
15594 /* "network" configuration display. */
15595 prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
15596 label = decode_label (bgp_static->tag);
15597
15598 vty_out (vty, " network %s/%d rd %s tag %d",
15599 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15600 p->prefixlen,
15601 rdbuf, label);
15602 vty_out (vty, "%s", VTY_NEWLINE);
15603 }
15604 return 0;
15605}
15606
15607/* Configuration of static route announcement and aggregate
15608 information. */
15609int
15610bgp_config_write_network (struct vty *vty, struct bgp *bgp,
15611 afi_t afi, safi_t safi, int *write)
15612{
15613 struct bgp_node *rn;
15614 struct prefix *p;
15615 struct bgp_static *bgp_static;
15616 struct bgp_aggregate *bgp_aggregate;
15617 char buf[SU_ADDRSTRLEN];
15618
Lou Berger298cc2f2016-01-12 13:42:02 -050015619 if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)))
paul718e3742002-12-13 20:15:29 +000015620 return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write);
15621
15622 /* Network configuration. */
15623 for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
15624 if ((bgp_static = rn->info) != NULL)
15625 {
15626 p = &rn->p;
15627
15628 /* "address-family" display. */
15629 bgp_config_write_family_header (vty, afi, safi, write);
15630
15631 /* "network" configuration display. */
15632 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15633 {
15634 u_int32_t destination;
15635 struct in_addr netmask;
15636
15637 destination = ntohl (p->u.prefix4.s_addr);
15638 masklen2ip (p->prefixlen, &netmask);
15639 vty_out (vty, " network %s",
15640 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN));
15641
15642 if ((IN_CLASSC (destination) && p->prefixlen == 24)
15643 || (IN_CLASSB (destination) && p->prefixlen == 16)
15644 || (IN_CLASSA (destination) && p->prefixlen == 8)
15645 || p->u.prefix4.s_addr == 0)
15646 {
15647 /* Natural mask is not display. */
15648 }
15649 else
15650 vty_out (vty, " mask %s", inet_ntoa (netmask));
15651 }
15652 else
15653 {
15654 vty_out (vty, " network %s/%d",
15655 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15656 p->prefixlen);
15657 }
15658
15659 if (bgp_static->rmap.name)
15660 vty_out (vty, " route-map %s", bgp_static->rmap.name);
Paul Jakma41367172007-08-06 15:24:51 +000015661 else
15662 {
15663 if (bgp_static->backdoor)
15664 vty_out (vty, " backdoor");
Paul Jakma41367172007-08-06 15:24:51 +000015665 }
paul718e3742002-12-13 20:15:29 +000015666
15667 vty_out (vty, "%s", VTY_NEWLINE);
15668 }
15669
15670 /* Aggregate-address configuration. */
15671 for (rn = bgp_table_top (bgp->aggregate[afi][safi]); rn; rn = bgp_route_next (rn))
15672 if ((bgp_aggregate = rn->info) != NULL)
15673 {
15674 p = &rn->p;
15675
15676 /* "address-family" display. */
15677 bgp_config_write_family_header (vty, afi, safi, write);
15678
15679 if (bgp_option_check (BGP_OPT_CONFIG_CISCO) && afi == AFI_IP)
15680 {
15681 struct in_addr netmask;
15682
15683 masklen2ip (p->prefixlen, &netmask);
15684 vty_out (vty, " aggregate-address %s %s",
15685 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15686 inet_ntoa (netmask));
15687 }
15688 else
15689 {
15690 vty_out (vty, " aggregate-address %s/%d",
15691 inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
15692 p->prefixlen);
15693 }
15694
15695 if (bgp_aggregate->as_set)
15696 vty_out (vty, " as-set");
15697
15698 if (bgp_aggregate->summary_only)
15699 vty_out (vty, " summary-only");
15700
15701 vty_out (vty, "%s", VTY_NEWLINE);
15702 }
15703
15704 return 0;
15705}
15706
15707int
15708bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
15709{
15710 struct bgp_node *rn;
15711 struct bgp_distance *bdistance;
15712
15713 /* Distance configuration. */
15714 if (bgp->distance_ebgp
15715 && bgp->distance_ibgp
15716 && bgp->distance_local
15717 && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
15718 || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
15719 || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
15720 vty_out (vty, " distance bgp %d %d %d%s",
15721 bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
15722 VTY_NEWLINE);
15723
15724 for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
15725 if ((bdistance = rn->info) != NULL)
15726 {
15727 vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
15728 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
15729 bdistance->access_list ? bdistance->access_list : "",
15730 VTY_NEWLINE);
15731 }
15732
15733 return 0;
15734}
15735
15736/* Allocate routing table structure and install commands. */
15737void
Stephen Hemminger66e5cd82009-02-09 10:14:16 -080015738bgp_route_init (void)
paul718e3742002-12-13 20:15:29 +000015739{
15740 /* Init BGP distance table. */
Paul Jakma64e580a2006-02-21 01:09:01 +000015741 bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
paul718e3742002-12-13 20:15:29 +000015742
15743 /* IPv4 BGP commands. */
15744 install_element (BGP_NODE, &bgp_network_cmd);
15745 install_element (BGP_NODE, &bgp_network_mask_cmd);
15746 install_element (BGP_NODE, &bgp_network_mask_natural_cmd);
15747 install_element (BGP_NODE, &bgp_network_route_map_cmd);
15748 install_element (BGP_NODE, &bgp_network_mask_route_map_cmd);
15749 install_element (BGP_NODE, &bgp_network_mask_natural_route_map_cmd);
15750 install_element (BGP_NODE, &bgp_network_backdoor_cmd);
15751 install_element (BGP_NODE, &bgp_network_mask_backdoor_cmd);
15752 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_cmd);
15753 install_element (BGP_NODE, &no_bgp_network_cmd);
15754 install_element (BGP_NODE, &no_bgp_network_mask_cmd);
15755 install_element (BGP_NODE, &no_bgp_network_mask_natural_cmd);
15756 install_element (BGP_NODE, &no_bgp_network_route_map_cmd);
15757 install_element (BGP_NODE, &no_bgp_network_mask_route_map_cmd);
15758 install_element (BGP_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15759 install_element (BGP_NODE, &no_bgp_network_backdoor_cmd);
15760 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_cmd);
15761 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_cmd);
15762
15763 install_element (BGP_NODE, &aggregate_address_cmd);
15764 install_element (BGP_NODE, &aggregate_address_mask_cmd);
15765 install_element (BGP_NODE, &aggregate_address_summary_only_cmd);
15766 install_element (BGP_NODE, &aggregate_address_mask_summary_only_cmd);
15767 install_element (BGP_NODE, &aggregate_address_as_set_cmd);
15768 install_element (BGP_NODE, &aggregate_address_mask_as_set_cmd);
15769 install_element (BGP_NODE, &aggregate_address_as_set_summary_cmd);
15770 install_element (BGP_NODE, &aggregate_address_mask_as_set_summary_cmd);
15771 install_element (BGP_NODE, &aggregate_address_summary_as_set_cmd);
15772 install_element (BGP_NODE, &aggregate_address_mask_summary_as_set_cmd);
15773 install_element (BGP_NODE, &no_aggregate_address_cmd);
15774 install_element (BGP_NODE, &no_aggregate_address_summary_only_cmd);
15775 install_element (BGP_NODE, &no_aggregate_address_as_set_cmd);
15776 install_element (BGP_NODE, &no_aggregate_address_as_set_summary_cmd);
15777 install_element (BGP_NODE, &no_aggregate_address_summary_as_set_cmd);
15778 install_element (BGP_NODE, &no_aggregate_address_mask_cmd);
15779 install_element (BGP_NODE, &no_aggregate_address_mask_summary_only_cmd);
15780 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_cmd);
15781 install_element (BGP_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15782 install_element (BGP_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15783
15784 /* IPv4 unicast configuration. */
15785 install_element (BGP_IPV4_NODE, &bgp_network_cmd);
15786 install_element (BGP_IPV4_NODE, &bgp_network_mask_cmd);
15787 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_cmd);
15788 install_element (BGP_IPV4_NODE, &bgp_network_route_map_cmd);
15789 install_element (BGP_IPV4_NODE, &bgp_network_mask_route_map_cmd);
15790 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015791 install_element (BGP_IPV4_NODE, &no_bgp_network_cmd);
paul718e3742002-12-13 20:15:29 +000015792 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_cmd);
15793 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_cmd);
15794 install_element (BGP_IPV4_NODE, &no_bgp_network_route_map_cmd);
15795 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_route_map_cmd);
15796 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_route_map_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000015797
paul718e3742002-12-13 20:15:29 +000015798 install_element (BGP_IPV4_NODE, &aggregate_address_cmd);
15799 install_element (BGP_IPV4_NODE, &aggregate_address_mask_cmd);
15800 install_element (BGP_IPV4_NODE, &aggregate_address_summary_only_cmd);
15801 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_only_cmd);
15802 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_cmd);
15803 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_cmd);
15804 install_element (BGP_IPV4_NODE, &aggregate_address_as_set_summary_cmd);
15805 install_element (BGP_IPV4_NODE, &aggregate_address_mask_as_set_summary_cmd);
15806 install_element (BGP_IPV4_NODE, &aggregate_address_summary_as_set_cmd);
15807 install_element (BGP_IPV4_NODE, &aggregate_address_mask_summary_as_set_cmd);
15808 install_element (BGP_IPV4_NODE, &no_aggregate_address_cmd);
15809 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_only_cmd);
15810 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_cmd);
15811 install_element (BGP_IPV4_NODE, &no_aggregate_address_as_set_summary_cmd);
15812 install_element (BGP_IPV4_NODE, &no_aggregate_address_summary_as_set_cmd);
15813 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_cmd);
15814 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_only_cmd);
15815 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_cmd);
15816 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15817 install_element (BGP_IPV4_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15818
15819 /* IPv4 multicast configuration. */
15820 install_element (BGP_IPV4M_NODE, &bgp_network_cmd);
15821 install_element (BGP_IPV4M_NODE, &bgp_network_mask_cmd);
15822 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_cmd);
15823 install_element (BGP_IPV4M_NODE, &bgp_network_route_map_cmd);
15824 install_element (BGP_IPV4M_NODE, &bgp_network_mask_route_map_cmd);
15825 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_route_map_cmd);
15826 install_element (BGP_IPV4M_NODE, &no_bgp_network_cmd);
15827 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_cmd);
15828 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_cmd);
15829 install_element (BGP_IPV4M_NODE, &no_bgp_network_route_map_cmd);
15830 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_route_map_cmd);
15831 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_route_map_cmd);
15832 install_element (BGP_IPV4M_NODE, &aggregate_address_cmd);
15833 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_cmd);
15834 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_only_cmd);
15835 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_only_cmd);
15836 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_cmd);
15837 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_cmd);
15838 install_element (BGP_IPV4M_NODE, &aggregate_address_as_set_summary_cmd);
15839 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_as_set_summary_cmd);
15840 install_element (BGP_IPV4M_NODE, &aggregate_address_summary_as_set_cmd);
15841 install_element (BGP_IPV4M_NODE, &aggregate_address_mask_summary_as_set_cmd);
15842 install_element (BGP_IPV4M_NODE, &no_aggregate_address_cmd);
15843 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_only_cmd);
15844 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_cmd);
15845 install_element (BGP_IPV4M_NODE, &no_aggregate_address_as_set_summary_cmd);
15846 install_element (BGP_IPV4M_NODE, &no_aggregate_address_summary_as_set_cmd);
15847 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_cmd);
15848 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_only_cmd);
15849 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_cmd);
15850 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_as_set_summary_cmd);
15851 install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
15852
Michael Lambert95cbbd22010-07-23 14:43:04 -040015853 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015854 install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015855 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
15856 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
15857 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15858 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15859 install_element (VIEW_NODE, &show_bgp_ipv4_encap_route_cmd);
15860 install_element (VIEW_NODE, &show_bgp_ipv6_encap_route_cmd);
15861 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15862 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15863 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015864 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015865 install_element (VIEW_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15866 install_element (VIEW_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15867 install_element (VIEW_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15868 install_element (VIEW_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15869 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15870 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15871 install_element (VIEW_NODE, &show_bgp_afi_safi_view_cmd);
15872 install_element (VIEW_NODE, &show_bgp_view_afi_safi_route_cmd);
15873 install_element (VIEW_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15874 install_element (VIEW_NODE, &show_bgp_ipv4_safi_regexp_cmd);
15875 install_element (VIEW_NODE, &show_bgp_ipv6_safi_regexp_cmd);
15876 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_list_cmd);
15877 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
15878 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
15879 install_element (VIEW_NODE, &show_bgp_ipv4_filter_list_cmd);
15880 install_element (VIEW_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
15881 install_element (VIEW_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
15882 install_element (VIEW_NODE, &show_bgp_ipv4_route_map_cmd);
15883 install_element (VIEW_NODE, &show_bgp_ipv4_cidr_only_cmd);
15884 install_element (VIEW_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
15885 install_element (VIEW_NODE, &show_bgp_ipv4_community_cmd);
15886 install_element (VIEW_NODE, &show_bgp_ipv4_community2_cmd);
15887 install_element (VIEW_NODE, &show_bgp_ipv4_community3_cmd);
15888 install_element (VIEW_NODE, &show_bgp_ipv4_community4_cmd);
15889 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_cmd);
15890 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_cmd);
15891 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_cmd);
15892 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015893 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15894 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community_cmd);
15895 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community2_cmd);
15896 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community3_cmd);
15897 install_element (VIEW_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015898 install_element (VIEW_NODE, &show_bgp_ipv4_community_exact_cmd);
15899 install_element (VIEW_NODE, &show_bgp_ipv4_community2_exact_cmd);
15900 install_element (VIEW_NODE, &show_bgp_ipv4_community3_exact_cmd);
15901 install_element (VIEW_NODE, &show_bgp_ipv4_community4_exact_cmd);
15902 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
15903 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
15904 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
15905 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
15906 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_cmd);
15907 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_cmd);
15908 install_element (VIEW_NODE, &show_bgp_ipv4_community_list_exact_cmd);
15909 install_element (VIEW_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
15910 install_element (VIEW_NODE, &show_bgp_ipv4_prefix_longer_cmd);
15911 install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
15912 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
15913 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
15914 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
15915 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
15916 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015917 install_element (VIEW_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015918 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
15919 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
15920 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
15921 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
15922 install_element (VIEW_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
15923 install_element (VIEW_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
15924 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
15925 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
15926 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
15927 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
15928 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
15929 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
15930 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
15931 install_element (VIEW_NODE, &show_bgp_ipv6_flap_address_cmd);
15932 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
15933 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
15934 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
15935 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
15936 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
15937 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
15938 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
15939 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
15940 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
15941 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
15942 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
15943 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
15944 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
15945 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
15946 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
15947 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
15948 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
15949 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
15950 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
15951 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
15952 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
15953 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
15954 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
15955 install_element (VIEW_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
15956 install_element (VIEW_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
15957 install_element (VIEW_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
15958 install_element (VIEW_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
15959 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
15960 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
15961 install_element (VIEW_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
15962 install_element (VIEW_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015963 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015964 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015965 install_element (VIEW_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015966 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015967 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015968 install_element (VIEW_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010015969
15970 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
Michael Lambert95cbbd22010-07-23 14:43:04 -040015971 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015972 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
15973 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
15974 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
15975 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
15976 install_element (RESTRICTED_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015977 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015978 install_element (RESTRICTED_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
15979 install_element (RESTRICTED_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
15980 install_element (RESTRICTED_NODE, &show_bgp_ipv4_encap_prefix_cmd);
15981 install_element (RESTRICTED_NODE, &show_bgp_ipv6_encap_prefix_cmd);
15982 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
15983 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
15984 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_route_cmd);
15985 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_prefix_cmd);
15986 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_cmd);
15987 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_cmd);
15988 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_cmd);
15989 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_cmd);
15990 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_cmd);
15991 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_cmd);
15992 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_cmd);
15993 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040015994 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_all_cmd);
15995 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community_cmd);
15996 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community2_cmd);
15997 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community3_cmd);
15998 install_element (RESTRICTED_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050015999 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community_exact_cmd);
16000 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community2_exact_cmd);
16001 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community3_exact_cmd);
16002 install_element (RESTRICTED_NODE, &show_bgp_ipv4_community4_exact_cmd);
16003 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16004 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16005 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16006 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016007 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016008 install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016009 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016010 install_element (RESTRICTED_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016011
Michael Lambert95cbbd22010-07-23 14:43:04 -040016012 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016013 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016014 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd);
16015 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd);
16016 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
16017 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
16018 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_route_cmd);
16019 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_route_cmd);
16020 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
16021 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
16022 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016023 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016024 install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_prefix_cmd);
16025 install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_prefix_cmd);
16026 install_element (ENABLE_NODE, &show_bgp_ipv4_encap_prefix_cmd);
16027 install_element (ENABLE_NODE, &show_bgp_ipv6_encap_prefix_cmd);
16028 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
16029 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
16030 install_element (ENABLE_NODE, &show_bgp_afi_safi_view_cmd);
16031 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_route_cmd);
16032 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_prefix_cmd);
16033 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_regexp_cmd);
16034 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_regexp_cmd);
16035 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_list_cmd);
16036 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_list_cmd);
16037 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_list_cmd);
16038 install_element (ENABLE_NODE, &show_bgp_ipv4_filter_list_cmd);
16039 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_filter_list_cmd);
16040 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_filter_list_cmd);
16041 install_element (ENABLE_NODE, &show_bgp_ipv4_route_map_cmd);
16042 install_element (ENABLE_NODE, &show_bgp_ipv4_cidr_only_cmd);
16043 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cidr_only_cmd);
16044 install_element (ENABLE_NODE, &show_bgp_ipv4_community_cmd);
16045 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_cmd);
16046 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_cmd);
16047 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_cmd);
16048 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_cmd);
16049 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_cmd);
16050 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_cmd);
16051 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016052 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_all_cmd);
16053 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community_cmd);
16054 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community2_cmd);
16055 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community3_cmd);
16056 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_community4_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016057 install_element (ENABLE_NODE, &show_bgp_ipv4_community_exact_cmd);
16058 install_element (ENABLE_NODE, &show_bgp_ipv4_community2_exact_cmd);
16059 install_element (ENABLE_NODE, &show_bgp_ipv4_community3_exact_cmd);
16060 install_element (ENABLE_NODE, &show_bgp_ipv4_community4_exact_cmd);
16061 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_exact_cmd);
16062 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community2_exact_cmd);
16063 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community3_exact_cmd);
16064 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community4_exact_cmd);
16065 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_cmd);
16066 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_cmd);
16067 install_element (ENABLE_NODE, &show_bgp_ipv4_community_list_exact_cmd);
16068 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_community_list_exact_cmd);
16069 install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_longer_cmd);
16070 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_longer_cmd);
16071 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_longer_cmd);
16072 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_advertised_route_cmd);
16073 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_advertised_route_cmd);
16074 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_routes_cmd);
16075 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_routes_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016076 install_element (ENABLE_NODE, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016077 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_routes_cmd);
16078 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_routes_cmd);
16079 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_received_prefix_filter_cmd);
16080 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_received_prefix_filter_cmd);
16081 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_dampened_paths_cmd);
16082 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_dampened_paths_cmd);
16083 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_dampened_paths_cmd);
16084 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_dampened_paths_cmd);
16085 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_statistics_cmd);
16086 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_statistics_cmd);
16087 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_statistics_cmd);
16088 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_statistics_cmd);
16089 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_address_cmd);
16090 install_element (ENABLE_NODE, &show_bgp_ipv6_flap_address_cmd);
16091 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_address_cmd);
16092 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_cmd);
16093 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_cmd);
16094 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_cmd);
16095 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_cmd);
16096 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_cidr_only_cmd);
16097 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_cidr_only_cmd);
16098 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_regexp_cmd);
16099 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_regexp_cmd);
16100 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_regexp_cmd);
16101 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_regexp_cmd);
16102 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_filter_list_cmd);
16103 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_filter_list_cmd);
16104 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_filter_list_cmd);
16105 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_filter_list_cmd);
16106 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_list_cmd);
16107 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_list_cmd);
16108 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_list_cmd);
16109 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_list_cmd);
16110 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_prefix_longer_cmd);
16111 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_prefix_longer_cmd);
16112 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_prefix_longer_cmd);
16113 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_prefix_longer_cmd);
16114 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_flap_route_map_cmd);
16115 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_flap_route_map_cmd);
16116 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_damp_flap_route_map_cmd);
16117 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_damp_flap_route_map_cmd);
16118 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_flap_cmd);
16119 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_flap_cmd);
16120 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_damp_cmd);
16121 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_damp_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016122 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016123 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016124 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016125 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016126 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016127 install_element (ENABLE_NODE, &show_bgp_view_ipv4_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016128
16129 /* BGP dampening clear commands */
16130 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
16131 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
16132 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_cmd);
16133 install_element (ENABLE_NODE, &clear_ip_bgp_dampening_address_mask_cmd);
16134
Paul Jakmaff7924f2006-09-04 01:10:36 +000016135 /* prefix count */
Lou Berger651b4022016-01-12 13:42:07 -050016136 install_element (ENABLE_NODE, &show_bgp_ipv4_safi_neighbor_prefix_counts_cmd);
16137 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_neighbor_prefix_counts_cmd);
Paul Jakmaff7924f2006-09-04 01:10:36 +000016138 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd);
16139
paul718e3742002-12-13 20:15:29 +000016140 /* New config IPv6 BGP commands. */
16141 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_cmd);
16142 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
16143 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
16144 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_route_map_cmd);
16145
16146 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
16147 install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_summary_only_cmd);
16148 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);
16149 install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_summary_only_cmd);
16150
G.Balaji73bfe0b2011-09-23 22:36:20 +053016151 install_element (BGP_IPV6M_NODE, &ipv6_bgp_network_cmd);
16152 install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_network_cmd);
16153
paul718e3742002-12-13 20:15:29 +000016154 /* Old config IPv6 BGP commands. */
16155 install_element (BGP_NODE, &old_ipv6_bgp_network_cmd);
16156 install_element (BGP_NODE, &old_no_ipv6_bgp_network_cmd);
16157
16158 install_element (BGP_NODE, &old_ipv6_aggregate_address_cmd);
16159 install_element (BGP_NODE, &old_ipv6_aggregate_address_summary_only_cmd);
16160 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_cmd);
16161 install_element (BGP_NODE, &old_no_ipv6_aggregate_address_summary_only_cmd);
16162
Michael Lambert95cbbd22010-07-23 14:43:04 -040016163 install_element (VIEW_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016164 install_element (VIEW_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016165 install_element (VIEW_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016166 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016167 install_element (VIEW_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016168 install_element (VIEW_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016169 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016170 install_element (VIEW_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016171 install_element (VIEW_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016172 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_cmd);
16173 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_cmd);
16174 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_cmd);
16175 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_cmd);
16176 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16177 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16178 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16179 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016180 install_element (VIEW_NODE, &show_bgp_community_list_cmd);
paul718e3742002-12-13 20:15:29 +000016181 install_element (VIEW_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016182 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016183 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016184 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016185 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016186 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016187 install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016188 install_element (VIEW_NODE, &show_bgp_ipv4_rsclient_cmd);
16189 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016190 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016191 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016192 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016193 install_element (VIEW_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016194 install_element (VIEW_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016195 install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016196 install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016197 install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016198 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016199 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016200 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016201 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016202 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016203 install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016204 install_element (VIEW_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16205 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016206 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016207 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016208 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016209 install_element (VIEW_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016210 install_element (VIEW_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016211
16212 /* Restricted:
16213 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
16214 */
Paul Jakma62687ff2008-08-23 14:27:06 +010016215 install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016216 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016217 install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016218 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016219 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_cmd);
16220 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_cmd);
16221 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_cmd);
16222 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_cmd);
16223 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16224 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16225 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16226 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
16227 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016228 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016229 install_element (RESTRICTED_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016230 install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016231 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_route_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016232 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_prefix_cmd);
Paul Jakma62687ff2008-08-23 14:27:06 +010016233 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016234 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016235 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016236 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016237 install_element (RESTRICTED_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016238
Michael Lambert95cbbd22010-07-23 14:43:04 -040016239 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd);
paul718e3742002-12-13 20:15:29 +000016240 install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016241 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd);
paul718e3742002-12-13 20:15:29 +000016242 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016243 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016244 install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
paul718e3742002-12-13 20:15:29 +000016245 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
paul718e3742002-12-13 20:15:29 +000016246 install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
paul718e3742002-12-13 20:15:29 +000016247 install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016248 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_cmd);
16249 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_cmd);
16250 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_cmd);
16251 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_cmd);
16252 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_exact_cmd);
16253 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community2_exact_cmd);
16254 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community3_exact_cmd);
16255 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community4_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016256 install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016257 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
paul718e3742002-12-13 20:15:29 +000016258 install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
paul718e3742002-12-13 20:15:29 +000016259 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
paul718e3742002-12-13 20:15:29 +000016260 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016261 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
paul718e3742002-12-13 20:15:29 +000016262 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016263 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016264 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016265 install_element (ENABLE_NODE, &show_bgp_ipv4_rsclient_cmd);
16266 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016267 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016268 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016269 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016270 install_element (ENABLE_NODE, &show_bgp_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016271 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_rsclient_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016272 install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
paulbb46e942003-10-24 19:02:03 +000016273 install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016274 install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
paulbb46e942003-10-24 19:02:03 +000016275 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_advertised_route_cmd);
paulbb46e942003-10-24 19:02:03 +000016276 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016277 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
paulbb46e942003-10-24 19:02:03 +000016278 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
paulbb46e942003-10-24 19:02:03 +000016279 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
paulbb46e942003-10-24 19:02:03 +000016280 install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016281 install_element (ENABLE_NODE, &show_bgp_view_ipv4_rsclient_cmd);
16282 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016283 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016284 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_route_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016285 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_route_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016286 install_element (ENABLE_NODE, &show_bgp_view_ipv6_rsclient_prefix_cmd);
Michael Lambert95cbbd22010-07-23 14:43:04 -040016287 install_element (ENABLE_NODE, &show_bgp_view_ipv6_safi_rsclient_prefix_cmd);
Paul Jakma2815e612006-09-14 02:56:07 +000016288
16289 /* Statistics */
16290 install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
Lou Berger651b4022016-01-12 13:42:07 -050016291 install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd);
paul718e3742002-12-13 20:15:29 +000016292
16293 install_element (BGP_NODE, &bgp_distance_cmd);
16294 install_element (BGP_NODE, &no_bgp_distance_cmd);
16295 install_element (BGP_NODE, &no_bgp_distance2_cmd);
16296 install_element (BGP_NODE, &bgp_distance_source_cmd);
16297 install_element (BGP_NODE, &no_bgp_distance_source_cmd);
16298 install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
16299 install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
16300
16301 install_element (BGP_NODE, &bgp_damp_set_cmd);
16302 install_element (BGP_NODE, &bgp_damp_set2_cmd);
16303 install_element (BGP_NODE, &bgp_damp_set3_cmd);
16304 install_element (BGP_NODE, &bgp_damp_unset_cmd);
16305 install_element (BGP_NODE, &bgp_damp_unset2_cmd);
16306 install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
16307 install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
16308 install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
16309 install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
16310 install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016311
16312 /* Deprecated AS-Pathlimit commands */
16313 install_element (BGP_NODE, &bgp_network_ttl_cmd);
16314 install_element (BGP_NODE, &bgp_network_mask_ttl_cmd);
16315 install_element (BGP_NODE, &bgp_network_mask_natural_ttl_cmd);
16316 install_element (BGP_NODE, &bgp_network_backdoor_ttl_cmd);
16317 install_element (BGP_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16318 install_element (BGP_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16319
16320 install_element (BGP_NODE, &no_bgp_network_ttl_cmd);
16321 install_element (BGP_NODE, &no_bgp_network_mask_ttl_cmd);
16322 install_element (BGP_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16323 install_element (BGP_NODE, &no_bgp_network_backdoor_ttl_cmd);
16324 install_element (BGP_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16325 install_element (BGP_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16326
16327 install_element (BGP_IPV4_NODE, &bgp_network_ttl_cmd);
16328 install_element (BGP_IPV4_NODE, &bgp_network_mask_ttl_cmd);
16329 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_ttl_cmd);
16330 install_element (BGP_IPV4_NODE, &bgp_network_backdoor_ttl_cmd);
16331 install_element (BGP_IPV4_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16332 install_element (BGP_IPV4_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16333
16334 install_element (BGP_IPV4_NODE, &no_bgp_network_ttl_cmd);
16335 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_ttl_cmd);
16336 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16337 install_element (BGP_IPV4_NODE, &no_bgp_network_backdoor_ttl_cmd);
16338 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16339 install_element (BGP_IPV4_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
16340
16341 install_element (BGP_IPV4M_NODE, &bgp_network_ttl_cmd);
16342 install_element (BGP_IPV4M_NODE, &bgp_network_mask_ttl_cmd);
16343 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_ttl_cmd);
16344 install_element (BGP_IPV4M_NODE, &bgp_network_backdoor_ttl_cmd);
16345 install_element (BGP_IPV4M_NODE, &bgp_network_mask_backdoor_ttl_cmd);
16346 install_element (BGP_IPV4M_NODE, &bgp_network_mask_natural_backdoor_ttl_cmd);
16347
16348 install_element (BGP_IPV4M_NODE, &no_bgp_network_ttl_cmd);
16349 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_ttl_cmd);
16350 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_ttl_cmd);
16351 install_element (BGP_IPV4M_NODE, &no_bgp_network_backdoor_ttl_cmd);
16352 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_backdoor_ttl_cmd);
16353 install_element (BGP_IPV4M_NODE, &no_bgp_network_mask_natural_backdoor_ttl_cmd);
Paul Jakma3bde17f2011-03-23 10:30:30 +000016354
Paul Jakmac8f3fe32010-12-05 20:28:02 +000016355 install_element (BGP_IPV6_NODE, &ipv6_bgp_network_ttl_cmd);
16356 install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_ttl_cmd);
Lou Bergerf9b6c392016-01-12 13:42:09 -050016357
16358 /* old style commands */
16359 install_element (VIEW_NODE, &show_ip_bgp_cmd);
16360 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
16361 install_element (VIEW_NODE, &show_ip_bgp_route_cmd);
16362 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
16363 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16364 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16365 install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
16366 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16367 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16368 install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16369 install_element (VIEW_NODE, &show_ip_bgp_view_cmd);
16370 install_element (VIEW_NODE, &show_ip_bgp_view_route_cmd);
16371 install_element (VIEW_NODE, &show_ip_bgp_view_prefix_cmd);
16372 install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
16373 install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16374 install_element (VIEW_NODE, &show_ip_bgp_prefix_list_cmd);
16375 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16376 install_element (VIEW_NODE, &show_ip_bgp_filter_list_cmd);
16377 install_element (VIEW_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16378 install_element (VIEW_NODE, &show_ip_bgp_route_map_cmd);
16379 install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16380 install_element (VIEW_NODE, &show_ip_bgp_cidr_only_cmd);
16381 install_element (VIEW_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16382 install_element (VIEW_NODE, &show_ip_bgp_community_all_cmd);
16383 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16384 install_element (VIEW_NODE, &show_ip_bgp_community_cmd);
16385 install_element (VIEW_NODE, &show_ip_bgp_community2_cmd);
16386 install_element (VIEW_NODE, &show_ip_bgp_community3_cmd);
16387 install_element (VIEW_NODE, &show_ip_bgp_community4_cmd);
16388 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_cmd);
16389 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_cmd);
16390 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_cmd);
16391 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_cmd);
16392 install_element (VIEW_NODE, &show_ip_bgp_community_exact_cmd);
16393 install_element (VIEW_NODE, &show_ip_bgp_community2_exact_cmd);
16394 install_element (VIEW_NODE, &show_ip_bgp_community3_exact_cmd);
16395 install_element (VIEW_NODE, &show_ip_bgp_community4_exact_cmd);
16396 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16397 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16398 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16399 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16400 install_element (VIEW_NODE, &show_ip_bgp_community_list_cmd);
16401 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16402 install_element (VIEW_NODE, &show_ip_bgp_community_list_exact_cmd);
16403 install_element (VIEW_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16404 install_element (VIEW_NODE, &show_ip_bgp_prefix_longer_cmd);
16405 install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16406 install_element (VIEW_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16407 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16408 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16409 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16410 install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd);
16411 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16412 install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16413 install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16414 install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd);
16415 install_element (VIEW_NODE, &show_ip_bgp_dampened_paths_cmd);
16416 install_element (VIEW_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16417 install_element (VIEW_NODE, &show_ip_bgp_flap_statistics_cmd);
16418 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16419 install_element (VIEW_NODE, &show_ip_bgp_flap_address_cmd);
16420 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_address_cmd);
16421 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_cmd);
16422 install_element (VIEW_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16423 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16424 install_element (VIEW_NODE, &show_ip_bgp_flap_regexp_cmd);
16425 install_element (VIEW_NODE, &show_ip_bgp_flap_filter_list_cmd);
16426 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16427 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16428 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16429 install_element (VIEW_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16430 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16431 install_element (VIEW_NODE, &show_ip_bgp_flap_route_map_cmd);
16432 install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16433 install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
16434 install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
16435 install_element (VIEW_NODE, &show_ip_bgp_rsclient_cmd);
16436 install_element (VIEW_NODE, &show_ip_bgp_rsclient_route_cmd);
16437 install_element (VIEW_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16438 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16439 install_element (VIEW_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16440 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_cmd);
16441 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16442 install_element (VIEW_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16443 install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
16444 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
16445 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16446 install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
16447 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16448 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16449 install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16450 install_element (RESTRICTED_NODE, &show_ip_bgp_view_route_cmd);
16451 install_element (RESTRICTED_NODE, &show_ip_bgp_view_prefix_cmd);
16452 install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
16453 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
16454 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
16455 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
16456 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
16457 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
16458 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
16459 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
16460 install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
16461 install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
16462 install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
16463 install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
16464 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16465 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16466 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16467 install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16468 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_route_cmd);
16469 install_element (RESTRICTED_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16470 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16471 install_element (RESTRICTED_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16472 install_element (ENABLE_NODE, &show_ip_bgp_cmd);
16473 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
16474 install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
16475 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
16476 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
16477 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
16478 install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
16479 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
16480 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
16481 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
16482 install_element (ENABLE_NODE, &show_ip_bgp_view_cmd);
16483 install_element (ENABLE_NODE, &show_ip_bgp_view_route_cmd);
16484 install_element (ENABLE_NODE, &show_ip_bgp_view_prefix_cmd);
16485 install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
16486 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
16487 install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
16488 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
16489 install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
16490 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
16491 install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
16492 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
16493 install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
16494 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
16495 install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
16496 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
16497 install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
16498 install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
16499 install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
16500 install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
16501 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
16502 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
16503 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
16504 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
16505 install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
16506 install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
16507 install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
16508 install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
16509 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
16510 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
16511 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
16512 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
16513 install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
16514 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
16515 install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
16516 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
16517 install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
16518 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
16519 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
16520 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
16521 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
16522 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
16523 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
16524 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
16525 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
16526 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
16527 install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd);
16528 install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
16529 install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
16530 install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
16531 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
16532 install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
16533 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd);
16534 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
16535 install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
16536 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
16537 install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
16538 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd);
16539 install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
16540 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
16541 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
16542 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
16543 install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
16544 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
16545 install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
16546 install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
16547 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
16548 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
16549 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_cmd);
16550 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_route_cmd);
16551 install_element (ENABLE_NODE, &show_ip_bgp_rsclient_prefix_cmd);
16552 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_advertised_route_cmd);
16553 install_element (ENABLE_NODE, &show_ip_bgp_view_neighbor_received_routes_cmd);
16554 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_cmd);
16555 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_route_cmd);
16556 install_element (ENABLE_NODE, &show_ip_bgp_view_rsclient_prefix_cmd);
16557 install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
16558 install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
16559 install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
16560 install_element (VIEW_NODE, &show_bgp_cmd);
16561 install_element (VIEW_NODE, &show_bgp_ipv6_cmd);
16562 install_element (VIEW_NODE, &show_bgp_route_cmd);
16563 install_element (VIEW_NODE, &show_bgp_prefix_cmd);
16564 install_element (VIEW_NODE, &show_bgp_regexp_cmd);
16565 install_element (VIEW_NODE, &show_bgp_prefix_list_cmd);
16566 install_element (VIEW_NODE, &show_bgp_filter_list_cmd);
16567 install_element (VIEW_NODE, &show_bgp_route_map_cmd);
16568 install_element (VIEW_NODE, &show_bgp_community_all_cmd);
16569 install_element (VIEW_NODE, &show_bgp_ipv6_community_all_cmd);
16570 install_element (VIEW_NODE, &show_bgp_community_cmd);
16571 install_element (VIEW_NODE, &show_bgp_community2_cmd);
16572 install_element (VIEW_NODE, &show_bgp_community3_cmd);
16573 install_element (VIEW_NODE, &show_bgp_community4_cmd);
16574 install_element (VIEW_NODE, &show_bgp_community_exact_cmd);
16575 install_element (VIEW_NODE, &show_bgp_community2_exact_cmd);
16576 install_element (VIEW_NODE, &show_bgp_community3_exact_cmd);
16577 install_element (VIEW_NODE, &show_bgp_community4_exact_cmd);
16578 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16579 install_element (VIEW_NODE, &show_bgp_community_list_exact_cmd);
16580 install_element (VIEW_NODE, &show_bgp_ipv6_safi_community_list_exact_cmd);
16581 install_element (VIEW_NODE, &show_bgp_prefix_longer_cmd);
16582 install_element (VIEW_NODE, &show_bgp_neighbor_advertised_route_cmd);
16583 install_element (VIEW_NODE, &show_bgp_neighbor_received_routes_cmd);
16584 install_element (VIEW_NODE, &show_bgp_neighbor_routes_cmd);
16585 install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16586 install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
16587 install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
16588 install_element (VIEW_NODE, &show_bgp_rsclient_cmd);
16589 install_element (VIEW_NODE, &show_bgp_view_cmd);
16590 install_element (VIEW_NODE, &show_bgp_view_route_cmd);
16591 install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
16592 install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16593 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16594 install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
16595 install_element (VIEW_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16596 install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
16597 install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
16598 install_element (VIEW_NODE, &show_bgp_view_rsclient_cmd);
16599 install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
16600 install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
16601 install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
16602 install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
16603 install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
16604 install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
16605 install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
16606 install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
16607 install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
16608 install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
16609 install_element (RESTRICTED_NODE, &show_bgp_view_route_cmd);
16610 install_element (RESTRICTED_NODE, &show_bgp_view_prefix_cmd);
16611 install_element (RESTRICTED_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16612 install_element (ENABLE_NODE, &show_bgp_cmd);
16613 install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
16614 install_element (ENABLE_NODE, &show_bgp_route_cmd);
16615 install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
16616 install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
16617 install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
16618 install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
16619 install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
16620 install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
16621 install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
16622 install_element (ENABLE_NODE, &show_bgp_community_cmd);
16623 install_element (ENABLE_NODE, &show_bgp_community2_cmd);
16624 install_element (ENABLE_NODE, &show_bgp_community3_cmd);
16625 install_element (ENABLE_NODE, &show_bgp_community4_cmd);
16626 install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
16627 install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
16628 install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
16629 install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
16630 install_element (ENABLE_NODE, &show_bgp_ipv6_safi_community_list_cmd);
16631 install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
16632 install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
16633 install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
16634 install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
16635 install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
16636 install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
16637 install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
16638 install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
16639 install_element (ENABLE_NODE, &show_bgp_rsclient_cmd);
16640 install_element (ENABLE_NODE, &show_bgp_view_cmd);
16641 install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
16642 install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
16643 install_element (ENABLE_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
16644 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
16645 install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
16646 install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_prefix_filter_cmd);
16647 install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
16648 install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
16649 install_element (ENABLE_NODE, &show_bgp_view_rsclient_cmd);
16650 install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
16651 install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
16652 install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
16653 install_element (VIEW_NODE, &show_ipv6_bgp_route_cmd);
16654 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_cmd);
16655 install_element (VIEW_NODE, &show_ipv6_bgp_regexp_cmd);
16656 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_list_cmd);
16657 install_element (VIEW_NODE, &show_ipv6_bgp_filter_list_cmd);
16658 install_element (VIEW_NODE, &show_ipv6_bgp_community_all_cmd);
16659 install_element (VIEW_NODE, &show_ipv6_bgp_community_cmd);
16660 install_element (VIEW_NODE, &show_ipv6_bgp_community2_cmd);
16661 install_element (VIEW_NODE, &show_ipv6_bgp_community3_cmd);
16662 install_element (VIEW_NODE, &show_ipv6_bgp_community4_cmd);
16663 install_element (VIEW_NODE, &show_ipv6_bgp_community_exact_cmd);
16664 install_element (VIEW_NODE, &show_ipv6_bgp_community2_exact_cmd);
16665 install_element (VIEW_NODE, &show_ipv6_bgp_community3_exact_cmd);
16666 install_element (VIEW_NODE, &show_ipv6_bgp_community4_exact_cmd);
16667 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_cmd);
16668 install_element (VIEW_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16669 install_element (VIEW_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16670 install_element (VIEW_NODE, &show_ipv6_mbgp_cmd);
16671 install_element (VIEW_NODE, &show_ipv6_mbgp_route_cmd);
16672 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_cmd);
16673 install_element (VIEW_NODE, &show_ipv6_mbgp_regexp_cmd);
16674 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16675 install_element (VIEW_NODE, &show_ipv6_mbgp_filter_list_cmd);
16676 install_element (VIEW_NODE, &show_ipv6_mbgp_community_all_cmd);
16677 install_element (VIEW_NODE, &show_ipv6_mbgp_community_cmd);
16678 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_cmd);
16679 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_cmd);
16680 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_cmd);
16681 install_element (VIEW_NODE, &show_ipv6_mbgp_community_exact_cmd);
16682 install_element (VIEW_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16683 install_element (VIEW_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16684 install_element (VIEW_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16685 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
16686 install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16687 install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16688 install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
16689 install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
16690 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
16691 install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
16692 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
16693 install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
16694 install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
16695 install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
16696 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
16697 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
16698 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
16699 install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
16700 install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
16701 install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
16702 install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
16703 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
16704 install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
16705 install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
16706 install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
16707 install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
16708 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
16709 install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
16710 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
16711 install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
16712 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
16713 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
16714 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
16715 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
16716 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
16717 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
16718 install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
16719 install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
16720 install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
16721 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
16722 install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
16723 install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
16724 install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16725 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
16726 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16727 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
16728 install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16729 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
16730 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16731 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
16732 install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
16733 install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
16734 install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16735 install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
16736 /* old with name safi collision */
16737 install_element (VIEW_NODE, &show_bgp_ipv6_community_cmd);
16738 install_element (VIEW_NODE, &show_bgp_ipv6_community2_cmd);
16739 install_element (VIEW_NODE, &show_bgp_ipv6_community3_cmd);
16740 install_element (VIEW_NODE, &show_bgp_ipv6_community4_cmd);
16741 install_element (VIEW_NODE, &show_bgp_ipv6_community_exact_cmd);
16742 install_element (VIEW_NODE, &show_bgp_ipv6_community2_exact_cmd);
16743 install_element (VIEW_NODE, &show_bgp_ipv6_community3_exact_cmd);
16744 install_element (VIEW_NODE, &show_bgp_ipv6_community4_exact_cmd);
16745 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
16746 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
16747 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
16748 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
16749 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
16750 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
16751 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
16752 install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
16753 install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
16754 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
16755 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
16756 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
16757 install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
16758 install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
16759 install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
16760 install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
16761 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16762 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_cmd);
16763 install_element (VIEW_NODE, &show_bgp_ipv6_community_list_exact_cmd);
16764 install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
16765
16766 install_element (VIEW_NODE, &show_bgp_rsclient_route_cmd);
16767 install_element (VIEW_NODE, &show_bgp_rsclient_prefix_cmd);
16768 install_element (RESTRICTED_NODE, &show_bgp_rsclient_route_cmd);
16769 install_element (RESTRICTED_NODE, &show_bgp_rsclient_prefix_cmd);
16770 install_element (ENABLE_NODE, &show_bgp_rsclient_route_cmd);
16771 install_element (ENABLE_NODE, &show_bgp_rsclient_prefix_cmd);
16772
16773 install_element (VIEW_NODE, &show_bgp_view_rsclient_route_cmd);
16774 install_element (VIEW_NODE, &show_bgp_view_rsclient_prefix_cmd);
16775 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_route_cmd);
16776 install_element (RESTRICTED_NODE, &show_bgp_view_rsclient_prefix_cmd);
16777 install_element (ENABLE_NODE, &show_bgp_view_rsclient_route_cmd);
16778 install_element (ENABLE_NODE, &show_bgp_view_rsclient_prefix_cmd);
paul718e3742002-12-13 20:15:29 +000016779}
Chris Caputo228da422009-07-18 05:44:03 +000016780
16781void
16782bgp_route_finish (void)
16783{
16784 bgp_table_unlock (bgp_distance_table);
16785 bgp_distance_table = NULL;
16786}